@declarion/react 0.57.0 → 0.59.2

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 (166) hide show
  1. package/README.md +0 -2
  2. package/dist-lib/AgentChatPanel.impl-DBH1Ff4G.js +1200 -0
  3. package/dist-lib/DetailAuditStrip-9eJM2Fml.js +288 -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-DFjz29Ff.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/chrome/headerActionZone.d.ts +27 -0
  27. package/dist-lib/components/detail-layout/DetailAuditStrip.d.ts +1 -2
  28. package/dist-lib/components/detail-layout/DetailHighlights.d.ts +1 -2
  29. package/dist-lib/components/detail-layout/blockMeta.d.ts +2 -1
  30. package/dist-lib/components/fields/BoolField.d.ts +1 -1
  31. package/dist-lib/components/fields/EnumField.d.ts +1 -1
  32. package/dist-lib/components/fields/IntArrayField.d.ts +1 -1
  33. package/dist-lib/components/fields/MultilangArrayField.d.ts +2 -0
  34. package/dist-lib/components/fields/MultilangField.d.ts +1 -1
  35. package/dist-lib/components/fields/MultilangTextField.d.ts +1 -1
  36. package/dist-lib/components/fields/NumberField.d.ts +1 -1
  37. package/dist-lib/components/fields/PasswordField.d.ts +1 -1
  38. package/dist-lib/components/fields/RefCombobox.d.ts +1 -1
  39. package/dist-lib/components/fields/SecretField.d.ts +1 -1
  40. package/dist-lib/components/fields/StringArrayField.d.ts +1 -1
  41. package/dist-lib/components/fields/TimestampField.d.ts +1 -1
  42. package/dist-lib/components/fields/cells/registry.d.ts +2 -1
  43. package/dist-lib/components/fields/index.d.ts +2 -1
  44. package/dist-lib/components/fields/langMap.d.ts +2 -0
  45. package/dist-lib/components/fields/secretValue.d.ts +2 -0
  46. package/dist-lib/components/file-widgets/UnknownFileWidget.d.ts +3 -0
  47. package/dist-lib/components/file-widgets/UploadFailureText.d.ts +4 -0
  48. package/dist-lib/components/file-widgets/helpers.d.ts +1 -1
  49. package/dist-lib/components/file-widgets/host.d.ts +4 -3
  50. package/dist-lib/components/file-widgets/types.d.ts +1 -0
  51. package/dist-lib/components/file-widgets/upload.d.ts +18 -3
  52. package/dist-lib/components/filters/filter-op-label.d.ts +3 -0
  53. package/dist-lib/components/layout/ImpersonationBanner.d.ts +1 -1
  54. package/dist-lib/components/layout/ImpersonationFrame.d.ts +1 -1
  55. package/dist-lib/components/layout/Layout.d.ts +2 -1
  56. package/dist-lib/components/layout/Sidebar.d.ts +2 -1
  57. package/dist-lib/components/layout/TenantChip.d.ts +1 -1
  58. package/dist-lib/components/list/ViewSwitcher.d.ts +4 -2
  59. package/dist-lib/components/pages/DocumentsMenu.d.ts +1 -2
  60. package/dist-lib/components/pages/ExportMenu.d.ts +3 -5
  61. package/dist-lib/components/pages/RecordDocumentsPanel.d.ts +1 -2
  62. package/dist-lib/components/pages/auth/AuthShell.d.ts +4 -31
  63. package/dist-lib/components/pages/exportRequest.d.ts +4 -6
  64. package/dist-lib/components/pages/list/DeleteViewDialog.d.ts +8 -0
  65. package/dist-lib/components/pages/list/ListCardRow.d.ts +1 -2
  66. package/dist-lib/components/pages/list/ListCardsBody.d.ts +0 -1
  67. package/dist-lib/components/pages/list/ListFloatbar.d.ts +2 -2
  68. package/dist-lib/components/pages/list/ListHeader.d.ts +2 -2
  69. package/dist-lib/components/pages/list/ListNoRows.d.ts +4 -5
  70. package/dist-lib/components/pages/list/ListToolbar.d.ts +3 -2
  71. package/dist-lib/components/pages/list/ListUrlBanner.d.ts +10 -0
  72. package/dist-lib/components/pages/list/RowActionsCell.d.ts +2 -4
  73. package/dist-lib/components/pages/list/RowContextMenu.d.ts +1 -2
  74. package/dist-lib/components/pages/list/columns.d.ts +2 -1
  75. package/dist-lib/components/pages/list/filter-meta.d.ts +2 -1
  76. package/dist-lib/components/pages/list/useActiveView.d.ts +38 -0
  77. package/dist-lib/components/pages/list/useListColumnLayout.d.ts +6 -5
  78. package/dist-lib/components/pages/list/useListQuery.d.ts +4 -4
  79. package/dist-lib/components/pages/list/useListSort.d.ts +5 -4
  80. package/dist-lib/components/pages/list/useListViews.d.ts +18 -8
  81. package/dist-lib/components/pages/list/useRowMenu.d.ts +2 -3
  82. package/dist-lib/components/pages/profile/Profile.d.ts +3 -0
  83. package/dist-lib/components/params/ParamsBlock.d.ts +1 -13
  84. package/dist-lib/components/params/param-editors.d.ts +3 -11
  85. package/dist-lib/components/primitives/ClassifiedFieldLocked.d.ts +1 -2
  86. package/dist-lib/components/shared/DynamicIcon.d.ts +2 -2
  87. package/dist-lib/components/shared/LoadingSkeleton.d.ts +1 -0
  88. package/dist-lib/components/shared/LucideIcon.d.ts +1 -1
  89. package/dist-lib/components/shared/useOwnRefresh.d.ts +1 -1
  90. package/dist-lib/declarion-react.css +1 -1
  91. package/dist-lib/embed/theme.d.ts +1 -1
  92. package/dist-lib/embed/useEmbedNavigate.d.ts +1 -1
  93. package/dist-lib/failure-v-uGSpbX.js +158 -0
  94. package/dist-lib/{field-classification-D6xQYn-h.js → field-classification-C28XE-_P.js} +514 -307
  95. package/dist-lib/format-count-DA4wmmWR.js +1771 -0
  96. package/dist-lib/hooks/useEntityData.d.ts +1 -1
  97. package/dist-lib/hooks/useFilters.d.ts +7 -5
  98. package/dist-lib/hooks/useLanguage.d.ts +4 -0
  99. package/dist-lib/hooks/useParams.d.ts +4 -51
  100. package/dist-lib/hooks/useRegisterScreenTab.d.ts +1 -1
  101. package/dist-lib/hooks/useSSE.d.ts +3 -3
  102. package/dist-lib/hooks/useTabTitle.d.ts +2 -0
  103. package/dist-lib/hooks/useText.d.ts +3 -3
  104. package/dist-lib/hooks/useVersionWatcher.d.ts +1 -1
  105. package/dist-lib/hooks/useViews.d.ts +20 -0
  106. package/dist-lib/index.d.ts +8 -7
  107. package/dist-lib/index.js +2716 -5803
  108. package/dist-lib/lib/action-dispatch.d.ts +2 -1
  109. package/dist-lib/lib/actions.d.ts +30 -42
  110. package/dist-lib/lib/anchor.d.ts +3 -4
  111. package/dist-lib/lib/decimal-text.d.ts +1 -0
  112. package/dist-lib/lib/document-templates.d.ts +1 -2
  113. package/dist-lib/lib/download.d.ts +2 -1
  114. package/dist-lib/lib/evidence-verdict.d.ts +2 -1
  115. package/dist-lib/lib/failure.d.ts +2 -0
  116. package/dist-lib/lib/field-classification.d.ts +3 -3
  117. package/dist-lib/lib/filters.d.ts +18 -2
  118. package/dist-lib/lib/format-count.d.ts +8 -7
  119. package/dist-lib/lib/language.d.ts +19 -0
  120. package/dist-lib/lib/mass-edit.d.ts +2 -1
  121. package/dist-lib/lib/realtime-query-keys.d.ts +1 -1
  122. package/dist-lib/lib/realtime-reconcile.d.ts +3 -4
  123. package/dist-lib/lib/screen-back.d.ts +4 -6
  124. package/dist-lib/lib/sort.d.ts +9 -9
  125. package/dist-lib/lib/timestamp.d.ts +5 -7
  126. package/dist-lib/lib/ui-actions.d.ts +2 -1
  127. package/dist-lib/peekDraftStore-D-cTbiIr.js +199 -0
  128. package/dist-lib/registry-Cb3W-czW.js +1950 -0
  129. package/dist-lib/safe-url-oSJw5pzO.js +34 -0
  130. package/dist-lib/stores/icon-registry.d.ts +2 -2
  131. package/dist-lib/stores/list-layout.d.ts +3 -4
  132. package/dist-lib/stores/realtime.d.ts +1 -1
  133. package/dist-lib/stores/tabs.d.ts +3 -2
  134. package/dist-lib/testing.d.ts +6 -0
  135. package/dist-lib/testing.js +98 -76
  136. package/dist-lib/types/api.d.ts +7 -8
  137. package/dist-lib/types/fieldType.d.ts +1 -1
  138. package/dist-lib/types/files.d.ts +4 -4
  139. package/dist-lib/types/schema.d.ts +44 -50
  140. package/dist-lib/useAgentConversation-D97IqE-J.js +623 -0
  141. package/dist-lib/{useCurrentScreen-CzwzQpoW.js → useCurrentScreen-BL5NZFCw.js} +2777 -3768
  142. package/dist-lib/useListQuery-BG1GyKtJ.js +103 -0
  143. package/dist-lib/useProperties-4Lg3odrt.js +83 -0
  144. package/dist-lib/{useTabSearchMirror-C39U85cg.js → useTabSearchMirror-ZVLlINBX.js} +49 -51
  145. package/dist-lib/useText-BFDCTUSo.js +952 -0
  146. package/dist-lib/{value-Bo8C8WMU.js → value-By1-WJ8J.js} +74 -76
  147. package/dist-lib/vite/fingerprint-plugin.d.ts +2 -3
  148. package/package.json +9 -9
  149. package/dist-lib/Grid-DWgUPuZ3.js +0 -404
  150. package/dist-lib/MarkdownRenderer-CcSFc2N3.js +0 -85
  151. package/dist-lib/RecordIdBadge-CGxPR-8q.js +0 -24
  152. package/dist-lib/SmartDetailPage.impl-lskCd-WG.js +0 -1846
  153. package/dist-lib/SmartListPage.impl-CrGbdzyK.js +0 -2854
  154. package/dist-lib/SortHeaderMenu-SYSAaqQJ.js +0 -106
  155. package/dist-lib/action-dispatch-CR4ajBtT.js +0 -1985
  156. package/dist-lib/cardProjection-CW5RIMko.js +0 -699
  157. package/dist-lib/components/pages/home/HomeStub.d.ts +0 -6
  158. package/dist-lib/components/pages/jobs/Jobs.d.ts +0 -1
  159. package/dist-lib/components/pages/pipeline/Pipeline.d.ts +0 -1
  160. package/dist-lib/format-count-Dobmi-Ji.js +0 -1551
  161. package/dist-lib/hooks/useUserLocale.d.ts +0 -1
  162. package/dist-lib/lib/messages.d.ts +0 -12
  163. package/dist-lib/peekDraftStore-5wQ7lq_V.js +0 -194
  164. package/dist-lib/registry-CjgUaF7C.js +0 -1768
  165. package/dist-lib/useListQuery-D7Hr5WM1.js +0 -96
  166. package/dist-lib/useProperties-CqtCzFCr.js +0 -81
@@ -0,0 +1,623 @@
1
+ import { A as e, Rn as t, j as n, jn as r, k as i } from "./useCurrentScreen-BL5NZFCw.js";
2
+ import { $ as a, P as o, p as s, t as c } from "./useText-BFDCTUSo.js";
3
+ import { p as l } from "./failure-v-uGSpbX.js";
4
+ import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
5
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
+ //#region src/components/agents/AgentElicitForm.tsx
7
+ function g({ message: e, schema: n, onSubmit: r, onCancel: i }) {
8
+ let a = c(), [o, s] = p(() => x(n)), [l, u] = p(null), d = () => {
9
+ let e = (n.required ?? []).filter((e) => b(o[e]));
10
+ if (e.length > 0) {
11
+ u(a("agent.elicit.required", "Required: {fields}", { fields: e.join(", ") }));
12
+ return;
13
+ }
14
+ r(o);
15
+ }, f = Object.entries(n.properties ?? {});
16
+ return /* @__PURE__ */ h("div", {
17
+ className: "rounded-md border border-divider bg-surface p-3 text-sm",
18
+ children: [
19
+ /* @__PURE__ */ m("div", {
20
+ className: "mb-3 font-medium",
21
+ children: e
22
+ }),
23
+ /* @__PURE__ */ m("div", {
24
+ className: "space-y-2",
25
+ children: f.map(([e, t]) => /* @__PURE__ */ m(_, {
26
+ name: e,
27
+ prop: t,
28
+ required: (n.required ?? []).includes(e),
29
+ value: o[e],
30
+ onChange: (t) => s((n) => ({
31
+ ...n,
32
+ [e]: t
33
+ }))
34
+ }, e))
35
+ }),
36
+ l && /* @__PURE__ */ m("div", {
37
+ className: "mt-2 text-xs text-destructive",
38
+ children: l
39
+ }),
40
+ /* @__PURE__ */ h("div", {
41
+ className: "mt-3 flex justify-end gap-2",
42
+ children: [i && /* @__PURE__ */ m(t, {
43
+ kind: "ghost",
44
+ onClick: i,
45
+ children: a("dialog.cancel", "Cancel")
46
+ }), /* @__PURE__ */ m(t, {
47
+ onClick: d,
48
+ children: a("agent.elicit.submit", "Submit")
49
+ })]
50
+ })
51
+ ]
52
+ });
53
+ }
54
+ function _({ name: e, prop: t, required: n, value: i, onChange: a }) {
55
+ let o = (t.title ?? y(e)) + (n ? " *" : ""), s = t.description;
56
+ return t.enum ? /* @__PURE__ */ m(v, {
57
+ label: o,
58
+ help: s,
59
+ children: /* @__PURE__ */ h("select", {
60
+ value: r(i),
61
+ onChange: (e) => a(e.target.value),
62
+ className: "w-full rounded-md border border-border bg-card p-2 text-sm",
63
+ children: [/* @__PURE__ */ m("option", {
64
+ value: "",
65
+ children: "—"
66
+ }), t.enum.map((e) => /* @__PURE__ */ m("option", {
67
+ value: String(e),
68
+ children: String(e)
69
+ }, String(e)))]
70
+ })
71
+ }) : t.type === "boolean" ? /* @__PURE__ */ m(v, {
72
+ label: o,
73
+ help: s,
74
+ children: /* @__PURE__ */ m("input", {
75
+ type: "checkbox",
76
+ checked: !!i,
77
+ onChange: (e) => a(e.target.checked)
78
+ })
79
+ }) : t.type === "array" && t.items?.enum ? /* @__PURE__ */ m(v, {
80
+ label: o,
81
+ help: s,
82
+ children: /* @__PURE__ */ m("select", {
83
+ multiple: !0,
84
+ value: Array.isArray(i) ? i.map(String) : [],
85
+ onChange: (e) => {
86
+ a(Array.from(e.target.selectedOptions).map((e) => e.value));
87
+ },
88
+ className: "w-full rounded-md border border-border bg-card p-2 text-sm",
89
+ children: t.items.enum.map((e) => /* @__PURE__ */ m("option", {
90
+ value: String(e),
91
+ children: String(e)
92
+ }, String(e)))
93
+ })
94
+ }) : t.type === "integer" || t.type === "number" ? /* @__PURE__ */ m(v, {
95
+ label: o,
96
+ help: s,
97
+ children: /* @__PURE__ */ m("input", {
98
+ type: "number",
99
+ step: t.type === "integer" ? 1 : "any",
100
+ min: t.minimum,
101
+ max: t.maximum,
102
+ value: i == null ? "" : r(i),
103
+ onChange: (e) => {
104
+ a(e.target.value === "" ? void 0 : Number(e.target.value));
105
+ },
106
+ className: "w-full rounded-md border border-border bg-card p-2 text-sm"
107
+ })
108
+ }) : t.format === "multiline" ? /* @__PURE__ */ m(v, {
109
+ label: o,
110
+ help: s,
111
+ children: /* @__PURE__ */ m("textarea", {
112
+ rows: 3,
113
+ value: r(i),
114
+ onChange: (e) => a(e.target.value),
115
+ className: "w-full rounded-md border border-border bg-card p-2 text-sm"
116
+ })
117
+ }) : /* @__PURE__ */ m(v, {
118
+ label: o,
119
+ help: s,
120
+ children: /* @__PURE__ */ m("input", {
121
+ type: t.format === "email" ? "email" : t.format === "url" ? "url" : t.format === "date-time" ? "datetime-local" : "text",
122
+ value: r(i),
123
+ onChange: (e) => a(e.target.value),
124
+ className: "w-full rounded-md border border-border bg-card p-2 text-sm"
125
+ })
126
+ });
127
+ }
128
+ function v({ label: e, help: t, children: n }) {
129
+ return /* @__PURE__ */ h("label", {
130
+ className: "block",
131
+ children: [
132
+ /* @__PURE__ */ m("span", {
133
+ className: "block text-xs font-medium text-muted-foreground",
134
+ children: e
135
+ }),
136
+ n,
137
+ t && /* @__PURE__ */ m("span", {
138
+ className: "mt-0.5 block text-xs text-muted-foreground",
139
+ children: t
140
+ })
141
+ ]
142
+ });
143
+ }
144
+ function y(e) {
145
+ return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
146
+ }
147
+ function b(e) {
148
+ return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
149
+ }
150
+ function x(e) {
151
+ let t = {};
152
+ for (let [n, r] of Object.entries(e.properties ?? {})) r.default !== void 0 && (t[n] = r.default);
153
+ return t;
154
+ }
155
+ //#endregion
156
+ //#region src/components/agents/AgentPicker.tsx
157
+ function S({ agents: e, selectedId: t, onSelect: n, label: r }) {
158
+ let i = c();
159
+ if (e.length < 2) return null;
160
+ let a = e.find((e) => e.id === t);
161
+ return /* @__PURE__ */ h("div", {
162
+ style: {
163
+ display: "flex",
164
+ alignItems: "center",
165
+ gap: 8,
166
+ padding: "8px 14px",
167
+ borderBottom: "1px solid var(--divider)"
168
+ },
169
+ children: [
170
+ /* @__PURE__ */ m("label", {
171
+ htmlFor: "agent-picker",
172
+ style: {
173
+ fontSize: 10.5,
174
+ color: "var(--text-3)"
175
+ },
176
+ children: r
177
+ }),
178
+ /* @__PURE__ */ m("select", {
179
+ id: "agent-picker",
180
+ value: t ?? "",
181
+ onChange: (e) => n(e.target.value),
182
+ style: {
183
+ flex: 1,
184
+ fontSize: 11.5,
185
+ padding: "3px 6px",
186
+ borderRadius: 6,
187
+ border: "1px solid var(--border)",
188
+ background: "var(--surface-2)",
189
+ color: "var(--text)"
190
+ },
191
+ children: e.map((e) => /* @__PURE__ */ m("option", {
192
+ value: e.id,
193
+ children: C(e, i)
194
+ }, e.id))
195
+ }),
196
+ a?.description && /* @__PURE__ */ m("span", {
197
+ style: {
198
+ flex: 2,
199
+ fontSize: 10.5,
200
+ color: "var(--text-3)"
201
+ },
202
+ children: i(a.description)
203
+ })
204
+ ]
205
+ });
206
+ }
207
+ function C(e, t) {
208
+ return t(e.name) || e.code;
209
+ }
210
+ //#endregion
211
+ //#region src/api/agents.ts
212
+ async function w() {
213
+ return (await o("agents.list_available", {})).agents ?? [];
214
+ }
215
+ async function T(e) {
216
+ return {
217
+ id: (await o("agent.start_conversation", { ...e.agent_id ? { agent_id: e.agent_id } : {} })).conversation_id,
218
+ status: "active"
219
+ };
220
+ }
221
+ async function E(e, t) {
222
+ return {
223
+ id: (await o("agent.send_message", {
224
+ conversation_id: t,
225
+ text: e
226
+ })).message_id,
227
+ conversation_id: t,
228
+ role: "user"
229
+ };
230
+ }
231
+ async function D(e, t) {
232
+ await o("agent.answer_question", {
233
+ invocation_id: e,
234
+ answer: t
235
+ });
236
+ }
237
+ async function O(e, t, n) {
238
+ await D(t, n);
239
+ }
240
+ async function k(e, t = "call") {
241
+ await D(e, {
242
+ approve: !0,
243
+ scope: t
244
+ });
245
+ }
246
+ async function A(e, t) {
247
+ await D(e, {
248
+ approve: !1,
249
+ ...t ? { note: t } : {}
250
+ });
251
+ }
252
+ async function j(e) {
253
+ await o("agent.cancel_question", { invocation_id: e });
254
+ }
255
+ async function M(e) {
256
+ await o("agent.cancel_conversation", { conversation_id: e });
257
+ }
258
+ async function N() {
259
+ let e = await l("agent_conversation", {
260
+ sort: "updated_at:desc",
261
+ page: 1,
262
+ per_page: 50
263
+ });
264
+ return (e.data ?? []).map((t) => ({
265
+ ...t,
266
+ agent: t.agent_id ? e.$refs?.agent?.[t.agent_id]?.code : void 0
267
+ }));
268
+ }
269
+ async function P(e) {
270
+ return L("agent_turn", {
271
+ filters: [{
272
+ field: "conversation_id",
273
+ op: "eq",
274
+ value: e
275
+ }],
276
+ sort: "runnable_message_seq:asc"
277
+ });
278
+ }
279
+ async function F(e) {
280
+ return L("agent_tool_invocation", {
281
+ filters: [{
282
+ field: "conversation_id",
283
+ op: "eq",
284
+ value: e
285
+ }],
286
+ sort: "created_at:asc"
287
+ });
288
+ }
289
+ async function I(e) {
290
+ return L("agent_message", {
291
+ filters: [{
292
+ field: "conversation_id",
293
+ op: "eq",
294
+ value: e
295
+ }],
296
+ sort: "seq:asc"
297
+ });
298
+ }
299
+ async function L(e, t) {
300
+ let n = [];
301
+ for (let r = 1;; r += 1) {
302
+ let i = await l(e, {
303
+ ...t,
304
+ page: r,
305
+ per_page: 1e3
306
+ }), a = i.data ?? [];
307
+ if (n.push(...a), i.meta?.has_more !== !0) return n;
308
+ if (a.length === 0) throw Error(`${e} pagination did not advance`);
309
+ }
310
+ }
311
+ //#endregion
312
+ //#region src/hooks/useAgentConversation.ts
313
+ var R = { streaming: !1 }, z = "declarion.agents.conversation_id";
314
+ function B(e) {
315
+ if (e) return `${z}:${e}`;
316
+ }
317
+ function V(e) {
318
+ if (typeof window > "u") return;
319
+ let t = B(e);
320
+ if (t) try {
321
+ return window.localStorage.getItem(t) || void 0;
322
+ } catch {
323
+ return;
324
+ }
325
+ }
326
+ function H(e, t) {
327
+ if (typeof window > "u") return;
328
+ let n = B(e);
329
+ if (n) try {
330
+ t ? window.localStorage.setItem(n, t) : window.localStorage.removeItem(n);
331
+ } catch {}
332
+ }
333
+ function U(e) {
334
+ return !(e instanceof a) || e.code !== "entity.foreign_key_violation" ? !1 : e.ext("constraint") === "agent_messages_tenant_conv_fk";
335
+ }
336
+ function W(e, t) {
337
+ return {
338
+ id: e,
339
+ conversation_id: t,
340
+ seq: 0,
341
+ role: "assistant",
342
+ content: [],
343
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
344
+ streaming: !0
345
+ };
346
+ }
347
+ function G(e, t) {
348
+ let n = !1, r = e.map((e) => e.role !== "assistant" || !e.streaming || e.id === t ? e : (n = !0, {
349
+ ...e,
350
+ streaming: !1
351
+ }));
352
+ return n ? r : e;
353
+ }
354
+ function K(e, t) {
355
+ let n = !1, r = [];
356
+ for (let i of e) {
357
+ if (i.id !== t || i.role !== "assistant") {
358
+ r.push(i);
359
+ continue;
360
+ }
361
+ if (n = !0, i.content.length !== 0) {
362
+ if (i.streaming) {
363
+ r.push({
364
+ ...i,
365
+ streaming: !1
366
+ });
367
+ continue;
368
+ }
369
+ r.push(i);
370
+ }
371
+ }
372
+ return n ? r : e;
373
+ }
374
+ function q(e) {
375
+ let t = e;
376
+ for (let n of e) n.role === "assistant" && n.streaming && (t = K(t, n.id));
377
+ return t;
378
+ }
379
+ function J(e, t, n, r) {
380
+ let i = !1, a = e.map((e) => e.id === n ? (i = !0, r(e)) : e);
381
+ return i ? a : [...e, r(W(n, t))];
382
+ }
383
+ function Y(e, t, n, r) {
384
+ if (!r) return e;
385
+ let i = e.find((e) => e.id === n);
386
+ return i && !i.streaming ? e : J(G(e, n), t, n, (e) => {
387
+ let t = [...e.content], n = t[t.length - 1];
388
+ return n?.type === "text" ? t[t.length - 1] = {
389
+ ...n,
390
+ text: n.text + r
391
+ } : t.push({
392
+ type: "text",
393
+ text: r
394
+ }), {
395
+ ...e,
396
+ streaming: !0,
397
+ content: t
398
+ };
399
+ });
400
+ }
401
+ function ee(e, t, n, r, i, a) {
402
+ let o = e.find((e) => e.id === n);
403
+ return o && !o.streaming ? e : J(G(e, n), t, n, (e) => r && e.content.some((e) => e.type === "tool_use" && e.id === r) ? e.streaming ? e : {
404
+ ...e,
405
+ streaming: !0
406
+ } : {
407
+ ...e,
408
+ streaming: !0,
409
+ content: [...e.content, {
410
+ type: "tool_use",
411
+ id: r || `pending-${n}-${e.content.length}`,
412
+ name: i,
413
+ input: a
414
+ }]
415
+ });
416
+ }
417
+ function te(e, t) {
418
+ let n = e.map((e) => e.streaming ? {
419
+ ...e,
420
+ streaming: !1
421
+ } : e), r = new Set(n.map((e) => e.id)), i = /* @__PURE__ */ new Set();
422
+ for (let e of n) if (e.role === "tool") for (let t of e.content) t.type === "tool_result" && t.id && i.add(t.id);
423
+ for (let e of t) {
424
+ if (e.role === "assistant") {
425
+ if (!e.streaming || r.has(e.id)) continue;
426
+ n.push(e);
427
+ continue;
428
+ }
429
+ if (e.role === "tool") {
430
+ if (r.has(e.id)) continue;
431
+ let t = e.content.find((e) => e.type === "tool_result");
432
+ if (t && i.has(t.id)) continue;
433
+ n.push(e);
434
+ }
435
+ }
436
+ return n;
437
+ }
438
+ function X(e) {
439
+ let t = e.payload?.message_id;
440
+ return typeof t == "string" && t ? t : void 0;
441
+ }
442
+ function Z(t) {
443
+ let a = s.getState().activeTenant?.id, [o, c] = p(t ?? V(a)), l = u((e) => {
444
+ H(a, e), c(e);
445
+ }, [a]), [m, h] = p([]), [g, _] = p(R), [v, y] = p([]), [b, x] = p([]), [S, C] = p([]), [D, L] = p([]), [z, B] = p(), W = f(/* @__PURE__ */ new Set()), Z = f(0);
446
+ d(() => {
447
+ if (!o) {
448
+ h([]), _(R), y([]), x([]);
449
+ return;
450
+ }
451
+ if (W.current.has(o)) {
452
+ W.current.delete(o);
453
+ return;
454
+ }
455
+ let e = !1;
456
+ return Promise.all([
457
+ I(o),
458
+ P(o),
459
+ F(o)
460
+ ]).then(([t, n, r]) => {
461
+ if (e) return;
462
+ let i = t.map((e) => e.streaming ? {
463
+ ...e,
464
+ streaming: !1
465
+ } : e);
466
+ h(i), y(n), x(r);
467
+ }, (t) => {
468
+ e || t?.status === 404 && (l(void 0), h([]));
469
+ }), () => {
470
+ e = !0;
471
+ };
472
+ }, [o, l]);
473
+ let Q = f(o);
474
+ d(() => {
475
+ Q.current = o;
476
+ }, [o]);
477
+ let $ = u((e) => {
478
+ let t = ++Z.current;
479
+ Promise.all([
480
+ I(e),
481
+ P(e),
482
+ F(e)
483
+ ]).then(([n, r, i]) => {
484
+ e === Q.current && t === Z.current && (h((e) => te(n, e)), y(r), x(i));
485
+ }, () => {});
486
+ }, []);
487
+ d(() => {
488
+ let t = (e) => {
489
+ let { convId: t, kind: n, turnId: r, payload: i } = e.detail;
490
+ t === Q.current && a(t, {
491
+ kind: n,
492
+ turnId: r,
493
+ payload: i
494
+ });
495
+ };
496
+ n.addEventListener(i, t);
497
+ let a = (e, t) => {
498
+ switch (t.kind) {
499
+ case "turn.started":
500
+ _((e) => ({
501
+ ...e,
502
+ streaming: !0
503
+ })), h((e) => G(e));
504
+ break;
505
+ case "assistant.message.created": {
506
+ let n = typeof t.payload?.message_id == "string" ? t.payload.message_id : "";
507
+ if (!n) break;
508
+ h((t) => J(G(t, n), e, n, (e) => ({
509
+ ...e,
510
+ streaming: !0
511
+ })));
512
+ break;
513
+ }
514
+ case "text.delta": {
515
+ let n = r(t.payload?.text), i = X(t);
516
+ if (!i || !n) break;
517
+ h((t) => Y(t, e, i, n));
518
+ break;
519
+ }
520
+ case "elicit.pending":
521
+ $(e);
522
+ break;
523
+ case "tool.pending":
524
+ $(e);
525
+ break;
526
+ case "tool.proposed": {
527
+ let n = X(t), r = typeof t.payload?.tool == "string" ? t.payload.tool : "", i = t.payload?.params ?? {}, a = typeof t.payload?.tool_use_id == "string" ? t.payload.tool_use_id : "";
528
+ if (!n || !r) break;
529
+ h((t) => ee(t, e, n, a, r, i));
530
+ break;
531
+ }
532
+ case "tool.result":
533
+ case "tool.failed":
534
+ case "tool.canceled":
535
+ $(e);
536
+ break;
537
+ case "turn.finished": {
538
+ _(R);
539
+ let e = X(t);
540
+ e && h((t) => K(t, e));
541
+ break;
542
+ }
543
+ case "error": h((e) => q(e)), _((e) => ({
544
+ ...e,
545
+ streaming: !1
546
+ }));
547
+ }
548
+ }, o = () => {
549
+ let e = Q.current;
550
+ e && $(e);
551
+ };
552
+ return n.addEventListener(e, o), () => {
553
+ n.removeEventListener(i, t), n.removeEventListener(e, o);
554
+ };
555
+ }, [$]);
556
+ let ne = u(async (e) => {
557
+ let t = o;
558
+ t || (t = (await T({ agent_id: z })).id, W.current.add(t), Q.current = t, l(t));
559
+ let n;
560
+ try {
561
+ n = await E(e, t);
562
+ } catch (r) {
563
+ if (!U(r)) throw r;
564
+ t = (await T({ agent_id: z })).id, W.current.add(t), Q.current = t, l(t), n = await E(e, t);
565
+ }
566
+ h((t) => t.some((e) => e.id === n.id) ? t : [...t, {
567
+ ...n,
568
+ content: [{
569
+ type: "text",
570
+ text: e
571
+ }]
572
+ }]);
573
+ }, [
574
+ o,
575
+ l,
576
+ z
577
+ ]), re = u(async (e, t) => {
578
+ await k(e, t), o && $(o);
579
+ }, [o, $]), ie = u(async (e, t) => {
580
+ await A(e, t), o && $(o);
581
+ }, [o, $]), ae = u(async (e, t) => {
582
+ o && (await O(o, e, t), $(o));
583
+ }, [o, $]), oe = u(async (e) => {
584
+ o && (await j(e), $(o));
585
+ }, [o, $]), se = u(async () => {
586
+ o && await M(o);
587
+ }, [o]), ce = u(async () => {
588
+ C(await N());
589
+ }, []), le = u(() => {
590
+ l(void 0), h([]), _(R);
591
+ }, [l]);
592
+ return d(() => {
593
+ let e = !0;
594
+ return w().then((t) => {
595
+ e && (L(t), B((e) => e ?? t.find((e) => e.is_default)?.id));
596
+ }).catch((e) => {
597
+ console.warn("agents.list_available failed; the agent picker is unavailable", e);
598
+ }), () => {
599
+ e = !1;
600
+ };
601
+ }, []), {
602
+ conversationId: o,
603
+ messages: m,
604
+ turn: g,
605
+ turns: v,
606
+ invocations: b,
607
+ conversations: S,
608
+ send: ne,
609
+ approve: re,
610
+ reject: ie,
611
+ submitInput: ae,
612
+ cancelInput: oe,
613
+ cancel: se,
614
+ refreshConversations: ce,
615
+ startNew: le,
616
+ agents: D,
617
+ selectedAgentId: z,
618
+ selectAgent: B,
619
+ setConversationId: l
620
+ };
621
+ }
622
+ //#endregion
623
+ export { j as a, N as c, I as d, A as f, g, S as h, M as i, F as l, E as m, D as n, T as o, O as p, k as r, w as s, Z as t, P as u };