@dudko.dev/agent-web-react 0.0.33 → 0.0.35
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 +53 -3
- package/dist/{elicitation-B6h_-yLg.d.cts → elicitation-xMLll5W9.d.cts} +52 -3
- package/dist/{elicitation-B6h_-yLg.d.ts → elicitation-xMLll5W9.d.ts} +52 -3
- package/dist/index.cjs +1566 -610
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +346 -9
- package/dist/index.d.ts +346 -9
- package/dist/index.js +1490 -553
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/styles.css +423 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
APP_DEFAULT_HEIGHT: () => APP_DEFAULT_HEIGHT,
|
|
34
34
|
APP_MAX_HEIGHT: () => APP_MAX_HEIGHT,
|
|
35
35
|
APP_MIN_HEIGHT: () => APP_MIN_HEIGHT,
|
|
36
|
+
ASK_USER_TOOL_NAME: () => ASK_USER_TOOL_NAME,
|
|
36
37
|
AgentChat: () => AgentChat,
|
|
37
38
|
AgentComposer: () => AgentComposer,
|
|
38
39
|
AgentLabelsProvider: () => AgentLabelsProvider,
|
|
@@ -48,6 +49,8 @@ __export(src_exports, {
|
|
|
48
49
|
ContextMeter: () => ContextMeter,
|
|
49
50
|
ElicitationPrompt: () => ElicitationPrompt,
|
|
50
51
|
FILE_PREVIEW_CHARS: () => FILE_PREVIEW_CHARS,
|
|
52
|
+
FOLLOW_LEAVE_PX: () => FOLLOW_LEAVE_PX,
|
|
53
|
+
FOLLOW_REJOIN_PX: () => FOLLOW_REJOIN_PX,
|
|
51
54
|
FRAME_MAX_HEIGHT: () => FRAME_MAX_HEIGHT,
|
|
52
55
|
FRAME_MIN_HEIGHT: () => FRAME_MIN_HEIGHT,
|
|
53
56
|
FileChip: () => FileChip,
|
|
@@ -55,6 +58,9 @@ __export(src_exports, {
|
|
|
55
58
|
FilesPanel: () => FilesPanel,
|
|
56
59
|
GeneratedMedia: () => GeneratedMedia,
|
|
57
60
|
HTML_PREVIEW_MAX_CHARS: () => HTML_PREVIEW_MAX_CHARS,
|
|
61
|
+
ImageThumb: () => ImageThumb,
|
|
62
|
+
ImageViewer: () => ImageViewer,
|
|
63
|
+
ImageViewerProvider: () => ImageViewerProvider,
|
|
58
64
|
ImagesNotSupportedError: () => import_agent_web8.ImagesNotSupportedError,
|
|
59
65
|
IndexedDBStore: () => import_agent_web8.IndexedDBStore,
|
|
60
66
|
LearnedSkills: () => LearnedSkills,
|
|
@@ -91,6 +97,8 @@ __export(src_exports, {
|
|
|
91
97
|
MessageList: () => MessageList,
|
|
92
98
|
ModelLoadBar: () => ModelLoadBar,
|
|
93
99
|
PlanView: () => PlanView,
|
|
100
|
+
QUESTION_TIMEOUT_MS: () => QUESTION_TIMEOUT_MS,
|
|
101
|
+
QuestionPrompt: () => QuestionPrompt,
|
|
94
102
|
SandboxedFrame: () => SandboxedFrame,
|
|
95
103
|
SessionBusyError: () => import_agent_web8.SessionBusyError,
|
|
96
104
|
SourceView: () => SourceView,
|
|
@@ -117,6 +125,8 @@ __export(src_exports, {
|
|
|
117
125
|
appMessageTextOf: () => appMessageTextOf,
|
|
118
126
|
appMimeTypeOf: () => appMimeTypeOf,
|
|
119
127
|
appSamplingErrorOf: () => appSamplingErrorOf,
|
|
128
|
+
askUserOutputKept: () => askUserOutputKept,
|
|
129
|
+
askUserWith: () => askUserWith,
|
|
120
130
|
attachmentKindOf: () => attachmentKindOf,
|
|
121
131
|
attachmentRefusal: () => attachmentRefusal,
|
|
122
132
|
buildMcpAppDocument: () => buildMcpAppDocument,
|
|
@@ -129,6 +139,7 @@ __export(src_exports, {
|
|
|
129
139
|
createApprovalQueue: () => createApprovalQueue,
|
|
130
140
|
createFileTools: () => import_agent_web8.createFileTools,
|
|
131
141
|
createInitialAgentState: () => createInitialAgentState,
|
|
142
|
+
createQuestionQueue: () => createQuestionQueue,
|
|
132
143
|
createRunControl: () => import_agent_web8.createRunControl,
|
|
133
144
|
createSubagentTool: () => import_agent_web8.createSubagentTool,
|
|
134
145
|
createWebLLMEngine: () => createWebLLMEngine,
|
|
@@ -144,11 +155,14 @@ __export(src_exports, {
|
|
|
144
155
|
elicitationLink: () => elicitationLink,
|
|
145
156
|
escapeAttribute: () => escapeAttribute,
|
|
146
157
|
fileKindOf: () => fileKindOf,
|
|
147
|
-
fileNameOf: () =>
|
|
158
|
+
fileNameOf: () => fileNameOf2,
|
|
148
159
|
filterCommands: () => filterCommands,
|
|
160
|
+
followsAfterResize: () => followsAfterResize,
|
|
161
|
+
followsAfterScroll: () => followsAfterScroll,
|
|
149
162
|
formatCountdown: () => formatCountdown,
|
|
150
163
|
formatElapsed: () => formatElapsed,
|
|
151
164
|
grantedAppCsp: () => grantedAppCsp,
|
|
165
|
+
imageExtensionOf: () => imageExtensionOf,
|
|
152
166
|
isMcpAppSandboxMessage: () => isMcpAppSandboxMessage,
|
|
153
167
|
isWebGPUAvailable: () => import_agent_web8.isWebGPUAvailable,
|
|
154
168
|
lessonsOf: () => lessonsOf,
|
|
@@ -172,6 +186,9 @@ __export(src_exports, {
|
|
|
172
186
|
pendingApprovalsOf: () => pendingApprovalsOf,
|
|
173
187
|
postStorageChange: () => import_agent_web8.postStorageChange,
|
|
174
188
|
preloadWebLLMModel: () => import_agent_web8.preloadWebLLMModel,
|
|
189
|
+
questionChoiceOf: () => questionChoiceOf,
|
|
190
|
+
questionOtherOf: () => questionOtherOf,
|
|
191
|
+
questionTimeoutOf: () => questionTimeoutOf,
|
|
175
192
|
resolveAppDownload: () => resolveAppDownload,
|
|
176
193
|
sandboxTokens: () => sandboxTokens,
|
|
177
194
|
sandboxedCsp: () => sandboxedCsp,
|
|
@@ -190,6 +207,7 @@ __export(src_exports, {
|
|
|
190
207
|
useAgentContext: () => useAgentContext,
|
|
191
208
|
useChatHistory: () => useChatHistory,
|
|
192
209
|
useCredentials: () => useCredentials,
|
|
210
|
+
useFollowScroll: () => useFollowScroll,
|
|
193
211
|
useLabels: () => useLabels,
|
|
194
212
|
useLocalModel: () => useLocalModel,
|
|
195
213
|
useMcpAppHost: () => useMcpAppHost,
|
|
@@ -201,7 +219,8 @@ __export(src_exports, {
|
|
|
201
219
|
webSearchOf: () => webSearchOf,
|
|
202
220
|
withAttachments: () => withAttachments,
|
|
203
221
|
withCspFirst: () => withCspFirst,
|
|
204
|
-
withPolicyFirst: () => withPolicyFirst
|
|
222
|
+
withPolicyFirst: () => withPolicyFirst,
|
|
223
|
+
withoutOwnWords: () => withoutOwnWords
|
|
205
224
|
});
|
|
206
225
|
module.exports = __toCommonJS(src_exports);
|
|
207
226
|
|
|
@@ -248,6 +267,127 @@ var createApprovalQueue = () => {
|
|
|
248
267
|
};
|
|
249
268
|
};
|
|
250
269
|
|
|
270
|
+
// src/questions.ts
|
|
271
|
+
var ASK_USER_TOOL_NAME = "ask_user";
|
|
272
|
+
var QUESTION_TIMEOUT_MS = 3e5;
|
|
273
|
+
var TIMER_MAX_MS = 2147483647;
|
|
274
|
+
var questionTimeoutOf = (askUser) => {
|
|
275
|
+
if (!askUser) return void 0;
|
|
276
|
+
const raw = askUser === true ? void 0 : askUser.timeoutMs;
|
|
277
|
+
if (raw === void 0 || raw === null) return QUESTION_TIMEOUT_MS;
|
|
278
|
+
if (typeof raw !== "number" || !(raw > 0) || raw > TIMER_MAX_MS) return void 0;
|
|
279
|
+
return Math.max(1, Math.floor(raw));
|
|
280
|
+
};
|
|
281
|
+
var askUserWith = (askUser, handler) => {
|
|
282
|
+
if (!askUser) return askUser;
|
|
283
|
+
if (askUser === true) return { onQuestion: handler };
|
|
284
|
+
return askUser.onQuestion ? askUser : { ...askUser, onQuestion: handler };
|
|
285
|
+
};
|
|
286
|
+
var DECLINED = { declined: true };
|
|
287
|
+
var createQuestionQueue = (options = {}) => {
|
|
288
|
+
const now = options.now ?? Date.now;
|
|
289
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
290
|
+
let disposed = false;
|
|
291
|
+
const list = () => [...waiting.values()].map((w) => w.question);
|
|
292
|
+
const changed = () => {
|
|
293
|
+
if (!disposed) options.onChange?.(list());
|
|
294
|
+
};
|
|
295
|
+
const handler = (request, ctx) => new Promise((resolve) => {
|
|
296
|
+
const signal = ctx?.signal;
|
|
297
|
+
if (disposed || signal?.aborted || waiting.has(request.id)) {
|
|
298
|
+
resolve(DECLINED);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const onAbort = () => {
|
|
302
|
+
if (waiting.get(request.id)?.settle !== settle) return;
|
|
303
|
+
settle(DECLINED);
|
|
304
|
+
changed();
|
|
305
|
+
};
|
|
306
|
+
const settle = (answer) => {
|
|
307
|
+
waiting.delete(request.id);
|
|
308
|
+
signal?.removeEventListener("abort", onAbort);
|
|
309
|
+
resolve(answer);
|
|
310
|
+
};
|
|
311
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
312
|
+
const timeoutMs = typeof options.timeoutMs === "function" ? options.timeoutMs() : options.timeoutMs;
|
|
313
|
+
waiting.set(request.id, {
|
|
314
|
+
question: {
|
|
315
|
+
...request,
|
|
316
|
+
options: request.options.map((o) => ({ ...o })),
|
|
317
|
+
...timeoutMs !== void 0 ? { expiresAt: now() + timeoutMs } : {}
|
|
318
|
+
},
|
|
319
|
+
settle
|
|
320
|
+
});
|
|
321
|
+
changed();
|
|
322
|
+
});
|
|
323
|
+
return {
|
|
324
|
+
handler,
|
|
325
|
+
pending: list,
|
|
326
|
+
answer: (id, answer) => {
|
|
327
|
+
const entry = waiting.get(id);
|
|
328
|
+
if (!entry) return false;
|
|
329
|
+
entry.settle(answer);
|
|
330
|
+
changed();
|
|
331
|
+
return true;
|
|
332
|
+
},
|
|
333
|
+
cancel: (match) => {
|
|
334
|
+
let any = false;
|
|
335
|
+
for (const entry of [...waiting.values()]) {
|
|
336
|
+
if (match && !match(entry.question)) continue;
|
|
337
|
+
entry.settle(DECLINED);
|
|
338
|
+
any = true;
|
|
339
|
+
}
|
|
340
|
+
if (any) changed();
|
|
341
|
+
},
|
|
342
|
+
dispose: () => {
|
|
343
|
+
disposed = true;
|
|
344
|
+
for (const entry of [...waiting.values()]) entry.settle(DECLINED);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
var questionChoiceOf = (question, picked) => {
|
|
349
|
+
const chosen = question.options.map((o) => o.label).filter((label) => picked.includes(label));
|
|
350
|
+
if (chosen.length === 0) return void 0;
|
|
351
|
+
return { choice: question.multiple ? chosen : chosen.slice(0, 1) };
|
|
352
|
+
};
|
|
353
|
+
var questionOtherOf = (question, text2) => question.allowOther && typeof text2 === "string" && text2.trim() ? { other: text2.trim() } : void 0;
|
|
354
|
+
var LABELS_ONLY = [
|
|
355
|
+
"The user chose: ",
|
|
356
|
+
"The user chose not to answer.",
|
|
357
|
+
"The user did not answer in time.",
|
|
358
|
+
"The question could not be put to the user",
|
|
359
|
+
"You have already asked the user "
|
|
360
|
+
];
|
|
361
|
+
var askUserOutputKept = (output, ok) => (
|
|
362
|
+
// A failed call is about the model's own arguments (a bad question): nobody was asked.
|
|
363
|
+
!ok || typeof output === "string" && LABELS_ONLY.some((start) => output.startsWith(start))
|
|
364
|
+
);
|
|
365
|
+
var withoutOutput = (call) => {
|
|
366
|
+
if (call.name !== ASK_USER_TOOL_NAME || askUserOutputKept(call.output, call.ok)) return call;
|
|
367
|
+
const { output: _dropped, ...rest } = call;
|
|
368
|
+
void _dropped;
|
|
369
|
+
return rest;
|
|
370
|
+
};
|
|
371
|
+
var withoutOwnWords = (event) => {
|
|
372
|
+
switch (event.type) {
|
|
373
|
+
case "step.tool-result": {
|
|
374
|
+
const cleaned = withoutOutput(event);
|
|
375
|
+
return cleaned === event ? event : { ...cleaned, output: void 0 };
|
|
376
|
+
}
|
|
377
|
+
case "step.complete": {
|
|
378
|
+
const calls = event.result.toolCalls;
|
|
379
|
+
const cleaned = calls.map(withoutOutput);
|
|
380
|
+
return cleaned.every((c, i) => c === calls[i]) ? event : { ...event, result: { ...event.result, toolCalls: cleaned } };
|
|
381
|
+
}
|
|
382
|
+
case "subagent.event": {
|
|
383
|
+
const inner = withoutOwnWords(event.event);
|
|
384
|
+
return inner === event.event ? event : { ...event, event: inner };
|
|
385
|
+
}
|
|
386
|
+
default:
|
|
387
|
+
return event;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
|
|
251
391
|
// src/state.ts
|
|
252
392
|
var import_agent_web = require("@dudko.dev/agent-web");
|
|
253
393
|
var approxTokens = (value) => {
|
|
@@ -395,6 +535,35 @@ var answerElicitation = (state, event, stepId) => {
|
|
|
395
535
|
]
|
|
396
536
|
};
|
|
397
537
|
};
|
|
538
|
+
var addQuestion = (state, event, extra) => state.questions?.some((q) => q.id === event.id) ? state : {
|
|
539
|
+
...state,
|
|
540
|
+
questions: [
|
|
541
|
+
...state.questions ?? [],
|
|
542
|
+
{
|
|
543
|
+
id: event.id,
|
|
544
|
+
question: event.question,
|
|
545
|
+
options: event.options.map((o) => ({ ...o })),
|
|
546
|
+
multiple: event.multiple,
|
|
547
|
+
allowOther: event.allowOther,
|
|
548
|
+
...extra.stepId ? { stepId: extra.stepId } : {},
|
|
549
|
+
...extra.subagent ? { subagent: extra.subagent } : {},
|
|
550
|
+
...extra.remote ? { remote: true } : {},
|
|
551
|
+
status: "pending"
|
|
552
|
+
}
|
|
553
|
+
]
|
|
554
|
+
};
|
|
555
|
+
var answerQuestion = (state, event) => state.questions?.some((q) => q.id === event.id) ? {
|
|
556
|
+
...state,
|
|
557
|
+
questions: state.questions.map(
|
|
558
|
+
(q) => q.id === event.id ? {
|
|
559
|
+
...q,
|
|
560
|
+
status: event.action,
|
|
561
|
+
automatic: event.automatic,
|
|
562
|
+
...event.action === "choice" && event.choice ? { choice: [...event.choice] } : {},
|
|
563
|
+
...event.reason ? { reason: event.reason } : {}
|
|
564
|
+
} : q
|
|
565
|
+
)
|
|
566
|
+
} : state;
|
|
398
567
|
var patchSubagent = (subagents, id, fn) => subagents.map((s) => s.id === id ? fn(s) : s);
|
|
399
568
|
var runningStepId = (steps) => [...steps].reverse().find((s) => s.status === "running")?.id;
|
|
400
569
|
var applySubagentEvent = (view, event) => {
|
|
@@ -627,6 +796,25 @@ var applySubagent = (state, event, ancestors, ctx) => {
|
|
|
627
796
|
inner,
|
|
628
797
|
known.subagents.find((s) => s.id === event.id)?.stepId
|
|
629
798
|
);
|
|
799
|
+
// A helper (or a subagent the host defined) asks the person through the run's handler:
|
|
800
|
+
// the question is the person's to answer, like the run's own, marked with who asks.
|
|
801
|
+
case "user.question-asked": {
|
|
802
|
+
const asker = inner.subagent ?? { id: event.id, depth: ancestors.length + 1 };
|
|
803
|
+
const node = known.subagents.find((s) => s.id === asker.id);
|
|
804
|
+
return addQuestion(known, inner, {
|
|
805
|
+
...ctx.remote ? { remote: true } : {},
|
|
806
|
+
// The helper's own step ids mean nothing here: the step that delegated it does.
|
|
807
|
+
stepId: (node ?? known.subagents.find((s) => s.id === event.id))?.stepId,
|
|
808
|
+
subagent: {
|
|
809
|
+
id: asker.id,
|
|
810
|
+
depth: asker.depth,
|
|
811
|
+
...node ? { name: node.name } : {},
|
|
812
|
+
...node?.role ? { role: node.role } : {}
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
case "user.question-answered":
|
|
817
|
+
return answerQuestion(known, inner);
|
|
630
818
|
// What a subagent generated is in the same workspace: it shows in the turn (its step
|
|
631
819
|
// ids are its own, so it is tied to no step here).
|
|
632
820
|
case "media.generated":
|
|
@@ -833,7 +1021,10 @@ var applyEvent = (state, event, ctx) => {
|
|
|
833
1021
|
...event.model !== void 0 ? { model: event.model } : {},
|
|
834
1022
|
...event.tierReason !== void 0 ? { tierReason: event.tierReason } : {}
|
|
835
1023
|
};
|
|
836
|
-
|
|
1024
|
+
const steps = state.steps.map(
|
|
1025
|
+
(s) => s.total === event.total ? s : { ...s, total: event.total }
|
|
1026
|
+
);
|
|
1027
|
+
return { ...state, steps: [...steps, view] };
|
|
837
1028
|
}
|
|
838
1029
|
case "step.escalated":
|
|
839
1030
|
return {
|
|
@@ -1085,6 +1276,15 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1085
1276
|
});
|
|
1086
1277
|
case "mcp.elicitation-answered":
|
|
1087
1278
|
return answerElicitation(state, event, runningStepId(state.steps));
|
|
1279
|
+
case "user.question-asked":
|
|
1280
|
+
return addQuestion(state, event, {
|
|
1281
|
+
// Asked in the tab that runs the agent: shown here, answered there only.
|
|
1282
|
+
...ctx.remote ? { remote: true } : {},
|
|
1283
|
+
stepId: event.step?.id,
|
|
1284
|
+
...event.subagent ? { subagent: event.subagent } : {}
|
|
1285
|
+
});
|
|
1286
|
+
case "user.question-answered":
|
|
1287
|
+
return answerQuestion(state, event);
|
|
1088
1288
|
case "tool.approval-requested":
|
|
1089
1289
|
return {
|
|
1090
1290
|
...state,
|
|
@@ -1216,6 +1416,12 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1216
1416
|
(e) => e.status === "pending" ? { ...e, status: "cancelled", automatic: true, reason: "stopped" } : e
|
|
1217
1417
|
)
|
|
1218
1418
|
} : {},
|
|
1419
|
+
// Nobody is asked any more once the run has stopped.
|
|
1420
|
+
...state.questions ? {
|
|
1421
|
+
questions: state.questions.map(
|
|
1422
|
+
(q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
|
|
1423
|
+
)
|
|
1424
|
+
} : {},
|
|
1219
1425
|
messages: finalizeAssistant(
|
|
1220
1426
|
state.messages,
|
|
1221
1427
|
state.finalText || "Stopped.",
|
|
@@ -1334,8 +1540,9 @@ var agentStateReducer = (state, action) => {
|
|
|
1334
1540
|
return { ...state, remote };
|
|
1335
1541
|
}
|
|
1336
1542
|
case "event": {
|
|
1543
|
+
const event = withoutOwnWords(action.event);
|
|
1337
1544
|
const next = syncRunMessage(
|
|
1338
|
-
applyEvent(state,
|
|
1545
|
+
applyEvent(state, event, {
|
|
1339
1546
|
at: action.at,
|
|
1340
1547
|
attachments: action.attachments,
|
|
1341
1548
|
...action.remote ? { remote: true } : {},
|
|
@@ -1343,7 +1550,7 @@ var agentStateReducer = (state, action) => {
|
|
|
1343
1550
|
})
|
|
1344
1551
|
);
|
|
1345
1552
|
const cap = action.maxEvents ?? 200;
|
|
1346
|
-
const events = cap > 0 ? [...state.events,
|
|
1553
|
+
const events = cap > 0 ? [...state.events, event].slice(-cap) : [...state.events, event];
|
|
1347
1554
|
return { ...next, events };
|
|
1348
1555
|
}
|
|
1349
1556
|
case "undelivered":
|
|
@@ -1424,6 +1631,13 @@ var useAgent = (config, options = {}) => {
|
|
|
1424
1631
|
(decision) => approvals.settleAll(decision),
|
|
1425
1632
|
[approvals]
|
|
1426
1633
|
);
|
|
1634
|
+
const [pendingQuestions, setPendingQuestions] = (0, import_react.useState)([]);
|
|
1635
|
+
const [questionQueue] = (0, import_react.useState)(
|
|
1636
|
+
() => createQuestionQueue({
|
|
1637
|
+
timeoutMs: () => questionTimeoutOf(configRef.current.askUser),
|
|
1638
|
+
onChange: setPendingQuestions
|
|
1639
|
+
})
|
|
1640
|
+
);
|
|
1427
1641
|
const uiOnRequest = (0, import_react.useCallback)(
|
|
1428
1642
|
(req2, ctx) => (req2.app ? appApprovals : approvals).handler(req2, ctx),
|
|
1429
1643
|
[approvals, appApprovals]
|
|
@@ -1458,10 +1672,12 @@ var useAgent = (config, options = {}) => {
|
|
|
1458
1672
|
return;
|
|
1459
1673
|
}
|
|
1460
1674
|
const routeApprovals = optionsRef.current.approvals !== false && !cfg.toolApproval?.onRequest;
|
|
1461
|
-
const
|
|
1675
|
+
const askUser = optionsRef.current.questions !== false ? askUserWith(cfg.askUser, questionQueue.handler) : cfg.askUser;
|
|
1676
|
+
const built = {
|
|
1462
1677
|
...cfg,
|
|
1463
|
-
toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest }
|
|
1464
|
-
|
|
1678
|
+
...routeApprovals ? { toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest } } : {},
|
|
1679
|
+
...askUser !== cfg.askUser ? { askUser } : {}
|
|
1680
|
+
};
|
|
1465
1681
|
let cancelled = false;
|
|
1466
1682
|
setBuildStatus({ status: "initializing" });
|
|
1467
1683
|
(0, import_agent_web2.createAgent)(built).then((agent) => {
|
|
@@ -1534,8 +1750,9 @@ var useAgent = (config, options = {}) => {
|
|
|
1534
1750
|
abortRef.current?.abort();
|
|
1535
1751
|
settleAll({ approved: false, reason: "the view was closed" });
|
|
1536
1752
|
appApprovals.settleAll({ approved: false, reason: "the view was closed" });
|
|
1753
|
+
questionQueue.dispose();
|
|
1537
1754
|
},
|
|
1538
|
-
[settleAll, appApprovals]
|
|
1755
|
+
[settleAll, appApprovals, questionQueue]
|
|
1539
1756
|
);
|
|
1540
1757
|
const runRef = (0, import_react.useRef)(void 0);
|
|
1541
1758
|
const run = (0, import_react.useCallback)(
|
|
@@ -1603,6 +1820,7 @@ var useAgent = (config, options = {}) => {
|
|
|
1603
1820
|
startedRef.current = false;
|
|
1604
1821
|
controlRef.current = void 0;
|
|
1605
1822
|
settleAll({ approved: false, reason: "the run ended" });
|
|
1823
|
+
questionQueue.cancel();
|
|
1606
1824
|
dispatch({ type: "status", ...buildStatusRef.current });
|
|
1607
1825
|
if (stopped && !began && shownGoal.trim()) left = [shownGoal, ...left];
|
|
1608
1826
|
if (left.length > 0) {
|
|
@@ -1617,7 +1835,7 @@ var useAgent = (config, options = {}) => {
|
|
|
1617
1835
|
}
|
|
1618
1836
|
}
|
|
1619
1837
|
},
|
|
1620
|
-
[settleAll]
|
|
1838
|
+
[settleAll, questionQueue]
|
|
1621
1839
|
);
|
|
1622
1840
|
runRef.current = run;
|
|
1623
1841
|
const send = (0, import_react.useCallback)((text2) => controlRef.current?.send(text2) ?? false, []);
|
|
@@ -1653,7 +1871,12 @@ var useAgent = (config, options = {}) => {
|
|
|
1653
1871
|
const stop = (0, import_react.useCallback)(() => {
|
|
1654
1872
|
abortRef.current?.abort();
|
|
1655
1873
|
settleAll({ approved: false, reason: "stopped by the user" });
|
|
1656
|
-
|
|
1874
|
+
questionQueue.cancel();
|
|
1875
|
+
}, [settleAll, questionQueue]);
|
|
1876
|
+
const answerQuestion2 = (0, import_react.useCallback)(
|
|
1877
|
+
(id, answer) => questionQueue.answer(id, answer),
|
|
1878
|
+
[questionQueue]
|
|
1879
|
+
);
|
|
1657
1880
|
const reset = (0, import_react.useCallback)(() => {
|
|
1658
1881
|
dispatch({ type: "reset" });
|
|
1659
1882
|
void configRef.current.memory?.clear(sessionRef.current).catch(() => {
|
|
@@ -1778,6 +2001,8 @@ var useAgent = (config, options = {}) => {
|
|
|
1778
2001
|
pendingApprovals: pendingApprovalsOf(state),
|
|
1779
2002
|
approve,
|
|
1780
2003
|
deny,
|
|
2004
|
+
pendingQuestions,
|
|
2005
|
+
answerQuestion: answerQuestion2,
|
|
1781
2006
|
approvalMode,
|
|
1782
2007
|
setApprovalMode,
|
|
1783
2008
|
approveAppToolCall,
|
|
@@ -2678,6 +2903,11 @@ var defaultLabels = {
|
|
|
2678
2903
|
subagentNoTools: "no tools",
|
|
2679
2904
|
approvalLeadHelper: (role) => role ? `The helper \u201C${role}\u201D wants to run` : "A helper the agent started wants to run",
|
|
2680
2905
|
mediaImage: (path) => `Generated image ${path}`,
|
|
2906
|
+
imageOpen: (name) => `Open image ${name}`,
|
|
2907
|
+
imagePrevious: "Previous image",
|
|
2908
|
+
imageNext: "Next image",
|
|
2909
|
+
imageZoom: "Zoom",
|
|
2910
|
+
imageCount: (index, total) => `${index} of ${total}`,
|
|
2681
2911
|
mediaAudio: (path) => `Generated audio ${path}`,
|
|
2682
2912
|
mediaFile: (path) => `Generated file ${path}`,
|
|
2683
2913
|
transcriptOf: (name) => `Transcript of ${name}`,
|
|
@@ -2789,6 +3019,25 @@ var defaultLabels = {
|
|
|
2789
3019
|
"no-tool-call": "no tool call was in progress"
|
|
2790
3020
|
},
|
|
2791
3021
|
elicitationDismiss: "Dismiss",
|
|
3022
|
+
questionLead: "The agent asks you",
|
|
3023
|
+
questionLeadHelper: (role) => role ? `The helper \u201C${role}\u201D asks you` : "A helper the agent started asks you",
|
|
3024
|
+
questionCount: (index, total) => `${index} of ${total}`,
|
|
3025
|
+
questionSeveral: "Pick one or more, then Send.",
|
|
3026
|
+
questionSend: "Send",
|
|
3027
|
+
questionOther: "Other\u2026",
|
|
3028
|
+
questionOtherLabel: "Your answer",
|
|
3029
|
+
questionSkip: "Skip",
|
|
3030
|
+
questionExpiresIn: (time) => `If you do not answer, the agent decides by itself in ${time}`,
|
|
3031
|
+
questionRemote: "Answered in the other tab, where the agent is running.",
|
|
3032
|
+
questionAutomatic: (reason) => `The agent went on without your answer: ${reason}.`,
|
|
3033
|
+
questionReasons: {
|
|
3034
|
+
timeout: "nobody answered in time",
|
|
3035
|
+
stopped: "the run was stopped",
|
|
3036
|
+
"handler-error": "the question could not be shown",
|
|
3037
|
+
"invalid-answer": "the answer did not fit the question",
|
|
3038
|
+
"cannot-park": "the question could not wait here"
|
|
3039
|
+
},
|
|
3040
|
+
questionDismiss: "Dismiss",
|
|
2792
3041
|
appFrom: (server) => `App from server \u201C${server}\u201D`,
|
|
2793
3042
|
appSandboxed: "sandboxed",
|
|
2794
3043
|
appSandboxedOrigin: "sandboxed on its own origin",
|
|
@@ -2880,6 +3129,7 @@ var NESTED = [
|
|
|
2880
3129
|
"decisionReasons",
|
|
2881
3130
|
"elicitationErrors",
|
|
2882
3131
|
"elicitationReasons",
|
|
3132
|
+
"questionReasons",
|
|
2883
3133
|
"fileKinds",
|
|
2884
3134
|
"appSandboxReasons"
|
|
2885
3135
|
];
|
|
@@ -3171,12 +3421,129 @@ var formatCountdown = (ms) => {
|
|
|
3171
3421
|
};
|
|
3172
3422
|
|
|
3173
3423
|
// src/components/AgentChat.tsx
|
|
3174
|
-
var
|
|
3175
|
-
var
|
|
3424
|
+
var import_react22 = require("react");
|
|
3425
|
+
var import_react_dom2 = require("react-dom");
|
|
3176
3426
|
|
|
3177
|
-
// src/hooks/use-
|
|
3427
|
+
// src/hooks/use-follow-scroll.ts
|
|
3178
3428
|
var import_react9 = require("react");
|
|
3179
3429
|
|
|
3430
|
+
// src/follow-scroll.ts
|
|
3431
|
+
var FOLLOW_REJOIN_PX = 80;
|
|
3432
|
+
var FOLLOW_LEAVE_PX = 2;
|
|
3433
|
+
var endGap = (m) => m.scrollHeight - m.scrollTop - m.clientHeight;
|
|
3434
|
+
var reach = (m) => Math.min(m.scrollTop, Math.max(0, m.scrollHeight - m.clientHeight));
|
|
3435
|
+
var followsAfterScroll = (following, before, now) => {
|
|
3436
|
+
if (before.scrollHeight !== now.scrollHeight || before.clientHeight !== now.clientHeight)
|
|
3437
|
+
return following;
|
|
3438
|
+
if (now.scrollTop < reach(before) - FOLLOW_LEAVE_PX) return false;
|
|
3439
|
+
if (now.scrollTop > before.scrollTop) return endGap(now) < FOLLOW_REJOIN_PX ? true : following;
|
|
3440
|
+
return following;
|
|
3441
|
+
};
|
|
3442
|
+
var followsAfterResize = (following, before, now) => following && !(now.clientHeight === before.clientHeight && now.scrollHeight >= before.scrollHeight && now.scrollTop < reach(before) - FOLLOW_LEAVE_PX);
|
|
3443
|
+
|
|
3444
|
+
// src/hooks/use-follow-scroll.ts
|
|
3445
|
+
var useIsoLayoutEffect = typeof window === "undefined" ? import_react9.useEffect : import_react9.useLayoutEffect;
|
|
3446
|
+
var measure = (el) => ({
|
|
3447
|
+
scrollTop: el.scrollTop,
|
|
3448
|
+
scrollHeight: el.scrollHeight,
|
|
3449
|
+
clientHeight: el.clientHeight
|
|
3450
|
+
});
|
|
3451
|
+
var anchorOf = (el) => {
|
|
3452
|
+
const box = el.getBoundingClientRect();
|
|
3453
|
+
if (box.width === 0 || box.height === 0) return void 0;
|
|
3454
|
+
const doc = el.ownerDocument;
|
|
3455
|
+
const marks = [];
|
|
3456
|
+
for (const dy of [8, 24, 48, 80, 120, 180]) {
|
|
3457
|
+
if (dy >= box.height) break;
|
|
3458
|
+
const node = doc.elementFromPoint(box.left + box.width / 2, box.top + dy);
|
|
3459
|
+
if (!node || node === el || !el.contains(node) || marks.some((m) => m.node === node)) continue;
|
|
3460
|
+
const r = node.getBoundingClientRect();
|
|
3461
|
+
marks.push({ node, offset: r.top - box.top, height: r.height });
|
|
3462
|
+
}
|
|
3463
|
+
marks.sort((a, b) => a.height - b.height);
|
|
3464
|
+
return marks.length ? { marks, top: el.scrollTop } : void 0;
|
|
3465
|
+
};
|
|
3466
|
+
var useFollowScroll = (ref, turn, live = true) => {
|
|
3467
|
+
const following = (0, import_react9.useRef)(true);
|
|
3468
|
+
const last = (0, import_react9.useRef)(void 0);
|
|
3469
|
+
const anchor = (0, import_react9.useRef)(void 0);
|
|
3470
|
+
const settle = (0, import_react9.useRef)(() => {
|
|
3471
|
+
});
|
|
3472
|
+
const arriving = (0, import_react9.useRef)(live);
|
|
3473
|
+
arriving.current = live;
|
|
3474
|
+
useIsoLayoutEffect(() => {
|
|
3475
|
+
const el = ref.current;
|
|
3476
|
+
if (!el) return;
|
|
3477
|
+
last.current = measure(el);
|
|
3478
|
+
const anchoring = el.style.getPropertyValue("overflow-anchor");
|
|
3479
|
+
el.style.setProperty("overflow-anchor", "none");
|
|
3480
|
+
const toEnd = () => {
|
|
3481
|
+
const top = el.scrollHeight - el.clientHeight;
|
|
3482
|
+
if (top - el.scrollTop > 0.5) el.scrollTop = top;
|
|
3483
|
+
};
|
|
3484
|
+
const keep = (render) => {
|
|
3485
|
+
const now = measure(el);
|
|
3486
|
+
const before = last.current;
|
|
3487
|
+
if (before) following.current = followsAfterResize(following.current, before, now);
|
|
3488
|
+
if (following.current) {
|
|
3489
|
+
if (render || arriving.current || !before || now.clientHeight !== before.clientHeight)
|
|
3490
|
+
toEnd();
|
|
3491
|
+
else if (endGap(now) > 0.5) following.current = false;
|
|
3492
|
+
} else if (anchor.current) {
|
|
3493
|
+
const seenAt = anchor.current.top;
|
|
3494
|
+
const mark = anchor.current.marks.find(
|
|
3495
|
+
(m) => m.node.isConnected && m.node.getClientRects().length > 0
|
|
3496
|
+
);
|
|
3497
|
+
if (mark) {
|
|
3498
|
+
const shift = mark.node.getBoundingClientRect().top - el.getBoundingClientRect().top - mark.offset + (el.scrollTop - seenAt);
|
|
3499
|
+
if (Math.abs(shift) > 0.5) el.scrollTop += shift;
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
last.current = measure(el);
|
|
3503
|
+
if (!following.current) anchor.current = anchorOf(el);
|
|
3504
|
+
};
|
|
3505
|
+
settle.current = () => keep(true);
|
|
3506
|
+
const onScroll = () => {
|
|
3507
|
+
const now = measure(el);
|
|
3508
|
+
const was = following.current;
|
|
3509
|
+
following.current = followsAfterScroll(was, last.current ?? now, now);
|
|
3510
|
+
last.current = now;
|
|
3511
|
+
anchor.current = following.current ? void 0 : anchorOf(el);
|
|
3512
|
+
};
|
|
3513
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
3514
|
+
const restore = () => {
|
|
3515
|
+
el.removeEventListener("scroll", onScroll);
|
|
3516
|
+
if (anchoring) el.style.setProperty("overflow-anchor", anchoring);
|
|
3517
|
+
else el.style.removeProperty("overflow-anchor");
|
|
3518
|
+
};
|
|
3519
|
+
if (typeof ResizeObserver === "undefined") return restore;
|
|
3520
|
+
const sizes = new ResizeObserver(() => keep(false));
|
|
3521
|
+
const watch = () => {
|
|
3522
|
+
sizes.disconnect();
|
|
3523
|
+
sizes.observe(el);
|
|
3524
|
+
for (const child of el.children) sizes.observe(child);
|
|
3525
|
+
};
|
|
3526
|
+
watch();
|
|
3527
|
+
const parts = typeof MutationObserver === "undefined" ? void 0 : new MutationObserver((records) => {
|
|
3528
|
+
if (records.some((r) => r.type === "childList")) watch();
|
|
3529
|
+
});
|
|
3530
|
+
parts?.observe(el, { childList: true });
|
|
3531
|
+
return () => {
|
|
3532
|
+
restore();
|
|
3533
|
+
sizes.disconnect();
|
|
3534
|
+
parts?.disconnect();
|
|
3535
|
+
};
|
|
3536
|
+
}, [ref]);
|
|
3537
|
+
useIsoLayoutEffect(() => {
|
|
3538
|
+
following.current = true;
|
|
3539
|
+
anchor.current = void 0;
|
|
3540
|
+
}, [turn]);
|
|
3541
|
+
useIsoLayoutEffect(() => settle.current());
|
|
3542
|
+
};
|
|
3543
|
+
|
|
3544
|
+
// src/hooks/use-mcp-app-host.ts
|
|
3545
|
+
var import_react10 = require("react");
|
|
3546
|
+
|
|
3180
3547
|
// src/mcp-app.ts
|
|
3181
3548
|
var import_agent_web5 = require("@dudko.dev/agent-web");
|
|
3182
3549
|
|
|
@@ -4041,27 +4408,27 @@ var useMcpAppHost = ({
|
|
|
4041
4408
|
sampling = false,
|
|
4042
4409
|
sample: sampleFn
|
|
4043
4410
|
}) => {
|
|
4044
|
-
const [requests, setRequests] = (0,
|
|
4045
|
-
const [draft, setDraft] = (0,
|
|
4046
|
-
const waiting = (0,
|
|
4411
|
+
const [requests, setRequests] = (0, import_react10.useState)([]);
|
|
4412
|
+
const [draft, setDraft] = (0, import_react10.useState)();
|
|
4413
|
+
const waiting = (0, import_react10.useRef)(
|
|
4047
4414
|
/* @__PURE__ */ new Map()
|
|
4048
4415
|
);
|
|
4049
|
-
const samplingAllowed = (0,
|
|
4050
|
-
const sampleRef = (0,
|
|
4416
|
+
const samplingAllowed = (0, import_react10.useRef)(/* @__PURE__ */ new Set());
|
|
4417
|
+
const sampleRef = (0, import_react10.useRef)(sampleFn);
|
|
4051
4418
|
sampleRef.current = sampleFn;
|
|
4052
|
-
const [gated, setGated] = (0,
|
|
4053
|
-
const connectionRef = (0,
|
|
4419
|
+
const [gated, setGated] = (0, import_react10.useState)({});
|
|
4420
|
+
const connectionRef = (0, import_react10.useRef)(connection);
|
|
4054
4421
|
connectionRef.current = connection;
|
|
4055
|
-
const approveRef = (0,
|
|
4422
|
+
const approveRef = (0, import_react10.useRef)(approve);
|
|
4056
4423
|
approveRef.current = approve;
|
|
4057
|
-
(0,
|
|
4424
|
+
(0, import_react10.useEffect)(
|
|
4058
4425
|
() => () => {
|
|
4059
4426
|
for (const { resolve } of waiting.current.values()) resolve(false);
|
|
4060
4427
|
waiting.current.clear();
|
|
4061
4428
|
},
|
|
4062
4429
|
[]
|
|
4063
4430
|
);
|
|
4064
|
-
const ask = (0,
|
|
4431
|
+
const ask = (0, import_react10.useCallback)(
|
|
4065
4432
|
(request, signal, extra = {}) => {
|
|
4066
4433
|
for (const w of waiting.current.values()) {
|
|
4067
4434
|
if (w.request.appId === request.appId) {
|
|
@@ -4086,7 +4453,7 @@ var useMcpAppHost = ({
|
|
|
4086
4453
|
},
|
|
4087
4454
|
[]
|
|
4088
4455
|
);
|
|
4089
|
-
const answer = (0,
|
|
4456
|
+
const answer = (0, import_react10.useCallback)((id, accept, options) => {
|
|
4090
4457
|
const w = waiting.current.get(id);
|
|
4091
4458
|
if (!w) return;
|
|
4092
4459
|
if (accept && w.request.kind === "link" && w.request.link) {
|
|
@@ -4112,16 +4479,16 @@ var useMcpAppHost = ({
|
|
|
4112
4479
|
}
|
|
4113
4480
|
w.resolve(accept);
|
|
4114
4481
|
}, []);
|
|
4115
|
-
const read = (0,
|
|
4482
|
+
const read = (0, import_react10.useCallback)((app, signal) => {
|
|
4116
4483
|
const c = connectionRef.current;
|
|
4117
4484
|
if (!c) return Promise.reject(new Error(`no connection to the server \u201C${app.server}\u201D`));
|
|
4118
4485
|
return c.readUiResource(app.server, app.resourceUri, signal ? { signal } : void 0);
|
|
4119
4486
|
}, []);
|
|
4120
|
-
const tool = (0,
|
|
4487
|
+
const tool = (0, import_react10.useCallback)(
|
|
4121
4488
|
(app) => connectionRef.current?.appTool(app.server, app.toolName),
|
|
4122
4489
|
[]
|
|
4123
4490
|
);
|
|
4124
|
-
const callTool = (0,
|
|
4491
|
+
const callTool = (0, import_react10.useCallback)(
|
|
4125
4492
|
async (app, name, args, signal) => {
|
|
4126
4493
|
const c = connectionRef.current;
|
|
4127
4494
|
if (!c) throw refused(`The server \u201C${app.server}\u201D is not connected`);
|
|
@@ -4158,15 +4525,15 @@ var useMcpAppHost = ({
|
|
|
4158
4525
|
},
|
|
4159
4526
|
[]
|
|
4160
4527
|
);
|
|
4161
|
-
const openLink = (0,
|
|
4528
|
+
const openLink = (0, import_react10.useCallback)(
|
|
4162
4529
|
(app, link, signal) => ask({ appId: app.id, server: app.server, kind: "link", link }, signal),
|
|
4163
4530
|
[ask]
|
|
4164
4531
|
);
|
|
4165
|
-
const message = (0,
|
|
4532
|
+
const message = (0, import_react10.useCallback)(
|
|
4166
4533
|
(app, text2, signal) => ask({ appId: app.id, server: app.server, kind: "message", text: text2 }, signal),
|
|
4167
4534
|
[ask]
|
|
4168
4535
|
);
|
|
4169
|
-
const downloadFile2 = (0,
|
|
4536
|
+
const downloadFile2 = (0, import_react10.useCallback)(
|
|
4170
4537
|
async (app, file, signal) => {
|
|
4171
4538
|
const c = connectionRef.current;
|
|
4172
4539
|
if (file.kind === "link" && !c) throw refused(`The server \u201C${app.server}\u201D is not connected`);
|
|
@@ -4189,7 +4556,7 @@ var useMcpAppHost = ({
|
|
|
4189
4556
|
},
|
|
4190
4557
|
[ask]
|
|
4191
4558
|
);
|
|
4192
|
-
const sample = (0,
|
|
4559
|
+
const sample = (0, import_react10.useCallback)(
|
|
4193
4560
|
async (app, params, signal) => {
|
|
4194
4561
|
const fn = sampleRef.current;
|
|
4195
4562
|
if (!fn) throw refused("This host cannot answer sampling requests");
|
|
@@ -4210,19 +4577,19 @@ var useMcpAppHost = ({
|
|
|
4210
4577
|
},
|
|
4211
4578
|
[ask]
|
|
4212
4579
|
);
|
|
4213
|
-
const pendingAppServers = (0,
|
|
4580
|
+
const pendingAppServers = (0, import_react10.useMemo)(
|
|
4214
4581
|
() => new Set(
|
|
4215
4582
|
approvals.filter((a) => a.app && a.status === "pending").map((a) => `${a.app.server}\0${a.app.resourceUri}`)
|
|
4216
4583
|
),
|
|
4217
4584
|
[approvals]
|
|
4218
4585
|
);
|
|
4219
|
-
const isWaiting = (0,
|
|
4586
|
+
const isWaiting = (0, import_react10.useCallback)(
|
|
4220
4587
|
(app) => requests.some((r) => r.appId === app.id) || Boolean(gated[app.id]) && pendingAppServers.has(`${app.server}\0${app.resourceUri}`),
|
|
4221
4588
|
[requests, gated, pendingAppServers]
|
|
4222
4589
|
);
|
|
4223
4590
|
const sandboxUrl = sandbox?.url;
|
|
4224
4591
|
const sandboxTimeout = sandbox?.timeoutMs;
|
|
4225
|
-
const sandboxSetting = (0,
|
|
4592
|
+
const sandboxSetting = (0, import_react10.useMemo)(
|
|
4226
4593
|
() => sandboxUrl === void 0 ? void 0 : {
|
|
4227
4594
|
url: sandboxUrl,
|
|
4228
4595
|
...sandboxTimeout !== void 0 ? { timeoutMs: sandboxTimeout } : {}
|
|
@@ -4230,7 +4597,7 @@ var useMcpAppHost = ({
|
|
|
4230
4597
|
[sandboxUrl, sandboxTimeout]
|
|
4231
4598
|
);
|
|
4232
4599
|
const samplingOn = sampling && Boolean(sampleFn);
|
|
4233
|
-
return (0,
|
|
4600
|
+
return (0, import_react10.useMemo)(
|
|
4234
4601
|
() => ({
|
|
4235
4602
|
connected: Boolean(connection),
|
|
4236
4603
|
read,
|
|
@@ -4513,11 +4880,11 @@ var AppRequestPrompt = ({
|
|
|
4513
4880
|
};
|
|
4514
4881
|
|
|
4515
4882
|
// src/components/McpAppFrame.tsx
|
|
4516
|
-
var
|
|
4883
|
+
var import_react11 = require("react");
|
|
4517
4884
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4518
4885
|
var HOST_INFO = { name: "@dudko.dev/agent-web-react", version: "1" };
|
|
4519
4886
|
var MAX_LISTED_CALLS = 12;
|
|
4520
|
-
var
|
|
4887
|
+
var useIsoLayoutEffect2 = typeof window === "undefined" ? import_react11.useEffect : import_react11.useLayoutEffect;
|
|
4521
4888
|
var userActivation = () => typeof navigator === "undefined" ? void 0 : navigator.userActivation?.isActive;
|
|
4522
4889
|
var silentSandboxes = /* @__PURE__ */ new Set();
|
|
4523
4890
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -4550,36 +4917,36 @@ var McpAppFrame = ({
|
|
|
4550
4917
|
className
|
|
4551
4918
|
}) => {
|
|
4552
4919
|
const L = useLabels(labels);
|
|
4553
|
-
const [collapsed, setCollapsed] = (0,
|
|
4554
|
-
const [menu, setMenu] = (0,
|
|
4555
|
-
const [reload, setReload] = (0,
|
|
4556
|
-
const [loaded, setLoaded] = (0,
|
|
4557
|
-
const [height, setHeight] = (0,
|
|
4558
|
-
const [calls, setCalls] = (0,
|
|
4559
|
-
const [fallback, setFallback] = (0,
|
|
4560
|
-
const [broken, setBroken] = (0,
|
|
4561
|
-
const [onOrigin, setOnOrigin] = (0,
|
|
4562
|
-
const shellLoaded = (0,
|
|
4563
|
-
const [mode, setMode] = (0,
|
|
4564
|
-
const modeRef = (0,
|
|
4565
|
-
const [holder, setHolder] = (0,
|
|
4566
|
-
const [fullRect, setFullRect] = (0,
|
|
4567
|
-
const leaveRef = (0,
|
|
4568
|
-
const rootRef = (0,
|
|
4569
|
-
const exitRef = (0,
|
|
4570
|
-
const allowFullscreenRef = (0,
|
|
4920
|
+
const [collapsed, setCollapsed] = (0, import_react11.useState)(defaultCollapsed);
|
|
4921
|
+
const [menu, setMenu] = (0, import_react11.useState)(false);
|
|
4922
|
+
const [reload, setReload] = (0, import_react11.useState)(0);
|
|
4923
|
+
const [loaded, setLoaded] = (0, import_react11.useState)();
|
|
4924
|
+
const [height, setHeight] = (0, import_react11.useState)(APP_DEFAULT_HEIGHT);
|
|
4925
|
+
const [calls, setCalls] = (0, import_react11.useState)([]);
|
|
4926
|
+
const [fallback, setFallback] = (0, import_react11.useState)();
|
|
4927
|
+
const [broken, setBroken] = (0, import_react11.useState)(false);
|
|
4928
|
+
const [onOrigin, setOnOrigin] = (0, import_react11.useState)(false);
|
|
4929
|
+
const shellLoaded = (0, import_react11.useRef)(void 0);
|
|
4930
|
+
const [mode, setMode] = (0, import_react11.useState)("inline");
|
|
4931
|
+
const modeRef = (0, import_react11.useRef)("inline");
|
|
4932
|
+
const [holder, setHolder] = (0, import_react11.useState)(0);
|
|
4933
|
+
const [fullRect, setFullRect] = (0, import_react11.useState)();
|
|
4934
|
+
const leaveRef = (0, import_react11.useRef)(void 0);
|
|
4935
|
+
const rootRef = (0, import_react11.useRef)(null);
|
|
4936
|
+
const exitRef = (0, import_react11.useRef)(null);
|
|
4937
|
+
const allowFullscreenRef = (0, import_react11.useRef)(allowFullscreen);
|
|
4571
4938
|
allowFullscreenRef.current = allowFullscreen;
|
|
4572
|
-
const iframeRef = (0,
|
|
4573
|
-
const bridgeRef = (0,
|
|
4574
|
-
const menuRef = (0,
|
|
4575
|
-
const themeRef = (0,
|
|
4939
|
+
const iframeRef = (0, import_react11.useRef)(null);
|
|
4940
|
+
const bridgeRef = (0, import_react11.useRef)(void 0);
|
|
4941
|
+
const menuRef = (0, import_react11.useRef)(null);
|
|
4942
|
+
const themeRef = (0, import_react11.useRef)(theme);
|
|
4576
4943
|
themeRef.current = theme;
|
|
4577
|
-
const hostRef = (0,
|
|
4944
|
+
const hostRef = (0, import_react11.useRef)(host);
|
|
4578
4945
|
hostRef.current = host;
|
|
4579
|
-
const appRef = (0,
|
|
4946
|
+
const appRef = (0, import_react11.useRef)(app);
|
|
4580
4947
|
appRef.current = app;
|
|
4581
4948
|
const live = !collapsed;
|
|
4582
|
-
(0,
|
|
4949
|
+
(0, import_react11.useEffect)(() => {
|
|
4583
4950
|
if (!live) return;
|
|
4584
4951
|
if (!hostRef.current.connected) {
|
|
4585
4952
|
setLoaded({ unavailable: true });
|
|
@@ -4602,7 +4969,7 @@ var McpAppFrame = ({
|
|
|
4602
4969
|
const resource = loaded && "resource" in loaded ? loaded.resource : void 0;
|
|
4603
4970
|
const sandboxUrl = host.sandbox?.url;
|
|
4604
4971
|
const timeoutMs = host.sandbox?.timeoutMs ?? MCP_APP_SANDBOX_TIMEOUT_MS;
|
|
4605
|
-
const placement = (0,
|
|
4972
|
+
const placement = (0, import_react11.useMemo)(() => {
|
|
4606
4973
|
if (!resource) return void 0;
|
|
4607
4974
|
if (sandboxUrl === void 0) return { mode: "opaque" };
|
|
4608
4975
|
if (fallback) return { mode: "opaque", reason: fallback };
|
|
@@ -4613,11 +4980,11 @@ var McpAppFrame = ({
|
|
|
4613
4980
|
if (!url) return { mode: "opaque", reason: "too-many-origins" };
|
|
4614
4981
|
return { mode: "origin", origin: target.origin, url };
|
|
4615
4982
|
}, [resource, sandboxUrl, fallback, app.server, reload]);
|
|
4616
|
-
const doc = (0,
|
|
4983
|
+
const doc = (0, import_react11.useMemo)(
|
|
4617
4984
|
() => !resource || !placement ? void 0 : placement.mode === "origin" ? buildMcpAppSandboxShell(placement.url) : buildMcpAppDocument(resource.html, resource.csp),
|
|
4618
4985
|
[resource, placement]
|
|
4619
4986
|
);
|
|
4620
|
-
(0,
|
|
4987
|
+
(0, import_react11.useEffect)(() => {
|
|
4621
4988
|
const reason = placement?.mode === "opaque" ? placement.reason : void 0;
|
|
4622
4989
|
if (reason && reason !== "no-answer" && sandboxUrl !== void 0) {
|
|
4623
4990
|
warnOnce(
|
|
@@ -4626,7 +4993,7 @@ var McpAppFrame = ({
|
|
|
4626
4993
|
);
|
|
4627
4994
|
}
|
|
4628
4995
|
}, [placement, sandboxUrl]);
|
|
4629
|
-
(0,
|
|
4996
|
+
(0, import_react11.useEffect)(() => {
|
|
4630
4997
|
const frame = iframeRef.current;
|
|
4631
4998
|
if (!live || !resource || !frame || !placement || broken) return;
|
|
4632
4999
|
const abort = new AbortController();
|
|
@@ -4771,10 +5138,10 @@ var McpAppFrame = ({
|
|
|
4771
5138
|
}, [live, resource, reload, variant, app.id, placement, broken, timeoutMs]);
|
|
4772
5139
|
const fullscreen = mode === "fullscreen" && live && !broken;
|
|
4773
5140
|
const waitingNow = host.isWaiting(app);
|
|
4774
|
-
(0,
|
|
5141
|
+
(0, import_react11.useEffect)(() => {
|
|
4775
5142
|
if (fullscreen && waitingNow) leaveRef.current?.();
|
|
4776
5143
|
}, [fullscreen, waitingNow]);
|
|
4777
|
-
|
|
5144
|
+
useIsoLayoutEffect2(() => {
|
|
4778
5145
|
if (!fullscreen) return;
|
|
4779
5146
|
const place = () => {
|
|
4780
5147
|
const chat2 = rootRef.current?.closest(".awr-chat");
|
|
@@ -4806,7 +5173,7 @@ var McpAppFrame = ({
|
|
|
4806
5173
|
ro?.disconnect();
|
|
4807
5174
|
};
|
|
4808
5175
|
}, [fullscreen]);
|
|
4809
|
-
(0,
|
|
5176
|
+
(0, import_react11.useEffect)(() => {
|
|
4810
5177
|
if (!fullscreen) return;
|
|
4811
5178
|
const before = document.activeElement;
|
|
4812
5179
|
exitRef.current?.focus();
|
|
@@ -4823,10 +5190,10 @@ var McpAppFrame = ({
|
|
|
4823
5190
|
if (frame && (before === frame || document.activeElement === document.body)) frame.focus();
|
|
4824
5191
|
};
|
|
4825
5192
|
}, [fullscreen]);
|
|
4826
|
-
(0,
|
|
5193
|
+
(0, import_react11.useEffect)(() => {
|
|
4827
5194
|
if (theme) bridgeRef.current?.updateContext({ theme });
|
|
4828
5195
|
}, [theme]);
|
|
4829
|
-
(0,
|
|
5196
|
+
(0, import_react11.useEffect)(() => {
|
|
4830
5197
|
if (!menu) return;
|
|
4831
5198
|
const close = (e) => {
|
|
4832
5199
|
if (e instanceof KeyboardEvent ? e.key === "Escape" : !menuRef.current?.contains(e.target)) {
|
|
@@ -5131,7 +5498,7 @@ var McpAppLine = ({ app, note, action, onAction, labels, className }) => {
|
|
|
5131
5498
|
};
|
|
5132
5499
|
|
|
5133
5500
|
// src/components/AgentComposer.tsx
|
|
5134
|
-
var
|
|
5501
|
+
var import_react12 = require("react");
|
|
5135
5502
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
5136
5503
|
var thinkingDefaults = (l) => [
|
|
5137
5504
|
{ id: "off", label: l.thinkingLevels.off },
|
|
@@ -5143,10 +5510,10 @@ var thinkingDefaults = (l) => [
|
|
|
5143
5510
|
var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
|
|
5144
5511
|
var ModeIcon = ({ mode }) => mode === "autopilot" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BoltIcon, { size: 14 }) : mode === "read-only" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EyeIcon, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ShieldIcon, { size: 14 });
|
|
5145
5512
|
var attachSeq = 0;
|
|
5146
|
-
var
|
|
5513
|
+
var useIsoLayoutEffect3 = typeof window === "undefined" ? import_react12.useEffect : import_react12.useLayoutEffect;
|
|
5147
5514
|
var useMenuPlacement = (open, anchor, align) => {
|
|
5148
|
-
const [style, setStyle] = (0,
|
|
5149
|
-
|
|
5515
|
+
const [style, setStyle] = (0, import_react12.useState)();
|
|
5516
|
+
useIsoLayoutEffect3(() => {
|
|
5150
5517
|
if (!open) return;
|
|
5151
5518
|
const place = () => {
|
|
5152
5519
|
const el = anchor.current;
|
|
@@ -5223,19 +5590,19 @@ var AgentComposer = ({
|
|
|
5223
5590
|
const L = useLabels(labelsOverride);
|
|
5224
5591
|
const MODE_CHIP = L.modes;
|
|
5225
5592
|
const DEFAULT_THINKING = thinkingDefaults(L);
|
|
5226
|
-
const [text2, setText] = (0,
|
|
5227
|
-
const [pending, setPending] = (0,
|
|
5228
|
-
const [menu, setMenu] = (0,
|
|
5229
|
-
const [active, setActive] = (0,
|
|
5230
|
-
const [dismissed, setDismissed] = (0,
|
|
5231
|
-
const [attachError, setAttachError] = (0,
|
|
5232
|
-
const [dragging, setDragging] = (0,
|
|
5233
|
-
const rootRef = (0,
|
|
5234
|
-
const modelRef = (0,
|
|
5235
|
-
const modeRef = (0,
|
|
5236
|
-
const [dropRect, setDropRect] = (0,
|
|
5237
|
-
const [compactBar, setCompactBar] = (0,
|
|
5238
|
-
(0,
|
|
5593
|
+
const [text2, setText] = (0, import_react12.useState)("");
|
|
5594
|
+
const [pending, setPending] = (0, import_react12.useState)([]);
|
|
5595
|
+
const [menu, setMenu] = (0, import_react12.useState)(void 0);
|
|
5596
|
+
const [active, setActive] = (0, import_react12.useState)(0);
|
|
5597
|
+
const [dismissed, setDismissed] = (0, import_react12.useState)(() => /* @__PURE__ */ new Set());
|
|
5598
|
+
const [attachError, setAttachError] = (0, import_react12.useState)();
|
|
5599
|
+
const [dragging, setDragging] = (0, import_react12.useState)(false);
|
|
5600
|
+
const rootRef = (0, import_react12.useRef)(null);
|
|
5601
|
+
const modelRef = (0, import_react12.useRef)(null);
|
|
5602
|
+
const modeRef = (0, import_react12.useRef)(null);
|
|
5603
|
+
const [dropRect, setDropRect] = (0, import_react12.useState)();
|
|
5604
|
+
const [compactBar, setCompactBar] = (0, import_react12.useState)(false);
|
|
5605
|
+
(0, import_react12.useEffect)(() => {
|
|
5239
5606
|
const el = rootRef.current;
|
|
5240
5607
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
5241
5608
|
const ro = new ResizeObserver(
|
|
@@ -5244,11 +5611,11 @@ var AgentComposer = ({
|
|
|
5244
5611
|
ro.observe(el);
|
|
5245
5612
|
return () => ro.disconnect();
|
|
5246
5613
|
}, [compactWidth]);
|
|
5247
|
-
const fileRef = (0,
|
|
5248
|
-
const inputRef = (0,
|
|
5614
|
+
const fileRef = (0, import_react12.useRef)(null);
|
|
5615
|
+
const inputRef = (0, import_react12.useRef)(null);
|
|
5249
5616
|
const draftId = draft?.id;
|
|
5250
5617
|
const draftText = draft?.text;
|
|
5251
|
-
(0,
|
|
5618
|
+
(0, import_react12.useEffect)(() => {
|
|
5252
5619
|
if (draftId === void 0 || !draftText) return;
|
|
5253
5620
|
setText((t) => t.trim() ? `${t.trimEnd()}
|
|
5254
5621
|
${draftText}` : draftText);
|
|
@@ -5265,10 +5632,10 @@ ${draftText}` : draftText);
|
|
|
5265
5632
|
onFinal: (heard) => setText((t) => t.trim() ? `${t.trimEnd()} ${heard}` : heard)
|
|
5266
5633
|
});
|
|
5267
5634
|
const showMic = speech !== false && stt.supported;
|
|
5268
|
-
const [startedAt, setStartedAt] = (0,
|
|
5269
|
-
const [now, setNow] = (0,
|
|
5270
|
-
const [lastElapsed, setLastElapsed] = (0,
|
|
5271
|
-
(0,
|
|
5635
|
+
const [startedAt, setStartedAt] = (0, import_react12.useState)();
|
|
5636
|
+
const [now, setNow] = (0, import_react12.useState)(() => Date.now());
|
|
5637
|
+
const [lastElapsed, setLastElapsed] = (0, import_react12.useState)();
|
|
5638
|
+
(0, import_react12.useEffect)(() => {
|
|
5272
5639
|
if (!busy) {
|
|
5273
5640
|
if (startedAt !== void 0) setLastElapsed(Date.now() - startedAt);
|
|
5274
5641
|
setStartedAt(void 0);
|
|
@@ -5281,7 +5648,7 @@ ${draftText}` : draftText);
|
|
|
5281
5648
|
return () => clearInterval(id);
|
|
5282
5649
|
}, [busy]);
|
|
5283
5650
|
const elapsed = startedAt !== void 0 ? now - startedAt : lastElapsed;
|
|
5284
|
-
const allCommands = (0,
|
|
5651
|
+
const allCommands = (0, import_react12.useMemo)(() => {
|
|
5285
5652
|
const out = [];
|
|
5286
5653
|
if (builtinCommands) {
|
|
5287
5654
|
out.push(
|
|
@@ -5361,8 +5728,8 @@ ${draftText}` : draftText);
|
|
|
5361
5728
|
const commandsStyle = useMenuPlacement(paletteOpen, rootRef, "stretch");
|
|
5362
5729
|
const modelStyle = useMenuPlacement(menu === "model", modelRef, "left");
|
|
5363
5730
|
const modeStyle = useMenuPlacement(menu === "mode", modeRef, "right");
|
|
5364
|
-
(0,
|
|
5365
|
-
(0,
|
|
5731
|
+
(0, import_react12.useEffect)(() => setActive(0), [text2, menu]);
|
|
5732
|
+
(0, import_react12.useEffect)(() => {
|
|
5366
5733
|
if (!menu) return;
|
|
5367
5734
|
const onDown = (e) => {
|
|
5368
5735
|
if (!rootRef.current?.contains(e.target)) setMenu(void 0);
|
|
@@ -5455,9 +5822,9 @@ ${draftText}` : draftText);
|
|
|
5455
5822
|
e.preventDefault();
|
|
5456
5823
|
void addFiles(pasted);
|
|
5457
5824
|
};
|
|
5458
|
-
const addFilesRef = (0,
|
|
5825
|
+
const addFilesRef = (0, import_react12.useRef)(addFiles);
|
|
5459
5826
|
addFilesRef.current = addFiles;
|
|
5460
|
-
(0,
|
|
5827
|
+
(0, import_react12.useEffect)(() => {
|
|
5461
5828
|
if (attachments === false) return;
|
|
5462
5829
|
const target = dropZone === "window" ? globalThis.window : dropZone === "self" ? rootRef.current : dropZone.current;
|
|
5463
5830
|
if (!target) return;
|
|
@@ -5942,7 +6309,7 @@ ${draftText}` : draftText);
|
|
|
5942
6309
|
};
|
|
5943
6310
|
|
|
5944
6311
|
// src/components/ChatHistoryList.tsx
|
|
5945
|
-
var
|
|
6312
|
+
var import_react13 = require("react");
|
|
5946
6313
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
5947
6314
|
var defaultTime = (ms) => {
|
|
5948
6315
|
const d = new Date(ms);
|
|
@@ -6012,7 +6379,7 @@ var ChatHistoryList = ({
|
|
|
6012
6379
|
}
|
|
6013
6380
|
)
|
|
6014
6381
|
] }, c.id);
|
|
6015
|
-
return renderChat ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
6382
|
+
return renderChat ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react13.Fragment, { children: renderChat(c, active, row) }, c.id) : row;
|
|
6016
6383
|
}) })
|
|
6017
6384
|
] });
|
|
6018
6385
|
};
|
|
@@ -6178,7 +6545,7 @@ var ContextMeter = ({
|
|
|
6178
6545
|
};
|
|
6179
6546
|
|
|
6180
6547
|
// src/components/ElicitationPrompt.tsx
|
|
6181
|
-
var
|
|
6548
|
+
var import_react14 = require("react");
|
|
6182
6549
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6183
6550
|
var reasonText = (outcome, L) => {
|
|
6184
6551
|
const reason = outcome.reason;
|
|
@@ -6188,8 +6555,8 @@ var reasonText = (outcome, L) => {
|
|
|
6188
6555
|
return reason || outcome.status;
|
|
6189
6556
|
};
|
|
6190
6557
|
var useNow = (active) => {
|
|
6191
|
-
const [now, setNow] = (0,
|
|
6192
|
-
(0,
|
|
6558
|
+
const [now, setNow] = (0, import_react14.useState)(() => Date.now());
|
|
6559
|
+
(0, import_react14.useEffect)(() => {
|
|
6193
6560
|
if (!active) return;
|
|
6194
6561
|
setNow(Date.now());
|
|
6195
6562
|
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
@@ -6317,11 +6684,11 @@ var FieldControl = ({ field, id, value, issue, onChange, L }) => {
|
|
|
6317
6684
|
] });
|
|
6318
6685
|
};
|
|
6319
6686
|
var FormBody = ({ elicitation, answer, L }) => {
|
|
6320
|
-
const baseId = (0,
|
|
6687
|
+
const baseId = (0, import_react14.useId)();
|
|
6321
6688
|
const schema = elicitation.requestedSchema;
|
|
6322
6689
|
const fields = elicitationFields(schema);
|
|
6323
|
-
const [draft, setDraft] = (0,
|
|
6324
|
-
const [issues, setIssues] = (0,
|
|
6690
|
+
const [draft, setDraft] = (0, import_react14.useState)(() => elicitationInitialDraft(schema));
|
|
6691
|
+
const [issues, setIssues] = (0, import_react14.useState)(void 0);
|
|
6325
6692
|
const fieldId = (i) => `${baseId}-f${i}`;
|
|
6326
6693
|
const submit = (e) => {
|
|
6327
6694
|
e.preventDefault();
|
|
@@ -6376,7 +6743,7 @@ var FormBody = ({ elicitation, answer, L }) => {
|
|
|
6376
6743
|
};
|
|
6377
6744
|
var UrlBody = ({ elicitation, answer, L }) => {
|
|
6378
6745
|
const link = elicitationLink(elicitation.url);
|
|
6379
|
-
const [opened, setOpened] = (0,
|
|
6746
|
+
const [opened, setOpened] = (0, import_react14.useState)(false);
|
|
6380
6747
|
const open = () => {
|
|
6381
6748
|
if (!link.openable || typeof window === "undefined") return;
|
|
6382
6749
|
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
@@ -6440,7 +6807,7 @@ var ElicitationPrompt = ({
|
|
|
6440
6807
|
className
|
|
6441
6808
|
}) => {
|
|
6442
6809
|
const L = useLabels(labels);
|
|
6443
|
-
const [dismissed, setDismissed] = (0,
|
|
6810
|
+
const [dismissed, setDismissed] = (0, import_react14.useState)(() => /* @__PURE__ */ new Set());
|
|
6444
6811
|
const automatic = showOutcomes ? (outcomes ?? []).filter(
|
|
6445
6812
|
(o) => o.automatic === true && o.status !== "pending" && !dismissed.has(o.id)
|
|
6446
6813
|
) : [];
|
|
@@ -6501,8 +6868,256 @@ var ElicitationPrompt = ({
|
|
|
6501
6868
|
};
|
|
6502
6869
|
|
|
6503
6870
|
// src/components/FilesPanel.tsx
|
|
6504
|
-
var
|
|
6871
|
+
var import_react16 = require("react");
|
|
6872
|
+
|
|
6873
|
+
// src/components/ImageViewer.tsx
|
|
6874
|
+
var import_react15 = require("react");
|
|
6875
|
+
var import_react_dom = require("react-dom");
|
|
6505
6876
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
6877
|
+
var fileNameOf = (name) => name.split(/[\\/]/).filter(Boolean).pop() ?? name;
|
|
6878
|
+
var SWIPE_PX = 48;
|
|
6879
|
+
var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
|
|
6880
|
+
const L = useLabels(labels);
|
|
6881
|
+
const rootRef = (0, import_react15.useRef)(null);
|
|
6882
|
+
const closeRef = (0, import_react15.useRef)(null);
|
|
6883
|
+
const imgRef = (0, import_react15.useRef)(null);
|
|
6884
|
+
const touch = (0, import_react15.useRef)(void 0);
|
|
6885
|
+
const [zoom, setZoom] = (0, import_react15.useState)(void 0);
|
|
6886
|
+
const count = images.length;
|
|
6887
|
+
const at = Math.min(Math.max(index, 0), count - 1);
|
|
6888
|
+
const image = images[at];
|
|
6889
|
+
const go = (step) => {
|
|
6890
|
+
if (count < 2) return;
|
|
6891
|
+
setZoom(void 0);
|
|
6892
|
+
onIndex((at + step + count) % count);
|
|
6893
|
+
};
|
|
6894
|
+
(0, import_react15.useEffect)(() => {
|
|
6895
|
+
closeRef.current?.focus();
|
|
6896
|
+
const root = document.documentElement;
|
|
6897
|
+
const before = root.style.overflow;
|
|
6898
|
+
root.style.overflow = "hidden";
|
|
6899
|
+
return () => {
|
|
6900
|
+
root.style.overflow = before;
|
|
6901
|
+
};
|
|
6902
|
+
}, []);
|
|
6903
|
+
const keys = (0, import_react15.useRef)(() => {
|
|
6904
|
+
});
|
|
6905
|
+
keys.current = (e) => {
|
|
6906
|
+
if (e.key === "Escape") {
|
|
6907
|
+
e.preventDefault();
|
|
6908
|
+
e.stopPropagation();
|
|
6909
|
+
onClose();
|
|
6910
|
+
} else if (e.key === "ArrowLeft") go(-1);
|
|
6911
|
+
else if (e.key === "ArrowRight") go(1);
|
|
6912
|
+
else if (e.key === "Tab") {
|
|
6913
|
+
const stops = [
|
|
6914
|
+
...rootRef.current?.querySelectorAll("button, a[href]") ?? []
|
|
6915
|
+
].filter((el) => !el.hasAttribute("disabled"));
|
|
6916
|
+
if (!stops.length) return;
|
|
6917
|
+
const first = stops[0];
|
|
6918
|
+
const last = stops[stops.length - 1];
|
|
6919
|
+
const active = document.activeElement;
|
|
6920
|
+
if (!rootRef.current?.contains(active)) {
|
|
6921
|
+
e.preventDefault();
|
|
6922
|
+
(e.shiftKey ? last : first).focus();
|
|
6923
|
+
} else if (e.shiftKey ? active === first : active === last) {
|
|
6924
|
+
e.preventDefault();
|
|
6925
|
+
(e.shiftKey ? last : first).focus();
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
};
|
|
6929
|
+
(0, import_react15.useEffect)(() => {
|
|
6930
|
+
const onKey = (e) => keys.current(e);
|
|
6931
|
+
document.addEventListener("keydown", onKey, true);
|
|
6932
|
+
return () => document.removeEventListener("keydown", onKey, true);
|
|
6933
|
+
}, []);
|
|
6934
|
+
if (!image) return null;
|
|
6935
|
+
const toggleZoom = () => {
|
|
6936
|
+
const img = imgRef.current;
|
|
6937
|
+
if (zoom !== void 0 || !img) return setZoom(void 0);
|
|
6938
|
+
setZoom(Math.max(img.naturalWidth, Math.round(img.clientWidth * 2)));
|
|
6939
|
+
};
|
|
6940
|
+
const onTouchStart = (e) => {
|
|
6941
|
+
touch.current = e.touches.length === 1 ? { x: e.touches[0].clientX, y: e.touches[0].clientY } : void 0;
|
|
6942
|
+
};
|
|
6943
|
+
const onTouchEnd = (e) => {
|
|
6944
|
+
const from = touch.current;
|
|
6945
|
+
touch.current = void 0;
|
|
6946
|
+
if (!from || zoom !== void 0 || e.changedTouches.length !== 1) return;
|
|
6947
|
+
const dx = e.changedTouches[0].clientX - from.x;
|
|
6948
|
+
const dy = e.changedTouches[0].clientY - from.y;
|
|
6949
|
+
if (Math.abs(dx) > SWIPE_PX && Math.abs(dx) > Math.abs(dy) * 1.5) go(dx < 0 ? 1 : -1);
|
|
6950
|
+
};
|
|
6951
|
+
const name = fileNameOf(image.name);
|
|
6952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref: rootRef, className: "awr-viewer", role: "dialog", "aria-modal": "true", "aria-label": name, children: [
|
|
6953
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "awr-viewer__bar", children: [
|
|
6954
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "awr-viewer__name", title: image.name, children: name }),
|
|
6955
|
+
count > 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "awr-viewer__count", "aria-live": "polite", children: L.imageCount(at + 1, count) }),
|
|
6956
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6957
|
+
"button",
|
|
6958
|
+
{
|
|
6959
|
+
type: "button",
|
|
6960
|
+
className: "awr-iconbtn awr-viewer__zoom",
|
|
6961
|
+
"aria-label": L.imageZoom,
|
|
6962
|
+
title: L.imageZoom,
|
|
6963
|
+
"aria-pressed": zoom !== void 0,
|
|
6964
|
+
onClick: toggleZoom,
|
|
6965
|
+
children: zoom !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ShrinkIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ExpandIcon, { size: 18 })
|
|
6966
|
+
}
|
|
6967
|
+
),
|
|
6968
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6969
|
+
"a",
|
|
6970
|
+
{
|
|
6971
|
+
className: "awr-iconbtn awr-viewer__download",
|
|
6972
|
+
href: image.src,
|
|
6973
|
+
download: name,
|
|
6974
|
+
"aria-label": L.fileDownload(name),
|
|
6975
|
+
title: L.download,
|
|
6976
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DownloadIcon, { size: 18 })
|
|
6977
|
+
}
|
|
6978
|
+
),
|
|
6979
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6980
|
+
"button",
|
|
6981
|
+
{
|
|
6982
|
+
ref: closeRef,
|
|
6983
|
+
type: "button",
|
|
6984
|
+
className: "awr-iconbtn awr-viewer__close",
|
|
6985
|
+
"aria-label": L.close,
|
|
6986
|
+
title: L.close,
|
|
6987
|
+
onClick: onClose,
|
|
6988
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(XIcon, { size: 18 })
|
|
6989
|
+
}
|
|
6990
|
+
)
|
|
6991
|
+
] }),
|
|
6992
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6993
|
+
"div",
|
|
6994
|
+
{
|
|
6995
|
+
className: `awr-viewer__stage${zoom !== void 0 ? " is-zoomed" : ""}`,
|
|
6996
|
+
onClick: (e) => {
|
|
6997
|
+
if (e.target === e.currentTarget) onClose();
|
|
6998
|
+
},
|
|
6999
|
+
onTouchStart,
|
|
7000
|
+
onTouchEnd,
|
|
7001
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7002
|
+
"img",
|
|
7003
|
+
{
|
|
7004
|
+
ref: imgRef,
|
|
7005
|
+
className: "awr-viewer__img",
|
|
7006
|
+
src: image.src,
|
|
7007
|
+
alt: image.alt ?? name,
|
|
7008
|
+
style: zoom !== void 0 ? { width: zoom } : void 0,
|
|
7009
|
+
onClick: toggleZoom,
|
|
7010
|
+
onDoubleClick: (e) => e.preventDefault(),
|
|
7011
|
+
draggable: false
|
|
7012
|
+
},
|
|
7013
|
+
image.src
|
|
7014
|
+
)
|
|
7015
|
+
}
|
|
7016
|
+
),
|
|
7017
|
+
count > 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
7018
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7019
|
+
"button",
|
|
7020
|
+
{
|
|
7021
|
+
type: "button",
|
|
7022
|
+
className: "awr-iconbtn awr-viewer__nav awr-viewer__nav--prev",
|
|
7023
|
+
"aria-label": L.imagePrevious,
|
|
7024
|
+
title: L.imagePrevious,
|
|
7025
|
+
onClick: () => go(-1),
|
|
7026
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": "true", children: "\u2039" })
|
|
7027
|
+
}
|
|
7028
|
+
),
|
|
7029
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7030
|
+
"button",
|
|
7031
|
+
{
|
|
7032
|
+
type: "button",
|
|
7033
|
+
className: "awr-iconbtn awr-viewer__nav awr-viewer__nav--next",
|
|
7034
|
+
"aria-label": L.imageNext,
|
|
7035
|
+
title: L.imageNext,
|
|
7036
|
+
onClick: () => go(1),
|
|
7037
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": "true", children: "\u203A" })
|
|
7038
|
+
}
|
|
7039
|
+
)
|
|
7040
|
+
] })
|
|
7041
|
+
] });
|
|
7042
|
+
};
|
|
7043
|
+
var ImageViewerContext = (0, import_react15.createContext)({ enabled: true });
|
|
7044
|
+
var ImageViewerProvider = ({
|
|
7045
|
+
enabled = true,
|
|
7046
|
+
render,
|
|
7047
|
+
children
|
|
7048
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageViewerContext.Provider, { value: { enabled, render }, children });
|
|
7049
|
+
var imageExtensionOf = (src) => {
|
|
7050
|
+
const type = /^data:image\/([a-z0-9.+-]+)/i.exec(src)?.[1]?.toLowerCase();
|
|
7051
|
+
return !type ? "" : type === "jpeg" ? ".jpg" : type === "svg+xml" ? ".svg" : `.${type}`;
|
|
7052
|
+
};
|
|
7053
|
+
var groupOf = (button) => {
|
|
7054
|
+
const scope = button.closest(".awr-msg") ?? button.parentElement ?? button;
|
|
7055
|
+
const buttons = [...scope.querySelectorAll("[data-awr-image]")];
|
|
7056
|
+
const images = buttons.flatMap((b) => {
|
|
7057
|
+
const img = b.querySelector("img");
|
|
7058
|
+
return img ? [{ src: img.currentSrc || img.src, name: b.dataset.awrImage || img.alt, alt: img.alt }] : [];
|
|
7059
|
+
});
|
|
7060
|
+
return { images, index: Math.max(0, buttons.indexOf(button)) };
|
|
7061
|
+
};
|
|
7062
|
+
var ImageThumb = ({
|
|
7063
|
+
src,
|
|
7064
|
+
name,
|
|
7065
|
+
alt,
|
|
7066
|
+
className,
|
|
7067
|
+
imgClassName,
|
|
7068
|
+
title,
|
|
7069
|
+
labels
|
|
7070
|
+
}) => {
|
|
7071
|
+
const L = useLabels(labels);
|
|
7072
|
+
const { enabled, render } = (0, import_react15.useContext)(ImageViewerContext);
|
|
7073
|
+
const ref = (0, import_react15.useRef)(null);
|
|
7074
|
+
const [open, setOpen] = (0, import_react15.useState)(void 0);
|
|
7075
|
+
const img = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("img", { className: imgClassName, src, alt });
|
|
7076
|
+
if (!enabled) {
|
|
7077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { className, href: src, target: "_blank", rel: "noopener noreferrer", title, children: img });
|
|
7078
|
+
}
|
|
7079
|
+
const close = () => {
|
|
7080
|
+
setOpen(void 0);
|
|
7081
|
+
ref.current?.focus();
|
|
7082
|
+
};
|
|
7083
|
+
const viewer = (o) => ({
|
|
7084
|
+
images: o.images,
|
|
7085
|
+
index: o.index,
|
|
7086
|
+
onIndex: (index) => setOpen({ ...o, index }),
|
|
7087
|
+
onClose: close,
|
|
7088
|
+
labels
|
|
7089
|
+
});
|
|
7090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
7091
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7092
|
+
"button",
|
|
7093
|
+
{
|
|
7094
|
+
ref,
|
|
7095
|
+
type: "button",
|
|
7096
|
+
className: ["awr-imgbtn", className].filter(Boolean).join(" "),
|
|
7097
|
+
"data-awr-image": name,
|
|
7098
|
+
"aria-label": L.imageOpen(fileNameOf(name)),
|
|
7099
|
+
"aria-haspopup": "dialog",
|
|
7100
|
+
title,
|
|
7101
|
+
onClick: (e) => {
|
|
7102
|
+
const button = e.currentTarget;
|
|
7103
|
+
setOpen({
|
|
7104
|
+
...groupOf(button),
|
|
7105
|
+
// Inside the chat's element, so its theme applies; it covers the window from there.
|
|
7106
|
+
host: button.closest(".awr-chat, .awr-theme") ?? document.body
|
|
7107
|
+
});
|
|
7108
|
+
},
|
|
7109
|
+
children: img
|
|
7110
|
+
}
|
|
7111
|
+
),
|
|
7112
|
+
open && (0, import_react_dom.createPortal)(
|
|
7113
|
+
render ? render(viewer(open), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageViewer, { ...viewer(open) })) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageViewer, { ...viewer(open) }),
|
|
7114
|
+
open.host
|
|
7115
|
+
)
|
|
7116
|
+
] });
|
|
7117
|
+
};
|
|
7118
|
+
|
|
7119
|
+
// src/components/FilesPanel.tsx
|
|
7120
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
6506
7121
|
var PREVIEW_CHARS = 2e4;
|
|
6507
7122
|
var FilesPanel = ({
|
|
6508
7123
|
files: vfs,
|
|
@@ -6518,9 +7133,9 @@ var FilesPanel = ({
|
|
|
6518
7133
|
}) => {
|
|
6519
7134
|
const L = useLabels(labels);
|
|
6520
7135
|
const fs = useVirtualFiles(vfs, prefix);
|
|
6521
|
-
const [preview, setPreview] = (0,
|
|
6522
|
-
const inputRef = (0,
|
|
6523
|
-
(0,
|
|
7136
|
+
const [preview, setPreview] = (0, import_react16.useState)();
|
|
7137
|
+
const inputRef = (0, import_react16.useRef)(null);
|
|
7138
|
+
(0, import_react16.useEffect)(() => {
|
|
6524
7139
|
if (preview && !fs.files.some((f) => f.path === preview.path)) setPreview(void 0);
|
|
6525
7140
|
}, [fs.files, preview]);
|
|
6526
7141
|
const open = async (f) => {
|
|
@@ -6543,11 +7158,11 @@ var FilesPanel = ({
|
|
|
6543
7158
|
a.download = f.path.split("/").pop() || "file";
|
|
6544
7159
|
a.click();
|
|
6545
7160
|
};
|
|
6546
|
-
return /* @__PURE__ */ (0,
|
|
6547
|
-
/* @__PURE__ */ (0,
|
|
6548
|
-
/* @__PURE__ */ (0,
|
|
6549
|
-
allowUpload && /* @__PURE__ */ (0,
|
|
6550
|
-
/* @__PURE__ */ (0,
|
|
7161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: ["awr-filespanel", className].filter(Boolean).join(" "), children: [
|
|
7162
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "awr-panel__head", children: [
|
|
7163
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "awr-panel__title", children: title ?? L.files }),
|
|
7164
|
+
allowUpload && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
7165
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6551
7166
|
"button",
|
|
6552
7167
|
{
|
|
6553
7168
|
type: "button",
|
|
@@ -6555,10 +7170,10 @@ var FilesPanel = ({
|
|
|
6555
7170
|
"aria-label": L.upload,
|
|
6556
7171
|
title: L.upload,
|
|
6557
7172
|
onClick: () => inputRef.current?.click(),
|
|
6558
|
-
children: /* @__PURE__ */ (0,
|
|
7173
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PlusIcon, { size: 16 })
|
|
6559
7174
|
}
|
|
6560
7175
|
),
|
|
6561
|
-
/* @__PURE__ */ (0,
|
|
7176
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6562
7177
|
"input",
|
|
6563
7178
|
{
|
|
6564
7179
|
ref: inputRef,
|
|
@@ -6573,15 +7188,15 @@ var FilesPanel = ({
|
|
|
6573
7188
|
)
|
|
6574
7189
|
] })
|
|
6575
7190
|
] }),
|
|
6576
|
-
fs.error && /* @__PURE__ */ (0,
|
|
6577
|
-
!fs.loading && fs.files.length === 0 && /* @__PURE__ */ (0,
|
|
6578
|
-
/* @__PURE__ */ (0,
|
|
6579
|
-
const row = /* @__PURE__ */ (0,
|
|
7191
|
+
fs.error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "awr-notice awr-notice--warn", children: fs.error }),
|
|
7192
|
+
!fs.loading && fs.files.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "awr-panel__empty", children: L.filesEmpty }),
|
|
7193
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { className: "awr-filelist", children: fs.files.map((f) => {
|
|
7194
|
+
const row = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
6580
7195
|
"li",
|
|
6581
7196
|
{
|
|
6582
7197
|
className: `awr-filelist__item${preview?.path === f.path ? " is-active" : ""}`,
|
|
6583
7198
|
children: [
|
|
6584
|
-
/* @__PURE__ */ (0,
|
|
7199
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
6585
7200
|
"button",
|
|
6586
7201
|
{
|
|
6587
7202
|
type: "button",
|
|
@@ -6589,13 +7204,13 @@ var FilesPanel = ({
|
|
|
6589
7204
|
onClick: () => void open(f),
|
|
6590
7205
|
title: `${L.preview}: ${f.path}`,
|
|
6591
7206
|
children: [
|
|
6592
|
-
/* @__PURE__ */ (0,
|
|
6593
|
-
/* @__PURE__ */ (0,
|
|
6594
|
-
/* @__PURE__ */ (0,
|
|
7207
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FileIcon, { size: 14 }),
|
|
7208
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "awr-filelist__path", children: f.path }),
|
|
7209
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "awr-filelist__size", children: L.bytes(f.size) })
|
|
6595
7210
|
]
|
|
6596
7211
|
}
|
|
6597
7212
|
),
|
|
6598
|
-
/* @__PURE__ */ (0,
|
|
7213
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6599
7214
|
"button",
|
|
6600
7215
|
{
|
|
6601
7216
|
type: "button",
|
|
@@ -6603,10 +7218,10 @@ var FilesPanel = ({
|
|
|
6603
7218
|
"aria-label": `${L.download} ${f.path}`,
|
|
6604
7219
|
title: L.download,
|
|
6605
7220
|
onClick: () => void download(f),
|
|
6606
|
-
children: /* @__PURE__ */ (0,
|
|
7221
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DownloadIcon, { size: 14 })
|
|
6607
7222
|
}
|
|
6608
7223
|
),
|
|
6609
|
-
allowDelete && /* @__PURE__ */ (0,
|
|
7224
|
+
allowDelete && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6610
7225
|
"button",
|
|
6611
7226
|
{
|
|
6612
7227
|
type: "button",
|
|
@@ -6614,22 +7229,34 @@ var FilesPanel = ({
|
|
|
6614
7229
|
"aria-label": `${L.delete} ${f.path}`,
|
|
6615
7230
|
title: L.delete,
|
|
6616
7231
|
onClick: () => void fs.remove(f.path),
|
|
6617
|
-
children: /* @__PURE__ */ (0,
|
|
7232
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(XIcon, { size: 14 })
|
|
6618
7233
|
}
|
|
6619
7234
|
)
|
|
6620
7235
|
]
|
|
6621
7236
|
},
|
|
6622
7237
|
f.path
|
|
6623
7238
|
);
|
|
6624
|
-
return renderFile ? /* @__PURE__ */ (0,
|
|
7239
|
+
return renderFile ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react16.Fragment, { children: renderFile(f, row) }, f.path) : row;
|
|
6625
7240
|
}) }),
|
|
6626
|
-
preview && /* @__PURE__ */ (0,
|
|
7241
|
+
preview && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "awr-filepreview", children: preview.kind === "image" ? (
|
|
7242
|
+
// A click (Enter, Space) opens it over the chat, fitted to the screen.
|
|
7243
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7244
|
+
ImageThumb,
|
|
7245
|
+
{
|
|
7246
|
+
src: preview.src,
|
|
7247
|
+
name: preview.path,
|
|
7248
|
+
alt: preview.path,
|
|
7249
|
+
title: preview.path,
|
|
7250
|
+
labels
|
|
7251
|
+
}
|
|
7252
|
+
)
|
|
7253
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pre", { children: preview.text.length > PREVIEW_CHARS ? `${preview.text.slice(0, PREVIEW_CHARS)}
|
|
6627
7254
|
\u2026` : preview.text }) })
|
|
6628
7255
|
] });
|
|
6629
7256
|
};
|
|
6630
7257
|
|
|
6631
7258
|
// src/components/FileChips.tsx
|
|
6632
|
-
var
|
|
7259
|
+
var import_react18 = require("react");
|
|
6633
7260
|
|
|
6634
7261
|
// src/file-kinds.ts
|
|
6635
7262
|
var import_agent_web6 = require("@dudko.dev/agent-web");
|
|
@@ -6647,12 +7274,12 @@ var fileKindOf = (path, mediaType) => {
|
|
|
6647
7274
|
if (mime === "text/plain" || /\.(?:txt|log)$/i.test(path) || (0, import_agent_web6.isTextMime)(mime)) return "text";
|
|
6648
7275
|
return "file";
|
|
6649
7276
|
};
|
|
6650
|
-
var
|
|
7277
|
+
var fileNameOf2 = (path) => path.split("/").filter(Boolean).pop() || "file";
|
|
6651
7278
|
|
|
6652
7279
|
// src/components/Media.tsx
|
|
6653
|
-
var
|
|
7280
|
+
var import_react17 = require("react");
|
|
6654
7281
|
var import_agent_web7 = require("@dudko.dev/agent-web");
|
|
6655
|
-
var
|
|
7282
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
6656
7283
|
var mediaFamilyOf = (mediaType) => {
|
|
6657
7284
|
const type = mediaType.toLowerCase().split(";")[0].trim();
|
|
6658
7285
|
if (Object.hasOwn(import_agent_web7.MEDIA_IMAGE_TYPES, type)) return "image";
|
|
@@ -6667,8 +7294,8 @@ var bytesOf = (content, encoding) => {
|
|
|
6667
7294
|
return bytes;
|
|
6668
7295
|
};
|
|
6669
7296
|
var useFileUrl = (files, path, mediaType) => {
|
|
6670
|
-
const [url, setUrl] = (0,
|
|
6671
|
-
(0,
|
|
7297
|
+
const [url, setUrl] = (0, import_react17.useState)(void 0);
|
|
7298
|
+
(0, import_react17.useEffect)(() => {
|
|
6672
7299
|
if (!files || !mediaType) return;
|
|
6673
7300
|
let made;
|
|
6674
7301
|
let gone = false;
|
|
@@ -6694,20 +7321,21 @@ var GeneratedMedia = ({ media, files, labels }) => {
|
|
|
6694
7321
|
const type = family ? media.mediaType.toLowerCase().split(";")[0].trim() : void 0;
|
|
6695
7322
|
const url = useFileUrl(files, media.path, type);
|
|
6696
7323
|
if (url && family === "image") {
|
|
6697
|
-
return /* @__PURE__ */ (0,
|
|
6698
|
-
|
|
7324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
7325
|
+
ImageThumb,
|
|
6699
7326
|
{
|
|
6700
7327
|
className: "awr-media awr-media--image",
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
7328
|
+
imgClassName: "awr-media__img",
|
|
7329
|
+
src: url,
|
|
7330
|
+
name: media.path,
|
|
7331
|
+
alt: L.mediaImage(media.path),
|
|
6704
7332
|
title: media.path,
|
|
6705
|
-
|
|
7333
|
+
labels
|
|
6706
7334
|
}
|
|
6707
7335
|
);
|
|
6708
7336
|
}
|
|
6709
7337
|
if (url && family === "audio") {
|
|
6710
|
-
return /* @__PURE__ */ (0,
|
|
7338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "awr-media awr-media--audio", title: media.path, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6711
7339
|
"audio",
|
|
6712
7340
|
{
|
|
6713
7341
|
className: "awr-media__audio",
|
|
@@ -6718,27 +7346,27 @@ var GeneratedMedia = ({ media, files, labels }) => {
|
|
|
6718
7346
|
}
|
|
6719
7347
|
) });
|
|
6720
7348
|
}
|
|
6721
|
-
return /* @__PURE__ */ (0,
|
|
6722
|
-
/* @__PURE__ */ (0,
|
|
7349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "awr-chip awr-file awr-media awr-media--file", title: L.mediaFile(media.path), children: [
|
|
7350
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FileIcon, { size: 13 }),
|
|
6723
7351
|
" ",
|
|
6724
7352
|
media.path
|
|
6725
7353
|
] });
|
|
6726
7354
|
};
|
|
6727
7355
|
var TranscriptBlock = ({ transcript, labels }) => {
|
|
6728
7356
|
const L = useLabels(labels);
|
|
6729
|
-
return /* @__PURE__ */ (0,
|
|
6730
|
-
/* @__PURE__ */ (0,
|
|
6731
|
-
/* @__PURE__ */ (0,
|
|
7357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("details", { className: "awr-transcript", children: [
|
|
7358
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("summary", { className: "awr-transcript__summary", children: [
|
|
7359
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FileIcon, { size: 13 }),
|
|
6732
7360
|
" ",
|
|
6733
7361
|
L.transcriptOf(transcript.name)
|
|
6734
7362
|
] }),
|
|
6735
|
-
/* @__PURE__ */ (0,
|
|
6736
|
-
/* @__PURE__ */ (0,
|
|
7363
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "awr-transcript__note", children: L.transcriptNote }),
|
|
7364
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("blockquote", { className: "awr-transcript__text", children: transcript.text })
|
|
6737
7365
|
] });
|
|
6738
7366
|
};
|
|
6739
7367
|
|
|
6740
7368
|
// src/components/SandboxedFrame.tsx
|
|
6741
|
-
var
|
|
7369
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
6742
7370
|
var FRAME_MIN_HEIGHT = 120;
|
|
6743
7371
|
var FRAME_MAX_HEIGHT = 800;
|
|
6744
7372
|
var clampFrameHeight = (height) => Math.min(
|
|
@@ -6755,12 +7383,12 @@ var SandboxedFrame = ({
|
|
|
6755
7383
|
height = 300,
|
|
6756
7384
|
children,
|
|
6757
7385
|
className
|
|
6758
|
-
}) => /* @__PURE__ */ (0,
|
|
6759
|
-
/* @__PURE__ */ (0,
|
|
6760
|
-
/* @__PURE__ */ (0,
|
|
7386
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: ["awr-frame", className].filter(Boolean).join(" "), children: [
|
|
7387
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "awr-frame__head", children: [
|
|
7388
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "awr-frame__label", children: label }),
|
|
6761
7389
|
actions
|
|
6762
7390
|
] }),
|
|
6763
|
-
html !== void 0 && children === void 0 ? /* @__PURE__ */ (0,
|
|
7391
|
+
html !== void 0 && children === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "awr-frame__well", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6764
7392
|
"iframe",
|
|
6765
7393
|
{
|
|
6766
7394
|
className: "awr-frame__iframe",
|
|
@@ -6772,11 +7400,11 @@ var SandboxedFrame = ({
|
|
|
6772
7400
|
},
|
|
6773
7401
|
scripts ? "scripts" : "static"
|
|
6774
7402
|
) }) : children,
|
|
6775
|
-
footer ? /* @__PURE__ */ (0,
|
|
7403
|
+
footer ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "awr-frame__foot", children: footer }) : null
|
|
6776
7404
|
] });
|
|
6777
7405
|
|
|
6778
7406
|
// src/components/FileChips.tsx
|
|
6779
|
-
var
|
|
7407
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
6780
7408
|
var FILE_PREVIEW_CHARS = 2e4;
|
|
6781
7409
|
var textOf = (file) => file.encoding === "base64" ? new TextDecoder().decode(bytesOf(file.content, "base64")) : file.content;
|
|
6782
7410
|
var KIND_ICON = {
|
|
@@ -6797,11 +7425,11 @@ var downloadFile = async (vfs, path) => {
|
|
|
6797
7425
|
);
|
|
6798
7426
|
const a = document.createElement("a");
|
|
6799
7427
|
a.href = url;
|
|
6800
|
-
a.download =
|
|
7428
|
+
a.download = fileNameOf2(path);
|
|
6801
7429
|
a.click();
|
|
6802
7430
|
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
6803
7431
|
};
|
|
6804
|
-
var Seg = ({ value, options, onChange, label }) => /* @__PURE__ */ (0,
|
|
7432
|
+
var Seg = ({ value, options, onChange, label }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "awr-seg", role: "group", "aria-label": label, children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
6805
7433
|
"button",
|
|
6806
7434
|
{
|
|
6807
7435
|
type: "button",
|
|
@@ -6836,32 +7464,32 @@ var SourceView = ({
|
|
|
6836
7464
|
const L = useLabels(labels);
|
|
6837
7465
|
const cut = text2.length > maxChars;
|
|
6838
7466
|
const shown = cut ? text2.slice(0, maxChars) : text2;
|
|
6839
|
-
const lines = (0,
|
|
7467
|
+
const lines = (0, import_react18.useMemo)(
|
|
6840
7468
|
() => linesOf(html ? tokenizeHtml(shown) : [{ kind: "text", text: shown }]),
|
|
6841
7469
|
[shown, html]
|
|
6842
7470
|
);
|
|
6843
|
-
return /* @__PURE__ */ (0,
|
|
6844
|
-
/* @__PURE__ */ (0,
|
|
7471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7472
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pre", { className: ["awr-source", className].filter(Boolean).join(" "), tabIndex: 0, children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-source__line", children: [
|
|
6845
7473
|
line.map(
|
|
6846
|
-
(t, k) => t.kind === "text" ? /* @__PURE__ */ (0,
|
|
7474
|
+
(t, k) => t.kind === "text" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react18.Fragment, { children: t.text }, k) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `awr-source__${t.kind}`, children: t.text }, k)
|
|
6847
7475
|
),
|
|
6848
7476
|
"\n"
|
|
6849
7477
|
] }, i)) }),
|
|
6850
|
-
cut && /* @__PURE__ */ (0,
|
|
7478
|
+
cut && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "awr-fileview__cut", children: L.fileCut(maxChars) })
|
|
6851
7479
|
] });
|
|
6852
7480
|
};
|
|
6853
7481
|
var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
|
|
6854
|
-
const html = (0,
|
|
7482
|
+
const html = (0, import_react18.useMemo)(() => textOf(file), [file]);
|
|
6855
7483
|
const options = htmlPreview === false ? void 0 : htmlPreview;
|
|
6856
7484
|
const tooLarge = html.length > HTML_PREVIEW_MAX_CHARS;
|
|
6857
7485
|
const canFrame = Boolean(options) && !tooLarge;
|
|
6858
|
-
const [view, setView] = (0,
|
|
6859
|
-
const [tall, setTall] = (0,
|
|
7486
|
+
const [view, setView] = (0, import_react18.useState)(canFrame ? "preview" : "source");
|
|
7487
|
+
const [tall, setTall] = (0, import_react18.useState)(false);
|
|
6860
7488
|
const showing = canFrame ? view : "source";
|
|
6861
7489
|
const scripts = options?.scripts === true;
|
|
6862
7490
|
const height = options?.height ?? 300;
|
|
6863
|
-
const linked = (0,
|
|
6864
|
-
return /* @__PURE__ */ (0,
|
|
7491
|
+
const linked = (0, import_react18.useMemo)(() => showing === "preview" ? linkedFilesOf(html) : [], [html, showing]);
|
|
7492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
6865
7493
|
SandboxedFrame,
|
|
6866
7494
|
{
|
|
6867
7495
|
className: "awr-frame--html",
|
|
@@ -6869,35 +7497,35 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
|
|
|
6869
7497
|
html: showing === "preview" ? html : void 0,
|
|
6870
7498
|
scripts,
|
|
6871
7499
|
height: tall ? height * 2 : height,
|
|
6872
|
-
label: /* @__PURE__ */ (0,
|
|
6873
|
-
/* @__PURE__ */ (0,
|
|
6874
|
-
/* @__PURE__ */ (0,
|
|
6875
|
-
/* @__PURE__ */ (0,
|
|
6876
|
-
/* @__PURE__ */ (0,
|
|
6877
|
-
/* @__PURE__ */ (0,
|
|
7500
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7501
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CodeIcon, { size: 14, className: "awr-frame__icon" }),
|
|
7502
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-frame__titles", children: [
|
|
7503
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-frame__title", children: L.htmlFrameTitle }),
|
|
7504
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-frame__badges", children: showing === "preview" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7505
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LockIcon, { size: 11 }),
|
|
6878
7506
|
" ",
|
|
6879
7507
|
L.htmlSandboxed,
|
|
6880
7508
|
" \xB7 ",
|
|
6881
|
-
/* @__PURE__ */ (0,
|
|
7509
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(NoNetworkIcon, { size: 11 }),
|
|
6882
7510
|
" ",
|
|
6883
7511
|
L.htmlNoNetwork
|
|
6884
7512
|
] }) : L.htmlSourceNote })
|
|
6885
7513
|
] })
|
|
6886
7514
|
] }),
|
|
6887
|
-
actions: canFrame ? /* @__PURE__ */ (0,
|
|
6888
|
-
/* @__PURE__ */ (0,
|
|
7515
|
+
actions: canFrame ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7516
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
6889
7517
|
Seg,
|
|
6890
7518
|
{
|
|
6891
7519
|
label: L.htmlFrameTitle,
|
|
6892
7520
|
value: showing,
|
|
6893
7521
|
onChange: setView,
|
|
6894
7522
|
options: [
|
|
6895
|
-
{ value: "preview", label: L.preview, icon: /* @__PURE__ */ (0,
|
|
6896
|
-
{ value: "source", label: L.fileSource, icon: /* @__PURE__ */ (0,
|
|
7523
|
+
{ value: "preview", label: L.preview, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EyeIcon, { size: 13 }) },
|
|
7524
|
+
{ value: "source", label: L.fileSource, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CodeIcon, { size: 13 }) }
|
|
6897
7525
|
]
|
|
6898
7526
|
}
|
|
6899
7527
|
),
|
|
6900
|
-
/* @__PURE__ */ (0,
|
|
7528
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
6901
7529
|
"button",
|
|
6902
7530
|
{
|
|
6903
7531
|
type: "button",
|
|
@@ -6907,14 +7535,14 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
|
|
|
6907
7535
|
"aria-pressed": tall,
|
|
6908
7536
|
disabled: showing !== "preview",
|
|
6909
7537
|
onClick: () => setTall((t) => !t),
|
|
6910
|
-
children: /* @__PURE__ */ (0,
|
|
7538
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ExpandIcon, { size: 15 })
|
|
6911
7539
|
}
|
|
6912
7540
|
)
|
|
6913
7541
|
] }) : void 0,
|
|
6914
|
-
footer: /* @__PURE__ */ (0,
|
|
6915
|
-
/* @__PURE__ */ (0,
|
|
6916
|
-
/* @__PURE__ */ (0,
|
|
6917
|
-
/* @__PURE__ */ (0,
|
|
7542
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7543
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FileIcon, { size: 11 }),
|
|
7544
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: written.path }),
|
|
7545
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-frame__footmeta", children: [
|
|
6918
7546
|
"\xB7 ",
|
|
6919
7547
|
L.bytes(file.size),
|
|
6920
7548
|
" \xB7",
|
|
@@ -6923,18 +7551,18 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
|
|
|
6923
7551
|
linked.length > 0 ? ` \xB7 ${L.htmlLinkedFiles(linked.join(", "))}` : ""
|
|
6924
7552
|
] })
|
|
6925
7553
|
] }),
|
|
6926
|
-
children: showing === "source" ? /* @__PURE__ */ (0,
|
|
6927
|
-
tooLarge && options ? /* @__PURE__ */ (0,
|
|
6928
|
-
/* @__PURE__ */ (0,
|
|
7554
|
+
children: showing === "source" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7555
|
+
tooLarge && options ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "awr-fileview__cut", children: L.htmlTooLarge }) : null,
|
|
7556
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SourceView, { text: html, html: true, maxChars: previewChars, className: "awr-frame__source" })
|
|
6929
7557
|
] }) : void 0
|
|
6930
7558
|
}
|
|
6931
7559
|
);
|
|
6932
7560
|
};
|
|
6933
7561
|
var ImagePreview = ({ written, vfs, onClose, L }) => {
|
|
6934
7562
|
const url = useFileUrl(vfs, written.path, written.mediaType.toLowerCase().split(";")[0].trim());
|
|
6935
|
-
return /* @__PURE__ */ (0,
|
|
6936
|
-
/* @__PURE__ */ (0,
|
|
6937
|
-
/* @__PURE__ */ (0,
|
|
7563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-fileview", children: [
|
|
7564
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FileViewHead, { written, kind: "image", onClose, L }),
|
|
7565
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "awr-fileview__image", children: url ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: url, alt: fileNameOf2(written.path) }) : null })
|
|
6938
7566
|
] });
|
|
6939
7567
|
};
|
|
6940
7568
|
var FileViewHead = ({
|
|
@@ -6943,15 +7571,15 @@ var FileViewHead = ({
|
|
|
6943
7571
|
onClose,
|
|
6944
7572
|
L,
|
|
6945
7573
|
children
|
|
6946
|
-
}) => /* @__PURE__ */ (0,
|
|
6947
|
-
/* @__PURE__ */ (0,
|
|
6948
|
-
/* @__PURE__ */ (0,
|
|
7574
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-fileview__head", children: [
|
|
7575
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-fileview__name", title: written.path, children: fileNameOf2(written.path) }),
|
|
7576
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-fileview__kind", children: [
|
|
6949
7577
|
"\xB7 ",
|
|
6950
7578
|
L.fileKinds[kind]
|
|
6951
7579
|
] }),
|
|
6952
|
-
/* @__PURE__ */ (0,
|
|
7580
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-fileview__actions", children: [
|
|
6953
7581
|
children,
|
|
6954
|
-
/* @__PURE__ */ (0,
|
|
7582
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
6955
7583
|
"button",
|
|
6956
7584
|
{
|
|
6957
7585
|
type: "button",
|
|
@@ -6959,7 +7587,7 @@ var FileViewHead = ({
|
|
|
6959
7587
|
"aria-label": L.closePreview,
|
|
6960
7588
|
title: L.closePreview,
|
|
6961
7589
|
onClick: onClose,
|
|
6962
|
-
children: /* @__PURE__ */ (0,
|
|
7590
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(XIcon, { size: 14 })
|
|
6963
7591
|
}
|
|
6964
7592
|
)
|
|
6965
7593
|
] })
|
|
@@ -6973,21 +7601,21 @@ var TextPreview = ({
|
|
|
6973
7601
|
onClose,
|
|
6974
7602
|
L
|
|
6975
7603
|
}) => {
|
|
6976
|
-
const text2 = (0,
|
|
6977
|
-
const rendered = (0,
|
|
7604
|
+
const text2 = (0, import_react18.useMemo)(() => textOf(file), [file]);
|
|
7605
|
+
const rendered = (0, import_react18.useMemo)(
|
|
6978
7606
|
() => renderFileContent?.(written, text2.slice(0, previewChars)),
|
|
6979
7607
|
[renderFileContent, written, text2, previewChars]
|
|
6980
7608
|
);
|
|
6981
7609
|
const hasRendered = rendered !== void 0 && rendered !== null && rendered !== false;
|
|
6982
|
-
const [view, setView] = (0,
|
|
6983
|
-
const [all, setAll] = (0,
|
|
7610
|
+
const [view, setView] = (0, import_react18.useState)("rendered");
|
|
7611
|
+
const [all, setAll] = (0, import_react18.useState)(false);
|
|
6984
7612
|
const showing = hasRendered ? view : "source";
|
|
6985
7613
|
const long = text2.length > 1200 || text2.split("\n").length > 16;
|
|
6986
|
-
return /* @__PURE__ */ (0,
|
|
6987
|
-
/* @__PURE__ */ (0,
|
|
7614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-fileview", children: [
|
|
7615
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FileViewHead, { written, kind, onClose, L, children: hasRendered && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
6988
7616
|
Seg,
|
|
6989
7617
|
{
|
|
6990
|
-
label:
|
|
7618
|
+
label: fileNameOf2(written.path),
|
|
6991
7619
|
value: showing,
|
|
6992
7620
|
onChange: setView,
|
|
6993
7621
|
options: [
|
|
@@ -6996,16 +7624,16 @@ var TextPreview = ({
|
|
|
6996
7624
|
]
|
|
6997
7625
|
}
|
|
6998
7626
|
) }),
|
|
6999
|
-
/* @__PURE__ */ (0,
|
|
7000
|
-
/* @__PURE__ */ (0,
|
|
7001
|
-
text2.length > previewChars && /* @__PURE__ */ (0,
|
|
7002
|
-
] }) : /* @__PURE__ */ (0,
|
|
7003
|
-
long && /* @__PURE__ */ (0,
|
|
7627
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: `awr-fileview__body${long && !all ? " is-folded" : ""}`, children: showing === "rendered" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
7628
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "awr-fileview__rendered", children: rendered }),
|
|
7629
|
+
text2.length > previewChars && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "awr-fileview__cut", children: L.fileCut(previewChars) })
|
|
7630
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SourceView, { text: text2, maxChars: previewChars }) }),
|
|
7631
|
+
long && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "awr-fileview__more", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: "awr-linkbtn", onClick: () => setAll((a) => !a), children: all ? L.fileShowLess : L.fileShowRest }) })
|
|
7004
7632
|
] });
|
|
7005
7633
|
};
|
|
7006
|
-
var NoPreview = ({ written, kind, onClose, L }) => /* @__PURE__ */ (0,
|
|
7007
|
-
/* @__PURE__ */ (0,
|
|
7008
|
-
/* @__PURE__ */ (0,
|
|
7634
|
+
var NoPreview = ({ written, kind, onClose, L }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-fileview", children: [
|
|
7635
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FileViewHead, { written, kind, onClose, L }),
|
|
7636
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "awr-fileview__none", children: L.fileNoPreview })
|
|
7009
7637
|
] });
|
|
7010
7638
|
var FileChips = ({
|
|
7011
7639
|
written,
|
|
@@ -7022,11 +7650,11 @@ var FileChips = ({
|
|
|
7022
7650
|
}) => {
|
|
7023
7651
|
const L = useLabels(labels);
|
|
7024
7652
|
const live = useVirtualFiles(vfs);
|
|
7025
|
-
const [openPath, setOpenPath] = (0,
|
|
7026
|
-
const [file, setFile] = (0,
|
|
7653
|
+
const [openPath, setOpenPath] = (0, import_react18.useState)(defaultOpen);
|
|
7654
|
+
const [file, setFile] = (0, import_react18.useState)();
|
|
7027
7655
|
const open = written.find((f) => f.path === openPath);
|
|
7028
7656
|
const stamp = live.files.find((f) => f.path === openPath)?.updatedAt;
|
|
7029
|
-
(0,
|
|
7657
|
+
(0, import_react18.useEffect)(() => {
|
|
7030
7658
|
if (!vfs || !openPath) return setFile(void 0);
|
|
7031
7659
|
let gone = false;
|
|
7032
7660
|
vfs.read(openPath).then((f) => {
|
|
@@ -7053,23 +7681,23 @@ var FileChips = ({
|
|
|
7053
7681
|
onClose: () => setOpenPath(void 0),
|
|
7054
7682
|
L
|
|
7055
7683
|
};
|
|
7056
|
-
if (kind === "html") return /* @__PURE__ */ (0,
|
|
7057
|
-
if (kind === "image") return /* @__PURE__ */ (0,
|
|
7058
|
-
if (kind === "file") return /* @__PURE__ */ (0,
|
|
7059
|
-
return /* @__PURE__ */ (0,
|
|
7684
|
+
if (kind === "html") return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HtmlPreview, { ...props }, open.path);
|
|
7685
|
+
if (kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ImagePreview, { ...props }, open.path);
|
|
7686
|
+
if (kind === "file") return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(NoPreview, { ...props }, open.path);
|
|
7687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TextPreview, { ...props }, open.path);
|
|
7060
7688
|
};
|
|
7061
|
-
return /* @__PURE__ */ (0,
|
|
7062
|
-
showHeader && /* @__PURE__ */ (0,
|
|
7063
|
-
/* @__PURE__ */ (0,
|
|
7064
|
-
/* @__PURE__ */ (0,
|
|
7065
|
-
onShowFiles && /* @__PURE__ */ (0,
|
|
7689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: ["awr-msg__files", className].filter(Boolean).join(" "), children: [
|
|
7690
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-msg__fileshead", children: [
|
|
7691
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FileIcon, { size: 13 }),
|
|
7692
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: L.filesWritten(written.length) }),
|
|
7693
|
+
onShowFiles && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: "awr-linkbtn", onClick: onShowFiles, children: L.showInFiles })
|
|
7066
7694
|
] }),
|
|
7067
|
-
/* @__PURE__ */ (0,
|
|
7695
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { className: "awr-filechips", children: written.map((w) => {
|
|
7068
7696
|
const info = live.files.find((f) => f.path === w.path);
|
|
7069
7697
|
const gone = Boolean(vfs) && !live.loading && !info;
|
|
7070
7698
|
const usable = Boolean(vfs) && !gone;
|
|
7071
7699
|
const isOpen = openPath === w.path && usable;
|
|
7072
|
-
const chip = /* @__PURE__ */ (0,
|
|
7700
|
+
const chip = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7073
7701
|
FileChip,
|
|
7074
7702
|
{
|
|
7075
7703
|
written: w,
|
|
@@ -7082,7 +7710,7 @@ var FileChips = ({
|
|
|
7082
7710
|
labels
|
|
7083
7711
|
}
|
|
7084
7712
|
);
|
|
7085
|
-
return /* @__PURE__ */ (0,
|
|
7713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("li", { className: "awr-filechips__item", children: renderFile ? renderFile(w, chip) : chip }, w.path);
|
|
7086
7714
|
}) }),
|
|
7087
7715
|
preview()
|
|
7088
7716
|
] });
|
|
@@ -7099,7 +7727,7 @@ var FileChip = ({
|
|
|
7099
7727
|
}) => {
|
|
7100
7728
|
const L = useLabels(labels);
|
|
7101
7729
|
const kind = fileKindOf(written.path, mediaType);
|
|
7102
|
-
const name =
|
|
7730
|
+
const name = fileNameOf2(written.path);
|
|
7103
7731
|
const Icon = KIND_ICON[kind];
|
|
7104
7732
|
const thumb = useFileUrl(
|
|
7105
7733
|
kind === "image" ? vfs : void 0,
|
|
@@ -7107,19 +7735,19 @@ var FileChip = ({
|
|
|
7107
7735
|
kind === "image" ? mediaType.toLowerCase().split(";")[0].trim() : void 0
|
|
7108
7736
|
);
|
|
7109
7737
|
const meta = gone ? L.fileGone : [L.fileKinds[kind], L.bytes(bytes), written.by ? L.fileBy(written.by.name) : ""].filter(Boolean).join(" \xB7 ");
|
|
7110
|
-
return /* @__PURE__ */ (0,
|
|
7738
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
7111
7739
|
"div",
|
|
7112
7740
|
{
|
|
7113
7741
|
className: `awr-filechip${open ? " is-open" : ""}${gone ? " is-gone" : ""}`,
|
|
7114
7742
|
title: written.path,
|
|
7115
7743
|
children: [
|
|
7116
|
-
/* @__PURE__ */ (0,
|
|
7117
|
-
/* @__PURE__ */ (0,
|
|
7118
|
-
/* @__PURE__ */ (0,
|
|
7119
|
-
/* @__PURE__ */ (0,
|
|
7744
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-filechip__thumb", children: thumb ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: thumb, alt: "" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { size: 16 }) }),
|
|
7745
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-filechip__text", children: [
|
|
7746
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-filechip__name", children: name }),
|
|
7747
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-filechip__meta", children: meta })
|
|
7120
7748
|
] }),
|
|
7121
|
-
vfs && /* @__PURE__ */ (0,
|
|
7122
|
-
onToggle && /* @__PURE__ */ (0,
|
|
7749
|
+
vfs && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-filechip__actions", children: [
|
|
7750
|
+
onToggle && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7123
7751
|
"button",
|
|
7124
7752
|
{
|
|
7125
7753
|
type: "button",
|
|
@@ -7128,10 +7756,10 @@ var FileChip = ({
|
|
|
7128
7756
|
title: open ? L.closePreview : L.preview,
|
|
7129
7757
|
"aria-expanded": open,
|
|
7130
7758
|
onClick: onToggle,
|
|
7131
|
-
children: open ? /* @__PURE__ */ (0,
|
|
7759
|
+
children: open ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChevronUpIcon, { size: 15 }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EyeIcon, { size: 15 })
|
|
7132
7760
|
}
|
|
7133
7761
|
),
|
|
7134
|
-
/* @__PURE__ */ (0,
|
|
7762
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7135
7763
|
"button",
|
|
7136
7764
|
{
|
|
7137
7765
|
type: "button",
|
|
@@ -7139,7 +7767,7 @@ var FileChip = ({
|
|
|
7139
7767
|
"aria-label": L.fileDownload(name),
|
|
7140
7768
|
title: L.download,
|
|
7141
7769
|
onClick: () => void downloadFile(vfs, written.path),
|
|
7142
|
-
children: /* @__PURE__ */ (0,
|
|
7770
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DownloadIcon, { size: 15 })
|
|
7143
7771
|
}
|
|
7144
7772
|
)
|
|
7145
7773
|
] })
|
|
@@ -7149,14 +7777,14 @@ var FileChip = ({
|
|
|
7149
7777
|
};
|
|
7150
7778
|
|
|
7151
7779
|
// src/components/StepList.tsx
|
|
7152
|
-
var
|
|
7780
|
+
var import_react20 = require("react");
|
|
7153
7781
|
|
|
7154
7782
|
// src/components/SubagentTree.tsx
|
|
7155
|
-
var
|
|
7156
|
-
var
|
|
7783
|
+
var import_react19 = require("react");
|
|
7784
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
7157
7785
|
var useElapsed = (startedAt, running) => {
|
|
7158
|
-
const [now, setNow] = (0,
|
|
7159
|
-
(0,
|
|
7786
|
+
const [now, setNow] = (0, import_react19.useState)(void 0);
|
|
7787
|
+
(0, import_react19.useEffect)(() => {
|
|
7160
7788
|
if (!running || startedAt === void 0) return;
|
|
7161
7789
|
setNow(Date.now());
|
|
7162
7790
|
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
@@ -7184,19 +7812,19 @@ var SubagentRow = ({
|
|
|
7184
7812
|
sub.toolCalls > 0 ? L.toolCalls(sub.toolCalls) : "",
|
|
7185
7813
|
time !== void 0 ? formatDuration(time) : ""
|
|
7186
7814
|
].filter(Boolean);
|
|
7187
|
-
return /* @__PURE__ */ (0,
|
|
7815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
7188
7816
|
"li",
|
|
7189
7817
|
{
|
|
7190
7818
|
className: `awr-subagent awr-subagent--${sub.status}${sub.dynamic ? " awr-subagent--dynamic" : ""}`,
|
|
7191
7819
|
"data-depth": sub.depth,
|
|
7192
7820
|
children: [
|
|
7193
|
-
/* @__PURE__ */ (0,
|
|
7194
|
-
/* @__PURE__ */ (0,
|
|
7195
|
-
/* @__PURE__ */ (0,
|
|
7196
|
-
sub.dynamic && role && /* @__PURE__ */ (0,
|
|
7197
|
-
sub.profile && /* @__PURE__ */ (0,
|
|
7198
|
-
/* @__PURE__ */ (0,
|
|
7199
|
-
running && onStop && /* @__PURE__ */ (0,
|
|
7821
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "awr-subagent__head", children: [
|
|
7822
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__icon", children: running ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SpinnerIcon, { size: 13 }) : sub.status === "done" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BotIcon, { size: 13 }) : sub.status === "stopped" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StopIcon, { size: 13 }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AlertIcon, { size: 13 }) }),
|
|
7823
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__name", title: sub.role, children: role || (sub.dynamic ? L.subagentHelper : sub.name) }),
|
|
7824
|
+
sub.dynamic && role && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__profile", children: L.subagentHelper }),
|
|
7825
|
+
sub.profile && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__profile", children: sub.profile }),
|
|
7826
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__task", title: sub.task, children: previewValue(sub.task, 90) }),
|
|
7827
|
+
running && onStop && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
7200
7828
|
"button",
|
|
7201
7829
|
{
|
|
7202
7830
|
type: "button",
|
|
@@ -7204,16 +7832,16 @@ var SubagentRow = ({
|
|
|
7204
7832
|
"aria-label": L.stopSubagent,
|
|
7205
7833
|
title: L.stopSubagent,
|
|
7206
7834
|
onClick: () => onStop(sub.id),
|
|
7207
|
-
children: /* @__PURE__ */ (0,
|
|
7835
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StopIcon, { size: 12 })
|
|
7208
7836
|
}
|
|
7209
7837
|
)
|
|
7210
7838
|
] }),
|
|
7211
|
-
showUsage && /* @__PURE__ */ (0,
|
|
7212
|
-
/* @__PURE__ */ (0,
|
|
7213
|
-
meta.map((part, i) => /* @__PURE__ */ (0,
|
|
7839
|
+
showUsage && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "awr-subagent__meta", children: [
|
|
7840
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__status", children: L.subagentStatus[sub.status] }),
|
|
7841
|
+
meta.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-subagent__metaitem", children: part }, i))
|
|
7214
7842
|
] }),
|
|
7215
|
-
showTools && sub.tools && /* @__PURE__ */ (0,
|
|
7216
|
-
/* @__PURE__ */ (0,
|
|
7843
|
+
showTools && sub.tools && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "awr-subagent__tools", children: sub.tools.length > 0 ? L.subagentTools(sub.tools.join(", ")) : L.subagentNoTools }),
|
|
7844
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "awr-subagent__activity", children: sub.status === "error" ? sub.error : sub.status === "stopped" ? L.subagentStopped : sub.status === "done" ? previewValue(sub.text, 160) : `${sub.activity}${!showUsage && sub.toolCalls ? ` \xB7 ${L.toolCalls(sub.toolCalls)}` : ""}` }),
|
|
7217
7845
|
children
|
|
7218
7846
|
]
|
|
7219
7847
|
}
|
|
@@ -7229,12 +7857,12 @@ var SubagentTree = ({
|
|
|
7229
7857
|
className
|
|
7230
7858
|
}) => {
|
|
7231
7859
|
if (subagents.length === 0) return null;
|
|
7232
|
-
const branch = (nodes, nested) => /* @__PURE__ */ (0,
|
|
7860
|
+
const branch = (nodes, nested) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
7233
7861
|
"ul",
|
|
7234
7862
|
{
|
|
7235
7863
|
className: ["awr-subagents", nested ? "awr-subagents--nested" : className].filter(Boolean).join(" "),
|
|
7236
7864
|
children: nodes.map((node) => {
|
|
7237
|
-
const row = /* @__PURE__ */ (0,
|
|
7865
|
+
const row = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
7238
7866
|
SubagentRow,
|
|
7239
7867
|
{
|
|
7240
7868
|
sub: node,
|
|
@@ -7246,7 +7874,7 @@ var SubagentTree = ({
|
|
|
7246
7874
|
},
|
|
7247
7875
|
node.id
|
|
7248
7876
|
);
|
|
7249
|
-
return renderSubagent ? /* @__PURE__ */ (0,
|
|
7877
|
+
return renderSubagent ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react19.Fragment, { children: renderSubagent(node, row) }, node.id) : row;
|
|
7250
7878
|
})
|
|
7251
7879
|
}
|
|
7252
7880
|
);
|
|
@@ -7254,7 +7882,7 @@ var SubagentTree = ({
|
|
|
7254
7882
|
};
|
|
7255
7883
|
|
|
7256
7884
|
// src/components/StepList.tsx
|
|
7257
|
-
var
|
|
7885
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
7258
7886
|
var WEB_SEARCH = "web_search";
|
|
7259
7887
|
var ToolCallRow = ({
|
|
7260
7888
|
call,
|
|
@@ -7272,37 +7900,47 @@ var ToolCallRow = ({
|
|
|
7272
7900
|
call.outputTokens ? `\u2248${formatTokens(call.outputTokens)} out` : "",
|
|
7273
7901
|
call.durationMs !== void 0 ? formatDuration(call.durationMs) : ""
|
|
7274
7902
|
].filter(Boolean).join(" \xB7 ");
|
|
7275
|
-
return /* @__PURE__ */ (0,
|
|
7903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
7276
7904
|
"li",
|
|
7277
7905
|
{
|
|
7278
7906
|
className: `awr-tool awr-tool--${state}${showTiers && call.attempt !== void 0 ? " awr-tool--earlier" : ""}`,
|
|
7279
7907
|
children: [
|
|
7280
|
-
/* @__PURE__ */ (0,
|
|
7281
|
-
/* @__PURE__ */ (0,
|
|
7282
|
-
/* @__PURE__ */ (0,
|
|
7283
|
-
previewValue(call.input) && /* @__PURE__ */ (0,
|
|
7284
|
-
call.status === "calling" && /* @__PURE__ */ (0,
|
|
7285
|
-
call.status === "done" && call.ok === false && /* @__PURE__ */ (0,
|
|
7286
|
-
showTiers && call.replayed && /* @__PURE__ */ (0,
|
|
7287
|
-
showTiers && call.attempt !== void 0 && /* @__PURE__ */ (0,
|
|
7288
|
-
call.app && /* @__PURE__ */ (0,
|
|
7289
|
-
/* @__PURE__ */ (0,
|
|
7908
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "awr-tool__row", children: [
|
|
7909
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ToolIcon, { size: 13, className: "awr-tool__icon" }),
|
|
7910
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { className: "awr-tool__name", children: call.name }),
|
|
7911
|
+
previewValue(call.input) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__args", children: previewValue(call.input) }),
|
|
7912
|
+
call.status === "calling" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SpinnerIcon, { size: 12, className: "awr-tool__spin" }),
|
|
7913
|
+
call.status === "done" && call.ok === false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__badge", children: L.failed }),
|
|
7914
|
+
showTiers && call.replayed && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__tag", title: L.replayedTitle, children: L.replayed }),
|
|
7915
|
+
showTiers && call.attempt !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__tag", children: L.attemptTag(call.attempt) }),
|
|
7916
|
+
call.app && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "awr-tool__tag awr-tool__tag--app", "data-app": call.app, children: [
|
|
7917
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AppIcon, { size: 10 }),
|
|
7290
7918
|
" ",
|
|
7291
7919
|
L.appTag
|
|
7292
7920
|
] }),
|
|
7293
|
-
showUsage && cost && /* @__PURE__ */ (0,
|
|
7921
|
+
showUsage && cost && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__cost", title: L.toolCostTitle, children: cost })
|
|
7294
7922
|
] }),
|
|
7295
|
-
images.length > 0 && /* @__PURE__ */ (0,
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7923
|
+
images.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "awr-tool__images", children: images.map((src, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7924
|
+
ImageThumb,
|
|
7925
|
+
{
|
|
7926
|
+
src,
|
|
7927
|
+
name: `${call.name}-${i + 1}${imageExtensionOf(src)}`,
|
|
7928
|
+
alt: `${call.name} result ${i + 1}`,
|
|
7929
|
+
imgClassName: "awr-thumb",
|
|
7930
|
+
labels
|
|
7931
|
+
},
|
|
7932
|
+
i
|
|
7933
|
+
)) }),
|
|
7934
|
+
search && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "awr-search", children: [
|
|
7935
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { className: "awr-search__query", children: [
|
|
7936
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GlobeIcon, { size: 12 }),
|
|
7299
7937
|
" ",
|
|
7300
7938
|
L.searchQuery,
|
|
7301
7939
|
" ",
|
|
7302
|
-
/* @__PURE__ */ (0,
|
|
7940
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("q", { children: search.query })
|
|
7303
7941
|
] }),
|
|
7304
|
-
search.results.length > 0 ? /* @__PURE__ */ (0,
|
|
7305
|
-
/* @__PURE__ */ (0,
|
|
7942
|
+
search.results.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ol", { className: "awr-search__results", children: search.results.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("li", { className: "awr-search__result", children: [
|
|
7943
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7306
7944
|
"a",
|
|
7307
7945
|
{
|
|
7308
7946
|
className: "awr-search__title",
|
|
@@ -7313,13 +7951,13 @@ var ToolCallRow = ({
|
|
|
7313
7951
|
}
|
|
7314
7952
|
),
|
|
7315
7953
|
" ",
|
|
7316
|
-
/* @__PURE__ */ (0,
|
|
7954
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "awr-search__host", children: [
|
|
7317
7955
|
r.host,
|
|
7318
7956
|
r.date ? ` \xB7 ${r.date}` : ""
|
|
7319
7957
|
] }),
|
|
7320
|
-
r.snippet && /* @__PURE__ */ (0,
|
|
7321
|
-
] }, i)) }) : /* @__PURE__ */ (0,
|
|
7322
|
-
(search.filtered > 0 || search.truncated) && /* @__PURE__ */ (0,
|
|
7958
|
+
r.snippet && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-search__snippet", children: r.snippet })
|
|
7959
|
+
] }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-search__note", children: L.searchNoResults }),
|
|
7960
|
+
(search.filtered > 0 || search.truncated) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-search__note", children: [
|
|
7323
7961
|
search.filtered > 0 ? L.searchFiltered(search.filtered) : "",
|
|
7324
7962
|
search.truncated ? L.searchTruncated : ""
|
|
7325
7963
|
].filter(Boolean).join(" \xB7 ") })
|
|
@@ -7333,11 +7971,11 @@ var UserNoteRow = ({
|
|
|
7333
7971
|
labels
|
|
7334
7972
|
}) => {
|
|
7335
7973
|
const L = useLabels(labels);
|
|
7336
|
-
return /* @__PURE__ */ (0,
|
|
7337
|
-
/* @__PURE__ */ (0,
|
|
7338
|
-
/* @__PURE__ */ (0,
|
|
7339
|
-
/* @__PURE__ */ (0,
|
|
7340
|
-
note.origin === "another-tab" && /* @__PURE__ */ (0,
|
|
7974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("li", { className: `awr-note awr-note--${note.at}`, children: [
|
|
7975
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SendIcon, { size: 12, className: "awr-note__icon" }),
|
|
7976
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-note__where", children: L.noteAt[note.at] }),
|
|
7977
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("q", { className: "awr-note__text", children: note.text }),
|
|
7978
|
+
note.origin === "another-tab" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-note__origin", children: L.fromAnotherTab })
|
|
7341
7979
|
] });
|
|
7342
7980
|
};
|
|
7343
7981
|
var decisionNote = (d, L) => {
|
|
@@ -7368,18 +8006,14 @@ var StepItem = ({
|
|
|
7368
8006
|
renderToolCall,
|
|
7369
8007
|
renderSubagent,
|
|
7370
8008
|
L
|
|
7371
|
-
}) => /* @__PURE__ */ (0,
|
|
7372
|
-
/* @__PURE__ */ (0,
|
|
7373
|
-
/* @__PURE__ */ (0,
|
|
7374
|
-
/* @__PURE__ */ (0,
|
|
7375
|
-
|
|
7376
|
-
"/",
|
|
7377
|
-
step.total
|
|
7378
|
-
] }),
|
|
7379
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "awr-step__desc", children: step.step.description })
|
|
8009
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("li", { className: `awr-step awr-step--${step.blocked ? "blocked" : step.status}`, children: [
|
|
8010
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "awr-step__head", children: [
|
|
8011
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-step__marker", children: step.status === "running" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SpinnerIcon, { size: 14 }) : step.blocked ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AlertIcon, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CheckIcon, { size: 14 }) }),
|
|
8012
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-step__index", children: `${step.index}/${step.total}` }),
|
|
8013
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-step__desc", children: step.step.description })
|
|
7380
8014
|
] }),
|
|
7381
|
-
showTiers && step.tier && /* @__PURE__ */ (0,
|
|
7382
|
-
/* @__PURE__ */ (0,
|
|
8015
|
+
showTiers && step.tier && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "awr-step__meta", children: [
|
|
8016
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7383
8017
|
"span",
|
|
7384
8018
|
{
|
|
7385
8019
|
className: `awr-step__tier awr-step__tier--${step.tier}`,
|
|
@@ -7387,29 +8021,29 @@ var StepItem = ({
|
|
|
7387
8021
|
children: L.tierNames[step.tier]
|
|
7388
8022
|
}
|
|
7389
8023
|
),
|
|
7390
|
-
step.model && /* @__PURE__ */ (0,
|
|
8024
|
+
step.model && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-step__model", children: step.model })
|
|
7391
8025
|
] }),
|
|
7392
|
-
showTiers && step.escalations?.map((e, i) => /* @__PURE__ */ (0,
|
|
7393
|
-
/* @__PURE__ */ (0,
|
|
7394
|
-
/* @__PURE__ */ (0,
|
|
7395
|
-
/* @__PURE__ */ (0,
|
|
8026
|
+
showTiers && step.escalations?.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "awr-step__escalated", children: [
|
|
8027
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { className: "awr-step__escalated-line", children: [
|
|
8028
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ArrowUpIcon, { size: 12 }),
|
|
8029
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: L.escalated(L.tierNames[e.from], L.tierNames[e.to], L.escalationReasons[e.reason]) })
|
|
7396
8030
|
] }),
|
|
7397
|
-
e.text?.trim() && /* @__PURE__ */ (0,
|
|
7398
|
-
/* @__PURE__ */ (0,
|
|
7399
|
-
/* @__PURE__ */ (0,
|
|
8031
|
+
e.text?.trim() && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("details", { className: "awr-step__attempt", children: [
|
|
8032
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("summary", { children: L.escalatedAttemptText }),
|
|
8033
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-step__text", children: e.text.trim() })
|
|
7400
8034
|
] })
|
|
7401
8035
|
] }, i)),
|
|
7402
|
-
showThoughts && step.reasoning.trim() && /* @__PURE__ */ (0,
|
|
7403
|
-
/* @__PURE__ */ (0,
|
|
7404
|
-
/* @__PURE__ */ (0,
|
|
8036
|
+
showThoughts && step.reasoning.trim() && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("details", { className: "awr-thought", open: step.status === "running" && !step.text, children: [
|
|
8037
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("summary", { children: [
|
|
8038
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(BrainIcon, { size: 13 }),
|
|
7405
8039
|
" ",
|
|
7406
8040
|
L.stepThoughts
|
|
7407
8041
|
] }),
|
|
7408
|
-
/* @__PURE__ */ (0,
|
|
8042
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-thought__text", children: step.reasoning.trim() })
|
|
7409
8043
|
] }),
|
|
7410
|
-
step.text.trim() && /* @__PURE__ */ (0,
|
|
7411
|
-
showToolCalls && step.toolCalls.length > 0 && /* @__PURE__ */ (0,
|
|
7412
|
-
const row = /* @__PURE__ */ (0,
|
|
8044
|
+
step.text.trim() && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-step__text", children: step.text.trim() }),
|
|
8045
|
+
showToolCalls && step.toolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "awr-step__tools", children: step.toolCalls.map((call, i) => {
|
|
8046
|
+
const row = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7413
8047
|
ToolCallRow,
|
|
7414
8048
|
{
|
|
7415
8049
|
call,
|
|
@@ -7419,15 +8053,15 @@ var StepItem = ({
|
|
|
7419
8053
|
},
|
|
7420
8054
|
i
|
|
7421
8055
|
);
|
|
7422
|
-
return renderToolCall ? /* @__PURE__ */ (0,
|
|
8056
|
+
return renderToolCall ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react20.Fragment, { children: renderToolCall(call, row) }, i) : row;
|
|
7423
8057
|
}) }),
|
|
7424
|
-
approvals.length > 0 && /* @__PURE__ */ (0,
|
|
7425
|
-
/* @__PURE__ */ (0,
|
|
7426
|
-
/* @__PURE__ */ (0,
|
|
7427
|
-
/* @__PURE__ */ (0,
|
|
7428
|
-
a.subagent && /* @__PURE__ */ (0,
|
|
8058
|
+
approvals.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "awr-step__tools", children: approvals.map((a) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("li", { className: `awr-tool awr-tool__row awr-tool--approval-${a.status}`, children: [
|
|
8059
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ShieldIcon, { size: 13, className: "awr-tool__icon" }),
|
|
8060
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { className: "awr-tool__name", children: a.name }),
|
|
8061
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__args", children: decisionLabel(a, L) }),
|
|
8062
|
+
a.subagent && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "awr-tool__tag", children: L.subagentHelper })
|
|
7429
8063
|
] }, a.id)) }),
|
|
7430
|
-
showSubagents && /* @__PURE__ */ (0,
|
|
8064
|
+
showSubagents && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7431
8065
|
SubagentTree,
|
|
7432
8066
|
{
|
|
7433
8067
|
subagents,
|
|
@@ -7436,14 +8070,14 @@ var StepItem = ({
|
|
|
7436
8070
|
renderSubagent
|
|
7437
8071
|
}
|
|
7438
8072
|
),
|
|
7439
|
-
notes.length > 0 && /* @__PURE__ */ (0,
|
|
7440
|
-
step.blocked && step.summary && /* @__PURE__ */ (0,
|
|
7441
|
-
showReplanFailed && step.replanFailed && /* @__PURE__ */ (0,
|
|
7442
|
-
/* @__PURE__ */ (0,
|
|
8073
|
+
notes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "awr-notes", children: notes.map((n) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UserNoteRow, { note: n }, n.id)) }),
|
|
8074
|
+
step.blocked && step.summary && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-step__blocked", children: step.summary }),
|
|
8075
|
+
showReplanFailed && step.replanFailed && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { className: "awr-step__warn", title: step.replanFailed, children: [
|
|
8076
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AlertIcon, { size: 12 }),
|
|
7443
8077
|
" ",
|
|
7444
8078
|
L.replanFailed
|
|
7445
8079
|
] }),
|
|
7446
|
-
showDecisions && step.decisions?.map((d, i) => /* @__PURE__ */ (0,
|
|
8080
|
+
showDecisions && step.decisions?.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7447
8081
|
"p",
|
|
7448
8082
|
{
|
|
7449
8083
|
className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
|
|
@@ -7478,8 +8112,8 @@ var StepList = ({
|
|
|
7478
8112
|
const known = new Set(steps.map((s) => s.id));
|
|
7479
8113
|
const atEnd = showNotes ? notes.filter((n) => !n.stepId || !known.has(n.stepId)) : [];
|
|
7480
8114
|
const loose = showSubagents ? subagents.filter((s) => !s.stepId || !known.has(s.stepId)) : [];
|
|
7481
|
-
return /* @__PURE__ */ (0,
|
|
7482
|
-
steps.map((step) => /* @__PURE__ */ (0,
|
|
8115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("ol", { className: ["awr-steps", className].filter(Boolean).join(" "), children: [
|
|
8116
|
+
steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7483
8117
|
StepItem,
|
|
7484
8118
|
{
|
|
7485
8119
|
step,
|
|
@@ -7501,7 +8135,7 @@ var StepList = ({
|
|
|
7501
8135
|
},
|
|
7502
8136
|
step.id
|
|
7503
8137
|
)),
|
|
7504
|
-
loose.length > 0 && /* @__PURE__ */ (0,
|
|
8138
|
+
loose.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { className: "awr-step awr-step--subagents", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7505
8139
|
SubagentTree,
|
|
7506
8140
|
{
|
|
7507
8141
|
subagents: loose,
|
|
@@ -7510,12 +8144,12 @@ var StepList = ({
|
|
|
7510
8144
|
renderSubagent
|
|
7511
8145
|
}
|
|
7512
8146
|
) }),
|
|
7513
|
-
atEnd.length > 0 && /* @__PURE__ */ (0,
|
|
8147
|
+
atEnd.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { className: "awr-step awr-step--notes", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "awr-notes", children: atEnd.map((n) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UserNoteRow, { note: n }, n.id)) }) })
|
|
7514
8148
|
] });
|
|
7515
8149
|
};
|
|
7516
8150
|
|
|
7517
8151
|
// src/components/MessageList.tsx
|
|
7518
|
-
var
|
|
8152
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
7519
8153
|
var usageLine = (usage, durationMs) => {
|
|
7520
8154
|
const parts = [];
|
|
7521
8155
|
if (usage && usage.totalTokens > 0) {
|
|
@@ -7526,8 +8160,17 @@ var usageLine = (usage, durationMs) => {
|
|
|
7526
8160
|
if (durationMs !== void 0) parts.push(formatDuration(durationMs));
|
|
7527
8161
|
return parts.join(" \xB7 ");
|
|
7528
8162
|
};
|
|
7529
|
-
var AttachmentView = ({ attachment: a }) => a.dataUrl && a.mediaType.startsWith("image/") ? /* @__PURE__ */ (0,
|
|
7530
|
-
|
|
8163
|
+
var AttachmentView = ({ attachment: a }) => a.dataUrl && a.mediaType.startsWith("image/") ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
8164
|
+
ImageThumb,
|
|
8165
|
+
{
|
|
8166
|
+
src: a.dataUrl,
|
|
8167
|
+
name: a.path ?? a.name,
|
|
8168
|
+
alt: a.name,
|
|
8169
|
+
imgClassName: "awr-thumb awr-thumb--msg",
|
|
8170
|
+
title: a.path ?? a.name
|
|
8171
|
+
}
|
|
8172
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "awr-chip awr-file", title: a.path ?? a.mediaType, children: [
|
|
8173
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FileIcon, { size: 13 }),
|
|
7531
8174
|
" ",
|
|
7532
8175
|
a.name
|
|
7533
8176
|
] });
|
|
@@ -7578,24 +8221,26 @@ var MessageList = ({
|
|
|
7578
8221
|
renderToolCall,
|
|
7579
8222
|
renderApp,
|
|
7580
8223
|
showApps = true,
|
|
8224
|
+
imageViewer = true,
|
|
8225
|
+
renderImageViewer,
|
|
7581
8226
|
labels,
|
|
7582
8227
|
className
|
|
7583
8228
|
}) => {
|
|
7584
8229
|
const L = useLabels(labels);
|
|
7585
8230
|
if (messages.length === 0) {
|
|
7586
|
-
return empty ? /* @__PURE__ */ (0,
|
|
8231
|
+
return empty ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-messages__empty", children: empty }) : null;
|
|
7587
8232
|
}
|
|
7588
|
-
return /* @__PURE__ */ (0,
|
|
8233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: ["awr-messages", className].filter(Boolean).join(" "), children: messages.map((m) => {
|
|
7589
8234
|
const steps = m.steps ?? [];
|
|
7590
8235
|
const hasActivity = showActivity && (steps.length > 0 || (m.subagents?.length ?? 0) > 0 || m.pending && !!liveExtra);
|
|
7591
8236
|
const usage = showUsage ? usageLine(m.usage, m.durationMs) : "";
|
|
7592
|
-
const node = /* @__PURE__ */ (0,
|
|
8237
|
+
const node = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
7593
8238
|
"div",
|
|
7594
8239
|
{
|
|
7595
8240
|
className: `awr-msg awr-msg--${m.role}${m.error ? " awr-msg--error" : ""}${m.pending ? " is-pending" : ""}`,
|
|
7596
|
-
children: /* @__PURE__ */ (0,
|
|
7597
|
-
m.role === "assistant" && hasActivity && /* @__PURE__ */ (0,
|
|
7598
|
-
/* @__PURE__ */ (0,
|
|
8241
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-msg__col", children: [
|
|
8242
|
+
m.role === "assistant" && hasActivity && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("details", { className: "awr-activity", open: m.pending || activityOpen, children: [
|
|
8243
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("summary", { className: "awr-activity__summary", children: activitySummary(
|
|
7599
8244
|
m,
|
|
7600
8245
|
showToolCalls,
|
|
7601
8246
|
showLearned,
|
|
@@ -7605,7 +8250,7 @@ var MessageList = ({
|
|
|
7605
8250
|
showApps && Boolean(renderApp)
|
|
7606
8251
|
) }),
|
|
7607
8252
|
m.pending && liveExtra,
|
|
7608
|
-
/* @__PURE__ */ (0,
|
|
8253
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
7609
8254
|
StepList,
|
|
7610
8255
|
{
|
|
7611
8256
|
steps,
|
|
@@ -7627,45 +8272,45 @@ var MessageList = ({
|
|
|
7627
8272
|
labels
|
|
7628
8273
|
}
|
|
7629
8274
|
),
|
|
7630
|
-
showLearned && m.fetches?.length ? /* @__PURE__ */ (0,
|
|
8275
|
+
showLearned && m.fetches?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: "awr-fetches", children: m.fetches.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
7631
8276
|
"li",
|
|
7632
8277
|
{
|
|
7633
8278
|
className: `awr-fetch${f.allowed ? "" : " awr-fetch--refused"}`,
|
|
7634
8279
|
children: [
|
|
7635
|
-
/* @__PURE__ */ (0,
|
|
8280
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GlobeIcon, { size: 12 }),
|
|
7636
8281
|
" ",
|
|
7637
|
-
/* @__PURE__ */ (0,
|
|
8282
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { children: f.url }),
|
|
7638
8283
|
" ",
|
|
7639
|
-
/* @__PURE__ */ (0,
|
|
8284
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-fetch__result", children: f.allowed ? f.status ?? "ok" : L.fetchRefused(f.reason ?? "") })
|
|
7640
8285
|
]
|
|
7641
8286
|
},
|
|
7642
8287
|
i
|
|
7643
8288
|
)) }) : null,
|
|
7644
|
-
showLearned && m.learned?.length ? /* @__PURE__ */ (0,
|
|
7645
|
-
/* @__PURE__ */ (0,
|
|
8289
|
+
showLearned && m.learned?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { className: "awr-learned", children: [
|
|
8290
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BookIcon, { size: 12 }),
|
|
7646
8291
|
" ",
|
|
7647
8292
|
L.learnedNow(m.learned.join(", "))
|
|
7648
8293
|
] }) : null,
|
|
7649
|
-
showThoughts && m.reasoning?.trim() && /* @__PURE__ */ (0,
|
|
7650
|
-
/* @__PURE__ */ (0,
|
|
7651
|
-
/* @__PURE__ */ (0,
|
|
8294
|
+
showThoughts && m.reasoning?.trim() && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("details", { className: "awr-thought", children: [
|
|
8295
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("summary", { children: [
|
|
8296
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BrainIcon, { size: 13 }),
|
|
7652
8297
|
" ",
|
|
7653
8298
|
L.answerThoughts
|
|
7654
8299
|
] }),
|
|
7655
|
-
/* @__PURE__ */ (0,
|
|
8300
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "awr-thought__text", children: m.reasoning.trim() })
|
|
7656
8301
|
] })
|
|
7657
8302
|
] }),
|
|
7658
|
-
showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ (0,
|
|
7659
|
-
showMedia && m.transcripts?.length ? /* @__PURE__ */ (0,
|
|
7660
|
-
(m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ (0,
|
|
8303
|
+
showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
|
|
8304
|
+
showMedia && m.transcripts?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
|
|
8305
|
+
(m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-msg__bubble", children: [
|
|
7661
8306
|
m.content ? renderContent ? renderContent(m) : m.content : null,
|
|
7662
|
-
m.pending && !m.content && /* @__PURE__ */ (0,
|
|
8307
|
+
m.pending && !m.content && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
|
|
7663
8308
|
] }),
|
|
7664
|
-
showMedia && m.media?.length ? /* @__PURE__ */ (0,
|
|
7665
|
-
const built = /* @__PURE__ */ (0,
|
|
7666
|
-
return renderMedia ? /* @__PURE__ */ (0,
|
|
8309
|
+
showMedia && m.media?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
|
|
8310
|
+
const built = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GeneratedMedia, { media: item, files, labels }, i);
|
|
8311
|
+
return renderMedia ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__mediaitem", children: renderMedia(item, m, built) }, i) : built;
|
|
7667
8312
|
}) }) : null,
|
|
7668
|
-
showFileChips && m.role === "assistant" && m.writtenFiles?.length ? /* @__PURE__ */ (0,
|
|
8313
|
+
showFileChips && m.role === "assistant" && m.writtenFiles?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
7669
8314
|
FileChips,
|
|
7670
8315
|
{
|
|
7671
8316
|
written: m.writtenFiles,
|
|
@@ -7677,34 +8322,305 @@ var MessageList = ({
|
|
|
7677
8322
|
labels
|
|
7678
8323
|
}
|
|
7679
8324
|
) : null,
|
|
7680
|
-
m.attachments?.length ? /* @__PURE__ */ (0,
|
|
7681
|
-
m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ (0,
|
|
8325
|
+
m.attachments?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__attachments", "aria-label": L.attachments, children: m.attachments.map((a, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__attachment", children: renderAttachment ? renderAttachment(a, m) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AttachmentView, { attachment: a }) }, i)) }) : null,
|
|
8326
|
+
m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__usage", title: L.usageTitle, children: usage })
|
|
7682
8327
|
] })
|
|
7683
8328
|
},
|
|
7684
8329
|
m.id
|
|
7685
8330
|
);
|
|
7686
|
-
return renderMessage ? /* @__PURE__ */ (0,
|
|
7687
|
-
}) });
|
|
8331
|
+
return renderMessage ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: renderMessage(m, node) }, m.id) : node;
|
|
8332
|
+
}) }) });
|
|
7688
8333
|
};
|
|
7689
8334
|
|
|
7690
8335
|
// src/components/ModelLoadBar.tsx
|
|
7691
|
-
var
|
|
8336
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
7692
8337
|
var ModelLoadBar = ({ load, className }) => {
|
|
7693
8338
|
const pct = Math.round(Math.max(0, Math.min(1, load.progress)) * 100);
|
|
7694
|
-
return /* @__PURE__ */ (0,
|
|
7695
|
-
/* @__PURE__ */ (0,
|
|
7696
|
-
/* @__PURE__ */ (0,
|
|
7697
|
-
/* @__PURE__ */ (0,
|
|
8339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: ["awr-modelload", className].filter(Boolean).join(" "), children: [
|
|
8340
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "awr-modelload__head", children: [
|
|
8341
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "awr-modelload__text", children: load.text || "Loading model\u2026" }),
|
|
8342
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "awr-modelload__pct", children: [
|
|
7698
8343
|
pct,
|
|
7699
8344
|
"%"
|
|
7700
8345
|
] })
|
|
7701
8346
|
] }),
|
|
7702
|
-
/* @__PURE__ */ (0,
|
|
8347
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "awr-modelload__track", role: "progressbar", "aria-valuenow": pct, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "awr-modelload__fill", style: { width: `${pct}%` } }) })
|
|
8348
|
+
] });
|
|
8349
|
+
};
|
|
8350
|
+
|
|
8351
|
+
// src/components/QuestionPrompt.tsx
|
|
8352
|
+
var import_react21 = require("react");
|
|
8353
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
8354
|
+
var useNow2 = (active) => {
|
|
8355
|
+
const [now, setNow] = (0, import_react21.useState)(() => Date.now());
|
|
8356
|
+
(0, import_react21.useEffect)(() => {
|
|
8357
|
+
if (!active) return;
|
|
8358
|
+
setNow(Date.now());
|
|
8359
|
+
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
8360
|
+
return () => clearInterval(timer);
|
|
8361
|
+
}, [active]);
|
|
8362
|
+
return now;
|
|
8363
|
+
};
|
|
8364
|
+
var Expiry2 = ({ expiresAt, L }) => {
|
|
8365
|
+
const now = useNow2(true);
|
|
8366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__expiry", children: L.questionExpiresIn(formatCountdown(expiresAt - now)) });
|
|
8367
|
+
};
|
|
8368
|
+
var reasonText2 = (q, L) => {
|
|
8369
|
+
const key = q.reason ?? q.status;
|
|
8370
|
+
return Object.hasOwn(L.questionReasons, key) ? L.questionReasons[key] : key;
|
|
8371
|
+
};
|
|
8372
|
+
var leadOf = (subagent, L) => subagent ? L.questionLeadHelper(previewValue(subagent.role ?? "", 60) || void 0, subagent.depth) : L.questionLead;
|
|
8373
|
+
var isTyping = (target) => target instanceof HTMLElement && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable);
|
|
8374
|
+
var QuestionCard = ({
|
|
8375
|
+
question: q,
|
|
8376
|
+
view,
|
|
8377
|
+
index,
|
|
8378
|
+
total,
|
|
8379
|
+
answer,
|
|
8380
|
+
showExpiry,
|
|
8381
|
+
showHelper,
|
|
8382
|
+
numberKeys,
|
|
8383
|
+
L
|
|
8384
|
+
}) => {
|
|
8385
|
+
const baseId = (0, import_react21.useId)();
|
|
8386
|
+
const textId = `${baseId}-q`;
|
|
8387
|
+
const otherId = `${baseId}-other`;
|
|
8388
|
+
const [picked, setPicked] = (0, import_react21.useState)([]);
|
|
8389
|
+
const [otherOpen, setOtherOpen] = (0, import_react21.useState)(false);
|
|
8390
|
+
const [otherText, setOtherText] = (0, import_react21.useState)("");
|
|
8391
|
+
const otherField = (0, import_react21.useRef)(null);
|
|
8392
|
+
const otherButton = (0, import_react21.useRef)(null);
|
|
8393
|
+
(0, import_react21.useEffect)(() => {
|
|
8394
|
+
if (otherOpen) otherField.current?.focus();
|
|
8395
|
+
}, [otherOpen]);
|
|
8396
|
+
const helper = showHelper && q.subagent ? { ...q.subagent, ...view?.subagent } : void 0;
|
|
8397
|
+
const choice = questionChoiceOf(q, picked);
|
|
8398
|
+
const other = questionOtherOf(q, otherText);
|
|
8399
|
+
const pick = (label) => {
|
|
8400
|
+
if (!q.multiple) {
|
|
8401
|
+
const one = questionChoiceOf(q, [label]);
|
|
8402
|
+
if (one) answer(one);
|
|
8403
|
+
return;
|
|
8404
|
+
}
|
|
8405
|
+
setPicked((p) => p.includes(label) ? p.filter((l) => l !== label) : [...p, label]);
|
|
8406
|
+
};
|
|
8407
|
+
const sendOther = (e) => {
|
|
8408
|
+
e.preventDefault();
|
|
8409
|
+
if (other) answer(other);
|
|
8410
|
+
};
|
|
8411
|
+
const onKeyDown = (e) => {
|
|
8412
|
+
if (!numberKeys || e.defaultPrevented || isTyping(e.target)) return;
|
|
8413
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
|
|
8414
|
+
const n = /^[1-9]$/.test(e.key) ? Number(e.key) : 0;
|
|
8415
|
+
const option = n ? q.options[n - 1] : void 0;
|
|
8416
|
+
if (!option) return;
|
|
8417
|
+
e.preventDefault();
|
|
8418
|
+
pick(option.label);
|
|
8419
|
+
};
|
|
8420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
8421
|
+
"section",
|
|
8422
|
+
{
|
|
8423
|
+
className: `awr-question${q.multiple ? " awr-question--multiple" : ""}${helper ? " awr-question--helper" : ""}`,
|
|
8424
|
+
role: "group",
|
|
8425
|
+
"aria-labelledby": textId,
|
|
8426
|
+
"data-question": q.id,
|
|
8427
|
+
"data-subagent": helper?.id,
|
|
8428
|
+
onKeyDown,
|
|
8429
|
+
children: [
|
|
8430
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__head", children: [
|
|
8431
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(QuestionIcon, { size: 16, className: "awr-question__icon" }),
|
|
8432
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__lead", role: "alert", children: leadOf(helper, L) }),
|
|
8433
|
+
total > 1 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__count", children: L.questionCount(index, total) })
|
|
8434
|
+
] }),
|
|
8435
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__text", id: textId, children: q.question }),
|
|
8436
|
+
q.multiple && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__hint", children: L.questionSeveral }),
|
|
8437
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "awr-question__options", children: q.options.map((o, i) => {
|
|
8438
|
+
const on = picked.includes(o.label);
|
|
8439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
8440
|
+
"button",
|
|
8441
|
+
{
|
|
8442
|
+
type: "button",
|
|
8443
|
+
className: `awr-question__option${on ? " is-picked" : ""}`,
|
|
8444
|
+
"data-option": i + 1,
|
|
8445
|
+
"aria-pressed": q.multiple ? on : void 0,
|
|
8446
|
+
"aria-keyshortcuts": numberKeys && i < 9 ? String(i + 1) : void 0,
|
|
8447
|
+
onClick: () => pick(o.label),
|
|
8448
|
+
children: [
|
|
8449
|
+
numberKeys && i < 9 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__key", "aria-hidden": "true", children: i + 1 }),
|
|
8450
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "awr-question__body", children: [
|
|
8451
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__label", children: o.label }),
|
|
8452
|
+
o.description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__desc", children: o.description })
|
|
8453
|
+
] }),
|
|
8454
|
+
q.multiple && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__mark", "aria-hidden": "true", children: on && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CheckIcon, { size: 14 }) })
|
|
8455
|
+
]
|
|
8456
|
+
},
|
|
8457
|
+
o.label
|
|
8458
|
+
);
|
|
8459
|
+
}) }),
|
|
8460
|
+
q.allowOther && otherOpen && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("form", { className: "awr-question__other", onSubmit: sendOther, children: [
|
|
8461
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { className: "awr-question__otherlabel", htmlFor: otherId, children: L.questionOtherLabel }),
|
|
8462
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__otherrow", children: [
|
|
8463
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8464
|
+
"input",
|
|
8465
|
+
{
|
|
8466
|
+
ref: otherField,
|
|
8467
|
+
id: otherId,
|
|
8468
|
+
className: "awr-question__input",
|
|
8469
|
+
type: "text",
|
|
8470
|
+
value: otherText,
|
|
8471
|
+
autoComplete: "off",
|
|
8472
|
+
onChange: (e) => setOtherText(e.target.value),
|
|
8473
|
+
onKeyDown: (e) => {
|
|
8474
|
+
if (e.key !== "Escape") return;
|
|
8475
|
+
e.preventDefault();
|
|
8476
|
+
e.stopPropagation();
|
|
8477
|
+
setOtherOpen(false);
|
|
8478
|
+
otherButton.current?.focus();
|
|
8479
|
+
}
|
|
8480
|
+
}
|
|
8481
|
+
),
|
|
8482
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "submit", className: "awr-btn awr-btn--primary", disabled: !other, children: L.questionSend })
|
|
8483
|
+
] })
|
|
8484
|
+
] }),
|
|
8485
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__actions", children: [
|
|
8486
|
+
q.multiple && !otherOpen && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8487
|
+
"button",
|
|
8488
|
+
{
|
|
8489
|
+
type: "button",
|
|
8490
|
+
className: "awr-btn awr-btn--primary",
|
|
8491
|
+
disabled: !choice,
|
|
8492
|
+
onClick: () => choice && answer(choice),
|
|
8493
|
+
children: L.questionSend
|
|
8494
|
+
}
|
|
8495
|
+
),
|
|
8496
|
+
q.allowOther && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8497
|
+
"button",
|
|
8498
|
+
{
|
|
8499
|
+
ref: otherButton,
|
|
8500
|
+
type: "button",
|
|
8501
|
+
className: "awr-btn",
|
|
8502
|
+
"aria-expanded": otherOpen,
|
|
8503
|
+
"aria-controls": otherOpen ? otherId : void 0,
|
|
8504
|
+
onClick: () => setOtherOpen((o) => !o),
|
|
8505
|
+
children: L.questionOther
|
|
8506
|
+
}
|
|
8507
|
+
),
|
|
8508
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8509
|
+
"button",
|
|
8510
|
+
{
|
|
8511
|
+
type: "button",
|
|
8512
|
+
className: "awr-btn awr-btn--ghost",
|
|
8513
|
+
onClick: () => answer({ declined: true }),
|
|
8514
|
+
children: L.questionSkip
|
|
8515
|
+
}
|
|
8516
|
+
)
|
|
8517
|
+
] }),
|
|
8518
|
+
showExpiry && q.expiresAt !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Expiry2, { expiresAt: q.expiresAt, L })
|
|
8519
|
+
]
|
|
8520
|
+
}
|
|
8521
|
+
);
|
|
8522
|
+
};
|
|
8523
|
+
var RemoteQuestion = ({ view, L }) => {
|
|
8524
|
+
const textId = `${(0, import_react21.useId)()}-q`;
|
|
8525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
8526
|
+
"section",
|
|
8527
|
+
{
|
|
8528
|
+
className: "awr-question awr-question--remote",
|
|
8529
|
+
role: "group",
|
|
8530
|
+
"aria-labelledby": textId,
|
|
8531
|
+
"data-question": view.id,
|
|
8532
|
+
children: [
|
|
8533
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__head", children: [
|
|
8534
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(QuestionIcon, { size: 16, className: "awr-question__icon" }),
|
|
8535
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__lead", children: leadOf(view.subagent, L) })
|
|
8536
|
+
] }),
|
|
8537
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__text", id: textId, children: view.question }),
|
|
8538
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ul", { className: "awr-question__list", children: view.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { children: [
|
|
8539
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__label", children: o.label }),
|
|
8540
|
+
o.description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__desc", children: o.description })
|
|
8541
|
+
] }, o.label)) }),
|
|
8542
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__remote", role: "status", children: L.questionRemote })
|
|
8543
|
+
]
|
|
8544
|
+
}
|
|
8545
|
+
);
|
|
8546
|
+
};
|
|
8547
|
+
var QuestionPrompt = ({
|
|
8548
|
+
questions,
|
|
8549
|
+
onAnswer,
|
|
8550
|
+
outcomes,
|
|
8551
|
+
showOutcomes = true,
|
|
8552
|
+
showExpiry = true,
|
|
8553
|
+
showHelper = true,
|
|
8554
|
+
showRemote = true,
|
|
8555
|
+
numberKeys = true,
|
|
8556
|
+
renderQuestion,
|
|
8557
|
+
labels,
|
|
8558
|
+
className
|
|
8559
|
+
}) => {
|
|
8560
|
+
const L = useLabels(labels);
|
|
8561
|
+
const [dismissed, setDismissed] = (0, import_react21.useState)(() => /* @__PURE__ */ new Set());
|
|
8562
|
+
const automatic = showOutcomes ? (outcomes ?? []).filter(
|
|
8563
|
+
(o) => o.automatic === true && o.status !== "pending" && o.status !== "stopped" && !dismissed.has(o.id)
|
|
8564
|
+
) : [];
|
|
8565
|
+
const remote = showRemote ? (outcomes ?? []).filter((o) => o.remote && o.status === "pending") : [];
|
|
8566
|
+
const current = questions[0];
|
|
8567
|
+
if (!current && automatic.length === 0 && remote.length === 0) return null;
|
|
8568
|
+
let card = null;
|
|
8569
|
+
if (current) {
|
|
8570
|
+
const answer = (a) => onAnswer(current.id, a);
|
|
8571
|
+
const builtIn = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8572
|
+
QuestionCard,
|
|
8573
|
+
{
|
|
8574
|
+
question: current,
|
|
8575
|
+
view: outcomes?.find((o) => o.id === current.id),
|
|
8576
|
+
index: 1,
|
|
8577
|
+
total: questions.length,
|
|
8578
|
+
answer,
|
|
8579
|
+
showExpiry,
|
|
8580
|
+
showHelper,
|
|
8581
|
+
numberKeys,
|
|
8582
|
+
L
|
|
8583
|
+
},
|
|
8584
|
+
current.id
|
|
8585
|
+
);
|
|
8586
|
+
card = renderQuestion ? renderQuestion(current, builtIn, answer) : builtIn;
|
|
8587
|
+
}
|
|
8588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: ["awr-questions", className].filter(Boolean).join(" "), children: [
|
|
8589
|
+
automatic.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
8590
|
+
"div",
|
|
8591
|
+
{
|
|
8592
|
+
className: "awr-question-outcome",
|
|
8593
|
+
role: "status",
|
|
8594
|
+
"data-reason": o.reason ?? o.status,
|
|
8595
|
+
children: [
|
|
8596
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AlertIcon, { size: 14, className: "awr-question-outcome__icon" }),
|
|
8597
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "awr-question-outcome__text", children: [
|
|
8598
|
+
L.questionAutomatic(reasonText2(o, L)),
|
|
8599
|
+
" ",
|
|
8600
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("q", { className: "awr-question-outcome__question", children: o.question })
|
|
8601
|
+
] }),
|
|
8602
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8603
|
+
"button",
|
|
8604
|
+
{
|
|
8605
|
+
type: "button",
|
|
8606
|
+
className: "awr-iconbtn awr-question-outcome__dismiss",
|
|
8607
|
+
"aria-label": L.questionDismiss,
|
|
8608
|
+
title: L.questionDismiss,
|
|
8609
|
+
onClick: () => setDismissed((d) => new Set(d).add(o.id)),
|
|
8610
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(XIcon, { size: 14 })
|
|
8611
|
+
}
|
|
8612
|
+
)
|
|
8613
|
+
]
|
|
8614
|
+
},
|
|
8615
|
+
o.id
|
|
8616
|
+
)),
|
|
8617
|
+
remote.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RemoteQuestion, { view: o, L }, o.id)),
|
|
8618
|
+
card
|
|
7703
8619
|
] });
|
|
7704
8620
|
};
|
|
7705
8621
|
|
|
7706
8622
|
// src/components/ToolApprovalPrompt.tsx
|
|
7707
|
-
var
|
|
8623
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7708
8624
|
var SkillConsentCard = ({
|
|
7709
8625
|
approval: a,
|
|
7710
8626
|
skill,
|
|
@@ -7714,7 +8630,7 @@ var SkillConsentCard = ({
|
|
|
7714
8630
|
showPreview,
|
|
7715
8631
|
onApprove,
|
|
7716
8632
|
onDeny
|
|
7717
|
-
}) => /* @__PURE__ */ (0,
|
|
8633
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
7718
8634
|
"div",
|
|
7719
8635
|
{
|
|
7720
8636
|
className: `awr-approval awr-approval--skill${helper ? " awr-approval--helper" : ""}`,
|
|
@@ -7722,28 +8638,28 @@ var SkillConsentCard = ({
|
|
|
7722
8638
|
"data-skill-server": skill.server,
|
|
7723
8639
|
"data-subagent": helper?.id,
|
|
7724
8640
|
children: [
|
|
7725
|
-
/* @__PURE__ */ (0,
|
|
7726
|
-
/* @__PURE__ */ (0,
|
|
7727
|
-
/* @__PURE__ */ (0,
|
|
8641
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__head", children: [
|
|
8642
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
|
|
8643
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: L.skillConsentLead(skill.server, skill.skill) })
|
|
7728
8644
|
] }),
|
|
7729
|
-
skill.description && /* @__PURE__ */ (0,
|
|
7730
|
-
/* @__PURE__ */ (0,
|
|
7731
|
-
/* @__PURE__ */ (0,
|
|
7732
|
-
/* @__PURE__ */ (0,
|
|
8645
|
+
skill.description && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__quote", children: skill.description }),
|
|
8646
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("p", { className: "awr-approval__skillmeta", children: [
|
|
8647
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("code", { className: "awr-tool__name", children: skill.name }),
|
|
8648
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: L.skillConsentSize(skill.size, skill.fileCount) })
|
|
7733
8649
|
] }),
|
|
7734
|
-
skill.byUri && /* @__PURE__ */ (0,
|
|
7735
|
-
skill.nestedIn && /* @__PURE__ */ (0,
|
|
7736
|
-
skill.dynamic && /* @__PURE__ */ (0,
|
|
7737
|
-
skill.dynamic && skill.noFileListing && /* @__PURE__ */ (0,
|
|
7738
|
-
showPreview && skill.body !== void 0 && /* @__PURE__ */ (0,
|
|
7739
|
-
/* @__PURE__ */ (0,
|
|
7740
|
-
/* @__PURE__ */ (0,
|
|
7741
|
-
skill.files.length > 0 && /* @__PURE__ */ (0,
|
|
8650
|
+
skill.byUri && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentByUri }),
|
|
8651
|
+
skill.nestedIn && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from awr-approval__nested", children: L.skillConsentNested(skill.nestedIn) }),
|
|
8652
|
+
skill.dynamic && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from awr-approval__dynamic", children: L.skillConsentDynamic }),
|
|
8653
|
+
skill.dynamic && skill.noFileListing && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentNoFileListing }),
|
|
8654
|
+
showPreview && skill.body !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("details", { className: "awr-approval__preview", children: [
|
|
8655
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("summary", { children: L.skillConsentPreview }),
|
|
8656
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("pre", { className: "awr-approval__quote awr-approval__body", children: skill.body }),
|
|
8657
|
+
skill.files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentFiles(skill.files.join(", "), skill.fileCount - skill.files.length) })
|
|
7742
8658
|
] }),
|
|
7743
|
-
/* @__PURE__ */ (0,
|
|
7744
|
-
/* @__PURE__ */ (0,
|
|
7745
|
-
/* @__PURE__ */ (0,
|
|
7746
|
-
allowRemember && /* @__PURE__ */ (0,
|
|
8659
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentNote(skill.server, skill.consent) }),
|
|
8660
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__actions", children: [
|
|
8661
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: "awr-btn awr-btn--primary", onClick: () => onApprove(a.id), children: L.skillConsentAllow }),
|
|
8662
|
+
allowRemember && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7747
8663
|
"button",
|
|
7748
8664
|
{
|
|
7749
8665
|
type: "button",
|
|
@@ -7752,7 +8668,7 @@ var SkillConsentCard = ({
|
|
|
7752
8668
|
children: L.skillConsentAlways
|
|
7753
8669
|
}
|
|
7754
8670
|
),
|
|
7755
|
-
/* @__PURE__ */ (0,
|
|
8671
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7756
8672
|
"button",
|
|
7757
8673
|
{
|
|
7758
8674
|
type: "button",
|
|
@@ -7778,9 +8694,9 @@ var ToolApprovalPrompt = ({
|
|
|
7778
8694
|
}) => {
|
|
7779
8695
|
const L = useLabels(labels);
|
|
7780
8696
|
if (approvals.length === 0) return null;
|
|
7781
|
-
return /* @__PURE__ */ (0,
|
|
8697
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
|
|
7782
8698
|
if (a.skill) {
|
|
7783
|
-
const card2 = /* @__PURE__ */ (0,
|
|
8699
|
+
const card2 = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7784
8700
|
SkillConsentCard,
|
|
7785
8701
|
{
|
|
7786
8702
|
approval: a,
|
|
@@ -7794,33 +8710,33 @@ var ToolApprovalPrompt = ({
|
|
|
7794
8710
|
},
|
|
7795
8711
|
a.id
|
|
7796
8712
|
);
|
|
7797
|
-
return renderApproval ? /* @__PURE__ */ (0,
|
|
8713
|
+
return renderApproval ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: renderApproval(a, card2) }, a.id) : card2;
|
|
7798
8714
|
}
|
|
7799
8715
|
const helper = showHelper ? a.subagent : void 0;
|
|
7800
8716
|
const app = a.app;
|
|
7801
|
-
const card = /* @__PURE__ */ (0,
|
|
8717
|
+
const card = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
7802
8718
|
"div",
|
|
7803
8719
|
{
|
|
7804
8720
|
className: `awr-approval${helper ? " awr-approval--helper" : ""}${app ? " awr-approval--app" : ""}`,
|
|
7805
8721
|
"data-subagent": helper?.id,
|
|
7806
8722
|
"data-app-server": app?.server,
|
|
7807
8723
|
children: [
|
|
7808
|
-
/* @__PURE__ */ (0,
|
|
7809
|
-
/* @__PURE__ */ (0,
|
|
7810
|
-
/* @__PURE__ */ (0,
|
|
8724
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__head", children: [
|
|
8725
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
|
|
8726
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
7811
8727
|
app ? L.approvalLeadApp(app.server) : helper ? L.approvalLeadHelper(
|
|
7812
8728
|
previewValue(helper.role ?? "", 60) || void 0,
|
|
7813
8729
|
helper.depth
|
|
7814
8730
|
) : L.approvalLead,
|
|
7815
8731
|
" ",
|
|
7816
|
-
/* @__PURE__ */ (0,
|
|
8732
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("code", { className: "awr-tool__name", children: app ? app.tool : a.name }),
|
|
7817
8733
|
a.readOnly && !app ? ` (${L.readOnlyTool})` : ""
|
|
7818
8734
|
] })
|
|
7819
8735
|
] }),
|
|
7820
|
-
previewValue(a.input, 300) && /* @__PURE__ */ (0,
|
|
7821
|
-
app && /* @__PURE__ */ (0,
|
|
7822
|
-
/* @__PURE__ */ (0,
|
|
7823
|
-
/* @__PURE__ */ (0,
|
|
8736
|
+
previewValue(a.input, 300) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
|
|
8737
|
+
app && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.approvalFromApp(app.server, a.readOnly) }),
|
|
8738
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__actions", children: [
|
|
8739
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7824
8740
|
"button",
|
|
7825
8741
|
{
|
|
7826
8742
|
type: "button",
|
|
@@ -7829,7 +8745,7 @@ var ToolApprovalPrompt = ({
|
|
|
7829
8745
|
children: L.approve
|
|
7830
8746
|
}
|
|
7831
8747
|
),
|
|
7832
|
-
allowRemember && /* @__PURE__ */ (0,
|
|
8748
|
+
allowRemember && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7833
8749
|
"button",
|
|
7834
8750
|
{
|
|
7835
8751
|
type: "button",
|
|
@@ -7838,7 +8754,7 @@ var ToolApprovalPrompt = ({
|
|
|
7838
8754
|
children: L.alwaysAllow
|
|
7839
8755
|
}
|
|
7840
8756
|
),
|
|
7841
|
-
/* @__PURE__ */ (0,
|
|
8757
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7842
8758
|
"button",
|
|
7843
8759
|
{
|
|
7844
8760
|
type: "button",
|
|
@@ -7852,12 +8768,12 @@ var ToolApprovalPrompt = ({
|
|
|
7852
8768
|
},
|
|
7853
8769
|
a.id
|
|
7854
8770
|
);
|
|
7855
|
-
return renderApproval ? /* @__PURE__ */ (0,
|
|
8771
|
+
return renderApproval ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: renderApproval(a, card) }, a.id) : card;
|
|
7856
8772
|
}) });
|
|
7857
8773
|
};
|
|
7858
8774
|
|
|
7859
8775
|
// src/components/UsageBadge.tsx
|
|
7860
|
-
var
|
|
8776
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
7861
8777
|
var UsageBadge = ({
|
|
7862
8778
|
usage,
|
|
7863
8779
|
compact = false,
|
|
@@ -7883,7 +8799,7 @@ var UsageBadge = ({
|
|
|
7883
8799
|
mediaText,
|
|
7884
8800
|
decisions ? L.usageDecisions(decisions) : ""
|
|
7885
8801
|
].filter(Boolean).join(" \xB7 ");
|
|
7886
|
-
return /* @__PURE__ */ (0,
|
|
8802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
|
|
7887
8803
|
formatTokens(usage.inputTokens),
|
|
7888
8804
|
"\u2191 ",
|
|
7889
8805
|
formatTokens(usage.outputTokens),
|
|
@@ -7896,13 +8812,13 @@ var UsageBadge = ({
|
|
|
7896
8812
|
};
|
|
7897
8813
|
|
|
7898
8814
|
// src/components/AgentChat.tsx
|
|
7899
|
-
var
|
|
8815
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7900
8816
|
var usePrefersDark = () => {
|
|
7901
8817
|
const query = "(prefers-color-scheme: dark)";
|
|
7902
|
-
const [dark, setDark] = (0,
|
|
8818
|
+
const [dark, setDark] = (0, import_react22.useState)(
|
|
7903
8819
|
() => typeof matchMedia === "function" && matchMedia(query).matches
|
|
7904
8820
|
);
|
|
7905
|
-
(0,
|
|
8821
|
+
(0, import_react22.useEffect)(() => {
|
|
7906
8822
|
if (typeof matchMedia !== "function") return;
|
|
7907
8823
|
const mq = matchMedia(query);
|
|
7908
8824
|
const on = () => setDark(mq.matches);
|
|
@@ -7913,7 +8829,7 @@ var usePrefersDark = () => {
|
|
|
7913
8829
|
};
|
|
7914
8830
|
var isHistoryHook = (h) => typeof h === "object" && h !== null && "select" in h && "chats" in h;
|
|
7915
8831
|
var cx = (...names) => names.filter(Boolean).join(" ");
|
|
7916
|
-
var AgentChat = (props) => /* @__PURE__ */ (0,
|
|
8832
|
+
var AgentChat = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AgentChatInner, { ...props }) });
|
|
7917
8833
|
var NO_LABELS = {};
|
|
7918
8834
|
var AgentChatInner = ({
|
|
7919
8835
|
controller,
|
|
@@ -7941,11 +8857,13 @@ var AgentChatInner = ({
|
|
|
7941
8857
|
showContext = false,
|
|
7942
8858
|
activityOpen = false,
|
|
7943
8859
|
showElicitation = true,
|
|
8860
|
+
showQuestions = true,
|
|
7944
8861
|
showSkillPreview = true,
|
|
7945
8862
|
showOtherTabs = true,
|
|
7946
8863
|
elicitations,
|
|
7947
8864
|
onElicitationAnswer,
|
|
7948
8865
|
renderElicitation,
|
|
8866
|
+
renderQuestion,
|
|
7949
8867
|
history,
|
|
7950
8868
|
defaultHistoryOpen,
|
|
7951
8869
|
files,
|
|
@@ -7962,6 +8880,8 @@ var AgentChatInner = ({
|
|
|
7962
8880
|
renderFileContent,
|
|
7963
8881
|
renderApproval,
|
|
7964
8882
|
slots = {},
|
|
8883
|
+
imageViewer = true,
|
|
8884
|
+
renderImageViewer,
|
|
7965
8885
|
components = {},
|
|
7966
8886
|
theme = "auto",
|
|
7967
8887
|
classNames = {},
|
|
@@ -7988,7 +8908,7 @@ var AgentChatInner = ({
|
|
|
7988
8908
|
}
|
|
7989
8909
|
const L = useLabels();
|
|
7990
8910
|
const external = isHistoryHook(history) ? history : void 0;
|
|
7991
|
-
const [ownStore] = (0,
|
|
8911
|
+
const [ownStore] = (0, import_react22.useState)(
|
|
7992
8912
|
() => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
|
|
7993
8913
|
);
|
|
7994
8914
|
const own = useChatHistory(agent, {
|
|
@@ -7996,20 +8916,20 @@ var AgentChatInner = ({
|
|
|
7996
8916
|
enabled: Boolean(history) && !external
|
|
7997
8917
|
});
|
|
7998
8918
|
const chats = history ? external ?? own : void 0;
|
|
7999
|
-
const rootRef = (0,
|
|
8000
|
-
const [narrow, setNarrow] = (0,
|
|
8001
|
-
(0,
|
|
8919
|
+
const rootRef = (0, import_react22.useRef)(null);
|
|
8920
|
+
const [narrow, setNarrow] = (0, import_react22.useState)(void 0);
|
|
8921
|
+
(0, import_react22.useEffect)(() => {
|
|
8002
8922
|
const el = rootRef.current;
|
|
8003
8923
|
if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
|
|
8004
|
-
const
|
|
8005
|
-
|
|
8006
|
-
const ro = new ResizeObserver(
|
|
8924
|
+
const measure2 = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
|
|
8925
|
+
measure2();
|
|
8926
|
+
const ro = new ResizeObserver(measure2);
|
|
8007
8927
|
ro.observe(el);
|
|
8008
8928
|
return () => ro.disconnect();
|
|
8009
8929
|
}, [narrowWidth]);
|
|
8010
|
-
const [historyChoice, setHistoryOpen] = (0,
|
|
8930
|
+
const [historyChoice, setHistoryOpen] = (0, import_react22.useState)(defaultHistoryOpen);
|
|
8011
8931
|
const historyOpen = historyChoice ?? narrow === false;
|
|
8012
|
-
const [filesOpen, setFilesOpen] = (0,
|
|
8932
|
+
const [filesOpen, setFilesOpen] = (0, import_react22.useState)(defaultFilesOpen);
|
|
8013
8933
|
const toggleHistory = () => {
|
|
8014
8934
|
setHistoryOpen(!historyOpen);
|
|
8015
8935
|
if (narrow && !historyOpen) setFilesOpen(false);
|
|
@@ -8022,19 +8942,22 @@ var AgentChatInner = ({
|
|
|
8022
8942
|
setFilesOpen(true);
|
|
8023
8943
|
if (narrow) setHistoryOpen(false);
|
|
8024
8944
|
};
|
|
8025
|
-
const
|
|
8026
|
-
const
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8945
|
+
const overlayOpen = narrow === true && (Boolean(chats) && historyOpen || Boolean(files) && filesOpen);
|
|
8946
|
+
const closeOverlays = () => {
|
|
8947
|
+
setHistoryOpen(false);
|
|
8948
|
+
setFilesOpen(false);
|
|
8949
|
+
};
|
|
8950
|
+
(0, import_react22.useEffect)(() => {
|
|
8951
|
+
if (!overlayOpen) return;
|
|
8952
|
+
const onKey = (e) => {
|
|
8953
|
+
if (e.key !== "Escape" || e.defaultPrevented) return;
|
|
8954
|
+
setHistoryOpen(false);
|
|
8955
|
+
setFilesOpen(false);
|
|
8956
|
+
};
|
|
8957
|
+
document.addEventListener("keydown", onKey);
|
|
8958
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
8959
|
+
}, [overlayOpen]);
|
|
8960
|
+
const bodyRef = (0, import_react22.useRef)(null);
|
|
8038
8961
|
const appHost = useMcpAppHost({
|
|
8039
8962
|
connection: mcpApps,
|
|
8040
8963
|
approve: agent.approveAppToolCall,
|
|
@@ -8046,23 +8969,28 @@ var AgentChatInner = ({
|
|
|
8046
8969
|
});
|
|
8047
8970
|
const prefersDark = usePrefersDark();
|
|
8048
8971
|
const appTheme = theme === "auto" ? prefersDark ? "dark" : "light" : theme;
|
|
8049
|
-
const [panelApp, setPanelAppState] = (0,
|
|
8972
|
+
const [panelApp, setPanelAppState] = (0, import_react22.useState)();
|
|
8050
8973
|
const setPanelApp = (app) => {
|
|
8051
8974
|
setPanelAppState(app);
|
|
8052
8975
|
onAppPanel?.(app);
|
|
8053
8976
|
};
|
|
8054
8977
|
const appsOn = showApps && Boolean(mcpApps);
|
|
8978
|
+
useFollowScroll(
|
|
8979
|
+
bodyRef,
|
|
8980
|
+
agent.messages.filter((m) => m.role === "user").length,
|
|
8981
|
+
agent.isRunning || agent.messages.some((m) => m.pending)
|
|
8982
|
+
);
|
|
8055
8983
|
const panelAllowed = appPanel !== false && appPanel !== null;
|
|
8056
8984
|
const panelTarget = typeof appPanel === "object" && appPanel ? appPanel : void 0;
|
|
8057
8985
|
const asSheet = !panelTarget && (appPanel === "sheet" || Boolean(narrow));
|
|
8058
|
-
(0,
|
|
8986
|
+
(0, import_react22.useEffect)(() => {
|
|
8059
8987
|
if (panelApp && !agent.messages.some((m) => m.apps?.some((a) => a.id === panelApp.id))) {
|
|
8060
8988
|
setPanelAppState(void 0);
|
|
8061
8989
|
onAppPanel?.(void 0);
|
|
8062
8990
|
}
|
|
8063
8991
|
}, [agent.messages, panelApp, onAppPanel]);
|
|
8064
8992
|
const drawApp = (app, message) => {
|
|
8065
|
-
const built = panelApp?.id === app.id ? /* @__PURE__ */ (0,
|
|
8993
|
+
const built = panelApp?.id === app.id ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8066
8994
|
McpAppLine,
|
|
8067
8995
|
{
|
|
8068
8996
|
app,
|
|
@@ -8070,7 +8998,7 @@ var AgentChatInner = ({
|
|
|
8070
8998
|
action: L.appBringBack,
|
|
8071
8999
|
onAction: () => setPanelApp(void 0)
|
|
8072
9000
|
}
|
|
8073
|
-
) : /* @__PURE__ */ (0,
|
|
9001
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8074
9002
|
McpAppFrame,
|
|
8075
9003
|
{
|
|
8076
9004
|
app,
|
|
@@ -8083,7 +9011,7 @@ var AgentChatInner = ({
|
|
|
8083
9011
|
);
|
|
8084
9012
|
return renderApp ? renderApp(app, message, built) : built;
|
|
8085
9013
|
};
|
|
8086
|
-
const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ (0,
|
|
9014
|
+
const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8087
9015
|
McpAppFrame,
|
|
8088
9016
|
{
|
|
8089
9017
|
app: panelApp,
|
|
@@ -8095,7 +9023,7 @@ var AgentChatInner = ({
|
|
|
8095
9023
|
},
|
|
8096
9024
|
panelApp.id
|
|
8097
9025
|
) : null;
|
|
8098
|
-
const [compacting, setCompacting] = (0,
|
|
9026
|
+
const [compacting, setCompacting] = (0, import_react22.useState)(false);
|
|
8099
9027
|
const compact = () => {
|
|
8100
9028
|
setCompacting(true);
|
|
8101
9029
|
void agent.compact().finally(() => setCompacting(false));
|
|
@@ -8106,9 +9034,10 @@ var AgentChatInner = ({
|
|
|
8106
9034
|
const Files = components.FilesPanel ?? FilesPanel;
|
|
8107
9035
|
const Approvals = components.ApprovalPrompt ?? ToolApprovalPrompt;
|
|
8108
9036
|
const Elicitations = components.ElicitationPrompt ?? ElicitationPrompt;
|
|
9037
|
+
const Questions = components.QuestionPrompt ?? QuestionPrompt;
|
|
8109
9038
|
const tabNotes = showOtherTabs ? [
|
|
8110
9039
|
agent.remote?.running && L.remoteRunning,
|
|
8111
|
-
agent.remote?.running && agent.approvals.some((a) => a.remote && a.status === "pending") && L.remoteWaitingConsent,
|
|
9040
|
+
agent.remote?.running && (agent.approvals.some((a) => a.remote && a.status === "pending") || (agent.questions ?? []).some((q) => q.remote && q.status === "pending")) && L.remoteWaitingConsent,
|
|
8112
9041
|
agent.remote?.ended === "gone" && L.remoteGone,
|
|
8113
9042
|
agent.sessionBusy && L.sessionBusy(agent.sessionBusy.heldBy)
|
|
8114
9043
|
].filter((t) => typeof t === "string") : [];
|
|
@@ -8116,18 +9045,18 @@ var AgentChatInner = ({
|
|
|
8116
9045
|
const showReplan = agent.replan && agent.replan.mode !== "continue";
|
|
8117
9046
|
const replanFailedEarly = showReplanFailed && agent.replan?.failed === true && agent.steps.length === 0;
|
|
8118
9047
|
const earlyDecisions = showDecisions ? agent.decisions ?? [] : [];
|
|
8119
|
-
const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ (0,
|
|
8120
|
-
agent.planThought.trim() && /* @__PURE__ */ (0,
|
|
8121
|
-
/* @__PURE__ */ (0,
|
|
8122
|
-
/* @__PURE__ */ (0,
|
|
9048
|
+
const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
9049
|
+
agent.planThought.trim() && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("details", { className: "awr-activity__plan", children: [
|
|
9050
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("summary", { children: L.planned }),
|
|
9051
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "awr-activity__thought", children: agent.planThought })
|
|
8123
9052
|
] }),
|
|
8124
|
-
showReplan && /* @__PURE__ */ (0,
|
|
8125
|
-
replanFailedEarly && /* @__PURE__ */ (0,
|
|
8126
|
-
/* @__PURE__ */ (0,
|
|
9053
|
+
showReplan && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
|
|
9054
|
+
replanFailedEarly && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "awr-step__warn", title: agent.replan.error, children: [
|
|
9055
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AlertIcon, { size: 12 }),
|
|
8127
9056
|
" ",
|
|
8128
9057
|
L.replanFailed
|
|
8129
9058
|
] }),
|
|
8130
|
-
earlyDecisions.map((d, i) => /* @__PURE__ */ (0,
|
|
9059
|
+
earlyDecisions.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8131
9060
|
"p",
|
|
8132
9061
|
{
|
|
8133
9062
|
className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
|
|
@@ -8136,8 +9065,8 @@ var AgentChatInner = ({
|
|
|
8136
9065
|
i
|
|
8137
9066
|
))
|
|
8138
9067
|
] }) : void 0;
|
|
8139
|
-
const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ (0,
|
|
8140
|
-
chats && /* @__PURE__ */ (0,
|
|
9068
|
+
const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__header", classNames.header), children: [
|
|
9069
|
+
chats && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8141
9070
|
"button",
|
|
8142
9071
|
{
|
|
8143
9072
|
type: "button",
|
|
@@ -8146,17 +9075,17 @@ var AgentChatInner = ({
|
|
|
8146
9075
|
title: L.showHistory,
|
|
8147
9076
|
"aria-pressed": historyOpen,
|
|
8148
9077
|
onClick: toggleHistory,
|
|
8149
|
-
children: /* @__PURE__ */ (0,
|
|
9078
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(HistoryIcon, { size: 16 })
|
|
8150
9079
|
}
|
|
8151
9080
|
),
|
|
8152
9081
|
slots.headerStart,
|
|
8153
|
-
/* @__PURE__ */ (0,
|
|
8154
|
-
showStatus && /* @__PURE__ */ (0,
|
|
8155
|
-
/* @__PURE__ */ (0,
|
|
8156
|
-
/* @__PURE__ */ (0,
|
|
9082
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-chat__title", children: title }),
|
|
9083
|
+
showStatus && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
|
|
9084
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "awr-status__dot" }),
|
|
9085
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "awr-status__text", children: L.status[agent.status] })
|
|
8157
9086
|
] }),
|
|
8158
|
-
showTotalUsage && /* @__PURE__ */ (0,
|
|
8159
|
-
files && /* @__PURE__ */ (0,
|
|
9087
|
+
showTotalUsage && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { title: L.totalUsage, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
|
|
9088
|
+
files && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8160
9089
|
"button",
|
|
8161
9090
|
{
|
|
8162
9091
|
type: "button",
|
|
@@ -8165,12 +9094,12 @@ var AgentChatInner = ({
|
|
|
8165
9094
|
title: L.showFiles,
|
|
8166
9095
|
"aria-pressed": filesOpen,
|
|
8167
9096
|
onClick: toggleFiles,
|
|
8168
|
-
children: /* @__PURE__ */ (0,
|
|
9097
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FileIcon, { size: 16 })
|
|
8169
9098
|
}
|
|
8170
9099
|
),
|
|
8171
9100
|
slots.headerEnd
|
|
8172
9101
|
] });
|
|
8173
|
-
return /* @__PURE__ */ (0,
|
|
9102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
8174
9103
|
"div",
|
|
8175
9104
|
{
|
|
8176
9105
|
ref: rootRef,
|
|
@@ -8178,8 +9107,16 @@ var AgentChatInner = ({
|
|
|
8178
9107
|
style,
|
|
8179
9108
|
"data-awr-theme": theme === "auto" ? void 0 : theme,
|
|
8180
9109
|
children: [
|
|
8181
|
-
|
|
8182
|
-
|
|
9110
|
+
overlayOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9111
|
+
"div",
|
|
9112
|
+
{
|
|
9113
|
+
className: cx("awr-chat__scrim", classNames.scrim),
|
|
9114
|
+
"aria-hidden": "true",
|
|
9115
|
+
onClick: closeOverlays
|
|
9116
|
+
}
|
|
9117
|
+
),
|
|
9118
|
+
chats && historyOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
|
|
9119
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8183
9120
|
HistoryList,
|
|
8184
9121
|
{
|
|
8185
9122
|
history: {
|
|
@@ -8198,7 +9135,7 @@ var AgentChatInner = ({
|
|
|
8198
9135
|
}
|
|
8199
9136
|
),
|
|
8200
9137
|
slots.sidebar,
|
|
8201
|
-
/* @__PURE__ */ (0,
|
|
9138
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8202
9139
|
"button",
|
|
8203
9140
|
{
|
|
8204
9141
|
type: "button",
|
|
@@ -8209,91 +9146,91 @@ var AgentChatInner = ({
|
|
|
8209
9146
|
}
|
|
8210
9147
|
)
|
|
8211
9148
|
] }),
|
|
8212
|
-
/* @__PURE__ */ (0,
|
|
9149
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__main", classNames.main), children: [
|
|
8213
9150
|
header,
|
|
8214
|
-
/* @__PURE__ */ (0,
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
),
|
|
8293
|
-
/* @__PURE__ */ (0,
|
|
9151
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__body", classNames.body), ref: bodyRef, children: [
|
|
9152
|
+
slots.beforeMessages,
|
|
9153
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9154
|
+
Messages,
|
|
9155
|
+
{
|
|
9156
|
+
messages: agent.messages,
|
|
9157
|
+
empty: emptyState ?? L.emptyState,
|
|
9158
|
+
showActivity,
|
|
9159
|
+
showToolCalls,
|
|
9160
|
+
showUsage,
|
|
9161
|
+
showThoughts,
|
|
9162
|
+
showNotes,
|
|
9163
|
+
showLearned,
|
|
9164
|
+
showTiers,
|
|
9165
|
+
showReplanFailed,
|
|
9166
|
+
showDecisions,
|
|
9167
|
+
showSearchResults,
|
|
9168
|
+
showSubagents,
|
|
9169
|
+
showMedia,
|
|
9170
|
+
showFileChips,
|
|
9171
|
+
files,
|
|
9172
|
+
htmlPreview,
|
|
9173
|
+
onShowFiles: files ? showFiles : void 0,
|
|
9174
|
+
renderFile,
|
|
9175
|
+
renderFileContent,
|
|
9176
|
+
renderMedia,
|
|
9177
|
+
renderSubagent,
|
|
9178
|
+
onStopSubagent: stoppableSubagents ? agent.stopSubagent : void 0,
|
|
9179
|
+
activityOpen,
|
|
9180
|
+
liveExtra,
|
|
9181
|
+
renderContent,
|
|
9182
|
+
renderMessage,
|
|
9183
|
+
renderAttachment,
|
|
9184
|
+
renderToolCall,
|
|
9185
|
+
showApps: appsOn,
|
|
9186
|
+
renderApp: appsOn ? drawApp : void 0,
|
|
9187
|
+
imageViewer,
|
|
9188
|
+
renderImageViewer
|
|
9189
|
+
}
|
|
9190
|
+
),
|
|
9191
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9192
|
+
Approvals,
|
|
9193
|
+
{
|
|
9194
|
+
approvals: agent.pendingApprovals,
|
|
9195
|
+
onApprove: agent.approve,
|
|
9196
|
+
onDeny: agent.deny,
|
|
9197
|
+
showSkillPreview,
|
|
9198
|
+
renderApproval
|
|
9199
|
+
}
|
|
9200
|
+
),
|
|
9201
|
+
showQuestions && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9202
|
+
Questions,
|
|
9203
|
+
{
|
|
9204
|
+
questions: agent.pendingQuestions ?? [],
|
|
9205
|
+
onAnswer: (id, answer) => agent.answerQuestion?.(id, answer),
|
|
9206
|
+
outcomes: agent.questions,
|
|
9207
|
+
renderQuestion
|
|
9208
|
+
}
|
|
9209
|
+
),
|
|
9210
|
+
appsOn && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9211
|
+
AppRequestPrompt,
|
|
9212
|
+
{
|
|
9213
|
+
requests: appHost.requests,
|
|
9214
|
+
onAnswer: appHost.answer,
|
|
9215
|
+
renderRequest: renderAppRequest
|
|
9216
|
+
}
|
|
9217
|
+
),
|
|
9218
|
+
showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9219
|
+
Elicitations,
|
|
9220
|
+
{
|
|
9221
|
+
elicitations,
|
|
9222
|
+
onAnswer: onElicitationAnswer,
|
|
9223
|
+
outcomes: agent.elicitations,
|
|
9224
|
+
renderElicitation
|
|
9225
|
+
}
|
|
9226
|
+
),
|
|
9227
|
+
agent.modelLoad && loading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ModelLoadBar, { load: agent.modelLoad }),
|
|
9228
|
+
slots.afterMessages
|
|
9229
|
+
] }),
|
|
9230
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__footer", classNames.footer), children: [
|
|
8294
9231
|
slots.footerStart,
|
|
8295
|
-
tabNotes.length > 0 && /* @__PURE__ */ (0,
|
|
8296
|
-
showContext !== false && /* @__PURE__ */ (0,
|
|
9232
|
+
tabNotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-tabnote", role: "status", children: tabNotes.map((text2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "awr-tabnote__text", children: text2 }, text2)) }),
|
|
9233
|
+
showContext !== false && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8297
9234
|
ContextMeter,
|
|
8298
9235
|
{
|
|
8299
9236
|
usage: agent.usage,
|
|
@@ -8304,11 +9241,11 @@ var AgentChatInner = ({
|
|
|
8304
9241
|
compacting
|
|
8305
9242
|
}
|
|
8306
9243
|
),
|
|
8307
|
-
composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ (0,
|
|
8308
|
-
/* @__PURE__ */ (0,
|
|
9244
|
+
composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "awr-chat__error", children: [
|
|
9245
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AlertIcon, { size: 14 }),
|
|
8309
9246
|
" ",
|
|
8310
9247
|
agent.error
|
|
8311
|
-
] }) : /* @__PURE__ */ (0,
|
|
9248
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8312
9249
|
Composer2,
|
|
8313
9250
|
{
|
|
8314
9251
|
controller: agent,
|
|
@@ -8324,8 +9261,8 @@ var AgentChatInner = ({
|
|
|
8324
9261
|
] }),
|
|
8325
9262
|
appPanelNode && (panelTarget ? (
|
|
8326
9263
|
// Outside the chat: the theme tokens come with it.
|
|
8327
|
-
(0,
|
|
8328
|
-
/* @__PURE__ */ (0,
|
|
9264
|
+
(0, import_react_dom2.createPortal)(
|
|
9265
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8329
9266
|
"div",
|
|
8330
9267
|
{
|
|
8331
9268
|
className: "awr-theme awr-apppanel",
|
|
@@ -8335,24 +9272,24 @@ var AgentChatInner = ({
|
|
|
8335
9272
|
),
|
|
8336
9273
|
panelTarget
|
|
8337
9274
|
)
|
|
8338
|
-
) : asSheet ? /* @__PURE__ */ (0,
|
|
8339
|
-
/* @__PURE__ */ (0,
|
|
8340
|
-
/* @__PURE__ */ (0,
|
|
9275
|
+
) : asSheet ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
9276
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-sheet__scrim", onClick: () => setPanelApp(void 0) }),
|
|
9277
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
8341
9278
|
"aside",
|
|
8342
9279
|
{
|
|
8343
9280
|
className: "awr-chat__appsheet",
|
|
8344
9281
|
role: "dialog",
|
|
8345
9282
|
"aria-label": L.appFrom(panelApp.server),
|
|
8346
9283
|
children: [
|
|
8347
|
-
/* @__PURE__ */ (0,
|
|
9284
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-sheet__grab" }),
|
|
8348
9285
|
appPanelNode
|
|
8349
9286
|
]
|
|
8350
9287
|
}
|
|
8351
9288
|
)
|
|
8352
|
-
] }) : /* @__PURE__ */ (0,
|
|
8353
|
-
files && filesOpen && /* @__PURE__ */ (0,
|
|
8354
|
-
/* @__PURE__ */ (0,
|
|
8355
|
-
/* @__PURE__ */ (0,
|
|
9289
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("aside", { className: "awr-chat__apppanel", children: appPanelNode })),
|
|
9290
|
+
files && filesOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("aside", { className: cx("awr-chat__files", classNames.files), children: [
|
|
9291
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Files, { files }) }),
|
|
9292
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8356
9293
|
"button",
|
|
8357
9294
|
{
|
|
8358
9295
|
type: "button",
|
|
@@ -8369,7 +9306,7 @@ var AgentChatInner = ({
|
|
|
8369
9306
|
};
|
|
8370
9307
|
|
|
8371
9308
|
// src/components/LearnedSkills.tsx
|
|
8372
|
-
var
|
|
9309
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
8373
9310
|
var LearnedSkills = ({
|
|
8374
9311
|
controller,
|
|
8375
9312
|
lessons,
|
|
@@ -8385,18 +9322,18 @@ var LearnedSkills = ({
|
|
|
8385
9322
|
const c = controller ?? ctx;
|
|
8386
9323
|
const list = lessons ?? c?.learned ?? [];
|
|
8387
9324
|
const forget = onForget === false ? void 0 : onForget ?? c?.forgetSkill;
|
|
8388
|
-
return /* @__PURE__ */ (0,
|
|
8389
|
-
!hideTitle && /* @__PURE__ */ (0,
|
|
8390
|
-
/* @__PURE__ */ (0,
|
|
9325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
|
|
9326
|
+
!hideTitle && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("h3", { className: "awr-notebook__title", children: [
|
|
9327
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BookIcon, { size: 14 }),
|
|
8391
9328
|
" ",
|
|
8392
9329
|
L.notebookTitle,
|
|
8393
|
-
list.length > 0 && /* @__PURE__ */ (0,
|
|
9330
|
+
list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "awr-notebook__count", children: list.length })
|
|
8394
9331
|
] }),
|
|
8395
|
-
list.length === 0 ? /* @__PURE__ */ (0,
|
|
8396
|
-
/* @__PURE__ */ (0,
|
|
8397
|
-
/* @__PURE__ */ (0,
|
|
8398
|
-
l.revision > 1 && /* @__PURE__ */ (0,
|
|
8399
|
-
forget && /* @__PURE__ */ (0,
|
|
9332
|
+
list.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("li", { className: "awr-lesson", children: [
|
|
9333
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "awr-lesson__head", children: [
|
|
9334
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("code", { className: "awr-lesson__name", children: l.name }),
|
|
9335
|
+
l.revision > 1 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
|
|
9336
|
+
forget && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8400
9337
|
"button",
|
|
8401
9338
|
{
|
|
8402
9339
|
type: "button",
|
|
@@ -8404,12 +9341,12 @@ var LearnedSkills = ({
|
|
|
8404
9341
|
title: `${L.notebookForget}: ${l.name}`,
|
|
8405
9342
|
"aria-label": `${L.notebookForget}: ${l.name}`,
|
|
8406
9343
|
onClick: () => void forget(l.name),
|
|
8407
|
-
children: /* @__PURE__ */ (0,
|
|
9344
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(XIcon, { size: 12 })
|
|
8408
9345
|
}
|
|
8409
9346
|
)
|
|
8410
9347
|
] }),
|
|
8411
|
-
/* @__PURE__ */ (0,
|
|
8412
|
-
showSources && l.sources.length > 0 && /* @__PURE__ */ (0,
|
|
9348
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "awr-lesson__when", children: l.description }),
|
|
9349
|
+
showSources && l.sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: "awr-lesson__from", children: [
|
|
8413
9350
|
L.notebookFrom,
|
|
8414
9351
|
" ",
|
|
8415
9352
|
l.sources.join(", ")
|
|
@@ -8419,8 +9356,8 @@ var LearnedSkills = ({
|
|
|
8419
9356
|
};
|
|
8420
9357
|
|
|
8421
9358
|
// src/components/Composer.tsx
|
|
8422
|
-
var
|
|
8423
|
-
var
|
|
9359
|
+
var import_react23 = require("react");
|
|
9360
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
8424
9361
|
var Composer = ({
|
|
8425
9362
|
onSubmit,
|
|
8426
9363
|
busy = false,
|
|
@@ -8429,7 +9366,7 @@ var Composer = ({
|
|
|
8429
9366
|
placeholder = "Ask the agent to do something\u2026",
|
|
8430
9367
|
className
|
|
8431
9368
|
}) => {
|
|
8432
|
-
const [text2, setText] = (0,
|
|
9369
|
+
const [text2, setText] = (0, import_react23.useState)("");
|
|
8433
9370
|
const submit = () => {
|
|
8434
9371
|
const value = text2.trim();
|
|
8435
9372
|
if (!value || busy || disabled) return;
|
|
@@ -8442,7 +9379,7 @@ var Composer = ({
|
|
|
8442
9379
|
submit();
|
|
8443
9380
|
}
|
|
8444
9381
|
};
|
|
8445
|
-
return /* @__PURE__ */ (0,
|
|
9382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
8446
9383
|
"form",
|
|
8447
9384
|
{
|
|
8448
9385
|
className: ["awr-composer", className].filter(Boolean).join(" "),
|
|
@@ -8451,7 +9388,7 @@ var Composer = ({
|
|
|
8451
9388
|
submit();
|
|
8452
9389
|
},
|
|
8453
9390
|
children: [
|
|
8454
|
-
/* @__PURE__ */ (0,
|
|
9391
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
8455
9392
|
"textarea",
|
|
8456
9393
|
{
|
|
8457
9394
|
className: "awr-composer__input",
|
|
@@ -8463,23 +9400,23 @@ var Composer = ({
|
|
|
8463
9400
|
rows: 1
|
|
8464
9401
|
}
|
|
8465
9402
|
),
|
|
8466
|
-
busy ? /* @__PURE__ */ (0,
|
|
9403
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
8467
9404
|
"button",
|
|
8468
9405
|
{
|
|
8469
9406
|
type: "button",
|
|
8470
9407
|
className: "awr-composer__btn awr-composer__btn--stop",
|
|
8471
9408
|
onClick: onStop,
|
|
8472
9409
|
"aria-label": "Stop",
|
|
8473
|
-
children: /* @__PURE__ */ (0,
|
|
9410
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(StopIcon, { size: 18 })
|
|
8474
9411
|
}
|
|
8475
|
-
) : /* @__PURE__ */ (0,
|
|
9412
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
8476
9413
|
"button",
|
|
8477
9414
|
{
|
|
8478
9415
|
type: "submit",
|
|
8479
9416
|
className: "awr-composer__btn",
|
|
8480
9417
|
disabled: disabled || !text2.trim(),
|
|
8481
9418
|
"aria-label": "Send",
|
|
8482
|
-
children: disabled ? /* @__PURE__ */ (0,
|
|
9419
|
+
children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SendIcon, { size: 18 })
|
|
8483
9420
|
}
|
|
8484
9421
|
)
|
|
8485
9422
|
]
|
|
@@ -8488,17 +9425,17 @@ var Composer = ({
|
|
|
8488
9425
|
};
|
|
8489
9426
|
|
|
8490
9427
|
// src/components/PlanView.tsx
|
|
8491
|
-
var
|
|
9428
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
8492
9429
|
var PlanView = ({ plan, showThought = true, className }) => {
|
|
8493
9430
|
if (!plan.steps.length && !plan.thought) return null;
|
|
8494
|
-
return /* @__PURE__ */ (0,
|
|
8495
|
-
showThought && plan.thought.trim() && /* @__PURE__ */ (0,
|
|
8496
|
-
plan.steps.length > 0 && /* @__PURE__ */ (0,
|
|
9431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
|
|
9432
|
+
showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
|
|
9433
|
+
plan.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("li", { className: "awr-plan__step", children: step.description }, step.id)) })
|
|
8497
9434
|
] });
|
|
8498
9435
|
};
|
|
8499
9436
|
|
|
8500
9437
|
// src/components/ApprovalModeSwitch.tsx
|
|
8501
|
-
var
|
|
9438
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
8502
9439
|
var DEFAULT_LABELS = {
|
|
8503
9440
|
autopilot: "Autopilot",
|
|
8504
9441
|
"ask-writes": "Ask before changes",
|
|
@@ -8518,13 +9455,13 @@ var ApprovalModeSwitch = ({
|
|
|
8518
9455
|
labels,
|
|
8519
9456
|
disabled,
|
|
8520
9457
|
className
|
|
8521
|
-
}) => /* @__PURE__ */ (0,
|
|
9458
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8522
9459
|
"div",
|
|
8523
9460
|
{
|
|
8524
9461
|
className: ["awr-modeswitch", className].filter(Boolean).join(" "),
|
|
8525
9462
|
role: "radiogroup",
|
|
8526
9463
|
"aria-label": "Tool consent",
|
|
8527
|
-
children: modes.map((m) => /* @__PURE__ */ (0,
|
|
9464
|
+
children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
8528
9465
|
"button",
|
|
8529
9466
|
{
|
|
8530
9467
|
type: "button",
|
|
@@ -8542,8 +9479,8 @@ var ApprovalModeSwitch = ({
|
|
|
8542
9479
|
);
|
|
8543
9480
|
|
|
8544
9481
|
// src/components/ApiKeyForm.tsx
|
|
8545
|
-
var
|
|
8546
|
-
var
|
|
9482
|
+
var import_react24 = require("react");
|
|
9483
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
8547
9484
|
var ApiKeyForm = ({
|
|
8548
9485
|
credentials,
|
|
8549
9486
|
credentialRef,
|
|
@@ -8552,10 +9489,10 @@ var ApiKeyForm = ({
|
|
|
8552
9489
|
onChange,
|
|
8553
9490
|
className
|
|
8554
9491
|
}) => {
|
|
8555
|
-
const [value, setValue] = (0,
|
|
8556
|
-
const [present, setPresent] = (0,
|
|
8557
|
-
const [busy, setBusy] = (0,
|
|
8558
|
-
(0,
|
|
9492
|
+
const [value, setValue] = (0, import_react24.useState)("");
|
|
9493
|
+
const [present, setPresent] = (0, import_react24.useState)(false);
|
|
9494
|
+
const [busy, setBusy] = (0, import_react24.useState)(false);
|
|
9495
|
+
(0, import_react24.useEffect)(() => {
|
|
8559
9496
|
let active = true;
|
|
8560
9497
|
credentials.hasKey(credentialRef).then((has) => {
|
|
8561
9498
|
if (active) setPresent(has);
|
|
@@ -8587,16 +9524,16 @@ var ApiKeyForm = ({
|
|
|
8587
9524
|
setBusy(false);
|
|
8588
9525
|
}
|
|
8589
9526
|
};
|
|
8590
|
-
return /* @__PURE__ */ (0,
|
|
8591
|
-
/* @__PURE__ */ (0,
|
|
9527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
|
|
9528
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "awr-keyform__label", children: [
|
|
8592
9529
|
label,
|
|
8593
|
-
present && /* @__PURE__ */ (0,
|
|
8594
|
-
/* @__PURE__ */ (0,
|
|
9530
|
+
present && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "awr-keyform__saved", children: [
|
|
9531
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckIcon, { size: 12 }),
|
|
8595
9532
|
" stored, encrypted"
|
|
8596
9533
|
] })
|
|
8597
9534
|
] }),
|
|
8598
|
-
/* @__PURE__ */ (0,
|
|
8599
|
-
/* @__PURE__ */ (0,
|
|
9535
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "awr-keyform__row", children: [
|
|
9536
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
8600
9537
|
"input",
|
|
8601
9538
|
{
|
|
8602
9539
|
className: "awr-keyform__input",
|
|
@@ -8614,7 +9551,7 @@ var ApiKeyForm = ({
|
|
|
8614
9551
|
disabled: busy
|
|
8615
9552
|
}
|
|
8616
9553
|
),
|
|
8617
|
-
/* @__PURE__ */ (0,
|
|
9554
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
8618
9555
|
"button",
|
|
8619
9556
|
{
|
|
8620
9557
|
type: "button",
|
|
@@ -8624,7 +9561,7 @@ var ApiKeyForm = ({
|
|
|
8624
9561
|
children: "Save"
|
|
8625
9562
|
}
|
|
8626
9563
|
),
|
|
8627
|
-
present && /* @__PURE__ */ (0,
|
|
9564
|
+
present && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
8628
9565
|
"button",
|
|
8629
9566
|
{
|
|
8630
9567
|
type: "button",
|
|
@@ -8645,6 +9582,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8645
9582
|
APP_DEFAULT_HEIGHT,
|
|
8646
9583
|
APP_MAX_HEIGHT,
|
|
8647
9584
|
APP_MIN_HEIGHT,
|
|
9585
|
+
ASK_USER_TOOL_NAME,
|
|
8648
9586
|
AgentChat,
|
|
8649
9587
|
AgentComposer,
|
|
8650
9588
|
AgentLabelsProvider,
|
|
@@ -8660,6 +9598,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8660
9598
|
ContextMeter,
|
|
8661
9599
|
ElicitationPrompt,
|
|
8662
9600
|
FILE_PREVIEW_CHARS,
|
|
9601
|
+
FOLLOW_LEAVE_PX,
|
|
9602
|
+
FOLLOW_REJOIN_PX,
|
|
8663
9603
|
FRAME_MAX_HEIGHT,
|
|
8664
9604
|
FRAME_MIN_HEIGHT,
|
|
8665
9605
|
FileChip,
|
|
@@ -8667,6 +9607,9 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8667
9607
|
FilesPanel,
|
|
8668
9608
|
GeneratedMedia,
|
|
8669
9609
|
HTML_PREVIEW_MAX_CHARS,
|
|
9610
|
+
ImageThumb,
|
|
9611
|
+
ImageViewer,
|
|
9612
|
+
ImageViewerProvider,
|
|
8670
9613
|
ImagesNotSupportedError,
|
|
8671
9614
|
IndexedDBStore,
|
|
8672
9615
|
LearnedSkills,
|
|
@@ -8703,6 +9646,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8703
9646
|
MessageList,
|
|
8704
9647
|
ModelLoadBar,
|
|
8705
9648
|
PlanView,
|
|
9649
|
+
QUESTION_TIMEOUT_MS,
|
|
9650
|
+
QuestionPrompt,
|
|
8706
9651
|
SandboxedFrame,
|
|
8707
9652
|
SessionBusyError,
|
|
8708
9653
|
SourceView,
|
|
@@ -8729,6 +9674,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8729
9674
|
appMessageTextOf,
|
|
8730
9675
|
appMimeTypeOf,
|
|
8731
9676
|
appSamplingErrorOf,
|
|
9677
|
+
askUserOutputKept,
|
|
9678
|
+
askUserWith,
|
|
8732
9679
|
attachmentKindOf,
|
|
8733
9680
|
attachmentRefusal,
|
|
8734
9681
|
buildMcpAppDocument,
|
|
@@ -8741,6 +9688,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8741
9688
|
createApprovalQueue,
|
|
8742
9689
|
createFileTools,
|
|
8743
9690
|
createInitialAgentState,
|
|
9691
|
+
createQuestionQueue,
|
|
8744
9692
|
createRunControl,
|
|
8745
9693
|
createSubagentTool,
|
|
8746
9694
|
createWebLLMEngine,
|
|
@@ -8758,9 +9706,12 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8758
9706
|
fileKindOf,
|
|
8759
9707
|
fileNameOf,
|
|
8760
9708
|
filterCommands,
|
|
9709
|
+
followsAfterResize,
|
|
9710
|
+
followsAfterScroll,
|
|
8761
9711
|
formatCountdown,
|
|
8762
9712
|
formatElapsed,
|
|
8763
9713
|
grantedAppCsp,
|
|
9714
|
+
imageExtensionOf,
|
|
8764
9715
|
isMcpAppSandboxMessage,
|
|
8765
9716
|
isWebGPUAvailable,
|
|
8766
9717
|
lessonsOf,
|
|
@@ -8784,6 +9735,9 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8784
9735
|
pendingApprovalsOf,
|
|
8785
9736
|
postStorageChange,
|
|
8786
9737
|
preloadWebLLMModel,
|
|
9738
|
+
questionChoiceOf,
|
|
9739
|
+
questionOtherOf,
|
|
9740
|
+
questionTimeoutOf,
|
|
8787
9741
|
resolveAppDownload,
|
|
8788
9742
|
sandboxTokens,
|
|
8789
9743
|
sandboxedCsp,
|
|
@@ -8802,6 +9756,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8802
9756
|
useAgentContext,
|
|
8803
9757
|
useChatHistory,
|
|
8804
9758
|
useCredentials,
|
|
9759
|
+
useFollowScroll,
|
|
8805
9760
|
useLabels,
|
|
8806
9761
|
useLocalModel,
|
|
8807
9762
|
useMcpAppHost,
|
|
@@ -8813,6 +9768,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
|
|
|
8813
9768
|
webSearchOf,
|
|
8814
9769
|
withAttachments,
|
|
8815
9770
|
withCspFirst,
|
|
8816
|
-
withPolicyFirst
|
|
9771
|
+
withPolicyFirst,
|
|
9772
|
+
withoutOwnWords
|
|
8817
9773
|
});
|
|
8818
9774
|
//# sourceMappingURL=index.cjs.map
|