dooers-agents-client 0.6.0 → 0.9.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/main.cjs +37 -9
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +16 -6
- package/dist/main.d.ts +16 -6
- package/dist/main.js +37 -9
- package/dist/main.js.map +1 -1
- package/package.json +9 -1
package/dist/main.cjs
CHANGED
|
@@ -49,6 +49,7 @@ function toThread(w) {
|
|
|
49
49
|
owner: toUser(w.owner),
|
|
50
50
|
users: w.users.map((u) => toUser(u)),
|
|
51
51
|
title: w.title,
|
|
52
|
+
metadata: w.metadata ?? null,
|
|
52
53
|
createdAt: w.created_at,
|
|
53
54
|
updatedAt: w.updated_at,
|
|
54
55
|
lastEventAt: w.last_event_at
|
|
@@ -239,12 +240,31 @@ function toWireContentPart(p) {
|
|
|
239
240
|
switch (p.type) {
|
|
240
241
|
case "text":
|
|
241
242
|
return { type: "text", text: p.text };
|
|
242
|
-
case "audio":
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
case "audio": {
|
|
244
|
+
const w = {
|
|
245
|
+
type: "audio",
|
|
246
|
+
ref_id: p.refId
|
|
247
|
+
};
|
|
248
|
+
if (p.duration != null) w.duration = p.duration;
|
|
249
|
+
if (p.url) w.url = p.url;
|
|
250
|
+
return w;
|
|
251
|
+
}
|
|
252
|
+
case "image": {
|
|
253
|
+
const w = {
|
|
254
|
+
type: "image",
|
|
255
|
+
ref_id: p.refId
|
|
256
|
+
};
|
|
257
|
+
if (p.url) w.url = p.url;
|
|
258
|
+
return w;
|
|
259
|
+
}
|
|
260
|
+
case "document": {
|
|
261
|
+
const w = {
|
|
262
|
+
type: "document",
|
|
263
|
+
ref_id: p.refId
|
|
264
|
+
};
|
|
265
|
+
if (p.url) w.url = p.url;
|
|
266
|
+
return w;
|
|
267
|
+
}
|
|
248
268
|
}
|
|
249
269
|
}
|
|
250
270
|
|
|
@@ -383,6 +403,9 @@ var AgentClient = class {
|
|
|
383
403
|
}
|
|
384
404
|
const formData = new FormData();
|
|
385
405
|
formData.append("file", file);
|
|
406
|
+
if (this.agentId) {
|
|
407
|
+
formData.append("agent_id", this.agentId);
|
|
408
|
+
}
|
|
386
409
|
const headers = {};
|
|
387
410
|
if (this.config.authToken) {
|
|
388
411
|
headers.Authorization = `Bearer ${this.config.authToken}`;
|
|
@@ -400,7 +423,8 @@ var AgentClient = class {
|
|
|
400
423
|
refId: result.ref_id,
|
|
401
424
|
mimeType: result.mime_type,
|
|
402
425
|
filename: result.filename,
|
|
403
|
-
sizeBytes: result.size_bytes
|
|
426
|
+
sizeBytes: result.size_bytes ?? result.size ?? 0,
|
|
427
|
+
publicUrl: result.public_url ?? void 0
|
|
404
428
|
};
|
|
405
429
|
}
|
|
406
430
|
connect(url, agentId, config) {
|
|
@@ -565,7 +589,7 @@ var AgentClient = class {
|
|
|
565
589
|
clientEventId
|
|
566
590
|
});
|
|
567
591
|
const promise = this.createPendingPromise(clientEventId);
|
|
568
|
-
|
|
592
|
+
const payload = {
|
|
569
593
|
thread_id: params.threadId,
|
|
570
594
|
client_event_id: clientEventId,
|
|
571
595
|
event: {
|
|
@@ -573,7 +597,11 @@ var AgentClient = class {
|
|
|
573
597
|
actor: "user",
|
|
574
598
|
content
|
|
575
599
|
}
|
|
576
|
-
}
|
|
600
|
+
};
|
|
601
|
+
if (params.metadata) {
|
|
602
|
+
payload.metadata = params.metadata;
|
|
603
|
+
}
|
|
604
|
+
this.send("event.create", payload);
|
|
577
605
|
return promise;
|
|
578
606
|
}
|
|
579
607
|
sendFormResponse(params) {
|