@finalai/agent-provider 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/HOSTING.md CHANGED
@@ -66,6 +66,75 @@ other hosted connection. `binding`
66
66
  selects another name. Existing explicit `url` calls remain static and compatible;
67
67
  they always point at that URL. There is no Final-specific compiler rewrite.
68
68
 
69
+ ## Connection tool policy
70
+
71
+ `tools.allow`, `tools.deny` and `tools.approval` keys are tool names or `*`
72
+ patterns, so a definition can scope a connection whose tool list it does not know:
73
+
74
+ ```ts
75
+ export default defineFinalConnection({
76
+ tools: {
77
+ allow: ['github.*', 'list_goals'],
78
+ deny: ['github.delete_repo'],
79
+ approval: { 'github.delete_*': always() },
80
+ },
81
+ });
82
+ ```
83
+
84
+ `*` matches any run of characters; everything else matches literally. `deny` wins
85
+ over `allow`. The most specific key governs a tool: an exact name, else the matching
86
+ pattern with the most literal characters, with ties resolved toward `ask`. Hosts
87
+ enforce this through `isToolExposed` and `toolApprovalOf` from
88
+ `@finalai/agent-provider`, and look up a tool's input-approval predicate under the
89
+ key `resolveToolApprovalKey` returns.
90
+
91
+ ## Loaded and searchable tools
92
+
93
+ A connection that can expose many tools, such as Final's with every service the
94
+ person has connected, can name the ones the harness should list up front:
95
+
96
+ ```ts
97
+ export default defineFinalConnection({
98
+ tools: { load: ['list_goals', 'get_goal', 'draft_goal', 'notify_user'] },
99
+ });
100
+ ```
101
+
102
+ Without `load`, the harness lists every exposed tool, as before. With it, the host
103
+ lists only the loaded tools and must keep every other exposed tool reachable: it
104
+ serves a search over the connection's remaining exposed tools (name, description,
105
+ input schema) and a call that runs a found tool by its real name, with the same
106
+ exposure and approval checks as a direct call. A host may instead add a found tool
107
+ to the list and send `notifications/tools/list_changed`; harnesses that ignore that
108
+ notification still need the call path. `load: []` leaves every tool to search.
109
+ Entries are tool names or `*` patterns. `isToolLoaded` from `@finalai/agent-provider`
110
+ applies the rule after exposure.
111
+
112
+ ## Selecting tools by annotation
113
+
114
+ `tools.allow` and `tools.deny` entries can be MCP annotation selectors as well as
115
+ tool names, so a definition can scope tools it cannot name in advance:
116
+
117
+ ```ts
118
+ export default defineFinalConnection({
119
+ tools: {
120
+ allow: ['list_goals', 'draft_goal', { readOnlyHint: true }],
121
+ deny: [{ destructiveHint: true, readOnlyHint: false }],
122
+ },
123
+ });
124
+ ```
125
+
126
+ A selector matches when every hint it sets equals the tool's hint, reading hints the
127
+ tool omits as the MCP spec's defaults (not read-only, destructive, not idempotent,
128
+ open world). The annotations come from the connection's server, so select on them
129
+ only for servers trusted to classify their own tools.
130
+
131
+ Selectors lower to `allowAnnotations` (each with the connection default approval and
132
+ input predicate) and `denyAnnotations`. A host exposes a tool when nothing in `deny`
133
+ or `denyAnnotations` matches it and either an `approvals` key (name or pattern)
134
+ governs it, `approvals` is null, or `toolAnnotationRuleFor` finds a rule; a tool an
135
+ `approvals` key governs keeps that approval, otherwise it runs under the rule's. `tools.approval` overrides apply only to
136
+ named tools.
137
+
69
138
  ## Resources and provider packages
70
139
 
71
140
  `HostedBindingsIface` is the shared `@finalai/agent-provider` contract. Hosting
@@ -69,6 +69,7 @@ export declare const harnessDescriptionSchema: z.ZodObject<{
69
69
  fork: z.ZodBoolean;
70
70
  authorMeta: z.ZodBoolean;
71
71
  nativeToolPolicy: z.ZodOptional<z.ZodBoolean>;
72
+ deferredToolSearch: z.ZodOptional<z.ZodBoolean>;
72
73
  }, z.core.$strip>;
73
74
  promptWhileRunning: z.ZodDefault<z.ZodEnum<typeof PromptWhileRunning>>;
74
75
  sessionSurvivesDisconnect: z.ZodDefault<z.ZodBoolean>;
@@ -80,7 +80,11 @@ const harnessDescriptionSchema = z.object({
80
80
  // the author's name to the text.
81
81
  authorMeta: z.boolean(),
82
82
  // Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.
83
- nativeToolPolicy: z.boolean().optional()
83
+ nativeToolPolicy: z.boolean().optional(),
84
+ // Defers and searches MCP tools itself (a harness-native tool search): the
85
+ // host lists every exposed tool, ignoring connections' `tools.load`, and
86
+ // adds no search of its own. Absent: the host applies `load` and serves search.
87
+ deferredToolSearch: z.boolean().optional()
84
88
  }),
85
89
  promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),
86
90
  // Keeps the session, its running work and its open requests across a dropped
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/harness.ts"],
4
- "sourcesContent": ["import type { McpServer } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { CredentialRoute, routeGrantSchema, type RouteGrantIface } from \"./credential-routes.mjs\";\nimport { CredentialDelivery, InferenceCredentialKind } from \"./credentials.mjs\";\nimport type { JsonSchema, JsonValue } from \"./json.mjs\";\nimport type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema } from \"./json.mjs\";\nimport { BaseCapability, InstructionRole, type ResolvedAgentManifestIface } from \"./manifest.mjs\";\nimport { bundleRef, providerRefSchema, type ProviderRef } from \"./provider-ref.mjs\";\nimport { referencedSharedSchemas, SCHEMA_IDS } from \"./schemas.mjs\";\n\n// Placeholder export name the compiler replaces with the defining module's path.\nexport const PENDING_BUNDLE_EXPORT = '<pending>';\n\n// A harness is a specific ACP agent program together with how to reach it. Hosting is part of what a harness is, so there is no\n// engine parameter: \"Pi on Final's serverless runtime\" and \"Pi on a server you\n// run\" are two harnesses. The hosting half is deliberately small; everything\n// about what the agent does goes over ACP v2.\n\nexport enum AcpTransport {\n Relay = 'relay',\n Ws = 'ws',\n Http = 'http',\n Stdio = 'stdio',\n}\n\nexport enum McpTransportKind {\n Acp = 'acp',\n Http = 'http',\n Stdio = 'stdio',\n}\n\n// How a harness provides one base capability.\nexport enum BaseToolProvision {\n // Routed to the declared sandbox target.\n Bound = 'bound',\n // Native on the harness's host and switchable through its own allow-lists.\n HostDisableable = 'host-disableable',\n // Native on the harness's host and not switchable.\n HostFixed = 'host-fixed',\n}\n\n// SDK wires a harness speaks to reach a bound sandbox target.\nexport enum SandboxWire {\n HandleRpc = 'handle-rpc',\n Mcp = 'mcp',\n}\n\nexport enum UserInstructionDelivery {\n History = 'history',\n System = 'system',\n}\n\n// Who operates the place a harness's credentials land. Every\n// harness, Final's included, gets the same grant forms; a subscription goes to\n// a third-party harness only when its owner allowed third-party harnesses.\n// Only installed provider packages may declare first-party; a bundle-declared\n// harness is third-party whatever it declares.\nexport enum HarnessTrustClass {\n // The provider operates the harness on infrastructure it runs (Final's serverless harnesses).\n FirstParty = 'first-party',\n // Someone else's host or program (remote hosts, external ACP agents, local processes).\n ThirdParty = 'third-party',\n}\n\n// What an accepted session/prompt does while the session is running. Both are valid; refusing one is a conformance failure.\nexport enum PromptWhileRunning {\n // Joins the running work: the model sees it at its next step.\n Inject = 'inject',\n // Runs after the current work goes idle; dropped by session/cancel if not started.\n Queue = 'queue',\n}\n\n// Defaults for a description that does not declare the hosting contract's\n// newer fields (bundle harnesses, older registrations): the session service\n// then assumes nothing survives a dropped connection and that a prompt while\n// running waits for idle.\nexport const DEFAULT_PROMPT_WHILE_RUNNING = PromptWhileRunning.Queue;\nexport const DEFAULT_SESSION_SURVIVES_DISCONNECT = false;\n\nexport const baseToolDeclarationSchema = z.object({\n provision: z.nativeEnum(BaseToolProvision),\n nativeTools: z.array(z.string()),\n});\n\nexport const harnessDescriptionSchema = z.object({\n // Everything configurable about this harness (model, reasoning, credentials,\n // permission mode, instructions, skills, cwd, ...). JSON Schema so Build can\n // render it; may $ref the shared final://schemas/* fragments.\n configSchema: jsonSchemaSchema,\n // Absent: user fragments enter history. System-only programs declare their conversion.\n userInstructionDelivery: z.nativeEnum(UserInstructionDelivery).optional(),\n acp: z.object({\n transports: z.array(z.nativeEnum(AcpTransport)).min(1),\n mcp: z.array(z.nativeEnum(McpTransportKind)),\n }),\n // A capability missing here is unavailable on this harness.\n baseTools: z.partialRecord(z.nativeEnum(BaseCapability), baseToolDeclarationSchema),\n consumes: z.array(z.nativeEnum(SandboxWire)),\n inference: z.object({\n vendors: z.array(z.string()),\n kinds: z.array(z.nativeEnum(InferenceCredentialKind)),\n delivery: z.nativeEnum(CredentialDelivery),\n }),\n // Absent: third-party.\n trust: z.nativeEnum(HarnessTrustClass).optional(),\n supports: z.object({\n observe: z.boolean(),\n resumeReplay: z.boolean(),\n fork: z.boolean(),\n // Renders _meta[\"final.ai\"].author itself; otherwise the channel prepends\n // the author's name to the text.\n authorMeta: z.boolean(),\n // Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.\n nativeToolPolicy: z.boolean().optional(),\n }),\n promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),\n // Keeps the session, its running work and its open requests across a dropped\n // connection, buffers updates for replay, and re-raises the open requests\n // with the same JSON-RPC ids on the next session/resume. False:\n // open turns end `harness_state_lost` after a reconnect.\n sessionSurvivesDisconnect: z.boolean().default(DEFAULT_SESSION_SURVIVES_DISCONNECT),\n});\n\nexport type BaseToolDeclarationIface = z.infer<typeof baseToolDeclarationSchema>;\nexport type HarnessDescriptionIface = z.infer<typeof harnessDescriptionSchema>;\n\nexport const deliveredHarnessConfig = (args: {\n config: JsonValue;\n description: HarnessDescriptionIface;\n}): JsonValue => {\n if (args.description.userInstructionDelivery !== UserInstructionDelivery.System)\n return args.config;\n const config = jsonObjectSchema.safeParse(args.config);\n if (!config.success) return args.config;\n const fields = referencedSharedSchemas(args.description.configSchema);\n const field =\n Object.entries(fields).find(([, schema]) => schema === SCHEMA_IDS.instructions)?.[0] ??\n 'instructions';\n const instructions = config.data[field];\n if (!Array.isArray(instructions)) return args.config;\n return {\n ...config.data,\n [field]: instructions.map((value) => {\n const fragment = jsonObjectSchema.safeParse(value);\n return fragment.success && fragment.data['role'] === InstructionRole.User\n ? { ...fragment.data, role: InstructionRole.System }\n : value;\n }),\n };\n};\n\nexport const harnessSessionRefSchema = z.object({\n harness: providerRefSchema,\n // Opaque to the session service; the harness's own id for the session.\n harnessSessionRef: z.string().min(1),\n // Bumped whenever the harness loses state; a mismatch on resume means the\n // session service must re-seed with session/new.\n generation: z.number().int().nonnegative(),\n});\n\nexport type HarnessSessionRefIface = z.infer<typeof harnessSessionRefSchema>;\n\n// Route-scoped, short-lived grants: credential-routes.ts.\nexport {\n credentialRefreshRequestSchema,\n CredentialRoute,\n routeGrantSchema,\n type CredentialRefreshRequestIface,\n type RouteGrantIface,\n} from \"./credential-routes.mjs\";\n\nexport interface CredentialGrantIface {\n // Base URL of the broker routes (`<base>/model`, `<base>/refresh`, ...).\n brokerUrl: string;\n grants: RouteGrantIface[];\n // What the model grant resolved to, for harnesses that hand credentials over\n // at open (delivery 'at-open'). Null for per-request harnesses.\n atOpen: AtOpenModelCredentialIface | null;\n // How to renew this grant; null only when it carries no route grant.\n refresh: CredentialGrantRefreshIface | null;\n}\n\n// Renewal is pulled, never pushed. Per-request harnesses fetch\n// `<brokerUrl>/model` on every request. At-open harnesses (or their host)\n// POST `url` with `authorization: Bearer <token>` and a\n// `credentialRefreshRequestSchema` body before `expiresAt` and once after a\n// vendor 401; the answer is the grant's next generation (a\n// `credentialRefreshResultSchema` body with its own `refresh`), which replaces\n// this one. The broker resolves the policy again for it, so a disconnected\n// credential falls through; a revoked grant (every open revokes the previous\n// open's grants) or a closed harness session is refused (401).\nexport interface CredentialGrantRefreshIface {\n // `<brokerUrl>/refresh`.\n url: string;\n // One of this grant's own route grants (the model route's).\n token: string;\n harnessSessionId: string;\n // When `token` expires; a refresh after it is refused.\n expiresAt: string;\n}\n\nexport interface AtOpenModelCredentialIface {\n vendor: string;\n kind: InferenceCredentialKind;\n // Base URL and bearer for an OpenAI- or Anthropic-compatible endpoint (the\n // platform proxy, a corporate gateway) or the vendor itself.\n baseUrl: string | null;\n apiKey: string | null;\n // Subscription material for Final-managed harnesses only (Claude setup token,\n // Codex app-server chatgptAuthTokens); renewed through the grant's refresh route.\n subscription: { format: 'claude-setup-token' | 'chatgpt-auth-tokens'; value: string } | null;\n fingerprint: string;\n}\n\nexport const atOpenModelCredentialSchema = z.object({\n vendor: z.string(),\n kind: z.nativeEnum(InferenceCredentialKind),\n baseUrl: z.string().min(1).nullable(),\n apiKey: z.string().min(1).nullable(),\n subscription: z\n .object({\n format: z.union([z.literal('claude-setup-token'), z.literal('chatgpt-auth-tokens')]),\n value: z.string().min(1),\n })\n .nullable(),\n fingerprint: z.string(),\n}) satisfies z.ZodType<AtOpenModelCredentialIface>;\n\nexport const credentialGrantRefreshSchema = z.object({\n url: z.string().min(1),\n token: z.string().min(1),\n harnessSessionId: z.string().min(1),\n expiresAt: z.string(),\n}) satisfies z.ZodType<CredentialGrantRefreshIface>;\n\nexport const credentialGrantSchema = z.object({\n brokerUrl: z.string().min(1),\n grants: z.array(routeGrantSchema),\n atOpen: atOpenModelCredentialSchema.nullable(),\n refresh: credentialGrantRefreshSchema.nullable(),\n}) satisfies z.ZodType<CredentialGrantIface>;\n\n// An `http` MCP server entry the harness was handed in `session/new`\n// (`mcpServers`), with fresh headers. Same name and url; the harness swaps the\n// headers of the entry with that url.\nexport interface RenewedMcpServerIface {\n name: string;\n url: string;\n headers: { name: string; value: string }[];\n}\n\n// What a refresh answers: the grant's next generation, plus fresh copies of the\n// other short-lived material the harness was handed at open. Renewing the\n// `mcp` route renews the session's `http` MCP server headers; renewing\n// `sandbox` renews the bound sandbox targets' endpoint tokens.\nexport interface CredentialRefreshResultIface extends CredentialGrantIface {\n mcpServers: RenewedMcpServerIface[];\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n}\n\nconst endpointTokenSchema = z.object({\n url: z.string().min(1),\n token: z.string(),\n expiresAt: z.string(),\n});\n\nexport const sandboxTargetEndpointSchema = z.object({\n target: z.string().min(1),\n bindingId: z.string().min(1),\n capabilities: z.array(z.string()),\n rpc: endpointTokenSchema.nullable(),\n mcp: endpointTokenSchema.nullable(),\n}) satisfies z.ZodType<SandboxTargetEndpointIface>;\n\nexport const renewedMcpServerSchema = z.object({\n name: z.string().min(1),\n url: z.string().min(1),\n headers: z.array(z.object({ name: z.string().min(1), value: z.string() })),\n}) satisfies z.ZodType<RenewedMcpServerIface>;\n\n// Absent renewals parse as none, so an answer without them still parses.\nexport const credentialRefreshResultSchema = credentialGrantSchema.extend({\n mcpServers: z.array(renewedMcpServerSchema).default([]),\n sandboxes: z.record(z.string(), sandboxTargetEndpointSchema).default({}),\n}) satisfies z.ZodType<CredentialRefreshResultIface, unknown>;\n\n// The refresh descriptor for a set of route grants: authenticated by the model\n// grant (else the first), due when that token expires.\nexport const grantRefreshFor = (args: {\n brokerUrl: string;\n harnessSessionId: string;\n grants: readonly RouteGrantIface[];\n}): CredentialGrantRefreshIface | null => {\n const grant =\n args.grants.find((candidate) => candidate.route === CredentialRoute.Model) ?? args.grants[0];\n if (grant == null) return null;\n return {\n url: `${args.brokerUrl.replace(/\\/+$/, '')}/refresh`,\n token: grant.token,\n harnessSessionId: args.harnessSessionId,\n expiresAt: grant.expiresAt,\n };\n};\n\nexport interface SecretReaderIface {\n get(name: string): Promise<string | null>;\n}\n\nexport interface TraceContextIface {\n traceparent: string | null;\n tracestate: string | null;\n}\n\n// A bound sandbox target as the session service hands it to a harness: a stable\n// per-binding address that starts the sandbox on the first tool call. Never a lease, a data-plane token for a live VM, or provider code.\nexport interface SandboxTargetEndpointIface {\n target: string;\n bindingId: string;\n capabilities: string[];\n rpc: { url: string; token: string; expiresAt: string } | null;\n mcp: { url: string; token: string; expiresAt: string } | null;\n}\n\nexport interface HarnessSessionContextIface {\n bindings?: HostedBindingsIface;\n sessionId: string;\n organizationId: string;\n definitionId: string;\n revisionId: string;\n // Public base URL of the session service for this session (MCP over HTTP,\n // sandbox endpoints, the broker).\n sessionServiceUrl: string;\n // The region of the session service serving the session and its sandbox\n // bindings, so a harness can run near it; null when unknown.\n sessionServiceRegion?: string | null;\n}\n\n// Lifecycle signals a harness implementation may report about the runtime\n// hosting a session (invocations, metering, traces). Informational: the\n// session service records them (agent.harness_invocations, Tinybird) and never\n// depends on them for correctness.\nexport interface HarnessObserverIface {\n // The runtime accepted the invocation request (its response began).\n invocationAccepted?(event: { invocationRef: string; at: string }): void;\n invocationStarted?(event: {\n invocationRef: string;\n at: string;\n bootMs: number | null;\n // The runtime's deployed version (Workers version id, commit), for rollouts.\n versionId?: string | null;\n commitSha?: string | null;\n }): void;\n invocationKeepalive?(event: { invocationRef: string; at: string; activeWork: number }): void;\n invocationEnded?(event: {\n invocationRef: string;\n at: string;\n reason: string;\n error: string | null;\n metering: Record<string, number>;\n }): void;\n trace?(event: { name: string; at: string; fields: Record<string, JsonValue> }): void;\n}\n\nexport interface OpenHarnessSessionArgsIface {\n session: HarnessSessionContextIface;\n // The session service's id for this harness session (agent.harness_sessions);\n // implementations key their runtime state and route grants by it.\n harnessSessionId: string;\n // Hosting may authorize the child endpoint to fork this source through ACP.\n forkSource?: { ref: HarnessSessionRefIface; acpSessionId: string };\n observer?: HarnessObserverIface;\n // The binding's config, validated against configSchema, dynamic slots resolved.\n config: JsonValue;\n manifest: ResolvedAgentManifestIface;\n // Already materialized ACP MCP server entries: authored tools, connections\n // (Final's MCP server among them), sandbox MCP projections where applicable.\n mcpServers: McpServer[];\n // Declared base capabilities with the target endpoint each is bound to.\n baseTools: Partial<Record<BaseCapability, SandboxTargetEndpointIface>>;\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n credentials: CredentialGrantIface;\n secrets: SecretReaderIface;\n trace: TraceContextIface;\n}\n\nexport interface ResumeHarnessSessionArgsIface extends OpenHarnessSessionArgsIface {\n ref: HarnessSessionRefIface;\n // Last log seq the session service holds from this harness session; the\n // harness replays anything newer after session/resume.\n lastSeq: number;\n}\n\n// Resolved only in memory; refs/manifests retain secret names, never TLS keys.\nexport interface HarnessClientTlsIface {\n cert: string;\n key: string;\n ca?: string;\n}\n\nexport type HarnessEndpointIface =\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Ws;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Http;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n // websocket-gateway relay channel (Final-managed harnesses).\n | { ref: HarnessSessionRefIface; transport: AcpTransport.Relay; channel: string; token: string }\n // Local development, CI and conformance only.\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Stdio;\n command: string;\n args: string[];\n env: Record<string, string>;\n };\n\nexport interface HarnessHealthIface {\n ok: boolean;\n detail?: string;\n checkedAt: string;\n}\n\n// The binding a description is asked for: its config (validated against the\n// configSchema of the binding-free description) and the definition's secrets.\nexport interface DescribeHarnessArgsIface {\n config: JsonValue;\n secrets: SecretReaderIface;\n}\n\nexport interface HarnessIface {\n // Without a binding: what Build renders before one exists (configSchema,\n // declared capabilities). With one: the description of that binding, which a\n // harness reaching an arbitrary agent derives from the agent itself (e.g. its\n // `initialize`). Every harness implements both; most ignore the binding.\n describe(binding?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface>;\n open(args: OpenHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n resume(args: ResumeHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n park(ref: HarnessSessionRefIface): Promise<void>;\n // Graceful by default: the program's state is durable (resumable) before it\n // stops, bounded by the implementation's timeout, then forced. `force` skips\n // the wait; the session service passes it when the program did not settle\n // ACP `session/close` within its bound.\n close(ref: HarnessSessionRefIface, opts?: CloseHarnessSessionOptsIface): Promise<void>;\n health(\n ref: HarnessSessionRefIface,\n context?: DescribeHarnessArgsIface,\n ): Promise<HarnessHealthIface>;\n}\n\nexport interface CloseHarnessSessionOptsIface {\n force?: boolean;\n // As with health, retained refs can resolve current client TLS without storing keys in the ref.\n context?: DescribeHarnessArgsIface;\n}\n\n// What an installed harness module exports: the implementation plus an\n// authoring helper that builds the manifest binding.\nexport interface HarnessModuleIface<Config> {\n ref: ProviderRef;\n harness: HarnessIface;\n binding: (config: Config) => { harness: ProviderRef; config: JsonValue };\n}\n\n// Custom harnesses in a definition's bundle. Calling the result\n// with a config yields the manifest binding; the implementation is resolved\n// from the bundle by export name.\nexport interface DefinedHarnessBindingIface {\n harness: ProviderRef;\n config: JsonValue;\n definedHarness: true;\n}\n\nexport interface DefinedHarnessIface<Config> extends HarnessIface {\n (config: Config): DefinedHarnessBindingIface;\n}\n\nexport const defineHarness = <Config extends JsonValue = JsonValue>(\n implementation: HarnessIface,\n): DefinedHarnessIface<Config> => {\n // The export name is unknown here; the compiler rewrites `bundle:<pending>`\n // to the module path that exported this harness.\n const binding = (config: Config): DefinedHarnessBindingIface => ({\n harness: bundleRef(PENDING_BUNDLE_EXPORT),\n config,\n definedHarness: true,\n });\n return Object.assign(binding, implementation);\n};\n\nexport const describeConfigSchema = (description: HarnessDescriptionIface): JsonSchema =>\n description.configSchema;\n"],
5
- "mappings": "AACA,YAAY,OAAO;AACnB,SAAS,iBAAiB,wBAA8C;AACxE,SAAS,oBAAoB,+BAA+B;AAG5D,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,gBAAgB,uBAAwD;AACjF,SAAS,WAAW,yBAA2C;AAC/D,SAAS,yBAAyB,kBAAkB;AAG7C,MAAM,wBAAwB;AAO9B,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,QAAK;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAOL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,SAAM;AACN,EAAAA,kBAAA,UAAO;AACP,EAAAA,kBAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AAOL,IAAK,oBAAL,kBAAKC,uBAAL;AAEL,EAAAA,mBAAA,WAAQ;AAER,EAAAA,mBAAA,qBAAkB;AAElB,EAAAA,mBAAA,eAAY;AANF,SAAAA;A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AAC9C;AAEO,MAAM,uBAAuB,CAAC,gBACnC,YAAY;",
4
+ "sourcesContent": ["import type { McpServer } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { CredentialRoute, routeGrantSchema, type RouteGrantIface } from \"./credential-routes.mjs\";\nimport { CredentialDelivery, InferenceCredentialKind } from \"./credentials.mjs\";\nimport type { JsonSchema, JsonValue } from \"./json.mjs\";\nimport type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema } from \"./json.mjs\";\nimport { BaseCapability, InstructionRole, type ResolvedAgentManifestIface } from \"./manifest.mjs\";\nimport { bundleRef, providerRefSchema, type ProviderRef } from \"./provider-ref.mjs\";\nimport { referencedSharedSchemas, SCHEMA_IDS } from \"./schemas.mjs\";\n\n// Placeholder export name the compiler replaces with the defining module's path.\nexport const PENDING_BUNDLE_EXPORT = '<pending>';\n\n// A harness is a specific ACP agent program together with how to reach it. Hosting is part of what a harness is, so there is no\n// engine parameter: \"Pi on Final's serverless runtime\" and \"Pi on a server you\n// run\" are two harnesses. The hosting half is deliberately small; everything\n// about what the agent does goes over ACP v2.\n\nexport enum AcpTransport {\n Relay = 'relay',\n Ws = 'ws',\n Http = 'http',\n Stdio = 'stdio',\n}\n\nexport enum McpTransportKind {\n Acp = 'acp',\n Http = 'http',\n Stdio = 'stdio',\n}\n\n// How a harness provides one base capability.\nexport enum BaseToolProvision {\n // Routed to the declared sandbox target.\n Bound = 'bound',\n // Native on the harness's host and switchable through its own allow-lists.\n HostDisableable = 'host-disableable',\n // Native on the harness's host and not switchable.\n HostFixed = 'host-fixed',\n}\n\n// SDK wires a harness speaks to reach a bound sandbox target.\nexport enum SandboxWire {\n HandleRpc = 'handle-rpc',\n Mcp = 'mcp',\n}\n\nexport enum UserInstructionDelivery {\n History = 'history',\n System = 'system',\n}\n\n// Who operates the place a harness's credentials land. Every\n// harness, Final's included, gets the same grant forms; a subscription goes to\n// a third-party harness only when its owner allowed third-party harnesses.\n// Only installed provider packages may declare first-party; a bundle-declared\n// harness is third-party whatever it declares.\nexport enum HarnessTrustClass {\n // The provider operates the harness on infrastructure it runs (Final's serverless harnesses).\n FirstParty = 'first-party',\n // Someone else's host or program (remote hosts, external ACP agents, local processes).\n ThirdParty = 'third-party',\n}\n\n// What an accepted session/prompt does while the session is running. Both are valid; refusing one is a conformance failure.\nexport enum PromptWhileRunning {\n // Joins the running work: the model sees it at its next step.\n Inject = 'inject',\n // Runs after the current work goes idle; dropped by session/cancel if not started.\n Queue = 'queue',\n}\n\n// Defaults for a description that does not declare the hosting contract's\n// newer fields (bundle harnesses, older registrations): the session service\n// then assumes nothing survives a dropped connection and that a prompt while\n// running waits for idle.\nexport const DEFAULT_PROMPT_WHILE_RUNNING = PromptWhileRunning.Queue;\nexport const DEFAULT_SESSION_SURVIVES_DISCONNECT = false;\n\nexport const baseToolDeclarationSchema = z.object({\n provision: z.nativeEnum(BaseToolProvision),\n nativeTools: z.array(z.string()),\n});\n\nexport const harnessDescriptionSchema = z.object({\n // Everything configurable about this harness (model, reasoning, credentials,\n // permission mode, instructions, skills, cwd, ...). JSON Schema so Build can\n // render it; may $ref the shared final://schemas/* fragments.\n configSchema: jsonSchemaSchema,\n // Absent: user fragments enter history. System-only programs declare their conversion.\n userInstructionDelivery: z.nativeEnum(UserInstructionDelivery).optional(),\n acp: z.object({\n transports: z.array(z.nativeEnum(AcpTransport)).min(1),\n mcp: z.array(z.nativeEnum(McpTransportKind)),\n }),\n // A capability missing here is unavailable on this harness.\n baseTools: z.partialRecord(z.nativeEnum(BaseCapability), baseToolDeclarationSchema),\n consumes: z.array(z.nativeEnum(SandboxWire)),\n inference: z.object({\n vendors: z.array(z.string()),\n kinds: z.array(z.nativeEnum(InferenceCredentialKind)),\n delivery: z.nativeEnum(CredentialDelivery),\n }),\n // Absent: third-party.\n trust: z.nativeEnum(HarnessTrustClass).optional(),\n supports: z.object({\n observe: z.boolean(),\n resumeReplay: z.boolean(),\n fork: z.boolean(),\n // Renders _meta[\"final.ai\"].author itself; otherwise the channel prepends\n // the author's name to the text.\n authorMeta: z.boolean(),\n // Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.\n nativeToolPolicy: z.boolean().optional(),\n // Defers and searches MCP tools itself (a harness-native tool search): the\n // host lists every exposed tool, ignoring connections' `tools.load`, and\n // adds no search of its own. Absent: the host applies `load` and serves search.\n deferredToolSearch: z.boolean().optional(),\n }),\n promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),\n // Keeps the session, its running work and its open requests across a dropped\n // connection, buffers updates for replay, and re-raises the open requests\n // with the same JSON-RPC ids on the next session/resume. False:\n // open turns end `harness_state_lost` after a reconnect.\n sessionSurvivesDisconnect: z.boolean().default(DEFAULT_SESSION_SURVIVES_DISCONNECT),\n});\n\nexport type BaseToolDeclarationIface = z.infer<typeof baseToolDeclarationSchema>;\nexport type HarnessDescriptionIface = z.infer<typeof harnessDescriptionSchema>;\n\nexport const deliveredHarnessConfig = (args: {\n config: JsonValue;\n description: HarnessDescriptionIface;\n}): JsonValue => {\n if (args.description.userInstructionDelivery !== UserInstructionDelivery.System)\n return args.config;\n const config = jsonObjectSchema.safeParse(args.config);\n if (!config.success) return args.config;\n const fields = referencedSharedSchemas(args.description.configSchema);\n const field =\n Object.entries(fields).find(([, schema]) => schema === SCHEMA_IDS.instructions)?.[0] ??\n 'instructions';\n const instructions = config.data[field];\n if (!Array.isArray(instructions)) return args.config;\n return {\n ...config.data,\n [field]: instructions.map((value) => {\n const fragment = jsonObjectSchema.safeParse(value);\n return fragment.success && fragment.data['role'] === InstructionRole.User\n ? { ...fragment.data, role: InstructionRole.System }\n : value;\n }),\n };\n};\n\nexport const harnessSessionRefSchema = z.object({\n harness: providerRefSchema,\n // Opaque to the session service; the harness's own id for the session.\n harnessSessionRef: z.string().min(1),\n // Bumped whenever the harness loses state; a mismatch on resume means the\n // session service must re-seed with session/new.\n generation: z.number().int().nonnegative(),\n});\n\nexport type HarnessSessionRefIface = z.infer<typeof harnessSessionRefSchema>;\n\n// Route-scoped, short-lived grants: credential-routes.ts.\nexport {\n credentialRefreshRequestSchema,\n CredentialRoute,\n routeGrantSchema,\n type CredentialRefreshRequestIface,\n type RouteGrantIface,\n} from \"./credential-routes.mjs\";\n\nexport interface CredentialGrantIface {\n // Base URL of the broker routes (`<base>/model`, `<base>/refresh`, ...).\n brokerUrl: string;\n grants: RouteGrantIface[];\n // What the model grant resolved to, for harnesses that hand credentials over\n // at open (delivery 'at-open'). Null for per-request harnesses.\n atOpen: AtOpenModelCredentialIface | null;\n // How to renew this grant; null only when it carries no route grant.\n refresh: CredentialGrantRefreshIface | null;\n}\n\n// Renewal is pulled, never pushed. Per-request harnesses fetch\n// `<brokerUrl>/model` on every request. At-open harnesses (or their host)\n// POST `url` with `authorization: Bearer <token>` and a\n// `credentialRefreshRequestSchema` body before `expiresAt` and once after a\n// vendor 401; the answer is the grant's next generation (a\n// `credentialRefreshResultSchema` body with its own `refresh`), which replaces\n// this one. The broker resolves the policy again for it, so a disconnected\n// credential falls through; a revoked grant (every open revokes the previous\n// open's grants) or a closed harness session is refused (401).\nexport interface CredentialGrantRefreshIface {\n // `<brokerUrl>/refresh`.\n url: string;\n // One of this grant's own route grants (the model route's).\n token: string;\n harnessSessionId: string;\n // When `token` expires; a refresh after it is refused.\n expiresAt: string;\n}\n\nexport interface AtOpenModelCredentialIface {\n vendor: string;\n kind: InferenceCredentialKind;\n // Base URL and bearer for an OpenAI- or Anthropic-compatible endpoint (the\n // platform proxy, a corporate gateway) or the vendor itself.\n baseUrl: string | null;\n apiKey: string | null;\n // Subscription material for Final-managed harnesses only (Claude setup token,\n // Codex app-server chatgptAuthTokens); renewed through the grant's refresh route.\n subscription: { format: 'claude-setup-token' | 'chatgpt-auth-tokens'; value: string } | null;\n fingerprint: string;\n}\n\nexport const atOpenModelCredentialSchema = z.object({\n vendor: z.string(),\n kind: z.nativeEnum(InferenceCredentialKind),\n baseUrl: z.string().min(1).nullable(),\n apiKey: z.string().min(1).nullable(),\n subscription: z\n .object({\n format: z.union([z.literal('claude-setup-token'), z.literal('chatgpt-auth-tokens')]),\n value: z.string().min(1),\n })\n .nullable(),\n fingerprint: z.string(),\n}) satisfies z.ZodType<AtOpenModelCredentialIface>;\n\nexport const credentialGrantRefreshSchema = z.object({\n url: z.string().min(1),\n token: z.string().min(1),\n harnessSessionId: z.string().min(1),\n expiresAt: z.string(),\n}) satisfies z.ZodType<CredentialGrantRefreshIface>;\n\nexport const credentialGrantSchema = z.object({\n brokerUrl: z.string().min(1),\n grants: z.array(routeGrantSchema),\n atOpen: atOpenModelCredentialSchema.nullable(),\n refresh: credentialGrantRefreshSchema.nullable(),\n}) satisfies z.ZodType<CredentialGrantIface>;\n\n// An `http` MCP server entry the harness was handed in `session/new`\n// (`mcpServers`), with fresh headers. Same name and url; the harness swaps the\n// headers of the entry with that url.\nexport interface RenewedMcpServerIface {\n name: string;\n url: string;\n headers: { name: string; value: string }[];\n}\n\n// What a refresh answers: the grant's next generation, plus fresh copies of the\n// other short-lived material the harness was handed at open. Renewing the\n// `mcp` route renews the session's `http` MCP server headers; renewing\n// `sandbox` renews the bound sandbox targets' endpoint tokens.\nexport interface CredentialRefreshResultIface extends CredentialGrantIface {\n mcpServers: RenewedMcpServerIface[];\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n}\n\nconst endpointTokenSchema = z.object({\n url: z.string().min(1),\n token: z.string(),\n expiresAt: z.string(),\n});\n\nexport const sandboxTargetEndpointSchema = z.object({\n target: z.string().min(1),\n bindingId: z.string().min(1),\n capabilities: z.array(z.string()),\n rpc: endpointTokenSchema.nullable(),\n mcp: endpointTokenSchema.nullable(),\n}) satisfies z.ZodType<SandboxTargetEndpointIface>;\n\nexport const renewedMcpServerSchema = z.object({\n name: z.string().min(1),\n url: z.string().min(1),\n headers: z.array(z.object({ name: z.string().min(1), value: z.string() })),\n}) satisfies z.ZodType<RenewedMcpServerIface>;\n\n// Absent renewals parse as none, so an answer without them still parses.\nexport const credentialRefreshResultSchema = credentialGrantSchema.extend({\n mcpServers: z.array(renewedMcpServerSchema).default([]),\n sandboxes: z.record(z.string(), sandboxTargetEndpointSchema).default({}),\n}) satisfies z.ZodType<CredentialRefreshResultIface, unknown>;\n\n// The refresh descriptor for a set of route grants: authenticated by the model\n// grant (else the first), due when that token expires.\nexport const grantRefreshFor = (args: {\n brokerUrl: string;\n harnessSessionId: string;\n grants: readonly RouteGrantIface[];\n}): CredentialGrantRefreshIface | null => {\n const grant =\n args.grants.find((candidate) => candidate.route === CredentialRoute.Model) ?? args.grants[0];\n if (grant == null) return null;\n return {\n url: `${args.brokerUrl.replace(/\\/+$/, '')}/refresh`,\n token: grant.token,\n harnessSessionId: args.harnessSessionId,\n expiresAt: grant.expiresAt,\n };\n};\n\nexport interface SecretReaderIface {\n get(name: string): Promise<string | null>;\n}\n\nexport interface TraceContextIface {\n traceparent: string | null;\n tracestate: string | null;\n}\n\n// A bound sandbox target as the session service hands it to a harness: a stable\n// per-binding address that starts the sandbox on the first tool call. Never a lease, a data-plane token for a live VM, or provider code.\nexport interface SandboxTargetEndpointIface {\n target: string;\n bindingId: string;\n capabilities: string[];\n rpc: { url: string; token: string; expiresAt: string } | null;\n mcp: { url: string; token: string; expiresAt: string } | null;\n}\n\nexport interface HarnessSessionContextIface {\n bindings?: HostedBindingsIface;\n sessionId: string;\n organizationId: string;\n definitionId: string;\n revisionId: string;\n // Public base URL of the session service for this session (MCP over HTTP,\n // sandbox endpoints, the broker).\n sessionServiceUrl: string;\n // The region of the session service serving the session and its sandbox\n // bindings, so a harness can run near it; null when unknown.\n sessionServiceRegion?: string | null;\n}\n\n// Lifecycle signals a harness implementation may report about the runtime\n// hosting a session (invocations, metering, traces). Informational: the\n// session service records them (agent.harness_invocations, Tinybird) and never\n// depends on them for correctness.\nexport interface HarnessObserverIface {\n // The runtime accepted the invocation request (its response began).\n invocationAccepted?(event: { invocationRef: string; at: string }): void;\n invocationStarted?(event: {\n invocationRef: string;\n at: string;\n bootMs: number | null;\n // The runtime's deployed version (Workers version id, commit), for rollouts.\n versionId?: string | null;\n commitSha?: string | null;\n }): void;\n invocationKeepalive?(event: { invocationRef: string; at: string; activeWork: number }): void;\n invocationEnded?(event: {\n invocationRef: string;\n at: string;\n reason: string;\n error: string | null;\n metering: Record<string, number>;\n }): void;\n trace?(event: { name: string; at: string; fields: Record<string, JsonValue> }): void;\n}\n\nexport interface OpenHarnessSessionArgsIface {\n session: HarnessSessionContextIface;\n // The session service's id for this harness session (agent.harness_sessions);\n // implementations key their runtime state and route grants by it.\n harnessSessionId: string;\n // Hosting may authorize the child endpoint to fork this source through ACP.\n forkSource?: { ref: HarnessSessionRefIface; acpSessionId: string };\n observer?: HarnessObserverIface;\n // The binding's config, validated against configSchema, dynamic slots resolved.\n config: JsonValue;\n manifest: ResolvedAgentManifestIface;\n // Already materialized ACP MCP server entries: authored tools, connections\n // (Final's MCP server among them), sandbox MCP projections where applicable.\n mcpServers: McpServer[];\n // Declared base capabilities with the target endpoint each is bound to.\n baseTools: Partial<Record<BaseCapability, SandboxTargetEndpointIface>>;\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n credentials: CredentialGrantIface;\n secrets: SecretReaderIface;\n trace: TraceContextIface;\n}\n\nexport interface ResumeHarnessSessionArgsIface extends OpenHarnessSessionArgsIface {\n ref: HarnessSessionRefIface;\n // Last log seq the session service holds from this harness session; the\n // harness replays anything newer after session/resume.\n lastSeq: number;\n}\n\n// Resolved only in memory; refs/manifests retain secret names, never TLS keys.\nexport interface HarnessClientTlsIface {\n cert: string;\n key: string;\n ca?: string;\n}\n\nexport type HarnessEndpointIface =\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Ws;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Http;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n // websocket-gateway relay channel (Final-managed harnesses).\n | { ref: HarnessSessionRefIface; transport: AcpTransport.Relay; channel: string; token: string }\n // Local development, CI and conformance only.\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Stdio;\n command: string;\n args: string[];\n env: Record<string, string>;\n };\n\nexport interface HarnessHealthIface {\n ok: boolean;\n detail?: string;\n checkedAt: string;\n}\n\n// The binding a description is asked for: its config (validated against the\n// configSchema of the binding-free description) and the definition's secrets.\nexport interface DescribeHarnessArgsIface {\n config: JsonValue;\n secrets: SecretReaderIface;\n}\n\nexport interface HarnessIface {\n // Without a binding: what Build renders before one exists (configSchema,\n // declared capabilities). With one: the description of that binding, which a\n // harness reaching an arbitrary agent derives from the agent itself (e.g. its\n // `initialize`). Every harness implements both; most ignore the binding.\n describe(binding?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface>;\n open(args: OpenHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n resume(args: ResumeHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n park(ref: HarnessSessionRefIface): Promise<void>;\n // Graceful by default: the program's state is durable (resumable) before it\n // stops, bounded by the implementation's timeout, then forced. `force` skips\n // the wait; the session service passes it when the program did not settle\n // ACP `session/close` within its bound.\n close(ref: HarnessSessionRefIface, opts?: CloseHarnessSessionOptsIface): Promise<void>;\n health(\n ref: HarnessSessionRefIface,\n context?: DescribeHarnessArgsIface,\n ): Promise<HarnessHealthIface>;\n}\n\nexport interface CloseHarnessSessionOptsIface {\n force?: boolean;\n // As with health, retained refs can resolve current client TLS without storing keys in the ref.\n context?: DescribeHarnessArgsIface;\n}\n\n// What an installed harness module exports: the implementation plus an\n// authoring helper that builds the manifest binding.\nexport interface HarnessModuleIface<Config> {\n ref: ProviderRef;\n harness: HarnessIface;\n binding: (config: Config) => { harness: ProviderRef; config: JsonValue };\n}\n\n// Custom harnesses in a definition's bundle. Calling the result\n// with a config yields the manifest binding; the implementation is resolved\n// from the bundle by export name.\nexport interface DefinedHarnessBindingIface {\n harness: ProviderRef;\n config: JsonValue;\n definedHarness: true;\n}\n\nexport interface DefinedHarnessIface<Config> extends HarnessIface {\n (config: Config): DefinedHarnessBindingIface;\n}\n\nexport const defineHarness = <Config extends JsonValue = JsonValue>(\n implementation: HarnessIface,\n): DefinedHarnessIface<Config> => {\n // The export name is unknown here; the compiler rewrites `bundle:<pending>`\n // to the module path that exported this harness.\n const binding = (config: Config): DefinedHarnessBindingIface => ({\n harness: bundleRef(PENDING_BUNDLE_EXPORT),\n config,\n definedHarness: true,\n });\n return Object.assign(binding, implementation);\n};\n\nexport const describeConfigSchema = (description: HarnessDescriptionIface): JsonSchema =>\n description.configSchema;\n"],
5
+ "mappings": "AACA,YAAY,OAAO;AACnB,SAAS,iBAAiB,wBAA8C;AACxE,SAAS,oBAAoB,+BAA+B;AAG5D,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,gBAAgB,uBAAwD;AACjF,SAAS,WAAW,yBAA2C;AAC/D,SAAS,yBAAyB,kBAAkB;AAG7C,MAAM,wBAAwB;AAO9B,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,QAAK;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAOL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,SAAM;AACN,EAAAA,kBAAA,UAAO;AACP,EAAAA,kBAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AAOL,IAAK,oBAAL,kBAAKC,uBAAL;AAEL,EAAAA,mBAAA,WAAQ;AAER,EAAAA,mBAAA,qBAAkB;AAElB,EAAAA,mBAAA,eAAY;AANF,SAAAA;AAAA,GAAA;AAUL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,SAAM;AAFI,SAAAA;AAAA,GA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6
6
  "names": ["AcpTransport", "McpTransportKind", "BaseToolProvision", "SandboxWire", "UserInstructionDelivery", "HarnessTrustClass", "PromptWhileRunning", "CredentialRoute", "routeGrantSchema"]
7
7
  }
@@ -10,6 +10,8 @@ export * from "./provider-ref.mjs";
10
10
  export * from "./sandbox/open-scope.mjs";
11
11
  export * from "./sandbox/types.mjs";
12
12
  export * from "./schemas.mjs";
13
+ export * from "./tool-annotations.mjs";
14
+ export * from "./tool-patterns.mjs";
13
15
  export * from "./channel-context.mjs";
14
16
  export * from "./semantic-events.mjs";
15
17
  export * from "./sandbox/snapshots.mjs";
@@ -17,6 +17,8 @@ export * from "./provider-ref.mjs";
17
17
  export * from "./sandbox/open-scope.mjs";
18
18
  export * from "./sandbox/types.mjs";
19
19
  export * from "./schemas.mjs";
20
+ export * from "./tool-annotations.mjs";
21
+ export * from "./tool-patterns.mjs";
20
22
  export * from "./channel-context.mjs";
21
23
  export * from "./semantic-events.mjs";
22
24
  export * from "./sandbox/snapshots.mjs";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/index.ts"],
4
- "sourcesContent": ["export {\n ProcessInspectionOperation,\n inspectedProcessSchema,\n processInspectionDetailSchema,\n processInspectionPageSchema,\n processInspectionRequestSchema,\n processInspectionResultSchema,\n type InspectedProcessIface,\n type ProcessInspectionDetailIface,\n type ProcessInspectionPageIface,\n type ProcessInspectionRequestIface,\n type ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nexport * from \"./channel.mjs\";\nexport * from \"./credentials.mjs\";\nexport * from \"./dynamic.mjs\";\nexport * from \"./harness.mjs\";\nexport * from \"./hosted-bindings.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./manifest.mjs\";\nexport * from \"./provider-ref.mjs\";\nexport * from \"./sandbox/open-scope.mjs\";\nexport * from \"./sandbox/types.mjs\";\nexport * from \"./schemas.mjs\";\n\nexport * from \"./channel-context.mjs\";\n\nexport * from \"./semantic-events.mjs\";\n\nexport * from \"./sandbox/snapshots.mjs\";\n\nexport {\n SandboxEditorOperation,\n sandboxEditorRequestSchema,\n sandboxEditorResultSchema,\n sandboxEditorSessionSchema,\n type SandboxEditorRequestIface,\n type SandboxEditorResultIface,\n type SandboxEditorSessionIface,\n} from \"./sandbox/editor.mjs\";\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;",
4
+ "sourcesContent": ["export {\n ProcessInspectionOperation,\n inspectedProcessSchema,\n processInspectionDetailSchema,\n processInspectionPageSchema,\n processInspectionRequestSchema,\n processInspectionResultSchema,\n type InspectedProcessIface,\n type ProcessInspectionDetailIface,\n type ProcessInspectionPageIface,\n type ProcessInspectionRequestIface,\n type ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nexport * from \"./channel.mjs\";\nexport * from \"./credentials.mjs\";\nexport * from \"./dynamic.mjs\";\nexport * from \"./harness.mjs\";\nexport * from \"./hosted-bindings.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./manifest.mjs\";\nexport * from \"./provider-ref.mjs\";\nexport * from \"./sandbox/open-scope.mjs\";\nexport * from \"./sandbox/types.mjs\";\nexport * from \"./schemas.mjs\";\nexport * from \"./tool-annotations.mjs\";\nexport * from \"./tool-patterns.mjs\";\n\nexport * from \"./channel-context.mjs\";\n\nexport * from \"./semantic-events.mjs\";\n\nexport * from \"./sandbox/snapshots.mjs\";\n\nexport {\n SandboxEditorOperation,\n sandboxEditorRequestSchema,\n sandboxEditorResultSchema,\n sandboxEditorSessionSchema,\n type SandboxEditorRequestIface,\n type SandboxEditorResultIface,\n type SandboxEditorSessionIface,\n} from \"./sandbox/editor.mjs\";\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,7 @@
1
1
  import * as z from 'zod';
2
2
  import { DynamicEvent } from "./dynamic.mjs";
3
+ export { agentAvatarSchema, avatarMediaSchema } from '@finalai/agent-protocol';
4
+ export type { AgentAvatarIface, AvatarMedia, AvatarState } from '@finalai/agent-protocol';
3
5
  export declare const MANIFEST_VERSION = 3;
4
6
  export declare enum BaseCapability {
5
7
  Shell = "shell",
@@ -39,7 +41,7 @@ export declare enum ScheduleDelivery {
39
41
  export declare const identitySchema: z.ZodObject<{
40
42
  name: z.ZodString;
41
43
  description: z.ZodNullable<z.ZodString>;
42
- avatarUrl: z.ZodNullable<z.ZodString>;
44
+ avatar: z.ZodOptional<z.ZodType<import("@finalai/agent-protocol").AgentAvatarIface, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-protocol").AgentAvatarIface, unknown>>>;
43
45
  }, z.core.$strip>;
44
46
  export declare enum InputApprovalKind {
45
47
  Tool = "tool",
@@ -79,6 +81,27 @@ export declare const mcpAuthSchema: z.ZodUnion<readonly [z.ZodObject<{
79
81
  }, z.core.$strip>, z.ZodObject<{
80
82
  kind: z.ZodLiteral<"final-session">;
81
83
  }, z.core.$strip>]>;
84
+ export declare const toolAnnotationSelectorSchema: z.ZodObject<{
85
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
86
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
87
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
88
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
89
+ }, z.core.$strict>;
90
+ export declare const toolAnnotationRuleSchema: z.ZodObject<{
91
+ match: z.ZodObject<{
92
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
93
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
94
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
95
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
96
+ }, z.core.$strict>;
97
+ approval: z.ZodEnum<typeof ToolApproval>;
98
+ inputApproval: z.ZodOptional<z.ZodObject<{
99
+ kind: z.ZodEnum<typeof InputApprovalKind>;
100
+ export: z.ZodString;
101
+ policyKey: z.ZodOptional<z.ZodString>;
102
+ dynamic: z.ZodOptional<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
103
+ }, z.core.$strip>>;
104
+ }, z.core.$strip>;
82
105
  export declare const workerMcpServerBindingSchema: z.ZodObject<{
83
106
  key: z.ZodString;
84
107
  kind: z.ZodLiteral<McpServerBindingKind.Worker>;
@@ -118,6 +141,28 @@ export declare const httpMcpServerBindingSchema: z.ZodObject<{
118
141
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
119
142
  approvals: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodEnum<typeof ToolApproval>>>;
120
143
  deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
144
+ load: z.ZodOptional<z.ZodArray<z.ZodString>>;
145
+ allowAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
146
+ match: z.ZodObject<{
147
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
148
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
149
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
150
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
151
+ }, z.core.$strict>;
152
+ approval: z.ZodEnum<typeof ToolApproval>;
153
+ inputApproval: z.ZodOptional<z.ZodObject<{
154
+ kind: z.ZodEnum<typeof InputApprovalKind>;
155
+ export: z.ZodString;
156
+ policyKey: z.ZodOptional<z.ZodString>;
157
+ dynamic: z.ZodOptional<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
158
+ }, z.core.$strip>>;
159
+ }, z.core.$strip>>>;
160
+ denyAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
161
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
162
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
163
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
164
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
165
+ }, z.core.$strict>>>;
121
166
  dynamicResolver: z.ZodOptional<z.ZodString>;
122
167
  inputApprovals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
123
168
  kind: z.ZodEnum<typeof InputApprovalKind>;
@@ -164,6 +209,28 @@ export declare const mcpServerBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
164
209
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
165
210
  approvals: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodEnum<typeof ToolApproval>>>;
166
211
  deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
212
+ load: z.ZodOptional<z.ZodArray<z.ZodString>>;
213
+ allowAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
214
+ match: z.ZodObject<{
215
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
216
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
217
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
218
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
219
+ }, z.core.$strict>;
220
+ approval: z.ZodEnum<typeof ToolApproval>;
221
+ inputApproval: z.ZodOptional<z.ZodObject<{
222
+ kind: z.ZodEnum<typeof InputApprovalKind>;
223
+ export: z.ZodString;
224
+ policyKey: z.ZodOptional<z.ZodString>;
225
+ dynamic: z.ZodOptional<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
226
+ }, z.core.$strip>>;
227
+ }, z.core.$strip>>>;
228
+ denyAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
229
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
230
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
231
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
232
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
233
+ }, z.core.$strict>>>;
167
234
  dynamicResolver: z.ZodOptional<z.ZodString>;
168
235
  inputApprovals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
169
236
  kind: z.ZodEnum<typeof InputApprovalKind>;
@@ -259,7 +326,7 @@ export declare const agentManifestSchema: z.ZodObject<{
259
326
  identity: z.ZodObject<{
260
327
  name: z.ZodString;
261
328
  description: z.ZodNullable<z.ZodString>;
262
- avatarUrl: z.ZodNullable<z.ZodString>;
329
+ avatar: z.ZodOptional<z.ZodType<import("@finalai/agent-protocol").AgentAvatarIface, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-protocol").AgentAvatarIface, unknown>>>;
263
330
  }, z.core.$strip>;
264
331
  harness: z.ZodObject<{
265
332
  harness: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -331,6 +398,28 @@ export declare const agentManifestSchema: z.ZodObject<{
331
398
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
332
399
  approvals: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodEnum<typeof ToolApproval>>>;
333
400
  deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
401
+ load: z.ZodOptional<z.ZodArray<z.ZodString>>;
402
+ allowAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
403
+ match: z.ZodObject<{
404
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
405
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
406
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
407
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
408
+ }, z.core.$strict>;
409
+ approval: z.ZodEnum<typeof ToolApproval>;
410
+ inputApproval: z.ZodOptional<z.ZodObject<{
411
+ kind: z.ZodEnum<typeof InputApprovalKind>;
412
+ export: z.ZodString;
413
+ policyKey: z.ZodOptional<z.ZodString>;
414
+ dynamic: z.ZodOptional<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
415
+ }, z.core.$strip>>;
416
+ }, z.core.$strip>>>;
417
+ denyAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
418
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
419
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
420
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
421
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
422
+ }, z.core.$strict>>>;
334
423
  dynamicResolver: z.ZodOptional<z.ZodString>;
335
424
  inputApprovals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
336
425
  kind: z.ZodEnum<typeof InputApprovalKind>;
@@ -424,7 +513,7 @@ export declare const resolvedAgentManifestSchema: z.ZodObject<{
424
513
  identity: z.ZodObject<{
425
514
  name: z.ZodString;
426
515
  description: z.ZodNullable<z.ZodString>;
427
- avatarUrl: z.ZodNullable<z.ZodString>;
516
+ avatar: z.ZodOptional<z.ZodType<import("@finalai/agent-protocol").AgentAvatarIface, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-protocol").AgentAvatarIface, unknown>>>;
428
517
  }, z.core.$strip>;
429
518
  tools: z.ZodObject<{
430
519
  base: z.ZodRecord<z.ZodEnum<typeof BaseCapability> & z.core.$partial, z.ZodObject<{
@@ -519,6 +608,28 @@ export declare const resolvedAgentManifestSchema: z.ZodObject<{
519
608
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
520
609
  approvals: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodEnum<typeof ToolApproval>>>;
521
610
  deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
611
+ load: z.ZodOptional<z.ZodArray<z.ZodString>>;
612
+ allowAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
613
+ match: z.ZodObject<{
614
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
615
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
616
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
617
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
618
+ }, z.core.$strict>;
619
+ approval: z.ZodEnum<typeof ToolApproval>;
620
+ inputApproval: z.ZodOptional<z.ZodObject<{
621
+ kind: z.ZodEnum<typeof InputApprovalKind>;
622
+ export: z.ZodString;
623
+ policyKey: z.ZodOptional<z.ZodString>;
624
+ dynamic: z.ZodOptional<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
625
+ }, z.core.$strip>>;
626
+ }, z.core.$strip>>>;
627
+ denyAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
628
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
629
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
630
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
631
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
632
+ }, z.core.$strict>>>;
522
633
  dynamicResolver: z.ZodOptional<z.ZodString>;
523
634
  inputApprovals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
524
635
  kind: z.ZodEnum<typeof InputApprovalKind>;
@@ -545,6 +656,8 @@ export type ToolDescriptorIface = z.infer<typeof toolDescriptorSchema>;
545
656
  export type McpAuth = z.infer<typeof mcpAuthSchema>;
546
657
  export type WorkerMcpServerBindingIface = z.infer<typeof workerMcpServerBindingSchema>;
547
658
  export type HttpMcpServerBindingIface = z.infer<typeof httpMcpServerBindingSchema>;
659
+ export type ToolAnnotationSelectorIface = z.infer<typeof toolAnnotationSelectorSchema>;
660
+ export type ToolAnnotationRuleIface = z.infer<typeof toolAnnotationRuleSchema>;
548
661
  export type McpServerBinding = z.infer<typeof mcpServerBindingSchema>;
549
662
  export type SandboxBindingIface = z.infer<typeof sandboxBindingSchema>;
550
663
  export type BaseToolsIface = z.infer<typeof baseToolsSchema>;
@@ -1,7 +1,9 @@
1
1
  import * as z from "zod";
2
+ import { agentAvatarSchema } from "@finalai/agent-protocol";
2
3
  import { containsDynamicSlot, DynamicEvent, maybeDynamic } from "./dynamic.mjs";
3
4
  import { jsonObjectSchema, jsonSchemaSchema, jsonValueSchema } from "./json.mjs";
4
5
  import { packageRef, providerRefSchema } from "./provider-ref.mjs";
6
+ import { agentAvatarSchema as agentAvatarSchema2, avatarMediaSchema } from "@finalai/agent-protocol";
5
7
  const MANIFEST_VERSION = 3;
6
8
  var BaseCapability = /* @__PURE__ */ ((BaseCapability2) => {
7
9
  BaseCapability2["Shell"] = "shell";
@@ -53,7 +55,7 @@ var ScheduleDelivery = /* @__PURE__ */ ((ScheduleDelivery2) => {
53
55
  const identitySchema = z.object({
54
56
  name: z.string().min(1).max(120),
55
57
  description: z.string().max(2e3).nullable(),
56
- avatarUrl: z.string().url().nullable()
58
+ avatar: agentAvatarSchema.optional()
57
59
  });
58
60
  var InputApprovalKind = /* @__PURE__ */ ((InputApprovalKind2) => {
59
61
  InputApprovalKind2["Tool"] = "tool";
@@ -91,6 +93,17 @@ const mcpAuthSchema = z.union([
91
93
  z.object({ kind: z.literal("final-session") })
92
94
  ]);
93
95
  const toolApprovalsSchema = z.record(z.string(), z.nativeEnum(ToolApproval)).nullable();
96
+ const toolAnnotationSelectorSchema = z.strictObject({
97
+ readOnlyHint: z.boolean().optional(),
98
+ destructiveHint: z.boolean().optional(),
99
+ idempotentHint: z.boolean().optional(),
100
+ openWorldHint: z.boolean().optional()
101
+ }).refine((selector) => Object.keys(selector).length > 0, "Select at least one annotation");
102
+ const toolAnnotationRuleSchema = z.object({
103
+ match: toolAnnotationSelectorSchema,
104
+ approval: z.nativeEnum(ToolApproval),
105
+ inputApproval: inputApprovalSchema.optional()
106
+ });
94
107
  const workerMcpServerBindingSchema = z.object({
95
108
  key: z.string().min(1),
96
109
  kind: z.literal("worker" /* Worker */),
@@ -104,9 +117,19 @@ const httpMcpServerBindingSchema = z.object({
104
117
  auth: mcpAuthSchema.nullable(),
105
118
  headers: z.record(z.string(), z.string()).default({}),
106
119
  // Null allows every tool the server lists, each with the default approval.
120
+ // Keys are tool names or `*` patterns (./tool-patterns.ts); the most
121
+ // specific matching key governs a tool.
107
122
  approvals: toolApprovalsSchema,
108
- // Tools hidden even when `approvals` would expose them.
123
+ // Tool names or `*` patterns hidden even when `approvals` would expose them.
109
124
  deny: z.array(z.string().min(1)).optional(),
125
+ // Exposed tools (names or `*` patterns) the harness lists up front. Absent
126
+ // lists every exposed tool; otherwise the host keeps the rest reachable
127
+ // through search (HOSTING.md).
128
+ load: z.array(z.string().min(1)).optional(),
129
+ // Tools also exposed by their MCP annotations; named tools keep `approvals`.
130
+ allowAnnotations: z.array(toolAnnotationRuleSchema).optional(),
131
+ // Tools hidden by their MCP annotations, whatever else exposes them.
132
+ denyAnnotations: z.array(toolAnnotationSelectorSchema).optional(),
110
133
  // The authored resolver that produced this connection, for retained boundary values.
111
134
  dynamicResolver: z.string().min(1).optional(),
112
135
  inputApprovals: z.record(z.string(), inputApprovalSchema).optional()
@@ -215,7 +238,7 @@ const skillBundleSchema = z.object({
215
238
  });
216
239
  const emptyManifest = (name) => ({
217
240
  version: MANIFEST_VERSION,
218
- identity: { name, description: null, avatarUrl: null },
241
+ identity: { name, description: null },
219
242
  harness: {
220
243
  harness: packageRef("@finalai/final-agent-provider/harnesses/serverless-final"),
221
244
  config: {}
@@ -241,7 +264,9 @@ export {
241
264
  ScheduleDelivery,
242
265
  ScheduleTarget,
243
266
  ToolApproval,
267
+ agentAvatarSchema2 as agentAvatarSchema,
244
268
  agentManifestSchema,
269
+ avatarMediaSchema,
245
270
  baseToolsSchema,
246
271
  bundleSchema,
247
272
  channelBindingSchema,
@@ -261,6 +286,8 @@ export {
261
286
  scheduleDefinitionSchema,
262
287
  skillBundleSchema,
263
288
  skillFileSchema,
289
+ toolAnnotationRuleSchema,
290
+ toolAnnotationSelectorSchema,
264
291
  toolDescriptorSchema,
265
292
  workerMcpServerBindingSchema
266
293
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/manifest.ts"],
4
- "sourcesContent": ["import * as z from 'zod';\nimport { containsDynamicSlot, DynamicEvent, maybeDynamic } from \"./dynamic.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema, jsonValueSchema } from \"./json.mjs\";\nimport { packageRef, providerRefSchema } from \"./provider-ref.mjs\";\n\n// The Agent Manifest. It lives in the provider contract\n// package because it is what harnesses, sandboxes and channels receive;\n// @finalai/agent-definition compiles directories into it and re-exports it.\n//\n// A harness owns its loop, native tools, prompt assembly, models, permission\n// modes, memory and compaction: all of that is `harness.config`, typed by the\n// harness's own configSchema. What ACP standardizes (MCP servers, prompts,\n// permissions, cancellation) is session input, identical for every harness.\n\nexport const MANIFEST_VERSION = 3;\n\n// Base tool capability classes, one to one with sandbox handle capabilities.\nexport enum BaseCapability {\n Shell = 'shell',\n Files = 'files',\n Process = 'process',\n Ports = 'ports',\n Browser = 'browser',\n ComputerUse = 'computerUse',\n}\n\nexport enum ToolApproval {\n Allow = 'allow',\n Ask = 'ask',\n}\n\n// What a session may do on a sandbox target: read files; also run\n// processes (execute, without file writes); or everything (write).\nexport enum SandboxAccess {\n Read = 'read',\n Execute = 'execute',\n Write = 'write',\n}\n\nconst SANDBOX_ACCESS_RANK = {\n [SandboxAccess.Read]: 0,\n [SandboxAccess.Execute]: 1,\n [SandboxAccess.Write]: 2,\n} satisfies Record<SandboxAccess, number>;\n\n// Each access includes the ones before it: read < execute < write.\nexport const sandboxAccessAtLeast = (access: SandboxAccess, floor: SandboxAccess): boolean =>\n SANDBOX_ACCESS_RANK[access] >= SANDBOX_ACCESS_RANK[floor];\n\nexport const narrowerSandboxAccess = (a: SandboxAccess, b: SandboxAccess): SandboxAccess =>\n SANDBOX_ACCESS_RANK[a] <= SANDBOX_ACCESS_RANK[b] ? a : b;\n\nexport enum SandboxAttach {\n Lazy = 'lazy',\n OnPrompt = 'on-prompt',\n}\n\nexport enum McpServerBindingKind {\n // Authored tools, served from the agent's Worker isolate behind the MCP host.\n Worker = 'worker',\n Http = 'http',\n}\n\nexport enum ScheduleTarget {\n OwnerDirect = 'owner-direct',\n BoundConversation = 'bound-conversation',\n}\n\n// Whether a schedule's firing must get a visible reply. Values match the schedules API.\nexport enum ScheduleDelivery {\n Always = 'always',\n // The agent replies only when there is something to say; an empty turn posts nothing.\n IfNeeded = 'if_needed',\n}\n\nexport const identitySchema = z.object({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n avatarUrl: z.string().url().nullable(),\n});\n\nexport enum InputApprovalKind {\n Tool = 'tool',\n Connection = 'connection',\n}\n\nexport const inputApprovalSchema = z.object({\n kind: z.nativeEnum(InputApprovalKind),\n export: z.string().min(1),\n // Connection default when absent; otherwise tools.approval[policyKey].\n policyKey: z.string().min(1).optional(),\n dynamic: jsonObjectSchema.optional(),\n});\nexport type InputApprovalIface = z.infer<typeof inputApprovalSchema>;\n\n// Tool descriptors are stored statically so `tools/list` never needs the isolate.\nexport const toolDescriptorSchema = z.object({\n name: z.string().min(1),\n description: z.string(),\n inputSchema: jsonSchemaSchema,\n outputSchema: jsonSchemaSchema.optional(),\n annotations: z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .optional(),\n // Bundle export implementing it ('tools/lookup_release_notes').\n export: z.string().min(1).optional(),\n // Boundary snapshot used to reconstruct dynamic tools after isolate eviction.\n dynamic: jsonObjectSchema.optional(),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const mcpAuthSchema = z.union([\n z.object({ secretKey: z.string().min(1), headerName: z.string().min(1).nullable() }),\n // Resolved by the broker to a session-scoped grant (Final's own MCP server).\n z.object({ kind: z.literal('final-session') }),\n]);\n\nconst toolApprovalsSchema = z.record(z.string(), z.nativeEnum(ToolApproval)).nullable();\n\nexport const workerMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Worker),\n tools: z.array(toolDescriptorSchema),\n approvals: toolApprovalsSchema,\n});\n\nexport const httpMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Http),\n url: z.string().url(),\n auth: mcpAuthSchema.nullable(),\n headers: z.record(z.string(), z.string()).default({}),\n // Null allows every tool the server lists, each with the default approval.\n approvals: toolApprovalsSchema,\n // Tools hidden even when `approvals` would expose them.\n deny: z.array(z.string().min(1)).optional(),\n // The authored resolver that produced this connection, for retained boundary values.\n dynamicResolver: z.string().min(1).optional(),\n inputApprovals: z.record(z.string(), inputApprovalSchema).optional(),\n});\n\nexport const mcpServerBindingSchema = z.discriminatedUnion('kind', [\n workerMcpServerBindingSchema,\n httpMcpServerBindingSchema,\n]);\n\nexport const sandboxBindingSchema = z.object({\n provider: providerRefSchema,\n // Provider-defined environment options (`computer`: a setup guide reference or\n // inline guide plus start-time parameters). Validated by the provider.\n environment: maybeDynamic(jsonValueSchema),\n access: z.nativeEnum(SandboxAccess).default(SandboxAccess.Write),\n attach: z.nativeEnum(SandboxAttach).default(SandboxAttach.Lazy),\n});\n\nexport const baseToolsSchema = z.object({\n base: z.partialRecord(z.nativeEnum(BaseCapability), z.object({ target: z.string().min(1) })),\n // Capabilities declared on the harness's own host with no sandbox target\n // (`baseTools({ shell: harnessHost })`): only a harness that\n // provides them natively (host-disableable, host-fixed) can serve them.\n host: z.array(z.nativeEnum(BaseCapability)).optional(),\n});\n\nexport const channelBindingSchema = z.object({\n // Stable within the definition; publish maps it to a binding id.\n key: z.string().min(1),\n channel: providerRefSchema,\n config: jsonObjectSchema.default({}),\n source: z.string().optional(),\n});\n\nexport const hookBindingSchema = z.object({\n slug: z.string().min(1),\n export: z.string().min(1),\n events: z.array(z.string().min(1)).min(1),\n});\n\nexport const scheduleDefinitionSchema = z.object({\n key: z.string().min(1),\n cron: z.string().min(1),\n timezone: z.string().min(1),\n prompt: z.string().min(1),\n target: z.nativeEnum(ScheduleTarget),\n});\n\nexport const bundleSchema = z.object({\n // Absent on historical revisions: the host must inspect their resources.\n hasPreparationFiles: z.boolean().optional(),\n hash: z.string().min(1),\n // Dynamic slot path \u2192 resolver export and events.\n resolvers: z.record(\n z.string(),\n z.object({ export: z.string().min(1), events: z.array(z.nativeEnum(DynamicEvent)).min(1) }),\n ),\n});\n\nexport const harnessBindingSchema = z.object({\n harness: providerRefSchema,\n // Validated against the harness's configSchema; may contain dynamic slots at\n // any depth (an instruction fragment, the model).\n config: maybeDynamic(jsonValueSchema),\n});\n\nexport const agentManifestSchema = z.object({\n // Read persisted v2 revisions; v3 writers require hosts enforcing hosted bindings.\n version: z.union([z.literal(2), z.literal(MANIFEST_VERSION)]),\n identity: identitySchema,\n harness: harnessBindingSchema,\n mcpServers: maybeDynamic(z.array(mcpServerBindingSchema)),\n sandboxes: maybeDynamic(z.record(z.string(), sandboxBindingSchema)),\n tools: baseToolsSchema,\n toolPolicy: z.record(z.string(), z.nativeEnum(ToolApproval)),\n // Organization secrets this agent may read, by name (`secrets.get`,\n // MCP `secretKey`, `apiKey({ secret })`). Nothing else is readable;\n // binding organization secrets requires an organization admin at publish.\n secrets: z.array(z.string().min(1)).default([]),\n channels: z.array(channelBindingSchema),\n channelSources: z\n .record(z.string(), z.object({ path: z.string(), source: z.string(), disabled: z.boolean() }))\n .optional(),\n hooks: z.array(hookBindingSchema),\n schedules: z.array(scheduleDefinitionSchema),\n bundle: bundleSchema.nullable(),\n});\n\n// What one session actually got: every dynamic slot replaced by its resolved\n// value (stored in agent.session_manifests).\nexport const resolvedAgentManifestSchema = agentManifestSchema\n .extend({\n harness: z.object({ harness: providerRefSchema, config: jsonValueSchema }),\n mcpServers: z.array(mcpServerBindingSchema),\n sandboxes: z.record(z.string(), sandboxBindingSchema.extend({ environment: jsonValueSchema })),\n })\n .superRefine((manifest, ctx) => {\n if (containsDynamicSlot(manifest)) {\n ctx.addIssue({\n code: 'custom',\n message: 'a resolved manifest must not contain dynamic slots',\n });\n }\n });\n\nexport type IdentityIface = z.infer<typeof identitySchema>;\nexport type ToolDescriptorIface = z.infer<typeof toolDescriptorSchema>;\nexport type McpAuth = z.infer<typeof mcpAuthSchema>;\nexport type WorkerMcpServerBindingIface = z.infer<typeof workerMcpServerBindingSchema>;\nexport type HttpMcpServerBindingIface = z.infer<typeof httpMcpServerBindingSchema>;\nexport type McpServerBinding = z.infer<typeof mcpServerBindingSchema>;\nexport type SandboxBindingIface = z.infer<typeof sandboxBindingSchema>;\nexport type BaseToolsIface = z.infer<typeof baseToolsSchema>;\nexport type ChannelBindingIface = z.infer<typeof channelBindingSchema>;\nexport type HookBindingIface = z.infer<typeof hookBindingSchema>;\nexport type ScheduleDefinitionIface = z.infer<typeof scheduleDefinitionSchema>;\nexport type BundleIface = z.infer<typeof bundleSchema>;\nexport type HarnessBindingIface = z.infer<typeof harnessBindingSchema>;\nexport type AgentManifestIface = z.infer<typeof agentManifestSchema>;\nexport type ResolvedAgentManifestIface = z.infer<typeof resolvedAgentManifestSchema>;\nexport type ResolvedSandboxBindingIface = ResolvedAgentManifestIface['sandboxes'][string];\n\n// The fields of a harness config the platform itself reads through the shared\n// schema fragments; everything else is opaque to the platform.\nexport enum InstructionRole {\n System = 'system',\n User = 'user',\n}\n\nexport const instructionFragmentSchema = z.object({\n role: z.nativeEnum(InstructionRole),\n content: z.string(),\n // Source file, for the compatibility report and Build.\n source: z.string().optional(),\n});\n\nexport const skillFileSchema = z.object({ path: z.string().min(1), content: z.string() });\nexport const skillBundleSchema = z.object({\n key: z.string().min(1),\n description: z.string().optional(),\n files: z.array(skillFileSchema),\n});\n\nexport type InstructionFragmentIface = z.infer<typeof instructionFragmentSchema>;\nexport type SkillBundleIface = z.infer<typeof skillBundleSchema>;\n\nexport const emptyManifest = (name: string): AgentManifestIface => ({\n version: MANIFEST_VERSION,\n identity: { name, description: null, avatarUrl: null },\n harness: {\n harness: packageRef('@finalai/final-agent-provider/harnesses/serverless-final'),\n config: {},\n },\n mcpServers: [],\n sandboxes: {},\n tools: { base: {} },\n toolPolicy: {},\n secrets: [],\n channels: [],\n hooks: [],\n schedules: [],\n bundle: null,\n});\n"],
5
- "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,qBAAqB,cAAc,oBAAoB;AAChE,SAAS,kBAAkB,kBAAkB,uBAAuB;AACpE,SAAS,YAAY,yBAAyB;AAWvC,MAAM,mBAAmB;AAGzB,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,iBAAc;AANJ,SAAAA;AAAA,GAAA;AASL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,SAAM;AAFI,SAAAA;AAAA,GAAA;AAOL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,aAAU;AACV,EAAAA,eAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AAMZ,MAAM,sBAAsB;AAAA,EAC1B,CAAC,iBAAkB,GAAG;AAAA,EACtB,CAAC,uBAAqB,GAAG;AAAA,EACzB,CAA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EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC;AACjF,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACrB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,EAAE,MAAM,eAAe;AAChC,CAAC;AAKM,MAAM,gBAAgB,CAAC,UAAsC;AAAA,EAClE,SAAS;AAAA,EACT,UAAU,EAAE,MAAM,aAAa,MAAM,WAAW,KAAK;AAAA,EACrD,SAAS;AAAA,IACP,SAAS,WAAW,0DAA0D;AAAA,IAC9E,QAAQ,CAAC;AAAA,EACX;AAAA,EACA,YAAY,CAAC;AAAA,EACb,WAAW,CAAC;AAAA,EACZ,OAAO,EAAE,MAAM,CAAC,EAAE;AAAA,EAClB,YAAY,CAAC;AAAA,EACb,SAAS,CAAC;AAAA,EACV,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AAAA,EACR,WAAW,CAAC;AAAA,EACZ,QAAQ;AACV;",
6
- "names": ["BaseCapability", "ToolApproval", "SandboxAccess", "SandboxAttach", "McpServerBindingKind", "ScheduleTarget", "ScheduleDelivery", "InputApprovalKind", "InstructionRole"]
4
+ "sourcesContent": ["import * as z from 'zod';\nimport { agentAvatarSchema } from '@finalai/agent-protocol';\nimport { containsDynamicSlot, DynamicEvent, maybeDynamic } from \"./dynamic.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema, jsonValueSchema } from \"./json.mjs\";\nimport { packageRef, providerRefSchema } from \"./provider-ref.mjs\";\n\nexport { agentAvatarSchema, avatarMediaSchema } from '@finalai/agent-protocol';\nexport type { AgentAvatarIface, AvatarMedia, AvatarState } from '@finalai/agent-protocol';\n\n// The Agent Manifest. It lives in the provider contract\n// package because it is what harnesses, sandboxes and channels receive;\n// @finalai/agent-definition compiles directories into it and re-exports it.\n//\n// A harness owns its loop, native tools, prompt assembly, models, permission\n// modes, memory and compaction: all of that is `harness.config`, typed by the\n// harness's own configSchema. What ACP standardizes (MCP servers, prompts,\n// permissions, cancellation) is session input, identical for every harness.\n\nexport const MANIFEST_VERSION = 3;\n\n// Base tool capability classes, one to one with sandbox handle capabilities.\nexport enum BaseCapability {\n Shell = 'shell',\n Files = 'files',\n Process = 'process',\n Ports = 'ports',\n Browser = 'browser',\n ComputerUse = 'computerUse',\n}\n\nexport enum ToolApproval {\n Allow = 'allow',\n Ask = 'ask',\n}\n\n// What a session may do on a sandbox target: read files; also run\n// processes (execute, without file writes); or everything (write).\nexport enum SandboxAccess {\n Read = 'read',\n Execute = 'execute',\n Write = 'write',\n}\n\nconst SANDBOX_ACCESS_RANK = {\n [SandboxAccess.Read]: 0,\n [SandboxAccess.Execute]: 1,\n [SandboxAccess.Write]: 2,\n} satisfies Record<SandboxAccess, number>;\n\n// Each access includes the ones before it: read < execute < write.\nexport const sandboxAccessAtLeast = (access: SandboxAccess, floor: SandboxAccess): boolean =>\n SANDBOX_ACCESS_RANK[access] >= SANDBOX_ACCESS_RANK[floor];\n\nexport const narrowerSandboxAccess = (a: SandboxAccess, b: SandboxAccess): SandboxAccess =>\n SANDBOX_ACCESS_RANK[a] <= SANDBOX_ACCESS_RANK[b] ? a : b;\n\nexport enum SandboxAttach {\n Lazy = 'lazy',\n OnPrompt = 'on-prompt',\n}\n\nexport enum McpServerBindingKind {\n // Authored tools, served from the agent's Worker isolate behind the MCP host.\n Worker = 'worker',\n Http = 'http',\n}\n\nexport enum ScheduleTarget {\n OwnerDirect = 'owner-direct',\n BoundConversation = 'bound-conversation',\n}\n\n// Whether a schedule's firing must get a visible reply. Values match the schedules API.\nexport enum ScheduleDelivery {\n Always = 'always',\n // The agent replies only when there is something to say; an empty turn posts nothing.\n IfNeeded = 'if_needed',\n}\n\nexport const identitySchema = z.object({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n avatar: agentAvatarSchema.optional(),\n});\n\nexport enum InputApprovalKind {\n Tool = 'tool',\n Connection = 'connection',\n}\n\nexport const inputApprovalSchema = z.object({\n kind: z.nativeEnum(InputApprovalKind),\n export: z.string().min(1),\n // Connection default when absent; otherwise tools.approval[policyKey].\n policyKey: z.string().min(1).optional(),\n dynamic: jsonObjectSchema.optional(),\n});\nexport type InputApprovalIface = z.infer<typeof inputApprovalSchema>;\n\n// Tool descriptors are stored statically so `tools/list` never needs the isolate.\nexport const toolDescriptorSchema = z.object({\n name: z.string().min(1),\n description: z.string(),\n inputSchema: jsonSchemaSchema,\n outputSchema: jsonSchemaSchema.optional(),\n annotations: z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .optional(),\n // Bundle export implementing it ('tools/lookup_release_notes').\n export: z.string().min(1).optional(),\n // Boundary snapshot used to reconstruct dynamic tools after isolate eviction.\n dynamic: jsonObjectSchema.optional(),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const mcpAuthSchema = z.union([\n z.object({ secretKey: z.string().min(1), headerName: z.string().min(1).nullable() }),\n // Resolved by the broker to a session-scoped grant (Final's own MCP server).\n z.object({ kind: z.literal('final-session') }),\n]);\n\nconst toolApprovalsSchema = z.record(z.string(), z.nativeEnum(ToolApproval)).nullable();\n\n// MCP tool annotation hints a connection policy selects on (./tool-annotations.ts).\nexport const toolAnnotationSelectorSchema = z\n .strictObject({\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .refine((selector) => Object.keys(selector).length > 0, 'Select at least one annotation');\n\n// Tools exposed because their annotations match, with the approval (and the\n// connection default's input predicate) they run under.\nexport const toolAnnotationRuleSchema = z.object({\n match: toolAnnotationSelectorSchema,\n approval: z.nativeEnum(ToolApproval),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const workerMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Worker),\n tools: z.array(toolDescriptorSchema),\n approvals: toolApprovalsSchema,\n});\n\nexport const httpMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Http),\n url: z.string().url(),\n auth: mcpAuthSchema.nullable(),\n headers: z.record(z.string(), z.string()).default({}),\n // Null allows every tool the server lists, each with the default approval.\n // Keys are tool names or `*` patterns (./tool-patterns.ts); the most\n // specific matching key governs a tool.\n approvals: toolApprovalsSchema,\n // Tool names or `*` patterns hidden even when `approvals` would expose them.\n deny: z.array(z.string().min(1)).optional(),\n // Exposed tools (names or `*` patterns) the harness lists up front. Absent\n // lists every exposed tool; otherwise the host keeps the rest reachable\n // through search (HOSTING.md).\n load: z.array(z.string().min(1)).optional(),\n // Tools also exposed by their MCP annotations; named tools keep `approvals`.\n allowAnnotations: z.array(toolAnnotationRuleSchema).optional(),\n // Tools hidden by their MCP annotations, whatever else exposes them.\n denyAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n // The authored resolver that produced this connection, for retained boundary values.\n dynamicResolver: z.string().min(1).optional(),\n inputApprovals: z.record(z.string(), inputApprovalSchema).optional(),\n});\n\nexport const mcpServerBindingSchema = z.discriminatedUnion('kind', [\n workerMcpServerBindingSchema,\n httpMcpServerBindingSchema,\n]);\n\nexport const sandboxBindingSchema = z.object({\n provider: providerRefSchema,\n // Provider-defined environment options (`computer`: a setup guide reference or\n // inline guide plus start-time parameters). Validated by the provider.\n environment: maybeDynamic(jsonValueSchema),\n access: z.nativeEnum(SandboxAccess).default(SandboxAccess.Write),\n attach: z.nativeEnum(SandboxAttach).default(SandboxAttach.Lazy),\n});\n\nexport const baseToolsSchema = z.object({\n base: z.partialRecord(z.nativeEnum(BaseCapability), z.object({ target: z.string().min(1) })),\n // Capabilities declared on the harness's own host with no sandbox target\n // (`baseTools({ shell: harnessHost })`): only a harness that\n // provides them natively (host-disableable, host-fixed) can serve them.\n host: z.array(z.nativeEnum(BaseCapability)).optional(),\n});\n\nexport const channelBindingSchema = z.object({\n // Stable within the definition; publish maps it to a binding id.\n key: z.string().min(1),\n channel: providerRefSchema,\n config: jsonObjectSchema.default({}),\n source: z.string().optional(),\n});\n\nexport const hookBindingSchema = z.object({\n slug: z.string().min(1),\n export: z.string().min(1),\n events: z.array(z.string().min(1)).min(1),\n});\n\nexport const scheduleDefinitionSchema = z.object({\n key: z.string().min(1),\n cron: z.string().min(1),\n timezone: z.string().min(1),\n prompt: z.string().min(1),\n target: z.nativeEnum(ScheduleTarget),\n});\n\nexport const bundleSchema = z.object({\n // Absent on historical revisions: the host must inspect their resources.\n hasPreparationFiles: z.boolean().optional(),\n hash: z.string().min(1),\n // Dynamic slot path \u2192 resolver export and events.\n resolvers: z.record(\n z.string(),\n z.object({ export: z.string().min(1), events: z.array(z.nativeEnum(DynamicEvent)).min(1) }),\n ),\n});\n\nexport const harnessBindingSchema = z.object({\n harness: providerRefSchema,\n // Validated against the harness's configSchema; may contain dynamic slots at\n // any depth (an instruction fragment, the model).\n config: maybeDynamic(jsonValueSchema),\n});\n\nexport const agentManifestSchema = z.object({\n // Read persisted v2 revisions; v3 writers require hosts enforcing hosted bindings.\n version: z.union([z.literal(2), z.literal(MANIFEST_VERSION)]),\n identity: identitySchema,\n harness: harnessBindingSchema,\n mcpServers: maybeDynamic(z.array(mcpServerBindingSchema)),\n sandboxes: maybeDynamic(z.record(z.string(), sandboxBindingSchema)),\n tools: baseToolsSchema,\n toolPolicy: z.record(z.string(), z.nativeEnum(ToolApproval)),\n // Organization secrets this agent may read, by name (`secrets.get`,\n // MCP `secretKey`, `apiKey({ secret })`). Nothing else is readable;\n // binding organization secrets requires an organization admin at publish.\n secrets: z.array(z.string().min(1)).default([]),\n channels: z.array(channelBindingSchema),\n channelSources: z\n .record(z.string(), z.object({ path: z.string(), source: z.string(), disabled: z.boolean() }))\n .optional(),\n hooks: z.array(hookBindingSchema),\n schedules: z.array(scheduleDefinitionSchema),\n bundle: bundleSchema.nullable(),\n});\n\n// What one session actually got: every dynamic slot replaced by its resolved\n// value (stored in agent.session_manifests).\nexport const resolvedAgentManifestSchema = agentManifestSchema\n .extend({\n harness: z.object({ harness: providerRefSchema, config: jsonValueSchema }),\n mcpServers: z.array(mcpServerBindingSchema),\n sandboxes: z.record(z.string(), sandboxBindingSchema.extend({ environment: jsonValueSchema })),\n })\n .superRefine((manifest, ctx) => {\n if (containsDynamicSlot(manifest)) {\n ctx.addIssue({\n code: 'custom',\n message: 'a resolved manifest must not contain dynamic slots',\n });\n }\n });\n\nexport type IdentityIface = z.infer<typeof identitySchema>;\nexport type ToolDescriptorIface = z.infer<typeof toolDescriptorSchema>;\nexport type McpAuth = z.infer<typeof mcpAuthSchema>;\nexport type WorkerMcpServerBindingIface = z.infer<typeof workerMcpServerBindingSchema>;\nexport type HttpMcpServerBindingIface = z.infer<typeof httpMcpServerBindingSchema>;\nexport type ToolAnnotationSelectorIface = z.infer<typeof toolAnnotationSelectorSchema>;\nexport type ToolAnnotationRuleIface = z.infer<typeof toolAnnotationRuleSchema>;\nexport type McpServerBinding = z.infer<typeof mcpServerBindingSchema>;\nexport type SandboxBindingIface = z.infer<typeof sandboxBindingSchema>;\nexport type BaseToolsIface = z.infer<typeof baseToolsSchema>;\nexport type ChannelBindingIface = z.infer<typeof channelBindingSchema>;\nexport type HookBindingIface = z.infer<typeof hookBindingSchema>;\nexport type ScheduleDefinitionIface = z.infer<typeof scheduleDefinitionSchema>;\nexport type BundleIface = z.infer<typeof bundleSchema>;\nexport type HarnessBindingIface = z.infer<typeof harnessBindingSchema>;\nexport type AgentManifestIface = z.infer<typeof agentManifestSchema>;\nexport type ResolvedAgentManifestIface = z.infer<typeof resolvedAgentManifestSchema>;\nexport type ResolvedSandboxBindingIface = ResolvedAgentManifestIface['sandboxes'][string];\n\n// The fields of a harness config the platform itself reads through the shared\n// schema fragments; everything else is opaque to the platform.\nexport enum InstructionRole {\n System = 'system',\n User = 'user',\n}\n\nexport const instructionFragmentSchema = z.object({\n role: z.nativeEnum(InstructionRole),\n content: z.string(),\n // Source file, for the compatibility report and Build.\n source: z.string().optional(),\n});\n\nexport const skillFileSchema = z.object({ path: z.string().min(1), content: z.string() });\nexport const skillBundleSchema = z.object({\n key: z.string().min(1),\n description: z.string().optional(),\n files: z.array(skillFileSchema),\n});\n\nexport type InstructionFragmentIface = z.infer<typeof instructionFragmentSchema>;\nexport type SkillBundleIface = z.infer<typeof skillBundleSchema>;\n\nexport const emptyManifest = (name: string): AgentManifestIface => ({\n version: MANIFEST_VERSION,\n identity: { name, description: null },\n harness: {\n harness: packageRef('@finalai/final-agent-provider/harnesses/serverless-final'),\n config: {},\n },\n mcpServers: [],\n sandboxes: {},\n tools: { base: {} },\n toolPolicy: {},\n secrets: [],\n channels: [],\n hooks: [],\n schedules: [],\n bundle: null,\n});\n"],
5
+ "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,yBAAyB;AAClC,SAAS,qBAAqB,cAAc,oBAAoB;AAChE,SAAS,kBAAkB,kBAAkB,uBAAuB;AACpE,SAAS,YAAY,yBAAyB;AAE9C,SAAS,qBAAAA,oBAAmB,yBAAyB;AAY9C,MAAM,mBAAmB;AAGzB,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,iBAAc;AANJ,SAAAA;AAAA,GAAA;AASL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,SAAM;AAFI,SAAAA;AAAA,GAAA;AAOL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,aAAU;AACV,EAAAA,eAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AAMZ,MAAM,sBAAsB;AAAA,EAC1B,CAAC,iBAAkB,GAAG;AAAA,EACtB,CAAC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EACX,OAAO,CAAC;AAAA,EACR,WAAW,CAAC;AAAA,EACZ,QAAQ;AACV;",
6
+ "names": ["agentAvatarSchema", "BaseCapability", "ToolApproval", "SandboxAccess", "SandboxAttach", "McpServerBindingKind", "ScheduleTarget", "ScheduleDelivery", "InputApprovalKind", "InstructionRole"]
7
7
  }
@@ -0,0 +1,7 @@
1
+ import type { HttpMcpServerBindingIface, ToolAnnotationRuleIface, ToolAnnotationSelectorIface, ToolDescriptorIface } from "./manifest.mjs";
2
+ export type ToolAnnotationsIface = NonNullable<ToolDescriptorIface['annotations']>;
3
+ export declare const toolAnnotationsMatch: (selector: ToolAnnotationSelectorIface, annotations: ToolAnnotationsIface | undefined) => boolean;
4
+ type AnnotationPolicyIface = Pick<HttpMcpServerBindingIface, 'allowAnnotations' | 'denyAnnotations'>;
5
+ export declare const isToolHiddenByAnnotations: (binding: AnnotationPolicyIface, annotations: ToolAnnotationsIface | undefined) => boolean;
6
+ export declare const toolAnnotationRuleFor: (binding: AnnotationPolicyIface, annotations: ToolAnnotationsIface | undefined) => ToolAnnotationRuleIface | undefined;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ const hintMatches = (wanted, actual, fallback) => wanted == null || (actual ?? fallback) === wanted;
2
+ const toolAnnotationsMatch = (selector, annotations) => hintMatches(selector.readOnlyHint, annotations?.readOnlyHint, false) && hintMatches(selector.destructiveHint, annotations?.destructiveHint, true) && hintMatches(selector.idempotentHint, annotations?.idempotentHint, false) && hintMatches(selector.openWorldHint, annotations?.openWorldHint, true);
3
+ const isToolHiddenByAnnotations = (binding, annotations) => binding.denyAnnotations?.some((selector) => toolAnnotationsMatch(selector, annotations)) === true;
4
+ const toolAnnotationRuleFor = (binding, annotations) => binding.allowAnnotations?.find((rule) => toolAnnotationsMatch(rule.match, annotations));
5
+ export {
6
+ isToolHiddenByAnnotations,
7
+ toolAnnotationRuleFor,
8
+ toolAnnotationsMatch
9
+ };
10
+ //# sourceMappingURL=tool-annotations.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/tool-annotations.ts"],
4
+ "sourcesContent": ["import type {\n HttpMcpServerBindingIface,\n ToolAnnotationRuleIface,\n ToolAnnotationSelectorIface,\n ToolDescriptorIface,\n} from \"./manifest.mjs\";\n\n// Selecting connection tools by their MCP annotations. A selector matches when\n// every hint it sets equals the tool's hint, reading a hint the tool omits as\n// the MCP spec's default (not read-only, destructive, not idempotent, open\n// world), so an unannotated tool never passes `{ readOnlyHint: true }`.\n// Annotations come from the connection's server: select on them only for\n// servers you trust to classify their own tools.\n\nexport type ToolAnnotationsIface = NonNullable<ToolDescriptorIface['annotations']>;\n\nconst hintMatches = (\n wanted: boolean | undefined,\n actual: boolean | undefined,\n fallback: boolean,\n): boolean => wanted == null || (actual ?? fallback) === wanted;\n\nexport const toolAnnotationsMatch = (\n selector: ToolAnnotationSelectorIface,\n annotations: ToolAnnotationsIface | undefined,\n): boolean =>\n hintMatches(selector.readOnlyHint, annotations?.readOnlyHint, false) &&\n hintMatches(selector.destructiveHint, annotations?.destructiveHint, true) &&\n hintMatches(selector.idempotentHint, annotations?.idempotentHint, false) &&\n hintMatches(selector.openWorldHint, annotations?.openWorldHint, true);\n\ntype AnnotationPolicyIface = Pick<\n HttpMcpServerBindingIface,\n 'allowAnnotations' | 'denyAnnotations'\n>;\n\nexport const isToolHiddenByAnnotations = (\n binding: AnnotationPolicyIface,\n annotations: ToolAnnotationsIface | undefined,\n): boolean =>\n binding.denyAnnotations?.some((selector) => toolAnnotationsMatch(selector, annotations)) === true;\n\n// The first allow rule a tool's annotations match: hosts expose the tool with\n// its approval when no approvals key already covers it.\nexport const toolAnnotationRuleFor = (\n binding: AnnotationPolicyIface,\n annotations: ToolAnnotationsIface | undefined,\n): ToolAnnotationRuleIface | undefined =>\n binding.allowAnnotations?.find((rule) => toolAnnotationsMatch(rule.match, annotations));\n"],
5
+ "mappings": "AAgBA,MAAM,cAAc,CAClB,QACA,QACA,aACY,UAAU,SAAS,UAAU,cAAc;AAElD,MAAM,uBAAuB,CAClC,UACA,gBAEA,YAAY,SAAS,cAAc,aAAa,cAAc,KAAK,KACnE,YAAY,SAAS,iBAAiB,aAAa,iBAAiB,IAAI,KACxE,YAAY,SAAS,gBAAgB,aAAa,gBAAgB,KAAK,KACvE,YAAY,SAAS,eAAe,aAAa,eAAe,IAAI;AAO/D,MAAM,4BAA4B,CACvC,SACA,gBAEA,QAAQ,iBAAiB,KAAK,CAAC,aAAa,qBAAqB,UAAU,WAAW,CAAC,MAAM;AAIxF,MAAM,wBAAwB,CACnC,SACA,gBAEA,QAAQ,kBAAkB,KAAK,CAAC,SAAS,qBAAqB,KAAK,OAAO,WAAW,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,11 @@
1
+ import { ToolApproval, type HttpMcpServerBindingIface } from "./manifest.mjs";
2
+ export declare const TOOL_PATTERN_WILDCARD = "*";
3
+ export declare const isToolPattern: (key: string) => boolean;
4
+ export declare const toolPatternMatches: (pattern: string, name: string) => boolean;
5
+ export declare const resolveToolApprovalKey: (approvals: Readonly<Record<string, ToolApproval>>, name: string) => string | undefined;
6
+ export declare const isToolDenied: (deny: readonly string[] | undefined, name: string) => boolean;
7
+ type ConnectionPolicyIface = Pick<HttpMcpServerBindingIface, 'approvals' | 'deny'>;
8
+ export declare const isToolExposed: (binding: ConnectionPolicyIface, name: string) => boolean;
9
+ export declare const isToolLoaded: (binding: Pick<HttpMcpServerBindingIface, "load">, name: string) => boolean;
10
+ export declare const toolApprovalOf: (binding: ConnectionPolicyIface, name: string) => ToolApproval;
11
+ export {};
@@ -0,0 +1,65 @@
1
+ import { ToolApproval } from "./manifest.mjs";
2
+ const TOOL_PATTERN_WILDCARD = "*";
3
+ const isToolPattern = (key) => key.includes(TOOL_PATTERN_WILDCARD);
4
+ const toolPatternMatches = (pattern, name) => {
5
+ let patternIndex = 0;
6
+ let nameIndex = 0;
7
+ let starIndex = -1;
8
+ let resumeIndex = 0;
9
+ while (nameIndex < name.length) {
10
+ const char = pattern[patternIndex];
11
+ if (char === TOOL_PATTERN_WILDCARD) {
12
+ starIndex = patternIndex;
13
+ resumeIndex = nameIndex;
14
+ patternIndex += 1;
15
+ } else if (char != null && char === name[nameIndex]) {
16
+ patternIndex += 1;
17
+ nameIndex += 1;
18
+ } else if (starIndex !== -1) {
19
+ patternIndex = starIndex + 1;
20
+ resumeIndex += 1;
21
+ nameIndex = resumeIndex;
22
+ } else {
23
+ return false;
24
+ }
25
+ }
26
+ while (pattern[patternIndex] === TOOL_PATTERN_WILDCARD) patternIndex += 1;
27
+ return patternIndex === pattern.length;
28
+ };
29
+ const literalLength = (pattern) => pattern.length - pattern.split(TOOL_PATTERN_WILDCARD).length + 1;
30
+ const resolveToolApprovalKey = (approvals, name) => {
31
+ if (Object.hasOwn(approvals, name)) return name;
32
+ let best;
33
+ for (const key of Object.keys(approvals)) {
34
+ if (!isToolPattern(key) || !toolPatternMatches(key, name)) continue;
35
+ if (best == null) {
36
+ best = key;
37
+ continue;
38
+ }
39
+ const specificity = literalLength(key) - literalLength(best);
40
+ if (specificity > 0) best = key;
41
+ if (specificity !== 0) continue;
42
+ const stricter = approvals[key] === ToolApproval.Ask && approvals[best] !== ToolApproval.Ask;
43
+ const looser = approvals[key] !== ToolApproval.Ask && approvals[best] === ToolApproval.Ask;
44
+ if (stricter || !looser && key < best) best = key;
45
+ }
46
+ return best;
47
+ };
48
+ const isToolDenied = (deny, name) => deny?.some((pattern) => toolPatternMatches(pattern, name)) === true;
49
+ const isToolExposed = (binding, name) => !isToolDenied(binding.deny, name) && (binding.approvals == null || resolveToolApprovalKey(binding.approvals, name) != null);
50
+ const isToolLoaded = (binding, name) => binding.load == null || binding.load.some((pattern) => toolPatternMatches(pattern, name));
51
+ const toolApprovalOf = (binding, name) => {
52
+ const key = binding.approvals == null ? void 0 : resolveToolApprovalKey(binding.approvals, name);
53
+ return key == null ? ToolApproval.Allow : binding.approvals?.[key] ?? ToolApproval.Allow;
54
+ };
55
+ export {
56
+ TOOL_PATTERN_WILDCARD,
57
+ isToolDenied,
58
+ isToolExposed,
59
+ isToolLoaded,
60
+ isToolPattern,
61
+ resolveToolApprovalKey,
62
+ toolApprovalOf,
63
+ toolPatternMatches
64
+ };
65
+ //# sourceMappingURL=tool-patterns.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/tool-patterns.ts"],
4
+ "sourcesContent": ["import { ToolApproval, type HttpMcpServerBindingIface } from \"./manifest.mjs\";\n\n// Tool-name patterns for an HTTP MCP connection's `approvals`, `deny` and\n// `inputApprovals` keys. `*` matches any run of characters, including none;\n// every other character matches itself. MCP tool names are letters, digits,\n// `_`, `-` and `.`, so `*` never collides with a real name. Hosts resolve\n// connection policy through these helpers so every host applies one rule.\n\nexport const TOOL_PATTERN_WILDCARD = '*';\n\nexport const isToolPattern = (key: string): boolean => key.includes(TOOL_PATTERN_WILDCARD);\n\n// Wildcard matching with a single backtrack point: linear in practice for `*` globs.\nexport const toolPatternMatches = (pattern: string, name: string): boolean => {\n let patternIndex = 0;\n let nameIndex = 0;\n let starIndex = -1;\n let resumeIndex = 0;\n while (nameIndex < name.length) {\n const char = pattern[patternIndex];\n if (char === TOOL_PATTERN_WILDCARD) {\n starIndex = patternIndex;\n resumeIndex = nameIndex;\n patternIndex += 1;\n } else if (char != null && char === name[nameIndex]) {\n patternIndex += 1;\n nameIndex += 1;\n } else if (starIndex !== -1) {\n patternIndex = starIndex + 1;\n resumeIndex += 1;\n nameIndex = resumeIndex;\n } else {\n return false;\n }\n }\n while (pattern[patternIndex] === TOOL_PATTERN_WILDCARD) patternIndex += 1;\n return patternIndex === pattern.length;\n};\n\nconst literalLength = (pattern: string): number =>\n pattern.length - pattern.split(TOOL_PATTERN_WILDCARD).length + 1;\n\n// The approvals key that governs `name`: the exact key, else the matching\n// pattern with the most literal characters. Equally specific patterns resolve\n// to the stricter policy (Ask), then lexically, so the result never depends on\n// key order. Undefined when no key matches.\nexport const resolveToolApprovalKey = (\n approvals: Readonly<Record<string, ToolApproval>>,\n name: string,\n): string | undefined => {\n if (Object.hasOwn(approvals, name)) return name;\n let best: string | undefined;\n for (const key of Object.keys(approvals)) {\n if (!isToolPattern(key) || !toolPatternMatches(key, name)) continue;\n if (best == null) {\n best = key;\n continue;\n }\n const specificity = literalLength(key) - literalLength(best);\n if (specificity > 0) best = key;\n if (specificity !== 0) continue;\n const stricter = approvals[key] === ToolApproval.Ask && approvals[best] !== ToolApproval.Ask;\n const looser = approvals[key] !== ToolApproval.Ask && approvals[best] === ToolApproval.Ask;\n if (stricter || (!looser && key < best)) best = key;\n }\n return best;\n};\n\nexport const isToolDenied = (deny: readonly string[] | undefined, name: string): boolean =>\n deny?.some((pattern) => toolPatternMatches(pattern, name)) === true;\n\ntype ConnectionPolicyIface = Pick<HttpMcpServerBindingIface, 'approvals' | 'deny'>;\n\n// Whether the connection exposes `name` at all. Null approvals expose every\n// listed tool; `deny` wins over any approvals key.\nexport const isToolExposed = (binding: ConnectionPolicyIface, name: string): boolean =>\n !isToolDenied(binding.deny, name) &&\n (binding.approvals == null || resolveToolApprovalKey(binding.approvals, name) != null);\n\n// Whether the harness lists an exposed tool up front (`load` names or\n// patterns); hosts keep the others reachable through search. Callers check\n// exposure first.\nexport const isToolLoaded = (\n binding: Pick<HttpMcpServerBindingIface, 'load'>,\n name: string,\n): boolean =>\n binding.load == null || binding.load.some((pattern) => toolPatternMatches(pattern, name));\n\n// The connection's approval for an exposed tool; Allow when nothing matches.\nexport const toolApprovalOf = (binding: ConnectionPolicyIface, name: string): ToolApproval => {\n const key =\n binding.approvals == null ? undefined : resolveToolApprovalKey(binding.approvals, name);\n return key == null ? ToolApproval.Allow : (binding.approvals?.[key] ?? ToolApproval.Allow);\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoD;AAQtD,MAAM,wBAAwB;AAE9B,MAAM,gBAAgB,CAAC,QAAyB,IAAI,SAAS,qBAAqB;AAGlF,MAAM,qBAAqB,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,CAAC,YAAY,mBAAmB,SAAS,IAAI,CAAC,MAAM;AAM1D,MAAM,gBAAgB,CAAC,SAAgC,SAC5D,CAAC,aAAa,QAAQ,MAAM,IAAI,MAC/B,QAAQ,aAAa,QAAQ,uBAAuB,QAAQ,WAAW,IAAI,KAAK;AAK5E,MAAM,eAAe,CAC1B,SACA,SAEA,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,KAAK,CAAC,YAAY,mBAAmB,SAAS,IAAI,CAAC;AAGnF,MAAM,iBAAiB,CAAC,SAAgC,SAA+B;AAC5F,QAAM,MACJ,QAAQ,aAAa,OAAO,SAAY,uBAAuB,QAAQ,WAAW,IAAI;AACxF,SAAO,OAAO,OAAO,aAAa,QAAS,QAAQ,YAAY,GAAG,KAAK,aAAa;AACtF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finalai/agent-provider",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "Provider contracts for the agent stack: harnesses, sandboxes (handle, wire, MCP projection), channels, credential policies, and the conformance kit.",
6
6
  "license": "Apache-2.0",
@@ -183,8 +183,8 @@
183
183
  },
184
184
  "dependencies": {
185
185
  "@agentclientprotocol/sdk": "1.8.0",
186
- "@finalai/acp-session": "0.1.3",
187
- "@finalai/agent-protocol": "0.1.3",
186
+ "@finalai/acp-session": "0.1.4",
187
+ "@finalai/agent-protocol": "0.1.4",
188
188
  "@modelcontextprotocol/client": "^2.1.0",
189
189
  "@modelcontextprotocol/core": "^2.1.0",
190
190
  "@modelcontextprotocol/server": "^2.1.0",