@finalai/agent-provider 0.8.0 → 0.10.0
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 +334 -245
- package/README.md +93 -14
- package/dist/modules/canonical-json.d.mts +4 -0
- package/dist/modules/canonical-json.mjs +33 -0
- package/dist/modules/canonical-json.mjs.map +7 -0
- package/dist/modules/channel.d.mts +9 -3
- package/dist/modules/channel.mjs.map +2 -2
- package/dist/modules/code-host/host.d.mts +10 -0
- package/dist/modules/code-host/host.mjs +88 -0
- package/dist/modules/code-host/host.mjs.map +7 -0
- package/dist/modules/code-host/in-process.d.mts +24 -0
- package/dist/modules/code-host/in-process.mjs +89 -0
- package/dist/modules/code-host/in-process.mjs.map +7 -0
- package/dist/modules/code-host/index.d.mts +4 -0
- package/dist/modules/code-host/index.mjs +5 -0
- package/dist/modules/code-host/index.mjs.map +7 -0
- package/dist/modules/code-host/serverless.d.mts +63 -0
- package/dist/modules/code-host/serverless.mjs +27 -0
- package/dist/modules/code-host/serverless.mjs.map +7 -0
- package/dist/modules/code-host/types.d.mts +152 -0
- package/dist/modules/code-host/types.mjs +85 -0
- package/dist/modules/code-host/types.mjs.map +7 -0
- package/dist/modules/conformance/agent.mjs +72 -6
- package/dist/modules/conformance/agent.mjs.map +2 -2
- package/dist/modules/conformance/harness-kit.d.mts +9 -2
- package/dist/modules/conformance/harness-kit.mjs +224 -63
- package/dist/modules/conformance/harness-kit.mjs.map +3 -3
- package/dist/modules/conformance/local-harness.d.mts +1 -4
- package/dist/modules/conformance/local-harness.mjs +21 -22
- package/dist/modules/conformance/local-harness.mjs.map +2 -2
- package/dist/modules/conformance/protocol.d.mts +1 -0
- package/dist/modules/conformance/protocol.mjs +2 -0
- package/dist/modules/conformance/protocol.mjs.map +2 -2
- package/dist/modules/conformance/sandbox-kit.d.mts +12 -4
- package/dist/modules/conformance/sandbox-kit.mjs +189 -103
- package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/chat-completions.mjs +1 -0
- package/dist/modules/conformance/scripted-model/chat-completions.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/directives.d.mts +3 -0
- package/dist/modules/conformance/scripted-model/directives.mjs +26 -10
- package/dist/modules/conformance/scripted-model/directives.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/messages.mjs +1 -0
- package/dist/modules/conformance/scripted-model/messages.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/responses.mjs +2 -0
- package/dist/modules/conformance/scripted-model/responses.mjs.map +2 -2
- package/dist/modules/conformance/stdio.d.mts +21 -0
- package/dist/modules/conformance/stdio.mjs +158 -0
- package/dist/modules/conformance/stdio.mjs.map +7 -0
- package/dist/modules/credential-routes.d.mts +2 -0
- package/dist/modules/credential-routes.mjs +2 -0
- package/dist/modules/credential-routes.mjs.map +2 -2
- package/dist/modules/document.d.mts +376 -0
- package/dist/modules/document.mjs +208 -0
- package/dist/modules/document.mjs.map +7 -0
- package/dist/modules/harness-configuration.d.mts +16 -0
- package/dist/modules/harness-configuration.mjs +83 -0
- package/dist/modules/harness-configuration.mjs.map +7 -0
- package/dist/modules/harness-definition.d.mts +280 -0
- package/dist/modules/harness-definition.mjs +430 -0
- package/dist/modules/harness-definition.mjs.map +7 -0
- package/dist/modules/harness-provider.d.mts +197 -0
- package/dist/modules/harness-provider.mjs +108 -0
- package/dist/modules/harness-provider.mjs.map +7 -0
- package/dist/modules/harness-requirements.d.mts +19 -0
- package/dist/modules/harness-requirements.mjs +40 -0
- package/dist/modules/harness-requirements.mjs.map +7 -0
- package/dist/modules/harness-start.d.mts +33 -0
- package/dist/modules/harness-start.mjs +107 -0
- package/dist/modules/harness-start.mjs.map +7 -0
- package/dist/modules/harness.d.mts +84 -109
- package/dist/modules/harness.mjs +56 -111
- package/dist/modules/harness.mjs.map +3 -3
- package/dist/modules/identity.d.mts +1 -0
- package/dist/modules/identity.mjs +2 -0
- package/dist/modules/identity.mjs.map +7 -0
- package/dist/modules/index.d.mts +12 -6
- package/dist/modules/index.mjs +12 -6
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/inference.d.mts +35 -0
- package/dist/modules/inference.mjs +74 -0
- package/dist/modules/inference.mjs.map +7 -0
- package/dist/modules/local-channel-context.mjs +3 -1
- package/dist/modules/local-channel-context.mjs.map +2 -2
- package/dist/modules/requirements-check.d.mts +30 -0
- package/dist/modules/requirements-check.mjs +164 -0
- package/dist/modules/requirements-check.mjs.map +7 -0
- package/dist/modules/room-surface.d.mts +0 -5
- package/dist/modules/room-surface.mjs.map +2 -2
- package/dist/modules/sandbox/client.d.mts +3 -0
- package/dist/modules/sandbox/client.mjs +101 -18
- package/dist/modules/sandbox/client.mjs.map +2 -2
- package/dist/modules/sandbox/grant.d.mts +78 -0
- package/dist/modules/sandbox/grant.mjs +134 -0
- package/dist/modules/sandbox/grant.mjs.map +7 -0
- package/dist/modules/sandbox/index.d.mts +3 -3
- package/dist/modules/sandbox/index.mjs +4 -5
- package/dist/modules/sandbox/index.mjs.map +2 -2
- package/dist/modules/sandbox/mcp-hosted.d.mts +1 -1
- package/dist/modules/sandbox/mcp-hosted.mjs +4 -7
- package/dist/modules/sandbox/mcp-hosted.mjs.map +2 -2
- package/dist/modules/sandbox/mcp.d.mts +4 -2
- package/dist/modules/sandbox/mcp.mjs +14 -7
- package/dist/modules/sandbox/mcp.mjs.map +2 -2
- package/dist/modules/sandbox/memory-sandbox.d.mts +2 -1
- package/dist/modules/sandbox/memory-sandbox.mjs +71 -41
- package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
- package/dist/modules/sandbox/networking.d.mts +7 -7
- package/dist/modules/sandbox/networking.mjs +16 -9
- package/dist/modules/sandbox/networking.mjs.map +2 -2
- package/dist/modules/sandbox/remote/adapter.d.mts +30 -0
- package/dist/modules/sandbox/remote/adapter.mjs +381 -0
- package/dist/modules/sandbox/remote/adapter.mjs.map +7 -0
- package/dist/modules/sandbox/remote/errors.d.mts +10 -0
- package/dist/modules/sandbox/remote/errors.mjs +62 -0
- package/dist/modules/sandbox/remote/errors.mjs.map +7 -0
- package/dist/modules/sandbox/remote/index.d.mts +5 -0
- package/dist/modules/sandbox/remote/index.mjs +6 -0
- package/dist/modules/sandbox/remote/index.mjs.map +7 -0
- package/dist/modules/sandbox/remote/ndjson.d.mts +6 -0
- package/dist/modules/sandbox/remote/ndjson.mjs +80 -0
- package/dist/modules/sandbox/remote/ndjson.mjs.map +7 -0
- package/dist/modules/sandbox/remote/platform-api.d.mts +8 -0
- package/dist/modules/sandbox/remote/platform-api.mjs +15 -0
- package/dist/modules/sandbox/remote/platform-api.mjs.map +7 -0
- package/dist/modules/sandbox/remote/preamble.d.mts +7 -0
- package/dist/modules/sandbox/remote/preamble.mjs +51 -0
- package/dist/modules/sandbox/remote/preamble.mjs.map +7 -0
- package/dist/modules/sandbox/remote/serve.d.mts +34 -0
- package/dist/modules/sandbox/remote/serve.mjs +519 -0
- package/dist/modules/sandbox/remote/serve.mjs.map +7 -0
- package/dist/modules/sandbox/remote/testing.d.mts +34 -0
- package/dist/modules/sandbox/remote/testing.mjs +275 -0
- package/dist/modules/sandbox/remote/testing.mjs.map +7 -0
- package/dist/modules/sandbox/seeds.d.mts +2 -2
- package/dist/modules/sandbox/seeds.mjs +2 -2
- package/dist/modules/sandbox/seeds.mjs.map +2 -2
- package/dist/modules/sandbox/server.d.mts +4 -6
- package/dist/modules/sandbox/server.mjs +93 -49
- package/dist/modules/sandbox/server.mjs.map +2 -2
- package/dist/modules/sandbox/setup/apply.d.mts +41 -0
- package/dist/modules/sandbox/setup/apply.mjs +204 -0
- package/dist/modules/sandbox/setup/apply.mjs.map +7 -0
- package/dist/modules/sandbox/setup/describe.d.mts +10 -0
- package/dist/modules/sandbox/setup/describe.mjs +62 -0
- package/dist/modules/sandbox/setup/describe.mjs.map +7 -0
- package/dist/modules/sandbox/setup/index.d.mts +6 -0
- package/dist/modules/sandbox/setup/index.mjs +17 -0
- package/dist/modules/sandbox/setup/index.mjs.map +7 -0
- package/dist/modules/sandbox/setup/paths.d.mts +8 -0
- package/dist/modules/sandbox/setup/paths.mjs +18 -0
- package/dist/modules/sandbox/setup/paths.mjs.map +7 -0
- package/dist/modules/sandbox/setup/schema.d.mts +42 -0
- package/dist/modules/sandbox/setup/schema.mjs +58 -0
- package/dist/modules/sandbox/setup/schema.mjs.map +7 -0
- package/dist/modules/sandbox/tool-policy.d.mts +1 -1
- package/dist/modules/sandbox/tool-policy.mjs +1 -1
- package/dist/modules/sandbox/tool-policy.mjs.map +2 -2
- package/dist/modules/sandbox/types.d.mts +117 -130
- package/dist/modules/sandbox/types.mjs +46 -50
- package/dist/modules/sandbox/types.mjs.map +3 -3
- package/dist/modules/sandbox/wire.d.mts +93 -6
- package/dist/modules/sandbox/wire.mjs +61 -38
- package/dist/modules/sandbox/wire.mjs.map +2 -2
- package/dist/modules/schemas.d.mts +5 -76
- package/dist/modules/schemas.mjs +18 -85
- package/dist/modules/schemas.mjs.map +2 -2
- package/dist/modules/tool-annotations.d.mts +15 -6
- package/dist/modules/tool-annotations.mjs +9 -3
- package/dist/modules/tool-annotations.mjs.map +2 -2
- package/dist/modules/tool-descriptor.d.mts +16 -0
- package/dist/modules/tool-descriptor.mjs +19 -0
- package/dist/modules/tool-descriptor.mjs.map +7 -0
- package/dist/modules/tool-patterns.d.mts +7 -7
- package/dist/modules/tool-patterns.mjs +10 -9
- package/dist/modules/tool-patterns.mjs.map +2 -2
- package/package.json +86 -36
- package/dist/modules/credentials.d.mts +0 -206
- package/dist/modules/credentials.mjs +0 -207
- package/dist/modules/credentials.mjs.map +0 -7
- package/dist/modules/dynamic.d.mts +0 -40
- package/dist/modules/dynamic.mjs +0 -79
- package/dist/modules/dynamic.mjs.map +0 -7
- package/dist/modules/hosted-bindings.d.mts +0 -15
- package/dist/modules/hosted-bindings.mjs +0 -21
- package/dist/modules/hosted-bindings.mjs.map +0 -7
- package/dist/modules/manifest.d.mts +0 -787
- package/dist/modules/manifest.mjs +0 -320
- package/dist/modules/manifest.mjs.map +0 -7
- package/dist/modules/provider-ref.d.mts +0 -29
- package/dist/modules/provider-ref.mjs +0 -55
- package/dist/modules/provider-ref.mjs.map +0 -7
- package/dist/modules/sandbox/open-scope-node.d.mts +0 -4
- package/dist/modules/sandbox/open-scope-node.mjs +0 -19
- package/dist/modules/sandbox/open-scope-node.mjs.map +0 -7
- package/dist/modules/sandbox/open-scope.d.mts +0 -16
- package/dist/modules/sandbox/open-scope.mjs +0 -66
- package/dist/modules/sandbox/open-scope.mjs.map +0 -7
- package/dist/modules/sandbox/workspace-identity.d.mts +0 -5
- package/dist/modules/sandbox/workspace-identity.mjs +0 -14
- package/dist/modules/sandbox/workspace-identity.mjs.map +0 -7
|
@@ -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 // 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 lists what `load` (or, without\n // it, HOSTING.md's defaults) leaves listed and serves search for the rest.\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;
|
|
6
|
-
"names": ["AcpTransport", "McpTransportKind", "
|
|
4
|
+
"sourcesContent": ["import type { McpServer } from '@agentclientprotocol/sdk/experimental/v2';\nimport { Capability } from '@finalai/agent-protocol';\nimport {\n InferenceSourceKind,\n type ResolvedHarnessSettingsIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { RuntimeKind } from '@finalai/agent-protocol';\nimport * as z from 'zod';\nimport { CredentialRoute, routeGrantSchema, type RouteGrantIface } from \"./credential-routes.mjs\";\nimport type { AgentDocumentIface } from \"./document.mjs\";\nimport type { JsonValue } from \"./json.mjs\";\nimport { jsonValueSchema } from \"./json.mjs\";\nimport type { HarnessDefinitionIface } from \"./harness-definition.mjs\";\nimport { sandboxGrantSchema, type SandboxGrantIface } from \"./sandbox/grant.mjs\";\n\n// The runtime side of a harness: what reaching one looks like to the session\n// service. A caller names a harness definition in its harness settings\n// (`{ harness, adapter?, configuration, environment? }`, plain data); the\n// platform starts a fresh one per session through a harness provider\n// (./harness-provider.ts) and speaks only ACP v2 to it. Harness and ACP\n// adapter definitions are ./harness-definition.ts.\n\nexport {\n HarnessComputeStatus,\n harnessEnvironmentSchema,\n harnessSettingsSchema,\n harnessUrlEnvironmentSchema,\n isUrlEnvironment,\n type HarnessEnvironmentIface,\n type HarnessSettingsIface,\n type HarnessUrlEnvironmentIface,\n type ResolvedHarnessSettingsIface,\n} from '@finalai/agent-protocol/agent-platform';\n\nexport enum AcpTransport {\n Relay = 'relay',\n Ws = 'ws',\n Http = 'http',\n Stdio = 'stdio',\n // A program the session service starts in a sandbox over the sandbox handle\n // RPC: ACP on its stdio, nothing listening on a port.\n Sandbox = 'sandbox',\n}\n\nexport enum McpTransportKind {\n Acp = 'acp',\n Http = 'http',\n Stdio = 'stdio',\n}\n\n// Wires a harness speaks to reach a provided sandbox.\nexport enum SandboxWire {\n HandleRpc = 'handle-rpc',\n Mcp = 'mcp',\n}\n\n// How a harness's model credential reaches it.\nexport enum CredentialDelivery {\n // Fetched from the broker's `model` route on every request.\n PerRequest = 'per-request',\n // Resolved once when the session opens and renewed through the grant's refresh route.\n AtOpen = 'at-open',\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 profile: the\n// session service then assumes nothing survives a dropped connection and that\n// a prompt while running waits for idle.\nexport const DEFAULT_PROMPT_WHILE_RUNNING = PromptWhileRunning.Queue;\nexport const DEFAULT_SESSION_SURVIVES_DISCONNECT = false;\n\nexport const harnessSessionRefSchema = z.object({\n // The harness's name, as harness settings name it.\n harness: z.string().min(1),\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: InferenceSourceKind;\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(InferenceSourceKind),\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 compute endpoints' tokens.\nexport interface CredentialRefreshResultIface extends CredentialGrantIface {\n mcpServers: RenewedMcpServerIface[];\n compute: Partial<Record<Capability, SandboxEndpointIface>>;\n}\n\nconst endpointTokenSchema = z.object({\n url: z.string().min(1),\n token: z.string(),\n expiresAt: z.string(),\n});\n\nexport const sandboxEndpointSchema = z.object({\n sandboxId: z.string().min(1),\n bindingId: z.string().min(1),\n grant: sandboxGrantSchema,\n features: z.array(z.string()),\n rpc: endpointTokenSchema.nullable(),\n mcp: endpointTokenSchema.nullable(),\n}) satisfies z.ZodType<SandboxEndpointIface>;\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 compute: z.partialRecord(z.nativeEnum(Capability), sandboxEndpointSchema).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 provided sandbox as the session service hands it to a harness, for one\n// capability: a stable per-session address that attaches the sandbox on the\n// first call, and the grant every call on it is held to. `files` and `shell`\n// share one sandbox and so one endpoint. Never a lease, a data-plane token for\n// a live machine, or provider code.\nexport interface SandboxEndpointIface {\n sandboxId: string;\n bindingId: string;\n grant: SandboxGrantIface;\n // Handle features the sandbox advertises (SandboxCapability), when known.\n features: 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 sessionId: string;\n organizationId: string;\n projectId: string;\n // The agent document's content hash the session pins.\n agent: string;\n // The published agent it was started as; null for an agent passed as a value.\n definitionId: string | null;\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, so a harness can\n // 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 and never 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, 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; implementations key\n // 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 agent: instructions, skills, tool policy and requirements.\n document: AgentDocumentIface;\n // The caller's harness settings, accepted by `accepts`, defaults applied.\n settings: ResolvedHarnessSettingsIface;\n // Already materialized ACP MCP server entries: the agent's own tools, the\n // provided integrations, sandbox MCP projections where applicable.\n mcpServers: McpServer[];\n // The provided sandbox for each capability the harness drives on one; a\n // capability served natively, or not provided, is absent.\n compute: Partial<Record<Capability, SandboxEndpointIface>>;\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// What the session service starts in a harness's environment sandbox: a\n// process, speaking ACP on its stdin and stdout, or a worker program, speaking\n// ACP on its stream. Both run over the sandbox handle RPC; nothing listens on\n// a port.\nexport const sandboxProcessStartSchema = z.strictObject({\n runtime: z.literal(RuntimeKind.Process),\n command: z.string().min(1),\n args: z.array(z.string()).default([]),\n env: z.record(z.string(), z.string()).default({}),\n cwd: z.string().min(1).optional(),\n});\n\nexport const sandboxWorkerStartSchema = z.strictObject({\n runtime: z.literal(RuntimeKind.Worker),\n program: z.string().min(1),\n env: z.record(z.string(), z.string()).default({}),\n // Handed to the program when it starts.\n input: jsonValueSchema.default(null),\n});\n\nexport const sandboxStartSchema = z.discriminatedUnion('runtime', [\n sandboxProcessStartSchema,\n sandboxWorkerStartSchema,\n]);\n\nexport type SandboxStartIface = z.output<typeof sandboxStartSchema>;\nexport type SandboxStartInputIface = z.input<typeof sandboxStartSchema>;\n\n// Resolved only in memory; refs 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 // A relay channel the runtime answers on.\n | { ref: HarnessSessionRefIface; transport: AcpTransport.Relay; channel: string; token: string }\n // A program the session service starts in a sandbox; ACP on its stdio.\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Sandbox;\n sandboxId: string;\n start: SandboxStartIface;\n }\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 settings a call is about and the project's secrets (a remote harness's\n// client certificate, by name).\nexport interface HarnessCallContextIface {\n settings: ResolvedHarnessSettingsIface;\n secrets: SecretReaderIface;\n}\n\n// A harness as a driver reaches it (the session service, the conformance\n// kit): what it is, as its definition says (configuration schema, features,\n// MCP transports, prompt-while-running, session survival), and its session\n// lifecycle.\nexport interface HarnessIface {\n definition: HarnessDefinitionIface;\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?: HarnessCallContextIface,\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?: HarnessCallContextIface;\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,YAAY,OAAO;AACnB,SAAS,iBAAiB,wBAA8C;AAGxE,SAAS,uBAAuB;AAEhC,SAAS,0BAAkD;AAS3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAEA,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,QAAK;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,WAAQ;AAGR,EAAAA,cAAA,aAAU;AAPA,SAAAA;AAAA,GAAA;AAUL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,SAAM;AACN,EAAAA,kBAAA,UAAO;AACP,EAAAA,kBAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AAOL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,SAAM;AAFI,SAAAA;AAAA,GAAA;AAML,IAAK,qBAAL,kBAAKC,wBAAL;AAEL,EAAAA,oBAAA,gBAAa;AAEb,EAAAA,oBAAA,YAAS;AAJC,SAAAA;AAAA,GAAA;AAQL,IAAK,qBAAL,kBAAKC,wBAAL;AAEL,EAAAA,oBAAA,YAAS;AAET,EAAAA,oBAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAUL,MAAM,+BAA+B;AACrC,MAAM,sCAAsC;AAE5C,MAAM,0BAA0B,EAAE,OAAO;AAAA;AAAA,EAE9C,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA;AAAA,EAEzB,mBAAmB,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA;AAAA;AAAA,EAGnC,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAC3C,CAAC;AAKD;AAAA,EACE;AAAA,EACA,mBAAAC;AAAA,EACA,oBAAAC;AAAA,OAGK;AA6CA,MAAM,8BAA8B,EAAE,OAAO;AAAA,EAClD,QAAQ,EAAE,OAAO;AAAA,EACjB,MAAM,EAAE,WAAW,mBAAmB;AAAA,EACtC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACpC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACnC,cAAc,EACX,OAAO;AAAA,IACN,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,oBAAoB,GAAG,EAAE,QAAQ,qBAAqB,CAAC,CAAC;AAAA,IACnF,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,CAAC,EACA,SAAS;AAAA,EACZ,aAAa,EAAE,OAAO;AACxB,CAAC;AAEM,MAAM,+BAA+B,EAAE,OAAO;AAAA,EACnD,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACrB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACvB,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAClC,WAAW,EAAE,OAAO;AACtB,CAAC;AAEM,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,QAAQ,EAAE,MAAM,gBAAgB;AAAA,EAChC,QAAQ,4BAA4B,SAAS;AAAA,EAC7C,SAAS,6BAA6B,SAAS;AACjD,CAAC;AAoBD,MAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACrB,OAAO,EAAE,OAAO;AAAA,EAChB,WAAW,EAAE,OAAO;AACtB,CAAC;AAEM,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,OAAO;AAAA,EACP,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAC5B,KAAK,oBAAoB,SAAS;AAAA,EAClC,KAAK,oBAAoB,SAAS;AACpC,CAAC;AAEM,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACrB,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3E,CAAC;AAGM,MAAM,gCAAgC,sBAAsB,OAAO;AAAA,EACxE,YAAY,EAAE,MAAM,sBAAsB,EAAE,QAAQ,CAAC,CAAC;AAAA,EACtD,SAAS,EAAE,cAAc,EAAE,WAAW,UAAU,GAAG,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACtF,CAAC;AAIM,MAAM,kBAAkB,CAAC,SAIU;AACxC,QAAM,QACJ,KAAK,OAAO,KAAK,CAAC,cAAc,UAAU,UAAU,gBAAgB,KAAK,KAAK,KAAK,OAAO,CAAC;AAC7F,MAAI,SAAS,KAAM,QAAO;AAC1B,SAAO;AAAA,IACL,KAAK,GAAG,KAAK,UAAU,QAAQ,QAAQ,EAAE,CAAC;AAAA,IAC1C,OAAO,MAAM;AAAA,IACb,kBAAkB,KAAK;AAAA,IACvB,WAAW,MAAM;AAAA,EACnB;AACF;AAqGO,MAAM,4BAA4B,EAAE,aAAa;AAAA,EACtD,SAAS,EAAE,QAAQ,YAAY,OAAO;AAAA,EACtC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAAA,EACpC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAAA,EAChD,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAClC,CAAC;AAEM,MAAM,2BAA2B,EAAE,aAAa;AAAA,EACrD,SAAS,EAAE,QAAQ,YAAY,MAAM;AAAA,EACrC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEhD,OAAO,gBAAgB,QAAQ,IAAI;AACrC,CAAC;AAEM,MAAM,qBAAqB,EAAE,mBAAmB,WAAW;AAAA,EAChE;AAAA,EACA;AACF,CAAC;",
|
|
6
|
+
"names": ["AcpTransport", "McpTransportKind", "SandboxWire", "CredentialDelivery", "PromptWhileRunning", "CredentialRoute", "routeGrantSchema"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@finalai/agent-protocol/identity';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/identity.ts"],
|
|
4
|
+
"sourcesContent": ["// Verifiers for the platform's tokens, for providers: a sandbox provider\n// checks the sandbox-provider assertions it is called with, and a backend\n// checks the downstream assertions a provider exchanged for it.\n\nexport * from '@finalai/agent-protocol/identity';\n"],
|
|
5
|
+
"mappings": "AAIA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/modules/index.d.mts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
export { ProcessInspectionOperation, inspectedProcessSchema, processInspectionDetailSchema, processInspectionPageSchema, processInspectionRequestSchema, processInspectionResultSchema, type InspectedProcessIface, type ProcessInspectionDetailIface, type ProcessInspectionPageIface, type ProcessInspectionRequestIface, type ProcessInspectionResultIface, } from '@finalai/agent-protocol/process-inspection';
|
|
2
2
|
export * from "./channel.mjs";
|
|
3
|
-
export * from "./credentials.mjs";
|
|
4
|
-
export * from "./dynamic.mjs";
|
|
5
3
|
export * from "./harness.mjs";
|
|
6
|
-
export * from "./
|
|
4
|
+
export * from "./harness-configuration.mjs";
|
|
5
|
+
export * from "./harness-definition.mjs";
|
|
6
|
+
export * from "./harness-provider.mjs";
|
|
7
7
|
export * from "./json.mjs";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./provider-ref.mjs";
|
|
8
|
+
export * from "./document.mjs";
|
|
10
9
|
export * from "./room-surface.mjs";
|
|
11
|
-
export * from "./sandbox/open-scope.mjs";
|
|
12
10
|
export * from "./sandbox/types.mjs";
|
|
13
11
|
export * from "./schemas.mjs";
|
|
14
12
|
export * from "./tool-annotations.mjs";
|
|
15
13
|
export * from "./tool-patterns.mjs";
|
|
14
|
+
export * from "./tool-descriptor.mjs";
|
|
15
|
+
export * from "./sandbox/grant.mjs";
|
|
16
|
+
export * from "./sandbox/setup/index.mjs";
|
|
17
|
+
export * from "./code-host/index.mjs";
|
|
16
18
|
export * from "./semantic-events.mjs";
|
|
17
19
|
export * from "./sandbox/snapshots.mjs";
|
|
18
20
|
export { SandboxEditorOperation, sandboxEditorRequestSchema, sandboxEditorResultSchema, sandboxEditorSessionSchema, type SandboxEditorRequestIface, type SandboxEditorResultIface, type SandboxEditorSessionIface, } from "./sandbox/editor.mjs";
|
|
21
|
+
export * from "./canonical-json.mjs";
|
|
22
|
+
export * from "./harness-requirements.mjs";
|
|
23
|
+
export * from "./inference.mjs";
|
|
24
|
+
export * from "./requirements-check.mjs";
|
package/dist/modules/index.mjs
CHANGED
|
@@ -7,19 +7,21 @@ import {
|
|
|
7
7
|
processInspectionResultSchema
|
|
8
8
|
} from "@finalai/agent-protocol/process-inspection";
|
|
9
9
|
export * from "./channel.mjs";
|
|
10
|
-
export * from "./credentials.mjs";
|
|
11
|
-
export * from "./dynamic.mjs";
|
|
12
10
|
export * from "./harness.mjs";
|
|
13
|
-
export * from "./
|
|
11
|
+
export * from "./harness-configuration.mjs";
|
|
12
|
+
export * from "./harness-definition.mjs";
|
|
13
|
+
export * from "./harness-provider.mjs";
|
|
14
14
|
export * from "./json.mjs";
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./provider-ref.mjs";
|
|
15
|
+
export * from "./document.mjs";
|
|
17
16
|
export * from "./room-surface.mjs";
|
|
18
|
-
export * from "./sandbox/open-scope.mjs";
|
|
19
17
|
export * from "./sandbox/types.mjs";
|
|
20
18
|
export * from "./schemas.mjs";
|
|
21
19
|
export * from "./tool-annotations.mjs";
|
|
22
20
|
export * from "./tool-patterns.mjs";
|
|
21
|
+
export * from "./tool-descriptor.mjs";
|
|
22
|
+
export * from "./sandbox/grant.mjs";
|
|
23
|
+
export * from "./sandbox/setup/index.mjs";
|
|
24
|
+
export * from "./code-host/index.mjs";
|
|
23
25
|
export * from "./semantic-events.mjs";
|
|
24
26
|
export * from "./sandbox/snapshots.mjs";
|
|
25
27
|
import {
|
|
@@ -28,6 +30,10 @@ import {
|
|
|
28
30
|
sandboxEditorResultSchema,
|
|
29
31
|
sandboxEditorSessionSchema
|
|
30
32
|
} from "./sandbox/editor.mjs";
|
|
33
|
+
export * from "./canonical-json.mjs";
|
|
34
|
+
export * from "./harness-requirements.mjs";
|
|
35
|
+
export * from "./inference.mjs";
|
|
36
|
+
export * from "./requirements-check.mjs";
|
|
31
37
|
export {
|
|
32
38
|
ProcessInspectionOperation,
|
|
33
39
|
SandboxEditorOperation,
|
|
@@ -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 \"./
|
|
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;AACd,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 \"./harness.mjs\";\nexport * from \"./harness-configuration.mjs\";\nexport * from \"./harness-definition.mjs\";\nexport * from \"./harness-provider.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./document.mjs\";\nexport * from \"./room-surface.mjs\";\nexport * from \"./sandbox/types.mjs\";\nexport * from \"./schemas.mjs\";\nexport * from \"./tool-annotations.mjs\";\nexport * from \"./tool-patterns.mjs\";\nexport * from \"./tool-descriptor.mjs\";\nexport * from \"./sandbox/grant.mjs\";\nexport * from \"./sandbox/setup/index.mjs\";\nexport * from \"./code-host/index.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\";\nexport * from \"./canonical-json.mjs\";\nexport * from \"./harness-requirements.mjs\";\nexport * from \"./inference.mjs\";\nexport * from \"./requirements-check.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;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CredentialScope, InferenceBillTo, type ApiKeySourceIface, type FinalCreditsSourceIface, type HarnessLoginSourceIface, type SubscriptionSourceIface } from '@finalai/agent-protocol/agent-platform';
|
|
2
|
+
export { CredentialScope, InferenceBillTo, InferenceSourceKind, inferenceSchema, inferenceSourceSchema, type InferenceSource, } from '@finalai/agent-protocol/agent-platform';
|
|
3
|
+
export declare const subscription: (args?: {
|
|
4
|
+
credential?: CredentialScope | `${CredentialScope}`;
|
|
5
|
+
vendor?: string;
|
|
6
|
+
}) => SubscriptionSourceIface;
|
|
7
|
+
export declare const apiKey: (secret: string, args?: {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
vendor?: string;
|
|
10
|
+
}) => ApiKeySourceIface;
|
|
11
|
+
export declare const finalCredits: (args?: {
|
|
12
|
+
billTo?: InferenceBillTo | `${InferenceBillTo}`;
|
|
13
|
+
budget?: string;
|
|
14
|
+
}) => FinalCreditsSourceIface;
|
|
15
|
+
export declare const harnessLogin: () => HarnessLoginSourceIface;
|
|
16
|
+
export declare const KNOWN_INFERENCE_VENDORS: readonly ["openai", "anthropic", "openrouter", "google", "bedrock"];
|
|
17
|
+
export declare enum CredentialFailureReason {
|
|
18
|
+
SubscriptionNotConnected = "subscription_not_connected",
|
|
19
|
+
UsageExhausted = "usage_exhausted",
|
|
20
|
+
BudgetExceeded = "budget_exceeded",
|
|
21
|
+
CredentialInvalid = "credential_invalid",
|
|
22
|
+
HarnessIncompatible = "harness_incompatible",
|
|
23
|
+
ModelNotOffered = "model_not_offered"
|
|
24
|
+
}
|
|
25
|
+
export declare enum CredentialFallbackReason {
|
|
26
|
+
Archived = "archived",
|
|
27
|
+
Invalid = "invalid",
|
|
28
|
+
VendorMismatch = "vendor_mismatch",
|
|
29
|
+
Exhausted = "exhausted",
|
|
30
|
+
NotGranted = "not_granted",
|
|
31
|
+
OverBudget = "over_budget",
|
|
32
|
+
KindUnsupported = "kind_unsupported",
|
|
33
|
+
Missing = "missing",
|
|
34
|
+
ModelNotOffered = "model_not_offered"
|
|
35
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CredentialScope,
|
|
3
|
+
InferenceBillTo,
|
|
4
|
+
InferenceSourceKind
|
|
5
|
+
} from "@finalai/agent-protocol/agent-platform";
|
|
6
|
+
import {
|
|
7
|
+
CredentialScope as CredentialScope2,
|
|
8
|
+
InferenceBillTo as InferenceBillTo2,
|
|
9
|
+
InferenceSourceKind as InferenceSourceKind2,
|
|
10
|
+
inferenceSchema,
|
|
11
|
+
inferenceSourceSchema
|
|
12
|
+
} from "@finalai/agent-protocol/agent-platform";
|
|
13
|
+
const subscription = (args = {}) => ({
|
|
14
|
+
source: InferenceSourceKind.Subscription,
|
|
15
|
+
credential: args.credential === "shared" ? CredentialScope.Shared : CredentialScope.Personal,
|
|
16
|
+
...args.vendor == null ? {} : { vendor: args.vendor }
|
|
17
|
+
});
|
|
18
|
+
const apiKey = (secret, args = {}) => ({
|
|
19
|
+
source: InferenceSourceKind.ApiKey,
|
|
20
|
+
secret,
|
|
21
|
+
...args.baseUrl == null ? {} : { baseUrl: args.baseUrl },
|
|
22
|
+
...args.vendor == null ? {} : { vendor: args.vendor }
|
|
23
|
+
});
|
|
24
|
+
const finalCredits = (args = {}) => ({
|
|
25
|
+
source: InferenceSourceKind.Final,
|
|
26
|
+
billTo: args.billTo === "person" ? InferenceBillTo.Person : InferenceBillTo.Project,
|
|
27
|
+
...args.budget == null ? {} : { budget: args.budget }
|
|
28
|
+
});
|
|
29
|
+
const harnessLogin = () => ({
|
|
30
|
+
source: InferenceSourceKind.Harness
|
|
31
|
+
});
|
|
32
|
+
const KNOWN_INFERENCE_VENDORS = [
|
|
33
|
+
"openai",
|
|
34
|
+
"anthropic",
|
|
35
|
+
"openrouter",
|
|
36
|
+
"google",
|
|
37
|
+
"bedrock"
|
|
38
|
+
];
|
|
39
|
+
var CredentialFailureReason = /* @__PURE__ */ ((CredentialFailureReason2) => {
|
|
40
|
+
CredentialFailureReason2["SubscriptionNotConnected"] = "subscription_not_connected";
|
|
41
|
+
CredentialFailureReason2["UsageExhausted"] = "usage_exhausted";
|
|
42
|
+
CredentialFailureReason2["BudgetExceeded"] = "budget_exceeded";
|
|
43
|
+
CredentialFailureReason2["CredentialInvalid"] = "credential_invalid";
|
|
44
|
+
CredentialFailureReason2["HarnessIncompatible"] = "harness_incompatible";
|
|
45
|
+
CredentialFailureReason2["ModelNotOffered"] = "model_not_offered";
|
|
46
|
+
return CredentialFailureReason2;
|
|
47
|
+
})(CredentialFailureReason || {});
|
|
48
|
+
var CredentialFallbackReason = /* @__PURE__ */ ((CredentialFallbackReason2) => {
|
|
49
|
+
CredentialFallbackReason2["Archived"] = "archived";
|
|
50
|
+
CredentialFallbackReason2["Invalid"] = "invalid";
|
|
51
|
+
CredentialFallbackReason2["VendorMismatch"] = "vendor_mismatch";
|
|
52
|
+
CredentialFallbackReason2["Exhausted"] = "exhausted";
|
|
53
|
+
CredentialFallbackReason2["NotGranted"] = "not_granted";
|
|
54
|
+
CredentialFallbackReason2["OverBudget"] = "over_budget";
|
|
55
|
+
CredentialFallbackReason2["KindUnsupported"] = "kind_unsupported";
|
|
56
|
+
CredentialFallbackReason2["Missing"] = "missing";
|
|
57
|
+
CredentialFallbackReason2["ModelNotOffered"] = "model_not_offered";
|
|
58
|
+
return CredentialFallbackReason2;
|
|
59
|
+
})(CredentialFallbackReason || {});
|
|
60
|
+
export {
|
|
61
|
+
CredentialFailureReason,
|
|
62
|
+
CredentialFallbackReason,
|
|
63
|
+
CredentialScope2 as CredentialScope,
|
|
64
|
+
InferenceBillTo2 as InferenceBillTo,
|
|
65
|
+
InferenceSourceKind2 as InferenceSourceKind,
|
|
66
|
+
KNOWN_INFERENCE_VENDORS,
|
|
67
|
+
apiKey,
|
|
68
|
+
finalCredits,
|
|
69
|
+
harnessLogin,
|
|
70
|
+
inferenceSchema,
|
|
71
|
+
inferenceSourceSchema,
|
|
72
|
+
subscription
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=inference.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/inference.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n CredentialScope,\n InferenceBillTo,\n InferenceSourceKind,\n type ApiKeySourceIface,\n type FinalCreditsSourceIface,\n type HarnessLoginSourceIface,\n type SubscriptionSourceIface,\n} from '@finalai/agent-protocol/agent-platform';\n\n// How a harness reaches its model and who is charged: an ordered list of\n// sources, first available wins. Each builder returns the wire form.\n\nexport {\n CredentialScope,\n InferenceBillTo,\n InferenceSourceKind,\n inferenceSchema,\n inferenceSourceSchema,\n type InferenceSource,\n} from '@finalai/agent-protocol/agent-platform';\n\n// The acting person's own subscription for the model's vendor, or one\n// connected for the whole project with `{ credential: 'shared' }`.\nexport const subscription = (\n args: { credential?: CredentialScope | `${CredentialScope}`; vendor?: string } = {},\n): SubscriptionSourceIface => ({\n source: InferenceSourceKind.Subscription,\n credential: args.credential === 'shared' ? CredentialScope.Shared : CredentialScope.Personal,\n ...(args.vendor == null ? {} : { vendor: args.vendor }),\n});\n\n// The project's secret of this name.\nexport const apiKey = (\n secret: string,\n args: { baseUrl?: string; vendor?: string } = {},\n): ApiKeySourceIface => ({\n source: InferenceSourceKind.ApiKey,\n secret,\n ...(args.baseUrl == null ? {} : { baseUrl: args.baseUrl }),\n ...(args.vendor == null ? {} : { vendor: args.vendor }),\n});\n\n// Final's metered inference, billed to the project unless `billTo: 'person'`.\nexport const finalCredits = (\n args: { billTo?: InferenceBillTo | `${InferenceBillTo}`; budget?: string } = {},\n): FinalCreditsSourceIface => ({\n source: InferenceSourceKind.Final,\n billTo: args.billTo === 'person' ? InferenceBillTo.Person : InferenceBillTo.Project,\n ...(args.budget == null ? {} : { budget: args.budget }),\n});\n\n// A CLI's own login on the machine a remote harness runs on.\nexport const harnessLogin = (): HarnessLoginSourceIface => ({\n source: InferenceSourceKind.Harness,\n});\n\n// Vendors are open strings; these are the ones the broker knows today.\nexport const KNOWN_INFERENCE_VENDORS = [\n 'openai',\n 'anthropic',\n 'openrouter',\n 'google',\n 'bedrock',\n] as const;\n\n// Why no source in the list produced a model credential; shown to people as a notice.\nexport enum CredentialFailureReason {\n SubscriptionNotConnected = 'subscription_not_connected',\n UsageExhausted = 'usage_exhausted',\n BudgetExceeded = 'budget_exceeded',\n CredentialInvalid = 'credential_invalid',\n HarnessIncompatible = 'harness_incompatible',\n // The only sources left were the platform's credits, which do not serve the model.\n ModelNotOffered = 'model_not_offered',\n}\n\n// Why one source was passed over for the next.\nexport enum CredentialFallbackReason {\n Archived = 'archived',\n Invalid = 'invalid',\n VendorMismatch = 'vendor_mismatch',\n Exhausted = 'exhausted',\n NotGranted = 'not_granted',\n OverBudget = 'over_budget',\n KindUnsupported = 'kind_unsupported',\n Missing = 'missing',\n // The platform's credits do not serve the requested model.\n ModelNotOffered = 'model_not_offered',\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAKP;AAAA,EACE,mBAAAA;AAAA,EACA,mBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAIA,MAAM,eAAe,CAC1B,OAAiF,CAAC,OACrD;AAAA,EAC7B,QAAQ,oBAAoB;AAAA,EAC5B,YAAY,KAAK,eAAe,WAAW,gBAAgB,SAAS,gBAAgB;AAAA,EACpF,GAAI,KAAK,UAAU,OAAO,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;AACvD;AAGO,MAAM,SAAS,CACpB,QACA,OAA8C,CAAC,OACxB;AAAA,EACvB,QAAQ,oBAAoB;AAAA,EAC5B;AAAA,EACA,GAAI,KAAK,WAAW,OAAO,CAAC,IAAI,EAAE,SAAS,KAAK,QAAQ;AAAA,EACxD,GAAI,KAAK,UAAU,OAAO,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;AACvD;AAGO,MAAM,eAAe,CAC1B,OAA6E,CAAC,OACjD;AAAA,EAC7B,QAAQ,oBAAoB;AAAA,EAC5B,QAAQ,KAAK,WAAW,WAAW,gBAAgB,SAAS,gBAAgB;AAAA,EAC5E,GAAI,KAAK,UAAU,OAAO,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;AACvD;AAGO,MAAM,eAAe,OAAgC;AAAA,EAC1D,QAAQ,oBAAoB;AAC9B;AAGO,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAK,0BAAL,kBAAKC,6BAAL;AACL,EAAAA,yBAAA,8BAA2B;AAC3B,EAAAA,yBAAA,oBAAiB;AACjB,EAAAA,yBAAA,oBAAiB;AACjB,EAAAA,yBAAA,uBAAoB;AACpB,EAAAA,yBAAA,yBAAsB;AAEtB,EAAAA,yBAAA,qBAAkB;AAPR,SAAAA;AAAA,GAAA;AAWL,IAAK,2BAAL,kBAAKC,8BAAL;AACL,EAAAA,0BAAA,cAAW;AACX,EAAAA,0BAAA,aAAU;AACV,EAAAA,0BAAA,oBAAiB;AACjB,EAAAA,0BAAA,eAAY;AACZ,EAAAA,0BAAA,gBAAa;AACb,EAAAA,0BAAA,gBAAa;AACb,EAAAA,0BAAA,qBAAkB;AAClB,EAAAA,0BAAA,aAAU;AAEV,EAAAA,0BAAA,qBAAkB;AAVR,SAAAA;AAAA,GAAA;",
|
|
6
|
+
"names": ["CredentialScope", "InferenceBillTo", "InferenceSourceKind", "CredentialFailureReason", "CredentialFallbackReason"]
|
|
7
|
+
}
|
|
@@ -9,6 +9,7 @@ const createLocalChannelContext = (options) => {
|
|
|
9
9
|
client: async () => unavailable(),
|
|
10
10
|
verify: async () => unavailable(),
|
|
11
11
|
exchange: async () => unavailable(),
|
|
12
|
+
redirect: async () => unavailable(),
|
|
12
13
|
connect: async () => unavailable(),
|
|
13
14
|
secret: options.secret,
|
|
14
15
|
fetch: async (input, init) => {
|
|
@@ -20,13 +21,14 @@ const createLocalChannelContext = (options) => {
|
|
|
20
21
|
binding: {
|
|
21
22
|
id: "local",
|
|
22
23
|
url: options.url ?? "http://localhost",
|
|
23
|
-
owner: { kind: "
|
|
24
|
+
owner: { kind: "install", installId: "local" }
|
|
24
25
|
},
|
|
25
26
|
config: options.config ?? {},
|
|
26
27
|
credentials: {
|
|
27
28
|
client: () => credentials.client(),
|
|
28
29
|
verify: (value) => credentials.verify(value),
|
|
29
30
|
exchange: (value) => credentials.exchange(value),
|
|
31
|
+
redirect: (value) => credentials.redirect(value),
|
|
30
32
|
connect: (value) => credentials.connect(value),
|
|
31
33
|
fetch: (input, init) => credentials.fetch(input, init),
|
|
32
34
|
secret: options.secret
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/local-channel-context.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ChannelReceiveContextIface, ChannelCredentialsIface } from \"./channel.mjs\";\nimport type { JsonObject } from \"./json.mjs\";\nexport interface LocalChannelContextOptionsIface {\n config?: JsonObject;\n secret(name: string): Promise<string | null>;\n credentials?: ChannelCredentialsIface;\n url?: string;\n fetch?: typeof fetch;\n}\n// Local route previews can validate and log ingress; authenticated platform operations require a host.\nexport const createLocalChannelContext = (\n options: LocalChannelContextOptionsIface,\n): ChannelReceiveContextIface => {\n const unavailable = (): never => {\n throw new Error('This channel operation needs an authenticated Final host.');\n };\n const noStream = (): AsyncIterable<never> => ({\n [Symbol.asyncIterator]: () => ({ next: async () => unavailable() }),\n });\n const credentials: ChannelCredentialsIface = options.credentials ?? {\n client: async () => unavailable(),\n verify: async () => unavailable(),\n exchange: async () => unavailable(),\n connect: async () => unavailable(),\n secret: options.secret,\n fetch: async (input, init) => {\n if (init?.credential != null && init.credential.kind !== 'none') return unavailable();\n return (options.fetch ?? globalThis.fetch)(input, { ...init, redirect: 'manual' });\n },\n };\n return {\n binding: {\n id: 'local',\n url: options.url ?? 'http://localhost',\n owner: { kind: '
|
|
5
|
-
"mappings": "AAUO,MAAM,4BAA4B,CACvC,YAC+B;AAC/B,QAAM,cAAc,MAAa;AAC/B,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,QAAM,WAAW,OAA6B;AAAA,IAC5C,CAAC,OAAO,aAAa,GAAG,OAAO,EAAE,MAAM,YAAY,YAAY,EAAE;AAAA,EACnE;AACA,QAAM,cAAuC,QAAQ,eAAe;AAAA,IAClE,QAAQ,YAAY,YAAY;AAAA,IAChC,QAAQ,YAAY,YAAY;AAAA,IAChC,UAAU,YAAY,YAAY;AAAA,IAClC,SAAS,YAAY,YAAY;AAAA,IACjC,QAAQ,QAAQ;AAAA,IAChB,OAAO,OAAO,OAAO,SAAS;AAC5B,UAAI,MAAM,cAAc,QAAQ,KAAK,WAAW,SAAS,OAAQ,QAAO,YAAY;AACpF,cAAQ,QAAQ,SAAS,WAAW,OAAO,OAAO,EAAE,GAAG,MAAM,UAAU,SAAS,CAAC;AAAA,IACnF;AAAA,EACF;AACA,SAAO;AAAA,IACL,SAAS;AAAA,MACP,IAAI;AAAA,MACJ,KAAK,QAAQ,OAAO;AAAA,MACpB,OAAO,EAAE,MAAM,
|
|
4
|
+
"sourcesContent": ["import type { ChannelReceiveContextIface, ChannelCredentialsIface } from \"./channel.mjs\";\nimport type { JsonObject } from \"./json.mjs\";\nexport interface LocalChannelContextOptionsIface {\n config?: JsonObject;\n secret(name: string): Promise<string | null>;\n credentials?: ChannelCredentialsIface;\n url?: string;\n fetch?: typeof fetch;\n}\n// Local route previews can validate and log ingress; authenticated platform operations require a host.\nexport const createLocalChannelContext = (\n options: LocalChannelContextOptionsIface,\n): ChannelReceiveContextIface => {\n const unavailable = (): never => {\n throw new Error('This channel operation needs an authenticated Final host.');\n };\n const noStream = (): AsyncIterable<never> => ({\n [Symbol.asyncIterator]: () => ({ next: async () => unavailable() }),\n });\n const credentials: ChannelCredentialsIface = options.credentials ?? {\n client: async () => unavailable(),\n verify: async () => unavailable(),\n exchange: async () => unavailable(),\n redirect: async () => unavailable(),\n connect: async () => unavailable(),\n secret: options.secret,\n fetch: async (input, init) => {\n if (init?.credential != null && init.credential.kind !== 'none') return unavailable();\n return (options.fetch ?? globalThis.fetch)(input, { ...init, redirect: 'manual' });\n },\n };\n return {\n binding: {\n id: 'local',\n url: options.url ?? 'http://localhost',\n owner: { kind: 'install', installId: 'local' },\n },\n config: options.config ?? {},\n credentials: {\n client: () => credentials.client(),\n verify: (value) => credentials.verify(value),\n exchange: (value) => credentials.exchange(value),\n redirect: (value) => credentials.redirect(value),\n connect: (value) => credentials.connect(value),\n fetch: (input, init) => credentials.fetch(input, init),\n secret: options.secret,\n },\n people: {\n resolve: async () => unavailable(),\n identify: async () => unavailable(),\n confirm: async () => unavailable(),\n revoke: async () => unavailable(),\n },\n places: {\n resolve: async () => unavailable(),\n observers: async () => unavailable(),\n connect: async () => unavailable(),\n disconnect: async () => unavailable(),\n follow: async () => unavailable(),\n unfollow: async () => unavailable(),\n },\n conversation: () => ({\n post: async () => unavailable(),\n input: async () => unavailable(),\n attach: async () => unavailable(),\n edit: async () => unavailable(),\n remove: async () => unavailable(),\n react: async () => unavailable(),\n }),\n observe: noStream,\n decisions: { resolve: async () => unavailable() },\n turns: { cancel: async () => unavailable() },\n store: { get: async () => unavailable(), set: async () => unavailable() },\n log: () => undefined,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAUO,MAAM,4BAA4B,CACvC,YAC+B;AAC/B,QAAM,cAAc,MAAa;AAC/B,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,QAAM,WAAW,OAA6B;AAAA,IAC5C,CAAC,OAAO,aAAa,GAAG,OAAO,EAAE,MAAM,YAAY,YAAY,EAAE;AAAA,EACnE;AACA,QAAM,cAAuC,QAAQ,eAAe;AAAA,IAClE,QAAQ,YAAY,YAAY;AAAA,IAChC,QAAQ,YAAY,YAAY;AAAA,IAChC,UAAU,YAAY,YAAY;AAAA,IAClC,UAAU,YAAY,YAAY;AAAA,IAClC,SAAS,YAAY,YAAY;AAAA,IACjC,QAAQ,QAAQ;AAAA,IAChB,OAAO,OAAO,OAAO,SAAS;AAC5B,UAAI,MAAM,cAAc,QAAQ,KAAK,WAAW,SAAS,OAAQ,QAAO,YAAY;AACpF,cAAQ,QAAQ,SAAS,WAAW,OAAO,OAAO,EAAE,GAAG,MAAM,UAAU,SAAS,CAAC;AAAA,IACnF;AAAA,EACF;AACA,SAAO;AAAA,IACL,SAAS;AAAA,MACP,IAAI;AAAA,MACJ,KAAK,QAAQ,OAAO;AAAA,MACpB,OAAO,EAAE,MAAM,WAAW,WAAW,QAAQ;AAAA,IAC/C;AAAA,IACA,QAAQ,QAAQ,UAAU,CAAC;AAAA,IAC3B,aAAa;AAAA,MACX,QAAQ,MAAM,YAAY,OAAO;AAAA,MACjC,QAAQ,CAAC,UAAU,YAAY,OAAO,KAAK;AAAA,MAC3C,UAAU,CAAC,UAAU,YAAY,SAAS,KAAK;AAAA,MAC/C,UAAU,CAAC,UAAU,YAAY,SAAS,KAAK;AAAA,MAC/C,SAAS,CAAC,UAAU,YAAY,QAAQ,KAAK;AAAA,MAC7C,OAAO,CAAC,OAAO,SAAS,YAAY,MAAM,OAAO,IAAI;AAAA,MACrD,QAAQ,QAAQ;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,YAAY,YAAY;AAAA,MACjC,UAAU,YAAY,YAAY;AAAA,MAClC,SAAS,YAAY,YAAY;AAAA,MACjC,QAAQ,YAAY,YAAY;AAAA,IAClC;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,YAAY,YAAY;AAAA,MACjC,WAAW,YAAY,YAAY;AAAA,MACnC,SAAS,YAAY,YAAY;AAAA,MACjC,YAAY,YAAY,YAAY;AAAA,MACpC,QAAQ,YAAY,YAAY;AAAA,MAChC,UAAU,YAAY,YAAY;AAAA,IACpC;AAAA,IACA,cAAc,OAAO;AAAA,MACnB,MAAM,YAAY,YAAY;AAAA,MAC9B,OAAO,YAAY,YAAY;AAAA,MAC/B,QAAQ,YAAY,YAAY;AAAA,MAChC,MAAM,YAAY,YAAY;AAAA,MAC9B,QAAQ,YAAY,YAAY;AAAA,MAChC,OAAO,YAAY,YAAY;AAAA,IACjC;AAAA,IACA,SAAS;AAAA,IACT,WAAW,EAAE,SAAS,YAAY,YAAY,EAAE;AAAA,IAChD,OAAO,EAAE,QAAQ,YAAY,YAAY,EAAE;AAAA,IAC3C,OAAO,EAAE,KAAK,YAAY,YAAY,GAAG,KAAK,YAAY,YAAY,EAAE;AAAA,IACxE,KAAK,MAAM;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Capability, type CapabilityAccess } from '@finalai/agent-protocol';
|
|
2
|
+
import { HarnessComputeStatus, RequirementKind, RequirementProblem, type ResolvedProvideDocumentIface } from '@finalai/agent-protocol/agent-platform';
|
|
3
|
+
import { type AgentDocumentIface } from "./document.mjs";
|
|
4
|
+
import { type HarnessSuitabilityArgsIface } from "./harness-requirements.mjs";
|
|
5
|
+
export interface UnmetIface {
|
|
6
|
+
kind: RequirementKind;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string | null;
|
|
9
|
+
problem: RequirementProblem;
|
|
10
|
+
detail: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface ProvidedSandboxIface {
|
|
13
|
+
capabilities: Partial<Record<Capability, CapabilityAccess>>;
|
|
14
|
+
}
|
|
15
|
+
export interface HarnessCheckInputIface extends Omit<HarnessSuitabilityArgsIface, 'document'> {
|
|
16
|
+
compute: Partial<Record<Capability, HarnessComputeStatus>>;
|
|
17
|
+
environment?: string | null;
|
|
18
|
+
awaitsEnvironment?: boolean;
|
|
19
|
+
enforces?: Partial<Record<Capability, readonly CapabilityAccess[]>>;
|
|
20
|
+
problems?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface RequirementsCheckArgsIface {
|
|
23
|
+
document: AgentDocumentIface;
|
|
24
|
+
provide: ResolvedProvideDocumentIface;
|
|
25
|
+
harness: HarnessCheckInputIface | null;
|
|
26
|
+
sandbox: (id: string) => ProvidedSandboxIface | null;
|
|
27
|
+
integrationExists: (id: string) => boolean;
|
|
28
|
+
inProcessCodeAvailable?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const unmetRequirements: (args: RequirementsCheckArgsIface) => UnmetIface[];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Capability,
|
|
3
|
+
capabilityAccessCovers,
|
|
4
|
+
DEFAULT_CAPABILITY_ACCESS as FULL_ACCESS
|
|
5
|
+
} from "@finalai/agent-protocol";
|
|
6
|
+
import {
|
|
7
|
+
HarnessComputeStatus,
|
|
8
|
+
RequirementKind,
|
|
9
|
+
RequirementProblem
|
|
10
|
+
} from "@finalai/agent-protocol/agent-platform";
|
|
11
|
+
import { computeRequirementsOf, inProcessCodeOf } from "./document.mjs";
|
|
12
|
+
import { harnessUnsuitability } from "./harness-requirements.mjs";
|
|
13
|
+
const describe = (text) => text ?? null;
|
|
14
|
+
const unmetRequirements = (args) => {
|
|
15
|
+
const { document, provide } = args;
|
|
16
|
+
const unmet = [];
|
|
17
|
+
if (provide.harness == null || args.harness == null) {
|
|
18
|
+
unmet.push({
|
|
19
|
+
kind: RequirementKind.Harness,
|
|
20
|
+
name: "harness",
|
|
21
|
+
description: null,
|
|
22
|
+
problem: provide.harness == null ? RequirementProblem.NotProvided : RequirementProblem.NotFound,
|
|
23
|
+
detail: provide.harness == null ? null : `Unknown harness ${provide.harness.harness}`
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
const unsuitable = harnessUnsuitability({ ...args.harness, document });
|
|
27
|
+
const details = [...args.harness.problems ?? []];
|
|
28
|
+
if (unsuitable != null) {
|
|
29
|
+
if (unsuitable.missingFeatures.length > 0)
|
|
30
|
+
details.push(`does not support ${unsuitable.missingFeatures.join(", ")}`);
|
|
31
|
+
if (unsuitable.permission != null)
|
|
32
|
+
details.push(
|
|
33
|
+
`runs at ${unsuitable.permission.offered}, above the agent's ceiling of ${unsuitable.permission.ceiling}`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (details.length > 0)
|
|
37
|
+
unmet.push({
|
|
38
|
+
kind: RequirementKind.Harness,
|
|
39
|
+
name: "harness",
|
|
40
|
+
description: null,
|
|
41
|
+
problem: RequirementProblem.Unsuitable,
|
|
42
|
+
detail: `${provide.harness.harness} ${details.join("; ")}`
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const harnessName = provide.harness?.harness ?? "The harness";
|
|
46
|
+
if (args.harness?.awaitsEnvironment === true)
|
|
47
|
+
unmet.push({
|
|
48
|
+
kind: RequirementKind.Compute,
|
|
49
|
+
name: Capability.Shell,
|
|
50
|
+
description: null,
|
|
51
|
+
problem: RequirementProblem.NotProvided,
|
|
52
|
+
detail: `${harnessName} runs in the sandbox provided for shell`
|
|
53
|
+
});
|
|
54
|
+
const compute = provide.compute ?? {};
|
|
55
|
+
const files = compute[Capability.Files];
|
|
56
|
+
const shell = compute[Capability.Shell];
|
|
57
|
+
if (files != null && shell != null && files !== shell)
|
|
58
|
+
unmet.push({
|
|
59
|
+
kind: RequirementKind.Compute,
|
|
60
|
+
name: Capability.Shell,
|
|
61
|
+
description: null,
|
|
62
|
+
problem: RequirementProblem.DifferentSandboxes,
|
|
63
|
+
detail: "`files` and `shell` must be provided by the same sandbox"
|
|
64
|
+
});
|
|
65
|
+
const insufficientAccess = (capability, sandboxId, required) => {
|
|
66
|
+
const sandbox = args.sandbox(sandboxId);
|
|
67
|
+
if (sandbox == null) return null;
|
|
68
|
+
const granted = sandbox.capabilities[capability];
|
|
69
|
+
if (granted == null) return `Sandbox ${sandboxId} does not offer ${capability}`;
|
|
70
|
+
if (!capabilityAccessCovers(granted, required))
|
|
71
|
+
return `Sandbox ${sandboxId} grants ${granted}; the agent requires ${required}`;
|
|
72
|
+
return null;
|
|
73
|
+
};
|
|
74
|
+
for (const [capability, requirement] of computeRequirementsOf(document)) {
|
|
75
|
+
const sandboxId = compute[capability];
|
|
76
|
+
const description = describe(requirement.description);
|
|
77
|
+
const served = args.harness?.compute[capability];
|
|
78
|
+
const fail = (problem, detail) => {
|
|
79
|
+
unmet.push({ kind: RequirementKind.Compute, name: capability, description, problem, detail });
|
|
80
|
+
};
|
|
81
|
+
if (served === HarnessComputeStatus.Unavailable) {
|
|
82
|
+
if (sandboxId != null || !requirement.optional)
|
|
83
|
+
fail(RequirementProblem.Unsuitable, `${harnessName} cannot use ${capability}`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (served === HarnessComputeStatus.Harness) {
|
|
87
|
+
if (args.harness?.awaitsEnvironment === true) continue;
|
|
88
|
+
const environment = args.harness?.environment ?? null;
|
|
89
|
+
if (sandboxId != null && sandboxId !== environment) {
|
|
90
|
+
fail(
|
|
91
|
+
RequirementProblem.Unsuitable,
|
|
92
|
+
environment == null ? `${harnessName} uses ${capability} on its own machine and cannot use a provided sandbox for it` : `${harnessName} uses ${capability} natively in sandbox ${environment}; provide that sandbox for it`
|
|
93
|
+
);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (environment != null) {
|
|
97
|
+
if (args.sandbox(environment) == null) {
|
|
98
|
+
fail(RequirementProblem.NotFound, `No sandbox ${environment} in this project`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const access2 = insufficientAccess(capability, environment, requirement.access);
|
|
102
|
+
if (access2 != null) {
|
|
103
|
+
fail(RequirementProblem.Unsuitable, access2);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const enforced = args.harness?.enforces?.[capability];
|
|
108
|
+
const full = capabilityAccessCovers(requirement.access, FULL_ACCESS[capability]);
|
|
109
|
+
if (enforced != null && !full && !enforced.includes(requirement.access))
|
|
110
|
+
fail(
|
|
111
|
+
RequirementProblem.Unsuitable,
|
|
112
|
+
`${harnessName} cannot hold ${capability} to ${requirement.access} with its own tools`
|
|
113
|
+
);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (sandboxId == null) {
|
|
117
|
+
if (!requirement.optional) fail(RequirementProblem.NotProvided, null);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (args.sandbox(sandboxId) == null) {
|
|
121
|
+
fail(RequirementProblem.NotFound, `No sandbox ${sandboxId} in this project`);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const access = insufficientAccess(capability, sandboxId, requirement.access);
|
|
125
|
+
if (access != null) fail(RequirementProblem.Unsuitable, access);
|
|
126
|
+
}
|
|
127
|
+
const integrations = provide.integrations ?? {};
|
|
128
|
+
for (const [slot, requirement] of Object.entries(document.require.integrations)) {
|
|
129
|
+
const integrationId = integrations[slot];
|
|
130
|
+
if (integrationId == null) {
|
|
131
|
+
if (!requirement.optional)
|
|
132
|
+
unmet.push({
|
|
133
|
+
kind: RequirementKind.Integration,
|
|
134
|
+
name: slot,
|
|
135
|
+
description: requirement.description,
|
|
136
|
+
problem: RequirementProblem.NotProvided,
|
|
137
|
+
detail: null
|
|
138
|
+
});
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (!args.integrationExists(integrationId))
|
|
142
|
+
unmet.push({
|
|
143
|
+
kind: RequirementKind.Integration,
|
|
144
|
+
name: slot,
|
|
145
|
+
description: requirement.description,
|
|
146
|
+
problem: RequirementProblem.NotFound,
|
|
147
|
+
detail: `No integration ${integrationId} in this project`
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (args.inProcessCodeAvailable !== true)
|
|
151
|
+
for (const name of inProcessCodeOf(document))
|
|
152
|
+
unmet.push({
|
|
153
|
+
kind: RequirementKind.Code,
|
|
154
|
+
name,
|
|
155
|
+
description: null,
|
|
156
|
+
problem: RequirementProblem.CodeUnavailable,
|
|
157
|
+
detail: `${name} only runs in the process that holds its code`
|
|
158
|
+
});
|
|
159
|
+
return unmet;
|
|
160
|
+
};
|
|
161
|
+
export {
|
|
162
|
+
unmetRequirements
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=requirements-check.mjs.map
|