@cloudflare/think 0.24.0 → 0.25.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 +18 -26
- package/dist/{chat-sdk-BEjKXjCm.js → chat-sdk-4Nu96eDX.js} +375 -256
- package/dist/chat-sdk-4Nu96eDX.js.map +1 -0
- package/dist/extensions/index.d.ts +30 -72
- package/dist/extensions/index.js +45 -47
- package/dist/extensions/index.js.map +1 -1
- package/dist/{fetch-DO3uQ9py.js → fetch-BbYxtlff.js} +10 -2
- package/dist/fetch-BbYxtlff.js.map +1 -0
- package/dist/manager-B3rcb_6p.js +493 -0
- package/dist/manager-B3rcb_6p.js.map +1 -0
- package/dist/manager-CWGumyKi.d.ts +3391 -0
- package/dist/messengers/index.d.ts +54 -66
- package/dist/messengers/index.js +2 -2
- package/dist/messengers/telegram.d.ts +4 -4
- package/dist/messengers/telegram.js +1 -1
- package/dist/think.d.ts +2 -2
- package/dist/think.js +8493 -10759
- package/dist/think.js.map +1 -1
- package/dist/tools/extensions.d.ts +1 -1
- package/dist/tools/extensions.js +1 -1
- package/dist/tools/fetch.js +1 -1
- package/dist/workflows.d.ts +5 -2
- package/docs/actions.md +12 -0
- package/docs/channels.md +10 -4
- package/docs/client-tools.md +57 -27
- package/docs/context.md +92 -0
- package/docs/getting-started.md +2 -2
- package/docs/index.md +109 -49
- package/docs/lifecycle-hooks.md +10 -21
- package/docs/multi-chat.md +5 -5
- package/docs/programmatic-submissions.md +28 -10
- package/docs/sub-agents.md +45 -51
- package/docs/tools.md +31 -3
- package/docs/workflows.md +4 -3
- package/package.json +13 -8
- package/dist/chat-sdk-BEjKXjCm.js.map +0 -1
- package/dist/fetch-DO3uQ9py.js.map +0 -1
- package/dist/hook-proxy-DY2sBNa0.js +0 -117
- package/dist/hook-proxy-DY2sBNa0.js.map +0 -1
- package/dist/index-DIQ9oY1t.d.ts +0 -5864
- package/dist/manager-CtXhU1fK.d.ts +0 -243
- package/dist/manager-sfWIcYJT.js +0 -333
- package/dist/manager-sfWIcYJT.js.map +0 -1
package/README.md
CHANGED
|
@@ -339,7 +339,7 @@ Script execution requires a Worker Loader binding:
|
|
|
339
339
|
| --------------------------------------- | ------------------------------------------------------------- |
|
|
340
340
|
| `@cloudflare/think` | `Think`, `Session` — main class + re-exports |
|
|
341
341
|
| `agents/sessions` | `Sessions`, `Session`, `createCompactFunction`, attachments |
|
|
342
|
-
| `agents/context` | `
|
|
342
|
+
| `agents/context` | `Context`, providers, `ContextConfig` — prompt context |
|
|
343
343
|
| `@cloudflare/think/messengers` | Messenger contracts, Chat SDK bridge, state agent, delivery |
|
|
344
344
|
| `@cloudflare/think/messengers/telegram` | Telegram messenger provider and delivery helpers |
|
|
345
345
|
| `@cloudflare/think/tools/fetch` | `createFetchTools()` — opt-in allowlisted HTTP reads |
|
|
@@ -358,7 +358,6 @@ Script execution requires a Worker Loader binding:
|
|
|
358
358
|
| `getTools()` | `{}` | AI SDK `ToolSet` for the agentic loop |
|
|
359
359
|
| `getMessengers()` | `{}` | Messenger ingress and delivery declarations |
|
|
360
360
|
| `getScheduledTasks()` | `{}` | Code-declared recurring prompts |
|
|
361
|
-
| `getScheduledTasksScope()` | `"root"` | Which instances arm declared tasks — `"root"` or `"all"` (sub-agents too) |
|
|
362
361
|
| `getDefaultTimezone()` | `undefined` | Default timezone for wall-clock schedules |
|
|
363
362
|
| `maxSteps` | `10` | Max tool-call rounds per turn (property) |
|
|
364
363
|
| `sendReasoning` | `true` | Send reasoning chunks to chat clients |
|
|
@@ -476,9 +475,8 @@ turn. See the
|
|
|
476
475
|
### Scheduled tasks
|
|
477
476
|
|
|
478
477
|
Use `getScheduledTasks()` for code-declared recurring prompts or deterministic
|
|
479
|
-
scheduled handlers. Think reconciles these declarations on startup,
|
|
480
|
-
|
|
481
|
-
occurrence after each run.
|
|
478
|
+
scheduled handlers. Think reconciles these declarations on startup, keeps one
|
|
479
|
+
pending occurrence per task, and arms the next occurrence after each run.
|
|
482
480
|
|
|
483
481
|
```ts
|
|
484
482
|
import { Think } from "@cloudflare/think";
|
|
@@ -539,23 +537,16 @@ work such as creating a Workflow run or writing a run ledger. Delivery is
|
|
|
539
537
|
at-least-once; use `idempotencyKey` or `occurrenceKey` for your own durable
|
|
540
538
|
idempotency.
|
|
541
539
|
|
|
542
|
-
Declared tasks are armed on the
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
`
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
`internal_reconcileScheduledTasks()` after updating that data. During
|
|
553
|
-
reconciliation Think records the task row before creating the underlying Agent
|
|
554
|
-
schedule, so a `schedule_id` may be temporarily empty if the object is
|
|
555
|
-
interrupted mid-reconcile; the next reconcile repairs that pending row. The
|
|
556
|
-
task `retry` option retries the prompt or handler action before the failure is
|
|
557
|
-
logged. The next occurrence is still scheduled after the action succeeds or
|
|
558
|
-
exhausts its retries, so failed occurrences do not block future runs.
|
|
540
|
+
Declared tasks are armed on the agent that declares them, a sub-agent
|
|
541
|
+
included: each sub-agent arms its own, and its root wakes it when one is due.
|
|
542
|
+
|
|
543
|
+
Each task is one durable job holding its next occurrence. Static declarations
|
|
544
|
+
reconcile on startup. If `getScheduledTasks()` reads product-owned data that can change
|
|
545
|
+
while the Durable Object is live, call `internal_reconcileScheduledTasks()`
|
|
546
|
+
after updating that data. The task `retry` option retries the prompt or
|
|
547
|
+
handler action before the failure goes to `onError()`. The next occurrence is
|
|
548
|
+
still scheduled after the action succeeds or exhausts its retries, so failed
|
|
549
|
+
occurrences do not block future runs.
|
|
559
550
|
|
|
560
551
|
### Lifecycle hooks
|
|
561
552
|
|
|
@@ -801,11 +792,12 @@ export class MyAgent extends Think<Env> {
|
|
|
801
792
|
|
|
802
793
|
A block declared without a `provider` is auto-wired to durable per-agent SQLite,
|
|
803
794
|
so `memory` above is writable through the `set_context` tool with no extra
|
|
804
|
-
wiring. The
|
|
805
|
-
into: a cold wake reuses the exact prompt
|
|
795
|
+
wiring. The transcript records the system prompt each turn was sent with, so
|
|
796
|
+
there is nothing to opt into: a cold wake reuses the exact prompt the model
|
|
797
|
+
already cached.
|
|
806
798
|
|
|
807
799
|
The assembled blocks are available as `this.context` once the Lifecycle has
|
|
808
|
-
started. See [Context](https://github.com/cloudflare/agents/blob/main/docs/
|
|
800
|
+
started. See [Context](https://github.com/cloudflare/agents/blob/main/docs/think/context.md)
|
|
809
801
|
for providers, tools, and frozen-prompt behavior.
|
|
810
802
|
|
|
811
803
|
### Upgrading from 0.17
|
|
@@ -994,7 +986,7 @@ For values you want broadcast to connected clients, use `state` / `setState` fro
|
|
|
994
986
|
- **WebSocket protocol** — wire-compatible with `useAgentChat` from `@cloudflare/think/react`
|
|
995
987
|
- **Built-in workspace** — every agent gets `this.workspace` with file tools auto-wired
|
|
996
988
|
- **Lifecycle hooks** — `beforeTurn`, `beforeStep`, `onStepFinish`, `onChunk`, `onChatResponse` fire on every turn
|
|
997
|
-
- **Stream resumption** — page refresh replays
|
|
989
|
+
- **Stream resumption** — page refresh replays the stored chunks of the reply in flight
|
|
998
990
|
- **Client tools** — accept tool schemas from clients, handle results and approvals
|
|
999
991
|
- **Durable submissions** — accept webhook/RPC-triggered turns with idempotent retry and status inspection
|
|
1000
992
|
- **Messengers** — receive Chat SDK webhooks and deliver streamed replies with provider-safe recovery
|