agents 0.31.0 → 0.32.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/dist/{agent-routing-wS1TimZ_.d.ts → agent-routing-vVMA7m8Y.d.ts} +6 -6
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-Bamxxb6Y.d.ts → agent-tools-gGXXkf1z.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/agent-tools.js +0 -1
- package/dist/agent-tools.js.map +1 -1
- package/dist/browser/ai.js +1 -1
- package/dist/browser/tools/ai-sdk.d.ts +66 -1
- package/dist/browser/tools/ai-sdk.js +2 -2
- package/dist/browser/tools/pi.js +2 -2
- package/dist/browser/tools/tanstack-ai.d.ts +2 -2
- package/dist/browser/tools/tanstack-ai.js +2 -2
- package/dist/browser/tools/tanstack-ai.js.map +1 -1
- package/dist/{browser-tool-lGnvEBLJ.js → browser-tool-DRan7Lk6.js} +2 -2
- package/dist/{browser-tool-lGnvEBLJ.js.map → browser-tool-DRan7Lk6.js.map} +1 -1
- package/dist/catalog-BpOejOsE.js +239 -0
- package/dist/catalog-BpOejOsE.js.map +1 -0
- package/dist/catalog-BpiVV1OF.d.ts +173 -0
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/{client-wn4-yqGz.d.ts → client-eSfgYvd3.d.ts} +2 -2
- package/dist/client.d.ts +1 -1
- package/dist/{cloudflare-Dzvc7V2N.js → cloudflare-CUUm_9q9.js} +26 -4
- package/dist/cloudflare-CUUm_9q9.js.map +1 -0
- package/dist/{do-oauth-client-provider-DfsUcpc3.d.ts → do-oauth-client-provider-DtNqv7oj.d.ts} +26 -2
- package/dist/{index-YSKgfgg9.d.ts → emitter-BJZtCVjQ.d.ts} +6 -140
- package/dist/emitter-DPOVcCln.js +15 -0
- package/dist/emitter-DPOVcCln.js.map +1 -0
- package/dist/experimental/channels/web/index.js +1 -1
- package/dist/harness/container/index.js +0 -1
- package/dist/harness/container/index.js.map +1 -1
- package/dist/harness/container/runtime/index.js +2 -2
- package/dist/harness/opencode/index.js +0 -1
- package/dist/harness/opencode/index.js.map +1 -1
- package/dist/harness/pi/index.d.ts +11 -4
- package/dist/harness/pi/index.js +43 -141
- package/dist/harness/pi/index.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/markdown-BZ-VLtA1.js +86 -0
- package/dist/markdown-BZ-VLtA1.js.map +1 -0
- package/dist/mcp/client/do-oauth-client-provider.d.ts +4 -2
- package/dist/mcp/client/do-oauth-client-provider.js +15 -1
- package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/models/pi-ai/index.js +129 -2
- package/dist/models/pi-ai/index.js.map +1 -1
- package/dist/observability/ai/index.js +1 -2
- package/dist/observability/ai/index.js.map +1 -1
- package/dist/observability/index.d.ts +170 -9
- package/dist/observability/index.js +386 -11
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/resource-B59OV2a2.js +325 -0
- package/dist/resource-B59OV2a2.js.map +1 -0
- package/dist/routing/index.d.ts +1 -1
- package/dist/script-CFDLTk5b.d.ts +91 -0
- package/dist/script-workspace-BpdAYq1R.d.ts +41 -0
- package/dist/serializable.d.ts +1 -1
- package/dist/skill-DRBcIBjC.d.ts +221 -0
- package/dist/skills/index.d.ts +275 -36
- package/dist/skills/index.js +265 -1534
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/runner.d.ts +37 -0
- package/dist/skills/runner.js +912 -0
- package/dist/skills/runner.js.map +1 -0
- package/dist/skills/tools/ai-sdk.d.ts +36 -0
- package/dist/skills/tools/ai-sdk.js +94 -0
- package/dist/skills/tools/ai-sdk.js.map +1 -0
- package/dist/source-9RQzlEhM.d.ts +112 -0
- package/dist/{src-BGolXG_H.js → src-DoGNJ4Ud.js} +4 -5
- package/dist/src-DoGNJ4Ud.js.map +1 -0
- package/dist/sub-routing.d.ts +1 -1
- package/dist/tool-CxKsvxjm.js.map +1 -1
- package/dist/tool-DkT_DJBm.js.map +1 -1
- package/dist/{tool-helpers-BodWi4gd.js → tool-helpers-BI7ifO2S.js} +1 -2
- package/dist/{tool-helpers-BodWi4gd.js.map → tool-helpers-BI7ifO2S.js.map} +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +10 -258
- package/dist/vite.js.map +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-CyoeosdO.js → websockets-C6SJtWCJ.js} +1 -2
- package/dist/{websockets-CyoeosdO.js.map → websockets-C6SJtWCJ.js.map} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +0 -1
- package/dist/workflows.js.map +1 -1
- package/docs/harnesses/pi.md +9 -3
- package/docs/mcp-client.md +23 -1
- package/docs/mcp-servers.md +2 -2
- package/docs/observability.md +5 -3
- package/package.json +24 -15
- package/dist/ai-sdk-hW3vntnk.d.ts +0 -72
- package/dist/cloudflare-Dzvc7V2N.js.map +0 -1
- package/dist/index-iv9FTXX9.d.ts +0 -311
- package/dist/skills/compile.d.ts +0 -40
- package/dist/skills/compile.js +0 -65
- package/dist/skills/compile.js.map +0 -1
- package/dist/src-BGolXG_H.js.map +0 -1
- package/skills-module.d.ts +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","names":[],"sources":["../../src/skills/script-workspace.ts","../../src/skills/runner.ts"],"sourcesContent":["/**\n * The Workspace a skill script reaches through `ctx.workspace`: a\n * `Workspace` from `@cloudflare/computer`, or anything with the same `fs`\n * methods.\n */\nexport interface SkillScriptWorkspace {\n readonly fs: {\n stat(path: string): Promise<{ size: number; isDirectory: boolean }>;\n readFile(path: string): Promise<ReadableStream<Uint8Array>>;\n writeFile(path: string, content: Uint8Array): Promise<void>;\n mkdir(path: string, options?: { recursive?: boolean }): Promise<void>;\n readdir(\n path: string\n ): Promise<Array<{ name: string; size: number; isDirectory: boolean }>>;\n find(\n directory: string,\n pattern?: string\n ): Promise<Array<{ path: string; type: \"file\" | \"dir\" }>>;\n };\n}\n\n/** Directory skill scripts and relative paths resolve against. */\nconst WORKSPACE_ROOT = \"/workspace\";\nconst TEXT_ENCODER = new TextEncoder();\nconst TEXT_DECODER = new TextDecoder();\n\n/** @internal File operations a skill script reaches through its host. */\nexport interface SkillWorkspaceAccess {\n /** Read UTF-8 text, or `null` when the file does not exist. */\n readFile(path: string): Promise<string | null>;\n /** List a directory. */\n listFiles(\n path: string\n ): Promise<Array<{ path: string; name: string; type: string; size: number }>>;\n /** Find paths matching a glob. */\n glob(\n pattern: string\n ): Promise<Array<{ path: string; type: string; size: number }>>;\n /** Describe a path, or `null` when it does not exist. */\n stat(path: string): Promise<{ type: string; size: number } | null>;\n /** Write a file, creating missing parent directories. */\n writeFile(path: string, content: string | Uint8Array): Promise<void>;\n}\n\n/**\n * @internal Adapt a Workspace for skill scripts. Relative paths resolve\n * against `/workspace`, and paths outside `/workspace` are rejected.\n */\nexport function createSkillWorkspaceAccess(\n workspace: SkillScriptWorkspace\n): SkillWorkspaceAccess {\n const { fs } = workspace;\n const access: SkillWorkspaceAccess = {\n async readFile(path) {\n try {\n return TEXT_DECODER.decode(\n await drain(await fs.readFile(resolvePath(path)))\n );\n } catch (error) {\n if (isNotFound(error)) return null;\n throw error;\n }\n },\n async listFiles(path) {\n const directory = resolvePath(path);\n const entries = await fs.readdir(directory);\n return entries.map((entry) => ({\n path: `${directory.replace(/\\/$/, \"\")}/${entry.name}`,\n name: entry.name,\n type: entry.isDirectory ? \"directory\" : \"file\",\n size: entry.size\n }));\n },\n async glob(pattern) {\n const segments = resolvePath(pattern).split(\"/\").filter(Boolean);\n const firstGlob = segments.findIndex((part) => /[*?[\\]{}]/.test(part));\n if (firstGlob === -1) {\n const path = `/${segments.join(\"/\")}`;\n const found = await access.stat(path);\n return found === null ? [] : [{ path, ...found }];\n }\n let matches: Array<{ path: string; type: \"file\" | \"dir\" }>;\n try {\n matches = await fs.find(\n `/${segments.slice(0, firstGlob).join(\"/\")}`,\n segments.slice(firstGlob).join(\"/\")\n );\n } catch (error) {\n if (isNotFound(error)) return [];\n throw error;\n }\n // `find` walks real entries under the resolved base; keep the result\n // inside the root even if the Workspace follows a symlink out of it.\n return Promise.all(\n matches\n .filter((match) => isInsideRoot(match.path))\n .map(async (match) =>\n match.type === \"dir\"\n ? { path: match.path, type: \"directory\", size: 0 }\n : {\n path: match.path,\n type: \"file\",\n size: (await fs.stat(match.path)).size\n }\n )\n );\n },\n async stat(path) {\n try {\n const info = await fs.stat(resolvePath(path));\n return {\n type: info.isDirectory ? \"directory\" : \"file\",\n size: info.size\n };\n } catch (error) {\n if (isNotFound(error)) return null;\n throw error;\n }\n },\n async writeFile(path, content) {\n const absolute = resolvePath(path);\n const parent = absolute.slice(0, absolute.lastIndexOf(\"/\"));\n if (parent) await fs.mkdir(parent, { recursive: true });\n await fs.writeFile(\n absolute,\n typeof content === \"string\" ? TEXT_ENCODER.encode(content) : content\n );\n }\n };\n return access;\n}\n\nfunction isInsideRoot(path: string): boolean {\n return path === WORKSPACE_ROOT || path.startsWith(`${WORKSPACE_ROOT}/`);\n}\n\n/** A script asked for a path outside `/workspace`. */\nclass SkillWorkspacePathError extends Error {\n readonly _tag = \"SkillWorkspacePathError\" as const;\n\n constructor(readonly path: string) {\n super(\n `Skill scripts can only access paths under ${WORKSPACE_ROOT}: ${path}`\n );\n this.name = \"SkillWorkspacePathError\";\n }\n}\n\n/**\n * Resolve a script-supplied path to a normalized absolute path under\n * `/workspace`. Relative paths resolve against `/workspace`; `.` and `..`\n * are applied before the check, so `../x` or `/workspace/../x` cannot reach\n * the rest of the Workspace filesystem.\n *\n * @throws SkillWorkspacePathError when the path resolves outside\n * `/workspace`. The host bridge reports it to the script as a failed call.\n */\nfunction resolvePath(path: string): string {\n if (path.includes(\"\\0\")) throw new SkillWorkspacePathError(path);\n const absolute = path.startsWith(\"/\") ? path : `${WORKSPACE_ROOT}/${path}`;\n const parts: string[] = [];\n for (const part of absolute.split(\"/\")) {\n if (part === \"\" || part === \".\") continue;\n if (part === \"..\") {\n parts.pop();\n continue;\n }\n parts.push(part);\n }\n const resolved = `/${parts.join(\"/\")}`;\n if (!isInsideRoot(resolved)) throw new SkillWorkspacePathError(path);\n return resolved;\n}\n\nfunction isNotFound(error: unknown): boolean {\n if (!error || typeof error !== \"object\") return false;\n const record = error as { code?: unknown; message?: unknown };\n return (\n record.code === \"ENOENT\" ||\n (typeof record.message === \"string\" &&\n /ENOENT|no such file|not found/i.test(record.message))\n );\n}\n\nasync function drain(stream: ReadableStream<Uint8Array>): Promise<Uint8Array> {\n const parts: Uint8Array[] = [];\n let total = 0;\n const reader = stream.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n if (!value || value.byteLength === 0) continue;\n parts.push(value);\n total += value.byteLength;\n }\n } finally {\n reader.releaseLock();\n }\n if (parts.length === 1) return parts[0];\n const bytes = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n bytes.set(part, offset);\n offset += part.byteLength;\n }\n return bytes;\n}\n","import { RpcTarget } from \"cloudflare:workers\";\nimport { DynamicWorkerExecutor, resolveProvider } from \"@cloudflare/codemode\";\nimport type { ToolProvider } from \"@cloudflare/codemode\";\nimport { Bash, defineCommand } from \"just-bash\";\nimport type { ToolSet } from \"ai\";\nimport { extensionOf, parseSkillResourcePath } from \"./resource\";\nimport type {\n SkillScriptContext,\n SkillScriptRequest,\n SkillScriptRunner\n} from \"./script\";\nimport {\n createSkillWorkspaceAccess,\n type SkillScriptWorkspace,\n type SkillWorkspaceAccess\n} from \"./script-workspace\";\nimport { formatSkill } from \"./markdown\";\n\n// Exported as `agents/skills/runner`, apart from `agents/skills`, because\n// it loads `just-bash` and `@cloudflare/codemode`, which do not tree-shake.\n//\n// TODO: Prefer storing skills in a `@cloudflare/computer` Workspace and\n// running their scripts through the Workspace runtime (the agent's shell).\n// This runner stays for skills served from R2 or a manifest until Computer\n// covers those cases.\n\n/**\n * Options for {@link runner}.\n *\n * @experimental Skill script execution is experimental and the option shape\n * may change before stabilizing.\n */\nexport interface WorkerSkillScriptRunnerOptions {\n loader: WorkerLoader;\n timeout?: number;\n network?: boolean;\n workspace?: \"none\" | \"read\" | \"read-write\";\n workspaceInstance?: SkillScriptWorkspace;\n tools?: ToolSet | (() => ToolSet | Promise<ToolSet>);\n}\n\ntype SkillScriptRuntime = \"javascript\" | \"typescript\" | \"python\" | \"bash\";\ntype WorkspaceAccess = \"none\" | \"read\" | \"read-write\";\n\nconst DEFAULT_SCRIPT_TIMEOUT_MS = 30_000;\nconst MAX_OUTPUT_ARTIFACT_BYTES = 64_000;\nconst MAX_OUTPUT_ARTIFACTS = 20;\n\nconst SUPPORTED_SCRIPT_EXTENSIONS = new Set([\n \".js\",\n \".mjs\",\n \".ts\",\n \".tsx\",\n \".py\",\n \".sh\",\n \".bash\"\n]);\n\n// Logged once per isolate the first time a skill script actually runs.\nlet runnerExperimentalWarned = false;\n\nfunction effectiveTimeout(options: WorkerSkillScriptRunnerOptions): number {\n return options.timeout ?? DEFAULT_SCRIPT_TIMEOUT_MS;\n}\n\nfunction effectiveWorkspaceAccess(\n options: WorkerSkillScriptRunnerOptions\n): WorkspaceAccess {\n if (options.workspace) return options.workspace;\n return options.workspaceInstance ? \"read\" : \"none\";\n}\n\nfunction parseSkillScriptPath(path: string):\n | {\n ok: true;\n runtime: SkillScriptRuntime;\n }\n | {\n ok: false;\n error: string;\n } {\n if (!path.startsWith(\"scripts/\")) {\n return {\n ok: false,\n error: `Skill script path must start with \"scripts/\": ${path}`\n };\n }\n\n if (!parseSkillResourcePath(path).ok) {\n return {\n ok: false,\n error: `Skill script path must be a normalized relative path under \"scripts/\": ${path}`\n };\n }\n\n const extension = extensionOf(path);\n if (!SUPPORTED_SCRIPT_EXTENSIONS.has(extension)) {\n return {\n ok: false,\n error: `Unsupported skill script extension \"${extension || \"(none)\"}\" for ${path}. Supported extensions: ${[...SUPPORTED_SCRIPT_EXTENSIONS].join(\", \")}`\n };\n }\n\n if (extension === \".sh\" || extension === \".bash\") {\n return { ok: true, runtime: \"bash\" };\n }\n if (extension === \".py\") {\n return { ok: true, runtime: \"python\" };\n }\n if (extension === \".ts\" || extension === \".tsx\") {\n return { ok: true, runtime: \"typescript\" };\n }\n return { ok: true, runtime: \"javascript\" };\n}\n\nfunction validateMountedResourcePaths(request: SkillScriptRequest): void {\n for (const resource of request.resources ?? []) {\n const path = parseSkillResourcePath(resource.path);\n if (!path.ok) throw path.error;\n }\n}\n\nfunction skillScriptContext(request: SkillScriptRequest): SkillScriptContext {\n return {\n skill: {\n name: request.skill.name,\n description: request.skill.description,\n ...(request.skill.license === undefined\n ? {}\n : { license: request.skill.license }),\n ...(request.skill.compatibility === undefined\n ? {}\n : { compatibility: request.skill.compatibility }),\n metadata: request.skill.metadata,\n allowedTools: request.skill.allowedTools\n }\n };\n}\n\n/**\n * Text bundled resources exposed to function-style JS/TS scripts via\n * `ctx.files`. Binary resources are omitted in v1.\n */\nfunction textFilesMap(request: SkillScriptRequest): Record<string, string> {\n const files: Record<string, string> = {};\n for (const resource of request.resources ?? []) {\n if ((resource.encoding ?? \"text\") === \"text\") {\n files[resource.path] = resource.content;\n }\n }\n return files;\n}\n\nfunction base64ToBytes(value: string): Uint8Array {\n const binary = atob(value);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction stdinText(stdin: unknown): string {\n return typeof stdin === \"string\" ? stdin : String(stdin ?? \"\");\n}\n\n// ── Python / Bash file mounting (path-based contract) ─────────────────\n\nfunction mountedFiles(request: SkillScriptRequest): Record<\n string,\n {\n content: string;\n encoding: \"text\" | \"base64\";\n }\n> {\n const files: Record<\n string,\n {\n content: string;\n encoding: \"text\" | \"base64\";\n }\n > = {\n \"/input.json\": {\n content: JSON.stringify(request.input),\n encoding: \"text\"\n },\n \"/context.json\": {\n content: JSON.stringify(skillScriptContext(request)),\n encoding: \"text\"\n },\n \"/skill/SKILL.md\": {\n content: formatSkill(request.skill),\n encoding: \"text\"\n }\n };\n\n for (const resource of request.resources ?? []) {\n const path = parseSkillResourcePath(resource.path);\n if (!path.ok) throw path.error;\n files[`/skill/${resource.path}`] = {\n content: resource.content,\n encoding: resource.encoding ?? \"text\"\n };\n }\n files[`/skill/${request.path}`] = {\n content: request.source,\n encoding: \"text\"\n };\n\n return files;\n}\n\nfunction bashFiles(\n request: SkillScriptRequest\n): Record<string, string | Uint8Array> {\n const files: Record<string, string | Uint8Array> = {\n \"/input.json\": JSON.stringify(request.input),\n \"/context.json\": JSON.stringify(skillScriptContext(request)),\n \"/skill-script.sh\": request.source,\n \"/skill/SKILL.md\": formatSkill(request.skill),\n [`/skill/${request.path}`]: request.source\n };\n\n for (const resource of request.resources ?? []) {\n const path = parseSkillResourcePath(resource.path);\n if (!path.ok) throw path.error;\n files[`/skill/${resource.path}`] =\n (resource.encoding ?? \"text\") === \"base64\"\n ? base64ToBytes(resource.content)\n : resource.content;\n }\n\n return files;\n}\n\n// ── JS/TS function-style wrapper ──────────────────────────────────────\n\n/**\n * Wrap a function-style JS/TS skill module so it runs inside the codemode\n * sandbox. The module must `export default` an async `run(input, ctx)`; we\n * rewrite the default export to a local binding, build the `ctx` capability\n * object from the host bridge proxy (`__host`), and invoke it.\n */\nfunction scriptModule(source: string, request: SkillScriptRequest): string {\n const runnableSource = stripStrayExports(\n source.replace(/^\\s*export\\s+default\\s+/m, \"const __skillRun = \")\n );\n const skillMeta = skillScriptContext(request).skill;\n\n return [\n \"async () => {\",\n ` const input = ${JSON.stringify(request.input)};`,\n ` const __skill = ${JSON.stringify(skillMeta)};`,\n ` const __files = ${JSON.stringify(textFilesMap(request))};`,\n \" const workspace = {\",\n \" readFile: (path) => __host.readFile(path),\",\n ' listFiles: (path = \".\") => __host.listFiles(path),',\n \" glob: (pattern) => __host.glob(pattern),\",\n \" stat: (path) => __host.stat(path),\",\n \" writeFile: (path, content) => __host.writeFile({ path, content })\",\n \" };\",\n \" const tools = new Proxy(\",\n \" { call: (name, input) => __host.callTool({ name, input }) },\",\n \" {\",\n \" get: (target, prop) =>\",\n \" prop in target\",\n \" ? target[prop]\",\n \" : (input) => __host.callTool({ name: String(prop), input })\",\n \" }\",\n \" );\",\n \" const output = {\",\n \" writeFile: (name, content) => __host.writeOutput({ name, content })\",\n \" };\",\n \" const ctx = { skill: __skill, files: __files, workspace, tools, output };\",\n \"\",\n runnableSource,\n \"\",\n ' if (typeof __skillRun !== \"function\") {',\n ' throw new Error(\"Skill script default export must be a function (input, ctx).\");',\n \" }\",\n \" return await __skillRun(input, ctx);\",\n \"}\"\n ].join(\"\\n\");\n}\n\n/**\n * Whether a script declares a default export, in either the raw author form\n * (`export default ...`) or the bundled form esbuild emits\n * (`export { run as default }`).\n */\nfunction hasDefaultExport(source: string): boolean {\n return (\n /^\\s*export\\s+default\\s+/m.test(source) ||\n /export\\s*\\{[^}]*\\bas\\s+default\\b[^}]*\\}/m.test(source)\n );\n}\n\n/**\n * Remove `export { ... }` blocks, which are illegal inside the function wrapper\n * the runner builds around skill scripts.\n */\nfunction stripStrayExports(source: string): string {\n return source.replace(/\\n?export\\s*\\{[\\s\\S]*?\\};?/g, \"\");\n}\n\nfunction rewriteBundledSource(source: string): string {\n // esbuild emits the default export as a binding inside an `export { ... }`\n // block, e.g. `export { run as default }` or, when the module also has named\n // exports, `export { helper, run as default }`. Extract the binding aliased\n // to `default` from anywhere in those blocks, then strip the (illegal-inside-\n // a-function) export statements and bind the captured name to `__skillRun`.\n const defaultBinding = source.match(\n /\\bexport\\s*\\{[^}]*\\b([A-Za-z_$][\\w$]*)\\s+as\\s+default\\b[^}]*\\}/m\n );\n const stripped = stripStrayExports(source);\n if (defaultBinding) {\n return `${stripped}\\nconst __skillRun = ${defaultBinding[1]};`;\n }\n return stripped;\n}\n\nconst RELATIVE_IMPORT =\n /(?:\\bimport\\s[^;]*?\\bfrom\\s*|\\bimport\\s*\\(\\s*|\\bimport\\s+)[\"']\\.\\.?\\//;\n\n/**\n * Skill scripts run directly in the sandbox; there is no in-Worker bundler.\n * A script must be one self-contained JavaScript module: TypeScript and\n * scripts that import sibling files must be compiled before they are stored.\n * esbuild's `export { run as default }` output is normalized into the\n * `__skillRun` binding the wrapper expects.\n */\nfunction prepareJavaScriptSource(\n request: SkillScriptRequest,\n runtime: \"javascript\" | \"typescript\"\n): string {\n if (runtime === \"javascript\" && !RELATIVE_IMPORT.test(request.source)) {\n return /^\\s*export\\s+default\\s+/m.test(request.source)\n ? request.source\n : rewriteBundledSource(request.source);\n }\n\n throw new Error(\n `Skill script \"${request.path}\" must be compiled to a self-contained JavaScript module before it can run. ` +\n \"Bundle TypeScript or multi-file scripts (for example with esbuild) before storing the skill.\"\n );\n}\n\n// ── Host bridge: single capability + permission surface ───────────────\n\nasync function executeToolFromSet(\n tools: ToolSet | undefined,\n name: string,\n input: unknown\n): Promise<unknown> {\n const target = tools?.[name];\n const execute =\n target && \"execute\" in target\n ? (target.execute as ((input: unknown) => Promise<unknown>) | undefined)\n : undefined;\n\n if (!execute) throw new Error(`Tool not available: ${name}`);\n return execute(input);\n}\n\nfunction stringifyHostResult(result: unknown): string {\n return JSON.stringify({ result });\n}\n\nfunction stringifyHostError(error: unknown): string {\n return JSON.stringify({\n error: error instanceof Error ? error.message : String(error)\n });\n}\n\ninterface OutputArtifact {\n path: string;\n encoding: \"text\";\n content: string;\n}\n\n/**\n * The single source of truth for skill-script capabilities and permission\n * enforcement. Every runtime delegates here:\n *\n * - JavaScript/TypeScript reach it through a codemode `ToolProvider`.\n * - Python receives it as an RPC `RpcTarget` (JSON-marshalling methods).\n * - Bash calls it from `just-bash` custom commands.\n *\n * Construct a fresh bridge per `run()` so the per-invocation `/output`\n * artifact buffer is never shared between concurrent script runs.\n */\nclass SkillScriptHostBridge extends RpcTarget {\n readonly #tools: ToolSet | undefined;\n readonly #workspace: SkillWorkspaceAccess | undefined;\n readonly #workspaceAccess: WorkspaceAccess;\n readonly #outputs = new Map<string, OutputArtifact>();\n\n constructor(\n tools: ToolSet | undefined,\n workspace: SkillScriptWorkspace | undefined,\n workspaceAccess: WorkspaceAccess\n ) {\n super();\n this.#tools = tools;\n this.#workspace =\n workspace === undefined\n ? undefined\n : createSkillWorkspaceAccess(workspace);\n this.#workspaceAccess = workspaceAccess;\n }\n\n // ── Introspection (host-side only) ──\n get workspaceAccess(): WorkspaceAccess {\n return this.#workspaceAccess;\n }\n\n hasTools(): boolean {\n return Boolean(this.#tools && Object.keys(this.#tools).length > 0);\n }\n\n // ── Canonical capability surface ──\n async callTool(name: string, input: unknown): Promise<unknown> {\n return executeToolFromSet(this.#tools, name, input);\n }\n\n async readFile(path: string): Promise<string | null> {\n return this.#requireWorkspace(\"read\").readFile(path);\n }\n\n async listFiles(path = \".\"): Promise<unknown> {\n return this.#requireWorkspace(\"read\").listFiles(path);\n }\n\n async glob(pattern: string): Promise<unknown> {\n return this.#requireWorkspace(\"read\").glob(pattern);\n }\n\n async stat(path: string): Promise<{ type: string; size: number } | null> {\n return this.#requireWorkspace(\"read\").stat(path);\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n await this.#requireWorkspace(\"read-write\").writeFile(path, content);\n }\n\n writeOutput(name: string, content: string): void {\n const key = String(name);\n const text = typeof content === \"string\" ? content : String(content ?? \"\");\n const bytes = new TextEncoder().encode(text).byteLength;\n if (bytes > MAX_OUTPUT_ARTIFACT_BYTES) {\n throw new Error(\n `Output artifact \"${key}\" exceeds ${MAX_OUTPUT_ARTIFACT_BYTES} bytes.`\n );\n }\n if (!this.#outputs.has(key) && this.#outputs.size >= MAX_OUTPUT_ARTIFACTS) {\n throw new Error(\n `Too many skill output artifacts (max ${MAX_OUTPUT_ARTIFACTS}).`\n );\n }\n this.#outputs.set(key, { path: key, encoding: \"text\", content: text });\n }\n\n getOutputFiles(): OutputArtifact[] {\n return [...this.#outputs.values()];\n }\n\n // ── Python-facing JSON marshalling (delegates to canonical surface) ──\n async tool(name: string, inputJson = \"{}\"): Promise<string> {\n try {\n const input = inputJson.trim() ? JSON.parse(inputJson) : {};\n return stringifyHostResult(await this.callTool(name, input));\n } catch (error) {\n return stringifyHostError(error);\n }\n }\n\n async workspaceReadFile(path: string): Promise<string> {\n try {\n return stringifyHostResult(await this.readFile(path));\n } catch (error) {\n return stringifyHostError(error);\n }\n }\n\n async workspaceListFiles(path = \".\"): Promise<string> {\n try {\n return stringifyHostResult(await this.listFiles(path));\n } catch (error) {\n return stringifyHostError(error);\n }\n }\n\n async workspaceGlob(pattern: string): Promise<string> {\n try {\n return stringifyHostResult(await this.glob(pattern));\n } catch (error) {\n return stringifyHostError(error);\n }\n }\n\n async workspaceWriteFile(path: string, content: string): Promise<string> {\n try {\n await this.writeFile(path, content);\n return stringifyHostResult(null);\n } catch (error) {\n return stringifyHostError(error);\n }\n }\n\n #requireWorkspace(access: \"read\" | \"read-write\"): SkillWorkspaceAccess {\n if (!this.#workspace || this.#workspaceAccess === \"none\") {\n throw new Error(\"Workspace access is not available.\");\n }\n if (access === \"read-write\" && this.#workspaceAccess !== \"read-write\") {\n throw new Error(\"Workspace write access is not available.\");\n }\n return this.#workspace;\n }\n}\n\n/**\n * Expose the bridge to JS/TS scripts as a single codemode provider namespace\n * (`__host`). The sandbox `ctx` object wraps these calls into the friendly\n * `workspace` / `tools` / `output` surface (see {@link scriptModule}).\n */\nfunction hostProvider(bridge: SkillScriptHostBridge): ToolProvider {\n return {\n name: \"__host\",\n tools: {\n callTool: {\n execute: (a: unknown) => {\n const { name, input } = a as { name: string; input: unknown };\n return bridge.callTool(name, input);\n }\n },\n readFile: {\n execute: (a: unknown) => bridge.readFile(String(a))\n },\n listFiles: {\n execute: (a: unknown) =>\n bridge.listFiles(typeof a === \"string\" ? a : \".\")\n },\n glob: {\n execute: (a: unknown) => bridge.glob(String(a))\n },\n stat: {\n execute: (a: unknown) => bridge.stat(String(a))\n },\n writeFile: {\n execute: (a: unknown) => {\n const { path, content } = a as { path: string; content: string };\n return bridge.writeFile(path, content);\n }\n },\n writeOutput: {\n execute: async (a: unknown) => {\n const { name, content } = a as { name: string; content: string };\n bridge.writeOutput(name, content);\n return null;\n }\n }\n }\n };\n}\n\n// ── Python runtime ────────────────────────────────────────────────────\n\nfunction pythonScriptModule(request: SkillScriptRequest): string {\n const source = request.source;\n const sourceLiteral = JSON.stringify(source);\n const filesLiteral = JSON.stringify(mountedFiles(request));\n\n return String.raw`\nimport asyncio\nimport base64\nimport contextlib\nimport inspect\nimport io\nimport json\nimport os\nimport sys\nimport time\nimport types\nfrom js import Object\nfrom pyodide.ffi import to_js as pyodide_to_js\nfrom workers import WorkerEntrypoint\n\nSKILL_SOURCE = ${sourceLiteral}\nSKILL_FILES = ${filesLiteral}\n\nasync def maybe_await(value):\n if inspect.isawaitable(value):\n return await value\n return value\n\nasync def decode_host_response(raw):\n data = json.loads(str(raw))\n if \"error\" in data:\n raise Exception(data[\"error\"])\n return data.get(\"result\")\n\ndef to_js(obj):\n return pyodide_to_js(obj, dict_converter=Object.fromEntries)\n\ndef materialize_files():\n os.makedirs(\"/output\", exist_ok=True)\n for path, file in SKILL_FILES.items():\n directory = os.path.dirname(path)\n if directory:\n os.makedirs(directory, exist_ok=True)\n mode = \"wb\" if file.get(\"encoding\") == \"base64\" else \"w\"\n with open(path, mode) as handle:\n if file.get(\"encoding\") == \"base64\":\n handle.write(base64.b64decode(file.get(\"content\", \"\")))\n else:\n handle.write(file.get(\"content\", \"\"))\n\ndef collect_output_files():\n output_files = []\n if not os.path.isdir(\"/output\"):\n return output_files\n\n for root, _dirs, files in os.walk(\"/output\"):\n for name in sorted(files):\n path = os.path.join(root, name)\n with open(path, \"rb\") as handle:\n content = handle.read()\n if len(content) > ${MAX_OUTPUT_ARTIFACT_BYTES}:\n raise Exception(f\"Output artifact exceeds ${MAX_OUTPUT_ARTIFACT_BYTES} bytes: {path}\")\n try:\n output_files.append({\n \"path\": path,\n \"encoding\": \"text\",\n \"content\": content.decode(\"utf-8\")\n })\n except UnicodeDecodeError:\n output_files.append({\n \"path\": path,\n \"encoding\": \"base64\",\n \"content\": base64.b64encode(content).decode(\"ascii\")\n })\n\n return sorted(output_files, key=lambda file: file[\"path\"])\n\ndef looks_function_style(source):\n return \"def run(\" in source or \"async def run(\" in source\n\ndef timeout_trace(deadline):\n def trace(frame, event, arg):\n if time.monotonic() > deadline:\n raise TimeoutError(\"Python script execution timed out\")\n return trace\n return trace\n\nclass ToolNamespace:\n def __init__(self, host):\n self.host = host\n\n async def call(self, name, input=None):\n raw = await self.host.tool(name, json.dumps(input if input is not None else {}))\n return await decode_host_response(raw)\n\n def __getattr__(self, name):\n async def call_tool(input=None):\n return await self.call(name, input)\n return call_tool\n\nclass WorkspaceNamespace:\n def __init__(self, host):\n self.host = host\n\n async def read_file(self, path):\n raw = await self.host.workspaceReadFile(path)\n return await decode_host_response(raw)\n\n async def list_files(self, path=\".\"):\n raw = await self.host.workspaceListFiles(path)\n return await decode_host_response(raw)\n\n async def glob(self, pattern):\n raw = await self.host.workspaceGlob(pattern)\n return await decode_host_response(raw)\n\n async def write_file(self, path, content):\n raw = await self.host.workspaceWriteFile(path, content)\n return await decode_host_response(raw)\n\nclass Default(WorkerEntrypoint):\n async def evaluate(self, input, ctx, host, timeout_ms=None):\n materialize_files()\n try:\n if looks_function_style(SKILL_SOURCE):\n skill_module = types.ModuleType(\"skill_script\")\n skill_module.tools = ToolNamespace(host)\n skill_module.workspace = WorkspaceNamespace(host)\n exec(SKILL_SOURCE, skill_module.__dict__)\n if not hasattr(skill_module, \"run\") or not callable(skill_module.run):\n raise Exception(\"Python function-style skill script must define a callable run(input, ctx).\")\n execution = maybe_await(skill_module.run(input, ctx))\n previous_trace = sys.gettrace()\n if timeout_ms is not None:\n sys.settrace(timeout_trace(time.monotonic() + (timeout_ms / 1000)))\n try:\n if timeout_ms is not None:\n result = await asyncio.wait_for(execution, timeout_ms / 1000)\n else:\n result = await execution\n finally:\n sys.settrace(previous_trace)\n return to_js({\n \"result\": result,\n \"logs\": [],\n \"mode\": \"function\",\n \"outputFiles\": collect_output_files()\n })\n\n stdout = io.StringIO()\n stderr = io.StringIO()\n previous_stdin = sys.stdin\n previous_trace = sys.gettrace()\n if timeout_ms is not None:\n sys.settrace(timeout_trace(time.monotonic() + (timeout_ms / 1000)))\n sys.stdin = io.StringIO(json.dumps(input))\n try:\n namespace = {\"__name__\": \"__main__\", \"__file__\": \"/skill/script.py\"}\n with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):\n exec(SKILL_SOURCE, namespace)\n finally:\n sys.stdin = previous_stdin\n sys.settrace(previous_trace)\n return to_js({\n \"result\": {\n \"stdout\": stdout.getvalue(),\n \"stderr\": stderr.getvalue(),\n \"exitCode\": 0\n },\n \"logs\": [],\n \"mode\": \"cli\",\n \"outputFiles\": collect_output_files()\n })\n except TimeoutError:\n return to_js({\"error\": \"Python script execution timed out\", \"logs\": []})\n except SystemExit as err:\n return to_js({\n \"result\": {\n \"stdout\": stdout.getvalue() if \"stdout\" in locals() else \"\",\n \"stderr\": stderr.getvalue() if \"stderr\" in locals() else \"\",\n \"exitCode\": int(err.code) if isinstance(err.code, int) else 1\n },\n \"logs\": [],\n \"mode\": \"cli\",\n \"outputFiles\": collect_output_files()\n })\n except asyncio.TimeoutError:\n return to_js({\"error\": \"Python script execution timed out\", \"logs\": []})\n except Exception as err:\n return to_js({\"error\": str(err), \"logs\": []})\n`;\n}\n\nasync function runPythonScript(\n request: SkillScriptRequest,\n options: WorkerSkillScriptRunnerOptions,\n bridge: SkillScriptHostBridge\n): Promise<unknown> {\n const worker = options.loader.get(\n `skill-python-${crypto.randomUUID()}`,\n () => ({\n compatibilityDate: \"2026-05-23\",\n compatibilityFlags: [\"python_workers\", \"disable_python_external_sdk\"],\n mainModule: \"skill_runner.py\",\n modules: {\n \"skill_runner.py\": pythonScriptModule(request)\n },\n globalOutbound: options.network ? undefined : null\n })\n );\n\n const entrypoint = worker.getEntrypoint() as unknown as {\n evaluate(\n input: unknown,\n ctx: SkillScriptContext,\n host: SkillScriptHostBridge,\n timeoutMs?: number\n ): Promise<{\n result?: unknown;\n error?: string;\n logs?: string[];\n mode?: \"cli\" | \"function\";\n outputFiles?: unknown[];\n }>;\n };\n\n const execution = entrypoint.evaluate(\n request.input,\n skillScriptContext(request),\n bridge,\n effectiveTimeout(options)\n );\n let timeout: ReturnType<typeof setTimeout> | null = null;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeout = setTimeout(\n () => reject(new Error(\"Python script execution timed out\")),\n effectiveTimeout(options)\n );\n });\n\n try {\n const response = await Promise.race([execution, timeoutPromise]);\n if (response.error) {\n throw new Error(response.error);\n }\n\n const outputFiles = response.outputFiles ?? [];\n\n if (response.mode === \"cli\") {\n if (\n typeof response.result === \"object\" &&\n response.result !== null &&\n outputFiles.length > 0\n ) {\n return {\n ...response.result,\n outputFiles\n };\n }\n return response.result;\n }\n\n if (response.logs?.length || outputFiles.length > 0) {\n return {\n result: response.result,\n ...(response.logs?.length ? { logs: response.logs } : {}),\n ...(outputFiles.length > 0 ? { outputFiles } : {})\n };\n }\n\n return response.result;\n } finally {\n if (timeout) clearTimeout(timeout);\n }\n}\n\n// ── Bash runtime ──────────────────────────────────────────────────────\n\nasync function runBashScript(\n request: SkillScriptRequest,\n options: WorkerSkillScriptRunnerOptions,\n bridge: SkillScriptHostBridge\n): Promise<unknown> {\n const customCommands = [];\n\n if (bridge.workspaceAccess !== \"none\") {\n customCommands.push(\n defineCommand(\"workspace-read\", async (args) => {\n const path = args[0];\n if (!path) return { stdout: \"\", stderr: \"Missing path\\n\", exitCode: 2 };\n try {\n return {\n stdout: (await bridge.readFile(path)) ?? \"\",\n stderr: \"\",\n exitCode: 0\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: `${error instanceof Error ? error.message : String(error)}\\n`,\n exitCode: 1\n };\n }\n }),\n defineCommand(\"workspace-list\", async (args) => {\n const path = args[0] ?? \".\";\n try {\n return {\n stdout: JSON.stringify(await bridge.listFiles(path)) + \"\\n\",\n stderr: \"\",\n exitCode: 0\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: `${error instanceof Error ? error.message : String(error)}\\n`,\n exitCode: 1\n };\n }\n }),\n defineCommand(\"workspace-glob\", async (args) => {\n const pattern = args[0];\n if (!pattern) {\n return { stdout: \"\", stderr: \"Missing pattern\\n\", exitCode: 2 };\n }\n try {\n return {\n stdout: JSON.stringify(await bridge.glob(pattern)) + \"\\n\",\n stderr: \"\",\n exitCode: 0\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: `${error instanceof Error ? error.message : String(error)}\\n`,\n exitCode: 1\n };\n }\n })\n );\n\n if (bridge.workspaceAccess === \"read-write\") {\n customCommands.push(\n defineCommand(\"workspace-write\", async (args, ctx) => {\n const path = args[0];\n if (!path) {\n return { stdout: \"\", stderr: \"Missing path\\n\", exitCode: 2 };\n }\n try {\n await bridge.writeFile(path, stdinText(ctx.stdin));\n return { stdout: \"\", stderr: \"\", exitCode: 0 };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: `${error instanceof Error ? error.message : String(error)}\\n`,\n exitCode: 1\n };\n }\n })\n );\n }\n }\n\n if (bridge.hasTools()) {\n customCommands.push(\n defineCommand(\"tool\", async (args, ctx) => {\n const name = args[0];\n if (!name) {\n return { stdout: \"\", stderr: \"Missing tool name\\n\", exitCode: 2 };\n }\n try {\n const rawInput = args[1] ?? stdinText(ctx.stdin) ?? \"{}\";\n const input = rawInput.trim() ? JSON.parse(rawInput) : {};\n const result = await bridge.callTool(name, input);\n return {\n stdout: JSON.stringify(result) + \"\\n\",\n stderr: \"\",\n exitCode: 0\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: `${error instanceof Error ? error.message : String(error)}\\n`,\n exitCode: 1\n };\n }\n })\n );\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(\n () => controller.abort(),\n effectiveTimeout(options)\n );\n\n try {\n const bash = new Bash({\n files: bashFiles(request),\n customCommands,\n defenseInDepth: true,\n network: options.network ? {} : undefined\n });\n const result = await bash.exec(\"bash /skill-script.sh\", {\n signal: controller.signal,\n stdin: JSON.stringify(request.input)\n });\n\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode\n };\n } finally {\n if (timeout) clearTimeout(timeout);\n }\n}\n\n// ── JavaScript / TypeScript runtime ───────────────────────────────────\n\nasync function runJavaScriptScript(\n request: SkillScriptRequest,\n options: WorkerSkillScriptRunnerOptions,\n bridge: SkillScriptHostBridge,\n runtime: \"javascript\" | \"typescript\"\n): Promise<unknown> {\n if (!hasDefaultExport(request.source)) {\n throw new Error(\n \"JS/TS skill scripts must `export default` an async run(input, ctx) function.\"\n );\n }\n\n const source = prepareJavaScriptSource(request, runtime);\n const executor = new DynamicWorkerExecutor({\n loader: options.loader,\n timeout: effectiveTimeout(options),\n globalOutbound: options.network ? undefined : null\n });\n const result = await executor.execute(scriptModule(source, request), [\n resolveProvider(hostProvider(bridge))\n ]);\n\n if (result.error) {\n const logs = result.logs?.length\n ? `\\n\\nConsole output:\\n${result.logs.join(\"\\n\")}`\n : \"\";\n throw new Error(`${result.error}${logs}`);\n }\n\n const outputFiles = bridge.getOutputFiles();\n if (result.logs?.length || outputFiles.length > 0) {\n return {\n result: result.result,\n ...(result.logs?.length ? { logs: result.logs } : {}),\n ...(outputFiles.length > 0 ? { outputFiles } : {})\n };\n }\n\n return result.result;\n}\n\n/**\n * Create a skill script runner backed by a Worker Loader.\n *\n * Capabilities are opt-in and enforced by a single host bridge: no network and\n * no tools by default, read-only workspace access when `workspaceInstance` is\n * provided. JS/TS scripts are function-style (`export default run(input, ctx)`)\n * and receive `ctx = { skill, files, workspace, tools, output }`. Python and\n * Bash use the path-based `/skill`, `/input.json`, `/output` contract.\n *\n * @experimental Skill script execution is experimental and may change before\n * stabilizing.\n */\nexport function runner(\n options: WorkerSkillScriptRunnerOptions\n): SkillScriptRunner {\n return {\n async run(request: SkillScriptRequest) {\n if (!runnerExperimentalWarned) {\n runnerExperimentalWarned = true;\n console.warn(\n \"[think] skills.runner script execution is experimental; the API and capabilities may change.\"\n );\n }\n\n const tools =\n typeof options.tools === \"function\"\n ? await options.tools()\n : options.tools;\n const validation = parseSkillScriptPath(request.path);\n if (!validation.ok) throw new Error(validation.error);\n validateMountedResourcePaths(request);\n\n // Fresh bridge per run so /output artifacts never leak between\n // concurrent script invocations.\n const bridge = new SkillScriptHostBridge(\n tools,\n options.workspaceInstance,\n effectiveWorkspaceAccess(options)\n );\n\n if (validation.runtime === \"bash\") {\n return await runBashScript(request, options, bridge);\n }\n\n if (validation.runtime === \"python\") {\n return await runPythonScript(request, options, bridge);\n }\n\n return await runJavaScriptScript(\n request,\n options,\n bridge,\n validation.runtime\n );\n }\n };\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,iBAAiB;AACvB,MAAM,eAAe,IAAI,YAAY;AACrC,MAAM,eAAe,IAAI,YAAY;;;;;AAwBrC,SAAgB,2BACd,WACsB;CACtB,MAAM,EAAE,OAAO;CACf,MAAM,SAA+B;EACnC,MAAM,SAAS,MAAM;GACnB,IAAI;IACF,OAAO,aAAa,OAClB,MAAM,MAAM,MAAM,GAAG,SAAS,YAAY,IAAI,CAAC,CAAC,CAClD;GACF,SAAS,OAAO;IACd,IAAI,WAAW,KAAK,GAAG,OAAO;IAC9B,MAAM;GACR;EACF;EACA,MAAM,UAAU,MAAM;GACpB,MAAM,YAAY,YAAY,IAAI;GAElC,QAAO,MADe,GAAG,QAAQ,SAAS,EAAA,CAC3B,KAAK,WAAW;IAC7B,MAAM,GAAG,UAAU,QAAQ,OAAO,EAAE,EAAE,GAAG,MAAM;IAC/C,MAAM,MAAM;IACZ,MAAM,MAAM,cAAc,cAAc;IACxC,MAAM,MAA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AAM,QAAQ,MAAM,IACpB,QAAQ;EACd,MAAM,aAAa,qBAAqB,QAAQ,IAAI;EACpD,IAAI,CAAC,WAAW,IAAI,MAAM,IAAI,MAAM,WAAW,KAAK;EACpD,6BAA6B,OAAO;EAIpC,MAAM,SAAS,IAAI,sBACjB,OACA,QAAQ,mBACR,yBAAyB,OAAO,CAClC;EAEA,IAAI,WAAW,YAAY,QACzB,OAAO,MAAM,cAAc,SAAS,SAAS,MAAM;EAGrD,IAAI,WAAW,YAAY,UACzB,OAAO,MAAM,gBAAgB,SAAS,SAAS,MAAM;EAGvD,OAAO,MAAM,oBACX,SACA,SACA,QACA,WAAW,OACb;CACF,EACF;AACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { n as SkillCatalog } from "../../catalog-BpiVV1OF.js";
|
|
2
|
+
import { a as SkillScriptRunner } from "../../script-CFDLTk5b.js";
|
|
3
|
+
import { ToolSet } from "ai";
|
|
4
|
+
|
|
5
|
+
//#region src/skills/tools/ai-sdk.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* AI SDK tools for Agent Skills, exported as `agents/skills/tools/ai-sdk`.
|
|
8
|
+
*
|
|
9
|
+
* Kept out of the `agents/skills` entry so the parser and sources do not
|
|
10
|
+
* pull in `ai` or `zod`.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** Options for {@link createSkillTools}. */
|
|
15
|
+
interface SkillToolsOptions {
|
|
16
|
+
/** Enables `run_skill_script`. Experimental. */
|
|
17
|
+
readonly scriptRunner?: SkillScriptRunner | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build AI SDK tools for a catalog: `activate_skill`, `read_skill_resource`,
|
|
21
|
+
* and, with a script runner, `run_skill_script`.
|
|
22
|
+
*
|
|
23
|
+
* Failures (an unknown skill, a missing file) are thrown, so the AI SDK
|
|
24
|
+
* returns them to the model as tool errors.
|
|
25
|
+
*
|
|
26
|
+
* @param catalog - The catalog to expose. Build tools again after reloading it.
|
|
27
|
+
* @param options - Optional script runner.
|
|
28
|
+
* @returns The tools, or an empty set when the catalog has no skills.
|
|
29
|
+
*/
|
|
30
|
+
declare function createSkillTools(
|
|
31
|
+
catalog: SkillCatalog,
|
|
32
|
+
options?: SkillToolsOptions
|
|
33
|
+
): ToolSet;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { SkillToolsOptions, createSkillTools };
|
|
36
|
+
//# sourceMappingURL=ai-sdk.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { i as renderSkillResource } from "../../catalog-BpOejOsE.js";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/skills/tools/ai-sdk.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build AI SDK tools for a catalog: `activate_skill`, `read_skill_resource`,
|
|
7
|
+
* and, with a script runner, `run_skill_script`.
|
|
8
|
+
*
|
|
9
|
+
* Failures (an unknown skill, a missing file) are thrown, so the AI SDK
|
|
10
|
+
* returns them to the model as tool errors.
|
|
11
|
+
*
|
|
12
|
+
* @param catalog - The catalog to expose. Build tools again after reloading it.
|
|
13
|
+
* @param options - Optional script runner.
|
|
14
|
+
* @returns The tools, or an empty set when the catalog has no skills.
|
|
15
|
+
*/
|
|
16
|
+
function createSkillTools(catalog, options = {}) {
|
|
17
|
+
const [first, ...rest] = catalog.skills.map((entry) => entry.skill.name);
|
|
18
|
+
if (first === void 0) return {};
|
|
19
|
+
const nameSchema = z.enum([first, ...rest]);
|
|
20
|
+
const tools = {
|
|
21
|
+
activate_skill: tool({
|
|
22
|
+
description: "Activate a skill by name. Use this when the user's task matches one of the available skills.",
|
|
23
|
+
inputSchema: z.object({ name: nameSchema }),
|
|
24
|
+
execute: async ({ name }) => {
|
|
25
|
+
const activated = catalog.activate(name);
|
|
26
|
+
if (!activated.ok) throw activated.error;
|
|
27
|
+
return activated.value;
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
read_skill_resource: tool({
|
|
31
|
+
description: "Read a bundled resource from an available skill by relative path. Pass name and path, or use a qualified path like skill-name/references/file.md.",
|
|
32
|
+
inputSchema: z.object({
|
|
33
|
+
name: nameSchema.optional(),
|
|
34
|
+
path: z.string().min(1)
|
|
35
|
+
}),
|
|
36
|
+
execute: async ({ name, path }) => {
|
|
37
|
+
const read = await catalog.readResource(name === void 0 ? { path } : {
|
|
38
|
+
name,
|
|
39
|
+
path
|
|
40
|
+
});
|
|
41
|
+
if (!read.ok) throw read.error;
|
|
42
|
+
return renderSkillResource(read.value);
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
const runner = options.scriptRunner;
|
|
47
|
+
if (runner) tools.run_skill_script = tool({
|
|
48
|
+
description: "Run a bundled script resource from an available skill. Use only when a skill instructs you to run a script.",
|
|
49
|
+
inputSchema: z.object({
|
|
50
|
+
name: nameSchema,
|
|
51
|
+
path: z.string().min(1),
|
|
52
|
+
input: z.unknown().default({})
|
|
53
|
+
}),
|
|
54
|
+
execute: async ({ name, path, input }) => {
|
|
55
|
+
const script = await catalog.readResource({
|
|
56
|
+
name,
|
|
57
|
+
path
|
|
58
|
+
});
|
|
59
|
+
if (!script.ok) throw script.error;
|
|
60
|
+
const { entry, resource } = script.value;
|
|
61
|
+
if (resource.kind !== "script") throw new Error(`Resource is not a script: ${name}/${path}`);
|
|
62
|
+
if (resource.encoding !== "text") throw new Error(`Script resource must be text: ${name}/${path}`);
|
|
63
|
+
const files = [];
|
|
64
|
+
for (const info of entry.resources) {
|
|
65
|
+
const read = await catalog.readResource({
|
|
66
|
+
name,
|
|
67
|
+
path: info.path
|
|
68
|
+
});
|
|
69
|
+
if (read.ok) files.push({
|
|
70
|
+
path: read.value.resource.path,
|
|
71
|
+
content: read.value.resource.content,
|
|
72
|
+
encoding: read.value.resource.encoding,
|
|
73
|
+
kind: read.value.resource.kind
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
return await runner.run({
|
|
78
|
+
skill: entry.skill,
|
|
79
|
+
path: resource.path,
|
|
80
|
+
source: resource.content,
|
|
81
|
+
input,
|
|
82
|
+
resources: files
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
throw new Error(`Skill script failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return tools;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { createSkillTools };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=ai-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk.js","names":[],"sources":["../../../src/skills/tools/ai-sdk.ts"],"sourcesContent":["import { tool, type ToolSet } from \"ai\";\nimport { z } from \"zod\";\nimport { renderSkillResource, type SkillCatalog } from \"../catalog\";\nimport type { SkillScriptFile, SkillScriptRunner } from \"../script\";\n\n/**\n * AI SDK tools for Agent Skills, exported as `agents/skills/tools/ai-sdk`.\n *\n * Kept out of the `agents/skills` entry so the parser and sources do not\n * pull in `ai` or `zod`.\n *\n * @module\n */\n\n/** Options for {@link createSkillTools}. */\nexport interface SkillToolsOptions {\n /** Enables `run_skill_script`. Experimental. */\n readonly scriptRunner?: SkillScriptRunner | null;\n}\n\n/**\n * Build AI SDK tools for a catalog: `activate_skill`, `read_skill_resource`,\n * and, with a script runner, `run_skill_script`.\n *\n * Failures (an unknown skill, a missing file) are thrown, so the AI SDK\n * returns them to the model as tool errors.\n *\n * @param catalog - The catalog to expose. Build tools again after reloading it.\n * @param options - Optional script runner.\n * @returns The tools, or an empty set when the catalog has no skills.\n */\nexport function createSkillTools(\n catalog: SkillCatalog,\n options: SkillToolsOptions = {}\n): ToolSet {\n const names = catalog.skills.map((entry) => entry.skill.name);\n const [first, ...rest] = names;\n if (first === undefined) return {};\n const nameSchema = z.enum([first, ...rest]);\n\n const tools: ToolSet = {\n activate_skill: tool({\n description:\n \"Activate a skill by name. Use this when the user's task matches one of the available skills.\",\n inputSchema: z.object({ name: nameSchema }),\n execute: async ({ name }) => {\n const activated = catalog.activate(name);\n // Thrown errors reach the model as a tool error, with this message.\n if (!activated.ok) throw activated.error;\n return activated.value;\n }\n }),\n read_skill_resource: tool({\n description:\n \"Read a bundled resource from an available skill by relative path. Pass name and path, or use a qualified path like skill-name/references/file.md.\",\n inputSchema: z.object({\n name: nameSchema.optional(),\n path: z.string().min(1)\n }),\n execute: async ({ name, path }) => {\n const read = await catalog.readResource(\n name === undefined ? { path } : { name, path }\n );\n if (!read.ok) throw read.error;\n return renderSkillResource(read.value);\n }\n })\n };\n\n const runner = options.scriptRunner;\n if (runner) {\n tools.run_skill_script = tool({\n description:\n \"Run a bundled script resource from an available skill. Use only when a skill instructs you to run a script.\",\n inputSchema: z.object({\n name: nameSchema,\n path: z.string().min(1),\n input: z.unknown().default({})\n }),\n execute: async ({ name, path, input }) => {\n const script = await catalog.readResource({ name, path });\n if (!script.ok) throw script.error;\n const { entry, resource } = script.value;\n if (resource.kind !== \"script\") {\n throw new Error(`Resource is not a script: ${name}/${path}`);\n }\n if (resource.encoding !== \"text\") {\n throw new Error(`Script resource must be text: ${name}/${path}`);\n }\n\n const files: SkillScriptFile[] = [];\n for (const info of entry.resources) {\n const read = await catalog.readResource({ name, path: info.path });\n if (read.ok) {\n files.push({\n path: read.value.resource.path,\n content: read.value.resource.content,\n encoding: read.value.resource.encoding,\n kind: read.value.resource.kind\n });\n }\n }\n\n try {\n return await runner.run({\n skill: entry.skill,\n path: resource.path,\n source: resource.content,\n input,\n resources: files\n });\n } catch (error) {\n throw new Error(\n `Skill script failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n });\n }\n\n return tools;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,SAAgB,iBACd,SACA,UAA6B,CAAC,GACrB;CAET,MAAM,CAAC,OAAO,GAAG,QADH,QAAQ,OAAO,KA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7D,IAAI,SAAS,aAAa,QACxB,MAAM,IAAI,MAAM,iCAAiC,KAAK,GAAG,MAAM;GAGjE,MAAM,QAA2B,CAAC;GAClC,KAAK,MAAM,QAAQ,MAAM,WAAW;IAClC,MAAM,OAAO,MAAM,QAAQ,aAAa;KAAE;KAAM,MAAM,KAAK;IAAK,CAAC;IACjE,IAAI,KAAK,IACP,MAAM,KAAK;KACT,MAAM,KAAK,MAAM,SAAS;KAC1B,SAAS,KAAK,MAAM,SAAS;KAC7B,UAAU,KAAK,MAAM,SAAS;KAC9B,MAAM,KAAK,MAAM,SAAS;IAC5B,CAAC;GAEL;GAEA,IAAI;IACF,OAAO,MAAM,OAAO,IAAI;KACtB,OAAO,MAAM;KACb,MAAM,SAAS;KACf,QAAQ,SAAS;KACjB;KACA,WAAW;IACb,CAAC;GACH,SAAS,OAAO;IACd,MAAM,IAAI,MACR,wBAAwB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KAC7E,EAAE,OAAO,MAAM,CACjB;GACF;EACF;CACF,CAAC;CAGH,OAAO;AACT"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
d as SkillResourceInfo,
|
|
3
|
+
h as SkillResult,
|
|
4
|
+
i as SkillParseError,
|
|
5
|
+
n as Skill,
|
|
6
|
+
p as SkillResourcePath,
|
|
7
|
+
r as SkillName,
|
|
8
|
+
u as SkillResource
|
|
9
|
+
} from "./skill-DRBcIBjC.js";
|
|
10
|
+
|
|
11
|
+
//#region src/skills/source.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Where skills are loaded from: a Computer Workspace, an R2 bucket, an
|
|
14
|
+
* in-memory manifest, or a custom store.
|
|
15
|
+
*
|
|
16
|
+
* A source lists every skill it holds on each call, so changes show up the
|
|
17
|
+
* next time a catalog is loaded. Expected failures are returned, not thrown.
|
|
18
|
+
*/
|
|
19
|
+
interface SkillSource {
|
|
20
|
+
/** Stable identifier used in diagnostics and duplicate-name warnings. */
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/**
|
|
23
|
+
* List the skills this source holds.
|
|
24
|
+
*
|
|
25
|
+
* @returns Valid skills and the skills that failed to parse, or
|
|
26
|
+
* `SkillSourceError` when the store could not be read.
|
|
27
|
+
*/
|
|
28
|
+
list(): Promise<SkillResult<SkillListing, SkillSourceError>>;
|
|
29
|
+
/**
|
|
30
|
+
* Read one file bundled with a skill.
|
|
31
|
+
*
|
|
32
|
+
* @param skill - The skill that owns the file.
|
|
33
|
+
* @param path - Path relative to the skill directory.
|
|
34
|
+
*/
|
|
35
|
+
readResource(
|
|
36
|
+
skill: SkillName,
|
|
37
|
+
path: SkillResourcePath
|
|
38
|
+
): Promise<
|
|
39
|
+
SkillResult<SkillResource, SkillResourceNotFoundError | SkillSourceError>
|
|
40
|
+
>;
|
|
41
|
+
}
|
|
42
|
+
/** Everything a source found in one {@link SkillSource.list} call. */
|
|
43
|
+
interface SkillListing {
|
|
44
|
+
/** Skills that parsed, in a stable order. */
|
|
45
|
+
readonly skills: readonly ListedSkill[];
|
|
46
|
+
/** Skills that did not follow the spec and were left out. */
|
|
47
|
+
readonly invalid: readonly InvalidSkill[];
|
|
48
|
+
}
|
|
49
|
+
/** A valid skill and the files bundled with it. */
|
|
50
|
+
interface ListedSkill {
|
|
51
|
+
/** The parsed `SKILL.md`. */
|
|
52
|
+
readonly skill: Skill;
|
|
53
|
+
/** Files in the skill directory other than `SKILL.md`. */
|
|
54
|
+
readonly resources: readonly SkillResourceInfo[];
|
|
55
|
+
/**
|
|
56
|
+
* Absolute directory of the skill in the agent's filesystem, when the
|
|
57
|
+
* source stores skills there. Agents with a shell can run scripts from it.
|
|
58
|
+
*/
|
|
59
|
+
readonly location?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Spec rules the skill breaks but was loaded anyway, for example a name
|
|
62
|
+
* that does not match its directory, as the spec's guide for agents
|
|
63
|
+
* recommends.
|
|
64
|
+
*/
|
|
65
|
+
readonly warnings?: readonly SkillParseError[];
|
|
66
|
+
}
|
|
67
|
+
/** A skill that failed to parse. */
|
|
68
|
+
interface InvalidSkill {
|
|
69
|
+
/** Where the broken skill lives, such as `my-skill/SKILL.md`. */
|
|
70
|
+
readonly location: string;
|
|
71
|
+
/** Which spec rule it broke. */
|
|
72
|
+
readonly error: SkillParseError;
|
|
73
|
+
}
|
|
74
|
+
/** A source's backing store failed. */
|
|
75
|
+
declare class SkillSourceError extends Error {
|
|
76
|
+
readonly sourceId: string;
|
|
77
|
+
readonly operation: "list" | "read-resource";
|
|
78
|
+
/** Stable tag for narrowing. */
|
|
79
|
+
readonly _tag: "SkillSourceError";
|
|
80
|
+
/**
|
|
81
|
+
* @param sourceId - The source that failed.
|
|
82
|
+
* @param operation - What the source was doing.
|
|
83
|
+
* @param cause - The underlying store error.
|
|
84
|
+
*/
|
|
85
|
+
constructor(
|
|
86
|
+
sourceId: string,
|
|
87
|
+
operation: "list" | "read-resource",
|
|
88
|
+
cause: unknown
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
/** A skill has no file at the requested path. */
|
|
92
|
+
declare class SkillResourceNotFoundError extends Error {
|
|
93
|
+
readonly skill: SkillName;
|
|
94
|
+
readonly path: string;
|
|
95
|
+
/** Stable tag for narrowing. */
|
|
96
|
+
readonly _tag: "SkillResourceNotFoundError";
|
|
97
|
+
/**
|
|
98
|
+
* @param skill - The skill that was searched.
|
|
99
|
+
* @param path - The missing path.
|
|
100
|
+
*/
|
|
101
|
+
constructor(skill: SkillName, path: string);
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export {
|
|
105
|
+
SkillSource as a,
|
|
106
|
+
SkillResourceNotFoundError as i,
|
|
107
|
+
ListedSkill as n,
|
|
108
|
+
SkillSourceError as o,
|
|
109
|
+
SkillListing as r,
|
|
110
|
+
InvalidSkill as t
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=source-9RQzlEhM.d.ts.map
|
|
@@ -2,16 +2,15 @@ import { camelCaseToKebabCase, isInternalJsStubProp } from "./utils.js";
|
|
|
2
2
|
import { getAgentByName } from "./agent-routing.js";
|
|
3
3
|
import { AGENT_TOOL_MILESTONE_PART, isAgentToolLifecycleChunk } from "./agent-tool-types.js";
|
|
4
4
|
import { n as getCurrentAgent$1, t as __DO_NOT_USE_WILL_BREAK__agentContext } from "./current-agent-DhoDkSnH.js";
|
|
5
|
-
import "./internal_context.js";
|
|
6
5
|
import { copyCallableMetadata, decoratedMethods, getCallableMetadata, isCallableMethod } from "./callable-decorator.js";
|
|
7
6
|
import "./types.js";
|
|
8
7
|
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-DZBYAB34.js";
|
|
9
8
|
import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-qMjJ6sHQ.js";
|
|
10
9
|
import { signAgentHeaders } from "./email.js";
|
|
11
10
|
import { sendAgentEmail } from "./email-send.js";
|
|
12
|
-
import {
|
|
11
|
+
import { i as writeSpanAttributes, n as tracer, r as withInvocationScope } from "./cloudflare-CUUm_9q9.js";
|
|
13
12
|
import { parseSubAgentPath } from "./sub-routing.js";
|
|
14
|
-
import { a as getConnectionFlag, c as isConnectionReadonly, d as setConnectionProtocolEnabled, f as setConnectionReadonly, i as ensureConnectionWrapped, l as registerInternalConnectionKeys, o as getConnectionRawState, s as isConnectionProtocolEnabled, t as WebSockets, u as setConnectionFlag } from "./websockets-
|
|
13
|
+
import { a as getConnectionFlag, c as isConnectionReadonly, d as setConnectionProtocolEnabled, f as setConnectionReadonly, i as ensureConnectionWrapped, l as registerInternalConnectionKeys, o as getConnectionRawState, s as isConnectionProtocolEnabled, t as WebSockets, u as setConnectionFlag } from "./websockets-C6SJtWCJ.js";
|
|
15
14
|
import { t as LifecycleCapability } from "./capability-DBAKc6UZ.js";
|
|
16
15
|
import { a as abortWithoutAlarmRetry, i as setLifecycleRouteTransport, n as setLifecycleEventSink, r as setLifecycleHostInvoker, t as Lifecycle } from "./lifecycle-v1rKHV2C.js";
|
|
17
16
|
import { isErrorRetryable, tryN, validateRetryOptions } from "./retries.js";
|
|
@@ -19,7 +18,7 @@ import { SqlError } from "./sql-error.js";
|
|
|
19
18
|
import { t as browserCapabilityId } from "./capability-id-B3J8Nok_.js";
|
|
20
19
|
import { a as ensureMcpServerTable, i as normalizeServerId, l as RPC_DO_PREFIX, o as MCPConnectionState, s as DisposableStore, t as MCPClientManager } from "./client-DMWujQJ1.js";
|
|
21
20
|
import { DurableObjectOAuthClientProvider } from "./mcp/client/do-oauth-client-provider.js";
|
|
22
|
-
import { genericObservability } from "./
|
|
21
|
+
import { t as genericObservability } from "./emitter-DPOVcCln.js";
|
|
23
22
|
import { n as setSchedulerCallbackResolver, t as Scheduler } from "./scheduler-FIHv2-kJ.js";
|
|
24
23
|
import { n as setQueueCallbackResolver, t as Queue } from "./queue-CcIjVYTE.js";
|
|
25
24
|
import { n as setTaskDefinitionResolver, r as setTaskRoutedMemoryLimitHandler, t as Tasks } from "./tasks-BN_5AWqI.js";
|
|
@@ -7017,4 +7016,4 @@ var StreamingResponse = class {
|
|
|
7017
7016
|
//#endregion
|
|
7018
7017
|
export { routeAgentEmail as a, getCurrentAgent as i, DEFAULT_AGENT_STATIC_OPTIONS as n, StreamingResponse as r, Agent as t };
|
|
7019
7018
|
|
|
7020
|
-
//# sourceMappingURL=src-
|
|
7019
|
+
//# sourceMappingURL=src-DoGNJ4Ud.js.map
|