backend-definition
Import
Section titled “Import”import * as api from "@fungi.computer/agar/backend-definition";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| type alias | AppSendBudgetRefusal | A declined Session send, with how long to wait before retrying. |
| type alias | MethodPolicy | A method’s schemas own both its TypeScript contract and JSON boundary. |
| type alias | ResultRowCodec | Decodes and bounds result rows; see resultRows in
@fungi.computer/agar/method-presentation. |
| type alias | MethodPresentation | How a finished call reads to a person: a pure projection run in the App backend.
rows is resultRows from @fungi.computer/agar/method-presentation; only a
backend that presents imports it, so one without presentations carries no row
decoder. |
| type alias | AppBackendMethod | Prepared method export consumed by the backend and its build. |
| type alias | AppBackendMethods | The prepared methods of one backend, keyed by their public names. |
| type alias | AppBackendClass | Typed backend export shared by a build and its runtime method admission. |
| type alias | AppBackendDefinition | A backend’s full generated API: its declared methods, the facet installer, and runtime dispatch by method name. |
| constant | appEventEmitResultSchema | EVENTS.emit acknowledges delivery with native void, not a JSON value. |
| constant | appSendBudgetRefusalSchema | App-originated Session send refusal; retry advice is a duration, not a timestamp. |
| constant | presentMethodName | Name of the generated, hidden read method that projects a finished call into its row. |
| function | defineAppMethod() | Define a typed method once; neither discovery nor builds execute its handler. |
| function | defineAppBackend() | Generate the API from the method exports; callers cannot supply a second catalog. |
AppSendBudgetRefusaltype alias
Section titled “AppSendBudgetRefusal”type AppSendBudgetRefusal = z.output<typeof appSendBudgetRefusalSchema>;A declined Session send, with how long to wait before retrying.
MethodPolicytype alias
Section titled “MethodPolicy”type MethodPolicy = Readonly<{ description: string; effect: "read" | "write" | "external"; requires: readonly AppCapabilityId[]; hidden?: true; anonymous?: true; pending?: true; present?: Readonly<{ verb: string; }>;}>;A method’s schemas own both its TypeScript contract and JSON boundary.
ResultRowCodectype alias
Section titled “ResultRowCodec”type ResultRowCodec = Readonly<{ decode: (row) => ResultRow; schema: z.ZodType;}>;Decodes and bounds result rows; see resultRows in
@fungi.computer/agar/method-presentation.
MethodPresentationtype alias
Section titled “MethodPresentation”type MethodPresentation<I, O> = Readonly<{ verb: string; row: (call) => ResultRow; rows: ResultRowCodec;}>;How a finished call reads to a person: a pure projection run in the App backend.
rows is resultRows from @fungi.computer/agar/method-presentation; only a
backend that presents imports it, so one without presentations carries no row
decoder.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
I |
O |
AppBackendMethodtype alias
Section titled “AppBackendMethod”type AppBackendMethod<Context> = Readonly<{ policy: MethodPolicy; input: z.ZodType; output: z.ZodType; present?: (input, output) => ResultRow; presentRow?: z.ZodType; call: (input, context, caller) => Promise<WhistleJsonValue>;}>;Prepared method export consumed by the backend and its build.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Context |
void |
AppBackendMethodstype alias
Section titled “AppBackendMethods”type AppBackendMethods<Context> = Readonly< Record<string, AppBackendMethod<Context>>>;The prepared methods of one backend, keyed by their public names.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Context |
void |
AppBackendClasstype alias
Section titled “AppBackendClass”type AppBackendClass = (...args) => object & object;Typed backend export shared by a build and its runtime method admission.
Type Declaration
Section titled “Type Declaration”| Name | Type |
|---|---|
prototype |
object |
AppBackendDefinitiontype alias
Section titled “AppBackendDefinition”type AppBackendDefinition<Context> = Readonly<{ methods: Readonly<Record<string, AppBackendMethod<Context>>>; sync?: Readonly<{ method: string; }>; gills?: readonly AppBackendGill[]; gill: (input, context, caller) => Promise<GillReply>; toolFamily?: AppApi["toolFamily"]; events?: Readonly< Record< string, Readonly<{ description: string; payload: z.ZodType; }> > >; implement: <C>(implementation) => C; call: (method, input, context, caller) => Promise<WhistleJsonValue>;}>;A backend’s full generated API: its declared methods, the facet installer, and runtime dispatch by method name.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Context |
void |
appEventEmitResultSchemaconstant
Section titled “appEventEmitResultSchema”const appEventEmitResultSchema: ZodUndefined;EVENTS.emit acknowledges delivery with native void, not a JSON value.
appSendBudgetRefusalSchemaconstant
Section titled “appSendBudgetRefusalSchema”const appSendBudgetRefusalSchema: ZodLazy< ZodObject< { error: ZodLiteral<"send_budget_exceeded">; retryAfterMs: ZodNumber; }, $strict >>;App-originated Session send refusal; retry advice is a duration, not a timestamp.
presentMethodNameconstant
Section titled “presentMethodName”const presentMethodName: "present" = "present";Name of the generated, hidden read method that projects a finished call into its row.
defineAppMethod()function
Section titled “defineAppMethod()”function defineAppMethod<I, O, Context>(method): AppBackendMethod<Context>;Define a typed method once; neither discovery nor builds execute its handler.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
I extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
- |
O extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
- |
Context |
void |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
method |
Omit<Readonly<{ description: string; effect: "external" | "read" | "write"; requires: readonly ( | "agent.list" | "agent.manage" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "approvals" | "apps.open" | "apps.call" | "llm.generation" | "media.generation" | "games:servers" | "git.repository" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[]; hidden?: true; anonymous?: true; pending?: true; present?: Readonly<{ verb: string; }>; }>, "present"> & { input: I; output: O; present?: Readonly<{ verb: string; row: (call: Readonly<{ input: output<I>; output: output<O>; }>) => { readonly id: string; readonly title: string; … 4 more …; readonly media?: { …; } | undefined; }; rows: Readonly<…>; }> | undefined; } & ({ …; } | { …; }) |
Returns
Section titled “Returns”AppBackendMethod<Context>
defineAppBackend()function
Section titled “defineAppBackend()”function defineAppBackend<Context>(options): AppBackendDefinition<Context>;Generate the API from the method exports; callers cannot supply a second catalog.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Context |
void |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
Readonly<{ methods: Readonly<Record<string, AppBackendMethod<Context>>>; events?: AppBackendDefinition<Context>["events"]; gills?: readonly AppBackendGill[]; sync?: AppBackendDefinition<Context>["sync"]; toolFamily?: AppBackendDefinition<Context>["toolFamily"]; }> |
Returns
Section titled “Returns”AppBackendDefinition<Context>
References
Section titled “References”AppBackendGill
Section titled “AppBackendGill”Re-exports AppBackendGill
pending
Section titled “pending”Re-exports pending
pendingSchema
Section titled “pendingSchema”Re-exports pendingSchema
Pending
Section titled “Pending”Re-exports Pending