agents 0.13.3 → 0.14.1
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/README.md +6 -4
- package/dist/{agent-tool-types-l98LCbBl.d.ts → agent-tool-types-BAJWu8s4.d.ts} +474 -117
- package/dist/agent-tool-types.d.ts +13 -11
- package/dist/{agent-tools-Bg5ilERh.d.ts → agent-tools-0R6KEert.d.ts} +2 -2
- package/dist/{agent-tools-BAdX1vdI.js → agent-tools-DYrkT-Kx.js} +46 -6
- package/dist/agent-tools-DYrkT-Kx.js.map +1 -0
- package/dist/agent-tools.d.ts +14 -20
- package/dist/agent-tools.js +10 -6
- package/dist/agent-tools.js.map +1 -1
- package/dist/browser/ai.d.ts +1 -1
- package/dist/browser/ai.js +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/tanstack-ai.d.ts +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/chat/index.d.ts +162 -19
- package/dist/chat/index.js +97 -13
- package/dist/chat/index.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +5 -5
- package/dist/chat-sdk/index.js +2 -2
- package/dist/chat-sdk/index.js.map +1 -1
- package/dist/{classPrivateFieldGet2-Evpt0SEr.js → classPrivateFieldGet2-D_obpP6O.js} +5 -5
- package/dist/classPrivateMethodInitSpec-10iTYB7F.js +7 -0
- package/dist/{client-D1kFXo80.js → client-FUizKzj2.js} +299 -95
- package/dist/client-FUizKzj2.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{compaction-helpers-B-pG5J22.d.ts → compaction-helpers-BEUILPss.d.ts} +59 -33
- package/dist/{compaction-helpers-fJyf8j4m.js → compaction-helpers-iiKMr2TQ.js} +22 -3
- package/dist/compaction-helpers-iiKMr2TQ.js.map +1 -0
- package/dist/{do-oauth-client-provider-4OKQU9rT.d.ts → do-oauth-client-provider-D4ZwyBDu.d.ts} +21 -1
- package/dist/{email-J0GGS3sa.d.ts → email-CL27preh.d.ts} +1 -1
- package/dist/email.d.ts +2 -2
- package/dist/experimental/memory/session/index.d.ts +30 -25
- package/dist/experimental/memory/session/index.js +7 -2
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/memory/utils/index.d.ts +12 -10
- package/dist/experimental/memory/utils/index.js +2 -2
- package/dist/{index-DKey3P4s.d.ts → index-RJ4OxMOe.d.ts} +270 -1
- package/dist/index.d.ts +74 -67
- package/dist/index.js +485 -64
- package/dist/index.js.map +1 -1
- package/dist/{internal_context-BZrMS0B5.d.ts → internal_context-Dg4Cgjcu.d.ts} +1 -1
- package/dist/internal_context.d.ts +1 -1
- package/dist/mcp/client.d.ts +17 -13
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.js +143 -17
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +35 -27
- package/dist/mcp/index.js +402 -69
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.d.ts +1 -1
- package/dist/observability/index.js +15 -1
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +1 -1
- package/dist/{retries-BVdRl5ZE.d.ts → retries-CF_HKSlJ.d.ts} +1 -1
- package/dist/retries.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{shared-Cvj92byG.d.ts → shared-4CAYLCTO.d.ts} +1 -1
- package/dist/{shared-CiKaIK4h.js → shared-BIpUk4G5.js} +3 -7
- package/dist/{shared-CiKaIK4h.js.map → shared-BIpUk4G5.js.map} +1 -1
- package/dist/skills/index.d.ts +236 -0
- package/dist/skills/index.js +1326 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/sub-routing.d.ts +6 -6
- package/dist/{tool-output-truncation-CH-khbZ3.js → tool-output-truncation-CNnnGZQ3.js} +1 -1
- package/dist/{tool-output-truncation-CH-khbZ3.js.map → tool-output-truncation-CNnnGZQ3.js.map} +1 -1
- package/dist/{types-_JjKmv-l.d.ts → types-6Zo2zfoO.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +248 -2
- package/dist/vite.js.map +1 -1
- package/dist/{workflow-types-Dkzg4hAx.d.ts → workflow-types-SrZK_o9p.d.ts} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +13 -3
- package/dist/workflows.js +10 -1
- package/dist/workflows.js.map +1 -1
- package/package.json +31 -13
- package/skills-module.d.ts +22 -0
- package/dist/agent-tools-BAdX1vdI.js.map +0 -1
- package/dist/client-D1kFXo80.js.map +0 -1
- package/dist/compaction-helpers-fJyf8j4m.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["parseYaml","extensionOf"],"sources":["../../src/skills/frontmatter.ts","../../src/skills/types.ts","../../src/skills/manifest.ts","../../src/skills/r2.ts","../../src/skills/runner.ts","../../src/skills/registry.ts"],"sourcesContent":["import { parse as parseYaml } from \"yaml\";\n\nexport interface ParsedSkillMarkdown {\n data: Record<string, unknown>;\n body: string;\n}\n\nexport function parseSkillFrontmatter(raw: string): ParsedSkillMarkdown {\n const match = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) return { data: {}, body: raw };\n\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\n return { data, body: match[2] ?? \"\" };\n}\n\nfunction optionalString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction optionalRecord(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\nexport function parseSkillMarkdown(raw: string): {\n name: string;\n description: string;\n body: string;\n compatibility?: string;\n license?: string;\n allowedTools?: string;\n metadata?: Record<string, unknown>;\n} | null {\n const { data, body } = parseSkillFrontmatter(raw);\n const name = optionalString(data.name);\n const description = optionalString(data.description);\n\n if (!name || !description) return null;\n\n return {\n name,\n description,\n body,\n compatibility: optionalString(data.compatibility),\n license: optionalString(data.license),\n allowedTools: optionalString(data[\"allowed-tools\"]),\n metadata: optionalRecord(data.metadata)\n };\n}\n","export interface SkillDescriptor {\n name: string;\n description: string;\n compatibility?: string;\n license?: string;\n allowedTools?: string;\n metadata?: Record<string, unknown>;\n sourceId?: string;\n version?: string;\n}\n\nexport interface SkillContent extends SkillDescriptor {\n body: string;\n rawContent?: string;\n resources?: SkillResourceDescriptor[];\n}\n\nexport interface SkillResourceDescriptor {\n path: string;\n kind: \"reference\" | \"script\" | \"asset\" | \"file\";\n size?: number;\n encoding?: \"text\" | \"base64\";\n mimeType?: string;\n}\n\nexport interface SkillResource extends SkillResourceDescriptor {\n content: string;\n}\n\nexport interface SkillScriptContext {\n skill: SkillDescriptor;\n}\n\n/**\n * The `ctx` object passed as the second argument to function-style JS/TS\n * skill scripts (`export default async function run(input, ctx)`).\n *\n * Capabilities are gated by the runner: `workspace` throws unless workspace\n * access is enabled, and `tools` only resolves tools the runner was given.\n */\nexport interface SkillRunContext {\n /** Metadata for the skill that owns this script. */\n skill: SkillDescriptor;\n /** Text bundled resources by relative path (e.g. `references/style-guide.md`). */\n files: Record<string, string>;\n /** Workspace access, gated by the runner's `workspace` permission. */\n workspace: {\n readFile(path: string): Promise<string | null>;\n listFiles(path?: string): Promise<unknown>;\n glob(pattern: string): Promise<unknown>;\n stat(path: string): Promise<{ type: string; size: number } | null>;\n writeFile(path: string, content: string): Promise<void>;\n };\n /** Explicitly granted tools: `tools.call(name, input)` or `tools.<name>(input)`. */\n tools: {\n call(name: string, input?: unknown): Promise<unknown>;\n } & Record<string, (input?: unknown) => Promise<unknown>>;\n /** Scratch artifacts returned to the model as `outputFiles`. */\n output: {\n writeFile(name: string, content: string): Promise<void>;\n };\n}\n\nexport interface SkillScriptRequest {\n skill: SkillContent;\n path: string;\n source: string;\n input: unknown;\n resources?: SkillResource[];\n}\n\nexport interface SkillScriptRunner {\n run(request: SkillScriptRequest): Promise<unknown>;\n}\n\nexport interface SkillSource {\n id: string;\n fingerprint: string;\n list(): Promise<SkillDescriptor[]>;\n load(name: string): Promise<SkillContent | null>;\n readResource?(name: string, path: string): Promise<SkillResource | null>;\n refresh?(): Promise<void>;\n}\n\nexport interface SkillManifestResource extends SkillResourceDescriptor {\n content: string;\n}\n\nexport interface SkillManifestEntry {\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 version?: string;\n resources?: SkillManifestResource[];\n}\n\nexport interface SkillManifest {\n id: string;\n fingerprint: string;\n skills: SkillManifestEntry[];\n}\n\nexport interface SkillRegistrySnapshot {\n fingerprint: string;\n catalogPrompt: string | null;\n}\n\nexport function validateSkillResourcePath(path: string): string | null {\n if (\n path.startsWith(\"/\") ||\n path.includes(\"\\0\") ||\n path.split(\"/\").some((part) => part === \"\" || part === \".\" || part === \"..\")\n ) {\n return `Skill resource path must be a normalized relative path: ${path}`;\n }\n return null;\n}\n","import type {\n SkillContent,\n SkillDescriptor,\n SkillManifest,\n SkillManifestEntry,\n SkillResource,\n SkillSource\n} from \"./types\";\nimport { validateSkillResourcePath } from \"./types\";\n\nfunction descriptorFromEntry(\n sourceId: string,\n entry: SkillManifestEntry\n): SkillDescriptor {\n return {\n name: entry.name,\n description: entry.description,\n compatibility: entry.compatibility,\n license: entry.license,\n allowedTools: entry.allowedTools,\n metadata: entry.metadata,\n sourceId,\n version: entry.version\n };\n}\n\nfunction contentFromEntry(\n sourceId: string,\n entry: SkillManifestEntry\n): SkillContent {\n return {\n ...descriptorFromEntry(sourceId, entry),\n body: entry.body,\n rawContent: entry.rawContent,\n resources: entry.resources\n ?.filter((resource) => validateSkillResourcePath(resource.path) === null)\n .map(({ content: _content, ...resource }) => ({\n ...resource\n }))\n };\n}\n\nexport function fromManifest(manifest: SkillManifest): SkillSource {\n const byName = new Map(manifest.skills.map((skill) => [skill.name, skill]));\n\n return {\n id: manifest.id,\n fingerprint: manifest.fingerprint,\n async list() {\n return manifest.skills.map((skill) =>\n descriptorFromEntry(manifest.id, skill)\n );\n },\n async load(name: string) {\n const skill = byName.get(name);\n return skill ? contentFromEntry(manifest.id, skill) : null;\n },\n async readResource(\n name: string,\n path: string\n ): Promise<SkillResource | null> {\n const skill = byName.get(name);\n if (validateSkillResourcePath(path) !== null) return null;\n const resource = skill?.resources?.find((entry) => entry.path === path);\n if (resource && validateSkillResourcePath(resource.path) !== null) {\n return null;\n }\n return resource ? { ...resource } : null;\n }\n };\n}\n","import { parseSkillMarkdown } from \"./frontmatter\";\nimport type {\n SkillContent,\n SkillDescriptor,\n SkillResource,\n SkillResourceDescriptor,\n SkillSource\n} from \"./types\";\nimport { validateSkillResourcePath } from \"./types\";\n\nexport interface R2SkillSourceOptions {\n prefix?: string;\n skills?: string[];\n id?: string;\n fingerprint?: \"metadata\" | \"content\";\n refreshIntervalMs?: number;\n}\n\ntype ListedObject = Pick<R2Object, \"key\" | \"etag\" | \"size\" | \"uploaded\">;\n\ninterface IndexedSkill {\n descriptor: SkillDescriptor;\n content: SkillContent;\n directory: string;\n}\n\nfunction normalizePrefix(prefix: string | undefined): string {\n if (!prefix) return \"\";\n return prefix.endsWith(\"/\") ? prefix : `${prefix}/`;\n}\n\nfunction resourceKind(path: string): SkillResourceDescriptor[\"kind\"] {\n if (path.startsWith(\"references/\")) return \"reference\";\n if (path.startsWith(\"scripts/\")) return \"script\";\n if (path.startsWith(\"assets/\")) return \"asset\";\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\nfunction base64Encode(bytes: ArrayBuffer): string {\n let binary = \"\";\n const view = new Uint8Array(bytes);\n for (let i = 0; i < view.length; i++) {\n binary += String.fromCharCode(view[i]!);\n }\n return btoa(binary);\n}\n\nasync function readObjectFingerprint(\n bucket: R2Bucket,\n key: string,\n path: string\n): Promise<string | null> {\n const object = await bucket.get(key);\n if (!object) return null;\n const encoding = resourceEncoding(path);\n const content =\n encoding === \"base64\"\n ? base64Encode(await object.arrayBuffer())\n : await object.text();\n return `${encoding}:${content}`;\n}\n\nfunction stableHash(parts: string[]): string {\n let hash = 0x811c9dc5;\n for (const part of parts) {\n for (let i = 0; i < part.length; i++) {\n hash ^= part.charCodeAt(i);\n hash = Math.imul(hash, 0x01000193);\n }\n // Fold a boundary between parts so that, e.g., [\"ab\", \"cd\"] and [\"abcd\"]\n // hash differently (otherwise the concatenated char stream is identical).\n hash ^= 0xff;\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(36);\n}\n\nfunction objectFingerprintPart(object: ListedObject): string {\n return [\n object.key,\n String(object.size),\n object.etag,\n object.uploaded?.toISOString() ?? \"\"\n ].join(\":\");\n}\n\nasync function listAllObjects(\n bucket: R2Bucket,\n prefix: string\n): Promise<ListedObject[]> {\n const objects: ListedObject[] = [];\n let cursor: string | undefined;\n let truncated = true;\n\n while (truncated) {\n const listed = await bucket.list({ prefix, cursor });\n objects.push(...listed.objects);\n truncated = listed.truncated;\n cursor = listed.truncated ? listed.cursor : undefined;\n }\n\n return objects.sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function readObject(\n bucket: R2Bucket,\n key: string\n): Promise<string | null> {\n const object = await bucket.get(key);\n return object ? object.text() : null;\n}\n\nasync function readResourceObject(\n bucket: R2Bucket,\n key: string,\n descriptor: SkillResourceDescriptor\n): Promise<SkillResource | null> {\n const object = await bucket.get(key);\n if (!object) return null;\n\n const encoding = descriptor.encoding ?? resourceEncoding(descriptor.path);\n const content =\n encoding === \"base64\"\n ? base64Encode(await object.arrayBuffer())\n : await object.text();\n\n return {\n ...descriptor,\n encoding,\n content\n };\n}\n\nexport function r2(\n bucket: R2Bucket,\n options: R2SkillSourceOptions = {}\n): SkillSource {\n const prefix = normalizePrefix(options.prefix);\n const id = options.id ?? `r2:${prefix || \"/\"}`;\n const allowedSkills = options.skills?.length ? new Set(options.skills) : null;\n const fingerprintMode = options.fingerprint ?? \"metadata\";\n const refreshIntervalMs = options.refreshIntervalMs ?? 60_000;\n let fingerprint = id;\n let loaded = false;\n let indexedAt = 0;\n let byName = new Map<string, IndexedSkill>();\n let resourcesByName = new Map<string, SkillResourceDescriptor[]>();\n\n async function refreshIndex(force = false): Promise<void> {\n if (loaded && !force && Date.now() - indexedAt < refreshIntervalMs) {\n return;\n }\n\n const objects = await listAllObjects(bucket, prefix);\n const objectsByKey = new Map(objects.map((object) => [object.key, object]));\n const skillDirectories = objects\n .map((object) => object.key.slice(prefix.length))\n .filter((key) => key.endsWith(\"/SKILL.md\"))\n .map((key) => key.slice(0, -\"SKILL.md\".length - 1))\n .filter((directory) => directory && !directory.includes(\"/\"));\n\n const nextByName = new Map<string, IndexedSkill>();\n const nextResourcesByName = new Map<string, SkillResourceDescriptor[]>();\n const fingerprintParts: string[] = [];\n\n for (const directory of skillDirectories) {\n const skillKey = `${prefix}${directory}/SKILL.md`;\n const rawContent = await readObject(bucket, skillKey);\n if (!rawContent) continue;\n\n const parsed = parseSkillMarkdown(rawContent);\n if (!parsed || allowedSkills?.has(parsed.name) === false) continue;\n\n const resourceKeys = objects\n .map((object) => object.key)\n .filter(\n (key) => key.startsWith(`${prefix}${directory}/`) && key !== skillKey\n )\n .filter(\n (key) =>\n validateSkillResourcePath(\n key.slice(`${prefix}${directory}/`.length)\n ) === null\n );\n const resources: SkillResourceDescriptor[] = [];\n\n for (const key of resourceKeys) {\n const path = key.slice(`${prefix}${directory}/`.length);\n const listedResource = objectsByKey.get(key);\n\n resources.push({\n path,\n kind: resourceKind(path),\n size: listedResource?.size,\n encoding: resourceEncoding(path),\n mimeType: resourceMimeType(path)\n });\n }\n\n const descriptor: SkillDescriptor = {\n name: parsed.name,\n description: parsed.description,\n compatibility: parsed.compatibility,\n license: parsed.license,\n allowedTools: parsed.allowedTools,\n metadata: parsed.metadata,\n sourceId: id\n };\n const content: SkillContent = {\n ...descriptor,\n body: parsed.body,\n rawContent,\n resources: resources.map((resource) => ({ ...resource }))\n };\n\n if (!nextByName.has(parsed.name)) {\n nextByName.set(parsed.name, { descriptor, content, directory });\n nextResourcesByName.set(parsed.name, resources);\n }\n\n const skillObjects = [skillKey, ...resourceKeys]\n .map((key) => objectsByKey.get(key))\n .filter((object): object is ListedObject => Boolean(object));\n if (fingerprintMode === \"content\") {\n fingerprintParts.push(rawContent);\n for (const key of resourceKeys) {\n const path = key.slice(`${prefix}${directory}/`.length);\n fingerprintParts.push(\n (await readObjectFingerprint(bucket, key, path)) ?? \"\"\n );\n }\n } else {\n fingerprintParts.push(...skillObjects.map(objectFingerprintPart));\n }\n }\n\n byName = nextByName;\n resourcesByName = nextResourcesByName;\n fingerprint = `${id}:${stableHash(fingerprintParts)}`;\n loaded = true;\n indexedAt = Date.now();\n }\n\n return {\n id,\n get fingerprint() {\n return fingerprint;\n },\n async list() {\n await refreshIndex();\n return [...byName.values()].map(({ descriptor }) => ({ ...descriptor }));\n },\n async load(name: string) {\n await refreshIndex();\n const skill = byName.get(name);\n return skill ? { ...skill.content } : null;\n },\n async readResource(name: string, path: string) {\n if (validateSkillResourcePath(path) !== null) return null;\n await refreshIndex();\n const skill = byName.get(name);\n if (!skill) return null;\n\n const resource = resourcesByName\n .get(name)\n ?.find((entry) => entry.path === path);\n if (!resource) return null;\n\n return readResourceObject(\n bucket,\n `${prefix}${skill.directory}/${path}`,\n resource\n );\n },\n async refresh() {\n await refreshIndex();\n }\n };\n}\n","import { RpcTarget } from \"cloudflare:workers\";\nimport type { ToolProvider } from \"@cloudflare/codemode\";\nimport type { ToolSet } from \"ai\";\nimport type {\n SkillScriptRequest,\n SkillScriptRunner,\n SkillScriptContext\n} from \"./types\";\nimport { validateSkillResourcePath } from \"./types\";\n\n/**\n * Minimal workspace surface the skill runner needs. A concrete `Workspace`\n * from `@cloudflare/shell` (or Think's `WorkspaceLike`) satisfies this\n * structurally, so the runner does not depend on a filesystem package.\n */\nexport interface SkillWorkspace {\n readFile(path: string): Promise<string | null>;\n writeFile(path: string, content: string): Promise<void>;\n readDir(path: string): Promise<unknown>;\n glob(pattern: string): Promise<unknown>;\n stat(path: string): Promise<{ type: string; size?: number } | null>;\n}\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?: SkillWorkspace;\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 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 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\nexport function validateSkillScriptPath(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 (\n path.startsWith(\"/\") ||\n path.includes(\"\\0\") ||\n path.split(\"/\").some((part) => part === \"\" || part === \".\" || part === \"..\")\n ) {\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 pathError = validateSkillResourcePath(resource.path);\n if (pathError) throw new Error(pathError);\n }\n}\n\nfunction skillScriptContext(request: SkillScriptRequest): SkillScriptContext {\n return {\n skill: {\n name: request.skill.name,\n description: request.skill.description,\n compatibility: request.skill.compatibility,\n license: request.skill.license,\n allowedTools: request.skill.allowedTools,\n metadata: request.skill.metadata,\n sourceId: request.skill.sourceId,\n version: request.skill.version\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: request.skill.rawContent ?? request.skill.body,\n encoding: \"text\"\n }\n };\n\n for (const resource of request.resources ?? []) {\n const pathError = validateSkillResourcePath(resource.path);\n if (pathError) throw new Error(pathError);\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\": request.skill.rawContent ?? request.skill.body,\n [`/skill/${request.path}`]: request.source\n };\n\n for (const resource of request.resources ?? []) {\n const pathError = validateSkillResourcePath(resource.path);\n if (pathError) throw new Error(pathError);\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\nfunction moduleSource(\n module: string | { js?: string; cjs?: string } | undefined\n): string | null {\n if (typeof module === \"string\") return module;\n return module?.js ?? module?.cjs ?? null;\n}\n\n/**\n * Remove `export { ... }` blocks (illegal inside the function wrapper) and\n * rewrite a `export { X as default }` binding to the local `__skillRun`.\n */\nfunction stripStrayExports(source: string): string {\n return source.replace(/\\n?export\\s*\\{[\\s\\S]*?\\};?/g, \"\");\n}\n\nfunction rewriteBundledSource(source: string): string {\n const defaultExport = source.match(\n /export\\s*\\{\\s*([A-Za-z_$][\\w$]*)\\s+as\\s+default\\s*\\};?/m\n );\n let out = source;\n if (defaultExport) {\n out = out.replace(\n defaultExport[0],\n `const __skillRun = ${defaultExport[1]};`\n );\n }\n return stripStrayExports(out);\n}\n\nasync function prepareJavaScriptSource(\n request: SkillScriptRequest,\n runtime: \"javascript\" | \"typescript\"\n): Promise<string> {\n const files: Record<string, string> = {};\n for (const resource of request.resources ?? []) {\n const extension = extensionOf(resource.path);\n if (\n resource.kind === \"script\" &&\n (resource.encoding ?? \"text\") === \"text\" &&\n [\".js\", \".mjs\", \".ts\", \".tsx\"].includes(extension)\n ) {\n files[resource.path] = resource.content;\n }\n }\n files[request.path] = request.source;\n\n // Only compile when TypeScript or when sibling script files need bundling.\n const needsBundler =\n runtime === \"typescript\" || Object.keys(files).length > 1;\n if (!needsBundler) return request.source;\n\n const { createWorker } = await import(\"@cloudflare/worker-bundler\");\n const result = await createWorker({\n files,\n entryPoint: request.path,\n bundle: true\n });\n const compiled =\n moduleSource(result.modules[result.mainModule]) ??\n moduleSource(Object.values(result.modules)[0]);\n\n if (!compiled) {\n throw new Error(`Failed to compile skill script: ${request.path}`);\n }\n\n return rewriteBundledSource(compiled);\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: SkillWorkspace | undefined;\n readonly #workspaceAccess: WorkspaceAccess;\n readonly #outputs = new Map<string, OutputArtifact>();\n\n constructor(\n tools: ToolSet | undefined,\n workspace: SkillWorkspace | undefined,\n workspaceAccess: WorkspaceAccess\n ) {\n super();\n this.#tools = tools;\n this.#workspace = 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\").readDir(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 const info = await this.#requireWorkspace(\"read\").stat(path);\n if (!info) return null;\n return { type: info.type, size: info.size ?? 0 };\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\"): SkillWorkspace {\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 { Bash, defineCommand } = await import(\"just-bash\");\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 (!/^\\s*export\\s+default\\s+/m.test(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 { DynamicWorkerExecutor, resolveProvider } =\n await import(\"@cloudflare/codemode\");\n\n const source = await 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 = validateSkillScriptPath(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","import { tool, type ToolSet } from \"ai\";\nimport { z } from \"zod\";\nimport type {\n SkillContent,\n SkillDescriptor,\n SkillRegistrySnapshot,\n SkillResource,\n SkillResourceDescriptor,\n SkillScriptRunner,\n SkillSource\n} from \"./types\";\nimport { validateSkillResourcePath } from \"./types\";\nimport { validateSkillScriptPath } from \"./runner\";\n\nconst SKILL_CONTEXT_LABEL = \"think_skills\";\n\nfunction stableSourceFingerprint(sources: SkillSource[]): string {\n return sources\n .map((source) => `${source.id}:${source.fingerprint}`)\n .join(\"|\");\n}\n\nfunction wrapSkillContent(skill: SkillContent): string {\n const version = skill.version ? ` version=\"${skill.version}\"` : \"\";\n const resourceList = skill.resources?.length\n ? [\n \"\",\n \"<skill_resources>\",\n ...skill.resources.map(\n (resource) =>\n ` <file kind=\"${resource.kind}\" encoding=\"${resource.encoding ?? \"text\"}\"${resource.size === undefined ? \"\" : ` size=\"${resource.size}\"`}>${resource.path}</file>`\n ),\n \"</skill_resources>\"\n ].join(\"\\n\")\n : \"\";\n\n return [\n `<skill_content name=\"${skill.name}\"${version}>`,\n skill.body.trim(),\n resourceList,\n \"</skill_content>\"\n ].join(\"\\n\");\n}\n\nfunction renderResourceList(\n resources: SkillResourceDescriptor[] | undefined\n): string {\n if (!resources?.length) return \"No bundled resources.\";\n return resources\n .map((resource) => {\n const encoding = resource.encoding ?? \"text\";\n const size =\n resource.size === undefined ? \"\" : `, ${resource.size} bytes`;\n const mimeType = resource.mimeType ? `, ${resource.mimeType}` : \"\";\n return `- ${resource.path} (${resource.kind}, ${encoding}${mimeType}${size})`;\n })\n .join(\"\\n\");\n}\n\nfunction validateResourcePath(path: string): string | null {\n if (path.startsWith(\"../\")) {\n return `Resource paths cannot use \"../\". To read from another skill, use a qualified path like \"other-skill/references/file.md\".`;\n }\n return validateSkillResourcePath(path);\n}\n\nexport class SkillRegistry {\n readonly contextLabel = SKILL_CONTEXT_LABEL;\n\n /**\n * Non-fatal diagnostics collected during the most recent {@link load} or\n * {@link refresh} (duplicate skill names, sources that failed to list).\n * Reset on every load so it never grows unbounded across refreshes.\n */\n readonly warnings: string[] = [];\n\n private sources: SkillSource[];\n private scriptRunner: SkillScriptRunner | null;\n private descriptors = new Map<string, SkillDescriptor>();\n private sourceBySkill = new Map<string, SkillSource>();\n private loaded = false;\n\n constructor(\n sources: SkillSource[],\n scriptRunner: SkillScriptRunner | null = null\n ) {\n this.sources = sources;\n this.scriptRunner = scriptRunner;\n }\n\n get fingerprint(): string {\n return stableSourceFingerprint(this.sources);\n }\n\n async load(): Promise<void> {\n if (this.loaded) return;\n\n this.descriptors.clear();\n this.sourceBySkill.clear();\n this.warnings.length = 0;\n\n // Skills are applied in `getSkills()` order: the first source to register\n // a name wins, and later collisions are skipped with a diagnostic. A bad\n // source must not take down the whole registry, so listing failures are\n // also recorded rather than thrown.\n for (const source of this.sources) {\n let descriptors: SkillDescriptor[];\n try {\n descriptors = await source.list();\n } catch (error) {\n this.warnings.push(\n `Skill source \"${source.id}\" failed to list skills and was skipped: ${error instanceof Error ? error.message : String(error)}`\n );\n continue;\n }\n\n for (const descriptor of descriptors) {\n const existing = this.descriptors.get(descriptor.name);\n if (existing) {\n this.warnings.push(\n `Duplicate skill \"${descriptor.name}\" from ${source.id} ignored; already registered from ${existing.sourceId}.`\n );\n continue;\n }\n this.descriptors.set(descriptor.name, {\n ...descriptor,\n sourceId: descriptor.sourceId ?? source.id\n });\n this.sourceBySkill.set(descriptor.name, source);\n }\n }\n\n this.loaded = true;\n }\n\n async refresh(): Promise<void> {\n const refreshErrors: string[] = [];\n await Promise.all(\n this.sources.map(async (source) => {\n try {\n await source.refresh?.();\n } catch (error) {\n refreshErrors.push(\n `Skill source \"${source.id}\" failed to refresh: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n })\n );\n this.loaded = false;\n await this.load();\n // `load()` reset warnings; re-append any refresh failures so they surface.\n this.warnings.push(...refreshErrors);\n }\n\n async snapshot(): Promise<SkillRegistrySnapshot> {\n await this.load();\n\n const catalog: string[] = [];\n\n for (const descriptor of this.descriptors.values()) {\n catalog.push(`- ${descriptor.name}: ${descriptor.description}`);\n }\n\n return {\n fingerprint: this.fingerprint,\n catalogPrompt: catalog.length\n ? [\n \"Available skills. When a task matches a skill, use activate_skill with its name before proceeding.\",\n \"\",\n ...catalog\n ].join(\"\\n\")\n : null\n };\n }\n\n async systemPrompt(): Promise<string | null> {\n const snapshot = await this.snapshot();\n return snapshot.catalogPrompt;\n }\n\n async loadSkill(name: string): Promise<SkillContent | null> {\n await this.load();\n const source = this.sourceBySkill.get(name);\n return source ? source.load(name) : null;\n }\n\n private resolveResourceTarget(\n name: string | undefined,\n path: string\n ):\n | {\n ok: true;\n name: string;\n path: string;\n }\n | {\n ok: false;\n error: string;\n } {\n const pathError = validateResourcePath(path);\n if (pathError) return { ok: false, error: pathError };\n\n if (name) return { ok: true, name, path };\n\n const [candidateName, ...rest] = path.split(\"/\");\n if (!candidateName || rest.length === 0) {\n return {\n ok: false,\n error:\n \"Resource path must include a skill name when name is omitted, for example: cloudflare-brand/references/tokens.md\"\n };\n }\n if (!this.descriptors.has(candidateName)) {\n return {\n ok: false,\n error: `Unknown skill in qualified resource path: ${candidateName}`\n };\n }\n return { ok: true, name: candidateName, path: rest.join(\"/\") };\n }\n\n private async readResource(\n name: string,\n path: string\n ): Promise<SkillResource | string> {\n const source = this.sourceBySkill.get(name);\n if (!source?.readResource) {\n return `Skill \"${name}\" has no readable resources.`;\n }\n const resource = await source.readResource(name, path);\n return resource ?? `Resource not found: ${name}/${path}`;\n }\n\n private async readSkillResources(\n skill: SkillContent\n ): Promise<SkillResource[]> {\n const resources: SkillResource[] = [];\n for (const descriptor of skill.resources ?? []) {\n const resource = await this.readResource(skill.name, descriptor.path);\n if (typeof resource !== \"string\") resources.push(resource);\n }\n return resources;\n }\n\n tools(): ToolSet {\n const modelSkillNames = [...this.descriptors.values()].map(\n (skill) => skill.name\n );\n\n const tools: ToolSet = {};\n\n if (modelSkillNames.length > 0) {\n tools.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({\n name: z.enum(modelSkillNames as [string, ...string[]])\n }),\n execute: async ({ name }: { name: string }) => {\n const skill = await this.loadSkill(name);\n if (!skill) {\n return `Skill not found: ${name}`;\n }\n return [\n wrapSkillContent(skill),\n \"\",\n \"Bundled resources:\",\n renderResourceList(skill.resources)\n ].join(\"\\n\");\n }\n });\n }\n\n if (modelSkillNames.length > 0) {\n tools.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: z.enum(modelSkillNames as [string, ...string[]]).optional(),\n path: z.string().min(1)\n }),\n execute: async ({ name, path }: { name?: string; path: string }) => {\n const target = this.resolveResourceTarget(name, path);\n if (!target.ok) return target.error;\n\n const resource = await this.readResource(target.name, target.path);\n if (typeof resource === \"string\") return resource;\n\n const encoding = resource.encoding ?? \"text\";\n const mimeType = resource.mimeType\n ? ` mimeType=\"${resource.mimeType}\"`\n : \"\";\n return [\n `<skill_resource name=\"${target.name}\" path=\"${resource.path}\" kind=\"${resource.kind}\" encoding=\"${encoding}\"${mimeType}>`,\n resource.content,\n \"</skill_resource>\"\n ].join(\"\\n\");\n }\n });\n }\n\n if (modelSkillNames.length > 0 && this.scriptRunner) {\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: z.enum(modelSkillNames as [string, ...string[]]),\n path: z.string().min(1),\n input: z.unknown().default({})\n }),\n execute: async ({\n name,\n path,\n input = {}\n }: {\n name: string;\n path: string;\n input: unknown;\n }) => {\n const validation = validateSkillScriptPath(path);\n if (!validation.ok) return validation.error;\n\n const skill = await this.loadSkill(name);\n if (!skill) return `Skill not found: ${name}`;\n\n const script = skill.resources?.find(\n (resource) => resource.path === path\n );\n if (!script) return `Script not found: ${name}/${path}`;\n if (script.kind !== \"script\") {\n return `Resource is not a script: ${name}/${path}`;\n }\n\n const source = this.sourceBySkill.get(name);\n if (!source?.readResource) {\n return `Skill \"${name}\" has no readable resources.`;\n }\n\n const resource = await source.readResource(name, path);\n if (!resource) return `Script not found: ${name}/${path}`;\n if ((resource.encoding ?? \"text\") !== \"text\") {\n return `Script resource must be text, got ${resource.encoding}: ${name}/${path}`;\n }\n\n try {\n return await this.scriptRunner!.run({\n skill,\n path,\n source: resource.content,\n input,\n resources: await this.readSkillResources(skill)\n });\n } catch (error) {\n return `Skill script failed: ${error instanceof Error ? error.message : String(error)}`;\n }\n }\n });\n }\n\n return tools;\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,sBAAsB,KAAkC;CACtE,MAAM,QAAQ,IAAI,MAAM,6CAA6C;CACrE,IAAI,CAAC,OAAO,OAAO;EAAE,MAAM,CAAC;EAAG,MAAM;CAAI;CAEzC,MAAM,SAASA,MAAU,MAAM,MAAM,EAAE;CAMvC,OAAO;EAAE,MAJP,WAAW,QAAQ,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,IACjE,SACD,CAAC;EAEQ,MAAM,MAAM,MAAM;CAAG;AACtC;AAEA,SAAS,eAAe,OAAoC;CAC1D,OAAO,OAAO,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,MAAM,KAAK,aAAc,IAAI;MAClC;MACA;MACA,QAAQ,SAAS;MACjB;MACA,WAAW,MAAM,KAAK,mBAAmB,KAAK;KAChD,CAAC;IACH,SAAS,OAAO;KACd,OAAO,wBAAwB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IACtF;GACF;EACF,CAAC;EAGH,OAAO;CACT;AACF"}
|
package/dist/sub-routing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./agent-tool-types-
|
|
2
|
+
Gt as SubAgentPathMatch,
|
|
3
|
+
Jt as routeSubAgentRequest,
|
|
4
|
+
Kt as getSubAgentByName,
|
|
5
|
+
Wt as SUB_PREFIX,
|
|
6
|
+
qt as parseSubAgentPath
|
|
7
|
+
} from "./agent-tool-types-BAJWu8s4.js";
|
|
8
8
|
export {
|
|
9
9
|
SUB_PREFIX,
|
|
10
10
|
SubAgentPathMatch,
|
package/dist/{tool-output-truncation-CH-khbZ3.js.map → tool-output-truncation-CNnnGZQ3.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-output-truncation-
|
|
1
|
+
{"version":3,"file":"tool-output-truncation-CNnnGZQ3.js","names":[],"sources":["../src/chat/tool-output-truncation.ts"],"sourcesContent":["export interface TruncatedToolOutput {\n output: unknown;\n truncated: boolean;\n originalLength: number;\n}\n\nconst DEFAULT_MAX_DEPTH = 8;\nconst TRUNCATED_FLAG = \"__truncated\";\nconst TRUNCATED_CHARS = \"__truncatedChars\";\n\nexport function truncateToolOutput(\n output: unknown,\n maxChars: number\n): TruncatedToolOutput {\n const original = stringifyForLength(output);\n if (original.length <= maxChars) {\n return { output, truncated: false, originalLength: original.length };\n }\n\n return {\n output: truncateValue(output, maxChars, original.length, 0),\n truncated: true,\n originalLength: original.length\n };\n}\n\nexport function truncatedSuffix(originalLength: number): string {\n return `... [truncated ${originalLength} chars]`;\n}\n\nfunction truncateValue(\n value: unknown,\n maxChars: number,\n originalLength: number,\n depth: number\n): unknown {\n if (typeof value === \"string\") {\n return truncateString(value, maxChars, value.length);\n }\n\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n\n if (depth >= DEFAULT_MAX_DEPTH) {\n return `[Nested output omitted ${truncatedSuffix(originalLength)}]`;\n }\n\n if (Array.isArray(value)) {\n return truncateArray(value, maxChars, originalLength, depth);\n }\n\n return truncateObject(\n value as Record<string, unknown>,\n maxChars,\n originalLength,\n depth\n );\n}\n\nfunction truncateArray(\n value: unknown[],\n maxChars: number,\n originalLength: number,\n depth: number\n): unknown[] {\n const childBudget = childMaxChars(maxChars, value.length);\n const result = value.map((item) =>\n truncateValue(item, childBudget, stringifyForLength(item).length, depth + 1)\n );\n\n while (result.length > 1 && stringifyForLength(result).length > maxChars) {\n result.pop();\n }\n\n if (result.length < value.length) {\n result.push(`Array output truncated ${truncatedSuffix(originalLength)}`);\n }\n\n if (stringifyForLength(result).length > maxChars) {\n return compactArrayMarker(maxChars, originalLength);\n }\n\n return result;\n}\n\nfunction truncateObject(\n value: Record<string, unknown>,\n maxChars: number,\n originalLength: number,\n depth: number\n): Record<string, unknown> {\n const entries = Object.entries(value);\n const childBudget = childMaxChars(maxChars, entries.length);\n const result: Record<string, unknown> = {};\n\n for (const [key, entryValue] of entries) {\n result[key] = truncateValue(\n entryValue,\n childBudget,\n stringifyForLength(entryValue).length,\n depth + 1\n );\n }\n\n const resultLength = stringifyForLength(result).length;\n if (resultLength <= maxChars) {\n return result;\n }\n\n shrinkStringFields(result, maxChars);\n const shrunkLength = stringifyForLength(result).length;\n if (shrunkLength > maxChars) {\n result[TRUNCATED_FLAG] = true;\n result[TRUNCATED_CHARS] = resultLength;\n }\n\n if (stringifyForLength(result).length > maxChars) {\n return compactObjectMarker(maxChars, originalLength);\n }\n\n return result;\n}\n\nfunction shrinkStringFields(\n value: Record<string, unknown>,\n maxChars: number\n): void {\n const stringEntries = Object.entries(value)\n .filter((entry): entry is [string, string] => typeof entry[1] === \"string\")\n .sort((a, b) => b[1].length - a[1].length);\n\n for (const [key, str] of stringEntries) {\n if (stringifyForLength(value).length <= maxChars) {\n return;\n }\n\n value[key] = truncateString(\n str,\n Math.max(0, Math.floor(maxChars / 4)),\n str.length\n );\n }\n}\n\nfunction truncateString(\n value: string,\n maxChars: number,\n originalLength: number\n): string {\n if (value.length <= maxChars) {\n return value;\n }\n\n const suffix = truncatedSuffix(originalLength);\n if (maxChars <= suffix.length) {\n return suffix.slice(0, maxChars);\n }\n\n return `${value.slice(0, maxChars - suffix.length)}${suffix}`;\n}\n\nfunction compactObjectMarker(\n maxChars: number,\n originalLength: number\n): Record<string, unknown> {\n const marker = {\n [TRUNCATED_FLAG]: true,\n [TRUNCATED_CHARS]: originalLength,\n note: \"Tool output omitted because it was too large to preserve structurally.\"\n };\n\n if (stringifyForLength(marker).length <= maxChars) {\n return marker;\n }\n\n return {\n [TRUNCATED_FLAG]: true,\n [TRUNCATED_CHARS]: originalLength\n };\n}\n\nfunction compactArrayMarker(\n maxChars: number,\n originalLength: number\n): unknown[] {\n const structuredMarker = compactObjectMarker(maxChars, originalLength);\n if (stringifyForLength([structuredMarker]).length <= maxChars) {\n return [structuredMarker];\n }\n\n const marker = [\n `Array output omitted because it was too large to preserve structurally ${truncatedSuffix(originalLength)}`\n ];\n\n if (stringifyForLength(marker).length <= maxChars) {\n return marker;\n }\n\n return [truncatedSuffix(originalLength).slice(0, maxChars)];\n}\n\nfunction childMaxChars(maxChars: number, childCount: number): number {\n if (childCount <= 1) {\n return maxChars;\n }\n\n return Math.max(80, Math.floor(maxChars / Math.min(childCount, 10)));\n}\n\nfunction stringifyForLength(value: unknown): string {\n try {\n if (typeof value === \"string\") {\n return value;\n }\n return JSON.stringify(value) ?? String(value);\n } catch {\n return String(value);\n }\n}\n"],"mappings":";AAMA,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AACvB,MAAM,kB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AAoB,UAAU,cAAc;CACrE,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,UACnD,OAAO,CAAC,gBAAgB;CAG1B,MAAM,SAAS,CACb,0EAA0E,gBAAgB,cAAc,GAC1G;CAEA,IAAI,mBAAmB,MAAM,EAAE,UAAU,UACvC,OAAO;CAGT,OAAO,CAAC,gBAAgB,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC5D;AAEA,SAAS,cAAc,UAAkB,YAA4B;CACnE,IAAI,cAAc,GAChB,OAAO;CAGT,OAAO,KAAK,IAAI,IAAI,KAAK,MAAM,WAAW,KAAK,IAAI,YAAY,EAAE,CAAC,CAAC;AACrE;AAEA,SAAS,mBAAmB,OAAwB;CAClD,IAAI;EACF,IAAI,OAAO,UAAU,UACnB,OAAO;EAET,OAAO,KAAK,UAAU,KAAK,KAAK,OAAO,KAAK;CAC9C,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MessageType } from "./types-
|
|
1
|
+
import { t as MessageType } from "./types-6Zo2zfoO.js";
|
|
2
2
|
export { MessageType };
|
package/dist/vite.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Plugin } from "vite";
|
|
|
8
8
|
* oxc#9170) so `@callable()` works at runtime. Will grow to cover other
|
|
9
9
|
* Agents-specific build concerns as needed.
|
|
10
10
|
*/
|
|
11
|
-
declare function agents(): Plugin;
|
|
11
|
+
declare function agents(): Plugin[];
|
|
12
12
|
//#endregion
|
|
13
13
|
export { agents as default };
|
|
14
14
|
//# sourceMappingURL=vite.d.ts.map
|
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,251 @@
|
|
|
1
1
|
import babel from "@rolldown/plugin-babel";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
4
|
+
import { basename, join, resolve } from "node:path";
|
|
5
|
+
import { parse } from "yaml";
|
|
2
6
|
//#region src/vite.ts
|
|
7
|
+
const SKILLS_SPECIFIER = "agents:skills";
|
|
8
|
+
const SKILLS_VIRTUAL_PREFIX = "\0agents:skills:";
|
|
9
|
+
const SKILL_RESOURCE_ROOTS = new Set([
|
|
10
|
+
"references",
|
|
11
|
+
"scripts",
|
|
12
|
+
"assets",
|
|
13
|
+
"graphics",
|
|
14
|
+
"fonts",
|
|
15
|
+
"templates",
|
|
16
|
+
"rendered-files",
|
|
17
|
+
"illustrations"
|
|
18
|
+
]);
|
|
19
|
+
const SKILL_IGNORED_ROOTS = new Set([
|
|
20
|
+
".git",
|
|
21
|
+
".hg",
|
|
22
|
+
".svn",
|
|
23
|
+
".DS_Store",
|
|
24
|
+
".idea",
|
|
25
|
+
".vscode",
|
|
26
|
+
"dist",
|
|
27
|
+
"build",
|
|
28
|
+
"coverage",
|
|
29
|
+
"node_modules"
|
|
30
|
+
]);
|
|
31
|
+
const SPEC_RESOURCE_ROOTS = new Set([
|
|
32
|
+
"references",
|
|
33
|
+
"scripts",
|
|
34
|
+
"assets"
|
|
35
|
+
]);
|
|
36
|
+
const SKILL_ASSET_WARN_BYTES = 256 * 1024;
|
|
37
|
+
const SKILL_BUNDLE_WARN_BYTES = 1024 * 1024;
|
|
38
|
+
function formatBytes(bytes) {
|
|
39
|
+
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
40
|
+
if (bytes >= 1024) return `${(bytes / 1024).toFixed(0)}KB`;
|
|
41
|
+
return `${bytes}B`;
|
|
42
|
+
}
|
|
43
|
+
function parseFrontmatter(raw) {
|
|
44
|
+
const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
45
|
+
if (!match) return {
|
|
46
|
+
data: {},
|
|
47
|
+
body: raw
|
|
48
|
+
};
|
|
49
|
+
const parsed = parse(match[1] ?? "");
|
|
50
|
+
return {
|
|
51
|
+
data: parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {},
|
|
52
|
+
body: match[2] ?? ""
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function stringField(value) {
|
|
56
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
57
|
+
}
|
|
58
|
+
function recordField(value) {
|
|
59
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
60
|
+
}
|
|
61
|
+
function resourceKind(path) {
|
|
62
|
+
if (path.startsWith("references/")) return "reference";
|
|
63
|
+
if (path.startsWith("scripts/")) return "script";
|
|
64
|
+
if (path.startsWith("assets/") || path.startsWith("graphics/") || path.startsWith("fonts/") || path.startsWith("templates/") || path.startsWith("rendered-files/") || path.startsWith("illustrations/")) return "asset";
|
|
65
|
+
return "file";
|
|
66
|
+
}
|
|
67
|
+
const TEXT_EXTENSIONS = new Set([
|
|
68
|
+
".bash",
|
|
69
|
+
".css",
|
|
70
|
+
".csv",
|
|
71
|
+
".html",
|
|
72
|
+
".js",
|
|
73
|
+
".json",
|
|
74
|
+
".jsx",
|
|
75
|
+
".md",
|
|
76
|
+
".mjs",
|
|
77
|
+
".py",
|
|
78
|
+
".sh",
|
|
79
|
+
".svg",
|
|
80
|
+
".ts",
|
|
81
|
+
".tsx",
|
|
82
|
+
".txt",
|
|
83
|
+
".xml",
|
|
84
|
+
".yaml",
|
|
85
|
+
".yml"
|
|
86
|
+
]);
|
|
87
|
+
const MIME_TYPES = new Map([
|
|
88
|
+
[".css", "text/css"],
|
|
89
|
+
[".gif", "image/gif"],
|
|
90
|
+
[".html", "text/html"],
|
|
91
|
+
[".jpg", "image/jpeg"],
|
|
92
|
+
[".jpeg", "image/jpeg"],
|
|
93
|
+
[".js", "text/javascript"],
|
|
94
|
+
[".json", "application/json"],
|
|
95
|
+
[".md", "text/markdown"],
|
|
96
|
+
[".mjs", "text/javascript"],
|
|
97
|
+
[".pdf", "application/pdf"],
|
|
98
|
+
[".png", "image/png"],
|
|
99
|
+
[".py", "text/x-python"],
|
|
100
|
+
[".sh", "text/x-shellscript"],
|
|
101
|
+
[".svg", "image/svg+xml"],
|
|
102
|
+
[".ts", "text/typescript"],
|
|
103
|
+
[".tsx", "text/typescript"],
|
|
104
|
+
[".txt", "text/plain"],
|
|
105
|
+
[".webp", "image/webp"],
|
|
106
|
+
[".woff", "font/woff"],
|
|
107
|
+
[".woff2", "font/woff2"],
|
|
108
|
+
[".xml", "application/xml"],
|
|
109
|
+
[".yaml", "application/yaml"],
|
|
110
|
+
[".yml", "application/yaml"]
|
|
111
|
+
]);
|
|
112
|
+
function extensionOf(path) {
|
|
113
|
+
const file = path.split("/").at(-1) ?? path;
|
|
114
|
+
const index = file.lastIndexOf(".");
|
|
115
|
+
return index === -1 ? "" : file.slice(index).toLowerCase();
|
|
116
|
+
}
|
|
117
|
+
function resourceEncoding(path) {
|
|
118
|
+
return TEXT_EXTENSIONS.has(extensionOf(path)) ? "text" : "base64";
|
|
119
|
+
}
|
|
120
|
+
function resourceMimeType(path) {
|
|
121
|
+
return MIME_TYPES.get(extensionOf(path));
|
|
122
|
+
}
|
|
123
|
+
async function collectFiles(root, relativeRoot = "", warn) {
|
|
124
|
+
const entries = await readdir(join(root, relativeRoot), { withFileTypes: true }).catch(() => []);
|
|
125
|
+
const files = [];
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (SKILL_IGNORED_ROOTS.has(entry.name)) continue;
|
|
128
|
+
const relativePath = relativeRoot ? `${relativeRoot}/${entry.name}` : entry.name;
|
|
129
|
+
const absolutePath = join(root, relativePath);
|
|
130
|
+
if (entry.isDirectory()) {
|
|
131
|
+
const resourceRoot = relativePath.split("/")[0];
|
|
132
|
+
if (!resourceRoot || SKILL_IGNORED_ROOTS.has(resourceRoot)) continue;
|
|
133
|
+
if (!SKILL_RESOURCE_ROOTS.has(resourceRoot)) {
|
|
134
|
+
if (!relativeRoot) warn?.(`Ignoring skill directory "${relativePath}". Bundled skill resources should live under references/, scripts/, assets/, or a known asset root.`);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!SPEC_RESOURCE_ROOTS.has(resourceRoot) && !relativeRoot) warn?.(`Bundling non-standard skill resource root "${resourceRoot}/". Prefer assets/ for portable Agent Skills when possible.`);
|
|
138
|
+
files.push(...await collectFiles(root, relativePath, warn));
|
|
139
|
+
} else if (entry.isFile() && relativePath !== "SKILL.md") {
|
|
140
|
+
const resourceRoot = relativePath.split("/")[0];
|
|
141
|
+
if (!resourceRoot || SKILL_IGNORED_ROOTS.has(resourceRoot)) continue;
|
|
142
|
+
if (!SKILL_RESOURCE_ROOTS.has(resourceRoot)) {
|
|
143
|
+
warn?.(`Ignoring skill file "${relativePath}". Bundled skill resources should live under references/, scripts/, assets/, or a known asset root.`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const info = await stat(absolutePath);
|
|
147
|
+
files.push({
|
|
148
|
+
path: relativePath,
|
|
149
|
+
absolutePath,
|
|
150
|
+
size: info.size
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return files.sort((a, b) => a.path.localeCompare(b.path));
|
|
155
|
+
}
|
|
156
|
+
async function collectWatchTargets(root, relativeRoot = "") {
|
|
157
|
+
const directory = join(root, relativeRoot);
|
|
158
|
+
const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);
|
|
159
|
+
const targets = [directory];
|
|
160
|
+
for (const entry of entries) {
|
|
161
|
+
if (SKILL_IGNORED_ROOTS.has(entry.name)) continue;
|
|
162
|
+
const relativePath = relativeRoot ? `${relativeRoot}/${entry.name}` : entry.name;
|
|
163
|
+
const resourceRoot = relativePath.split("/")[0];
|
|
164
|
+
if (!resourceRoot || SKILL_IGNORED_ROOTS.has(resourceRoot)) continue;
|
|
165
|
+
const absolutePath = join(root, relativePath);
|
|
166
|
+
targets.push(absolutePath);
|
|
167
|
+
if (entry.isDirectory()) targets.push(...await collectWatchTargets(root, relativePath));
|
|
168
|
+
}
|
|
169
|
+
return targets;
|
|
170
|
+
}
|
|
171
|
+
async function readSkill(skillDir, warn) {
|
|
172
|
+
const rawContent = await readFile(join(skillDir, "SKILL.md"), "utf8").catch(() => null);
|
|
173
|
+
if (rawContent === null) return null;
|
|
174
|
+
const { data, body } = parseFrontmatter(rawContent);
|
|
175
|
+
const name = stringField(data.name);
|
|
176
|
+
const description = stringField(data.description);
|
|
177
|
+
if (!name || !description) return null;
|
|
178
|
+
const resources = await Promise.all((await collectFiles(skillDir, "", warn)).map(async (file) => {
|
|
179
|
+
const encoding = resourceEncoding(file.path);
|
|
180
|
+
const bytes = await readFile(file.absolutePath);
|
|
181
|
+
return {
|
|
182
|
+
path: file.path,
|
|
183
|
+
kind: resourceKind(file.path),
|
|
184
|
+
size: file.size,
|
|
185
|
+
encoding,
|
|
186
|
+
mimeType: resourceMimeType(file.path),
|
|
187
|
+
content: encoding === "base64" ? bytes.toString("base64") : bytes.toString()
|
|
188
|
+
};
|
|
189
|
+
}));
|
|
190
|
+
return {
|
|
191
|
+
name,
|
|
192
|
+
description,
|
|
193
|
+
body,
|
|
194
|
+
rawContent,
|
|
195
|
+
compatibility: stringField(data.compatibility),
|
|
196
|
+
license: stringField(data.license),
|
|
197
|
+
allowedTools: stringField(data["allowed-tools"]),
|
|
198
|
+
metadata: recordField(data.metadata),
|
|
199
|
+
resources
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
async function buildSkillsModule(dir, warn) {
|
|
203
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
204
|
+
const skills = [];
|
|
205
|
+
const seen = /* @__PURE__ */ new Set();
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
if (!entry.isDirectory()) continue;
|
|
208
|
+
const skill = await readSkill(join(dir, entry.name), warn);
|
|
209
|
+
if (!skill) continue;
|
|
210
|
+
if (seen.has(skill.name)) {
|
|
211
|
+
warn?.(`Duplicate bundled skill name "${skill.name}" in "${entry.name}/"; keeping the first occurrence and ignoring this one.`);
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
seen.add(skill.name);
|
|
215
|
+
skills.push(skill);
|
|
216
|
+
}
|
|
217
|
+
skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
218
|
+
let totalBytes = 0;
|
|
219
|
+
for (const skill of skills) for (const resource of skill.resources) {
|
|
220
|
+
totalBytes += resource.size;
|
|
221
|
+
if (resource.size > SKILL_ASSET_WARN_BYTES) warn?.(`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().`);
|
|
222
|
+
}
|
|
223
|
+
if (totalBytes > SKILL_BUNDLE_WARN_BYTES) warn?.(`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().`);
|
|
224
|
+
const hash = createHash("sha256");
|
|
225
|
+
hash.update(JSON.stringify(skills));
|
|
226
|
+
const manifest = {
|
|
227
|
+
id: `bundle:${basename(dir)}`,
|
|
228
|
+
fingerprint: hash.digest("hex"),
|
|
229
|
+
skills
|
|
230
|
+
};
|
|
231
|
+
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`;
|
|
232
|
+
}
|
|
233
|
+
function skillsImportPlugin() {
|
|
234
|
+
return {
|
|
235
|
+
name: "agents-skills-import",
|
|
236
|
+
async resolveId(source, importer) {
|
|
237
|
+
if (source !== SKILLS_SPECIFIER && !source.startsWith(`${SKILLS_SPECIFIER}/`)) return null;
|
|
238
|
+
if (!importer) return null;
|
|
239
|
+
return `${SKILLS_VIRTUAL_PREFIX}${resolve(importer, "..", source === SKILLS_SPECIFIER ? "skills" : source.slice(14))}`;
|
|
240
|
+
},
|
|
241
|
+
async load(id) {
|
|
242
|
+
if (!id.startsWith(SKILLS_VIRTUAL_PREFIX)) return null;
|
|
243
|
+
const dir = id.slice(15);
|
|
244
|
+
for (const target of await collectWatchTargets(dir)) this.addWatchFile(target);
|
|
245
|
+
return buildSkillsModule(dir, (message) => this.warn(message));
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
3
249
|
/**
|
|
4
250
|
* Vite plugin for Agents SDK projects.
|
|
5
251
|
*
|
|
@@ -8,10 +254,10 @@ import babel from "@rolldown/plugin-babel";
|
|
|
8
254
|
* Agents-specific build concerns as needed.
|
|
9
255
|
*/
|
|
10
256
|
function agents() {
|
|
11
|
-
return babel({ presets: [{
|
|
257
|
+
return [skillsImportPlugin(), babel({ presets: [{
|
|
12
258
|
preset: () => ({ plugins: [["@babel/plugin-proposal-decorators", { version: "2023-11" }]] }),
|
|
13
259
|
rolldown: { filter: { code: "@" } }
|
|
14
|
-
}] });
|
|
260
|
+
}] })];
|
|
15
261
|
}
|
|
16
262
|
//#endregion
|
|
17
263
|
export { agents as default };
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import babel from \"@rolldown/plugin-babel\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Vite plugin for Agents SDK projects.\n *\n * Currently handles TC39 decorator transforms (Oxc doesn't support them yet,\n * oxc#9170) so `@callable()` works at runtime. Will grow to cover other\n * Agents-specific build concerns as needed.\n */\nexport default function agents(): Plugin {\n return 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"],"mappings":";;;;;;;;;AAUA,SAAwB,SAAiB;CACvC,OAAO,MAAM,EACX,SAAS,CACP;EACE,eAAe,EACb,SAAS,CACP,CAAC,qCAAqC,EAAE,SAAS,UAAU,CAAC,CAC9D,EACF;EACA,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE;CACpC,CACF,EACF,CAAC;AACH"}
|
|
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\";\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 }>;\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 return {\n path: file.path,\n kind: resourceKind(file.path),\n size: file.size,\n encoding,\n mimeType: resourceMimeType(file.path),\n content:\n encoding === \"base64\" ? bytes.toString(\"base64\") : bytes.toString()\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\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\n/**\n * Vite plugin for Agents SDK projects.\n *\n * Currently handles TC39 decorator transforms (Oxc doesn't support them yet,\n * oxc#9170) so `@callable()` works at runtime. Will grow to cover other\n * Agents-specific build concerns as needed.\n */\nexport default function agents(): Plugin[] {\n return [\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":";;;;;;AAOA,MAAM,mBAAmB;AACzB,MAAM,wBAA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