agents 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.
Files changed (137) hide show
  1. package/README.md +1 -0
  2. package/dist/{agent-tool-types-CzGGB-20.d.ts → agent-routing-CnkaHb-v.d.ts} +2921 -3057
  3. package/dist/agent-routing.d.ts +14 -0
  4. package/dist/agent-routing.js +187 -0
  5. package/dist/agent-routing.js.map +1 -0
  6. package/dist/agent-tool-types.d.ts +26 -26
  7. package/dist/{agent-tools-zR2d5uij.d.ts → agent-tools-C0XJqWzB.d.ts} +7 -7
  8. package/dist/agent-tools.d.ts +21 -21
  9. package/dist/agent-tools.js +2 -1
  10. package/dist/agent-tools.js.map +1 -1
  11. package/dist/browser/ai.js +2 -1
  12. package/dist/browser/ai.js.map +1 -1
  13. package/dist/capability-BjSKYpzg.js +42 -0
  14. package/dist/capability-BjSKYpzg.js.map +1 -0
  15. package/dist/capability-runner-CvHGZqUu.d.ts +150 -0
  16. package/dist/chat/index.d.ts +22 -15
  17. package/dist/chat/index.js +4 -4
  18. package/dist/chat/index.js.map +1 -1
  19. package/dist/chat/react.d.ts +14 -1
  20. package/dist/chat/react.js +82 -52
  21. package/dist/chat/react.js.map +1 -1
  22. package/dist/chat/transport.js +1 -1
  23. package/dist/chat-sdk/index.d.ts +4 -4
  24. package/dist/chat-sdk/index.js +1 -1
  25. package/dist/{client-zqKcsyFa.js → client-jagG8a9_.js} +129 -37
  26. package/dist/client-jagG8a9_.js.map +1 -0
  27. package/dist/client.d.ts +1 -1
  28. package/dist/client.js +1 -1
  29. package/dist/{cloudflare-BduZwmYK.js → cloudflare-Dzvc7V2N.js} +10 -3
  30. package/dist/{cloudflare-BduZwmYK.js.map → cloudflare-Dzvc7V2N.js.map} +1 -1
  31. package/dist/current-agent-CuMErtly.d.ts +283 -0
  32. package/dist/current-agent-DhoDkSnH.js +51 -0
  33. package/dist/current-agent-DhoDkSnH.js.map +1 -0
  34. package/dist/diagnostics-CaBjfz4J.js +41 -0
  35. package/dist/diagnostics-CaBjfz4J.js.map +1 -0
  36. package/dist/{do-oauth-client-provider-VTZj2VtM.d.ts → do-oauth-client-provider-Tmf1vgKz.d.ts} +2 -2
  37. package/dist/durable-object-lifecycle-D6nNQJJd.js +862 -0
  38. package/dist/durable-object-lifecycle-D6nNQJJd.js.map +1 -0
  39. package/dist/{email-CL27preh.d.ts → email-7TatiTnl.d.ts} +38 -9
  40. package/dist/email-send.d.ts +15 -0
  41. package/dist/email-send.js +32 -0
  42. package/dist/email-send.js.map +1 -0
  43. package/dist/email.d.ts +14 -10
  44. package/dist/email.js.map +1 -1
  45. package/dist/experimental/memory/session/index.d.ts +3 -2
  46. package/dist/experimental/memory/session/index.js +15 -10
  47. package/dist/experimental/memory/session/index.js.map +1 -1
  48. package/dist/{handler-stateless-C_bo-Ytq.d.ts → handler-stateless-DxYpJ_XF.d.ts} +3 -3
  49. package/dist/{handler-stateless-CIkKPETH.js → handler-stateless-VvrWSAVA.js} +5 -5
  50. package/dist/handler-stateless-VvrWSAVA.js.map +1 -0
  51. package/dist/{index-BRnybD6X.d.ts → index-DcSAZKsB.d.ts} +19 -31
  52. package/dist/index.d.ts +98 -95
  53. package/dist/index.js +10 -7234
  54. package/dist/internal_context-BlxFEWfn.d.ts +19 -0
  55. package/dist/internal_context.d.ts +10 -4
  56. package/dist/internal_context.js +1 -10
  57. package/dist/{client-invoker-BNSZxAkv.d.ts → invoker-CG0_p_Wq.d.ts} +2 -2
  58. package/dist/{client-invoker-VNZ7X0nn.js → invoker-CHMnoxIA.js} +2 -2
  59. package/dist/invoker-CHMnoxIA.js.map +1 -0
  60. package/dist/lifecycle/index.d.ts +48 -0
  61. package/dist/lifecycle/index.js +4 -0
  62. package/dist/mcp/{do-oauth-client-provider.d.ts → client/do-oauth-client-provider.d.ts} +1 -1
  63. package/dist/mcp/{do-oauth-client-provider.js → client/do-oauth-client-provider.js} +1 -1
  64. package/dist/mcp/client/do-oauth-client-provider.js.map +1 -0
  65. package/dist/mcp/client/index.d.ts +42 -0
  66. package/dist/mcp/{client.js → client/index.js} +1 -1
  67. package/dist/mcp/{x402.d.ts → client/x402.d.ts} +2 -2
  68. package/dist/mcp/{x402.js → client/x402.js} +2 -2
  69. package/dist/mcp/client/x402.js.map +1 -0
  70. package/dist/mcp/index.d.ts +36 -36
  71. package/dist/mcp/index.js +14 -16
  72. package/dist/mcp/index.js.map +1 -1
  73. package/dist/mcp/{server.d.ts → server/index.d.ts} +1 -1
  74. package/dist/mcp/{server.js → server/index.js} +1 -1
  75. package/dist/observability/ai/index.js +50 -35
  76. package/dist/observability/ai/index.js.map +1 -1
  77. package/dist/observability/index.d.ts +4 -4
  78. package/dist/observability/index.js +3 -50
  79. package/dist/observability/index.js.map +1 -1
  80. package/dist/{protocol-Dqc2MQxo.js → protocol-B0nh6KNf.js} +19 -21
  81. package/dist/protocol-B0nh6KNf.js.map +1 -0
  82. package/dist/react.d.ts +4 -4
  83. package/dist/react.js +1 -1
  84. package/dist/schedule.d.ts +25 -94
  85. package/dist/schedule.js +1 -98
  86. package/dist/schedule.js.map +1 -1
  87. package/dist/scheduler-CR9RHGos.js +857 -0
  88. package/dist/scheduler-CR9RHGos.js.map +1 -0
  89. package/dist/scheduler-DQoTGoAW.d.ts +224 -0
  90. package/dist/schedules/index.d.ts +22 -0
  91. package/dist/schedules/index.js +2 -0
  92. package/dist/schedules/parser.d.ts +79 -0
  93. package/dist/schedules/parser.js +103 -0
  94. package/dist/schedules/parser.js.map +1 -0
  95. package/dist/serializable.d.ts +1 -1
  96. package/dist/sql-error-CPY-GXyI.d.ts +12 -0
  97. package/dist/sql-error.d.ts +2 -0
  98. package/dist/sql-error.js +16 -0
  99. package/dist/sql-error.js.map +1 -0
  100. package/dist/src-5W6JNKVb.js +6613 -0
  101. package/dist/src-5W6JNKVb.js.map +1 -0
  102. package/dist/sub-routing.d.ts +12 -12
  103. package/dist/workflow-types.d.ts +25 -25
  104. package/dist/workflows.d.ts +22 -22
  105. package/dist/workflows.js +2 -1
  106. package/dist/workflows.js.map +1 -1
  107. package/dist/{ws-chat-transport-CIoOBbO7.js → ws-chat-transport-rWwta645.js} +152 -15
  108. package/dist/ws-chat-transport-rWwta645.js.map +1 -0
  109. package/docs/agent-class.md +28 -86
  110. package/docs/chat-agents.md +13 -12
  111. package/docs/durable-execution.md +1 -1
  112. package/docs/http-websockets.md +1 -11
  113. package/docs/human-in-the-loop.md +1 -1
  114. package/docs/index.md +1 -0
  115. package/docs/lifecycle.md +323 -0
  116. package/docs/long-running-agents.md +2 -4
  117. package/docs/mcp-client.md +55 -0
  118. package/docs/observability.md +11 -11
  119. package/docs/resumable-streaming.md +1 -1
  120. package/docs/scheduling.md +175 -15
  121. package/docs/server-driven-messages.md +1 -1
  122. package/docs/sub-agents.md +1 -1
  123. package/package.json +30 -21
  124. package/dist/cli/index.d.ts +0 -1
  125. package/dist/cli/index.js +0 -26
  126. package/dist/cli/index.js.map +0 -1
  127. package/dist/client-invoker-VNZ7X0nn.js.map +0 -1
  128. package/dist/client-zqKcsyFa.js.map +0 -1
  129. package/dist/handler-stateless-CIkKPETH.js.map +0 -1
  130. package/dist/index.js.map +0 -1
  131. package/dist/internal_context-Dg4Cgjcu.d.ts +0 -37
  132. package/dist/internal_context.js.map +0 -1
  133. package/dist/mcp/client.d.ts +0 -42
  134. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  135. package/dist/mcp/x402.js.map +0 -1
  136. package/dist/protocol-Dqc2MQxo.js.map +0 -1
  137. package/dist/ws-chat-transport-CIoOBbO7.js.map +0 -1
@@ -0,0 +1,42 @@
1
+ //#region src/lifecycle/capability.ts
2
+ const installedServices = /* @__PURE__ */ new WeakMap();
3
+ /**
4
+ * Base class for capabilities that consume standard Lifecycle services.
5
+ *
6
+ * @experimental The API surface may change before stabilizing.
7
+ */
8
+ var LifecycleCapability = class {
9
+ constructor(capabilityId) {
10
+ if (capabilityId.trim() === "") throw new Error("Lifecycle capability IDs must be non-empty");
11
+ this.capabilityId = capabilityId;
12
+ }
13
+ /** Default startup hook; capabilities override when they own startup work. */
14
+ onStart(_context) {}
15
+ /** Standard services when installed, or undefined in isolated unit tests. */
16
+ get lifecycleServices() {
17
+ return installedServices.get(this);
18
+ }
19
+ /** Standard services supplied when Lifecycle installs this capability. */
20
+ get lifecycle() {
21
+ const services = this.lifecycleServices;
22
+ if (!services) throw new Error(`${this.constructor.name} must be installed with Lifecycle.use() before use`);
23
+ return services;
24
+ }
25
+ };
26
+ /**
27
+ * @internal Bind the standard service surface to one capability instance.
28
+ * `Lifecycle.use()` calls this during installation. Test a capability by
29
+ * installing it on a minimal Durable Object with a real Lifecycle rather
30
+ * than binding fake services.
31
+ */
32
+ function bindLifecycleCapability(capability, services) {
33
+ installedServices.set(capability, services);
34
+ }
35
+ /** @internal Read a capability ID without exposing installation internals. */
36
+ function lifecycleCapabilityId(capability) {
37
+ return capability instanceof LifecycleCapability ? capability.capabilityId : void 0;
38
+ }
39
+ //#endregion
40
+ export { bindLifecycleCapability as n, lifecycleCapabilityId as r, LifecycleCapability as t };
41
+
42
+ //# sourceMappingURL=capability-BjSKYpzg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-BjSKYpzg.js","names":[],"sources":["../src/lifecycle/capability.ts"],"sourcesContent":["import type {\n CapabilityStartContext,\n DurableObjectCapability\n} from \"./capability-runner\";\n\n/** Opaque address understood by a Lifecycle routing transport. */\nexport type LifecycleRouteAddress = {\n /** Stable equality and storage key. */\n readonly key: string;\n /** Transport-owned serialized address. */\n readonly data: string;\n};\n\n/** Context supplied with a routed capability message. */\nexport type LifecycleRouteContext = {\n /** Address of the sending Lifecycle, or undefined for an unrouted root. */\n readonly source: LifecycleRouteAddress | undefined;\n /** Capability-owned message payload. */\n readonly payload: unknown;\n};\n\n/** Alarm coordination available to every Lifecycle capability. */\nexport type LifecycleAlarms = {\n /** Recompute the physical alarm from installed capability state. */\n readonly rearm: () => Promise<void>;\n /**\n * True once explicit host teardown permanently disabled alarm arming.\n * Capabilities stop dispatching durable work when this reports true.\n */\n readonly disabled: () => boolean;\n};\n\n/** Best-effort telemetry available to every Lifecycle capability. */\nexport type LifecycleEvents = {\n /** Publish an event under this capability's stable identity. */\n readonly emit: (type: string, payload: unknown) => void;\n};\n\n/** Routing available to every Lifecycle capability. */\nexport type LifecycleRoutes = {\n /** This Lifecycle's transport address, or undefined at the route root. */\n readonly source: LifecycleRouteAddress | undefined;\n /** Route a capability-owned message to the root Lifecycle. */\n readonly toRoot: (payload: unknown) => Promise<unknown>;\n /** Route a capability-owned message to another Lifecycle. */\n readonly to: (\n target: LifecycleRouteAddress,\n payload: unknown\n ) => Promise<unknown>;\n};\n\n/**\n * Standard services granted to every installed Lifecycle capability.\n *\n * @experimental The API surface may change before stabilizing.\n */\nexport type LifecycleServices = {\n readonly storage: DurableObjectStorage;\n readonly ready: () => Promise<void>;\n /** True while capability and host startup hooks are still running. */\n readonly starting: () => boolean;\n readonly alarms: LifecycleAlarms;\n /**\n * Run a capability-held user callback inside the host invocation context.\n * Capability hooks run outside host context; this is the one boundary for\n * entering it, and a host composition root may substitute its own wrapper\n * (Agent adds tracing span scope).\n */\n readonly runInHostContext: (fn: () => unknown) => Promise<unknown>;\n readonly events: LifecycleEvents;\n readonly routes: LifecycleRoutes;\n};\n\nconst installedServices = new WeakMap<object, LifecycleServices>();\n\n/**\n * Base class for capabilities that consume standard Lifecycle services.\n *\n * @experimental The API surface may change before stabilizing.\n */\nexport abstract class LifecycleCapability<Props extends object = object> {\n readonly capabilityId: string;\n\n protected constructor(capabilityId: string) {\n if (capabilityId.trim() === \"\") {\n throw new Error(\"Lifecycle capability IDs must be non-empty\");\n }\n this.capabilityId = capabilityId;\n }\n\n /** Default startup hook; capabilities override when they own startup work. */\n onStart(_context: CapabilityStartContext<Props>): void {}\n\n /** Standard services when installed, or undefined in isolated unit tests. */\n protected get lifecycleServices(): LifecycleServices | undefined {\n return installedServices.get(this);\n }\n\n /** Standard services supplied when Lifecycle installs this capability. */\n protected get lifecycle(): LifecycleServices {\n const services = this.lifecycleServices;\n if (!services) {\n throw new Error(\n `${this.constructor.name} must be installed with Lifecycle.use() before use`\n );\n }\n return services;\n }\n}\n\n/**\n * @internal Bind the standard service surface to one capability instance.\n * `Lifecycle.use()` calls this during installation. Test a capability by\n * installing it on a minimal Durable Object with a real Lifecycle rather\n * than binding fake services.\n */\nexport function bindLifecycleCapability(\n capability: LifecycleCapability,\n services: LifecycleServices\n): void {\n installedServices.set(capability, services);\n}\n\n/** @internal Read a capability ID without exposing installation internals. */\nexport function lifecycleCapabilityId(\n capability: DurableObjectCapability\n): string | undefined {\n return capability instanceof LifecycleCapability\n ? capability.capabilityId\n : undefined;\n}\n"],"mappings":";AAyEA,MAAM,oCAAoB,IAAI,QAAmC;;;;;;AAOjE,IAAsB,sBAAtB,MAAyE;CAGvE,YAAsB,cAAsB;EAC1C,IAAI,aAAa,KAAK,MAAM,IAC1B,MAAM,IAAI,MAAM,4CAA4C;EAE9D,KAAK,eAAe;CACtB;;CAGA,QAAQ,UAA+C,CAAC;;CAGxD,IAAc,oBAAmD;EAC/D,OAAO,kBAAkB,IAAI,IAAI;CACnC;;CAGA,IAAc,YAA+B;EAC3C,MAAM,WAAW,KAAK;EACtB,IAAI,CAAC,UACH,MAAM,IAAI,MACR,GAAG,KAAK,YAAY,KAAK,mDAC3B;EAEF,OAAO;CACT;AACF;;;;;;;AAQA,SAAgB,wBACd,YACA,UACM;CACN,kBAAkB,IAAI,YAAY,QAAQ;AAC5C;;AAGA,SAAgB,sBACd,YACoB;CACpB,OAAO,sBAAsB,sBACzB,WAAW,eACX,KAAA;AACN"}
@@ -0,0 +1,150 @@
1
+ //#region src/lifecycle/capability.d.ts
2
+ /** Opaque address understood by a Lifecycle routing transport. */
3
+ type LifecycleRouteAddress = {
4
+ /** Stable equality and storage key. */ readonly key: string /** Transport-owned serialized address. */;
5
+ readonly data: string;
6
+ };
7
+ /** Context supplied with a routed capability message. */
8
+ type LifecycleRouteContext = {
9
+ /** Address of the sending Lifecycle, or undefined for an unrouted root. */ readonly source:
10
+ | LifecycleRouteAddress
11
+ | undefined /** Capability-owned message payload. */;
12
+ readonly payload: unknown;
13
+ };
14
+ /** Alarm coordination available to every Lifecycle capability. */
15
+ type LifecycleAlarms = {
16
+ /** Recompute the physical alarm from installed capability state. */ readonly rearm: () => Promise<void>;
17
+ /**
18
+ * True once explicit host teardown permanently disabled alarm arming.
19
+ * Capabilities stop dispatching durable work when this reports true.
20
+ */
21
+ readonly disabled: () => boolean;
22
+ };
23
+ /** Best-effort telemetry available to every Lifecycle capability. */
24
+ type LifecycleEvents = {
25
+ /** Publish an event under this capability's stable identity. */ readonly emit: (
26
+ type: string,
27
+ payload: unknown
28
+ ) => void;
29
+ };
30
+ /** Routing available to every Lifecycle capability. */
31
+ type LifecycleRoutes = {
32
+ /** This Lifecycle's transport address, or undefined at the route root. */ readonly source:
33
+ | LifecycleRouteAddress
34
+ | undefined /** Route a capability-owned message to the root Lifecycle. */;
35
+ readonly toRoot: (
36
+ payload: unknown
37
+ ) => Promise<unknown> /** Route a capability-owned message to another Lifecycle. */;
38
+ readonly to: (
39
+ target: LifecycleRouteAddress,
40
+ payload: unknown
41
+ ) => Promise<unknown>;
42
+ };
43
+ /**
44
+ * Standard services granted to every installed Lifecycle capability.
45
+ *
46
+ * @experimental The API surface may change before stabilizing.
47
+ */
48
+ type LifecycleServices = {
49
+ readonly storage: DurableObjectStorage;
50
+ readonly ready: () => Promise<void> /** True while capability and host startup hooks are still running. */;
51
+ readonly starting: () => boolean;
52
+ readonly alarms: LifecycleAlarms;
53
+ /**
54
+ * Run a capability-held user callback inside the host invocation context.
55
+ * Capability hooks run outside host context; this is the one boundary for
56
+ * entering it, and a host composition root may substitute its own wrapper
57
+ * (Agent adds tracing span scope).
58
+ */
59
+ readonly runInHostContext: (fn: () => unknown) => Promise<unknown>;
60
+ readonly events: LifecycleEvents;
61
+ readonly routes: LifecycleRoutes;
62
+ };
63
+ /**
64
+ * Base class for capabilities that consume standard Lifecycle services.
65
+ *
66
+ * @experimental The API surface may change before stabilizing.
67
+ */
68
+ declare abstract class LifecycleCapability<Props extends object = object> {
69
+ readonly capabilityId: string;
70
+ protected constructor(capabilityId: string);
71
+ /** Default startup hook; capabilities override when they own startup work. */
72
+ onStart(_context: CapabilityStartContext<Props>): void;
73
+ /** Standard services when installed, or undefined in isolated unit tests. */
74
+ protected get lifecycleServices(): LifecycleServices | undefined;
75
+ /** Standard services supplied when Lifecycle installs this capability. */
76
+ protected get lifecycle(): LifecycleServices;
77
+ }
78
+ //#endregion
79
+ //#region src/lifecycle/capability-runner.d.ts
80
+ type MaybePromise<T> = T | Promise<T>;
81
+ /** One capability's requested physical alarm. */
82
+ type AlarmContribution =
83
+ | number
84
+ | {
85
+ /** Epoch time in milliseconds. */ readonly time: number /** Ignore ordinary wake-time candidates while this request exists. */;
86
+ readonly exclusive: true;
87
+ }
88
+ | null;
89
+ /** One best-effort event published by a Lifecycle capability. */
90
+ type LifecycleEvent = {
91
+ /** Stable capability or subsystem name. */ readonly source: string /** Stable event name within that source. */;
92
+ readonly type: string /** Event-specific data. */;
93
+ readonly payload: unknown;
94
+ };
95
+ /** Context supplied when durable capabilities start. */
96
+ type CapabilityStartContext<Props extends object = object> = {
97
+ /** Properties supplied while resolving the Durable Object. */ readonly props:
98
+ | Props
99
+ | undefined;
100
+ };
101
+ /** Context supplied when durable capabilities inspect an HTTP request. */
102
+ type CapabilityRequestContext = {
103
+ /** The request entering the Durable Object. */ readonly request: Request;
104
+ };
105
+ /**
106
+ * A capability installed into a Durable Object lifecycle.
107
+ *
108
+ * Capabilities extending `LifecycleCapability` receive the standard storage,
109
+ * readiness, alarm, event, and routing surface. Host-specific bindings and
110
+ * protocol adapters remain explicit constructor dependencies. Hook parameters
111
+ * carry only phase data; hooks do not run in ambient host context.
112
+ *
113
+ * @experimental The API surface may change before stabilizing.
114
+ */
115
+ interface DurableObjectCapability<Props extends object = object> {
116
+ /** Initialize or recover the capability before the host handles work. */
117
+ onStart?(context: CapabilityStartContext<Props>): MaybePromise<void>;
118
+ /**
119
+ * Inspect an HTTP request before the host's request handler.
120
+ *
121
+ * Return a response to handle the request, or `undefined` to continue.
122
+ */
123
+ onRequest?(
124
+ context: CapabilityRequestContext
125
+ ): MaybePromise<Response | undefined | void>;
126
+ /** Run work assigned to the capability when the host's alarm fires. */
127
+ onAlarm?(): MaybePromise<void>;
128
+ /** Handle one message routed to this capability identity. */
129
+ onRoute?(context: LifecycleRouteContext): MaybePromise<unknown>;
130
+ /** Return this capability's next requested physical alarm. */
131
+ getNextAlarm?(): MaybePromise<AlarmContribution>;
132
+ /** Release live or in-memory resources during explicit host destruction. */
133
+ dispose?(): MaybePromise<void>;
134
+ }
135
+ //#endregion
136
+ export {
137
+ LifecycleEvent as a,
138
+ LifecycleEvents as c,
139
+ LifecycleRoutes as d,
140
+ LifecycleServices as f,
141
+ DurableObjectCapability as i,
142
+ LifecycleRouteAddress as l,
143
+ CapabilityRequestContext as n,
144
+ LifecycleAlarms as o,
145
+ CapabilityStartContext as r,
146
+ LifecycleCapability as s,
147
+ AlarmContribution as t,
148
+ LifecycleRouteContext as u
149
+ };
150
+ //# sourceMappingURL=capability-runner-CvHGZqUu.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import {
2
- U as FiberRecoveryContext,
3
- _ as AgentToolRunState,
4
- a as AgentToolEvent,
5
- o as AgentToolEventMessage,
6
- s as AgentToolEventState
7
- } from "../agent-tool-types-CzGGB-20.js";
2
+ H as AgentToolEvent,
3
+ U as AgentToolEventMessage,
4
+ W as AgentToolEventState,
5
+ et as AgentToolRunState,
6
+ v as FiberRecoveryContext
7
+ } from "../agent-routing-CnkaHb-v.js";
8
8
  import {
9
9
  n as ClientToolSchema,
10
10
  r as createToolsFromClientSchemas,
@@ -18,7 +18,7 @@ import {
18
18
  r as AgentToolProgressEmitResult,
19
19
  s as interceptAgentToolBroadcast,
20
20
  t as AgentToolBroadcastHooks
21
- } from "../agent-tools-zR2d5uij.js";
21
+ } from "../agent-tools-C0XJqWzB.js";
22
22
  import { JSONSchema7, UIMessage } from "ai";
23
23
  import { Connection } from "agents";
24
24
 
@@ -192,7 +192,9 @@ declare function enforceRowSizeLimit(
192
192
  //#region src/chat/stream-accumulator.d.ts
193
193
  interface StreamAccumulatorOptions {
194
194
  messageId: string;
195
+ /** Whether chunks continue the current assistant message when merged. */
195
196
  continuation?: boolean;
197
+ /** Eager seed; omitted continuations seed from the messages passed to `mergeInto`. */
196
198
  existingParts?: UIMessage["parts"];
197
199
  existingMetadata?: Record<string, unknown>;
198
200
  }
@@ -236,6 +238,7 @@ declare class StreamAccumulator {
236
238
  readonly parts: UIMessage["parts"];
237
239
  metadata?: Record<string, unknown>;
238
240
  private _isContinuation;
241
+ private _pendingContinuationChunks;
239
242
  constructor(options: StreamAccumulatorOptions);
240
243
  applyChunk(chunk: StreamChunkData): ChunkResult;
241
244
  /** Snapshot the current state as a UIMessage. */
@@ -243,7 +246,8 @@ declare class StreamAccumulator {
243
246
  /**
244
247
  * Merge this accumulator's message into an existing message array.
245
248
  * Handles continuation (walk backward for last assistant), replacement
246
- * (update existing by messageId), or append (new message).
249
+ * (update existing by messageId), or append (new message). An unseeded
250
+ * continuation adopts current parts here before applying its queued chunks.
247
251
  */
248
252
  mergeInto(messages: UIMessage[]): UIMessage[];
249
253
  }
@@ -521,9 +525,11 @@ type ChatRecoveryProgressContext = {
521
525
  ageMs: number;
522
526
  };
523
527
  /**
524
- * Configuration for durable chat recovery. `true` uses these defaults:
525
- * `maxAttempts: 10`, `stableTimeoutMs: 10_000`, `noProgressTimeoutMs: 300_000`
526
- * (5 min), `maxRecoveryWork: 1000`, and a generic terminal message.
528
+ * Configuration for durable chat recovery, which is always enabled for chat
529
+ * turns. `true` uses these defaults: `maxAttempts: 10`,
530
+ * `stableTimeoutMs: 10_000`, `noProgressTimeoutMs: 300_000` (5 min),
531
+ * `maxRecoveryWork: 1000`, and a generic terminal message. Assign an object to
532
+ * tune recovery without disabling its durable bookkeeping.
527
533
  *
528
534
  * **Apply this as a class field or in the constructor — never assign it in
529
535
  * `onStart()`.** On every wake the SDK evaluates recovery budgets (and may seal
@@ -535,7 +541,7 @@ type ChatRecoveryProgressContext = {
535
541
  * `onStart()`.
536
542
  */
537
543
  type ChatRecoveryConfig =
538
- | boolean
544
+ | true
539
545
  | {
540
546
  maxAttempts?: number;
541
547
  stableTimeoutMs?: number;
@@ -596,8 +602,8 @@ type ChatRecoveryConfig =
596
602
  ): boolean | Promise<boolean>;
597
603
  onExhausted?(ctx: ChatRecoveryExhaustedContext): void | Promise<void>;
598
604
  };
605
+ /** Fully-defaulted configuration for always-on durable chat recovery. */
599
606
  type ResolvedChatRecoveryConfig = {
600
- enabled: boolean;
601
607
  maxAttempts: number;
602
608
  stableTimeoutMs: number;
603
609
  terminalMessage: string;
@@ -708,7 +714,7 @@ type BroadcastStreamEvent =
708
714
  error?: boolean;
709
715
  replay?: boolean;
710
716
  replayComplete?: boolean;
711
- continuation?: boolean /** Required when continuation=true so the accumulator can pick up existing parts. */;
717
+ continuation?: boolean /** @deprecated Continuations now seed from current messages in `messagesUpdate`. */;
712
718
  currentMessages?: UIMessage[];
713
719
  }
714
720
  | {
@@ -2272,7 +2278,8 @@ declare const CHAT_RECOVERY_ALARM_DEBOUNCE_MS: number;
2272
2278
  declare const CHAT_RECOVERING_FLAG_TTL_MS: number;
2273
2279
  /**
2274
2280
  * Resolve a raw `chatRecovery` config field into the fully-defaulted form the
2275
- * engine reasons about. Identical defaulting in both packages today.
2281
+ * engine reasons about. Durable recovery is always enabled; a legacy runtime
2282
+ * `false` value from previously compiled JavaScript safely receives defaults.
2276
2283
  */
2277
2284
  declare function resolveChatRecoveryConfig(
2278
2285
  raw: ChatRecoveryConfig | undefined
@@ -1,9 +1,9 @@
1
1
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "../classPrivateFieldGet2-DZBYAB34.js";
2
+ import { t as _classPrivateMethodInitSpec } from "../classPrivateMethodInitSpec-qMjJ6sHQ.js";
2
3
  import { i as normalizeToolInput, n as getPartialStreamText, r as isReplayChunk, t as applyChunkToParts } from "../message-builder-BymO4N_D.js";
3
4
  import { i as interceptAgentToolBroadcast, n as applyAgentToolEvent, r as createAgentToolEventState, t as AgentToolProgressEmitter } from "../agent-tools-y7zLfw4Q.js";
4
- import { t as _classPrivateMethodInitSpec } from "../classPrivateMethodInitSpec-qMjJ6sHQ.js";
5
5
  import { t as truncateToolOutput } from "../tool-output-truncation-CNnnGZQ3.js";
6
- import { i as StreamAccumulator, n as STREAM_RESUME_NONE_REASONS, r as transition, t as CHAT_MESSAGE_TYPES } from "../protocol-Dqc2MQxo.js";
6
+ import { i as StreamAccumulator, n as STREAM_RESUME_NONE_REASONS, r as transition, t as CHAT_MESSAGE_TYPES } from "../protocol-B0nh6KNf.js";
7
7
  import { t as MessageType } from "../wire-types-CnMt6_HR.js";
8
8
  import { jsonSchema, tool } from "ai";
9
9
  import { nanoid } from "nanoid";
@@ -2561,12 +2561,12 @@ const CHAT_RECOVERY_ALARM_DEBOUNCE_MS = 30 * 1e3;
2561
2561
  const CHAT_RECOVERING_FLAG_TTL_MS = 900 * 1e3;
2562
2562
  /**
2563
2563
  * Resolve a raw `chatRecovery` config field into the fully-defaulted form the
2564
- * engine reasons about. Identical defaulting in both packages today.
2564
+ * engine reasons about. Durable recovery is always enabled; a legacy runtime
2565
+ * `false` value from previously compiled JavaScript safely receives defaults.
2565
2566
  */
2566
2567
  function resolveChatRecoveryConfig(raw) {
2567
2568
  const custom = typeof raw === "object" && raw !== null ? raw : void 0;
2568
2569
  return {
2569
- enabled: raw !== false,
2570
2570
  maxAttempts: Math.max(1, Math.floor(custom?.maxAttempts ?? 10)),
2571
2571
  stableTimeoutMs: Math.max(0, Math.floor(custom?.stableTimeoutMs ?? 1e4)),
2572
2572
  terminalMessage: custom?.terminalMessage ?? "The assistant was interrupted and could not recover. Please try again.",