capable-kit 0.1.0-alpha.10 → 0.1.0-alpha.11
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/CHANGELOG.md +171 -0
- package/LICENSE +21 -0
- package/README.md +6 -0
- package/dist/ai-sdk.d.mts +2 -2
- package/dist/ai-sdk.mjs +1 -1
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +1 -1
- package/dist/bin.mjs +19 -15
- package/dist/bin.mjs.map +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +2 -2
- package/dist/eve.d.mts +20 -14
- package/dist/eve.mjs +450 -211
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-WiBWfyTn.d.mts → index-BIO_hbXJ.d.mts} +8 -2
- package/dist/{index-D-NV4PiU.d.mts → index-C0tU5Y2n.d.mts} +4 -4
- package/dist/{index-CHuCLJIs.d.mts → index-CwvjDizW.d.mts} +5 -3
- package/dist/{index-1A44jLuE.d.mts → index-F_eaksy8.d.mts} +7 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/mcp.d.mts +14 -4
- package/dist/mcp.mjs +2 -2
- package/dist/{mount-BmLHp349.mjs → mount-pvIaehZC.mjs} +148 -104
- package/dist/mount-pvIaehZC.mjs.map +1 -0
- package/dist/react-query.d.mts +1 -1
- package/dist/react-query.mjs +1 -1
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +3 -3
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-_6OmFRYa.mjs → src-Bk3lEhI7.mjs} +38 -18
- package/dist/src-Bk3lEhI7.mjs.map +1 -0
- package/dist/{src-DePlcG_t.mjs → src-C2OEkZ3c.mjs} +38 -65
- package/dist/src-C2OEkZ3c.mjs.map +1 -0
- package/dist/{src-C5jGDnuu.mjs → src-DFrxQ_S6.mjs} +9 -7
- package/dist/src-DFrxQ_S6.mjs.map +1 -0
- package/dist/{src-3LE9S4QE.mjs → src-DklM1g7V.mjs} +5 -5
- package/dist/src-DklM1g7V.mjs.map +1 -0
- package/dist/{src-B2WeUwUT.mjs → src-TCQGaWar.mjs} +60 -18
- package/dist/src-TCQGaWar.mjs.map +1 -0
- package/dist/{subscription-DPdwovhw.d.mts → subscription-fVgS4T8P.d.mts} +2 -2
- package/dist/swr.d.mts +1 -1
- package/dist/swr.mjs +1 -1
- package/docs/CONTEXT.md +5 -2
- package/docs/internal/eve-recovery-validation.md +12 -11
- package/docs/internal/implementation-friction.md +59 -0
- package/docs/site/concepts/errors.mdx +15 -3
- package/docs/site/hosting/standalone-server.mdx +2 -0
- package/docs/site/patterns/remote-apps.mdx +23 -1
- package/docs/site/quickstart.mdx +2 -1
- package/docs/site/reference/packages-and-entry-points.mdx +2 -1
- package/docs/site/reference/the-cap-cli.mdx +2 -2
- package/docs/site/surfaces/eve.mdx +6 -4
- package/docs/site/surfaces/mcp.mdx +84 -2
- package/package.json +13 -7
- package/src/index.ts +2 -0
- package/src/package.test.ts +6 -0
- package/dist/mount-BmLHp349.mjs.map +0 -1
- package/dist/src-3LE9S4QE.mjs.map +0 -1
- package/dist/src-B2WeUwUT.mjs.map +0 -1
- package/dist/src-C5jGDnuu.mjs.map +0 -1
- package/dist/src-DePlcG_t.mjs.map +0 -1
- package/dist/src-_6OmFRYa.mjs.map +0 -1
package/dist/eve.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eve.mjs","names":[],"sources":["../../eve/src/agent-presentation.ts","../../eve/src/agent.ts","../../eve/src/index.ts"],"sourcesContent":["import type { EveAgentResult } from \"./agent.ts\";\n\n/** Portable presentation shared by the CLI and other presentation-aware surfaces. */\nexport function presentAgentResult(result: EveAgentResult & { runId?: string }): string {\n const status = {\n running: \"Running. Check the result again to follow progress.\",\n waiting: \"Waiting for input.\",\n completed: \"Completed.\",\n failed: \"Agent execution failed.\",\n cancelled: \"Cancelled.\",\n }[result.status];\n const parts = [status];\n if (result.text) parts.push(result.text);\n if (result.data !== undefined) parts.push(JSON.stringify(result.data, null, 2));\n if (result.textTruncated) parts.push(\"The answer was truncated.\");\n if (result.dataOmitted) parts.push(\"Structured output was too large to include.\");\n for (const request of result.requests) {\n parts.push(request.prompt);\n parts.push(`Request ID: ${request.requestId}`);\n if (request.options?.length) {\n parts.push(request.options.map(option => `- ${option.label} (option ID: ${option.id})${option.description ? ` — ${option.description}` : \"\"}`).join(\"\\n\"));\n }\n if (request.allowFreeform === false || (request.options?.length && request.allowFreeform !== true)) {\n parts.push(\"Reply with an option ID.\");\n }\n }\n if (result.requiresHostInput) parts.push(\"Approval or authorization must be completed through the Eve host.\");\n if (result.runId) parts.push(`Run ID: ${result.runId}`);\n return parts.join(\"\\n\\n\");\n}\n","import { createApp, type App } from \"@capable/app\";\nimport { capability, defineApp, type CapabilityDefinition, type DefinedErrors, type Schema } from \"@capable/core\";\nimport type { Client } from \"eve/client\";\nimport { z } from \"zod\";\nimport { presentAgentResult } from \"./agent-presentation.ts\";\n\nconst runInput = z.object({ runId: z.string().min(1).describe(\"Eve session ID returned by send.\") });\nconst question = z.object({\n requestId: z.string(),\n prompt: z.string(),\n display: z.enum([\"confirmation\", \"select\", \"text\"]).optional(),\n allowFreeform: z.boolean().optional(),\n options: z.array(z.object({ id: z.string(), label: z.string(), description: z.string().optional() })).optional(),\n});\nconst resultSchema = z.object({\n status: z.enum([\"running\", \"waiting\", \"completed\", \"failed\", \"cancelled\"]),\n cursor: z.number().int().nonnegative(),\n eventCount: z.number().int().nonnegative(),\n requests: z.array(question),\n text: z.string().optional(),\n data: z.json().optional(),\n dataOmitted: z.boolean().optional(),\n textTruncated: z.boolean().optional(),\n requiresHostInput: z.boolean().optional(),\n error: z.string().optional(),\n});\nexport interface EveAgentQuestion {\n requestId: string;\n prompt: string;\n display?: \"confirmation\" | \"select\" | \"text\" | undefined;\n allowFreeform?: boolean | undefined;\n options?: { id: string; label: string; description?: string | undefined }[] | undefined;\n}\nexport type EveAgentData = string | number | boolean | null | EveAgentData[] | { [key: string]: EveAgentData };\nexport interface EveAgentResult {\n status: \"running\" | \"waiting\" | \"completed\" | \"failed\" | \"cancelled\";\n cursor: number;\n eventCount: number;\n requests: EveAgentQuestion[];\n text?: string | undefined;\n data?: EveAgentData | undefined;\n dataOmitted?: boolean | undefined;\n textTruncated?: boolean | undefined;\n requiresHostInput?: boolean | undefined;\n error?: string | undefined;\n}\n\ntype AgentCapability<TInput extends Record<string, unknown>, TOutput, TParsed extends Record<string, unknown> = TInput> =\n CapabilityDefinition<undefined, Schema<TInput, TParsed>, TOutput, DefinedErrors<{}>, {}, \"unary\">;\ntype AgentCapabilities = {\n send: AgentCapability<{\n message: string; runId?: string | undefined; requestId?: string | undefined;\n optionId?: string | undefined; wait?: boolean | undefined; timeoutMs?: number | undefined;\n }, EveAgentResult & { runId: string }>;\n result: AgentCapability<{ runId: string; cursor?: number | undefined }, EveAgentResult, { runId: string; cursor: number }>;\n cancel: AgentCapability<{ runId: string; turnId?: string | undefined }, { status: \"accepted\" | \"no_active_turn\" }>;\n};\nexport interface EveAgentAdapter<TName extends string> {\n readonly app: App<{ [K in TName]: AgentCapabilities }>;\n /** Abort local requests without cancelling remote execution. */\n dispose(): void;\n}\nexport type EveAgentOperation = \"send\" | \"result\" | \"cancel\";\n\nexport interface EveAgentAdapterOptions<TName extends string> {\n /** Namespace and capability ID prefix; unique within the composed App. */\n readonly name: TName;\n /** Host-configured client for ONE authenticated caller. Never share an adapter across callers. */\n readonly client: Pick<Client, \"sessions\">;\n /** Recheck host-owned authorization on every invocation, including reconstructed reads. Throw to deny. */\n readonly authorize: (operation: EveAgentOperation, runId?: string) => void | Promise<void>;\n readonly maxEventsPerRead?: number;\n readonly readTimeoutMs?: number;\n}\n\ntype Run = {\n sessionId: string;\n result: EveAgentResult;\n cancelled: boolean;\n hostInputs: Set<string>;\n authorizations: Set<string>;\n message: string | undefined;\n data: EveAgentData | undefined;\n dataOmitted: boolean;\n pending: Map<string, z.infer<typeof question>>;\n};\n\n/**\n * Wrap Eve execution as a caller-scoped Capable App.\n * Eve session IDs are run IDs. Every read reconstructs state from durable events.\n */\nexport function createEveAgentAdapter<const TName extends string>(options: EveAgentAdapterOptions<TName>): EveAgentAdapter<TName> {\n if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(options.name)) throw new Error(\"Invalid Eve agent namespace\");\n const maxEvents = positive(options.maxEventsPerRead ?? 10_000, \"maxEventsPerRead\");\n const timeoutMs = positive(options.readTimeoutMs ?? 1_000, \"readTimeoutMs\");\n const lifetime = new AbortController();\n\n async function authorize(operation: EveAgentOperation, runId?: string) {\n lifetime.signal.throwIfAborted();\n await options.authorize(operation, runId);\n lifetime.signal.throwIfAborted();\n }\n function signalFor(signal?: AbortSignal) {\n return AbortSignal.any([lifetime.signal, ...(signal ? [signal] : [])]);\n }\n async function readRun(runId: string, signal?: AbortSignal): Promise<Run> {\n const run: Run = {\n sessionId: runId,\n result: { status: \"running\", cursor: 0, eventCount: 0, requests: [] },\n cancelled: false, hostInputs: new Set(), authorizations: new Set(),\n message: undefined, data: undefined, dataOmitted: false, pending: new Map(),\n };\n const requestSignal = signalFor(signal);\n requestSignal.throwIfAborted();\n const read = new AbortController();\n const timer = setTimeout(() => read.abort(), timeoutMs);\n const combined = AbortSignal.any([requestSignal, read.signal]);\n try {\n const session = options.client.sessions.attach(runId);\n for await (const event of session.stream({ startIndex: 0, follow: false, signal: combined, streamReconnectPolicy: { reconnect: false } })) {\n if (run.result.cursor >= maxEvents) throw new Error(\"Eve history exceeds maxEventsPerRead\");\n if (event.type === \"input.requested\") {\n for (const request of event.data.requests) {\n if (request.kind === \"question\") {\n // Deliberate allowlist: no action input, tool names, IDs, or credentials.\n const safe = question.parse(request);\n if (JSON.stringify(safe).length > 65_536 || (!run.pending.has(safe.requestId) && run.pending.size >= 100)) throw new Error(\"Eve question limit exceeded\");\n run.pending.set(safe.requestId, safe);\n } else {\n remember(run.hostInputs, request.requestId);\n }\n }\n } else if (event.type === \"authorization.required\") {\n remember(run.authorizations, event.data.name);\n } else if (event.type === \"authorization.completed\") {\n run.authorizations.delete(event.data.name);\n } else if (event.type === \"input.resolved\") {\n for (const resolution of event.data.resolutions) {\n run.pending.delete(resolution.requestId);\n run.hostInputs.delete(resolution.requestId);\n }\n run.result.requests = [...run.pending.values()];\n } else if (event.type === \"turn.started\" || event.type === \"step.started\") {\n run.result = { status: \"running\", cursor: run.result.cursor, eventCount: 0, requests: [] };\n if (event.type === \"turn.started\") {\n run.cancelled = false;\n run.message = undefined;\n run.data = undefined;\n run.dataOmitted = false;\n }\n } else if (event.type === \"message.completed\" && event.data.finishReason !== \"tool-calls\") {\n run.message = event.data.message?.slice(0, 65_536);\n run.result.textTruncated = (event.data.message?.length ?? 0) > 65_536;\n } else if (event.type === \"result.completed\") {\n run.dataOmitted = JSON.stringify(event.data.result).length > 65_536;\n run.data = run.dataOmitted ? undefined : z.json().parse(event.data.result);\n } else if (event.type === \"turn.cancelled\") {\n run.cancelled = true;\n } else if (event.type === \"session.failed\" || event.type === \"turn.failed\") {\n run.result.status = \"failed\";\n // Raw failure details can include private tool arguments or credentials.\n run.result.error = \"Eve agent execution failed\";\n } else if (event.type === \"session.completed\" || event.type === \"session.waiting\") {\n run.result.status = run.cancelled ? \"cancelled\"\n : event.type === \"session.waiting\" && (run.pending.size > 0 || (run.hostInputs.size > 0 || run.authorizations.size > 0) || (run.message === undefined && run.data === undefined && !run.dataOmitted)) ? \"waiting\" : \"completed\";\n if (run.result.status === \"completed\" && run.message !== undefined) run.result.text = run.message;\n if (run.result.status === \"completed\") {\n run.result.requests = [];\n delete run.result.requiresHostInput;\n if (run.data !== undefined) run.result.data = run.data;\n if (run.dataOmitted) run.result.dataOmitted = true;\n }\n if (run.result.status === \"waiting\") {\n run.result.requests = [...run.pending.values()];\n run.result.requiresHostInput = (run.hostInputs.size > 0 || run.authorizations.size > 0) || run.pending.size === 0;\n }\n }\n\n run.result.cursor++;\n }\n // Eve can swallow stream aborts. Never validate an answer against partial history.\n combined.throwIfAborted();\n return run;\n } finally {\n clearTimeout(timer);\n read.abort();\n }\n }\n\n const capabilities = {\n send: capability({\n id: `${options.name}.send`, effect: \"write\",\n description: \"Send a message, optionally continuing an Eve session and waiting for its answer.\",\n meta: { cli: { positional: [\"message\"] } },\n input: z.object({\n message: z.string().min(1).max(65_536).describe(\"Message to send, or a text answer to a pending question. With option-id, only the selected option is submitted.\"),\n runId: z.string().min(1).optional().describe(\"Continue this Eve session. Omit to begin a new conversation.\"),\n requestId: z.string().min(1).optional().describe(\"Pending question to answer. Required when several questions are waiting; use with run-id.\"),\n optionId: z.string().min(1).optional().describe(\"Answer option ID shown by result. Required for questions that do not accept freeform text; use with run-id.\"),\n wait: z.boolean().optional().describe(\"Wait for an answer, pending input, failure, or cancellation. Otherwise return the run ID immediately.\"),\n timeoutMs: z.number().int().min(1).max(300_000).optional().describe(\"Wait limit in milliseconds after acceptance (default: 30000; maximum: 300000). Only used with wait. Expiry leaves Eve running.\"),\n }),\n output: resultSchema.extend({ runId: z.string() }),\n toPresentation: presentAgentResult,\n handler: async ({ input, signal }) => {\n await authorize(\"send\", input.runId);\n if (!input.runId && (input.requestId || input.optionId)) throw new Error(\"Question answers require a runId\");\n const waiting = new AbortController();\n const requestSignal = AbortSignal.any([signalFor(signal), waiting.signal]);\n const sendOptions = { signal: requestSignal, streamReconnectPolicy: { reconnect: false as const } };\n let response;\n if (input.runId) {\n const run = await readRun(input.runId, signal);\n const session = options.client.sessions.attach(input.runId, { streamIndex: run.result.cursor });\n if (input.requestId || run.pending.size) {\n const pending = input.requestId ? run.pending.get(input.requestId)\n : run.pending.size === 1 ? [...run.pending.values()][0] : undefined;\n if (!pending || run.result.status !== \"waiting\") throw new Error(\"Specify requestId for a current pending question\");\n if (input.optionId) {\n if (!pending.options?.some(option => option.id === input.optionId)) throw new Error(\"Unknown answer option\");\n } else if (pending.allowFreeform === false || (pending.options?.length && pending.allowFreeform !== true)) {\n throw new Error(\"This question requires optionId\");\n }\n response = await session.respond([{\n requestId: pending.requestId,\n ...(input.optionId ? { optionId: input.optionId } : { text: input.message }),\n }], sendOptions);\n } else {\n if (input.optionId) throw new Error(\"No pending question for optionId\");\n if (run.hostInputs.size || run.authorizations.size) throw new Error(\"Pending approval or authorization requires host action\");\n response = await session.send(input.message, sendOptions);\n }\n if (response.sessionId !== input.runId) throw new Error(\"Eve resumed a different session\");\n } else {\n ({ response } = await options.client.sessions.create({ message: input.message, ...sendOptions }));\n }\n const runId = response.sessionId;\n const accepted = { runId, status: \"running\" as const, cursor: 0, eventCount: 0, requests: [] };\n if (!input.wait) return accepted;\n // Eve correlates this stream with the accepted delivery, skipping old turn boundaries.\n // The timer starts after acceptance; aborting this local stream never cancels Eve.\n const timer = setTimeout(() => waiting.abort(), input.timeoutMs ?? 30_000);\n try {\n let count = 0;\n let boundary = false;\n for await (const event of response) {\n requestSignal.throwIfAborted();\n if (++count > maxEvents) throw new Error(\"Eve response exceeds maxEventsPerRead\");\n if ([\"session.waiting\", \"session.completed\", \"session.failed\", \"turn.failed\"].includes(event.type)) {\n boundary = true;\n break;\n }\n }\n requestSignal.throwIfAborted();\n if (!boundary) return accepted;\n const run = await readRun(runId, requestSignal);\n return { runId, ...run.result, eventCount: run.result.cursor };\n } catch (error) {\n signalFor(signal).throwIfAborted();\n if (waiting.signal.aborted) return accepted;\n throw error;\n } finally {\n clearTimeout(timer);\n waiting.abort();\n }\n },\n }),\n result: capability({\n id: `${options.name}.result`, effect: \"read\",\n description: \"Read bounded progress, pending questions, or the final output. Pass the last returned cursor.\",\n input: runInput.extend({ cursor: z.number().int().nonnegative().default(0).describe(\"Cursor from the previous result, used to count new events. Defaults to 0; the full current result is still returned.\") }),\n output: resultSchema,\n toPresentation: presentAgentResult,\n handler: async ({ input, signal }) => {\n await authorize(\"result\", input.runId);\n const run = await readRun(input.runId, signal);\n if (input.cursor > run.result.cursor) throw new Error(\"Eve cursor is ahead of this run\");\n return { ...run.result, eventCount: run.result.cursor - input.cursor };\n },\n }),\n cancel: capability({\n id: `${options.name}.cancel`, effect: \"write\",\n description: \"Request cooperative cancellation of the active Eve turn. Acceptance is not completion.\",\n input: runInput.extend({ turnId: z.string().min(1).optional().describe(\"Specific Eve turn to cancel. Omit to cancel the session’s active turn.\") }),\n output: z.object({ status: z.enum([\"accepted\", \"no_active_turn\"]) }),\n toPresentation: ({ status }) => status === \"accepted\"\n ? \"Cancellation requested. Check the result to confirm execution has stopped.\"\n : \"No active turn to cancel.\",\n handler: async ({ input, signal }) => {\n await authorize(\"cancel\", input.runId);\n signalFor(signal).throwIfAborted();\n // Cancellation can run alongside a bounded result read.\n const result = await options.client.sessions.attach(input.runId).cancel({\n signal: signalFor(signal),\n ...(input.turnId ? { turnId: input.turnId } : {}),\n });\n return { status: result.status };\n },\n }),\n };\n // Widen the key during construction: TypeScript cannot reduce context inference\n // for a generic mapped namespace, although all three capabilities are context-free.\n const checked: AgentCapabilities = capabilities;\n const app = createApp(defineApp({ capabilities: { [options.name]: checked } })) as App<{ [K in TName]: AgentCapabilities }>;\n return {\n app,\n dispose() {\n lifetime.abort();\n },\n };\n}\n\nfunction positive(value: number, name: string) {\n if (!Number.isSafeInteger(value) || value < 1) throw new Error(`${name} must be a positive safe integer`);\n return value;\n}\n\nfunction remember(values: Set<string>, value: string) {\n if (value.length > 65_536 || (!values.has(value) && values.size >= 100)) {\n throw new Error(\"Eve pending input limit exceeded\");\n }\n values.add(value);\n}\n","import {\n getAppRuntime,\n getCapabilityDisplay,\n flattenManifestCapabilities,\n type AnyApp,\n type ManifestCapability,\n} from \"@capable/app\";\nimport type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n defineDynamic,\n defineTool,\n defineDurableCallback,\n type DynamicResolveContext,\n type DynamicSentinel,\n type ToolDefinition,\n type ToolContext,\n} from \"eve/tools\";\nimport type { Approval } from \"eve/tools/approval\";\n\nexport type EveCapabilityMeta =\n | false\n | {\n readonly name?: string;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly eve?: EveCapabilityMeta;\n }\n}\n\nexport type CreateEveToolsOptions = {\n readonly approval?: (\n capability: ManifestCapability,\n ) => Approval | undefined;\n};\n\nexport type EveAppProvider =\n | AnyApp\n | ((\n context: DynamicResolveContext,\n ) => AnyApp | Promise<AnyApp>);\n\nconst emptyInputSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\ntype EveTool = ToolDefinition<Record<string, unknown>, unknown>;\n\n/**\n * Projects an executable Capable App into native, in-process Eve tools.\n *\n * Eve owns the live executor bindings and checkpoints each call and result.\n * Session resolvers rebuild App bindings after a cold start. Define the App or\n * provider in deployed module code and keep persistent data outside the process.\n */\nexport function createEveTools(\n app: EveAppProvider,\n options: CreateEveToolsOptions = {},\n): DynamicSentinel<Record<string, EveTool>> {\n const capabilitiesByApp = new WeakMap<\n AnyApp,\n Promise<readonly ManifestCapability[]>\n >();\n const capabilities = (resolvedApp: AnyApp) => {\n const existing = capabilitiesByApp.get(resolvedApp);\n if (existing) return existing;\n const resolved = getAppRuntime(resolvedApp).manifest().then((manifest) =>\n flattenManifestCapabilities(manifest.capabilities)\n );\n capabilitiesByApp.set(resolvedApp, resolved);\n return resolved;\n };\n\n return defineDynamic({\n events: {\n \"session.started\": async (_event, resolveContext) => {\n const resolvedApp = typeof app === \"function\"\n ? await app(resolveContext)\n : app;\n const tools: Record<string, EveTool> = {};\n const names = new Set<string>();\n\n for (const capability of await capabilities(resolvedApp)) {\n const display = getCapabilityDisplay(capability);\n const meta = capability.meta.eve as EveCapabilityMeta | undefined;\n if (meta === false) continue;\n if (capability.execution === \"events\") {\n if (meta !== undefined) {\n throw new Error(\n `Event Capability \"${capability.id}\" cannot be exposed as an Eve tool`,\n );\n }\n continue;\n }\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `Eve tool name \"${name}\" is invalid; set meta.eve.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (names.has(name)) {\n throw new Error(`Duplicate Eve tool name \"${name}\"`);\n }\n names.add(name);\n\n const policy = options.approval?.(capability);\n const approval = policy && durableApproval(policy, capability.id);\n const definition: Omit<EveTool, \"execute\"> = {\n description:\n display.description ??\n display.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: (capability.input ??\n emptyInputSchema) as EveTool[\"inputSchema\"],\n ...(capability.output\n ? {\n outputSchema:\n capability.output as NonNullable<EveTool[\"outputSchema\"]>,\n }\n : {}),\n ...(approval ? { approval } : {}),\n };\n const id = capability.id;\n tools[name] = defineTool({\n ...definition,\n execute: defineDurableCallback({\n closure: { id },\n callback: async ({ id }, input: Record<string, unknown>, context: ToolContext) => {\n // A rejected approval can change the latest resolver's caller.\n // Rebuild per-caller Apps from the actual execution identity.\n const executionApp = typeof app === \"function\"\n ? await app({ ...resolveContext, session: context.session })\n : app;\n const result = await getAppRuntime(executionApp).call({\n id, input, signal: context.abortSignal,\n });\n return result.output;\n },\n }),\n });\n }\n\n return tools;\n },\n },\n });\n}\n\n/** The resolver reconstructs policies; persist identity and reject rebinding to a different capability. */\nfunction durablePolicy<T extends (...args: never[]) => unknown>(policy: T, id: string): T {\n return defineDurableCallback({\n closure: { id },\n callback: (snapshot, ...args: Parameters<T>) => {\n if (snapshot.id !== id) throw new Error(\"Eve capability identity changed during recovery\");\n return policy(...args);\n },\n }) as T;\n}\n\nfunction durableApproval(policy: Approval, id: string): Approval {\n if (typeof policy === \"function\") return durablePolicy(policy, id);\n return {\n request: durablePolicy(policy.request, id),\n ...(policy.response ? { response: durablePolicy(policy.response, id) } : {}),\n };\n}\n\nexport {\n createEveAgentAdapter,\n type EveAgentAdapter,\n type EveAgentAdapterOptions,\n type EveAgentOperation,\n type EveAgentData,\n type EveAgentQuestion,\n type E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;EACd,WAAW,UAAU,GAAG,SAAwB;GAC9C,IAAI,SAAS,OAAO,IAAI,MAAM,IAAI,MAAM,iDAAiD;GACzF,OAAO,OAAO,GAAG,IAAI;EACvB;CACF,CAAC;AACH;AAEA,SAAS,gBAAgB,QAAkB,IAAsB;CAC/D,IAAI,OAAO,WAAW,YAAY,OAAO,cAAc,QAAQ,EAAE;CACjE,OAAO;EACL,SAAS,cAAc,OAAO,SAAS,EAAE;EACzC,GAAI,OAAO,WAAW,EAAE,UAAU,cAAc,OAAO,UAAU,EAAE,EAAE,IAAI,CAAC;CAC5E;AACF"}
|
|
1
|
+
{"version":3,"file":"eve.mjs","names":["delivery","deliveryOf","sessionOf"],"sources":["../../eve/src/agent-schemas.ts","../../eve/src/agent-presentation.ts","../../eve/src/agent.ts","../../eve/src/index.ts"],"sourcesContent":["import type { Schema } from \"@capable/core\";\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\ntype Direction = \"input\" | \"output\";\ntype JsonSchema = Record<string, unknown>;\ntype Path = readonly PropertyKey[];\n\nclass Invalid extends Error {\n readonly path: Path;\n\n constructor(path: Path, message: string) {\n super(message);\n this.path = path;\n }\n}\n\nfunction fail(path: Path, message: string): never {\n throw new Invalid(path, message);\n}\n\nexport interface Field<\n TInput,\n TOutput,\n TInputOptional extends boolean = false,\n TOutputOptional extends boolean = false,\n> {\n readonly parse: (value: unknown) => TOutput;\n readonly parseAt: (value: unknown, path: Path) => TOutput;\n readonly json: (direction: Direction) => JsonSchema;\n readonly inputOptional: TInputOptional;\n readonly outputOptional: TOutputOptional;\n readonly inputType?: TInput;\n}\n\nfunction field<TInput, TOutput>(\n parseAt: (value: unknown, path: Path) => TOutput,\n json: (direction: Direction) => JsonSchema,\n): Field<TInput, TOutput> {\n return {\n parse: (value) => parseAt(value, []),\n parseAt,\n json,\n inputOptional: false,\n outputOptional: false,\n };\n}\n\nexport function string(\n options: {\n readonly minLength?: number;\n readonly maxLength?: number;\n readonly description?: string;\n } = {},\n): Field<string, string> {\n return field<string, string>((value, path) => {\n if (typeof value !== \"string\") fail(path, \"Expected string\");\n if (options.minLength !== undefined && value.length < options.minLength) {\n fail(path, `Expected at least ${options.minLength} characters`);\n }\n if (options.maxLength !== undefined && value.length > options.maxLength) {\n fail(path, `Expected at most ${options.maxLength} characters`);\n }\n return value;\n }, () => ({\n type: \"string\",\n ...(options.minLength === undefined ? {} : { minLength: options.minLength }),\n ...(options.maxLength === undefined ? {} : { maxLength: options.maxLength }),\n ...(options.description === undefined ? {} : { description: options.description }),\n }));\n}\n\nexport function integer(\n options: {\n readonly minimum?: number;\n readonly maximum?: number;\n readonly description?: string;\n } = {},\n): Field<number, number> {\n const minimum = options.minimum ?? -Number.MAX_SAFE_INTEGER;\n const maximum = options.maximum ?? Number.MAX_SAFE_INTEGER;\n return field<number, number>((value, path) => {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value)) {\n fail(path, \"Expected integer\");\n }\n if (value < minimum) fail(path, `Expected an integer >= ${minimum}`);\n if (value > maximum) fail(path, `Expected an integer <= ${maximum}`);\n return value;\n }, () => ({\n type: \"integer\",\n minimum,\n maximum,\n ...(options.description === undefined ? {} : { description: options.description }),\n }));\n}\n\nexport function boolean(\n options: { readonly description?: string } = {},\n): Field<boolean, boolean> {\n return field<boolean, boolean>((value, path) => {\n if (typeof value !== \"boolean\") fail(path, \"Expected boolean\");\n return value;\n }, () => ({\n type: \"boolean\",\n ...(options.description === undefined ? {} : { description: options.description }),\n }));\n}\n\nexport function enumOf<const T extends string>(\n ...values: readonly T[]\n): Field<T, T> {\n const allowed = new Set<string>(values);\n return field<T, T>((value, path) => {\n if (typeof value !== \"string\" || !allowed.has(value)) {\n fail(path, `Expected one of: ${values.join(\", \")}`);\n }\n return value as T;\n }, () => ({ type: \"string\", enum: [...values] }));\n}\n\nexport function array<TItem>(\n item: Field<TItem, TItem>,\n): Field<TItem[], TItem[]> {\n return field<TItem[], TItem[]>((value, path) => {\n if (!Array.isArray(value)) fail(path, \"Expected array\");\n return Array.from(value, (entry, index) =>\n item.parseAt(entry, [...path, index])\n );\n }, (direction) => ({ type: \"array\", items: item.json(direction) }));\n}\n\nexport function optional<T>(\n item: Field<T, T>,\n): Field<T | undefined, T | undefined, true, true> {\n return {\n parse: (value) => value === undefined ? undefined : item.parse(value),\n parseAt: (value, path) =>\n value === undefined ? undefined : item.parseAt(value, path),\n json: item.json,\n inputOptional: true,\n outputOptional: true,\n };\n}\n\nexport function withDefault<T>(\n item: Field<T, T>,\n value: T,\n): Field<T | undefined, T, true, false> {\n return {\n parse: (input) => input === undefined ? value : item.parse(input),\n parseAt: (input, path) =>\n input === undefined ? value : item.parseAt(input, path),\n json: (direction) =>\n direction === \"input\"\n ? { default: value, ...item.json(direction) }\n : item.json(direction),\n inputOptional: true,\n outputOptional: false,\n };\n}\n\nfunction jsonValueSchema(): JsonSchema {\n return {\n anyOf: [\n { type: \"string\" },\n { type: \"number\" },\n { type: \"boolean\" },\n { type: \"null\" },\n { type: \"array\", items: {} },\n { type: \"object\", additionalProperties: {} },\n ],\n };\n}\n\nexport function json(): Field<JsonValue, JsonValue> {\n return field<JsonValue, JsonValue>(\n (value, path) => parseJson(value, path, new Set()),\n jsonValueSchema,\n );\n}\n\nexport function parseJsonValue(value: unknown): JsonValue {\n return parseJson(value, [], new Set());\n}\n\nfunction parseJson(value: unknown, path: Path, seen: Set<object>): JsonValue {\n if (value === null) return null;\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) fail(path, \"Expected a finite number\");\n return value;\n }\n if (typeof value !== \"object\") fail(path, \"Expected a JSON value\");\n if (seen.has(value)) fail(path, \"Expected an acyclic JSON value\");\n seen.add(value);\n try {\n if (Array.isArray(value)) {\n return Array.from(value, (entry, index) =>\n parseJson(entry, [...path, index], seen)\n );\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n fail(path, \"Expected a plain JSON object\");\n }\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [\n key,\n parseJson(entry, [...path, key], seen),\n ])) as JsonValue;\n } finally {\n seen.delete(value);\n }\n}\n\ntype Shape = Record<string, Field<unknown, unknown, boolean, boolean>>;\ntype InputOf<TField> = TField extends Field<infer T, any, any, any> ? T : never;\ntype OutputOf<TField> = TField extends Field<any, infer T, any, any> ? T : never;\ntype InputOptionalOf<TField> =\n TField extends Field<any, any, infer T, any> ? T : never;\ntype OutputOptionalOf<TField> =\n TField extends Field<any, any, any, infer T> ? T : never;\ntype RequiredKeys<TS extends Shape, TDirectory extends Direction> = {\n [K in keyof TS]: TS[K] extends Field<any, any, any, any>\n ? (TDirectory extends \"input\"\n ? InputOptionalOf<TS[K]>\n : OutputOptionalOf<TS[K]>) extends false ? K : never\n : never;\n}[keyof TS];\ntype OptionalKeys<TS extends Shape, TDirectory extends Direction> =\n Exclude<keyof TS, RequiredKeys<TS, TDirectory>>;\n\nexport type ShapeInput<TS extends Shape> = {\n [K in RequiredKeys<TS, \"input\">]: InputOf<TS[K]>;\n} & {\n [K in OptionalKeys<TS, \"input\">]?: InputOf<TS[K]>;\n};\n\nexport type ShapeOutput<TS extends Shape> = {\n [K in RequiredKeys<TS, \"output\">]: OutputOf<TS[K]>;\n} & {\n [K in OptionalKeys<TS, \"output\">]?: OutputOf<TS[K]>;\n};\n\nexport type ObjectField<TInput, TOutput> =\n & Field<TInput, TOutput, false, false>\n & Schema<TInput, TOutput>;\n\nexport function object<const TS extends Shape>(\n shape: TS,\n): ObjectField<ShapeInput<TS>, ShapeOutput<TS>> {\n const json = (direction: Direction) => shapeJson(shape, direction);\n const parseAt = (value: unknown, path: Path) =>\n parseShape(shape, value, path) as ShapeOutput<TS>;\n return {\n ...defineSchema<ShapeInput<TS>, ShapeOutput<TS>>(parseAt, json),\n parse: (value) => parseAt(value, []),\n parseAt,\n json,\n inputOptional: false,\n outputOptional: false,\n };\n}\n\nfunction parseShape<TS extends Shape>(\n shape: TS,\n value: unknown,\n path: Path,\n): ShapeOutput<TS> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n fail(path, \"Expected object\");\n }\n const source = value as Record<string, unknown>;\n const parsed: Record<string, unknown> = {};\n for (const [key, item] of Object.entries(shape)) {\n const fieldPath = [...path, key];\n if (!Object.hasOwn(source, key)) {\n if (!item.inputOptional) fail(fieldPath, \"Required\");\n const output = item.parseAt(undefined, fieldPath);\n if (output !== undefined) parsed[key] = output;\n continue;\n }\n const output = item.parseAt(source[key], fieldPath);\n if (output !== undefined) parsed[key] = output;\n }\n return parsed as ShapeOutput<TS>;\n}\n\nfunction shapeJson<TS extends Shape>(\n shape: TS,\n direction: Direction,\n): JsonSchema {\n const properties: Record<string, JsonSchema> = {};\n const required: string[] = [];\n for (const [key, item] of Object.entries(shape)) {\n properties[key] = item.json(direction);\n if (!(direction === \"input\" ? item.inputOptional : item.outputOptional)) {\n required.push(key);\n }\n }\n return {\n type: \"object\",\n properties,\n required,\n ...(direction === \"output\" ? { additionalProperties: false } : {}),\n };\n}\n\nconst targetUrls: Readonly<Record<string, string>> = {\n \"draft-2020-12\": \"https://json-schema.org/draft/2020-12/schema\",\n \"draft-07\": \"http://json-schema.org/draft-07/schema#\",\n};\n\nfunction defineSchema<TInput, TOutput>(\n parseAt: (value: unknown, path: Path) => TOutput,\n json: (direction: Direction) => JsonSchema,\n): Schema<TInput, TOutput> {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"capable-eve\",\n validate(value) {\n try {\n return { value: parseAt(value, []) };\n } catch (error) {\n if (!(error instanceof Invalid)) throw error;\n return {\n issues: error.path.length === 0\n ? [{ message: error.message }]\n : [{ message: error.message, path: [...error.path] }],\n };\n }\n },\n jsonSchema: {\n input: (options) => withTarget(json(\"input\"), options.target),\n output: (options) => withTarget(json(\"output\"), options.target),\n },\n },\n };\n}\n\nfunction withTarget(schema: JsonSchema, target: string): JsonSchema {\n const url = targetUrls[target];\n return url === undefined ? schema : { $schema: url, ...schema };\n}\n","import type { EveAgentResult } from \"./agent.ts\";\n\n/** Portable presentation shared by the CLI and other presentation-aware surfaces. */\nexport function presentAgentResult(result: EveAgentResult & { runId?: string }): string {\n const status = {\n running: \"Running. Check the result again to follow progress.\",\n waiting: \"Waiting for input.\",\n completed: \"Completed.\",\n failed: \"Agent execution failed.\",\n cancelled: \"Cancelled.\",\n }[result.status];\n const parts = [status];\n if (result.text) parts.push(result.text);\n if (result.data !== undefined) parts.push(JSON.stringify(result.data, null, 2));\n if (result.textTruncated) parts.push(\"The answer was truncated.\");\n if (result.dataOmitted) parts.push(\"Structured output was too large to include.\");\n for (const request of result.requests) {\n parts.push(request.prompt);\n parts.push(`Request ID: ${request.requestId}`);\n if (request.options?.length) {\n parts.push(request.options.map(option => `- ${option.label} (option ID: ${option.id})${option.description ? ` — ${option.description}` : \"\"}`).join(\"\\n\"));\n }\n if (request.allowFreeform === false || (request.options?.length && request.allowFreeform !== true)) {\n parts.push(\"Reply with an option ID.\");\n }\n }\n if (result.requiresHostInput) parts.push(\"Approval or authorization must be completed through the Eve host.\");\n if (result.runId) parts.push(`Run ID: ${result.runId}`);\n return parts.join(\"\\n\\n\");\n}\n","import { createApp, type App } from \"@capable/app\";\nimport { capability, defineApp, type CapabilityDefinition, type DefinedErrors, type Schema } from \"@capable/core\";\nimport type { Client, SessionStreamEvent } from \"eve/client\";\nimport {\n delivery as deliveryOf, emptySessionView, failure, foldEvents, interaction, openInteractions, parts, reply, session as sessionOf, turn, turns,\n type Interaction, type SessionView,\n} from \"eve/events\";\nimport type { Delivery } from \"eve/sessions\";\nimport {\n array,\n boolean,\n enumOf,\n integer,\n json,\n object,\n optional,\n parseJsonValue,\n string,\n withDefault,\n type JsonValue,\n} from \"./agent-schemas.ts\";\nimport { presentAgentResult } from \"./agent-presentation.ts\";\n\nconst runId = string({ minLength: 1, description: \"Eve session ID returned by send.\" });\nconst question = object({\n requestId: string(),\n prompt: string(),\n display: optional(enumOf(\"confirmation\", \"select\", \"text\")),\n allowFreeform: optional(boolean()),\n options: optional(array(object({\n id: string(),\n label: string(),\n description: optional(string()),\n }))),\n});\nconst resultShape = {\n status: enumOf(\"running\", \"waiting\", \"completed\", \"failed\", \"cancelled\"),\n cursor: integer({ minimum: 0 }),\n eventCount: integer({ minimum: 0 }),\n requests: array(question),\n text: optional(string()),\n data: optional(json()),\n dataOmitted: optional(boolean()),\n textTruncated: optional(boolean()),\n requiresHostInput: optional(boolean()),\n error: optional(string()),\n};\nconst resultSchema = object(resultShape);\nconst sendOutput = object({ ...resultShape, runId: string() });\nexport interface EveAgentQuestion {\n requestId: string;\n prompt: string;\n display?: \"confirmation\" | \"select\" | \"text\" | undefined;\n allowFreeform?: boolean | undefined;\n options?: { id: string; label: string; description?: string | undefined }[] | undefined;\n}\nexport type EveAgentData = JsonValue;\nexport interface EveAgentResult {\n status: \"running\" | \"waiting\" | \"completed\" | \"failed\" | \"cancelled\";\n cursor: number;\n eventCount: number;\n requests: EveAgentQuestion[];\n text?: string | undefined;\n data?: EveAgentData | undefined;\n dataOmitted?: boolean | undefined;\n textTruncated?: boolean | undefined;\n requiresHostInput?: boolean | undefined;\n error?: string | undefined;\n}\n\ntype AgentCapability<TInput extends Record<string, unknown>, TOutput, TParsed extends Record<string, unknown> = TInput> =\n CapabilityDefinition<undefined, Schema<TInput, TParsed>, TOutput, DefinedErrors<{}>, {}, \"unary\">;\ntype AgentCapabilities = {\n send: AgentCapability<{\n message: string; runId?: string | undefined; requestId?: string | undefined;\n optionId?: string | undefined; wait?: boolean | undefined; timeoutMs?: number | undefined;\n }, EveAgentResult & { runId: string }>;\n result: AgentCapability<{ runId: string; cursor?: number | undefined }, EveAgentResult, { runId: string; cursor: number }>;\n cancel: AgentCapability<{ runId: string; turnId?: string | undefined }, { status: \"accepted\" | \"pending\" | \"no_active_turn\" }>;\n};\nexport interface EveAgentAdapter<TName extends string> {\n readonly app: App<{ [K in TName]: AgentCapabilities }>;\n /** Abort local requests without cancelling remote execution. */\n dispose(): void;\n}\nexport type EveAgentOperation = \"send\" | \"result\" | \"cancel\";\n\nexport interface EveAgentAdapterOptions<TName extends string> {\n /** Namespace and capability ID prefix; unique within the composed App. */\n readonly name: TName;\n /** Host-configured client for ONE authenticated caller. Never share an adapter across callers. */\n readonly client: Pick<Client, \"sessions\">;\n /** Recheck host-owned authorization on every invocation, including reconstructed reads. Throw to deny. */\n readonly authorize: (operation: EveAgentOperation, runId?: string) => void | Promise<void>;\n readonly maxEventsPerRead?: number;\n readonly readTimeoutMs?: number;\n}\n\ntype Question = EveAgentQuestion;\ntype Run = { view: SessionView; cursor: number; result: EveAgentResult };\n\n/**\n * Wrap Eve execution as a caller-scoped Capable App.\n * Eve session IDs are run IDs. Every read reconstructs state from durable events.\n */\nexport function createEveAgentAdapter<const TName extends string>(options: EveAgentAdapterOptions<TName>): EveAgentAdapter<TName> {\n if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(options.name)) throw new Error(\"Invalid Eve agent namespace\");\n const maxEvents = positive(options.maxEventsPerRead ?? 10_000, \"maxEventsPerRead\");\n const timeoutMs = positive(options.readTimeoutMs ?? 1_000, \"readTimeoutMs\");\n const lifetime = new AbortController();\n\n async function authorize(operation: EveAgentOperation, runId?: string) {\n lifetime.signal.throwIfAborted();\n await options.authorize(operation, runId);\n lifetime.signal.throwIfAborted();\n }\n function signalFor(signal?: AbortSignal) {\n return AbortSignal.any([lifetime.signal, ...(signal ? [signal] : [])]);\n }\n async function readRun(runId: string, signal?: AbortSignal, since = 0, turnId?: string): Promise<Run> {\n const requestSignal = signalFor(signal);\n requestSignal.throwIfAborted();\n const read = new AbortController();\n const timer = setTimeout(() => read.abort(), timeoutMs);\n const combined = AbortSignal.any([requestSignal, read.signal]);\n const events: SessionStreamEvent[] = [];\n try {\n const session = options.client.sessions.attach(runId);\n for await (const event of session.stream({ follow: false, signal: combined, reconnect: false })) {\n if (events.length >= maxEvents) throw new Error(\"Eve history exceeds maxEventsPerRead\");\n events.push(event);\n }\n // Eve can swallow stream aborts. Never validate an answer against partial history.\n combined.throwIfAborted();\n } finally {\n clearTimeout(timer);\n read.abort();\n }\n const cursor = events.length ? events.at(-1)!.meta.position.line + 1 : 0;\n const view = foldEvents(emptySessionView(), events);\n const eventCount = events.filter(event => event.meta.position.line >= since).length;\n return { view, cursor, result: summarize(view, cursor, eventCount, turnId) };\n }\n\n const capabilities = {\n send: capability({\n id: `${options.name}.send`, effect: \"write\",\n description: \"Send a message, optionally continuing an Eve session and waiting for its answer.\",\n meta: { cli: { positional: [\"message\"] } },\n input: object({\n message: string({\n minLength: 1,\n maxLength: 65_536,\n description: \"Message to send, or a text answer to a pending question. With option-id, only the selected option is submitted.\",\n }),\n runId: optional(string({ minLength: 1, description: \"Continue this Eve session. Omit to begin a new conversation.\" })),\n requestId: optional(string({ minLength: 1, description: \"Pending question to answer. Required when several questions are waiting; use with run-id.\" })),\n optionId: optional(string({ minLength: 1, description: \"Answer option ID shown by result. Required for questions that do not accept freeform text; use with run-id.\" })),\n wait: optional(boolean({ description: \"Wait for an answer, pending input, failure, or cancellation. Otherwise return the run ID immediately.\" })),\n timeoutMs: optional(integer({\n minimum: 1,\n maximum: 300_000,\n description: \"Wait limit in milliseconds after acceptance (default: 30000; maximum: 300000). Only used with wait. Expiry leaves Eve running.\",\n })),\n }),\n output: sendOutput,\n toPresentation: presentAgentResult,\n handler: async ({ input, signal }) => {\n await authorize(\"send\", input.runId);\n if (!input.runId && (input.requestId || input.optionId)) throw new Error(\"Question answers require a runId\");\n const waiting = new AbortController();\n const requestSignal = AbortSignal.any([signalFor(signal), waiting.signal]);\n const sendOptions = { signal: requestSignal, reconnect: false as const };\n let delivery: Delivery;\n let answered: Interaction | undefined;\n let view = emptySessionView();\n let cursor = 0;\n if (input.runId) {\n const run = await readRun(input.runId, signal);\n ({ view, cursor } = run);\n const session = options.client.sessions.attach(input.runId, { streamIndex: cursor });\n const open = openInteractions(view);\n const pending = questionsOf(open);\n if (input.requestId || pending.length) {\n const selected = input.requestId ? pending.find(entry => entry.requestId === input.requestId)\n : pending.length === 1 ? pending[0] : undefined;\n if (!selected || run.result.status !== \"waiting\") throw new Error(\"Specify requestId for a current pending question\");\n if (input.optionId) {\n if (!selected.options?.some(option => option.id === input.optionId)) throw new Error(\"Unknown answer option\");\n } else if (selected.allowFreeform === false || (selected.options?.length && selected.allowFreeform !== true)) {\n throw new Error(\"This question requires optionId\");\n }\n answered = interaction(view, selected.requestId);\n delivery = await session.respond([{\n interactionId: selected.requestId,\n ...(input.optionId ? { optionId: input.optionId } : { text: input.message }),\n }], sendOptions);\n } else {\n if (input.optionId) throw new Error(\"No pending question for optionId\");\n if (open.length) throw new Error(\"Pending approval or authorization requires host action\");\n delivery = await session.send(input.message, sendOptions);\n }\n if (delivery.sessionId !== input.runId) throw new Error(\"Eve resumed a different session\");\n } else {\n ({ delivery } = await options.client.sessions.create({ message: input.message, ...sendOptions }));\n }\n const runId = delivery.sessionId;\n const accepted = { runId, status: \"running\" as const, cursor: 0, eventCount: 0, requests: [] };\n if (!input.wait) return accepted;\n // Follow from the pre-send cursor until this delivery's turn settles or pauses again.\n // The timer starts after acceptance; aborting this local stream never cancels Eve.\n const timer = setTimeout(() => waiting.abort(), input.timeoutMs ?? 30_000);\n try {\n let line: SessionStreamEvent[] = [];\n let count = 0;\n let boundary: string | undefined | false = false;\n const stream = options.client.sessions.attach(runId).stream({ startIndex: cursor, signal: requestSignal, reconnect: false });\n for await (const event of stream) {\n requestSignal.throwIfAborted();\n if (++count > maxEvents) throw new Error(\"Eve response exceeds maxEventsPerRead\");\n line.push(event);\n if (event.meta.endOfLine === false) continue;\n view = foldEvents(view, line);\n line = [];\n if (settled(view, delivery.deliveryId, answered)) {\n boundary = deliveryOf(view, delivery.deliveryId)?.turnId ?? answered?.turnId;\n break;\n }\n }\n requestSignal.throwIfAborted();\n if (boundary === false) return accepted;\n // Summarize this delivery's turn, not whichever turn is newest by the time of the reread.\n const run = await readRun(runId, requestSignal, 0, boundary);\n return { runId, ...run.result };\n } catch (error) {\n signalFor(signal).throwIfAborted();\n if (waiting.signal.aborted) return accepted;\n throw error;\n } finally {\n clearTimeout(timer);\n waiting.abort();\n }\n },\n }),\n result: capability({\n id: `${options.name}.result`, effect: \"read\",\n description: \"Read bounded progress, pending questions, or the final output. Pass the last returned cursor.\",\n input: object({\n runId,\n cursor: withDefault(\n integer({\n minimum: 0,\n description: \"Cursor from the previous result, used to count new events. Defaults to 0; the full current result is still returned.\",\n }),\n 0,\n ),\n }),\n output: resultSchema,\n toPresentation: presentAgentResult,\n handler: async ({ input, signal }) => {\n await authorize(\"result\", input.runId);\n const run = await readRun(input.runId, signal, input.cursor);\n if (input.cursor > run.cursor) throw new Error(\"Eve cursor is ahead of this run\");\n return run.result;\n },\n }),\n cancel: capability({\n id: `${options.name}.cancel`, effect: \"write\",\n description: \"Cancel the active Eve turn. Pending means Eve accepted the request but has not confirmed it yet.\",\n input: object({\n runId,\n turnId: optional(string({\n minLength: 1,\n description: \"Specific Eve turn to cancel. Omit to cancel the session’s active turn.\",\n })),\n }),\n output: object({ status: enumOf(\"accepted\", \"pending\", \"no_active_turn\") }),\n toPresentation: ({ status }) => status === \"accepted\" ? \"Cancelled the active turn.\"\n : status === \"pending\" ? \"Cancellation requested. Check the result to confirm execution has stopped.\"\n : \"No active turn to cancel.\",\n handler: async ({ input, signal }) => {\n await authorize(\"cancel\", input.runId);\n signalFor(signal).throwIfAborted();\n // Cancellation can run alongside a bounded result read.\n const delivery = await options.client.sessions.attach(input.runId).cancel({\n signal: signalFor(signal),\n ...(input.turnId ? { turnId: input.turnId } : {}),\n });\n // Bound the local confirmation read; expiry leaves the accepted cancel to Eve.\n const confirm = new AbortController();\n const timer = setTimeout(() => confirm.abort(), timeoutMs);\n try {\n const { outcome } = await delivery.result({ signal: AbortSignal.any([signalFor(signal), confirm.signal]) });\n if (outcome === \"applied\") return { status: \"accepted\" as const };\n if (outcome === \"ignored\") return { status: \"no_active_turn\" as const };\n throw new Error(\"Eve cancellation failed\");\n } catch (error) {\n signalFor(signal).throwIfAborted();\n if (confirm.signal.aborted) return { status: \"pending\" as const };\n throw error;\n } finally {\n clearTimeout(timer);\n }\n },\n }),\n };\n // Widen the key during construction: TypeScript cannot reduce context inference\n // for a generic mapped namespace, although all three capabilities are context-free.\n const checked: AgentCapabilities = capabilities;\n const app = createApp(defineApp({ capabilities: { [options.name]: checked } })) as App<{ [K in TName]: AgentCapabilities }>;\n return {\n app,\n dispose() {\n lifetime.abort();\n },\n };\n}\n\nfunction positive(value: number, name: string) {\n if (!Number.isSafeInteger(value) || value < 1) throw new Error(`${name} must be a positive safe integer`);\n return value;\n}\n\nfunction questionsOf(open: readonly Interaction[]): Question[] {\n const found = open.filter(entry => entry.request.kind === \"question\");\n if (found.length > 100) throw new Error(\"Eve question limit exceeded\");\n return found.map(entry => {\n // Deliberate allowlist: no call input, tool names, sign-in details, or credentials.\n const safe = question.parse({ ...entry.request, requestId: entry.interactionId });\n if (JSON.stringify(safe).length > 65_536) throw new Error(\"Eve question limit exceeded\");\n return safe;\n });\n}\n\nfunction summarize(view: SessionView, cursor: number, eventCount: number, turnId?: string): EveAgentResult {\n const base = { cursor, eventCount, requests: [] };\n const latest = turnId ? turn(view, turnId) : turns(view).at(-1);\n // Raw failure details can include private tool arguments or credentials.\n if (failure(view, latest?.turnId)) return { ...base, status: \"failed\", error: \"Eve agent execution failed\" };\n const open = openInteractions(view).filter(entry => !turnId || entry.turnId === turnId);\n if (open.length) {\n const requests = questionsOf(open);\n return { ...base, status: \"waiting\", requests, requiresHostInput: requests.length < open.length };\n }\n if (!latest || latest.status === \"running\") return { ...base, status: \"running\" };\n if (latest.outcome === \"cancelled\") return { ...base, status: \"cancelled\" };\n if (latest.outcome !== \"completed\") return { ...base, status: \"failed\", error: \"Eve agent execution failed\" };\n const result: EveAgentResult = { ...base, status: \"completed\" };\n const text = reply(view, latest.turnId).flatMap(part => part.kind === \"text\" && typeof part.value === \"string\" ? [part.value] : []).join(\"\");\n if (text) {\n result.text = text.slice(0, 65_536);\n if (text.length > 65_536) result.textTruncated = true;\n }\n const data = parts(view, { turnId: latest.turnId, kind: \"result\" }).at(-1)?.value;\n if (data !== undefined) {\n if (JSON.stringify(data).length > 65_536) result.dataOmitted = true;\n else result.data = parseJsonValue(data);\n }\n return result;\n}\n\n/** True once the delivery settled and its turn settled or paused on a new interaction. */\nfunction settled(view: SessionView, deliveryId: string, answered?: Interaction) {\n const received = deliveryOf(view, deliveryId);\n if (received?.status !== \"settled\") return sessionOf(view).status === \"ended\";\n const turnId = received.turnId ?? answered?.turnId;\n if (!turnId) return true;\n return turn(view, turnId)?.status === \"settled\"\n || openInteractions(view).some(entry => entry.turnId === turnId && entry.interactionId !== answered?.interactionId);\n}\n","import {\n getAppRuntime,\n getCapabilityDisplay,\n flattenManifestCapabilities,\n type AnyApp,\n type ManifestCapability,\n} from \"@capable/app\";\nimport type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n defineDynamic,\n defineTool,\n type DynamicContext,\n type DynamicSentinel,\n type DynamicToolResult,\n type ToolDefinition,\n} from \"eve/tools\";\nimport type { Approval } from \"eve/tools/approval\";\n\nexport type EveCapabilityMeta =\n | false\n | {\n readonly name?: string;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly eve?: EveCapabilityMeta;\n }\n}\n\nexport type CreateEveToolsOptions = {\n readonly approval?: (\n capability: ManifestCapability,\n ) => Approval | undefined;\n};\n\n/** Providers receive only the session; discovery and execution both supply one. */\nexport type EveAppContext = { readonly session: DynamicContext[\"session\"] };\n\nexport type EveAppProvider =\n | AnyApp\n | ((context: EveAppContext) => AnyApp | Promise<AnyApp>);\n\nconst emptyInputSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\ntype EveTool = ToolDefinition<Record<string, unknown>, unknown>;\n\n/**\n * Projects an executable Capable App into native, in-process Eve tools.\n *\n * Eve evaluates the resolver before every model call. The App manifest is\n * memoized per session, and each call rebuilds the App from the execution\n * session. Keep persistent data outside the process.\n */\nexport function createEveTools(\n app: EveAppProvider,\n options: CreateEveToolsOptions = {},\n): DynamicSentinel<DynamicToolResult> {\n const resolveApp = (context: EveAppContext) =>\n typeof app === \"function\" ? app({ session: context.session }) : app;\n\n return defineDynamic(async (context) => {\n const capabilities = await context.memo(\n [\"capable.manifest\", context.session.id],\n async () => {\n const manifest = await getAppRuntime(await resolveApp(context)).manifest();\n return flattenManifestCapabilities(manifest.capabilities);\n },\n );\n const tools: Record<string, EveTool> = {};\n const names = new Set<string>();\n\n for (const capability of capabilities) {\n const display = getCapabilityDisplay(capability);\n const meta = capability.meta.eve as EveCapabilityMeta | undefined;\n if (meta === false) continue;\n if (capability.execution === \"events\") {\n if (meta !== undefined) {\n throw new Error(\n `Event Capability \"${capability.id}\" cannot be exposed as an Eve tool`,\n );\n }\n continue;\n }\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `Eve tool name \"${name}\" is invalid; set meta.eve.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (names.has(name)) {\n throw new Error(`Duplicate Eve tool name \"${name}\"`);\n }\n names.add(name);\n\n const approval = options.approval?.(capability);\n const id = capability.id;\n tools[name] = defineTool({\n description:\n display.description ??\n display.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: (capability.input ??\n emptyInputSchema) as EveTool[\"inputSchema\"],\n ...(capability.output\n ? {\n outputSchema:\n capability.output as NonNullable<EveTool[\"outputSchema\"]>,\n }\n : {}),\n ...(approval ? { approval } : {}),\n execute: async (input, toolContext) => {\n // A rejected approval can change the latest resolver's caller.\n // Rebuild per-caller Apps from the actual execution identity.\n const executionApp = await resolveApp({ session: toolContext.session });\n const result = await getAppRuntime(executionApp).call({\n id, input, signal: toolContext.abortSignal,\n });\n return result.output;\n },\n });\n }\n\n return tools;\n });\n}\n\nexport {\n createEveAgentAdapter,\n type EveAg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I,GAChB,MAAM,IAAI,MAAM,4BAA4B,KAAK,EAAE;GAErD,MAAM,IAAI,IAAI;GAEd,MAAM,WAAW,QAAQ,WAAW,UAAU;GAC9C,MAAM,KAAK,WAAW;GACtB,MAAM,QAAQ,WAAW;IACvB,aACE,QAAQ,eACR,QAAQ,SACR,iCAAiC,WAAW,KAAK,KAAK,GAAG,EAAE;IAC7D,aAAc,WAAW,SACvB;IACF,GAAI,WAAW,SACX,EACE,cACE,WAAW,OACf,IACA,CAAC;IACL,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;IAC/B,SAAS,OAAO,OAAO,gBAAgB;KAOrC,QAAO,MAHc,cAAc,MADR,WAAW,EAAE,SAAS,YAAY,QAAQ,CAAC,CACvB,CAAC,CAAC,KAAK;MACpD;MAAI;MAAO,QAAQ,YAAY;KACjC,CAAC,EAAA,CACa;IAChB;GACF,CAAC;EACH;EAEA,OAAO;CACT,CAAC;AACH"}
|
package/dist/http.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as HttpGroupMeta, c as FetchHandler, d as createProtocolHandler, f as JsonValue, i as HttpCapabilityMeta, l as TransportHeaders, m as defineProtocolCodec, n as CompiledHttpRoute, o as HttpMethod, p as ProtocolCodec, r as ContextProvider, s as createHttpHandler, t as CapabilitySelection, u as createHttpTransport } from "./index-
|
|
1
|
+
import { a as HttpGroupMeta, c as FetchHandler, d as createProtocolHandler, f as JsonValue, i as HttpCapabilityMeta, l as TransportHeaders, m as defineProtocolCodec, n as CompiledHttpRoute, o as HttpMethod, p as ProtocolCodec, r as ContextProvider, s as createHttpHandler, t as CapabilitySelection, u as createHttpTransport } from "./index-CwvjDizW.mjs";
|
|
2
2
|
export { type CapabilitySelection, type CompiledHttpRoute, type ContextProvider, type FetchHandler, type HttpCapabilityMeta, type HttpGroupMeta, type HttpMethod, type JsonValue, type ProtocolCodec, type TransportHeaders, createHttpHandler, createHttpTransport, createProtocolHandler, defineProtocolCodec };
|
package/dist/http.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as defineProtocolCodec, n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-
|
|
1
|
+
import { i as defineProtocolCodec, n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-Bk3lEhI7.mjs";
|
|
2
2
|
export { createHttpHandler, createHttpTransport, createProtocolHandler, defineProtocolCodec };
|
|
@@ -65,6 +65,12 @@ type AnyDefinedErrors = {
|
|
|
65
65
|
readonly [CAPABILITY_ERROR_DEFINITIONS_SYMBOL]: CapabilityErrorContract;
|
|
66
66
|
};
|
|
67
67
|
declare function defineErrors<const TDefinitions extends CapabilityErrorContract>(definitions: TDefinitions): DefinedErrors<TDefinitions>;
|
|
68
|
+
/** @internal Mark an error as validated for external wire serialization. */
|
|
69
|
+
declare function markPublicError<TError extends object>(error: TError): TError;
|
|
70
|
+
/** @internal Revoke wire-serialization permission when an error escapes an unvalidated seam. */
|
|
71
|
+
declare function unmarkPublicError(error: unknown): void;
|
|
72
|
+
/** @internal True only for errors explicitly validated or created at a public boundary. */
|
|
73
|
+
declare function isPublicError(error: unknown): boolean;
|
|
68
74
|
//#endregion
|
|
69
75
|
//#region packages/core/src/projection.d.ts
|
|
70
76
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -331,5 +337,5 @@ declare function subscribeLocatedCapability(located: LocatedCapability, input: u
|
|
|
331
337
|
}): Promise<AsyncIterableIterator<unknown>>;
|
|
332
338
|
declare function isCapability(value: unknown): value is AnyCapability;
|
|
333
339
|
//#endregion
|
|
334
|
-
export { CapabilityErrorContract as $, CAPABILITY_GROUP_SYMBOL as A, MarkdownPresentationPart as B, isCapability as C, AnyCapabilityGroup as D, APPLICATION_SYMBOL as E, defineApp as F, TablePresentationPart as G, PresentationRenderer as H, group as I, renderPresentationMarkdown as J, normalizePresentation as K, isCapabilityGroup as L, CapabilityTree as M, GroupMetaRegistry as N, AppContext as O, LocatedCapability as P, CAPABILITY_ERRORS_SYMBOL as Q, FilePresentationPart as R, executeLocatedCapability as S, subscribeLocatedCapability as T, PresentationTableCell as U, PresentationPart as V, PresentationValue as W, md as X, MaybePromise as Y, AnyDefinedErrors as Z, ExecuteCapabilityOptions as _, CapabilityDefinition as a, defineErrors as at, capability as b, CapabilityFactory as c,
|
|
335
|
-
//# sourceMappingURL=index-
|
|
340
|
+
export { CapabilityErrorContract as $, CAPABILITY_GROUP_SYMBOL as A, MarkdownPresentationPart as B, isCapability as C, AnyCapabilityGroup as D, APPLICATION_SYMBOL as E, defineApp as F, TablePresentationPart as G, PresentationRenderer as H, group as I, renderPresentationMarkdown as J, normalizePresentation as K, isCapabilityGroup as L, CapabilityTree as M, GroupMetaRegistry as N, AppContext as O, LocatedCapability as P, CAPABILITY_ERRORS_SYMBOL as Q, FilePresentationPart as R, executeLocatedCapability as S, subscribeLocatedCapability as T, PresentationTableCell as U, PresentationPart as V, PresentationValue as W, md as X, MaybePromise as Y, AnyDefinedErrors as Z, ExecuteCapabilityOptions as _, CapabilityDefinition as a, defineErrors as at, capability as b, CapabilityFactory as c, unmarkPublicError as ct, CapabilityMetaRegistry as d, InferSchemaInput as dt, CapabilityErrorDefinition as et, CapabilityMiddleware as f, InferSchemaOutput as ft, CapabilitySubscriberArgs as g, schemaToJsonSchema as gt, CapabilitySubscriber as h, parseSchema as ht, CapabilityContext as i, ErrorMetaRegistry as it, CapabilityGroupDefinition as j, AppDefinition as k, CapabilityHandlerArgs as l, AnyObjectSchema as lt, CapabilityOutput as m, SchemaValidationError as mt, CAPABILITY_SYMBOL as n, CapableError as nt, CapabilityEffect as o, isPublicError as ot, CapabilityMiddlewareArgs as p, Schema as pt, present as q, CallableCapability as r, DefinedErrors as rt, CapabilityExecution as s, markPublicError as st, AnyCapability as t, CapabilityErrorFactory as tt, CapabilityInput as u, AnySchema as ut, SubscribableCapability as v, subscribeCapability as w, executeCapability as x, SubscribeCapabilityOptions as y, ImagePresentationPart as z };
|
|
341
|
+
//# sourceMappingURL=index-BIO_hbXJ.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Y as MaybePromise, k as AppDefinition } from "./index-
|
|
2
|
-
import { t as ApplicationSelection } from "./index-
|
|
3
|
-
import { p as ProtocolCodec, r as ContextProvider, t as CapabilitySelection } from "./index-
|
|
1
|
+
import { Y as MaybePromise, k as AppDefinition } from "./index-BIO_hbXJ.mjs";
|
|
2
|
+
import { t as ApplicationSelection } from "./index-F_eaksy8.mjs";
|
|
3
|
+
import { p as ProtocolCodec, r as ContextProvider, t as CapabilitySelection } from "./index-CwvjDizW.mjs";
|
|
4
4
|
//#region packages/server/src/index.d.ts
|
|
5
5
|
type ServerMount<TContext> = {
|
|
6
6
|
readonly kind: "capable.server.mount";
|
|
@@ -40,4 +40,4 @@ type CreateServerArgs<TContext> = [TContext] extends [undefined] ? [options?: Cr
|
|
|
40
40
|
declare function createServer<TContext>(app: AppDefinition<any, TContext>, ...[providedOptions]: CreateServerArgs<TContext>): CapableServer;
|
|
41
41
|
//#endregion
|
|
42
42
|
export { createServer as a, ServerMount as i, CompiledServerMount as n, http as o, ServerMiddleware as r, protocol as s, CapableServer as t };
|
|
43
|
-
//# sourceMappingURL=index-
|
|
43
|
+
//# sourceMappingURL=index-C0tU5Y2n.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as CapabilityTree, P as LocatedCapability, k as AppDefinition } from "./index-
|
|
2
|
-
import { d as AnyApp, t as ApplicationSelection, y as ApplicationTransport } from "./index-
|
|
1
|
+
import { M as CapabilityTree, P as LocatedCapability, k as AppDefinition } from "./index-BIO_hbXJ.mjs";
|
|
2
|
+
import { d as AnyApp, t as ApplicationSelection, y as ApplicationTransport } from "./index-F_eaksy8.mjs";
|
|
3
3
|
//#region packages/fetch/src/codec.d.ts
|
|
4
4
|
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
5
5
|
readonly [key: string]: JsonValue;
|
|
@@ -19,6 +19,7 @@ type FetchHandler = (request: Request) => Response | Promise<Response>;
|
|
|
19
19
|
declare function createProtocolHandler(application: AnyApp | ((request: Request) => AnyApp | Promise<AnyApp>), options?: {
|
|
20
20
|
readonly basePath?: string;
|
|
21
21
|
readonly codec?: ProtocolCodec;
|
|
22
|
+
readonly onError?: (error: unknown) => void;
|
|
22
23
|
}): {
|
|
23
24
|
readonly fetch: FetchHandler;
|
|
24
25
|
};
|
|
@@ -63,6 +64,7 @@ declare function createHttpHandler<const TCapabilities extends CapabilityTree, T
|
|
|
63
64
|
readonly openapiPath?: string | false;
|
|
64
65
|
readonly requireExplicitRoutes?: boolean;
|
|
65
66
|
readonly selection?: CapabilitySelection<TCapabilities>;
|
|
67
|
+
readonly onError?: (error: unknown) => void;
|
|
66
68
|
}): {
|
|
67
69
|
readonly fetch: FetchHandler;
|
|
68
70
|
readonly routes: readonly CompiledHttpRoute[];
|
|
@@ -70,4 +72,4 @@ declare function createHttpHandler<const TCapabilities extends CapabilityTree, T
|
|
|
70
72
|
};
|
|
71
73
|
//#endregion
|
|
72
74
|
export { HttpGroupMeta as a, FetchHandler as c, createProtocolHandler as d, JsonValue as f, HttpCapabilityMeta as i, TransportHeaders as l, defineProtocolCodec as m, CompiledHttpRoute as n, HttpMethod as o, ProtocolCodec as p, ContextProvider as r, createHttpHandler as s, CapabilitySelection as t, createHttpTransport as u };
|
|
73
|
-
//# sourceMappingURL=index-
|
|
75
|
+
//# sourceMappingURL=index-CwvjDizW.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as CapabilityTree, O as AppContext, V as PresentationPart, Y as MaybePromise, a as CapabilityDefinition,
|
|
1
|
+
import { M as CapabilityTree, O as AppContext, V as PresentationPart, Y as MaybePromise, a as CapabilityDefinition, dt as InferSchemaInput, j as CapabilityGroupDefinition, k as AppDefinition, lt as AnyObjectSchema, m as CapabilityOutput, s as CapabilityExecution, t as AnyCapability, v as SubscribableCapability } from "./index-BIO_hbXJ.mjs";
|
|
2
2
|
//#region packages/app/src/manifest.d.ts
|
|
3
3
|
type JsonSchema = Readonly<Record<string, unknown>>;
|
|
4
4
|
type ManifestError = {
|
|
@@ -65,6 +65,9 @@ interface ApplicationTransport {
|
|
|
65
65
|
call(call: CapabilityCall): Promise<CapabilityResult>;
|
|
66
66
|
subscribe(call: CapabilityCall): Promise<AsyncIterableIterator<CapabilityResult>>;
|
|
67
67
|
}
|
|
68
|
+
type CreateRemoteAppOptions = {
|
|
69
|
+
readonly manifest?: ApplicationManifest;
|
|
70
|
+
};
|
|
68
71
|
declare const APP_RUNTIME_SYMBOL: unique symbol;
|
|
69
72
|
declare const APP_CAPABILITIES_SYMBOL: unique symbol;
|
|
70
73
|
type AppCapabilityReference<TCapability extends AnyCapability = AnyCapability> = {
|
|
@@ -104,7 +107,7 @@ type CreateAppOptions<TContext> = {
|
|
|
104
107
|
};
|
|
105
108
|
type CreateAppArgs<TContext> = [TContext] extends [undefined] ? [options?: Partial<CreateAppOptions<TContext>>] : [options: CreateAppOptions<TContext>];
|
|
106
109
|
declare function createApp<const TDefinition extends AppDefinition<any, any>>(definition: TDefinition, ...[options]: CreateAppArgs<AppContext<TDefinition>>): App<DefinitionCapabilities<TDefinition>>;
|
|
107
|
-
declare function createRemoteApp<TDefinition extends AppDefinition<any, any> = AppDefinition<CapabilityTree>>(transport: ApplicationTransport): App<DefinitionCapabilities<TDefinition>>;
|
|
110
|
+
declare function createRemoteApp<TDefinition extends AppDefinition<any, any> = AppDefinition<CapabilityTree>>(transport: ApplicationTransport, options?: CreateRemoteAppOptions): App<DefinitionCapabilities<TDefinition>>;
|
|
108
111
|
declare class TransportError extends Error {
|
|
109
112
|
readonly code: string;
|
|
110
113
|
readonly status: number | undefined;
|
|
@@ -159,5 +162,5 @@ type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree>
|
|
|
159
162
|
};
|
|
160
163
|
declare function selectApp<const TCapabilities extends CapabilityTree>(application: App<TCapabilities>, selection: ApplicationSelection<TCapabilities>): App<TCapabilities>;
|
|
161
164
|
//#endregion
|
|
162
|
-
export {
|
|
163
|
-
//# sourceMappingURL=index-
|
|
165
|
+
export { ApplicationManifest as A, CreateRemoteAppOptions as C, getAppRuntime as D, createRemoteApp as E, ManifestNode as F, createAppManifest as I, flattenManifestCapabilities as L, ManifestCapability as M, ManifestError as N, isApp as O, ManifestGroup as P, CapabilityResult as S, createApp as T, AppCapabilityReference as _, CustomizedCapability as a, CallableTree as b, getCapabilityNavigationMeta as c, AnyApp as d, App as f, AppCapabilityIsSubscribable as g, AppCapabilityIsLive as h, CapabilityCustomization as i, JsonSchema as j, subscribe as k, APP_CAPABILITIES_SYMBOL as l, AppCapabilityCall as m, composeApps as n, customize as o, AppCapabilities as p, selectApp as r, getCapabilityDisplay as s, ApplicationSelection as t, APP_RUNTIME_SYMBOL as u, AppContextProvider as v, TransportError as w, CapabilityCall as x, ApplicationTransport as y };
|
|
166
|
+
//# sourceMappingURL=index-F_eaksy8.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as defineApp, H as PresentationRenderer, I as group, M as CapabilityTree, O as AppContext, U as PresentationTableCell, V as PresentationPart, W as PresentationValue, X as md, _ as ExecuteCapabilityOptions, a as CapabilityDefinition, at as defineErrors, b as capability, c as CapabilityFactory, f as CapabilityMiddleware, g as CapabilitySubscriberArgs, h as CapabilitySubscriber, i as CapabilityContext, k as AppDefinition, l as CapabilityHandlerArgs, m as CapabilityOutput, o as CapabilityEffect, p as CapabilityMiddlewareArgs, q as present, rt as DefinedErrors, s as CapabilityExecution, u as CapabilityInput, x as executeCapability } from "./index-
|
|
2
|
-
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-
|
|
3
|
-
import {
|
|
4
|
-
export { type App, type AppCapabilityCall, type AppCapabilityReference, type AppContext, type AppContextProvider, type AppDefinition, type ApplicationSelection, type CapabilityContext, type CapabilityCustomization, type CapabilityDefinition, type CapabilityEffect, type CapabilityExecution, type CapabilityFactory, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, type CustomizedCapability, type DefinedErrors, type ExecuteCapabilityOptions, type PresentationPart, type PresentationRenderer, type PresentationTableCell, type PresentationValue, type WatchQueryOptions, capability, composeApps, createApp, createRemoteApp, customize, defineApp, defineErrors, executeCapability, group, md, present, selectApp, subscribe, watchQuery };
|
|
1
|
+
import { F as defineApp, H as PresentationRenderer, I as group, M as CapabilityTree, O as AppContext, U as PresentationTableCell, V as PresentationPart, W as PresentationValue, X as md, _ as ExecuteCapabilityOptions, a as CapabilityDefinition, at as defineErrors, b as capability, c as CapabilityFactory, f as CapabilityMiddleware, g as CapabilitySubscriberArgs, h as CapabilitySubscriber, i as CapabilityContext, k as AppDefinition, l as CapabilityHandlerArgs, m as CapabilityOutput, o as CapabilityEffect, p as CapabilityMiddlewareArgs, q as present, rt as DefinedErrors, s as CapabilityExecution, u as CapabilityInput, x as executeCapability } from "./index-BIO_hbXJ.mjs";
|
|
2
|
+
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-fVgS4T8P.mjs";
|
|
3
|
+
import { A as ApplicationManifest, C as CreateRemoteAppOptions, E as createRemoteApp, T as createApp, _ as AppCapabilityReference, a as CustomizedCapability, f as App, i as CapabilityCustomization, k as subscribe, m as AppCapabilityCall, n as composeApps, o as customize, r as selectApp, t as ApplicationSelection, v as AppContextProvider } from "./index-F_eaksy8.mjs";
|
|
4
|
+
export { type App, type AppCapabilityCall, type AppCapabilityReference, type AppContext, type AppContextProvider, type AppDefinition, type ApplicationManifest, type ApplicationSelection, type CapabilityContext, type CapabilityCustomization, type CapabilityDefinition, type CapabilityEffect, type CapabilityExecution, type CapabilityFactory, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, type CreateRemoteAppOptions, type CustomizedCapability, type DefinedErrors, type ExecuteCapabilityOptions, type PresentationPart, type PresentationRenderer, type PresentationTableCell, type PresentationValue, type WatchQueryOptions, capability, composeApps, createApp, createRemoteApp, customize, defineApp, defineErrors, executeCapability, group, md, present, selectApp, subscribe, watchQuery };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as defineErrors, c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability, v as present } from "./src-
|
|
1
|
+
import { S as defineErrors, c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability, v as present } from "./src-TCQGaWar.mjs";
|
|
2
2
|
import { t as md } from "./projection-Cgq2u0Wt.mjs";
|
|
3
|
-
import { l as createApp, n as selectApp, p as subscribe, r as customize, t as composeApps, u as createRemoteApp } from "./src-
|
|
3
|
+
import { l as createApp, n as selectApp, p as subscribe, r as customize, t as composeApps, u as createRemoteApp } from "./src-C2OEkZ3c.mjs";
|
|
4
4
|
export { capability, composeApps, createApp, createRemoteApp, customize, defineApp, defineErrors, executeCapability, group, md, present, selectApp, subscribe, watchQuery };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as ServerMount } from "./index-
|
|
1
|
+
import { M as ManifestCapability, S as CapabilityResult, d as AnyApp, j as JsonSchema, t as ApplicationSelection } from "./index-F_eaksy8.mjs";
|
|
2
|
+
import { i as ServerMount } from "./index-C0tU5Y2n.mjs";
|
|
3
|
+
import { McpServer, RegisteredTool } from "@modelcontextprotocol/server";
|
|
4
|
+
//#region packages/mcp/src/register.d.ts
|
|
5
|
+
/** Register App-backed tools alongside native SDK tools and resources. */
|
|
6
|
+
declare function registerCapableTools(server: McpServer, tools: readonly McpTool[]): RegisteredTool[];
|
|
7
|
+
//#endregion
|
|
3
8
|
//#region packages/mcp/src/index.d.ts
|
|
4
9
|
type McpCapabilityMeta = false | {
|
|
5
10
|
readonly name?: string;
|
|
@@ -23,6 +28,10 @@ declare module "@capable/core" {
|
|
|
23
28
|
readonly mcp?: McpCapabilityMeta;
|
|
24
29
|
}
|
|
25
30
|
}
|
|
31
|
+
type McpToolNameFormatter = (capability: ManifestCapability) => string;
|
|
32
|
+
type CreateMcpOptions = {
|
|
33
|
+
readonly toolName?: McpToolNameFormatter;
|
|
34
|
+
};
|
|
26
35
|
type McpTool = {
|
|
27
36
|
readonly name: string;
|
|
28
37
|
readonly title?: string;
|
|
@@ -43,7 +52,7 @@ type McpTool = {
|
|
|
43
52
|
readonly signal?: AbortSignal;
|
|
44
53
|
}): Promise<CapabilityResult>;
|
|
45
54
|
};
|
|
46
|
-
declare function createMcp(app: AnyApp): Promise<readonly McpTool[]>;
|
|
55
|
+
declare function createMcp(app: AnyApp, options?: CreateMcpOptions): Promise<readonly McpTool[]>;
|
|
47
56
|
//#endregion
|
|
48
57
|
//#region packages/mcp/src/mount.d.ts
|
|
49
58
|
type McpCacheHint = {
|
|
@@ -60,6 +69,7 @@ type McpMountOptions = {
|
|
|
60
69
|
readonly icons?: readonly McpIcon[];
|
|
61
70
|
readonly instructions?: string;
|
|
62
71
|
readonly selection?: ApplicationSelection;
|
|
72
|
+
readonly toolName?: McpToolNameFormatter;
|
|
63
73
|
readonly cache?: {
|
|
64
74
|
readonly discovery?: McpCacheHint;
|
|
65
75
|
readonly tools?: McpCacheHint;
|
|
@@ -67,5 +77,5 @@ type McpMountOptions = {
|
|
|
67
77
|
};
|
|
68
78
|
declare function mcp<TContext = any>(options?: McpMountOptions): ServerMount<TContext>;
|
|
69
79
|
//#endregion
|
|
70
|
-
export { type McpCacheHint, McpCapabilityMeta, McpIcon, type McpMountOptions, McpTool, createMcp, mcp };
|
|
80
|
+
export { CreateMcpOptions, type McpCacheHint, McpCapabilityMeta, McpIcon, type McpMountOptions, McpTool, McpToolNameFormatter, createMcp, mcp, registerCapableTools };
|
|
71
81
|
//# sourceMappingURL=mcp.d.mts.map
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createMcp, t as mcp } from "./mount-
|
|
2
|
-
export { createMcp, mcp };
|
|
1
|
+
import { n as createMcp, r as registerCapableTools, t as mcp } from "./mount-pvIaehZC.mjs";
|
|
2
|
+
export { createMcp, mcp, registerCapableTools };
|