agents 0.13.3 → 0.14.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 +6 -4
- package/dist/{agent-tool-types-l98LCbBl.d.ts → agent-tool-types-LInzZfLo.d.ts} +463 -116
- package/dist/agent-tool-types.d.ts +13 -11
- package/dist/{agent-tools-Bg5ilERh.d.ts → agent-tools-BE9xosUG.d.ts} +2 -2
- package/dist/agent-tools.d.ts +14 -20
- package/dist/agent-tools.js +10 -6
- package/dist/agent-tools.js.map +1 -1
- package/dist/browser/ai.d.ts +1 -1
- package/dist/browser/ai.js +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/tanstack-ai.d.ts +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/chat/index.d.ts +138 -19
- package/dist/chat/index.js +96 -12
- package/dist/chat/index.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +4 -4
- package/dist/classPrivateMethodInitSpec-bG0tD96O.js +7 -0
- package/dist/{client-D1kFXo80.js → client-NradHZZz.js} +206 -75
- package/dist/client-NradHZZz.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{compaction-helpers-fJyf8j4m.js → compaction-helpers-BjT2NKRZ.js} +22 -3
- package/dist/compaction-helpers-BjT2NKRZ.js.map +1 -0
- package/dist/{compaction-helpers-B-pG5J22.d.ts → compaction-helpers-DpP_XP9J.d.ts} +59 -33
- package/dist/{do-oauth-client-provider-4OKQU9rT.d.ts → do-oauth-client-provider-CPm9rK5I.d.ts} +1 -1
- package/dist/{email-J0GGS3sa.d.ts → email-1fTSJwPm.d.ts} +1 -1
- package/dist/email.d.ts +2 -2
- package/dist/experimental/memory/session/index.d.ts +30 -25
- package/dist/experimental/memory/session/index.js +7 -2
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/memory/utils/index.d.ts +12 -10
- package/dist/experimental/memory/utils/index.js +2 -2
- package/dist/{index-DKey3P4s.d.ts → index-Brdu5nMI.d.ts} +270 -1
- package/dist/index.d.ts +74 -67
- package/dist/index.js +467 -63
- package/dist/index.js.map +1 -1
- package/dist/{internal_context-BZrMS0B5.d.ts → internal_context-CcZy2Em7.d.ts} +1 -1
- package/dist/internal_context.d.ts +1 -1
- package/dist/mcp/client.d.ts +17 -13
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/index.d.ts +35 -27
- package/dist/mcp/index.js +402 -69
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.d.ts +1 -1
- package/dist/observability/index.js +15 -1
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/{retries-BVdRl5ZE.d.ts → retries-ClWwxADl.d.ts} +1 -1
- package/dist/retries.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{shared-Cvj92byG.d.ts → shared-CpY1FLvm.d.ts} +1 -1
- package/dist/{shared-CiKaIK4h.js → shared-DdOn6sp4.js} +3 -7
- package/dist/{shared-CiKaIK4h.js.map → shared-DdOn6sp4.js.map} +1 -1
- package/dist/skills/index.d.ts +236 -0
- package/dist/skills/index.js +1326 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/sub-routing.d.ts +6 -6
- package/dist/{tool-output-truncation-CH-khbZ3.js → tool-output-truncation-BF4AZQlw.js} +1 -1
- package/dist/{tool-output-truncation-CH-khbZ3.js.map → tool-output-truncation-BF4AZQlw.js.map} +1 -1
- package/dist/{types-_JjKmv-l.d.ts → types-B0GymtN_.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +248 -2
- package/dist/vite.js.map +1 -1
- package/dist/{workflow-types-Dkzg4hAx.d.ts → workflow-types-DPkuBi--.d.ts} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +13 -3
- package/dist/workflows.js +10 -1
- package/dist/workflows.js.map +1 -1
- package/package.json +21 -3
- package/skills-module.d.ts +22 -0
- package/dist/client-D1kFXo80.js.map +0 -1
- package/dist/compaction-helpers-fJyf8j4m.js.map +0 -1
package/dist/chat/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as isReplayChunk, n as createAgentToolEventState, r as applyChunkToParts, t as applyAgentToolEvent } from "../agent-tools-BAdX1vdI.js";
|
|
2
|
-
import { t as truncateToolOutput } from "../tool-output-truncation-
|
|
2
|
+
import { t as truncateToolOutput } from "../tool-output-truncation-BF4AZQlw.js";
|
|
3
3
|
import { jsonSchema, tool } from "ai";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
//#region src/chat/sanitize.ts
|
|
@@ -520,7 +520,8 @@ const CHAT_MESSAGE_TYPES = {
|
|
|
520
520
|
STREAM_RESUME_NONE: "cf_agent_stream_resume_none",
|
|
521
521
|
TOOL_RESULT: "cf_agent_tool_result",
|
|
522
522
|
TOOL_APPROVAL: "cf_agent_tool_approval",
|
|
523
|
-
MESSAGE_UPDATED: "cf_agent_message_updated"
|
|
523
|
+
MESSAGE_UPDATED: "cf_agent_message_updated",
|
|
524
|
+
CHAT_RECOVERING: "cf_agent_chat_recovering"
|
|
524
525
|
};
|
|
525
526
|
//#endregion
|
|
526
527
|
//#region src/chat/resumable-stream.ts
|
|
@@ -969,6 +970,22 @@ var ContinuationState = class {
|
|
|
969
970
|
this.activeConnectionId = null;
|
|
970
971
|
}
|
|
971
972
|
/**
|
|
973
|
+
* Mark a connection as no longer available without canceling the
|
|
974
|
+
* continuation it initiated.
|
|
975
|
+
*/
|
|
976
|
+
releaseConnection(connectionId) {
|
|
977
|
+
this.awaitingConnections.delete(connectionId);
|
|
978
|
+
if (this.pending?.connectionId === connectionId) this.pending = {
|
|
979
|
+
...this.pending,
|
|
980
|
+
connectionId: null
|
|
981
|
+
};
|
|
982
|
+
if (this.deferred?.connectionId === connectionId) this.deferred = {
|
|
983
|
+
...this.deferred,
|
|
984
|
+
connectionId: null
|
|
985
|
+
};
|
|
986
|
+
if (this.activeConnectionId === connectionId) this.activeConnectionId = null;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
972
989
|
* Send STREAM_RESUME_NONE to all connections waiting for a
|
|
973
990
|
* continuation stream to start, then clear the map.
|
|
974
991
|
*/
|
|
@@ -1019,7 +1036,7 @@ var ContinuationState = class {
|
|
|
1019
1036
|
prerequisite: d.prerequisite,
|
|
1020
1037
|
pastCoalesce: false
|
|
1021
1038
|
};
|
|
1022
|
-
this.awaitingConnections.set(d.connectionId, d.connection);
|
|
1039
|
+
if (d.connectionId !== null) this.awaitingConnections.set(d.connectionId, d.connection);
|
|
1023
1040
|
return this.pending;
|
|
1024
1041
|
}
|
|
1025
1042
|
};
|
|
@@ -1172,6 +1189,60 @@ function toolResultUpdate(toolCallId, output, overrideState, errorText) {
|
|
|
1172
1189
|
};
|
|
1173
1190
|
}
|
|
1174
1191
|
/**
|
|
1192
|
+
* Build an update descriptor for a terminal tool result that belongs to a
|
|
1193
|
+
* tool part in a *different* (earlier) assistant message than the one
|
|
1194
|
+
* currently being streamed.
|
|
1195
|
+
*
|
|
1196
|
+
* This is the "cross-message" case: an approved server tool executes during a
|
|
1197
|
+
* continuation stream, but its tool part lives in the assistant message that
|
|
1198
|
+
* originally requested it. `StreamAccumulator` surfaces this as a
|
|
1199
|
+
* `cross-message-tool-update` action because the accumulator only owns the
|
|
1200
|
+
* current turn's new content and cannot mutate a part from a prior message.
|
|
1201
|
+
*
|
|
1202
|
+
* Compared to {@link toolResultUpdate} this builder is deliberately more
|
|
1203
|
+
* defensive, mirroring the equivalent fallback in `@cloudflare/ai-chat`:
|
|
1204
|
+
*
|
|
1205
|
+
* - It matches the broad set of pre-terminal **and** terminal states, so a
|
|
1206
|
+
* provider that replays the entire prior tool round-trip during a
|
|
1207
|
+
* continuation (notably the OpenAI Responses API — issue #1404) still
|
|
1208
|
+
* resolves to the same part instead of silently missing it.
|
|
1209
|
+
* - It is **first-write-wins**: a chunk arriving for a tool that already holds
|
|
1210
|
+
* a terminal result is treated as a replay and the existing output is never
|
|
1211
|
+
* overwritten. In that case `apply` returns the *same part reference*, which
|
|
1212
|
+
* callers use as an idempotent-no-op signal to skip the durable write and a
|
|
1213
|
+
* redundant `MESSAGE_UPDATED` broadcast.
|
|
1214
|
+
* - It preserves a streamed `preliminary` flag when one is present, otherwise
|
|
1215
|
+
* marks the result final (`preliminary: false`).
|
|
1216
|
+
*/
|
|
1217
|
+
function crossMessageToolResultUpdate(toolCallId, updateType, output, errorText, preliminary) {
|
|
1218
|
+
return {
|
|
1219
|
+
toolCallId,
|
|
1220
|
+
matchStates: [
|
|
1221
|
+
"input-streaming",
|
|
1222
|
+
"input-available",
|
|
1223
|
+
"approval-requested",
|
|
1224
|
+
"approval-responded",
|
|
1225
|
+
"output-available",
|
|
1226
|
+
"output-error",
|
|
1227
|
+
"output-denied"
|
|
1228
|
+
],
|
|
1229
|
+
apply: (part) => {
|
|
1230
|
+
if (part.state === "output-available" || part.state === "output-error" || part.state === "output-denied") return part;
|
|
1231
|
+
if (updateType === "output-error") return {
|
|
1232
|
+
...part,
|
|
1233
|
+
state: "output-error",
|
|
1234
|
+
errorText: errorText ?? "Tool execution failed"
|
|
1235
|
+
};
|
|
1236
|
+
return {
|
|
1237
|
+
...part,
|
|
1238
|
+
state: "output-available",
|
|
1239
|
+
output,
|
|
1240
|
+
preliminary: preliminary ?? false
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1175
1246
|
* Build an update descriptor for applying a tool approval.
|
|
1176
1247
|
*
|
|
1177
1248
|
* Matches parts in `input-available` or `approval-requested` state.
|
|
@@ -1311,23 +1382,35 @@ function assistantContentKey(message, sanitize) {
|
|
|
1311
1382
|
return JSON.stringify(sanitized.parts);
|
|
1312
1383
|
}
|
|
1313
1384
|
function mergeServerToolOutputs(incoming, serverMessages) {
|
|
1314
|
-
const
|
|
1385
|
+
const serverResolvedParts = /* @__PURE__ */ new Map();
|
|
1315
1386
|
for (const msg of serverMessages) {
|
|
1316
1387
|
if (msg.role !== "assistant") continue;
|
|
1317
|
-
for (const part of msg.parts)
|
|
1388
|
+
for (const part of msg.parts) {
|
|
1389
|
+
const record = part;
|
|
1390
|
+
if ("toolCallId" in record && "state" in record && (record.state === "output-available" || record.state === "output-error" || record.state === "output-denied")) serverResolvedParts.set(record.toolCallId, record);
|
|
1391
|
+
}
|
|
1318
1392
|
}
|
|
1319
|
-
if (
|
|
1393
|
+
if (serverResolvedParts.size === 0) return incoming;
|
|
1320
1394
|
return incoming.map((msg) => {
|
|
1321
1395
|
if (msg.role !== "assistant") return msg;
|
|
1322
1396
|
let hasChanges = false;
|
|
1323
1397
|
const updatedParts = msg.parts.map((part) => {
|
|
1324
|
-
|
|
1398
|
+
const record = part;
|
|
1399
|
+
if ("toolCallId" in record && "state" in record && (record.state === "input-available" || record.state === "approval-requested" || record.state === "approval-responded") && serverResolvedParts.has(record.toolCallId)) {
|
|
1325
1400
|
hasChanges = true;
|
|
1326
|
-
|
|
1401
|
+
const server = serverResolvedParts.get(record.toolCallId);
|
|
1402
|
+
const merged = {
|
|
1327
1403
|
...part,
|
|
1328
|
-
state:
|
|
1329
|
-
output: serverToolOutputs.get(part.toolCallId)
|
|
1404
|
+
state: server.state
|
|
1330
1405
|
};
|
|
1406
|
+
if (server.state === "output-available") {
|
|
1407
|
+
if ("output" in server) merged.output = server.output;
|
|
1408
|
+
} else if (server.state === "output-error") {
|
|
1409
|
+
if ("errorText" in server) merged.errorText = server.errorText;
|
|
1410
|
+
} else if (server.state === "output-denied") {
|
|
1411
|
+
if ("approval" in server) merged.approval = server.approval;
|
|
1412
|
+
}
|
|
1413
|
+
return merged;
|
|
1331
1414
|
}
|
|
1332
1415
|
return part;
|
|
1333
1416
|
});
|
|
@@ -1379,7 +1462,7 @@ function findMessageByToolCallId(messages, toolCallId) {
|
|
|
1379
1462
|
}
|
|
1380
1463
|
//#endregion
|
|
1381
1464
|
//#region src/chat/recovery.ts
|
|
1382
|
-
function createChatFiberSnapshot({ kind, requestId, continuation, messages, lastBody, lastClientTools }) {
|
|
1465
|
+
function createChatFiberSnapshot({ kind, requestId, recoveryRootRequestId, continuation, messages, lastBody, lastClientTools }) {
|
|
1383
1466
|
const latestMessage = messages.length > 0 ? messages[messages.length - 1] : void 0;
|
|
1384
1467
|
let latestUser;
|
|
1385
1468
|
for (let index = messages.length - 1; index >= 0; index--) if (messages[index].role === "user") {
|
|
@@ -1390,6 +1473,7 @@ function createChatFiberSnapshot({ kind, requestId, continuation, messages, last
|
|
|
1390
1473
|
kind,
|
|
1391
1474
|
version: 1,
|
|
1392
1475
|
requestId,
|
|
1476
|
+
recoveryRootRequestId,
|
|
1393
1477
|
continuation,
|
|
1394
1478
|
latestMessageId: latestMessage?.id,
|
|
1395
1479
|
latestMessageRole: latestMessage?.role,
|
|
@@ -1427,6 +1511,6 @@ function unwrapChatFiberSnapshot(key, value, expectedKind) {
|
|
|
1427
1511
|
};
|
|
1428
1512
|
}
|
|
1429
1513
|
//#endregion
|
|
1430
|
-
export { AbortRegistry, CHAT_MESSAGE_TYPES, ContinuationState, ROW_MAX_BYTES, ResumableStream, StreamAccumulator, SubmitConcurrencyController, TurnQueue, applyAgentToolEvent, applyChunkToParts, applyToolUpdate, assistantContentKey, transition as broadcastTransition, byteLength, createAgentToolEventState, createChatFiberSnapshot, createToolsFromClientSchemas, enforceRowSizeLimit, isReplayChunk, parseProtocolMessage, reconcileMessages, resolveToolMergeId, sanitizeMessage, toolApprovalUpdate, toolResultUpdate, unwrapChatFiberSnapshot, wrapChatFiberSnapshot };
|
|
1514
|
+
export { AbortRegistry, CHAT_MESSAGE_TYPES, ContinuationState, ROW_MAX_BYTES, ResumableStream, StreamAccumulator, SubmitConcurrencyController, TurnQueue, applyAgentToolEvent, applyChunkToParts, applyToolUpdate, assistantContentKey, transition as broadcastTransition, byteLength, createAgentToolEventState, createChatFiberSnapshot, createToolsFromClientSchemas, crossMessageToolResultUpdate, enforceRowSizeLimit, isReplayChunk, parseProtocolMessage, reconcileMessages, resolveToolMergeId, sanitizeMessage, toolApprovalUpdate, toolResultUpdate, unwrapChatFiberSnapshot, wrapChatFiberSnapshot };
|
|
1431
1515
|
|
|
1432
1516
|
//# sourceMappingURL=index.js.map
|