super-agent-sdk 1.0.4 → 1.0.5
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/README.md +21 -12
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +38 -8
- package/dist/index.mjs +195 -167
- package/dist/mammoth.browser-COPV53yV.js +14917 -0
- package/dist/mammoth.browser-DiAPPO3x.cjs +230 -0
- package/dist/purify.es-C-6FFqDW.js +898 -0
- package/dist/purify.es-Dsdnkgrg.cjs +3 -0
- package/dist/widget.cjs +214 -5
- package/dist/widget.d.ts +61 -13
- package/dist/widget.mjs +1308 -655
- package/package.json +8 -3
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (Array.isArray(
|
|
3
|
-
if (
|
|
1
|
+
function f(a) {
|
|
2
|
+
if (Array.isArray(a)) return a.map((e) => f(e));
|
|
3
|
+
if (a && typeof a == "object" && a.constructor === Object) {
|
|
4
4
|
const e = {};
|
|
5
|
-
for (const [t,
|
|
6
|
-
const o = t.replace(/_([a-z])/g, (
|
|
7
|
-
e[o] =
|
|
5
|
+
for (const [t, n] of Object.entries(a)) {
|
|
6
|
+
const o = t.replace(/_([a-z])/g, (r, s) => s.toUpperCase());
|
|
7
|
+
e[o] = f(n);
|
|
8
8
|
}
|
|
9
9
|
return e;
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return a;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const w = "/api/agent/runtime/v1";
|
|
14
|
+
class I {
|
|
14
15
|
constructor(e) {
|
|
15
|
-
this.refreshing = null
|
|
16
|
+
this.refreshing = null;
|
|
17
|
+
const t = e.baseUrl ?? w;
|
|
18
|
+
this.baseUrl = t.replace(/\/$/, ""), this.tokenGateway = e.tokenGateway.replace(/\/$/, ""), this.appId = e.appId ?? "", this.token = e.token ?? "", this.botId = e.botId, this.isAbsoluteUrl = /^https?:\/\//.test(this.baseUrl), this.isAbsoluteGateway = /^https?:\/\//.test(this.tokenGateway);
|
|
16
19
|
}
|
|
17
20
|
getBotId() {
|
|
18
21
|
return this.botId;
|
|
@@ -23,28 +26,24 @@ class g {
|
|
|
23
26
|
setToken(e) {
|
|
24
27
|
this.token = e;
|
|
25
28
|
}
|
|
26
|
-
/** Derive
|
|
29
|
+
/** Derive browser origin (for relative URL resolution) */
|
|
27
30
|
getOrigin() {
|
|
28
|
-
|
|
29
|
-
return new URL(this.baseUrl).origin;
|
|
30
|
-
} catch {
|
|
31
|
-
return "";
|
|
32
|
-
}
|
|
31
|
+
return typeof window < "u" ? window.location.origin : "";
|
|
33
32
|
}
|
|
34
|
-
/** POST /
|
|
33
|
+
/** POST {origin}{tokenGateway}/v1/token — 获取 token + appId */
|
|
35
34
|
async fetchToken() {
|
|
36
|
-
const
|
|
35
|
+
const t = `${this.isAbsoluteGateway ? this.tokenGateway : `${this.getOrigin()}${this.tokenGateway}`}/v1/token`, n = await fetch(t, {
|
|
37
36
|
method: "POST",
|
|
38
37
|
headers: { "Content-Type": "application/json" },
|
|
39
|
-
body: JSON.stringify({
|
|
38
|
+
body: JSON.stringify({ botId: this.botId })
|
|
40
39
|
});
|
|
41
|
-
if (!
|
|
42
|
-
throw new Error(`HTTP ${
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
throw new Error(
|
|
46
|
-
const
|
|
47
|
-
return this.token =
|
|
40
|
+
if (!n.ok)
|
|
41
|
+
throw new Error(`HTTP ${n.status}: ${n.statusText}`);
|
|
42
|
+
const o = await n.json();
|
|
43
|
+
if (o.code !== "200")
|
|
44
|
+
throw new Error(o.message || `API error: ${o.code}`);
|
|
45
|
+
const r = f(o.data);
|
|
46
|
+
return this.token = r.token, r.appId && !this.appId && (this.appId = r.appId), r.token;
|
|
48
47
|
}
|
|
49
48
|
headers(e) {
|
|
50
49
|
return {
|
|
@@ -67,30 +66,30 @@ class g {
|
|
|
67
66
|
this.refreshing = null;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
async request(e, t,
|
|
69
|
+
async request(e, t, n) {
|
|
71
70
|
if (!this.token && !await this.handleTokenRefresh())
|
|
72
71
|
throw new Error("SDK token not available: POST /token failed");
|
|
73
|
-
let o = `${this.baseUrl}${t}`;
|
|
74
|
-
if (
|
|
72
|
+
let o = this.isAbsoluteUrl ? `${this.baseUrl}${t}` : `${this.getOrigin()}${this.baseUrl}${t}`;
|
|
73
|
+
if (n != null && n.params) {
|
|
75
74
|
const i = new URLSearchParams();
|
|
76
|
-
for (const [l, d] of Object.entries(
|
|
75
|
+
for (const [l, d] of Object.entries(n.params))
|
|
77
76
|
d != null && i.set(l, String(d));
|
|
78
77
|
const c = i.toString();
|
|
79
78
|
c && (o += `?${c}`);
|
|
80
79
|
}
|
|
81
|
-
const
|
|
80
|
+
const r = await fetch(o, {
|
|
82
81
|
method: e,
|
|
83
82
|
headers: this.headers(),
|
|
84
|
-
body:
|
|
83
|
+
body: n != null && n.body ? JSON.stringify(n.body) : void 0
|
|
85
84
|
});
|
|
86
|
-
if (
|
|
87
|
-
return this.request(e, t, { ...
|
|
88
|
-
if (!
|
|
89
|
-
throw new Error(`HTTP ${
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
throw new Error(
|
|
93
|
-
return
|
|
85
|
+
if (r.status === 401 && !(n != null && n.retry) && await this.handleTokenRefresh())
|
|
86
|
+
return this.request(e, t, { ...n, retry: !0 });
|
|
87
|
+
if (!r.ok)
|
|
88
|
+
throw new Error(`HTTP ${r.status}: ${r.statusText}`);
|
|
89
|
+
const s = await r.json();
|
|
90
|
+
if (s.code !== "200")
|
|
91
|
+
throw new Error(s.message || `API error: ${s.code}`);
|
|
92
|
+
return f(s.data);
|
|
94
93
|
}
|
|
95
94
|
get(e, t) {
|
|
96
95
|
return this.request("GET", e, { params: t });
|
|
@@ -105,26 +104,26 @@ class g {
|
|
|
105
104
|
return this.request("DELETE", e);
|
|
106
105
|
}
|
|
107
106
|
/** For SSE streaming — returns raw Response (no envelope unwrap) */
|
|
108
|
-
async streamPost(e, t,
|
|
107
|
+
async streamPost(e, t, n) {
|
|
109
108
|
if (!this.token && !await this.handleTokenRefresh())
|
|
110
109
|
throw new Error("SDK token not available: POST /token failed");
|
|
111
|
-
const o = `${this.baseUrl}${e}`,
|
|
110
|
+
const o = this.isAbsoluteUrl ? `${this.baseUrl}${e}` : `${this.getOrigin()}${this.baseUrl}${e}`, r = await fetch(o, {
|
|
112
111
|
method: "POST",
|
|
113
112
|
headers: this.headers(),
|
|
114
113
|
body: JSON.stringify(t),
|
|
115
|
-
signal:
|
|
114
|
+
signal: n
|
|
116
115
|
});
|
|
117
|
-
return
|
|
116
|
+
return r.status === 401 && await this.handleTokenRefresh() ? fetch(o, {
|
|
118
117
|
method: "POST",
|
|
119
118
|
headers: this.headers(),
|
|
120
119
|
body: JSON.stringify(t),
|
|
121
|
-
signal:
|
|
122
|
-
}) :
|
|
120
|
+
signal: n
|
|
121
|
+
}) : r;
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
|
-
function
|
|
126
|
-
const e =
|
|
127
|
-
`).map((
|
|
124
|
+
function y(a) {
|
|
125
|
+
const e = a.split(`
|
|
126
|
+
`).map((n) => n.trim()).filter((n) => n.startsWith("data:")).map((n) => n.slice(5).trim());
|
|
128
127
|
if (!e.length) return null;
|
|
129
128
|
let t;
|
|
130
129
|
try {
|
|
@@ -153,14 +152,19 @@ function f(n) {
|
|
|
153
152
|
type: "tool_result",
|
|
154
153
|
content: t.output ?? "",
|
|
155
154
|
toolName: t.name,
|
|
156
|
-
toolCallId: t.id
|
|
155
|
+
toolCallId: t.id,
|
|
156
|
+
// 通用 artifacts(type + data),原样透传
|
|
157
|
+
artifacts: Array.isArray(t.artifacts) ? t.artifacts : void 0,
|
|
158
|
+
// fill_html_template 的 render_mode + html
|
|
159
|
+
renderMode: t.render_mode ?? t.renderMode,
|
|
160
|
+
html: t.html
|
|
157
161
|
};
|
|
158
162
|
case "done":
|
|
159
163
|
return {
|
|
160
164
|
type: "done",
|
|
161
165
|
content: t.content ?? "",
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
sessionId: t.sessionId ?? t.session_id ?? "",
|
|
167
|
+
messageId: t.messageId ?? t.message_id
|
|
164
168
|
};
|
|
165
169
|
case "error":
|
|
166
170
|
return { type: "error", content: t.message ?? "Unknown error" };
|
|
@@ -185,191 +189,215 @@ function f(n) {
|
|
|
185
189
|
return null;
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
|
-
async function
|
|
189
|
-
if (!
|
|
192
|
+
async function m(a, e, t) {
|
|
193
|
+
if (!a.body) {
|
|
190
194
|
t(new Error("Response body is null"));
|
|
191
195
|
return;
|
|
192
196
|
}
|
|
193
|
-
const
|
|
194
|
-
let
|
|
197
|
+
const n = a.body.getReader(), o = new TextDecoder();
|
|
198
|
+
let r = "";
|
|
195
199
|
try {
|
|
196
200
|
for (; ; ) {
|
|
197
|
-
const { value:
|
|
201
|
+
const { value: s, done: i } = await n.read();
|
|
198
202
|
if (i) break;
|
|
199
|
-
|
|
203
|
+
r += o.decode(s, { stream: !0 });
|
|
200
204
|
let c;
|
|
201
|
-
for (; (c =
|
|
205
|
+
for (; (c = r.indexOf(`
|
|
202
206
|
|
|
203
207
|
`)) !== -1; ) {
|
|
204
|
-
const l =
|
|
205
|
-
|
|
206
|
-
const d =
|
|
208
|
+
const l = r.slice(0, c);
|
|
209
|
+
r = r.slice(c + 2);
|
|
210
|
+
const d = y(l);
|
|
207
211
|
d && e(d);
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
|
-
if (
|
|
211
|
-
const
|
|
212
|
-
|
|
214
|
+
if (r.trim()) {
|
|
215
|
+
const s = y(r);
|
|
216
|
+
s && e(s);
|
|
213
217
|
}
|
|
214
|
-
} catch (
|
|
215
|
-
(
|
|
218
|
+
} catch (s) {
|
|
219
|
+
(s == null ? void 0 : s.name) !== "AbortError" && t(s instanceof Error ? s : new Error(String(s)));
|
|
216
220
|
} finally {
|
|
217
221
|
try {
|
|
218
|
-
|
|
222
|
+
n.releaseLock();
|
|
219
223
|
} catch {
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
|
-
function
|
|
224
|
-
const t = new AbortController(),
|
|
225
|
-
botId:
|
|
227
|
+
function k(a, e) {
|
|
228
|
+
const t = new AbortController(), n = e.signal ? b(e.signal, t.signal) : t.signal, o = {
|
|
229
|
+
botId: a.getBotId(),
|
|
226
230
|
message: e.message,
|
|
227
231
|
sessionId: e.sessionId,
|
|
228
232
|
stream: e.stream !== !1
|
|
229
233
|
};
|
|
230
|
-
return o.stream ?
|
|
231
|
-
var
|
|
232
|
-
if (!
|
|
233
|
-
(
|
|
234
|
+
return o.stream ? a.streamPost("/chat", o, n).then((r) => {
|
|
235
|
+
var s;
|
|
236
|
+
if (!r.ok) {
|
|
237
|
+
(s = e.onError) == null || s.call(e, new Error(`HTTP ${r.status}`));
|
|
234
238
|
return;
|
|
235
239
|
}
|
|
236
|
-
return
|
|
237
|
-
|
|
240
|
+
return m(
|
|
241
|
+
r,
|
|
238
242
|
(i) => {
|
|
239
243
|
var c, l, d, h;
|
|
240
|
-
i.type === "done" && i.sessionId ? (c = e.onDone) == null || c.call(e, { sessionId: i.sessionId, content: i.content }) : i.type === "done" ? (l = e.onDone) == null || l.call(e, { sessionId: "", content: i.content }) : i.type === "error" ? (d = e.onError) == null || d.call(e, new Error(i.content)) : (h = e.onMessage) == null || h.call(e, i);
|
|
244
|
+
i.type === "done" && i.sessionId ? (c = e.onDone) == null || c.call(e, { sessionId: i.sessionId, content: i.content, messageId: i.messageId }) : i.type === "done" ? (l = e.onDone) == null || l.call(e, { sessionId: "", content: i.content, messageId: i.messageId }) : i.type === "error" ? (d = e.onError) == null || d.call(e, new Error(i.content)) : (h = e.onMessage) == null || h.call(e, i);
|
|
241
245
|
},
|
|
242
246
|
(i) => {
|
|
243
247
|
var c;
|
|
244
248
|
return (c = e.onError) == null ? void 0 : c.call(e, i);
|
|
245
249
|
}
|
|
246
250
|
);
|
|
247
|
-
}).catch((
|
|
248
|
-
var
|
|
249
|
-
(
|
|
250
|
-
}) :
|
|
251
|
-
var
|
|
252
|
-
(
|
|
253
|
-
sessionId:
|
|
254
|
-
content:
|
|
251
|
+
}).catch((r) => {
|
|
252
|
+
var s;
|
|
253
|
+
(r == null ? void 0 : r.name) !== "AbortError" && ((s = e.onError) == null || s.call(e, r instanceof Error ? r : new Error(String(r))));
|
|
254
|
+
}) : a.post("/chat", o).then((r) => {
|
|
255
|
+
var s;
|
|
256
|
+
(s = e.onDone) == null || s.call(e, {
|
|
257
|
+
sessionId: r.sessionId,
|
|
258
|
+
content: r.content ?? ""
|
|
255
259
|
});
|
|
256
|
-
}).catch((
|
|
257
|
-
var
|
|
258
|
-
(
|
|
260
|
+
}).catch((r) => {
|
|
261
|
+
var s;
|
|
262
|
+
(s = e.onError) == null || s.call(e, r instanceof Error ? r : new Error(String(r)));
|
|
259
263
|
}), t;
|
|
260
264
|
}
|
|
261
|
-
function
|
|
262
|
-
const t = new AbortController(),
|
|
263
|
-
return
|
|
265
|
+
function b(a, e) {
|
|
266
|
+
const t = new AbortController(), n = () => t.abort();
|
|
267
|
+
return a.addEventListener("abort", n, { once: !0 }), e.addEventListener("abort", n, { once: !0 }), (a.aborted || e.aborted) && t.abort(), t.signal;
|
|
264
268
|
}
|
|
265
|
-
async function
|
|
266
|
-
return (await
|
|
267
|
-
botId:
|
|
269
|
+
async function T(a) {
|
|
270
|
+
return (await a.post("/chat/sessions", {
|
|
271
|
+
botId: a.getBotId()
|
|
268
272
|
})).sessionId;
|
|
269
273
|
}
|
|
270
|
-
function
|
|
274
|
+
function S(a) {
|
|
271
275
|
return {
|
|
272
276
|
// 后端返回 thread_id,toCamelCase 转为 threadId,映射为 sessionId
|
|
273
|
-
sessionId:
|
|
274
|
-
botId:
|
|
275
|
-
title:
|
|
276
|
-
createTime:
|
|
277
|
-
updateTime:
|
|
277
|
+
sessionId: a.threadId ?? a.sessionId,
|
|
278
|
+
botId: a.botId,
|
|
279
|
+
title: a.title,
|
|
280
|
+
createTime: a.createTime,
|
|
281
|
+
updateTime: a.updateTime
|
|
278
282
|
};
|
|
279
283
|
}
|
|
280
|
-
async function
|
|
281
|
-
const t = await
|
|
282
|
-
botId:
|
|
284
|
+
async function $(a, e) {
|
|
285
|
+
const t = await a.get("/chat/conversations", {
|
|
286
|
+
botId: a.getBotId(),
|
|
283
287
|
page: (e == null ? void 0 : e.page) ?? 1,
|
|
284
288
|
size: (e == null ? void 0 : e.size) ?? 20
|
|
285
289
|
});
|
|
286
290
|
return {
|
|
287
291
|
...t,
|
|
288
|
-
items: t.items.map(
|
|
292
|
+
items: t.items.map(S)
|
|
289
293
|
};
|
|
290
294
|
}
|
|
291
|
-
async function
|
|
292
|
-
await
|
|
295
|
+
async function p(a, e, t) {
|
|
296
|
+
await a.patch(`/chat/conversations/${e}`, { title: t });
|
|
293
297
|
}
|
|
294
|
-
async function
|
|
295
|
-
await
|
|
298
|
+
async function A(a, e) {
|
|
299
|
+
await a.del(`/chat/conversations/${e}`);
|
|
296
300
|
}
|
|
297
|
-
async function
|
|
298
|
-
const t = await
|
|
299
|
-
return
|
|
301
|
+
async function C(a, e) {
|
|
302
|
+
const t = await a.get(`/chat/conversations/${e}/messages`);
|
|
303
|
+
return O(t);
|
|
300
304
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
function O(a) {
|
|
306
|
+
var n, o, r;
|
|
307
|
+
const e = [], t = [...a].sort((s, i) => (s.seq ?? 0) - (i.seq ?? 0));
|
|
308
|
+
for (const s of t) {
|
|
309
|
+
const i = s.role;
|
|
310
|
+
if (i === "system") continue;
|
|
311
|
+
const c = s.messageId ?? `msg_${s.id}`, l = new Date(s.createTime ?? "").getTime() || Date.now();
|
|
312
|
+
if (i === "human")
|
|
308
313
|
e.push({
|
|
309
|
-
id:
|
|
314
|
+
id: c,
|
|
310
315
|
role: "user",
|
|
311
|
-
parts: [{ type: "text", content:
|
|
312
|
-
timestamp:
|
|
316
|
+
parts: [{ type: "text", content: s.content ?? "" }],
|
|
317
|
+
timestamp: l
|
|
313
318
|
});
|
|
314
|
-
else if (
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
if (
|
|
319
|
-
for (const
|
|
320
|
-
let
|
|
319
|
+
else if (i === "ai") {
|
|
320
|
+
const d = [];
|
|
321
|
+
s.reasoning && d.push({ type: "thinking", content: s.reasoning }), s.content && d.push({ type: "text", content: s.content });
|
|
322
|
+
const h = s.toolCalls;
|
|
323
|
+
if (h && Array.isArray(h))
|
|
324
|
+
for (const u of h) {
|
|
325
|
+
let g;
|
|
321
326
|
try {
|
|
322
|
-
|
|
327
|
+
g = typeof u.args == "string" ? u.args : JSON.stringify(u.args ?? {});
|
|
323
328
|
} catch {
|
|
324
|
-
|
|
329
|
+
g = String(u.args ?? "{}");
|
|
325
330
|
}
|
|
326
|
-
|
|
331
|
+
d.push({
|
|
327
332
|
type: "tool_call",
|
|
328
|
-
toolName:
|
|
329
|
-
toolCallId:
|
|
330
|
-
args:
|
|
333
|
+
toolName: u.name ?? "",
|
|
334
|
+
toolCallId: u.id ?? "",
|
|
335
|
+
args: g
|
|
331
336
|
});
|
|
332
337
|
}
|
|
333
|
-
e.push({ id:
|
|
334
|
-
} else
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
338
|
+
e.push({ id: c, role: "assistant", parts: d, timestamp: l });
|
|
339
|
+
} else if (i === "tool") {
|
|
340
|
+
const d = Array.isArray(s.artifacts) ? s.artifacts : void 0;
|
|
341
|
+
e.push({
|
|
342
|
+
id: c,
|
|
343
|
+
role: "assistant",
|
|
344
|
+
parts: [{
|
|
345
|
+
type: "tool_result",
|
|
346
|
+
toolName: s.toolName ?? "",
|
|
347
|
+
toolCallId: s.toolCallId ?? "",
|
|
348
|
+
content: s.content ?? "",
|
|
349
|
+
artifacts: d,
|
|
350
|
+
renderMode: ((n = s.metadata) == null ? void 0 : n.renderMode) ?? ((o = s.metadata) == null ? void 0 : o.render_mode),
|
|
351
|
+
html: (r = s.metadata) == null ? void 0 : r.html
|
|
352
|
+
}],
|
|
353
|
+
timestamp: l
|
|
354
|
+
});
|
|
355
|
+
}
|
|
345
356
|
}
|
|
346
357
|
return e;
|
|
347
358
|
}
|
|
348
|
-
async function
|
|
349
|
-
await
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
359
|
+
async function _(a, e, t, n, o, r) {
|
|
360
|
+
const s = await a.streamPost(
|
|
361
|
+
`/chat/interrupt/${e}/respond`,
|
|
362
|
+
{
|
|
363
|
+
sessionId: t,
|
|
364
|
+
action: n.action,
|
|
365
|
+
value: n.value
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
if (!s.ok) {
|
|
369
|
+
const i = new Error(`HTTP ${s.status}`);
|
|
370
|
+
throw r == null || r(i), i;
|
|
371
|
+
}
|
|
372
|
+
o && await m(
|
|
373
|
+
s,
|
|
374
|
+
(i) => {
|
|
375
|
+
i.type === "error" ? r == null || r(new Error(i.content)) : o(i);
|
|
376
|
+
},
|
|
377
|
+
(i) => r == null ? void 0 : r(i)
|
|
378
|
+
);
|
|
354
379
|
}
|
|
355
|
-
function
|
|
356
|
-
const e = new
|
|
380
|
+
function E(a) {
|
|
381
|
+
const e = new I(a);
|
|
382
|
+
return {
|
|
357
383
|
getToken: () => e.fetchToken(),
|
|
358
|
-
createSession: () =>
|
|
359
|
-
chat: (
|
|
360
|
-
listConversations: (
|
|
361
|
-
renameConversation: (
|
|
362
|
-
deleteConversation: (
|
|
363
|
-
getMessages: (
|
|
364
|
-
respondInterrupt: (
|
|
365
|
-
setToken: (
|
|
366
|
-
feedback: (
|
|
367
|
-
|
|
368
|
-
(s =
|
|
384
|
+
createSession: () => T(e),
|
|
385
|
+
chat: (n) => k(e, n),
|
|
386
|
+
listConversations: (n) => $(e, n),
|
|
387
|
+
renameConversation: (n, o) => p(e, n, o),
|
|
388
|
+
deleteConversation: (n) => A(e, n),
|
|
389
|
+
getMessages: (n) => C(e, n),
|
|
390
|
+
respondInterrupt: (n, o, r, s, i) => _(e, n, o, r, s, i),
|
|
391
|
+
setToken: (n) => e.setToken(n),
|
|
392
|
+
feedback: async (n, o, r) => {
|
|
393
|
+
const s = { type: o };
|
|
394
|
+
o === "dislike" && ((r == null ? void 0 : r.reason) != null && (s.reason = r.reason), r != null && r.remark && (s.remark = r.remark)), await e.post(`/chat/messages/${n}/feedback`, s);
|
|
395
|
+
},
|
|
396
|
+
cancelFeedback: async (n) => {
|
|
397
|
+
await e.del(`/chat/messages/${n}/feedback`);
|
|
369
398
|
}
|
|
370
399
|
};
|
|
371
|
-
return t;
|
|
372
400
|
}
|
|
373
401
|
export {
|
|
374
|
-
|
|
402
|
+
E as createSuperAgent
|
|
375
403
|
};
|