@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.js CHANGED
@@ -109,6 +109,127 @@ var createApprovalQueue = () => {
109
109
  };
110
110
  };
111
111
 
112
+ // src/questions.ts
113
+ var ASK_USER_TOOL_NAME = "ask_user";
114
+ var QUESTION_TIMEOUT_MS = 3e5;
115
+ var TIMER_MAX_MS = 2147483647;
116
+ var questionTimeoutOf = (askUser) => {
117
+ if (!askUser) return void 0;
118
+ const raw = askUser === true ? void 0 : askUser.timeoutMs;
119
+ if (raw === void 0 || raw === null) return QUESTION_TIMEOUT_MS;
120
+ if (typeof raw !== "number" || !(raw > 0) || raw > TIMER_MAX_MS) return void 0;
121
+ return Math.max(1, Math.floor(raw));
122
+ };
123
+ var askUserWith = (askUser, handler) => {
124
+ if (!askUser) return askUser;
125
+ if (askUser === true) return { onQuestion: handler };
126
+ return askUser.onQuestion ? askUser : { ...askUser, onQuestion: handler };
127
+ };
128
+ var DECLINED = { declined: true };
129
+ var createQuestionQueue = (options = {}) => {
130
+ const now = options.now ?? Date.now;
131
+ const waiting = /* @__PURE__ */ new Map();
132
+ let disposed = false;
133
+ const list = () => [...waiting.values()].map((w) => w.question);
134
+ const changed = () => {
135
+ if (!disposed) options.onChange?.(list());
136
+ };
137
+ const handler = (request, ctx) => new Promise((resolve) => {
138
+ const signal = ctx?.signal;
139
+ if (disposed || signal?.aborted || waiting.has(request.id)) {
140
+ resolve(DECLINED);
141
+ return;
142
+ }
143
+ const onAbort = () => {
144
+ if (waiting.get(request.id)?.settle !== settle) return;
145
+ settle(DECLINED);
146
+ changed();
147
+ };
148
+ const settle = (answer) => {
149
+ waiting.delete(request.id);
150
+ signal?.removeEventListener("abort", onAbort);
151
+ resolve(answer);
152
+ };
153
+ signal?.addEventListener("abort", onAbort, { once: true });
154
+ const timeoutMs = typeof options.timeoutMs === "function" ? options.timeoutMs() : options.timeoutMs;
155
+ waiting.set(request.id, {
156
+ question: {
157
+ ...request,
158
+ options: request.options.map((o) => ({ ...o })),
159
+ ...timeoutMs !== void 0 ? { expiresAt: now() + timeoutMs } : {}
160
+ },
161
+ settle
162
+ });
163
+ changed();
164
+ });
165
+ return {
166
+ handler,
167
+ pending: list,
168
+ answer: (id, answer) => {
169
+ const entry = waiting.get(id);
170
+ if (!entry) return false;
171
+ entry.settle(answer);
172
+ changed();
173
+ return true;
174
+ },
175
+ cancel: (match) => {
176
+ let any = false;
177
+ for (const entry of [...waiting.values()]) {
178
+ if (match && !match(entry.question)) continue;
179
+ entry.settle(DECLINED);
180
+ any = true;
181
+ }
182
+ if (any) changed();
183
+ },
184
+ dispose: () => {
185
+ disposed = true;
186
+ for (const entry of [...waiting.values()]) entry.settle(DECLINED);
187
+ }
188
+ };
189
+ };
190
+ var questionChoiceOf = (question, picked) => {
191
+ const chosen = question.options.map((o) => o.label).filter((label) => picked.includes(label));
192
+ if (chosen.length === 0) return void 0;
193
+ return { choice: question.multiple ? chosen : chosen.slice(0, 1) };
194
+ };
195
+ var questionOtherOf = (question, text) => question.allowOther && typeof text === "string" && text.trim() ? { other: text.trim() } : void 0;
196
+ var LABELS_ONLY = [
197
+ "The user chose: ",
198
+ "The user chose not to answer.",
199
+ "The user did not answer in time.",
200
+ "The question could not be put to the user",
201
+ "You have already asked the user "
202
+ ];
203
+ var askUserOutputKept = (output, ok) => (
204
+ // A failed call is about the model's own arguments (a bad question): nobody was asked.
205
+ !ok || typeof output === "string" && LABELS_ONLY.some((start) => output.startsWith(start))
206
+ );
207
+ var withoutOutput = (call) => {
208
+ if (call.name !== ASK_USER_TOOL_NAME || askUserOutputKept(call.output, call.ok)) return call;
209
+ const { output: _dropped, ...rest } = call;
210
+ void _dropped;
211
+ return rest;
212
+ };
213
+ var withoutOwnWords = (event) => {
214
+ switch (event.type) {
215
+ case "step.tool-result": {
216
+ const cleaned = withoutOutput(event);
217
+ return cleaned === event ? event : { ...cleaned, output: void 0 };
218
+ }
219
+ case "step.complete": {
220
+ const calls = event.result.toolCalls;
221
+ const cleaned = calls.map(withoutOutput);
222
+ return cleaned.every((c, i) => c === calls[i]) ? event : { ...event, result: { ...event.result, toolCalls: cleaned } };
223
+ }
224
+ case "subagent.event": {
225
+ const inner = withoutOwnWords(event.event);
226
+ return inner === event.event ? event : { ...event, event: inner };
227
+ }
228
+ default:
229
+ return event;
230
+ }
231
+ };
232
+
112
233
  // src/state.ts
113
234
  import {
114
235
  isReplayedToolOutput
@@ -258,6 +379,35 @@ var answerElicitation = (state, event, stepId) => {
258
379
  ]
259
380
  };
260
381
  };
382
+ var addQuestion = (state, event, extra) => state.questions?.some((q) => q.id === event.id) ? state : {
383
+ ...state,
384
+ questions: [
385
+ ...state.questions ?? [],
386
+ {
387
+ id: event.id,
388
+ question: event.question,
389
+ options: event.options.map((o) => ({ ...o })),
390
+ multiple: event.multiple,
391
+ allowOther: event.allowOther,
392
+ ...extra.stepId ? { stepId: extra.stepId } : {},
393
+ ...extra.subagent ? { subagent: extra.subagent } : {},
394
+ ...extra.remote ? { remote: true } : {},
395
+ status: "pending"
396
+ }
397
+ ]
398
+ };
399
+ var answerQuestion = (state, event) => state.questions?.some((q) => q.id === event.id) ? {
400
+ ...state,
401
+ questions: state.questions.map(
402
+ (q) => q.id === event.id ? {
403
+ ...q,
404
+ status: event.action,
405
+ automatic: event.automatic,
406
+ ...event.action === "choice" && event.choice ? { choice: [...event.choice] } : {},
407
+ ...event.reason ? { reason: event.reason } : {}
408
+ } : q
409
+ )
410
+ } : state;
261
411
  var patchSubagent = (subagents, id, fn) => subagents.map((s) => s.id === id ? fn(s) : s);
262
412
  var runningStepId = (steps) => [...steps].reverse().find((s) => s.status === "running")?.id;
263
413
  var applySubagentEvent = (view, event) => {
@@ -490,6 +640,25 @@ var applySubagent = (state, event, ancestors, ctx) => {
490
640
  inner,
491
641
  known.subagents.find((s) => s.id === event.id)?.stepId
492
642
  );
643
+ // A helper (or a subagent the host defined) asks the person through the run's handler:
644
+ // the question is the person's to answer, like the run's own, marked with who asks.
645
+ case "user.question-asked": {
646
+ const asker = inner.subagent ?? { id: event.id, depth: ancestors.length + 1 };
647
+ const node = known.subagents.find((s) => s.id === asker.id);
648
+ return addQuestion(known, inner, {
649
+ ...ctx.remote ? { remote: true } : {},
650
+ // The helper's own step ids mean nothing here: the step that delegated it does.
651
+ stepId: (node ?? known.subagents.find((s) => s.id === event.id))?.stepId,
652
+ subagent: {
653
+ id: asker.id,
654
+ depth: asker.depth,
655
+ ...node ? { name: node.name } : {},
656
+ ...node?.role ? { role: node.role } : {}
657
+ }
658
+ });
659
+ }
660
+ case "user.question-answered":
661
+ return answerQuestion(known, inner);
493
662
  // What a subagent generated is in the same workspace: it shows in the turn (its step
494
663
  // ids are its own, so it is tied to no step here).
495
664
  case "media.generated":
@@ -951,6 +1120,15 @@ var applyEvent = (state, event, ctx) => {
951
1120
  });
952
1121
  case "mcp.elicitation-answered":
953
1122
  return answerElicitation(state, event, runningStepId(state.steps));
1123
+ case "user.question-asked":
1124
+ return addQuestion(state, event, {
1125
+ // Asked in the tab that runs the agent: shown here, answered there only.
1126
+ ...ctx.remote ? { remote: true } : {},
1127
+ stepId: event.step?.id,
1128
+ ...event.subagent ? { subagent: event.subagent } : {}
1129
+ });
1130
+ case "user.question-answered":
1131
+ return answerQuestion(state, event);
954
1132
  case "tool.approval-requested":
955
1133
  return {
956
1134
  ...state,
@@ -1082,6 +1260,12 @@ var applyEvent = (state, event, ctx) => {
1082
1260
  (e) => e.status === "pending" ? { ...e, status: "cancelled", automatic: true, reason: "stopped" } : e
1083
1261
  )
1084
1262
  } : {},
1263
+ // Nobody is asked any more once the run has stopped.
1264
+ ...state.questions ? {
1265
+ questions: state.questions.map(
1266
+ (q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
1267
+ )
1268
+ } : {},
1085
1269
  messages: finalizeAssistant(
1086
1270
  state.messages,
1087
1271
  state.finalText || "Stopped.",
@@ -1200,8 +1384,9 @@ var agentStateReducer = (state, action) => {
1200
1384
  return { ...state, remote };
1201
1385
  }
1202
1386
  case "event": {
1387
+ const event = withoutOwnWords(action.event);
1203
1388
  const next = syncRunMessage(
1204
- applyEvent(state, action.event, {
1389
+ applyEvent(state, event, {
1205
1390
  at: action.at,
1206
1391
  attachments: action.attachments,
1207
1392
  ...action.remote ? { remote: true } : {},
@@ -1209,7 +1394,7 @@ var agentStateReducer = (state, action) => {
1209
1394
  })
1210
1395
  );
1211
1396
  const cap = action.maxEvents ?? 200;
1212
- const events = cap > 0 ? [...state.events, action.event].slice(-cap) : [...state.events, action.event];
1397
+ const events = cap > 0 ? [...state.events, event].slice(-cap) : [...state.events, event];
1213
1398
  return { ...next, events };
1214
1399
  }
1215
1400
  case "undelivered":
@@ -1260,6 +1445,13 @@ var useAgent = (config, options = {}) => {
1260
1445
  (decision) => approvals.settleAll(decision),
1261
1446
  [approvals]
1262
1447
  );
1448
+ const [pendingQuestions, setPendingQuestions] = useState([]);
1449
+ const [questionQueue] = useState(
1450
+ () => createQuestionQueue({
1451
+ timeoutMs: () => questionTimeoutOf(configRef.current.askUser),
1452
+ onChange: setPendingQuestions
1453
+ })
1454
+ );
1263
1455
  const uiOnRequest = useCallback(
1264
1456
  (req2, ctx) => (req2.app ? appApprovals : approvals).handler(req2, ctx),
1265
1457
  [approvals, appApprovals]
@@ -1294,10 +1486,12 @@ var useAgent = (config, options = {}) => {
1294
1486
  return;
1295
1487
  }
1296
1488
  const routeApprovals = optionsRef.current.approvals !== false && !cfg.toolApproval?.onRequest;
1297
- const built = routeApprovals ? {
1489
+ const askUser = optionsRef.current.questions !== false ? askUserWith(cfg.askUser, questionQueue.handler) : cfg.askUser;
1490
+ const built = {
1298
1491
  ...cfg,
1299
- toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest }
1300
- } : cfg;
1492
+ ...routeApprovals ? { toolApproval: { ...cfg.toolApproval, mode: modeRef.current, onRequest: uiOnRequest } } : {},
1493
+ ...askUser !== cfg.askUser ? { askUser } : {}
1494
+ };
1301
1495
  let cancelled = false;
1302
1496
  setBuildStatus({ status: "initializing" });
1303
1497
  createAgent(built).then((agent) => {
@@ -1370,8 +1564,9 @@ var useAgent = (config, options = {}) => {
1370
1564
  abortRef.current?.abort();
1371
1565
  settleAll({ approved: false, reason: "the view was closed" });
1372
1566
  appApprovals.settleAll({ approved: false, reason: "the view was closed" });
1567
+ questionQueue.dispose();
1373
1568
  },
1374
- [settleAll, appApprovals]
1569
+ [settleAll, appApprovals, questionQueue]
1375
1570
  );
1376
1571
  const runRef = useRef(void 0);
1377
1572
  const run = useCallback(
@@ -1439,6 +1634,7 @@ var useAgent = (config, options = {}) => {
1439
1634
  startedRef.current = false;
1440
1635
  controlRef.current = void 0;
1441
1636
  settleAll({ approved: false, reason: "the run ended" });
1637
+ questionQueue.cancel();
1442
1638
  dispatch({ type: "status", ...buildStatusRef.current });
1443
1639
  if (stopped && !began && shownGoal.trim()) left = [shownGoal, ...left];
1444
1640
  if (left.length > 0) {
@@ -1453,7 +1649,7 @@ var useAgent = (config, options = {}) => {
1453
1649
  }
1454
1650
  }
1455
1651
  },
1456
- [settleAll]
1652
+ [settleAll, questionQueue]
1457
1653
  );
1458
1654
  runRef.current = run;
1459
1655
  const send = useCallback((text) => controlRef.current?.send(text) ?? false, []);
@@ -1489,7 +1685,12 @@ var useAgent = (config, options = {}) => {
1489
1685
  const stop = useCallback(() => {
1490
1686
  abortRef.current?.abort();
1491
1687
  settleAll({ approved: false, reason: "stopped by the user" });
1492
- }, [settleAll]);
1688
+ questionQueue.cancel();
1689
+ }, [settleAll, questionQueue]);
1690
+ const answerQuestion2 = useCallback(
1691
+ (id, answer) => questionQueue.answer(id, answer),
1692
+ [questionQueue]
1693
+ );
1493
1694
  const reset = useCallback(() => {
1494
1695
  dispatch({ type: "reset" });
1495
1696
  void configRef.current.memory?.clear(sessionRef.current).catch(() => {
@@ -1614,6 +1815,8 @@ var useAgent = (config, options = {}) => {
1614
1815
  pendingApprovals: pendingApprovalsOf(state),
1615
1816
  approve,
1616
1817
  deny,
1818
+ pendingQuestions,
1819
+ answerQuestion: answerQuestion2,
1617
1820
  approvalMode,
1618
1821
  setApprovalMode,
1619
1822
  approveAppToolCall,
@@ -2316,6 +2519,31 @@ var attachmentRefusal = (kind, caps, canConvertPdf = false) => {
2316
2519
  }
2317
2520
  return void 0;
2318
2521
  };
2522
+ var menuSections = (options) => {
2523
+ const out = [];
2524
+ for (const option of options) {
2525
+ const section = option.section || void 0;
2526
+ const last = out[out.length - 1];
2527
+ if (last && last.section === section) last.options.push(option);
2528
+ else out.push({ ...section ? { section } : {}, options: [option] });
2529
+ }
2530
+ return out;
2531
+ };
2532
+ var menuKeyTarget = (key, index, count) => {
2533
+ if (count <= 0) return void 0;
2534
+ switch (key) {
2535
+ case "ArrowDown":
2536
+ return index < 0 ? 0 : (index + 1) % count;
2537
+ case "ArrowUp":
2538
+ return index < 0 ? count - 1 : (index - 1 + count) % count;
2539
+ case "Home":
2540
+ return 0;
2541
+ case "End":
2542
+ return count - 1;
2543
+ default:
2544
+ return void 0;
2545
+ }
2546
+ };
2319
2547
  var formatElapsed = (ms) => {
2320
2548
  const s = Math.max(0, Math.floor(ms / 1e3));
2321
2549
  if (s < 60) return `${s}s`;
@@ -2636,6 +2864,25 @@ var defaultLabels = {
2636
2864
  "no-tool-call": "no tool call was in progress"
2637
2865
  },
2638
2866
  elicitationDismiss: "Dismiss",
2867
+ questionLead: "The agent asks you",
2868
+ questionLeadHelper: (role) => role ? `The helper \u201C${role}\u201D asks you` : "A helper the agent started asks you",
2869
+ questionCount: (index, total) => `${index} of ${total}`,
2870
+ questionSeveral: "Pick one or more, then Send.",
2871
+ questionSend: "Send",
2872
+ questionOther: "Other\u2026",
2873
+ questionOtherLabel: "Your answer",
2874
+ questionSkip: "Skip",
2875
+ questionExpiresIn: (time) => `If you do not answer, the agent decides by itself in ${time}`,
2876
+ questionRemote: "Answered in the other tab, where the agent is running.",
2877
+ questionAutomatic: (reason) => `The agent went on without your answer: ${reason}.`,
2878
+ questionReasons: {
2879
+ timeout: "nobody answered in time",
2880
+ stopped: "the run was stopped",
2881
+ "handler-error": "the question could not be shown",
2882
+ "invalid-answer": "the answer did not fit the question",
2883
+ "cannot-park": "the question could not wait here"
2884
+ },
2885
+ questionDismiss: "Dismiss",
2639
2886
  appFrom: (server) => `App from server \u201C${server}\u201D`,
2640
2887
  appSandboxed: "sandboxed",
2641
2888
  appSandboxedOrigin: "sandboxed on its own origin",
@@ -2727,6 +2974,7 @@ var NESTED = [
2727
2974
  "decisionReasons",
2728
2975
  "elicitationErrors",
2729
2976
  "elicitationReasons",
2977
+ "questionReasons",
2730
2978
  "fileKinds",
2731
2979
  "appSandboxReasons"
2732
2980
  ];
@@ -2814,7 +3062,7 @@ var useAgentContext = () => {
2814
3062
  var useOptionalAgentContext = () => useContext2(AgentContext);
2815
3063
 
2816
3064
  // src/components/AgentChat.tsx
2817
- import { useEffect as useEffect16, useRef as useRef11, useState as useState16 } from "react";
3065
+ import { useEffect as useEffect17, useRef as useRef12, useState as useState17 } from "react";
2818
3066
  import { createPortal as createPortal2 } from "react-dom";
2819
3067
 
2820
3068
  // src/hooks/use-follow-scroll.ts
@@ -4724,8 +4972,8 @@ var McpAppLine = ({ app, note, action, onAction, labels, className }) => {
4724
4972
  };
4725
4973
 
4726
4974
  // src/components/AgentComposer.tsx
4727
- import { useEffect as useEffect9, useLayoutEffect as useLayoutEffect3, useMemo as useMemo6, useRef as useRef8, useState as useState9 } from "react";
4728
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
4975
+ import { Fragment as Fragment2, useEffect as useEffect9, useLayoutEffect as useLayoutEffect3, useMemo as useMemo6, useRef as useRef8, useState as useState9 } from "react";
4976
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
4729
4977
  var thinkingDefaults = (l) => [
4730
4978
  { id: "off", label: l.thinkingLevels.off },
4731
4979
  { id: "none", label: l.thinkingLevels.none },
@@ -4735,6 +4983,34 @@ var thinkingDefaults = (l) => [
4735
4983
  ];
4736
4984
  var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
4737
4985
  var ModeIcon = ({ mode }) => mode === "autopilot" ? /* @__PURE__ */ jsx5(BoltIcon, { size: 14 }) : mode === "read-only" ? /* @__PURE__ */ jsx5(EyeIcon, { size: 14 }) : /* @__PURE__ */ jsx5(ShieldIcon, { size: 14 });
4986
+ var useMenuKeys = (open, menuRef, chipRef, close) => {
4987
+ useEffect9(() => {
4988
+ if (!open) return;
4989
+ const menu = menuRef.current;
4990
+ const rows = menu ? [...menu.querySelectorAll('[role^="menuitem"]')] : [];
4991
+ (rows.find((r) => r.getAttribute("aria-checked") === "true") ?? rows[0])?.focus();
4992
+ }, [open, menuRef]);
4993
+ return (e) => {
4994
+ const menu = menuRef.current;
4995
+ if (!menu) return;
4996
+ if (e.key === "Escape") {
4997
+ e.preventDefault();
4998
+ close();
4999
+ chipRef.current?.focus();
5000
+ return;
5001
+ }
5002
+ const rows = [...menu.querySelectorAll('[role^="menuitem"]')];
5003
+ const to = menuKeyTarget(
5004
+ e.key,
5005
+ rows.indexOf(document.activeElement),
5006
+ rows.length
5007
+ );
5008
+ if (to === void 0) return;
5009
+ e.preventDefault();
5010
+ rows[to].focus();
5011
+ };
5012
+ };
5013
+ var opensMenu = (key) => key === "ArrowDown" || key === "ArrowUp";
4738
5014
  var attachSeq = 0;
4739
5015
  var useIsoLayoutEffect3 = typeof window === "undefined" ? useEffect9 : useLayoutEffect3;
4740
5016
  var useMenuPlacement = (open, anchor, align) => {
@@ -4826,6 +5102,10 @@ var AgentComposer = ({
4826
5102
  const rootRef = useRef8(null);
4827
5103
  const modelRef = useRef8(null);
4828
5104
  const modeRef = useRef8(null);
5105
+ const modelChipRef = useRef8(null);
5106
+ const modeChipRef = useRef8(null);
5107
+ const modelMenuRef = useRef8(null);
5108
+ const modeMenuRef = useRef8(null);
4829
5109
  const [dropRect, setDropRect] = useState9();
4830
5110
  const [compactBar, setCompactBar] = useState9(false);
4831
5111
  useEffect9(() => {
@@ -4954,6 +5234,9 @@ ${draftText}` : draftText);
4954
5234
  const commandsStyle = useMenuPlacement(paletteOpen, rootRef, "stretch");
4955
5235
  const modelStyle = useMenuPlacement(menu === "model", modelRef, "left");
4956
5236
  const modeStyle = useMenuPlacement(menu === "mode", modeRef, "right");
5237
+ const closeMenu = () => setMenu(void 0);
5238
+ const modelMenuKeys = useMenuKeys(menu === "model", modelMenuRef, modelChipRef, closeMenu);
5239
+ const modeMenuKeys = useMenuKeys(menu === "mode", modeMenuRef, modeChipRef, closeMenu);
4957
5240
  useEffect9(() => setActive(0), [text, menu]);
4958
5241
  useEffect9(() => {
4959
5242
  if (!menu) return;
@@ -5351,7 +5634,7 @@ ${draftText}` : draftText);
5351
5634
  ] }),
5352
5635
  stt.listening && stt.interim && /* @__PURE__ */ jsx5("div", { className: "awr-composer2__interim", children: stt.interim }),
5353
5636
  /* @__PURE__ */ jsxs3("div", { className: "awr-toolbar", children: [
5354
- attachments !== false && /* @__PURE__ */ jsxs3(Fragment2, { children: [
5637
+ attachments !== false && /* @__PURE__ */ jsxs3(Fragment3, { children: [
5355
5638
  /* @__PURE__ */ jsx5(
5356
5639
  "button",
5357
5640
  {
@@ -5411,8 +5694,15 @@ ${draftText}` : draftText);
5411
5694
  "button",
5412
5695
  {
5413
5696
  type: "button",
5697
+ ref: modelChipRef,
5414
5698
  className: "awr-tchip awr-tchip--btn",
5415
5699
  onClick: () => setMenu(menu === "model" ? void 0 : "model"),
5700
+ onKeyDown: (e) => {
5701
+ if (menu !== "model" && opensMenu(e.key)) {
5702
+ e.preventDefault();
5703
+ setMenu("model");
5704
+ }
5705
+ },
5416
5706
  "aria-haspopup": "menu",
5417
5707
  "aria-expanded": menu === "model",
5418
5708
  title: [model?.label, thinkingLabel].filter(Boolean).join(" \xB7 "),
@@ -5422,47 +5712,81 @@ ${draftText}` : draftText);
5422
5712
  ]
5423
5713
  }
5424
5714
  ),
5425
- menu === "model" && /* @__PURE__ */ jsxs3("div", { className: "awr-menu awr-menu--pop", style: modelStyle, role: "menu", children: [
5426
- thinking && /* @__PURE__ */ jsxs3(Fragment2, { children: [
5427
- /* @__PURE__ */ jsx5("div", { className: "awr-menu__head", children: L.thinking }),
5428
- thinkingOptions.map((o) => /* @__PURE__ */ jsx5(
5429
- "button",
5430
- {
5431
- type: "button",
5432
- role: "menuitemradio",
5433
- "aria-checked": thinking.value === o.id,
5434
- className: `awr-menu__item${thinking.value === o.id ? " is-active" : ""}`,
5435
- onClick: () => {
5436
- thinking.onChange(o.id);
5437
- setMenu(void 0);
5438
- },
5439
- children: o.label
5440
- },
5441
- o.id
5442
- ))
5443
- ] }),
5444
- model?.options?.length ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
5445
- /* @__PURE__ */ jsx5("div", { className: "awr-menu__head", children: L.model }),
5446
- model.options.map((o) => /* @__PURE__ */ jsxs3(
5447
- "button",
5448
- {
5449
- type: "button",
5450
- role: "menuitemradio",
5451
- "aria-checked": model.value === o.id,
5452
- className: `awr-menu__item${model.value === o.id ? " is-active" : ""}`,
5453
- onClick: () => {
5454
- model.onSelect?.(o.id);
5455
- setMenu(void 0);
5456
- },
5457
- children: [
5458
- o.label,
5459
- o.group && /* @__PURE__ */ jsx5("span", { className: "awr-menu__group", children: o.group })
5460
- ]
5461
- },
5462
- o.id
5463
- ))
5464
- ] }) : null
5465
- ] })
5715
+ menu === "model" && /* @__PURE__ */ jsxs3(
5716
+ "div",
5717
+ {
5718
+ className: "awr-menu awr-menu--pop",
5719
+ style: modelStyle,
5720
+ role: "menu",
5721
+ ref: modelMenuRef,
5722
+ onKeyDown: modelMenuKeys,
5723
+ children: [
5724
+ thinking && /* @__PURE__ */ jsxs3(Fragment3, { children: [
5725
+ /* @__PURE__ */ jsx5("div", { className: "awr-menu__head", children: L.thinking }),
5726
+ thinkingOptions.map((o) => /* @__PURE__ */ jsx5(
5727
+ "button",
5728
+ {
5729
+ type: "button",
5730
+ role: "menuitemradio",
5731
+ "aria-checked": thinking.value === o.id,
5732
+ className: `awr-menu__item${thinking.value === o.id ? " is-active" : ""}`,
5733
+ onClick: () => {
5734
+ thinking.onChange(o.id);
5735
+ setMenu(void 0);
5736
+ },
5737
+ children: o.label
5738
+ },
5739
+ o.id
5740
+ ))
5741
+ ] }),
5742
+ model?.options?.length ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
5743
+ /* @__PURE__ */ jsx5("div", { className: "awr-menu__head", children: L.model }),
5744
+ menuSections(model.options).map((run, i, runs) => {
5745
+ const rows = run.options.map((o) => /* @__PURE__ */ jsxs3(
5746
+ "button",
5747
+ {
5748
+ type: "button",
5749
+ role: "menuitemradio",
5750
+ "aria-checked": model.value === o.id,
5751
+ className: `awr-menu__item${model.value === o.id ? " is-active" : ""}`,
5752
+ onClick: () => {
5753
+ model.onSelect?.(o.id);
5754
+ setMenu(void 0);
5755
+ },
5756
+ children: [
5757
+ o.label,
5758
+ o.group && /* @__PURE__ */ jsx5("span", { className: "awr-menu__group", children: o.group })
5759
+ ]
5760
+ },
5761
+ o.id
5762
+ ));
5763
+ if (run.section)
5764
+ return /* @__PURE__ */ jsxs3(
5765
+ "div",
5766
+ {
5767
+ role: "group",
5768
+ "aria-label": run.section,
5769
+ className: "awr-menu__section",
5770
+ children: [
5771
+ /* @__PURE__ */ jsx5(
5772
+ "div",
5773
+ {
5774
+ className: "awr-menu__head awr-menu__sectionhead",
5775
+ "aria-hidden": "true",
5776
+ children: run.section
5777
+ }
5778
+ ),
5779
+ rows
5780
+ ]
5781
+ },
5782
+ `s${i}`
5783
+ );
5784
+ return runs[i - 1]?.section ? /* @__PURE__ */ jsx5("div", { className: "awr-menu__section awr-menu__section--plain", children: rows }, `s${i}`) : /* @__PURE__ */ jsx5(Fragment2, { children: rows }, `s${i}`);
5785
+ })
5786
+ ] }) : null
5787
+ ]
5788
+ }
5789
+ )
5466
5790
  ] }),
5467
5791
  /* @__PURE__ */ jsx5("span", { className: "awr-toolbar__spacer" }),
5468
5792
  toolbarEnd,
@@ -5471,9 +5795,16 @@ ${draftText}` : draftText);
5471
5795
  "button",
5472
5796
  {
5473
5797
  type: "button",
5798
+ ref: modeChipRef,
5474
5799
  className: `awr-tchip awr-tchip--btn awr-mode awr-mode--${agent.approvalMode}`,
5475
5800
  title: MODE_CHIP[agent.approvalMode].hint,
5476
5801
  onClick: () => setMenu(menu === "mode" ? void 0 : "mode"),
5802
+ onKeyDown: (e) => {
5803
+ if (menu !== "mode" && opensMenu(e.key)) {
5804
+ e.preventDefault();
5805
+ setMenu("mode");
5806
+ }
5807
+ },
5477
5808
  "aria-haspopup": "menu",
5478
5809
  "aria-expanded": menu === "mode",
5479
5810
  "aria-label": `${L.toolConsent}: ${MODE_CHIP[agent.approvalMode].label}`,
@@ -5483,29 +5814,39 @@ ${draftText}` : draftText);
5483
5814
  ]
5484
5815
  }
5485
5816
  ),
5486
- menu === "mode" && /* @__PURE__ */ jsxs3("div", { className: "awr-menu awr-menu--pop", style: modeStyle, role: "menu", children: [
5487
- /* @__PURE__ */ jsx5("div", { className: "awr-menu__head", children: L.toolConsent }),
5488
- MODES.map((m) => /* @__PURE__ */ jsxs3(
5489
- "button",
5490
- {
5491
- type: "button",
5492
- role: "menuitemradio",
5493
- "aria-checked": agent.approvalMode === m,
5494
- className: `awr-menu__item${agent.approvalMode === m ? " is-active" : ""}`,
5495
- onClick: () => {
5496
- agent.setApprovalMode(m);
5497
- setMenu(void 0);
5498
- },
5499
- children: [
5500
- /* @__PURE__ */ jsx5(ModeIcon, { mode: m }),
5501
- " ",
5502
- MODE_CHIP[m].label,
5503
- /* @__PURE__ */ jsx5("span", { className: "awr-menu__desc", children: MODE_CHIP[m].hint })
5504
- ]
5505
- },
5506
- m
5507
- ))
5508
- ] })
5817
+ menu === "mode" && /* @__PURE__ */ jsxs3(
5818
+ "div",
5819
+ {
5820
+ className: "awr-menu awr-menu--pop",
5821
+ style: modeStyle,
5822
+ role: "menu",
5823
+ ref: modeMenuRef,
5824
+ onKeyDown: modeMenuKeys,
5825
+ children: [
5826
+ /* @__PURE__ */ jsx5("div", { className: "awr-menu__head", children: L.toolConsent }),
5827
+ MODES.map((m) => /* @__PURE__ */ jsxs3(
5828
+ "button",
5829
+ {
5830
+ type: "button",
5831
+ role: "menuitemradio",
5832
+ "aria-checked": agent.approvalMode === m,
5833
+ className: `awr-menu__item${agent.approvalMode === m ? " is-active" : ""}`,
5834
+ onClick: () => {
5835
+ agent.setApprovalMode(m);
5836
+ setMenu(void 0);
5837
+ },
5838
+ children: [
5839
+ /* @__PURE__ */ jsx5(ModeIcon, { mode: m }),
5840
+ " ",
5841
+ MODE_CHIP[m].label,
5842
+ /* @__PURE__ */ jsx5("span", { className: "awr-menu__desc", children: MODE_CHIP[m].hint })
5843
+ ]
5844
+ },
5845
+ m
5846
+ ))
5847
+ ]
5848
+ }
5849
+ )
5509
5850
  ] }),
5510
5851
  canSteer && /* @__PURE__ */ jsx5("button", { type: "button", className: "awr-sendbtn", onClick: submit, "aria-label": L.steer, children: /* @__PURE__ */ jsx5(SendIcon, { size: 16 }) }),
5511
5852
  busy ? /* @__PURE__ */ jsx5(
@@ -5535,7 +5876,7 @@ ${draftText}` : draftText);
5535
5876
  };
5536
5877
 
5537
5878
  // src/components/ChatHistoryList.tsx
5538
- import { Fragment as Fragment3 } from "react";
5879
+ import { Fragment as Fragment4 } from "react";
5539
5880
  import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
5540
5881
  var defaultTime = (ms) => {
5541
5882
  const d = new Date(ms);
@@ -5605,7 +5946,7 @@ var ChatHistoryList = ({
5605
5946
  }
5606
5947
  )
5607
5948
  ] }, c.id);
5608
- return renderChat ? /* @__PURE__ */ jsx6(Fragment3, { children: renderChat(c, active, row) }, c.id) : row;
5949
+ return renderChat ? /* @__PURE__ */ jsx6(Fragment4, { children: renderChat(c, active, row) }, c.id) : row;
5609
5950
  }) })
5610
5951
  ] });
5611
5952
  };
@@ -6012,12 +6353,12 @@ var ElicitationPrompt = ({
6012
6353
  };
6013
6354
 
6014
6355
  // src/components/FilesPanel.tsx
6015
- import { Fragment as Fragment5, useEffect as useEffect12, useRef as useRef10, useState as useState12 } from "react";
6356
+ import { Fragment as Fragment6, useEffect as useEffect12, useRef as useRef10, useState as useState12 } from "react";
6016
6357
 
6017
6358
  // src/components/ImageViewer.tsx
6018
6359
  import { createContext as createContext3, useContext as useContext3, useEffect as useEffect11, useRef as useRef9, useState as useState11 } from "react";
6019
6360
  import { createPortal } from "react-dom";
6020
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
6361
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
6021
6362
  var fileNameOf = (name) => name.split(/[\\/]/).filter(Boolean).pop() ?? name;
6022
6363
  var SWIPE_PX = 48;
6023
6364
  var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
@@ -6158,7 +6499,7 @@ var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
6158
6499
  )
6159
6500
  }
6160
6501
  ),
6161
- count > 1 && /* @__PURE__ */ jsxs7(Fragment4, { children: [
6502
+ count > 1 && /* @__PURE__ */ jsxs7(Fragment5, { children: [
6162
6503
  /* @__PURE__ */ jsx9(
6163
6504
  "button",
6164
6505
  {
@@ -6231,7 +6572,7 @@ var ImageThumb = ({
6231
6572
  onClose: close,
6232
6573
  labels
6233
6574
  });
6234
- return /* @__PURE__ */ jsxs7(Fragment4, { children: [
6575
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
6235
6576
  /* @__PURE__ */ jsx9(
6236
6577
  "button",
6237
6578
  {
@@ -6261,7 +6602,7 @@ var ImageThumb = ({
6261
6602
  };
6262
6603
 
6263
6604
  // src/components/FilesPanel.tsx
6264
- import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
6605
+ import { Fragment as Fragment7, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
6265
6606
  var PREVIEW_CHARS = 2e4;
6266
6607
  var FilesPanel = ({
6267
6608
  files: vfs,
@@ -6305,7 +6646,7 @@ var FilesPanel = ({
6305
6646
  return /* @__PURE__ */ jsxs8("div", { className: ["awr-filespanel", className].filter(Boolean).join(" "), children: [
6306
6647
  /* @__PURE__ */ jsxs8("div", { className: "awr-panel__head", children: [
6307
6648
  /* @__PURE__ */ jsx10("span", { className: "awr-panel__title", children: title ?? L.files }),
6308
- allowUpload && /* @__PURE__ */ jsxs8(Fragment6, { children: [
6649
+ allowUpload && /* @__PURE__ */ jsxs8(Fragment7, { children: [
6309
6650
  /* @__PURE__ */ jsx10(
6310
6651
  "button",
6311
6652
  {
@@ -6380,7 +6721,7 @@ var FilesPanel = ({
6380
6721
  },
6381
6722
  f.path
6382
6723
  );
6383
- return renderFile ? /* @__PURE__ */ jsx10(Fragment5, { children: renderFile(f, row) }, f.path) : row;
6724
+ return renderFile ? /* @__PURE__ */ jsx10(Fragment6, { children: renderFile(f, row) }, f.path) : row;
6384
6725
  }) }),
6385
6726
  preview && /* @__PURE__ */ jsx10("div", { className: "awr-filepreview", children: preview.kind === "image" ? (
6386
6727
  // A click (Enter, Space) opens it over the chat, fitted to the screen.
@@ -6400,7 +6741,7 @@ var FilesPanel = ({
6400
6741
  };
6401
6742
 
6402
6743
  // src/components/FileChips.tsx
6403
- import { Fragment as Fragment7, useEffect as useEffect14, useMemo as useMemo7, useState as useState14 } from "react";
6744
+ import { Fragment as Fragment8, useEffect as useEffect14, useMemo as useMemo7, useState as useState14 } from "react";
6404
6745
 
6405
6746
  // src/file-kinds.ts
6406
6747
  import { MEDIA_IMAGE_TYPES, isTextMime } from "@dudko.dev/agent-web";
@@ -6548,7 +6889,7 @@ var SandboxedFrame = ({
6548
6889
  ] });
6549
6890
 
6550
6891
  // src/components/FileChips.tsx
6551
- import { Fragment as Fragment8, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
6892
+ import { Fragment as Fragment9, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
6552
6893
  var FILE_PREVIEW_CHARS = 2e4;
6553
6894
  var textOf = (file) => file.encoding === "base64" ? new TextDecoder().decode(bytesOf(file.content, "base64")) : file.content;
6554
6895
  var KIND_ICON = {
@@ -6612,10 +6953,10 @@ var SourceView = ({
6612
6953
  () => linesOf(html ? tokenizeHtml(shown) : [{ kind: "text", text: shown }]),
6613
6954
  [shown, html]
6614
6955
  );
6615
- return /* @__PURE__ */ jsxs11(Fragment8, { children: [
6956
+ return /* @__PURE__ */ jsxs11(Fragment9, { children: [
6616
6957
  /* @__PURE__ */ jsx13("pre", { className: ["awr-source", className].filter(Boolean).join(" "), tabIndex: 0, children: lines.map((line, i) => /* @__PURE__ */ jsxs11("span", { className: "awr-source__line", children: [
6617
6958
  line.map(
6618
- (t, k) => t.kind === "text" ? /* @__PURE__ */ jsx13(Fragment7, { children: t.text }, k) : /* @__PURE__ */ jsx13("span", { className: `awr-source__${t.kind}`, children: t.text }, k)
6959
+ (t, k) => t.kind === "text" ? /* @__PURE__ */ jsx13(Fragment8, { children: t.text }, k) : /* @__PURE__ */ jsx13("span", { className: `awr-source__${t.kind}`, children: t.text }, k)
6619
6960
  ),
6620
6961
  "\n"
6621
6962
  ] }, i)) }),
@@ -6641,11 +6982,11 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
6641
6982
  html: showing === "preview" ? html : void 0,
6642
6983
  scripts,
6643
6984
  height: tall ? height * 2 : height,
6644
- label: /* @__PURE__ */ jsxs11(Fragment8, { children: [
6985
+ label: /* @__PURE__ */ jsxs11(Fragment9, { children: [
6645
6986
  /* @__PURE__ */ jsx13(CodeIcon, { size: 14, className: "awr-frame__icon" }),
6646
6987
  /* @__PURE__ */ jsxs11("span", { className: "awr-frame__titles", children: [
6647
6988
  /* @__PURE__ */ jsx13("span", { className: "awr-frame__title", children: L.htmlFrameTitle }),
6648
- /* @__PURE__ */ jsx13("span", { className: "awr-frame__badges", children: showing === "preview" ? /* @__PURE__ */ jsxs11(Fragment8, { children: [
6989
+ /* @__PURE__ */ jsx13("span", { className: "awr-frame__badges", children: showing === "preview" ? /* @__PURE__ */ jsxs11(Fragment9, { children: [
6649
6990
  /* @__PURE__ */ jsx13(LockIcon, { size: 11 }),
6650
6991
  " ",
6651
6992
  L.htmlSandboxed,
@@ -6656,7 +6997,7 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
6656
6997
  ] }) : L.htmlSourceNote })
6657
6998
  ] })
6658
6999
  ] }),
6659
- actions: canFrame ? /* @__PURE__ */ jsxs11(Fragment8, { children: [
7000
+ actions: canFrame ? /* @__PURE__ */ jsxs11(Fragment9, { children: [
6660
7001
  /* @__PURE__ */ jsx13(
6661
7002
  Seg,
6662
7003
  {
@@ -6683,7 +7024,7 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
6683
7024
  }
6684
7025
  )
6685
7026
  ] }) : void 0,
6686
- footer: /* @__PURE__ */ jsxs11(Fragment8, { children: [
7027
+ footer: /* @__PURE__ */ jsxs11(Fragment9, { children: [
6687
7028
  /* @__PURE__ */ jsx13(FileIcon, { size: 11 }),
6688
7029
  /* @__PURE__ */ jsx13("code", { children: written.path }),
6689
7030
  /* @__PURE__ */ jsxs11("span", { className: "awr-frame__footmeta", children: [
@@ -6695,7 +7036,7 @@ var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
6695
7036
  linked.length > 0 ? ` \xB7 ${L.htmlLinkedFiles(linked.join(", "))}` : ""
6696
7037
  ] })
6697
7038
  ] }),
6698
- children: showing === "source" ? /* @__PURE__ */ jsxs11(Fragment8, { children: [
7039
+ children: showing === "source" ? /* @__PURE__ */ jsxs11(Fragment9, { children: [
6699
7040
  tooLarge && options ? /* @__PURE__ */ jsx13("p", { className: "awr-fileview__cut", children: L.htmlTooLarge }) : null,
6700
7041
  /* @__PURE__ */ jsx13(SourceView, { text: html, html: true, maxChars: previewChars, className: "awr-frame__source" })
6701
7042
  ] }) : void 0
@@ -6768,7 +7109,7 @@ var TextPreview = ({
6768
7109
  ]
6769
7110
  }
6770
7111
  ) }),
6771
- /* @__PURE__ */ jsx13("div", { className: `awr-fileview__body${long && !all ? " is-folded" : ""}`, children: showing === "rendered" ? /* @__PURE__ */ jsxs11(Fragment8, { children: [
7112
+ /* @__PURE__ */ jsx13("div", { className: `awr-fileview__body${long && !all ? " is-folded" : ""}`, children: showing === "rendered" ? /* @__PURE__ */ jsxs11(Fragment9, { children: [
6772
7113
  /* @__PURE__ */ jsx13("div", { className: "awr-fileview__rendered", children: rendered }),
6773
7114
  text.length > previewChars && /* @__PURE__ */ jsx13("p", { className: "awr-fileview__cut", children: L.fileCut(previewChars) })
6774
7115
  ] }) : /* @__PURE__ */ jsx13(SourceView, { text, maxChars: previewChars }) }),
@@ -6921,10 +7262,10 @@ var FileChip = ({
6921
7262
  };
6922
7263
 
6923
7264
  // src/components/StepList.tsx
6924
- import { Fragment as Fragment10 } from "react";
7265
+ import { Fragment as Fragment11 } from "react";
6925
7266
 
6926
7267
  // src/components/SubagentTree.tsx
6927
- import { Fragment as Fragment9, useEffect as useEffect15, useState as useState15 } from "react";
7268
+ import { Fragment as Fragment10, useEffect as useEffect15, useState as useState15 } from "react";
6928
7269
  import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
6929
7270
  var useElapsed = (startedAt, running) => {
6930
7271
  const [now, setNow] = useState15(void 0);
@@ -7018,7 +7359,7 @@ var SubagentTree = ({
7018
7359
  },
7019
7360
  node.id
7020
7361
  );
7021
- return renderSubagent ? /* @__PURE__ */ jsx14(Fragment9, { children: renderSubagent(node, row) }, node.id) : row;
7362
+ return renderSubagent ? /* @__PURE__ */ jsx14(Fragment10, { children: renderSubagent(node, row) }, node.id) : row;
7022
7363
  })
7023
7364
  }
7024
7365
  );
@@ -7197,7 +7538,7 @@ var StepItem = ({
7197
7538
  },
7198
7539
  i
7199
7540
  );
7200
- return renderToolCall ? /* @__PURE__ */ jsx15(Fragment10, { children: renderToolCall(call, row) }, i) : row;
7541
+ return renderToolCall ? /* @__PURE__ */ jsx15(Fragment11, { children: renderToolCall(call, row) }, i) : row;
7201
7542
  }) }),
7202
7543
  approvals.length > 0 && /* @__PURE__ */ jsx15("ul", { className: "awr-step__tools", children: approvals.map((a) => /* @__PURE__ */ jsxs13("li", { className: `awr-tool awr-tool__row awr-tool--approval-${a.status}`, children: [
7203
7544
  /* @__PURE__ */ jsx15(ShieldIcon, { size: 13, className: "awr-tool__icon" }),
@@ -7492,8 +7833,279 @@ var ModelLoadBar = ({ load, className }) => {
7492
7833
  ] });
7493
7834
  };
7494
7835
 
7495
- // src/components/ToolApprovalPrompt.tsx
7836
+ // src/components/QuestionPrompt.tsx
7837
+ import { useEffect as useEffect16, useId as useId2, useRef as useRef11, useState as useState16 } from "react";
7496
7838
  import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
7839
+ var useNow2 = (active) => {
7840
+ const [now, setNow] = useState16(() => Date.now());
7841
+ useEffect16(() => {
7842
+ if (!active) return;
7843
+ setNow(Date.now());
7844
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
7845
+ return () => clearInterval(timer);
7846
+ }, [active]);
7847
+ return now;
7848
+ };
7849
+ var Expiry2 = ({ expiresAt, L }) => {
7850
+ const now = useNow2(true);
7851
+ return /* @__PURE__ */ jsx18("p", { className: "awr-question__expiry", children: L.questionExpiresIn(formatCountdown(expiresAt - now)) });
7852
+ };
7853
+ var reasonText2 = (q, L) => {
7854
+ const key = q.reason ?? q.status;
7855
+ return Object.hasOwn(L.questionReasons, key) ? L.questionReasons[key] : key;
7856
+ };
7857
+ var leadOf = (subagent, L) => subagent ? L.questionLeadHelper(previewValue(subagent.role ?? "", 60) || void 0, subagent.depth) : L.questionLead;
7858
+ var isTyping = (target) => target instanceof HTMLElement && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable);
7859
+ var QuestionCard = ({
7860
+ question: q,
7861
+ view,
7862
+ index,
7863
+ total,
7864
+ answer,
7865
+ showExpiry,
7866
+ showHelper,
7867
+ numberKeys,
7868
+ L
7869
+ }) => {
7870
+ const baseId = useId2();
7871
+ const textId = `${baseId}-q`;
7872
+ const otherId = `${baseId}-other`;
7873
+ const [picked, setPicked] = useState16([]);
7874
+ const [otherOpen, setOtherOpen] = useState16(false);
7875
+ const [otherText, setOtherText] = useState16("");
7876
+ const otherField = useRef11(null);
7877
+ const otherButton = useRef11(null);
7878
+ useEffect16(() => {
7879
+ if (otherOpen) otherField.current?.focus();
7880
+ }, [otherOpen]);
7881
+ const helper = showHelper && q.subagent ? { ...q.subagent, ...view?.subagent } : void 0;
7882
+ const choice = questionChoiceOf(q, picked);
7883
+ const other = questionOtherOf(q, otherText);
7884
+ const pick = (label) => {
7885
+ if (!q.multiple) {
7886
+ const one = questionChoiceOf(q, [label]);
7887
+ if (one) answer(one);
7888
+ return;
7889
+ }
7890
+ setPicked((p) => p.includes(label) ? p.filter((l) => l !== label) : [...p, label]);
7891
+ };
7892
+ const sendOther = (e) => {
7893
+ e.preventDefault();
7894
+ if (other) answer(other);
7895
+ };
7896
+ const onKeyDown = (e) => {
7897
+ if (!numberKeys || e.defaultPrevented || isTyping(e.target)) return;
7898
+ if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
7899
+ const n = /^[1-9]$/.test(e.key) ? Number(e.key) : 0;
7900
+ const option = n ? q.options[n - 1] : void 0;
7901
+ if (!option) return;
7902
+ e.preventDefault();
7903
+ pick(option.label);
7904
+ };
7905
+ return /* @__PURE__ */ jsxs16(
7906
+ "section",
7907
+ {
7908
+ className: `awr-question${q.multiple ? " awr-question--multiple" : ""}${helper ? " awr-question--helper" : ""}`,
7909
+ role: "group",
7910
+ "aria-labelledby": textId,
7911
+ "data-question": q.id,
7912
+ "data-subagent": helper?.id,
7913
+ onKeyDown,
7914
+ children: [
7915
+ /* @__PURE__ */ jsxs16("div", { className: "awr-question__head", children: [
7916
+ /* @__PURE__ */ jsx18(QuestionIcon, { size: 16, className: "awr-question__icon" }),
7917
+ /* @__PURE__ */ jsx18("span", { className: "awr-question__lead", role: "alert", children: leadOf(helper, L) }),
7918
+ total > 1 && /* @__PURE__ */ jsx18("span", { className: "awr-question__count", children: L.questionCount(index, total) })
7919
+ ] }),
7920
+ /* @__PURE__ */ jsx18("p", { className: "awr-question__text", id: textId, children: q.question }),
7921
+ q.multiple && /* @__PURE__ */ jsx18("p", { className: "awr-question__hint", children: L.questionSeveral }),
7922
+ /* @__PURE__ */ jsx18("div", { className: "awr-question__options", children: q.options.map((o, i) => {
7923
+ const on = picked.includes(o.label);
7924
+ return /* @__PURE__ */ jsxs16(
7925
+ "button",
7926
+ {
7927
+ type: "button",
7928
+ className: `awr-question__option${on ? " is-picked" : ""}`,
7929
+ "data-option": i + 1,
7930
+ "aria-pressed": q.multiple ? on : void 0,
7931
+ "aria-keyshortcuts": numberKeys && i < 9 ? String(i + 1) : void 0,
7932
+ onClick: () => pick(o.label),
7933
+ children: [
7934
+ numberKeys && i < 9 && /* @__PURE__ */ jsx18("span", { className: "awr-question__key", "aria-hidden": "true", children: i + 1 }),
7935
+ /* @__PURE__ */ jsxs16("span", { className: "awr-question__body", children: [
7936
+ /* @__PURE__ */ jsx18("span", { className: "awr-question__label", children: o.label }),
7937
+ o.description && /* @__PURE__ */ jsx18("span", { className: "awr-question__desc", children: o.description })
7938
+ ] }),
7939
+ q.multiple && /* @__PURE__ */ jsx18("span", { className: "awr-question__mark", "aria-hidden": "true", children: on && /* @__PURE__ */ jsx18(CheckIcon, { size: 14 }) })
7940
+ ]
7941
+ },
7942
+ o.label
7943
+ );
7944
+ }) }),
7945
+ q.allowOther && otherOpen && /* @__PURE__ */ jsxs16("form", { className: "awr-question__other", onSubmit: sendOther, children: [
7946
+ /* @__PURE__ */ jsx18("label", { className: "awr-question__otherlabel", htmlFor: otherId, children: L.questionOtherLabel }),
7947
+ /* @__PURE__ */ jsxs16("div", { className: "awr-question__otherrow", children: [
7948
+ /* @__PURE__ */ jsx18(
7949
+ "input",
7950
+ {
7951
+ ref: otherField,
7952
+ id: otherId,
7953
+ className: "awr-question__input",
7954
+ type: "text",
7955
+ value: otherText,
7956
+ autoComplete: "off",
7957
+ onChange: (e) => setOtherText(e.target.value),
7958
+ onKeyDown: (e) => {
7959
+ if (e.key !== "Escape") return;
7960
+ e.preventDefault();
7961
+ e.stopPropagation();
7962
+ setOtherOpen(false);
7963
+ otherButton.current?.focus();
7964
+ }
7965
+ }
7966
+ ),
7967
+ /* @__PURE__ */ jsx18("button", { type: "submit", className: "awr-btn awr-btn--primary", disabled: !other, children: L.questionSend })
7968
+ ] })
7969
+ ] }),
7970
+ /* @__PURE__ */ jsxs16("div", { className: "awr-question__actions", children: [
7971
+ q.multiple && !otherOpen && /* @__PURE__ */ jsx18(
7972
+ "button",
7973
+ {
7974
+ type: "button",
7975
+ className: "awr-btn awr-btn--primary",
7976
+ disabled: !choice,
7977
+ onClick: () => choice && answer(choice),
7978
+ children: L.questionSend
7979
+ }
7980
+ ),
7981
+ q.allowOther && /* @__PURE__ */ jsx18(
7982
+ "button",
7983
+ {
7984
+ ref: otherButton,
7985
+ type: "button",
7986
+ className: "awr-btn",
7987
+ "aria-expanded": otherOpen,
7988
+ "aria-controls": otherOpen ? otherId : void 0,
7989
+ onClick: () => setOtherOpen((o) => !o),
7990
+ children: L.questionOther
7991
+ }
7992
+ ),
7993
+ /* @__PURE__ */ jsx18(
7994
+ "button",
7995
+ {
7996
+ type: "button",
7997
+ className: "awr-btn awr-btn--ghost",
7998
+ onClick: () => answer({ declined: true }),
7999
+ children: L.questionSkip
8000
+ }
8001
+ )
8002
+ ] }),
8003
+ showExpiry && q.expiresAt !== void 0 && /* @__PURE__ */ jsx18(Expiry2, { expiresAt: q.expiresAt, L })
8004
+ ]
8005
+ }
8006
+ );
8007
+ };
8008
+ var RemoteQuestion = ({ view, L }) => {
8009
+ const textId = `${useId2()}-q`;
8010
+ return /* @__PURE__ */ jsxs16(
8011
+ "section",
8012
+ {
8013
+ className: "awr-question awr-question--remote",
8014
+ role: "group",
8015
+ "aria-labelledby": textId,
8016
+ "data-question": view.id,
8017
+ children: [
8018
+ /* @__PURE__ */ jsxs16("div", { className: "awr-question__head", children: [
8019
+ /* @__PURE__ */ jsx18(QuestionIcon, { size: 16, className: "awr-question__icon" }),
8020
+ /* @__PURE__ */ jsx18("span", { className: "awr-question__lead", children: leadOf(view.subagent, L) })
8021
+ ] }),
8022
+ /* @__PURE__ */ jsx18("p", { className: "awr-question__text", id: textId, children: view.question }),
8023
+ /* @__PURE__ */ jsx18("ul", { className: "awr-question__list", children: view.options.map((o) => /* @__PURE__ */ jsxs16("li", { children: [
8024
+ /* @__PURE__ */ jsx18("span", { className: "awr-question__label", children: o.label }),
8025
+ o.description && /* @__PURE__ */ jsx18("span", { className: "awr-question__desc", children: o.description })
8026
+ ] }, o.label)) }),
8027
+ /* @__PURE__ */ jsx18("p", { className: "awr-question__remote", role: "status", children: L.questionRemote })
8028
+ ]
8029
+ }
8030
+ );
8031
+ };
8032
+ var QuestionPrompt = ({
8033
+ questions,
8034
+ onAnswer,
8035
+ outcomes,
8036
+ showOutcomes = true,
8037
+ showExpiry = true,
8038
+ showHelper = true,
8039
+ showRemote = true,
8040
+ numberKeys = true,
8041
+ renderQuestion,
8042
+ labels,
8043
+ className
8044
+ }) => {
8045
+ const L = useLabels(labels);
8046
+ const [dismissed, setDismissed] = useState16(() => /* @__PURE__ */ new Set());
8047
+ const automatic = showOutcomes ? (outcomes ?? []).filter(
8048
+ (o) => o.automatic === true && o.status !== "pending" && o.status !== "stopped" && !dismissed.has(o.id)
8049
+ ) : [];
8050
+ const remote = showRemote ? (outcomes ?? []).filter((o) => o.remote && o.status === "pending") : [];
8051
+ const current = questions[0];
8052
+ if (!current && automatic.length === 0 && remote.length === 0) return null;
8053
+ let card = null;
8054
+ if (current) {
8055
+ const answer = (a) => onAnswer(current.id, a);
8056
+ const builtIn = /* @__PURE__ */ jsx18(
8057
+ QuestionCard,
8058
+ {
8059
+ question: current,
8060
+ view: outcomes?.find((o) => o.id === current.id),
8061
+ index: 1,
8062
+ total: questions.length,
8063
+ answer,
8064
+ showExpiry,
8065
+ showHelper,
8066
+ numberKeys,
8067
+ L
8068
+ },
8069
+ current.id
8070
+ );
8071
+ card = renderQuestion ? renderQuestion(current, builtIn, answer) : builtIn;
8072
+ }
8073
+ return /* @__PURE__ */ jsxs16("div", { className: ["awr-questions", className].filter(Boolean).join(" "), children: [
8074
+ automatic.map((o) => /* @__PURE__ */ jsxs16(
8075
+ "div",
8076
+ {
8077
+ className: "awr-question-outcome",
8078
+ role: "status",
8079
+ "data-reason": o.reason ?? o.status,
8080
+ children: [
8081
+ /* @__PURE__ */ jsx18(AlertIcon, { size: 14, className: "awr-question-outcome__icon" }),
8082
+ /* @__PURE__ */ jsxs16("span", { className: "awr-question-outcome__text", children: [
8083
+ L.questionAutomatic(reasonText2(o, L)),
8084
+ " ",
8085
+ /* @__PURE__ */ jsx18("q", { className: "awr-question-outcome__question", children: o.question })
8086
+ ] }),
8087
+ /* @__PURE__ */ jsx18(
8088
+ "button",
8089
+ {
8090
+ type: "button",
8091
+ className: "awr-iconbtn awr-question-outcome__dismiss",
8092
+ "aria-label": L.questionDismiss,
8093
+ title: L.questionDismiss,
8094
+ onClick: () => setDismissed((d) => new Set(d).add(o.id)),
8095
+ children: /* @__PURE__ */ jsx18(XIcon, { size: 14 })
8096
+ }
8097
+ )
8098
+ ]
8099
+ },
8100
+ o.id
8101
+ )),
8102
+ remote.map((o) => /* @__PURE__ */ jsx18(RemoteQuestion, { view: o, L }, o.id)),
8103
+ card
8104
+ ] });
8105
+ };
8106
+
8107
+ // src/components/ToolApprovalPrompt.tsx
8108
+ import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
7497
8109
  var SkillConsentCard = ({
7498
8110
  approval: a,
7499
8111
  skill,
@@ -7503,7 +8115,7 @@ var SkillConsentCard = ({
7503
8115
  showPreview,
7504
8116
  onApprove,
7505
8117
  onDeny
7506
- }) => /* @__PURE__ */ jsxs16(
8118
+ }) => /* @__PURE__ */ jsxs17(
7507
8119
  "div",
7508
8120
  {
7509
8121
  className: `awr-approval awr-approval--skill${helper ? " awr-approval--helper" : ""}`,
@@ -7511,28 +8123,28 @@ var SkillConsentCard = ({
7511
8123
  "data-skill-server": skill.server,
7512
8124
  "data-subagent": helper?.id,
7513
8125
  children: [
7514
- /* @__PURE__ */ jsxs16("div", { className: "awr-approval__head", children: [
7515
- /* @__PURE__ */ jsx18(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
7516
- /* @__PURE__ */ jsx18("span", { children: L.skillConsentLead(skill.server, skill.skill) })
8126
+ /* @__PURE__ */ jsxs17("div", { className: "awr-approval__head", children: [
8127
+ /* @__PURE__ */ jsx19(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
8128
+ /* @__PURE__ */ jsx19("span", { children: L.skillConsentLead(skill.server, skill.skill) })
7517
8129
  ] }),
7518
- skill.description && /* @__PURE__ */ jsx18("p", { className: "awr-approval__quote", children: skill.description }),
7519
- /* @__PURE__ */ jsxs16("p", { className: "awr-approval__skillmeta", children: [
7520
- /* @__PURE__ */ jsx18("code", { className: "awr-tool__name", children: skill.name }),
7521
- /* @__PURE__ */ jsx18("span", { children: L.skillConsentSize(skill.size, skill.fileCount) })
8130
+ skill.description && /* @__PURE__ */ jsx19("p", { className: "awr-approval__quote", children: skill.description }),
8131
+ /* @__PURE__ */ jsxs17("p", { className: "awr-approval__skillmeta", children: [
8132
+ /* @__PURE__ */ jsx19("code", { className: "awr-tool__name", children: skill.name }),
8133
+ /* @__PURE__ */ jsx19("span", { children: L.skillConsentSize(skill.size, skill.fileCount) })
7522
8134
  ] }),
7523
- skill.byUri && /* @__PURE__ */ jsx18("p", { className: "awr-approval__from", children: L.skillConsentByUri }),
7524
- skill.nestedIn && /* @__PURE__ */ jsx18("p", { className: "awr-approval__from awr-approval__nested", children: L.skillConsentNested(skill.nestedIn) }),
7525
- skill.dynamic && /* @__PURE__ */ jsx18("p", { className: "awr-approval__from awr-approval__dynamic", children: L.skillConsentDynamic }),
7526
- skill.dynamic && skill.noFileListing && /* @__PURE__ */ jsx18("p", { className: "awr-approval__from", children: L.skillConsentNoFileListing }),
7527
- showPreview && skill.body !== void 0 && /* @__PURE__ */ jsxs16("details", { className: "awr-approval__preview", children: [
7528
- /* @__PURE__ */ jsx18("summary", { children: L.skillConsentPreview }),
7529
- /* @__PURE__ */ jsx18("pre", { className: "awr-approval__quote awr-approval__body", children: skill.body }),
7530
- skill.files.length > 0 && /* @__PURE__ */ jsx18("p", { className: "awr-approval__from", children: L.skillConsentFiles(skill.files.join(", "), skill.fileCount - skill.files.length) })
8135
+ skill.byUri && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentByUri }),
8136
+ skill.nestedIn && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from awr-approval__nested", children: L.skillConsentNested(skill.nestedIn) }),
8137
+ skill.dynamic && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from awr-approval__dynamic", children: L.skillConsentDynamic }),
8138
+ skill.dynamic && skill.noFileListing && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentNoFileListing }),
8139
+ showPreview && skill.body !== void 0 && /* @__PURE__ */ jsxs17("details", { className: "awr-approval__preview", children: [
8140
+ /* @__PURE__ */ jsx19("summary", { children: L.skillConsentPreview }),
8141
+ /* @__PURE__ */ jsx19("pre", { className: "awr-approval__quote awr-approval__body", children: skill.body }),
8142
+ skill.files.length > 0 && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentFiles(skill.files.join(", "), skill.fileCount - skill.files.length) })
7531
8143
  ] }),
7532
- /* @__PURE__ */ jsx18("p", { className: "awr-approval__from", children: L.skillConsentNote(skill.server, skill.consent) }),
7533
- /* @__PURE__ */ jsxs16("div", { className: "awr-approval__actions", children: [
7534
- /* @__PURE__ */ jsx18("button", { type: "button", className: "awr-btn awr-btn--primary", onClick: () => onApprove(a.id), children: L.skillConsentAllow }),
7535
- allowRemember && /* @__PURE__ */ jsx18(
8144
+ /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.skillConsentNote(skill.server, skill.consent) }),
8145
+ /* @__PURE__ */ jsxs17("div", { className: "awr-approval__actions", children: [
8146
+ /* @__PURE__ */ jsx19("button", { type: "button", className: "awr-btn awr-btn--primary", onClick: () => onApprove(a.id), children: L.skillConsentAllow }),
8147
+ allowRemember && /* @__PURE__ */ jsx19(
7536
8148
  "button",
7537
8149
  {
7538
8150
  type: "button",
@@ -7541,7 +8153,7 @@ var SkillConsentCard = ({
7541
8153
  children: L.skillConsentAlways
7542
8154
  }
7543
8155
  ),
7544
- /* @__PURE__ */ jsx18(
8156
+ /* @__PURE__ */ jsx19(
7545
8157
  "button",
7546
8158
  {
7547
8159
  type: "button",
@@ -7567,9 +8179,9 @@ var ToolApprovalPrompt = ({
7567
8179
  }) => {
7568
8180
  const L = useLabels(labels);
7569
8181
  if (approvals.length === 0) return null;
7570
- return /* @__PURE__ */ jsx18("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
8182
+ return /* @__PURE__ */ jsx19("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
7571
8183
  if (a.skill) {
7572
- const card2 = /* @__PURE__ */ jsx18(
8184
+ const card2 = /* @__PURE__ */ jsx19(
7573
8185
  SkillConsentCard,
7574
8186
  {
7575
8187
  approval: a,
@@ -7583,33 +8195,33 @@ var ToolApprovalPrompt = ({
7583
8195
  },
7584
8196
  a.id
7585
8197
  );
7586
- return renderApproval ? /* @__PURE__ */ jsx18("div", { children: renderApproval(a, card2) }, a.id) : card2;
8198
+ return renderApproval ? /* @__PURE__ */ jsx19("div", { children: renderApproval(a, card2) }, a.id) : card2;
7587
8199
  }
7588
8200
  const helper = showHelper ? a.subagent : void 0;
7589
8201
  const app = a.app;
7590
- const card = /* @__PURE__ */ jsxs16(
8202
+ const card = /* @__PURE__ */ jsxs17(
7591
8203
  "div",
7592
8204
  {
7593
8205
  className: `awr-approval${helper ? " awr-approval--helper" : ""}${app ? " awr-approval--app" : ""}`,
7594
8206
  "data-subagent": helper?.id,
7595
8207
  "data-app-server": app?.server,
7596
8208
  children: [
7597
- /* @__PURE__ */ jsxs16("div", { className: "awr-approval__head", children: [
7598
- /* @__PURE__ */ jsx18(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
7599
- /* @__PURE__ */ jsxs16("span", { children: [
8209
+ /* @__PURE__ */ jsxs17("div", { className: "awr-approval__head", children: [
8210
+ /* @__PURE__ */ jsx19(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
8211
+ /* @__PURE__ */ jsxs17("span", { children: [
7600
8212
  app ? L.approvalLeadApp(app.server) : helper ? L.approvalLeadHelper(
7601
8213
  previewValue(helper.role ?? "", 60) || void 0,
7602
8214
  helper.depth
7603
8215
  ) : L.approvalLead,
7604
8216
  " ",
7605
- /* @__PURE__ */ jsx18("code", { className: "awr-tool__name", children: app ? app.tool : a.name }),
8217
+ /* @__PURE__ */ jsx19("code", { className: "awr-tool__name", children: app ? app.tool : a.name }),
7606
8218
  a.readOnly && !app ? ` (${L.readOnlyTool})` : ""
7607
8219
  ] })
7608
8220
  ] }),
7609
- previewValue(a.input, 300) && /* @__PURE__ */ jsx18("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
7610
- app && /* @__PURE__ */ jsx18("p", { className: "awr-approval__from", children: L.approvalFromApp(app.server, a.readOnly) }),
7611
- /* @__PURE__ */ jsxs16("div", { className: "awr-approval__actions", children: [
7612
- /* @__PURE__ */ jsx18(
8221
+ previewValue(a.input, 300) && /* @__PURE__ */ jsx19("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
8222
+ app && /* @__PURE__ */ jsx19("p", { className: "awr-approval__from", children: L.approvalFromApp(app.server, a.readOnly) }),
8223
+ /* @__PURE__ */ jsxs17("div", { className: "awr-approval__actions", children: [
8224
+ /* @__PURE__ */ jsx19(
7613
8225
  "button",
7614
8226
  {
7615
8227
  type: "button",
@@ -7618,7 +8230,7 @@ var ToolApprovalPrompt = ({
7618
8230
  children: L.approve
7619
8231
  }
7620
8232
  ),
7621
- allowRemember && /* @__PURE__ */ jsx18(
8233
+ allowRemember && /* @__PURE__ */ jsx19(
7622
8234
  "button",
7623
8235
  {
7624
8236
  type: "button",
@@ -7627,7 +8239,7 @@ var ToolApprovalPrompt = ({
7627
8239
  children: L.alwaysAllow
7628
8240
  }
7629
8241
  ),
7630
- /* @__PURE__ */ jsx18(
8242
+ /* @__PURE__ */ jsx19(
7631
8243
  "button",
7632
8244
  {
7633
8245
  type: "button",
@@ -7641,12 +8253,12 @@ var ToolApprovalPrompt = ({
7641
8253
  },
7642
8254
  a.id
7643
8255
  );
7644
- return renderApproval ? /* @__PURE__ */ jsx18("div", { children: renderApproval(a, card) }, a.id) : card;
8256
+ return renderApproval ? /* @__PURE__ */ jsx19("div", { children: renderApproval(a, card) }, a.id) : card;
7645
8257
  }) });
7646
8258
  };
7647
8259
 
7648
8260
  // src/components/UsageBadge.tsx
7649
- import { jsxs as jsxs17 } from "react/jsx-runtime";
8261
+ import { jsxs as jsxs18 } from "react/jsx-runtime";
7650
8262
  var UsageBadge = ({
7651
8263
  usage,
7652
8264
  compact = false,
@@ -7672,7 +8284,7 @@ var UsageBadge = ({
7672
8284
  mediaText,
7673
8285
  decisions ? L.usageDecisions(decisions) : ""
7674
8286
  ].filter(Boolean).join(" \xB7 ");
7675
- return /* @__PURE__ */ jsxs17("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
8287
+ return /* @__PURE__ */ jsxs18("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
7676
8288
  formatTokens(usage.inputTokens),
7677
8289
  "\u2191 ",
7678
8290
  formatTokens(usage.outputTokens),
@@ -7685,13 +8297,13 @@ var UsageBadge = ({
7685
8297
  };
7686
8298
 
7687
8299
  // src/components/AgentChat.tsx
7688
- import { Fragment as Fragment11, jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
8300
+ import { Fragment as Fragment12, jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
7689
8301
  var usePrefersDark = () => {
7690
8302
  const query = "(prefers-color-scheme: dark)";
7691
- const [dark, setDark] = useState16(
8303
+ const [dark, setDark] = useState17(
7692
8304
  () => typeof matchMedia === "function" && matchMedia(query).matches
7693
8305
  );
7694
- useEffect16(() => {
8306
+ useEffect17(() => {
7695
8307
  if (typeof matchMedia !== "function") return;
7696
8308
  const mq = matchMedia(query);
7697
8309
  const on = () => setDark(mq.matches);
@@ -7702,7 +8314,7 @@ var usePrefersDark = () => {
7702
8314
  };
7703
8315
  var isHistoryHook = (h) => typeof h === "object" && h !== null && "select" in h && "chats" in h;
7704
8316
  var cx = (...names) => names.filter(Boolean).join(" ");
7705
- var AgentChat = (props) => /* @__PURE__ */ jsx19(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ jsx19(AgentChatInner, { ...props }) });
8317
+ var AgentChat = (props) => /* @__PURE__ */ jsx20(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ jsx20(AgentChatInner, { ...props }) });
7706
8318
  var NO_LABELS = {};
7707
8319
  var AgentChatInner = ({
7708
8320
  controller,
@@ -7730,11 +8342,13 @@ var AgentChatInner = ({
7730
8342
  showContext = false,
7731
8343
  activityOpen = false,
7732
8344
  showElicitation = true,
8345
+ showQuestions = true,
7733
8346
  showSkillPreview = true,
7734
8347
  showOtherTabs = true,
7735
8348
  elicitations,
7736
8349
  onElicitationAnswer,
7737
8350
  renderElicitation,
8351
+ renderQuestion,
7738
8352
  history,
7739
8353
  defaultHistoryOpen,
7740
8354
  files,
@@ -7779,7 +8393,7 @@ var AgentChatInner = ({
7779
8393
  }
7780
8394
  const L = useLabels();
7781
8395
  const external = isHistoryHook(history) ? history : void 0;
7782
- const [ownStore] = useState16(
8396
+ const [ownStore] = useState17(
7783
8397
  () => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
7784
8398
  );
7785
8399
  const own = useChatHistory(agent, {
@@ -7787,9 +8401,9 @@ var AgentChatInner = ({
7787
8401
  enabled: Boolean(history) && !external
7788
8402
  });
7789
8403
  const chats = history ? external ?? own : void 0;
7790
- const rootRef = useRef11(null);
7791
- const [narrow, setNarrow] = useState16(void 0);
7792
- useEffect16(() => {
8404
+ const rootRef = useRef12(null);
8405
+ const [narrow, setNarrow] = useState17(void 0);
8406
+ useEffect17(() => {
7793
8407
  const el = rootRef.current;
7794
8408
  if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
7795
8409
  const measure2 = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
@@ -7798,9 +8412,9 @@ var AgentChatInner = ({
7798
8412
  ro.observe(el);
7799
8413
  return () => ro.disconnect();
7800
8414
  }, [narrowWidth]);
7801
- const [historyChoice, setHistoryOpen] = useState16(defaultHistoryOpen);
8415
+ const [historyChoice, setHistoryOpen] = useState17(defaultHistoryOpen);
7802
8416
  const historyOpen = historyChoice ?? narrow === false;
7803
- const [filesOpen, setFilesOpen] = useState16(defaultFilesOpen);
8417
+ const [filesOpen, setFilesOpen] = useState17(defaultFilesOpen);
7804
8418
  const toggleHistory = () => {
7805
8419
  setHistoryOpen(!historyOpen);
7806
8420
  if (narrow && !historyOpen) setFilesOpen(false);
@@ -7818,7 +8432,7 @@ var AgentChatInner = ({
7818
8432
  setHistoryOpen(false);
7819
8433
  setFilesOpen(false);
7820
8434
  };
7821
- useEffect16(() => {
8435
+ useEffect17(() => {
7822
8436
  if (!overlayOpen) return;
7823
8437
  const onKey = (e) => {
7824
8438
  if (e.key !== "Escape" || e.defaultPrevented) return;
@@ -7828,7 +8442,7 @@ var AgentChatInner = ({
7828
8442
  document.addEventListener("keydown", onKey);
7829
8443
  return () => document.removeEventListener("keydown", onKey);
7830
8444
  }, [overlayOpen]);
7831
- const bodyRef = useRef11(null);
8445
+ const bodyRef = useRef12(null);
7832
8446
  const appHost = useMcpAppHost({
7833
8447
  connection: mcpApps,
7834
8448
  approve: agent.approveAppToolCall,
@@ -7840,7 +8454,7 @@ var AgentChatInner = ({
7840
8454
  });
7841
8455
  const prefersDark = usePrefersDark();
7842
8456
  const appTheme = theme === "auto" ? prefersDark ? "dark" : "light" : theme;
7843
- const [panelApp, setPanelAppState] = useState16();
8457
+ const [panelApp, setPanelAppState] = useState17();
7844
8458
  const setPanelApp = (app) => {
7845
8459
  setPanelAppState(app);
7846
8460
  onAppPanel?.(app);
@@ -7854,14 +8468,14 @@ var AgentChatInner = ({
7854
8468
  const panelAllowed = appPanel !== false && appPanel !== null;
7855
8469
  const panelTarget = typeof appPanel === "object" && appPanel ? appPanel : void 0;
7856
8470
  const asSheet = !panelTarget && (appPanel === "sheet" || Boolean(narrow));
7857
- useEffect16(() => {
8471
+ useEffect17(() => {
7858
8472
  if (panelApp && !agent.messages.some((m) => m.apps?.some((a) => a.id === panelApp.id))) {
7859
8473
  setPanelAppState(void 0);
7860
8474
  onAppPanel?.(void 0);
7861
8475
  }
7862
8476
  }, [agent.messages, panelApp, onAppPanel]);
7863
8477
  const drawApp = (app, message) => {
7864
- const built = panelApp?.id === app.id ? /* @__PURE__ */ jsx19(
8478
+ const built = panelApp?.id === app.id ? /* @__PURE__ */ jsx20(
7865
8479
  McpAppLine,
7866
8480
  {
7867
8481
  app,
@@ -7869,7 +8483,7 @@ var AgentChatInner = ({
7869
8483
  action: L.appBringBack,
7870
8484
  onAction: () => setPanelApp(void 0)
7871
8485
  }
7872
- ) : /* @__PURE__ */ jsx19(
8486
+ ) : /* @__PURE__ */ jsx20(
7873
8487
  McpAppFrame,
7874
8488
  {
7875
8489
  app,
@@ -7882,7 +8496,7 @@ var AgentChatInner = ({
7882
8496
  );
7883
8497
  return renderApp ? renderApp(app, message, built) : built;
7884
8498
  };
7885
- const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ jsx19(
8499
+ const appPanelNode = appsOn && panelApp ? /* @__PURE__ */ jsx20(
7886
8500
  McpAppFrame,
7887
8501
  {
7888
8502
  app: panelApp,
@@ -7894,7 +8508,7 @@ var AgentChatInner = ({
7894
8508
  },
7895
8509
  panelApp.id
7896
8510
  ) : null;
7897
- const [compacting, setCompacting] = useState16(false);
8511
+ const [compacting, setCompacting] = useState17(false);
7898
8512
  const compact = () => {
7899
8513
  setCompacting(true);
7900
8514
  void agent.compact().finally(() => setCompacting(false));
@@ -7905,9 +8519,10 @@ var AgentChatInner = ({
7905
8519
  const Files = components.FilesPanel ?? FilesPanel;
7906
8520
  const Approvals = components.ApprovalPrompt ?? ToolApprovalPrompt;
7907
8521
  const Elicitations = components.ElicitationPrompt ?? ElicitationPrompt;
8522
+ const Questions = components.QuestionPrompt ?? QuestionPrompt;
7908
8523
  const tabNotes = showOtherTabs ? [
7909
8524
  agent.remote?.running && L.remoteRunning,
7910
- agent.remote?.running && agent.approvals.some((a) => a.remote && a.status === "pending") && L.remoteWaitingConsent,
8525
+ agent.remote?.running && (agent.approvals.some((a) => a.remote && a.status === "pending") || (agent.questions ?? []).some((q) => q.remote && q.status === "pending")) && L.remoteWaitingConsent,
7911
8526
  agent.remote?.ended === "gone" && L.remoteGone,
7912
8527
  agent.sessionBusy && L.sessionBusy(agent.sessionBusy.heldBy)
7913
8528
  ].filter((t) => typeof t === "string") : [];
@@ -7915,18 +8530,18 @@ var AgentChatInner = ({
7915
8530
  const showReplan = agent.replan && agent.replan.mode !== "continue";
7916
8531
  const replanFailedEarly = showReplanFailed && agent.replan?.failed === true && agent.steps.length === 0;
7917
8532
  const earlyDecisions = showDecisions ? agent.decisions ?? [] : [];
7918
- const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ jsxs18(Fragment11, { children: [
7919
- agent.planThought.trim() && /* @__PURE__ */ jsxs18("details", { className: "awr-activity__plan", children: [
7920
- /* @__PURE__ */ jsx19("summary", { children: L.planned }),
7921
- /* @__PURE__ */ jsx19("p", { className: "awr-activity__thought", children: agent.planThought })
8533
+ const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ jsxs19(Fragment12, { children: [
8534
+ agent.planThought.trim() && /* @__PURE__ */ jsxs19("details", { className: "awr-activity__plan", children: [
8535
+ /* @__PURE__ */ jsx20("summary", { children: L.planned }),
8536
+ /* @__PURE__ */ jsx20("p", { className: "awr-activity__thought", children: agent.planThought })
7922
8537
  ] }),
7923
- showReplan && /* @__PURE__ */ jsx19("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
7924
- replanFailedEarly && /* @__PURE__ */ jsxs18("p", { className: "awr-step__warn", title: agent.replan.error, children: [
7925
- /* @__PURE__ */ jsx19(AlertIcon, { size: 12 }),
8538
+ showReplan && /* @__PURE__ */ jsx20("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
8539
+ replanFailedEarly && /* @__PURE__ */ jsxs19("p", { className: "awr-step__warn", title: agent.replan.error, children: [
8540
+ /* @__PURE__ */ jsx20(AlertIcon, { size: 12 }),
7926
8541
  " ",
7927
8542
  L.replanFailed
7928
8543
  ] }),
7929
- earlyDecisions.map((d, i) => /* @__PURE__ */ jsx19(
8544
+ earlyDecisions.map((d, i) => /* @__PURE__ */ jsx20(
7930
8545
  "p",
7931
8546
  {
7932
8547
  className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
@@ -7935,8 +8550,8 @@ var AgentChatInner = ({
7935
8550
  i
7936
8551
  ))
7937
8552
  ] }) : void 0;
7938
- const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ jsxs18("div", { className: cx("awr-chat__header", classNames.header), children: [
7939
- chats && /* @__PURE__ */ jsx19(
8553
+ const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__header", classNames.header), children: [
8554
+ chats && /* @__PURE__ */ jsx20(
7940
8555
  "button",
7941
8556
  {
7942
8557
  type: "button",
@@ -7945,17 +8560,17 @@ var AgentChatInner = ({
7945
8560
  title: L.showHistory,
7946
8561
  "aria-pressed": historyOpen,
7947
8562
  onClick: toggleHistory,
7948
- children: /* @__PURE__ */ jsx19(HistoryIcon, { size: 16 })
8563
+ children: /* @__PURE__ */ jsx20(HistoryIcon, { size: 16 })
7949
8564
  }
7950
8565
  ),
7951
8566
  slots.headerStart,
7952
- /* @__PURE__ */ jsx19("div", { className: "awr-chat__title", children: title }),
7953
- showStatus && /* @__PURE__ */ jsxs18("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
7954
- /* @__PURE__ */ jsx19("span", { className: "awr-status__dot" }),
7955
- /* @__PURE__ */ jsx19("span", { className: "awr-status__text", children: L.status[agent.status] })
8567
+ /* @__PURE__ */ jsx20("div", { className: "awr-chat__title", children: title }),
8568
+ showStatus && /* @__PURE__ */ jsxs19("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
8569
+ /* @__PURE__ */ jsx20("span", { className: "awr-status__dot" }),
8570
+ /* @__PURE__ */ jsx20("span", { className: "awr-status__text", children: L.status[agent.status] })
7956
8571
  ] }),
7957
- showTotalUsage && /* @__PURE__ */ jsx19("span", { title: L.totalUsage, children: /* @__PURE__ */ jsx19(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
7958
- files && /* @__PURE__ */ jsx19(
8572
+ showTotalUsage && /* @__PURE__ */ jsx20("span", { title: L.totalUsage, children: /* @__PURE__ */ jsx20(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
8573
+ files && /* @__PURE__ */ jsx20(
7959
8574
  "button",
7960
8575
  {
7961
8576
  type: "button",
@@ -7964,12 +8579,12 @@ var AgentChatInner = ({
7964
8579
  title: L.showFiles,
7965
8580
  "aria-pressed": filesOpen,
7966
8581
  onClick: toggleFiles,
7967
- children: /* @__PURE__ */ jsx19(FileIcon, { size: 16 })
8582
+ children: /* @__PURE__ */ jsx20(FileIcon, { size: 16 })
7968
8583
  }
7969
8584
  ),
7970
8585
  slots.headerEnd
7971
8586
  ] });
7972
- return /* @__PURE__ */ jsxs18(
8587
+ return /* @__PURE__ */ jsxs19(
7973
8588
  "div",
7974
8589
  {
7975
8590
  ref: rootRef,
@@ -7977,7 +8592,7 @@ var AgentChatInner = ({
7977
8592
  style,
7978
8593
  "data-awr-theme": theme === "auto" ? void 0 : theme,
7979
8594
  children: [
7980
- overlayOpen && /* @__PURE__ */ jsx19(
8595
+ overlayOpen && /* @__PURE__ */ jsx20(
7981
8596
  "div",
7982
8597
  {
7983
8598
  className: cx("awr-chat__scrim", classNames.scrim),
@@ -7985,8 +8600,8 @@ var AgentChatInner = ({
7985
8600
  onClick: closeOverlays
7986
8601
  }
7987
8602
  ),
7988
- chats && historyOpen && /* @__PURE__ */ jsxs18("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
7989
- /* @__PURE__ */ jsx19(
8603
+ chats && historyOpen && /* @__PURE__ */ jsxs19("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
8604
+ /* @__PURE__ */ jsx20(
7990
8605
  HistoryList,
7991
8606
  {
7992
8607
  history: {
@@ -8005,7 +8620,7 @@ var AgentChatInner = ({
8005
8620
  }
8006
8621
  ),
8007
8622
  slots.sidebar,
8008
- /* @__PURE__ */ jsx19(
8623
+ /* @__PURE__ */ jsx20(
8009
8624
  "button",
8010
8625
  {
8011
8626
  type: "button",
@@ -8016,11 +8631,11 @@ var AgentChatInner = ({
8016
8631
  }
8017
8632
  )
8018
8633
  ] }),
8019
- /* @__PURE__ */ jsxs18("div", { className: cx("awr-chat__main", classNames.main), children: [
8634
+ /* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__main", classNames.main), children: [
8020
8635
  header,
8021
- /* @__PURE__ */ jsxs18("div", { className: cx("awr-chat__body", classNames.body), ref: bodyRef, children: [
8636
+ /* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__body", classNames.body), ref: bodyRef, children: [
8022
8637
  slots.beforeMessages,
8023
- /* @__PURE__ */ jsx19(
8638
+ /* @__PURE__ */ jsx20(
8024
8639
  Messages,
8025
8640
  {
8026
8641
  messages: agent.messages,
@@ -8058,7 +8673,7 @@ var AgentChatInner = ({
8058
8673
  renderImageViewer
8059
8674
  }
8060
8675
  ),
8061
- /* @__PURE__ */ jsx19(
8676
+ /* @__PURE__ */ jsx20(
8062
8677
  Approvals,
8063
8678
  {
8064
8679
  approvals: agent.pendingApprovals,
@@ -8068,7 +8683,16 @@ var AgentChatInner = ({
8068
8683
  renderApproval
8069
8684
  }
8070
8685
  ),
8071
- appsOn && /* @__PURE__ */ jsx19(
8686
+ showQuestions && /* @__PURE__ */ jsx20(
8687
+ Questions,
8688
+ {
8689
+ questions: agent.pendingQuestions ?? [],
8690
+ onAnswer: (id, answer) => agent.answerQuestion?.(id, answer),
8691
+ outcomes: agent.questions,
8692
+ renderQuestion
8693
+ }
8694
+ ),
8695
+ appsOn && /* @__PURE__ */ jsx20(
8072
8696
  AppRequestPrompt,
8073
8697
  {
8074
8698
  requests: appHost.requests,
@@ -8076,7 +8700,7 @@ var AgentChatInner = ({
8076
8700
  renderRequest: renderAppRequest
8077
8701
  }
8078
8702
  ),
8079
- showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */ jsx19(
8703
+ showElicitation && elicitations && onElicitationAnswer && /* @__PURE__ */ jsx20(
8080
8704
  Elicitations,
8081
8705
  {
8082
8706
  elicitations,
@@ -8085,13 +8709,13 @@ var AgentChatInner = ({
8085
8709
  renderElicitation
8086
8710
  }
8087
8711
  ),
8088
- agent.modelLoad && loading && /* @__PURE__ */ jsx19(ModelLoadBar, { load: agent.modelLoad }),
8712
+ agent.modelLoad && loading && /* @__PURE__ */ jsx20(ModelLoadBar, { load: agent.modelLoad }),
8089
8713
  slots.afterMessages
8090
8714
  ] }),
8091
- /* @__PURE__ */ jsxs18("div", { className: cx("awr-chat__footer", classNames.footer), children: [
8715
+ /* @__PURE__ */ jsxs19("div", { className: cx("awr-chat__footer", classNames.footer), children: [
8092
8716
  slots.footerStart,
8093
- tabNotes.length > 0 && /* @__PURE__ */ jsx19("div", { className: "awr-tabnote", role: "status", children: tabNotes.map((text) => /* @__PURE__ */ jsx19("p", { className: "awr-tabnote__text", children: text }, text)) }),
8094
- showContext !== false && /* @__PURE__ */ jsx19(
8717
+ tabNotes.length > 0 && /* @__PURE__ */ jsx20("div", { className: "awr-tabnote", role: "status", children: tabNotes.map((text) => /* @__PURE__ */ jsx20("p", { className: "awr-tabnote__text", children: text }, text)) }),
8718
+ showContext !== false && /* @__PURE__ */ jsx20(
8095
8719
  ContextMeter,
8096
8720
  {
8097
8721
  usage: agent.usage,
@@ -8102,11 +8726,11 @@ var AgentChatInner = ({
8102
8726
  compacting
8103
8727
  }
8104
8728
  ),
8105
- composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ jsxs18("div", { className: "awr-chat__error", children: [
8106
- /* @__PURE__ */ jsx19(AlertIcon, { size: 14 }),
8729
+ composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ jsxs19("div", { className: "awr-chat__error", children: [
8730
+ /* @__PURE__ */ jsx20(AlertIcon, { size: 14 }),
8107
8731
  " ",
8108
8732
  agent.error
8109
- ] }) : /* @__PURE__ */ jsx19(
8733
+ ] }) : /* @__PURE__ */ jsx20(
8110
8734
  Composer2,
8111
8735
  {
8112
8736
  controller: agent,
@@ -8123,7 +8747,7 @@ var AgentChatInner = ({
8123
8747
  appPanelNode && (panelTarget ? (
8124
8748
  // Outside the chat: the theme tokens come with it.
8125
8749
  createPortal2(
8126
- /* @__PURE__ */ jsx19(
8750
+ /* @__PURE__ */ jsx20(
8127
8751
  "div",
8128
8752
  {
8129
8753
  className: "awr-theme awr-apppanel",
@@ -8133,24 +8757,24 @@ var AgentChatInner = ({
8133
8757
  ),
8134
8758
  panelTarget
8135
8759
  )
8136
- ) : asSheet ? /* @__PURE__ */ jsxs18(Fragment11, { children: [
8137
- /* @__PURE__ */ jsx19("div", { className: "awr-sheet__scrim", onClick: () => setPanelApp(void 0) }),
8138
- /* @__PURE__ */ jsxs18(
8760
+ ) : asSheet ? /* @__PURE__ */ jsxs19(Fragment12, { children: [
8761
+ /* @__PURE__ */ jsx20("div", { className: "awr-sheet__scrim", onClick: () => setPanelApp(void 0) }),
8762
+ /* @__PURE__ */ jsxs19(
8139
8763
  "aside",
8140
8764
  {
8141
8765
  className: "awr-chat__appsheet",
8142
8766
  role: "dialog",
8143
8767
  "aria-label": L.appFrom(panelApp.server),
8144
8768
  children: [
8145
- /* @__PURE__ */ jsx19("div", { className: "awr-sheet__grab" }),
8769
+ /* @__PURE__ */ jsx20("div", { className: "awr-sheet__grab" }),
8146
8770
  appPanelNode
8147
8771
  ]
8148
8772
  }
8149
8773
  )
8150
- ] }) : /* @__PURE__ */ jsx19("aside", { className: "awr-chat__apppanel", children: appPanelNode })),
8151
- files && filesOpen && /* @__PURE__ */ jsxs18("aside", { className: cx("awr-chat__files", classNames.files), children: [
8152
- /* @__PURE__ */ jsx19(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ jsx19(Files, { files }) }),
8153
- /* @__PURE__ */ jsx19(
8774
+ ] }) : /* @__PURE__ */ jsx20("aside", { className: "awr-chat__apppanel", children: appPanelNode })),
8775
+ files && filesOpen && /* @__PURE__ */ jsxs19("aside", { className: cx("awr-chat__files", classNames.files), children: [
8776
+ /* @__PURE__ */ jsx20(ImageViewerProvider, { enabled: imageViewer, render: renderImageViewer, children: /* @__PURE__ */ jsx20(Files, { files }) }),
8777
+ /* @__PURE__ */ jsx20(
8154
8778
  "button",
8155
8779
  {
8156
8780
  type: "button",
@@ -8167,7 +8791,7 @@ var AgentChatInner = ({
8167
8791
  };
8168
8792
 
8169
8793
  // src/components/LearnedSkills.tsx
8170
- import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
8794
+ import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
8171
8795
  var LearnedSkills = ({
8172
8796
  controller,
8173
8797
  lessons,
@@ -8183,18 +8807,18 @@ var LearnedSkills = ({
8183
8807
  const c = controller ?? ctx;
8184
8808
  const list = lessons ?? c?.learned ?? [];
8185
8809
  const forget = onForget === false ? void 0 : onForget ?? c?.forgetSkill;
8186
- return /* @__PURE__ */ jsxs19("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
8187
- !hideTitle && /* @__PURE__ */ jsxs19("h3", { className: "awr-notebook__title", children: [
8188
- /* @__PURE__ */ jsx20(BookIcon, { size: 14 }),
8810
+ return /* @__PURE__ */ jsxs20("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
8811
+ !hideTitle && /* @__PURE__ */ jsxs20("h3", { className: "awr-notebook__title", children: [
8812
+ /* @__PURE__ */ jsx21(BookIcon, { size: 14 }),
8189
8813
  " ",
8190
8814
  L.notebookTitle,
8191
- list.length > 0 && /* @__PURE__ */ jsx20("span", { className: "awr-notebook__count", children: list.length })
8815
+ list.length > 0 && /* @__PURE__ */ jsx21("span", { className: "awr-notebook__count", children: list.length })
8192
8816
  ] }),
8193
- list.length === 0 ? /* @__PURE__ */ jsx20("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ jsx20("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ jsxs19("li", { className: "awr-lesson", children: [
8194
- /* @__PURE__ */ jsxs19("div", { className: "awr-lesson__head", children: [
8195
- /* @__PURE__ */ jsx20("code", { className: "awr-lesson__name", children: l.name }),
8196
- l.revision > 1 && /* @__PURE__ */ jsx20("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
8197
- forget && /* @__PURE__ */ jsx20(
8817
+ list.length === 0 ? /* @__PURE__ */ jsx21("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ jsx21("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ jsxs20("li", { className: "awr-lesson", children: [
8818
+ /* @__PURE__ */ jsxs20("div", { className: "awr-lesson__head", children: [
8819
+ /* @__PURE__ */ jsx21("code", { className: "awr-lesson__name", children: l.name }),
8820
+ l.revision > 1 && /* @__PURE__ */ jsx21("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
8821
+ forget && /* @__PURE__ */ jsx21(
8198
8822
  "button",
8199
8823
  {
8200
8824
  type: "button",
@@ -8202,12 +8826,12 @@ var LearnedSkills = ({
8202
8826
  title: `${L.notebookForget}: ${l.name}`,
8203
8827
  "aria-label": `${L.notebookForget}: ${l.name}`,
8204
8828
  onClick: () => void forget(l.name),
8205
- children: /* @__PURE__ */ jsx20(XIcon, { size: 12 })
8829
+ children: /* @__PURE__ */ jsx21(XIcon, { size: 12 })
8206
8830
  }
8207
8831
  )
8208
8832
  ] }),
8209
- /* @__PURE__ */ jsx20("p", { className: "awr-lesson__when", children: l.description }),
8210
- showSources && l.sources.length > 0 && /* @__PURE__ */ jsxs19("p", { className: "awr-lesson__from", children: [
8833
+ /* @__PURE__ */ jsx21("p", { className: "awr-lesson__when", children: l.description }),
8834
+ showSources && l.sources.length > 0 && /* @__PURE__ */ jsxs20("p", { className: "awr-lesson__from", children: [
8211
8835
  L.notebookFrom,
8212
8836
  " ",
8213
8837
  l.sources.join(", ")
@@ -8217,8 +8841,8 @@ var LearnedSkills = ({
8217
8841
  };
8218
8842
 
8219
8843
  // src/components/Composer.tsx
8220
- import { useState as useState17 } from "react";
8221
- import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
8844
+ import { useState as useState18 } from "react";
8845
+ import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
8222
8846
  var Composer = ({
8223
8847
  onSubmit,
8224
8848
  busy = false,
@@ -8227,7 +8851,7 @@ var Composer = ({
8227
8851
  placeholder = "Ask the agent to do something\u2026",
8228
8852
  className
8229
8853
  }) => {
8230
- const [text, setText] = useState17("");
8854
+ const [text, setText] = useState18("");
8231
8855
  const submit = () => {
8232
8856
  const value = text.trim();
8233
8857
  if (!value || busy || disabled) return;
@@ -8240,7 +8864,7 @@ var Composer = ({
8240
8864
  submit();
8241
8865
  }
8242
8866
  };
8243
- return /* @__PURE__ */ jsxs20(
8867
+ return /* @__PURE__ */ jsxs21(
8244
8868
  "form",
8245
8869
  {
8246
8870
  className: ["awr-composer", className].filter(Boolean).join(" "),
@@ -8249,7 +8873,7 @@ var Composer = ({
8249
8873
  submit();
8250
8874
  },
8251
8875
  children: [
8252
- /* @__PURE__ */ jsx21(
8876
+ /* @__PURE__ */ jsx22(
8253
8877
  "textarea",
8254
8878
  {
8255
8879
  className: "awr-composer__input",
@@ -8261,23 +8885,23 @@ var Composer = ({
8261
8885
  rows: 1
8262
8886
  }
8263
8887
  ),
8264
- busy ? /* @__PURE__ */ jsx21(
8888
+ busy ? /* @__PURE__ */ jsx22(
8265
8889
  "button",
8266
8890
  {
8267
8891
  type: "button",
8268
8892
  className: "awr-composer__btn awr-composer__btn--stop",
8269
8893
  onClick: onStop,
8270
8894
  "aria-label": "Stop",
8271
- children: /* @__PURE__ */ jsx21(StopIcon, { size: 18 })
8895
+ children: /* @__PURE__ */ jsx22(StopIcon, { size: 18 })
8272
8896
  }
8273
- ) : /* @__PURE__ */ jsx21(
8897
+ ) : /* @__PURE__ */ jsx22(
8274
8898
  "button",
8275
8899
  {
8276
8900
  type: "submit",
8277
8901
  className: "awr-composer__btn",
8278
8902
  disabled: disabled || !text.trim(),
8279
8903
  "aria-label": "Send",
8280
- children: disabled ? /* @__PURE__ */ jsx21(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ jsx21(SendIcon, { size: 18 })
8904
+ children: disabled ? /* @__PURE__ */ jsx22(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ jsx22(SendIcon, { size: 18 })
8281
8905
  }
8282
8906
  )
8283
8907
  ]
@@ -8286,17 +8910,17 @@ var Composer = ({
8286
8910
  };
8287
8911
 
8288
8912
  // src/components/PlanView.tsx
8289
- import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
8913
+ import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
8290
8914
  var PlanView = ({ plan, showThought = true, className }) => {
8291
8915
  if (!plan.steps.length && !plan.thought) return null;
8292
- return /* @__PURE__ */ jsxs21("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
8293
- showThought && plan.thought.trim() && /* @__PURE__ */ jsx22("p", { className: "awr-plan__thought", children: plan.thought }),
8294
- plan.steps.length > 0 && /* @__PURE__ */ jsx22("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ jsx22("li", { className: "awr-plan__step", children: step.description }, step.id)) })
8916
+ return /* @__PURE__ */ jsxs22("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
8917
+ showThought && plan.thought.trim() && /* @__PURE__ */ jsx23("p", { className: "awr-plan__thought", children: plan.thought }),
8918
+ plan.steps.length > 0 && /* @__PURE__ */ jsx23("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ jsx23("li", { className: "awr-plan__step", children: step.description }, step.id)) })
8295
8919
  ] });
8296
8920
  };
8297
8921
 
8298
8922
  // src/components/ApprovalModeSwitch.tsx
8299
- import { jsx as jsx23 } from "react/jsx-runtime";
8923
+ import { jsx as jsx24 } from "react/jsx-runtime";
8300
8924
  var DEFAULT_LABELS = {
8301
8925
  autopilot: "Autopilot",
8302
8926
  "ask-writes": "Ask before changes",
@@ -8316,13 +8940,13 @@ var ApprovalModeSwitch = ({
8316
8940
  labels,
8317
8941
  disabled,
8318
8942
  className
8319
- }) => /* @__PURE__ */ jsx23(
8943
+ }) => /* @__PURE__ */ jsx24(
8320
8944
  "div",
8321
8945
  {
8322
8946
  className: ["awr-modeswitch", className].filter(Boolean).join(" "),
8323
8947
  role: "radiogroup",
8324
8948
  "aria-label": "Tool consent",
8325
- children: modes.map((m) => /* @__PURE__ */ jsx23(
8949
+ children: modes.map((m) => /* @__PURE__ */ jsx24(
8326
8950
  "button",
8327
8951
  {
8328
8952
  type: "button",
@@ -8340,8 +8964,8 @@ var ApprovalModeSwitch = ({
8340
8964
  );
8341
8965
 
8342
8966
  // src/components/ApiKeyForm.tsx
8343
- import { useEffect as useEffect17, useState as useState18 } from "react";
8344
- import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
8967
+ import { useEffect as useEffect18, useState as useState19 } from "react";
8968
+ import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
8345
8969
  var ApiKeyForm = ({
8346
8970
  credentials,
8347
8971
  credentialRef,
@@ -8350,10 +8974,10 @@ var ApiKeyForm = ({
8350
8974
  onChange,
8351
8975
  className
8352
8976
  }) => {
8353
- const [value, setValue] = useState18("");
8354
- const [present, setPresent] = useState18(false);
8355
- const [busy, setBusy] = useState18(false);
8356
- useEffect17(() => {
8977
+ const [value, setValue] = useState19("");
8978
+ const [present, setPresent] = useState19(false);
8979
+ const [busy, setBusy] = useState19(false);
8980
+ useEffect18(() => {
8357
8981
  let active = true;
8358
8982
  credentials.hasKey(credentialRef).then((has) => {
8359
8983
  if (active) setPresent(has);
@@ -8385,16 +9009,16 @@ var ApiKeyForm = ({
8385
9009
  setBusy(false);
8386
9010
  }
8387
9011
  };
8388
- return /* @__PURE__ */ jsxs22("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
8389
- /* @__PURE__ */ jsxs22("label", { className: "awr-keyform__label", children: [
9012
+ return /* @__PURE__ */ jsxs23("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
9013
+ /* @__PURE__ */ jsxs23("label", { className: "awr-keyform__label", children: [
8390
9014
  label,
8391
- present && /* @__PURE__ */ jsxs22("span", { className: "awr-keyform__saved", children: [
8392
- /* @__PURE__ */ jsx24(CheckIcon, { size: 12 }),
9015
+ present && /* @__PURE__ */ jsxs23("span", { className: "awr-keyform__saved", children: [
9016
+ /* @__PURE__ */ jsx25(CheckIcon, { size: 12 }),
8393
9017
  " stored, encrypted"
8394
9018
  ] })
8395
9019
  ] }),
8396
- /* @__PURE__ */ jsxs22("div", { className: "awr-keyform__row", children: [
8397
- /* @__PURE__ */ jsx24(
9020
+ /* @__PURE__ */ jsxs23("div", { className: "awr-keyform__row", children: [
9021
+ /* @__PURE__ */ jsx25(
8398
9022
  "input",
8399
9023
  {
8400
9024
  className: "awr-keyform__input",
@@ -8412,7 +9036,7 @@ var ApiKeyForm = ({
8412
9036
  disabled: busy
8413
9037
  }
8414
9038
  ),
8415
- /* @__PURE__ */ jsx24(
9039
+ /* @__PURE__ */ jsx25(
8416
9040
  "button",
8417
9041
  {
8418
9042
  type: "button",
@@ -8422,7 +9046,7 @@ var ApiKeyForm = ({
8422
9046
  children: "Save"
8423
9047
  }
8424
9048
  ),
8425
- present && /* @__PURE__ */ jsx24(
9049
+ present && /* @__PURE__ */ jsx25(
8426
9050
  "button",
8427
9051
  {
8428
9052
  type: "button",
@@ -8472,6 +9096,7 @@ export {
8472
9096
  APP_DEFAULT_HEIGHT,
8473
9097
  APP_MAX_HEIGHT,
8474
9098
  APP_MIN_HEIGHT,
9099
+ ASK_USER_TOOL_NAME,
8475
9100
  AgentChat,
8476
9101
  AgentComposer,
8477
9102
  AgentLabelsProvider,
@@ -8535,6 +9160,8 @@ export {
8535
9160
  MessageList,
8536
9161
  ModelLoadBar,
8537
9162
  PlanView,
9163
+ QUESTION_TIMEOUT_MS,
9164
+ QuestionPrompt,
8538
9165
  SandboxedFrame,
8539
9166
  SessionBusyError,
8540
9167
  SourceView,
@@ -8561,6 +9188,8 @@ export {
8561
9188
  appMessageTextOf,
8562
9189
  appMimeTypeOf,
8563
9190
  appSamplingErrorOf,
9191
+ askUserOutputKept,
9192
+ askUserWith,
8564
9193
  attachmentKindOf,
8565
9194
  attachmentRefusal,
8566
9195
  buildMcpAppDocument,
@@ -8573,6 +9202,7 @@ export {
8573
9202
  createApprovalQueue,
8574
9203
  createFileTools,
8575
9204
  createInitialAgentState,
9205
+ createQuestionQueue,
8576
9206
  createRunControl2 as createRunControl,
8577
9207
  createSubagentTool,
8578
9208
  createWebLLMEngine,
@@ -8609,6 +9239,8 @@ export {
8609
9239
  mcpAppSandboxShellCsp,
8610
9240
  mcpAppSandboxTarget,
8611
9241
  mediaFamilyOf,
9242
+ menuKeyTarget,
9243
+ menuSections,
8612
9244
  mergeChatRecord,
8613
9245
  mergeLabels,
8614
9246
  newChatId,
@@ -8619,6 +9251,9 @@ export {
8619
9251
  pendingApprovalsOf,
8620
9252
  postStorageChange2 as postStorageChange,
8621
9253
  preloadWebLLMModel2 as preloadWebLLMModel,
9254
+ questionChoiceOf,
9255
+ questionOtherOf,
9256
+ questionTimeoutOf,
8622
9257
  resolveAppDownload,
8623
9258
  sandboxTokens,
8624
9259
  sandboxedCsp,
@@ -8649,6 +9284,7 @@ export {
8649
9284
  webSearchOf,
8650
9285
  withAttachments,
8651
9286
  withCspFirst,
8652
- withPolicyFirst
9287
+ withPolicyFirst,
9288
+ withoutOwnWords
8653
9289
  };
8654
9290
  //# sourceMappingURL=index.js.map