@cloudflare/think 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-DO3uQ9py.js","names":[],"sources":["../src/workspace-files.ts","../src/tools/fetch.ts"],"sourcesContent":["import type { Workspace } from \"@cloudflare/computer\";\nimport type { CreateAIToolsOptions } from \"@cloudflare/computer/tools/ai-sdk\";\n\n/**\n * The filesystem methods Think uses, from `@cloudflare/computer`'s\n * `workspace.fs`.\n */\nexport type ThinkWorkspaceFilesystem = Pick<\n Workspace[\"fs\"],\n | \"readFile\"\n | \"writeFile\"\n | \"mkdir\"\n | \"rm\"\n | \"stat\"\n | \"readdir\"\n | \"find\"\n | \"grep\"\n>;\n\n/** The parts of a Workspace the `@cloudflare/computer` tools use besides `fs`. */\ntype ToolsWorkspace = CreateAIToolsOptions[\"workspace\"];\n\n/**\n * The Workspace a Think agent works in.\n *\n * A `Workspace` from `@cloudflare/computer` satisfies this, and so does the\n * client `getWorkspace(stub)` returns for a Workspace owned by another\n * Durable Object. Think reads and writes through `workspace.fs`. The\n * `@cloudflare/computer` tools also use `runtime` for `exec` and `assets`\n * for `publish` when the Workspace has them.\n *\n * @experimental The API surface may change before stabilizing.\n */\nexport type ThinkWorkspace = {\n /** The Workspace filesystem. */\n readonly fs: ThinkWorkspaceFilesystem;\n} & Partial<Pick<ToolsWorkspace, \"runtime\" | \"sessionId\" | \"assets\">>;\n\n/** One file, directory, or symlink in a Workspace. */\nexport type WorkspaceEntry = {\n /** Absolute path. */\n readonly path: string;\n /** Last path segment. */\n readonly name: string;\n /** Entry kind. */\n readonly type: \"file\" | \"directory\" | \"symlink\";\n /** Size in bytes. `0` for directories. */\n readonly size: number;\n /** Last modification time in milliseconds since the epoch. */\n readonly updatedAt: number;\n};\n\n/** Directory Computer's backends and tools treat as the working root. */\nexport const WORKSPACE_ROOT = \"/workspace\";\n\n/**\n * Resolve a path against {@link WORKSPACE_ROOT}. Absolute paths pass\n * through; relative ones, such as an extension's `notes/today.md`, land\n * under `/workspace`.\n *\n * @param path - Absolute or root-relative path.\n * @returns An absolute path.\n */\nexport function resolveWorkspacePath(path: string): string {\n if (path.startsWith(\"/\")) return path;\n const relative = path.replace(/^\\.\\//, \"\");\n return relative === \"\" || relative === \".\"\n ? WORKSPACE_ROOT\n : `${WORKSPACE_ROOT}/${relative}`;\n}\n\nconst TEXT_ENCODER = new TextEncoder();\nconst TEXT_DECODER = new TextDecoder();\n\n/**\n * Think's file operations over a {@link ThinkWorkspace}.\n *\n * Translates the Workspace's node-style filesystem into the shape Think's\n * internals use: missing files read as `null` instead of rejecting with\n * `ENOENT`, writes create their parent directories, and listings return\n * {@link WorkspaceEntry} values.\n *\n * @internal\n */\nexport class WorkspaceFiles {\n readonly #fs: ThinkWorkspaceFilesystem;\n\n /**\n * @param workspace - The Workspace to operate on.\n */\n constructor(workspace: ThinkWorkspace) {\n this.#fs = workspace.fs;\n }\n\n /**\n * Read a file as UTF-8 text.\n *\n * @param path - Absolute file path.\n * @returns The text, or `null` when the file does not exist.\n */\n async readText(path: string): Promise<string | null> {\n const bytes = await this.readBytes(path);\n return bytes === null ? null : TEXT_DECODER.decode(bytes);\n }\n\n /**\n * Read a file's bytes.\n *\n * @param path - Absolute file path.\n * @returns The bytes, or `null` when the file does not exist.\n */\n async readBytes(path: string): Promise<Uint8Array | null> {\n try {\n return await drain(await this.#fs.readFile(path));\n } catch (error) {\n if (isNotFound(error)) return null;\n throw error;\n }\n }\n\n /**\n * Write a file, creating missing parent directories.\n *\n * @param path - Absolute file path.\n * @param content - Text, written as UTF-8, or bytes.\n */\n async write(path: string, content: string | Uint8Array): Promise<void> {\n const parent = parentDirectory(path);\n if (parent !== \"/\") await this.#fs.mkdir(parent, { recursive: true });\n await this.#fs.writeFile(\n path,\n typeof content === \"string\" ? TEXT_ENCODER.encode(content) : content\n );\n }\n\n /**\n * Remove a file or directory.\n *\n * @param path - Absolute path.\n * @param options - `recursive` removes a non-empty directory; `force`\n * accepts a missing path.\n */\n async remove(\n path: string,\n options?: { recursive?: boolean; force?: boolean }\n ): Promise<void> {\n await this.#fs.rm(path, options);\n }\n\n /**\n * List a directory's entries in name order.\n *\n * @param path - Absolute directory path.\n * @param options - Page size and start.\n * @returns The entries on the requested page.\n */\n async list(\n path: string,\n options?: { limit?: number; offset?: number }\n ): Promise<WorkspaceEntry[]> {\n const entries = await this.#fs.readdir(path, options);\n return entries.map((entry) => ({\n path: joinPath(path, entry.name),\n name: entry.name,\n type: entry.isDirectory\n ? \"directory\"\n : entry.isSymbolicLink\n ? \"symlink\"\n : \"file\",\n size: entry.size,\n updatedAt: entry.mtime\n }));\n }\n}\n\nasync function drain(stream: ReadableStream<Uint8Array>): Promise<Uint8Array> {\n const parts: Uint8Array[] = [];\n let total = 0;\n for await (const part of stream) {\n parts.push(part);\n total += part.byteLength;\n }\n if (parts.length === 1 && parts[0]) return parts[0];\n const bytes = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n bytes.set(part, offset);\n offset += part.byteLength;\n }\n return bytes;\n}\n\nfunction isNotFound(error: unknown): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n );\n}\n\nfunction parentDirectory(path: string): string {\n const index = path.lastIndexOf(\"/\");\n return index <= 0 ? \"/\" : path.slice(0, index);\n}\n\nfunction joinPath(directory: string, name: string): string {\n return directory.endsWith(\"/\")\n ? `${directory}${name}`\n : `${directory}/${name}`;\n}\n","import type { JSONValue, ToolSet } from \"ai\";\nimport { tool } from \"ai\";\nimport { isPrivateOrLocalHost } from \"agents/webfetch\";\nimport { z } from \"zod\";\nimport { WorkspaceFiles, type ThinkWorkspace } from \"../workspace-files\";\n\n// ── Public types ──────────────────────────────────────────────────\n//\n// A conservative, opt-in HTTP read capability for Think agents. It is\n// deliberately read-only (GET), allowlisted, and bounded. It is NOT a\n// general-purpose HTTP client and NOT an SSRF primitive — mutations and\n// rendered-page automation live elsewhere (explicit actions, Browser Run).\n//\n// @experimental The API surface may change before stabilizing.\n\nexport type FetchResponseMode = \"text\" | \"json\" | \"auto\" | \"workspace\";\nexport type FetchRedirectPolicy = \"allowlisted\" | \"same-origin\" | \"none\";\n\nexport type FetchErrorCode =\n | \"disallowed_url\"\n | \"disallowed_redirect\"\n | \"timeout\"\n | \"aborted\"\n | \"non_2xx\"\n | \"unsupported_content_type\"\n | \"invalid_json\"\n | \"too_large\"\n | \"request_failed\";\n\nexport type FetchResult =\n | {\n ok: true;\n status: number;\n finalUrl: string;\n contentType: string;\n bytes: number;\n truncated: boolean;\n response: \"text\" | \"json\" | \"workspace\";\n body?: string;\n json?: JSONValue;\n path?: string;\n }\n | {\n ok: false;\n code: FetchErrorCode;\n status?: number;\n finalUrl?: string;\n message: string;\n };\n\nexport interface FetchToolEvent {\n tool: string;\n ok: boolean;\n requestedUrl: string;\n finalUrl?: string;\n status?: number;\n bytes?: number;\n truncated?: boolean;\n response?: FetchResponseMode;\n code?: FetchErrorCode;\n}\n\nexport interface FetchBindingTarget {\n /** The service binding / Fetcher requests are routed through. */\n binding: Fetcher;\n /** Documented purpose — surfaced in the generated tool description. */\n description?: string;\n /**\n * Allowlist for this target. Entries starting with `/` match the request\n * pathname (e.g. `/v1/docs/**`); entries starting with `http(s)://` match\n * the full canonical URL.\n */\n allowlist: string[];\n /** Fixed, server-side headers. Never settable by the model, never echoed. */\n headers?: Record<string, string>;\n /** Base URL used to resolve relative paths. Defaults to `https://binding.local`. */\n baseUrl?: string;\n}\n\nexport interface CreateFetchToolsOptions {\n /**\n * Allowlist for the generic public `fetch_url` tool. Entries are absolute\n * URL/origin/path globs (e.g. `https://developers.cloudflare.com/**`). When\n * omitted/empty, `fetch_url` is not registered.\n */\n allowlist?: string[];\n /**\n * Named binding targets. Each entry generates a `fetch_<name>` tool with the\n * binding, allowlist, and fixed headers baked in.\n */\n bindings?: Record<string, FetchBindingTarget>;\n /** Hard download cap in bytes. Default 1_000_000. */\n maxBytes?: number;\n /** Model-facing text truncation in characters. Default 24_000. */\n maxModelChars?: number;\n /** Allow large/binary bodies to spill to a workspace file. Default false. */\n spillToWorkspace?: boolean;\n /** Workspace used for `response: \"workspace\"` / spill. */\n workspace?: ThinkWorkspace;\n /** Per-request timeout in ms. Default 10_000. */\n timeoutMs?: number;\n /** Default response handling. Default `\"auto\"`. */\n response?: FetchResponseMode;\n /** Redirect policy. Default `\"allowlisted\"`. */\n followRedirects?: FetchRedirectPolicy;\n /** Header names the model may set. Default `[\"accept\", \"accept-language\", \"range\"]`. */\n modelHeaderAllowlist?: string[];\n /**\n * Default `Accept` header sent when neither the binding's fixed headers nor\n * the model already set one. Defaults to a markdown-first, weighted value so\n * content-negotiating endpoints return clean markdown/plain text/JSON instead\n * of HTML. Set to `\"\"` to send no default `Accept` header.\n */\n defaultAccept?: string;\n /** Observability hook. Fires once per fetch (success or failure/block). */\n onEvent?: (event: FetchToolEvent) => void;\n}\n\nconst DEFAULT_MAX_BYTES = 1_000_000;\nconst DEFAULT_MAX_MODEL_CHARS = 24_000;\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst DEFAULT_MODEL_HEADER_ALLOWLIST = [\"accept\", \"accept-language\", \"range\"];\n// Markdown-first, but still accepts everything (`*/*;q=0.1`) so a strict\n// content-negotiating server never answers 406.\nconst DEFAULT_ACCEPT =\n \"text/markdown, text/plain;q=0.9, application/json;q=0.8, text/html;q=0.5, */*;q=0.1\";\nconst MAX_REDIRECTS = 5;\n\ninterface ResolvedConfig {\n maxBytes: number;\n maxModelChars: number;\n spillToWorkspace: boolean;\n workspace?: ThinkWorkspace;\n timeoutMs: number;\n response: FetchResponseMode;\n followRedirects: FetchRedirectPolicy;\n modelHeaderAllowlist: Set<string>;\n defaultAccept: string;\n onEvent?: (event: FetchToolEvent) => void;\n}\n\ninterface CompiledPattern {\n scope: \"path\" | \"url\";\n re: RegExp;\n}\n\ninterface ResolvedTarget {\n kind: \"public\" | \"binding\";\n binding?: Fetcher;\n allowlist: CompiledPattern[];\n fixedHeaders: Record<string, string>;\n baseUrl: string;\n}\n\n/**\n * Create the Think fetch tools.\n *\n * Returns a generic `fetch_url` tool (when a public `allowlist` is configured)\n * plus one `fetch_<name>` tool per configured binding target. Throws when no\n * allowlist and no bindings are configured, so a misconfiguration fails loudly\n * instead of silently registering nothing.\n *\n * @example\n * ```ts\n * createFetchTools({\n * allowlist: [\"https://developers.cloudflare.com/**\"],\n * bindings: {\n * docsApi: { binding: env.DOCS_API, allowlist: [\"/v1/docs/**\"] }\n * }\n * });\n * ```\n */\nexport function createFetchTools(options: CreateFetchToolsOptions): ToolSet {\n const publicAllowlist = (options.allowlist ?? []).filter(\n (entry) => entry.length > 0\n );\n const bindings = options.bindings ?? {};\n const bindingNames = Object.keys(bindings);\n\n if (publicAllowlist.length === 0 && bindingNames.length === 0) {\n throw new Error(\n \"createFetchTools requires a non-empty `allowlist` or at least one `bindings` target.\"\n );\n }\n\n const config: ResolvedConfig = {\n maxBytes: options.maxBytes ?? DEFAULT_MAX_BYTES,\n maxModelChars: options.maxModelChars ?? DEFAULT_MAX_MODEL_CHARS,\n spillToWorkspace: options.spillToWorkspace ?? false,\n workspace: options.workspace,\n timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n response: options.response ?? \"auto\",\n followRedirects: options.followRedirects ?? \"allowlisted\",\n modelHeaderAllowlist: new Set(\n (options.modelHeaderAllowlist ?? DEFAULT_MODEL_HEADER_ALLOWLIST).map(\n (name) => name.toLowerCase()\n )\n ),\n defaultAccept: options.defaultAccept ?? DEFAULT_ACCEPT,\n onEvent: options.onEvent\n };\n\n const tools: ToolSet = {};\n\n if (publicAllowlist.length > 0) {\n const target: ResolvedTarget = {\n kind: \"public\",\n allowlist: publicAllowlist.map(compilePattern),\n fixedHeaders: {},\n baseUrl: \"\"\n };\n tools.fetch_url = tool({\n description:\n \"Fetch an allowlisted public URL over HTTP(S) (read-only GET). \" +\n \"Returns the response body as text or JSON, or spills large/binary \" +\n \"bodies to a workspace file. The URL must be on the configured \" +\n \"allowlist; disallowed or private-network URLs are rejected.\",\n inputSchema: z.object({\n url: z\n .string()\n .describe(\"Absolute http(s) URL to fetch. Must be allowlisted.\"),\n response: responseModeSchema,\n headers: headersSchema\n }),\n execute: (input: FetchUrlInput, opts) =>\n runFetch({\n toolName: \"fetch_url\",\n target,\n config,\n requested: input.url,\n responseOverride: input.response,\n modelHeaders: input.headers,\n abortSignal: opts?.abortSignal\n }),\n toModelOutput: ({ output }) => toModelOutput(output as FetchResult)\n });\n }\n\n for (const name of bindingNames) {\n const def = bindings[name];\n const toolName = `fetch_${sanitizeName(name)}`;\n const target: ResolvedTarget = {\n kind: \"binding\",\n binding: def.binding,\n allowlist: def.allowlist.map(compilePattern),\n fixedHeaders: def.headers ?? {},\n baseUrl: def.baseUrl ?? \"https://binding.local\"\n };\n const purpose = def.description ? ` ${def.description}` : \"\";\n tools[toolName] = tool({\n description:\n `Fetch a read-only resource from the \"${name}\" service binding.${purpose} ` +\n \"Provide a path (or an allowlisted absolute URL). Requests are routed \" +\n \"through the configured binding with fixed server-side headers.\",\n inputSchema: z.object({\n path: z\n .string()\n .describe(\n \"Path (e.g. /v1/docs/search) or an allowlisted absolute URL.\"\n ),\n response: responseModeSchema,\n headers: headersSchema\n }),\n execute: (input: FetchBindingInput, opts) =>\n runFetch({\n toolName,\n target,\n config,\n requested: input.path,\n responseOverride: input.response,\n modelHeaders: input.headers,\n abortSignal: opts?.abortSignal\n }),\n toModelOutput: ({ output }) => toModelOutput(output as FetchResult)\n });\n }\n\n return tools;\n}\n\nconst responseModeSchema = z\n .enum([\"text\", \"json\", \"auto\", \"workspace\"])\n .optional()\n .describe(\n \"How to handle the response body. Defaults to the configured mode.\"\n );\n\nconst headersSchema = z\n .record(z.string(), z.string())\n .optional()\n .describe(\"Optional request headers; only safe read headers are honored.\");\n\ninterface FetchUrlInput {\n url: string;\n response?: FetchResponseMode;\n headers?: Record<string, string>;\n}\n\ninterface FetchBindingInput {\n path: string;\n response?: FetchResponseMode;\n headers?: Record<string, string>;\n}\n\ninterface RunFetchArgs {\n toolName: string;\n target: ResolvedTarget;\n config: ResolvedConfig;\n requested: string;\n responseOverride?: FetchResponseMode;\n modelHeaders?: Record<string, string>;\n abortSignal?: AbortSignal;\n}\n\nasync function runFetch(args: RunFetchArgs): Promise<FetchResult> {\n const { toolName, config, requested } = args;\n const result = await runFetchInner(args);\n if (config.onEvent) {\n try {\n config.onEvent(\n result.ok\n ? {\n tool: toolName,\n ok: true,\n requestedUrl: requested,\n finalUrl: result.finalUrl,\n status: result.status,\n bytes: result.bytes,\n truncated: result.truncated,\n response: result.response\n }\n : {\n tool: toolName,\n ok: false,\n requestedUrl: requested,\n finalUrl: result.finalUrl,\n status: result.status,\n code: result.code\n }\n );\n } catch {\n // Observability must never break a tool call.\n }\n }\n return result;\n}\n\nasync function runFetchInner(args: RunFetchArgs): Promise<FetchResult> {\n const { target, config, requested, responseOverride, modelHeaders } = args;\n\n // Resolve the requested string into an absolute URL.\n const rawUrl =\n target.kind === \"binding\" && !/^https?:\\/\\//i.test(requested)\n ? resolveAgainstBase(requested, target.baseUrl)\n : requested;\n if (rawUrl === null) {\n return { ok: false, code: \"disallowed_url\", message: \"Invalid path.\" };\n }\n\n const normalized = normalizeRequestUrl(rawUrl);\n if (\"error\" in normalized) {\n return { ok: false, code: \"disallowed_url\", message: normalized.error };\n }\n const url = normalized.url;\n\n if (target.kind === \"public\" && isPrivateOrLocalHost(url.hostname)) {\n return {\n ok: false,\n code: \"disallowed_url\",\n message: `Refusing to fetch a private or local address: ${url.hostname}`\n };\n }\n\n if (!matchesAllowlist(url, target.allowlist)) {\n return {\n ok: false,\n code: \"disallowed_url\",\n message: `URL is not on the allowlist: ${url.toString()}`\n };\n }\n\n const responseMode = responseOverride ?? config.response;\n const safeModelHeaders = filterModelHeaders(\n modelHeaders,\n config.modelHeaderAllowlist\n );\n\n return executeRequest({\n target,\n config,\n initialUrl: url,\n responseMode,\n fixedHeaders: target.fixedHeaders,\n modelHeaders: safeModelHeaders,\n abortSignal: args.abortSignal\n });\n}\n\ninterface ExecuteRequestArgs {\n target: ResolvedTarget;\n config: ResolvedConfig;\n initialUrl: URL;\n responseMode: FetchResponseMode;\n fixedHeaders: Record<string, string>;\n modelHeaders: Record<string, string>;\n abortSignal?: AbortSignal;\n}\n\nasync function executeRequest(args: ExecuteRequestArgs): Promise<FetchResult> {\n const { target, config, initialUrl, responseMode } = args;\n const method = \"GET\";\n\n const controller = new AbortController();\n const onAbort = () => controller.abort();\n if (args.abortSignal) {\n if (args.abortSignal.aborted) controller.abort();\n else args.abortSignal.addEventListener(\"abort\", onAbort, { once: true });\n }\n const timer = setTimeout(() => controller.abort(), config.timeoutMs);\n\n const initialOrigin = initialUrl.origin;\n let currentUrl = initialUrl;\n let headers: Record<string, string> = applyDefaultAccept(\n mergeHeaders(args.fixedHeaders, args.modelHeaders),\n config.defaultAccept\n );\n\n try {\n for (let hop = 0; ; hop++) {\n if (hop > MAX_REDIRECTS) {\n return {\n ok: false,\n code: \"request_failed\",\n finalUrl: currentUrl.toString(),\n message: \"Too many redirects.\"\n };\n }\n\n const res = await doFetch(\n target,\n currentUrl,\n method,\n headers,\n controller.signal\n );\n\n if (isRedirect(res.status)) {\n const location = res.headers.get(\"location\");\n if (location) {\n const redirectOutcome = resolveRedirect({\n target,\n config,\n location,\n currentUrl,\n initialOrigin\n });\n if (\"error\" in redirectOutcome) {\n discardBody(res);\n return {\n ok: false,\n code: \"disallowed_redirect\",\n status: res.status,\n finalUrl: currentUrl.toString(),\n message: redirectOutcome.error\n };\n }\n // We're following the redirect; drop the 3xx body before the next hop.\n discardBody(res);\n // Strip credentials/headers on cross-origin hops, but keep a safe\n // default Accept so the next hop still negotiates for clean content.\n if (redirectOutcome.url.origin !== currentUrl.origin) {\n headers = applyDefaultAccept({}, config.defaultAccept);\n }\n currentUrl = redirectOutcome.url;\n continue;\n }\n }\n\n if (res.status < 200 || res.status >= 300) {\n discardBody(res);\n return {\n ok: false,\n code: \"non_2xx\",\n status: res.status,\n finalUrl: currentUrl.toString(),\n message: `HTTP ${res.status}`\n };\n }\n\n return finalizeResponse({\n res,\n config,\n responseMode,\n finalUrl: currentUrl.toString()\n });\n }\n } catch (error) {\n if (controller.signal.aborted) {\n const aborted = args.abortSignal?.aborted ?? false;\n return {\n ok: false,\n code: aborted ? \"aborted\" : \"timeout\",\n finalUrl: currentUrl.toString(),\n message: aborted ? \"Request aborted.\" : \"Request timed out.\"\n };\n }\n return {\n ok: false,\n code: \"request_failed\",\n finalUrl: currentUrl.toString(),\n message: errorMessage(error)\n };\n } finally {\n clearTimeout(timer);\n args.abortSignal?.removeEventListener(\"abort\", onAbort);\n }\n}\n\n/**\n * Cancel a response body we won't read (non-2xx, blocked/followed redirects)\n * so the underlying connection isn't left dangling.\n */\nfunction discardBody(res: Response): void {\n res.body?.cancel().catch(() => {});\n}\n\nfunction doFetch(\n target: ResolvedTarget,\n url: URL,\n method: string,\n headers: Record<string, string>,\n signal: AbortSignal\n): Promise<Response> {\n const init: RequestInit = {\n method,\n headers,\n redirect: \"manual\",\n signal\n };\n if (target.kind === \"binding\" && target.binding) {\n return target.binding.fetch(url.toString(), init);\n }\n return fetch(url.toString(), init);\n}\n\ninterface ResolveRedirectArgs {\n target: ResolvedTarget;\n config: ResolvedConfig;\n location: string;\n currentUrl: URL;\n initialOrigin: string;\n}\n\nfunction resolveRedirect(\n args: ResolveRedirectArgs\n): { url: URL } | { error: string } {\n const { target, config, location, currentUrl, initialOrigin } = args;\n if (config.followRedirects === \"none\") {\n return { error: \"Redirects are disabled.\" };\n }\n\n let next: URL;\n try {\n next = new URL(location, currentUrl);\n } catch {\n return { error: \"Invalid redirect target.\" };\n }\n if (next.protocol !== \"http:\" && next.protocol !== \"https:\") {\n return { error: \"Redirect to a non-http(s) URL is not allowed.\" };\n }\n if (next.username || next.password) {\n return { error: \"Redirect to a URL with credentials is not allowed.\" };\n }\n\n // Bindings are a transport, not a generic client: never redirect off-origin.\n if (target.kind === \"binding\" && next.origin !== currentUrl.origin) {\n return { error: \"Cross-origin redirects are not allowed for bindings.\" };\n }\n\n if (target.kind === \"public\" && isPrivateOrLocalHost(next.hostname)) {\n return {\n error: `Redirect to a private or local address: ${next.hostname}`\n };\n }\n\n if (config.followRedirects === \"same-origin\") {\n if (next.origin !== initialOrigin) {\n return { error: \"Redirect escaped the original origin.\" };\n }\n } else if (config.followRedirects === \"allowlisted\") {\n if (!matchesAllowlist(next, target.allowlist)) {\n return { error: \"Redirect target is not on the allowlist.\" };\n }\n }\n\n return { url: next };\n}\n\ninterface FinalizeArgs {\n res: Response;\n config: ResolvedConfig;\n responseMode: FetchResponseMode;\n finalUrl: string;\n}\n\nasync function finalizeResponse(args: FinalizeArgs): Promise<FetchResult> {\n const { res, config, responseMode, finalUrl } = args;\n const contentType = (res.headers.get(\"content-type\") ?? \"\")\n .split(\";\")[0]\n .trim()\n .toLowerCase();\n\n const { bytes, capped } = await readCapped(res, config.maxBytes);\n const mode = resolveResponseMode(responseMode, contentType, config);\n\n // An empty body (204, HEAD-like, or a content-less 2xx) is a successful\n // empty-text read, not an unsupported content type.\n if (bytes.byteLength === 0 && mode !== \"workspace\") {\n return {\n ok: true,\n status: res.status,\n finalUrl,\n contentType,\n bytes: 0,\n truncated: false,\n response: \"text\",\n body: \"\"\n };\n }\n\n if (mode === \"unsupported\") {\n return {\n ok: false,\n code: \"unsupported_content_type\",\n finalUrl,\n message: `Unsupported content type: ${contentType || \"unknown\"}. Use response: \"workspace\" to store it.`\n };\n }\n\n if (mode === \"workspace\") {\n return spillToWorkspace({\n bytes,\n capped,\n contentType,\n finalUrl,\n status: res.status,\n config\n });\n }\n\n const text = new TextDecoder().decode(bytes);\n\n if (mode === \"json\") {\n if (capped) {\n return {\n ok: false,\n code: \"too_large\",\n finalUrl,\n message: `Response exceeded the ${config.maxBytes} byte cap and cannot be parsed as JSON. Use response: \"workspace\".`\n };\n }\n try {\n const json = JSON.parse(text) as JSONValue;\n return {\n ok: true,\n status: res.status,\n finalUrl,\n contentType,\n bytes: bytes.byteLength,\n truncated: false,\n response: \"json\",\n json\n };\n } catch {\n return {\n ok: false,\n code: \"invalid_json\",\n finalUrl,\n message: \"Response body is not valid JSON.\"\n };\n }\n }\n\n const { value, truncated: textTruncated } = truncateText(\n text,\n config.maxModelChars\n );\n return {\n ok: true,\n status: res.status,\n finalUrl,\n contentType,\n bytes: bytes.byteLength,\n truncated: capped || textTruncated,\n response: \"text\",\n body: value\n };\n}\n\ninterface SpillArgs {\n bytes: Uint8Array;\n capped: boolean;\n contentType: string;\n finalUrl: string;\n status: number;\n config: ResolvedConfig;\n}\n\nasync function spillToWorkspace(args: SpillArgs): Promise<FetchResult> {\n const { bytes, capped, contentType, finalUrl, status, config } = args;\n const ws = config.workspace;\n if (!ws) {\n return {\n ok: false,\n code: \"unsupported_content_type\",\n finalUrl,\n message:\n 'response: \"workspace\" requires a workspace, but none is configured.'\n };\n }\n\n const path = `/workspace/fetched/${Date.now()}-${randomToken()}.${extensionFor(contentType)}`;\n try {\n await new WorkspaceFiles(ws).write(path, bytes);\n } catch (error) {\n return {\n ok: false,\n code: \"request_failed\",\n finalUrl,\n message: `Failed to write workspace file: ${errorMessage(error)}`\n };\n }\n\n return {\n ok: true,\n status,\n finalUrl,\n contentType,\n bytes: bytes.byteLength,\n truncated: capped,\n response: \"workspace\",\n path\n };\n}\n\nasync function readCapped(\n res: Response,\n maxBytes: number\n): Promise<{ bytes: Uint8Array; capped: boolean }> {\n const body = res.body;\n if (!body) return { bytes: new Uint8Array(0), capped: false };\n\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n let capped = false;\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n if (!value) continue;\n if (total + value.byteLength > maxBytes) {\n const remaining = Math.max(0, maxBytes - total);\n if (remaining > 0) chunks.push(value.slice(0, remaining));\n total += remaining;\n capped = true;\n await reader.cancel().catch(() => {});\n break;\n }\n chunks.push(value);\n total += value.byteLength;\n }\n\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return { bytes: out, capped };\n}\n\ntype ResolvedResponseMode = \"text\" | \"json\" | \"workspace\" | \"unsupported\";\n\nfunction resolveResponseMode(\n mode: FetchResponseMode,\n contentType: string,\n config: ResolvedConfig\n): ResolvedResponseMode {\n if (mode === \"text\") return \"text\";\n if (mode === \"json\") return \"json\";\n if (mode === \"workspace\") return \"workspace\";\n\n // auto\n if (isJsonContentType(contentType)) return \"json\";\n if (isTextualContentType(contentType)) return \"text\";\n if (config.spillToWorkspace && config.workspace) return \"workspace\";\n return \"unsupported\";\n}\n\n// ── Allowlist + URL helpers ───────────────────────────────────────\n\nfunction normalizeRequestUrl(raw: string): { url: URL } | { error: string } {\n let url: URL;\n try {\n url = new URL(raw);\n } catch {\n return { error: \"Invalid URL.\" };\n }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n return { error: \"Only http(s) URLs are allowed.\" };\n }\n if (url.username || url.password) {\n return { error: \"URLs with embedded credentials are not allowed.\" };\n }\n return { url };\n}\n\nfunction resolveAgainstBase(pathOrUrl: string, baseUrl: string): string | null {\n try {\n return new URL(pathOrUrl, baseUrl).toString();\n } catch {\n return null;\n }\n}\n\n/**\n * A bare origin (`https://example.com`, no path) is treated as the origin and\n * everything under it, since the canonical URL always has at least a `/` path.\n * Patterns with an explicit path are matched literally unless they include\n * globs.\n */\nfunction normalizeAllowlistPattern(pattern: string): string {\n if (/^https?:\\/\\/[^/]+$/i.test(pattern)) return `${pattern}/**`;\n return pattern;\n}\n\n/**\n * Compile an allowlist pattern once at config time so we don't rebuild a\n * `RegExp` on every request. Path-only patterns (`/v1/**`) match against the\n * URL pathname; everything else matches against the canonical origin+path.\n */\nfunction compilePattern(pattern: string): CompiledPattern {\n const normalized = normalizeAllowlistPattern(pattern);\n return {\n scope: normalized.startsWith(\"/\") ? \"path\" : \"url\",\n re: globToRegExp(normalized)\n };\n}\n\nfunction canonicalForMatch(url: URL): string {\n const host = url.hostname.replace(/\\.$/, \"\");\n const port = url.port ? `:${url.port}` : \"\";\n return `${url.protocol}//${host}${port}${url.pathname}`;\n}\n\nfunction matchesAllowlist(url: URL, patterns: CompiledPattern[]): boolean {\n const canonical = canonicalForMatch(url);\n for (const pattern of patterns) {\n const subject = pattern.scope === \"path\" ? url.pathname : canonical;\n if (pattern.re.test(subject)) return true;\n }\n return false;\n}\n\nfunction globToRegExp(glob: string): RegExp {\n let re = \"\";\n for (let i = 0; i < glob.length; i++) {\n const c = glob[i];\n if (c === \"*\") {\n if (glob[i + 1] === \"*\") {\n re += \".*\";\n i++;\n } else {\n re += \"[^/]*\";\n }\n } else if (\"\\\\^$.|?+()[]{}\".includes(c)) {\n re += `\\\\${c}`;\n } else {\n re += c;\n }\n }\n return new RegExp(`^${re}$`);\n}\n\n/**\n * Merge fixed (server-side) and model headers into a lowercased-key map. Fixed\n * headers win, so the model can never override a binding's configured header,\n * and case-only duplicates (`Accept` vs `accept`) can't both be sent.\n */\nfunction mergeHeaders(\n fixed: Record<string, string>,\n model: Record<string, string>\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [name, value] of Object.entries(model)) {\n out[name.toLowerCase()] = value;\n }\n for (const [name, value] of Object.entries(fixed)) {\n out[name.toLowerCase()] = value;\n }\n return out;\n}\n\nfunction applyDefaultAccept(\n headers: Record<string, string>,\n defaultAccept: string\n): Record<string, string> {\n if (!defaultAccept) return headers;\n const hasAccept = Object.keys(headers).some(\n (name) => name.toLowerCase() === \"accept\"\n );\n if (hasAccept) return headers;\n return { ...headers, accept: defaultAccept };\n}\n\nfunction filterModelHeaders(\n headers: Record<string, string> | undefined,\n allowlist: Set<string>\n): Record<string, string> {\n if (!headers) return {};\n const out: Record<string, string> = {};\n for (const [name, value] of Object.entries(headers)) {\n if (allowlist.has(name.toLowerCase())) out[name] = value;\n }\n return out;\n}\n\n// ── Content-type helpers ──────────────────────────────────────────\n\nfunction isJsonContentType(contentType: string): boolean {\n return (\n contentType === \"application/json\" ||\n contentType.endsWith(\"+json\") ||\n contentType === \"text/json\"\n );\n}\n\nfunction isTextualContentType(contentType: string): boolean {\n if (contentType.length === 0) return false;\n if (contentType.startsWith(\"text/\")) return true;\n if (isJsonContentType(contentType)) return true;\n return (\n contentType === \"application/xml\" ||\n contentType === \"application/javascript\" ||\n contentType === \"application/x-www-form-urlencoded\"\n );\n}\n\nfunction extensionFor(contentType: string): string {\n if (isJsonContentType(contentType)) return \"json\";\n if (contentType === \"text/html\") return \"html\";\n if (contentType.includes(\"xml\")) return \"xml\";\n if (contentType.startsWith(\"text/\")) return \"txt\";\n if (contentType === \"application/pdf\") return \"pdf\";\n if (contentType.startsWith(\"image/\")) {\n return contentType.slice(\"image/\".length).split(\"+\")[0] || \"img\";\n }\n return \"bin\";\n}\n\nfunction truncateText(\n value: string,\n maxChars: number\n): { value: string; truncated: boolean } {\n if (value.length <= maxChars) return { value, truncated: false };\n return {\n value: `${value.slice(0, maxChars)}\\n... (truncated ${value.length - maxChars} chars)`,\n truncated: true\n };\n}\n\nfunction isRedirect(status: number): boolean {\n return (\n status === 301 ||\n status === 302 ||\n status === 303 ||\n status === 307 ||\n status === 308\n );\n}\n\nfunction sanitizeName(name: string): string {\n return name.replace(/[^a-zA-Z0-9_]/g, \"_\");\n}\n\nfunction randomToken(): string {\n return Math.random().toString(36).slice(2, 10);\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n// ── Model output mapping ──────────────────────────────────────────\n\nfunction toModelOutput(\n output: FetchResult\n):\n | { type: \"text\"; value: string }\n | { type: \"error-text\"; value: string }\n | { type: \"json\"; value: JSONValue } {\n if (!output.ok) {\n return { type: \"error-text\", value: output.message };\n }\n if (output.response === \"json\") {\n return {\n type: \"json\",\n value: {\n status: output.status,\n finalUrl: output.finalUrl,\n contentType: output.contentType,\n json: output.json ?? null\n }\n };\n }\n if (output.response === \"workspace\") {\n return {\n type: \"text\",\n value:\n `Fetched ${output.finalUrl} (${output.contentType || \"unknown\"}, ` +\n `${output.bytes} bytes${output.truncated ? \", truncated\" : \"\"}) ` +\n `and saved to ${output.path}.`\n };\n }\n const prefix = `Fetched ${output.finalUrl} (HTTP ${output.status}, ${output.contentType || \"unknown\"}${output.truncated ? \", truncated\" : \"\"}):\\n\\n`;\n return { type: \"text\", value: prefix + (output.body ?? \"\") };\n}\n"],"mappings":";;;;;;AAqDA,MAAa,iBAAiB;;;;;;;;;AAU9B,SAAgB,qBAAqB,MAAsB;CACzD,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO;CACjC,MAAM,WAAW,KAAK,QAAQ,SAAS,EAAE;CACzC,OAAO,aAAa,MAAM,aAAa,MACnC,iBACA,GAAG,eAAe,GAAG;AAC3B;AAEA,MAAM,eAAe,IAAI,YAAY;AACrC,MAAM,eAAe,IAAI,YAAY;;;;;;;;;;;;AAYrC,IAAa,iBAAb,MAA4B;;;;CAM1B,YAAY,WAA2B;;EACrC,uBAAA,KAAA,MAAW,UAAU,EAAA;CACvB;;;;;;;CAQA,MAAM,SAAS,MAAsC;EACnD,MAAM,QAAQ,MAAM,KAAK,UAAU,IAAI;EACvC,OAAO,UAAU,OAAO,OAAO,aAAa,OAAO,KAAK;CAC1D;;;;;;;CAQA,MAAM,UAAU,MAA0C;EACxD,IAAI;GACF,OAAO,MAAM,MAAM,MAAA,uBAAA,KAAM,IAAA,CAAA,CAAS,SAAS,IAAI,CAAC;EAClD,SAAS,OAAO;GACd,IAAI,WAAW,KAAK,GAAG,OAAO;GAC9B,MAAM;EACR;CACF;;;;;;;CAQA,MAAM,MAAM,MAAc,SAA6C;EACrE,MAAM,SAAS,gBAAgB,IAAI;EACnC,IAAI,WAAW,KAAK,MAAA,uBAAA,KAAM,IAAA,CAAA,CAAS,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;EACpE,MAAA,uBAAA,KAAM,IAAA,CAA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,MAAM;EAAc,OAAO,OAAO;CAAQ;CAErD,IAAI,OAAO,aAAa,QACtB,OAAO;EACL,MAAM;EACN,OAAO;GACL,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,aAAa,OAAO;GACpB,MAAM,OAAO,QAAQ;EACvB;CACF;CAEF,IAAI,OAAO,aAAa,aACtB,OAAO;EACL,MAAM;EACN,OACE,WAAW,OAAO,SAAS,IAAI,OAAO,eAAe,UAAU,IAC5D,OAAO,MAAM,QAAQ,OAAO,YAAY,gBAAgB,GAAG,iBAC9C,OAAO,KAAK;CAChC;CAGF,OAAO;EAAE,MAAM;EAAQ,OAAO,WADJ,OAAO,SAAS,SAAS,OAAO,OAAO,IAAI,OAAO,eAAe,YAAY,OAAO,YAAY,gBAAgB,GAAG,WACrG,OAAO,QAAQ;CAAI;AAC7D"}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  i as ExtensionManifest,
3
3
  t as ExtensionManager
4
- } from "./manager-dOcdCX4u.js";
4
+ } from "./manager-rze95KCk.js";
5
5
  import {
6
6
  l as ThinkWorkspace,
7
7
  t as CreateFetchToolsOptions
8
- } from "./fetch-C7s1mpgg.js";
8
+ } from "./fetch-CU2fC7O6.js";
9
9
  import {
10
10
  FlexibleSchema,
11
11
  GenerateTextOnStepFinishCallback,
@@ -30,15 +30,65 @@ import {
30
30
  UIMessage,
31
31
  streamText
32
32
  } from "ai";
33
- import * as skills from "agents/skills";
34
33
  import {
34
+ DEFAULT_WORKSPACE_SKILLS_ROOT,
35
+ InvalidSkill,
36
+ InvalidSkillResourcePathError,
37
+ ListedSkill,
38
+ LoadSkillCatalogOptions,
39
+ ParseSkillOptions,
40
+ R2SkillSourceOptions,
41
+ Skill,
42
+ Skill as Skill$1,
43
+ SkillCatalog,
44
+ SkillCatalog as SkillCatalog$1,
45
+ SkillCatalogEntry,
46
+ SkillCatalogResource,
47
+ SkillDiagnostic,
48
+ SkillListing,
49
+ SkillManifest,
50
+ SkillManifestEntry,
51
+ SkillManifestResource,
52
+ SkillName,
53
+ SkillParseError,
54
+ SkillParseErrorCode,
55
+ SkillParseResult,
56
+ SkillResource,
57
+ SkillResourceError,
58
+ SkillResourceInfo,
59
+ SkillResourceKind,
60
+ SkillResourceNotFoundError,
61
+ SkillResourcePath,
62
+ SkillResult,
35
63
  SkillRunContext,
64
+ SkillRunContext as SkillRunContext$1,
65
+ SkillScriptContext,
66
+ SkillScriptFile,
67
+ SkillScriptRequest,
36
68
  SkillScriptRunner,
69
+ SkillScriptRunner as SkillScriptRunner$1,
70
+ SkillScriptWorkspace,
37
71
  SkillSource,
38
72
  SkillSource as SkillSource$1,
39
- SkillWorkspaceSeedOptions,
40
- SkillWorkspaceSeedOptions as SkillWorkspaceSeedOptions$1
73
+ SkillSource as SkillSource$2,
74
+ SkillSourceError,
75
+ SkillWorkspace,
76
+ UnknownSkillError,
77
+ WorkspaceSkillSourceOptions,
78
+ formatSkill,
79
+ formatSkillDiagnostic as formatSkillDiagnostic$1,
80
+ fromManifest,
81
+ isModelInvocable,
82
+ loadSkillCatalog as loadSkillCatalog$1,
83
+ manifest,
84
+ parseSkill,
85
+ parseSkillName,
86
+ parseSkillResourcePath,
87
+ r2,
88
+ renderSkillResource,
89
+ workspace
41
90
  } from "agents/skills";
91
+ import { WorkerSkillScriptRunnerOptions, runner } from "agents/skills/runner";
42
92
  import {
43
93
  Agent,
44
94
  AgentToolLifecycleResult,
@@ -118,6 +168,64 @@ import { ChatSdkStateAdapterOptions, ChatSdkStateAgent } from "agents/chat-sdk";
118
168
  import { RpcTarget } from "cloudflare:workers";
119
169
  import { Streams } from "agents/streams";
120
170
 
171
+ //#region src/skills.d.ts
172
+ declare namespace skills_d_exports {
173
+ export {
174
+ DEFAULT_WORKSPACE_SKILLS_ROOT,
175
+ InvalidSkill,
176
+ InvalidSkillResourcePathError,
177
+ ListedSkill,
178
+ LoadSkillCatalogOptions,
179
+ ParseSkillOptions,
180
+ R2SkillSourceOptions,
181
+ Skill$1 as Skill,
182
+ SkillCatalog$1 as SkillCatalog,
183
+ SkillCatalogEntry,
184
+ SkillCatalogResource,
185
+ SkillDiagnostic,
186
+ SkillListing,
187
+ SkillManifest,
188
+ SkillManifestEntry,
189
+ SkillManifestResource,
190
+ SkillName,
191
+ SkillParseError,
192
+ SkillParseErrorCode,
193
+ SkillParseResult,
194
+ SkillResource,
195
+ SkillResourceError,
196
+ SkillResourceInfo,
197
+ SkillResourceKind,
198
+ SkillResourceNotFoundError,
199
+ SkillResourcePath,
200
+ SkillResult,
201
+ SkillRunContext$1 as SkillRunContext,
202
+ SkillScriptContext,
203
+ SkillScriptFile,
204
+ SkillScriptRequest,
205
+ SkillScriptRunner$1 as SkillScriptRunner,
206
+ SkillScriptWorkspace,
207
+ SkillSource$2 as SkillSource,
208
+ SkillSourceError,
209
+ SkillWorkspace,
210
+ UnknownSkillError,
211
+ WorkerSkillScriptRunnerOptions,
212
+ WorkspaceSkillSourceOptions,
213
+ formatSkill,
214
+ formatSkillDiagnostic$1 as formatSkillDiagnostic,
215
+ fromManifest,
216
+ isModelInvocable,
217
+ loadSkillCatalog$1 as loadSkillCatalog,
218
+ manifest,
219
+ parseSkill,
220
+ parseSkillName,
221
+ parseSkillResourcePath,
222
+ r2,
223
+ renderSkillResource,
224
+ runner,
225
+ workspace
226
+ };
227
+ }
228
+ //#endregion
121
229
  //#region src/session.d.ts
122
230
  /** Options for a block declared through `withContext()` / `addContext()`. */
123
231
  type SessionContextOptions = Omit<ContextConfig, "label">;
@@ -1005,7 +1113,7 @@ interface TurnInput {
1005
1113
  * Contains everything Think assembled — the hook can inspect and override.
1006
1114
  */
1007
1115
  interface TurnContext {
1008
- /** Assembled system prompt (from context blocks or getSystemPrompt fallback). */
1116
+ /** Assembled system prompt: an overridden `getSystemPrompt()`, then context blocks. */
1009
1117
  system: string;
1010
1118
  /**
1011
1119
  * Assembled model messages (truncated, pruned). When a `whenChanged:
@@ -1630,15 +1738,8 @@ declare class Think<
1630
1738
  storeMessages: boolean;
1631
1739
  /** Store tool input/output on `execute_tool` spans. */
1632
1740
  storeTools: boolean;
1633
- /**
1634
- * Project `getSkills()` into the active workspace so the agent can read
1635
- * and edit skills as files under `/workspace/.agents/skills`.
1636
- * Existing edits are preserved. Off by default: skills load from their
1637
- * sources and nothing is written to the Workspace, as before. Set `{}` to
1638
- * project with the defaults.
1639
- */
1640
- skillWorkspace: false | SkillWorkspaceSeedOptions;
1641
- private _skillRegistry;
1741
+ private _skillSources;
1742
+ private _skillCatalog;
1642
1743
  private _loggedSkillWarnings;
1643
1744
  private _loggedProtocolWarnings;
1644
1745
  /**
@@ -2330,11 +2431,21 @@ declare class Think<
2330
2431
  */
2331
2432
  resolveModel(model?: ThinkModel): LanguageModel;
2332
2433
  /**
2333
- * Return the fallback system prompt for the assistant.
2334
- * Ignored when context blocks are configured. Use `configureContext()` for
2335
- * always-on instructions that should coexist with context blocks or skills.
2434
+ * Return the instructions at the top of the system prompt.
2435
+ *
2436
+ * An override always comes first, followed by the context blocks from
2437
+ * `configureContext()`, skills, and extensions. Think's default text is
2438
+ * used only when the agent overrides nothing and has no context blocks.
2336
2439
  */
2337
2440
  getSystemPrompt(): string;
2441
+ /**
2442
+ * The base system prompt for a turn: an overridden `getSystemPrompt()`,
2443
+ * then the frozen context blocks. Think's default `getSystemPrompt()` is
2444
+ * only a fallback for an agent with no context blocks.
2445
+ *
2446
+ * @internal Exposed to subclasses for tests.
2447
+ */
2448
+ protected _buildBaseSystemPrompt(): Promise<string>;
2338
2449
  /** Return the tools available to the assistant. */
2339
2450
  getTools(): ToolSet;
2340
2451
  /** Return action descriptors compiled into tools for the assistant. */
@@ -2751,36 +2862,40 @@ declare class Think<
2751
2862
  /**
2752
2863
  * Return Agent Skills sources for this Think agent.
2753
2864
  *
2754
- * Bundled skills are typically imported with the Agents Vite plugin:
2865
+ * A skill is a directory with a `SKILL.md` file, as defined by
2866
+ * https://agentskills.io. Keep skills as files in the agent's Workspace
2867
+ * and they become available as soon as they are written:
2755
2868
  *
2756
2869
  * ```typescript
2757
- * import productSkills from "agents:skills"; // -> ./skills next to this file
2870
+ * getSkills() {
2871
+ * return [skills.workspace(this.workspace)]; // /workspace/.agents/skills
2872
+ * }
2758
2873
  * ```
2759
2874
  *
2760
- * Sources are applied in order; the first source to register a skill name
2761
- * wins, and later collisions are skipped with a logged warning.
2875
+ * `skills.r2()` reads skills from an R2 bucket and `skills.manifest()`
2876
+ * defines them in code. Sources are applied in order; the first source to
2877
+ * provide a skill name wins, and later collisions are skipped with a
2878
+ * logged warning. Sources are listed again before every turn.
2762
2879
  */
2763
2880
  getSkills(): SkillSource[] | Promise<SkillSource[]>;
2764
2881
  private _initializeSkills;
2765
- private _configureSkillWorkspace;
2882
+ /** Load the catalog from every source and log new diagnostics. */
2883
+ private _loadSkillCatalog;
2766
2884
  /**
2767
- * Log registry diagnostics (duplicate names, sources that failed to list),
2768
- * deduped by message so a new collision after a deploy still surfaces while
2769
- * the same warning is not repeated on every turn.
2885
+ * Log a skills warning once per object lifetime, so a new problem after a
2886
+ * deploy still surfaces while the same warning is not repeated every turn.
2770
2887
  */
2771
- private _logSkillWarnings;
2888
+ private _warnSkillsOnce;
2772
2889
  /**
2773
2890
  * Return an optional runner that enables the `run_skill_script` tool.
2774
2891
  *
2892
+ * Prefer keeping skills in the Workspace and letting the agent run their
2893
+ * scripts with its shell tools.
2894
+ *
2775
2895
  * @experimental Skill script execution is experimental and may change
2776
2896
  * before stabilizing.
2777
2897
  */
2778
2898
  getSkillScriptRunner(): SkillScriptRunner | null;
2779
- /**
2780
- * The persisted skills fingerprint, read from `think_config` once per
2781
- * object lifetime; `null` once read and absent. Saves the per-turn probe.
2782
- */
2783
- private _skillsFingerprint;
2784
2899
  private _refreshSkillsIfChanged;
2785
2900
  /**
2786
2901
  * Return sandboxed extension configurations. Defines load order,
@@ -5566,31 +5681,31 @@ export {
5566
5681
  MediaEvictionConfig as $n,
5567
5682
  RunTurnWait as $t,
5568
5683
  ERROR_MESSENGER_RESPONSE as A,
5569
- TurnConfig as An,
5684
+ ToolCallResultContext as An,
5570
5685
  ChunkContext as At,
5571
5686
  defaultDeliveryTag as B,
5572
- defaultContextOverflowClassifier as Bn,
5687
+ action as Bn,
5573
5688
  MessageMetadataCallback as Bt,
5574
5689
  toMessengerAuthor as C,
5575
- ThinkSubmissionInspection as Cn,
5690
+ ThinkScheduledTasks as Cn,
5576
5691
  ChatRecoveryConfig$1 as Ct,
5577
5692
  DeliveryKind as D,
5578
- ToolCallContext as Dn,
5693
+ ThinkWallClockSchedule as Dn,
5579
5694
  ChatRecoveryProgressContext as Dt,
5580
5695
  DeliverMessengerReplyOptions as E,
5581
- ThinkWallClockSchedule as En,
5696
+ ThinkTime as En,
5582
5697
  ChatRecoveryOptions$1 as Et,
5583
5698
  MessengerDeliveryTarget as F,
5584
- TurnTrigger as Fn,
5699
+ TurnResult as Fn,
5585
5700
  ExtensionConfig as Ft,
5586
5701
  parseMessengerReplySnapshot as G,
5587
5702
  ChannelDefinition as Gn,
5588
5703
  PrepareStepResult$1 as Gt,
5589
5704
  messengerReplyFailureMode as H,
5590
- skills as Hn,
5705
+ isAction as Hn,
5591
5706
  PendingApproval as Ht,
5592
5707
  MessengerReplySnapshot as I,
5593
- TypedToolCall$1 as In,
5708
+ TurnTrigger as In,
5594
5709
  FiberContext$1 as It,
5595
5710
  MessengerAttachment as J,
5596
5711
  ChannelIngress as Jn,
@@ -5599,37 +5714,37 @@ export {
5599
5714
  ChannelDeliveryPolicy as Kn,
5600
5715
  RejectExecutionOptions as Kt,
5601
5716
  MessengerReplyStage as L,
5602
- TypedToolResult as Ln,
5717
+ TypedToolCall$1 as Ln,
5603
5718
  FiberRecoveryContext$1 as Lt,
5604
5719
  MESSENGER_REPLY_FIBER_NAME as M,
5605
- TurnInput as Mn,
5720
+ TurnContext as Mn,
5606
5721
  ContextOverflowConfig as Mt,
5607
5722
  MessengerDeliveryPolicy as N,
5608
- TurnInputMessages as Nn,
5723
+ TurnInput as Nn,
5609
5724
  DeleteSubmissionsOptions as Nt,
5610
5725
  DeliveryTag as O,
5611
- ToolCallDecision as On,
5726
+ ToolCallContext as On,
5612
5727
  ChatResponseResult$1 as Ot,
5613
5728
  MessengerDeliverySurface as P,
5614
- TurnResult as Pn,
5729
+ TurnInputMessages as Pn,
5615
5730
  DeliverNoticeOptions as Pt,
5616
5731
  MessengerEvent as Q,
5617
5732
  messengerChannel as Qn,
5618
5733
  RunTurnSubmit as Qt,
5619
5734
  TextStreamCallback as R,
5620
- WaitForSubmissionOptions as Rn,
5735
+ TypedToolResult as Rn,
5621
5736
  ListSubmissionsOptions as Rt,
5622
5737
  toMessengerAttachment as S,
5623
- ThinkScheduledTasks as Sn,
5738
+ ThinkScheduledTaskSchedule as Sn,
5624
5739
  ChatOptions as St,
5625
5740
  toMessengerThread as T,
5626
- ThinkTime as Tn,
5741
+ ThinkSubmissionStatus as Tn,
5627
5742
  ChatRecoveryExhaustedContext as Tt,
5628
5743
  messengerReplyRecoveryMode as U,
5629
5744
  ChannelCapabilities as Un,
5630
5745
  PrepareStepContext as Ut,
5631
5746
  deliverMessengerReply as V,
5632
- isAction as Vn,
5747
+ defaultContextOverflowClassifier as Vn,
5633
5748
  OnStartDegradation as Vt,
5634
5749
  messengerReplySnapshot as W,
5635
5750
  ChannelContext as Wn,
@@ -5644,88 +5759,89 @@ export {
5644
5759
  ThinkChannels as Zn,
5645
5760
  RunTurnStream as Zt,
5646
5761
  defaultChatSdkEvent as _,
5647
- ThinkModel as _n,
5762
+ ThinkIntervalSchedule as _n,
5648
5763
  AddMessagesOptions as _t,
5649
5764
  MessengerConversationMode as a,
5650
- SkillWorkspaceSeedOptions$1 as an,
5765
+ SkillRunContext as an,
5651
5766
  toMessengerUserMessage as at,
5652
5767
  normalizeMessengers as b,
5653
- ThinkScheduledTaskContext as bn,
5768
+ ThinkScheduledTask as bn,
5654
5769
  ChatErrorContext as bt,
5655
5770
  MessengerDefinition as c,
5656
- StepResult as cn,
5771
+ StepContext as cn,
5657
5772
  ActionApprovalPolicy as ct,
5658
5773
  MessengerThinkTarget as d,
5659
- StreamableResult as dn,
5774
+ StreamCallback as dn,
5660
5775
  ActionConfig as dt,
5661
5776
  SaveMessagesOptions$1 as en,
5662
5777
  CompactAfterOptions as er,
5663
5778
  MessengerMessage as et,
5664
5779
  NormalizedMessengerDefinition as f,
5665
- SubmitMessagesOptions as fn,
5780
+ StreamableResult as fn,
5666
5781
  ActionContext as ft,
5667
5782
  chatSdkMessenger as g,
5668
- ThinkIntervalSchedule as gn,
5783
+ Think as gn,
5669
5784
  ActiveTurn as gt,
5670
5785
  ThinkMessengers as h,
5671
- Think as hn,
5786
+ TextStreamPart$1 as hn,
5672
5787
  ActionPermissionSpec as ht,
5673
5788
  MessengerConcurrency as i,
5674
- SkillSource$1 as in,
5789
+ SkillCatalog as in,
5790
+ skills_d_exports as ir,
5675
5791
  serializableMessengerEvent as it,
5676
5792
  INTERRUPTED_MESSENGER_RESPONSE as j,
5677
- TurnContext as jn,
5793
+ TurnConfig as jn,
5678
5794
  ChunkPart as jt,
5679
5795
  EMPTY_MESSENGER_RESPONSE as k,
5680
- ToolCallResultContext as kn,
5796
+ ToolCallDecision as kn,
5681
5797
  ChatStartEvent as kt,
5682
5798
  MessengerRespondTo as l,
5683
- StopCondition$1 as ln,
5799
+ StepResult as ln,
5684
5800
  ActionAuthorizationContext as lt,
5685
5801
  ThinkMessengerStateAgent as m,
5686
- TextStreamPart$1 as mn,
5802
+ SubmitMessagesResult as mn,
5687
5803
  ActionKind as mt,
5688
5804
  ChatSdkMessengerOptions as n,
5689
5805
  SessionMessage$1 as nn,
5690
5806
  SessionContextOptions as nr,
5691
5807
  messengerContextFromEvent as nt,
5692
5808
  MessengerConversationResolver as o,
5693
- StepConfig as on,
5809
+ SkillSource$1 as on,
5694
5810
  Action as ot,
5695
5811
  ThinkMessengerRuntime as p,
5696
- SubmitMessagesResult as pn,
5812
+ SubmitMessagesOptions as pn,
5697
5813
  ActionIdempotencyKey as pt,
5698
5814
  MessengerAction as q,
5699
5815
  ChannelDeliverySurface as qn,
5700
5816
  ReplyAttachment as qt,
5701
5817
  DEFAULT_MESSENGER_CONCURRENCY as r,
5702
- SkillRunContext as rn,
5818
+ Skill as rn,
5703
5819
  ThinkSession as rr,
5704
5820
  resolveChannelSpeakerLabel as rt,
5705
5821
  MessengerConversationTarget as s,
5706
- StepContext as sn,
5822
+ StepConfig as sn,
5707
5823
  ActionApprovalDescriptor as st,
5708
5824
  ChatSdkMessengerEventInput as t,
5709
5825
  SaveMessagesResult$1 as tn,
5710
5826
  CompactionErrorHandler as tr,
5711
5827
  MessengerThread as tt,
5712
5828
  MessengerThinkHost as u,
5713
- StreamCallback as un,
5829
+ StopCondition$1 as un,
5714
5830
  ActionAuthorizationDecision as ut,
5715
5831
  defaultConversationName as v,
5716
- ThinkModelId as vn,
5832
+ ThinkModel as vn,
5717
5833
  CancelSubmissionResult as vt,
5718
5834
  toMessengerMessage as w,
5719
- ThinkSubmissionStatus as wn,
5835
+ ThinkSubmissionInspection as wn,
5720
5836
  ChatRecoveryContext$1 as wt,
5721
5837
  resolveSelfMention as x,
5722
- ThinkScheduledTaskSchedule as xn,
5838
+ ThinkScheduledTaskContext as xn,
5723
5839
  ChatInterruptedInfo as xt,
5724
5840
  idempotencyKeyForEvent as y,
5725
- ThinkScheduledTask as yn,
5841
+ ThinkModelId as yn,
5726
5842
  ChatErrorClassification as yt,
5727
5843
  TextStreamCallbackOptions as z,
5728
- action as zn,
5844
+ WaitForSubmissionOptions as zn,
5729
5845
  MessageConcurrency$1 as zt
5730
5846
  };
5731
- //# sourceMappingURL=index-Cjq_e9F2.d.ts.map
5847
+ //# sourceMappingURL=index-DDnny6kt.d.ts.map
@@ -36,7 +36,6 @@ interface ExtensionManifest {
36
36
  type:
37
37
  | "readonly"
38
38
  | "writable"
39
- | "skill"
40
39
  | "searchable" /** Maximum token budget for this block. */;
41
40
  maxTokens?: number;
42
41
  }>;
@@ -233,4 +232,4 @@ export {
233
232
  ExtensionInfo as r,
234
233
  ExtensionManager as t
235
234
  };
236
- //# sourceMappingURL=manager-dOcdCX4u.d.ts.map
235
+ //# sourceMappingURL=manager-rze95KCk.d.ts.map
@@ -58,7 +58,7 @@ import {
58
58
  x as resolveSelfMention,
59
59
  y as idempotencyKeyForEvent,
60
60
  z as TextStreamCallbackOptions
61
- } from "../index-Cjq_e9F2.js";
61
+ } from "../index-DDnny6kt.js";
62
62
  export {
63
63
  type ChannelSpeakerLabel,
64
64
  type ChatSdkMessengerEventInput,
@@ -2,7 +2,7 @@ import {
2
2
  R as TextStreamCallback,
3
3
  c as MessengerDefinition,
4
4
  n as ChatSdkMessengerOptions
5
- } from "../index-Cjq_e9F2.js";
5
+ } from "../index-DDnny6kt.js";
6
6
  import { TelegramAdapterConfig } from "@chat-adapter/telegram";
7
7
 
8
8
  //#region src/messengers/telegram.d.ts
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
package/dist/think.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $n as MediaEvictionConfig, $t as RunTurnWait, An as TurnConfig, At as ChunkContext, Bn as defaultContextOverflowClassifier, Bt as MessageMetadataCallback, Cn as ThinkSubmissionInspection, Ct as ChatRecoveryConfig, D as DeliveryKind, Dn as ToolCallContext, Dt as ChatRecoveryProgressContext, En as ThinkWallClockSchedule, Et as ChatRecoveryOptions, Fn as TurnTrigger, Ft as ExtensionConfig, Gn as ChannelDefinition, Gt as PrepareStepResult, Hn as skills, Ht as PendingApproval, In as TypedToolCall, It as FiberContext, Jn as ChannelIngress, Jt as ResolvedChatRecoveryConfig, Kn as ChannelDeliveryPolicy, Kt as RejectExecutionOptions, Ln as TypedToolResult, Lt as FiberRecoveryContext, Mn as TurnInput, Mt as ContextOverflowConfig, Nn as TurnInputMessages, Nt as DeleteSubmissionsOptions, O as DeliveryTag, On as ToolCallDecision, Ot as ChatResponseResult, Pn as TurnResult, Pt as DeliverNoticeOptions, Qn as messengerChannel, Qt as RunTurnSubmit, Rn as WaitForSubmissionOptions, Rt as ListSubmissionsOptions, Sn as ThinkScheduledTasks, St as ChatOptions, Tn as ThinkTime, Tt as ChatRecoveryExhaustedContext, Un as ChannelCapabilities, Ut as PrepareStepContext, Vn as isAction, Vt as OnStartDegradation, Wn as ChannelContext, Wt as PrepareStepFunction, Xn as NormalizedChannelDefinition, Xt as RunTurnOptions, Yn as ChannelKind, Yt as RunTurnBase, Zn as ThinkChannels, Zt as RunTurnStream, _n as ThinkModel, _t as AddMessagesOptions, an as SkillWorkspaceSeedOptions, bn as ThinkScheduledTaskContext, bt as ChatErrorContext, cn as StepResult, ct as ActionApprovalPolicy, dn as StreamableResult, dt as ActionConfig, en as SaveMessagesOptions, er as CompactAfterOptions, fn as SubmitMessagesOptions, ft as ActionContext, gn as ThinkIntervalSchedule, gt as ActiveTurn, hn as Think, ht as ActionPermissionSpec, in as SkillSource, jn as TurnContext, jt as ChunkPart, kn as ToolCallResultContext, kt as ChatStartEvent, ln as StopCondition, lt as ActionAuthorizationContext, mn as TextStreamPart, mt as ActionKind, nn as SessionMessage, nr as SessionContextOptions, on as StepConfig, ot as Action, pn as SubmitMessagesResult, pt as ActionIdempotencyKey, qn as ChannelDeliverySurface, qt as ReplyAttachment, rn as SkillRunContext, rr as ThinkSession, sn as StepContext, st as ActionApprovalDescriptor, tn as SaveMessagesResult, tr as CompactionErrorHandler, un as StreamCallback, ut as ActionAuthorizationDecision, vn as ThinkModelId, vt as CancelSubmissionResult, wn as ThinkSubmissionStatus, wt as ChatRecoveryContext, xn as ThinkScheduledTaskSchedule, xt as ChatInterruptedInfo, yn as ThinkScheduledTask, yt as ChatErrorClassification, zn as action, zt as MessageConcurrency } from "./index-Cjq_e9F2.js";
2
- import { a as FetchResponseMode, d as lazyWorkspace, i as FetchRedirectPolicy, l as ThinkWorkspace, n as FetchBindingTarget, o as FetchResult, r as FetchErrorCode, s as FetchToolEvent, t as CreateFetchToolsOptions, u as ThinkWorkspaceFilesystem } from "./fetch-C7s1mpgg.js";
3
- export { Action, ActionApprovalDescriptor, ActionApprovalPolicy, ActionAuthorizationContext, ActionAuthorizationDecision, ActionConfig, ActionContext, ActionIdempotencyKey, ActionKind, ActionPermissionSpec, ActiveTurn, AddMessagesOptions, CancelSubmissionResult, type ChannelCapabilities, type ChannelContext, type ChannelDefinition, type ChannelDeliveryPolicy, type ChannelDeliverySurface, type ChannelIngress, type ChannelKind, ChatErrorClassification, ChatErrorContext, ChatInterruptedInfo, ChatOptions, type ChatRecoveryConfig, type ChatRecoveryContext, type ChatRecoveryExhaustedContext, type ChatRecoveryOptions, type ChatRecoveryProgressContext, type ChatResponseResult, ChatStartEvent, ChunkContext, ChunkPart, type CompactAfterOptions, type CompactionErrorHandler, ContextOverflowConfig, type CreateFetchToolsOptions, DeleteSubmissionsOptions, DeliverNoticeOptions, type DeliveryKind, type DeliveryTag, ExtensionConfig, type FetchBindingTarget, type FetchErrorCode, type FetchRedirectPolicy, type FetchResponseMode, type FetchResult, type FetchToolEvent, type FiberContext, type FiberRecoveryContext, ListSubmissionsOptions, type MediaEvictionConfig, type MessageConcurrency, MessageMetadataCallback, type NormalizedChannelDefinition, OnStartDegradation, PendingApproval, PrepareStepContext, type PrepareStepFunction, type PrepareStepResult, RejectExecutionOptions, ReplyAttachment, type ResolvedChatRecoveryConfig, RunTurnBase, RunTurnOptions, RunTurnStream, RunTurnSubmit, RunTurnWait, type SaveMessagesOptions, type SaveMessagesResult, ThinkSession as Session, ThinkSession, type SessionContextOptions, type SessionMessage, type SkillRunContext, type SkillSource, type SkillWorkspaceSeedOptions, StepConfig, StepContext, type StepResult, type StopCondition, StreamCallback, StreamableResult, SubmitMessagesOptions, SubmitMessagesResult, type TextStreamPart, Think, type ThinkChannels, ThinkIntervalSchedule, ThinkModel, ThinkModelId, ThinkScheduledTask, ThinkScheduledTaskContext, ThinkScheduledTaskSchedule, ThinkScheduledTasks, ThinkSubmissionInspection, ThinkSubmissionStatus, ThinkTime, ThinkWallClockSchedule, type ThinkWorkspace, type ThinkWorkspaceFilesystem, ToolCallContext, ToolCallDecision, ToolCallResultContext, TurnConfig, TurnContext, TurnInput, TurnInputMessages, TurnResult, TurnTrigger, type TypedToolCall, type TypedToolResult, WaitForSubmissionOptions, action, defaultContextOverflowClassifier, isAction, lazyWorkspace, messengerChannel, skills };
1
+ import { $n as MediaEvictionConfig, $t as RunTurnWait, An as ToolCallResultContext, At as ChunkContext, Bn as action, Bt as MessageMetadataCallback, Cn as ThinkScheduledTasks, Ct as ChatRecoveryConfig, D as DeliveryKind, Dn as ThinkWallClockSchedule, Dt as ChatRecoveryProgressContext, En as ThinkTime, Et as ChatRecoveryOptions, Fn as TurnResult, Ft as ExtensionConfig, Gn as ChannelDefinition, Gt as PrepareStepResult, Hn as isAction, Ht as PendingApproval, In as TurnTrigger, It as FiberContext, Jn as ChannelIngress, Jt as ResolvedChatRecoveryConfig, Kn as ChannelDeliveryPolicy, Kt as RejectExecutionOptions, Ln as TypedToolCall, Lt as FiberRecoveryContext, Mn as TurnContext, Mt as ContextOverflowConfig, Nn as TurnInput, Nt as DeleteSubmissionsOptions, O as DeliveryTag, On as ToolCallContext, Ot as ChatResponseResult, Pn as TurnInputMessages, Pt as DeliverNoticeOptions, Qn as messengerChannel, Qt as RunTurnSubmit, Rn as TypedToolResult, Rt as ListSubmissionsOptions, Sn as ThinkScheduledTaskSchedule, St as ChatOptions, Tn as ThinkSubmissionStatus, Tt as ChatRecoveryExhaustedContext, Un as ChannelCapabilities, Ut as PrepareStepContext, Vn as defaultContextOverflowClassifier, Vt as OnStartDegradation, Wn as ChannelContext, Wt as PrepareStepFunction, Xn as NormalizedChannelDefinition, Xt as RunTurnOptions, Yn as ChannelKind, Yt as RunTurnBase, Zn as ThinkChannels, Zt as RunTurnStream, _n as ThinkIntervalSchedule, _t as AddMessagesOptions, an as SkillRunContext, bn as ThinkScheduledTask, bt as ChatErrorContext, cn as StepContext, ct as ActionApprovalPolicy, dn as StreamCallback, dt as ActionConfig, en as SaveMessagesOptions, er as CompactAfterOptions, fn as StreamableResult, ft as ActionContext, gn as Think, gt as ActiveTurn, hn as TextStreamPart, ht as ActionPermissionSpec, in as SkillCatalog, ir as skills_d_exports, jn as TurnConfig, jt as ChunkPart, kn as ToolCallDecision, kt as ChatStartEvent, ln as StepResult, lt as ActionAuthorizationContext, mn as SubmitMessagesResult, mt as ActionKind, nn as SessionMessage, nr as SessionContextOptions, on as SkillSource, ot as Action, pn as SubmitMessagesOptions, pt as ActionIdempotencyKey, qn as ChannelDeliverySurface, qt as ReplyAttachment, rn as Skill, rr as ThinkSession, sn as StepConfig, st as ActionApprovalDescriptor, tn as SaveMessagesResult, tr as CompactionErrorHandler, un as StopCondition, ut as ActionAuthorizationDecision, vn as ThinkModel, vt as CancelSubmissionResult, wn as ThinkSubmissionInspection, wt as ChatRecoveryContext, xn as ThinkScheduledTaskContext, xt as ChatInterruptedInfo, yn as ThinkModelId, yt as ChatErrorClassification, zn as WaitForSubmissionOptions, zt as MessageConcurrency } from "./index-DDnny6kt.js";
2
+ import { a as FetchResponseMode, i as FetchRedirectPolicy, l as ThinkWorkspace, n as FetchBindingTarget, o as FetchResult, r as FetchErrorCode, s as FetchToolEvent, t as CreateFetchToolsOptions, u as ThinkWorkspaceFilesystem } from "./fetch-CU2fC7O6.js";
3
+ export { Action, ActionApprovalDescriptor, ActionApprovalPolicy, ActionAuthorizationContext, ActionAuthorizationDecision, ActionConfig, ActionContext, ActionIdempotencyKey, ActionKind, ActionPermissionSpec, ActiveTurn, AddMessagesOptions, CancelSubmissionResult, type ChannelCapabilities, type ChannelContext, type ChannelDefinition, type ChannelDeliveryPolicy, type ChannelDeliverySurface, type ChannelIngress, type ChannelKind, ChatErrorClassification, ChatErrorContext, ChatInterruptedInfo, ChatOptions, type ChatRecoveryConfig, type ChatRecoveryContext, type ChatRecoveryExhaustedContext, type ChatRecoveryOptions, type ChatRecoveryProgressContext, type ChatResponseResult, ChatStartEvent, ChunkContext, ChunkPart, type CompactAfterOptions, type CompactionErrorHandler, ContextOverflowConfig, type CreateFetchToolsOptions, DeleteSubmissionsOptions, DeliverNoticeOptions, type DeliveryKind, type DeliveryTag, ExtensionConfig, type FetchBindingTarget, type FetchErrorCode, type FetchRedirectPolicy, type FetchResponseMode, type FetchResult, type FetchToolEvent, type FiberContext, type FiberRecoveryContext, ListSubmissionsOptions, type MediaEvictionConfig, type MessageConcurrency, MessageMetadataCallback, type NormalizedChannelDefinition, OnStartDegradation, PendingApproval, PrepareStepContext, type PrepareStepFunction, type PrepareStepResult, RejectExecutionOptions, ReplyAttachment, type ResolvedChatRecoveryConfig, RunTurnBase, RunTurnOptions, RunTurnStream, RunTurnSubmit, RunTurnWait, type SaveMessagesOptions, type SaveMessagesResult, ThinkSession as Session, ThinkSession, type SessionContextOptions, type SessionMessage, type Skill, type SkillCatalog, type SkillRunContext, type SkillSource, StepConfig, StepContext, type StepResult, type StopCondition, StreamCallback, StreamableResult, SubmitMessagesOptions, SubmitMessagesResult, type TextStreamPart, Think, type ThinkChannels, ThinkIntervalSchedule, ThinkModel, ThinkModelId, ThinkScheduledTask, ThinkScheduledTaskContext, ThinkScheduledTaskSchedule, ThinkScheduledTasks, ThinkSubmissionInspection, ThinkSubmissionStatus, ThinkTime, ThinkWallClockSchedule, type ThinkWorkspace, type ThinkWorkspaceFilesystem, ToolCallContext, ToolCallDecision, ToolCallResultContext, TurnConfig, TurnContext, TurnInput, TurnInputMessages, TurnResult, TurnTrigger, type TypedToolCall, type TypedToolResult, WaitForSubmissionOptions, action, defaultContextOverflowClassifier, isAction, messengerChannel, skills_d_exports as skills };