@declarion/react 0.109.0 → 0.111.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.
- package/dist-lib/api/agents.js +2 -1
- package/dist-lib/api/audience.js +12 -0
- package/dist-lib/api/auth.js +1 -1
- package/dist-lib/api/client.js +100 -91
- package/dist-lib/api/schema.js +31 -31
- package/dist-lib/components/agents/ChatAttachments.js +20 -10
- package/dist-lib/components/file-widgets/DocumentCard.js +1 -1
- package/dist-lib/components/file-widgets/FileList.js +1 -1
- package/dist-lib/components/file-widgets/Grid.js +1 -1
- package/dist-lib/components/file-widgets/upload.js +64 -61
- package/dist-lib/hooks/useAgentConversation.js +112 -104
- package/dist-lib/hooks/useAuth.js +4 -1
- package/dist-lib/hooks/useSchema.js +21 -29
- package/dist-lib/index.d.ts +3 -3
- package/dist-lib/stores/auth.js +35 -35
- package/dist-lib/test/seed-schema.js +4 -3
- package/dist-lib/testing.d.ts +1 -1
- package/dist-lib/{useResponsiveMode-DODbtSrY.d.ts → useResponsiveMode-C4MeAgoS.d.ts} +0 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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
|
|
18
|
-
if (!(r instanceof
|
|
17
|
+
function f(e, n, r) {
|
|
18
|
+
if (!(r instanceof d)) return {
|
|
19
19
|
code: "UNKNOWN",
|
|
20
|
-
message:
|
|
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
|
|
32
|
+
async function p(e) {
|
|
33
33
|
let t = i();
|
|
34
34
|
try {
|
|
35
|
-
return await
|
|
35
|
+
return await m(e, t ? await n() : null);
|
|
36
36
|
} catch (i) {
|
|
37
|
-
if (!(i instanceof
|
|
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
|
|
45
|
+
return await m(e, a);
|
|
46
46
|
} catch (e) {
|
|
47
|
-
throw e instanceof
|
|
47
|
+
throw e instanceof d && e.status === 401 && s()(), e;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
let { file: i, entityCode: a, fieldCode: o, slotCode: s, onProgress: c, signal:
|
|
53
|
-
return new Promise((n,
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
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
|
-
},
|
|
64
|
-
let r =
|
|
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 (
|
|
69
|
-
let e =
|
|
68
|
+
if (p.status >= 200 && p.status < 300) {
|
|
69
|
+
let e = g(i);
|
|
70
70
|
if (!e || !e.id) {
|
|
71
|
-
|
|
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
|
-
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
if (
|
|
85
|
-
|
|
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
|
-
|
|
88
|
+
u.addEventListener("abort", () => p.abort(), { once: !0 });
|
|
89
89
|
}
|
|
90
|
-
let
|
|
91
|
-
|
|
90
|
+
let m = new FormData();
|
|
91
|
+
m.append("file", i, i.name), p.send(m);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
function
|
|
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
|
-
|
|
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 =
|
|
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:
|
|
110
|
+
presigned_url: y(e.presigned_url),
|
|
111
111
|
filename: r,
|
|
112
|
-
content_type:
|
|
113
|
-
size_bytes:
|
|
114
|
-
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 == "
|
|
118
|
+
return typeof e == "object" && !!e;
|
|
123
119
|
}
|
|
124
120
|
function y(e) {
|
|
125
|
-
return typeof e == "
|
|
121
|
+
return typeof e == "string" ? e : void 0;
|
|
126
122
|
}
|
|
127
123
|
function b(e) {
|
|
128
|
-
return typeof e == "
|
|
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:
|
|
157
|
-
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
57
|
+
function D(e) {
|
|
58
58
|
let t = e;
|
|
59
|
-
for (let n of e) n.role === "assistant" && n.streaming && (t =
|
|
59
|
+
for (let n of e) n.role === "assistant" && n.streaming && (t = E(t, n.id));
|
|
60
60
|
return t;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
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(
|
|
64
|
+
return i ? a : [...e, r(w(n, t))];
|
|
65
65
|
}
|
|
66
|
-
function
|
|
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 :
|
|
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
|
|
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 :
|
|
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
|
|
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
|
|
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
|
|
122
|
-
let b = n.getState().activeTenant?.id, [x,
|
|
123
|
-
|
|
124
|
-
}, [b]), [
|
|
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
|
-
|
|
130
|
+
N([]), F(y), L([]), z([]);
|
|
128
131
|
return;
|
|
129
132
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
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(([
|
|
140
|
-
if (e) return;
|
|
141
|
-
let
|
|
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
|
-
|
|
148
|
+
N(a), L(r), z(i);
|
|
146
149
|
}, (t) => {
|
|
147
|
-
e || t?.status === 404 && (
|
|
150
|
+
e || t?.status === 404 && (M(void 0), N([]));
|
|
148
151
|
}), () => {
|
|
149
152
|
e = !0;
|
|
150
153
|
};
|
|
151
|
-
}, [x,
|
|
152
|
-
let
|
|
154
|
+
}, [x, M]);
|
|
155
|
+
let Y = _(x);
|
|
153
156
|
g(() => {
|
|
154
|
-
|
|
157
|
+
Y.current = x;
|
|
155
158
|
}, [x]);
|
|
156
|
-
let
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
+
let X = _(!1), Z = _(null), Q = h((e) => {
|
|
160
|
+
if (X.current) {
|
|
161
|
+
Z.current = e;
|
|
159
162
|
return;
|
|
160
163
|
}
|
|
161
|
-
|
|
162
|
-
let t = ++
|
|
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 ===
|
|
171
|
+
e === Y.current && t === q.current && (N((e) => ie(n, e)), L(r), z(i));
|
|
169
172
|
}, () => {}).finally(() => {
|
|
170
|
-
|
|
171
|
-
let e =
|
|
172
|
-
|
|
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 ===
|
|
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
|
-
|
|
191
|
+
F((e) => ({
|
|
189
192
|
...e,
|
|
190
193
|
streaming: !0
|
|
191
|
-
})),
|
|
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
|
-
|
|
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 =
|
|
206
|
+
let r = t(n.payload?.text), i = j(n);
|
|
204
207
|
if (!i || !r) break;
|
|
205
|
-
|
|
208
|
+
N((t) => k(t, e, i, r));
|
|
206
209
|
break;
|
|
207
210
|
}
|
|
208
211
|
case "elicit.pending":
|
|
209
|
-
|
|
212
|
+
Q(e);
|
|
210
213
|
break;
|
|
211
214
|
case "tool.pending":
|
|
212
|
-
|
|
215
|
+
Q(e);
|
|
213
216
|
break;
|
|
214
217
|
case "tool.proposed": {
|
|
215
|
-
let t =
|
|
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
|
-
|
|
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
|
-
|
|
226
|
+
Q(e);
|
|
224
227
|
break;
|
|
225
228
|
case "turn.finished": {
|
|
226
|
-
|
|
227
|
-
let e =
|
|
228
|
-
e &&
|
|
229
|
+
F(y);
|
|
230
|
+
let e = j(n);
|
|
231
|
+
e && N((t) => E(t, e));
|
|
229
232
|
break;
|
|
230
233
|
}
|
|
231
|
-
case "error":
|
|
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 =
|
|
238
|
-
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
|
|
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:
|
|
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
|
|
250
|
-
} catch (
|
|
251
|
-
if (!
|
|
252
|
-
i = (await l({ agent_id:
|
|
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
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
]),
|
|
271
|
-
await o(e, t), x &&
|
|
272
|
-
}, [x,
|
|
273
|
-
await te(e, t), x &&
|
|
274
|
-
}, [x,
|
|
275
|
-
x && (await ne(x, e, t),
|
|
276
|
-
}, [x,
|
|
277
|
-
x && (await c(e),
|
|
278
|
-
}, [x,
|
|
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]),
|
|
281
|
-
|
|
282
|
-
}, []),
|
|
283
|
-
|
|
284
|
-
}, [
|
|
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
|
|
288
|
-
e && (
|
|
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:
|
|
297
|
-
turn:
|
|
298
|
-
turns:
|
|
299
|
-
invocations:
|
|
300
|
-
conversations:
|
|
301
|
-
send:
|
|
302
|
-
approve:
|
|
303
|
-
reject:
|
|
304
|
-
submitInput:
|
|
305
|
-
cancelInput:
|
|
306
|
-
cancel:
|
|
307
|
-
refreshConversations:
|
|
308
|
-
startNew:
|
|
309
|
-
agents:
|
|
310
|
-
selectedAgentId:
|
|
311
|
-
selectAgent:
|
|
312
|
-
setConversationId:
|
|
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 {
|
|
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
|
-
|
|
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,
|