@declarion/react 0.175.0 → 0.180.0

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.
@@ -10,65 +10,64 @@ import { AgentPicker as c } from "./AgentPicker.js";
10
10
  import { fold as l } from "./transcript-runs.js";
11
11
  import { useSchema as u } from "../../hooks/useSchema.js";
12
12
  import { useParam as d } from "../../hooks/useParams.js";
13
- import { coerceDisplayString as f } from "../../lib/display-value.js";
14
- import { useText as p } from "../../hooks/useText.js";
15
- import { useTabNavigate as m } from "../../hooks/useTabNavigate.js";
16
- import { screenTitleForPath as h } from "../../types/schema.js";
17
- import { useEntity as g } from "../../hooks/useEntity.js";
18
- import { failureTitle as _ } from "../../lib/failure.js";
19
- import { pluralText as v, textWithNodes as y } from "../../lib/language.js";
20
- import { useFileSelection as b } from "../file-widgets/useFileSelection.js";
21
- import { ComposerAttachments as x, MessageAttachments as S, replyFilesVisible as ee } from "./ChatAttachments.js";
13
+ import { useText as f } from "../../hooks/useText.js";
14
+ import { useTabNavigate as p } from "../../hooks/useTabNavigate.js";
15
+ import { screenTitleForPath as m } from "../../types/schema.js";
16
+ import { useEntity as h } from "../../hooks/useEntity.js";
17
+ import { failureTitle as g } from "../../lib/failure.js";
18
+ import { pluralText as _, textWithNodes as v } from "../../lib/language.js";
19
+ import { useFileSelection as y } from "../file-widgets/useFileSelection.js";
20
+ import { ComposerAttachments as b, MessageAttachments as x, replyFilesVisible as S } from "./ChatAttachments.js";
22
21
  import { useEffect as C, useRef as w, useState as T } from "react";
23
22
  import { jsx as E, jsxs as D } from "react/jsx-runtime";
24
- import { useLocation as te } from "react-router";
25
- import ne from "react-textarea-autosize";
23
+ import { useLocation as ee } from "react-router";
24
+ import te from "react-textarea-autosize";
26
25
  // src/components/agents/AgentChatPanel.impl.tsx
27
- var re = 80;
28
- function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docked: g = !1 }) {
29
- let v = a();
30
- o(v.conversationId);
31
- let S = p(), { pathname: ee } = te(), { data: O } = u(), k = d ? h(S, ee, O?.screens, O?.entities)?.title : void 0, j = p("errors"), [M, N] = T(""), [P, F] = T(null), I = w(null), [L, R] = T(!1), z = w(null), B = b({
26
+ var ne = 80, O = "/errors/";
27
+ function k({ open: n, onClose: i, context: d, title: p = "", askOnOpen: h, docked: _ = !1 }) {
28
+ let x = a();
29
+ o(x.conversationId);
30
+ let S = f(), { pathname: O } = ee(), { data: k } = u(), re = d ? m(S, O, k?.screens, k?.entities)?.title : void 0, ae = f("errors"), [j, M] = T(""), [N, P] = T(null), F = w(null), [I, L] = T(!1), R = w(null), z = y({
32
31
  entityCode: "agent_message",
33
32
  fieldCode: "attachments"
34
- }), V = w(null), H = w(null), U = w(!0), [W, G] = T(!1), K = () => {
35
- let e = H.current;
33
+ }), B = w(null), V = w(null), H = w(!0), [U, W] = T(!1), de = () => {
34
+ let e = V.current;
36
35
  if (!e) return;
37
- let t = e.scrollHeight - e.scrollTop - e.clientHeight <= re;
38
- U.current = t, t && W && G(!1);
39
- }, q = (e = "smooth") => {
40
- let t = H.current;
36
+ let t = e.scrollHeight - e.scrollTop - e.clientHeight <= ne;
37
+ H.current = t, t && U && W(!1);
38
+ }, G = (e = "smooth") => {
39
+ let t = V.current;
41
40
  t && (t.scrollTo({
42
41
  top: t.scrollHeight,
43
42
  behavior: e
44
- }), U.current = !0, G(!1));
43
+ }), H.current = !0, W(!1));
45
44
  };
46
45
  if (C(() => {
47
- U.current ? q("smooth") : G(!0);
48
- }, [v.messages]), C(() => {
49
- n && q("instant");
46
+ H.current ? G("smooth") : W(!0);
47
+ }, [x.messages]), C(() => {
48
+ n && G("instant");
50
49
  }, [n]), C(() => {
51
- let e = m?.trim();
52
- n && e && I.current !== e && (I.current = e, z.current?.(e));
53
- }, [n, m]), !n) return null;
54
- let J = async (e) => {
55
- let t = B.readyFiles, n = B.selections.filter((e) => e.state === "ready").map((e) => e.localId);
56
- if ((e.trim() || t.length !== 0) && B.settled) {
57
- F(null), N("");
50
+ let e = h?.trim();
51
+ n && e && F.current !== e && (F.current = e, R.current?.(e));
52
+ }, [n, h]), !n) return null;
53
+ let K = async (e) => {
54
+ let t = z.readyFiles, n = z.selections.filter((e) => e.state === "ready").map((e) => e.localId);
55
+ if ((e.trim() || t.length !== 0) && z.settled) {
56
+ P(null), M("");
58
57
  try {
59
- await v.send(e, d, t), B.release(n);
58
+ await x.send(e, d, t), z.release(n);
60
59
  } catch (t) {
61
- console.error("agent send failed", t), F(_(j, t)), N(e);
60
+ console.error("agent send failed", t), P(g(ae, t)), M(e);
62
61
  }
63
62
  }
64
63
  };
65
- z.current = J;
66
- let Y = (e) => {
67
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), J(M));
68
- }, X = v.invocations.filter((e) => e.status === "pending_approval"), Z = v.invocations.filter((e) => e.kind === "input_request" && e.status === "pending_input"), fe = v.turns.filter((e) => e.status === "queued" || e.status === "running" || e.status === "waiting" || e.status === "failed"), pe = v.invocations.filter((e) => e.status === "outcome_unknown"), me = v.messages.length === 0 && !v.turn.streaming, he = X.length > 0 || Z.length > 0, Q = v.turn.streaming && !he || v.turns.some((e) => e.status === "running"), ge = v.messages.some((e) => e.role === "assistant" && e.streaming && e.content.length > 0), $ = (M.trim().length > 0 || B.readyFiles.length > 0) && B.settled;
64
+ R.current = K;
65
+ let q = (e) => {
66
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), K(j));
67
+ }, J = x.invocations.filter((e) => e.status === "pending_approval"), Y = x.invocations.filter((e) => e.kind === "input_request" && e.status === "pending_input"), X = x.turns.filter((e) => e.status === "queued" || e.status === "running" || e.status === "waiting" || e.status === "failed"), Z = x.invocations.filter((e) => e.status === "outcome_unknown"), fe = x.messages.length === 0 && !x.turn.streaming, me = J.length > 0 || Y.length > 0, Q = x.turn.streaming && !me || x.turns.some((e) => e.status === "running"), ge = x.messages.some((e) => e.role === "assistant" && e.streaming && e.content.length > 0), $ = (j.trim().length > 0 || z.readyFiles.length > 0) && z.settled;
69
68
  return /* @__PURE__ */ D("aside", {
70
69
  style: {
71
- ...g ? {
70
+ ..._ ? {
72
71
  gridArea: "assistant",
73
72
  minWidth: 0,
74
73
  minHeight: 0
@@ -114,12 +113,13 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
114
113
  /* @__PURE__ */ D("div", {
115
114
  style: { flex: 1 },
116
115
  children: [/* @__PURE__ */ E("div", {
116
+ "data-conversation-agent": !0,
117
117
  style: {
118
118
  fontSize: 12.5,
119
119
  fontWeight: 600,
120
120
  color: "var(--text)"
121
121
  },
122
- children: f
122
+ children: x.conversations.find((e) => e.id === x.conversationId)?.agent || p
123
123
  }), /* @__PURE__ */ D("div", {
124
124
  style: {
125
125
  fontSize: 10.5,
@@ -133,27 +133,27 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
133
133
  height: 5,
134
134
  background: "var(--success)",
135
135
  borderRadius: 999
136
- } }), y(S("agent.panel.context", "context: {context}"), { context: /* @__PURE__ */ E("span", { children: k || S("agent.panel.context_platform", "Platform") }) })]
136
+ } }), v(S("agent.panel.context", "context: {context}"), { context: /* @__PURE__ */ E("span", { children: re || S("agent.panel.context_platform", "Platform") }) })]
137
137
  })]
138
138
  }),
139
- v.messages.length > 0 && /* @__PURE__ */ E(t, {
139
+ x.messages.length > 0 && /* @__PURE__ */ E(t, {
140
140
  size: 24,
141
141
  icon: /* @__PURE__ */ E(e.copy, { size: 12 }),
142
- onClick: () => void ue(S, v.messages),
142
+ onClick: () => void pe(S, x.messages),
143
143
  title: S("agent.panel.copy_all", "Copy entire conversation")
144
144
  }),
145
145
  /* @__PURE__ */ E(t, {
146
146
  size: 24,
147
147
  icon: /* @__PURE__ */ E(e.clock, { size: 12 }),
148
148
  onClick: () => {
149
- R((e) => !e), v.refreshConversations();
149
+ L((e) => !e), x.refreshConversations();
150
150
  },
151
151
  title: S("agent.panel.earlier", "Earlier conversations")
152
152
  }),
153
- v.conversationId && /* @__PURE__ */ E(t, {
153
+ x.conversationId && /* @__PURE__ */ E(t, {
154
154
  size: 24,
155
155
  icon: /* @__PURE__ */ E(e.plus, { size: 12 }),
156
- onClick: v.startNew,
156
+ onClick: x.startNew,
157
157
  title: S("agent.panel.new_conversation", "New conversation")
158
158
  }),
159
159
  /* @__PURE__ */ E(t, {
@@ -169,22 +169,22 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
169
169
  })
170
170
  ]
171
171
  }),
172
- !v.conversationId && /* @__PURE__ */ E(c, {
173
- agents: v.agents,
174
- selectedId: v.selectedAgentId,
175
- onSelect: v.selectAgent,
172
+ !x.conversationId && /* @__PURE__ */ E(c, {
173
+ agents: x.agents,
174
+ selectedId: x.selectedAgentId,
175
+ onSelect: x.selectAgent,
176
176
  label: S("agent.panel.agent", "Agent")
177
177
  }),
178
- L && /* @__PURE__ */ E(ce, {
179
- conversations: v.conversations,
180
- currentId: v.conversationId,
178
+ I && /* @__PURE__ */ E(le, {
179
+ conversations: x.conversations,
180
+ currentId: x.conversationId,
181
181
  onPick: (e) => {
182
- v.setConversationId(e), R(!1);
182
+ x.setConversationId(e), L(!1);
183
183
  }
184
184
  }),
185
185
  /* @__PURE__ */ D("div", {
186
- ref: H,
187
- onScroll: K,
186
+ ref: V,
187
+ onScroll: de,
188
188
  style: {
189
189
  flex: 1,
190
190
  overflowY: "auto",
@@ -195,23 +195,24 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
195
195
  position: "relative"
196
196
  },
197
197
  children: [
198
- me && /* @__PURE__ */ E(A, { children: S("agent.panel.intro", "Hi — I can answer questions about your data, suggest actions, draft YAML definitions, and run allowed tools within your permissions. What would you like to do?") }),
199
- l(v.messages, v.invocations).map((e) => e.kind === "message" ? /* @__PURE__ */ E(le, {
198
+ fe && /* @__PURE__ */ E(A, { children: S("agent.panel.intro", "Hi — I can answer questions about your data, suggest actions, draft YAML definitions, and run allowed tools within your permissions. What would you like to do?") }),
199
+ l(x.messages, x.invocations).map((e) => e.kind === "message" ? /* @__PURE__ */ E(ue, {
200
200
  message: e.message,
201
- turns: v.turns
202
- }, e.message.id) : /* @__PURE__ */ E(se, { run: e }, e.id)),
203
- fe.map((e) => /* @__PURE__ */ E(ie, { agentTurn: e }, e.id)),
204
- X.map((e) => /* @__PURE__ */ E(de, {
201
+ delivered: e.delivered,
202
+ turns: x.turns
203
+ }, e.message.id) : /* @__PURE__ */ E(ce, { run: e }, e.id)),
204
+ X.map((e) => /* @__PURE__ */ E(ie, { agentTurn: e }, e.id)),
205
+ J.map((e) => /* @__PURE__ */ E(he, {
205
206
  tool: e,
206
- onApprove: async (t) => v.approve(e.id, t),
207
- onReject: async (t) => v.reject(e.id, t)
207
+ onApprove: async (t) => x.approve(e.id, t),
208
+ onReject: async (t) => x.reject(e.id, t)
208
209
  }, e.id)),
209
- Z.map((e) => /* @__PURE__ */ E(s, {
210
- ...ae(S, e),
211
- onSubmit: (t) => void v.submitInput(e.id, t),
212
- onCancel: () => void v.cancelInput(e.id)
210
+ Y.map((e) => /* @__PURE__ */ E(s, {
211
+ ...oe(S, e),
212
+ onSubmit: (t) => void x.submitInput(e.id, t),
213
+ onCancel: () => void x.cancelInput(e.id)
213
214
  }, e.id)),
214
- pe.map((e) => /* @__PURE__ */ E(oe, { invocation: e }, e.id)),
215
+ Z.map((e) => /* @__PURE__ */ E(se, { invocation: e }, e.id)),
215
216
  Q && !ge && /* @__PURE__ */ D("div", {
216
217
  style: {
217
218
  display: "flex",
@@ -222,7 +223,7 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
222
223
  },
223
224
  children: [/* @__PURE__ */ E(r, { size: 12 }), S("agent.panel.thinking", "Thinking…")]
224
225
  }),
225
- P && /* @__PURE__ */ E("div", {
226
+ N && /* @__PURE__ */ E("div", {
226
227
  style: {
227
228
  padding: "8px 10px",
228
229
  background: "var(--surface-2)",
@@ -231,12 +232,12 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
231
232
  fontSize: 11.5,
232
233
  color: "var(--text-2)"
233
234
  },
234
- children: /* @__PURE__ */ E("strong", { children: P })
235
+ children: /* @__PURE__ */ E("strong", { children: N })
235
236
  })
236
237
  ]
237
238
  }),
238
- W && /* @__PURE__ */ D("button", {
239
- onClick: () => q("smooth"),
239
+ U && /* @__PURE__ */ D("button", {
240
+ onClick: () => G("smooth"),
240
241
  style: {
241
242
  position: "absolute",
242
243
  right: 16,
@@ -264,12 +265,12 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
264
265
  background: "var(--surface-2)"
265
266
  },
266
267
  children: [
267
- /* @__PURE__ */ E(x, {
268
- selections: B.selections,
269
- onCancel: B.cancel,
270
- onRemove: B.remove
268
+ /* @__PURE__ */ E(b, {
269
+ selections: z.selections,
270
+ onCancel: z.cancel,
271
+ onRemove: z.remove
271
272
  }),
272
- B.failed && /* @__PURE__ */ E("div", {
273
+ z.failed && /* @__PURE__ */ E("div", {
273
274
  role: "status",
274
275
  style: {
275
276
  fontSize: 11,
@@ -289,10 +290,10 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
289
290
  borderRadius: "var(--radius-md)"
290
291
  },
291
292
  children: [
292
- /* @__PURE__ */ E(ne, {
293
- value: M,
294
- onChange: (e) => N(e.target.value),
295
- onKeyDown: Y,
293
+ /* @__PURE__ */ E(te, {
294
+ value: j,
295
+ onChange: (e) => M(e.target.value),
296
+ onKeyDown: q,
296
297
  placeholder: S("agent.panel.ask_placeholder", "Ask or describe what you want…"),
297
298
  minRows: 1,
298
299
  maxRows: 8,
@@ -310,23 +311,23 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
310
311
  }
311
312
  }),
312
313
  /* @__PURE__ */ E("input", {
313
- ref: V,
314
+ ref: B,
314
315
  type: "file",
315
316
  multiple: !0,
316
317
  hidden: !0,
317
318
  "data-testid": "agent-chat-file-input",
318
319
  onChange: (e) => {
319
- e.target.files && B.add(e.target.files), e.target.value = "";
320
+ e.target.files && z.add(e.target.files), e.target.value = "";
320
321
  }
321
322
  }),
322
323
  /* @__PURE__ */ E(t, {
323
324
  size: 26,
324
325
  icon: /* @__PURE__ */ E(e.paperclip, { size: 12 }),
325
- onClick: () => V.current?.click(),
326
+ onClick: () => B.current?.click(),
326
327
  title: S("agent.panel.attach_files", "Attach files")
327
328
  }),
328
329
  Q ? /* @__PURE__ */ E("button", {
329
- onClick: () => void v.cancel(),
330
+ onClick: () => void x.cancel(),
330
331
  "aria-label": S("agent.panel.stop", "Stop generating"),
331
332
  title: S("agent.panel.stop", "Stop generating"),
332
333
  style: {
@@ -343,7 +344,7 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
343
344
  },
344
345
  children: /* @__PURE__ */ E(e.x, { size: 13 })
345
346
  }) : /* @__PURE__ */ E("button", {
346
- onClick: () => void J(M),
347
+ onClick: () => void K(j),
347
348
  disabled: !$,
348
349
  "aria-label": S("agent.panel.send", "Send"),
349
350
  style: {
@@ -378,7 +379,7 @@ function O({ open: n, onClose: i, context: d, title: f = "", askOnOpen: m, docke
378
379
  ]
379
380
  });
380
381
  }
381
- function k() {
382
+ function re() {
382
383
  return /* @__PURE__ */ E("span", {
383
384
  "aria-hidden": !0,
384
385
  style: {
@@ -421,14 +422,15 @@ function A({ children: t, dataMessageId: n, dataStreaming: r }) {
421
422
  minWidth: 0,
422
423
  fontSize: 12.5,
423
424
  lineHeight: 1.55,
424
- color: "var(--text)"
425
+ color: "var(--text)",
426
+ overflowWrap: "anywhere"
425
427
  },
426
428
  children: t
427
429
  })]
428
430
  });
429
431
  }
430
432
  function ie({ agentTurn: e }) {
431
- let t = p(), n = p("errors"), r = g("agent_turn")?.fields.get("status"), i = e.status === "failed" ? n(e.error_code ?? "", f(e.error_details) || n("agents.turn_failed", "The assistant could not finish this turn.")) : void 0;
433
+ let t = f(), n = f("errors"), r = h("agent_turn")?.fields.get("status"), i = e.status === "failed" ? ae(e) : void 0, a = i ? n(i.code, i.title || n("agents.turn_failed", "The assistant could not finish this turn.")) : void 0;
432
434
  return /* @__PURE__ */ D("div", {
433
435
  "data-agent-turn": e.id,
434
436
  "data-turn-status": e.status,
@@ -440,11 +442,18 @@ function ie({ agentTurn: e }) {
440
442
  e.status === "queued" && (t(r?.values?.find((e) => e.code === "queued")?.name) || e.status),
441
443
  e.status === "running" && t("agent.panel.turn_working", "Working…"),
442
444
  e.status === "waiting" && t("agent.panel.turn_waiting", "Waiting for your response"),
443
- e.status === "failed" && t("agent.panel.turn_unfinished", "The agent couldn't finish: {reason}", { reason: i ?? "" })
445
+ e.status === "failed" && a
444
446
  ]
445
447
  });
446
448
  }
447
- function ae(e, t) {
449
+ function ae(e) {
450
+ let t = j(e.error_details) ? e.error_details.error : void 0, n = j(t) ? t : {}, r = typeof n.type == "string" ? n.type : "";
451
+ return {
452
+ code: r.startsWith(O) ? r.slice(8) : e.error_code ?? "",
453
+ title: typeof n.title == "string" ? n.title : ""
454
+ };
455
+ }
456
+ function oe(e, t) {
448
457
  let n = e("agent.panel.input_needed", "Your response is needed."), r = t.question;
449
458
  if (r && (r.message || r.schema)) return {
450
459
  message: r.message || t.reason || n,
@@ -456,8 +465,8 @@ function ae(e, t) {
456
465
  schema: j(i.schema) ? i.schema : {}
457
466
  };
458
467
  }
459
- function oe({ invocation: e }) {
460
- let t = p();
468
+ function se({ invocation: e }) {
469
+ let t = f();
461
470
  return /* @__PURE__ */ E("div", {
462
471
  "data-agent-invocation": e.id,
463
472
  "data-invocation-status": "outcome_unknown",
@@ -469,7 +478,7 @@ function oe({ invocation: e }) {
469
478
  fontSize: 11.5,
470
479
  color: "var(--text-2)"
471
480
  },
472
- children: y(t("agent.panel.outcome_uncertain", "The outcome of {tool} is unknown. It was not retried automatically."), { tool: /* @__PURE__ */ E("span", {
481
+ children: v(t("agent.panel.outcome_uncertain", "The outcome of {tool} is unknown. It was not retried automatically."), { tool: /* @__PURE__ */ E("span", {
473
482
  className: "mono",
474
483
  children: e.tool_code
475
484
  }) })
@@ -478,7 +487,7 @@ function oe({ invocation: e }) {
478
487
  function j(e) {
479
488
  return typeof e == "object" && !!e && !Array.isArray(e);
480
489
  }
481
- function se({ run: e }) {
490
+ function ce({ run: e }) {
482
491
  let [t, n] = T(!1), r = M(), i = e.calls.filter((e) => e.isError).length, a = e.calls.filter((e) => !P(e.status)).length;
483
492
  return /* @__PURE__ */ D("div", {
484
493
  "data-activity-run": e.id,
@@ -530,20 +539,20 @@ function se({ run: e }) {
530
539
  });
531
540
  }
532
541
  function M() {
533
- let e = p();
542
+ let e = f();
534
543
  return (t, n, r) => {
535
544
  let i = [];
536
- return t > 0 && i.push(v(e, "agent.panel.operations", t, {
545
+ return t > 0 && i.push(_(e, "agent.panel.operations", t, {
537
546
  one: "{count} operation",
538
547
  other: "{count} operations"
539
- })), n > 0 && i.push(e("agent.panel.running", "running")), r > 0 && i.push(v(e, "agent.panel.failed_count", r, {
548
+ })), n > 0 && i.push(e("agent.panel.running", "running")), r > 0 && i.push(_(e, "agent.panel.failed_count", r, {
540
549
  one: "{count} failed",
541
550
  other: "{count} failed"
542
551
  })), i.join(" · ") || e("agent.panel.worked", "worked");
543
552
  };
544
553
  }
545
554
  function N({ call: e }) {
546
- let [t, n] = T(!1), r = p(), i = F(e.name), a = g("agent_tool_invocation")?.fields.get("status"), o = e.status ?? "running", s = r(a?.values?.find((e) => e.code === o)?.name) || o, c = e.status === "outcome_unknown" ? "outcome_unknown" : e.isError ? "failed" : P(e.status) ? "ok" : "running";
555
+ let [t, n] = T(!1), r = f(), i = I(e.name), a = h("agent_tool_invocation")?.fields.get("status"), o = e.status ?? "running", s = r(a?.values?.find((e) => e.code === o)?.name) || o, c = e.status === "outcome_unknown" ? "outcome_unknown" : e.isError ? "failed" : P(e.status) ? "ok" : "running";
547
556
  return /* @__PURE__ */ D("div", {
548
557
  "data-activity-call": e.name,
549
558
  "data-call-state": c,
@@ -599,8 +608,8 @@ function N({ call: e }) {
599
608
  function P(e) {
600
609
  return e === "succeeded" || e === "failed" || e === "rejected" || e === "canceled" || e === "outcome_unknown";
601
610
  }
602
- function ce({ conversations: e, currentId: t, onPick: n }) {
603
- let r = p();
611
+ function le({ conversations: e, currentId: t, onPick: n }) {
612
+ let r = f();
604
613
  return e.length === 0 ? /* @__PURE__ */ E("div", {
605
614
  style: {
606
615
  padding: "8px 12px",
@@ -615,7 +624,7 @@ function ce({ conversations: e, currentId: t, onPick: n }) {
615
624
  overflowY: "auto",
616
625
  borderBottom: "1px solid var(--border)"
617
626
  },
618
- children: e.map((e) => /* @__PURE__ */ E("button", {
627
+ children: e.map((e) => /* @__PURE__ */ D("button", {
619
628
  type: "button",
620
629
  "data-conversation-id": e.id,
621
630
  onClick: () => n(e.id),
@@ -630,89 +639,178 @@ function ce({ conversations: e, currentId: t, onPick: n }) {
630
639
  cursor: "pointer",
631
640
  color: "var(--text)"
632
641
  },
633
- children: e.title?.trim() || r("agent.panel.untitled", "Untitled conversation")
642
+ children: [/* @__PURE__ */ E("div", {
643
+ style: { overflowWrap: "anywhere" },
644
+ children: e.title?.trim() || r("agent.panel.untitled", "Untitled conversation")
645
+ }), /* @__PURE__ */ E("div", {
646
+ "data-conversation-facts": !0,
647
+ style: {
648
+ fontSize: 10.5,
649
+ color: "var(--text-3)",
650
+ overflowWrap: "anywhere"
651
+ },
652
+ children: F(r, e).join(" · ")
653
+ })]
634
654
  }, e.id))
635
655
  });
636
656
  }
637
- function F(e) {
638
- let t = p(), { value: n } = d("agents.transcript_names", "code"), { data: r } = u();
639
- return n === "display" && t(r?.actions?.[e]?.display?.name ?? I(r, e)) || e;
657
+ function F(e, t) {
658
+ let n = [];
659
+ return t.agent && n.push(t.agent), t.chat_id && n.push(e("agent.panel.messenger_chat", "chat {chat}", { chat: H(t.chat_id) })), t.topic_id && n.push(e("agent.panel.messenger_topic", "topic {topic}", { topic: t.topic_id })), t.updated_at && n.push(new Date(t.updated_at).toLocaleString(e.language, {
660
+ dateStyle: "medium",
661
+ timeStyle: "short"
662
+ })), n;
663
+ }
664
+ function I(e) {
665
+ let t = f(), { value: n } = d("agents.transcript_names", "code"), { data: r } = u();
666
+ return n === "display" && t(r?.actions?.[e]?.display?.name ?? L(r, e)) || e;
640
667
  }
641
- function I(e, t) {
668
+ function L(e, t) {
642
669
  let n = t.indexOf(".");
643
670
  if (!(n < 0)) return e?.entities?.[t.slice(0, n)]?.actions?.[t.slice(n + 1)]?.display?.name;
644
671
  }
645
- function le({ message: e, turns: t }) {
646
- let n = ee(e, t) ? e.attachments : void 0;
672
+ function ue({ message: e, delivered: t, turns: n }) {
673
+ let r = S(e, n) ? e.attachments : void 0;
647
674
  if (e.role === "user") {
648
- let t = U(e.content);
649
- return e.content.some((e) => e.type !== "text" && e.type !== "location") ? /* @__PURE__ */ E(L, {
675
+ let t = J(e.content);
676
+ return e.content.some((e) => e.type !== "text" && e.type !== "location") ? /* @__PURE__ */ E(U, {
650
677
  message: e,
651
- files: n
678
+ files: r
652
679
  }) : /* @__PURE__ */ D("div", {
653
680
  style: {
654
681
  alignSelf: "flex-end",
655
682
  maxWidth: "80%",
683
+ minWidth: 0,
656
684
  display: "flex",
657
685
  flexDirection: "column",
658
686
  alignItems: "flex-end"
659
687
  },
660
688
  "data-message-id": e.id,
661
689
  "data-streaming": e.streaming ? "true" : void 0,
662
- children: [t && /* @__PURE__ */ E("div", {
663
- style: {
664
- padding: "8px 12px",
665
- background: "var(--inverted-surface)",
666
- color: "var(--inverted-surface-fg)",
667
- borderRadius: "var(--radius-lg)",
668
- fontSize: 12.5,
669
- lineHeight: 1.5
670
- },
671
- children: t
672
- }), /* @__PURE__ */ E(S, {
673
- files: n,
674
- align: "end"
675
- })]
690
+ children: [
691
+ t && /* @__PURE__ */ E(R, { text: t }),
692
+ /* @__PURE__ */ E(x, {
693
+ files: r,
694
+ align: "end"
695
+ }),
696
+ /* @__PURE__ */ E(V, { message: e })
697
+ ]
676
698
  });
677
699
  }
678
- return e.role === "tool" ? /* @__PURE__ */ E(L, { message: e }) : e.role === "system" ? e.content.some((e) => e.type === "decision") ? /* @__PURE__ */ E(L, { message: e }) : /* @__PURE__ */ E(A, {
700
+ return e.role === "tool" ? /* @__PURE__ */ E(U, { message: e }) : e.role === "system" ? e.content.some((e) => e.type === "decision") ? /* @__PURE__ */ E(U, { message: e }) : z(e) ? /* @__PURE__ */ E(B, { message: e }) : /* @__PURE__ */ D(A, {
679
701
  dataMessageId: e.id,
680
- children: e.content.map((e, t) => /* @__PURE__ */ E(V, { block: e }, t))
681
- }) : e.content.length === 0 && !n?.length ? null : /* @__PURE__ */ D(A, {
702
+ children: [e.content.map((e, t) => /* @__PURE__ */ E(K, { block: e }, t)), /* @__PURE__ */ E(V, { message: e })]
703
+ }) : e.content.length === 0 && !r?.length ? null : /* @__PURE__ */ D(A, {
682
704
  dataMessageId: e.id,
683
705
  dataStreaming: e.streaming,
684
706
  children: [
685
- e.content.map((e, t) => /* @__PURE__ */ E(V, { block: e }, t)),
686
- e.streaming && /* @__PURE__ */ E(k, {}),
687
- /* @__PURE__ */ E(S, {
688
- files: n,
707
+ e.content.map((e, t) => /* @__PURE__ */ E(K, { block: e }, t)),
708
+ e.streaming && /* @__PURE__ */ E(re, {}),
709
+ /* @__PURE__ */ E(x, {
710
+ files: r,
689
711
  align: "start"
690
- })
712
+ }),
713
+ t && /* @__PURE__ */ E(V, { message: t })
691
714
  ]
692
715
  });
693
716
  }
694
- function L({ message: e, files: t }) {
717
+ function R({ text: e, dim: t }) {
718
+ return /* @__PURE__ */ E("div", {
719
+ style: {
720
+ padding: "8px 12px",
721
+ borderRadius: "var(--radius-lg)",
722
+ fontSize: 12.5,
723
+ lineHeight: 1.5,
724
+ whiteSpace: "pre-wrap",
725
+ overflowWrap: "anywhere",
726
+ ...t ? {
727
+ background: "var(--surface-2)",
728
+ color: "var(--text-2)"
729
+ } : {
730
+ background: "var(--inverted-surface)",
731
+ color: "var(--inverted-surface-fg)"
732
+ }
733
+ },
734
+ children: e
735
+ });
736
+ }
737
+ function z(e) {
738
+ return !e.bot_id || e.delivery_key ? !1 : e.content.some((e) => e.type === "reaction" || e.type === "text" && (!!e.callback_data || e.heard === !0));
739
+ }
740
+ function B({ message: e }) {
741
+ let t = f(), n = e.content.some((e) => e.type === "text" && e.heard === !0), r = e.content.some((e) => e.type === "text" && !!e.callback_data), i = J(e.content), a = e.content.find((e) => e.type === "reaction"), o = a?.type === "reaction" ? a.emoji ?? "" : i, s = n ? t("agent.panel.heard_started_nothing", "Heard, started nothing") : r ? t("agent.panel.pressed_button", "Pressed a button") : "";
695
742
  return /* @__PURE__ */ D("div", {
696
743
  "data-message-id": e.id,
697
- "data-streaming": e.streaming ? "true" : void 0,
744
+ "data-person-on-messenger": n ? "heard" : r ? "pressed" : "reacted",
698
745
  style: {
699
746
  alignSelf: "flex-end",
700
747
  maxWidth: "80%",
748
+ minWidth: 0,
701
749
  display: "flex",
702
750
  flexDirection: "column",
703
751
  alignItems: "flex-end"
704
752
  },
705
- children: [e.content.map((e, t) => /* @__PURE__ */ E(V, { block: e }, t)), /* @__PURE__ */ E(S, {
753
+ children: [
754
+ o && /* @__PURE__ */ E(R, {
755
+ text: o,
756
+ dim: n
757
+ }),
758
+ s && /* @__PURE__ */ E("div", {
759
+ "data-messenger-mark": !0,
760
+ style: {
761
+ fontSize: 10.5,
762
+ color: "var(--text-3)",
763
+ marginTop: 2
764
+ },
765
+ children: s
766
+ }),
767
+ /* @__PURE__ */ E(V, { message: e })
768
+ ]
769
+ });
770
+ }
771
+ function V({ message: e }) {
772
+ let t = f(), n = h("agent_message")?.fields.get("delivery_status");
773
+ if (!e.bot_id) return null;
774
+ let r = [];
775
+ return e.bot && r.push(e.bot), e.chat_id && r.push(t("agent.panel.messenger_chat", "chat {chat}", { chat: H(e.chat_id) })), e.topic_id && r.push(t("agent.panel.messenger_topic", "topic {topic}", { topic: e.topic_id })), !e.delivery_key && e.sender_external_id && r.push(t("agent.panel.messenger_from", "from {sender}", { sender: e.sender_user || H(e.sender_external_id) })), e.delivery_status && r.push(t(n?.values?.find((t) => t.code === e.delivery_status)?.name) || e.delivery_status), /* @__PURE__ */ E("div", {
776
+ "data-messenger-facts": !0,
777
+ "data-delivery-status": e.delivery_status ?? void 0,
778
+ style: {
779
+ fontSize: 10.5,
780
+ color: e.delivery_status === "failed" ? "var(--danger)" : "var(--text-3)",
781
+ marginTop: 2,
782
+ overflowWrap: "anywhere"
783
+ },
784
+ children: r.join(" · ")
785
+ });
786
+ }
787
+ function H(e) {
788
+ return e.slice(e.indexOf(":") + 1);
789
+ }
790
+ function U({ message: e, files: t }) {
791
+ return /* @__PURE__ */ D("div", {
792
+ "data-message-id": e.id,
793
+ "data-streaming": e.streaming ? "true" : void 0,
794
+ style: {
795
+ alignSelf: "flex-end",
796
+ maxWidth: "80%",
797
+ minWidth: 0,
798
+ display: "flex",
799
+ flexDirection: "column",
800
+ alignItems: "flex-end",
801
+ overflowWrap: "anywhere"
802
+ },
803
+ children: [e.content.map((e, t) => /* @__PURE__ */ E(K, { block: e }, t)), /* @__PURE__ */ E(x, {
706
804
  files: t,
707
805
  align: "end"
708
806
  })]
709
807
  });
710
808
  }
711
- function R({ href: e, children: t, ...n }) {
712
- let r = m(), i = {
809
+ function W({ href: e, children: t, ...n }) {
810
+ let r = p(), i = {
713
811
  color: "var(--accent-text)",
714
812
  textDecoration: "underline"
715
- }, a = z(e);
813
+ }, a = de(e);
716
814
  return a ? /* @__PURE__ */ E("a", {
717
815
  ...n,
718
816
  href: e,
@@ -730,7 +828,7 @@ function R({ href: e, children: t, ...n }) {
730
828
  children: t
731
829
  });
732
830
  }
733
- function z(e) {
831
+ function de(e) {
734
832
  if (typeof e != "string") return null;
735
833
  let t;
736
834
  try {
@@ -740,8 +838,8 @@ function z(e) {
740
838
  }
741
839
  return t.origin === window.location.origin ? `${t.pathname}${t.search}${t.hash}` : null;
742
840
  }
743
- var B = {
744
- a: R,
841
+ var G = {
842
+ a: W,
745
843
  code({ node: e, inline: t, className: n, children: r, ...i }) {
746
844
  return t ? /* @__PURE__ */ E("code", {
747
845
  ...i,
@@ -799,8 +897,8 @@ var B = {
799
897
  });
800
898
  }
801
899
  };
802
- function V({ block: e }) {
803
- let t = p();
900
+ function K({ block: e }) {
901
+ let t = f();
804
902
  switch (e.type) {
805
903
  case "text": return /* @__PURE__ */ E("div", {
806
904
  className: "agent-md",
@@ -809,30 +907,30 @@ function V({ block: e }) {
809
907
  plugins: "gfm",
810
908
  prose: !1,
811
909
  skipHtml: !1,
812
- components: B
910
+ components: G
813
911
  })
814
912
  });
815
913
  case "tool_use": {
816
- let n = W(t, e.name, e.input);
817
- return /* @__PURE__ */ E(H, {
914
+ let n = Y(t, e.name, e.input);
915
+ return /* @__PURE__ */ E(q, {
818
916
  kind: "call",
819
917
  label: n.label,
820
918
  sub: n.sub,
821
919
  body: e.input
822
920
  });
823
921
  }
824
- case "tool_result": return /* @__PURE__ */ E(H, {
922
+ case "tool_result": return /* @__PURE__ */ E(q, {
825
923
  kind: "result",
826
- label: G(t, e),
924
+ label: X(t, e),
827
925
  body: e.output,
828
926
  isError: !!e.is_error
829
927
  });
830
- case "elicit_response": return /* @__PURE__ */ E(H, {
928
+ case "elicit_response": return /* @__PURE__ */ E(q, {
831
929
  kind: "result",
832
930
  label: t("agent.panel.chip.answer", "answer"),
833
931
  body: e.data
834
932
  });
835
- case "decision": return /* @__PURE__ */ E(q, { block: e });
933
+ case "decision": return /* @__PURE__ */ E(fe, { block: e });
836
934
  case "location":
837
935
  case "thinking":
838
936
  case "redacted_thinking": return null;
@@ -868,7 +966,7 @@ function V({ block: e }) {
868
966
  default: return null;
869
967
  }
870
968
  }
871
- function H({ kind: e, label: t, sub: n, body: r, isError: i }) {
969
+ function q({ kind: e, label: t, sub: n, body: r, isError: i }) {
872
970
  return /* @__PURE__ */ D("details", {
873
971
  style: {
874
972
  marginTop: 6,
@@ -953,10 +1051,10 @@ function H({ kind: e, label: t, sub: n, body: r, isError: i }) {
953
1051
  })]
954
1052
  });
955
1053
  }
956
- function U(e) {
1054
+ function J(e) {
957
1055
  return e.map((e) => e.type === "text" ? e.text : "").join("");
958
1056
  }
959
- function W(e, t, n) {
1057
+ function Y(e, t, n) {
960
1058
  if (t === "action.invoke") {
961
1059
  let r = typeof n?.code == "string" ? n.code : "";
962
1060
  if (r) return {
@@ -966,14 +1064,14 @@ function W(e, t, n) {
966
1064
  }
967
1065
  return { label: t };
968
1066
  }
969
- function G(e, t) {
1067
+ function X(e, t) {
970
1068
  return t.name ? t.name : t.is_error ? e("agent.panel.chip.error", "error") : e("agent.panel.chip.result", "result");
971
1069
  }
972
- function K(e, t) {
1070
+ function Z(e, t) {
973
1071
  return t === "approved" ? e("agent.panel.decision.approve", "Approved") : e("agent.panel.decision.reject", "Rejected");
974
1072
  }
975
- function q({ block: e }) {
976
- let t = p(), n = e.decision === "approved", r = n ? "var(--success)" : "var(--destructive)";
1073
+ function fe({ block: e }) {
1074
+ let t = f(), n = e.decision === "approved", r = n ? "var(--success)" : "var(--destructive)";
977
1075
  return /* @__PURE__ */ D("div", {
978
1076
  style: {
979
1077
  marginTop: 6,
@@ -1000,7 +1098,7 @@ function q({ block: e }) {
1000
1098
  }),
1001
1099
  /* @__PURE__ */ E("span", {
1002
1100
  style: { fontWeight: 600 },
1003
- children: K(t, e.decision)
1101
+ children: Z(t, e.decision)
1004
1102
  }),
1005
1103
  /* @__PURE__ */ E("span", {
1006
1104
  className: "mono",
@@ -1020,10 +1118,10 @@ function q({ block: e }) {
1020
1118
  ]
1021
1119
  });
1022
1120
  }
1023
- async function ue(e, t) {
1121
+ async function pe(e, t) {
1024
1122
  let n = [];
1025
1123
  for (let r of t) {
1026
- let t = `[${r.role}]`, i = r.content.map((t) => J(e, t)).filter((e) => e.length > 0).join("\n");
1124
+ let t = `[${r.role}]`, i = r.content.map((t) => me(e, t)).filter((e) => e.length > 0).join("\n");
1027
1125
  i && n.push(`${t}\n${i}`);
1028
1126
  }
1029
1127
  let r = n.join("\n\n");
@@ -1033,42 +1131,42 @@ async function ue(e, t) {
1033
1131
  console.error("agent: copyTranscript failed", e);
1034
1132
  }
1035
1133
  }
1036
- function J(e, t) {
1134
+ function me(e, t) {
1037
1135
  switch (t.type) {
1038
1136
  case "text": return t.text;
1039
1137
  case "tool_use": {
1040
- let n = W(e, t.name, t.input);
1138
+ let n = Y(e, t.name, t.input);
1041
1139
  return `${n.sub ? `→ ${n.label} (${n.sub})` : `→ ${n.label}`}\n${JSON.stringify(t.input, null, 2)}`;
1042
1140
  }
1043
- case "tool_result": return `${`${t.is_error ? "✗" : "✓"} ${G(e, t)}`}\n${JSON.stringify(t.output, null, 2)}`;
1141
+ case "tool_result": return `${`${t.is_error ? "✗" : "✓"} ${X(e, t)}`}\n${JSON.stringify(t.output, null, 2)}`;
1044
1142
  case "elicit_response": return `${e("agent.panel.chip.answer", "answer")}\n${JSON.stringify(t.data, null, 2)}`;
1045
- case "decision": return `${K(e, t.decision)} ${t.tool_code}${t.note ? ` — ${t.note}` : ""}`;
1143
+ case "decision": return `${Z(e, t.decision)} ${t.tool_code}${t.note ? ` — ${t.note}` : ""}`;
1046
1144
  case "system": return `— ${t.reason}`;
1047
1145
  case "summary": return t.text;
1048
1146
  case "attachment": return t.content;
1049
1147
  default: return "";
1050
1148
  }
1051
1149
  }
1052
- function Y(e, t) {
1150
+ function Q(e, t) {
1053
1151
  return e("agent.panel.proposal", "Run {code}.", { code: t });
1054
1152
  }
1055
- function de({ tool: t, onApprove: r, onReject: i }) {
1056
- let a = p(), o = p("errors"), s = JSON.stringify(t.params ?? {}, null, 2), [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(""), [h, g] = T(null), [v, y] = T(!1), b = async (e) => {
1153
+ function he({ tool: t, onApprove: r, onReject: i }) {
1154
+ let a = f(), o = f("errors"), s = JSON.stringify(t.params ?? {}, null, 2), [c, l] = T(!1), [u, d] = T(!1), [p, m] = T(""), [h, _] = T(null), [v, y] = T(!1), b = async (e) => {
1057
1155
  if (!v) {
1058
1156
  y(!0);
1059
1157
  try {
1060
1158
  await r(e);
1061
1159
  } catch (e) {
1062
- g(_(o, e)), y(!1);
1160
+ _(g(o, e)), y(!1);
1063
1161
  }
1064
1162
  }
1065
1163
  }, x = async () => {
1066
1164
  if (!v) {
1067
1165
  y(!0);
1068
1166
  try {
1069
- await i(f.trim() || void 0);
1167
+ await i(p.trim() || void 0);
1070
1168
  } catch (e) {
1071
- g(_(o, e)), y(!1);
1169
+ _(g(o, e)), y(!1);
1072
1170
  }
1073
1171
  }
1074
1172
  }, S = typeof t.confidence == "number" ? Math.round(Math.max(0, Math.min(1, t.confidence)) * 100) : null;
@@ -1130,7 +1228,7 @@ function de({ tool: t, onApprove: r, onReject: i }) {
1130
1228
  color: "var(--text)",
1131
1229
  marginBottom: 8
1132
1230
  },
1133
- children: t.question?.message?.trim() || Y(a, t.tool_code)
1231
+ children: t.question?.message?.trim() || Q(a, t.tool_code)
1134
1232
  }),
1135
1233
  t.reason?.trim() && /* @__PURE__ */ E("div", {
1136
1234
  style: {
@@ -1194,7 +1292,7 @@ function de({ tool: t, onApprove: r, onReject: i }) {
1194
1292
  }),
1195
1293
  u && /* @__PURE__ */ E("input", {
1196
1294
  type: "text",
1197
- value: f,
1295
+ value: p,
1198
1296
  onChange: (e) => m(e.target.value),
1199
1297
  placeholder: a("agent.panel.reject_note", "Why not? (optional) — then Send rejection"),
1200
1298
  autoFocus: !0,
@@ -1250,4 +1348,4 @@ function de({ tool: t, onApprove: r, onReject: i }) {
1250
1348
  ]
1251
1349
  });
1252
1350
  }
1253
- export { O as AgentChatPanel, Y as proposalFallback };
1351
+ export { k as AgentChatPanel, Q as proposalFallback };