Skip to content

API reference

See the generated Forage API reference. It covers Forage.createCatalog, the createCatalog function, operation definitions, and the search and description result types.

A bounded, machine-readable failure at a Forage public seam.

  • Error

new ForageError(code, message, options?): ForageError

"empty_query" | "empty_catalog" | "unknown_target" | "duplicate_operation" | "invalid_input"

string

ErrorOptions

ForageError

Error.constructor

readonly code: "empty_query" | "empty_catalog" | "unknown_target" | "duplicate_operation" | "invalid_input"

readonly failure: object

code: "empty_query" | "empty_catalog" | "unknown_target" | "duplicate_operation" | "invalid_input"

message: string

ForageCatalog = Readonly<{ revision: string; search: (rawInput) => SearchOutput; describe: (rawInput) => DescribeOutput; list: (rawInput) => ListOutput; stamp: () => string; }>

Immutable public facade for one prepared catalog revision.


ForageDefinition = Readonly<{ replay: "safe"; path: string; description: string; input: typeof forageSearchInput | typeof forageDescribeInput | typeof forageListInput; output: typeof searchOutputSchema | typeof describeOutputSchema | typeof listOutputSchema; }>

Structural operation definition consumed by a capability composer.


ForageApi = object

Public convenience namespace contract.

createCatalog: typeof createCatalog

Construct one immutable catalog revision.

forageSearchDefinition: typeof forageSearchDefinition

Structural search operation definition.

forageDescribeDefinition: typeof forageDescribeDefinition

Structural description operation definition.

forageListDefinition: typeof forageListDefinition

Structural exhaustive listing definition.


ForageSearchInput = z.input<typeof forageSearchInput>>

Parsed search request type.


ForageListInput = z.input<typeof forageListInput>>

Exhaustive listing request type.


ListOutput = z.infer<typeof listOutputSchema>>

Exhaustive page response type.


ForageDescribeInput = z.input<typeof forageDescribeInput>>

Parsed description request type.


SearchResult = z.infer<typeof searchResultSchema>>

One ranked search result type.


SearchOutput = z.infer<typeof searchOutputSchema>>

Search response envelope type.


DescribeOutput = z.infer<typeof describeOutputSchema>>

Description response type.


ForageFailure = z.infer<typeof forageFailureSchema>>

Typed failure value type.


Operation = z.infer<typeof operationSchema>>

Catalog operation descriptor type.


CatalogInput = z.input<typeof catalogInputSchema>>

Catalog construction input type.

const forageSearchDefinition: ForageDefinition

The search operation has schema metadata only; it has no host behavior.


const forageDescribeDefinition: ForageDefinition

The description operation has schema metadata only; it has no host behavior.


const forageListDefinition: ForageDefinition

Pure exhaustive catalog listing; no execution or authority is granted.


const Forage: ForageApi

Narrow convenience namespace for the package’s public seams.


const forageSearchInput: ZodObject<{ query: ZodString; maxResults: ZodDefault<ZodNumber>>; }, $strip>>

Input accepted by the pure catalog search seam.


const forageDescribeInput: ZodObject<{ path: ZodString; detail: ZodDefault<ZodEnum<{ index: "index"; full: "full"; }>>; methods: ZodOptional<ZodArray<ZodString>>>>; }, $strip>>

Input accepted by the pure catalog description seam.


const forageListInput: ZodObject<{ cursor: ZodOptional<ZodString>>; limit: ZodDefault<ZodNumber>>; namespace: ZodOptional<ZodString>>; }, $strip>>

Exhaustive listing request; cursor is scoped to one immutable catalog and filter.


const searchResultSchema: ZodObject<{ path: ZodString; description: ZodOptional<ZodString>>; score: ZodNumber; matchReason: ZodOptional<ZodString>>; sample: ZodOptional<ZodRecord<ZodString, ZodJSONSchema>>>>; capabilityNotes: ZodOptional<ZodString>>; peers: ZodOptional<ZodArray<ZodObject<{ path: ZodString; capabilityNotes: ZodOptional<ZodString>>; }, $strip>>>>>>; }, $strip>>

One ranked operation in a search response.


const searchOutputSchema: ZodObject<{ results: ZodArray<ZodObject<{ path: ZodString; description: ZodOptional<ZodString>>; score: ZodNumber; matchReason: ZodOptional<ZodString>>; sample: ZodOptional<ZodRecord<ZodString, ZodJSONSchema>>>>; capabilityNotes: ZodOptional<ZodString>>; peers: ZodOptional<ZodArray<ZodObject<{ path: ZodString; capabilityNotes: ZodOptional<ZodString>>; }, $strip>>>>>>; }, $strip>>>>; total: ZodNumber; truncated: ZodBoolean; topScore: ZodNumber; margin: ZodNumber; catalogStamp: ZodString; }, $strip>>

Bounded search response envelope.


const listOutputSchema: ZodObject<{ results: ZodArray<ZodObject<{ path: ZodString; description: ZodOptional<ZodString>>; score: ZodNumber; matchReason: ZodOptional<ZodString>>; sample: ZodOptional<ZodRecord<ZodString, ZodJSONSchema>>>>; capabilityNotes: ZodOptional<ZodString>>; peers: ZodOptional<ZodArray<ZodObject<{ path: ZodString; capabilityNotes: ZodOptional<ZodString>>; }, $strip>>>>>>; }, $strip>>>>; total: ZodNumber; nextCursor: ZodNullable<ZodString>>; catalogStamp: ZodString; }, $strip>>

One exhaustive page, using the exact search operation summary schema.


const describeOutputSchema: ZodObject<{ path: ZodString; description: ZodOptional<ZodString>>; types: ZodString; kind: ZodEnum<{ module: "module"; operation: "operation"; }>; usage: ZodOptional<ZodString>>; }, $strip>>

Deterministic description response.


const forageFailureSchema: ZodObject<{ code: ZodEnum<{ empty_query: "empty_query"; empty_catalog: "empty_catalog"; unknown_target: "unknown_target"; duplicate_operation: "duplicate_operation"; invalid_input: "invalid_input"; }>; message: ZodString; }, $strip>>

Closed failure vocabulary for malformed or absent catalog requests.


const operationSchema: ZodObject<{ path: ZodString; description: ZodOptional<ZodString>>; input: ZodCustom<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>, ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>>>; output: ZodOptional<ZodCustom<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>, ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>>>>>; capabilityNotes: ZodOptional<ZodString>>; instructions: ZodOptional<ZodString>>; }, $strip>>

A secret-free, callback-free operation descriptor.


const catalogInputSchema: ZodObject<{ revision: ZodString; operations: ZodArray<ZodObject<{ path: ZodString; description: ZodOptional<ZodString>>; input: ZodCustom<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>, ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>>>; output: ZodOptional<ZodCustom<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>, ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>>>>>>; capabilityNotes: ZodOptional<ZodString>>; instructions: ZodOptional<ZodString>>; }, $strip>>>>; }, $strip>>

Input used to construct one immutable catalog revision.

createCatalog(input): ForageCatalog

Construct one immutable catalog revision with a narrow public facade.

string = ...

object[] = ...

ForageCatalog


listOperations(operations, catalogStamp, rawInput): object

Page a trusted immutable operation-summary view. Hosts may filter the existing catalog to their bound operations before paging; this is the one cursor owner. Order is namespace then full path, compared by UTF-16 code units, never locale. Unlike search, no equivalent operations are merged into peers.

readonly object[]

string

string = ...

number = ...

string = ...

object

results: object[]

total: number

nextCursor: string | null

catalogStamp: string

Renames and re-exports Forage