@declarion/react 0.57.0 → 0.59.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.
Files changed (165) hide show
  1. package/README.md +0 -2
  2. package/dist-lib/AgentChatPanel.impl-DBH1Ff4G.js +1200 -0
  3. package/dist-lib/DetailAuditStrip-GNRA_eP5.js +289 -0
  4. package/dist-lib/{DraggableChildrenTable-BV5sb8Uo.js → DraggableChildrenTable-4RZC351U.js} +87 -86
  5. package/dist-lib/Grid-CQabaBLx.js +405 -0
  6. package/dist-lib/{LayoutRenderer-C9AH9cXf.js → LayoutRenderer-DGKWZKpW.js} +1000 -1114
  7. package/dist-lib/{ListCardsBody-DXcDg536.js → ListCardsBody-DfGmyNIu.js} +84 -84
  8. package/dist-lib/MarkdownRenderer-BDbzDv_y.js +87 -0
  9. package/dist-lib/{RefreshControl-CNtN8zSl.js → RefreshControl-Bhoib0ZA.js} +126 -155
  10. package/dist-lib/SmartDetailPage.impl-Ds2RGg6K.js +1565 -0
  11. package/dist-lib/SmartListPage.impl-BrZLE_Gb.js +3046 -0
  12. package/dist-lib/{SmartRecordListPage.impl-Bkl9aZJ8.js → SmartRecordListPage.impl-C1FJLr80.js} +281 -280
  13. package/dist-lib/SortHeaderMenu-Cijxk4cX.js +107 -0
  14. package/dist-lib/action-dispatch-DY0c8U81.js +1967 -0
  15. package/dist-lib/api/client.d.ts +5 -0
  16. package/dist-lib/api/data.d.ts +2 -4
  17. package/dist-lib/api/entities.d.ts +8 -15
  18. package/dist-lib/api/events.d.ts +3 -3
  19. package/dist-lib/cardProjection-Bkl2SSYz.js +499 -0
  20. package/dist-lib/components/actions/ResponsiveActionBar.d.ts +17 -16
  21. package/dist-lib/components/agents/AgentChatPanel.d.ts +3 -13
  22. package/dist-lib/components/agents/AgentChatPanel.impl.d.ts +14 -0
  23. package/dist-lib/components/agents/AgentPicker.d.ts +1 -2
  24. package/dist-lib/components/chrome/PageShell.d.ts +7 -0
  25. package/dist-lib/components/chrome/RecordHeader.d.ts +1 -2
  26. package/dist-lib/components/detail-layout/DetailAuditStrip.d.ts +1 -2
  27. package/dist-lib/components/detail-layout/DetailHighlights.d.ts +1 -2
  28. package/dist-lib/components/detail-layout/blockMeta.d.ts +2 -1
  29. package/dist-lib/components/fields/BoolField.d.ts +1 -1
  30. package/dist-lib/components/fields/EnumField.d.ts +1 -1
  31. package/dist-lib/components/fields/IntArrayField.d.ts +1 -1
  32. package/dist-lib/components/fields/MultilangArrayField.d.ts +2 -0
  33. package/dist-lib/components/fields/MultilangField.d.ts +1 -1
  34. package/dist-lib/components/fields/MultilangTextField.d.ts +1 -1
  35. package/dist-lib/components/fields/NumberField.d.ts +1 -1
  36. package/dist-lib/components/fields/PasswordField.d.ts +1 -1
  37. package/dist-lib/components/fields/RefCombobox.d.ts +1 -1
  38. package/dist-lib/components/fields/SecretField.d.ts +1 -1
  39. package/dist-lib/components/fields/StringArrayField.d.ts +1 -1
  40. package/dist-lib/components/fields/TimestampField.d.ts +1 -1
  41. package/dist-lib/components/fields/cells/registry.d.ts +2 -1
  42. package/dist-lib/components/fields/index.d.ts +2 -1
  43. package/dist-lib/components/fields/langMap.d.ts +2 -0
  44. package/dist-lib/components/fields/secretValue.d.ts +2 -0
  45. package/dist-lib/components/file-widgets/UnknownFileWidget.d.ts +3 -0
  46. package/dist-lib/components/file-widgets/UploadFailureText.d.ts +4 -0
  47. package/dist-lib/components/file-widgets/helpers.d.ts +1 -1
  48. package/dist-lib/components/file-widgets/host.d.ts +4 -3
  49. package/dist-lib/components/file-widgets/types.d.ts +1 -0
  50. package/dist-lib/components/file-widgets/upload.d.ts +18 -3
  51. package/dist-lib/components/filters/filter-op-label.d.ts +3 -0
  52. package/dist-lib/components/layout/ImpersonationBanner.d.ts +1 -1
  53. package/dist-lib/components/layout/ImpersonationFrame.d.ts +1 -1
  54. package/dist-lib/components/layout/Layout.d.ts +2 -1
  55. package/dist-lib/components/layout/Sidebar.d.ts +2 -1
  56. package/dist-lib/components/layout/TenantChip.d.ts +1 -1
  57. package/dist-lib/components/list/ViewSwitcher.d.ts +4 -2
  58. package/dist-lib/components/pages/DocumentsMenu.d.ts +1 -2
  59. package/dist-lib/components/pages/ExportMenu.d.ts +3 -5
  60. package/dist-lib/components/pages/RecordDocumentsPanel.d.ts +1 -2
  61. package/dist-lib/components/pages/auth/AuthShell.d.ts +4 -31
  62. package/dist-lib/components/pages/exportRequest.d.ts +4 -6
  63. package/dist-lib/components/pages/list/DeleteViewDialog.d.ts +8 -0
  64. package/dist-lib/components/pages/list/ListCardRow.d.ts +1 -2
  65. package/dist-lib/components/pages/list/ListCardsBody.d.ts +0 -1
  66. package/dist-lib/components/pages/list/ListFloatbar.d.ts +2 -2
  67. package/dist-lib/components/pages/list/ListHeader.d.ts +2 -2
  68. package/dist-lib/components/pages/list/ListNoRows.d.ts +4 -5
  69. package/dist-lib/components/pages/list/ListToolbar.d.ts +3 -2
  70. package/dist-lib/components/pages/list/ListUrlBanner.d.ts +10 -0
  71. package/dist-lib/components/pages/list/RowActionsCell.d.ts +2 -4
  72. package/dist-lib/components/pages/list/RowContextMenu.d.ts +1 -2
  73. package/dist-lib/components/pages/list/columns.d.ts +2 -1
  74. package/dist-lib/components/pages/list/filter-meta.d.ts +2 -1
  75. package/dist-lib/components/pages/list/useActiveView.d.ts +38 -0
  76. package/dist-lib/components/pages/list/useListColumnLayout.d.ts +6 -5
  77. package/dist-lib/components/pages/list/useListQuery.d.ts +4 -4
  78. package/dist-lib/components/pages/list/useListSort.d.ts +5 -4
  79. package/dist-lib/components/pages/list/useListViews.d.ts +18 -8
  80. package/dist-lib/components/pages/list/useRowMenu.d.ts +2 -3
  81. package/dist-lib/components/pages/profile/Profile.d.ts +3 -0
  82. package/dist-lib/components/params/ParamsBlock.d.ts +1 -13
  83. package/dist-lib/components/params/param-editors.d.ts +3 -11
  84. package/dist-lib/components/primitives/ClassifiedFieldLocked.d.ts +1 -2
  85. package/dist-lib/components/shared/DynamicIcon.d.ts +2 -2
  86. package/dist-lib/components/shared/LoadingSkeleton.d.ts +1 -0
  87. package/dist-lib/components/shared/LucideIcon.d.ts +1 -1
  88. package/dist-lib/components/shared/useOwnRefresh.d.ts +1 -1
  89. package/dist-lib/declarion-react.css +1 -1
  90. package/dist-lib/embed/theme.d.ts +1 -1
  91. package/dist-lib/embed/useEmbedNavigate.d.ts +1 -1
  92. package/dist-lib/failure-v-uGSpbX.js +158 -0
  93. package/dist-lib/{field-classification-D6xQYn-h.js → field-classification-C28XE-_P.js} +514 -307
  94. package/dist-lib/format-count-DA4wmmWR.js +1771 -0
  95. package/dist-lib/hooks/useEntityData.d.ts +1 -1
  96. package/dist-lib/hooks/useFilters.d.ts +7 -5
  97. package/dist-lib/hooks/useLanguage.d.ts +4 -0
  98. package/dist-lib/hooks/useParams.d.ts +4 -51
  99. package/dist-lib/hooks/useRegisterScreenTab.d.ts +1 -1
  100. package/dist-lib/hooks/useSSE.d.ts +3 -3
  101. package/dist-lib/hooks/useTabTitle.d.ts +2 -0
  102. package/dist-lib/hooks/useText.d.ts +3 -3
  103. package/dist-lib/hooks/useVersionWatcher.d.ts +1 -1
  104. package/dist-lib/hooks/useViews.d.ts +20 -0
  105. package/dist-lib/index.d.ts +8 -7
  106. package/dist-lib/index.js +2716 -5795
  107. package/dist-lib/lib/action-dispatch.d.ts +2 -1
  108. package/dist-lib/lib/actions.d.ts +30 -42
  109. package/dist-lib/lib/anchor.d.ts +3 -4
  110. package/dist-lib/lib/decimal-text.d.ts +1 -0
  111. package/dist-lib/lib/document-templates.d.ts +1 -2
  112. package/dist-lib/lib/download.d.ts +2 -1
  113. package/dist-lib/lib/evidence-verdict.d.ts +2 -1
  114. package/dist-lib/lib/failure.d.ts +2 -0
  115. package/dist-lib/lib/field-classification.d.ts +3 -3
  116. package/dist-lib/lib/filters.d.ts +18 -2
  117. package/dist-lib/lib/format-count.d.ts +8 -7
  118. package/dist-lib/lib/language.d.ts +19 -0
  119. package/dist-lib/lib/mass-edit.d.ts +2 -1
  120. package/dist-lib/lib/realtime-query-keys.d.ts +1 -1
  121. package/dist-lib/lib/realtime-reconcile.d.ts +3 -4
  122. package/dist-lib/lib/screen-back.d.ts +4 -6
  123. package/dist-lib/lib/sort.d.ts +9 -9
  124. package/dist-lib/lib/timestamp.d.ts +5 -7
  125. package/dist-lib/lib/ui-actions.d.ts +2 -1
  126. package/dist-lib/peekDraftStore-D-cTbiIr.js +199 -0
  127. package/dist-lib/registry-Cb3W-czW.js +1950 -0
  128. package/dist-lib/safe-url-oSJw5pzO.js +34 -0
  129. package/dist-lib/stores/icon-registry.d.ts +2 -2
  130. package/dist-lib/stores/list-layout.d.ts +3 -4
  131. package/dist-lib/stores/realtime.d.ts +1 -1
  132. package/dist-lib/stores/tabs.d.ts +3 -2
  133. package/dist-lib/testing.d.ts +6 -0
  134. package/dist-lib/testing.js +98 -76
  135. package/dist-lib/types/api.d.ts +7 -8
  136. package/dist-lib/types/fieldType.d.ts +1 -1
  137. package/dist-lib/types/files.d.ts +4 -4
  138. package/dist-lib/types/schema.d.ts +44 -50
  139. package/dist-lib/useAgentConversation-D97IqE-J.js +623 -0
  140. package/dist-lib/{useCurrentScreen-CzwzQpoW.js → useCurrentScreen-BL5NZFCw.js} +2777 -3768
  141. package/dist-lib/useListQuery-BG1GyKtJ.js +103 -0
  142. package/dist-lib/useProperties-4Lg3odrt.js +83 -0
  143. package/dist-lib/{useTabSearchMirror-C39U85cg.js → useTabSearchMirror-ZVLlINBX.js} +49 -51
  144. package/dist-lib/useText-BFDCTUSo.js +952 -0
  145. package/dist-lib/{value-Bo8C8WMU.js → value-By1-WJ8J.js} +74 -76
  146. package/dist-lib/vite/fingerprint-plugin.d.ts +2 -3
  147. package/package.json +9 -9
  148. package/dist-lib/Grid-DWgUPuZ3.js +0 -404
  149. package/dist-lib/MarkdownRenderer-CcSFc2N3.js +0 -85
  150. package/dist-lib/RecordIdBadge-CGxPR-8q.js +0 -24
  151. package/dist-lib/SmartDetailPage.impl-lskCd-WG.js +0 -1846
  152. package/dist-lib/SmartListPage.impl-CrGbdzyK.js +0 -2854
  153. package/dist-lib/SortHeaderMenu-SYSAaqQJ.js +0 -106
  154. package/dist-lib/action-dispatch-CR4ajBtT.js +0 -1985
  155. package/dist-lib/cardProjection-CW5RIMko.js +0 -699
  156. package/dist-lib/components/pages/home/HomeStub.d.ts +0 -6
  157. package/dist-lib/components/pages/jobs/Jobs.d.ts +0 -1
  158. package/dist-lib/components/pages/pipeline/Pipeline.d.ts +0 -1
  159. package/dist-lib/format-count-Dobmi-Ji.js +0 -1551
  160. package/dist-lib/hooks/useUserLocale.d.ts +0 -1
  161. package/dist-lib/lib/messages.d.ts +0 -12
  162. package/dist-lib/peekDraftStore-5wQ7lq_V.js +0 -194
  163. package/dist-lib/registry-CjgUaF7C.js +0 -1768
  164. package/dist-lib/useListQuery-D7Hr5WM1.js +0 -96
  165. package/dist-lib/useProperties-CqtCzFCr.js +0 -81
@@ -0,0 +1,1200 @@
1
+ import { s as e } from "./DynamicIcon-DW5krHuX.js";
2
+ import { Dt as t, Ln as n, Rn as r, Vt as i, jn as a, nn as o, xt as s } from "./useCurrentScreen-BL5NZFCw.js";
3
+ import { d as c, f as l, t as u, u as d } from "./useText-BFDCTUSo.js";
4
+ import { t as f } from "./failure-v-uGSpbX.js";
5
+ import { g as p, h as m, t as h } from "./useAgentConversation-D97IqE-J.js";
6
+ import { useEffect as g, useRef as _, useState as v } from "react";
7
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
8
+ import x from "react-textarea-autosize";
9
+ //#region src/components/agents/transcript-runs.ts
10
+ var S = /* @__PURE__ */ new Set(["operation.search"]);
11
+ function C(e, t = []) {
12
+ let n = [], r = /* @__PURE__ */ new Map();
13
+ for (let e of t) e.assistant_message_id && e.provider_call_id && r.set(T(e.assistant_message_id, e.provider_call_id), e);
14
+ for (let t of e) {
15
+ let e = w(t, r);
16
+ if (D(t) && n.push({
17
+ kind: "message",
18
+ message: E(t)
19
+ }), e.length === 0) continue;
20
+ let i = n[n.length - 1], a = i?.kind === "run" ? i : (n.push({
21
+ kind: "run",
22
+ id: t.id,
23
+ calls: []
24
+ }), n[n.length - 1]);
25
+ for (let t of e) S.has(t.name) || a.calls.push(t);
26
+ a.calls.length === 0 && n.pop();
27
+ }
28
+ return n;
29
+ }
30
+ function w(e, t) {
31
+ let n = [];
32
+ for (let r of e.content ?? []) {
33
+ if (r.type !== "tool_use") continue;
34
+ let i = r, a = i.id ?? "", o = t.get(T(e.id, a)), s = o?.status;
35
+ n.push({
36
+ id: o?.id ?? `${e.id}:${a || n.length}`,
37
+ name: i.name ?? "",
38
+ input: i.input,
39
+ messageId: e.id,
40
+ status: s,
41
+ ...o?.result === void 0 ? {} : { output: o.result },
42
+ ...s === "failed" || s === "rejected" || s === "canceled" || s === "outcome_unknown" ? { isError: !0 } : {}
43
+ });
44
+ }
45
+ return n;
46
+ }
47
+ function T(e, t) {
48
+ return `${e}\u0000${t}`;
49
+ }
50
+ function E(e) {
51
+ return {
52
+ ...e,
53
+ content: (e.content ?? []).filter((e) => e.type !== "tool_use" && e.type !== "tool_result")
54
+ };
55
+ }
56
+ function D(e) {
57
+ return (e.content ?? []).some((e) => e.type !== "tool_use" && e.type !== "tool_result");
58
+ }
59
+ //#endregion
60
+ //#region src/components/agents/AgentChatPanel.impl.tsx
61
+ var O = 80;
62
+ function k({ open: t, onClose: r, context: i, title: a = "", askOnOpen: s }) {
63
+ let l = h(), d = u(), S = u("errors"), [w, T] = v(""), [E, D] = v(null), k = _(null), [A, P] = v(!1), I = _(null), L = _(null), R = _(!0), [B, V] = v(!1), H = () => {
64
+ let e = L.current;
65
+ if (!e) return;
66
+ let t = e.scrollHeight - e.scrollTop - e.clientHeight <= O;
67
+ R.current = t, t && B && V(!1);
68
+ }, U = (e = "smooth") => {
69
+ let t = L.current;
70
+ t && (t.scrollTo({
71
+ top: t.scrollHeight,
72
+ behavior: e
73
+ }), R.current = !0, V(!1));
74
+ };
75
+ if (g(() => {
76
+ R.current ? U("smooth") : V(!0);
77
+ }, [l.messages]), g(() => {
78
+ t && U("instant");
79
+ }, [t]), g(() => {
80
+ let e = s?.trim();
81
+ t && e && k.current !== e && (k.current = e, I.current?.(e));
82
+ }, [t, s]), !t) return null;
83
+ let W = async (e) => {
84
+ if (e.trim()) {
85
+ D(null), T("");
86
+ try {
87
+ await l.send(e);
88
+ } catch (t) {
89
+ console.error("agent send failed", t), D(f(S, t)), T(e);
90
+ }
91
+ }
92
+ };
93
+ I.current = W;
94
+ let G = (e) => {
95
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), W(w));
96
+ }, K = l.invocations.filter((e) => e.status === "pending_approval"), q = l.invocations.filter((e) => e.kind === "input_request" && e.status === "pending_input"), J = l.turns.filter((e) => e.status === "queued" || e.status === "running" || e.status === "waiting" || e.status === "failed"), Y = l.invocations.filter((e) => e.status === "outcome_unknown"), X = l.messages.length === 0 && !l.turn.streaming, Z = K.length > 0 || q.length > 0, Q = l.turn.streaming && !Z || l.turns.some((e) => e.status === "running"), ie = l.messages.some((e) => e.role === "assistant" && e.streaming && e.content.length > 0), $ = w.trim().length > 0;
97
+ return /* @__PURE__ */ b("aside", {
98
+ style: {
99
+ position: "fixed",
100
+ top: "var(--topbar-h)",
101
+ right: 0,
102
+ bottom: "var(--tabbar-h, 0px)",
103
+ width: 400,
104
+ zIndex: 30,
105
+ background: "var(--surface)",
106
+ borderLeft: "1px solid var(--border)",
107
+ display: "flex",
108
+ flexDirection: "column",
109
+ boxShadow: "var(--shadow-md)"
110
+ },
111
+ children: [
112
+ /* @__PURE__ */ b("div", {
113
+ style: {
114
+ display: "flex",
115
+ alignItems: "center",
116
+ padding: "10px 14px",
117
+ gap: 8,
118
+ borderBottom: "1px solid var(--divider)"
119
+ },
120
+ children: [
121
+ /* @__PURE__ */ y("span", {
122
+ style: {
123
+ width: 22,
124
+ height: 22,
125
+ borderRadius: 6,
126
+ background: "linear-gradient(135deg, var(--accent), var(--accent-hover))",
127
+ display: "flex",
128
+ alignItems: "center",
129
+ justifyContent: "center"
130
+ },
131
+ children: /* @__PURE__ */ y(e.sparkle, {
132
+ size: 13,
133
+ style: { color: "var(--accent-foreground)" }
134
+ })
135
+ }),
136
+ /* @__PURE__ */ b("div", {
137
+ style: { flex: 1 },
138
+ children: [/* @__PURE__ */ y("div", {
139
+ style: {
140
+ fontSize: 12.5,
141
+ fontWeight: 600,
142
+ color: "var(--text)"
143
+ },
144
+ children: a
145
+ }), /* @__PURE__ */ b("div", {
146
+ style: {
147
+ fontSize: 10.5,
148
+ color: "var(--text-3)",
149
+ display: "flex",
150
+ alignItems: "center",
151
+ gap: 4
152
+ },
153
+ children: [/* @__PURE__ */ y("span", { style: {
154
+ width: 5,
155
+ height: 5,
156
+ background: "var(--success)",
157
+ borderRadius: 999
158
+ } }), c(d("agent.panel.context", "context: {context}"), { context: /* @__PURE__ */ y("span", {
159
+ className: "mono",
160
+ children: i || d("agent.panel.context_platform", "Platform")
161
+ }) })]
162
+ })]
163
+ }),
164
+ l.messages.length > 0 && /* @__PURE__ */ y(n, {
165
+ size: 24,
166
+ icon: /* @__PURE__ */ y(e.copy, { size: 12 }),
167
+ onClick: () => void ne(d, l.messages),
168
+ title: d("agent.panel.copy_all", "Copy entire conversation")
169
+ }),
170
+ /* @__PURE__ */ y(n, {
171
+ size: 24,
172
+ icon: /* @__PURE__ */ y(e.clock, { size: 12 }),
173
+ onClick: () => {
174
+ P((e) => !e), l.refreshConversations();
175
+ },
176
+ title: d("agent.panel.earlier", "Earlier conversations")
177
+ }),
178
+ l.conversationId && /* @__PURE__ */ y(n, {
179
+ size: 24,
180
+ icon: /* @__PURE__ */ y(e.plus, { size: 12 }),
181
+ onClick: l.startNew,
182
+ title: d("agent.panel.new_conversation", "New conversation")
183
+ }),
184
+ /* @__PURE__ */ y(n, {
185
+ size: 24,
186
+ icon: /* @__PURE__ */ y(e.settings, { size: 12 }),
187
+ title: d("agent.panel.preferences", "Preferences")
188
+ }),
189
+ /* @__PURE__ */ y(n, {
190
+ size: 24,
191
+ icon: /* @__PURE__ */ y(e.x, { size: 13 }),
192
+ onClick: r,
193
+ title: d("agent.panel.close", "Close")
194
+ })
195
+ ]
196
+ }),
197
+ !l.conversationId && /* @__PURE__ */ y(m, {
198
+ agents: l.agents,
199
+ selectedId: l.selectedAgentId,
200
+ onSelect: l.selectAgent,
201
+ label: d("agent.panel.agent", "Agent")
202
+ }),
203
+ A && /* @__PURE__ */ y(z, {
204
+ conversations: l.conversations,
205
+ currentId: l.conversationId,
206
+ onPick: (e) => {
207
+ l.setConversationId(e), P(!1);
208
+ }
209
+ }),
210
+ /* @__PURE__ */ b("div", {
211
+ ref: L,
212
+ onScroll: H,
213
+ style: {
214
+ flex: 1,
215
+ overflowY: "auto",
216
+ padding: "12px 14px",
217
+ display: "flex",
218
+ flexDirection: "column",
219
+ gap: 12,
220
+ position: "relative"
221
+ },
222
+ children: [
223
+ X && /* @__PURE__ */ y(j, { children: d("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?") }),
224
+ C(l.messages, l.invocations).map((e) => e.kind === "message" ? /* @__PURE__ */ y(te, { message: e.message }, e.message.id) : /* @__PURE__ */ y(F, { run: e }, e.id)),
225
+ J.map((e) => /* @__PURE__ */ y(M, { agentTurn: e }, e.id)),
226
+ K.map((e) => /* @__PURE__ */ y(re, {
227
+ tool: e,
228
+ onApprove: async (t) => l.approve(e.id, t),
229
+ onReject: async (t) => l.reject(e.id, t)
230
+ }, e.id)),
231
+ q.map((e) => /* @__PURE__ */ y(p, {
232
+ ...N(d, e),
233
+ onSubmit: (t) => void l.submitInput(e.id, t),
234
+ onCancel: () => void l.cancelInput(e.id)
235
+ }, e.id)),
236
+ Y.map((e) => /* @__PURE__ */ y(ee, { invocation: e }, e.id)),
237
+ Q && !ie && /* @__PURE__ */ b("div", {
238
+ style: {
239
+ display: "flex",
240
+ gap: 6,
241
+ alignItems: "center",
242
+ color: "var(--text-3)",
243
+ fontSize: 11.5
244
+ },
245
+ children: [/* @__PURE__ */ y(o, { size: 12 }), d("agent.panel.thinking", "Thinking…")]
246
+ }),
247
+ E && /* @__PURE__ */ y("div", {
248
+ style: {
249
+ padding: "8px 10px",
250
+ background: "var(--surface-2)",
251
+ border: "1px solid var(--border)",
252
+ borderRadius: 6,
253
+ fontSize: 11.5,
254
+ color: "var(--text-2)"
255
+ },
256
+ children: /* @__PURE__ */ y("strong", { children: E })
257
+ })
258
+ ]
259
+ }),
260
+ B && /* @__PURE__ */ b("button", {
261
+ onClick: () => U("smooth"),
262
+ style: {
263
+ position: "absolute",
264
+ right: 16,
265
+ bottom: 110,
266
+ padding: "6px 12px",
267
+ borderRadius: 999,
268
+ background: "var(--accent)",
269
+ color: "var(--accent-foreground)",
270
+ border: 0,
271
+ fontSize: 11,
272
+ fontWeight: 600,
273
+ cursor: "pointer",
274
+ boxShadow: "var(--shadow-md)",
275
+ display: "inline-flex",
276
+ alignItems: "center",
277
+ gap: 4,
278
+ zIndex: 1
279
+ },
280
+ children: [/* @__PURE__ */ y(e.arrowDown, { size: 11 }), d("agent.panel.jump_latest", "Jump to latest")]
281
+ }),
282
+ /* @__PURE__ */ b("div", {
283
+ style: {
284
+ padding: 10,
285
+ borderTop: "1px solid var(--divider)",
286
+ background: "var(--surface-2)"
287
+ },
288
+ children: [/* @__PURE__ */ b("div", {
289
+ style: {
290
+ display: "flex",
291
+ alignItems: "flex-end",
292
+ gap: 6,
293
+ padding: 6,
294
+ background: "var(--surface)",
295
+ border: "1px solid var(--border)",
296
+ borderRadius: 8
297
+ },
298
+ children: [
299
+ /* @__PURE__ */ y(x, {
300
+ value: w,
301
+ onChange: (e) => T(e.target.value),
302
+ onKeyDown: G,
303
+ placeholder: d("agent.panel.ask_placeholder", "Ask or describe what you want…"),
304
+ minRows: 1,
305
+ maxRows: 8,
306
+ style: {
307
+ flex: 1,
308
+ border: 0,
309
+ outline: 0,
310
+ background: "transparent",
311
+ resize: "none",
312
+ fontSize: 12.5,
313
+ lineHeight: 1.5,
314
+ color: "var(--text)",
315
+ padding: "4px 6px",
316
+ fontFamily: "inherit"
317
+ }
318
+ }),
319
+ /* @__PURE__ */ y(n, {
320
+ size: 26,
321
+ icon: /* @__PURE__ */ y(e.paperclip, { size: 12 }),
322
+ title: d("agent.panel.attach_context", "Attach context")
323
+ }),
324
+ Q ? /* @__PURE__ */ y("button", {
325
+ onClick: () => void l.cancel(),
326
+ "aria-label": d("agent.panel.stop", "Stop generating"),
327
+ title: d("agent.panel.stop", "Stop generating"),
328
+ style: {
329
+ width: 26,
330
+ height: 26,
331
+ borderRadius: 6,
332
+ border: 0,
333
+ cursor: "pointer",
334
+ background: "var(--destructive)",
335
+ color: "var(--destructive-foreground)",
336
+ display: "inline-flex",
337
+ alignItems: "center",
338
+ justifyContent: "center"
339
+ },
340
+ children: /* @__PURE__ */ y(e.x, { size: 13 })
341
+ }) : /* @__PURE__ */ y("button", {
342
+ onClick: () => void W(w),
343
+ disabled: !$,
344
+ "aria-label": d("agent.panel.send", "Send"),
345
+ style: {
346
+ width: 26,
347
+ height: 26,
348
+ borderRadius: 6,
349
+ border: 0,
350
+ cursor: $ ? "pointer" : "default",
351
+ background: $ ? "var(--accent)" : "var(--surface-3)",
352
+ color: $ ? "var(--accent-foreground)" : "var(--text-4)",
353
+ display: "inline-flex",
354
+ alignItems: "center",
355
+ justifyContent: "center"
356
+ },
357
+ children: /* @__PURE__ */ y(e.arrowUp, { size: 13 })
358
+ })
359
+ ]
360
+ }), /* @__PURE__ */ b("div", {
361
+ style: {
362
+ display: "flex",
363
+ alignItems: "center",
364
+ gap: 6,
365
+ marginTop: 6,
366
+ fontSize: 10.5,
367
+ color: "var(--text-4)"
368
+ },
369
+ children: [/* @__PURE__ */ y(e.shield, { size: 10 }), /* @__PURE__ */ y("span", { children: d("agent.panel.footer", "Runs within your permissions. All actions audit-logged.") })]
370
+ })]
371
+ })
372
+ ]
373
+ });
374
+ }
375
+ function A() {
376
+ return /* @__PURE__ */ y("span", {
377
+ "aria-hidden": !0,
378
+ style: {
379
+ display: "inline-block",
380
+ width: 2,
381
+ height: 13,
382
+ marginLeft: 2,
383
+ verticalAlign: "text-bottom",
384
+ background: "var(--text-3)",
385
+ animation: "agent-blink 1s steps(2, end) infinite"
386
+ }
387
+ });
388
+ }
389
+ function j({ children: t, dataMessageId: n, dataStreaming: r }) {
390
+ return /* @__PURE__ */ b("div", {
391
+ "data-message-id": n,
392
+ "data-streaming": r ? "true" : void 0,
393
+ style: {
394
+ display: "flex",
395
+ gap: 8,
396
+ alignItems: "flex-start"
397
+ },
398
+ children: [/* @__PURE__ */ y("span", {
399
+ style: {
400
+ width: 20,
401
+ height: 20,
402
+ borderRadius: 5,
403
+ background: "var(--accent-soft)",
404
+ color: "var(--accent)",
405
+ display: "inline-flex",
406
+ alignItems: "center",
407
+ justifyContent: "center",
408
+ flexShrink: 0,
409
+ marginTop: 2
410
+ },
411
+ children: /* @__PURE__ */ y(e.sparkle, { size: 11 })
412
+ }), /* @__PURE__ */ y("div", {
413
+ style: {
414
+ flex: 1,
415
+ minWidth: 0,
416
+ fontSize: 12.5,
417
+ lineHeight: 1.55,
418
+ color: "var(--text)"
419
+ },
420
+ children: t
421
+ })]
422
+ });
423
+ }
424
+ function M({ agentTurn: e }) {
425
+ let t = u(), n = u("errors"), r = s("agent_turn")?.fields.get("status"), i = e.status === "failed" ? n(e.error_code ?? "", a(e.error_details) || n("agents.turn_failed", "The assistant could not finish this turn.")) : void 0;
426
+ return /* @__PURE__ */ b("div", {
427
+ "data-agent-turn": e.id,
428
+ "data-turn-status": e.status,
429
+ style: {
430
+ fontSize: 11.5,
431
+ color: "var(--text-3)"
432
+ },
433
+ children: [
434
+ e.status === "queued" && (t(r?.values?.find((e) => e.code === "queued")?.name) || e.status),
435
+ e.status === "running" && t("agent.panel.turn_working", "Working…"),
436
+ e.status === "waiting" && t("agent.panel.turn_waiting", "Waiting for your response"),
437
+ e.status === "failed" && t("agent.panel.turn_unfinished", "The agent couldn't finish: {reason}", { reason: i ?? "" })
438
+ ]
439
+ });
440
+ }
441
+ function N(e, t) {
442
+ let n = e("agent.panel.input_needed", "Your response is needed."), r = t.question;
443
+ if (r && (r.message || r.schema)) return {
444
+ message: r.message || t.reason || n,
445
+ schema: P(r.schema) ? r.schema : {}
446
+ };
447
+ let i = t.params ?? {};
448
+ return {
449
+ message: typeof i.message == "string" ? i.message : t.reason || n,
450
+ schema: P(i.schema) ? i.schema : {}
451
+ };
452
+ }
453
+ function ee({ invocation: e }) {
454
+ let t = u();
455
+ return /* @__PURE__ */ y("div", {
456
+ "data-agent-invocation": e.id,
457
+ "data-invocation-status": "outcome_unknown",
458
+ style: {
459
+ padding: "10px 12px",
460
+ background: "var(--surface-2)",
461
+ border: "1px solid var(--border)",
462
+ borderRadius: 8,
463
+ fontSize: 11.5,
464
+ color: "var(--text-2)"
465
+ },
466
+ children: c(t("agent.panel.outcome_uncertain", "The outcome of {tool} is unknown. It was not retried automatically."), { tool: /* @__PURE__ */ y("span", {
467
+ className: "mono",
468
+ children: e.tool_code
469
+ }) })
470
+ });
471
+ }
472
+ function P(e) {
473
+ return typeof e == "object" && !!e && !Array.isArray(e);
474
+ }
475
+ function F({ run: e }) {
476
+ let [t, n] = v(!1), r = I(), i = e.calls.filter((e) => e.isError).length, a = e.calls.filter((e) => !R(e.status)).length;
477
+ return /* @__PURE__ */ b("div", {
478
+ "data-activity-run": e.id,
479
+ style: {
480
+ display: "flex",
481
+ gap: 8,
482
+ alignItems: "flex-start"
483
+ },
484
+ children: [/* @__PURE__ */ y("span", { style: {
485
+ width: 20,
486
+ flexShrink: 0
487
+ } }), /* @__PURE__ */ b("div", {
488
+ style: {
489
+ flex: 1,
490
+ minWidth: 0
491
+ },
492
+ children: [/* @__PURE__ */ b("button", {
493
+ type: "button",
494
+ onClick: () => n((e) => !e),
495
+ "data-activity-toggle": !0,
496
+ "data-call-count": e.calls.length,
497
+ "data-failed-count": i,
498
+ style: {
499
+ display: "inline-flex",
500
+ alignItems: "center",
501
+ gap: 6,
502
+ padding: "2px 6px",
503
+ fontSize: 11.5,
504
+ color: "var(--text-3)",
505
+ background: "transparent",
506
+ border: "1px solid var(--border)",
507
+ borderRadius: 999,
508
+ cursor: "pointer"
509
+ },
510
+ children: [/* @__PURE__ */ y("span", {
511
+ "aria-hidden": !0,
512
+ children: t ? "▾" : "▸"
513
+ }), /* @__PURE__ */ y("span", { children: r(e.calls.length, a, i) })]
514
+ }), t && /* @__PURE__ */ y("div", {
515
+ style: {
516
+ marginTop: 4,
517
+ display: "flex",
518
+ flexDirection: "column",
519
+ gap: 3
520
+ },
521
+ children: e.calls.map((e) => /* @__PURE__ */ y(L, { call: e }, e.id))
522
+ })]
523
+ })]
524
+ });
525
+ }
526
+ function I() {
527
+ let e = u();
528
+ return (t, n, r) => {
529
+ let i = [];
530
+ return t > 0 && i.push(d(e, "agent.panel.operations", t, {
531
+ one: "{count} operation",
532
+ other: "{count} operations"
533
+ })), n > 0 && i.push(e("agent.panel.running", "running")), r > 0 && i.push(d(e, "agent.panel.failed_count", r, {
534
+ one: "{count} failed",
535
+ other: "{count} failed"
536
+ })), i.join(" · ") || e("agent.panel.worked", "worked");
537
+ };
538
+ }
539
+ function L({ call: e }) {
540
+ let [t, n] = v(!1), r = u(), i = B(e.name), a = s("agent_tool_invocation")?.fields.get("status"), o = e.status ?? "running", c = r(a?.values?.find((e) => e.code === o)?.name) || o, l = e.status === "outcome_unknown" ? "outcome_unknown" : e.isError ? "failed" : R(e.status) ? "ok" : "running";
541
+ return /* @__PURE__ */ b("div", {
542
+ "data-activity-call": e.name,
543
+ "data-call-state": l,
544
+ children: [/* @__PURE__ */ b("button", {
545
+ type: "button",
546
+ onClick: () => n((e) => !e),
547
+ style: {
548
+ display: "inline-flex",
549
+ alignItems: "center",
550
+ gap: 6,
551
+ padding: "1px 4px",
552
+ fontSize: 11,
553
+ background: "transparent",
554
+ border: "none",
555
+ cursor: "pointer",
556
+ color: l === "failed" ? "var(--danger)" : "var(--text-2)"
557
+ },
558
+ children: [
559
+ /* @__PURE__ */ y("span", {
560
+ "aria-hidden": !0,
561
+ children: t ? "▾" : "▸"
562
+ }),
563
+ /* @__PURE__ */ y("span", {
564
+ className: "mono",
565
+ children: i
566
+ }),
567
+ /* @__PURE__ */ y("span", {
568
+ style: { color: "var(--text-3)" },
569
+ children: c
570
+ })
571
+ ]
572
+ }), t && /* @__PURE__ */ y("pre", {
573
+ style: {
574
+ margin: "2px 0 0 18px",
575
+ padding: 6,
576
+ fontSize: 10.5,
577
+ lineHeight: 1.45,
578
+ background: "var(--surface-2)",
579
+ borderRadius: 5,
580
+ overflowX: "auto",
581
+ whiteSpace: "pre-wrap",
582
+ wordBreak: "break-word",
583
+ color: "var(--text-2)"
584
+ },
585
+ children: JSON.stringify({
586
+ operation: e.name,
587
+ input: e.input,
588
+ output: e.output
589
+ }, null, 2)
590
+ })]
591
+ });
592
+ }
593
+ function R(e) {
594
+ return e === "succeeded" || e === "failed" || e === "rejected" || e === "canceled" || e === "outcome_unknown";
595
+ }
596
+ function z({ conversations: e, currentId: t, onPick: n }) {
597
+ let r = u();
598
+ return e.length === 0 ? /* @__PURE__ */ y("div", {
599
+ style: {
600
+ padding: "8px 12px",
601
+ fontSize: 11.5,
602
+ color: "var(--text-3)"
603
+ },
604
+ children: r("agent.panel.no_earlier", "No earlier conversations.")
605
+ }) : /* @__PURE__ */ y("div", {
606
+ "data-conversation-list": !0,
607
+ style: {
608
+ maxHeight: 200,
609
+ overflowY: "auto",
610
+ borderBottom: "1px solid var(--border)"
611
+ },
612
+ children: e.map((e) => /* @__PURE__ */ y("button", {
613
+ type: "button",
614
+ "data-conversation-id": e.id,
615
+ onClick: () => n(e.id),
616
+ style: {
617
+ display: "block",
618
+ width: "100%",
619
+ textAlign: "left",
620
+ padding: "6px 12px",
621
+ fontSize: 12,
622
+ background: e.id === t ? "var(--surface-2)" : "transparent",
623
+ border: "none",
624
+ cursor: "pointer",
625
+ color: "var(--text)"
626
+ },
627
+ children: e.title?.trim() || r("agent.panel.untitled", "Untitled conversation")
628
+ }, e.id))
629
+ });
630
+ }
631
+ function B(e) {
632
+ let t = u(), { value: n } = i("agents.transcript_names", "code"), { data: r } = l();
633
+ return n === "display" && t(r?.actions?.[e]?.display?.name ?? V(r, e)) || e;
634
+ }
635
+ function V(e, t) {
636
+ let n = t.indexOf(".");
637
+ if (!(n < 0)) return e?.entities?.[t.slice(0, n)]?.actions?.[t.slice(n + 1)]?.display?.name;
638
+ }
639
+ function te({ message: e }) {
640
+ if (e.role === "user") {
641
+ let t = K(e.content), n = e.content.some((e) => e.type !== "text");
642
+ return t && !n ? /* @__PURE__ */ y("div", {
643
+ style: {
644
+ alignSelf: "flex-end",
645
+ maxWidth: "80%",
646
+ padding: "8px 12px",
647
+ background: "var(--inverted-surface)",
648
+ color: "var(--inverted-surface-fg)",
649
+ borderRadius: 10,
650
+ fontSize: 12.5,
651
+ lineHeight: 1.5
652
+ },
653
+ "data-message-id": e.id,
654
+ "data-streaming": e.streaming ? "true" : void 0,
655
+ children: t
656
+ }) : /* @__PURE__ */ y(H, { message: e });
657
+ }
658
+ return e.role === "tool" ? /* @__PURE__ */ y(H, { message: e }) : e.role === "system" ? e.content.some((e) => e.type === "decision") ? /* @__PURE__ */ y(H, { message: e }) : /* @__PURE__ */ y(j, {
659
+ dataMessageId: e.id,
660
+ children: e.content.map((e, t) => /* @__PURE__ */ y(W, { block: e }, t))
661
+ }) : e.content.length === 0 ? null : /* @__PURE__ */ b(j, {
662
+ dataMessageId: e.id,
663
+ dataStreaming: e.streaming,
664
+ children: [e.content.map((e, t) => /* @__PURE__ */ y(W, { block: e }, t)), e.streaming && /* @__PURE__ */ y(A, {})]
665
+ });
666
+ }
667
+ function H({ message: e }) {
668
+ return /* @__PURE__ */ y("div", {
669
+ "data-message-id": e.id,
670
+ "data-streaming": e.streaming ? "true" : void 0,
671
+ style: {
672
+ alignSelf: "flex-end",
673
+ maxWidth: "80%",
674
+ display: "flex",
675
+ flexDirection: "column",
676
+ alignItems: "flex-end"
677
+ },
678
+ children: e.content.map((e, t) => /* @__PURE__ */ y(W, { block: e }, t))
679
+ });
680
+ }
681
+ var U = {
682
+ code({ node: e, inline: t, className: n, children: r, ...i }) {
683
+ return t ? /* @__PURE__ */ y("code", {
684
+ ...i,
685
+ style: {
686
+ background: "var(--surface-2)",
687
+ padding: "1px 4px",
688
+ borderRadius: 4,
689
+ fontFamily: "var(--font-mono, ui-monospace)",
690
+ fontSize: "0.92em"
691
+ },
692
+ children: r
693
+ }) : /* @__PURE__ */ y("pre", {
694
+ style: {
695
+ background: "var(--surface-2)",
696
+ border: "1px solid var(--border)",
697
+ borderRadius: 6,
698
+ padding: "8px 10px",
699
+ margin: "6px 0",
700
+ overflowX: "auto",
701
+ fontSize: 11.5,
702
+ lineHeight: 1.5
703
+ },
704
+ children: /* @__PURE__ */ y("code", {
705
+ className: n,
706
+ ...i,
707
+ children: r
708
+ })
709
+ });
710
+ },
711
+ a({ children: e, ...t }) {
712
+ return /* @__PURE__ */ y("a", {
713
+ ...t,
714
+ target: "_blank",
715
+ rel: "noopener noreferrer",
716
+ style: {
717
+ color: "var(--accent)",
718
+ textDecoration: "underline"
719
+ },
720
+ children: e
721
+ });
722
+ },
723
+ ul({ children: e, ...t }) {
724
+ return /* @__PURE__ */ y("ul", {
725
+ ...t,
726
+ style: {
727
+ paddingLeft: 18,
728
+ margin: "4px 0"
729
+ },
730
+ children: e
731
+ });
732
+ },
733
+ ol({ children: e, ...t }) {
734
+ return /* @__PURE__ */ y("ol", {
735
+ ...t,
736
+ style: {
737
+ paddingLeft: 20,
738
+ margin: "4px 0"
739
+ },
740
+ children: e
741
+ });
742
+ },
743
+ p({ children: e, ...t }) {
744
+ return /* @__PURE__ */ y("p", {
745
+ ...t,
746
+ style: { margin: "4px 0" },
747
+ children: e
748
+ });
749
+ }
750
+ };
751
+ function W({ block: e }) {
752
+ let n = u();
753
+ switch (e.type) {
754
+ case "text": return /* @__PURE__ */ y("div", {
755
+ className: "agent-md",
756
+ children: /* @__PURE__ */ y(t, {
757
+ content: e.text,
758
+ plugins: "gfm",
759
+ prose: !1,
760
+ skipHtml: !1,
761
+ components: U
762
+ })
763
+ });
764
+ case "tool_use": {
765
+ let t = q(n, e.name, e.input);
766
+ return /* @__PURE__ */ y(G, {
767
+ kind: "call",
768
+ label: t.label,
769
+ sub: t.sub,
770
+ body: e.input
771
+ });
772
+ }
773
+ case "tool_result": return /* @__PURE__ */ y(G, {
774
+ kind: "result",
775
+ label: J(n, e),
776
+ body: e.output,
777
+ isError: !!e.is_error
778
+ });
779
+ case "elicit_response": return /* @__PURE__ */ y(G, {
780
+ kind: "result",
781
+ label: n("agent.panel.chip.answer", "answer"),
782
+ body: e.data
783
+ });
784
+ case "decision": return /* @__PURE__ */ y(X, { block: e });
785
+ case "system": return /* @__PURE__ */ b("div", {
786
+ style: {
787
+ fontSize: 10.5,
788
+ fontStyle: "italic",
789
+ color: "var(--text-3)"
790
+ },
791
+ children: ["— ", e.reason]
792
+ });
793
+ case "summary": return /* @__PURE__ */ y("div", {
794
+ style: {
795
+ fontSize: 10.5,
796
+ fontStyle: "italic",
797
+ color: "var(--text-3)"
798
+ },
799
+ children: e.text
800
+ });
801
+ case "attachment": return /* @__PURE__ */ y("pre", {
802
+ className: "mono",
803
+ style: {
804
+ marginTop: 8,
805
+ padding: "8px 10px",
806
+ background: "var(--surface-2)",
807
+ border: "1px solid var(--border)",
808
+ borderRadius: 6,
809
+ fontSize: 10.5,
810
+ overflowX: "auto"
811
+ },
812
+ children: e.content
813
+ });
814
+ default: return null;
815
+ }
816
+ }
817
+ function G({ kind: e, label: t, sub: n, body: r, isError: i }) {
818
+ return /* @__PURE__ */ b("details", {
819
+ style: {
820
+ marginTop: 6,
821
+ background: "var(--surface-2)",
822
+ border: "1px solid var(--border)",
823
+ borderRadius: 6,
824
+ fontSize: 11,
825
+ width: "100%",
826
+ minWidth: 0,
827
+ maxWidth: "100%",
828
+ boxSizing: "border-box",
829
+ overflow: "hidden"
830
+ },
831
+ children: [/* @__PURE__ */ b("summary", {
832
+ style: {
833
+ padding: "5px 8px",
834
+ cursor: "pointer",
835
+ display: "flex",
836
+ alignItems: "center",
837
+ gap: 6,
838
+ listStyle: "none",
839
+ userSelect: "none",
840
+ color: "var(--text-2)"
841
+ },
842
+ children: [
843
+ /* @__PURE__ */ y("span", {
844
+ "aria-hidden": !0,
845
+ style: {
846
+ color: i ? "var(--destructive)" : "var(--text-3)",
847
+ fontFamily: "var(--font-mono, ui-monospace)",
848
+ width: 10
849
+ },
850
+ children: e === "call" ? "→" : i ? "✗" : "✓"
851
+ }),
852
+ /* @__PURE__ */ y("span", {
853
+ className: "mono",
854
+ style: {
855
+ color: "var(--text-2)",
856
+ flex: "0 1 auto",
857
+ minWidth: 0,
858
+ overflow: "hidden",
859
+ textOverflow: "ellipsis",
860
+ whiteSpace: "nowrap"
861
+ },
862
+ children: t
863
+ }),
864
+ n && /* @__PURE__ */ y("span", {
865
+ style: {
866
+ fontSize: 10,
867
+ color: "var(--text-4)",
868
+ fontStyle: "italic",
869
+ flex: "0 1 auto",
870
+ overflow: "hidden",
871
+ textOverflow: "ellipsis",
872
+ whiteSpace: "nowrap"
873
+ },
874
+ children: n
875
+ }),
876
+ /* @__PURE__ */ y("span", { style: { flex: 1 } }),
877
+ /* @__PURE__ */ y("span", {
878
+ "aria-hidden": !0,
879
+ style: {
880
+ fontSize: 9,
881
+ color: "var(--text-4)"
882
+ },
883
+ children: "▾"
884
+ })
885
+ ]
886
+ }), /* @__PURE__ */ y("pre", {
887
+ className: "mono",
888
+ style: {
889
+ margin: 0,
890
+ padding: "4px 8px 6px",
891
+ fontSize: 10.5,
892
+ lineHeight: 1.45,
893
+ color: "var(--text-2)",
894
+ overflowX: "auto",
895
+ background: "var(--surface)",
896
+ borderTop: "1px solid var(--border)"
897
+ },
898
+ children: JSON.stringify(r, null, 2)
899
+ })]
900
+ });
901
+ }
902
+ function K(e) {
903
+ return e.map((e) => e.type === "text" ? e.text : "").join("");
904
+ }
905
+ function q(e, t, n) {
906
+ if (t === "action.invoke") {
907
+ let r = typeof n?.code == "string" ? n.code : "";
908
+ if (r) return {
909
+ label: r,
910
+ sub: e("agent.panel.chip.via", "via {tool}", { tool: t })
911
+ };
912
+ }
913
+ return { label: t };
914
+ }
915
+ function J(e, t) {
916
+ return t.name ? t.name : t.is_error ? e("agent.panel.chip.error", "error") : e("agent.panel.chip.result", "result");
917
+ }
918
+ function Y(e, t) {
919
+ return t === "approved" ? e("agent.panel.decision.approve", "Approved") : e("agent.panel.decision.reject", "Rejected");
920
+ }
921
+ function X({ block: e }) {
922
+ let t = u(), n = e.decision === "approved", r = n ? "var(--success)" : "var(--destructive)";
923
+ return /* @__PURE__ */ b("div", {
924
+ style: {
925
+ marginTop: 6,
926
+ padding: "5px 10px",
927
+ background: "var(--surface-2)",
928
+ border: "1px solid var(--border)",
929
+ borderLeft: `3px solid ${r}`,
930
+ borderRadius: 6,
931
+ fontSize: 11.5,
932
+ display: "inline-flex",
933
+ alignItems: "center",
934
+ gap: 6,
935
+ color: "var(--text)"
936
+ },
937
+ title: e.decided_at ? t("agent.panel.decided_at", "decided {time}", { time: e.decided_at }) : void 0,
938
+ children: [
939
+ /* @__PURE__ */ y("span", {
940
+ "aria-hidden": !0,
941
+ style: {
942
+ color: r,
943
+ fontWeight: 700
944
+ },
945
+ children: n ? "✓" : "✗"
946
+ }),
947
+ /* @__PURE__ */ y("span", {
948
+ style: { fontWeight: 600 },
949
+ children: Y(t, e.decision)
950
+ }),
951
+ /* @__PURE__ */ y("span", {
952
+ className: "mono",
953
+ style: {
954
+ color: "var(--text-3)",
955
+ fontSize: 11
956
+ },
957
+ children: e.tool_code
958
+ }),
959
+ e.note && /* @__PURE__ */ b("span", {
960
+ style: {
961
+ color: "var(--text-3)",
962
+ fontStyle: "italic"
963
+ },
964
+ children: ["— ", e.note]
965
+ })
966
+ ]
967
+ });
968
+ }
969
+ async function ne(e, t) {
970
+ let n = [];
971
+ for (let r of t) {
972
+ let t = `[${r.role}]`, i = r.content.map((t) => Z(e, t)).filter((e) => e.length > 0).join("\n");
973
+ i && n.push(`${t}\n${i}`);
974
+ }
975
+ let r = n.join("\n\n");
976
+ try {
977
+ await navigator.clipboard.writeText(r);
978
+ } catch (e) {
979
+ console.error("agent: copyTranscript failed", e);
980
+ }
981
+ }
982
+ function Z(e, t) {
983
+ switch (t.type) {
984
+ case "text": return t.text;
985
+ case "tool_use": {
986
+ let n = q(e, t.name, t.input);
987
+ return `${n.sub ? `→ ${n.label} (${n.sub})` : `→ ${n.label}`}\n${JSON.stringify(t.input, null, 2)}`;
988
+ }
989
+ case "tool_result": return `${`${t.is_error ? "✗" : "✓"} ${J(e, t)}`}\n${JSON.stringify(t.output, null, 2)}`;
990
+ case "elicit_response": return `${e("agent.panel.chip.answer", "answer")}\n${JSON.stringify(t.data, null, 2)}`;
991
+ case "decision": return `${Y(e, t.decision)} ${t.tool_code}${t.note ? ` — ${t.note}` : ""}`;
992
+ case "system": return `— ${t.reason}`;
993
+ case "summary": return t.text;
994
+ case "attachment": return t.content;
995
+ default: return "";
996
+ }
997
+ }
998
+ function Q(e, t) {
999
+ return e("agent.panel.proposal", "Run {code}.", { code: t });
1000
+ }
1001
+ function re({ tool: t, onApprove: n, onReject: i }) {
1002
+ let a = u(), o = u("errors"), s = JSON.stringify(t.params ?? {}, null, 2), [c, l] = v(!1), [d, p] = v(!1), [m, h] = v(""), [g, _] = v(null), [x, S] = v(!1), C = async (e) => {
1003
+ if (!x) {
1004
+ S(!0);
1005
+ try {
1006
+ await n(e);
1007
+ } catch (e) {
1008
+ _(f(o, e)), S(!1);
1009
+ }
1010
+ }
1011
+ }, w = async () => {
1012
+ if (!x) {
1013
+ S(!0);
1014
+ try {
1015
+ await i(m.trim() || void 0);
1016
+ } catch (e) {
1017
+ _(f(o, e)), S(!1);
1018
+ }
1019
+ }
1020
+ }, T = typeof t.confidence == "number" ? Math.round(Math.max(0, Math.min(1, t.confidence)) * 100) : null;
1021
+ return /* @__PURE__ */ b("div", {
1022
+ style: {
1023
+ marginTop: 4,
1024
+ padding: "10px 12px",
1025
+ background: "var(--surface-2)",
1026
+ border: "1px solid var(--border)",
1027
+ borderRadius: 7
1028
+ },
1029
+ children: [
1030
+ /* @__PURE__ */ b("div", {
1031
+ style: {
1032
+ display: "flex",
1033
+ alignItems: "center",
1034
+ gap: 6,
1035
+ marginBottom: 6
1036
+ },
1037
+ children: [
1038
+ /* @__PURE__ */ y(e.bolt, {
1039
+ size: 11,
1040
+ style: { color: "var(--accent)" }
1041
+ }),
1042
+ /* @__PURE__ */ y("span", {
1043
+ style: {
1044
+ fontSize: 11.5,
1045
+ fontWeight: 600,
1046
+ color: "var(--text)"
1047
+ },
1048
+ children: a("agent.panel.proposed", "AI proposed")
1049
+ }),
1050
+ /* @__PURE__ */ y("span", {
1051
+ className: "mono",
1052
+ style: {
1053
+ fontSize: 10.5,
1054
+ color: "var(--text-3)"
1055
+ },
1056
+ children: t.tool_code
1057
+ }),
1058
+ T !== null && /* @__PURE__ */ y("span", {
1059
+ title: a("agent.panel.confidence_title", "LLM confidence {percent}%", { percent: T }),
1060
+ style: {
1061
+ marginLeft: "auto",
1062
+ fontSize: 10,
1063
+ color: "var(--text-3)",
1064
+ padding: "1px 6px",
1065
+ border: "1px solid var(--border)",
1066
+ borderRadius: 999
1067
+ },
1068
+ children: a("agent.panel.confidence", "{percent}% confident", { percent: T })
1069
+ })
1070
+ ]
1071
+ }),
1072
+ /* @__PURE__ */ y("div", {
1073
+ style: {
1074
+ fontSize: 12,
1075
+ lineHeight: 1.45,
1076
+ color: "var(--text)",
1077
+ marginBottom: 8
1078
+ },
1079
+ children: t.question?.message?.trim() || Q(a, t.tool_code)
1080
+ }),
1081
+ t.reason?.trim() && /* @__PURE__ */ y("div", {
1082
+ style: {
1083
+ fontSize: 11.5,
1084
+ lineHeight: 1.45,
1085
+ color: "var(--text-2)",
1086
+ marginBottom: 8
1087
+ },
1088
+ children: t.reason.trim()
1089
+ }),
1090
+ /* @__PURE__ */ b("button", {
1091
+ type: "button",
1092
+ onClick: () => l((e) => !e),
1093
+ style: {
1094
+ background: "transparent",
1095
+ border: 0,
1096
+ padding: 0,
1097
+ marginBottom: c ? 6 : 0,
1098
+ fontSize: 10.5,
1099
+ color: "var(--text-3)",
1100
+ cursor: "pointer",
1101
+ display: "inline-flex",
1102
+ alignItems: "center",
1103
+ gap: 4
1104
+ },
1105
+ children: [/* @__PURE__ */ y("span", {
1106
+ style: {
1107
+ display: "inline-block",
1108
+ transform: c ? "rotate(90deg)" : "none",
1109
+ transition: "transform 0.15s",
1110
+ fontSize: 9,
1111
+ lineHeight: 1
1112
+ },
1113
+ children: "▶"
1114
+ }), c ? a("agent.panel.hide_params", "Hide parameters") : a("agent.panel.view_params", "View parameters")]
1115
+ }),
1116
+ c && /* @__PURE__ */ y("pre", {
1117
+ className: "mono",
1118
+ style: {
1119
+ width: "100%",
1120
+ margin: 0,
1121
+ padding: 6,
1122
+ fontSize: 10.5,
1123
+ lineHeight: 1.45,
1124
+ background: "var(--surface)",
1125
+ border: "1px solid var(--border)",
1126
+ borderRadius: 6,
1127
+ color: "var(--text)",
1128
+ overflowX: "auto",
1129
+ whiteSpace: "pre-wrap"
1130
+ },
1131
+ children: s
1132
+ }),
1133
+ g && /* @__PURE__ */ y("div", {
1134
+ style: {
1135
+ marginTop: 4,
1136
+ fontSize: 10.5,
1137
+ color: "var(--text-2)"
1138
+ },
1139
+ children: g
1140
+ }),
1141
+ d && /* @__PURE__ */ y("input", {
1142
+ type: "text",
1143
+ value: m,
1144
+ onChange: (e) => h(e.target.value),
1145
+ placeholder: a("agent.panel.reject_note", "Why not? (optional) — then Send rejection"),
1146
+ autoFocus: !0,
1147
+ style: {
1148
+ marginTop: 6,
1149
+ width: "100%",
1150
+ padding: "5px 7px",
1151
+ fontSize: 11,
1152
+ background: "var(--surface)",
1153
+ border: "1px solid var(--border)",
1154
+ borderRadius: 6,
1155
+ color: "var(--text)"
1156
+ }
1157
+ }),
1158
+ /* @__PURE__ */ b("div", {
1159
+ style: {
1160
+ display: "flex",
1161
+ gap: 6,
1162
+ marginTop: 8,
1163
+ justifyContent: "flex-end"
1164
+ },
1165
+ children: [
1166
+ d ? /* @__PURE__ */ y(r, {
1167
+ size: "xs",
1168
+ kind: "ghost",
1169
+ onClick: w,
1170
+ disabled: x,
1171
+ children: a("agent.panel.reject_send", "Send rejection")
1172
+ }) : /* @__PURE__ */ y(r, {
1173
+ size: "xs",
1174
+ kind: "ghost",
1175
+ onClick: () => p(!0),
1176
+ disabled: x,
1177
+ children: a("agent.panel.reject", "Reject…")
1178
+ }),
1179
+ t.confirmation_mode !== "always" && /* @__PURE__ */ y(r, {
1180
+ size: "xs",
1181
+ kind: "ghost",
1182
+ onClick: () => C("conversation"),
1183
+ disabled: x,
1184
+ children: a("agent.panel.approve_chat", "Approve for this chat")
1185
+ }),
1186
+ /* @__PURE__ */ y(r, {
1187
+ size: "xs",
1188
+ kind: "primary",
1189
+ icon: /* @__PURE__ */ y(e.check, { size: 11 }),
1190
+ onClick: () => C("call"),
1191
+ disabled: x,
1192
+ children: a("agent.panel.approve_once", "Approve once")
1193
+ })
1194
+ ]
1195
+ })
1196
+ ]
1197
+ });
1198
+ }
1199
+ //#endregion
1200
+ export { k as AgentChatPanel };