super-agent-sdk 1.0.3 → 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/dist/index.mjs CHANGED
@@ -1,38 +1,49 @@
1
- function h(s) {
2
- if (Array.isArray(s)) return s.map((e) => h(e));
3
- if (s && typeof s == "object" && s.constructor === Object) {
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 [r, t] of Object.entries(s)) {
6
- const o = r.replace(/_([a-z])/g, (n, a) => a.toUpperCase());
7
- e[o] = h(t);
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 s;
11
+ return a;
12
12
  }
13
- class g {
13
+ const w = "/api/agent/runtime/v1";
14
+ class I {
14
15
  constructor(e) {
15
- this.refreshing = null, this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.appId = e.appId ?? "", this.token = e.token ?? "", this.botId = e.botId;
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;
19
22
  }
20
- setToken(e, r) {
21
- this.appId = e, this.token = r;
23
+ getAppKey() {
24
+ return this.appId;
22
25
  }
23
- /** POST without auth headers (for /token endpoint) */
24
- async postPublic(e, r) {
25
- const t = `${this.baseUrl}${e}`, o = await fetch(t, {
26
+ setToken(e) {
27
+ this.token = e;
28
+ }
29
+ /** Derive browser origin (for relative URL resolution) */
30
+ getOrigin() {
31
+ return typeof window < "u" ? window.location.origin : "";
32
+ }
33
+ /** POST {origin}{tokenGateway}/v1/token — 获取 token + appId */
34
+ async fetchToken() {
35
+ const t = `${this.isAbsoluteGateway ? this.tokenGateway : `${this.getOrigin()}${this.tokenGateway}`}/v1/token`, n = await fetch(t, {
26
36
  method: "POST",
27
37
  headers: { "Content-Type": "application/json" },
28
- body: r ? JSON.stringify(r) : void 0
38
+ body: JSON.stringify({ botId: this.botId })
29
39
  });
30
- if (!o.ok)
31
- throw new Error(`HTTP ${o.status}: ${o.statusText}`);
32
- const n = await o.json();
33
- if (n.code !== "200")
34
- throw new Error(n.message || `API error: ${n.code}`);
35
- return h(n.data);
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;
36
47
  }
37
48
  headers(e) {
38
49
  return {
@@ -47,8 +58,7 @@ class g {
47
58
  return await this.refreshing, !0;
48
59
  try {
49
60
  return this.refreshing = (async () => {
50
- const e = await this.postPublic("/token", { botId: this.botId });
51
- this.appId = e.appId, this.token = e.token;
61
+ await this.fetchToken();
52
62
  })(), await this.refreshing, !0;
53
63
  } catch {
54
64
  return !1;
@@ -56,290 +66,338 @@ class g {
56
66
  this.refreshing = null;
57
67
  }
58
68
  }
59
- async request(e, r, t) {
60
- if ((!this.appId || !this.token) && !await this.handleTokenRefresh())
69
+ async request(e, t, n) {
70
+ if (!this.token && !await this.handleTokenRefresh())
61
71
  throw new Error("SDK token not available: POST /token failed");
62
- let o = `${this.baseUrl}${r}`;
63
- if (t != null && t.params) {
64
- const c = new URLSearchParams();
65
- for (const [l, d] of Object.entries(t.params))
66
- d != null && c.set(l, String(d));
67
- const i = c.toString();
68
- i && (o += `?${i}`);
72
+ let o = this.isAbsoluteUrl ? `${this.baseUrl}${t}` : `${this.getOrigin()}${this.baseUrl}${t}`;
73
+ if (n != null && n.params) {
74
+ const i = new URLSearchParams();
75
+ for (const [l, d] of Object.entries(n.params))
76
+ d != null && i.set(l, String(d));
77
+ const c = i.toString();
78
+ c && (o += `?${c}`);
69
79
  }
70
- const n = await fetch(o, {
80
+ const r = await fetch(o, {
71
81
  method: e,
72
82
  headers: this.headers(),
73
- body: t != null && t.body ? JSON.stringify(t.body) : void 0
83
+ body: n != null && n.body ? JSON.stringify(n.body) : void 0
74
84
  });
75
- if (n.status === 401 && !(t != null && t.retry) && await this.handleTokenRefresh())
76
- return this.request(e, r, { ...t, retry: !0 });
77
- if (!n.ok)
78
- throw new Error(`HTTP ${n.status}: ${n.statusText}`);
79
- const a = await n.json();
80
- if (a.code !== "200")
81
- throw new Error(a.message || `API error: ${a.code}`);
82
- return h(a.data);
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);
83
93
  }
84
- get(e, r) {
85
- return this.request("GET", e, { params: r });
94
+ get(e, t) {
95
+ return this.request("GET", e, { params: t });
86
96
  }
87
- post(e, r) {
88
- return this.request("POST", e, { body: r });
97
+ post(e, t) {
98
+ return this.request("POST", e, { body: t });
89
99
  }
90
- patch(e, r) {
91
- return this.request("PATCH", e, { body: r });
100
+ patch(e, t) {
101
+ return this.request("PATCH", e, { body: t });
92
102
  }
93
103
  del(e) {
94
104
  return this.request("DELETE", e);
95
105
  }
96
106
  /** For SSE streaming — returns raw Response (no envelope unwrap) */
97
- async streamPost(e, r, t) {
98
- if ((!this.appId || !this.token) && !await this.handleTokenRefresh())
107
+ async streamPost(e, t, n) {
108
+ if (!this.token && !await this.handleTokenRefresh())
99
109
  throw new Error("SDK token not available: POST /token failed");
100
- const o = `${this.baseUrl}${e}`, n = await fetch(o, {
110
+ const o = this.isAbsoluteUrl ? `${this.baseUrl}${e}` : `${this.getOrigin()}${this.baseUrl}${e}`, r = await fetch(o, {
101
111
  method: "POST",
102
112
  headers: this.headers(),
103
- body: JSON.stringify(r),
104
- signal: t
113
+ body: JSON.stringify(t),
114
+ signal: n
105
115
  });
106
- return n.status === 401 && await this.handleTokenRefresh() ? fetch(o, {
116
+ return r.status === 401 && await this.handleTokenRefresh() ? fetch(o, {
107
117
  method: "POST",
108
118
  headers: this.headers(),
109
- body: JSON.stringify(r),
110
- signal: t
111
- }) : n;
119
+ body: JSON.stringify(t),
120
+ signal: n
121
+ }) : r;
112
122
  }
113
123
  }
114
- function f(s) {
115
- const e = s.split(`
116
- `).map((t) => t.trim()).filter((t) => t.startsWith("data:")).map((t) => t.slice(5).trim());
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());
117
127
  if (!e.length) return null;
118
- let r;
128
+ let t;
119
129
  try {
120
- r = JSON.parse(e.join(`
130
+ t = JSON.parse(e.join(`
121
131
  `));
122
132
  } catch {
123
133
  return null;
124
134
  }
125
- switch (r.type) {
135
+ switch (t.type) {
126
136
  case "user":
127
- return { type: "user", content: r.content ?? "" };
137
+ return { type: "user", content: t.content ?? "" };
128
138
  case "thinking":
129
- return { type: "thinking", content: r.content ?? "" };
139
+ return { type: "thinking", content: t.content ?? "" };
130
140
  case "ai":
131
- return { type: "ai", content: r.content ?? "" };
141
+ return { type: "ai", content: t.content ?? "" };
132
142
  case "tool_call":
133
143
  return {
134
144
  type: "tool_call",
135
- content: r.name ?? "",
136
- toolName: r.name,
137
- toolCallId: r.id,
138
- args: typeof r.args == "string" ? r.args : JSON.stringify(r.args ?? {})
145
+ content: t.name ?? "",
146
+ toolName: t.name,
147
+ toolCallId: t.id,
148
+ args: typeof t.args == "string" ? t.args : JSON.stringify(t.args ?? {})
139
149
  };
140
150
  case "tool_result":
141
151
  return {
142
152
  type: "tool_result",
143
- content: r.output ?? "",
144
- toolName: r.name,
145
- toolCallId: r.id
153
+ content: t.output ?? "",
154
+ toolName: t.name,
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
146
161
  };
147
162
  case "done":
148
163
  return {
149
164
  type: "done",
150
- content: r.content ?? "",
151
- // 后端 SSE 返回 session_id (snake_case),此处统一映射为 sessionId
152
- sessionId: r.sessionId ?? r.session_id ?? ""
165
+ content: t.content ?? "",
166
+ sessionId: t.sessionId ?? t.session_id ?? "",
167
+ messageId: t.messageId ?? t.message_id
153
168
  };
154
169
  case "error":
155
- return { type: "error", content: r.message ?? "Unknown error" };
170
+ return { type: "error", content: t.message ?? "Unknown error" };
171
+ case "interrupt":
172
+ return {
173
+ type: "interrupt",
174
+ content: t.content ?? "",
175
+ interrupt: {
176
+ interruptId: t.interruptId ?? t.interrupt_id ?? "",
177
+ interruptType: t.interruptType ?? t.interrupt_type ?? "confirm",
178
+ content: t.content ?? "",
179
+ options: t.options,
180
+ placeholder: t.placeholder,
181
+ inputType: t.inputType ?? t.input_type,
182
+ maxLength: t.maxLength ?? t.max_length,
183
+ required: t.required,
184
+ fields: t.fields,
185
+ metadata: t.metadata
186
+ }
187
+ };
156
188
  default:
157
189
  return null;
158
190
  }
159
191
  }
160
- async function y(s, e, r) {
161
- if (!s.body) {
162
- r(new Error("Response body is null"));
192
+ async function m(a, e, t) {
193
+ if (!a.body) {
194
+ t(new Error("Response body is null"));
163
195
  return;
164
196
  }
165
- const t = s.body.getReader(), o = new TextDecoder();
166
- let n = "";
197
+ const n = a.body.getReader(), o = new TextDecoder();
198
+ let r = "";
167
199
  try {
168
200
  for (; ; ) {
169
- const { value: a, done: c } = await t.read();
170
- if (c) break;
171
- n += o.decode(a, { stream: !0 });
172
- let i;
173
- for (; (i = n.indexOf(`
201
+ const { value: s, done: i } = await n.read();
202
+ if (i) break;
203
+ r += o.decode(s, { stream: !0 });
204
+ let c;
205
+ for (; (c = r.indexOf(`
174
206
 
175
207
  `)) !== -1; ) {
176
- const l = n.slice(0, i);
177
- n = n.slice(i + 2);
178
- const d = f(l);
208
+ const l = r.slice(0, c);
209
+ r = r.slice(c + 2);
210
+ const d = y(l);
179
211
  d && e(d);
180
212
  }
181
213
  }
182
- if (n.trim()) {
183
- const a = f(n);
184
- a && e(a);
214
+ if (r.trim()) {
215
+ const s = y(r);
216
+ s && e(s);
185
217
  }
186
- } catch (a) {
187
- (a == null ? void 0 : a.name) !== "AbortError" && r(a instanceof Error ? a : new Error(String(a)));
218
+ } catch (s) {
219
+ (s == null ? void 0 : s.name) !== "AbortError" && t(s instanceof Error ? s : new Error(String(s)));
188
220
  } finally {
189
221
  try {
190
- t.releaseLock();
222
+ n.releaseLock();
191
223
  } catch {
192
224
  }
193
225
  }
194
226
  }
195
- function m(s, e) {
196
- const r = new AbortController(), t = e.signal ? I(e.signal, r.signal) : r.signal, o = {
197
- botId: s.getBotId(),
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(),
198
230
  message: e.message,
199
231
  sessionId: e.sessionId,
200
232
  stream: e.stream !== !1
201
233
  };
202
- return o.stream ? s.streamPost("/chat", o, t).then((n) => {
203
- var a;
204
- if (!n.ok) {
205
- (a = e.onError) == null || a.call(e, new Error(`HTTP ${n.status}`));
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}`));
206
238
  return;
207
239
  }
208
- return y(
209
- n,
210
- (c) => {
211
- var i, l, d, u;
212
- c.type === "done" && c.sessionId ? (i = e.onDone) == null || i.call(e, { sessionId: c.sessionId, content: c.content }) : c.type === "done" ? (l = e.onDone) == null || l.call(e, { sessionId: "", content: c.content }) : c.type === "error" ? (d = e.onError) == null || d.call(e, new Error(c.content)) : (u = e.onMessage) == null || u.call(e, c);
240
+ return m(
241
+ r,
242
+ (i) => {
243
+ var c, l, d, h;
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);
213
245
  },
214
- (c) => {
215
- var i;
216
- return (i = e.onError) == null ? void 0 : i.call(e, c);
246
+ (i) => {
247
+ var c;
248
+ return (c = e.onError) == null ? void 0 : c.call(e, i);
217
249
  }
218
250
  );
219
- }).catch((n) => {
220
- var a;
221
- (n == null ? void 0 : n.name) !== "AbortError" && ((a = e.onError) == null || a.call(e, n instanceof Error ? n : new Error(String(n))));
222
- }) : s.post("/chat", o).then((n) => {
223
- var a;
224
- (a = e.onDone) == null || a.call(e, {
225
- sessionId: n.sessionId,
226
- content: n.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 ?? ""
227
259
  });
228
- }).catch((n) => {
229
- var a;
230
- (a = e.onError) == null || a.call(e, n instanceof Error ? n : new Error(String(n)));
231
- }), r;
260
+ }).catch((r) => {
261
+ var s;
262
+ (s = e.onError) == null || s.call(e, r instanceof Error ? r : new Error(String(r)));
263
+ }), t;
232
264
  }
233
- function I(s, e) {
234
- const r = new AbortController(), t = () => r.abort();
235
- return s.addEventListener("abort", t, { once: !0 }), e.addEventListener("abort", t, { once: !0 }), (s.aborted || e.aborted) && r.abort(), r.signal;
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;
236
268
  }
237
- async function w(s) {
238
- return (await s.post("/chat/sessions", {
239
- botId: s.getBotId()
269
+ async function T(a) {
270
+ return (await a.post("/chat/sessions", {
271
+ botId: a.getBotId()
240
272
  })).sessionId;
241
273
  }
242
- function b(s) {
274
+ function S(a) {
243
275
  return {
244
276
  // 后端返回 thread_id,toCamelCase 转为 threadId,映射为 sessionId
245
- sessionId: s.threadId ?? s.sessionId,
246
- botId: s.botId,
247
- title: s.title,
248
- createTime: s.createTime,
249
- updateTime: s.updateTime
277
+ sessionId: a.threadId ?? a.sessionId,
278
+ botId: a.botId,
279
+ title: a.title,
280
+ createTime: a.createTime,
281
+ updateTime: a.updateTime
250
282
  };
251
283
  }
252
- async function k(s, e) {
253
- const r = await s.get("/chat/conversations", {
254
- botId: s.getBotId(),
284
+ async function $(a, e) {
285
+ const t = await a.get("/chat/conversations", {
286
+ botId: a.getBotId(),
255
287
  page: (e == null ? void 0 : e.page) ?? 1,
256
288
  size: (e == null ? void 0 : e.size) ?? 20
257
289
  });
258
290
  return {
259
- ...r,
260
- items: r.items.map(b)
291
+ ...t,
292
+ items: t.items.map(S)
261
293
  };
262
294
  }
263
- async function T(s, e, r) {
264
- await s.patch(`/chat/conversations/${e}`, { title: r });
295
+ async function p(a, e, t) {
296
+ await a.patch(`/chat/conversations/${e}`, { title: t });
265
297
  }
266
- async function S(s, e) {
267
- await s.del(`/chat/conversations/${e}`);
298
+ async function A(a, e) {
299
+ await a.del(`/chat/conversations/${e}`);
268
300
  }
269
- async function E(s, e) {
270
- const r = await s.get(`/chat/conversations/${e}/messages`);
271
- return C(r);
301
+ async function C(a, e) {
302
+ const t = await a.get(`/chat/conversations/${e}/messages`);
303
+ return O(t);
272
304
  }
273
- function C(s) {
274
- const e = [], r = [...s].sort((t, o) => (t.seq ?? 0) - (o.seq ?? 0));
275
- for (const t of r) {
276
- const o = t.role;
277
- if (o === "system") continue;
278
- const n = t.messageId ?? `msg_${t.id}`, a = new Date(t.createTime ?? "").getTime() || Date.now();
279
- if (o === "human")
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")
280
313
  e.push({
281
- id: n,
314
+ id: c,
282
315
  role: "user",
283
- parts: [{ type: "text", content: t.content ?? "" }],
284
- timestamp: a
316
+ parts: [{ type: "text", content: s.content ?? "" }],
317
+ timestamp: l
285
318
  });
286
- else if (o === "ai") {
287
- const c = [];
288
- t.reasoning && c.push({ type: "thinking", content: t.reasoning }), t.content && c.push({ type: "text", content: t.content });
289
- const i = t.toolCalls;
290
- if (i && Array.isArray(i))
291
- for (const l of i) {
292
- let d;
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;
293
326
  try {
294
- d = typeof l.args == "string" ? l.args : JSON.stringify(l.args ?? {});
327
+ g = typeof u.args == "string" ? u.args : JSON.stringify(u.args ?? {});
295
328
  } catch {
296
- d = String(l.args ?? "{}");
329
+ g = String(u.args ?? "{}");
297
330
  }
298
- c.push({
331
+ d.push({
299
332
  type: "tool_call",
300
- toolName: l.name ?? "",
301
- toolCallId: l.id ?? "",
302
- args: d
333
+ toolName: u.name ?? "",
334
+ toolCallId: u.id ?? "",
335
+ args: g
303
336
  });
304
337
  }
305
- e.push({ id: n, role: "assistant", parts: c, timestamp: a });
306
- } else o === "tool" && e.push({
307
- id: n,
308
- role: "assistant",
309
- parts: [{
310
- type: "tool_result",
311
- toolName: t.toolName ?? "",
312
- toolCallId: t.toolCallId ?? "",
313
- content: t.content ?? ""
314
- }],
315
- timestamp: a
316
- });
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
+ }
317
356
  }
318
357
  return e;
319
358
  }
320
- function $(s) {
321
- const e = new g(s), r = {
322
- getToken: async () => {
323
- const t = await e.postPublic(
324
- "/token",
325
- { botId: e.getBotId() }
326
- );
327
- return e.setToken(t.appId, t.token), t;
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
+ );
379
+ }
380
+ function E(a) {
381
+ const e = new I(a);
382
+ return {
383
+ getToken: () => e.fetchToken(),
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);
328
395
  },
329
- createSession: () => w(e),
330
- chat: (t) => m(e, t),
331
- listConversations: (t) => k(e, t),
332
- renameConversation: (t, o) => T(e, t, o),
333
- deleteConversation: (t) => S(e, t),
334
- getMessages: (t) => E(e, t),
335
- setToken: (t, o) => e.setToken(t, o),
336
- feedback: (t, o) => {
337
- var n;
338
- (n = r.onFeedback) == null || n.call(r, t, o);
396
+ cancelFeedback: async (n) => {
397
+ await e.del(`/chat/messages/${n}/feedback`);
339
398
  }
340
399
  };
341
- return r;
342
400
  }
343
401
  export {
344
- $ as createSuperAgent
402
+ E as createSuperAgent
345
403
  };