@agent-native/core 0.14.5 → 0.14.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/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +54 -0
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +11 -1
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +120 -48
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/chat-threads/store.d.ts +6 -1
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +109 -40
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +8 -1
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +110 -5
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +7 -1
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +2 -2
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/mcp-client/manager.d.ts.map +1 -1
- package/dist/mcp-client/manager.js +10 -0
- package/dist/mcp-client/manager.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +6 -0
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/sentry.d.ts.map +1 -1
- package/dist/server/sentry.js +20 -0
- package/dist/server/sentry.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantChat.d.ts","sourceRoot":"","sources":["../../src/client/AssistantChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,C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E;IAClE,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAEjD,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,QAI9C;AAqCD,OAAO,EACL,iBAAiB,EAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA+gD7B,eAAO,MAAM,aAAa,gGA4DxB,CAAC"}
|
|
@@ -238,6 +238,64 @@ function activeRunLooksStale(runInfo) {
|
|
|
238
238
|
function repoHasAssistantMessage(repo) {
|
|
239
239
|
return repo?.messages?.some((m) => (m.message?.role ?? m.role) === "assistant");
|
|
240
240
|
}
|
|
241
|
+
function getRepoMessages(repo) {
|
|
242
|
+
return Array.isArray(repo?.messages) ? repo.messages : [];
|
|
243
|
+
}
|
|
244
|
+
function getRepoMessage(entry) {
|
|
245
|
+
return entry?.message ?? entry;
|
|
246
|
+
}
|
|
247
|
+
function isAssistantMessageTerminal(message) {
|
|
248
|
+
const statusType = message?.status && typeof message.status === "object"
|
|
249
|
+
? message.status.type
|
|
250
|
+
: undefined;
|
|
251
|
+
return statusType === "complete" || statusType === "incomplete";
|
|
252
|
+
}
|
|
253
|
+
function repoTextLength(repo) {
|
|
254
|
+
let length = 0;
|
|
255
|
+
for (const entry of getRepoMessages(repo)) {
|
|
256
|
+
const message = getRepoMessage(entry);
|
|
257
|
+
const content = message?.content;
|
|
258
|
+
if (typeof content === "string") {
|
|
259
|
+
length += content.length;
|
|
260
|
+
}
|
|
261
|
+
else if (Array.isArray(content)) {
|
|
262
|
+
for (const part of content) {
|
|
263
|
+
if (part?.type === "text" && typeof part.text === "string") {
|
|
264
|
+
length += part.text.length;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return length;
|
|
270
|
+
}
|
|
271
|
+
function repoTerminalAssistantCount(repo) {
|
|
272
|
+
return getRepoMessages(repo).filter((entry) => {
|
|
273
|
+
const message = getRepoMessage(entry);
|
|
274
|
+
return message?.role === "assistant" && isAssistantMessageTerminal(message);
|
|
275
|
+
}).length;
|
|
276
|
+
}
|
|
277
|
+
function shouldImportServerThreadData(currentRepo, incomingRepo) {
|
|
278
|
+
const incomingCount = getRepoMessages(incomingRepo).length;
|
|
279
|
+
if (incomingCount === 0)
|
|
280
|
+
return false;
|
|
281
|
+
const currentCount = getRepoMessages(currentRepo).length;
|
|
282
|
+
if (currentCount === 0)
|
|
283
|
+
return true;
|
|
284
|
+
if (incomingCount < currentCount)
|
|
285
|
+
return false;
|
|
286
|
+
if (incomingCount === currentCount) {
|
|
287
|
+
const currentTerminalAssistants = repoTerminalAssistantCount(currentRepo);
|
|
288
|
+
const incomingTerminalAssistants = repoTerminalAssistantCount(incomingRepo);
|
|
289
|
+
if (incomingTerminalAssistants < currentTerminalAssistants) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
if (incomingTerminalAssistants <= currentTerminalAssistants &&
|
|
293
|
+
repoTextLength(incomingRepo) < repoTextLength(currentRepo)) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
241
299
|
function clearPendingSelection() {
|
|
242
300
|
fetch(agentNativePath(`/_agent-native/application-state/${PENDING_SELECTION_KEY}`), {
|
|
243
301
|
method: "DELETE",
|
|
@@ -1433,7 +1491,7 @@ function ensureMessageMetadata(repo) {
|
|
|
1433
1491
|
return repo;
|
|
1434
1492
|
}
|
|
1435
1493
|
// Re-export for backwards compatibility
|
|
1436
|
-
import { extractThreadMeta } from "../agent/thread-data-builder.js";
|
|
1494
|
+
import { extractThreadMeta, normalizeThreadRepository, } from "../agent/thread-data-builder.js";
|
|
1437
1495
|
export { extractThreadMeta };
|
|
1438
1496
|
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, composerDisabled = false, composerDisabledPlaceholder, isNewThread, onSlashCommand, execMode, onExecModeChange, planModeDisabled, planModeDisabledReason, selectedModel, defaultModel, selectedEngine, selectedEffort, availableModels, onModelChange, onEffortChange, onForkChat, }, ref) {
|
|
1439
1497
|
const scrollRef = useRef(null);
|
|
@@ -1441,6 +1499,44 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1441
1499
|
const threadRuntime = useThreadRuntime();
|
|
1442
1500
|
const isRuntimeRunning = thread.isRunning;
|
|
1443
1501
|
const messages = thread.messages;
|
|
1502
|
+
// Patch the underlying assistant-ui MessageRepository so addOrUpdateMessage
|
|
1503
|
+
// can't throw "Parent message not found" mid-run. assistant-ui calls
|
|
1504
|
+
// `repository.clear()` from `runtime.import()` and from `resetHead(null)`,
|
|
1505
|
+
// and on a few async paths (history-adapter load, branch reset, repeat
|
|
1506
|
+
// imports) the repo can be cleared between the `append` that added the
|
|
1507
|
+
// user message and the `performRoundtrip` call that tries to record the
|
|
1508
|
+
// assistant placeholder against that user message's id. The internal-bug
|
|
1509
|
+
// throw turns into an unhandled rejection that Sentry captures from the
|
|
1510
|
+
// images.agent-native.com prompt composer (AGENT-NATIVE-BROWSER-18). Fix
|
|
1511
|
+
// it by relinking to the current head whenever the requested parent has
|
|
1512
|
+
// gone missing instead of throwing.
|
|
1513
|
+
useEffect(() => {
|
|
1514
|
+
const repo = threadRuntime?.__internal_threadBinding?.getState?.()
|
|
1515
|
+
?.repository;
|
|
1516
|
+
if (!repo || typeof repo.addOrUpdateMessage !== "function")
|
|
1517
|
+
return;
|
|
1518
|
+
const patched = repo;
|
|
1519
|
+
if (patched.__agentNativePatched)
|
|
1520
|
+
return;
|
|
1521
|
+
patched.__agentNativePatched = true;
|
|
1522
|
+
const original = repo.addOrUpdateMessage.bind(repo);
|
|
1523
|
+
repo.addOrUpdateMessage = function (parentId, message) {
|
|
1524
|
+
try {
|
|
1525
|
+
return original(parentId, message);
|
|
1526
|
+
}
|
|
1527
|
+
catch (err) {
|
|
1528
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1529
|
+
if (parentId && msg.includes("Parent message not found")) {
|
|
1530
|
+
const fallbackParent = this.head?.current?.id ?? null;
|
|
1531
|
+
if (fallbackParent && fallbackParent !== parentId) {
|
|
1532
|
+
return original(fallbackParent, message);
|
|
1533
|
+
}
|
|
1534
|
+
return original(null, message);
|
|
1535
|
+
}
|
|
1536
|
+
throw err;
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
}, [threadRuntime]);
|
|
1444
1540
|
const [missingApiKey, setMissingApiKey] = useState(false);
|
|
1445
1541
|
const isComposerDisabled = missingApiKey || composerDisabled;
|
|
1446
1542
|
// Increments each time the user clicks the (disabled) composer while no LLM
|
|
@@ -1498,12 +1594,21 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1498
1594
|
onGenerateTitleRef.current = onGenerateTitle;
|
|
1499
1595
|
const titleGeneratedRef = useRef(false);
|
|
1500
1596
|
const importThreadData = useCallback((threadData, options) => {
|
|
1501
|
-
const repo = typeof threadData === "string" ? JSON.parse(threadData) : threadData;
|
|
1597
|
+
const repo = normalizeThreadRepository(typeof threadData === "string" ? JSON.parse(threadData) : threadData);
|
|
1502
1598
|
if (repo?.messages?.length > 0) {
|
|
1503
|
-
|
|
1504
|
-
|
|
1599
|
+
let shouldImport = true;
|
|
1600
|
+
try {
|
|
1601
|
+
shouldImport = shouldImportServerThreadData(normalizeThreadRepository(threadRuntime.export()), repo);
|
|
1602
|
+
}
|
|
1603
|
+
catch {
|
|
1604
|
+
shouldImport = true;
|
|
1605
|
+
}
|
|
1606
|
+
if (shouldImport) {
|
|
1607
|
+
if (options?.markTitleGenerated) {
|
|
1608
|
+
titleGeneratedRef.current = true;
|
|
1609
|
+
}
|
|
1610
|
+
threadRuntime.import(ensureMessageMetadata(repo));
|
|
1505
1611
|
}
|
|
1506
|
-
threadRuntime.import(ensureMessageMetadata(repo));
|
|
1507
1612
|
}
|
|
1508
1613
|
if (Array.isArray(repo?.queuedMessages)) {
|
|
1509
1614
|
setQueuedMessages(repo.queuedMessages);
|