@declarion/react 0.109.0 → 0.110.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.
@@ -1,9 +1,9 @@
1
1
  import { errorCodeOf as e, isApiErrorBody as t } from "../../types/api.js";
2
2
  import { awaitEmbedToken as n, clearEmbedToken as r, isEmbedTokenMode as i } from "../../embed/token.js";
3
- import { callHandler as a, ensureRefresh as o, getPersistentAuthFailureHandler as s, isTransientFailure as c } from "../../api/client.js";
4
- import { failureTitle as l } from "../../lib/failure.js";
3
+ import { callHandler as a, ensureRefresh as o, getPersistentAuthFailureHandler as s, isTransientFailure as c, withPublishedLanguage as l } from "../../api/client.js";
4
+ import { failureTitle as u } from "../../lib/failure.js";
5
5
  //#region src/components/file-widgets/upload.ts
6
- var u = class extends Error {
6
+ var d = class extends Error {
7
7
  code;
8
8
  status;
9
9
  raw;
@@ -14,10 +14,10 @@ var u = class extends Error {
14
14
  return this.raw?.[e];
15
15
  }
16
16
  };
17
- function d(e, n, r) {
18
- if (!(r instanceof u)) return {
17
+ function f(e, n, r) {
18
+ if (!(r instanceof d)) return {
19
19
  code: "UNKNOWN",
20
- message: l(n, r)
20
+ message: u(n, r)
21
21
  };
22
22
  if (t(r.raw)) return {
23
23
  code: r.code,
@@ -29,12 +29,12 @@ function d(e, n, r) {
29
29
  };
30
30
  return r.code === "file.upload_failed" && (i.detail = e("file.upload.status", "HTTP status {status}", { status: r.status })), i;
31
31
  }
32
- async function f(e) {
32
+ async function p(e) {
33
33
  let t = i();
34
34
  try {
35
- return await p(e, t ? await n() : null);
35
+ return await m(e, t ? await n() : null);
36
36
  } catch (i) {
37
- if (!(i instanceof u && i.status === 401 && (i.code === "auth.token_refresh_needed" || i.code === "auth.unauthorized"))) throw i;
37
+ if (!(i instanceof d && i.status === 401 && (i.code === "auth.token_refresh_needed" || i.code === "auth.unauthorized"))) throw i;
38
38
  let a = null;
39
39
  try {
40
40
  t ? (r(), a = await n()) : await o();
@@ -42,17 +42,17 @@ async function f(e) {
42
42
  throw !t && c(e) ? e : (s()(), i);
43
43
  }
44
44
  try {
45
- return await p(e, a);
45
+ return await m(e, a);
46
46
  } catch (e) {
47
- throw e instanceof u && e.status === 401 && s()(), e;
47
+ throw e instanceof d && e.status === 401 && s()(), e;
48
48
  }
49
49
  }
50
50
  }
51
- function p(n, r) {
52
- let { file: i, entityCode: a, fieldCode: o, slotCode: s, onProgress: c, signal: l } = n;
53
- return new Promise((n, d) => {
54
- let f = new XMLHttpRequest();
55
- if (f.open("POST", m(a, o, s)), f.withCredentials = r === null, r && f.setRequestHeader("Authorization", `Bearer ${r}`), f.upload.onprogress = (e) => {
51
+ function m(n, r) {
52
+ let { file: i, entityCode: a, fieldCode: o, slotCode: s, onProgress: c, signal: u } = n;
53
+ return new Promise((n, f) => {
54
+ let p = new XMLHttpRequest();
55
+ if (p.open("POST", l(h(a, o, s))), p.withCredentials = r === null, r && p.setRequestHeader("Authorization", `Bearer ${r}`), p.upload.onprogress = (e) => {
56
56
  if (!c) return;
57
57
  let t = e.lengthComputable ? e.total : i.size, n = t > 0 ? Math.min(100, Math.round(e.loaded / t * 100)) : 0;
58
58
  c({
@@ -60,72 +60,68 @@ function p(n, r) {
60
60
  total: t,
61
61
  pct: n
62
62
  });
63
- }, f.onload = () => {
64
- let r = f.responseText || "", i = null;
63
+ }, p.onload = () => {
64
+ let r = p.responseText || "", i = null;
65
65
  try {
66
66
  i = r ? JSON.parse(r) : null;
67
67
  } catch {}
68
- if (f.status >= 200 && f.status < 300) {
69
- let e = h(i);
68
+ if (p.status >= 200 && p.status < 300) {
69
+ let e = g(i);
70
70
  if (!e || !e.id) {
71
- d(new u(f.status, "file.upload_no_id", "The upload finished but returned no file identifier."));
71
+ f(new d(p.status, "file.upload_no_id", "The upload finished but returned no file identifier."));
72
72
  return;
73
73
  }
74
74
  n(e);
75
75
  return;
76
76
  }
77
77
  let a = t(i) ? e(i.type) : "", o = t(i) ? i.title : "";
78
- d(new u(f.status, a || "file.upload_failed", o, i));
79
- }, f.onerror = () => {
80
- d(new u(0, "file.upload_network", "The upload stopped because the network connection failed."));
81
- }, f.onabort = () => {
82
- d(new u(0, "ABORTED", "Upload aborted"));
83
- }, l) {
84
- if (l.aborted) {
85
- f.abort(), d(new u(0, "ABORTED", "Upload aborted"));
78
+ f(new d(p.status, a || "file.upload_failed", o, i));
79
+ }, p.onerror = () => {
80
+ f(new d(0, "file.upload_network", "The upload stopped because the network connection failed."));
81
+ }, p.onabort = () => {
82
+ f(new d(0, "ABORTED", "Upload aborted"));
83
+ }, u) {
84
+ if (u.aborted) {
85
+ p.abort(), f(new d(0, "ABORTED", "Upload aborted"));
86
86
  return;
87
87
  }
88
- l.addEventListener("abort", () => f.abort(), { once: !0 });
88
+ u.addEventListener("abort", () => p.abort(), { once: !0 });
89
89
  }
90
- let p = new FormData();
91
- p.append("file", i, i.name), f.send(p);
90
+ let m = new FormData();
91
+ m.append("file", i, i.name), p.send(m);
92
92
  });
93
93
  }
94
- function m(e, t, n) {
94
+ function h(e, t, n) {
95
95
  let r = new URLSearchParams();
96
96
  e && t && (r.set("entity_code", e), r.set("field_code", t), n && r.set("slot_code", n));
97
97
  let i = r.toString();
98
98
  return i ? `/api/files/upload?${i}` : "/api/files/upload";
99
99
  }
100
- function h(e) {
101
- return _(e) && _(e.file) ? g(e.file) : null;
102
- }
103
100
  function g(e) {
104
- let t = v(e.file_id), n = v(e.url);
101
+ return v(e) && v(e.file) ? _(e.file) : null;
102
+ }
103
+ function _(e) {
104
+ let t = y(e.file_id), n = y(e.url);
105
105
  if (!t || !n) return null;
106
- let r = v(e.filename_original) ?? v(e.filename_normalized) ?? t;
106
+ let r = y(e.filename_original) ?? y(e.filename_normalized) ?? t;
107
107
  return {
108
108
  id: t,
109
109
  url: n,
110
- presigned_url: v(e.presigned_url),
110
+ presigned_url: y(e.presigned_url),
111
111
  filename: r,
112
- content_type: v(e.content_type) ?? "application/octet-stream",
113
- size_bytes: y(e.size_bytes) ?? 0,
114
- sha256: v(e.sha256) ?? "",
115
- dedup: b(e.dedup)
112
+ content_type: y(e.content_type) ?? "application/octet-stream",
113
+ size_bytes: b(e.size_bytes) ?? 0,
114
+ sha256: y(e.sha256) ?? ""
116
115
  };
117
116
  }
118
- function _(e) {
119
- return typeof e == "object" && !!e;
120
- }
121
117
  function v(e) {
122
- return typeof e == "string" ? e : void 0;
118
+ return typeof e == "object" && !!e;
123
119
  }
124
120
  function y(e) {
125
- return typeof e == "number" ? e : void 0;
121
+ return typeof e == "string" ? e : void 0;
126
122
  }
127
123
  function b(e) {
128
- return typeof e == "boolean" ? e : void 0;
124
+ return typeof e == "number" ? e : void 0;
129
125
  }
130
126
  async function x(e) {
131
127
  await a("file.discard", { file_id: e });
@@ -153,8 +149,8 @@ function T(e, t, n) {
153
149
  code: n.code,
154
150
  message: t(n.code, S),
155
151
  detail: e("file.upload.size_limit", "{size} of {max} allowed", {
156
- size: D(n.size),
157
- max: D(n.max)
152
+ size: O(n.size, e.language),
153
+ max: O(n.max, e.language)
158
154
  })
159
155
  } : {
160
156
  code: n.code,
@@ -170,15 +166,22 @@ function E(e, t) {
170
166
  }
171
167
  return e === t;
172
168
  }
173
- function D(e) {
174
- if (e < 1024) return `${e} B`;
175
- let t = [
176
- "KB",
177
- "MB",
178
- "GB"
179
- ], n = e / 1024, r = 0;
180
- for (; n >= 1024 && r < t.length - 1;) n /= 1024, r++;
181
- return `${n.toFixed(n >= 10 ? 0 : 1)} ${t[r]}`;
169
+ var D = [
170
+ "byte",
171
+ "kilobyte",
172
+ "megabyte",
173
+ "gigabyte"
174
+ ];
175
+ function O(e, t) {
176
+ let n = e, r = 0;
177
+ for (; n >= 1024 && r < D.length - 1;) n /= 1024, r++;
178
+ let i = r === 0 || n >= 10 ? 0 : 1;
179
+ return new Intl.NumberFormat(t, {
180
+ style: "unit",
181
+ unit: D[r],
182
+ unitDisplay: "short",
183
+ maximumFractionDigits: i
184
+ }).format(n);
182
185
  }
183
186
  //#endregion
184
- export { u as UploadError, x as discardFile, D as formatBytes, T as uploadCheckFailure, d as uploadFailure, f as uploadFile, w as validateClientSide };
187
+ export { d as UploadError, x as discardFile, O as formatBytes, T as uploadCheckFailure, f as uploadFailure, p as uploadFile, w as validateClientSide };
@@ -2,14 +2,14 @@ import { ApiError as e } from "../types/api.js";
2
2
  import { coerceDisplayString as t } from "../lib/display-value.js";
3
3
  import { useAuthStore as n } from "../stores/auth.js";
4
4
  import { AGENT_FRAME_EVENT as r, AGENT_MESSAGE_CHANGED_EVENT as i, agentBus as a } from "../api/events.js";
5
- import { approveInvocation as o, cancelConversation as s, cancelInvocation as c, createConversation as l, listAvailableAgents as ee, listConversations as u, loadConversationInvocations as d, loadConversationTurns as f, loadHistory as p, rejectInvocation as te, sendElicitResponse as ne, sendMessage as m } from "../api/agents.js";
5
+ import { approveInvocation as o, cancelConversation as s, cancelInvocation as c, createConversation as l, listAvailableAgents as u, listConversations as ee, loadConversationInvocations as d, loadConversationTurns as f, loadHistory as p, rejectInvocation as te, sendElicitResponse as ne, sendMessage as m } from "../api/agents.js";
6
6
  import { useCallback as h, useEffect as g, useRef as _, useState as v } from "react";
7
7
  //#region src/hooks/useAgentConversation.ts
8
8
  var y = { streaming: !1 }, b = "declarion.agents.conversation_id";
9
9
  function x(e) {
10
10
  if (e) return `${b}:${e}`;
11
11
  }
12
- function S(e) {
12
+ function re(e) {
13
13
  if (typeof window > "u") return;
14
14
  let t = x(e);
15
15
  if (t) try {
@@ -18,17 +18,17 @@ function S(e) {
18
18
  return;
19
19
  }
20
20
  }
21
- function C(e, t) {
21
+ function S(e, t) {
22
22
  if (typeof window > "u") return;
23
23
  let n = x(e);
24
24
  if (n) try {
25
25
  t ? window.localStorage.setItem(n, t) : window.localStorage.removeItem(n);
26
26
  } catch {}
27
27
  }
28
- function w(t) {
28
+ function C(t) {
29
29
  return !(t instanceof e) || t.code !== "entity.foreign_key_violation" ? !1 : t.ext("constraint") === "agent_messages_tenant_conv_fk";
30
30
  }
31
- function T(e, t) {
31
+ function w(e, t) {
32
32
  return {
33
33
  id: e,
34
34
  conversation_id: t,
@@ -39,14 +39,14 @@ function T(e, t) {
39
39
  streaming: !0
40
40
  };
41
41
  }
42
- function E(e, t) {
42
+ function T(e, t) {
43
43
  let n = !1, r = e.map((e) => e.role !== "assistant" || !e.streaming || e.id === t ? e : (n = !0, {
44
44
  ...e,
45
45
  streaming: !1
46
46
  }));
47
47
  return n ? r : e;
48
48
  }
49
- function D(e, t) {
49
+ function E(e, t) {
50
50
  let n = !1, r = [];
51
51
  for (let i of e) i.id !== t || i.role !== "assistant" ? r.push(i) : (n = !0, i.content.length !== 0 && (i.streaming ? r.push({
52
52
  ...i,
@@ -54,19 +54,19 @@ function D(e, t) {
54
54
  }) : r.push(i)));
55
55
  return n ? r : e;
56
56
  }
57
- function O(e) {
57
+ function D(e) {
58
58
  let t = e;
59
- for (let n of e) n.role === "assistant" && n.streaming && (t = D(t, n.id));
59
+ for (let n of e) n.role === "assistant" && n.streaming && (t = E(t, n.id));
60
60
  return t;
61
61
  }
62
- function k(e, t, n, r) {
62
+ function O(e, t, n, r) {
63
63
  let i = !1, a = e.map((e) => e.id === n ? (i = !0, r(e)) : e);
64
- return i ? a : [...e, r(T(n, t))];
64
+ return i ? a : [...e, r(w(n, t))];
65
65
  }
66
- function A(e, t, n, r) {
66
+ function k(e, t, n, r) {
67
67
  if (!r) return e;
68
68
  let i = e.find((e) => e.id === n);
69
- return i && !i.streaming ? e : k(E(e, n), t, n, (e) => {
69
+ return i && !i.streaming ? e : O(T(e, n), t, n, (e) => {
70
70
  let t = [...e.content], n = t[t.length - 1];
71
71
  return n?.type === "text" ? t[t.length - 1] = {
72
72
  ...n,
@@ -81,9 +81,9 @@ function A(e, t, n, r) {
81
81
  };
82
82
  });
83
83
  }
84
- function j(e, t, n, r, i, a) {
84
+ function A(e, t, n, r, i, a) {
85
85
  let o = e.find((e) => e.id === n);
86
- return o && !o.streaming ? e : k(E(e, n), t, n, (e) => r && e.content.some((e) => e.type === "tool_use" && e.id === r) ? e.streaming ? e : {
86
+ return o && !o.streaming ? e : O(T(e, n), t, n, (e) => r && e.content.some((e) => e.type === "tool_use" && e.id === r) ? e.streaming ? e : {
87
87
  ...e,
88
88
  streaming: !0
89
89
  } : {
@@ -97,7 +97,7 @@ function j(e, t, n, r, i, a) {
97
97
  }]
98
98
  });
99
99
  }
100
- function re(e, t) {
100
+ function ie(e, t) {
101
101
  let n = e.map((e) => e.streaming ? {
102
102
  ...e,
103
103
  streaming: !1
@@ -114,68 +114,71 @@ function re(e, t) {
114
114
  }
115
115
  return n;
116
116
  }
117
- function M(e) {
117
+ function j(e) {
118
118
  let t = e.payload?.message_id;
119
119
  return typeof t == "string" && t ? t : void 0;
120
120
  }
121
- function N(e) {
122
- let b = n.getState().activeTenant?.id, [x, T] = v(e ?? S(b)), N = h((e) => {
123
- C(b, e), T(e);
124
- }, [b]), [P, F] = v([]), [I, L] = v(y), [R, z] = v([]), [B, V] = v([]), [H, U] = v([]), [W, G] = v([]), [K, q] = v(), J = _(/* @__PURE__ */ new Set()), Y = _(0);
121
+ function M(e) {
122
+ let b = n.getState().activeTenant?.id, [x, w] = v(e ?? re(b)), M = h((e) => {
123
+ S(b, e), w(e);
124
+ }, [b]), [ae, N] = v([]), [P, F] = v(y), [I, L] = v([]), [R, z] = v([]), [B, V] = v([]), [H, U] = v([]), [W, G] = v(), K = _(/* @__PURE__ */ new Set()), q = _(0), J = _(null), oe = (e) => (J.current?.fingerprint !== e && (J.current = {
125
+ key: crypto.randomUUID(),
126
+ fingerprint: e
127
+ }), J.current.key);
125
128
  g(() => {
126
129
  if (!x) {
127
- F([]), L(y), z([]), V([]);
130
+ N([]), F(y), L([]), z([]);
128
131
  return;
129
132
  }
130
- if (J.current.has(x)) {
131
- J.current.delete(x);
133
+ if (K.current.has(x)) {
134
+ K.current.delete(x);
132
135
  return;
133
136
  }
134
- let e = !1;
137
+ let e = !1, t = ++q.current;
135
138
  return Promise.all([
136
139
  p(x),
137
140
  f(x),
138
141
  d(x)
139
- ]).then(([t, n, r]) => {
140
- if (e) return;
141
- let i = t.map((e) => e.streaming ? {
142
+ ]).then(([n, r, i]) => {
143
+ if (e || t !== q.current) return;
144
+ let a = n.map((e) => e.streaming ? {
142
145
  ...e,
143
146
  streaming: !1
144
147
  } : e);
145
- F(i), z(n), V(r);
148
+ N(a), L(r), z(i);
146
149
  }, (t) => {
147
- e || t?.status === 404 && (N(void 0), F([]));
150
+ e || t?.status === 404 && (M(void 0), N([]));
148
151
  }), () => {
149
152
  e = !0;
150
153
  };
151
- }, [x, N]);
152
- let X = _(x);
154
+ }, [x, M]);
155
+ let Y = _(x);
153
156
  g(() => {
154
- X.current = x;
157
+ Y.current = x;
155
158
  }, [x]);
156
- let Z = _(!1), Q = _(null), $ = h((e) => {
157
- if (Z.current) {
158
- Q.current = e;
159
+ let X = _(!1), Z = _(null), Q = h((e) => {
160
+ if (X.current) {
161
+ Z.current = e;
159
162
  return;
160
163
  }
161
- Z.current = !0;
162
- let t = ++Y.current;
164
+ X.current = !0;
165
+ let t = ++q.current;
163
166
  Promise.all([
164
167
  p(e),
165
168
  f(e),
166
169
  d(e)
167
170
  ]).then(([n, r, i]) => {
168
- e === X.current && t === Y.current && (F((e) => re(n, e)), z(r), V(i));
171
+ e === Y.current && t === q.current && (N((e) => ie(n, e)), L(r), z(i));
169
172
  }, () => {}).finally(() => {
170
- Z.current = !1;
171
- let e = Q.current;
172
- Q.current = null, e && $(e);
173
+ X.current = !1;
174
+ let e = Z.current;
175
+ Z.current = null, e && Q(e);
173
176
  });
174
177
  }, []);
175
178
  g(() => {
176
179
  let e = (e) => {
177
180
  let { convId: t, kind: r, turnId: i, payload: a } = e.detail;
178
- t === X.current && n(t, {
181
+ t === Y.current && n(t, {
179
182
  kind: r,
180
183
  turnId: i,
181
184
  payload: a
@@ -185,73 +188,78 @@ function N(e) {
185
188
  let n = (e, n) => {
186
189
  switch (n.kind) {
187
190
  case "turn.started":
188
- L((e) => ({
191
+ F((e) => ({
189
192
  ...e,
190
193
  streaming: !0
191
- })), F((e) => E(e));
194
+ })), N((e) => T(e));
192
195
  break;
193
196
  case "assistant.message.created": {
194
197
  let t = typeof n.payload?.message_id == "string" ? n.payload.message_id : "";
195
198
  if (!t) break;
196
- F((n) => k(E(n, t), e, t, (e) => ({
199
+ N((n) => O(T(n, t), e, t, (e) => ({
197
200
  ...e,
198
201
  streaming: !0
199
202
  })));
200
203
  break;
201
204
  }
202
205
  case "text.delta": {
203
- let r = t(n.payload?.text), i = M(n);
206
+ let r = t(n.payload?.text), i = j(n);
204
207
  if (!i || !r) break;
205
- F((t) => A(t, e, i, r));
208
+ N((t) => k(t, e, i, r));
206
209
  break;
207
210
  }
208
211
  case "elicit.pending":
209
- $(e);
212
+ Q(e);
210
213
  break;
211
214
  case "tool.pending":
212
- $(e);
215
+ Q(e);
213
216
  break;
214
217
  case "tool.proposed": {
215
- let t = M(n), r = typeof n.payload?.tool == "string" ? n.payload.tool : "", i = n.payload?.params ?? {}, a = typeof n.payload?.tool_use_id == "string" ? n.payload.tool_use_id : "";
218
+ let t = j(n), r = typeof n.payload?.tool == "string" ? n.payload.tool : "", i = n.payload?.params ?? {}, a = typeof n.payload?.tool_use_id == "string" ? n.payload.tool_use_id : "";
216
219
  if (!t || !r) break;
217
- F((n) => j(n, e, t, a, r, i));
220
+ N((n) => A(n, e, t, a, r, i));
218
221
  break;
219
222
  }
220
223
  case "tool.result":
221
224
  case "tool.failed":
222
225
  case "tool.canceled":
223
- $(e);
226
+ Q(e);
224
227
  break;
225
228
  case "turn.finished": {
226
- L(y);
227
- let e = M(n);
228
- e && F((t) => D(t, e));
229
+ F(y);
230
+ let e = j(n);
231
+ e && N((t) => E(t, e));
229
232
  break;
230
233
  }
231
- case "error": F((e) => O(e)), L((e) => ({
234
+ case "error": N((e) => D(e)), F((e) => ({
232
235
  ...e,
233
236
  streaming: !1
234
237
  }));
235
238
  }
236
239
  }, o = () => {
237
- let e = X.current;
238
- e && $(e);
240
+ let e = Y.current;
241
+ e && Q(e);
239
242
  };
240
243
  return a.addEventListener(i, o), () => {
241
244
  a.removeEventListener(r, e), a.removeEventListener(i, o);
242
245
  };
243
- }, [$]);
244
- let ie = h(async (e, t, n = []) => {
246
+ }, [Q]);
247
+ let $ = h(async (e, t, n = []) => {
245
248
  let r = n.map((e) => e.id), i = x;
246
- i || (i = (await l({ agent_id: K })).id, J.current.add(i), X.current = i, N(i));
247
- let a;
249
+ i || (i = (await l({ agent_id: W })).id, K.current.add(i), Y.current = i, M(i));
250
+ let a, o = (n) => m(e, n, t, r, oe(JSON.stringify([
251
+ n,
252
+ e,
253
+ t ?? null,
254
+ r
255
+ ])));
248
256
  try {
249
- a = await m(e, i, t, r);
250
- } catch (n) {
251
- if (!w(n)) throw n;
252
- i = (await l({ agent_id: K })).id, J.current.add(i), X.current = i, N(i), a = await m(e, i, t, r);
257
+ a = await o(i);
258
+ } catch (e) {
259
+ if (!C(e)) throw e;
260
+ i = (await l({ agent_id: W })).id, K.current.add(i), Y.current = i, M(i), a = await o(i);
253
261
  }
254
- F((t) => {
262
+ J.current = null, N((t) => {
255
263
  if (t.some((e) => e.id === a.id)) return t;
256
264
  let r = e ? [{
257
265
  type: "text",
@@ -265,27 +273,27 @@ function N(e) {
265
273
  });
266
274
  }, [
267
275
  x,
268
- N,
269
- K
270
- ]), ae = h(async (e, t) => {
271
- await o(e, t), x && $(x);
272
- }, [x, $]), oe = h(async (e, t) => {
273
- await te(e, t), x && $(x);
274
- }, [x, $]), se = h(async (e, t) => {
275
- x && (await ne(x, e, t), $(x));
276
- }, [x, $]), ce = h(async (e) => {
277
- x && (await c(e), $(x));
278
- }, [x, $]), le = h(async () => {
276
+ M,
277
+ W
278
+ ]), se = h(async (e, t) => {
279
+ await o(e, t), x && Q(x);
280
+ }, [x, Q]), ce = h(async (e, t) => {
281
+ await te(e, t), x && Q(x);
282
+ }, [x, Q]), le = h(async (e, t) => {
283
+ x && (await ne(x, e, t), Q(x));
284
+ }, [x, Q]), ue = h(async (e) => {
285
+ x && (await c(e), Q(x));
286
+ }, [x, Q]), de = h(async () => {
279
287
  x && await s(x);
280
- }, [x]), ue = h(async () => {
281
- U(await u());
282
- }, []), de = h(() => {
283
- N(void 0), F([]), L(y);
284
- }, [N]);
288
+ }, [x]), fe = h(async () => {
289
+ V(await ee());
290
+ }, []), pe = h(() => {
291
+ M(void 0), N([]), F(y);
292
+ }, [M]);
285
293
  return g(() => {
286
294
  let e = !0;
287
- return ee().then((t) => {
288
- e && (G(t), q((e) => e ?? t.find((e) => e.is_default)?.id));
295
+ return u().then((t) => {
296
+ e && (U(t), G((e) => e ?? t.find((e) => e.is_default)?.id));
289
297
  }).catch((e) => {
290
298
  console.warn("agents.list_available failed; the agent picker is unavailable", e);
291
299
  }), () => {
@@ -293,24 +301,24 @@ function N(e) {
293
301
  };
294
302
  }, []), {
295
303
  conversationId: x,
296
- messages: P,
297
- turn: I,
298
- turns: R,
299
- invocations: B,
300
- conversations: H,
301
- send: ie,
302
- approve: ae,
303
- reject: oe,
304
- submitInput: se,
305
- cancelInput: ce,
306
- cancel: le,
307
- refreshConversations: ue,
308
- startNew: de,
309
- agents: W,
310
- selectedAgentId: K,
311
- selectAgent: q,
312
- setConversationId: N
304
+ messages: ae,
305
+ turn: P,
306
+ turns: I,
307
+ invocations: R,
308
+ conversations: B,
309
+ send: $,
310
+ approve: se,
311
+ reject: ce,
312
+ submitInput: le,
313
+ cancelInput: ue,
314
+ cancel: de,
315
+ refreshConversations: fe,
316
+ startNew: pe,
317
+ agents: H,
318
+ selectedAgentId: W,
319
+ selectAgent: G,
320
+ setConversationId: M
313
321
  };
314
322
  }
315
323
  //#endregion
316
- export { N as useAgentConversation };
324
+ export { M as useAgentConversation };
@@ -51,7 +51,10 @@ function g() {
51
51
  confirmSignup: D.mutate,
52
52
  switchTenant: O.mutate,
53
53
  logout: async () => {
54
- await x(), C.removeQueries({ predicate: (e) => !h.has(e.queryKey[0]) }), C.getMutationCache().clear(), d.getState().clear(), S("/login");
54
+ let e = x();
55
+ C.removeQueries({ predicate: (e) => !h.has(e.queryKey[0]) }), C.getMutationCache().clear(), d.getState().clear(), S("/login"), await e.catch((e) => {
56
+ c.error(o(w, e));
57
+ });
55
58
  },
56
59
  isLoginPending: T.isPending,
57
60
  isSignupPending: E.isPending,