@agents24/node 0.5.17 → 0.5.19
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/compatibility.json +5 -5
- package/dist/bff.cjs +84 -38
- package/dist/bff.cjs.map +1 -1
- package/dist/bff.d.cts +1 -1
- package/dist/bff.d.ts +1 -1
- package/dist/bff.js +84 -38
- package/dist/bff.js.map +1 -1
- package/dist/{client-ChHref1j.d.cts → client-YEw6vRtg.d.cts} +6 -0
- package/dist/{client-ChHref1j.d.ts → client-YEw6vRtg.d.ts} +6 -0
- package/dist/index.cjs +25 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -15
- package/dist/index.js.map +1 -1
- package/dist/types/bff-sse.d.ts +3 -1
- package/dist/types/bff-sse.d.ts.map +1 -1
- package/dist/types/bff.d.ts.map +1 -1
- package/dist/types/embed.d.ts.map +1 -1
- package/dist/types/streams.d.ts +3 -3
- package/dist/types/streams.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _agents24_client_protocol from '@agents24/client/protocol';
|
|
1
2
|
import { ToolInputOverrides, ContextWindow, RuntimeEvent, ThreadMessagesPage, ThreadMessageSubmission, ThreadMessage, RunCancelResult, AttachmentUploadResult, AttachmentContentAccess, RunResumeResult, ThreadsResponse, ThreadSummaryEvent, ThreadDetail, ThreadDeleteResult, RunContext } from '@agents24/client/protocol';
|
|
2
3
|
|
|
3
4
|
type Agents24SDKErrorKind = "protocol" | "network" | "http";
|
|
@@ -137,6 +138,8 @@ type BackendSessionRequestOptions = RequestOptions & {
|
|
|
137
138
|
};
|
|
138
139
|
type StreamRequestOptions = RequestOptions & {
|
|
139
140
|
signal?: AbortSignal;
|
|
141
|
+
leaseSeconds?: number;
|
|
142
|
+
onControl?: (control: _agents24_client_protocol.ObservationControl) => void | Promise<void>;
|
|
140
143
|
};
|
|
141
144
|
type AgentStreamRequest = {
|
|
142
145
|
client_submission_id?: string;
|
|
@@ -370,6 +373,9 @@ type ThreadDeleteOptions = {
|
|
|
370
373
|
integrationId: string;
|
|
371
374
|
};
|
|
372
375
|
type ThreadSummaryEventOptions = {
|
|
376
|
+
threadId?: string;
|
|
377
|
+
leaseSeconds?: number;
|
|
378
|
+
onControl?: (control: _agents24_client_protocol.ObservationControl) => void | Promise<void>;
|
|
373
379
|
externalUserId: string;
|
|
374
380
|
externalSessionId?: string | null;
|
|
375
381
|
cursor?: number | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _agents24_client_protocol from '@agents24/client/protocol';
|
|
1
2
|
import { ToolInputOverrides, ContextWindow, RuntimeEvent, ThreadMessagesPage, ThreadMessageSubmission, ThreadMessage, RunCancelResult, AttachmentUploadResult, AttachmentContentAccess, RunResumeResult, ThreadsResponse, ThreadSummaryEvent, ThreadDetail, ThreadDeleteResult, RunContext } from '@agents24/client/protocol';
|
|
2
3
|
|
|
3
4
|
type Agents24SDKErrorKind = "protocol" | "network" | "http";
|
|
@@ -137,6 +138,8 @@ type BackendSessionRequestOptions = RequestOptions & {
|
|
|
137
138
|
};
|
|
138
139
|
type StreamRequestOptions = RequestOptions & {
|
|
139
140
|
signal?: AbortSignal;
|
|
141
|
+
leaseSeconds?: number;
|
|
142
|
+
onControl?: (control: _agents24_client_protocol.ObservationControl) => void | Promise<void>;
|
|
140
143
|
};
|
|
141
144
|
type AgentStreamRequest = {
|
|
142
145
|
client_submission_id?: string;
|
|
@@ -370,6 +373,9 @@ type ThreadDeleteOptions = {
|
|
|
370
373
|
integrationId: string;
|
|
371
374
|
};
|
|
372
375
|
type ThreadSummaryEventOptions = {
|
|
376
|
+
threadId?: string;
|
|
377
|
+
leaseSeconds?: number;
|
|
378
|
+
onControl?: (control: _agents24_client_protocol.ObservationControl) => void | Promise<void>;
|
|
373
379
|
externalUserId: string;
|
|
374
380
|
externalSessionId?: string | null;
|
|
375
381
|
cursor?: number | null;
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var crypto = require('crypto');
|
|
4
4
|
var protocol = require('@agents24/client/protocol');
|
|
5
|
+
var client = require('@agents24/client');
|
|
5
6
|
|
|
6
7
|
// src/http.ts
|
|
7
8
|
|
|
@@ -161,12 +162,20 @@ var Agents24HttpClient = class {
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
};
|
|
164
|
-
async function consumePayloads(response, onPayload, signal) {
|
|
165
|
+
async function consumePayloads(response, onPayload, signal, onControl) {
|
|
165
166
|
if (!response.body) {
|
|
166
167
|
throw new Agents24SDKError("Stream response did not include a readable body.", { kind: "protocol" });
|
|
167
168
|
}
|
|
168
169
|
const reader = response.body.getReader();
|
|
169
|
-
const parser = protocol.createSseParser({
|
|
170
|
+
const parser = protocol.createSseParser({
|
|
171
|
+
decoder: new TextDecoder(),
|
|
172
|
+
onPayload,
|
|
173
|
+
signal,
|
|
174
|
+
onComment: async (comment) => {
|
|
175
|
+
const control = protocol.parseObservationControl(comment);
|
|
176
|
+
if (control) await onControl?.(control);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
170
179
|
const abort = () => {
|
|
171
180
|
void reader.cancel(signal?.reason).catch(() => void 0);
|
|
172
181
|
};
|
|
@@ -184,16 +193,16 @@ async function consumePayloads(response, onPayload, signal) {
|
|
|
184
193
|
reader.releaseLock();
|
|
185
194
|
}
|
|
186
195
|
}
|
|
187
|
-
async function consumeRuntimeEventStream(response, onEvent, signal) {
|
|
196
|
+
async function consumeRuntimeEventStream(response, onEvent, signal, onControl) {
|
|
188
197
|
await consumePayloads(response, async (payload) => {
|
|
189
198
|
const event = protocol.parseRuntimeSsePayload(payload);
|
|
190
199
|
if (onEvent) await onEvent(event);
|
|
191
|
-
}, signal);
|
|
200
|
+
}, signal, onControl);
|
|
192
201
|
}
|
|
193
|
-
async function consumeThreadSummaryEventStream(response, onEvent, signal) {
|
|
202
|
+
async function consumeThreadSummaryEventStream(response, onEvent, signal, onControl) {
|
|
194
203
|
await consumePayloads(response, async (payload) => {
|
|
195
204
|
await onEvent(protocol.parseThreadSummarySsePayload(payload));
|
|
196
|
-
}, signal);
|
|
205
|
+
}, signal, onControl);
|
|
197
206
|
}
|
|
198
207
|
|
|
199
208
|
// src/agents.ts
|
|
@@ -503,8 +512,6 @@ var ClientSessionsNamespace = class {
|
|
|
503
512
|
);
|
|
504
513
|
}
|
|
505
514
|
};
|
|
506
|
-
|
|
507
|
-
// src/embed.ts
|
|
508
515
|
var EmbedNamespace = class {
|
|
509
516
|
constructor(http) {
|
|
510
517
|
this.http = http;
|
|
@@ -525,7 +532,7 @@ var EmbedNamespace = class {
|
|
|
525
532
|
return this.stream(`/public/embed/agents/${agentId}/runs/${runId}/stream`, payload, onEvent, options);
|
|
526
533
|
}
|
|
527
534
|
async stream(path, payload, onEvent, options) {
|
|
528
|
-
const response = await this.http.fetchOrThrow(this.http.url(path, { stream_features: "assistant-completion-v1" }), {
|
|
535
|
+
const response = await this.http.fetchOrThrow(this.http.url(path, { stream_features: "assistant-completion-v1", lease_seconds: options.leaseSeconds }), {
|
|
529
536
|
method: "POST",
|
|
530
537
|
headers: this.http.streamHeaders(void 0, options, true),
|
|
531
538
|
body: JSON.stringify(payload),
|
|
@@ -600,10 +607,12 @@ var EmbedNamespace = class {
|
|
|
600
607
|
external_session_id: options.externalSessionId,
|
|
601
608
|
cursor: options.cursor,
|
|
602
609
|
runtime_target: options.runtimeTarget,
|
|
603
|
-
integration_id: options.integrationId
|
|
610
|
+
integration_id: options.integrationId,
|
|
611
|
+
thread_id: options.threadId,
|
|
612
|
+
lease_seconds: options.leaseSeconds
|
|
604
613
|
}), { method: "GET", headers: this.http.streamHeaders(), signal: options.signal }, "Failed to connect to the embedded-agent thread event endpoint.");
|
|
605
614
|
await assertOk(response);
|
|
606
|
-
await consumeThreadSummaryEventStream(response, onEvent, options.signal);
|
|
615
|
+
await consumeThreadSummaryEventStream(response, onEvent, options.signal, options.onControl);
|
|
607
616
|
}
|
|
608
617
|
async subscribeAgentThreadEventsMulti(options, onEvent) {
|
|
609
618
|
const response = await this.http.fetchOrThrow(this.http.url("/public/embed/threads/events", {
|
|
@@ -612,10 +621,12 @@ var EmbedNamespace = class {
|
|
|
612
621
|
external_session_id: options.externalSessionId,
|
|
613
622
|
cursor: options.cursor,
|
|
614
623
|
runtime_target: options.runtimeTarget,
|
|
615
|
-
integration_id: options.integrationId
|
|
624
|
+
integration_id: options.integrationId,
|
|
625
|
+
thread_id: options.threadId,
|
|
626
|
+
lease_seconds: options.leaseSeconds
|
|
616
627
|
}), { method: "GET", headers: this.http.streamHeaders(), signal: options.signal }, "Failed to connect to the embedded-agent thread event endpoint.");
|
|
617
628
|
await assertOk(response);
|
|
618
|
-
await consumeThreadSummaryEventStream(response, onEvent, options.signal);
|
|
629
|
+
await consumeThreadSummaryEventStream(response, onEvent, options.signal, options.onControl);
|
|
619
630
|
}
|
|
620
631
|
threadMessageQuery(scope) {
|
|
621
632
|
return {
|
|
@@ -836,7 +847,7 @@ var EmbedNamespace = class {
|
|
|
836
847
|
if (options.threadId) form.set("thread_id", options.threadId);
|
|
837
848
|
if (options.runtimeTarget) form.set("runtime_target", options.runtimeTarget);
|
|
838
849
|
if (options.integrationId) form.set("integration_id", options.integrationId);
|
|
839
|
-
for (const file of options.files) form.append("files", file, file.name);
|
|
850
|
+
for (const file of options.files) form.append("files", file.slice(0, file.size, client.normalizeAttachmentMimeType(file.type, file.name)), file.name);
|
|
840
851
|
const response = await this.http.fetchOrThrow(this.http.url(`/public/embed/agents/${agentId}/attachments/upload`), {
|
|
841
852
|
method: "POST",
|
|
842
853
|
headers: this.http.multipartHeaders(void 0, { idempotencyKey: options.idempotencyKey }, true),
|