@agent-native/core 0.84.48 → 0.84.51
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/core/CHANGELOG.md +18 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/production-agent.ts +16 -6
- package/corpus/core/src/client/agent-chat-adapter.ts +40 -9
- package/corpus/core/src/client/sse-event-processor.ts +31 -15
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +14 -4
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +36 -9
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +4 -3
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +22 -5
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/routes.d.ts +2 -2
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- 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;AAkBrE,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,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AO,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,CAgjDlB"}
|
|
@@ -1055,6 +1055,7 @@ export function createAgentChatAdapter(options) {
|
|
|
1055
1055
|
const turnId = generateTurnId();
|
|
1056
1056
|
let runId = null;
|
|
1057
1057
|
let lastSeq = -1;
|
|
1058
|
+
const seenRunSeqs = new Map();
|
|
1058
1059
|
let currentRunDispatchMode = null;
|
|
1059
1060
|
let currentMessageText = normalizeMentions(recoveryMessageText.trim() || userMessageText);
|
|
1060
1061
|
let currentHistory = history;
|
|
@@ -1208,6 +1209,22 @@ export function createAgentChatAdapter(options) {
|
|
|
1208
1209
|
if (mode)
|
|
1209
1210
|
currentRunDispatchMode = mode;
|
|
1210
1211
|
};
|
|
1212
|
+
const rememberRunSeq = (seq) => {
|
|
1213
|
+
lastSeq = seq;
|
|
1214
|
+
if (runId) {
|
|
1215
|
+
seenRunSeqs.set(runId, seq);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
const reconnectCursorForRun = (nextRunId, previousRunId) => {
|
|
1219
|
+
const rememberedSeq = seenRunSeqs.get(nextRunId);
|
|
1220
|
+
if (rememberedSeq !== undefined) {
|
|
1221
|
+
lastSeq = rememberedSeq;
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
if (previousRunId !== nextRunId) {
|
|
1225
|
+
lastSeq = -1;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1211
1228
|
const currentSSEOptions = () => ({
|
|
1212
1229
|
durableBackgroundRun: currentRunDispatchMode?.startsWith("background") === true,
|
|
1213
1230
|
});
|
|
@@ -1305,7 +1322,7 @@ export function createAgentChatAdapter(options) {
|
|
|
1305
1322
|
}
|
|
1306
1323
|
updateCurrentRunDispatchMode(reconnectRes.headers.get("X-Dispatch-Mode"));
|
|
1307
1324
|
for await (const result of readSSEStream(reconnectRes.body, content, toolCallCounter, tabId, (seq) => {
|
|
1308
|
-
|
|
1325
|
+
rememberRunSeq(seq);
|
|
1309
1326
|
if (threadId)
|
|
1310
1327
|
updateActiveRunSeq(seq);
|
|
1311
1328
|
}, runId, currentSSEOptions())) {
|
|
@@ -1380,12 +1397,13 @@ export function createAgentChatAdapter(options) {
|
|
|
1380
1397
|
return false;
|
|
1381
1398
|
}
|
|
1382
1399
|
const activeRunId = String(active.runId);
|
|
1400
|
+
const previousRunId = runId;
|
|
1383
1401
|
runId = activeRunId;
|
|
1384
1402
|
if (!attemptedRunIds.includes(activeRunId)) {
|
|
1385
1403
|
attemptedRunIds.push(activeRunId);
|
|
1386
1404
|
}
|
|
1387
|
-
|
|
1388
|
-
setActiveRun({ threadId, runId: activeRunId, lastSeq
|
|
1405
|
+
reconnectCursorForRun(activeRunId, previousRunId);
|
|
1406
|
+
setActiveRun({ threadId, runId: activeRunId, lastSeq });
|
|
1389
1407
|
const reconnected = yield* reconnectCurrentRun();
|
|
1390
1408
|
if (reconnected)
|
|
1391
1409
|
return true;
|
|
@@ -1449,12 +1467,13 @@ export function createAgentChatAdapter(options) {
|
|
|
1449
1467
|
if (activeStatus !== "running" && activeStatus !== "starting") {
|
|
1450
1468
|
return false;
|
|
1451
1469
|
}
|
|
1470
|
+
const previousRunId = runId;
|
|
1452
1471
|
runId = activeRunId;
|
|
1453
1472
|
if (!attemptedRunIds.includes(activeRunId)) {
|
|
1454
1473
|
attemptedRunIds.push(activeRunId);
|
|
1455
1474
|
}
|
|
1456
|
-
|
|
1457
|
-
setActiveRun({ threadId, runId: activeRunId, lastSeq
|
|
1475
|
+
reconnectCursorForRun(activeRunId, previousRunId);
|
|
1476
|
+
setActiveRun({ threadId, runId: activeRunId, lastSeq });
|
|
1458
1477
|
const reconnected = yield* reconnectCurrentRun();
|
|
1459
1478
|
if (reconnected)
|
|
1460
1479
|
return true;
|
|
@@ -1834,13 +1853,14 @@ export function createAgentChatAdapter(options) {
|
|
|
1834
1853
|
}
|
|
1835
1854
|
if (activeRunId) {
|
|
1836
1855
|
try {
|
|
1856
|
+
const previousRunId = runId;
|
|
1837
1857
|
runId = activeRunId;
|
|
1838
1858
|
if (!attemptedRunIds.includes(runId)) {
|
|
1839
1859
|
attemptedRunIds.push(runId);
|
|
1840
1860
|
}
|
|
1841
|
-
|
|
1861
|
+
reconnectCursorForRun(activeRunId, previousRunId);
|
|
1842
1862
|
if (threadId) {
|
|
1843
|
-
setActiveRun({ threadId, runId, lastSeq
|
|
1863
|
+
setActiveRun({ threadId, runId, lastSeq });
|
|
1844
1864
|
}
|
|
1845
1865
|
const reconnected = yield* reconnectCurrentRun();
|
|
1846
1866
|
if (reconnected)
|
|
@@ -1959,7 +1979,7 @@ export function createAgentChatAdapter(options) {
|
|
|
1959
1979
|
setActiveRun({ threadId, runId, lastSeq: -1 });
|
|
1960
1980
|
}
|
|
1961
1981
|
for await (const result of readSSEStream(res.body, content, toolCallCounter, tabId, (seq) => {
|
|
1962
|
-
|
|
1982
|
+
rememberRunSeq(seq);
|
|
1963
1983
|
if (runId && threadId) {
|
|
1964
1984
|
updateActiveRunSeq(seq);
|
|
1965
1985
|
}
|
|
@@ -2132,9 +2152,16 @@ export function createAgentChatAdapter(options) {
|
|
|
2132
2152
|
if (activeReconnected)
|
|
2133
2153
|
return;
|
|
2134
2154
|
if (err instanceof AgentStartupTimeoutError) {
|
|
2135
|
-
|
|
2155
|
+
if (startupRecoveryAttempts < MAX_STARTUP_RECOVERY_ATTEMPTS) {
|
|
2156
|
+
await retryDelay(startupRecoveryAttempts++, abortSignal);
|
|
2157
|
+
if (abortSignal.aborted)
|
|
2158
|
+
return;
|
|
2159
|
+
continue;
|
|
2160
|
+
}
|
|
2161
|
+
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
2162
|
captureChatClientError(err, "startup-timeout", {
|
|
2137
2163
|
timeoutMs: err.timeoutMs,
|
|
2164
|
+
startupRecoveryAttempts,
|
|
2138
2165
|
});
|
|
2139
2166
|
const runError = {
|
|
2140
2167
|
message,
|