/** * The contribution API behind the extensible MDA primitives. * * `defineExtension(kind, options)` returns the factory a connector namespace * calls, such as `connectors.mcp({ … })`. Argument parsing, branding, and * manifest stamping are shared. * * Every kind declares its input through `args`, which takes a schema from any * [Standard Schema](https://standardschema.dev) library — Zod, Valibot, * ArkType — or a plain function where a schema does not fit. Validating through * that interface keeps the vendor out of this package's dependencies, so a * contributor picks whichever library they already use. * * This module is deliberately absent from the package barrel. Only the * first-party namespaces in `namespaces.ts` contribute primitives, so an agent * project cannot mount its own adapter or HTTP route into the managed runtime. * Opening it up to third-party packages is a later step. * * The `auth` primitive is extended by a plain factory rather * than through here: it returns inert configuration objects with no brand, * hooks, or normalization to share. They gain an envelope when this API is * exported and their inputs need validating at the boundary. */ import type { StandardSchemaV1 } from "@standard-schema/spec"; import type { ChannelTransport } from "./channels/runtime.js"; import { type Connector, type ConnectorRequirements, type ConnectorToolList, type EventsContext, type HttpContext, type SandboxContext, type ToolContext } from "./runtime/connector.js"; /** The primitives that carry a shared construction envelope. */ export type ExtensionKind = "connector"; /** * How author input becomes the arguments a primitive is built from. * * Either a schema from any [Standard Schema](https://standardschema.dev) * library — Zod, Valibot, ArkType, … — or a plain function for the cases a * schema cannot express. Both run at module load, so misconfiguration surfaces * at build or dev startup rather than mid-run. Defaults and coercions belong * here too: whatever this produces is what the primitive carries. */ export type ExtensionArgs = StandardSchemaV1 | ((input: TInput) => TArgs); /** Shared by every kind: how the factory's input is validated, and its name. */ interface ExtensionEnvelope { args: ExtensionArgs; /** * How the factory is spelled in an agent project, e.g. `"connectors.mcp"`. * Prefixes validation errors, which is the only place an author sees it. */ label: string; } /** * A connector contributes tools, HTTP routes, sandbox provisioning, inbound * events, and/or a named messaging surface. Hooks receive the built connector, * so they can read the parsed arguments spread onto it. */ export interface ConnectorExtensionOptions extends ExtensionEnvelope { /** Diagnostic label (e.g. `"mcp_servers"`). Mounts use the file-stem name. */ kind: TKind; tools?(ctx: ToolContext, self: ConnectorInstance): ConnectorToolList | Promise; http?(ctx: HttpContext, self: ConnectorInstance): void | Promise; sandbox?(ctx: SandboxContext, self: ConnectorInstance): void | Promise; events?(ctx: EventsContext, self: ConnectorInstance): Response | Promise; messaging?(env: NodeJS.ProcessEnv, self: ConnectorInstance): ChannelTransport | undefined; requirements?(name: string, self: ConnectorInstance): ConnectorRequirements; } /** The connector a `"connector"` extension builds: its brand, kind, and args. */ export type ConnectorInstance = Connector & TArgs & { readonly kind: TKind; }; export declare function defineExtension(kind: "connector", options: ConnectorExtensionOptions): (input: TInput) => ConnectorInstance; export {}; //# sourceMappingURL=extension.d.ts.map