agents 0.11.5 → 0.11.7
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/dist/browser/ai.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/browser/tanstack-ai.js.map +1 -1
- package/dist/chat/index.d.ts +162 -88
- package/dist/chat/index.js +232 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/{classPrivateFieldGet2-DAZNVUKb.js → classPrivateFieldGet2-Bqby-AHD.js} +5 -5
- package/dist/{client-BYF13FDD.js → client-D1kFXo80.js} +7 -1
- package/dist/{client-BYF13FDD.js.map → client-D1kFXo80.js.map} +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/compaction-helpers-C_cN3z55.js.map +1 -1
- package/dist/email.js.map +1 -1
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/{index-DabjI66m.d.ts → index-BM7Nk0QD.d.ts} +21 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -15
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.js +1 -1
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/dist/{shared-BovR6hRc.js → shared-mfBbxjS1.js} +3 -3
- package/dist/{shared-BovR6hRc.js.map → shared-mfBbxjS1.js.map} +1 -1
- package/dist/sub-routing.d.ts +1 -1
- package/dist/sub-routing.js.map +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { MessageType } from "./types.js";
|
|
|
2
2
|
import { camelCaseToKebabCase } from "./utils.js";
|
|
3
3
|
import { createHeaderBasedEmailResolver, signAgentHeaders } from "./email.js";
|
|
4
4
|
import { __DO_NOT_USE_WILL_BREAK__agentContext } from "./internal_context.js";
|
|
5
|
-
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-
|
|
5
|
+
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-Bqby-AHD.js";
|
|
6
6
|
import { SUB_PREFIX, getSubAgentByName, parseSubAgentPath, routeSubAgentRequest } from "./sub-routing.js";
|
|
7
7
|
import { isErrorRetryable, tryN, validateRetryOptions } from "./retries.js";
|
|
8
|
-
import { o as RPC_DO_PREFIX, r as MCPConnectionState, s as DisposableStore, t as MCPClientManager } from "./client-
|
|
8
|
+
import { o as RPC_DO_PREFIX, r as MCPConnectionState, s as DisposableStore, t as MCPClientManager } from "./client-D1kFXo80.js";
|
|
9
9
|
import { DurableObjectOAuthClientProvider } from "./mcp/do-oauth-client-provider.js";
|
|
10
10
|
import { genericObservability } from "./observability/index.js";
|
|
11
11
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -157,10 +157,22 @@ const _sendIdentityWarnedClasses = /* @__PURE__ */ new WeakSet();
|
|
|
157
157
|
* Child classes can override specific options without spreading.
|
|
158
158
|
*/
|
|
159
159
|
const DEFAULT_AGENT_STATIC_OPTIONS = {
|
|
160
|
+
/** Whether the Agent should hibernate when inactive */
|
|
160
161
|
hibernate: true,
|
|
162
|
+
/** Whether to send identity (name, agent) to clients on connect */
|
|
161
163
|
sendIdentityOnConnect: true,
|
|
164
|
+
/**
|
|
165
|
+
* Timeout in seconds before a running interval schedule is considered "hung"
|
|
166
|
+
* and force-reset. Increase this if you have callbacks that legitimately
|
|
167
|
+
* take longer than 30 seconds.
|
|
168
|
+
*/
|
|
162
169
|
hungScheduleTimeoutSeconds: 30,
|
|
170
|
+
/**
|
|
171
|
+
* Interval in milliseconds for keepAlive() alarm heartbeats.
|
|
172
|
+
* Lower values mean faster recovery after eviction but more frequent alarms.
|
|
173
|
+
*/
|
|
163
174
|
keepAliveIntervalMs: DEFAULT_KEEP_ALIVE_INTERVAL_MS,
|
|
175
|
+
/** Default retry options for schedule(), queue(), and this.retry() */
|
|
164
176
|
retry: {
|
|
165
177
|
maxAttempts: 3,
|
|
166
178
|
baseDelayMs: 100,
|
|
@@ -1894,7 +1906,10 @@ var Agent = class Agent extends Server {
|
|
|
1894
1906
|
* Executes any scheduled tasks that are due.
|
|
1895
1907
|
*
|
|
1896
1908
|
* Calls super.alarm() first to ensure PartyServer's #ensureInitialized()
|
|
1897
|
-
* runs, which
|
|
1909
|
+
* runs, which resolves this.name from ctx.id.name (including for
|
|
1910
|
+
* facets, which are spawned with an explicit id so they have their
|
|
1911
|
+
* own ctx.id.name; pre-2026-03-15 alarms fall back to the legacy
|
|
1912
|
+
* __ps_name storage record) and calls onStart() if needed.
|
|
1898
1913
|
*
|
|
1899
1914
|
* @remarks
|
|
1900
1915
|
* To schedule a task, please use the `this.schedule` method instead.
|
|
@@ -2118,23 +2133,29 @@ var Agent = class Agent extends Server {
|
|
|
2118
2133
|
* parent and triggered "Cannot perform I/O on behalf of a different
|
|
2119
2134
|
* Durable Object" on the child.
|
|
2120
2135
|
*
|
|
2121
|
-
* We
|
|
2122
|
-
* so any code that legitimately branches on it
|
|
2123
|
-
* parent-owned alarms in schedule guards — sees
|
|
2124
|
-
* the first `onStart()` run. Broadcast paths no
|
|
2125
|
-
* facets, since facets can be directly
|
|
2126
|
-
* routing and have their own WebSocket
|
|
2136
|
+
* We set `_isFacet` eagerly (before `__unsafe_ensureInitialized`
|
|
2137
|
+
* runs `onStart()`) so any code that legitimately branches on it
|
|
2138
|
+
* — e.g. skipping parent-owned alarms in schedule guards — sees
|
|
2139
|
+
* the flag during the first `onStart()` run. Broadcast paths no
|
|
2140
|
+
* longer special-case facets, since facets can be directly
|
|
2141
|
+
* addressed via sub-agent routing and have their own WebSocket
|
|
2142
|
+
* connections.
|
|
2143
|
+
*
|
|
2144
|
+
* The facet's name (and `this.name` getter) is handled entirely by
|
|
2145
|
+
* partyserver via `ctx.id.name`, which is populated because the
|
|
2146
|
+
* parent passed an explicit `id: parentNs.idFromName(name)` to
|
|
2147
|
+
* `ctx.facets.get()` — see {@link _cf_resolveSubAgent}. No
|
|
2148
|
+
* `setName()` call or `__ps_name` storage write is needed; the
|
|
2149
|
+
* facet's name survives cold wake automatically because the
|
|
2150
|
+
* factory re-runs and `idFromName` is deterministic.
|
|
2127
2151
|
*
|
|
2128
2152
|
* @internal Called by {@link subAgent}.
|
|
2129
2153
|
*/
|
|
2130
2154
|
async _cf_initAsFacet(name, parentPath = []) {
|
|
2155
|
+
if (this.name !== name) throw new Error(`Facet bootstrap mismatch: expected this.name === "${name}" but got "${this.name}". This usually means the parent passed the wrong (or no) id to ctx.facets.get(). See _cf_resolveSubAgent.`);
|
|
2131
2156
|
this._isFacet = true;
|
|
2132
2157
|
this._parentPath = parentPath;
|
|
2133
|
-
await Promise.all([
|
|
2134
|
-
this.ctx.storage.put("cf_agents_is_facet", true),
|
|
2135
|
-
this.ctx.storage.put("__ps_name", name),
|
|
2136
|
-
this.ctx.storage.put("cf_agents_parent_path", parentPath)
|
|
2137
|
-
]);
|
|
2158
|
+
await Promise.all([this.ctx.storage.put("cf_agents_is_facet", true), this.ctx.storage.put("cf_agents_parent_path", parentPath)]);
|
|
2138
2159
|
await this.__unsafe_ensureInitialized();
|
|
2139
2160
|
}
|
|
2140
2161
|
/**
|
|
@@ -2256,7 +2277,17 @@ var Agent = class Agent extends Server {
|
|
|
2256
2277
|
if (!Cls) throw new Error(`Sub-agent class "${className}" not found in worker exports. Make sure the class is exported from your worker entry point and that the export name matches the class name.`);
|
|
2257
2278
|
if (name.includes("\0")) throw new Error(`Sub-agent name contains null character (\\0), which is reserved.`);
|
|
2258
2279
|
const facetKey = `${className}\0${name}`;
|
|
2259
|
-
const
|
|
2280
|
+
const parentClassName = this.constructor.name;
|
|
2281
|
+
const parentNs = ctx.exports[parentClassName];
|
|
2282
|
+
if (!parentNs?.idFromName) {
|
|
2283
|
+
const minificationHint = /^_*[a-z][a-z0-9]{0,2}$/.test(parentClassName) ? ` The class name "${parentClassName}" looks minified — make sure your bundler preserves class names (e.g. esbuild's \`keepNames: true\`).` : "";
|
|
2284
|
+
throw new Error(`Sub-agent bootstrap requires the parent class "${parentClassName}" to be bound as a Durable Object namespace, but ctx.exports["${parentClassName}"] is missing or doesn't expose idFromName.${minificationHint} Make sure the parent agent class is registered in your wrangler.jsonc durable_objects.bindings under its class name.`);
|
|
2285
|
+
}
|
|
2286
|
+
const facetId = parentNs.idFromName(name);
|
|
2287
|
+
const stub = ctx.facets.get(facetKey, () => ({
|
|
2288
|
+
class: Cls,
|
|
2289
|
+
id: facetId
|
|
2290
|
+
}));
|
|
2260
2291
|
const childParentPath = this.selfPath;
|
|
2261
2292
|
await stub._cf_initAsFacet(name, childParentPath);
|
|
2262
2293
|
this._recordSubAgent(className, name);
|