@cloudflare/think 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -18
- package/dist/{fetch-C7s1mpgg.d.ts → fetch-CU2fC7O6.d.ts} +1 -30
- package/dist/{fetch-9f1p8UrI.js → fetch-DO3uQ9py.js} +2 -47
- package/dist/fetch-DO3uQ9py.js.map +1 -0
- package/dist/{index-Cjq_e9F2.d.ts → index-BFK9bpzz.d.ts} +2 -2
- package/dist/messengers/index.d.ts +1 -1
- package/dist/messengers/telegram.d.ts +1 -1
- package/dist/think.d.ts +3 -3
- package/dist/think.js +2 -2
- package/dist/think.js.map +1 -1
- package/dist/tools/fetch.d.ts +1 -1
- package/dist/tools/fetch.js +1 -1
- package/dist/workflows.d.ts +1 -1
- package/docs/channels.md +1 -5
- package/docs/index.md +1 -2
- package/docs/lifecycle-hooks.md +1 -3
- package/docs/multi-chat.md +5 -7
- package/docs/tools.md +0 -17
- package/package.json +6 -7
- package/dist/fetch-9f1p8UrI.js.map +0 -1
package/README.md
CHANGED
|
@@ -228,19 +228,8 @@ import { getWeather } from "ws:tools";
|
|
|
228
228
|
export default async () => (await getWeather({ city: "Lisbon" })).text;
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
```ts
|
|
234
|
-
import { getWorkspace } from "@cloudflare/computer";
|
|
235
|
-
import { lazyWorkspace } from "@cloudflare/think";
|
|
236
|
-
|
|
237
|
-
override workspace = lazyWorkspace(async () =>
|
|
238
|
-
getWorkspace(await this.parentAgent(Directory))
|
|
239
|
-
);
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
Every Think agent can hand out its own Workspace the same way: `getWorkspace`
|
|
243
|
-
calls the agent's `__getWorkspaceStub()` over RPC.
|
|
231
|
+
Every Think agent can hand out its own Workspace: `getWorkspace(stub)` from
|
|
232
|
+
`@cloudflare/computer` calls the agent's `__getWorkspaceStub()` over RPC.
|
|
244
233
|
|
|
245
234
|
## Agent Skills
|
|
246
235
|
|
|
@@ -384,7 +373,7 @@ Script execution requires a Worker Loader binding:
|
|
|
384
373
|
|
|
385
374
|
| Export | Description |
|
|
386
375
|
| --------------------------------------- | ------------------------------------------------------------- |
|
|
387
|
-
| `@cloudflare/think` | `Think`, `Session
|
|
376
|
+
| `@cloudflare/think` | `Think`, `Session` — main class + re-exports |
|
|
388
377
|
| `agents/sessions` | `Sessions`, `Session`, `createCompactFunction`, attachments |
|
|
389
378
|
| `agents/context` | `ContextBlocks`, providers, `ContextConfig` — prompt assembly |
|
|
390
379
|
| `@cloudflare/think/messengers` | Messenger contracts, Chat SDK bridge, state agent, delivery |
|
|
@@ -725,9 +714,7 @@ Extensions can subscribe to `beforeTurn`, `beforeToolCall`, `afterToolCall`, `on
|
|
|
725
714
|
```js
|
|
726
715
|
// extension source (loaded via getExtensions())
|
|
727
716
|
({
|
|
728
|
-
tools: {
|
|
729
|
-
/* ... */
|
|
730
|
-
},
|
|
717
|
+
tools: {/* ... */},
|
|
731
718
|
hooks: {
|
|
732
719
|
beforeToolCall: async (snapshot, host) => {
|
|
733
720
|
/* observation */
|
|
@@ -1162,7 +1149,7 @@ getTools() {
|
|
|
1162
1149
|
| Package | Notes |
|
|
1163
1150
|
| ---------------------------- | --------------------------------------------------------- |
|
|
1164
1151
|
| `agents` | Cloudflare Agents SDK peer dependency |
|
|
1165
|
-
| `ai` | Vercel AI SDK
|
|
1152
|
+
| `ai` | Vercel AI SDK v7 peer dependency |
|
|
1166
1153
|
| `zod` | Schema validation peer dependency |
|
|
1167
1154
|
| `@cloudflare/computer` | Workspace and workspace tools peer dependency |
|
|
1168
1155
|
| `@cloudflare/codemode` | Code execution, `createExecuteTool`, and JS skill scripts |
|
|
@@ -34,34 +34,6 @@ type ToolsWorkspace = CreateAIToolsOptions["workspace"];
|
|
|
34
34
|
type ThinkWorkspace = {
|
|
35
35
|
/** The Workspace filesystem. */ readonly fs: ThinkWorkspaceFilesystem;
|
|
36
36
|
} & Partial<Pick<ToolsWorkspace, "runtime" | "sessionId" | "assets">>;
|
|
37
|
-
/**
|
|
38
|
-
* A {@link ThinkWorkspace} that resolves the real Workspace on first use.
|
|
39
|
-
*
|
|
40
|
-
* Use it for a Workspace another Durable Object owns, so the agent does not
|
|
41
|
-
* reach the owner until a turn actually touches a file:
|
|
42
|
-
*
|
|
43
|
-
* ```ts
|
|
44
|
-
* import { getWorkspace } from "@cloudflare/computer";
|
|
45
|
-
*
|
|
46
|
-
* override workspace = lazyWorkspace(async () =>
|
|
47
|
-
* getWorkspace(await this.parentAgent(Directory))
|
|
48
|
-
* );
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* The resolved Workspace is kept and reused. A failed resolution is not
|
|
52
|
-
* kept, so the next operation tries again. To start over with a new client,
|
|
53
|
-
* for example after disposing the old one, assign a new `lazyWorkspace`.
|
|
54
|
-
*
|
|
55
|
-
* Only `fs` is forwarded, so the agent gets the file tools but no `exec`:
|
|
56
|
-
* the exec tool lists the Workspace's backends synchronously, before
|
|
57
|
-
* anything has been resolved.
|
|
58
|
-
*
|
|
59
|
-
* @param resolve - Produces the Workspace.
|
|
60
|
-
* @returns A Workspace whose `fs` forwards to the resolved one.
|
|
61
|
-
*/
|
|
62
|
-
declare function lazyWorkspace(
|
|
63
|
-
resolve: () => Promise<ThinkWorkspace>
|
|
64
|
-
): ThinkWorkspace;
|
|
65
37
|
//#endregion
|
|
66
38
|
//#region src/tools/fetch.d.ts
|
|
67
39
|
type FetchResponseMode = "text" | "json" | "auto" | "workspace";
|
|
@@ -184,7 +156,6 @@ declare function createFetchTools(options: CreateFetchToolsOptions): ToolSet;
|
|
|
184
156
|
export {
|
|
185
157
|
FetchResponseMode as a,
|
|
186
158
|
createFetchTools as c,
|
|
187
|
-
lazyWorkspace as d,
|
|
188
159
|
FetchRedirectPolicy as i,
|
|
189
160
|
ThinkWorkspace as l,
|
|
190
161
|
FetchBindingTarget as n,
|
|
@@ -194,4 +165,4 @@ export {
|
|
|
194
165
|
CreateFetchToolsOptions as t,
|
|
195
166
|
ThinkWorkspaceFilesystem as u
|
|
196
167
|
};
|
|
197
|
-
//# sourceMappingURL=fetch-
|
|
168
|
+
//# sourceMappingURL=fetch-CU2fC7O6.d.ts.map
|
|
@@ -127,51 +127,6 @@ function parentDirectory(path) {
|
|
|
127
127
|
function joinPath(directory, name) {
|
|
128
128
|
return directory.endsWith("/") ? `${directory}${name}` : `${directory}/${name}`;
|
|
129
129
|
}
|
|
130
|
-
/**
|
|
131
|
-
* A {@link ThinkWorkspace} that resolves the real Workspace on first use.
|
|
132
|
-
*
|
|
133
|
-
* Use it for a Workspace another Durable Object owns, so the agent does not
|
|
134
|
-
* reach the owner until a turn actually touches a file:
|
|
135
|
-
*
|
|
136
|
-
* ```ts
|
|
137
|
-
* import { getWorkspace } from "@cloudflare/computer";
|
|
138
|
-
*
|
|
139
|
-
* override workspace = lazyWorkspace(async () =>
|
|
140
|
-
* getWorkspace(await this.parentAgent(Directory))
|
|
141
|
-
* );
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
* The resolved Workspace is kept and reused. A failed resolution is not
|
|
145
|
-
* kept, so the next operation tries again. To start over with a new client,
|
|
146
|
-
* for example after disposing the old one, assign a new `lazyWorkspace`.
|
|
147
|
-
*
|
|
148
|
-
* Only `fs` is forwarded, so the agent gets the file tools but no `exec`:
|
|
149
|
-
* the exec tool lists the Workspace's backends synchronously, before
|
|
150
|
-
* anything has been resolved.
|
|
151
|
-
*
|
|
152
|
-
* @param resolve - Produces the Workspace.
|
|
153
|
-
* @returns A Workspace whose `fs` forwards to the resolved one.
|
|
154
|
-
*/
|
|
155
|
-
function lazyWorkspace(resolve) {
|
|
156
|
-
let resolved;
|
|
157
|
-
const fs = async () => {
|
|
158
|
-
resolved ??= resolve().catch((error) => {
|
|
159
|
-
resolved = void 0;
|
|
160
|
-
throw error;
|
|
161
|
-
});
|
|
162
|
-
return (await resolved).fs;
|
|
163
|
-
};
|
|
164
|
-
return { fs: {
|
|
165
|
-
readFile: async (...args) => (await fs()).readFile(...args),
|
|
166
|
-
writeFile: async (...args) => (await fs()).writeFile(...args),
|
|
167
|
-
mkdir: async (...args) => (await fs()).mkdir(...args),
|
|
168
|
-
rm: async (...args) => (await fs()).rm(...args),
|
|
169
|
-
stat: async (...args) => (await fs()).stat(...args),
|
|
170
|
-
readdir: async (...args) => (await fs()).readdir(...args),
|
|
171
|
-
find: async (...args) => (await fs()).find(...args),
|
|
172
|
-
grep: async (...args) => (await fs()).grep(...args)
|
|
173
|
-
} };
|
|
174
|
-
}
|
|
175
130
|
//#endregion
|
|
176
131
|
//#region src/tools/fetch.ts
|
|
177
132
|
const DEFAULT_MAX_BYTES = 1e6;
|
|
@@ -767,6 +722,6 @@ function toModelOutput(output) {
|
|
|
767
722
|
};
|
|
768
723
|
}
|
|
769
724
|
//#endregion
|
|
770
|
-
export {
|
|
725
|
+
export { WorkspaceFiles as n, resolveWorkspacePath as r, createFetchTools as t };
|
|
771
726
|
|
|
772
|
-
//# sourceMappingURL=fetch-
|
|
727
|
+
//# sourceMappingURL=fetch-DO3uQ9py.js.map
|
|
@@ -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;;;;;;;;;;;;A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as CreateFetchToolsOptions
|
|
8
|
-
} from "./fetch-
|
|
8
|
+
} from "./fetch-CU2fC7O6.js";
|
|
9
9
|
import {
|
|
10
10
|
FlexibleSchema,
|
|
11
11
|
GenerateTextOnStepFinishCallback,
|
|
@@ -5728,4 +5728,4 @@ export {
|
|
|
5728
5728
|
action as zn,
|
|
5729
5729
|
MessageConcurrency$1 as zt
|
|
5730
5730
|
};
|
|
5731
|
-
//# sourceMappingURL=index-
|
|
5731
|
+
//# sourceMappingURL=index-BFK9bpzz.d.ts.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
R as TextStreamCallback,
|
|
3
3
|
c as MessengerDefinition,
|
|
4
4
|
n as ChatSdkMessengerOptions
|
|
5
|
-
} from "../index-
|
|
5
|
+
} from "../index-BFK9bpzz.js";
|
|
6
6
|
import { TelegramAdapterConfig } from "@chat-adapter/telegram";
|
|
7
7
|
|
|
8
8
|
//#region src/messengers/telegram.d.ts
|
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-
|
|
2
|
-
import { a as FetchResponseMode,
|
|
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,
|
|
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-BFK9bpzz.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 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, messengerChannel, skills };
|
package/dist/think.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, r as _assertClassBrand, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-DwGJfC3w.js";
|
|
2
2
|
import { n as sanitizeName, r as _classPrivateMethodInitSpec, t as ExtensionManager } from "./manager-BubfmA3q.js";
|
|
3
|
-
import {
|
|
3
|
+
import { n as WorkspaceFiles, r as resolveWorkspacePath, t as createFetchTools } from "./fetch-DO3uQ9py.js";
|
|
4
4
|
import { truncatePausedExecutionOutput } from "./tools/execute.js";
|
|
5
5
|
import { _ as MESSENGER_REPLY_FIBER_NAME, n as ThinkMessengerRuntime, t as DEFAULT_MESSENGER_CONCURRENCY } from "./chat-sdk-BEjKXjCm.js";
|
|
6
6
|
import "./messengers/index.js";
|
|
@@ -11286,6 +11286,6 @@ for (const method of [
|
|
|
11286
11286
|
Think.prototype.rejectExecution
|
|
11287
11287
|
]) callable()(method, void 0);
|
|
11288
11288
|
//#endregion
|
|
11289
|
-
export { ThinkSession as Session, ThinkSession, Think, action, defaultContextOverflowClassifier, isAction,
|
|
11289
|
+
export { ThinkSession as Session, ThinkSession, Think, action, defaultContextOverflowClassifier, isAction, messengerChannel, skills };
|
|
11290
11290
|
|
|
11291
11291
|
//# sourceMappingURL=think.js.map
|