@agent-native/core 0.84.49 → 0.84.52
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +20 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/run-store.ts +33 -6
- package/corpus/core/src/client/AssistantChat.tsx +84 -23
- package/corpus/core/src/client/agent-chat-adapter.ts +59 -9
- package/corpus/core/src/client/blocks/library/DiffBlock.tsx +7 -5
- package/corpus/core/src/client/session-replay.ts +170 -47
- package/corpus/core/src/client/sse-event-processor.ts +106 -29
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +5 -0
- package/corpus/templates/analytics/changelog/2026-07-02-agent-chat-can-keep-working-through-longer-data-queries-inst.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-02-session-replay-playback-recovers-from-failed-snapshot-uploads.md +6 -0
- package/corpus/templates/analytics/netlify.toml +3 -0
- package/corpus/templates/analytics/server/lib/session-replay.ts +9 -5
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +3 -0
- package/corpus/templates/plan/changelog/2026-07-02-agent-chat-can-keep-working-through-longer-visual-plan-updat.md +6 -0
- package/corpus/templates/plan/netlify.toml +3 -0
- package/corpus/templates/plan/server/plugins/agent-chat.ts +4 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +30 -6
- package/dist/agent/run-store.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +64 -13
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +50 -9
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +6 -5
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +134 -39
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +29 -3
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +72 -18
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +7 -7
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat-adapter.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AAOhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-chat-adapter.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AAOhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAmBrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,oBAAoB;AAC9B;;;;GAIG;AACD,KAAK;AACP,0EAA0E;GACxE,WAAW,CAAC;AA+pChB;;;;GAIG;AACH;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC3C,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC5C,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,eAAe,GAAG,SAAS,CAAA;KAAE,CAAC;IACrD,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE;QAAE,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAA;KAAE,CAAC;IAC3D,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAkkDlB"}
|
|
@@ -1055,6 +1055,8 @@ export function createAgentChatAdapter(options) {
|
|
|
1055
1055
|
const turnId = generateTurnId();
|
|
1056
1056
|
let runId = null;
|
|
1057
1057
|
let lastSeq = -1;
|
|
1058
|
+
const seenRunSeqs = new Map();
|
|
1059
|
+
const preparingActionStatesByRun = new Map();
|
|
1058
1060
|
let currentRunDispatchMode = null;
|
|
1059
1061
|
let currentMessageText = normalizeMentions(recoveryMessageText.trim() || userMessageText);
|
|
1060
1062
|
let currentHistory = history;
|
|
@@ -1208,8 +1210,37 @@ export function createAgentChatAdapter(options) {
|
|
|
1208
1210
|
if (mode)
|
|
1209
1211
|
currentRunDispatchMode = mode;
|
|
1210
1212
|
};
|
|
1213
|
+
const rememberRunSeq = (seq) => {
|
|
1214
|
+
lastSeq = seq;
|
|
1215
|
+
if (runId) {
|
|
1216
|
+
seenRunSeqs.set(runId, seq);
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
const reconnectCursorForRun = (nextRunId, previousRunId) => {
|
|
1220
|
+
const rememberedSeq = seenRunSeqs.get(nextRunId);
|
|
1221
|
+
if (rememberedSeq !== undefined) {
|
|
1222
|
+
lastSeq = rememberedSeq;
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
if (previousRunId !== nextRunId) {
|
|
1226
|
+
lastSeq = -1;
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
const preparingActionStateForRun = (id) => {
|
|
1230
|
+
if (!id)
|
|
1231
|
+
return undefined;
|
|
1232
|
+
const existing = preparingActionStatesByRun.get(id);
|
|
1233
|
+
if (existing)
|
|
1234
|
+
return existing;
|
|
1235
|
+
const state = {};
|
|
1236
|
+
preparingActionStatesByRun.set(id, state);
|
|
1237
|
+
return state;
|
|
1238
|
+
};
|
|
1211
1239
|
const currentSSEOptions = () => ({
|
|
1212
1240
|
durableBackgroundRun: currentRunDispatchMode?.startsWith("background") === true,
|
|
1241
|
+
...(runId
|
|
1242
|
+
? { preparingActionState: preparingActionStateForRun(runId) }
|
|
1243
|
+
: {}),
|
|
1213
1244
|
});
|
|
1214
1245
|
const captureChatClientError = (error, phase, extra = {}) => {
|
|
1215
1246
|
captureError(error, {
|
|
@@ -1305,7 +1336,7 @@ export function createAgentChatAdapter(options) {
|
|
|
1305
1336
|
}
|
|
1306
1337
|
updateCurrentRunDispatchMode(reconnectRes.headers.get("X-Dispatch-Mode"));
|
|
1307
1338
|
for await (const result of readSSEStream(reconnectRes.body, content, toolCallCounter, tabId, (seq) => {
|
|
1308
|
-
|
|
1339
|
+
rememberRunSeq(seq);
|
|
1309
1340
|
if (threadId)
|
|
1310
1341
|
updateActiveRunSeq(seq);
|
|
1311
1342
|
}, runId, currentSSEOptions())) {
|
|
@@ -1380,12 +1411,13 @@ export function createAgentChatAdapter(options) {
|
|
|
1380
1411
|
return false;
|
|
1381
1412
|
}
|
|
1382
1413
|
const activeRunId = String(active.runId);
|
|
1414
|
+
const previousRunId = runId;
|
|
1383
1415
|
runId = activeRunId;
|
|
1384
1416
|
if (!attemptedRunIds.includes(activeRunId)) {
|
|
1385
1417
|
attemptedRunIds.push(activeRunId);
|
|
1386
1418
|
}
|
|
1387
|
-
|
|
1388
|
-
setActiveRun({ threadId, runId: activeRunId, lastSeq
|
|
1419
|
+
reconnectCursorForRun(activeRunId, previousRunId);
|
|
1420
|
+
setActiveRun({ threadId, runId: activeRunId, lastSeq });
|
|
1389
1421
|
const reconnected = yield* reconnectCurrentRun();
|
|
1390
1422
|
if (reconnected)
|
|
1391
1423
|
return true;
|
|
@@ -1449,12 +1481,13 @@ export function createAgentChatAdapter(options) {
|
|
|
1449
1481
|
if (activeStatus !== "running" && activeStatus !== "starting") {
|
|
1450
1482
|
return false;
|
|
1451
1483
|
}
|
|
1484
|
+
const previousRunId = runId;
|
|
1452
1485
|
runId = activeRunId;
|
|
1453
1486
|
if (!attemptedRunIds.includes(activeRunId)) {
|
|
1454
1487
|
attemptedRunIds.push(activeRunId);
|
|
1455
1488
|
}
|
|
1456
|
-
|
|
1457
|
-
setActiveRun({ threadId, runId: activeRunId, lastSeq
|
|
1489
|
+
reconnectCursorForRun(activeRunId, previousRunId);
|
|
1490
|
+
setActiveRun({ threadId, runId: activeRunId, lastSeq });
|
|
1458
1491
|
const reconnected = yield* reconnectCurrentRun();
|
|
1459
1492
|
if (reconnected)
|
|
1460
1493
|
return true;
|
|
@@ -1834,13 +1867,14 @@ export function createAgentChatAdapter(options) {
|
|
|
1834
1867
|
}
|
|
1835
1868
|
if (activeRunId) {
|
|
1836
1869
|
try {
|
|
1870
|
+
const previousRunId = runId;
|
|
1837
1871
|
runId = activeRunId;
|
|
1838
1872
|
if (!attemptedRunIds.includes(runId)) {
|
|
1839
1873
|
attemptedRunIds.push(runId);
|
|
1840
1874
|
}
|
|
1841
|
-
|
|
1875
|
+
reconnectCursorForRun(activeRunId, previousRunId);
|
|
1842
1876
|
if (threadId) {
|
|
1843
|
-
setActiveRun({ threadId, runId, lastSeq
|
|
1877
|
+
setActiveRun({ threadId, runId, lastSeq });
|
|
1844
1878
|
}
|
|
1845
1879
|
const reconnected = yield* reconnectCurrentRun();
|
|
1846
1880
|
if (reconnected)
|
|
@@ -1959,7 +1993,7 @@ export function createAgentChatAdapter(options) {
|
|
|
1959
1993
|
setActiveRun({ threadId, runId, lastSeq: -1 });
|
|
1960
1994
|
}
|
|
1961
1995
|
for await (const result of readSSEStream(res.body, content, toolCallCounter, tabId, (seq) => {
|
|
1962
|
-
|
|
1996
|
+
rememberRunSeq(seq);
|
|
1963
1997
|
if (runId && threadId) {
|
|
1964
1998
|
updateActiveRunSeq(seq);
|
|
1965
1999
|
}
|
|
@@ -2132,9 +2166,16 @@ export function createAgentChatAdapter(options) {
|
|
|
2132
2166
|
if (activeReconnected)
|
|
2133
2167
|
return;
|
|
2134
2168
|
if (err instanceof AgentStartupTimeoutError) {
|
|
2135
|
-
|
|
2169
|
+
if (startupRecoveryAttempts < MAX_STARTUP_RECOVERY_ATTEMPTS) {
|
|
2170
|
+
await retryDelay(startupRecoveryAttempts++, abortSignal);
|
|
2171
|
+
if (abortSignal.aborted)
|
|
2172
|
+
return;
|
|
2173
|
+
continue;
|
|
2174
|
+
}
|
|
2175
|
+
const message = "The agent chat endpoint did not start streaming in time after several recovery attempts. This usually means prompt setup, the LLM gateway, or the provider is stalled.";
|
|
2136
2176
|
captureChatClientError(err, "startup-timeout", {
|
|
2137
2177
|
timeoutMs: err.timeoutMs,
|
|
2178
|
+
startupRecoveryAttempts,
|
|
2138
2179
|
});
|
|
2139
2180
|
const runError = {
|
|
2140
2181
|
message,
|