@agents24/node 0.5.16 → 0.5.18
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 +91 -39
- 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 +91 -39
- 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 +24 -12
- 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 +25 -13
- 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
|
@@ -161,12 +161,20 @@ var Agents24HttpClient = class {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
|
-
async function consumePayloads(response, onPayload, signal) {
|
|
164
|
+
async function consumePayloads(response, onPayload, signal, onControl) {
|
|
165
165
|
if (!response.body) {
|
|
166
166
|
throw new Agents24SDKError("Stream response did not include a readable body.", { kind: "protocol" });
|
|
167
167
|
}
|
|
168
168
|
const reader = response.body.getReader();
|
|
169
|
-
const parser = protocol.createSseParser({
|
|
169
|
+
const parser = protocol.createSseParser({
|
|
170
|
+
decoder: new TextDecoder(),
|
|
171
|
+
onPayload,
|
|
172
|
+
signal,
|
|
173
|
+
onComment: async (comment) => {
|
|
174
|
+
const control = protocol.parseObservationControl(comment);
|
|
175
|
+
if (control) await onControl?.(control);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
170
178
|
const abort = () => {
|
|
171
179
|
void reader.cancel(signal?.reason).catch(() => void 0);
|
|
172
180
|
};
|
|
@@ -184,16 +192,16 @@ async function consumePayloads(response, onPayload, signal) {
|
|
|
184
192
|
reader.releaseLock();
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
|
-
async function consumeRuntimeEventStream(response, onEvent, signal) {
|
|
195
|
+
async function consumeRuntimeEventStream(response, onEvent, signal, onControl) {
|
|
188
196
|
await consumePayloads(response, async (payload) => {
|
|
189
197
|
const event = protocol.parseRuntimeSsePayload(payload);
|
|
190
198
|
if (onEvent) await onEvent(event);
|
|
191
|
-
}, signal);
|
|
199
|
+
}, signal, onControl);
|
|
192
200
|
}
|
|
193
|
-
async function consumeThreadSummaryEventStream(response, onEvent, signal) {
|
|
201
|
+
async function consumeThreadSummaryEventStream(response, onEvent, signal, onControl) {
|
|
194
202
|
await consumePayloads(response, async (payload) => {
|
|
195
203
|
await onEvent(protocol.parseThreadSummarySsePayload(payload));
|
|
196
|
-
}, signal);
|
|
204
|
+
}, signal, onControl);
|
|
197
205
|
}
|
|
198
206
|
|
|
199
207
|
// src/agents.ts
|
|
@@ -281,7 +289,7 @@ var AgentsNamespace = class {
|
|
|
281
289
|
});
|
|
282
290
|
}
|
|
283
291
|
async stream(agentId, payload, onEvent, mode, options = {}) {
|
|
284
|
-
const response = await this.http.fetchOrThrow(this.http.url(`/agents/${agentId}/stream`, { mode }), {
|
|
292
|
+
const response = await this.http.fetchOrThrow(this.http.url(`/agents/${agentId}/stream`, { mode, stream_features: "assistant-completion-v1" }), {
|
|
285
293
|
method: "POST",
|
|
286
294
|
headers: this.http.streamHeaders(),
|
|
287
295
|
body: JSON.stringify(payload),
|
|
@@ -525,7 +533,7 @@ var EmbedNamespace = class {
|
|
|
525
533
|
return this.stream(`/public/embed/agents/${agentId}/runs/${runId}/stream`, payload, onEvent, options);
|
|
526
534
|
}
|
|
527
535
|
async stream(path, payload, onEvent, options) {
|
|
528
|
-
const response = await this.http.fetchOrThrow(this.http.url(path), {
|
|
536
|
+
const response = await this.http.fetchOrThrow(this.http.url(path, { stream_features: "assistant-completion-v1", lease_seconds: options.leaseSeconds }), {
|
|
529
537
|
method: "POST",
|
|
530
538
|
headers: this.http.streamHeaders(void 0, options, true),
|
|
531
539
|
body: JSON.stringify(payload),
|
|
@@ -600,10 +608,12 @@ var EmbedNamespace = class {
|
|
|
600
608
|
external_session_id: options.externalSessionId,
|
|
601
609
|
cursor: options.cursor,
|
|
602
610
|
runtime_target: options.runtimeTarget,
|
|
603
|
-
integration_id: options.integrationId
|
|
611
|
+
integration_id: options.integrationId,
|
|
612
|
+
thread_id: options.threadId,
|
|
613
|
+
lease_seconds: options.leaseSeconds
|
|
604
614
|
}), { method: "GET", headers: this.http.streamHeaders(), signal: options.signal }, "Failed to connect to the embedded-agent thread event endpoint.");
|
|
605
615
|
await assertOk(response);
|
|
606
|
-
await consumeThreadSummaryEventStream(response, onEvent, options.signal);
|
|
616
|
+
await consumeThreadSummaryEventStream(response, onEvent, options.signal, options.onControl);
|
|
607
617
|
}
|
|
608
618
|
async subscribeAgentThreadEventsMulti(options, onEvent) {
|
|
609
619
|
const response = await this.http.fetchOrThrow(this.http.url("/public/embed/threads/events", {
|
|
@@ -612,10 +622,12 @@ var EmbedNamespace = class {
|
|
|
612
622
|
external_session_id: options.externalSessionId,
|
|
613
623
|
cursor: options.cursor,
|
|
614
624
|
runtime_target: options.runtimeTarget,
|
|
615
|
-
integration_id: options.integrationId
|
|
625
|
+
integration_id: options.integrationId,
|
|
626
|
+
thread_id: options.threadId,
|
|
627
|
+
lease_seconds: options.leaseSeconds
|
|
616
628
|
}), { method: "GET", headers: this.http.streamHeaders(), signal: options.signal }, "Failed to connect to the embedded-agent thread event endpoint.");
|
|
617
629
|
await assertOk(response);
|
|
618
|
-
await consumeThreadSummaryEventStream(response, onEvent, options.signal);
|
|
630
|
+
await consumeThreadSummaryEventStream(response, onEvent, options.signal, options.onControl);
|
|
619
631
|
}
|
|
620
632
|
threadMessageQuery(scope) {
|
|
621
633
|
return {
|