@dudko.dev/agent-web-react 0.0.27 → 0.0.29

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
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AlertIcon,
3
+ ArrowUpIcon,
3
4
  BoltIcon,
4
5
  BookIcon,
5
6
  BotIcon,
@@ -22,10 +23,12 @@ import {
22
23
  XIcon,
23
24
  errMessage,
24
25
  formatDuration,
26
+ formatProbability,
25
27
  formatTokens,
26
28
  imagesInOutput,
27
- previewValue
28
- } from "./chunk-LCJZEGB5.js";
29
+ previewValue,
30
+ webSearchOf
31
+ } from "./chunk-UUB7CE6N.js";
29
32
 
30
33
  // src/hooks/use-agent.ts
31
34
  import { useCallback, useEffect, useReducer, useRef, useState } from "react";
@@ -35,6 +38,9 @@ import {
35
38
  } from "@dudko.dev/agent-web";
36
39
 
37
40
  // src/state.ts
41
+ import {
42
+ isReplayedToolOutput
43
+ } from "@dudko.dev/agent-web";
38
44
  var approxTokens = (value) => {
39
45
  if (value === void 0) return 0;
40
46
  let text;
@@ -53,14 +59,28 @@ var emptyUsage = () => ({
53
59
  cachedInputTokens: 0,
54
60
  cacheWriteTokens: 0
55
61
  });
56
- var addUsage = (a, b) => ({
57
- inputTokens: a.inputTokens + b.inputTokens,
58
- outputTokens: a.outputTokens + b.outputTokens,
59
- totalTokens: a.totalTokens + b.totalTokens,
60
- reasoningTokens: (a.reasoningTokens ?? 0) + (b.reasoningTokens ?? 0),
61
- cachedInputTokens: (a.cachedInputTokens ?? 0) + (b.cachedInputTokens ?? 0),
62
- cacheWriteTokens: (a.cacheWriteTokens ?? 0) + (b.cacheWriteTokens ?? 0)
63
- });
62
+ var USAGE_COUNTS = [
63
+ "mediaCalls",
64
+ "imagesGenerated",
65
+ "speechCharacters",
66
+ "transcriptionSeconds",
67
+ "decisionCalls"
68
+ ];
69
+ var addUsage = (a, b) => {
70
+ const sum = {
71
+ inputTokens: a.inputTokens + b.inputTokens,
72
+ outputTokens: a.outputTokens + b.outputTokens,
73
+ totalTokens: a.totalTokens + b.totalTokens,
74
+ reasoningTokens: (a.reasoningTokens ?? 0) + (b.reasoningTokens ?? 0),
75
+ cachedInputTokens: (a.cachedInputTokens ?? 0) + (b.cachedInputTokens ?? 0),
76
+ cacheWriteTokens: (a.cacheWriteTokens ?? 0) + (b.cacheWriteTokens ?? 0)
77
+ };
78
+ for (const key of USAGE_COUNTS) {
79
+ const n = (a[key] ?? 0) + (b[key] ?? 0);
80
+ if (n) sum[key] = n;
81
+ }
82
+ return sum;
83
+ };
64
84
  var lessonsOf = (skills) => skills.filter((s) => s.origin?.kind === "learned").map((s) => ({
65
85
  name: s.name,
66
86
  description: s.description,
@@ -118,8 +138,13 @@ var applySubagentEvent = (view, event) => {
118
138
  return {
119
139
  ...view,
120
140
  steps: view.steps + 1,
121
- activity: `step ${event.index}/${event.total}: ${event.step.description}`
141
+ activity: `step ${event.index}/${event.total}: ${event.step.description}`,
142
+ // Known only when the child runs with model tiers.
143
+ ...event.model !== void 0 ? { model: event.model } : {},
144
+ ...event.tier !== void 0 ? { tier: event.tier } : {}
122
145
  };
146
+ case "step.escalated":
147
+ return { ...view, tier: event.to, ...event.model ? { model: event.model } : {} };
123
148
  case "step.tool-call":
124
149
  return { ...view, toolCalls: view.toolCalls + 1, activity: `\u2192 ${event.name}` };
125
150
  case "final.text-delta":
@@ -132,6 +157,208 @@ var applySubagentEvent = (view, event) => {
132
157
  return view;
133
158
  }
134
159
  };
160
+ var ensureSubagent = (state, id, name, ancestors, ctx) => {
161
+ if (state.subagents.some((s) => s.id === id)) return state;
162
+ const parentId = ancestors[ancestors.length - 1]?.id;
163
+ const parent = parentId ? state.subagents.find((s) => s.id === parentId) : void 0;
164
+ const stepId = parent ? parent.stepId : runningStepId(state.steps);
165
+ const node = {
166
+ id,
167
+ name,
168
+ task: "",
169
+ ...parentId ? { parentId } : {},
170
+ depth: ancestors.length + 1,
171
+ status: "running",
172
+ ...stepId ? { stepId } : {},
173
+ ...ctx.at !== void 0 ? { startedAt: ctx.at } : {},
174
+ activity: "starting",
175
+ steps: 0,
176
+ toolCalls: 0,
177
+ text: "",
178
+ usage: emptyUsage()
179
+ };
180
+ return { ...state, subagents: [...state.subagents, node] };
181
+ };
182
+ var startSubagent = (state, event, ancestors, ctx) => {
183
+ const depth = Math.max(event.depth ?? 1, ancestors.length + 1);
184
+ const parentId = ancestors[ancestors.length - 1]?.id ?? (depth > 1 ? event.parentId : void 0);
185
+ const told = {
186
+ name: event.name,
187
+ task: event.task,
188
+ depth,
189
+ ...parentId ? { parentId } : {},
190
+ ...event.profile ? { profile: event.profile } : {},
191
+ ...event.dynamic ? { dynamic: true } : {},
192
+ ...event.role ? { role: event.role } : {},
193
+ ...event.tools ? { tools: event.tools } : {}
194
+ };
195
+ if (state.subagents.some((s) => s.id === event.id)) {
196
+ return {
197
+ ...state,
198
+ subagents: patchSubagent(state.subagents, event.id, (s) => ({ ...s, ...told }))
199
+ };
200
+ }
201
+ const parent = parentId ? state.subagents.find((s) => s.id === parentId) : void 0;
202
+ const stepId = parent ? parent.stepId : runningStepId(state.steps);
203
+ const node = {
204
+ id: event.id,
205
+ ...told,
206
+ status: "running",
207
+ stepId,
208
+ ...ctx.at !== void 0 ? { startedAt: ctx.at } : {},
209
+ activity: "starting",
210
+ steps: 0,
211
+ toolCalls: 0,
212
+ text: "",
213
+ usage: emptyUsage()
214
+ };
215
+ return { ...state, subagents: [...state.subagents, node] };
216
+ };
217
+ var subagentDuration = (s, at) => at !== void 0 && s.startedAt !== void 0 ? { durationMs: Math.max(0, at - s.startedAt) } : {};
218
+ var addMedia = (state, view) => ({
219
+ ...state,
220
+ media: [...state.media ?? [], view],
221
+ ...view.stepId ? {
222
+ steps: patchStep(state.steps, view.stepId, (s) => ({
223
+ ...s,
224
+ media: [...s.media ?? [], view]
225
+ }))
226
+ } : {}
227
+ });
228
+ var mediaOf = (event, withStep) => ({
229
+ kind: event.kind,
230
+ path: event.path,
231
+ mediaType: event.mediaType,
232
+ bytes: event.bytes,
233
+ model: event.model,
234
+ ...withStep && event.step ? { stepId: event.step.id } : {}
235
+ });
236
+ var transcriptOf = (event) => ({
237
+ source: event.source,
238
+ name: event.name,
239
+ text: event.text,
240
+ ...event.language ? { language: event.language } : {},
241
+ ...event.durationInSeconds !== void 0 ? { durationInSeconds: event.durationInSeconds } : {},
242
+ model: event.model
243
+ });
244
+ var applySubagent = (state, event, ancestors, ctx) => {
245
+ switch (event.type) {
246
+ case "subagent.start":
247
+ return startSubagent(state, event, ancestors, ctx);
248
+ case "subagent.event": {
249
+ const known = ensureSubagent(state, event.id, event.name, ancestors, ctx);
250
+ const inner = event.event;
251
+ switch (inner.type) {
252
+ case "subagent.start":
253
+ case "subagent.event":
254
+ case "subagent.complete":
255
+ case "subagent.error":
256
+ return applySubagent(known, inner, [...ancestors, { id: event.id }], ctx);
257
+ // A helper the model started asks through the run's own consent gate (the event says
258
+ // which helper): its request is the user's to answer, like the run's. A subagent with
259
+ // a gate of its own (no `subagent` on the event) is its host's business.
260
+ case "tool.approval-requested": {
261
+ if (!inner.subagent || known.approvals.some((a) => a.id === inner.id)) return known;
262
+ const node = known.subagents.find((s) => s.id === inner.subagent.id);
263
+ return {
264
+ ...known,
265
+ approvals: [
266
+ ...known.approvals,
267
+ {
268
+ id: inner.id,
269
+ name: inner.name,
270
+ input: inner.input,
271
+ readOnly: inner.readOnly,
272
+ // The helper's own step ids mean nothing here: the step that delegated it does.
273
+ stepId: node?.stepId,
274
+ subagent: {
275
+ id: inner.subagent.id,
276
+ depth: inner.subagent.depth,
277
+ ...node ? { name: node.name } : {},
278
+ ...node?.role ? { role: node.role } : {}
279
+ },
280
+ status: "pending"
281
+ }
282
+ ]
283
+ };
284
+ }
285
+ case "tool.approval-resolved":
286
+ return known.approvals.some((a) => a.id === inner.id) ? {
287
+ ...known,
288
+ approvals: patchApproval(known.approvals, inner.id, (a) => ({
289
+ ...a,
290
+ status: inner.approved ? "approved" : "denied",
291
+ reason: inner.reason,
292
+ automatic: inner.automatic
293
+ }))
294
+ } : known;
295
+ // What a subagent generated is in the same workspace: it shows in the turn (its step
296
+ // ids are its own, so it is tied to no step here).
297
+ case "media.generated":
298
+ return addMedia(known, mediaOf(inner, false));
299
+ case "media.transcribed":
300
+ return { ...known, transcripts: [...known.transcripts ?? [], transcriptOf(inner)] };
301
+ default:
302
+ return {
303
+ ...known,
304
+ subagents: patchSubagent(
305
+ known.subagents,
306
+ event.id,
307
+ (s) => applySubagentEvent(s, inner)
308
+ )
309
+ };
310
+ }
311
+ }
312
+ case "subagent.complete": {
313
+ const known = ensureSubagent(state, event.id, event.name, ancestors, ctx);
314
+ return {
315
+ ...known,
316
+ subagents: patchSubagent(known.subagents, event.id, (s) => ({
317
+ ...s,
318
+ status: "done",
319
+ activity: "done",
320
+ text: event.text,
321
+ usage: event.usage,
322
+ ...subagentDuration(s, ctx.at)
323
+ }))
324
+ };
325
+ }
326
+ case "subagent.error": {
327
+ const known = ensureSubagent(state, event.id, event.name, ancestors, ctx);
328
+ return {
329
+ ...known,
330
+ subagents: patchSubagent(known.subagents, event.id, (s) => ({
331
+ ...s,
332
+ status: event.stopped ? "stopped" : "error",
333
+ activity: event.stopped ? "stopped" : "failed",
334
+ error: event.error,
335
+ // A helper says what it had spent when it ended; a static subagent does not.
336
+ ...event.usage ? { usage: event.usage } : {},
337
+ ...subagentDuration(s, ctx.at)
338
+ }))
339
+ };
340
+ }
341
+ }
342
+ };
343
+ var subagentTree = (subagents) => {
344
+ const nodes = /* @__PURE__ */ new Map();
345
+ for (const s of subagents) nodes.set(s.id, { ...s, children: [] });
346
+ const loops = (node) => {
347
+ let up = node.parentId;
348
+ for (let i = 0; up !== void 0 && i <= nodes.size; i++) {
349
+ if (up === node.id) return true;
350
+ up = nodes.get(up)?.parentId;
351
+ }
352
+ return false;
353
+ };
354
+ const roots = [];
355
+ for (const node of nodes.values()) {
356
+ const parent = node.parentId !== void 0 && !loops(node) ? nodes.get(node.parentId) : void 0;
357
+ if (parent) parent.children.push(node);
358
+ else roots.push(node);
359
+ }
360
+ return roots;
361
+ };
135
362
  var finalizeAssistant = (messages, content, extra = {}) => {
136
363
  for (let i = messages.length - 1; i >= 0; i--) {
137
364
  const m = messages[i];
@@ -213,10 +440,39 @@ var applyEvent = (state, event, ctx) => {
213
440
  reasoning: "",
214
441
  toolCalls: [],
215
442
  status: "running",
216
- blocked: false
443
+ blocked: false,
444
+ // Only with `config.executorTiers`: without it the view is what it always was.
445
+ ...event.tier !== void 0 ? { tier: event.tier } : {},
446
+ ...event.model !== void 0 ? { model: event.model } : {},
447
+ ...event.tierReason !== void 0 ? { tierReason: event.tierReason } : {}
217
448
  };
218
449
  return { ...state, steps: [...state.steps, view] };
219
450
  }
451
+ case "step.escalated":
452
+ return {
453
+ ...state,
454
+ steps: patchStep(state.steps, event.step.id, (s) => {
455
+ const attempt = (s.escalations?.length ?? 0) + 1;
456
+ return {
457
+ ...s,
458
+ tier: event.to,
459
+ ...event.model ? { model: event.model } : {},
460
+ text: "",
461
+ reasoning: "",
462
+ toolCalls: s.toolCalls.map((c) => c.attempt === void 0 ? { ...c, attempt } : c),
463
+ escalations: [
464
+ ...s.escalations ?? [],
465
+ {
466
+ from: event.from,
467
+ to: event.to,
468
+ reason: event.reason,
469
+ ...event.model ? { model: event.model } : {},
470
+ ...s.text.trim() ? { text: s.text } : {}
471
+ }
472
+ ]
473
+ };
474
+ })
475
+ };
220
476
  case "step.reasoning-delta":
221
477
  return {
222
478
  ...state,
@@ -260,6 +516,7 @@ var applyEvent = (state, event, ctx) => {
260
516
  ok: event.ok,
261
517
  status: "done",
262
518
  outputTokens: approxTokens(event.output),
519
+ ...isReplayedToolOutput(event.output) ? { replayed: true } : {},
263
520
  ...ctx.at !== void 0 && c.startedAt !== void 0 ? { durationMs: Math.max(0, ctx.at - c.startedAt) } : {}
264
521
  };
265
522
  }
@@ -275,6 +532,16 @@ var applyEvent = (state, event, ctx) => {
275
532
  ...s,
276
533
  status: "done",
277
534
  summary: event.result.summary,
535
+ // With tiers: where the step finished and how it got there. The result's list is the
536
+ // authority; an escalation seen live keeps what only the event told (model, text).
537
+ ...event.result.tier !== void 0 ? { tier: event.result.tier } : {},
538
+ ...event.result.model !== void 0 ? { model: event.result.model } : {},
539
+ ...event.result.escalations?.length ? {
540
+ escalations: event.result.escalations.map((e, i) => {
541
+ const live = s.escalations?.[i];
542
+ return live && live.from === e.from && live.to === e.to ? { ...live, reason: e.reason } : { from: e.from, to: e.to, reason: e.reason };
543
+ })
544
+ } : {},
278
545
  blocked: event.result.blocked,
279
546
  // The result carries the authoritative, ordered tool-call list; keep
280
547
  // the timing the streamed calls measured (matched in order per name).
@@ -293,21 +560,68 @@ var applyEvent = (state, event, ctx) => {
293
560
  inputTokens: approxTokens(c.input),
294
561
  outputTokens: approxTokens(c.output),
295
562
  ...streamed?.startedAt !== void 0 ? { startedAt: streamed.startedAt } : {},
296
- ...streamed?.durationMs !== void 0 ? { durationMs: streamed.durationMs } : {}
563
+ ...streamed?.durationMs !== void 0 ? { durationMs: streamed.durationMs } : {},
564
+ // With tiers the list holds every attempt's calls, in the order they were made.
565
+ ...streamed?.attempt !== void 0 ? { attempt: streamed.attempt } : {},
566
+ ...isReplayedToolOutput(c.output) ? { replayed: true } : {}
297
567
  };
298
568
  });
299
569
  })()
300
570
  }))
301
571
  };
302
- case "replan.decision":
572
+ case "replan.decision": {
573
+ if (!event.failed) {
574
+ return {
575
+ ...state,
576
+ replan: {
577
+ mode: event.mode,
578
+ reason: event.reason,
579
+ ...event.byUser ? { byUser: true } : {},
580
+ ...event.confidence !== void 0 ? { confidence: event.confidence } : {}
581
+ }
582
+ };
583
+ }
584
+ const error = state.replan?.failed ? state.replan.error : void 0;
585
+ const last = state.steps[state.steps.length - 1];
303
586
  return {
304
587
  ...state,
305
588
  replan: {
306
589
  mode: event.mode,
307
590
  reason: event.reason,
308
- ...event.byUser ? { byUser: true } : {}
309
- }
591
+ ...event.byUser ? { byUser: true } : {},
592
+ failed: true,
593
+ ...error ? { error } : {}
594
+ },
595
+ steps: last ? patchStep(state.steps, last.id, (s) => ({
596
+ ...s,
597
+ replanFailed: error ?? event.reason
598
+ })) : state.steps
310
599
  };
600
+ }
601
+ case "decision": {
602
+ const view = {
603
+ point: event.point,
604
+ accepted: event.accepted,
605
+ ...event.choice !== void 0 ? { choice: event.choice } : {},
606
+ ...event.confidence !== void 0 ? { confidence: event.confidence } : {},
607
+ threshold: event.threshold,
608
+ ...event.reason ? { reason: event.reason } : {},
609
+ durationMs: event.durationMs,
610
+ ...event.model ? { model: event.model } : {}
611
+ };
612
+ const last = state.steps[state.steps.length - 1];
613
+ return last ? {
614
+ ...state,
615
+ steps: patchStep(state.steps, last.id, (s) => ({
616
+ ...s,
617
+ decisions: [...s.decisions ?? [], view]
618
+ }))
619
+ } : { ...state, decisions: [...state.decisions ?? [], view] };
620
+ }
621
+ case "media.generated":
622
+ return addMedia(state, mediaOf(event, true));
623
+ case "media.transcribed":
624
+ return { ...state, transcripts: [...state.transcripts ?? [], transcriptOf(event)] };
311
625
  case "message.queued":
312
626
  return state.queued.some((q) => q.id === event.id) ? state : { ...state, queued: [...state.queued, { id: event.id, text: event.text }] };
313
627
  case "message.delivered": {
@@ -350,6 +664,7 @@ var applyEvent = (state, event, ctx) => {
350
664
  input: event.input,
351
665
  readOnly: event.readOnly,
352
666
  stepId: event.step?.id,
667
+ ...event.subagent ? { subagent: event.subagent } : {},
353
668
  status: "pending"
354
669
  }
355
670
  ]
@@ -381,55 +696,10 @@ var applyEvent = (state, event, ctx) => {
381
696
  };
382
697
  }
383
698
  case "subagent.start":
384
- return {
385
- ...state,
386
- subagents: [
387
- ...state.subagents,
388
- {
389
- id: event.id,
390
- name: event.name,
391
- task: event.task,
392
- status: "running",
393
- ...event.profile ? { profile: event.profile } : {},
394
- stepId: runningStepId(state.steps),
395
- activity: "starting",
396
- steps: 0,
397
- toolCalls: 0,
398
- text: "",
399
- usage: emptyUsage()
400
- }
401
- ]
402
- };
403
699
  case "subagent.event":
404
- return {
405
- ...state,
406
- subagents: patchSubagent(
407
- state.subagents,
408
- event.id,
409
- (s) => applySubagentEvent(s, event.event)
410
- )
411
- };
412
700
  case "subagent.complete":
413
- return {
414
- ...state,
415
- subagents: patchSubagent(state.subagents, event.id, (s) => ({
416
- ...s,
417
- status: "done",
418
- activity: "done",
419
- text: event.text,
420
- usage: event.usage
421
- }))
422
- };
423
701
  case "subagent.error":
424
- return {
425
- ...state,
426
- subagents: patchSubagent(state.subagents, event.id, (s) => ({
427
- ...s,
428
- status: event.stopped ? "stopped" : "error",
429
- activity: event.stopped ? "stopped" : "failed",
430
- error: event.error
431
- }))
432
- };
702
+ return applySubagent(state, event, [], ctx);
433
703
  case "skill.activated":
434
704
  return state.skills.includes(event.name) ? state : { ...state, skills: [...state.skills, event.name] };
435
705
  case "skill.learned": {
@@ -494,6 +764,12 @@ var applyEvent = (state, event, ctx) => {
494
764
  )
495
765
  };
496
766
  case "error":
767
+ if (event.phase === "replan") {
768
+ return {
769
+ ...state,
770
+ replan: { mode: "continue", reason: "", failed: true, error: event.error }
771
+ };
772
+ }
497
773
  return event.phase === "run" ? {
498
774
  ...state,
499
775
  error: event.error,
@@ -526,6 +802,9 @@ var syncRunMessage = (state) => {
526
802
  if (state.learnedNow.length > 0 && m.learned !== state.learnedNow)
527
803
  patch.learned = state.learnedNow;
528
804
  if (state.fetches.length > 0 && m.fetches !== state.fetches) patch.fetches = state.fetches;
805
+ if (state.media && m.media !== state.media) patch.media = state.media;
806
+ if (state.transcripts && m.transcripts !== state.transcripts)
807
+ patch.transcripts = state.transcripts;
529
808
  if ((m.approvals?.length ?? 0) !== decided.length || decided.some((a, k) => m.approvals?.[k] !== a)) {
530
809
  patch.approvals = decided;
531
810
  }
@@ -1501,7 +1780,54 @@ var defaultLabels = {
1501
1780
  stopSubagent: "Stop this subagent",
1502
1781
  subagentStopped: "stopped",
1503
1782
  failed: "failed",
1504
- toolCostTitle: "Estimated tokens of the arguments and of the result fed back to the model (chars / 4), and the call's duration"
1783
+ toolCostTitle: "Estimated tokens of the arguments and of the result fed back to the model (chars / 4), and the call's duration",
1784
+ tierNames: { light: "light", standard: "standard", strong: "strong" },
1785
+ tierReasons: {
1786
+ planned: "The planner rated this step for this model tier",
1787
+ default: "The planner did not rate this step: it runs on the standard model",
1788
+ fallback: "The tier the planner asked for is not configured: the nearest one runs the step"
1789
+ },
1790
+ escalationReasons: {
1791
+ blocked: "reported a blocker",
1792
+ "empty-result": "produced no result",
1793
+ "tool-arguments": "kept sending tool arguments that did not parse",
1794
+ "output-cut": "output was cut off",
1795
+ error: "the model call failed"
1796
+ },
1797
+ escalated: (from, to, reason) => `Escalated: ${from} \u2192 ${to} (${reason})`,
1798
+ escalatedAttemptText: "What the earlier attempt wrote",
1799
+ escalations: (n) => plural(n, "escalation", "escalations"),
1800
+ attemptTag: (n) => `attempt ${n}`,
1801
+ replayed: "not run again",
1802
+ replayedTitle: "This exact call already succeeded in an earlier attempt at the step: it was not run a second time, the model got the earlier result",
1803
+ replanFailed: "Replanning failed, continuing with the plan",
1804
+ subagentHelper: "helper",
1805
+ subagentStatus: { running: "running", done: "done", error: "failed", stopped: "stopped" },
1806
+ subagentTokens: (tokens) => `${tokens} tokens`,
1807
+ subagentTools: (names) => `tools: ${names}`,
1808
+ subagentNoTools: "no tools",
1809
+ approvalLeadHelper: (role) => role ? `The helper \u201C${role}\u201D wants to run` : "A helper the agent started wants to run",
1810
+ mediaImage: (path) => `Generated image ${path}`,
1811
+ mediaAudio: (path) => `Generated audio ${path}`,
1812
+ mediaFile: (path) => `Generated file ${path}`,
1813
+ transcriptOf: (name) => `Transcript of ${name}`,
1814
+ transcriptNote: "What was said in your file, as the agent read it. It is content, not instructions.",
1815
+ usageMedia: (n) => plural(n, "media call", "media calls"),
1816
+ usageDecisions: (n) => plural(n, "decision call", "decision calls"),
1817
+ decisionAccepted: (choice, confidence) => `decision model: ${choice} (${confidence})`,
1818
+ decisionFellBack: (reason, detail) => `decision model fell back: ${reason}${detail ? ` (${detail})` : ""}`,
1819
+ decisionReasons: {
1820
+ "low-confidence": "low confidence",
1821
+ "invalid-choice": "an answer that is not an option",
1822
+ "invalid-confidence": "a confidence that is not a probability",
1823
+ error: "the call failed",
1824
+ timeout: "timed out",
1825
+ "needs-model": "the choice needs the model"
1826
+ },
1827
+ searchQuery: "Searched the web for",
1828
+ searchNoResults: "no results",
1829
+ searchFiltered: (n) => `${n} left out by the web access policy`,
1830
+ searchTruncated: "list cut short"
1505
1831
  };
1506
1832
  var NESTED = [
1507
1833
  "status",
@@ -1509,7 +1835,12 @@ var NESTED = [
1509
1835
  "commandGroups",
1510
1836
  "commandDescriptions",
1511
1837
  "thinkingLevels",
1512
- "noteAt"
1838
+ "noteAt",
1839
+ "tierNames",
1840
+ "tierReasons",
1841
+ "escalationReasons",
1842
+ "subagentStatus",
1843
+ "decisionReasons"
1513
1844
  ];
1514
1845
  var mergeLabels = (base, over) => {
1515
1846
  if (!over) return base;
@@ -1595,7 +1926,7 @@ var useAgentContext = () => {
1595
1926
  var useOptionalAgentContext = () => useContext2(AgentContext);
1596
1927
 
1597
1928
  // src/components/AgentChat.tsx
1598
- import { useEffect as useEffect7, useRef as useRef7, useState as useState9 } from "react";
1929
+ import { useEffect as useEffect9, useRef as useRef7, useState as useState11 } from "react";
1599
1930
 
1600
1931
  // src/components/AgentComposer.tsx
1601
1932
  import { useEffect as useEffect5, useLayoutEffect, useMemo as useMemo4, useRef as useRef5, useState as useState7 } from "react";
@@ -2653,69 +2984,290 @@ var FilesPanel = ({
2653
2984
  ] });
2654
2985
  };
2655
2986
 
2656
- // src/components/StepList.tsx
2657
- import { Fragment as Fragment5 } from "react";
2987
+ // src/components/Media.tsx
2988
+ import { useEffect as useEffect7, useState as useState9 } from "react";
2989
+ import { MEDIA_AUDIO_TYPES, MEDIA_IMAGE_TYPES } from "@dudko.dev/agent-web";
2658
2990
  import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
2659
- var ToolCallRow = ({ call, showUsage = true, labels }) => {
2991
+ var mediaFamilyOf = (mediaType) => {
2992
+ const type = mediaType.toLowerCase().split(";")[0].trim();
2993
+ if (Object.hasOwn(MEDIA_IMAGE_TYPES, type)) return "image";
2994
+ if (Object.hasOwn(MEDIA_AUDIO_TYPES, type)) return "audio";
2995
+ return void 0;
2996
+ };
2997
+ var bytesOf = (content, encoding) => {
2998
+ if (encoding !== "base64") return new TextEncoder().encode(content);
2999
+ const binary = atob(content);
3000
+ const bytes = new Uint8Array(binary.length);
3001
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
3002
+ return bytes;
3003
+ };
3004
+ var useFileUrl = (files, path, mediaType) => {
3005
+ const [url, setUrl] = useState9(void 0);
3006
+ useEffect7(() => {
3007
+ if (!files || !mediaType) return;
3008
+ let made;
3009
+ let gone = false;
3010
+ files.read(path).then((file) => {
3011
+ if (gone || !file) return;
3012
+ made = URL.createObjectURL(
3013
+ new Blob([bytesOf(file.content, file.encoding)], { type: mediaType })
3014
+ );
3015
+ setUrl(made);
3016
+ }).catch(() => {
3017
+ });
3018
+ return () => {
3019
+ gone = true;
3020
+ if (made) URL.revokeObjectURL(made);
3021
+ setUrl(void 0);
3022
+ };
3023
+ }, [files, path, mediaType]);
3024
+ return url;
3025
+ };
3026
+ var GeneratedMedia = ({ media, files, labels }) => {
2660
3027
  const L = useLabels(labels);
2661
- const state = call.status === "calling" ? "calling" : call.ok === false ? "failed" : "ok";
2662
- const images = call.ok === false ? [] : imagesInOutput(call.output).slice(0, 4);
2663
- const cost = [
2664
- call.inputTokens ? `\u2248${formatTokens(call.inputTokens)} in` : "",
2665
- call.outputTokens ? `\u2248${formatTokens(call.outputTokens)} out` : "",
2666
- call.durationMs !== void 0 ? formatDuration(call.durationMs) : ""
2667
- ].filter(Boolean).join(" \xB7 ");
2668
- return /* @__PURE__ */ jsxs5("li", { className: `awr-tool awr-tool--${state}`, children: [
2669
- /* @__PURE__ */ jsxs5("div", { className: "awr-tool__row", children: [
2670
- /* @__PURE__ */ jsx7(ToolIcon, { size: 13, className: "awr-tool__icon" }),
2671
- /* @__PURE__ */ jsx7("code", { className: "awr-tool__name", children: call.name }),
2672
- previewValue(call.input) && /* @__PURE__ */ jsx7("span", { className: "awr-tool__args", children: previewValue(call.input) }),
2673
- call.status === "calling" && /* @__PURE__ */ jsx7(SpinnerIcon, { size: 12, className: "awr-tool__spin" }),
2674
- call.status === "done" && call.ok === false && /* @__PURE__ */ jsx7("span", { className: "awr-tool__badge", children: L.failed }),
2675
- showUsage && cost && /* @__PURE__ */ jsx7("span", { className: "awr-tool__cost", title: L.toolCostTitle, children: cost })
3028
+ const family = mediaFamilyOf(media.mediaType);
3029
+ const type = family ? media.mediaType.toLowerCase().split(";")[0].trim() : void 0;
3030
+ const url = useFileUrl(files, media.path, type);
3031
+ if (url && family === "image") {
3032
+ return /* @__PURE__ */ jsx7(
3033
+ "a",
3034
+ {
3035
+ className: "awr-media awr-media--image",
3036
+ href: url,
3037
+ target: "_blank",
3038
+ rel: "noopener noreferrer",
3039
+ title: media.path,
3040
+ children: /* @__PURE__ */ jsx7("img", { className: "awr-media__img", src: url, alt: L.mediaImage(media.path) })
3041
+ }
3042
+ );
3043
+ }
3044
+ if (url && family === "audio") {
3045
+ return /* @__PURE__ */ jsx7("span", { className: "awr-media awr-media--audio", title: media.path, children: /* @__PURE__ */ jsx7(
3046
+ "audio",
3047
+ {
3048
+ className: "awr-media__audio",
3049
+ controls: true,
3050
+ preload: "metadata",
3051
+ src: url,
3052
+ "aria-label": L.mediaAudio(media.path)
3053
+ }
3054
+ ) });
3055
+ }
3056
+ return /* @__PURE__ */ jsxs5("span", { className: "awr-chip awr-file awr-media awr-media--file", title: L.mediaFile(media.path), children: [
3057
+ /* @__PURE__ */ jsx7(FileIcon, { size: 13 }),
3058
+ " ",
3059
+ media.path
3060
+ ] });
3061
+ };
3062
+ var TranscriptBlock = ({ transcript, labels }) => {
3063
+ const L = useLabels(labels);
3064
+ return /* @__PURE__ */ jsxs5("details", { className: "awr-transcript", children: [
3065
+ /* @__PURE__ */ jsxs5("summary", { className: "awr-transcript__summary", children: [
3066
+ /* @__PURE__ */ jsx7(FileIcon, { size: 13 }),
3067
+ " ",
3068
+ L.transcriptOf(transcript.name)
2676
3069
  ] }),
2677
- images.length > 0 && /* @__PURE__ */ jsx7("div", { className: "awr-tool__images", children: images.map((src, i) => /* @__PURE__ */ jsx7("a", { href: src, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx7("img", { className: "awr-thumb", src, alt: `${call.name} result ${i + 1}` }) }, i)) })
3070
+ /* @__PURE__ */ jsx7("p", { className: "awr-transcript__note", children: L.transcriptNote }),
3071
+ /* @__PURE__ */ jsx7("blockquote", { className: "awr-transcript__text", children: transcript.text })
2678
3072
  ] });
2679
3073
  };
3074
+
3075
+ // src/components/StepList.tsx
3076
+ import { Fragment as Fragment6 } from "react";
3077
+
3078
+ // src/components/SubagentTree.tsx
3079
+ import { Fragment as Fragment5, useEffect as useEffect8, useState as useState10 } from "react";
3080
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
3081
+ var useElapsed = (startedAt, running) => {
3082
+ const [now, setNow] = useState10(void 0);
3083
+ useEffect8(() => {
3084
+ if (!running || startedAt === void 0) return;
3085
+ setNow(Date.now());
3086
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
3087
+ return () => clearInterval(timer);
3088
+ }, [running, startedAt]);
3089
+ return running && startedAt !== void 0 && now !== void 0 ? Math.max(0, now - startedAt) : void 0;
3090
+ };
2680
3091
  var SubagentRow = ({
2681
3092
  sub,
2682
3093
  onStop,
3094
+ showUsage = true,
3095
+ showTools = true,
3096
+ labels,
3097
+ children
3098
+ }) => {
3099
+ const L = useLabels(labels);
3100
+ const running = sub.status === "running";
3101
+ const elapsed = useElapsed(sub.startedAt, running);
3102
+ const time = sub.durationMs ?? elapsed;
3103
+ const role = sub.dynamic ? previewValue(sub.role ?? "", 48) : "";
3104
+ const meta = [
3105
+ sub.model ?? "",
3106
+ sub.tier ? L.tierNames[sub.tier] : "",
3107
+ sub.usage.totalTokens > 0 ? L.subagentTokens(formatTokens(sub.usage.totalTokens)) : "",
3108
+ sub.toolCalls > 0 ? L.toolCalls(sub.toolCalls) : "",
3109
+ time !== void 0 ? formatDuration(time) : ""
3110
+ ].filter(Boolean);
3111
+ return /* @__PURE__ */ jsxs6(
3112
+ "li",
3113
+ {
3114
+ className: `awr-subagent awr-subagent--${sub.status}${sub.dynamic ? " awr-subagent--dynamic" : ""}`,
3115
+ "data-depth": sub.depth,
3116
+ children: [
3117
+ /* @__PURE__ */ jsxs6("div", { className: "awr-subagent__head", children: [
3118
+ /* @__PURE__ */ jsx8("span", { className: "awr-subagent__icon", children: running ? /* @__PURE__ */ jsx8(SpinnerIcon, { size: 13 }) : sub.status === "done" ? /* @__PURE__ */ jsx8(BotIcon, { size: 13 }) : sub.status === "stopped" ? /* @__PURE__ */ jsx8(StopIcon, { size: 13 }) : /* @__PURE__ */ jsx8(AlertIcon, { size: 13 }) }),
3119
+ /* @__PURE__ */ jsx8("span", { className: "awr-subagent__name", title: sub.role, children: role || (sub.dynamic ? L.subagentHelper : sub.name) }),
3120
+ sub.dynamic && role && /* @__PURE__ */ jsx8("span", { className: "awr-subagent__profile", children: L.subagentHelper }),
3121
+ sub.profile && /* @__PURE__ */ jsx8("span", { className: "awr-subagent__profile", children: sub.profile }),
3122
+ /* @__PURE__ */ jsx8("span", { className: "awr-subagent__task", title: sub.task, children: previewValue(sub.task, 90) }),
3123
+ running && onStop && /* @__PURE__ */ jsx8(
3124
+ "button",
3125
+ {
3126
+ type: "button",
3127
+ className: "awr-iconbtn awr-subagent__stop",
3128
+ "aria-label": L.stopSubagent,
3129
+ title: L.stopSubagent,
3130
+ onClick: () => onStop(sub.id),
3131
+ children: /* @__PURE__ */ jsx8(StopIcon, { size: 12 })
3132
+ }
3133
+ )
3134
+ ] }),
3135
+ showUsage && /* @__PURE__ */ jsxs6("div", { className: "awr-subagent__meta", children: [
3136
+ /* @__PURE__ */ jsx8("span", { className: "awr-subagent__status", children: L.subagentStatus[sub.status] }),
3137
+ meta.map((part, i) => /* @__PURE__ */ jsx8("span", { className: "awr-subagent__metaitem", children: part }, i))
3138
+ ] }),
3139
+ showTools && sub.tools && /* @__PURE__ */ jsx8("div", { className: "awr-subagent__tools", children: sub.tools.length > 0 ? L.subagentTools(sub.tools.join(", ")) : L.subagentNoTools }),
3140
+ /* @__PURE__ */ jsx8("div", { className: "awr-subagent__activity", children: sub.status === "error" ? sub.error : sub.status === "stopped" ? L.subagentStopped : sub.status === "done" ? previewValue(sub.text, 160) : `${sub.activity}${!showUsage && sub.toolCalls ? ` \xB7 ${L.toolCalls(sub.toolCalls)}` : ""}` }),
3141
+ children
3142
+ ]
3143
+ }
3144
+ );
3145
+ };
3146
+ var SubagentTree = ({
3147
+ subagents,
3148
+ onStop,
3149
+ showUsage = true,
3150
+ showTools = true,
3151
+ renderSubagent,
3152
+ labels,
3153
+ className
3154
+ }) => {
3155
+ if (subagents.length === 0) return null;
3156
+ const branch = (nodes, nested) => /* @__PURE__ */ jsx8(
3157
+ "ul",
3158
+ {
3159
+ className: ["awr-subagents", nested ? "awr-subagents--nested" : className].filter(Boolean).join(" "),
3160
+ children: nodes.map((node) => {
3161
+ const row = /* @__PURE__ */ jsx8(
3162
+ SubagentRow,
3163
+ {
3164
+ sub: node,
3165
+ onStop,
3166
+ showUsage,
3167
+ showTools,
3168
+ labels,
3169
+ children: node.children.length > 0 ? branch(node.children, true) : null
3170
+ },
3171
+ node.id
3172
+ );
3173
+ return renderSubagent ? /* @__PURE__ */ jsx8(Fragment5, { children: renderSubagent(node, row) }, node.id) : row;
3174
+ })
3175
+ }
3176
+ );
3177
+ return branch(subagentTree(subagents), false);
3178
+ };
3179
+
3180
+ // src/components/StepList.tsx
3181
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
3182
+ var WEB_SEARCH = "web_search";
3183
+ var ToolCallRow = ({
3184
+ call,
3185
+ showUsage = true,
3186
+ showTiers = true,
3187
+ showSearchResults = true,
2683
3188
  labels
2684
3189
  }) => {
2685
3190
  const L = useLabels(labels);
2686
- return /* @__PURE__ */ jsxs5("li", { className: `awr-subagent awr-subagent--${sub.status}`, children: [
2687
- /* @__PURE__ */ jsxs5("div", { className: "awr-subagent__head", children: [
2688
- /* @__PURE__ */ jsx7(BotIcon, { size: 13, className: "awr-subagent__icon" }),
2689
- /* @__PURE__ */ jsx7("span", { className: "awr-subagent__name", children: sub.name }),
2690
- sub.profile && /* @__PURE__ */ jsx7("span", { className: "awr-subagent__profile", children: sub.profile }),
2691
- /* @__PURE__ */ jsx7("span", { className: "awr-subagent__task", title: sub.task, children: previewValue(sub.task, 90) }),
2692
- sub.status === "running" && /* @__PURE__ */ jsx7(SpinnerIcon, { size: 12, className: "awr-tool__spin" }),
2693
- sub.status === "running" && onStop && /* @__PURE__ */ jsx7(
2694
- "button",
2695
- {
2696
- type: "button",
2697
- className: "awr-iconbtn awr-subagent__stop",
2698
- "aria-label": L.stopSubagent,
2699
- title: L.stopSubagent,
2700
- onClick: () => onStop(sub.id),
2701
- children: /* @__PURE__ */ jsx7(StopIcon, { size: 12 })
2702
- }
2703
- )
2704
- ] }),
2705
- /* @__PURE__ */ jsx7("div", { className: "awr-subagent__activity", children: sub.status === "error" ? sub.error : sub.status === "stopped" ? L.subagentStopped : sub.status === "done" ? previewValue(sub.text, 160) : `${sub.activity}${sub.toolCalls ? ` \xB7 ${L.toolCalls(sub.toolCalls)}` : ""}` })
2706
- ] });
3191
+ const state = call.status === "calling" ? "calling" : call.ok === false ? "failed" : "ok";
3192
+ const images = call.ok === false ? [] : imagesInOutput(call.output).slice(0, 4);
3193
+ const search = showSearchResults && call.name === WEB_SEARCH && call.status === "done" && call.ok !== false ? webSearchOf(call.output) : void 0;
3194
+ const cost = [
3195
+ call.inputTokens ? `\u2248${formatTokens(call.inputTokens)} in` : "",
3196
+ call.outputTokens ? `\u2248${formatTokens(call.outputTokens)} out` : "",
3197
+ call.durationMs !== void 0 ? formatDuration(call.durationMs) : ""
3198
+ ].filter(Boolean).join(" \xB7 ");
3199
+ return /* @__PURE__ */ jsxs7(
3200
+ "li",
3201
+ {
3202
+ className: `awr-tool awr-tool--${state}${showTiers && call.attempt !== void 0 ? " awr-tool--earlier" : ""}`,
3203
+ children: [
3204
+ /* @__PURE__ */ jsxs7("div", { className: "awr-tool__row", children: [
3205
+ /* @__PURE__ */ jsx9(ToolIcon, { size: 13, className: "awr-tool__icon" }),
3206
+ /* @__PURE__ */ jsx9("code", { className: "awr-tool__name", children: call.name }),
3207
+ previewValue(call.input) && /* @__PURE__ */ jsx9("span", { className: "awr-tool__args", children: previewValue(call.input) }),
3208
+ call.status === "calling" && /* @__PURE__ */ jsx9(SpinnerIcon, { size: 12, className: "awr-tool__spin" }),
3209
+ call.status === "done" && call.ok === false && /* @__PURE__ */ jsx9("span", { className: "awr-tool__badge", children: L.failed }),
3210
+ showTiers && call.replayed && /* @__PURE__ */ jsx9("span", { className: "awr-tool__tag", title: L.replayedTitle, children: L.replayed }),
3211
+ showTiers && call.attempt !== void 0 && /* @__PURE__ */ jsx9("span", { className: "awr-tool__tag", children: L.attemptTag(call.attempt) }),
3212
+ showUsage && cost && /* @__PURE__ */ jsx9("span", { className: "awr-tool__cost", title: L.toolCostTitle, children: cost })
3213
+ ] }),
3214
+ images.length > 0 && /* @__PURE__ */ jsx9("div", { className: "awr-tool__images", children: images.map((src, i) => /* @__PURE__ */ jsx9("a", { href: src, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx9("img", { className: "awr-thumb", src, alt: `${call.name} result ${i + 1}` }) }, i)) }),
3215
+ search && /* @__PURE__ */ jsxs7("div", { className: "awr-search", children: [
3216
+ /* @__PURE__ */ jsxs7("p", { className: "awr-search__query", children: [
3217
+ /* @__PURE__ */ jsx9(GlobeIcon, { size: 12 }),
3218
+ " ",
3219
+ L.searchQuery,
3220
+ " ",
3221
+ /* @__PURE__ */ jsx9("q", { children: search.query })
3222
+ ] }),
3223
+ search.results.length > 0 ? /* @__PURE__ */ jsx9("ol", { className: "awr-search__results", children: search.results.map((r, i) => /* @__PURE__ */ jsxs7("li", { className: "awr-search__result", children: [
3224
+ /* @__PURE__ */ jsx9(
3225
+ "a",
3226
+ {
3227
+ className: "awr-search__title",
3228
+ href: r.url,
3229
+ target: "_blank",
3230
+ rel: "noopener noreferrer",
3231
+ children: r.title
3232
+ }
3233
+ ),
3234
+ " ",
3235
+ /* @__PURE__ */ jsxs7("span", { className: "awr-search__host", children: [
3236
+ r.host,
3237
+ r.date ? ` \xB7 ${r.date}` : ""
3238
+ ] }),
3239
+ r.snippet && /* @__PURE__ */ jsx9("p", { className: "awr-search__snippet", children: r.snippet })
3240
+ ] }, i)) }) : /* @__PURE__ */ jsx9("p", { className: "awr-search__note", children: L.searchNoResults }),
3241
+ (search.filtered > 0 || search.truncated) && /* @__PURE__ */ jsx9("p", { className: "awr-search__note", children: [
3242
+ search.filtered > 0 ? L.searchFiltered(search.filtered) : "",
3243
+ search.truncated ? L.searchTruncated : ""
3244
+ ].filter(Boolean).join(" \xB7 ") })
3245
+ ] })
3246
+ ]
3247
+ }
3248
+ );
2707
3249
  };
2708
3250
  var UserNoteRow = ({
2709
3251
  note,
2710
3252
  labels
2711
3253
  }) => {
2712
3254
  const L = useLabels(labels);
2713
- return /* @__PURE__ */ jsxs5("li", { className: `awr-note awr-note--${note.at}`, children: [
2714
- /* @__PURE__ */ jsx7(SendIcon, { size: 12, className: "awr-note__icon" }),
2715
- /* @__PURE__ */ jsx7("span", { className: "awr-note__where", children: L.noteAt[note.at] }),
2716
- /* @__PURE__ */ jsx7("q", { className: "awr-note__text", children: note.text })
3255
+ return /* @__PURE__ */ jsxs7("li", { className: `awr-note awr-note--${note.at}`, children: [
3256
+ /* @__PURE__ */ jsx9(SendIcon, { size: 12, className: "awr-note__icon" }),
3257
+ /* @__PURE__ */ jsx9("span", { className: "awr-note__where", children: L.noteAt[note.at] }),
3258
+ /* @__PURE__ */ jsx9("q", { className: "awr-note__text", children: note.text })
2717
3259
  ] });
2718
3260
  };
3261
+ var decisionNote = (d, L) => {
3262
+ if (d.accepted) {
3263
+ return L.decisionAccepted(
3264
+ d.choice ?? "",
3265
+ d.confidence !== void 0 ? formatProbability(d.confidence) : ""
3266
+ );
3267
+ }
3268
+ const detail = d.reason === "low-confidence" && d.confidence !== void 0 ? `${formatProbability(d.confidence)} < ${formatProbability(d.threshold)}` : "";
3269
+ return L.decisionFellBack(d.reason ? L.decisionReasons[d.reason] : "", detail);
3270
+ };
2719
3271
  var decisionLabel = (a, L) => a.status === "pending" ? L.consentWaiting : a.status === "approved" ? L.consentAllowed : L.consentDenied(a.reason);
2720
3272
  var StepItem = ({
2721
3273
  step,
@@ -2726,39 +3278,98 @@ var StepItem = ({
2726
3278
  showToolCalls,
2727
3279
  showUsage,
2728
3280
  showThoughts,
3281
+ showTiers,
3282
+ showReplanFailed,
3283
+ showDecisions,
3284
+ showSearchResults,
3285
+ showSubagents,
2729
3286
  renderToolCall,
3287
+ renderSubagent,
2730
3288
  L
2731
- }) => /* @__PURE__ */ jsxs5("li", { className: `awr-step awr-step--${step.blocked ? "blocked" : step.status}`, children: [
2732
- /* @__PURE__ */ jsxs5("div", { className: "awr-step__head", children: [
2733
- /* @__PURE__ */ jsx7("span", { className: "awr-step__marker", children: step.status === "running" ? /* @__PURE__ */ jsx7(SpinnerIcon, { size: 14 }) : step.blocked ? /* @__PURE__ */ jsx7(AlertIcon, { size: 14 }) : /* @__PURE__ */ jsx7(CheckIcon, { size: 14 }) }),
2734
- /* @__PURE__ */ jsxs5("span", { className: "awr-step__index", children: [
3289
+ }) => /* @__PURE__ */ jsxs7("li", { className: `awr-step awr-step--${step.blocked ? "blocked" : step.status}`, children: [
3290
+ /* @__PURE__ */ jsxs7("div", { className: "awr-step__head", children: [
3291
+ /* @__PURE__ */ jsx9("span", { className: "awr-step__marker", children: step.status === "running" ? /* @__PURE__ */ jsx9(SpinnerIcon, { size: 14 }) : step.blocked ? /* @__PURE__ */ jsx9(AlertIcon, { size: 14 }) : /* @__PURE__ */ jsx9(CheckIcon, { size: 14 }) }),
3292
+ /* @__PURE__ */ jsxs7("span", { className: "awr-step__index", children: [
2735
3293
  step.index,
2736
3294
  "/",
2737
3295
  step.total
2738
3296
  ] }),
2739
- /* @__PURE__ */ jsx7("span", { className: "awr-step__desc", children: step.step.description })
3297
+ /* @__PURE__ */ jsx9("span", { className: "awr-step__desc", children: step.step.description })
3298
+ ] }),
3299
+ showTiers && step.tier && /* @__PURE__ */ jsxs7("div", { className: "awr-step__meta", children: [
3300
+ /* @__PURE__ */ jsx9(
3301
+ "span",
3302
+ {
3303
+ className: `awr-step__tier awr-step__tier--${step.tier}`,
3304
+ title: step.tierReason ? L.tierReasons[step.tierReason] : void 0,
3305
+ children: L.tierNames[step.tier]
3306
+ }
3307
+ ),
3308
+ step.model && /* @__PURE__ */ jsx9("span", { className: "awr-step__model", children: step.model })
2740
3309
  ] }),
2741
- showThoughts && step.reasoning.trim() && /* @__PURE__ */ jsxs5("details", { className: "awr-thought", open: step.status === "running" && !step.text, children: [
2742
- /* @__PURE__ */ jsxs5("summary", { children: [
2743
- /* @__PURE__ */ jsx7(BrainIcon, { size: 13 }),
3310
+ showTiers && step.escalations?.map((e, i) => /* @__PURE__ */ jsxs7("div", { className: "awr-step__escalated", children: [
3311
+ /* @__PURE__ */ jsxs7("p", { className: "awr-step__escalated-line", children: [
3312
+ /* @__PURE__ */ jsx9(ArrowUpIcon, { size: 12 }),
3313
+ /* @__PURE__ */ jsx9("span", { children: L.escalated(L.tierNames[e.from], L.tierNames[e.to], L.escalationReasons[e.reason]) })
3314
+ ] }),
3315
+ e.text?.trim() && /* @__PURE__ */ jsxs7("details", { className: "awr-step__attempt", children: [
3316
+ /* @__PURE__ */ jsx9("summary", { children: L.escalatedAttemptText }),
3317
+ /* @__PURE__ */ jsx9("p", { className: "awr-step__text", children: e.text.trim() })
3318
+ ] })
3319
+ ] }, i)),
3320
+ showThoughts && step.reasoning.trim() && /* @__PURE__ */ jsxs7("details", { className: "awr-thought", open: step.status === "running" && !step.text, children: [
3321
+ /* @__PURE__ */ jsxs7("summary", { children: [
3322
+ /* @__PURE__ */ jsx9(BrainIcon, { size: 13 }),
2744
3323
  " ",
2745
3324
  L.stepThoughts
2746
3325
  ] }),
2747
- /* @__PURE__ */ jsx7("p", { className: "awr-thought__text", children: step.reasoning.trim() })
3326
+ /* @__PURE__ */ jsx9("p", { className: "awr-thought__text", children: step.reasoning.trim() })
2748
3327
  ] }),
2749
- step.text.trim() && /* @__PURE__ */ jsx7("p", { className: "awr-step__text", children: step.text.trim() }),
2750
- showToolCalls && step.toolCalls.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "awr-step__tools", children: step.toolCalls.map((call, i) => {
2751
- const row = /* @__PURE__ */ jsx7(ToolCallRow, { call, showUsage }, i);
2752
- return renderToolCall ? /* @__PURE__ */ jsx7(Fragment5, { children: renderToolCall(call, row) }, i) : row;
3328
+ step.text.trim() && /* @__PURE__ */ jsx9("p", { className: "awr-step__text", children: step.text.trim() }),
3329
+ showToolCalls && step.toolCalls.length > 0 && /* @__PURE__ */ jsx9("ul", { className: "awr-step__tools", children: step.toolCalls.map((call, i) => {
3330
+ const row = /* @__PURE__ */ jsx9(
3331
+ ToolCallRow,
3332
+ {
3333
+ call,
3334
+ showUsage,
3335
+ showTiers,
3336
+ showSearchResults
3337
+ },
3338
+ i
3339
+ );
3340
+ return renderToolCall ? /* @__PURE__ */ jsx9(Fragment6, { children: renderToolCall(call, row) }, i) : row;
2753
3341
  }) }),
2754
- approvals.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "awr-step__tools", children: approvals.map((a) => /* @__PURE__ */ jsxs5("li", { className: `awr-tool awr-tool__row awr-tool--approval-${a.status}`, children: [
2755
- /* @__PURE__ */ jsx7(ShieldIcon, { size: 13, className: "awr-tool__icon" }),
2756
- /* @__PURE__ */ jsx7("code", { className: "awr-tool__name", children: a.name }),
2757
- /* @__PURE__ */ jsx7("span", { className: "awr-tool__args", children: decisionLabel(a, L) })
3342
+ approvals.length > 0 && /* @__PURE__ */ jsx9("ul", { className: "awr-step__tools", children: approvals.map((a) => /* @__PURE__ */ jsxs7("li", { className: `awr-tool awr-tool__row awr-tool--approval-${a.status}`, children: [
3343
+ /* @__PURE__ */ jsx9(ShieldIcon, { size: 13, className: "awr-tool__icon" }),
3344
+ /* @__PURE__ */ jsx9("code", { className: "awr-tool__name", children: a.name }),
3345
+ /* @__PURE__ */ jsx9("span", { className: "awr-tool__args", children: decisionLabel(a, L) }),
3346
+ a.subagent && /* @__PURE__ */ jsx9("span", { className: "awr-tool__tag", children: L.subagentHelper })
2758
3347
  ] }, a.id)) }),
2759
- subagents.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "awr-subagents", children: subagents.map((sub) => /* @__PURE__ */ jsx7(SubagentRow, { sub, onStop: onStopSubagent }, sub.id)) }),
2760
- notes.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "awr-notes", children: notes.map((n) => /* @__PURE__ */ jsx7(UserNoteRow, { note: n }, n.id)) }),
2761
- step.blocked && step.summary && /* @__PURE__ */ jsx7("p", { className: "awr-step__blocked", children: step.summary })
3348
+ showSubagents && /* @__PURE__ */ jsx9(
3349
+ SubagentTree,
3350
+ {
3351
+ subagents,
3352
+ onStop: onStopSubagent,
3353
+ showUsage,
3354
+ renderSubagent
3355
+ }
3356
+ ),
3357
+ notes.length > 0 && /* @__PURE__ */ jsx9("ul", { className: "awr-notes", children: notes.map((n) => /* @__PURE__ */ jsx9(UserNoteRow, { note: n }, n.id)) }),
3358
+ step.blocked && step.summary && /* @__PURE__ */ jsx9("p", { className: "awr-step__blocked", children: step.summary }),
3359
+ showReplanFailed && step.replanFailed && /* @__PURE__ */ jsxs7("p", { className: "awr-step__warn", title: step.replanFailed, children: [
3360
+ /* @__PURE__ */ jsx9(AlertIcon, { size: 12 }),
3361
+ " ",
3362
+ L.replanFailed
3363
+ ] }),
3364
+ showDecisions && step.decisions?.map((d, i) => /* @__PURE__ */ jsx9(
3365
+ "p",
3366
+ {
3367
+ className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
3368
+ title: d.model,
3369
+ children: decisionNote(d, L)
3370
+ },
3371
+ i
3372
+ ))
2762
3373
  ] });
2763
3374
  var StepList = ({
2764
3375
  steps,
@@ -2770,7 +3381,13 @@ var StepList = ({
2770
3381
  showToolCalls = true,
2771
3382
  showUsage = true,
2772
3383
  showThoughts = true,
3384
+ showTiers = true,
3385
+ showReplanFailed = true,
3386
+ showDecisions = true,
3387
+ showSearchResults = true,
3388
+ showSubagents = true,
2773
3389
  renderToolCall,
3390
+ renderSubagent,
2774
3391
  labels,
2775
3392
  className
2776
3393
  }) => {
@@ -2778,8 +3395,9 @@ var StepList = ({
2778
3395
  if (steps.length === 0) return null;
2779
3396
  const known = new Set(steps.map((s) => s.id));
2780
3397
  const atEnd = showNotes ? notes.filter((n) => !n.stepId || !known.has(n.stepId)) : [];
2781
- return /* @__PURE__ */ jsxs5("ol", { className: ["awr-steps", className].filter(Boolean).join(" "), children: [
2782
- steps.map((step) => /* @__PURE__ */ jsx7(
3398
+ const loose = showSubagents ? subagents.filter((s) => !s.stepId || !known.has(s.stepId)) : [];
3399
+ return /* @__PURE__ */ jsxs7("ol", { className: ["awr-steps", className].filter(Boolean).join(" "), children: [
3400
+ steps.map((step) => /* @__PURE__ */ jsx9(
2783
3401
  StepItem,
2784
3402
  {
2785
3403
  step,
@@ -2790,17 +3408,32 @@ var StepList = ({
2790
3408
  showToolCalls,
2791
3409
  showUsage,
2792
3410
  showThoughts,
3411
+ showTiers,
3412
+ showReplanFailed,
3413
+ showDecisions,
3414
+ showSearchResults,
3415
+ showSubagents,
2793
3416
  renderToolCall,
3417
+ renderSubagent,
2794
3418
  L
2795
3419
  },
2796
3420
  step.id
2797
3421
  )),
2798
- atEnd.length > 0 && /* @__PURE__ */ jsx7("li", { className: "awr-step awr-step--notes", children: /* @__PURE__ */ jsx7("ul", { className: "awr-notes", children: atEnd.map((n) => /* @__PURE__ */ jsx7(UserNoteRow, { note: n }, n.id)) }) })
3422
+ loose.length > 0 && /* @__PURE__ */ jsx9("li", { className: "awr-step awr-step--subagents", children: /* @__PURE__ */ jsx9(
3423
+ SubagentTree,
3424
+ {
3425
+ subagents: loose,
3426
+ onStop: onStopSubagent,
3427
+ showUsage,
3428
+ renderSubagent
3429
+ }
3430
+ ) }),
3431
+ atEnd.length > 0 && /* @__PURE__ */ jsx9("li", { className: "awr-step awr-step--notes", children: /* @__PURE__ */ jsx9("ul", { className: "awr-notes", children: atEnd.map((n) => /* @__PURE__ */ jsx9(UserNoteRow, { note: n }, n.id)) }) })
2799
3432
  ] });
2800
3433
  };
2801
3434
 
2802
3435
  // src/components/MessageList.tsx
2803
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
3436
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
2804
3437
  var usageLine = (usage, durationMs) => {
2805
3438
  const parts = [];
2806
3439
  if (usage && usage.totalTokens > 0) {
@@ -2811,16 +3444,18 @@ var usageLine = (usage, durationMs) => {
2811
3444
  if (durationMs !== void 0) parts.push(formatDuration(durationMs));
2812
3445
  return parts.join(" \xB7 ");
2813
3446
  };
2814
- var AttachmentView = ({ attachment: a }) => a.dataUrl && a.mediaType.startsWith("image/") ? /* @__PURE__ */ jsx8("a", { href: a.dataUrl, target: "_blank", rel: "noreferrer", title: a.path ?? a.name, children: /* @__PURE__ */ jsx8("img", { className: "awr-thumb awr-thumb--msg", src: a.dataUrl, alt: a.name }) }) : /* @__PURE__ */ jsxs6("span", { className: "awr-chip awr-file", title: a.path ?? a.mediaType, children: [
2815
- /* @__PURE__ */ jsx8(FileIcon, { size: 13 }),
3447
+ var AttachmentView = ({ attachment: a }) => a.dataUrl && a.mediaType.startsWith("image/") ? /* @__PURE__ */ jsx10("a", { href: a.dataUrl, target: "_blank", rel: "noreferrer", title: a.path ?? a.name, children: /* @__PURE__ */ jsx10("img", { className: "awr-thumb awr-thumb--msg", src: a.dataUrl, alt: a.name }) }) : /* @__PURE__ */ jsxs8("span", { className: "awr-chip awr-file", title: a.path ?? a.mediaType, children: [
3448
+ /* @__PURE__ */ jsx10(FileIcon, { size: 13 }),
2816
3449
  " ",
2817
3450
  a.name
2818
3451
  ] });
2819
3452
  var toolCallCount = (m) => (m.steps ?? []).reduce((n, s) => n + s.toolCalls.length, 0);
2820
- var activitySummary = (m, showToolCalls, showLearned, L) => {
3453
+ var activitySummary = (m, showToolCalls, showLearned, showTiers, L) => {
2821
3454
  const steps = m.steps ?? [];
2822
3455
  const parts = [L.steps(steps.length)];
2823
3456
  if (showToolCalls) parts.push(L.toolCalls(toolCallCount(m)));
3457
+ const escalations = steps.reduce((n, s) => n + (s.escalations?.length ?? 0), 0);
3458
+ if (showTiers && escalations > 0) parts.push(L.escalations(escalations));
2824
3459
  if (m.subagents?.length) parts.push(L.subagents(m.subagents.length));
2825
3460
  if (m.skills?.length) parts.push(L.skillsUsed(m.skills.join(", ")));
2826
3461
  if (showLearned && m.learned?.length) parts.push(L.learnedNow(m.learned.join(", ")));
@@ -2836,6 +3471,15 @@ var MessageList = ({
2836
3471
  showThoughts = true,
2837
3472
  showNotes = true,
2838
3473
  showLearned = true,
3474
+ showTiers = true,
3475
+ showReplanFailed = true,
3476
+ showDecisions = true,
3477
+ showSearchResults = true,
3478
+ showSubagents = true,
3479
+ showMedia = true,
3480
+ files,
3481
+ renderMedia,
3482
+ renderSubagent,
2839
3483
  onStopSubagent,
2840
3484
  activityOpen = false,
2841
3485
  liveExtra,
@@ -2848,21 +3492,21 @@ var MessageList = ({
2848
3492
  }) => {
2849
3493
  const L = useLabels(labels);
2850
3494
  if (messages.length === 0) {
2851
- return empty ? /* @__PURE__ */ jsx8("div", { className: "awr-messages__empty", children: empty }) : null;
3495
+ return empty ? /* @__PURE__ */ jsx10("div", { className: "awr-messages__empty", children: empty }) : null;
2852
3496
  }
2853
- return /* @__PURE__ */ jsx8("div", { className: ["awr-messages", className].filter(Boolean).join(" "), children: messages.map((m) => {
3497
+ return /* @__PURE__ */ jsx10("div", { className: ["awr-messages", className].filter(Boolean).join(" "), children: messages.map((m) => {
2854
3498
  const steps = m.steps ?? [];
2855
3499
  const hasActivity = showActivity && (steps.length > 0 || (m.subagents?.length ?? 0) > 0 || m.pending && !!liveExtra);
2856
3500
  const usage = showUsage ? usageLine(m.usage, m.durationMs) : "";
2857
- const node = /* @__PURE__ */ jsx8(
3501
+ const node = /* @__PURE__ */ jsx10(
2858
3502
  "div",
2859
3503
  {
2860
3504
  className: `awr-msg awr-msg--${m.role}${m.error ? " awr-msg--error" : ""}${m.pending ? " is-pending" : ""}`,
2861
- children: /* @__PURE__ */ jsxs6("div", { className: "awr-msg__col", children: [
2862
- m.role === "assistant" && hasActivity && /* @__PURE__ */ jsxs6("details", { className: "awr-activity", open: m.pending || activityOpen, children: [
2863
- /* @__PURE__ */ jsx8("summary", { className: "awr-activity__summary", children: activitySummary(m, showToolCalls, showLearned, L) }),
3505
+ children: /* @__PURE__ */ jsxs8("div", { className: "awr-msg__col", children: [
3506
+ m.role === "assistant" && hasActivity && /* @__PURE__ */ jsxs8("details", { className: "awr-activity", open: m.pending || activityOpen, children: [
3507
+ /* @__PURE__ */ jsx10("summary", { className: "awr-activity__summary", children: activitySummary(m, showToolCalls, showLearned, showTiers, L) }),
2864
3508
  m.pending && liveExtra,
2865
- /* @__PURE__ */ jsx8(
3509
+ /* @__PURE__ */ jsx10(
2866
3510
  StepList,
2867
3511
  {
2868
3512
  steps,
@@ -2874,153 +3518,190 @@ var MessageList = ({
2874
3518
  showToolCalls,
2875
3519
  showUsage,
2876
3520
  showThoughts,
3521
+ showTiers,
3522
+ showReplanFailed,
3523
+ showDecisions,
3524
+ showSearchResults,
3525
+ showSubagents,
2877
3526
  renderToolCall,
3527
+ renderSubagent,
2878
3528
  labels
2879
3529
  }
2880
3530
  ),
2881
- showLearned && m.fetches?.length ? /* @__PURE__ */ jsx8("ul", { className: "awr-fetches", children: m.fetches.map((f, i) => /* @__PURE__ */ jsxs6(
3531
+ showLearned && m.fetches?.length ? /* @__PURE__ */ jsx10("ul", { className: "awr-fetches", children: m.fetches.map((f, i) => /* @__PURE__ */ jsxs8(
2882
3532
  "li",
2883
3533
  {
2884
3534
  className: `awr-fetch${f.allowed ? "" : " awr-fetch--refused"}`,
2885
3535
  children: [
2886
- /* @__PURE__ */ jsx8(GlobeIcon, { size: 12 }),
3536
+ /* @__PURE__ */ jsx10(GlobeIcon, { size: 12 }),
2887
3537
  " ",
2888
- /* @__PURE__ */ jsx8("code", { children: f.url }),
3538
+ /* @__PURE__ */ jsx10("code", { children: f.url }),
2889
3539
  " ",
2890
- /* @__PURE__ */ jsx8("span", { className: "awr-fetch__result", children: f.allowed ? f.status ?? "ok" : L.fetchRefused(f.reason ?? "") })
3540
+ /* @__PURE__ */ jsx10("span", { className: "awr-fetch__result", children: f.allowed ? f.status ?? "ok" : L.fetchRefused(f.reason ?? "") })
2891
3541
  ]
2892
3542
  },
2893
3543
  i
2894
3544
  )) }) : null,
2895
- showLearned && m.learned?.length ? /* @__PURE__ */ jsxs6("p", { className: "awr-learned", children: [
2896
- /* @__PURE__ */ jsx8(BookIcon, { size: 12 }),
3545
+ showLearned && m.learned?.length ? /* @__PURE__ */ jsxs8("p", { className: "awr-learned", children: [
3546
+ /* @__PURE__ */ jsx10(BookIcon, { size: 12 }),
2897
3547
  " ",
2898
3548
  L.learnedNow(m.learned.join(", "))
2899
3549
  ] }) : null,
2900
- showThoughts && m.reasoning?.trim() && /* @__PURE__ */ jsxs6("details", { className: "awr-thought", children: [
2901
- /* @__PURE__ */ jsxs6("summary", { children: [
2902
- /* @__PURE__ */ jsx8(BrainIcon, { size: 13 }),
3550
+ showThoughts && m.reasoning?.trim() && /* @__PURE__ */ jsxs8("details", { className: "awr-thought", children: [
3551
+ /* @__PURE__ */ jsxs8("summary", { children: [
3552
+ /* @__PURE__ */ jsx10(BrainIcon, { size: 13 }),
2903
3553
  " ",
2904
3554
  L.answerThoughts
2905
3555
  ] }),
2906
- /* @__PURE__ */ jsx8("p", { className: "awr-thought__text", children: m.reasoning.trim() })
3556
+ /* @__PURE__ */ jsx10("p", { className: "awr-thought__text", children: m.reasoning.trim() })
2907
3557
  ] })
2908
3558
  ] }),
2909
- (m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ jsxs6("div", { className: "awr-msg__bubble", children: [
3559
+ showMedia && m.transcripts?.length ? /* @__PURE__ */ jsx10("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ jsx10(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
3560
+ (m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ jsxs8("div", { className: "awr-msg__bubble", children: [
2910
3561
  m.content ? renderContent ? renderContent(m) : m.content : null,
2911
- m.pending && !m.content && /* @__PURE__ */ jsx8(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
3562
+ m.pending && !m.content && /* @__PURE__ */ jsx10(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
2912
3563
  ] }),
2913
- m.attachments?.length ? /* @__PURE__ */ jsx8("div", { className: "awr-msg__attachments", "aria-label": L.attachments, children: m.attachments.map((a, i) => /* @__PURE__ */ jsx8("span", { className: "awr-msg__attachment", children: renderAttachment ? renderAttachment(a, m) : /* @__PURE__ */ jsx8(AttachmentView, { attachment: a }) }, i)) }) : null,
2914
- m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ jsx8("div", { className: "awr-msg__usage", title: L.usageTitle, children: usage })
3564
+ showMedia && m.media?.length ? /* @__PURE__ */ jsx10("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
3565
+ const built = /* @__PURE__ */ jsx10(GeneratedMedia, { media: item, files, labels }, i);
3566
+ return renderMedia ? /* @__PURE__ */ jsx10("span", { className: "awr-msg__mediaitem", children: renderMedia(item, m, built) }, i) : built;
3567
+ }) }) : null,
3568
+ m.attachments?.length ? /* @__PURE__ */ jsx10("div", { className: "awr-msg__attachments", "aria-label": L.attachments, children: m.attachments.map((a, i) => /* @__PURE__ */ jsx10("span", { className: "awr-msg__attachment", children: renderAttachment ? renderAttachment(a, m) : /* @__PURE__ */ jsx10(AttachmentView, { attachment: a }) }, i)) }) : null,
3569
+ m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ jsx10("div", { className: "awr-msg__usage", title: L.usageTitle, children: usage })
2915
3570
  ] })
2916
3571
  },
2917
3572
  m.id
2918
3573
  );
2919
- return renderMessage ? /* @__PURE__ */ jsx8("div", { children: renderMessage(m, node) }, m.id) : node;
3574
+ return renderMessage ? /* @__PURE__ */ jsx10("div", { children: renderMessage(m, node) }, m.id) : node;
2920
3575
  }) });
2921
3576
  };
2922
3577
 
2923
3578
  // src/components/ModelLoadBar.tsx
2924
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
3579
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2925
3580
  var ModelLoadBar = ({ load, className }) => {
2926
3581
  const pct = Math.round(Math.max(0, Math.min(1, load.progress)) * 100);
2927
- return /* @__PURE__ */ jsxs7("div", { className: ["awr-modelload", className].filter(Boolean).join(" "), children: [
2928
- /* @__PURE__ */ jsxs7("div", { className: "awr-modelload__head", children: [
2929
- /* @__PURE__ */ jsx9("span", { className: "awr-modelload__text", children: load.text || "Loading model\u2026" }),
2930
- /* @__PURE__ */ jsxs7("span", { className: "awr-modelload__pct", children: [
3582
+ return /* @__PURE__ */ jsxs9("div", { className: ["awr-modelload", className].filter(Boolean).join(" "), children: [
3583
+ /* @__PURE__ */ jsxs9("div", { className: "awr-modelload__head", children: [
3584
+ /* @__PURE__ */ jsx11("span", { className: "awr-modelload__text", children: load.text || "Loading model\u2026" }),
3585
+ /* @__PURE__ */ jsxs9("span", { className: "awr-modelload__pct", children: [
2931
3586
  pct,
2932
3587
  "%"
2933
3588
  ] })
2934
3589
  ] }),
2935
- /* @__PURE__ */ jsx9("div", { className: "awr-modelload__track", role: "progressbar", "aria-valuenow": pct, children: /* @__PURE__ */ jsx9("div", { className: "awr-modelload__fill", style: { width: `${pct}%` } }) })
3590
+ /* @__PURE__ */ jsx11("div", { className: "awr-modelload__track", role: "progressbar", "aria-valuenow": pct, children: /* @__PURE__ */ jsx11("div", { className: "awr-modelload__fill", style: { width: `${pct}%` } }) })
2936
3591
  ] });
2937
3592
  };
2938
3593
 
2939
3594
  // src/components/ToolApprovalPrompt.tsx
2940
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
3595
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2941
3596
  var ToolApprovalPrompt = ({
2942
3597
  approvals,
2943
3598
  onApprove,
2944
3599
  onDeny,
2945
3600
  allowRemember = true,
3601
+ showHelper = true,
2946
3602
  renderApproval,
2947
3603
  labels,
2948
3604
  className
2949
3605
  }) => {
2950
3606
  const L = useLabels(labels);
2951
3607
  if (approvals.length === 0) return null;
2952
- return /* @__PURE__ */ jsx10("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
2953
- const card = /* @__PURE__ */ jsxs8("div", { className: "awr-approval", children: [
2954
- /* @__PURE__ */ jsxs8("div", { className: "awr-approval__head", children: [
2955
- /* @__PURE__ */ jsx10(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
2956
- /* @__PURE__ */ jsxs8("span", { children: [
2957
- L.approvalLead,
2958
- " ",
2959
- /* @__PURE__ */ jsx10("code", { className: "awr-tool__name", children: a.name }),
2960
- a.readOnly ? ` (${L.readOnlyTool})` : ""
2961
- ] })
2962
- ] }),
2963
- previewValue(a.input, 300) && /* @__PURE__ */ jsx10("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
2964
- /* @__PURE__ */ jsxs8("div", { className: "awr-approval__actions", children: [
2965
- /* @__PURE__ */ jsx10(
2966
- "button",
2967
- {
2968
- type: "button",
2969
- className: "awr-btn awr-btn--primary",
2970
- onClick: () => onApprove(a.id),
2971
- children: L.approve
2972
- }
2973
- ),
2974
- allowRemember && /* @__PURE__ */ jsx10(
2975
- "button",
2976
- {
2977
- type: "button",
2978
- className: "awr-btn",
2979
- onClick: () => onApprove(a.id, { remember: true }),
2980
- children: L.alwaysAllow
2981
- }
2982
- ),
2983
- /* @__PURE__ */ jsx10(
2984
- "button",
2985
- {
2986
- type: "button",
2987
- className: "awr-btn awr-btn--danger",
2988
- onClick: () => onDeny(a.id, L.declinedReason),
2989
- children: L.deny
2990
- }
2991
- )
2992
- ] })
2993
- ] }, a.id);
2994
- return renderApproval ? /* @__PURE__ */ jsx10("div", { children: renderApproval(a, card) }, a.id) : card;
3608
+ return /* @__PURE__ */ jsx12("div", { className: ["awr-approvals", className].filter(Boolean).join(" "), role: "alert", children: approvals.map((a) => {
3609
+ const helper = showHelper ? a.subagent : void 0;
3610
+ const card = /* @__PURE__ */ jsxs10(
3611
+ "div",
3612
+ {
3613
+ className: `awr-approval${helper ? " awr-approval--helper" : ""}`,
3614
+ "data-subagent": helper?.id,
3615
+ children: [
3616
+ /* @__PURE__ */ jsxs10("div", { className: "awr-approval__head", children: [
3617
+ /* @__PURE__ */ jsx12(ShieldIcon, { size: 14, className: "awr-approval__icon" }),
3618
+ /* @__PURE__ */ jsxs10("span", { children: [
3619
+ helper ? L.approvalLeadHelper(
3620
+ previewValue(helper.role ?? "", 60) || void 0,
3621
+ helper.depth
3622
+ ) : L.approvalLead,
3623
+ " ",
3624
+ /* @__PURE__ */ jsx12("code", { className: "awr-tool__name", children: a.name }),
3625
+ a.readOnly ? ` (${L.readOnlyTool})` : ""
3626
+ ] })
3627
+ ] }),
3628
+ previewValue(a.input, 300) && /* @__PURE__ */ jsx12("pre", { className: "awr-approval__input", children: previewValue(a.input, 300) }),
3629
+ /* @__PURE__ */ jsxs10("div", { className: "awr-approval__actions", children: [
3630
+ /* @__PURE__ */ jsx12(
3631
+ "button",
3632
+ {
3633
+ type: "button",
3634
+ className: "awr-btn awr-btn--primary",
3635
+ onClick: () => onApprove(a.id),
3636
+ children: L.approve
3637
+ }
3638
+ ),
3639
+ allowRemember && /* @__PURE__ */ jsx12(
3640
+ "button",
3641
+ {
3642
+ type: "button",
3643
+ className: "awr-btn",
3644
+ onClick: () => onApprove(a.id, { remember: true }),
3645
+ children: L.alwaysAllow
3646
+ }
3647
+ ),
3648
+ /* @__PURE__ */ jsx12(
3649
+ "button",
3650
+ {
3651
+ type: "button",
3652
+ className: "awr-btn awr-btn--danger",
3653
+ onClick: () => onDeny(a.id, L.declinedReason),
3654
+ children: L.deny
3655
+ }
3656
+ )
3657
+ ] })
3658
+ ]
3659
+ },
3660
+ a.id
3661
+ );
3662
+ return renderApproval ? /* @__PURE__ */ jsx12("div", { children: renderApproval(a, card) }, a.id) : card;
2995
3663
  }) });
2996
3664
  };
2997
3665
 
2998
3666
  // src/components/UsageBadge.tsx
2999
- import { jsxs as jsxs9 } from "react/jsx-runtime";
3000
- var UsageBadge = ({ usage, compact = false, className }) => {
3001
- if (usage.totalTokens === 0) return null;
3667
+ import { jsxs as jsxs11 } from "react/jsx-runtime";
3668
+ var UsageBadge = ({
3669
+ usage,
3670
+ compact = false,
3671
+ showCalls = true,
3672
+ labels,
3673
+ className
3674
+ }) => {
3675
+ const L = useLabels(labels);
3676
+ const media = showCalls ? usage.mediaCalls ?? 0 : 0;
3677
+ const decisions = showCalls ? usage.decisionCalls ?? 0 : 0;
3678
+ if (usage.totalTokens === 0 && media === 0 && decisions === 0) return null;
3002
3679
  const reasoning = usage.reasoningTokens ?? 0;
3003
3680
  const cached = usage.cachedInputTokens ?? 0;
3004
3681
  const title = [
3005
3682
  `${usage.inputTokens} in + ${usage.outputTokens} out = ${usage.totalTokens} tokens`,
3006
3683
  reasoning ? `${reasoning} thinking` : "",
3007
- cached ? `${cached} input tokens from the prompt cache` : ""
3684
+ cached ? `${cached} input tokens from the prompt cache` : "",
3685
+ media ? L.usageMedia(media) : "",
3686
+ decisions ? L.usageDecisions(decisions) : ""
3008
3687
  ].filter(Boolean).join(" \xB7 ");
3009
- return /* @__PURE__ */ jsxs9("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
3688
+ return /* @__PURE__ */ jsxs11("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
3010
3689
  formatTokens(usage.inputTokens),
3011
3690
  "\u2191 ",
3012
3691
  formatTokens(usage.outputTokens),
3013
3692
  "\u2193",
3014
3693
  !compact && reasoning > 0 && ` \xB7 ${formatTokens(reasoning)} think`,
3015
- !compact && cached > 0 && ` \xB7 ${formatTokens(cached)} cached`
3694
+ !compact && cached > 0 && ` \xB7 ${formatTokens(cached)} cached`,
3695
+ !compact && media > 0 && ` \xB7 ${L.usageMedia(media)}`,
3696
+ !compact && decisions > 0 && ` \xB7 ${L.usageDecisions(decisions)}`
3016
3697
  ] });
3017
3698
  };
3018
3699
 
3019
3700
  // src/components/AgentChat.tsx
3020
- import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
3701
+ import { Fragment as Fragment7, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
3021
3702
  var isHistoryHook = (h) => typeof h === "object" && h !== null && "select" in h && "chats" in h;
3022
3703
  var cx = (...names) => names.filter(Boolean).join(" ");
3023
- var AgentChat = (props) => /* @__PURE__ */ jsx11(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ jsx11(AgentChatInner, { ...props }) });
3704
+ var AgentChat = (props) => /* @__PURE__ */ jsx13(AgentLabelsProvider, { labels: props.labels ?? NO_LABELS, children: /* @__PURE__ */ jsx13(AgentChatInner, { ...props }) });
3024
3705
  var NO_LABELS = {};
3025
3706
  var AgentChatInner = ({
3026
3707
  controller,
@@ -3033,6 +3714,12 @@ var AgentChatInner = ({
3033
3714
  showThoughts = true,
3034
3715
  showNotes = true,
3035
3716
  showLearned = true,
3717
+ showTiers = true,
3718
+ showReplanFailed = true,
3719
+ showDecisions = true,
3720
+ showSearchResults = true,
3721
+ showSubagents = true,
3722
+ showMedia = true,
3036
3723
  stoppableSubagents = true,
3037
3724
  showTotalUsage = true,
3038
3725
  showStatus = true,
@@ -3049,6 +3736,8 @@ var AgentChatInner = ({
3049
3736
  renderMessage,
3050
3737
  renderAttachment,
3051
3738
  renderToolCall,
3739
+ renderSubagent,
3740
+ renderMedia,
3052
3741
  renderApproval,
3053
3742
  slots = {},
3054
3743
  components = {},
@@ -3066,7 +3755,7 @@ var AgentChatInner = ({
3066
3755
  }
3067
3756
  const L = useLabels();
3068
3757
  const external = isHistoryHook(history) ? history : void 0;
3069
- const [ownStore] = useState9(
3758
+ const [ownStore] = useState11(
3070
3759
  () => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
3071
3760
  );
3072
3761
  const own = useChatHistory(agent, {
@@ -3075,8 +3764,8 @@ var AgentChatInner = ({
3075
3764
  });
3076
3765
  const chats = history ? external ?? own : void 0;
3077
3766
  const rootRef = useRef7(null);
3078
- const [narrow, setNarrow] = useState9(void 0);
3079
- useEffect7(() => {
3767
+ const [narrow, setNarrow] = useState11(void 0);
3768
+ useEffect9(() => {
3080
3769
  const el = rootRef.current;
3081
3770
  if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
3082
3771
  const measure = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
@@ -3085,9 +3774,9 @@ var AgentChatInner = ({
3085
3774
  ro.observe(el);
3086
3775
  return () => ro.disconnect();
3087
3776
  }, [narrowWidth]);
3088
- const [historyChoice, setHistoryOpen] = useState9(defaultHistoryOpen);
3777
+ const [historyChoice, setHistoryOpen] = useState11(defaultHistoryOpen);
3089
3778
  const historyOpen = historyChoice ?? narrow === false;
3090
- const [filesOpen, setFilesOpen] = useState9(defaultFilesOpen);
3779
+ const [filesOpen, setFilesOpen] = useState11(defaultFilesOpen);
3091
3780
  const toggleHistory = () => {
3092
3781
  setHistoryOpen(!historyOpen);
3093
3782
  if (narrow && !historyOpen) setFilesOpen(false);
@@ -3098,11 +3787,11 @@ var AgentChatInner = ({
3098
3787
  };
3099
3788
  const bodyRef = useRef7(null);
3100
3789
  const stickRef = useRef7(true);
3101
- useEffect7(() => {
3790
+ useEffect9(() => {
3102
3791
  const el = bodyRef.current;
3103
3792
  if (el && stickRef.current) el.scrollTop = el.scrollHeight;
3104
3793
  }, [agent.messages, agent.steps, agent.finalText, agent.modelLoad, agent.pendingApprovals]);
3105
- const [compacting, setCompacting] = useState9(false);
3794
+ const [compacting, setCompacting] = useState11(false);
3106
3795
  const compact = () => {
3107
3796
  setCompacting(true);
3108
3797
  void agent.compact().finally(() => setCompacting(false));
@@ -3114,15 +3803,30 @@ var AgentChatInner = ({
3114
3803
  const Approvals = components.ApprovalPrompt ?? ToolApprovalPrompt;
3115
3804
  const loading = agent.modelLoad && agent.modelLoad.progress < 1;
3116
3805
  const showReplan = agent.replan && agent.replan.mode !== "continue";
3117
- const liveExtra = agent.planThought.trim() || showReplan ? /* @__PURE__ */ jsxs10(Fragment6, { children: [
3118
- agent.planThought.trim() && /* @__PURE__ */ jsxs10("details", { className: "awr-activity__plan", children: [
3119
- /* @__PURE__ */ jsx11("summary", { children: L.planned }),
3120
- /* @__PURE__ */ jsx11("p", { className: "awr-activity__thought", children: agent.planThought })
3806
+ const replanFailedEarly = showReplanFailed && agent.replan?.failed === true && agent.steps.length === 0;
3807
+ const earlyDecisions = showDecisions ? agent.decisions ?? [] : [];
3808
+ const liveExtra = agent.planThought.trim() || showReplan || replanFailedEarly || earlyDecisions.length > 0 ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
3809
+ agent.planThought.trim() && /* @__PURE__ */ jsxs12("details", { className: "awr-activity__plan", children: [
3810
+ /* @__PURE__ */ jsx13("summary", { children: L.planned }),
3811
+ /* @__PURE__ */ jsx13("p", { className: "awr-activity__thought", children: agent.planThought })
3812
+ ] }),
3813
+ showReplan && /* @__PURE__ */ jsx13("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) }),
3814
+ replanFailedEarly && /* @__PURE__ */ jsxs12("p", { className: "awr-step__warn", title: agent.replan.error, children: [
3815
+ /* @__PURE__ */ jsx13(AlertIcon, { size: 12 }),
3816
+ " ",
3817
+ L.replanFailed
3121
3818
  ] }),
3122
- showReplan && /* @__PURE__ */ jsx11("div", { className: "awr-activity__replan", children: L.replanned(agent.replan.mode, agent.replan.reason) })
3819
+ earlyDecisions.map((d, i) => /* @__PURE__ */ jsx13(
3820
+ "p",
3821
+ {
3822
+ className: `awr-step__decision${d.accepted ? "" : " awr-step__decision--fallback"}`,
3823
+ children: decisionNote(d, L)
3824
+ },
3825
+ i
3826
+ ))
3123
3827
  ] }) : void 0;
3124
- const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ jsxs10("div", { className: cx("awr-chat__header", classNames.header), children: [
3125
- chats && /* @__PURE__ */ jsx11(
3828
+ const header = slots.header === false ? null : slots.header !== void 0 ? slots.header : /* @__PURE__ */ jsxs12("div", { className: cx("awr-chat__header", classNames.header), children: [
3829
+ chats && /* @__PURE__ */ jsx13(
3126
3830
  "button",
3127
3831
  {
3128
3832
  type: "button",
@@ -3131,17 +3835,17 @@ var AgentChatInner = ({
3131
3835
  title: L.showHistory,
3132
3836
  "aria-pressed": historyOpen,
3133
3837
  onClick: toggleHistory,
3134
- children: /* @__PURE__ */ jsx11(HistoryIcon, { size: 16 })
3838
+ children: /* @__PURE__ */ jsx13(HistoryIcon, { size: 16 })
3135
3839
  }
3136
3840
  ),
3137
3841
  slots.headerStart,
3138
- /* @__PURE__ */ jsx11("div", { className: "awr-chat__title", children: title }),
3139
- showStatus && /* @__PURE__ */ jsxs10("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
3140
- /* @__PURE__ */ jsx11("span", { className: "awr-status__dot" }),
3141
- /* @__PURE__ */ jsx11("span", { className: "awr-status__text", children: L.status[agent.status] })
3842
+ /* @__PURE__ */ jsx13("div", { className: "awr-chat__title", children: title }),
3843
+ showStatus && /* @__PURE__ */ jsxs12("span", { className: `awr-status awr-status--${agent.status}`, title: L.status[agent.status], children: [
3844
+ /* @__PURE__ */ jsx13("span", { className: "awr-status__dot" }),
3845
+ /* @__PURE__ */ jsx13("span", { className: "awr-status__text", children: L.status[agent.status] })
3142
3846
  ] }),
3143
- showTotalUsage && /* @__PURE__ */ jsx11("span", { title: L.totalUsage, children: /* @__PURE__ */ jsx11(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
3144
- files && /* @__PURE__ */ jsx11(
3847
+ showTotalUsage && /* @__PURE__ */ jsx13("span", { title: L.totalUsage, children: /* @__PURE__ */ jsx13(UsageBadge, { usage: agent.totalUsage, compact: narrow !== false }) }),
3848
+ files && /* @__PURE__ */ jsx13(
3145
3849
  "button",
3146
3850
  {
3147
3851
  type: "button",
@@ -3150,12 +3854,12 @@ var AgentChatInner = ({
3150
3854
  title: L.showFiles,
3151
3855
  "aria-pressed": filesOpen,
3152
3856
  onClick: toggleFiles,
3153
- children: /* @__PURE__ */ jsx11(FileIcon, { size: 16 })
3857
+ children: /* @__PURE__ */ jsx13(FileIcon, { size: 16 })
3154
3858
  }
3155
3859
  ),
3156
3860
  slots.headerEnd
3157
3861
  ] });
3158
- return /* @__PURE__ */ jsxs10(
3862
+ return /* @__PURE__ */ jsxs12(
3159
3863
  "div",
3160
3864
  {
3161
3865
  ref: rootRef,
@@ -3163,8 +3867,8 @@ var AgentChatInner = ({
3163
3867
  style,
3164
3868
  "data-awr-theme": theme === "auto" ? void 0 : theme,
3165
3869
  children: [
3166
- chats && historyOpen && /* @__PURE__ */ jsxs10("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
3167
- /* @__PURE__ */ jsx11(
3870
+ chats && historyOpen && /* @__PURE__ */ jsxs12("aside", { className: cx("awr-chat__sidebar", classNames.sidebar), children: [
3871
+ /* @__PURE__ */ jsx13(
3168
3872
  HistoryList,
3169
3873
  {
3170
3874
  history: {
@@ -3183,7 +3887,7 @@ var AgentChatInner = ({
3183
3887
  }
3184
3888
  ),
3185
3889
  slots.sidebar,
3186
- /* @__PURE__ */ jsx11(
3890
+ /* @__PURE__ */ jsx13(
3187
3891
  "button",
3188
3892
  {
3189
3893
  type: "button",
@@ -3194,9 +3898,9 @@ var AgentChatInner = ({
3194
3898
  }
3195
3899
  )
3196
3900
  ] }),
3197
- /* @__PURE__ */ jsxs10("div", { className: cx("awr-chat__main", classNames.main), children: [
3901
+ /* @__PURE__ */ jsxs12("div", { className: cx("awr-chat__main", classNames.main), children: [
3198
3902
  header,
3199
- /* @__PURE__ */ jsxs10(
3903
+ /* @__PURE__ */ jsxs12(
3200
3904
  "div",
3201
3905
  {
3202
3906
  className: cx("awr-chat__body", classNames.body),
@@ -3207,7 +3911,7 @@ var AgentChatInner = ({
3207
3911
  },
3208
3912
  children: [
3209
3913
  slots.beforeMessages,
3210
- /* @__PURE__ */ jsx11(
3914
+ /* @__PURE__ */ jsx13(
3211
3915
  Messages,
3212
3916
  {
3213
3917
  messages: agent.messages,
@@ -3218,6 +3922,15 @@ var AgentChatInner = ({
3218
3922
  showThoughts,
3219
3923
  showNotes,
3220
3924
  showLearned,
3925
+ showTiers,
3926
+ showReplanFailed,
3927
+ showDecisions,
3928
+ showSearchResults,
3929
+ showSubagents,
3930
+ showMedia,
3931
+ files,
3932
+ renderMedia,
3933
+ renderSubagent,
3221
3934
  onStopSubagent: stoppableSubagents ? agent.stopSubagent : void 0,
3222
3935
  activityOpen,
3223
3936
  liveExtra,
@@ -3227,7 +3940,7 @@ var AgentChatInner = ({
3227
3940
  renderToolCall
3228
3941
  }
3229
3942
  ),
3230
- /* @__PURE__ */ jsx11(
3943
+ /* @__PURE__ */ jsx13(
3231
3944
  Approvals,
3232
3945
  {
3233
3946
  approvals: agent.pendingApprovals,
@@ -3236,14 +3949,14 @@ var AgentChatInner = ({
3236
3949
  renderApproval
3237
3950
  }
3238
3951
  ),
3239
- agent.modelLoad && loading && /* @__PURE__ */ jsx11(ModelLoadBar, { load: agent.modelLoad }),
3952
+ agent.modelLoad && loading && /* @__PURE__ */ jsx13(ModelLoadBar, { load: agent.modelLoad }),
3240
3953
  slots.afterMessages
3241
3954
  ]
3242
3955
  }
3243
3956
  ),
3244
- /* @__PURE__ */ jsxs10("div", { className: cx("awr-chat__footer", classNames.footer), children: [
3957
+ /* @__PURE__ */ jsxs12("div", { className: cx("awr-chat__footer", classNames.footer), children: [
3245
3958
  slots.footerStart,
3246
- showContext !== false && /* @__PURE__ */ jsx11(
3959
+ showContext !== false && /* @__PURE__ */ jsx13(
3247
3960
  ContextMeter,
3248
3961
  {
3249
3962
  usage: agent.usage,
@@ -3254,11 +3967,11 @@ var AgentChatInner = ({
3254
3967
  compacting
3255
3968
  }
3256
3969
  ),
3257
- composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ jsxs10("div", { className: "awr-chat__error", children: [
3258
- /* @__PURE__ */ jsx11(AlertIcon, { size: 14 }),
3970
+ composer === false ? agent.error && agent.status === "error" && /* @__PURE__ */ jsxs12("div", { className: "awr-chat__error", children: [
3971
+ /* @__PURE__ */ jsx13(AlertIcon, { size: 14 }),
3259
3972
  " ",
3260
3973
  agent.error
3261
- ] }) : /* @__PURE__ */ jsx11(
3974
+ ] }) : /* @__PURE__ */ jsx13(
3262
3975
  Composer2,
3263
3976
  {
3264
3977
  controller: agent,
@@ -3271,9 +3984,9 @@ var AgentChatInner = ({
3271
3984
  )
3272
3985
  ] })
3273
3986
  ] }),
3274
- files && filesOpen && /* @__PURE__ */ jsxs10("aside", { className: cx("awr-chat__files", classNames.files), children: [
3275
- /* @__PURE__ */ jsx11(Files, { files }),
3276
- /* @__PURE__ */ jsx11(
3987
+ files && filesOpen && /* @__PURE__ */ jsxs12("aside", { className: cx("awr-chat__files", classNames.files), children: [
3988
+ /* @__PURE__ */ jsx13(Files, { files }),
3989
+ /* @__PURE__ */ jsx13(
3277
3990
  "button",
3278
3991
  {
3279
3992
  type: "button",
@@ -3290,7 +4003,7 @@ var AgentChatInner = ({
3290
4003
  };
3291
4004
 
3292
4005
  // src/components/LearnedSkills.tsx
3293
- import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
4006
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
3294
4007
  var LearnedSkills = ({
3295
4008
  controller,
3296
4009
  lessons,
@@ -3306,18 +4019,18 @@ var LearnedSkills = ({
3306
4019
  const c = controller ?? ctx;
3307
4020
  const list = lessons ?? c?.learned ?? [];
3308
4021
  const forget = onForget === false ? void 0 : onForget ?? c?.forgetSkill;
3309
- return /* @__PURE__ */ jsxs11("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
3310
- !hideTitle && /* @__PURE__ */ jsxs11("h3", { className: "awr-notebook__title", children: [
3311
- /* @__PURE__ */ jsx12(BookIcon, { size: 14 }),
4022
+ return /* @__PURE__ */ jsxs13("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
4023
+ !hideTitle && /* @__PURE__ */ jsxs13("h3", { className: "awr-notebook__title", children: [
4024
+ /* @__PURE__ */ jsx14(BookIcon, { size: 14 }),
3312
4025
  " ",
3313
4026
  L.notebookTitle,
3314
- list.length > 0 && /* @__PURE__ */ jsx12("span", { className: "awr-notebook__count", children: list.length })
4027
+ list.length > 0 && /* @__PURE__ */ jsx14("span", { className: "awr-notebook__count", children: list.length })
3315
4028
  ] }),
3316
- list.length === 0 ? /* @__PURE__ */ jsx12("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ jsx12("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ jsxs11("li", { className: "awr-lesson", children: [
3317
- /* @__PURE__ */ jsxs11("div", { className: "awr-lesson__head", children: [
3318
- /* @__PURE__ */ jsx12("code", { className: "awr-lesson__name", children: l.name }),
3319
- l.revision > 1 && /* @__PURE__ */ jsx12("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
3320
- forget && /* @__PURE__ */ jsx12(
4029
+ list.length === 0 ? /* @__PURE__ */ jsx14("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ jsx14("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ jsxs13("li", { className: "awr-lesson", children: [
4030
+ /* @__PURE__ */ jsxs13("div", { className: "awr-lesson__head", children: [
4031
+ /* @__PURE__ */ jsx14("code", { className: "awr-lesson__name", children: l.name }),
4032
+ l.revision > 1 && /* @__PURE__ */ jsx14("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
4033
+ forget && /* @__PURE__ */ jsx14(
3321
4034
  "button",
3322
4035
  {
3323
4036
  type: "button",
@@ -3325,12 +4038,12 @@ var LearnedSkills = ({
3325
4038
  title: `${L.notebookForget}: ${l.name}`,
3326
4039
  "aria-label": `${L.notebookForget}: ${l.name}`,
3327
4040
  onClick: () => void forget(l.name),
3328
- children: /* @__PURE__ */ jsx12(XIcon, { size: 12 })
4041
+ children: /* @__PURE__ */ jsx14(XIcon, { size: 12 })
3329
4042
  }
3330
4043
  )
3331
4044
  ] }),
3332
- /* @__PURE__ */ jsx12("p", { className: "awr-lesson__when", children: l.description }),
3333
- showSources && l.sources.length > 0 && /* @__PURE__ */ jsxs11("p", { className: "awr-lesson__from", children: [
4045
+ /* @__PURE__ */ jsx14("p", { className: "awr-lesson__when", children: l.description }),
4046
+ showSources && l.sources.length > 0 && /* @__PURE__ */ jsxs13("p", { className: "awr-lesson__from", children: [
3334
4047
  L.notebookFrom,
3335
4048
  " ",
3336
4049
  l.sources.join(", ")
@@ -3340,8 +4053,8 @@ var LearnedSkills = ({
3340
4053
  };
3341
4054
 
3342
4055
  // src/components/Composer.tsx
3343
- import { useState as useState10 } from "react";
3344
- import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
4056
+ import { useState as useState12 } from "react";
4057
+ import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
3345
4058
  var Composer = ({
3346
4059
  onSubmit,
3347
4060
  busy = false,
@@ -3350,7 +4063,7 @@ var Composer = ({
3350
4063
  placeholder = "Ask the agent to do something\u2026",
3351
4064
  className
3352
4065
  }) => {
3353
- const [text, setText] = useState10("");
4066
+ const [text, setText] = useState12("");
3354
4067
  const submit = () => {
3355
4068
  const value = text.trim();
3356
4069
  if (!value || busy || disabled) return;
@@ -3363,7 +4076,7 @@ var Composer = ({
3363
4076
  submit();
3364
4077
  }
3365
4078
  };
3366
- return /* @__PURE__ */ jsxs12(
4079
+ return /* @__PURE__ */ jsxs14(
3367
4080
  "form",
3368
4081
  {
3369
4082
  className: ["awr-composer", className].filter(Boolean).join(" "),
@@ -3372,7 +4085,7 @@ var Composer = ({
3372
4085
  submit();
3373
4086
  },
3374
4087
  children: [
3375
- /* @__PURE__ */ jsx13(
4088
+ /* @__PURE__ */ jsx15(
3376
4089
  "textarea",
3377
4090
  {
3378
4091
  className: "awr-composer__input",
@@ -3384,23 +4097,23 @@ var Composer = ({
3384
4097
  rows: 1
3385
4098
  }
3386
4099
  ),
3387
- busy ? /* @__PURE__ */ jsx13(
4100
+ busy ? /* @__PURE__ */ jsx15(
3388
4101
  "button",
3389
4102
  {
3390
4103
  type: "button",
3391
4104
  className: "awr-composer__btn awr-composer__btn--stop",
3392
4105
  onClick: onStop,
3393
4106
  "aria-label": "Stop",
3394
- children: /* @__PURE__ */ jsx13(StopIcon, { size: 18 })
4107
+ children: /* @__PURE__ */ jsx15(StopIcon, { size: 18 })
3395
4108
  }
3396
- ) : /* @__PURE__ */ jsx13(
4109
+ ) : /* @__PURE__ */ jsx15(
3397
4110
  "button",
3398
4111
  {
3399
4112
  type: "submit",
3400
4113
  className: "awr-composer__btn",
3401
4114
  disabled: disabled || !text.trim(),
3402
4115
  "aria-label": "Send",
3403
- children: disabled ? /* @__PURE__ */ jsx13(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ jsx13(SendIcon, { size: 18 })
4116
+ children: disabled ? /* @__PURE__ */ jsx15(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ jsx15(SendIcon, { size: 18 })
3404
4117
  }
3405
4118
  )
3406
4119
  ]
@@ -3409,17 +4122,17 @@ var Composer = ({
3409
4122
  };
3410
4123
 
3411
4124
  // src/components/PlanView.tsx
3412
- import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
4125
+ import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
3413
4126
  var PlanView = ({ plan, showThought = true, className }) => {
3414
4127
  if (!plan.steps.length && !plan.thought) return null;
3415
- return /* @__PURE__ */ jsxs13("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
3416
- showThought && plan.thought.trim() && /* @__PURE__ */ jsx14("p", { className: "awr-plan__thought", children: plan.thought }),
3417
- plan.steps.length > 0 && /* @__PURE__ */ jsx14("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ jsx14("li", { className: "awr-plan__step", children: step.description }, step.id)) })
4128
+ return /* @__PURE__ */ jsxs15("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
4129
+ showThought && plan.thought.trim() && /* @__PURE__ */ jsx16("p", { className: "awr-plan__thought", children: plan.thought }),
4130
+ plan.steps.length > 0 && /* @__PURE__ */ jsx16("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ jsx16("li", { className: "awr-plan__step", children: step.description }, step.id)) })
3418
4131
  ] });
3419
4132
  };
3420
4133
 
3421
4134
  // src/components/ApprovalModeSwitch.tsx
3422
- import { jsx as jsx15 } from "react/jsx-runtime";
4135
+ import { jsx as jsx17 } from "react/jsx-runtime";
3423
4136
  var DEFAULT_LABELS = {
3424
4137
  autopilot: "Autopilot",
3425
4138
  "ask-writes": "Ask before changes",
@@ -3439,13 +4152,13 @@ var ApprovalModeSwitch = ({
3439
4152
  labels,
3440
4153
  disabled,
3441
4154
  className
3442
- }) => /* @__PURE__ */ jsx15(
4155
+ }) => /* @__PURE__ */ jsx17(
3443
4156
  "div",
3444
4157
  {
3445
4158
  className: ["awr-modeswitch", className].filter(Boolean).join(" "),
3446
4159
  role: "radiogroup",
3447
4160
  "aria-label": "Tool consent",
3448
- children: modes.map((m) => /* @__PURE__ */ jsx15(
4161
+ children: modes.map((m) => /* @__PURE__ */ jsx17(
3449
4162
  "button",
3450
4163
  {
3451
4164
  type: "button",
@@ -3463,8 +4176,8 @@ var ApprovalModeSwitch = ({
3463
4176
  );
3464
4177
 
3465
4178
  // src/components/ApiKeyForm.tsx
3466
- import { useEffect as useEffect8, useState as useState11 } from "react";
3467
- import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
4179
+ import { useEffect as useEffect10, useState as useState13 } from "react";
4180
+ import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
3468
4181
  var ApiKeyForm = ({
3469
4182
  credentials,
3470
4183
  credentialRef,
@@ -3473,10 +4186,10 @@ var ApiKeyForm = ({
3473
4186
  onChange,
3474
4187
  className
3475
4188
  }) => {
3476
- const [value, setValue] = useState11("");
3477
- const [present, setPresent] = useState11(false);
3478
- const [busy, setBusy] = useState11(false);
3479
- useEffect8(() => {
4189
+ const [value, setValue] = useState13("");
4190
+ const [present, setPresent] = useState13(false);
4191
+ const [busy, setBusy] = useState13(false);
4192
+ useEffect10(() => {
3480
4193
  let active = true;
3481
4194
  credentials.hasKey(credentialRef).then((has) => {
3482
4195
  if (active) setPresent(has);
@@ -3508,16 +4221,16 @@ var ApiKeyForm = ({
3508
4221
  setBusy(false);
3509
4222
  }
3510
4223
  };
3511
- return /* @__PURE__ */ jsxs14("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
3512
- /* @__PURE__ */ jsxs14("label", { className: "awr-keyform__label", children: [
4224
+ return /* @__PURE__ */ jsxs16("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
4225
+ /* @__PURE__ */ jsxs16("label", { className: "awr-keyform__label", children: [
3513
4226
  label,
3514
- present && /* @__PURE__ */ jsxs14("span", { className: "awr-keyform__saved", children: [
3515
- /* @__PURE__ */ jsx16(CheckIcon, { size: 12 }),
4227
+ present && /* @__PURE__ */ jsxs16("span", { className: "awr-keyform__saved", children: [
4228
+ /* @__PURE__ */ jsx18(CheckIcon, { size: 12 }),
3516
4229
  " stored, encrypted"
3517
4230
  ] })
3518
4231
  ] }),
3519
- /* @__PURE__ */ jsxs14("div", { className: "awr-keyform__row", children: [
3520
- /* @__PURE__ */ jsx16(
4232
+ /* @__PURE__ */ jsxs16("div", { className: "awr-keyform__row", children: [
4233
+ /* @__PURE__ */ jsx18(
3521
4234
  "input",
3522
4235
  {
3523
4236
  className: "awr-keyform__input",
@@ -3535,7 +4248,7 @@ var ApiKeyForm = ({
3535
4248
  disabled: busy
3536
4249
  }
3537
4250
  ),
3538
- /* @__PURE__ */ jsx16(
4251
+ /* @__PURE__ */ jsx18(
3539
4252
  "button",
3540
4253
  {
3541
4254
  type: "button",
@@ -3545,7 +4258,7 @@ var ApiKeyForm = ({
3545
4258
  children: "Save"
3546
4259
  }
3547
4260
  ),
3548
- present && /* @__PURE__ */ jsx16(
4261
+ present && /* @__PURE__ */ jsx18(
3549
4262
  "button",
3550
4263
  {
3551
4264
  type: "button",
@@ -3601,6 +4314,7 @@ export {
3601
4314
  Composer,
3602
4315
  ContextMeter,
3603
4316
  FilesPanel,
4317
+ GeneratedMedia,
3604
4318
  ImagesNotSupportedError,
3605
4319
  IndexedDBStore,
3606
4320
  LearnedSkills,
@@ -3612,8 +4326,10 @@ export {
3612
4326
  PlanView,
3613
4327
  StepList,
3614
4328
  SubagentRow,
4329
+ SubagentTree,
3615
4330
  ToolApprovalPrompt,
3616
4331
  ToolCallRow,
4332
+ TranscriptBlock,
3617
4333
  UsageBadge,
3618
4334
  UserNoteRow,
3619
4335
  VaultCredentialStore2 as VaultCredentialStore,
@@ -3630,6 +4346,7 @@ export {
3630
4346
  createSubagentTool,
3631
4347
  createWebLLMEngine,
3632
4348
  createWebLLMModel2 as createWebLLMModel,
4349
+ decisionNote,
3633
4350
  defaultLabels,
3634
4351
  defineSkill,
3635
4352
  defineTool,
@@ -3640,6 +4357,7 @@ export {
3640
4357
  lessonsOf,
3641
4358
  loadSkillFromUrl,
3642
4359
  markReadOnly,
4360
+ mediaFamilyOf,
3643
4361
  mergeLabels,
3644
4362
  newChatId,
3645
4363
  noticesOf,
@@ -3648,6 +4366,7 @@ export {
3648
4366
  preloadWebLLMModel2 as preloadWebLLMModel,
3649
4367
  serveSubagentWorker,
3650
4368
  steerIntent,
4369
+ subagentTree,
3651
4370
  supportsImages,
3652
4371
  supportsPdf,
3653
4372
  unloadWebLLMModel2 as unloadWebLLMModel,
@@ -3662,6 +4381,7 @@ export {
3662
4381
  useSpeechToText,
3663
4382
  useVirtualFiles,
3664
4383
  useWebLLMModel,
4384
+ webSearchOf,
3665
4385
  withAttachments
3666
4386
  };
3667
4387
  //# sourceMappingURL=index.js.map