agents 0.31.0 → 0.33.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.
Files changed (148) hide show
  1. package/dist/{agent-routing-wS1TimZ_.d.ts → agent-routing-vVMA7m8Y.d.ts} +6 -6
  2. package/dist/agent-routing.d.ts +1 -1
  3. package/dist/agent-tool-types.d.ts +1 -1
  4. package/dist/{agent-tools-Bamxxb6Y.d.ts → agent-tools-gGXXkf1z.d.ts} +2 -2
  5. package/dist/agent-tools.d.ts +1 -1
  6. package/dist/agent-tools.js +0 -1
  7. package/dist/agent-tools.js.map +1 -1
  8. package/dist/{ai-sdk-hW3vntnk.d.ts → ai-sdk-CpuRsjP5.d.ts} +2 -2
  9. package/dist/browser/ai.js +2 -3
  10. package/dist/browser/ai.js.map +1 -1
  11. package/dist/browser/index.d.ts +29 -21
  12. package/dist/browser/index.js +937 -4
  13. package/dist/browser/index.js.map +1 -0
  14. package/dist/browser/tools/ai-sdk.d.ts +5 -5
  15. package/dist/browser/tools/ai-sdk.js +9 -3
  16. package/dist/browser/tools/ai-sdk.js.map +1 -1
  17. package/dist/browser/tools/pi.d.ts +11 -8
  18. package/dist/browser/tools/pi.js +58 -11
  19. package/dist/browser/tools/pi.js.map +1 -1
  20. package/dist/browser/tools/tanstack-ai.d.ts +6 -6
  21. package/dist/browser/tools/tanstack-ai.js +3 -3
  22. package/dist/browser/tools/tanstack-ai.js.map +1 -1
  23. package/dist/{browser-D9RNpJuT.d.ts → browser-CI97khiJ.d.ts} +222 -94
  24. package/dist/{browser-tool-BhjCcNVE.d.ts → browser-tool-Cxtiwfua.d.ts} +2 -2
  25. package/dist/browser-tool-DOqT1oSD.js +360 -0
  26. package/dist/browser-tool-DOqT1oSD.js.map +1 -0
  27. package/dist/catalog-BpOejOsE.js +239 -0
  28. package/dist/catalog-BpOejOsE.js.map +1 -0
  29. package/dist/catalog-BpiVV1OF.d.ts +173 -0
  30. package/dist/chat/index.d.ts +2 -2
  31. package/dist/chat/react.js +1 -0
  32. package/dist/chat/react.js.map +1 -1
  33. package/dist/chat-sdk/index.d.ts +1 -1
  34. package/dist/chat-sdk/index.js +1 -1
  35. package/dist/cli.js +63 -62
  36. package/dist/{client-wn4-yqGz.d.ts → client-eSfgYvd3.d.ts} +2 -2
  37. package/dist/client.d.ts +1 -1
  38. package/dist/{cloudflare-Dzvc7V2N.js → cloudflare-CUUm_9q9.js} +26 -4
  39. package/dist/cloudflare-CUUm_9q9.js.map +1 -0
  40. package/dist/{connector-CM-uuxKM.js → connector-Dl098To-.js} +402 -3
  41. package/dist/connector-Dl098To-.js.map +1 -0
  42. package/dist/{do-oauth-client-provider-DfsUcpc3.d.ts → do-oauth-client-provider-DtNqv7oj.d.ts} +26 -2
  43. package/dist/{index-YSKgfgg9.d.ts → emitter-BJZtCVjQ.d.ts} +6 -140
  44. package/dist/emitter-DPOVcCln.js +15 -0
  45. package/dist/emitter-DPOVcCln.js.map +1 -0
  46. package/dist/experimental/channels/web/index.js +1 -1
  47. package/dist/experimental/webmcp.js +1 -1
  48. package/dist/harness/container/index.js +0 -1
  49. package/dist/harness/container/index.js.map +1 -1
  50. package/dist/harness/container/runtime/index.js +2 -2
  51. package/dist/harness/opencode/index.js +0 -1
  52. package/dist/harness/opencode/index.js.map +1 -1
  53. package/dist/harness/pi/index.d.ts +84 -30
  54. package/dist/harness/pi/index.js +120 -224
  55. package/dist/harness/pi/index.js.map +1 -1
  56. package/dist/index.d.ts +2 -3
  57. package/dist/index.js +2 -2
  58. package/dist/{input-schema-BQykTEp_.js → input-schema-0uUu392-.js} +2 -2
  59. package/dist/input-schema-0uUu392-.js.map +1 -0
  60. package/dist/{input-schema-B0Etuo-o.js → input-schema-waggtYrH.js} +2 -2
  61. package/dist/input-schema-waggtYrH.js.map +1 -0
  62. package/dist/markdown-BZ-VLtA1.js +86 -0
  63. package/dist/markdown-BZ-VLtA1.js.map +1 -0
  64. package/dist/mcp/client/do-oauth-client-provider.d.ts +4 -2
  65. package/dist/mcp/client/do-oauth-client-provider.js +15 -1
  66. package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
  67. package/dist/mcp/client/index.d.ts +1 -1
  68. package/dist/mcp/client/x402.d.ts +8 -8
  69. package/dist/mcp/index.d.ts +2 -2
  70. package/dist/mcp/index.js +4 -4
  71. package/dist/mcp/index.js.map +1 -1
  72. package/dist/models/pi-ai/index.js +12 -15
  73. package/dist/models/pi-ai/index.js.map +1 -1
  74. package/dist/observability/ai/index.js +1 -2
  75. package/dist/observability/ai/index.js.map +1 -1
  76. package/dist/observability/index.d.ts +170 -9
  77. package/dist/observability/index.js +386 -11
  78. package/dist/observability/index.js.map +1 -1
  79. package/dist/react.d.ts +2 -2
  80. package/dist/resource-B59OV2a2.js +325 -0
  81. package/dist/resource-B59OV2a2.js.map +1 -0
  82. package/dist/routing/index.d.ts +1 -1
  83. package/dist/script-CFDLTk5b.d.ts +91 -0
  84. package/dist/script-workspace-BpdAYq1R.d.ts +41 -0
  85. package/dist/serializable.d.ts +1 -1
  86. package/dist/{session-7CDgVE0z.js → session-CRY0bGiI.js} +423 -411
  87. package/dist/session-CRY0bGiI.js.map +1 -0
  88. package/dist/skill-DRBcIBjC.d.ts +221 -0
  89. package/dist/skills/index.d.ts +275 -36
  90. package/dist/skills/index.js +265 -1534
  91. package/dist/skills/index.js.map +1 -1
  92. package/dist/skills/runner.d.ts +37 -0
  93. package/dist/skills/runner.js +912 -0
  94. package/dist/skills/runner.js.map +1 -0
  95. package/dist/skills/tools/ai-sdk.d.ts +36 -0
  96. package/dist/skills/tools/ai-sdk.js +94 -0
  97. package/dist/skills/tools/ai-sdk.js.map +1 -0
  98. package/dist/source-9RQzlEhM.d.ts +112 -0
  99. package/dist/{src-BGolXG_H.js → src-DoGNJ4Ud.js} +4 -5
  100. package/dist/src-DoGNJ4Ud.js.map +1 -0
  101. package/dist/sub-routing.d.ts +1 -1
  102. package/dist/tool-CxKsvxjm.js.map +1 -1
  103. package/dist/tool-DkT_DJBm.js.map +1 -1
  104. package/dist/{tool-helpers-BodWi4gd.js → tool-helpers-F3_Wy2YX.js} +2 -3
  105. package/dist/{tool-helpers-BodWi4gd.js.map → tool-helpers-F3_Wy2YX.js.map} +1 -1
  106. package/dist/vite.d.ts +2 -2
  107. package/dist/vite.js +10 -258
  108. package/dist/vite.js.map +1 -1
  109. package/dist/voice/index.d.ts +1 -1
  110. package/dist/web/fetch/tools/ai-sdk.js +1 -1
  111. package/dist/web/fetch/tools/pi.d.ts +4 -7
  112. package/dist/web/fetch/tools/pi.js +7 -6
  113. package/dist/web/fetch/tools/pi.js.map +1 -1
  114. package/dist/web/fetch/tools/tanstack-ai.js +1 -1
  115. package/dist/web/search/tools/ai-sdk.js +1 -1
  116. package/dist/web/search/tools/pi.d.ts +5 -4
  117. package/dist/web/search/tools/pi.js +5 -10
  118. package/dist/web/search/tools/pi.js.map +1 -1
  119. package/dist/web/search/tools/tanstack-ai.js +1 -1
  120. package/dist/websockets/index.js +1 -1
  121. package/dist/{websockets-CyoeosdO.js → websockets-C6SJtWCJ.js} +1 -2
  122. package/dist/{websockets-CyoeosdO.js.map → websockets-C6SJtWCJ.js.map} +1 -1
  123. package/dist/workflow-types.d.ts +1 -1
  124. package/dist/workflows.d.ts +1 -1
  125. package/dist/workflows.js +0 -1
  126. package/dist/workflows.js.map +1 -1
  127. package/docs/browse-the-web.md +36 -3
  128. package/docs/harnesses/pi.md +59 -33
  129. package/docs/mcp-client.md +23 -1
  130. package/docs/mcp-servers.md +2 -2
  131. package/docs/models-pi-ai.md +1 -1
  132. package/docs/observability.md +5 -3
  133. package/package.json +37 -22
  134. package/dist/browser-1eUbPvC2.js +0 -931
  135. package/dist/browser-1eUbPvC2.js.map +0 -1
  136. package/dist/browser-tool-lGnvEBLJ.js +0 -497
  137. package/dist/browser-tool-lGnvEBLJ.js.map +0 -1
  138. package/dist/cloudflare-Dzvc7V2N.js.map +0 -1
  139. package/dist/connector-CM-uuxKM.js.map +0 -1
  140. package/dist/index-iv9FTXX9.d.ts +0 -311
  141. package/dist/input-schema-B0Etuo-o.js.map +0 -1
  142. package/dist/input-schema-BQykTEp_.js.map +0 -1
  143. package/dist/session-7CDgVE0z.js.map +0 -1
  144. package/dist/skills/compile.d.ts +0 -40
  145. package/dist/skills/compile.js +0 -65
  146. package/dist/skills/compile.js.map +0 -1
  147. package/dist/src-BGolXG_H.js.map +0 -1
  148. package/skills-module.d.ts +0 -22
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":["parseYaml"],"sources":["../src/vite.ts"],"sourcesContent":["import babel from \"@rolldown/plugin-babel\";\nimport { createHash } from \"node:crypto\";\nimport { readdir, readFile, stat } from \"node:fs/promises\";\nimport { basename, join, resolve } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport type { Plugin } from \"vite\";\nimport { compileSkillScript, isCompilableSkillScript } from \"./skills/compile\";\n\nconst SKILLS_SPECIFIER = \"agents:skills\";\nconst SKILLS_VIRTUAL_PREFIX = \"\\0agents:skills:\";\nconst SKILL_RESOURCE_ROOTS = new Set([\n \"references\",\n \"scripts\",\n \"assets\",\n \"graphics\",\n \"fonts\",\n \"templates\",\n \"rendered-files\",\n \"illustrations\"\n]);\nconst SKILL_IGNORED_ROOTS = new Set([\n \".git\",\n \".hg\",\n \".svn\",\n \".DS_Store\",\n \".idea\",\n \".vscode\",\n \"dist\",\n \"build\",\n \"coverage\",\n \"node_modules\"\n]);\nconst SPEC_RESOURCE_ROOTS = new Set([\"references\", \"scripts\", \"assets\"]);\n\n// Bundled skill resources are base64-embedded into the Worker bundle, which\n// inflates them by ~1.33x and competes with app code for the bundle-size\n// budget. These heuristic thresholds (raw bytes) trigger a recommendation to\n// move large assets to an R2-backed skill source instead.\nconst SKILL_ASSET_WARN_BYTES = 256 * 1024;\nconst SKILL_BUNDLE_WARN_BYTES = 1024 * 1024;\n\nfunction formatBytes(bytes: number): string {\n if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n if (bytes >= 1024) return `${(bytes / 1024).toFixed(0)}KB`;\n return `${bytes}B`;\n}\n\ninterface SkillFile {\n name: string;\n description: string;\n body: string;\n rawContent: string;\n compatibility?: string;\n license?: string;\n allowedTools?: string;\n metadata?: Record<string, unknown>;\n resources: Array<{\n path: string;\n kind: \"reference\" | \"script\" | \"asset\" | \"file\";\n size: number;\n encoding: \"text\" | \"base64\";\n mimeType?: string;\n content: string;\n precompiled?: boolean;\n }>;\n}\n\nfunction parseFrontmatter(raw: string): {\n data: Record<string, unknown>;\n body: string;\n} {\n const match = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) return { data: {}, body: raw };\n const parsed = parseYaml(match[1] ?? \"\");\n const data =\n parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : {};\n return { data, body: match[2] ?? \"\" };\n}\n\nfunction stringField(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction recordField(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction resourceKind(path: string): \"reference\" | \"script\" | \"asset\" | \"file\" {\n if (path.startsWith(\"references/\")) return \"reference\";\n if (path.startsWith(\"scripts/\")) return \"script\";\n if (\n path.startsWith(\"assets/\") ||\n path.startsWith(\"graphics/\") ||\n path.startsWith(\"fonts/\") ||\n path.startsWith(\"templates/\") ||\n path.startsWith(\"rendered-files/\") ||\n path.startsWith(\"illustrations/\")\n ) {\n return \"asset\";\n }\n return \"file\";\n}\n\nconst TEXT_EXTENSIONS = new Set([\n \".bash\",\n \".css\",\n \".csv\",\n \".html\",\n \".js\",\n \".json\",\n \".jsx\",\n \".md\",\n \".mjs\",\n \".py\",\n \".sh\",\n \".svg\",\n \".ts\",\n \".tsx\",\n \".txt\",\n \".xml\",\n \".yaml\",\n \".yml\"\n]);\n\nconst MIME_TYPES = new Map([\n [\".css\", \"text/css\"],\n [\".gif\", \"image/gif\"],\n [\".html\", \"text/html\"],\n [\".jpg\", \"image/jpeg\"],\n [\".jpeg\", \"image/jpeg\"],\n [\".js\", \"text/javascript\"],\n [\".json\", \"application/json\"],\n [\".md\", \"text/markdown\"],\n [\".mjs\", \"text/javascript\"],\n [\".pdf\", \"application/pdf\"],\n [\".png\", \"image/png\"],\n [\".py\", \"text/x-python\"],\n [\".sh\", \"text/x-shellscript\"],\n [\".svg\", \"image/svg+xml\"],\n [\".ts\", \"text/typescript\"],\n [\".tsx\", \"text/typescript\"],\n [\".txt\", \"text/plain\"],\n [\".webp\", \"image/webp\"],\n [\".woff\", \"font/woff\"],\n [\".woff2\", \"font/woff2\"],\n [\".xml\", \"application/xml\"],\n [\".yaml\", \"application/yaml\"],\n [\".yml\", \"application/yaml\"]\n]);\n\nfunction extensionOf(path: string): string {\n const file = path.split(\"/\").at(-1) ?? path;\n const index = file.lastIndexOf(\".\");\n return index === -1 ? \"\" : file.slice(index).toLowerCase();\n}\n\nfunction resourceEncoding(path: string): \"text\" | \"base64\" {\n return TEXT_EXTENSIONS.has(extensionOf(path)) ? \"text\" : \"base64\";\n}\n\nfunction resourceMimeType(path: string): string | undefined {\n return MIME_TYPES.get(extensionOf(path));\n}\n\nasync function collectFiles(\n root: string,\n relativeRoot = \"\",\n warn?: (message: string) => void\n): Promise<Array<{ path: string; absolutePath: string; size: number }>> {\n const entries = await readdir(join(root, relativeRoot), {\n withFileTypes: true\n }).catch(() => []);\n const files: Array<{ path: string; absolutePath: string; size: number }> = [];\n\n for (const entry of entries) {\n if (SKILL_IGNORED_ROOTS.has(entry.name)) continue;\n const relativePath = relativeRoot\n ? `${relativeRoot}/${entry.name}`\n : entry.name;\n const absolutePath = join(root, relativePath);\n if (entry.isDirectory()) {\n const resourceRoot = relativePath.split(\"/\")[0];\n if (!resourceRoot || SKILL_IGNORED_ROOTS.has(resourceRoot)) continue;\n if (!SKILL_RESOURCE_ROOTS.has(resourceRoot)) {\n if (!relativeRoot) {\n warn?.(\n `Ignoring skill directory \"${relativePath}\". Bundled skill resources should live under references/, scripts/, assets/, or a known asset root.`\n );\n }\n continue;\n }\n if (!SPEC_RESOURCE_ROOTS.has(resourceRoot) && !relativeRoot) {\n warn?.(\n `Bundling non-standard skill resource root \"${resourceRoot}/\". Prefer assets/ for portable Agent Skills when possible.`\n );\n }\n files.push(...(await collectFiles(root, relativePath, warn)));\n } else if (entry.isFile() && relativePath !== \"SKILL.md\") {\n const resourceRoot = relativePath.split(\"/\")[0];\n if (!resourceRoot || SKILL_IGNORED_ROOTS.has(resourceRoot)) continue;\n if (!SKILL_RESOURCE_ROOTS.has(resourceRoot)) {\n warn?.(\n `Ignoring skill file \"${relativePath}\". Bundled skill resources should live under references/, scripts/, assets/, or a known asset root.`\n );\n continue;\n }\n const info = await stat(absolutePath);\n files.push({ path: relativePath, absolutePath, size: info.size });\n }\n }\n\n return files.sort((a, b) => a.path.localeCompare(b.path));\n}\n\nasync function collectWatchTargets(\n root: string,\n relativeRoot = \"\"\n): Promise<string[]> {\n const directory = join(root, relativeRoot);\n const entries = await readdir(directory, { withFileTypes: true }).catch(\n () => []\n );\n const targets = [directory];\n\n for (const entry of entries) {\n if (SKILL_IGNORED_ROOTS.has(entry.name)) continue;\n const relativePath = relativeRoot\n ? `${relativeRoot}/${entry.name}`\n : entry.name;\n const resourceRoot = relativePath.split(\"/\")[0];\n if (!resourceRoot || SKILL_IGNORED_ROOTS.has(resourceRoot)) continue;\n\n const absolutePath = join(root, relativePath);\n targets.push(absolutePath);\n\n if (entry.isDirectory()) {\n targets.push(...(await collectWatchTargets(root, relativePath)));\n }\n }\n\n return targets;\n}\n\nasync function readSkill(\n skillDir: string,\n warn?: (message: string) => void\n): Promise<SkillFile | null> {\n const skillPath = join(skillDir, \"SKILL.md\");\n const rawContent = await readFile(skillPath, \"utf8\").catch(() => null);\n if (rawContent === null) return null;\n\n const { data, body } = parseFrontmatter(rawContent);\n const name = stringField(data.name);\n const description = stringField(data.description);\n if (!name || !description) return null;\n\n const resources = await Promise.all(\n (await collectFiles(skillDir, \"\", warn)).map(async (file) => {\n const encoding = resourceEncoding(file.path);\n const bytes = await readFile(file.absolutePath);\n const kind = resourceKind(file.path);\n let content =\n encoding === \"base64\" ? bytes.toString(\"base64\") : bytes.toString();\n let precompiled = false;\n\n // Compile text script resources to self-contained JS at build time so the\n // runtime never needs an in-Worker bundler to run them.\n let size = file.size;\n if (\n kind === \"script\" &&\n encoding === \"text\" &&\n isCompilableSkillScript(file.path)\n ) {\n try {\n content = (await compileSkillScript(file.absolutePath)).content;\n precompiled = true;\n // The compiled bundle (which may inline sibling files and bundled\n // dependencies) is what actually ships, so report its size for the\n // bundle-size warnings rather than the raw source size.\n size = Buffer.byteLength(content);\n } catch (error) {\n warn?.(\n `Failed to compile skill script \"${file.path}\": ${\n error instanceof Error ? error.message : String(error)\n }. Skill scripts must be self-contained, compilable modules to run at runtime.`\n );\n }\n }\n\n return {\n path: file.path,\n kind,\n size,\n encoding,\n mimeType: resourceMimeType(file.path),\n content,\n precompiled\n };\n })\n );\n\n return {\n name,\n description,\n body,\n rawContent,\n compatibility: stringField(data.compatibility),\n license: stringField(data.license),\n allowedTools: stringField(data[\"allowed-tools\"]),\n metadata: recordField(data.metadata),\n resources\n };\n}\n\nasync function buildSkillsModule(\n dir: string,\n warn?: (message: string) => void\n): Promise<string> {\n const entries = await readdir(dir, { withFileTypes: true });\n const skills: SkillFile[] = [];\n const seen = new Set<string>();\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const skill = await readSkill(join(dir, entry.name), warn);\n if (!skill) continue;\n if (seen.has(skill.name)) {\n warn?.(\n `Duplicate bundled skill name \"${skill.name}\" in \"${entry.name}/\"; keeping the first occurrence and ignoring this one.`\n );\n continue;\n }\n seen.add(skill.name);\n skills.push(skill);\n }\n\n skills.sort((a, b) => a.name.localeCompare(b.name));\n\n let totalBytes = 0;\n for (const skill of skills) {\n for (const resource of skill.resources) {\n totalBytes += resource.size;\n if (resource.size > SKILL_ASSET_WARN_BYTES) {\n warn?.(\n `Bundled skill resource \"${skill.name}/${resource.path}\" is ${formatBytes(resource.size)}; large assets bloat the Worker bundle (base64, ~1.33x). Prefer an R2-backed source via skills.r2().`\n );\n }\n }\n }\n if (totalBytes > SKILL_BUNDLE_WARN_BYTES) {\n warn?.(\n `Bundled skills total ${formatBytes(totalBytes)} of embedded resources; this competes with the Worker bundle-size budget. Consider serving large skills from R2 via skills.r2().`\n );\n }\n\n const hash = createHash(\"sha256\");\n hash.update(JSON.stringify(skills));\n\n const manifest = {\n id: `bundle:${basename(dir)}`,\n fingerprint: hash.digest(\"hex\"),\n skills\n };\n\n return `const manifest = ${JSON.stringify(manifest)};\\nexport default {\\n id: manifest.id,\\n fingerprint: manifest.fingerprint,\\n async list() {\\n return manifest.skills.map(({ body, rawContent, resources, ...skill }) => skill);\\n },\\n async load(name) {\\n const skill = manifest.skills.find((entry) => entry.name === name);\\n if (!skill) return null;\\n return {\\n ...skill,\\n resources: skill.resources.map(({ content, ...resource }) => resource)\\n };\\n },\\n async readResource(name, path) {\\n const skill = manifest.skills.find((entry) => entry.name === name);\\n const resource = skill?.resources.find((entry) => entry.path === path);\\n return resource ? { ...resource } : null;\\n }\\n};\\n`;\n}\n\nconst TURNDOWN_STUB_ID = \"\\0agents:turndown-stub\";\nconst TURNDOWN_STUB_MESSAGE =\n \"The Agents Vite plugin stubbed the 'turndown' package to keep Workers \" +\n \"bundles compatible with just-bash. If your app uses turndown directly, \" +\n \"configure the plugin with agents({ stubTurndown: false }).\";\n\n// `just-bash` (pulled in by the workspace bash tool / skill runner) statically\n// depends on `turndown`, whose ESM build runs a top-level `require()` on its\n// Node DOM fallback. Workers is ESM with no global `require`, so the module\n// throws at startup — even when the bash tool is never used. turndown is only\n// needed by just-bash's niche `html-to-markdown` command, so we replace it with\n// a diagnostic stub by default to keep Workers deploys clean. Opt out with\n// `agents({ stubTurndown: false })` if you rely on turndown elsewhere.\nfunction turndownStubPlugin(): Plugin {\n return {\n name: \"agents-turndown-stub\",\n enforce: \"pre\",\n resolveId(source) {\n if (source === \"turndown\") return TURNDOWN_STUB_ID;\n return null;\n },\n load(id) {\n if (id !== TURNDOWN_STUB_ID) return null;\n return `const message = ${JSON.stringify(TURNDOWN_STUB_MESSAGE)};\nclass TurndownService {\n constructor() {}\n use() { return this; }\n addRule() { return this; }\n keep() { return this; }\n remove() { return this; }\n turndown() { throw new Error(message); }\n}\nexport default TurndownService;\n`;\n }\n };\n}\n\nfunction skillsImportPlugin(): Plugin {\n return {\n name: \"agents-skills-import\",\n async resolveId(source, importer) {\n // `agents:skills` resolves to a `./skills` directory next to the\n // importer; `agents:skills/<dir>` points at a sibling directory.\n if (\n source !== SKILLS_SPECIFIER &&\n !source.startsWith(`${SKILLS_SPECIFIER}/`)\n ) {\n return null;\n }\n if (!importer) return null;\n const relative =\n source === SKILLS_SPECIFIER\n ? \"skills\"\n : source.slice(SKILLS_SPECIFIER.length + 1);\n const resolved = resolve(importer, \"..\", relative);\n return `${SKILLS_VIRTUAL_PREFIX}${resolved}`;\n },\n async load(id) {\n if (!id.startsWith(SKILLS_VIRTUAL_PREFIX)) return null;\n const dir = id.slice(SKILLS_VIRTUAL_PREFIX.length);\n for (const target of await collectWatchTargets(dir)) {\n this.addWatchFile(target);\n }\n return buildSkillsModule(dir, (message) => this.warn(message));\n }\n };\n}\n\nexport interface AgentsPluginOptions {\n /**\n * Replace `turndown` with a diagnostic stub so `just-bash` (workspace bash\n * tool / skill runner) doesn't drag turndown's `require()`-using DOM fallback\n * into the Worker's module-init path and break deploys. Enabled by default.\n * Set to `false` if your app uses turndown directly and needs the real\n * implementation.\n */\n stubTurndown?: boolean;\n}\n\n/**\n * Vite plugin for Agents SDK projects.\n *\n * Handles TC39 decorator transforms (Oxc doesn't support them yet, oxc#9170) so\n * `@callable()` works at runtime, the `agents:skills` import transform, and\n * stubbing `turndown` to keep Workers deploys clean. Will grow to cover other\n * Agents-specific build concerns as needed.\n */\nexport default function agents(options: AgentsPluginOptions = {}): Plugin[] {\n const { stubTurndown = true } = options;\n return [\n ...(stubTurndown ? [turndownStubPlugin()] : []),\n skillsImportPlugin(),\n babel({\n presets: [\n {\n preset: () => ({\n plugins: [\n [\"@babel/plugin-proposal-decorators\", { version: \"2023-11\" }]\n ]\n }),\n rolldown: { filter: { code: \"@\" } }\n }\n ]\n }) as unknown as Plugin\n ];\n}\n"],"mappings":";;;;;;;AAQA,MAAM,mBAAmB;AACzB,MAAM,wBAAwB;AAC9B,MAAM,uCAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,sCAAsB,IAAI,IAAI;CAAC;CAAc;CAAW;AAAQ,CAAC;AAMvE,MAAM,yBAAyB,MAAM;AACrC,MAAM,0BAA0B,OAAO;AAEvC,SAAS,YAAY,OAAuB;CAC1C,IAAI,SAAS,OAAO,MAAM,OAAO,IAAI,SAAS,OAAO,MAAA,CAAO,QAAQ,CAAC,EAAE;CACvE,IAAI,SAAS,MAAM,OAAO,IAAI,QAAQ,KAAA,CAAM,QAAQ,CAAC,EAAE;CACvD,OAAO,GAAG,MAAM;AAClB;AAsBA,SAAS,iBAAiB,KAGxB;CACA,MAAM,QAAQ,IAAI,MAAM,6CAA6C;CACrE,IAAI,CAAC,OAAO,OAAO;EAAE,MAAM,CAAC;EAAG,MAAM;CAAI;CACzC,MAAM,SAASA,MAAU,MAAM,MAAM,EAAE;CAKvC,OAAO;EAAE,MAHP,WAAW,QAAQ,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,IACjE,SACD,CAAC;EACQ,MAAM,MAAM,MAAM;CAAG;AACtC;AAEA,SAAS,YAAY,OAAoC;CACvD,OA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EAC3C;EACA,MAAM,KAAK,IAAI;GACb,IAAI,CAAC,GAAG,WAAW,qBAAqB,GAAG,OAAO;GAClD,MAAM,MAAM,GAAG,MAAM,EAA4B;GACjD,KAAK,MAAM,UAAU,MAAM,oBAAoB,GAAG,GAChD,KAAK,aAAa,MAAM;GAE1B,OAAO,kBAAkB,MAAM,YAAY,KAAK,KAAK,OAAO,CAAC;EAC/D;CACF;AACF;;;;;;;;;AAqBA,SAAwB,OAAO,UAA+B,CAAC,GAAa;CAC1E,MAAM,EAAE,eAAe,SAAS;CAChC,OAAO;EACL,GAAI,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC;EAC7C,mBAAmB;EACnB,MAAM,EACJ,SAAS,CACP;GACE,eAAe,EACb,SAAS,CACP,CAAC,qCAAqC,EAAE,SAAS,UAAU,CAAC,CAC9D,EACF;GACA,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE;EACpC,CACF,EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import babel from \"@rolldown/plugin-babel\";\nimport type { Plugin } from \"vite\";\n\nconst TURNDOWN_STUB_ID = \"\\0agents:turndown-stub\";\nconst TURNDOWN_STUB_MESSAGE =\n \"The Agents Vite plugin stubbed the 'turndown' package to keep Workers \" +\n \"bundles compatible with just-bash. If your app uses turndown directly, \" +\n \"configure the plugin with agents({ stubTurndown: false }).\";\n\n// `just-bash` (pulled in by the workspace bash tool / skill runner) statically\n// depends on `turndown`, whose ESM build runs a top-level `require()` on its\n// Node DOM fallback. Workers is ESM with no global `require`, so the module\n// throws at startup — even when the bash tool is never used. turndown is only\n// needed by just-bash's niche `html-to-markdown` command, so we replace it with\n// a diagnostic stub by default to keep Workers deploys clean. Opt out with\n// `agents({ stubTurndown: false })` if you rely on turndown elsewhere.\nfunction turndownStubPlugin(): Plugin {\n return {\n name: \"agents-turndown-stub\",\n enforce: \"pre\",\n resolveId(source) {\n if (source === \"turndown\") return TURNDOWN_STUB_ID;\n return null;\n },\n load(id) {\n if (id !== TURNDOWN_STUB_ID) return null;\n return `const message = ${JSON.stringify(TURNDOWN_STUB_MESSAGE)};\nclass TurndownService {\n constructor() {}\n use() { return this; }\n addRule() { return this; }\n keep() { return this; }\n remove() { return this; }\n turndown() { throw new Error(message); }\n}\nexport default TurndownService;\n`;\n }\n };\n}\n\nconst REMOVED_SKILLS_IMPORT_MESSAGE =\n 'The \"agents:skills\" import has been removed. Skills are now files: store them in a Computer Workspace ' +\n \"and return skills.workspace(this.workspace) from getSkills(), or load them with skills.r2(bucket) or \" +\n \"skills.manifest({ id, skills }). See https://developers.cloudflare.com/agents/skills/\";\n\n// `agents:skills` used to bundle a skills directory at build time. Fail with\n// a migration message instead of Vite's generic \"failed to resolve import\".\nfunction removedSkillsImportPlugin(): Plugin {\n return {\n name: \"agents-removed-skills-import\",\n enforce: \"pre\",\n resolveId(source) {\n if (source === \"agents:skills\" || source.startsWith(\"agents:skills/\")) {\n this.error(REMOVED_SKILLS_IMPORT_MESSAGE);\n }\n return null;\n }\n };\n}\n\nexport interface AgentsPluginOptions {\n /**\n * Replace `turndown` with a diagnostic stub so `just-bash` (workspace bash\n * tool / skill runner) doesn't drag turndown's `require()`-using DOM fallback\n * into the Worker's module-init path and break deploys. Enabled by default.\n * Set to `false` if your app uses turndown directly and needs the real\n * implementation.\n */\n stubTurndown?: boolean;\n}\n\n/**\n * Vite plugin for Agents SDK projects.\n *\n * Handles TC39 decorator transforms (Oxc doesn't support them yet, oxc#9170) so\n * `@callable()` works at runtime, and stubs `turndown` to keep Workers\n * deploys clean. Will grow to cover other\n * Agents-specific build concerns as needed.\n */\nexport default function agents(options: AgentsPluginOptions = {}): Plugin[] {\n const { stubTurndown = true } = options;\n return [\n ...(stubTurndown ? [turndownStubPlugin()] : []),\n removedSkillsImportPlugin(),\n babel({\n presets: [\n {\n preset: () => ({\n plugins: [\n [\"@babel/plugin-proposal-decorators\", { version: \"2023-11\" }]\n ]\n }),\n rolldown: { filter: { code: \"@\" } }\n }\n ]\n }) as unknown as Plugin\n ];\n}\n"],"mappings":";;AAGA,MAAM,mBAAmB;AACzB,MAAM,wBACJ;AAWF,SAAS,qBAA6B;CACpC,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,QAAQ;GAChB,IAAI,WAAW,YAAY,OAAO;GAClC,OAAO;EACT;EACA,KAAK,IAAI;GACP,IAAI,OAAO,kBAAkB,OAAO;GACpC,OAAO,mBAAmB,KAAK,UAAU,qBAAqB,EAAE;;;;;;;;;;;EAWlE;CACF;AACF;AAEA,MAAM,gCACJ;AAMF,SAAS,4BAAoC;CAC3C,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,QAAQ;GAChB,IAAI,WAAW,mBAAmB,OAAO,WAAW,gBAAgB,GAClE,KAAK,MAAM,6BAA6B;GAE1C,OAAO;EACT;CACF;AACF;;;;;;;;;AAqBA,SAAwB,OAAO,UAA+B,CAAC,GAAa;CAC1E,MAAM,EAAE,eAAe,SAAS;CAChC,OAAO;EACL,GAAI,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC;EAC7C,0BAA0B;EAC1B,MAAM,EACJ,SAAS,CACP;GACE,eAAe,EACb,SAAS,CACP,CAAC,qCAAqC,EAAE,SAAS,UAAU,CAAC,CAC9D,EACF;GACA,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE;EACpC,CACF,EACF,CAAC;CACH;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { x as Connection } from "../capability-runner-BiVUtjqC.js";
2
- import { c as Agent } from "../agent-routing-wS1TimZ_.js";
2
+ import { c as Agent } from "../agent-routing-vVMA7m8Y.js";
3
3
  import {
4
4
  C as VoiceTransport,
5
5
  D as VoiceTurnSource,
@@ -1,5 +1,5 @@
1
1
  import { a as WebFetchError, r as toolFailure, t as createWebFetchToolCore } from "../../../tool-CxKsvxjm.js";
2
- import { t as webFetchInputSchema } from "../../../input-schema-BQykTEp_.js";
2
+ import { t as webFetchInputSchema } from "../../../input-schema-0uUu392-.js";
3
3
  //#region src/web/fetch/tools/ai-sdk.ts
4
4
  /**
5
5
  * Create an AI SDK tool that reads a URL as Markdown, JSON, or text. The
@@ -10,17 +10,14 @@ import {
10
10
  x as WebFetchToolOutput,
11
11
  y as WebFetchPage
12
12
  } from "../../../tool-DoVberpN.js";
13
- import { Type } from "@earendil-works/pi-ai";
14
13
  import { ToolRegistration } from "@earendil-works/pi-durable";
15
14
 
16
15
  //#region src/web/fetch/tools/pi.d.ts
17
16
  /** The model's input schema. pi already coerces `"20000"` to `20000`. */
18
- declare function webFetchParameters(): Type.TObject<{
19
- url: Type.TString;
20
- offset: Type.TOptional<Type.TInteger>;
21
- format: Type.TOptional<
22
- Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"raw">]>
23
- >;
17
+ declare function webFetchParameters(): import("@earendil-works/pi-schema").Schema<{
18
+ url: string;
19
+ offset?: number | undefined;
20
+ format?: "auto" | "raw" | undefined;
24
21
  }>;
25
22
  type WebFetchParameters = ReturnType<typeof webFetchParameters>;
26
23
  /**
@@ -1,5 +1,6 @@
1
1
  import { a as WebFetchError, d as MAX_WEB_FETCH_URL_LENGTH, t as createWebFetchToolCore } from "../../../tool-CxKsvxjm.js";
2
- import { Type } from "@earendil-works/pi-ai";
2
+ import { int, obj, opt, str } from "@earendil-works/pi-schema";
3
+ import { StringEnum } from "@earendil-works/pi-ai";
3
4
  //#region src/web/fetch/tools/pi.ts
4
5
  /**
5
6
  * `agents/webfetch/pi` — the `web_fetch` tool for the pi harness.
@@ -8,18 +9,18 @@ import { Type } from "@earendil-works/pi-ai";
8
9
  */
9
10
  /** The model's input schema. pi already coerces `"20000"` to `20000`. */
10
11
  function webFetchParameters() {
11
- return Type.Object({
12
- url: Type.String({
12
+ return obj({
13
+ url: str({
13
14
  minLength: 1,
14
15
  maxLength: MAX_WEB_FETCH_URL_LENGTH,
15
16
  description: "The http(s) URL to read."
16
17
  }),
17
- offset: Type.Optional(Type.Integer({
18
+ offset: opt(int({
18
19
  minimum: 0,
19
20
  description: "Character offset into the content, to continue a long page from the previous result's offset. Default 0."
20
21
  })),
21
- format: Type.Optional(Type.Union([Type.Literal("auto"), Type.Literal("raw")], { description: "\"auto\" (default) converts to the most readable form; \"raw\" returns the body as served." }))
22
- });
22
+ format: opt(StringEnum(["auto", "raw"], { description: "\"auto\" (default) converts to the most readable form; \"raw\" returns the body as served." }))
23
+ }, { open: true });
23
24
  }
24
25
  /**
25
26
  * Create a pi tool that reads a URL as Markdown, JSON, or text. Install it
@@ -1 +1 @@
1
- {"version":3,"file":"pi.js","names":[],"sources":["../../../../src/web/fetch/tools/pi.ts"],"sourcesContent":["/**\n * `agents/webfetch/pi` — the `web_fetch` tool for the pi harness.\n *\n * @beta\n */\nimport { Type } from \"@earendil-works/pi-ai\";\nimport type { ToolRegistration } from \"@earendil-works/pi-durable\";\nimport { MAX_WEB_FETCH_URL_LENGTH, type WebFetchToolOutput } from \"../contract\";\nimport type { WebFetchErrorCode } from \"../source\";\nimport { createWebFetchToolCore, type WebFetchToolOptions } from \"../tool\";\n\nexport type {\n WebFetchFormat,\n WebFetchPage,\n WebFetchToolInput,\n WebFetchToolOutput,\n WebFetchVia\n} from \"../contract\";\nexport {\n WebFetchError,\n type WebFetchErrorCode,\n type WebFetchRequest,\n type WebFetchSource\n} from \"../source\";\nexport type { WebFetchToolOptions } from \"../tool\";\n\n/** The model's input schema. pi already coerces `\"20000\"` to `20000`. */\nfunction webFetchParameters() {\n return Type.Object({\n url: Type.String({\n minLength: 1,\n maxLength: MAX_WEB_FETCH_URL_LENGTH,\n description: \"The http(s) URL to read.\"\n }),\n offset: Type.Optional(\n Type.Integer({\n minimum: 0,\n description:\n \"Character offset into the content, to continue a long page from the previous result's offset. Default 0.\"\n })\n ),\n format: Type.Optional(\n Type.Union([Type.Literal(\"auto\"), Type.Literal(\"raw\")], {\n description:\n '\"auto\" (default) converts to the most readable form; \"raw\" returns the body as served.'\n })\n )\n });\n}\n\ntype WebFetchParameters = ReturnType<typeof webFetchParameters>;\n\n/**\n * Host-side details pi stores with each `web_fetch` result: the output (the\n * window the model read, with the page's metadata) or the failure.\n */\nexport type WebFetchToolDetails =\n | { ok: true; output: WebFetchToolOutput }\n | {\n ok: false;\n /** The source's error message, with the detail for the host. */\n message: string;\n status: number;\n code: WebFetchErrorCode;\n retryable: boolean;\n url?: string;\n /** The response's media type, when a response was read. */\n contentType?: string;\n };\n\n/**\n * Create a pi tool that reads a URL as Markdown, JSON, or text. Install it\n * on a registry like any other pi tool.\n *\n * The model chooses the URL, the window (`offset`), and the format; the\n * host chooses the URL policy, size limits, and window size. The tool is\n * `replay: \"safe\"`: a fetch interrupted mid-call (say, by an eviction) runs\n * again when the session recovers. Completed results are stored and not\n * fetched again.\n *\n * @example\n * ```ts\n * import { createRegistry, Harness } from \"@earendil-works/pi-durable\";\n * import { webFetchTool } from \"agents/webfetch/pi\";\n *\n * // In PiHarness's factory, so each object gets its own registry.\n * harness: ({ storage, context, onWake }) => {\n * const registry = createRegistry();\n * registry.install({\n * name: \"tools\",\n * tools: [webFetchTool({ binding: this.env.AI })]\n * });\n * return Harness.open(storage, { models, registry, onWake }, context);\n * }\n * ```\n */\nexport function webFetchTool(\n options: WebFetchToolOptions\n): ToolRegistration<WebFetchParameters, WebFetchToolDetails> {\n const core = createWebFetchToolCore(options);\n return {\n name: core.name,\n description: core.description,\n parameters: webFetchParameters(),\n replay: \"safe\",\n async execute(input, _api, context) {\n const run = await core.run(input, { signal: context.abortSignal });\n if (run.ok) {\n return {\n output: [{ type: \"text\", text: run.text }],\n details: { ok: true, output: run.output }\n };\n }\n const details: WebFetchToolDetails = {\n ok: false,\n message: run.error.message,\n status: run.error.status,\n code: run.error.code,\n retryable: run.error.retryable\n };\n if (run.error.url !== undefined) details.url = run.error.url;\n if (run.error.contentType !== undefined) {\n details.contentType = run.error.contentType;\n }\n return {\n output: [{ type: \"text\", text: run.text }],\n isError: true,\n details\n };\n }\n };\n}\n"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":["/**\n * `agents/webfetch/pi` — the `web_fetch` tool for the pi harness.\n *\n * @beta\n */\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport type { ToolRegistration } from \"@earendil-works/pi-durable\";\nimport { int, obj, opt, str } from \"@earendil-works/pi-schema\";\nimport { MAX_WEB_FETCH_URL_LENGTH, type WebFetchToolOutput } from \"../contract\";\nimport type { WebFetchErrorCode } from \"../source\";\nimport { createWebFetchToolCore, type WebFetchToolOptions } from \"../tool\";\n\nexport type {\n WebFetchFormat,\n WebFetchPage,\n WebFetchToolInput,\n WebFetchToolOutput,\n WebFetchVia\n} from \"../contract\";\nexport {\n WebFetchError,\n type WebFetchErrorCode,\n type WebFetchRequest,\n type WebFetchSource\n} from \"../source\";\nexport type { WebFetchToolOptions } from \"../tool\";\n\n/** The model's input schema. pi already coerces `\"20000\"` to `20000`. */\nfunction webFetchParameters() {\n return obj(\n {\n url: str({\n minLength: 1,\n maxLength: MAX_WEB_FETCH_URL_LENGTH,\n description: \"The http(s) URL to read.\"\n }),\n offset: opt(\n int({\n minimum: 0,\n description:\n \"Character offset into the content, to continue a long page from the previous result's offset. Default 0.\"\n })\n ),\n format: opt(\n StringEnum([\"auto\", \"raw\"] as const, {\n description:\n '\"auto\" (default) converts to the most readable form; \"raw\" returns the body as served.'\n })\n )\n },\n { open: true }\n );\n}\n\ntype WebFetchParameters = ReturnType<typeof webFetchParameters>;\n\n/**\n * Host-side details pi stores with each `web_fetch` result: the output (the\n * window the model read, with the page's metadata) or the failure.\n */\nexport type WebFetchToolDetails =\n | { ok: true; output: WebFetchToolOutput }\n | {\n ok: false;\n /** The source's error message, with the detail for the host. */\n message: string;\n status: number;\n code: WebFetchErrorCode;\n retryable: boolean;\n url?: string;\n /** The response's media type, when a response was read. */\n contentType?: string;\n };\n\n/**\n * Create a pi tool that reads a URL as Markdown, JSON, or text. Install it\n * on a registry like any other pi tool.\n *\n * The model chooses the URL, the window (`offset`), and the format; the\n * host chooses the URL policy, size limits, and window size. The tool is\n * `replay: \"safe\"`: a fetch interrupted mid-call (say, by an eviction) runs\n * again when the session recovers. Completed results are stored and not\n * fetched again.\n *\n * @example\n * ```ts\n * import { createRegistry, Harness } from \"@earendil-works/pi-durable\";\n * import { webFetchTool } from \"agents/webfetch/pi\";\n *\n * // In PiHarness's factory, so each object gets its own registry.\n * harness: ({ storage, context, onWake }) => {\n * const registry = createRegistry();\n * registry.install({\n * name: \"tools\",\n * tools: [webFetchTool({ binding: this.env.AI })]\n * });\n * return Harness.open(storage, { models, registry, onWake }, context);\n * }\n * ```\n */\nexport function webFetchTool(\n options: WebFetchToolOptions\n): ToolRegistration<WebFetchParameters, WebFetchToolDetails> {\n const core = createWebFetchToolCore(options);\n return {\n name: core.name,\n description: core.description,\n parameters: webFetchParameters(),\n replay: \"safe\",\n async execute(input, _api, context) {\n const run = await core.run(input, { signal: context.abortSignal });\n if (run.ok) {\n return {\n output: [{ type: \"text\", text: run.text }],\n details: { ok: true, output: run.output }\n };\n }\n const details: WebFetchToolDetails = {\n ok: false,\n message: run.error.message,\n status: run.error.status,\n code: run.error.code,\n retryable: run.error.retryable\n };\n if (run.error.url !== undefined) details.url = run.error.url;\n if (run.error.contentType !== undefined) {\n details.contentType = run.error.contentType;\n }\n return {\n output: [{ type: \"text\", text: run.text }],\n isError: true,\n details\n };\n }\n };\n}\n"],"mappings":";;;;;;;;;;AA4BA,SAAS,qBAAqB;CAC5B,OAAO,IACL;EACE,KAAK,IAAI;GACP,WAAW;GACX,WAAW;GACX,aAAa;EACf,CAAC;EACD,QAAQ,IACN,IAAI;GACF,SAAS;GACT,aACE;EACJ,CAAC,CACH;EACA,QAAQ,IACN,WAAW,CAAC,QAAQ,KAAK,GAAY,EACnC,aACE,6FACJ,CAAC,CACH;CACF,GACA,EAAE,MAAM,KAAK,CACf;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,aACd,SAC2D;CAC3D,MAAM,OAAO,uBAAuB,OAAO;CAC3C,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,YAAY,mBAAmB;EAC/B,QAAQ;EACR,MAAM,QAAQ,OAAO,MAAM,SAAS;GAClC,MAAM,MAAM,MAAM,KAAK,IAAI,OAAO,EAAE,QAAQ,QAAQ,YAAY,CAAC;GACjE,IAAI,IAAI,IACN,OAAO;IACL,QAAQ,CAAC;KAAE,MAAM;KAAQ,MAAM,IAAI;IAAK,CAAC;IACzC,SAAS;KAAE,IAAI;KAAM,QAAQ,IAAI;IAAO;GAC1C;GAEF,MAAM,UAA+B;IACnC,IAAI;IACJ,SAAS,IAAI,MAAM;IACnB,QAAQ,IAAI,MAAM;IAClB,MAAM,IAAI,MAAM;IAChB,WAAW,IAAI,MAAM;GACvB;GACA,IAAI,IAAI,MAAM,QAAQ,KAAA,GAAW,QAAQ,MAAM,IAAI,MAAM;GACzD,IAAI,IAAI,MAAM,gBAAgB,KAAA,GAC5B,QAAQ,cAAc,IAAI,MAAM;GAElC,OAAO;IACL,QAAQ,CAAC;KAAE,MAAM;KAAQ,MAAM,IAAI;IAAK,CAAC;IACzC,SAAS;IACT;GACF;EACF;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { a as WebFetchError, r as toolFailure, t as createWebFetchToolCore } from "../../../tool-CxKsvxjm.js";
2
- import { t as webFetchInputSchema } from "../../../input-schema-BQykTEp_.js";
2
+ import { t as webFetchInputSchema } from "../../../input-schema-0uUu392-.js";
3
3
  import { toolDefinition } from "@tanstack/ai";
4
4
  //#region src/web/fetch/tools/tanstack-ai.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { i as WebSearchError, n as createWebSearchToolCore, r as toolFailure } from "../../../tool-DkT_DJBm.js";
2
- import { t as webSearchInputSchema } from "../../../input-schema-B0Etuo-o.js";
2
+ import { t as webSearchInputSchema } from "../../../input-schema-waggtYrH.js";
3
3
  //#region src/web/search/tools/ai-sdk.ts
4
4
  /**
5
5
  * Create an AI SDK tool that searches the web through Cloudflare's Web
@@ -9,7 +9,6 @@ import {
9
9
  r as WebSearchToolOptions,
10
10
  w as WebSearchResult
11
11
  } from "../../../tool-CTp72Jb_.js";
12
- import { Type } from "@earendil-works/pi-ai";
13
12
  import { ToolRegistration } from "@earendil-works/pi-durable";
14
13
 
15
14
  //#region src/web/search/tools/pi.d.ts
@@ -18,9 +17,11 @@ import { ToolRegistration } from "@earendil-works/pi-durable";
18
17
  * `limit`; a larger value is not rejected (which would cost a validation
19
18
  * round trip) but capped by the core. pi already coerces `"5"` to `5`.
20
19
  */
21
- declare function webSearchParameters(maxLimit: number): Type.TObject<{
22
- query: Type.TString;
23
- limit: Type.TOptional<Type.TInteger>;
20
+ declare function webSearchParameters(
21
+ maxLimit: number
22
+ ): import("@earendil-works/pi-schema").Schema<{
23
+ query: string;
24
+ limit?: number | undefined;
24
25
  }>;
25
26
  type WebSearchParameters = ReturnType<typeof webSearchParameters>;
26
27
  /**
@@ -1,28 +1,23 @@
1
1
  import { i as WebSearchError, n as createWebSearchToolCore, u as MAX_WEB_SEARCH_QUERY_LENGTH } from "../../../tool-DkT_DJBm.js";
2
- import { Type } from "@earendil-works/pi-ai";
2
+ import { int, obj, opt, str } from "@earendil-works/pi-schema";
3
3
  //#region src/web/search/tools/pi.ts
4
4
  /**
5
- * `agents/websearch/pi` — the `web_search` tool for the pi harness.
6
- *
7
- * @beta
8
- */
9
- /**
10
5
  * The model's input schema. The description tells the model the host's
11
6
  * `limit`; a larger value is not rejected (which would cost a validation
12
7
  * round trip) but capped by the core. pi already coerces `"5"` to `5`.
13
8
  */
14
9
  function webSearchParameters(maxLimit) {
15
- return Type.Object({
16
- query: Type.String({
10
+ return obj({
11
+ query: str({
17
12
  minLength: 1,
18
13
  maxLength: MAX_WEB_SEARCH_QUERY_LENGTH,
19
14
  description: "What to search for."
20
15
  }),
21
- limit: Type.Optional(Type.Integer({
16
+ limit: opt(int({
22
17
  minimum: 1,
23
18
  description: `How many results to return (at most ${maxLimit}).`
24
19
  }))
25
- });
20
+ }, { open: true });
26
21
  }
27
22
  /**
28
23
  * Create a pi tool that searches the web through Cloudflare's Web Search
@@ -1 +1 @@
1
- {"version":3,"file":"pi.js","names":[],"sources":["../../../../src/web/search/tools/pi.ts"],"sourcesContent":["/**\n * `agents/websearch/pi` — the `web_search` tool for the pi harness.\n *\n * @beta\n */\nimport { Type } from \"@earendil-works/pi-ai\";\nimport type { ToolRegistration } from \"@earendil-works/pi-durable\";\nimport {\n MAX_WEB_SEARCH_QUERY_LENGTH,\n type WebSearchToolOutput\n} from \"../contract\";\nimport type { WebSearchErrorCode } from \"../source\";\nimport { createWebSearchToolCore, type WebSearchToolOptions } from \"../tool\";\n\nexport type {\n WebSearchResponse,\n WebSearchResult,\n WebSearchToolInput,\n WebSearchToolOutput\n} from \"../contract\";\nexport {\n WebSearchError,\n type WebSearchErrorCode,\n type WebSearchProvider,\n type WebSearchSource\n} from \"../source\";\nexport type { WebSearchToolOptions } from \"../tool\";\n\n/**\n * The model's input schema. The description tells the model the host's\n * `limit`; a larger value is not rejected (which would cost a validation\n * round trip) but capped by the core. pi already coerces `\"5\"` to `5`.\n */\nfunction webSearchParameters(maxLimit: number) {\n return Type.Object({\n query: Type.String({\n minLength: 1,\n maxLength: MAX_WEB_SEARCH_QUERY_LENGTH,\n description: \"What to search for.\"\n }),\n limit: Type.Optional(\n Type.Integer({\n minimum: 1,\n description: `How many results to return (at most ${maxLimit}).`\n })\n )\n });\n}\n\ntype WebSearchParameters = ReturnType<typeof webSearchParameters>;\n\n/**\n * Host-side details pi stores with each `web_search` result: the full API\n * response (untrimmed descriptions, provider metadata) or the failure.\n */\nexport type WebSearchToolDetails =\n | { ok: true; output: WebSearchToolOutput }\n | {\n ok: false;\n /** The source's error message, with the API's detail. */\n message: string;\n status: number;\n code: WebSearchErrorCode;\n retryable: boolean;\n requestId?: string;\n };\n\n/**\n * Create a pi tool that searches the web through Cloudflare's Web Search\n * API. Install it on a registry like any other pi tool.\n *\n * The model chooses the query and (within the host's `limit`) how many\n * results; the host chooses the gateway, provider, and billing. The tool is\n * `replay: \"safe\"`: a search interrupted mid-call (say, by an eviction) runs\n * again when the session recovers, which is a second billed search.\n * Completed results are stored and not searched again.\n *\n * @example\n * ```ts\n * import { createRegistry, Harness } from \"@earendil-works/pi-durable\";\n * import { webSearchTool } from \"agents/websearch/pi\";\n *\n * // In PiHarness's factory, so each object gets its own registry.\n * harness: ({ storage, context, onWake }) => {\n * const registry = createRegistry();\n * registry.install({\n * name: \"tools\",\n * tools: [webSearchTool({ binding: this.env.AI, provider: \"exa\" })]\n * });\n * return Harness.open(storage, { models, registry, onWake }, context);\n * }\n * ```\n */\nexport function webSearchTool(\n options: WebSearchToolOptions\n): ToolRegistration<WebSearchParameters, WebSearchToolDetails> {\n const core = createWebSearchToolCore(options);\n return {\n name: core.name,\n description: core.description,\n parameters: webSearchParameters(core.limit),\n replay: \"safe\",\n async execute(input, _api, context) {\n const run = await core.run(input, { signal: context.abortSignal });\n if (run.ok) {\n return {\n output: [{ type: \"text\", text: run.text }],\n details: { ok: true, output: run.output }\n };\n }\n return {\n output: [{ type: \"text\", text: run.text }],\n isError: true,\n details: {\n ok: false,\n message: run.error.message,\n status: run.error.status,\n code: run.error.code,\n retryable: run.error.retryable,\n requestId: run.error.requestId\n }\n };\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAiCA,SAAS,oBAAoB,UAAkB;CAC7C,OAAO,KAAK,OAAO;EACjB,OAAO,KAAK,OAAO;GACjB,WAAW;GACX,WAAW;GACX,aAAa;EACf,CAAC;EACD,OAAO,KAAK,SACV,KAAK,QAAQ;GACX,SAAS;GACT,aAAa,uCAAuC,SAAS;EAC/D,CAAC,CACH;CACF,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,cACd,SAC6D;CAC7D,MAAM,OAAO,wBAAwB,OAAO;CAC5C,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,YAAY,oBAAoB,KAAK,KAAK;EAC1C,QAAQ;EACR,MAAM,QAAQ,OAAO,MAAM,SAAS;GAClC,MAAM,MAAM,MAAM,KAAK,IAAI,OAAO,EAAE,QAAQ,QAAQ,YAAY,CAAC;GACjE,IAAI,IAAI,IACN,OAAO;IACL,QAAQ,CAAC;KAAE,MAAM;KAAQ,MAAM,IAAI;IAAK,CAAC;IACzC,SAAS;KAAE,IAAI;KAAM,QAAQ,IAAI;IAAO;GAC1C;GAEF,OAAO;IACL,QAAQ,CAAC;KAAE,MAAM;KAAQ,MAAM,IAAI;IAAK,CAAC;IACzC,SAAS;IACT,SAAS;KACP,IAAI;KACJ,SAAS,IAAI,MAAM;KACnB,QAAQ,IAAI,MAAM;KAClB,MAAM,IAAI,MAAM;KAChB,WAAW,IAAI,MAAM;KACrB,WAAW,IAAI,MAAM;IACvB;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"pi.js","names":[],"sources":["../../../../src/web/search/tools/pi.ts"],"sourcesContent":["/**\n * `agents/websearch/pi` — the `web_search` tool for the pi harness.\n *\n * @beta\n */\nimport type { ToolRegistration } from \"@earendil-works/pi-durable\";\nimport { int, obj, opt, str } from \"@earendil-works/pi-schema\";\nimport {\n MAX_WEB_SEARCH_QUERY_LENGTH,\n type WebSearchToolOutput\n} from \"../contract\";\nimport type { WebSearchErrorCode } from \"../source\";\nimport { createWebSearchToolCore, type WebSearchToolOptions } from \"../tool\";\n\nexport type {\n WebSearchResponse,\n WebSearchResult,\n WebSearchToolInput,\n WebSearchToolOutput\n} from \"../contract\";\nexport {\n WebSearchError,\n type WebSearchErrorCode,\n type WebSearchProvider,\n type WebSearchSource\n} from \"../source\";\nexport type { WebSearchToolOptions } from \"../tool\";\n\n/**\n * The model's input schema. The description tells the model the host's\n * `limit`; a larger value is not rejected (which would cost a validation\n * round trip) but capped by the core. pi already coerces `\"5\"` to `5`.\n */\nfunction webSearchParameters(maxLimit: number) {\n return obj(\n {\n query: str({\n minLength: 1,\n maxLength: MAX_WEB_SEARCH_QUERY_LENGTH,\n description: \"What to search for.\"\n }),\n limit: opt(\n int({\n minimum: 1,\n description: `How many results to return (at most ${maxLimit}).`\n })\n )\n },\n { open: true }\n );\n}\n\ntype WebSearchParameters = ReturnType<typeof webSearchParameters>;\n\n/**\n * Host-side details pi stores with each `web_search` result: the full API\n * response (untrimmed descriptions, provider metadata) or the failure.\n */\nexport type WebSearchToolDetails =\n | { ok: true; output: WebSearchToolOutput }\n | {\n ok: false;\n /** The source's error message, with the API's detail. */\n message: string;\n status: number;\n code: WebSearchErrorCode;\n retryable: boolean;\n requestId?: string;\n };\n\n/**\n * Create a pi tool that searches the web through Cloudflare's Web Search\n * API. Install it on a registry like any other pi tool.\n *\n * The model chooses the query and (within the host's `limit`) how many\n * results; the host chooses the gateway, provider, and billing. The tool is\n * `replay: \"safe\"`: a search interrupted mid-call (say, by an eviction) runs\n * again when the session recovers, which is a second billed search.\n * Completed results are stored and not searched again.\n *\n * @example\n * ```ts\n * import { createRegistry, Harness } from \"@earendil-works/pi-durable\";\n * import { webSearchTool } from \"agents/websearch/pi\";\n *\n * // In PiHarness's factory, so each object gets its own registry.\n * harness: ({ storage, context, onWake }) => {\n * const registry = createRegistry();\n * registry.install({\n * name: \"tools\",\n * tools: [webSearchTool({ binding: this.env.AI, provider: \"exa\" })]\n * });\n * return Harness.open(storage, { models, registry, onWake }, context);\n * }\n * ```\n */\nexport function webSearchTool(\n options: WebSearchToolOptions\n): ToolRegistration<WebSearchParameters, WebSearchToolDetails> {\n const core = createWebSearchToolCore(options);\n return {\n name: core.name,\n description: core.description,\n parameters: webSearchParameters(core.limit),\n replay: \"safe\",\n async execute(input, _api, context) {\n const run = await core.run(input, { signal: context.abortSignal });\n if (run.ok) {\n return {\n output: [{ type: \"text\", text: run.text }],\n details: { ok: true, output: run.output }\n };\n }\n return {\n output: [{ type: \"text\", text: run.text }],\n isError: true,\n details: {\n ok: false,\n message: run.error.message,\n status: run.error.status,\n code: run.error.code,\n retryable: run.error.retryable,\n requestId: run.error.requestId\n }\n };\n }\n };\n}\n"],"mappings":";;;;;;;;AAiCA,SAAS,oBAAoB,UAAkB;CAC7C,OAAO,IACL;EACE,OAAO,IAAI;GACT,WAAW;GACX,WAAW;GACX,aAAa;EACf,CAAC;EACD,OAAO,IACL,IAAI;GACF,SAAS;GACT,aAAa,uCAAuC,SAAS;EAC/D,CAAC,CACH;CACF,GACA,EAAE,MAAM,KAAK,CACf;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,cACd,SAC6D;CAC7D,MAAM,OAAO,wBAAwB,OAAO;CAC5C,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,YAAY,oBAAoB,KAAK,KAAK;EAC1C,QAAQ;EACR,MAAM,QAAQ,OAAO,MAAM,SAAS;GAClC,MAAM,MAAM,MAAM,KAAK,IAAI,OAAO,EAAE,QAAQ,QAAQ,YAAY,CAAC;GACjE,IAAI,IAAI,IACN,OAAO;IACL,QAAQ,CAAC;KAAE,MAAM;KAAQ,MAAM,IAAI;IAAK,CAAC;IACzC,SAAS;KAAE,IAAI;KAAM,QAAQ,IAAI;IAAO;GAC1C;GAEF,OAAO;IACL,QAAQ,CAAC;KAAE,MAAM;KAAQ,MAAM,IAAI;IAAK,CAAC;IACzC,SAAS;IACT,SAAS;KACP,IAAI;KACJ,SAAS,IAAI,MAAM;KACnB,QAAQ,IAAI,MAAM;KAClB,MAAM,IAAI,MAAM;KAChB,WAAW,IAAI,MAAM;KACrB,WAAW,IAAI,MAAM;IACvB;GACF;EACF;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { i as WebSearchError, n as createWebSearchToolCore, r as toolFailure } from "../../../tool-DkT_DJBm.js";
2
- import { t as webSearchInputSchema } from "../../../input-schema-B0Etuo-o.js";
2
+ import { t as webSearchInputSchema } from "../../../input-schema-waggtYrH.js";
3
3
  import { toolDefinition } from "@tanstack/ai";
4
4
  //#region src/web/search/tools/tanstack-ai.ts
5
5
  /**
@@ -1,3 +1,3 @@
1
1
  import { a as isCapnWebTransportUpgrade, i as capnWebTransportUrl, r as CAPNWEB_TRANSPORT_VALUE, t as CAPNWEB_TRANSPORT_QUERY } from "../transport-protocol-BxyngQ_R.js";
2
- import { l as registerInternalConnectionKeys, n as CF_NO_PROTOCOL_KEY, r as CF_READONLY_KEY, t as WebSockets } from "../websockets-CyoeosdO.js";
2
+ import { l as registerInternalConnectionKeys, n as CF_NO_PROTOCOL_KEY, r as CF_READONLY_KEY, t as WebSockets } from "../websockets-C6SJtWCJ.js";
3
3
  export { CAPNWEB_TRANSPORT_QUERY, CAPNWEB_TRANSPORT_VALUE, CF_NO_PROTOCOL_KEY, CF_READONLY_KEY, WebSockets, capnWebTransportUrl, isCapnWebTransportUpgrade, registerInternalConnectionKeys };
@@ -4,7 +4,6 @@ import { a as isCapnWebTransportUpgrade, n as CAPNWEB_TRANSPORT_SEND } from "./t
4
4
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-DZBYAB34.js";
5
5
  import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-qMjJ6sHQ.js";
6
6
  import { t as LifecycleCapability } from "./capability-DBAKc6UZ.js";
7
- import "./lifecycle-v1rKHV2C.js";
8
7
  import { newWebSocketRpcSession } from "capnweb";
9
8
  import { RpcTarget as RpcTarget$1 } from "cloudflare:workers";
10
9
  import { nanoid } from "nanoid";
@@ -1039,4 +1038,4 @@ async function _dispatchCallable(name, invoke, connection) {
1039
1038
  //#endregion
1040
1039
  export { getConnectionFlag as a, isConnectionReadonly as c, setConnectionProtocolEnabled as d, setConnectionReadonly as f, ensureConnectionWrapped as i, registerInternalConnectionKeys as l, CF_NO_PROTOCOL_KEY as n, getConnectionRawState as o, CF_READONLY_KEY as r, isConnectionProtocolEnabled as s, WebSockets as t, setConnectionFlag as u };
1041
1040
 
1042
- //# sourceMappingURL=websockets-CyoeosdO.js.map
1041
+ //# sourceMappingURL=websockets-C6SJtWCJ.js.map