@dudko.dev/agent-web-react 0.0.34 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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,
@@ -96,6 +97,8 @@ __export(src_exports, {
96
97
  MessageList: () => MessageList,
97
98
  ModelLoadBar: () => ModelLoadBar,
98
99
  PlanView: () => PlanView,
100
+ QUESTION_TIMEOUT_MS: () => QUESTION_TIMEOUT_MS,
101
+ QuestionPrompt: () => QuestionPrompt,
99
102
  SandboxedFrame: () => SandboxedFrame,
100
103
  SessionBusyError: () => import_agent_web8.SessionBusyError,
101
104
  SourceView: () => SourceView,
@@ -122,6 +125,8 @@ __export(src_exports, {
122
125
  appMessageTextOf: () => appMessageTextOf,
123
126
  appMimeTypeOf: () => appMimeTypeOf,
124
127
  appSamplingErrorOf: () => appSamplingErrorOf,
128
+ askUserOutputKept: () => askUserOutputKept,
129
+ askUserWith: () => askUserWith,
125
130
  attachmentKindOf: () => attachmentKindOf,
126
131
  attachmentRefusal: () => attachmentRefusal,
127
132
  buildMcpAppDocument: () => buildMcpAppDocument,
@@ -134,6 +139,7 @@ __export(src_exports, {
134
139
  createApprovalQueue: () => createApprovalQueue,
135
140
  createFileTools: () => import_agent_web8.createFileTools,
136
141
  createInitialAgentState: () => createInitialAgentState,
142
+ createQuestionQueue: () => createQuestionQueue,
137
143
  createRunControl: () => import_agent_web8.createRunControl,
138
144
  createSubagentTool: () => import_agent_web8.createSubagentTool,
139
145
  createWebLLMEngine: () => createWebLLMEngine,
@@ -170,6 +176,8 @@ __export(src_exports, {
170
176
  mcpAppSandboxShellCsp: () => mcpAppSandboxShellCsp,
171
177
  mcpAppSandboxTarget: () => mcpAppSandboxTarget,
172
178
  mediaFamilyOf: () => mediaFamilyOf,
179
+ menuKeyTarget: () => menuKeyTarget,
180
+ menuSections: () => menuSections,
173
181
  mergeChatRecord: () => mergeChatRecord,
174
182
  mergeLabels: () => mergeLabels,
175
183
  newChatId: () => newChatId,
@@ -180,6 +188,9 @@ __export(src_exports, {
180
188
  pendingApprovalsOf: () => pendingApprovalsOf,
181
189
  postStorageChange: () => import_agent_web8.postStorageChange,
182
190
  preloadWebLLMModel: () => import_agent_web8.preloadWebLLMModel,
191
+ questionChoiceOf: () => questionChoiceOf,
192
+ questionOtherOf: () => questionOtherOf,
193
+ questionTimeoutOf: () => questionTimeoutOf,
183
194
  resolveAppDownload: () => resolveAppDownload,
184
195
  sandboxTokens: () => sandboxTokens,
185
196
  sandboxedCsp: () => sandboxedCsp,
@@ -210,7 +221,8 @@ __export(src_exports, {
210
221
  webSearchOf: () => webSearchOf,
211
222
  withAttachments: () => withAttachments,
212
223
  withCspFirst: () => withCspFirst,
213
- withPolicyFirst: () => withPolicyFirst
224
+ withPolicyFirst: () => withPolicyFirst,
225
+ withoutOwnWords: () => withoutOwnWords
214
226
  });
215
227
  module.exports = __toCommonJS(src_exports);
216
228
 
@@ -257,6 +269,127 @@ var createApprovalQueue = () => {
257
269
  };
258
270
  };
259
271
 
272
+ // src/questions.ts
273
+ var ASK_USER_TOOL_NAME = "ask_user";
274
+ var QUESTION_TIMEOUT_MS = 3e5;
275
+ var TIMER_MAX_MS = 2147483647;
276
+ var questionTimeoutOf = (askUser) => {
277
+ if (!askUser) return void 0;
278
+ const raw = askUser === true ? void 0 : askUser.timeoutMs;
279
+ if (raw === void 0 || raw === null) return QUESTION_TIMEOUT_MS;
280
+ if (typeof raw !== "number" || !(raw > 0) || raw > TIMER_MAX_MS) return void 0;
281
+ return Math.max(1, Math.floor(raw));
282
+ };
283
+ var askUserWith = (askUser, handler) => {
284
+ if (!askUser) return askUser;
285
+ if (askUser === true) return { onQuestion: handler };
286
+ return askUser.onQuestion ? askUser : { ...askUser, onQuestion: handler };
287
+ };
288
+ var DECLINED = { declined: true };
289
+ var createQuestionQueue = (options = {}) => {
290
+ const now = options.now ?? Date.now;
291
+ const waiting = /* @__PURE__ */ new Map();
292
+ let disposed = false;
293
+ const list = () => [...waiting.values()].map((w) => w.question);
294
+ const changed = () => {
295
+ if (!disposed) options.onChange?.(list());
296
+ };
297
+ const handler = (request, ctx) => new Promise((resolve) => {
298
+ const signal = ctx?.signal;
299
+ if (disposed || signal?.aborted || waiting.has(request.id)) {
300
+ resolve(DECLINED);
301
+ return;
302
+ }
303
+ const onAbort = () => {
304
+ if (waiting.get(request.id)?.settle !== settle) return;
305
+ settle(DECLINED);
306
+ changed();
307
+ };
308
+ const settle = (answer) => {
309
+ waiting.delete(request.id);
310
+ signal?.removeEventListener("abort", onAbort);
311
+ resolve(answer);
312
+ };
313
+ signal?.addEventListener("abort", onAbort, { once: true });
314
+ const timeoutMs = typeof options.timeoutMs === "function" ? options.timeoutMs() : options.timeoutMs;
315
+ waiting.set(request.id, {
316
+ question: {
317
+ ...request,
318
+ options: request.options.map((o) => ({ ...o })),
319
+ ...timeoutMs !== void 0 ? { expiresAt: now() + timeoutMs } : {}
320
+ },
321
+ settle
322
+ });
323
+ changed();
324
+ });
325
+ return {
326
+ handler,
327
+ pending: list,
328
+ answer: (id, answer) => {
329
+ const entry = waiting.get(id);
330
+ if (!entry) return false;
331
+ entry.settle(answer);
332
+ changed();
333
+ return true;
334
+ },
335
+ cancel: (match) => {
336
+ let any = false;
337
+ for (const entry of [...waiting.values()]) {
338
+ if (match && !match(entry.question)) continue;
339
+ entry.settle(DECLINED);
340
+ any = true;
341
+ }
342
+ if (any) changed();
343
+ },
344
+ dispose: () => {
345
+ disposed = true;
346
+ for (const entry of [...waiting.values()]) entry.settle(DECLINED);
347
+ }
348
+ };
349
+ };
350
+ var questionChoiceOf = (question, picked) => {
351
+ const chosen = question.options.map((o) => o.label).filter((label) => picked.includes(label));
352
+ if (chosen.length === 0) return void 0;
353
+ return { choice: question.multiple ? chosen : chosen.slice(0, 1) };
354
+ };
355
+ var questionOtherOf = (question, text2) => question.allowOther && typeof text2 === "string" && text2.trim() ? { other: text2.trim() } : void 0;
356
+ var LABELS_ONLY = [
357
+ "The user chose: ",
358
+ "The user chose not to answer.",
359
+ "The user did not answer in time.",
360
+ "The question could not be put to the user",
361
+ "You have already asked the user "
362
+ ];
363
+ var askUserOutputKept = (output, ok) => (
364
+ // A failed call is about the model's own arguments (a bad question): nobody was asked.
365
+ !ok || typeof output === "string" && LABELS_ONLY.some((start) => output.startsWith(start))
366
+ );
367
+ var withoutOutput = (call) => {
368
+ if (call.name !== ASK_USER_TOOL_NAME || askUserOutputKept(call.output, call.ok)) return call;
369
+ const { output: _dropped, ...rest } = call;
370
+ void _dropped;
371
+ return rest;
372
+ };
373
+ var withoutOwnWords = (event) => {
374
+ switch (event.type) {
375
+ case "step.tool-result": {
376
+ const cleaned = withoutOutput(event);
377
+ return cleaned === event ? event : { ...cleaned, output: void 0 };
378
+ }
379
+ case "step.complete": {
380
+ const calls = event.result.toolCalls;
381
+ const cleaned = calls.map(withoutOutput);
382
+ return cleaned.every((c, i) => c === calls[i]) ? event : { ...event, result: { ...event.result, toolCalls: cleaned } };
383
+ }
384
+ case "subagent.event": {
385
+ const inner = withoutOwnWords(event.event);
386
+ return inner === event.event ? event : { ...event, event: inner };
387
+ }
388
+ default:
389
+ return event;
390
+ }
391
+ };
392
+
260
393
  // src/state.ts
261
394
  var import_agent_web = require("@dudko.dev/agent-web");
262
395
  var approxTokens = (value) => {
@@ -404,6 +537,35 @@ var answerElicitation = (state, event, stepId) => {
404
537
  ]
405
538
  };
406
539
  };
540
+ var addQuestion = (state, event, extra) => state.questions?.some((q) => q.id === event.id) ? state : {
541
+ ...state,
542
+ questions: [
543
+ ...state.questions ?? [],
544
+ {
545
+ id: event.id,
546
+ question: event.question,
547
+ options: event.options.map((o) => ({ ...o })),
548
+ multiple: event.multiple,
549
+ allowOther: event.allowOther,
550
+ ...extra.stepId ? { stepId: extra.stepId } : {},
551
+ ...extra.subagent ? { subagent: extra.subagent } : {},
552
+ ...extra.remote ? { remote: true } : {},
553
+ status: "pending"
554
+ }
555
+ ]
556
+ };
557
+ var answerQuestion = (state, event) => state.questions?.some((q) => q.id === event.id) ? {
558
+ ...state,
559
+ questions: state.questions.map(
560
+ (q) => q.id === event.id ? {
561
+ ...q,
562
+ status: event.action,
563
+ automatic: event.automatic,
564
+ ...event.action === "choice" && event.choice ? { choice: [...event.choice] } : {},
565
+ ...event.reason ? { reason: event.reason } : {}
566
+ } : q
567
+ )
568
+ } : state;
407
569
  var patchSubagent = (subagents, id, fn) => subagents.map((s) => s.id === id ? fn(s) : s);
408
570
  var runningStepId = (steps) => [...steps].reverse().find((s) => s.status === "running")?.id;
409
571
  var applySubagentEvent = (view, event) => {
@@ -636,6 +798,25 @@ var applySubagent = (state, event, ancestors, ctx) => {
636
798
  inner,
637
799
  known.subagents.find((s) => s.id === event.id)?.stepId
638
800
  );
801
+ // A helper (or a subagent the host defined) asks the person through the run's handler:
802
+ // the question is the person's to answer, like the run's own, marked with who asks.
803
+ case "user.question-asked": {
804
+ const asker = inner.subagent ?? { id: event.id, depth: ancestors.length + 1 };
805
+ const node = known.subagents.find((s) => s.id === asker.id);
806
+ return addQuestion(known, inner, {
807
+ ...ctx.remote ? { remote: true } : {},
808
+ // The helper's own step ids mean nothing here: the step that delegated it does.
809
+ stepId: (node ?? known.subagents.find((s) => s.id === event.id))?.stepId,
810
+ subagent: {
811
+ id: asker.id,
812
+ depth: asker.depth,
813
+ ...node ? { name: node.name } : {},
814
+ ...node?.role ? { role: node.role } : {}
815
+ }
816
+ });
817
+ }
818
+ case "user.question-answered":
819
+ return answerQuestion(known, inner);
639
820
  // What a subagent generated is in the same workspace: it shows in the turn (its step
640
821
  // ids are its own, so it is tied to no step here).
641
822
  case "media.generated":
@@ -1097,6 +1278,15 @@ var applyEvent = (state, event, ctx) => {
1097
1278
  });
1098
1279
  case "mcp.elicitation-answered":
1099
1280
  return answerElicitation(state, event, runningStepId(state.steps));
1281
+ case "user.question-asked":
1282
+ return addQuestion(state, event, {
1283
+ // Asked in the tab that runs the agent: shown here, answered there only.
1284
+ ...ctx.remote ? { remote: true } : {},
1285
+ stepId: event.step?.id,
1286
+ ...event.subagent ? { subagent: event.subagent } : {}
1287
+ });
1288
+ case "user.question-answered":
1289
+ return answerQuestion(state, event);
1100
1290
  case "tool.approval-requested":
1101
1291
  return {
1102
1292
  ...state,
@@ -1228,6 +1418,12 @@ var applyEvent = (state, event, ctx) => {
1228
1418
  (e) => e.status === "pending" ? { ...e, status: "cancelled", automatic: true, reason: "stopped" } : e
1229
1419
  )
1230
1420
  } : {},
1421
+ // Nobody is asked any more once the run has stopped.
1422
+ ...state.questions ? {
1423
+ questions: state.questions.map(
1424
+ (q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
1425
+ )
1426
+ } : {},
1231
1427
  messages: finalizeAssistant(
1232
1428
  state.messages,
1233
1429
  state.finalText || "Stopped.",
@@ -1346,8 +1542,9 @@ var agentStateReducer = (state, action) => {
1346
1542
  return { ...state, remote };
1347
1543
  }
1348
1544
  case "event": {
1545
+ const event = withoutOwnWords(action.event);
1349
1546
  const next = syncRunMessage(
1350
- applyEvent(state, action.event, {
1547
+ applyEvent(state, event, {
1351
1548
  at: action.at,
1352
1549
  attachments: action.attachments,
1353
1550
  ...action.remote ? { remote: true } : {},
@@ -1355,7 +1552,7 @@ var agentStateReducer = (state, action) => {
1355
1552
  })
1356
1553
  );
1357
1554
  const cap = action.maxEvents ?? 200;
1358
- const events = cap > 0 ? [...state.events, action.event].slice(-cap) : [...state.events, action.event];
1555
+ const events = cap > 0 ? [...state.events, event].slice(-cap) : [...state.events, event];
1359
1556
  return { ...next, events };
1360
1557
  }
1361
1558
  case "undelivered":
@@ -1436,6 +1633,13 @@ var useAgent = (config, options = {}) => {
1436
1633
  (decision) => approvals.settleAll(decision),
1437
1634
  [approvals]
1438
1635
  );
1636
+ const [pendingQuestions, setPendingQuestions] = (0, import_react.useState)([]);
1637
+ const [questionQueue] = (0, import_react.useState)(
1638
+ () => createQuestionQueue({
1639
+ timeoutMs: () => questionTimeoutOf(configRef.current.askUser),
1640
+ onChange: setPendingQuestions
1641
+ })
1642
+ );
1439
1643
  const uiOnRequest = (0, import_react.useCallback)(
1440
1644
  (req2, ctx) => (req2.app ? appApprovals : approvals).handler(req2, ctx),
1441
1645
  [approvals, appApprovals]
@@ -1470,10 +1674,12 @@ var useAgent = (config, options = {}) => {
1470
1674
  return;
1471
1675
  }
1472
1676
  const routeApprovals = optionsRef.current.approvals !== false && !cfg.toolApproval?.onRequest;
1473
- const built = routeApprovals ? {
1677
+ const askUser = optionsRef.current.questions !== false ? askUserWith(cfg.askUser, questionQueue.handler) : cfg.askUser;
1678
+ const built = {
1474
1679
  ...cfg,
1475
- toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest }
1476
- } : cfg;
1680
+ ...routeApprovals ? { toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest } } : {},
1681
+ ...askUser !== cfg.askUser ? { askUser } : {}
1682
+ };
1477
1683
  let cancelled = false;
1478
1684
  setBuildStatus({ status: "initializing" });
1479
1685
  (0, import_agent_web2.createAgent)(built).then((agent) => {
@@ -1546,8 +1752,9 @@ var useAgent = (config, options = {}) => {
1546
1752
  abortRef.current?.abort();
1547
1753
  settleAll({ approved: false, reason: "the view was closed" });
1548
1754
  appApprovals.settleAll({ approved: false, reason: "the view was closed" });
1755
+ questionQueue.dispose();
1549
1756
  },
1550
- [settleAll, appApprovals]
1757
+ [settleAll, appApprovals, questionQueue]
1551
1758
  );
1552
1759
  const runRef = (0, import_react.useRef)(void 0);
1553
1760
  const run = (0, import_react.useCallback)(
@@ -1615,6 +1822,7 @@ var useAgent = (config, options = {}) => {
1615
1822
  startedRef.current = false;
1616
1823
  controlRef.current = void 0;
1617
1824
  settleAll({ approved: false, reason: "the run ended" });
1825
+ questionQueue.cancel();
1618
1826
  dispatch({ type: "status", ...buildStatusRef.current });
1619
1827
  if (stopped && !began && shownGoal.trim()) left = [shownGoal, ...left];
1620
1828
  if (left.length > 0) {
@@ -1629,7 +1837,7 @@ var useAgent = (config, options = {}) => {
1629
1837
  }
1630
1838
  }
1631
1839
  },
1632
- [settleAll]
1840
+ [settleAll, questionQueue]
1633
1841
  );
1634
1842
  runRef.current = run;
1635
1843
  const send = (0, import_react.useCallback)((text2) => controlRef.current?.send(text2) ?? false, []);
@@ -1665,7 +1873,12 @@ var useAgent = (config, options = {}) => {
1665
1873
  const stop = (0, import_react.useCallback)(() => {
1666
1874
  abortRef.current?.abort();
1667
1875
  settleAll({ approved: false, reason: "stopped by the user" });
1668
- }, [settleAll]);
1876
+ questionQueue.cancel();
1877
+ }, [settleAll, questionQueue]);
1878
+ const answerQuestion2 = (0, import_react.useCallback)(
1879
+ (id, answer) => questionQueue.answer(id, answer),
1880
+ [questionQueue]
1881
+ );
1669
1882
  const reset = (0, import_react.useCallback)(() => {
1670
1883
  dispatch({ type: "reset" });
1671
1884
  void configRef.current.memory?.clear(sessionRef.current).catch(() => {
@@ -1790,6 +2003,8 @@ var useAgent = (config, options = {}) => {
1790
2003
  pendingApprovals: pendingApprovalsOf(state),
1791
2004
  approve,
1792
2005
  deny,
2006
+ pendingQuestions,
2007
+ answerQuestion: answerQuestion2,
1793
2008
  approvalMode,
1794
2009
  setApprovalMode,
1795
2010
  approveAppToolCall,
@@ -2486,6 +2701,31 @@ var attachmentRefusal = (kind, caps, canConvertPdf = false) => {
2486
2701
  }
2487
2702
  return void 0;
2488
2703
  };
2704
+ var menuSections = (options) => {
2705
+ const out = [];
2706
+ for (const option of options) {
2707
+ const section = option.section || void 0;
2708
+ const last = out[out.length - 1];
2709
+ if (last && last.section === section) last.options.push(option);
2710
+ else out.push({ ...section ? { section } : {}, options: [option] });
2711
+ }
2712
+ return out;
2713
+ };
2714
+ var menuKeyTarget = (key, index, count) => {
2715
+ if (count <= 0) return void 0;
2716
+ switch (key) {
2717
+ case "ArrowDown":
2718
+ return index < 0 ? 0 : (index + 1) % count;
2719
+ case "ArrowUp":
2720
+ return index < 0 ? count - 1 : (index - 1 + count) % count;
2721
+ case "Home":
2722
+ return 0;
2723
+ case "End":
2724
+ return count - 1;
2725
+ default:
2726
+ return void 0;
2727
+ }
2728
+ };
2489
2729
  var formatElapsed = (ms) => {
2490
2730
  const s = Math.max(0, Math.floor(ms / 1e3));
2491
2731
  if (s < 60) return `${s}s`;
@@ -2806,6 +3046,25 @@ var defaultLabels = {
2806
3046
  "no-tool-call": "no tool call was in progress"
2807
3047
  },
2808
3048
  elicitationDismiss: "Dismiss",
3049
+ questionLead: "The agent asks you",
3050
+ questionLeadHelper: (role) => role ? `The helper \u201C${role}\u201D asks you` : "A helper the agent started asks you",
3051
+ questionCount: (index, total) => `${index} of ${total}`,
3052
+ questionSeveral: "Pick one or more, then Send.",
3053
+ questionSend: "Send",
3054
+ questionOther: "Other\u2026",
3055
+ questionOtherLabel: "Your answer",
3056
+ questionSkip: "Skip",
3057
+ questionExpiresIn: (time) => `If you do not answer, the agent decides by itself in ${time}`,
3058
+ questionRemote: "Answered in the other tab, where the agent is running.",
3059
+ questionAutomatic: (reason) => `The agent went on without your answer: ${reason}.`,
3060
+ questionReasons: {
3061
+ timeout: "nobody answered in time",
3062
+ stopped: "the run was stopped",
3063
+ "handler-error": "the question could not be shown",
3064
+ "invalid-answer": "the answer did not fit the question",
3065
+ "cannot-park": "the question could not wait here"
3066
+ },
3067
+ questionDismiss: "Dismiss",
2809
3068
  appFrom: (server) => `App from server \u201C${server}\u201D`,
2810
3069
  appSandboxed: "sandboxed",
2811
3070
  appSandboxedOrigin: "sandboxed on its own origin",
@@ -2897,6 +3156,7 @@ var NESTED = [
2897
3156
  "decisionReasons",
2898
3157
  "elicitationErrors",
2899
3158
  "elicitationReasons",
3159
+ "questionReasons",
2900
3160
  "fileKinds",
2901
3161
  "appSandboxReasons"
2902
3162
  ];
@@ -3188,7 +3448,7 @@ var formatCountdown = (ms) => {
3188
3448
  };
3189
3449
 
3190
3450
  // src/components/AgentChat.tsx
3191
- var import_react21 = require("react");
3451
+ var import_react22 = require("react");
3192
3452
  var import_react_dom2 = require("react-dom");
3193
3453
 
3194
3454
  // src/hooks/use-follow-scroll.ts
@@ -5276,6 +5536,34 @@ var thinkingDefaults = (l) => [
5276
5536
  ];
5277
5537
  var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
5278
5538
  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 });
5539
+ var useMenuKeys = (open, menuRef, chipRef, close) => {
5540
+ (0, import_react12.useEffect)(() => {
5541
+ if (!open) return;
5542
+ const menu = menuRef.current;
5543
+ const rows = menu ? [...menu.querySelectorAll('[role^="menuitem"]')] : [];
5544
+ (rows.find((r) => r.getAttribute("aria-checked") === "true") ?? rows[0])?.focus();
5545
+ }, [open, menuRef]);
5546
+ return (e) => {
5547
+ const menu = menuRef.current;
5548
+ if (!menu) return;
5549
+ if (e.key === "Escape") {
5550
+ e.preventDefault();
5551
+ close();
5552
+ chipRef.current?.focus();
5553
+ return;
5554
+ }
5555
+ const rows = [...menu.querySelectorAll('[role^="menuitem"]')];
5556
+ const to = menuKeyTarget(
5557
+ e.key,
5558
+ rows.indexOf(document.activeElement),
5559
+ rows.length
5560
+ );
5561
+ if (to === void 0) return;
5562
+ e.preventDefault();
5563
+ rows[to].focus();
5564
+ };
5565
+ };
5566
+ var opensMenu = (key) => key === "ArrowDown" || key === "ArrowUp";
5279
5567
  var attachSeq = 0;
5280
5568
  var useIsoLayoutEffect3 = typeof window === "undefined" ? import_react12.useEffect : import_react12.useLayoutEffect;
5281
5569
  var useMenuPlacement = (open, anchor, align) => {
@@ -5367,6 +5655,10 @@ var AgentComposer = ({
5367
5655
  const rootRef = (0, import_react12.useRef)(null);
5368
5656
  const modelRef = (0, import_react12.useRef)(null);
5369
5657
  const modeRef = (0, import_react12.useRef)(null);
5658
+ const modelChipRef = (0, import_react12.useRef)(null);
5659
+ const modeChipRef = (0, import_react12.useRef)(null);
5660
+ const modelMenuRef = (0, import_react12.useRef)(null);
5661
+ const modeMenuRef = (0, import_react12.useRef)(null);
5370
5662
  const [dropRect, setDropRect] = (0, import_react12.useState)();
5371
5663
  const [compactBar, setCompactBar] = (0, import_react12.useState)(false);
5372
5664
  (0, import_react12.useEffect)(() => {
@@ -5495,6 +5787,9 @@ ${draftText}` : draftText);
5495
5787
  const commandsStyle = useMenuPlacement(paletteOpen, rootRef, "stretch");
5496
5788
  const modelStyle = useMenuPlacement(menu === "model", modelRef, "left");
5497
5789
  const modeStyle = useMenuPlacement(menu === "mode", modeRef, "right");
5790
+ const closeMenu = () => setMenu(void 0);
5791
+ const modelMenuKeys = useMenuKeys(menu === "model", modelMenuRef, modelChipRef, closeMenu);
5792
+ const modeMenuKeys = useMenuKeys(menu === "mode", modeMenuRef, modeChipRef, closeMenu);
5498
5793
  (0, import_react12.useEffect)(() => setActive(0), [text2, menu]);
5499
5794
  (0, import_react12.useEffect)(() => {
5500
5795
  if (!menu) return;
@@ -5952,8 +6247,15 @@ ${draftText}` : draftText);
5952
6247
  "button",
5953
6248
  {
5954
6249
  type: "button",
6250
+ ref: modelChipRef,
5955
6251
  className: "awr-tchip awr-tchip--btn",
5956
6252
  onClick: () => setMenu(menu === "model" ? void 0 : "model"),
6253
+ onKeyDown: (e) => {
6254
+ if (menu !== "model" && opensMenu(e.key)) {
6255
+ e.preventDefault();
6256
+ setMenu("model");
6257
+ }
6258
+ },
5957
6259
  "aria-haspopup": "menu",
5958
6260
  "aria-expanded": menu === "model",
5959
6261
  title: [model?.label, thinkingLabel].filter(Boolean).join(" \xB7 "),
@@ -5963,47 +6265,81 @@ ${draftText}` : draftText);
5963
6265
  ]
5964
6266
  }
5965
6267
  ),
5966
- menu === "model" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-menu awr-menu--pop", style: modelStyle, role: "menu", children: [
5967
- thinking && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
5968
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.thinking }),
5969
- thinkingOptions.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
5970
- "button",
5971
- {
5972
- type: "button",
5973
- role: "menuitemradio",
5974
- "aria-checked": thinking.value === o.id,
5975
- className: `awr-menu__item${thinking.value === o.id ? " is-active" : ""}`,
5976
- onClick: () => {
5977
- thinking.onChange(o.id);
5978
- setMenu(void 0);
5979
- },
5980
- children: o.label
5981
- },
5982
- o.id
5983
- ))
5984
- ] }),
5985
- model?.options?.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
5986
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.model }),
5987
- model.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
5988
- "button",
5989
- {
5990
- type: "button",
5991
- role: "menuitemradio",
5992
- "aria-checked": model.value === o.id,
5993
- className: `awr-menu__item${model.value === o.id ? " is-active" : ""}`,
5994
- onClick: () => {
5995
- model.onSelect?.(o.id);
5996
- setMenu(void 0);
5997
- },
5998
- children: [
5999
- o.label,
6000
- o.group && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__group", children: o.group })
6001
- ]
6002
- },
6003
- o.id
6004
- ))
6005
- ] }) : null
6006
- ] })
6268
+ menu === "model" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6269
+ "div",
6270
+ {
6271
+ className: "awr-menu awr-menu--pop",
6272
+ style: modelStyle,
6273
+ role: "menu",
6274
+ ref: modelMenuRef,
6275
+ onKeyDown: modelMenuKeys,
6276
+ children: [
6277
+ thinking && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6278
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.thinking }),
6279
+ thinkingOptions.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6280
+ "button",
6281
+ {
6282
+ type: "button",
6283
+ role: "menuitemradio",
6284
+ "aria-checked": thinking.value === o.id,
6285
+ className: `awr-menu__item${thinking.value === o.id ? " is-active" : ""}`,
6286
+ onClick: () => {
6287
+ thinking.onChange(o.id);
6288
+ setMenu(void 0);
6289
+ },
6290
+ children: o.label
6291
+ },
6292
+ o.id
6293
+ ))
6294
+ ] }),
6295
+ model?.options?.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6296
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.model }),
6297
+ menuSections(model.options).map((run, i, runs) => {
6298
+ const rows = run.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6299
+ "button",
6300
+ {
6301
+ type: "button",
6302
+ role: "menuitemradio",
6303
+ "aria-checked": model.value === o.id,
6304
+ className: `awr-menu__item${model.value === o.id ? " is-active" : ""}`,
6305
+ onClick: () => {
6306
+ model.onSelect?.(o.id);
6307
+ setMenu(void 0);
6308
+ },
6309
+ children: [
6310
+ o.label,
6311
+ o.group && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__group", children: o.group })
6312
+ ]
6313
+ },
6314
+ o.id
6315
+ ));
6316
+ if (run.section)
6317
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6318
+ "div",
6319
+ {
6320
+ role: "group",
6321
+ "aria-label": run.section,
6322
+ className: "awr-menu__section",
6323
+ children: [
6324
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6325
+ "div",
6326
+ {
6327
+ className: "awr-menu__head awr-menu__sectionhead",
6328
+ "aria-hidden": "true",
6329
+ children: run.section
6330
+ }
6331
+ ),
6332
+ rows
6333
+ ]
6334
+ },
6335
+ `s${i}`
6336
+ );
6337
+ return runs[i - 1]?.section ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__section awr-menu__section--plain", children: rows }, `s${i}`) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react12.Fragment, { children: rows }, `s${i}`);
6338
+ })
6339
+ ] }) : null
6340
+ ]
6341
+ }
6342
+ )
6007
6343
  ] }),
6008
6344
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-toolbar__spacer" }),
6009
6345
  toolbarEnd,
@@ -6012,9 +6348,16 @@ ${draftText}` : draftText);
6012
6348
  "button",
6013
6349
  {
6014
6350
  type: "button",
6351
+ ref: modeChipRef,
6015
6352
  className: `awr-tchip awr-tchip--btn awr-mode awr-mode--${agent.approvalMode}`,
6016
6353
  title: MODE_CHIP[agent.approvalMode].hint,
6017
6354
  onClick: () => setMenu(menu === "mode" ? void 0 : "mode"),
6355
+ onKeyDown: (e) => {
6356
+ if (menu !== "mode" && opensMenu(e.key)) {
6357
+ e.preventDefault();
6358
+ setMenu("mode");
6359
+ }
6360
+ },
6018
6361
  "aria-haspopup": "menu",
6019
6362
  "aria-expanded": menu === "mode",
6020
6363
  "aria-label": `${L.toolConsent}: ${MODE_CHIP[agent.approvalMode].label}`,
@@ -6024,29 +6367,39 @@ ${draftText}` : draftText);
6024
6367
  ]
6025
6368
  }
6026
6369
  ),
6027
- menu === "mode" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-menu awr-menu--pop", style: modeStyle, role: "menu", children: [
6028
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.toolConsent }),
6029
- MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6030
- "button",
6031
- {
6032
- type: "button",
6033
- role: "menuitemradio",
6034
- "aria-checked": agent.approvalMode === m,
6035
- className: `awr-menu__item${agent.approvalMode === m ? " is-active" : ""}`,
6036
- onClick: () => {
6037
- agent.setApprovalMode(m);
6038
- setMenu(void 0);
6039
- },
6040
- children: [
6041
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModeIcon, { mode: m }),
6042
- " ",
6043
- MODE_CHIP[m].label,
6044
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__desc", children: MODE_CHIP[m].hint })
6045
- ]
6046
- },
6047
- m
6048
- ))
6049
- ] })
6370
+ menu === "mode" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6371
+ "div",
6372
+ {
6373
+ className: "awr-menu awr-menu--pop",
6374
+ style: modeStyle,
6375
+ role: "menu",
6376
+ ref: modeMenuRef,
6377
+ onKeyDown: modeMenuKeys,
6378
+ children: [
6379
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.toolConsent }),
6380
+ MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6381
+ "button",
6382
+ {
6383
+ type: "button",
6384
+ role: "menuitemradio",
6385
+ "aria-checked": agent.approvalMode === m,
6386
+ className: `awr-menu__item${agent.approvalMode === m ? " is-active" : ""}`,
6387
+ onClick: () => {
6388
+ agent.setApprovalMode(m);
6389
+ setMenu(void 0);
6390
+ },
6391
+ children: [
6392
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModeIcon, { mode: m }),
6393
+ " ",
6394
+ MODE_CHIP[m].label,
6395
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__desc", children: MODE_CHIP[m].hint })
6396
+ ]
6397
+ },
6398
+ m
6399
+ ))
6400
+ ]
6401
+ }
6402
+ )
6050
6403
  ] }),
6051
6404
  canSteer && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "awr-sendbtn", onClick: submit, "aria-label": L.steer, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SendIcon, { size: 16 }) }),
6052
6405
  busy ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -8115,8 +8468,279 @@ var ModelLoadBar = ({ load, className }) => {
8115
8468
  ] });
8116
8469
  };
8117
8470
 
8118
- // src/components/ToolApprovalPrompt.tsx
8471
+ // src/components/QuestionPrompt.tsx
8472
+ var import_react21 = require("react");
8119
8473
  var import_jsx_runtime19 = require("react/jsx-runtime");
8474
+ var useNow2 = (active) => {
8475
+ const [now, setNow] = (0, import_react21.useState)(() => Date.now());
8476
+ (0, import_react21.useEffect)(() => {
8477
+ if (!active) return;
8478
+ setNow(Date.now());
8479
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
8480
+ return () => clearInterval(timer);
8481
+ }, [active]);
8482
+ return now;
8483
+ };
8484
+ var Expiry2 = ({ expiresAt, L }) => {
8485
+ const now = useNow2(true);
8486
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__expiry", children: L.questionExpiresIn(formatCountdown(expiresAt - now)) });
8487
+ };
8488
+ var reasonText2 = (q, L) => {
8489
+ const key = q.reason ?? q.status;
8490
+ return Object.hasOwn(L.questionReasons, key) ? L.questionReasons[key] : key;
8491
+ };
8492
+ var leadOf = (subagent, L) => subagent ? L.questionLeadHelper(previewValue(subagent.role ?? "", 60) || void 0, subagent.depth) : L.questionLead;
8493
+ var isTyping = (target) => target instanceof HTMLElement && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable);
8494
+ var QuestionCard = ({
8495
+ question: q,
8496
+ view,
8497
+ index,
8498
+ total,
8499
+ answer,
8500
+ showExpiry,
8501
+ showHelper,
8502
+ numberKeys,
8503
+ L
8504
+ }) => {
8505
+ const baseId = (0, import_react21.useId)();
8506
+ const textId = `${baseId}-q`;
8507
+ const otherId = `${baseId}-other`;
8508
+ const [picked, setPicked] = (0, import_react21.useState)([]);
8509
+ const [otherOpen, setOtherOpen] = (0, import_react21.useState)(false);
8510
+ const [otherText, setOtherText] = (0, import_react21.useState)("");
8511
+ const otherField = (0, import_react21.useRef)(null);
8512
+ const otherButton = (0, import_react21.useRef)(null);
8513
+ (0, import_react21.useEffect)(() => {
8514
+ if (otherOpen) otherField.current?.focus();
8515
+ }, [otherOpen]);
8516
+ const helper = showHelper && q.subagent ? { ...q.subagent, ...view?.subagent } : void 0;
8517
+ const choice = questionChoiceOf(q, picked);
8518
+ const other = questionOtherOf(q, otherText);
8519
+ const pick = (label) => {
8520
+ if (!q.multiple) {
8521
+ const one = questionChoiceOf(q, [label]);
8522
+ if (one) answer(one);
8523
+ return;
8524
+ }
8525
+ setPicked((p) => p.includes(label) ? p.filter((l) => l !== label) : [...p, label]);
8526
+ };
8527
+ const sendOther = (e) => {
8528
+ e.preventDefault();
8529
+ if (other) answer(other);
8530
+ };
8531
+ const onKeyDown = (e) => {
8532
+ if (!numberKeys || e.defaultPrevented || isTyping(e.target)) return;
8533
+ if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
8534
+ const n = /^[1-9]$/.test(e.key) ? Number(e.key) : 0;
8535
+ const option = n ? q.options[n - 1] : void 0;
8536
+ if (!option) return;
8537
+ e.preventDefault();
8538
+ pick(option.label);
8539
+ };
8540
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8541
+ "section",
8542
+ {
8543
+ className: `awr-question${q.multiple ? " awr-question--multiple" : ""}${helper ? " awr-question--helper" : ""}`,
8544
+ role: "group",
8545
+ "aria-labelledby": textId,
8546
+ "data-question": q.id,
8547
+ "data-subagent": helper?.id,
8548
+ onKeyDown,
8549
+ children: [
8550
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__head", children: [
8551
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(QuestionIcon, { size: 16, className: "awr-question__icon" }),
8552
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__lead", role: "alert", children: leadOf(helper, L) }),
8553
+ total > 1 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__count", children: L.questionCount(index, total) })
8554
+ ] }),
8555
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__text", id: textId, children: q.question }),
8556
+ q.multiple && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__hint", children: L.questionSeveral }),
8557
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "awr-question__options", children: q.options.map((o, i) => {
8558
+ const on = picked.includes(o.label);
8559
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8560
+ "button",
8561
+ {
8562
+ type: "button",
8563
+ className: `awr-question__option${on ? " is-picked" : ""}`,
8564
+ "data-option": i + 1,
8565
+ "aria-pressed": q.multiple ? on : void 0,
8566
+ "aria-keyshortcuts": numberKeys && i < 9 ? String(i + 1) : void 0,
8567
+ onClick: () => pick(o.label),
8568
+ children: [
8569
+ numberKeys && i < 9 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__key", "aria-hidden": "true", children: i + 1 }),
8570
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "awr-question__body", children: [
8571
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__label", children: o.label }),
8572
+ o.description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__desc", children: o.description })
8573
+ ] }),
8574
+ 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 }) })
8575
+ ]
8576
+ },
8577
+ o.label
8578
+ );
8579
+ }) }),
8580
+ q.allowOther && otherOpen && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("form", { className: "awr-question__other", onSubmit: sendOther, children: [
8581
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { className: "awr-question__otherlabel", htmlFor: otherId, children: L.questionOtherLabel }),
8582
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__otherrow", children: [
8583
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8584
+ "input",
8585
+ {
8586
+ ref: otherField,
8587
+ id: otherId,
8588
+ className: "awr-question__input",
8589
+ type: "text",
8590
+ value: otherText,
8591
+ autoComplete: "off",
8592
+ onChange: (e) => setOtherText(e.target.value),
8593
+ onKeyDown: (e) => {
8594
+ if (e.key !== "Escape") return;
8595
+ e.preventDefault();
8596
+ e.stopPropagation();
8597
+ setOtherOpen(false);
8598
+ otherButton.current?.focus();
8599
+ }
8600
+ }
8601
+ ),
8602
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "submit", className: "awr-btn awr-btn--primary", disabled: !other, children: L.questionSend })
8603
+ ] })
8604
+ ] }),
8605
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__actions", children: [
8606
+ q.multiple && !otherOpen && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8607
+ "button",
8608
+ {
8609
+ type: "button",
8610
+ className: "awr-btn awr-btn--primary",
8611
+ disabled: !choice,
8612
+ onClick: () => choice && answer(choice),
8613
+ children: L.questionSend
8614
+ }
8615
+ ),
8616
+ q.allowOther && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8617
+ "button",
8618
+ {
8619
+ ref: otherButton,
8620
+ type: "button",
8621
+ className: "awr-btn",
8622
+ "aria-expanded": otherOpen,
8623
+ "aria-controls": otherOpen ? otherId : void 0,
8624
+ onClick: () => setOtherOpen((o) => !o),
8625
+ children: L.questionOther
8626
+ }
8627
+ ),
8628
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8629
+ "button",
8630
+ {
8631
+ type: "button",
8632
+ className: "awr-btn awr-btn--ghost",
8633
+ onClick: () => answer({ declined: true }),
8634
+ children: L.questionSkip
8635
+ }
8636
+ )
8637
+ ] }),
8638
+ showExpiry && q.expiresAt !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Expiry2, { expiresAt: q.expiresAt, L })
8639
+ ]
8640
+ }
8641
+ );
8642
+ };
8643
+ var RemoteQuestion = ({ view, L }) => {
8644
+ const textId = `${(0, import_react21.useId)()}-q`;
8645
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8646
+ "section",
8647
+ {
8648
+ className: "awr-question awr-question--remote",
8649
+ role: "group",
8650
+ "aria-labelledby": textId,
8651
+ "data-question": view.id,
8652
+ children: [
8653
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-question__head", children: [
8654
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(QuestionIcon, { size: 16, className: "awr-question__icon" }),
8655
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__lead", children: leadOf(view.subagent, L) })
8656
+ ] }),
8657
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__text", id: textId, children: view.question }),
8658
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ul", { className: "awr-question__list", children: view.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { children: [
8659
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__label", children: o.label }),
8660
+ o.description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "awr-question__desc", children: o.description })
8661
+ ] }, o.label)) }),
8662
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-question__remote", role: "status", children: L.questionRemote })
8663
+ ]
8664
+ }
8665
+ );
8666
+ };
8667
+ var QuestionPrompt = ({
8668
+ questions,
8669
+ onAnswer,
8670
+ outcomes,
8671
+ showOutcomes = true,
8672
+ showExpiry = true,
8673
+ showHelper = true,
8674
+ showRemote = true,
8675
+ numberKeys = true,
8676
+ renderQuestion,
8677
+ labels,
8678
+ className
8679
+ }) => {
8680
+ const L = useLabels(labels);
8681
+ const [dismissed, setDismissed] = (0, import_react21.useState)(() => /* @__PURE__ */ new Set());
8682
+ const automatic = showOutcomes ? (outcomes ?? []).filter(
8683
+ (o) => o.automatic === true && o.status !== "pending" && o.status !== "stopped" && !dismissed.has(o.id)
8684
+ ) : [];
8685
+ const remote = showRemote ? (outcomes ?? []).filter((o) => o.remote && o.status === "pending") : [];
8686
+ const current = questions[0];
8687
+ if (!current && automatic.length === 0 && remote.length === 0) return null;
8688
+ let card = null;
8689
+ if (current) {
8690
+ const answer = (a) => onAnswer(current.id, a);
8691
+ const builtIn = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8692
+ QuestionCard,
8693
+ {
8694
+ question: current,
8695
+ view: outcomes?.find((o) => o.id === current.id),
8696
+ index: 1,
8697
+ total: questions.length,
8698
+ answer,
8699
+ showExpiry,
8700
+ showHelper,
8701
+ numberKeys,
8702
+ L
8703
+ },
8704
+ current.id
8705
+ );
8706
+ card = renderQuestion ? renderQuestion(current, builtIn, answer) : builtIn;
8707
+ }
8708
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: ["awr-questions", className].filter(Boolean).join(" "), children: [
8709
+ automatic.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8710
+ "div",
8711
+ {
8712
+ className: "awr-question-outcome",
8713
+ role: "status",
8714
+ "data-reason": o.reason ?? o.status,
8715
+ children: [
8716
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AlertIcon, { size: 14, className: "awr-question-outcome__icon" }),
8717
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "awr-question-outcome__text", children: [
8718
+ L.questionAutomatic(reasonText2(o, L)),
8719
+ " ",
8720
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("q", { className: "awr-question-outcome__question", children: o.question })
8721
+ ] }),
8722
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8723
+ "button",
8724
+ {
8725
+ type: "button",
8726
+ className: "awr-iconbtn awr-question-outcome__dismiss",
8727
+ "aria-label": L.questionDismiss,
8728
+ title: L.questionDismiss,
8729
+ onClick: () => setDismissed((d) => new Set(d).add(o.id)),
8730
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(XIcon, { size: 14 })
8731
+ }
8732
+ )
8733
+ ]
8734
+ },
8735
+ o.id
8736
+ )),
8737
+ remote.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RemoteQuestion, { view: o, L }, o.id)),
8738
+ card
8739
+ ] });
8740
+ };
8741
+
8742
+ // src/components/ToolApprovalPrompt.tsx
8743
+ var import_jsx_runtime20 = require("react/jsx-runtime");
8120
8744
  var SkillConsentCard = ({
8121
8745
  approval: a,
8122
8746
  skill,
@@ -8126,7 +8750,7 @@ var SkillConsentCard = ({
8126
8750
  showPreview,
8127
8751
  onApprove,
8128
8752
  onDeny
8129
- }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8753
+ }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
8130
8754
  "div",
8131
8755
  {
8132
8756
  className: `awr-approval awr-approval--skill${helper ? " awr-approval--helper" : ""}`,
@@ -8134,28 +8758,28 @@ var SkillConsentCard = ({
8134
8758
  "data-skill-server": skill.server,
8135
8759
  "data-subagent": helper?.id,
8136
8760
  children: [
8137
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-approval__head", children: [
8138
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
8139
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: L.skillConsentLead(skill.server, skill.skill) })
8761
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__head", children: [
8762
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
8763
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: L.skillConsentLead(skill.server, skill.skill) })
8140
8764
  ] }),
8141
- skill.description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__quote", children: skill.description }),
8142
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("p", { className: "awr-approval__skillmeta", children: [
8143
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("code", { className: "awr-tool__name", children: skill.name }),
8144
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: L.skillConsentSize(skill.size, skill.fileCount) })
8765
+ skill.description && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__quote", children: skill.description }),
8766
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("p", { className: "awr-approval__skillmeta", children: [
8767
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("code", { className: "awr-tool__name", children: skill.name }),
8768
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: L.skillConsentSize(skill.size, skill.fileCount) })
8145
8769
  ] }),
8146
- skill.byUri && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from", children: L.skillConsentByUri }),
8147
- skill.nestedIn && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from awr-approval__nested", children: L.skillConsentNested(skill.nestedIn) }),
8148
- skill.dynamic && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from awr-approval__dynamic", children: L.skillConsentDynamic }),
8149
- skill.dynamic && skill.noFileListing && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from", children: L.skillConsentNoFileListing }),
8150
- showPreview && skill.body !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("details", { className: "awr-approval__preview", children: [
8151
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("summary", { children: L.skillConsentPreview }),
8152
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("pre", { className: "awr-approval__quote awr-approval__body", children: skill.body }),
8153
- skill.files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from", children: L.skillConsentFiles(skill.files.join(", "), skill.fileCount - skill.files.length) })
8770
+ skill.byUri && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentByUri }),
8771
+ skill.nestedIn && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from awr-approval__nested", children: L.skillConsentNested(skill.nestedIn) }),
8772
+ skill.dynamic && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from awr-approval__dynamic", children: L.skillConsentDynamic }),
8773
+ skill.dynamic && skill.noFileListing && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentNoFileListing }),
8774
+ showPreview && skill.body !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("details", { className: "awr-approval__preview", children: [
8775
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("summary", { children: L.skillConsentPreview }),
8776
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("pre", { className: "awr-approval__quote awr-approval__body", children: skill.body }),
8777
+ 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) })
8154
8778
  ] }),
8155
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from", children: L.skillConsentNote(skill.server, skill.consent) }),
8156
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-approval__actions", children: [
8157
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: "awr-btn awr-btn--primary", onClick: () => onApprove(a.id), children: L.skillConsentAllow }),
8158
- allowRemember && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8779
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.skillConsentNote(skill.server, skill.consent) }),
8780
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__actions", children: [
8781
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: "awr-btn awr-btn--primary", onClick: () => onApprove(a.id), children: L.skillConsentAllow }),
8782
+ allowRemember && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8159
8783
  "button",
8160
8784
  {
8161
8785
  type: "button",
@@ -8164,7 +8788,7 @@ var SkillConsentCard = ({
8164
8788
  children: L.skillConsentAlways
8165
8789
  }
8166
8790
  ),
8167
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8791
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8168
8792
  "button",
8169
8793
  {
8170
8794
  type: "button",
@@ -8190,9 +8814,9 @@ var ToolApprovalPrompt = ({
8190
8814
  }) => {
8191
8815
  const L = useLabels(labels);
8192
8816
  if (approvals.length === 0) return null;
8193
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
8817
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
8194
8818
  if (a.skill) {
8195
- const card2 = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8819
+ const card2 = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8196
8820
  SkillConsentCard,
8197
8821
  {
8198
8822
  approval: a,
@@ -8206,33 +8830,33 @@ var ToolApprovalPrompt = ({
8206
8830
  },
8207
8831
  a.id
8208
8832
  );
8209
- return renderApproval ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: renderApproval(a, card2) }, a.id) : card2;
8833
+ return renderApproval ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: renderApproval(a, card2) }, a.id) : card2;
8210
8834
  }
8211
8835
  const helper = showHelper ? a.subagent : void 0;
8212
8836
  const app = a.app;
8213
- const card = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8837
+ const card = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
8214
8838
  "div",
8215
8839
  {
8216
8840
  className: `awr-approval${helper ? " awr-approval--helper" : ""}${app ? " awr-approval--app" : ""}`,
8217
8841
  "data-subagent": helper?.id,
8218
8842
  "data-app-server": app?.server,
8219
8843
  children: [
8220
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-approval__head", children: [
8221
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
8222
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
8844
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__head", children: [
8845
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
8846
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
8223
8847
  app ? L.approvalLeadApp(app.server) : helper ? L.approvalLeadHelper(
8224
8848
  previewValue(helper.role ?? "", 60) || void 0,
8225
8849
  helper.depth
8226
8850
  ) : L.approvalLead,
8227
8851
  " ",
8228
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("code", { className: "awr-tool__name", children: app ? app.tool : a.name }),
8852
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("code", { className: "awr-tool__name", children: app ? app.tool : a.name }),
8229
8853
  a.readOnly && !app ? ` (${L.readOnlyTool})` : ""
8230
8854
  ] })
8231
8855
  ] }),
8232
- previewValue(a.input, 300) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
8233
- app && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "awr-approval__from", children: L.approvalFromApp(app.server, a.readOnly) }),
8234
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "awr-approval__actions", children: [
8235
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8856
+ previewValue(a.input, 300) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
8857
+ app && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "awr-approval__from", children: L.approvalFromApp(app.server, a.readOnly) }),
8858
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "awr-approval__actions", children: [
8859
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8236
8860
  "button",
8237
8861
  {
8238
8862
  type: "button",
@@ -8241,7 +8865,7 @@ var ToolApprovalPrompt = ({
8241
8865
  children: L.approve
8242
8866
  }
8243
8867
  ),
8244
- allowRemember && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8868
+ allowRemember && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8245
8869
  "button",
8246
8870
  {
8247
8871
  type: "button",
@@ -8250,7 +8874,7 @@ var ToolApprovalPrompt = ({
8250
8874
  children: L.alwaysAllow
8251
8875
  }
8252
8876
  ),
8253
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8877
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8254
8878
  "button",
8255
8879
  {
8256
8880
  type: "button",
@@ -8264,12 +8888,12 @@ var ToolApprovalPrompt = ({
8264
8888
  },
8265
8889
  a.id
8266
8890
  );
8267
- return renderApproval ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: renderApproval(a, card) }, a.id) : card;
8891
+ return renderApproval ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: renderApproval(a, card) }, a.id) : card;
8268
8892
  }) });
8269
8893
  };
8270
8894
 
8271
8895
  // src/components/UsageBadge.tsx
8272
- var import_jsx_runtime20 = require("react/jsx-runtime");
8896
+ var import_jsx_runtime21 = require("react/jsx-runtime");
8273
8897
  var UsageBadge = ({
8274
8898
  usage,
8275
8899
  compact = false,
@@ -8295,7 +8919,7 @@ var UsageBadge = ({
8295
8919
  mediaText,
8296
8920
  decisions ? L.usageDecisions(decisions) : ""
8297
8921
  ].filter(Boolean).join(" \xB7 ");
8298
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
8922
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
8299
8923
  formatTokens(usage.inputTokens),
8300
8924
  "\u2191 ",
8301
8925
  formatTokens(usage.outputTokens),
@@ -8308,13 +8932,13 @@ var UsageBadge = ({
8308
8932
  };
8309
8933
 
8310
8934
  // src/components/AgentChat.tsx
8311
- var import_jsx_runtime21 = require("react/jsx-runtime");
8935
+ var import_jsx_runtime22 = require("react/jsx-runtime");
8312
8936
  var usePrefersDark = () => {
8313
8937
  const query = "(prefers-color-scheme: dark)";
8314
- const [dark, setDark] = (0, import_react21.useState)(
8938
+ const [dark, setDark] = (0, import_react22.useState)(
8315
8939
  () => typeof matchMedia === "function" && matchMedia(query).matches
8316
8940
  );
8317
- (0, import_react21.useEffect)(() => {
8941
+ (0, import_react22.useEffect)(() => {
8318
8942
  if (typeof matchMedia !== "function") return;
8319
8943
  const mq = matchMedia(query);
8320
8944
  const on = () => setDark(mq.matches);
@@ -8325,7 +8949,7 @@ var usePrefersDark = () => {
8325
8949
  };
8326
8950
  var isHistoryHook = (h) => typeof h === "object" && h !== null && "select" in h && "chats" in h;
8327
8951
  var cx = (...names) => names.filter(Boolean).join(" ");
8328
- var AgentChat = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AgentChatInner, { ...props }) });
8952
+ var AgentChat = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AgentChatInner, { ...props }) });
8329
8953
  var NO_LABELS = {};
8330
8954
  var AgentChatInner = ({
8331
8955
  controller,
@@ -8353,11 +8977,13 @@ var AgentChatInner = ({
8353
8977
  showContext = false,
8354
8978
  activityOpen = false,
8355
8979
  showElicitation = true,
8980
+ showQuestions = true,
8356
8981
  showSkillPreview = true,
8357
8982
  showOtherTabs = true,
8358
8983
  elicitations,
8359
8984
  onElicitationAnswer,
8360
8985
  renderElicitation,
8986
+ renderQuestion,
8361
8987
  history,
8362
8988
  defaultHistoryOpen,
8363
8989
  files,
@@ -8402,7 +9028,7 @@ var AgentChatInner = ({
8402
9028
  }
8403
9029
  const L = useLabels();
8404
9030
  const external = isHistoryHook(history) ? history : void 0;
8405
- const [ownStore] = (0, import_react21.useState)(
9031
+ const [ownStore] = (0, import_react22.useState)(
8406
9032
  () => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
8407
9033
  );
8408
9034
  const own = useChatHistory(agent, {
@@ -8410,9 +9036,9 @@ var AgentChatInner = ({
8410
9036
  enabled: Boolean(history) && !external
8411
9037
  });
8412
9038
  const chats = history ? external ?? own : void 0;
8413
- const rootRef = (0, import_react21.useRef)(null);
8414
- const [narrow, setNarrow] = (0, import_react21.useState)(void 0);
8415
- (0, import_react21.useEffect)(() => {
9039
+ const rootRef = (0, import_react22.useRef)(null);
9040
+ const [narrow, setNarrow] = (0, import_react22.useState)(void 0);
9041
+ (0, import_react22.useEffect)(() => {
8416
9042
  const el = rootRef.current;
8417
9043
  if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
8418
9044
  const measure2 = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
@@ -8421,9 +9047,9 @@ var AgentChatInner = ({
8421
9047
  ro.observe(el);
8422
9048
  return () => ro.disconnect();
8423
9049
  }, [narrowWidth]);
8424
- const [historyChoice, setHistoryOpen] = (0, import_react21.useState)(defaultHistoryOpen);
9050
+ const [historyChoice, setHistoryOpen] = (0, import_react22.useState)(defaultHistoryOpen);
8425
9051
  const historyOpen = historyChoice ?? narrow === false;
8426
- const [filesOpen, setFilesOpen] = (0, import_react21.useState)(defaultFilesOpen);
9052
+ const [filesOpen, setFilesOpen] = (0, import_react22.useState)(defaultFilesOpen);
8427
9053
  const toggleHistory = () => {
8428
9054
  setHistoryOpen(!historyOpen);
8429
9055
  if (narrow && !historyOpen) setFilesOpen(false);
@@ -8441,7 +9067,7 @@ var AgentChatInner = ({
8441
9067
  setHistoryOpen(false);
8442
9068
  setFilesOpen(false);
8443
9069
  };
8444
- (0, import_react21.useEffect)(() => {
9070
+ (0, import_react22.useEffect)(() => {
8445
9071
  if (!overlayOpen) return;
8446
9072
  const onKey = (e) => {
8447
9073
  if (e.key !== "Escape" || e.defaultPrevented) return;
@@ -8451,7 +9077,7 @@ var AgentChatInner = ({
8451
9077
  document.addEventListener("keydown", onKey);
8452
9078
  return () => document.removeEventListener("keydown", onKey);
8453
9079
  }, [overlayOpen]);
8454
- const bodyRef = (0, import_react21.useRef)(null);
9080
+ const bodyRef = (0, import_react22.useRef)(null);
8455
9081
  const appHost = useMcpAppHost({
8456
9082
  connection: mcpApps,
8457
9083
  approve: agent.approveAppToolCall,
@@ -8463,7 +9089,7 @@ var AgentChatInner = ({
8463
9089
  });
8464
9090
  const prefersDark = usePrefersDark();
8465
9091
  const appTheme = theme === "auto" ? prefersDark ? "dark" : "light" : theme;
8466
- const [panelApp, setPanelAppState] = (0, import_react21.useState)();
9092
+ const [panelApp, setPanelAppState] = (0, import_react22.useState)();
8467
9093
  const setPanelApp = (app) => {
8468
9094
  setPanelAppState(app);
8469
9095
  onAppPanel?.(app);
@@ -8477,14 +9103,14 @@ var AgentChatInner = ({
8477
9103
  const panelAllowed = appPanel !== false && appPanel !== null;
8478
9104
  const panelTarget = typeof appPanel === "object" && appPanel ? appPanel : void 0;
8479
9105
  const asSheet = !panelTarget && (appPanel === "sheet" || Boolean(narrow));
8480
- (0, import_react21.useEffect)(() => {
9106
+ (0, import_react22.useEffect)(() => {
8481
9107
  if (panelApp && !agent.messages.some((m) => m.apps?.some((a) => a.id === panelApp.id))) {
8482
9108
  setPanelAppState(void 0);
8483
9109
  onAppPanel?.(void 0);
8484
9110
  }
8485
9111
  }, [agent.messages, panelApp, onAppPanel]);
8486
9112
  const drawApp = (app, message) => {
8487
- const built = panelApp?.id === app.id ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9113
+ const built = panelApp?.id === app.id ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8488
9114
  McpAppLine,
8489
9115
  {
8490
9116
  app,
@@ -8492,7 +9118,7 @@ var AgentChatInner = ({
8492
9118
  action: L.appBringBack,
8493
9119
  onAction: () => setPanelApp(void 0)
8494
9120
  }
8495
- ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9121
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8496
9122
  McpAppFrame,
8497
9123
  {
8498
9124
  app,
@@ -8505,7 +9131,7 @@ var AgentChatInner = ({
8505
9131
  );
8506
9132
  return renderApp ? renderApp(app, message, built) : built;
8507
9133
  };
8508
- const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9134
+ const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8509
9135
  McpAppFrame,
8510
9136
  {
8511
9137
  app: panelApp,
@@ -8517,7 +9143,7 @@ var AgentChatInner = ({
8517
9143
  },
8518
9144
  panelApp.id
8519
9145
  ) : null;
8520
- const [compacting, setCompacting] = (0, import_react21.useState)(false);
9146
+ const [compacting, setCompacting] = (0, import_react22.useState)(false);
8521
9147
  const compact = () => {
8522
9148
  setCompacting(true);
8523
9149
  void agent.compact().finally(() => setCompacting(false));
@@ -8528,9 +9154,10 @@ var AgentChatInner = ({
8528
9154
  const Files = components.FilesPanel ?? FilesPanel;
8529
9155
  const Approvals = components.ApprovalPrompt ?? ToolApprovalPrompt;
8530
9156
  const Elicitations = components.ElicitationPrompt ?? ElicitationPrompt;
9157
+ const Questions = components.QuestionPrompt ?? QuestionPrompt;
8531
9158
  const tabNotes = showOtherTabs ? [
8532
9159
  agent.remote?.running && L.remoteRunning,
8533
- agent.remote?.running && agent.approvals.some((a) => a.remote && a.status === "pending") && L.remoteWaitingConsent,
9160
+ agent.remote?.running && (agent.approvals.some((a) => a.remote && a.status === "pending") || (agent.questions ?? []).some((q) => q.remote && q.status === "pending")) && L.remoteWaitingConsent,
8534
9161
  agent.remote?.ended === "gone" && L.remoteGone,
8535
9162
  agent.sessionBusy && L.sessionBusy(agent.sessionBusy.heldBy)
8536
9163
  ].filter((t) => typeof t === "string") : [];
@@ -8538,18 +9165,18 @@ var AgentChatInner = ({
8538
9165
  const showReplan = agent.replan && agent.replan.mode !== "continue";
8539
9166
  const replanFailedEarly = showReplanFailed && agent.replan?.failed === true && agent.steps.length === 0;
8540
9167
  const earlyDecisions = showDecisions ? agent.decisions ?? [] : [];
8541
- const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
8542
- agent.planThought.trim() && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("details", { className: "awr-activity__plan", children: [
8543
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("summary", { children: L.planned }),
8544
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "awr-activity__thought", children: agent.planThought })
9168
+ const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
9169
+ agent.planThought.trim() && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("details", { className: "awr-activity__plan", children: [
9170
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("summary", { children: L.planned }),
9171
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "awr-activity__thought", children: agent.planThought })
8545
9172
  ] }),
8546
- showReplan && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
8547
- replanFailedEarly && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "awr-step__warn", title: agent.replan.error, children: [
8548
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AlertIcon, { size: 12 }),
9173
+ showReplan && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
9174
+ replanFailedEarly && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "awr-step__warn", title: agent.replan.error, children: [
9175
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AlertIcon, { size: 12 }),
8549
9176
  " ",
8550
9177
  L.replanFailed
8551
9178
  ] }),
8552
- earlyDecisions.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9179
+ earlyDecisions.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8553
9180
  "p",
8554
9181
  {
8555
9182
  className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
@@ -8558,8 +9185,8 @@ var AgentChatInner = ({
8558
9185
  i
8559
9186
  ))
8560
9187
  ] }) : void 0;
8561
- const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cx("awr-chat__header", classNames.header), children: [
8562
- chats && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9188
+ 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: [
9189
+ chats && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8563
9190
  "button",
8564
9191
  {
8565
9192
  type: "button",
@@ -8568,17 +9195,17 @@ var AgentChatInner = ({
8568
9195
  title: L.showHistory,
8569
9196
  "aria-pressed": historyOpen,
8570
9197
  onClick: toggleHistory,
8571
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(HistoryIcon, { size: 16 })
9198
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(HistoryIcon, { size: 16 })
8572
9199
  }
8573
9200
  ),
8574
9201
  slots.headerStart,
8575
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "awr-chat__title", children: title }),
8576
- showStatus && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
8577
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "awr-status__dot" }),
8578
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "awr-status__text", children: L.status[agent.status] })
9202
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-chat__title", children: title }),
9203
+ showStatus && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
9204
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "awr-status__dot" }),
9205
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "awr-status__text", children: L.status[agent.status] })
8579
9206
  ] }),
8580
- showTotalUsage && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { title: L.totalUsage, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
8581
- files && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9207
+ 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 }) }),
9208
+ files && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8582
9209
  "button",
8583
9210
  {
8584
9211
  type: "button",
@@ -8587,12 +9214,12 @@ var AgentChatInner = ({
8587
9214
  title: L.showFiles,
8588
9215
  "aria-pressed": filesOpen,
8589
9216
  onClick: toggleFiles,
8590
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FileIcon, { size: 16 })
9217
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FileIcon, { size: 16 })
8591
9218
  }
8592
9219
  ),
8593
9220
  slots.headerEnd
8594
9221
  ] });
8595
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
9222
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
8596
9223
  "div",
8597
9224
  {
8598
9225
  ref: rootRef,
@@ -8600,7 +9227,7 @@ var AgentChatInner = ({
8600
9227
  style,
8601
9228
  "data-awr-theme": theme === "auto" ? void 0 : theme,
8602
9229
  children: [
8603
- overlayOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9230
+ overlayOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8604
9231
  "div",
8605
9232
  {
8606
9233
  className: cx("awr-chat__scrim", classNames.scrim),
@@ -8608,8 +9235,8 @@ var AgentChatInner = ({
8608
9235
  onClick: closeOverlays
8609
9236
  }
8610
9237
  ),
8611
- chats && historyOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
8612
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9238
+ chats && historyOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
9239
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8613
9240
  HistoryList,
8614
9241
  {
8615
9242
  history: {
@@ -8628,7 +9255,7 @@ var AgentChatInner = ({
8628
9255
  }
8629
9256
  ),
8630
9257
  slots.sidebar,
8631
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9258
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8632
9259
  "button",
8633
9260
  {
8634
9261
  type: "button",
@@ -8639,11 +9266,11 @@ var AgentChatInner = ({
8639
9266
  }
8640
9267
  )
8641
9268
  ] }),
8642
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cx("awr-chat__main", classNames.main), children: [
9269
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__main", classNames.main), children: [
8643
9270
  header,
8644
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cx("awr-chat__body", classNames.body), ref: bodyRef, children: [
9271
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__body", classNames.body), ref: bodyRef, children: [
8645
9272
  slots.beforeMessages,
8646
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9273
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8647
9274
  Messages,
8648
9275
  {
8649
9276
  messages: agent.messages,
@@ -8681,7 +9308,7 @@ var AgentChatInner = ({
8681
9308
  renderImageViewer
8682
9309
  }
8683
9310
  ),
8684
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9311
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8685
9312
  Approvals,
8686
9313
  {
8687
9314
  approvals: agent.pendingApprovals,
@@ -8691,7 +9318,16 @@ var AgentChatInner = ({
8691
9318
  renderApproval
8692
9319
  }
8693
9320
  ),
8694
- appsOn && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9321
+ showQuestions && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
9322
+ Questions,
9323
+ {
9324
+ questions: agent.pendingQuestions ?? [],
9325
+ onAnswer: (id, answer) => agent.answerQuestion?.(id, answer),
9326
+ outcomes: agent.questions,
9327
+ renderQuestion
9328
+ }
9329
+ ),
9330
+ appsOn && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8695
9331
  AppRequestPrompt,
8696
9332
  {
8697
9333
  requests: appHost.requests,
@@ -8699,7 +9335,7 @@ var AgentChatInner = ({
8699
9335
  renderRequest: renderAppRequest
8700
9336
  }
8701
9337
  ),
8702
- showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9338
+ showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8703
9339
  Elicitations,
8704
9340
  {
8705
9341
  elicitations,
@@ -8708,13 +9344,13 @@ var AgentChatInner = ({
8708
9344
  renderElicitation
8709
9345
  }
8710
9346
  ),
8711
- agent.modelLoad && loading && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ModelLoadBar, { load: agent.modelLoad }),
9347
+ agent.modelLoad && loading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ModelLoadBar, { load: agent.modelLoad }),
8712
9348
  slots.afterMessages
8713
9349
  ] }),
8714
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cx("awr-chat__footer", classNames.footer), children: [
9350
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("awr-chat__footer", classNames.footer), children: [
8715
9351
  slots.footerStart,
8716
- tabNotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "awr-tabnote", role: "status", children: tabNotes.map((text2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "awr-tabnote__text", children: text2 }, text2)) }),
8717
- showContext !== false && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9352
+ 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)) }),
9353
+ showContext !== false && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8718
9354
  ContextMeter,
8719
9355
  {
8720
9356
  usage: agent.usage,
@@ -8725,11 +9361,11 @@ var AgentChatInner = ({
8725
9361
  compacting
8726
9362
  }
8727
9363
  ),
8728
- composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "awr-chat__error", children: [
8729
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AlertIcon, { size: 14 }),
9364
+ composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "awr-chat__error", children: [
9365
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AlertIcon, { size: 14 }),
8730
9366
  " ",
8731
9367
  agent.error
8732
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9368
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8733
9369
  Composer2,
8734
9370
  {
8735
9371
  controller: agent,
@@ -8746,7 +9382,7 @@ var AgentChatInner = ({
8746
9382
  appPanelNode && (panelTarget ? (
8747
9383
  // Outside the chat: the theme tokens come with it.
8748
9384
  (0, import_react_dom2.createPortal)(
8749
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9385
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8750
9386
  "div",
8751
9387
  {
8752
9388
  className: "awr-theme awr-apppanel",
@@ -8756,24 +9392,24 @@ var AgentChatInner = ({
8756
9392
  ),
8757
9393
  panelTarget
8758
9394
  )
8759
- ) : asSheet ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
8760
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "awr-sheet__scrim", onClick: () => setPanelApp(void 0) }),
8761
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
9395
+ ) : asSheet ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
9396
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-sheet__scrim", onClick: () => setPanelApp(void 0) }),
9397
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
8762
9398
  "aside",
8763
9399
  {
8764
9400
  className: "awr-chat__appsheet",
8765
9401
  role: "dialog",
8766
9402
  "aria-label": L.appFrom(panelApp.server),
8767
9403
  children: [
8768
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "awr-sheet__grab" }),
9404
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "awr-sheet__grab" }),
8769
9405
  appPanelNode
8770
9406
  ]
8771
9407
  }
8772
9408
  )
8773
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("aside", { className: "awr-chat__apppanel", children: appPanelNode })),
8774
- files && filesOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("aside", { className: cx("awr-chat__files", classNames.files), children: [
8775
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Files, { files }) }),
8776
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
9409
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("aside", { className: "awr-chat__apppanel", children: appPanelNode })),
9410
+ files && filesOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("aside", { className: cx("awr-chat__files", classNames.files), children: [
9411
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Files, { files }) }),
9412
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8777
9413
  "button",
8778
9414
  {
8779
9415
  type: "button",
@@ -8790,7 +9426,7 @@ var AgentChatInner = ({
8790
9426
  };
8791
9427
 
8792
9428
  // src/components/LearnedSkills.tsx
8793
- var import_jsx_runtime22 = require("react/jsx-runtime");
9429
+ var import_jsx_runtime23 = require("react/jsx-runtime");
8794
9430
  var LearnedSkills = ({
8795
9431
  controller,
8796
9432
  lessons,
@@ -8806,18 +9442,18 @@ var LearnedSkills = ({
8806
9442
  const c = controller ?? ctx;
8807
9443
  const list = lessons ?? c?.learned ?? [];
8808
9444
  const forget = onForget === false ? void 0 : onForget ?? c?.forgetSkill;
8809
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
8810
- !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("h3", { className: "awr-notebook__title", children: [
8811
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BookIcon, { size: 14 }),
9445
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
9446
+ !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("h3", { className: "awr-notebook__title", children: [
9447
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BookIcon, { size: 14 }),
8812
9448
  " ",
8813
9449
  L.notebookTitle,
8814
- list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "awr-notebook__count", children: list.length })
9450
+ list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "awr-notebook__count", children: list.length })
8815
9451
  ] }),
8816
- list.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("li", { className: "awr-lesson", children: [
8817
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "awr-lesson__head", children: [
8818
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("code", { className: "awr-lesson__name", children: l.name }),
8819
- l.revision > 1 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
8820
- forget && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
9452
+ 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: [
9453
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "awr-lesson__head", children: [
9454
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("code", { className: "awr-lesson__name", children: l.name }),
9455
+ l.revision > 1 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
9456
+ forget && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8821
9457
  "button",
8822
9458
  {
8823
9459
  type: "button",
@@ -8825,12 +9461,12 @@ var LearnedSkills = ({
8825
9461
  title: `${L.notebookForget}: ${l.name}`,
8826
9462
  "aria-label": `${L.notebookForget}: ${l.name}`,
8827
9463
  onClick: () => void forget(l.name),
8828
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(XIcon, { size: 12 })
9464
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(XIcon, { size: 12 })
8829
9465
  }
8830
9466
  )
8831
9467
  ] }),
8832
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "awr-lesson__when", children: l.description }),
8833
- showSources && l.sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "awr-lesson__from", children: [
9468
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "awr-lesson__when", children: l.description }),
9469
+ showSources && l.sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: "awr-lesson__from", children: [
8834
9470
  L.notebookFrom,
8835
9471
  " ",
8836
9472
  l.sources.join(", ")
@@ -8840,8 +9476,8 @@ var LearnedSkills = ({
8840
9476
  };
8841
9477
 
8842
9478
  // src/components/Composer.tsx
8843
- var import_react22 = require("react");
8844
- var import_jsx_runtime23 = require("react/jsx-runtime");
9479
+ var import_react23 = require("react");
9480
+ var import_jsx_runtime24 = require("react/jsx-runtime");
8845
9481
  var Composer = ({
8846
9482
  onSubmit,
8847
9483
  busy = false,
@@ -8850,7 +9486,7 @@ var Composer = ({
8850
9486
  placeholder = "Ask the agent to do something\u2026",
8851
9487
  className
8852
9488
  }) => {
8853
- const [text2, setText] = (0, import_react22.useState)("");
9489
+ const [text2, setText] = (0, import_react23.useState)("");
8854
9490
  const submit = () => {
8855
9491
  const value = text2.trim();
8856
9492
  if (!value || busy || disabled) return;
@@ -8863,7 +9499,7 @@ var Composer = ({
8863
9499
  submit();
8864
9500
  }
8865
9501
  };
8866
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
9502
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
8867
9503
  "form",
8868
9504
  {
8869
9505
  className: ["awr-composer", className].filter(Boolean).join(" "),
@@ -8872,7 +9508,7 @@ var Composer = ({
8872
9508
  submit();
8873
9509
  },
8874
9510
  children: [
8875
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
9511
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8876
9512
  "textarea",
8877
9513
  {
8878
9514
  className: "awr-composer__input",
@@ -8884,23 +9520,23 @@ var Composer = ({
8884
9520
  rows: 1
8885
9521
  }
8886
9522
  ),
8887
- busy ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
9523
+ busy ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8888
9524
  "button",
8889
9525
  {
8890
9526
  type: "button",
8891
9527
  className: "awr-composer__btn awr-composer__btn--stop",
8892
9528
  onClick: onStop,
8893
9529
  "aria-label": "Stop",
8894
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StopIcon, { size: 18 })
9530
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(StopIcon, { size: 18 })
8895
9531
  }
8896
- ) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
9532
+ ) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8897
9533
  "button",
8898
9534
  {
8899
9535
  type: "submit",
8900
9536
  className: "awr-composer__btn",
8901
9537
  disabled: disabled || !text2.trim(),
8902
9538
  "aria-label": "Send",
8903
- children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SendIcon, { size: 18 })
9539
+ children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SendIcon, { size: 18 })
8904
9540
  }
8905
9541
  )
8906
9542
  ]
@@ -8909,17 +9545,17 @@ var Composer = ({
8909
9545
  };
8910
9546
 
8911
9547
  // src/components/PlanView.tsx
8912
- var import_jsx_runtime24 = require("react/jsx-runtime");
9548
+ var import_jsx_runtime25 = require("react/jsx-runtime");
8913
9549
  var PlanView = ({ plan, showThought = true, className }) => {
8914
9550
  if (!plan.steps.length && !plan.thought) return null;
8915
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
8916
- showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
8917
- plan.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { className: "awr-plan__step", children: step.description }, step.id)) })
9551
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
9552
+ showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
9553
+ 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)) })
8918
9554
  ] });
8919
9555
  };
8920
9556
 
8921
9557
  // src/components/ApprovalModeSwitch.tsx
8922
- var import_jsx_runtime25 = require("react/jsx-runtime");
9558
+ var import_jsx_runtime26 = require("react/jsx-runtime");
8923
9559
  var DEFAULT_LABELS = {
8924
9560
  autopilot: "Autopilot",
8925
9561
  "ask-writes": "Ask before changes",
@@ -8939,13 +9575,13 @@ var ApprovalModeSwitch = ({
8939
9575
  labels,
8940
9576
  disabled,
8941
9577
  className
8942
- }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
9578
+ }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
8943
9579
  "div",
8944
9580
  {
8945
9581
  className: ["awr-modeswitch", className].filter(Boolean).join(" "),
8946
9582
  role: "radiogroup",
8947
9583
  "aria-label": "Tool consent",
8948
- children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
9584
+ children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
8949
9585
  "button",
8950
9586
  {
8951
9587
  type: "button",
@@ -8963,8 +9599,8 @@ var ApprovalModeSwitch = ({
8963
9599
  );
8964
9600
 
8965
9601
  // src/components/ApiKeyForm.tsx
8966
- var import_react23 = require("react");
8967
- var import_jsx_runtime26 = require("react/jsx-runtime");
9602
+ var import_react24 = require("react");
9603
+ var import_jsx_runtime27 = require("react/jsx-runtime");
8968
9604
  var ApiKeyForm = ({
8969
9605
  credentials,
8970
9606
  credentialRef,
@@ -8973,10 +9609,10 @@ var ApiKeyForm = ({
8973
9609
  onChange,
8974
9610
  className
8975
9611
  }) => {
8976
- const [value, setValue] = (0, import_react23.useState)("");
8977
- const [present, setPresent] = (0, import_react23.useState)(false);
8978
- const [busy, setBusy] = (0, import_react23.useState)(false);
8979
- (0, import_react23.useEffect)(() => {
9612
+ const [value, setValue] = (0, import_react24.useState)("");
9613
+ const [present, setPresent] = (0, import_react24.useState)(false);
9614
+ const [busy, setBusy] = (0, import_react24.useState)(false);
9615
+ (0, import_react24.useEffect)(() => {
8980
9616
  let active = true;
8981
9617
  credentials.hasKey(credentialRef).then((has) => {
8982
9618
  if (active) setPresent(has);
@@ -9008,16 +9644,16 @@ var ApiKeyForm = ({
9008
9644
  setBusy(false);
9009
9645
  }
9010
9646
  };
9011
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
9012
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "awr-keyform__label", children: [
9647
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
9648
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "awr-keyform__label", children: [
9013
9649
  label,
9014
- present && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "awr-keyform__saved", children: [
9015
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CheckIcon, { size: 12 }),
9650
+ present && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "awr-keyform__saved", children: [
9651
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckIcon, { size: 12 }),
9016
9652
  " stored, encrypted"
9017
9653
  ] })
9018
9654
  ] }),
9019
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "awr-keyform__row", children: [
9020
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9655
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "awr-keyform__row", children: [
9656
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9021
9657
  "input",
9022
9658
  {
9023
9659
  className: "awr-keyform__input",
@@ -9035,7 +9671,7 @@ var ApiKeyForm = ({
9035
9671
  disabled: busy
9036
9672
  }
9037
9673
  ),
9038
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9674
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9039
9675
  "button",
9040
9676
  {
9041
9677
  type: "button",
@@ -9045,7 +9681,7 @@ var ApiKeyForm = ({
9045
9681
  children: "Save"
9046
9682
  }
9047
9683
  ),
9048
- present && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9684
+ present && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9049
9685
  "button",
9050
9686
  {
9051
9687
  type: "button",
@@ -9066,6 +9702,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9066
9702
  APP_DEFAULT_HEIGHT,
9067
9703
  APP_MAX_HEIGHT,
9068
9704
  APP_MIN_HEIGHT,
9705
+ ASK_USER_TOOL_NAME,
9069
9706
  AgentChat,
9070
9707
  AgentComposer,
9071
9708
  AgentLabelsProvider,
@@ -9129,6 +9766,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9129
9766
  MessageList,
9130
9767
  ModelLoadBar,
9131
9768
  PlanView,
9769
+ QUESTION_TIMEOUT_MS,
9770
+ QuestionPrompt,
9132
9771
  SandboxedFrame,
9133
9772
  SessionBusyError,
9134
9773
  SourceView,
@@ -9155,6 +9794,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9155
9794
  appMessageTextOf,
9156
9795
  appMimeTypeOf,
9157
9796
  appSamplingErrorOf,
9797
+ askUserOutputKept,
9798
+ askUserWith,
9158
9799
  attachmentKindOf,
9159
9800
  attachmentRefusal,
9160
9801
  buildMcpAppDocument,
@@ -9167,6 +9808,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9167
9808
  createApprovalQueue,
9168
9809
  createFileTools,
9169
9810
  createInitialAgentState,
9811
+ createQuestionQueue,
9170
9812
  createRunControl,
9171
9813
  createSubagentTool,
9172
9814
  createWebLLMEngine,
@@ -9203,6 +9845,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9203
9845
  mcpAppSandboxShellCsp,
9204
9846
  mcpAppSandboxTarget,
9205
9847
  mediaFamilyOf,
9848
+ menuKeyTarget,
9849
+ menuSections,
9206
9850
  mergeChatRecord,
9207
9851
  mergeLabels,
9208
9852
  newChatId,
@@ -9213,6 +9857,9 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9213
9857
  pendingApprovalsOf,
9214
9858
  postStorageChange,
9215
9859
  preloadWebLLMModel,
9860
+ questionChoiceOf,
9861
+ questionOtherOf,
9862
+ questionTimeoutOf,
9216
9863
  resolveAppDownload,
9217
9864
  sandboxTokens,
9218
9865
  sandboxedCsp,
@@ -9243,6 +9890,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9243
9890
  webSearchOf,
9244
9891
  withAttachments,
9245
9892
  withCspFirst,
9246
- withPolicyFirst
9893
+ withPolicyFirst,
9894
+ withoutOwnWords
9247
9895
  });
9248
9896
  //# sourceMappingURL=index.cjs.map