@agent-native/core 0.58.4 → 0.59.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/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +4 -51
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +84 -88
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat.d.ts +28 -0
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +84 -3
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts +2 -1
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +4 -2
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/terminal/AgentTerminal.d.ts.map +1 -1
- package/dist/client/terminal/AgentTerminal.js +6 -7
- package/dist/client/terminal/AgentTerminal.js.map +1 -1
- package/dist/client/use-agent-engine-configured.d.ts +16 -0
- package/dist/client/use-agent-engine-configured.d.ts.map +1 -0
- package/dist/client/use-agent-engine-configured.js +60 -0
- package/dist/client/use-agent-engine-configured.js.map +1 -0
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +13 -0
- package/dist/server/framework-request-handler.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiTabAssistantChat.d.ts","sourceRoot":"","sources":["../../src/client/MultiTabAssistantChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAUf,OAAO,EAEL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"MultiTabAssistantChat.d.ts","sourceRoot":"","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C,SAAS,CAAC;IAC5E,2DAA2D;IAC3D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,gCAAgC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC7E,sGAAsG;IACtG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,UAAiB,EACjB,YAAY,EACZ,aAAa,EACb,aAAqB,EACrB,MAAqD,EACrD,UAAU,EACV,mBAA0B,EAC1B,YAAY,EACZ,KAAY,EACZ,GAAG,KAAK,EACT,EAAE,0BAA0B,2CA4rD5B"}
|
|
@@ -12,7 +12,23 @@ import { callAction } from "./use-action.js";
|
|
|
12
12
|
import { RunStuckBanner } from "./RunStuckBanner.js";
|
|
13
13
|
import { DEFAULT_MODEL } from "../agent/default-model.js";
|
|
14
14
|
import { getReasoningEffortOptionsForModel, isReasoningEffort, } from "../shared/reasoning-effort.js";
|
|
15
|
-
import { AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE, AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE, AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, appendAgentChatContextToMessage, normalizeAgentChatContextItem, } from "./agent-chat.js";
|
|
15
|
+
import { AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE, AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE, AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, appendAgentChatContextToMessage, claimAgentChatSubmit, drainBufferedAgentChatSubmits, normalizeAgentChatContextItem, parseSubmitChatMessage, } from "./agent-chat.js";
|
|
16
|
+
/** The single path that hands a queued send to a mounted chat ref. */
|
|
17
|
+
function deliverPendingSend(ref, send) {
|
|
18
|
+
if (!send.submit) {
|
|
19
|
+
ref.prefillMessage(send.message);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (send.trackInRunsTray || send.requestMode) {
|
|
23
|
+
ref.sendMessage(send.message, send.images, {
|
|
24
|
+
...(send.trackInRunsTray ? { trackInRunsTray: true } : {}),
|
|
25
|
+
...(send.requestMode ? { requestMode: send.requestMode } : {}),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
ref.sendMessage(send.message, send.images);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
16
32
|
const MODEL_SELECTION_STORAGE_KEY = "agent-native:chat-models:selection";
|
|
17
33
|
function readStoredModelSelection(key) {
|
|
18
34
|
if (typeof window === "undefined")
|
|
@@ -265,9 +281,6 @@ function HelpPopover({ onClose }) {
|
|
|
265
281
|
function readString(value) {
|
|
266
282
|
return typeof value === "string" ? value.trim() : "";
|
|
267
283
|
}
|
|
268
|
-
function normalizeRequestMode(value) {
|
|
269
|
-
return value === "act" || value === "plan" ? value : undefined;
|
|
270
|
-
}
|
|
271
284
|
function requestModeFromExecMode(value) {
|
|
272
285
|
if (value === "plan")
|
|
273
286
|
return "plan";
|
|
@@ -321,7 +334,8 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
321
334
|
if (activeThreadId)
|
|
322
335
|
mountedTabsRef.current.add(activeThreadId);
|
|
323
336
|
const chatRefs = useRef(new Map());
|
|
324
|
-
|
|
337
|
+
// Sends queued until their target thread is ready (see PendingDelivery).
|
|
338
|
+
const pendingDeliveries = useRef([]);
|
|
325
339
|
const pendingContextItems = useRef(new Map());
|
|
326
340
|
const [runningThreads, setRunningThreads] = useState(new Set());
|
|
327
341
|
const [showHistory, setShowHistory] = useState(false);
|
|
@@ -968,25 +982,15 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
968
982
|
clearContextInTab(currentTabId);
|
|
969
983
|
return;
|
|
970
984
|
}
|
|
971
|
-
|
|
985
|
+
const parsed = parseSubmitChatMessage(event);
|
|
986
|
+
if (!parsed)
|
|
972
987
|
return;
|
|
973
|
-
|
|
974
|
-
if (!
|
|
988
|
+
// Dedup the live post against the cold-start replay; first one wins.
|
|
989
|
+
if (!claimAgentChatSubmit(parsed.submitMessageId))
|
|
975
990
|
return;
|
|
976
|
-
const context =
|
|
977
|
-
const
|
|
978
|
-
const
|
|
979
|
-
const effort = event.data.data?.effort;
|
|
980
|
-
const newTab = event.data.data?.newTab;
|
|
981
|
-
const tabId = event.data.data?.tabId;
|
|
982
|
-
const requestedTabId = typeof tabId === "string" ? tabId : undefined;
|
|
983
|
-
const background = event.data.data?.background;
|
|
984
|
-
const submit = event.data.data?.submit !== false;
|
|
985
|
-
const rawImages = event.data.data?.images;
|
|
986
|
-
const images = Array.isArray(rawImages)
|
|
987
|
-
? rawImages.filter((image) => typeof image === "string" && image.length > 0)
|
|
988
|
-
: undefined;
|
|
989
|
-
const requestMode = normalizeRequestMode(event.data.data?.requestMode ?? event.data.data?.mode) ?? requestModeFromExecMode(props.execMode);
|
|
991
|
+
const { message, context, openSidebar, model, effort, newTab, background, submit, images, } = parsed;
|
|
992
|
+
const requestedTabId = parsed.tabId;
|
|
993
|
+
const requestMode = parsed.requestMode ?? requestModeFromExecMode(props.execMode);
|
|
990
994
|
// Make sure the sidebar is visible to show the response, unless the
|
|
991
995
|
// caller explicitly opted out or it's a background send.
|
|
992
996
|
if (openSidebar !== false && !background) {
|
|
@@ -999,6 +1003,13 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
999
1003
|
const fullMessage = context
|
|
1000
1004
|
? appendAgentChatContextToMessage(message, context)
|
|
1001
1005
|
: message;
|
|
1006
|
+
const send = {
|
|
1007
|
+
message: fullMessage,
|
|
1008
|
+
images,
|
|
1009
|
+
submit,
|
|
1010
|
+
...(background ? { trackInRunsTray: true } : {}),
|
|
1011
|
+
...(requestMode ? { requestMode } : {}),
|
|
1012
|
+
};
|
|
1002
1013
|
const sendToTab = (threadId) => {
|
|
1003
1014
|
// If a model override was specified, apply it only if we recognize it
|
|
1004
1015
|
if (model) {
|
|
@@ -1019,32 +1030,11 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1019
1030
|
}
|
|
1020
1031
|
}
|
|
1021
1032
|
const ref = chatRefs.current.get(threadId);
|
|
1022
|
-
const sendOptions = background || requestMode
|
|
1023
|
-
? {
|
|
1024
|
-
...(background ? { trackInRunsTray: true } : {}),
|
|
1025
|
-
...(requestMode ? { requestMode } : {}),
|
|
1026
|
-
}
|
|
1027
|
-
: undefined;
|
|
1028
1033
|
if (ref) {
|
|
1029
|
-
|
|
1030
|
-
if (sendOptions) {
|
|
1031
|
-
ref.sendMessage(fullMessage, images, sendOptions);
|
|
1032
|
-
}
|
|
1033
|
-
else {
|
|
1034
|
-
ref.sendMessage(fullMessage, images);
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
else {
|
|
1038
|
-
ref.prefillMessage(fullMessage);
|
|
1039
|
-
}
|
|
1034
|
+
deliverPendingSend(ref, send);
|
|
1040
1035
|
}
|
|
1041
1036
|
else {
|
|
1042
|
-
|
|
1043
|
-
message: fullMessage,
|
|
1044
|
-
images,
|
|
1045
|
-
submit,
|
|
1046
|
-
...(sendOptions ? sendOptions : {}),
|
|
1047
|
-
});
|
|
1037
|
+
pendingDeliveries.current.push({ threadId, send });
|
|
1048
1038
|
}
|
|
1049
1039
|
};
|
|
1050
1040
|
if (newTab) {
|
|
@@ -1065,9 +1055,14 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1065
1055
|
}
|
|
1066
1056
|
else {
|
|
1067
1057
|
const currentTabId = activeThreadIdRef.current;
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1070
|
-
|
|
1058
|
+
if (currentTabId) {
|
|
1059
|
+
sendToTab(currentTabId);
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
// Cold start: no thread yet. Queue for the first active thread (the
|
|
1063
|
+
// bootstrap effect creates it) rather than racing a second create.
|
|
1064
|
+
pendingDeliveries.current.push({ threadId: null, send });
|
|
1065
|
+
}
|
|
1071
1066
|
}
|
|
1072
1067
|
};
|
|
1073
1068
|
window.addEventListener("message", handler);
|
|
@@ -1083,47 +1078,48 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1083
1078
|
setContextInTab,
|
|
1084
1079
|
switchThread,
|
|
1085
1080
|
]);
|
|
1086
|
-
//
|
|
1081
|
+
// Replay submits posted before this lazy panel's listener attached. Dedup in
|
|
1082
|
+
// the handler keeps a live + replayed message single.
|
|
1083
|
+
useEffect(() => {
|
|
1084
|
+
const buffered = drainBufferedAgentChatSubmits();
|
|
1085
|
+
for (const data of buffered) {
|
|
1086
|
+
window.dispatchEvent(new MessageEvent("message", {
|
|
1087
|
+
data: { type: "agentNative.submitChat", data },
|
|
1088
|
+
origin: window.location.origin,
|
|
1089
|
+
}));
|
|
1090
|
+
}
|
|
1091
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1092
|
+
}, []);
|
|
1093
|
+
// Flush queued context items and sends once their thread's ref is mounted
|
|
1094
|
+
// (re-runs on ref mount via openTabIds and on cold-start target via
|
|
1095
|
+
// activeThreadId).
|
|
1087
1096
|
useEffect(() => {
|
|
1088
|
-
const
|
|
1089
|
-
...pendingSends.current.keys(),
|
|
1090
|
-
...pendingContextItems.current.keys(),
|
|
1091
|
-
]);
|
|
1092
|
-
for (const tabId of pendingTabIds) {
|
|
1097
|
+
for (const [tabId, items] of pendingContextItems.current) {
|
|
1093
1098
|
const ref = chatRefs.current.get(tabId);
|
|
1094
|
-
if (ref)
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
else {
|
|
1115
|
-
ref.sendMessage(pending.message, pending.images);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
else {
|
|
1119
|
-
ref.prefillMessage(pending.message);
|
|
1120
|
-
}
|
|
1121
|
-
}, 50);
|
|
1122
|
-
pendingSends.current.delete(tabId);
|
|
1123
|
-
}
|
|
1099
|
+
if (!ref)
|
|
1100
|
+
continue;
|
|
1101
|
+
for (const item of items)
|
|
1102
|
+
ref.setComposerContextItem(item);
|
|
1103
|
+
pendingContextItems.current.delete(tabId);
|
|
1104
|
+
}
|
|
1105
|
+
if (pendingDeliveries.current.length === 0)
|
|
1106
|
+
return;
|
|
1107
|
+
const active = activeThreadIdRef.current;
|
|
1108
|
+
const remaining = [];
|
|
1109
|
+
for (const delivery of pendingDeliveries.current) {
|
|
1110
|
+
const threadId = delivery.threadId ?? active ?? null;
|
|
1111
|
+
const ref = threadId ? chatRefs.current.get(threadId) : null;
|
|
1112
|
+
if (threadId && ref) {
|
|
1113
|
+
const { send } = delivery;
|
|
1114
|
+
setTimeout(() => deliverPendingSend(ref, send), 50);
|
|
1115
|
+
}
|
|
1116
|
+
else {
|
|
1117
|
+
// Not ready — keep it, pinning the resolved threadId once known.
|
|
1118
|
+
remaining.push(threadId ? { threadId, send: delivery.send } : delivery);
|
|
1124
1119
|
}
|
|
1125
1120
|
}
|
|
1126
|
-
|
|
1121
|
+
pendingDeliveries.current = remaining;
|
|
1122
|
+
}, [openTabIds, activeThreadId]);
|
|
1127
1123
|
// Listen for chatRunning completion events
|
|
1128
1124
|
useEffect(() => {
|
|
1129
1125
|
const handler = (e) => {
|
|
@@ -1159,7 +1155,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1159
1155
|
dismissedSubAgentTabsRef.current.add(tabId);
|
|
1160
1156
|
}
|
|
1161
1157
|
chatRefs.current.delete(tabId);
|
|
1162
|
-
|
|
1158
|
+
pendingDeliveries.current = pendingDeliveries.current.filter((d) => d.threadId !== tabId);
|
|
1163
1159
|
pendingContextItems.current.delete(tabId);
|
|
1164
1160
|
newThreadIds.current.delete(tabId);
|
|
1165
1161
|
threadModelRef.current.delete(tabId);
|
|
@@ -1221,7 +1217,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1221
1217
|
dismissedSubAgentTabsRef.current.add(key);
|
|
1222
1218
|
}
|
|
1223
1219
|
chatRefs.current.delete(key);
|
|
1224
|
-
|
|
1220
|
+
pendingDeliveries.current = pendingDeliveries.current.filter((d) => d.threadId !== key);
|
|
1225
1221
|
pendingContextItems.current.delete(key);
|
|
1226
1222
|
newThreadIds.current.delete(key);
|
|
1227
1223
|
threadModelRef.current.delete(key);
|
|
@@ -1253,7 +1249,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1253
1249
|
dismissedSubAgentTabsRef.current.clear();
|
|
1254
1250
|
// Clean up all old refs
|
|
1255
1251
|
chatRefs.current.clear();
|
|
1256
|
-
|
|
1252
|
+
pendingDeliveries.current = [];
|
|
1257
1253
|
pendingContextItems.current.clear();
|
|
1258
1254
|
threadModelRef.current.clear();
|
|
1259
1255
|
setParentMap({});
|