@dudko.dev/agent-web-react 0.0.31 → 0.0.33
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 +35 -8
- package/dist/{chunk-EMF7DTGS.js → chunk-G5GGIMD4.js} +29 -1
- package/dist/chunk-G5GGIMD4.js.map +1 -0
- package/dist/{elicitation-DbW6QKxS.d.cts → elicitation-B6h_-yLg.d.cts} +62 -3
- package/dist/{elicitation-DbW6QKxS.d.ts → elicitation-B6h_-yLg.d.ts} +62 -3
- package/dist/index.cjs +515 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -16
- package/dist/index.d.ts +153 -16
- package/dist/index.js +513 -72
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/pipeline.cjs.map +1 -1
- package/dist/pipeline.js +1 -1
- package/dist/styles.css +23 -0
- package/package.json +4 -3
- package/dist/chunk-EMF7DTGS.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -46,13 +46,14 @@ import {
|
|
|
46
46
|
ToolIcon,
|
|
47
47
|
XIcon,
|
|
48
48
|
errMessage,
|
|
49
|
+
followOtherTabs,
|
|
49
50
|
formatDuration,
|
|
50
51
|
formatProbability,
|
|
51
52
|
formatTokens,
|
|
52
53
|
imagesInOutput,
|
|
53
54
|
previewValue,
|
|
54
55
|
webSearchOf
|
|
55
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-G5GGIMD4.js";
|
|
56
57
|
import {
|
|
57
58
|
MCP_APP_POLICY_TOKEN_MAX_CHARS,
|
|
58
59
|
MCP_APP_SANDBOX_PROXY_READY,
|
|
@@ -64,6 +65,7 @@ import {
|
|
|
64
65
|
|
|
65
66
|
// src/hooks/use-agent.ts
|
|
66
67
|
import { useCallback, useEffect, useReducer, useRef, useState } from "react";
|
|
68
|
+
import * as core from "@dudko.dev/agent-web";
|
|
67
69
|
import {
|
|
68
70
|
createAgent,
|
|
69
71
|
createRunControl
|
|
@@ -190,6 +192,7 @@ var createInitialAgentState = () => ({
|
|
|
190
192
|
events: [],
|
|
191
193
|
seq: 0
|
|
192
194
|
});
|
|
195
|
+
var BLOCKER_MARK = "[BLOCKER]";
|
|
193
196
|
var resetRun = (state) => ({
|
|
194
197
|
...createInitialAgentState(),
|
|
195
198
|
status: state.status,
|
|
@@ -226,6 +229,7 @@ var addElicitation = (state, event, extra) => state.elicitations?.some((e) => e.
|
|
|
226
229
|
...event.url ? { url: event.url } : {},
|
|
227
230
|
...extra.stepId ? { stepId: extra.stepId } : {},
|
|
228
231
|
...extra.subagent ? { subagent: extra.subagent } : {},
|
|
232
|
+
...extra.remote ? { remote: true } : {},
|
|
229
233
|
status: "pending"
|
|
230
234
|
}
|
|
231
235
|
]
|
|
@@ -442,6 +446,7 @@ var applySubagent = (state, event, ancestors, ctx) => {
|
|
|
442
446
|
...node?.role ? { role: node.role } : {}
|
|
443
447
|
},
|
|
444
448
|
...inner.skill ? { skill: inner.skill } : {},
|
|
449
|
+
...ctx.remote ? { remote: true } : {},
|
|
445
450
|
status: "pending"
|
|
446
451
|
}
|
|
447
452
|
]
|
|
@@ -466,6 +471,7 @@ var applySubagent = (state, event, ancestors, ctx) => {
|
|
|
466
471
|
case "mcp.elicitation-requested": {
|
|
467
472
|
const node = inner.subagent ? known.subagents.find((s) => s.id === inner.subagent.id) : void 0;
|
|
468
473
|
return addElicitation(known, inner, {
|
|
474
|
+
...ctx.remote ? { remote: true } : {},
|
|
469
475
|
// The subagent's own step ids mean nothing here: the step that delegated it does.
|
|
470
476
|
stepId: (node ?? known.subagents.find((s) => s.id === event.id))?.stepId,
|
|
471
477
|
...inner.subagent ? {
|
|
@@ -504,6 +510,7 @@ var applySubagent = (state, event, ancestors, ctx) => {
|
|
|
504
510
|
return fileDeleted(known, inner.path);
|
|
505
511
|
// An app a subagent's call came with is shown in the turn too, and says whose call it was.
|
|
506
512
|
case "mcp.app": {
|
|
513
|
+
if (ctx.remote) return known;
|
|
507
514
|
const node = known.subagents.find((s) => s.id === event.id);
|
|
508
515
|
return addApp(known, inner, {
|
|
509
516
|
id: event.id,
|
|
@@ -595,14 +602,37 @@ var streamAssistant = (messages, content) => {
|
|
|
595
602
|
}
|
|
596
603
|
return messages;
|
|
597
604
|
};
|
|
605
|
+
var WAITING_ID = "waiting-for-session";
|
|
606
|
+
var withoutBusy = (state) => {
|
|
607
|
+
if (!state.sessionBusy) return state;
|
|
608
|
+
const { sessionBusy: _over, ...rest } = state;
|
|
609
|
+
void _over;
|
|
610
|
+
return { ...rest, queued: rest.queued.filter((q) => q.id !== WAITING_ID) };
|
|
611
|
+
};
|
|
612
|
+
var withoutSubmitted = (state) => {
|
|
613
|
+
if (!state.submitted) return state;
|
|
614
|
+
const { submitted, ...rest } = state;
|
|
615
|
+
const ids = /* @__PURE__ */ new Set([submitted.userId, submitted.assistantId]);
|
|
616
|
+
return { ...rest, messages: rest.messages.filter((m) => !ids.has(m.id)) };
|
|
617
|
+
};
|
|
618
|
+
var keepSubmitted = (state) => {
|
|
619
|
+
if (!state.submitted) return state;
|
|
620
|
+
const { submitted: _kept, ...rest } = state;
|
|
621
|
+
void _kept;
|
|
622
|
+
return rest;
|
|
623
|
+
};
|
|
598
624
|
var applyEvent = (state, event, ctx) => {
|
|
599
625
|
switch (event.type) {
|
|
600
626
|
case "run.start": {
|
|
601
|
-
const base = resetRun(state);
|
|
627
|
+
const base = resetRun(ctx.remote ? state : withoutSubmitted(state));
|
|
602
628
|
const userId = `msg-${base.seq}`;
|
|
603
629
|
const assistantId = `msg-${base.seq + 1}`;
|
|
604
630
|
return {
|
|
605
631
|
...base,
|
|
632
|
+
// Another tab's run keeps the view of it; a run of this tab's ends it (and any wait).
|
|
633
|
+
...ctx.remote && state.remote ? { remote: state.remote } : {},
|
|
634
|
+
// ...and this tab's sent turn, still waiting for its own run.start (or a session.busy).
|
|
635
|
+
...ctx.remote && state.submitted ? { submitted: state.submitted } : {},
|
|
606
636
|
goal: event.goal,
|
|
607
637
|
runStartedAt: ctx.at,
|
|
608
638
|
runMessageId: assistantId,
|
|
@@ -613,9 +643,16 @@ var applyEvent = (state, event, ctx) => {
|
|
|
613
643
|
role: "user",
|
|
614
644
|
content: event.goal,
|
|
615
645
|
pending: false,
|
|
646
|
+
...ctx.remote ? { remote: true } : {},
|
|
616
647
|
...ctx.attachments?.length ? { attachments: ctx.attachments } : {}
|
|
617
648
|
},
|
|
618
|
-
{
|
|
649
|
+
{
|
|
650
|
+
id: assistantId,
|
|
651
|
+
role: "assistant",
|
|
652
|
+
content: "",
|
|
653
|
+
pending: true,
|
|
654
|
+
...ctx.remote ? { remote: true } : {}
|
|
655
|
+
}
|
|
619
656
|
],
|
|
620
657
|
seq: base.seq + 2
|
|
621
658
|
};
|
|
@@ -697,7 +734,13 @@ var applyEvent = (state, event, ctx) => {
|
|
|
697
734
|
case "step.text-delta":
|
|
698
735
|
return {
|
|
699
736
|
...state,
|
|
700
|
-
|
|
737
|
+
// "[BLOCKER]" is the executor's signal to the core that a step cannot be completed (the
|
|
738
|
+
// core strips it from the step's summary): never a word for the user. Stripped from the
|
|
739
|
+
// text as it accumulates, so a marker split across two deltas goes too.
|
|
740
|
+
steps: patchStep(state.steps, event.step.id, (s) => ({
|
|
741
|
+
...s,
|
|
742
|
+
text: (s.text + event.delta).split(BLOCKER_MARK).join("")
|
|
743
|
+
}))
|
|
701
744
|
};
|
|
702
745
|
case "step.tool-call": {
|
|
703
746
|
const tagged = new Set(
|
|
@@ -849,9 +892,15 @@ var applyEvent = (state, event, ctx) => {
|
|
|
849
892
|
case "file.deleted":
|
|
850
893
|
return fileDeleted(state, event.path);
|
|
851
894
|
case "mcp.app":
|
|
852
|
-
return addApp(state, event);
|
|
895
|
+
return ctx.remote ? state : addApp(state, event);
|
|
853
896
|
case "message.queued":
|
|
854
|
-
return state.queued.some((q) => q.id === event.id) ? state : {
|
|
897
|
+
return state.queued.some((q) => q.id === event.id) ? state : {
|
|
898
|
+
...state,
|
|
899
|
+
queued: [
|
|
900
|
+
...state.queued,
|
|
901
|
+
{ id: event.id, text: event.text, ...event.origin ? { origin: event.origin } : {} }
|
|
902
|
+
]
|
|
903
|
+
};
|
|
855
904
|
case "message.delivered": {
|
|
856
905
|
const anchor = event.at === "round" ? runningStepId(state.steps) : event.at === "step" ? state.steps[state.steps.length - 1]?.id : void 0;
|
|
857
906
|
return {
|
|
@@ -859,7 +908,13 @@ var applyEvent = (state, event, ctx) => {
|
|
|
859
908
|
queued: state.queued.filter((q) => q.id !== event.id),
|
|
860
909
|
notes: [
|
|
861
910
|
...state.notes,
|
|
862
|
-
{
|
|
911
|
+
{
|
|
912
|
+
id: event.id,
|
|
913
|
+
text: event.text,
|
|
914
|
+
at: event.at,
|
|
915
|
+
...anchor ? { stepId: anchor } : {},
|
|
916
|
+
...event.origin ? { origin: event.origin } : {}
|
|
917
|
+
}
|
|
863
918
|
]
|
|
864
919
|
};
|
|
865
920
|
}
|
|
@@ -886,6 +941,8 @@ var applyEvent = (state, event, ctx) => {
|
|
|
886
941
|
};
|
|
887
942
|
case "mcp.elicitation-requested":
|
|
888
943
|
return addElicitation(state, event, {
|
|
944
|
+
// Asked in the tab that runs the tool call: shown here, answered there.
|
|
945
|
+
...ctx.remote ? { remote: true } : {},
|
|
889
946
|
stepId: event.step?.id,
|
|
890
947
|
...event.subagent ? { subagent: event.subagent } : {}
|
|
891
948
|
});
|
|
@@ -905,6 +962,8 @@ var applyEvent = (state, event, ctx) => {
|
|
|
905
962
|
...event.subagent ? { subagent: event.subagent } : {},
|
|
906
963
|
...event.app ? { app: event.app } : {},
|
|
907
964
|
...event.skill ? { skill: event.skill } : {},
|
|
965
|
+
// Asked in the tab that runs the tool: shown here, answered there.
|
|
966
|
+
...ctx.remote ? { remote: true } : {},
|
|
908
967
|
status: "pending"
|
|
909
968
|
}
|
|
910
969
|
]
|
|
@@ -989,9 +1048,26 @@ var applyEvent = (state, event, ctx) => {
|
|
|
989
1048
|
};
|
|
990
1049
|
case "budget.exceeded":
|
|
991
1050
|
return { ...state, budget: { kind: event.kind, tokens: event.tokens, cap: event.cap } };
|
|
992
|
-
case "
|
|
1051
|
+
case "session.busy":
|
|
1052
|
+
state = withoutSubmitted(state);
|
|
993
1053
|
return {
|
|
994
1054
|
...state,
|
|
1055
|
+
sessionBusy: { heldBy: event.heldBy, ...ctx.goal ? { goal: ctx.goal } : {} },
|
|
1056
|
+
// What the user sent waits with the run: shown as queued, not lost.
|
|
1057
|
+
...ctx.goal ? {
|
|
1058
|
+
queued: [
|
|
1059
|
+
...state.queued.filter((q) => q.id !== WAITING_ID),
|
|
1060
|
+
{ id: WAITING_ID, text: ctx.goal }
|
|
1061
|
+
]
|
|
1062
|
+
} : {}
|
|
1063
|
+
};
|
|
1064
|
+
case "session.acquired":
|
|
1065
|
+
return withoutBusy(state);
|
|
1066
|
+
case "stopped":
|
|
1067
|
+
if (!ctx.remote && state.sessionBusy) return withoutBusy(state);
|
|
1068
|
+
if (!ctx.remote && state.submitted) return withoutSubmitted(state);
|
|
1069
|
+
return {
|
|
1070
|
+
...withoutBusy(state),
|
|
995
1071
|
stopped: true,
|
|
996
1072
|
// Nothing of the run is waiting any more once it has stopped (an app's request is not
|
|
997
1073
|
// the run's).
|
|
@@ -1017,8 +1093,9 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1017
1093
|
};
|
|
1018
1094
|
}
|
|
1019
1095
|
return event.phase === "run" ? {
|
|
1020
|
-
...state,
|
|
1096
|
+
...withoutBusy(keepSubmitted(state)),
|
|
1021
1097
|
error: event.error,
|
|
1098
|
+
errorCode: event.code,
|
|
1022
1099
|
messages: finalizeAssistant(
|
|
1023
1100
|
state.messages,
|
|
1024
1101
|
state.finalText || `Error: ${event.error}`,
|
|
@@ -1062,6 +1139,8 @@ var syncRunMessage = (state) => {
|
|
|
1062
1139
|
messages[i] = { ...m, ...patch };
|
|
1063
1140
|
return { ...state, messages };
|
|
1064
1141
|
};
|
|
1142
|
+
var pendingApprovalsOf = (state) => state.approvals.filter((a) => a.status === "pending" && !a.remote);
|
|
1143
|
+
var agentStatusOf = (state) => state.remote?.running && (state.status === "ready" || state.status === "idle") ? "running" : state.status;
|
|
1065
1144
|
var agentStateReducer = (state, action) => {
|
|
1066
1145
|
switch (action.type) {
|
|
1067
1146
|
case "reset":
|
|
@@ -1073,22 +1152,69 @@ var agentStateReducer = (state, action) => {
|
|
|
1073
1152
|
};
|
|
1074
1153
|
case "notebook":
|
|
1075
1154
|
return { ...state, learned: action.lessons };
|
|
1155
|
+
case "submitted": {
|
|
1156
|
+
if (state.submitted) return state;
|
|
1157
|
+
const userId = `msg-${state.seq}`;
|
|
1158
|
+
const assistantId = `msg-${state.seq + 1}`;
|
|
1159
|
+
return {
|
|
1160
|
+
...state,
|
|
1161
|
+
submitted: { userId, assistantId },
|
|
1162
|
+
messages: [
|
|
1163
|
+
...state.messages,
|
|
1164
|
+
{
|
|
1165
|
+
id: userId,
|
|
1166
|
+
role: "user",
|
|
1167
|
+
content: action.goal,
|
|
1168
|
+
pending: false,
|
|
1169
|
+
...action.attachments?.length ? { attachments: action.attachments } : {}
|
|
1170
|
+
},
|
|
1171
|
+
{ id: assistantId, role: "assistant", content: "", pending: true }
|
|
1172
|
+
],
|
|
1173
|
+
seq: state.seq + 2
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1076
1176
|
case "status":
|
|
1077
1177
|
return {
|
|
1078
1178
|
...state,
|
|
1079
1179
|
status: action.status,
|
|
1080
|
-
error: action.status === "error" ? action.error : void 0
|
|
1180
|
+
error: action.status === "error" ? action.error : void 0,
|
|
1181
|
+
errorCode: void 0
|
|
1081
1182
|
};
|
|
1183
|
+
case "remote": {
|
|
1184
|
+
const remote = action.remote;
|
|
1185
|
+
if (!remote) {
|
|
1186
|
+
const { remote: _gone, ...rest } = state;
|
|
1187
|
+
void _gone;
|
|
1188
|
+
return rest;
|
|
1189
|
+
}
|
|
1190
|
+
if (remote.ended === "gone" && state.remote?.running) {
|
|
1191
|
+
return syncRunMessage({
|
|
1192
|
+
...state,
|
|
1193
|
+
remote,
|
|
1194
|
+
messages: finalizeAssistant(state.messages, state.finalText, { error: true })
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return { ...state, remote };
|
|
1198
|
+
}
|
|
1082
1199
|
case "event": {
|
|
1083
1200
|
const next = syncRunMessage(
|
|
1084
|
-
applyEvent(state, action.event, {
|
|
1201
|
+
applyEvent(state, action.event, {
|
|
1202
|
+
at: action.at,
|
|
1203
|
+
attachments: action.attachments,
|
|
1204
|
+
...action.remote ? { remote: true } : {},
|
|
1205
|
+
...action.goal ? { goal: action.goal } : {}
|
|
1206
|
+
})
|
|
1085
1207
|
);
|
|
1086
1208
|
const cap = action.maxEvents ?? 200;
|
|
1087
1209
|
const events = cap > 0 ? [...state.events, action.event].slice(-cap) : [...state.events, action.event];
|
|
1088
1210
|
return { ...next, events };
|
|
1089
1211
|
}
|
|
1090
1212
|
case "undelivered":
|
|
1091
|
-
return {
|
|
1213
|
+
return {
|
|
1214
|
+
...state,
|
|
1215
|
+
queued: action.keepQueued ? state.queued : [],
|
|
1216
|
+
undelivered: action.texts
|
|
1217
|
+
};
|
|
1092
1218
|
case "load": {
|
|
1093
1219
|
const maxSeq = action.messages.reduce((n, m) => {
|
|
1094
1220
|
const k = Number(/^msg-(\d+)$/.exec(m.id)?.[1] ?? -1);
|
|
@@ -1109,6 +1235,10 @@ var agentStateReducer = (state, action) => {
|
|
|
1109
1235
|
};
|
|
1110
1236
|
|
|
1111
1237
|
// src/hooks/use-agent.ts
|
|
1238
|
+
var dbNameOf = (store) => {
|
|
1239
|
+
const name = store?.dbName;
|
|
1240
|
+
return typeof name === "string" && name ? name : void 0;
|
|
1241
|
+
};
|
|
1112
1242
|
var useAgent = (config, options = {}) => {
|
|
1113
1243
|
const [state, dispatch] = useReducer(agentStateReducer, void 0, createInitialAgentState);
|
|
1114
1244
|
const agentRef = useRef(void 0);
|
|
@@ -1181,6 +1311,57 @@ var useAgent = (config, options = {}) => {
|
|
|
1181
1311
|
cancelled = true;
|
|
1182
1312
|
};
|
|
1183
1313
|
}, [generation, autoStart, ...deps ?? []]);
|
|
1314
|
+
const watchRef = useRef(void 0);
|
|
1315
|
+
const startedRef = useRef(false);
|
|
1316
|
+
const watchDb = options.watch !== false && config.sessionLock !== "off" ? dbNameOf(config.memory) : void 0;
|
|
1317
|
+
useEffect(() => {
|
|
1318
|
+
const watchSession3 = core.watchSession;
|
|
1319
|
+
if (!watchDb || typeof watchSession3 !== "function") return;
|
|
1320
|
+
const watch = watchSession3({
|
|
1321
|
+
dbName: watchDb,
|
|
1322
|
+
sessionId,
|
|
1323
|
+
onEvent: (event) => {
|
|
1324
|
+
if (startedRef.current) return;
|
|
1325
|
+
dispatch({
|
|
1326
|
+
type: "event",
|
|
1327
|
+
event,
|
|
1328
|
+
remote: true,
|
|
1329
|
+
maxEvents: optionsRef.current.maxEvents,
|
|
1330
|
+
at: Date.now()
|
|
1331
|
+
});
|
|
1332
|
+
},
|
|
1333
|
+
onState: (s) => {
|
|
1334
|
+
if (startedRef.current && s.running) return;
|
|
1335
|
+
dispatch({
|
|
1336
|
+
type: "remote",
|
|
1337
|
+
remote: {
|
|
1338
|
+
running: s.running,
|
|
1339
|
+
...s.runId ? { runId: s.runId } : {},
|
|
1340
|
+
...s.ended ? { ended: s.ended } : {}
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
watchRef.current = watch;
|
|
1346
|
+
return () => {
|
|
1347
|
+
watch.close();
|
|
1348
|
+
if (watchRef.current === watch) watchRef.current = void 0;
|
|
1349
|
+
};
|
|
1350
|
+
}, [watchDb, sessionId]);
|
|
1351
|
+
const skillsDb = dbNameOf(typeof config.learning === "object" ? config.learning.store : void 0);
|
|
1352
|
+
useEffect(() => {
|
|
1353
|
+
return followOtherTabs(
|
|
1354
|
+
core,
|
|
1355
|
+
skillsDb,
|
|
1356
|
+
(change) => change.kind === "skills",
|
|
1357
|
+
() => {
|
|
1358
|
+
const agent = agentRef.current;
|
|
1359
|
+
if (!agent || typeof agent.reloadLearnedSkills !== "function") return;
|
|
1360
|
+
void agent.reloadLearnedSkills().then((skills) => dispatch({ type: "notebook", lessons: lessonsOf(skills) })).catch(() => {
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
);
|
|
1364
|
+
}, [skillsDb]);
|
|
1184
1365
|
useEffect(
|
|
1185
1366
|
() => () => {
|
|
1186
1367
|
abortRef.current?.abort();
|
|
@@ -1199,7 +1380,17 @@ var useAgent = (config, options = {}) => {
|
|
|
1199
1380
|
const control = createRunControl();
|
|
1200
1381
|
controlRef.current = control;
|
|
1201
1382
|
let left = [];
|
|
1383
|
+
let stopped = false;
|
|
1384
|
+
let began = false;
|
|
1385
|
+
const shownGoal = runOptions?.label ?? goal;
|
|
1202
1386
|
dispatch({ type: "status", status: "running" });
|
|
1387
|
+
if (shownGoal.trim()) {
|
|
1388
|
+
dispatch({
|
|
1389
|
+
type: "submitted",
|
|
1390
|
+
goal: shownGoal,
|
|
1391
|
+
...runOptions?.attachments?.length ? { attachments: runOptions.attachments } : {}
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1203
1394
|
try {
|
|
1204
1395
|
const result = await agent.run(goal, {
|
|
1205
1396
|
signal: controller.signal,
|
|
@@ -1209,12 +1400,18 @@ var useAgent = (config, options = {}) => {
|
|
|
1209
1400
|
...runOptions?.files?.length ? { files: runOptions.files } : {},
|
|
1210
1401
|
onEvent: (event) => {
|
|
1211
1402
|
const start = event.type === "run.start";
|
|
1403
|
+
if (start) {
|
|
1404
|
+
startedRef.current = true;
|
|
1405
|
+
began = true;
|
|
1406
|
+
}
|
|
1212
1407
|
const shown = start && runOptions?.label ? { ...event, goal: runOptions.label } : event;
|
|
1213
1408
|
dispatch({
|
|
1214
1409
|
type: "event",
|
|
1215
1410
|
event: shown,
|
|
1216
1411
|
maxEvents: optionsRef.current.maxEvents,
|
|
1217
1412
|
at: Date.now(),
|
|
1413
|
+
// What the user sent waits with the run: shown as queued meanwhile.
|
|
1414
|
+
...event.type === "session.busy" && shownGoal.trim() ? { goal: shownGoal } : {},
|
|
1218
1415
|
...start && runOptions?.attachments?.length ? { attachments: runOptions.attachments } : {}
|
|
1219
1416
|
});
|
|
1220
1417
|
try {
|
|
@@ -1224,6 +1421,7 @@ var useAgent = (config, options = {}) => {
|
|
|
1224
1421
|
}
|
|
1225
1422
|
});
|
|
1226
1423
|
left = result.undelivered ?? [];
|
|
1424
|
+
stopped = result.stopped;
|
|
1227
1425
|
return result;
|
|
1228
1426
|
} catch (err) {
|
|
1229
1427
|
left = control.pending();
|
|
@@ -1235,11 +1433,13 @@ var useAgent = (config, options = {}) => {
|
|
|
1235
1433
|
return void 0;
|
|
1236
1434
|
} finally {
|
|
1237
1435
|
abortRef.current = void 0;
|
|
1436
|
+
startedRef.current = false;
|
|
1238
1437
|
controlRef.current = void 0;
|
|
1239
1438
|
settleAll({ approved: false, reason: "the run ended" });
|
|
1240
1439
|
dispatch({ type: "status", ...buildStatusRef.current });
|
|
1440
|
+
if (stopped && !began && shownGoal.trim()) left = [shownGoal, ...left];
|
|
1241
1441
|
if (left.length > 0) {
|
|
1242
|
-
if (!controller.signal.aborted && optionsRef.current.followUp !== false) {
|
|
1442
|
+
if (!controller.signal.aborted && !stopped && optionsRef.current.followUp !== false) {
|
|
1243
1443
|
dispatch({ type: "undelivered", texts: [] });
|
|
1244
1444
|
void runRef.current?.(left.join("\n\n"));
|
|
1245
1445
|
} else {
|
|
@@ -1254,6 +1454,24 @@ var useAgent = (config, options = {}) => {
|
|
|
1254
1454
|
);
|
|
1255
1455
|
runRef.current = run;
|
|
1256
1456
|
const send = useCallback((text) => controlRef.current?.send(text) ?? false, []);
|
|
1457
|
+
const sendRemote = useCallback((text) => {
|
|
1458
|
+
const watch = watchRef.current;
|
|
1459
|
+
const clean = typeof text === "string" ? text.trim() : "";
|
|
1460
|
+
if (!watch?.state.running || !clean) return false;
|
|
1461
|
+
void watch.send(clean).then((ok) => {
|
|
1462
|
+
if (!ok) {
|
|
1463
|
+
dispatch({
|
|
1464
|
+
type: "undelivered",
|
|
1465
|
+
texts: [...stateRef.current.undelivered, clean],
|
|
1466
|
+
keepQueued: true
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
return true;
|
|
1471
|
+
}, []);
|
|
1472
|
+
const stopRemote = useCallback(() => {
|
|
1473
|
+
if (watchRef.current?.state.running) void watchRef.current.stop();
|
|
1474
|
+
}, []);
|
|
1257
1475
|
const stopSubagent = useCallback(
|
|
1258
1476
|
(id) => controlRef.current?.stopSubagent(id) ?? false,
|
|
1259
1477
|
[]
|
|
@@ -1370,11 +1588,16 @@ var useAgent = (config, options = {}) => {
|
|
|
1370
1588
|
}
|
|
1371
1589
|
return result;
|
|
1372
1590
|
}, []);
|
|
1591
|
+
const remoteRunning = state.remote?.running === true;
|
|
1373
1592
|
return {
|
|
1374
1593
|
...state,
|
|
1594
|
+
// `running` over ready / idle only: a build in progress or an error stays visible.
|
|
1595
|
+
status: agentStatusOf(state),
|
|
1375
1596
|
run,
|
|
1376
1597
|
stop,
|
|
1598
|
+
stopRemote,
|
|
1377
1599
|
send,
|
|
1600
|
+
sendRemote,
|
|
1378
1601
|
stopSubagent,
|
|
1379
1602
|
forgetSkill,
|
|
1380
1603
|
sendUndelivered,
|
|
@@ -1382,9 +1605,10 @@ var useAgent = (config, options = {}) => {
|
|
|
1382
1605
|
reset,
|
|
1383
1606
|
reload,
|
|
1384
1607
|
agent: agentRef.current,
|
|
1385
|
-
isRunning: state.status === "running",
|
|
1386
|
-
isReady: state.status === "ready",
|
|
1387
|
-
|
|
1608
|
+
isRunning: state.status === "running" || remoteRunning,
|
|
1609
|
+
isReady: state.status === "ready" && !remoteRunning,
|
|
1610
|
+
// Another tab's consent requests are answered there, never here.
|
|
1611
|
+
pendingApprovals: pendingApprovalsOf(state),
|
|
1388
1612
|
approve,
|
|
1389
1613
|
deny,
|
|
1390
1614
|
approvalMode,
|
|
@@ -1399,26 +1623,36 @@ var useAgent = (config, options = {}) => {
|
|
|
1399
1623
|
|
|
1400
1624
|
// src/hooks/use-chat-history.ts
|
|
1401
1625
|
import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
1626
|
+
import * as core3 from "@dudko.dev/agent-web";
|
|
1402
1627
|
|
|
1403
1628
|
// src/chat-history.ts
|
|
1629
|
+
import * as core2 from "@dudko.dev/agent-web";
|
|
1404
1630
|
var DB_VERSION = 1;
|
|
1405
1631
|
var req = (r) => new Promise((resolve, reject) => {
|
|
1406
1632
|
r.onsuccess = () => resolve(r.result);
|
|
1407
1633
|
r.onerror = () => reject(r.error);
|
|
1408
1634
|
});
|
|
1635
|
+
var committed = (tx, r) => new Promise((resolve, reject) => {
|
|
1636
|
+
tx.oncomplete = () => resolve();
|
|
1637
|
+
tx.onabort = () => reject(tx.error ?? r.error ?? new Error("the transaction was aborted"));
|
|
1638
|
+
tx.onerror = () => reject(tx.error ?? r.error);
|
|
1639
|
+
});
|
|
1409
1640
|
var ChatHistoryStore = class {
|
|
1641
|
+
/** The IndexedDB database (undefined in memory): the name its `chats` notices go out under. */
|
|
1410
1642
|
dbName;
|
|
1643
|
+
name;
|
|
1411
1644
|
storeName;
|
|
1412
1645
|
memory;
|
|
1413
1646
|
db;
|
|
1414
1647
|
constructor(opts = {}) {
|
|
1415
|
-
this.
|
|
1648
|
+
this.name = opts.dbName ?? "agent-web-react";
|
|
1416
1649
|
this.storeName = opts.storeName ?? "chats";
|
|
1417
1650
|
if (opts.memory || typeof indexedDB === "undefined") this.memory = /* @__PURE__ */ new Map();
|
|
1651
|
+
this.dbName = this.memory ? void 0 : this.name;
|
|
1418
1652
|
}
|
|
1419
1653
|
open() {
|
|
1420
1654
|
this.db ??= new Promise((resolve, reject) => {
|
|
1421
|
-
const r = indexedDB.open(this.
|
|
1655
|
+
const r = indexedDB.open(this.name, DB_VERSION);
|
|
1422
1656
|
r.onupgradeneeded = () => {
|
|
1423
1657
|
if (!r.result.objectStoreNames.contains(this.storeName)) {
|
|
1424
1658
|
r.result.createObjectStore(this.storeName, { keyPath: "id" });
|
|
@@ -1436,6 +1670,54 @@ var ChatHistoryStore = class {
|
|
|
1436
1670
|
const db = await this.open();
|
|
1437
1671
|
return db.transaction(this.storeName, mode).objectStore(this.storeName);
|
|
1438
1672
|
}
|
|
1673
|
+
/** One write in its own transaction, resolved once it committed - then the notice. */
|
|
1674
|
+
async write(op, notice) {
|
|
1675
|
+
const db = await this.open();
|
|
1676
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
1677
|
+
await committed(tx, op(tx.objectStore(this.storeName)));
|
|
1678
|
+
this.announce(notice);
|
|
1679
|
+
}
|
|
1680
|
+
announce(notice) {
|
|
1681
|
+
if (typeof core2.postStorageChange === "function") {
|
|
1682
|
+
core2.postStorageChange(this.dbName, { kind: "chats", ...notice });
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Read the stored record and write what `merge` makes of it in ONE readwrite transaction: no
|
|
1687
|
+
* other tab's save can land between the read and the write. `merge` is synchronous (a
|
|
1688
|
+
* transaction does not survive an await). Resolves with what was written, once committed.
|
|
1689
|
+
*/
|
|
1690
|
+
async putMerged(id, merge) {
|
|
1691
|
+
if (this.memory) {
|
|
1692
|
+
const record = merge(this.memory.get(id));
|
|
1693
|
+
this.memory.set(record.id, structuredClone(record));
|
|
1694
|
+
return record;
|
|
1695
|
+
}
|
|
1696
|
+
const db = await this.open();
|
|
1697
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
1698
|
+
const store = tx.objectStore(this.storeName);
|
|
1699
|
+
let written;
|
|
1700
|
+
let failed;
|
|
1701
|
+
const read = store.get(id);
|
|
1702
|
+
const done = committed(tx, read);
|
|
1703
|
+
read.onsuccess = () => {
|
|
1704
|
+
try {
|
|
1705
|
+
written = merge(read.result);
|
|
1706
|
+
store.put(written);
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
failed = err;
|
|
1709
|
+
tx.abort();
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
try {
|
|
1713
|
+
await done;
|
|
1714
|
+
} catch (err) {
|
|
1715
|
+
throw failed ?? err;
|
|
1716
|
+
}
|
|
1717
|
+
if (!written) throw new Error("the chat could not be saved");
|
|
1718
|
+
this.announce({ op: "put", key: id });
|
|
1719
|
+
return written;
|
|
1720
|
+
}
|
|
1439
1721
|
async list() {
|
|
1440
1722
|
const all = this.memory ? [...this.memory.values()] : await req((await this.tx("readonly")).getAll());
|
|
1441
1723
|
return all.map(({ messages, ...rest }) => ({ ...rest, messageCount: messages.length })).sort((a, b) => b.updatedAt - a.updatedAt);
|
|
@@ -1449,21 +1731,21 @@ var ChatHistoryStore = class {
|
|
|
1449
1731
|
this.memory.set(record.id, structuredClone(record));
|
|
1450
1732
|
return;
|
|
1451
1733
|
}
|
|
1452
|
-
await
|
|
1734
|
+
await this.write((store) => store.put(record), { op: "put", key: record.id });
|
|
1453
1735
|
}
|
|
1454
1736
|
async delete(id) {
|
|
1455
1737
|
if (this.memory) {
|
|
1456
1738
|
this.memory.delete(id);
|
|
1457
1739
|
return;
|
|
1458
1740
|
}
|
|
1459
|
-
await
|
|
1741
|
+
await this.write((store) => store.delete(id), { op: "delete", key: id });
|
|
1460
1742
|
}
|
|
1461
1743
|
async clear() {
|
|
1462
1744
|
if (this.memory) {
|
|
1463
1745
|
this.memory.clear();
|
|
1464
1746
|
return;
|
|
1465
1747
|
}
|
|
1466
|
-
await
|
|
1748
|
+
await this.write((store) => store.clear(), { op: "clear" });
|
|
1467
1749
|
}
|
|
1468
1750
|
};
|
|
1469
1751
|
var chatTitle = (messages) => {
|
|
@@ -1474,6 +1756,61 @@ var chatTitle = (messages) => {
|
|
|
1474
1756
|
var newChatId = () => `chat-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1475
1757
|
|
|
1476
1758
|
// src/hooks/use-chat-history.ts
|
|
1759
|
+
var USAGE_KEYS = [
|
|
1760
|
+
"inputTokens",
|
|
1761
|
+
"outputTokens",
|
|
1762
|
+
"totalTokens",
|
|
1763
|
+
"reasoningTokens",
|
|
1764
|
+
"cachedInputTokens",
|
|
1765
|
+
"cacheWriteTokens"
|
|
1766
|
+
];
|
|
1767
|
+
var sumUsage = (base, more) => {
|
|
1768
|
+
const out = { ...base ?? {} };
|
|
1769
|
+
for (const u of more) {
|
|
1770
|
+
if (!u) continue;
|
|
1771
|
+
for (const k of USAGE_KEYS) out[k] = (out[k] ?? 0) + (u[k] ?? 0);
|
|
1772
|
+
}
|
|
1773
|
+
for (const k of USAGE_KEYS) out[k] ??= 0;
|
|
1774
|
+
return out;
|
|
1775
|
+
};
|
|
1776
|
+
var renumber = (own, after) => {
|
|
1777
|
+
let next = after.reduce(
|
|
1778
|
+
(max, m) => Math.max(max, Number(/^msg-(\d+)$/.exec(m.id)?.[1] ?? -1)),
|
|
1779
|
+
-1
|
|
1780
|
+
);
|
|
1781
|
+
return own.map((m) => ({ ...m, id: `msg-${next += 1}` }));
|
|
1782
|
+
};
|
|
1783
|
+
var unchangedSince = (messages, base) => base !== void 0 && messages.length === base.known.size && messages.every((m) => base.known.has(m));
|
|
1784
|
+
var mergeChatRecord = (view, stored, base) => {
|
|
1785
|
+
const local = view.messages.filter((m) => !m.remote);
|
|
1786
|
+
if (!stored || base && stored.updatedAt <= base.updatedAt) {
|
|
1787
|
+
return { record: { ...view, messages: local }, merged: false };
|
|
1788
|
+
}
|
|
1789
|
+
const own = local.filter((m) => !base?.known.has(m));
|
|
1790
|
+
const messages = [...stored.messages, ...renumber(own, stored.messages)];
|
|
1791
|
+
return {
|
|
1792
|
+
record: {
|
|
1793
|
+
...view,
|
|
1794
|
+
createdAt: stored.createdAt,
|
|
1795
|
+
title: chatTitle(messages),
|
|
1796
|
+
messages,
|
|
1797
|
+
totalUsage: sumUsage(
|
|
1798
|
+
stored.totalUsage,
|
|
1799
|
+
own.map((m) => m.role === "assistant" ? m.usage : void 0)
|
|
1800
|
+
)
|
|
1801
|
+
},
|
|
1802
|
+
merged: true
|
|
1803
|
+
};
|
|
1804
|
+
};
|
|
1805
|
+
var saveChat = async (store, view, base) => {
|
|
1806
|
+
let merged = false;
|
|
1807
|
+
const record = await store.putMerged(view.id, (stored) => {
|
|
1808
|
+
const out = mergeChatRecord(view, stored, base);
|
|
1809
|
+
merged = out.merged;
|
|
1810
|
+
return out.record;
|
|
1811
|
+
});
|
|
1812
|
+
return { record, merged };
|
|
1813
|
+
};
|
|
1477
1814
|
var useChatHistory = (agent, options = {}) => {
|
|
1478
1815
|
const enabled = options.enabled !== false;
|
|
1479
1816
|
const store = useMemo(() => options.store ?? new ChatHistoryStore(), [options.store]);
|
|
@@ -1482,6 +1819,8 @@ var useChatHistory = (agent, options = {}) => {
|
|
|
1482
1819
|
const createdRef = useRef2(/* @__PURE__ */ new Map());
|
|
1483
1820
|
const agentRef = useRef2(agent);
|
|
1484
1821
|
agentRef.current = agent;
|
|
1822
|
+
const baseRef = useRef2(void 0);
|
|
1823
|
+
const staleRef = useRef2(void 0);
|
|
1485
1824
|
const refresh = useCallback2(async () => {
|
|
1486
1825
|
try {
|
|
1487
1826
|
setChats(await store.list());
|
|
@@ -1496,6 +1835,7 @@ var useChatHistory = (agent, options = {}) => {
|
|
|
1496
1835
|
const record = await store.get(id).catch(() => void 0);
|
|
1497
1836
|
if (!record) return;
|
|
1498
1837
|
createdRef.current.set(id, record.createdAt);
|
|
1838
|
+
baseRef.current = { id, known: new Set(record.messages), updatedAt: record.updatedAt };
|
|
1499
1839
|
agentRef.current.loadChat({
|
|
1500
1840
|
sessionId: record.id,
|
|
1501
1841
|
messages: record.messages,
|
|
@@ -1528,13 +1868,43 @@ var useChatHistory = (agent, options = {}) => {
|
|
|
1528
1868
|
active = false;
|
|
1529
1869
|
};
|
|
1530
1870
|
}, [enabled, store]);
|
|
1531
|
-
const { messages, totalUsage, sessionId, isRunning } = agent;
|
|
1532
1871
|
useEffect2(() => {
|
|
1533
|
-
if (!enabled
|
|
1872
|
+
if (!enabled) return;
|
|
1873
|
+
let openSaved;
|
|
1874
|
+
return followOtherTabs(
|
|
1875
|
+
core3,
|
|
1876
|
+
store.dbName,
|
|
1877
|
+
(change) => {
|
|
1878
|
+
if (change.kind !== "chats") return false;
|
|
1879
|
+
if (change.op === "put" && change.key === agentRef.current.sessionId) openSaved = change.key;
|
|
1880
|
+
return true;
|
|
1881
|
+
},
|
|
1882
|
+
() => {
|
|
1883
|
+
void refresh();
|
|
1884
|
+
const key = openSaved;
|
|
1885
|
+
openSaved = void 0;
|
|
1886
|
+
const current = agentRef.current;
|
|
1887
|
+
if (key === void 0 || key !== current.sessionId) return;
|
|
1888
|
+
if (current.remote?.running) staleRef.current = key;
|
|
1889
|
+
else if (!current.isRunning) void select(key);
|
|
1890
|
+
}
|
|
1891
|
+
);
|
|
1892
|
+
}, [enabled, store, refresh, select]);
|
|
1893
|
+
const { messages, totalUsage, sessionId, isRunning, remote } = agent;
|
|
1894
|
+
useEffect2(() => {
|
|
1895
|
+
if (!enabled || loading || isRunning) return;
|
|
1896
|
+
if (staleRef.current === sessionId) {
|
|
1897
|
+
staleRef.current = void 0;
|
|
1898
|
+
void select(sessionId);
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
if (remote || messages.length === 0) return;
|
|
1902
|
+
const base = baseRef.current?.id === sessionId ? baseRef.current : void 0;
|
|
1903
|
+
if (unchangedSince(messages, base)) return;
|
|
1534
1904
|
const now = Date.now();
|
|
1535
1905
|
const createdAt = createdRef.current.get(sessionId) ?? now;
|
|
1536
1906
|
createdRef.current.set(sessionId, createdAt);
|
|
1537
|
-
const
|
|
1907
|
+
const view = {
|
|
1538
1908
|
id: sessionId,
|
|
1539
1909
|
title: chatTitle(messages),
|
|
1540
1910
|
createdAt,
|
|
@@ -1542,14 +1912,24 @@ var useChatHistory = (agent, options = {}) => {
|
|
|
1542
1912
|
messages,
|
|
1543
1913
|
totalUsage
|
|
1544
1914
|
};
|
|
1545
|
-
void
|
|
1915
|
+
void (async () => {
|
|
1916
|
+
const { record, merged } = await saveChat(store, view, base);
|
|
1917
|
+
baseRef.current = {
|
|
1918
|
+
id: sessionId,
|
|
1919
|
+
known: new Set(merged ? record.messages : messages),
|
|
1920
|
+
updatedAt: record.updatedAt
|
|
1921
|
+
};
|
|
1922
|
+
await refresh();
|
|
1923
|
+
if (merged && agentRef.current.sessionId === sessionId) await select(sessionId);
|
|
1924
|
+
})().catch(() => {
|
|
1546
1925
|
});
|
|
1547
|
-
}, [enabled, loading, isRunning, messages, totalUsage, sessionId, store, refresh]);
|
|
1926
|
+
}, [enabled, loading, isRunning, remote, messages, totalUsage, sessionId, store, refresh, select]);
|
|
1548
1927
|
return { chats, currentId: sessionId, loading, select, newChat, remove };
|
|
1549
1928
|
};
|
|
1550
1929
|
|
|
1551
1930
|
// src/hooks/use-virtual-files.ts
|
|
1552
1931
|
import { useCallback as useCallback3, useEffect as useEffect3, useState as useState3 } from "react";
|
|
1932
|
+
import * as core4 from "@dudko.dev/agent-web";
|
|
1553
1933
|
var readDataUrl = (file) => new Promise((resolve, reject) => {
|
|
1554
1934
|
const r = new FileReader();
|
|
1555
1935
|
r.onload = () => resolve(String(r.result));
|
|
@@ -1574,7 +1954,18 @@ var useVirtualFiles = (vfs, prefix = "/") => {
|
|
|
1574
1954
|
useEffect3(() => {
|
|
1575
1955
|
if (!vfs) return;
|
|
1576
1956
|
void refresh();
|
|
1577
|
-
|
|
1957
|
+
const local = vfs.onChange(() => void refresh());
|
|
1958
|
+
const namespace = vfs.namespace;
|
|
1959
|
+
const remote = followOtherTabs(
|
|
1960
|
+
core4,
|
|
1961
|
+
vfs.dbName,
|
|
1962
|
+
(change) => change.kind === "files" && (!namespace || change.namespace === namespace),
|
|
1963
|
+
() => void refresh()
|
|
1964
|
+
);
|
|
1965
|
+
return () => {
|
|
1966
|
+
local();
|
|
1967
|
+
remote();
|
|
1968
|
+
};
|
|
1578
1969
|
}, [vfs, refresh]);
|
|
1579
1970
|
const upload = useCallback3(
|
|
1580
1971
|
async (file, dir = "/uploads") => {
|
|
@@ -1670,11 +2061,25 @@ var useSpeechToText = (options = {}) => {
|
|
|
1670
2061
|
};
|
|
1671
2062
|
|
|
1672
2063
|
// src/hooks/use-credentials.ts
|
|
1673
|
-
import { useCallback as useCallback5, useMemo as useMemo2, useState as useState5 } from "react";
|
|
2064
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo2, useState as useState5 } from "react";
|
|
2065
|
+
import * as core5 from "@dudko.dev/agent-web";
|
|
1674
2066
|
import { VaultCredentialStore } from "@dudko.dev/agent-web";
|
|
2067
|
+
var storeDbName = (store) => {
|
|
2068
|
+
const name = store?.dbName;
|
|
2069
|
+
return typeof name === "string" && name ? name : void 0;
|
|
2070
|
+
};
|
|
1675
2071
|
var useCredentials = (store) => {
|
|
1676
2072
|
const resolved = useMemo2(() => store ?? new VaultCredentialStore(), [store]);
|
|
1677
2073
|
const [version, setVersion] = useState5(0);
|
|
2074
|
+
const dbName = storeDbName(resolved);
|
|
2075
|
+
useEffect5(() => {
|
|
2076
|
+
return followOtherTabs(
|
|
2077
|
+
core5,
|
|
2078
|
+
dbName,
|
|
2079
|
+
(change) => change.kind === "credentials",
|
|
2080
|
+
() => setVersion((v) => v + 1)
|
|
2081
|
+
);
|
|
2082
|
+
}, [dbName]);
|
|
1678
2083
|
const setKey = useCallback5(
|
|
1679
2084
|
async (ref, key) => {
|
|
1680
2085
|
await resolved.setApiKey(ref, key);
|
|
@@ -2078,6 +2483,11 @@ var defaultLabels = {
|
|
|
2078
2483
|
discardUndelivered: "Discard",
|
|
2079
2484
|
stopSubagent: "Stop this subagent",
|
|
2080
2485
|
subagentStopped: "stopped",
|
|
2486
|
+
remoteRunning: "Running in another tab: follow it here, write to it or stop it.",
|
|
2487
|
+
remoteWaitingConsent: "It waits for an answer in the other tab.",
|
|
2488
|
+
remoteGone: "The tab running this conversation closed before it finished.",
|
|
2489
|
+
sessionBusy: (heldBy) => heldBy === "this-tab" ? "Waiting for the other run of this conversation to finish\u2026" : "Waiting for the other tab to finish this conversation\u2026",
|
|
2490
|
+
fromAnotherTab: "from another tab",
|
|
2081
2491
|
failed: "failed",
|
|
2082
2492
|
toolCostTitle: "Estimated tokens of the arguments and of the result fed back to the model (chars / 4), and the call's duration",
|
|
2083
2493
|
tierNames: { light: "light", standard: "standard", strong: "strong" },
|
|
@@ -2396,11 +2806,11 @@ var useAgentContext = () => {
|
|
|
2396
2806
|
var useOptionalAgentContext = () => useContext2(AgentContext);
|
|
2397
2807
|
|
|
2398
2808
|
// src/components/AgentChat.tsx
|
|
2399
|
-
import { useEffect as
|
|
2809
|
+
import { useEffect as useEffect14, useRef as useRef9, useState as useState15 } from "react";
|
|
2400
2810
|
import { createPortal } from "react-dom";
|
|
2401
2811
|
|
|
2402
2812
|
// src/hooks/use-mcp-app-host.ts
|
|
2403
|
-
import { useCallback as useCallback7, useEffect as
|
|
2813
|
+
import { useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef5, useState as useState7 } from "react";
|
|
2404
2814
|
|
|
2405
2815
|
// src/mcp-app.ts
|
|
2406
2816
|
import { mcpAppOrigin } from "@dudko.dev/agent-web";
|
|
@@ -3240,7 +3650,7 @@ var useMcpAppHost = ({
|
|
|
3240
3650
|
connectionRef.current = connection;
|
|
3241
3651
|
const approveRef = useRef5(approve);
|
|
3242
3652
|
approveRef.current = approve;
|
|
3243
|
-
|
|
3653
|
+
useEffect6(
|
|
3244
3654
|
() => () => {
|
|
3245
3655
|
for (const { resolve } of waiting.current.values()) resolve(false);
|
|
3246
3656
|
waiting.current.clear();
|
|
@@ -3571,11 +3981,11 @@ var AppRequestPrompt = ({
|
|
|
3571
3981
|
};
|
|
3572
3982
|
|
|
3573
3983
|
// src/components/McpAppFrame.tsx
|
|
3574
|
-
import { useEffect as
|
|
3984
|
+
import { useEffect as useEffect7, useLayoutEffect, useMemo as useMemo5, useRef as useRef6, useState as useState8 } from "react";
|
|
3575
3985
|
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
3576
3986
|
var HOST_INFO = { name: "@dudko.dev/agent-web-react", version: "1" };
|
|
3577
3987
|
var MAX_LISTED_CALLS = 12;
|
|
3578
|
-
var useIsoLayoutEffect = typeof window === "undefined" ?
|
|
3988
|
+
var useIsoLayoutEffect = typeof window === "undefined" ? useEffect7 : useLayoutEffect;
|
|
3579
3989
|
var userActivation = () => typeof navigator === "undefined" ? void 0 : navigator.userActivation?.isActive;
|
|
3580
3990
|
var silentSandboxes = /* @__PURE__ */ new Set();
|
|
3581
3991
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -3637,7 +4047,7 @@ var McpAppFrame = ({
|
|
|
3637
4047
|
const appRef = useRef6(app);
|
|
3638
4048
|
appRef.current = app;
|
|
3639
4049
|
const live = !collapsed;
|
|
3640
|
-
|
|
4050
|
+
useEffect7(() => {
|
|
3641
4051
|
if (!live) return;
|
|
3642
4052
|
if (!hostRef.current.connected) {
|
|
3643
4053
|
setLoaded({ unavailable: true });
|
|
@@ -3675,7 +4085,7 @@ var McpAppFrame = ({
|
|
|
3675
4085
|
() => !resource || !placement ? void 0 : placement.mode === "origin" ? buildMcpAppSandboxShell(placement.url) : buildMcpAppDocument(resource.html, resource.csp),
|
|
3676
4086
|
[resource, placement]
|
|
3677
4087
|
);
|
|
3678
|
-
|
|
4088
|
+
useEffect7(() => {
|
|
3679
4089
|
const reason = placement?.mode === "opaque" ? placement.reason : void 0;
|
|
3680
4090
|
if (reason && reason !== "no-answer" && sandboxUrl !== void 0) {
|
|
3681
4091
|
warnOnce(
|
|
@@ -3684,7 +4094,7 @@ var McpAppFrame = ({
|
|
|
3684
4094
|
);
|
|
3685
4095
|
}
|
|
3686
4096
|
}, [placement, sandboxUrl]);
|
|
3687
|
-
|
|
4097
|
+
useEffect7(() => {
|
|
3688
4098
|
const frame = iframeRef.current;
|
|
3689
4099
|
if (!live || !resource || !frame || !placement || broken) return;
|
|
3690
4100
|
const abort = new AbortController();
|
|
@@ -3829,7 +4239,7 @@ var McpAppFrame = ({
|
|
|
3829
4239
|
}, [live, resource, reload, variant, app.id, placement, broken, timeoutMs]);
|
|
3830
4240
|
const fullscreen = mode === "fullscreen" && live && !broken;
|
|
3831
4241
|
const waitingNow = host.isWaiting(app);
|
|
3832
|
-
|
|
4242
|
+
useEffect7(() => {
|
|
3833
4243
|
if (fullscreen && waitingNow) leaveRef.current?.();
|
|
3834
4244
|
}, [fullscreen, waitingNow]);
|
|
3835
4245
|
useIsoLayoutEffect(() => {
|
|
@@ -3864,7 +4274,7 @@ var McpAppFrame = ({
|
|
|
3864
4274
|
ro?.disconnect();
|
|
3865
4275
|
};
|
|
3866
4276
|
}, [fullscreen]);
|
|
3867
|
-
|
|
4277
|
+
useEffect7(() => {
|
|
3868
4278
|
if (!fullscreen) return;
|
|
3869
4279
|
const before = document.activeElement;
|
|
3870
4280
|
exitRef.current?.focus();
|
|
@@ -3881,10 +4291,10 @@ var McpAppFrame = ({
|
|
|
3881
4291
|
if (frame && (before === frame || document.activeElement === document.body)) frame.focus();
|
|
3882
4292
|
};
|
|
3883
4293
|
}, [fullscreen]);
|
|
3884
|
-
|
|
4294
|
+
useEffect7(() => {
|
|
3885
4295
|
if (theme) bridgeRef.current?.updateContext({ theme });
|
|
3886
4296
|
}, [theme]);
|
|
3887
|
-
|
|
4297
|
+
useEffect7(() => {
|
|
3888
4298
|
if (!menu) return;
|
|
3889
4299
|
const close = (e) => {
|
|
3890
4300
|
if (e instanceof KeyboardEvent ? e.key === "Escape" : !menuRef.current?.contains(e.target)) {
|
|
@@ -4189,7 +4599,7 @@ var McpAppLine = ({ app, note, action, onAction, labels, className }) => {
|
|
|
4189
4599
|
};
|
|
4190
4600
|
|
|
4191
4601
|
// src/components/AgentComposer.tsx
|
|
4192
|
-
import { useEffect as
|
|
4602
|
+
import { useEffect as useEffect8, useLayoutEffect as useLayoutEffect2, useMemo as useMemo6, useRef as useRef7, useState as useState9 } from "react";
|
|
4193
4603
|
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4194
4604
|
var thinkingDefaults = (l) => [
|
|
4195
4605
|
{ id: "off", label: l.thinkingLevels.off },
|
|
@@ -4201,7 +4611,7 @@ var thinkingDefaults = (l) => [
|
|
|
4201
4611
|
var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
|
|
4202
4612
|
var ModeIcon = ({ mode }) => mode === "autopilot" ? /* @__PURE__ */ jsx5(BoltIcon, { size: 14 }) : mode === "read-only" ? /* @__PURE__ */ jsx5(EyeIcon, { size: 14 }) : /* @__PURE__ */ jsx5(ShieldIcon, { size: 14 });
|
|
4203
4613
|
var attachSeq = 0;
|
|
4204
|
-
var useIsoLayoutEffect2 = typeof window === "undefined" ?
|
|
4614
|
+
var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect8 : useLayoutEffect2;
|
|
4205
4615
|
var useMenuPlacement = (open, anchor, align) => {
|
|
4206
4616
|
const [style, setStyle] = useState9();
|
|
4207
4617
|
useIsoLayoutEffect2(() => {
|
|
@@ -4293,7 +4703,7 @@ var AgentComposer = ({
|
|
|
4293
4703
|
const modeRef = useRef7(null);
|
|
4294
4704
|
const [dropRect, setDropRect] = useState9();
|
|
4295
4705
|
const [compactBar, setCompactBar] = useState9(false);
|
|
4296
|
-
|
|
4706
|
+
useEffect8(() => {
|
|
4297
4707
|
const el = rootRef.current;
|
|
4298
4708
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
4299
4709
|
const ro = new ResizeObserver(
|
|
@@ -4306,13 +4716,16 @@ var AgentComposer = ({
|
|
|
4306
4716
|
const inputRef = useRef7(null);
|
|
4307
4717
|
const draftId = draft?.id;
|
|
4308
4718
|
const draftText = draft?.text;
|
|
4309
|
-
|
|
4719
|
+
useEffect8(() => {
|
|
4310
4720
|
if (draftId === void 0 || !draftText) return;
|
|
4311
4721
|
setText((t) => t.trim() ? `${t.trimEnd()}
|
|
4312
4722
|
${draftText}` : draftText);
|
|
4313
4723
|
inputRef.current?.focus();
|
|
4314
4724
|
}, [draftId, draftText]);
|
|
4315
4725
|
const busy = agent.isRunning;
|
|
4726
|
+
const following = !!agent.remote?.running && !agent.sessionBusy;
|
|
4727
|
+
const steerTo = following ? agent.sendRemote : agent.send;
|
|
4728
|
+
const stopIt = following ? agent.stopRemote : agent.stop;
|
|
4316
4729
|
const ready = agent.isReady && !disabled;
|
|
4317
4730
|
const caps = agent.agent?.capabilities;
|
|
4318
4731
|
const stt = useSpeechToText({
|
|
@@ -4323,7 +4736,7 @@ ${draftText}` : draftText);
|
|
|
4323
4736
|
const [startedAt, setStartedAt] = useState9();
|
|
4324
4737
|
const [now, setNow] = useState9(() => Date.now());
|
|
4325
4738
|
const [lastElapsed, setLastElapsed] = useState9();
|
|
4326
|
-
|
|
4739
|
+
useEffect8(() => {
|
|
4327
4740
|
if (!busy) {
|
|
4328
4741
|
if (startedAt !== void 0) setLastElapsed(Date.now() - startedAt);
|
|
4329
4742
|
setStartedAt(void 0);
|
|
@@ -4356,7 +4769,7 @@ ${draftText}` : draftText);
|
|
|
4356
4769
|
name: "stop",
|
|
4357
4770
|
description: L.commandDescriptions.stop,
|
|
4358
4771
|
group: L.commandGroups.commands,
|
|
4359
|
-
run:
|
|
4772
|
+
run: stopIt
|
|
4360
4773
|
},
|
|
4361
4774
|
{
|
|
4362
4775
|
name: "autopilot",
|
|
@@ -4408,7 +4821,7 @@ ${draftText}` : draftText);
|
|
|
4408
4821
|
}
|
|
4409
4822
|
}
|
|
4410
4823
|
return [...out, ...commands];
|
|
4411
|
-
}, [agent, builtinCommands, skillCommands, commands, thinking, L]);
|
|
4824
|
+
}, [agent, stopIt, builtinCommands, skillCommands, commands, thinking, L]);
|
|
4412
4825
|
const slash = parseSlash(text);
|
|
4413
4826
|
const matches = slash && !/\s/.test(text.trimStart()) ? filterCommands(allCommands, slash.name) : [];
|
|
4414
4827
|
const palette = menu === "commands" && !slash ? allCommands : matches;
|
|
@@ -4416,8 +4829,8 @@ ${draftText}` : draftText);
|
|
|
4416
4829
|
const commandsStyle = useMenuPlacement(paletteOpen, rootRef, "stretch");
|
|
4417
4830
|
const modelStyle = useMenuPlacement(menu === "model", modelRef, "left");
|
|
4418
4831
|
const modeStyle = useMenuPlacement(menu === "mode", modeRef, "right");
|
|
4419
|
-
|
|
4420
|
-
|
|
4832
|
+
useEffect8(() => setActive(0), [text, menu]);
|
|
4833
|
+
useEffect8(() => {
|
|
4421
4834
|
if (!menu) return;
|
|
4422
4835
|
const onDown = (e) => {
|
|
4423
4836
|
if (!rootRef.current?.contains(e.target)) setMenu(void 0);
|
|
@@ -4512,7 +4925,7 @@ ${draftText}` : draftText);
|
|
|
4512
4925
|
};
|
|
4513
4926
|
const addFilesRef = useRef7(addFiles);
|
|
4514
4927
|
addFilesRef.current = addFiles;
|
|
4515
|
-
|
|
4928
|
+
useEffect8(() => {
|
|
4516
4929
|
if (attachments === false) return;
|
|
4517
4930
|
const target = dropZone === "window" ? globalThis.window : dropZone === "self" ? rootRef.current : dropZone.current;
|
|
4518
4931
|
if (!target) return;
|
|
@@ -4582,7 +4995,7 @@ ${draftText}` : draftText);
|
|
|
4582
4995
|
const raw = text.trim();
|
|
4583
4996
|
const intent = steerIntent({ raw, busy, steering, hasAttachments: pending.length > 0 });
|
|
4584
4997
|
if (intent === "steer") {
|
|
4585
|
-
if (
|
|
4998
|
+
if (steerTo(raw)) setText("");
|
|
4586
4999
|
return;
|
|
4587
5000
|
}
|
|
4588
5001
|
if (intent === "attachments") {
|
|
@@ -4693,6 +5106,7 @@ ${draftText}` : draftText);
|
|
|
4693
5106
|
agent.queued.map((q) => /* @__PURE__ */ jsxs3("div", { className: "awr-queued__item", role: "status", children: [
|
|
4694
5107
|
/* @__PURE__ */ jsx5(ClockIcon, { size: 13, className: "awr-queued__icon" }),
|
|
4695
5108
|
/* @__PURE__ */ jsx5("span", { className: "awr-queued__text", title: q.text, children: q.text }),
|
|
5109
|
+
q.origin === "another-tab" && /* @__PURE__ */ jsx5("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
|
|
4696
5110
|
/* @__PURE__ */ jsx5("span", { className: "awr-queued__state", children: L.queuedWaiting })
|
|
4697
5111
|
] }, q.id)),
|
|
4698
5112
|
agent.undelivered.length > 0 && /* @__PURE__ */ jsxs3("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
|
|
@@ -4974,7 +5388,7 @@ ${draftText}` : draftText);
|
|
|
4974
5388
|
{
|
|
4975
5389
|
type: "button",
|
|
4976
5390
|
className: "awr-sendbtn awr-sendbtn--stop",
|
|
4977
|
-
onClick:
|
|
5391
|
+
onClick: stopIt,
|
|
4978
5392
|
"aria-label": L.stop,
|
|
4979
5393
|
children: /* @__PURE__ */ jsx5(StopIcon, { size: 16 })
|
|
4980
5394
|
}
|
|
@@ -5150,7 +5564,7 @@ var ContextMeter = ({
|
|
|
5150
5564
|
};
|
|
5151
5565
|
|
|
5152
5566
|
// src/components/ElicitationPrompt.tsx
|
|
5153
|
-
import { useEffect as
|
|
5567
|
+
import { useEffect as useEffect9, useId, useState as useState10 } from "react";
|
|
5154
5568
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
5155
5569
|
var reasonText = (outcome, L) => {
|
|
5156
5570
|
const reason = outcome.reason;
|
|
@@ -5161,7 +5575,7 @@ var reasonText = (outcome, L) => {
|
|
|
5161
5575
|
};
|
|
5162
5576
|
var useNow = (active) => {
|
|
5163
5577
|
const [now, setNow] = useState10(() => Date.now());
|
|
5164
|
-
|
|
5578
|
+
useEffect9(() => {
|
|
5165
5579
|
if (!active) return;
|
|
5166
5580
|
setNow(Date.now());
|
|
5167
5581
|
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
@@ -5473,7 +5887,7 @@ var ElicitationPrompt = ({
|
|
|
5473
5887
|
};
|
|
5474
5888
|
|
|
5475
5889
|
// src/components/FilesPanel.tsx
|
|
5476
|
-
import { Fragment as Fragment4, useEffect as
|
|
5890
|
+
import { Fragment as Fragment4, useEffect as useEffect10, useRef as useRef8, useState as useState11 } from "react";
|
|
5477
5891
|
import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
5478
5892
|
var PREVIEW_CHARS = 2e4;
|
|
5479
5893
|
var FilesPanel = ({
|
|
@@ -5492,7 +5906,7 @@ var FilesPanel = ({
|
|
|
5492
5906
|
const fs = useVirtualFiles(vfs, prefix);
|
|
5493
5907
|
const [preview, setPreview] = useState11();
|
|
5494
5908
|
const inputRef = useRef8(null);
|
|
5495
|
-
|
|
5909
|
+
useEffect10(() => {
|
|
5496
5910
|
if (preview && !fs.files.some((f) => f.path === preview.path)) setPreview(void 0);
|
|
5497
5911
|
}, [fs.files, preview]);
|
|
5498
5912
|
const open = async (f) => {
|
|
@@ -5601,7 +6015,7 @@ var FilesPanel = ({
|
|
|
5601
6015
|
};
|
|
5602
6016
|
|
|
5603
6017
|
// src/components/FileChips.tsx
|
|
5604
|
-
import { Fragment as Fragment6, useEffect as
|
|
6018
|
+
import { Fragment as Fragment6, useEffect as useEffect12, useMemo as useMemo7, useState as useState13 } from "react";
|
|
5605
6019
|
|
|
5606
6020
|
// src/file-kinds.ts
|
|
5607
6021
|
import { MEDIA_IMAGE_TYPES, isTextMime } from "@dudko.dev/agent-web";
|
|
@@ -5622,7 +6036,7 @@ var fileKindOf = (path, mediaType) => {
|
|
|
5622
6036
|
var fileNameOf = (path) => path.split("/").filter(Boolean).pop() || "file";
|
|
5623
6037
|
|
|
5624
6038
|
// src/components/Media.tsx
|
|
5625
|
-
import { useEffect as
|
|
6039
|
+
import { useEffect as useEffect11, useState as useState12 } from "react";
|
|
5626
6040
|
import { MEDIA_AUDIO_TYPES, MEDIA_IMAGE_TYPES as MEDIA_IMAGE_TYPES2 } from "@dudko.dev/agent-web";
|
|
5627
6041
|
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
5628
6042
|
var mediaFamilyOf = (mediaType) => {
|
|
@@ -5640,7 +6054,7 @@ var bytesOf = (content, encoding) => {
|
|
|
5640
6054
|
};
|
|
5641
6055
|
var useFileUrl = (files, path, mediaType) => {
|
|
5642
6056
|
const [url, setUrl] = useState12(void 0);
|
|
5643
|
-
|
|
6057
|
+
useEffect11(() => {
|
|
5644
6058
|
if (!files || !mediaType) return;
|
|
5645
6059
|
let made;
|
|
5646
6060
|
let gone = false;
|
|
@@ -5998,7 +6412,7 @@ var FileChips = ({
|
|
|
5998
6412
|
const [file, setFile] = useState13();
|
|
5999
6413
|
const open = written.find((f) => f.path === openPath);
|
|
6000
6414
|
const stamp = live.files.find((f) => f.path === openPath)?.updatedAt;
|
|
6001
|
-
|
|
6415
|
+
useEffect12(() => {
|
|
6002
6416
|
if (!vfs || !openPath) return setFile(void 0);
|
|
6003
6417
|
let gone = false;
|
|
6004
6418
|
vfs.read(openPath).then((f) => {
|
|
@@ -6124,11 +6538,11 @@ var FileChip = ({
|
|
|
6124
6538
|
import { Fragment as Fragment9 } from "react";
|
|
6125
6539
|
|
|
6126
6540
|
// src/components/SubagentTree.tsx
|
|
6127
|
-
import { Fragment as Fragment8, useEffect as
|
|
6541
|
+
import { Fragment as Fragment8, useEffect as useEffect13, useState as useState14 } from "react";
|
|
6128
6542
|
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
6129
6543
|
var useElapsed = (startedAt, running) => {
|
|
6130
6544
|
const [now, setNow] = useState14(void 0);
|
|
6131
|
-
|
|
6545
|
+
useEffect13(() => {
|
|
6132
6546
|
if (!running || startedAt === void 0) return;
|
|
6133
6547
|
setNow(Date.now());
|
|
6134
6548
|
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
@@ -6308,7 +6722,8 @@ var UserNoteRow = ({
|
|
|
6308
6722
|
return /* @__PURE__ */ jsxs12("li", { className: `awr-note awr-note--${note.at}`, children: [
|
|
6309
6723
|
/* @__PURE__ */ jsx14(SendIcon, { size: 12, className: "awr-note__icon" }),
|
|
6310
6724
|
/* @__PURE__ */ jsx14("span", { className: "awr-note__where", children: L.noteAt[note.at] }),
|
|
6311
|
-
/* @__PURE__ */ jsx14("q", { className: "awr-note__text", children: note.text })
|
|
6725
|
+
/* @__PURE__ */ jsx14("q", { className: "awr-note__text", children: note.text }),
|
|
6726
|
+
note.origin === "another-tab" && /* @__PURE__ */ jsx14("span", { className: "awr-note__origin", children: L.fromAnotherTab })
|
|
6312
6727
|
] });
|
|
6313
6728
|
};
|
|
6314
6729
|
var decisionNote = (d, L) => {
|
|
@@ -6840,13 +7255,18 @@ var UsageBadge = ({
|
|
|
6840
7255
|
const media = showCalls ? usage.mediaCalls ?? 0 : 0;
|
|
6841
7256
|
const decisions = showCalls ? usage.decisionCalls ?? 0 : 0;
|
|
6842
7257
|
if (usage.totalTokens === 0 && media === 0 && decisions === 0) return null;
|
|
7258
|
+
const mediaText = media ? L.usageMedia(media, {
|
|
7259
|
+
imagesGenerated: usage.imagesGenerated ?? 0,
|
|
7260
|
+
speechCharacters: usage.speechCharacters ?? 0,
|
|
7261
|
+
transcriptionSeconds: usage.transcriptionSeconds ?? 0
|
|
7262
|
+
}) : "";
|
|
6843
7263
|
const reasoning = usage.reasoningTokens ?? 0;
|
|
6844
7264
|
const cached = usage.cachedInputTokens ?? 0;
|
|
6845
7265
|
const title = [
|
|
6846
7266
|
`${usage.inputTokens} in + ${usage.outputTokens} out = ${usage.totalTokens} tokens`,
|
|
6847
7267
|
reasoning ? `${reasoning} thinking` : "",
|
|
6848
7268
|
cached ? `${cached} input tokens from the prompt cache` : "",
|
|
6849
|
-
|
|
7269
|
+
mediaText,
|
|
6850
7270
|
decisions ? L.usageDecisions(decisions) : ""
|
|
6851
7271
|
].filter(Boolean).join(" \xB7 ");
|
|
6852
7272
|
return /* @__PURE__ */ jsxs16("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
|
|
@@ -6856,7 +7276,7 @@ var UsageBadge = ({
|
|
|
6856
7276
|
"\u2193",
|
|
6857
7277
|
!compact && reasoning > 0 && ` \xB7 ${formatTokens(reasoning)} think`,
|
|
6858
7278
|
!compact && cached > 0 && ` \xB7 ${formatTokens(cached)} cached`,
|
|
6859
|
-
!compact &&
|
|
7279
|
+
!compact && mediaText && ` \xB7 ${mediaText}`,
|
|
6860
7280
|
!compact && decisions > 0 && ` \xB7 ${L.usageDecisions(decisions)}`
|
|
6861
7281
|
] });
|
|
6862
7282
|
};
|
|
@@ -6868,7 +7288,7 @@ var usePrefersDark = () => {
|
|
|
6868
7288
|
const [dark, setDark] = useState15(
|
|
6869
7289
|
() => typeof matchMedia === "function" && matchMedia(query).matches
|
|
6870
7290
|
);
|
|
6871
|
-
|
|
7291
|
+
useEffect14(() => {
|
|
6872
7292
|
if (typeof matchMedia !== "function") return;
|
|
6873
7293
|
const mq = matchMedia(query);
|
|
6874
7294
|
const on = () => setDark(mq.matches);
|
|
@@ -6908,6 +7328,7 @@ var AgentChatInner = ({
|
|
|
6908
7328
|
activityOpen = false,
|
|
6909
7329
|
showElicitation = true,
|
|
6910
7330
|
showSkillPreview = true,
|
|
7331
|
+
showOtherTabs = true,
|
|
6911
7332
|
elicitations,
|
|
6912
7333
|
onElicitationAnswer,
|
|
6913
7334
|
renderElicitation,
|
|
@@ -6963,7 +7384,7 @@ var AgentChatInner = ({
|
|
|
6963
7384
|
const chats = history ? external ?? own : void 0;
|
|
6964
7385
|
const rootRef = useRef9(null);
|
|
6965
7386
|
const [narrow, setNarrow] = useState15(void 0);
|
|
6966
|
-
|
|
7387
|
+
useEffect14(() => {
|
|
6967
7388
|
const el = rootRef.current;
|
|
6968
7389
|
if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
|
|
6969
7390
|
const measure = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
|
|
@@ -6989,7 +7410,7 @@ var AgentChatInner = ({
|
|
|
6989
7410
|
};
|
|
6990
7411
|
const bodyRef = useRef9(null);
|
|
6991
7412
|
const stickRef = useRef9(true);
|
|
6992
|
-
|
|
7413
|
+
useEffect14(() => {
|
|
6993
7414
|
const el = bodyRef.current;
|
|
6994
7415
|
if (el && stickRef.current) el.scrollTop = el.scrollHeight;
|
|
6995
7416
|
}, [
|
|
@@ -7020,7 +7441,7 @@ var AgentChatInner = ({
|
|
|
7020
7441
|
const panelAllowed = appPanel !== false && appPanel !== null;
|
|
7021
7442
|
const panelTarget = typeof appPanel === "object" && appPanel ? appPanel : void 0;
|
|
7022
7443
|
const asSheet = !panelTarget && (appPanel === "sheet" || Boolean(narrow));
|
|
7023
|
-
|
|
7444
|
+
useEffect14(() => {
|
|
7024
7445
|
if (panelApp && !agent.messages.some((m) => m.apps?.some((a) => a.id === panelApp.id))) {
|
|
7025
7446
|
setPanelAppState(void 0);
|
|
7026
7447
|
onAppPanel?.(void 0);
|
|
@@ -7071,6 +7492,12 @@ var AgentChatInner = ({
|
|
|
7071
7492
|
const Files = components.FilesPanel ?? FilesPanel;
|
|
7072
7493
|
const Approvals = components.ApprovalPrompt ?? ToolApprovalPrompt;
|
|
7073
7494
|
const Elicitations = components.ElicitationPrompt ?? ElicitationPrompt;
|
|
7495
|
+
const tabNotes = showOtherTabs ? [
|
|
7496
|
+
agent.remote?.running && L.remoteRunning,
|
|
7497
|
+
agent.remote?.running && agent.approvals.some((a) => a.remote && a.status === "pending") && L.remoteWaitingConsent,
|
|
7498
|
+
agent.remote?.ended === "gone" && L.remoteGone,
|
|
7499
|
+
agent.sessionBusy && L.sessionBusy(agent.sessionBusy.heldBy)
|
|
7500
|
+
].filter((t) => typeof t === "string") : [];
|
|
7074
7501
|
const loading = agent.modelLoad && agent.modelLoad.progress < 1;
|
|
7075
7502
|
const showReplan = agent.replan && agent.replan.mode !== "continue";
|
|
7076
7503
|
const replanFailedEarly = showReplanFailed && agent.replan?.failed === true && agent.steps.length === 0;
|
|
@@ -7251,6 +7678,7 @@ var AgentChatInner = ({
|
|
|
7251
7678
|
),
|
|
7252
7679
|
/* @__PURE__ */ jsxs17("div", { className: cx("awr-chat__footer", classNames.footer), children: [
|
|
7253
7680
|
slots.footerStart,
|
|
7681
|
+
tabNotes.length > 0 && /* @__PURE__ */ jsx18("div", { className: "awr-tabnote", role: "status", children: tabNotes.map((text) => /* @__PURE__ */ jsx18("p", { className: "awr-tabnote__text", children: text }, text)) }),
|
|
7254
7682
|
showContext !== false && /* @__PURE__ */ jsx18(
|
|
7255
7683
|
ContextMeter,
|
|
7256
7684
|
{
|
|
@@ -7500,7 +7928,7 @@ var ApprovalModeSwitch = ({
|
|
|
7500
7928
|
);
|
|
7501
7929
|
|
|
7502
7930
|
// src/components/ApiKeyForm.tsx
|
|
7503
|
-
import { useEffect as
|
|
7931
|
+
import { useEffect as useEffect15, useState as useState17 } from "react";
|
|
7504
7932
|
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7505
7933
|
var ApiKeyForm = ({
|
|
7506
7934
|
credentials,
|
|
@@ -7513,7 +7941,7 @@ var ApiKeyForm = ({
|
|
|
7513
7941
|
const [value, setValue] = useState17("");
|
|
7514
7942
|
const [present, setPresent] = useState17(false);
|
|
7515
7943
|
const [busy, setBusy] = useState17(false);
|
|
7516
|
-
|
|
7944
|
+
useEffect15(() => {
|
|
7517
7945
|
let active = true;
|
|
7518
7946
|
credentials.hasKey(credentialRef).then((has) => {
|
|
7519
7947
|
if (active) setPresent(has);
|
|
@@ -7622,7 +8050,11 @@ import {
|
|
|
7622
8050
|
AttachmentsNotSupportedError,
|
|
7623
8051
|
ImagesNotSupportedError,
|
|
7624
8052
|
supportsImages,
|
|
7625
|
-
supportsPdf
|
|
8053
|
+
supportsPdf,
|
|
8054
|
+
onStorageChange,
|
|
8055
|
+
postStorageChange as postStorageChange2,
|
|
8056
|
+
watchSession as watchSession2,
|
|
8057
|
+
SessionBusyError
|
|
7626
8058
|
} from "@dudko.dev/agent-web";
|
|
7627
8059
|
export {
|
|
7628
8060
|
APP_DEFAULT_HEIGHT,
|
|
@@ -7687,6 +8119,7 @@ export {
|
|
|
7687
8119
|
ModelLoadBar,
|
|
7688
8120
|
PlanView,
|
|
7689
8121
|
SandboxedFrame,
|
|
8122
|
+
SessionBusyError,
|
|
7690
8123
|
SourceView,
|
|
7691
8124
|
StepList,
|
|
7692
8125
|
SubagentRow,
|
|
@@ -7700,6 +8133,7 @@ export {
|
|
|
7700
8133
|
VfsSkillStore,
|
|
7701
8134
|
VirtualFileSystem,
|
|
7702
8135
|
agentStateReducer,
|
|
8136
|
+
agentStatusOf,
|
|
7703
8137
|
appDisplayModeAllowed,
|
|
7704
8138
|
appDownloadOf,
|
|
7705
8139
|
appDownloadRefusal,
|
|
@@ -7755,22 +8189,28 @@ export {
|
|
|
7755
8189
|
mcpAppSandboxShellCsp,
|
|
7756
8190
|
mcpAppSandboxTarget,
|
|
7757
8191
|
mediaFamilyOf,
|
|
8192
|
+
mergeChatRecord,
|
|
7758
8193
|
mergeLabels,
|
|
7759
8194
|
newChatId,
|
|
7760
8195
|
noticesOf,
|
|
8196
|
+
onStorageChange,
|
|
7761
8197
|
parseSkillMarkdown,
|
|
7762
8198
|
parseSlash,
|
|
8199
|
+
pendingApprovalsOf,
|
|
8200
|
+
postStorageChange2 as postStorageChange,
|
|
7763
8201
|
preloadWebLLMModel2 as preloadWebLLMModel,
|
|
7764
8202
|
resolveAppDownload,
|
|
7765
8203
|
sandboxTokens,
|
|
7766
8204
|
sandboxedCsp,
|
|
7767
8205
|
saveAppFile,
|
|
8206
|
+
saveChat,
|
|
7768
8207
|
serveSubagentWorker,
|
|
7769
8208
|
steerIntent,
|
|
7770
8209
|
subagentTree,
|
|
7771
8210
|
supportsImages,
|
|
7772
8211
|
supportsPdf,
|
|
7773
8212
|
tokenizeHtml,
|
|
8213
|
+
unchangedSince,
|
|
7774
8214
|
unloadWebLLMModel2 as unloadWebLLMModel,
|
|
7775
8215
|
usageLine,
|
|
7776
8216
|
useAgent,
|
|
@@ -7784,6 +8224,7 @@ export {
|
|
|
7784
8224
|
useSpeechToText,
|
|
7785
8225
|
useVirtualFiles,
|
|
7786
8226
|
useWebLLMModel,
|
|
8227
|
+
watchSession2 as watchSession,
|
|
7787
8228
|
webSearchOf,
|
|
7788
8229
|
withAttachments,
|
|
7789
8230
|
withCspFirst,
|