super-agent-sdk 1.0.9 → 1.0.11

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/index.mjs CHANGED
@@ -1,20 +1,21 @@
1
- function u(r) {
2
- if (Array.isArray(r)) return r.map((e) => u(e));
1
+ import { c as J } from "./nosUploader-C94D61NK.js";
2
+ function h(r) {
3
+ if (Array.isArray(r)) return r.map((e) => h(e));
3
4
  if (r && typeof r == "object" && r.constructor === Object) {
4
5
  const e = {};
5
- for (const [t, s] of Object.entries(r)) {
6
- const o = t.replace(/_([a-z])/g, (a, n) => n.toUpperCase());
7
- e[o] = u(s);
6
+ for (const [t, n] of Object.entries(r)) {
7
+ const i = t.replace(/_([a-z])/g, (a, s) => s.toUpperCase());
8
+ e[i] = h(n);
8
9
  }
9
10
  return e;
10
11
  }
11
12
  return r;
12
13
  }
13
- const I = "/api/agent/runtime/v1";
14
- class w {
14
+ const w = "/api/agent/runtime/v1";
15
+ class T {
15
16
  constructor(e) {
16
17
  this.refreshing = null;
17
- const t = e.baseUrl ?? I;
18
+ const t = e.baseUrl ?? w;
18
19
  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);
19
20
  }
20
21
  getBotId() {
@@ -32,17 +33,17 @@ class w {
32
33
  }
33
34
  /** POST {origin}{tokenGateway}/v1/token — 获取 token + appId */
34
35
  async fetchToken() {
35
- const t = `${this.isAbsoluteGateway ? this.tokenGateway : `${this.getOrigin()}${this.tokenGateway}`}/v1/token`, s = await fetch(t, {
36
+ const t = `${this.isAbsoluteGateway ? this.tokenGateway : `${this.getOrigin()}${this.tokenGateway}`}/v1/token`, n = await fetch(t, {
36
37
  method: "POST",
37
38
  headers: { "Content-Type": "application/json" },
38
39
  body: JSON.stringify({ botId: this.botId })
39
40
  });
40
- if (!s.ok)
41
- throw new Error(`HTTP ${s.status}: ${s.statusText}`);
42
- const o = await s.json();
43
- if (o.code !== "200")
44
- throw new Error(o.message || `API error: ${o.code}`);
45
- const a = u(o.data);
41
+ if (!n.ok)
42
+ throw new Error(`HTTP ${n.status}: ${n.statusText}`);
43
+ const i = await n.json();
44
+ if (i.code !== "200")
45
+ throw new Error(i.message || `API error: ${i.code}`);
46
+ const a = h(i.data);
46
47
  return this.token = a.token, a.appId && !this.appId && (this.appId = a.appId), a.token;
47
48
  }
48
49
  headers(e) {
@@ -66,30 +67,30 @@ class w {
66
67
  this.refreshing = null;
67
68
  }
68
69
  }
69
- async request(e, t, s) {
70
+ async request(e, t, n) {
70
71
  if (!this.token && !await this.handleTokenRefresh())
71
72
  throw new Error("SDK token not available: POST /token failed");
72
- let o = this.isAbsoluteUrl ? `${this.baseUrl}${t}` : `${this.getOrigin()}${this.baseUrl}${t}`;
73
- if (s != null && s.params) {
74
- const i = new URLSearchParams();
75
- for (const [d, l] of Object.entries(s.params))
76
- l != null && i.set(d, String(l));
77
- const c = i.toString();
78
- c && (o += `?${c}`);
73
+ let i = this.isAbsoluteUrl ? `${this.baseUrl}${t}` : `${this.getOrigin()}${this.baseUrl}${t}`;
74
+ if (n != null && n.params) {
75
+ const o = new URLSearchParams();
76
+ for (const [d, l] of Object.entries(n.params))
77
+ l != null && o.set(d, String(l));
78
+ const c = o.toString();
79
+ c && (i += `?${c}`);
79
80
  }
80
- const a = await fetch(o, {
81
+ const a = await fetch(i, {
81
82
  method: e,
82
83
  headers: this.headers(),
83
- body: s != null && s.body ? JSON.stringify(s.body) : void 0
84
+ body: n != null && n.body ? JSON.stringify(n.body) : void 0
84
85
  });
85
- if (a.status === 401 && !(s != null && s.retry) && await this.handleTokenRefresh())
86
- return this.request(e, t, { ...s, retry: !0 });
86
+ if (a.status === 401 && !(n != null && n.retry) && await this.handleTokenRefresh())
87
+ return this.request(e, t, { ...n, retry: !0 });
87
88
  if (!a.ok)
88
89
  throw new Error(`HTTP ${a.status}: ${a.statusText}`);
89
- const n = await a.json();
90
- if (n.code !== "200")
91
- throw new Error(n.message || `API error: ${n.code}`);
92
- return u(n.data);
90
+ const s = await a.json();
91
+ if (s.code !== "200")
92
+ throw new Error(s.message || `API error: ${s.code}`);
93
+ return h(s.data);
93
94
  }
94
95
  get(e, t) {
95
96
  return this.request("GET", e, { params: t });
@@ -104,26 +105,36 @@ class w {
104
105
  return this.request("DELETE", e);
105
106
  }
106
107
  /** For SSE streaming — returns raw Response (no envelope unwrap) */
107
- async streamPost(e, t, s) {
108
+ async streamPost(e, t, n) {
108
109
  if (!this.token && !await this.handleTokenRefresh())
109
110
  throw new Error("SDK token not available: POST /token failed");
110
- const o = this.isAbsoluteUrl ? `${this.baseUrl}${e}` : `${this.getOrigin()}${this.baseUrl}${e}`, a = await fetch(o, {
111
+ const i = this.isAbsoluteUrl ? `${this.baseUrl}${e}` : `${this.getOrigin()}${this.baseUrl}${e}`, a = await fetch(i, {
111
112
  method: "POST",
112
113
  headers: this.headers(),
113
114
  body: JSON.stringify(t),
114
- signal: s
115
+ signal: n
115
116
  });
116
- return a.status === 401 && await this.handleTokenRefresh() ? fetch(o, {
117
+ return a.status === 401 && await this.handleTokenRefresh() ? fetch(i, {
117
118
  method: "POST",
118
119
  headers: this.headers(),
119
120
  body: JSON.stringify(t),
120
- signal: s
121
+ signal: n
121
122
  }) : a;
122
123
  }
123
124
  }
124
- function y(r) {
125
+ function u(r) {
126
+ return typeof r == "string" ? r : Array.isArray(r) ? r.map((e) => {
127
+ if (typeof e == "string") return e;
128
+ if (e && typeof e == "object") {
129
+ if (typeof e.text == "string") return e.text;
130
+ if (e.type) return `[${e.type}${e.mime_type ? ": " + e.mime_type : ""}]`;
131
+ }
132
+ return "";
133
+ }).join("") : r == null ? "" : String(r);
134
+ }
135
+ function I(r) {
125
136
  const e = r.split(`
126
- `).map((s) => s.trim()).filter((s) => s.startsWith("data:")).map((s) => s.slice(5).trim());
137
+ `).map((n) => n.trim()).filter((n) => n.startsWith("data:")).map((n) => n.slice(5).trim());
127
138
  if (!e.length) return null;
128
139
  let t;
129
140
  try {
@@ -134,11 +145,11 @@ function y(r) {
134
145
  }
135
146
  switch (t.type) {
136
147
  case "user":
137
- return { type: "user", content: t.content ?? "" };
148
+ return { type: "user", content: u(t.content) };
138
149
  case "thinking":
139
- return { type: "thinking", content: t.content ?? "" };
150
+ return { type: "thinking", content: u(t.content) };
140
151
  case "ai":
141
- return { type: "ai", content: t.content ?? "" };
152
+ return { type: "ai", content: u(t.content) };
142
153
  case "tool_call":
143
154
  return {
144
155
  type: "tool_call",
@@ -150,7 +161,7 @@ function y(r) {
150
161
  case "tool_result":
151
162
  return {
152
163
  type: "tool_result",
153
- content: t.output ?? "",
164
+ content: u(t.output),
154
165
  toolName: t.name,
155
166
  toolCallId: t.id,
156
167
  // 通用 artifacts(type + data),原样透传
@@ -162,14 +173,14 @@ function y(r) {
162
173
  case "done":
163
174
  return {
164
175
  type: "done",
165
- content: t.content ?? "",
176
+ content: u(t.content),
166
177
  sessionId: t.sessionId ?? t.session_id ?? "",
167
178
  messageId: t.messageId ?? t.message_id
168
179
  };
169
180
  case "stop":
170
181
  return {
171
182
  type: "stop",
172
- content: t.content ?? "",
183
+ content: u(t.content),
173
184
  sessionId: t.sessionId ?? t.session_id ?? "",
174
185
  messageId: t.messageId ?? t.message_id
175
186
  };
@@ -196,90 +207,95 @@ function y(r) {
196
207
  return null;
197
208
  }
198
209
  }
199
- async function m(r, e, t) {
210
+ async function p(r, e, t) {
200
211
  if (!r.body) {
201
212
  t(new Error("Response body is null"));
202
213
  return;
203
214
  }
204
- const s = r.body.getReader(), o = new TextDecoder();
215
+ const n = r.body.getReader(), i = new TextDecoder();
205
216
  let a = "";
206
217
  try {
207
218
  for (; ; ) {
208
- const { value: n, done: i } = await s.read();
209
- if (i) break;
210
- a += o.decode(n, { stream: !0 });
219
+ const { value: s, done: o } = await n.read();
220
+ if (o) break;
221
+ a += i.decode(s, { stream: !0 });
211
222
  let c;
212
223
  for (; (c = a.indexOf(`
213
224
 
214
225
  `)) !== -1; ) {
215
226
  const d = a.slice(0, c);
216
227
  a = a.slice(c + 2);
217
- const l = y(d);
228
+ const l = I(d);
218
229
  l && e(l);
219
230
  }
220
231
  }
221
232
  if (a.trim()) {
222
- const n = y(a);
223
- n && e(n);
233
+ const s = I(a);
234
+ s && e(s);
224
235
  }
225
- } catch (n) {
226
- (n == null ? void 0 : n.name) !== "AbortError" && t(n instanceof Error ? n : new Error(String(n)));
236
+ } catch (s) {
237
+ (s == null ? void 0 : s.name) !== "AbortError" && t(s instanceof Error ? s : new Error(String(s)));
227
238
  } finally {
228
239
  try {
229
- s.releaseLock();
240
+ n.releaseLock();
230
241
  } catch {
231
242
  }
232
243
  }
233
244
  }
234
- function p(r, e) {
235
- const t = new AbortController(), s = e.signal ? T(e.signal, t.signal) : t.signal, o = {
245
+ function k(r, e) {
246
+ var a;
247
+ const t = new AbortController(), n = e.signal ? b(e.signal, t.signal) : t.signal, i = {
236
248
  botId: r.getBotId(),
237
249
  message: e.message,
238
250
  sessionId: e.sessionId,
239
- stream: e.stream !== !1
251
+ stream: e.stream !== !1,
252
+ // url 仅前端回显(下载/预览),剥离后发送——签名 URL 不进后端
253
+ ...(a = e.attachments) != null && a.length ? {
254
+ attachments: e.attachments.map(({ url: s, ...o }) => o)
255
+ } : {}
240
256
  };
241
- return o.stream ? r.streamPost("/chat", o, s).then((a) => {
242
- var n;
243
- if (!a.ok) {
244
- (n = e.onError) == null || n.call(e, new Error(`HTTP ${a.status}`));
257
+ return i.stream ? r.streamPost("/chat", i, n).then((s) => {
258
+ var o;
259
+ if (!s.ok) {
260
+ (o = e.onError) == null || o.call(e, new Error(`HTTP ${s.status}`));
245
261
  return;
246
262
  }
247
- return m(
248
- a,
249
- (i) => {
250
- var c, d, l, h, f, g;
251
- i.type === "done" && i.sessionId ? (c = e.onDone) == null || c.call(e, { sessionId: i.sessionId, content: i.content, messageId: i.messageId }) : i.type === "done" ? (d = e.onDone) == null || d.call(e, { sessionId: "", content: i.content, messageId: i.messageId }) : i.type === "stop" ? ((l = e.onMessage) == null || l.call(e, i), (h = e.onDone) == null || h.call(e, { sessionId: i.sessionId ?? "", content: i.content, messageId: i.messageId })) : i.type === "error" ? (f = e.onError) == null || f.call(e, new Error(i.content)) : (g = e.onMessage) == null || g.call(e, i);
263
+ return p(
264
+ s,
265
+ (c) => {
266
+ var d, l, f, g, y, m;
267
+ c.type === "done" && c.sessionId ? (d = e.onDone) == null || d.call(e, { sessionId: c.sessionId, content: c.content, messageId: c.messageId }) : c.type === "done" ? (l = e.onDone) == null || l.call(e, { sessionId: "", content: c.content, messageId: c.messageId }) : c.type === "stop" ? ((f = e.onMessage) == null || f.call(e, c), (g = e.onDone) == null || g.call(e, { sessionId: c.sessionId ?? "", content: c.content, messageId: c.messageId })) : c.type === "error" ? (y = e.onError) == null || y.call(e, new Error(c.content)) : (m = e.onMessage) == null || m.call(e, c);
252
268
  },
253
- (i) => {
254
- var c;
255
- return (c = e.onError) == null ? void 0 : c.call(e, i);
269
+ (c) => {
270
+ var d;
271
+ return (d = e.onError) == null ? void 0 : d.call(e, c);
256
272
  }
257
273
  );
258
- }).catch((a) => {
259
- var n;
260
- (a == null ? void 0 : a.name) !== "AbortError" && ((n = e.onError) == null || n.call(e, a instanceof Error ? a : new Error(String(a))));
261
- }) : r.post("/chat", o).then((a) => {
262
- var n;
263
- (n = e.onDone) == null || n.call(e, {
264
- sessionId: a.sessionId,
265
- content: a.content ?? "",
266
- messageId: a.messageId
274
+ }).catch((s) => {
275
+ var o;
276
+ (s == null ? void 0 : s.name) !== "AbortError" && ((o = e.onError) == null || o.call(e, s instanceof Error ? s : new Error(String(s))));
277
+ }) : r.post("/chat", i).then((s) => {
278
+ var o;
279
+ (o = e.onDone) == null || o.call(e, {
280
+ sessionId: s.sessionId,
281
+ content: s.content ?? "",
282
+ messageId: s.messageId
267
283
  });
268
- }).catch((a) => {
269
- var n;
270
- (n = e.onError) == null || n.call(e, a instanceof Error ? a : new Error(String(a)));
284
+ }).catch((s) => {
285
+ var o;
286
+ (o = e.onError) == null || o.call(e, s instanceof Error ? s : new Error(String(s)));
271
287
  }), t;
272
288
  }
273
- function T(r, e) {
274
- const t = new AbortController(), s = () => t.abort();
275
- return r.addEventListener("abort", s, { once: !0 }), e.addEventListener("abort", s, { once: !0 }), (r.aborted || e.aborted) && t.abort(), t.signal;
289
+ function b(r, e) {
290
+ const t = new AbortController(), n = () => t.abort();
291
+ return r.addEventListener("abort", n, { once: !0 }), e.addEventListener("abort", n, { once: !0 }), (r.aborted || e.aborted) && t.abort(), t.signal;
276
292
  }
277
- async function b(r) {
293
+ async function S(r) {
278
294
  return (await r.post("/chat/sessions", {
279
295
  botId: r.getBotId()
280
296
  })).sessionId;
281
297
  }
282
- function k(r) {
298
+ function $(r) {
283
299
  return {
284
300
  // 后端返回 thread_id,toCamelCase 转为 threadId,映射为 sessionId
285
301
  sessionId: r.threadId ?? r.sessionId,
@@ -289,7 +305,7 @@ function k(r) {
289
305
  updateTime: r.updateTime
290
306
  };
291
307
  }
292
- async function S(r, e) {
308
+ async function A(r, e) {
293
309
  const t = await r.get("/chat/conversations", {
294
310
  botId: r.getBotId(),
295
311
  page: (e == null ? void 0 : e.page) ?? 1,
@@ -297,77 +313,94 @@ async function S(r, e) {
297
313
  });
298
314
  return {
299
315
  ...t,
300
- items: t.items.map(k)
316
+ items: t.items.map($)
301
317
  };
302
318
  }
303
- async function $(r, e, t) {
319
+ async function C(r, e, t) {
304
320
  await r.patch(`/chat/conversations/${e}`, { title: t });
305
321
  }
306
- async function C(r, e) {
322
+ async function _(r, e) {
307
323
  await r.del(`/chat/conversations/${e}`);
308
324
  }
309
- async function A(r, e) {
325
+ async function O(r, e) {
310
326
  const t = await r.get(`/chat/conversations/${e}/messages`);
311
- return O(t);
327
+ return P(t);
312
328
  }
313
- function O(r) {
314
- const e = [...r].sort((n, i) => {
315
- const c = new Date(n.createTime ?? 0).getTime() || 0, d = new Date(i.createTime ?? 0).getTime() || 0;
316
- return c !== d ? c - d : (n.seq ?? 0) - (i.seq ?? 0);
329
+ function P(r) {
330
+ const e = [...r].sort((s, o) => {
331
+ const c = new Date(s.createTime ?? 0).getTime() || 0, d = new Date(o.createTime ?? 0).getTime() || 0;
332
+ return c !== d ? c - d : (s.seq ?? 0) - (o.seq ?? 0);
317
333
  }), t = /* @__PURE__ */ new Map();
318
- for (const n of e)
319
- n.role === "tool" && n.toolCallId && t.set(n.toolCallId, n.content || "");
320
- const s = /* @__PURE__ */ new Set(), o = [], a = (n, i, c) => {
321
- const d = o[o.length - 1];
322
- (d == null ? void 0 : d.role) === "assistant" ? (d.parts.push(...n), d.id = i) : o.push({ id: i, role: "assistant", parts: [...n], timestamp: c });
334
+ for (const s of e)
335
+ s.role === "tool" && s.toolCallId && t.set(s.toolCallId, s.content || "");
336
+ const n = /* @__PURE__ */ new Set(), i = [], a = (s, o, c) => {
337
+ const d = i[i.length - 1];
338
+ (d == null ? void 0 : d.role) === "assistant" ? (d.parts.push(...s), d.id = o) : i.push({ id: o, role: "assistant", parts: [...s], timestamp: c });
323
339
  };
324
- for (const n of e) {
325
- if (n.role === "system") continue;
326
- const i = String(n.id ?? n.messageId ?? `msg_${Date.now()}`), c = new Date(n.createTime ?? "").getTime() || Date.now();
327
- if (n.role === "human") {
328
- o.push({ id: i, role: "user", parts: [{ type: "text", content: n.content ?? "" }], timestamp: c });
340
+ for (const s of e) {
341
+ if (s.role === "system") continue;
342
+ const o = String(s.id ?? s.messageId ?? `msg_${Date.now()}`), c = new Date(s.createTime ?? "").getTime() || Date.now();
343
+ if (s.role === "human") {
344
+ const d = (s.attachments ?? []).map((l) => ({
345
+ type: "attachment",
346
+ attachment: {
347
+ nosKey: l.nosKey ?? l.attachmentId ?? "",
348
+ // 历史回显后端不带 nosKey,占位空串
349
+ filename: l.filename ?? "file",
350
+ size: l.size ?? void 0,
351
+ mime: l.mime ?? void 0,
352
+ url: l.url ?? void 0
353
+ // 公开读桶下载链接(有则 chip 可点击下载)
354
+ }
355
+ }));
356
+ i.push({
357
+ id: o,
358
+ role: "user",
359
+ parts: [...d, { type: "text", content: u(s.content) }],
360
+ timestamp: c
361
+ });
329
362
  continue;
330
363
  }
331
- if (n.role === "ai") {
332
- const d = _(n, t, s);
333
- d.length > 0 && a(d, i, c);
364
+ if (s.role === "ai") {
365
+ const d = x(s, t, n);
366
+ d.length > 0 && a(d, o, c);
334
367
  continue;
335
368
  }
336
- if (n.role === "tool") {
337
- if (n.toolCallId && s.has(n.toolCallId)) continue;
338
- a([v(n)], i, c);
369
+ if (s.role === "tool") {
370
+ if (s.toolCallId && n.has(s.toolCallId)) continue;
371
+ a([v(s)], o, c);
339
372
  }
340
373
  }
341
- return o;
374
+ return i;
342
375
  }
343
- function _(r, e, t) {
344
- const s = [];
345
- r.reasoning && s.push({ type: "thinking", content: r.reasoning }), r.content && s.push({ type: "text", content: r.content });
346
- for (const o of r.toolCalls ?? [])
347
- o.is_interrupt ? (t.add(o.id), s.push(P(o, e))) : s.push(E(o));
348
- return s;
376
+ function x(r, e, t) {
377
+ const n = [];
378
+ r.reasoning && n.push({ type: "thinking", content: r.reasoning }), r.content && n.push({ type: "text", content: u(r.content) });
379
+ for (const i of r.toolCalls ?? [])
380
+ i.is_interrupt ? (t.add(i.id), n.push(E(i, e))) : n.push(U(i));
381
+ return n;
349
382
  }
350
- function P(r, e) {
351
- const t = e.has(r.id), s = typeof r.args == "object" ? r.args : {};
383
+ function E(r, e) {
384
+ const t = e.has(r.id), n = typeof r.args == "object" ? r.args : {};
352
385
  return {
353
386
  type: "interrupt",
354
387
  interrupt: {
355
388
  interruptId: r.id ?? "",
356
- interruptType: s.interruptType ?? "input",
357
- content: s.content ?? "",
358
- options: s.options,
359
- placeholder: s.placeholder,
360
- inputType: s.inputType,
361
- maxLength: s.maxLength,
362
- required: s.required,
363
- fields: s.fields,
364
- metadata: s.metadata
389
+ interruptType: n.interruptType ?? "input",
390
+ content: n.content ?? "",
391
+ options: n.options,
392
+ placeholder: n.placeholder,
393
+ inputType: n.inputType,
394
+ maxLength: n.maxLength,
395
+ required: n.required,
396
+ fields: n.fields,
397
+ metadata: n.metadata
365
398
  },
366
399
  resolved: t,
367
- response: t ? { action: "submit", value: x(e.get(r.id)) } : void 0
400
+ response: t ? { action: "submit", value: D(e.get(r.id)) } : void 0
368
401
  };
369
402
  }
370
- function E(r) {
403
+ function U(r) {
371
404
  let e;
372
405
  try {
373
406
  e = typeof r.args == "string" ? r.args : JSON.stringify(r.args ?? {});
@@ -377,19 +410,19 @@ function E(r) {
377
410
  return { type: "tool_call", toolName: r.name ?? "", toolCallId: r.id ?? "", args: e };
378
411
  }
379
412
  function v(r) {
380
- var t, s, o;
413
+ var t, n, i;
381
414
  const e = Array.isArray(r.artifacts) ? r.artifacts : void 0;
382
415
  return {
383
416
  type: "tool_result",
384
417
  toolName: r.toolName ?? "",
385
418
  toolCallId: r.toolCallId ?? "",
386
- content: r.content ?? "",
419
+ content: u(r.content),
387
420
  artifacts: e,
388
- renderMode: ((t = r.metadata) == null ? void 0 : t.renderMode) ?? ((s = r.metadata) == null ? void 0 : s.render_mode),
389
- html: (o = r.metadata) == null ? void 0 : o.html
421
+ renderMode: ((t = r.metadata) == null ? void 0 : t.renderMode) ?? ((n = r.metadata) == null ? void 0 : n.render_mode),
422
+ html: (i = r.metadata) == null ? void 0 : i.html
390
423
  };
391
424
  }
392
- function x(r) {
425
+ function D(r) {
393
426
  if (r != null)
394
427
  try {
395
428
  return JSON.parse(r);
@@ -397,57 +430,58 @@ function x(r) {
397
430
  return r;
398
431
  }
399
432
  }
400
- async function U(r, e, t, s, o, a) {
401
- const n = await r.streamPost(
433
+ async function N(r, e, t, n, i, a) {
434
+ const s = await r.streamPost(
402
435
  `/chat/interrupt/${e}/respond`,
403
436
  {
404
437
  sessionId: t,
405
- action: s.action,
406
- value: s.value
438
+ action: n.action,
439
+ value: n.value
407
440
  }
408
441
  );
409
- if (!n.ok) {
410
- const i = new Error(`HTTP ${n.status}`);
411
- throw a == null || a(i), i;
442
+ if (!s.ok) {
443
+ const o = new Error(`HTTP ${s.status}`);
444
+ throw a == null || a(o), o;
412
445
  }
413
- o && await m(
414
- n,
415
- (i) => {
416
- i.type === "error" ? a == null || a(new Error(i.content)) : o(i);
446
+ i && await p(
447
+ s,
448
+ (o) => {
449
+ o.type === "error" ? a == null || a(new Error(o.content)) : i(o);
417
450
  },
418
- (i) => a == null ? void 0 : a(i)
451
+ (o) => a == null ? void 0 : a(o)
419
452
  );
420
453
  }
421
- async function D(r) {
454
+ async function q(r) {
422
455
  return r.get(`/chat/bots/${r.getBotId()}/skills`);
423
456
  }
424
- async function q(r, e) {
457
+ async function L(r, e) {
425
458
  await r.post("/chat/stop", { sessionId: e });
426
459
  }
427
- function N(r) {
428
- const e = new w(r);
460
+ function G(r) {
461
+ const e = new T(r);
429
462
  return {
430
463
  botId: e.getBotId(),
431
464
  getToken: () => e.fetchToken(),
432
- createSession: () => b(e),
433
- chat: (s) => p(e, s),
434
- listConversations: (s) => S(e, s),
435
- renameConversation: (s, o) => $(e, s, o),
436
- deleteConversation: (s) => C(e, s),
437
- getMessages: (s) => A(e, s),
438
- respondInterrupt: (s, o, a, n, i) => U(e, s, o, a, n, i),
439
- setToken: (s) => e.setToken(s),
440
- feedback: async (s, o, a) => {
441
- const n = { type: o };
442
- o === "dislike" && ((a == null ? void 0 : a.reason) != null && (n.reason = a.reason), a != null && a.remark && (n.remark = a.remark)), await e.post(`/chat/messages/${s}/feedback`, n);
465
+ createSession: () => S(e),
466
+ chat: (n) => k(e, n),
467
+ listConversations: (n) => A(e, n),
468
+ renameConversation: (n, i) => C(e, n, i),
469
+ deleteConversation: (n) => _(e, n),
470
+ getMessages: (n) => O(e, n),
471
+ respondInterrupt: (n, i, a, s, o) => N(e, n, i, a, s, o),
472
+ setToken: (n) => e.setToken(n),
473
+ feedback: async (n, i, a) => {
474
+ const s = { type: i };
475
+ i === "dislike" && ((a == null ? void 0 : a.reason) != null && (s.reason = a.reason), a != null && a.remark && (s.remark = a.remark)), await e.post(`/chat/messages/${n}/feedback`, s);
443
476
  },
444
- cancelFeedback: async (s) => {
445
- await e.del(`/chat/messages/${s}/feedback`);
477
+ cancelFeedback: async (n) => {
478
+ await e.del(`/chat/messages/${n}/feedback`);
446
479
  },
447
- listSkills: () => D(e),
448
- stopGeneration: (s) => q(e, s)
480
+ listSkills: () => q(e),
481
+ stopGeneration: (n) => L(e, n)
449
482
  };
450
483
  }
451
484
  export {
452
- N as createSuperAgent
485
+ J as createNosUploader,
486
+ G as createSuperAgent
453
487
  };