@blazingagents/sdk 0.31.0 → 0.33.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/README.md +3 -0
- package/dist/chat-transport.js +1 -3
- package/dist/client.d.ts +1 -1
- package/dist/client.js +25 -25
- package/dist/contracts/entities/chat-connections.d.ts +51 -0
- package/dist/contracts/entities/chat-connections.js +24 -0
- package/dist/contracts/entities/chat.d.ts +2 -0
- package/dist/contracts/entities/mcp-connections.d.ts +0 -4
- package/dist/contracts/entities/mcp-connections.js +0 -16
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +2 -2
- package/dist/direct-chat-transport.js +28 -40
- package/dist/errors.js +0 -2
- package/dist/functions.js +2 -2
- package/dist/generation.d.ts +1 -2
- package/dist/generation.js +45 -79
- package/dist/http.d.ts +5 -10
- package/dist/http.js +8 -1
- package/dist/index.d.ts +2 -2
- package/dist/resources/agents.js +12 -12
- package/dist/resources/artifacts.js +4 -4
- package/dist/resources/chat-connections.js +21 -9
- package/dist/resources/mcp-connections.js +7 -13
- package/dist/resources/memories.js +6 -6
- package/dist/resources/merchant-bindings.js +3 -3
- package/dist/resources/merchant-usage-events.js +5 -5
- package/dist/resources/prompts.js +4 -4
- package/dist/resources/providers.js +6 -6
- package/dist/resources/sessions.js +13 -17
- package/dist/resources/skills.js +9 -8
- package/dist/resources/tasks.js +10 -11
- package/dist/resources/usage.js +2 -2
- package/dist/resources/workspaces.js +4 -4
- package/dist/types.d.ts +31 -11
- package/package.json +2 -2
package/dist/generation.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createTextStreamResponse, parsePartialJson } from "ai";
|
|
|
2
2
|
import { sessionIdSchema, turnIdSchema } from "./contracts/ids.js";
|
|
3
3
|
import { BlazingAgentsError } from "./errors.js";
|
|
4
4
|
import { dispatchChatFunctions, toChatFunctionDefinitions, } from "./functions.js";
|
|
5
|
-
import { requestStream } from "./http.js";
|
|
5
|
+
import { apiPath, requestStream } from "./http.js";
|
|
6
6
|
/**
|
|
7
7
|
* Creates or resumes a Session and returns its SSE stream and Session ID.
|
|
8
8
|
* @param config - Authentication, base URL, and transport configuration.
|
|
@@ -21,8 +21,8 @@ export async function chat(config, input) {
|
|
|
21
21
|
* (`POST /v1/agents/:agentId/sessions/:sessionId`).
|
|
22
22
|
*/
|
|
23
23
|
const path = input.sessionId === undefined
|
|
24
|
-
? `/v1/agents/${input.agentId}/sessions`
|
|
25
|
-
: `/v1/agents/${input.agentId}/sessions/${input.sessionId}`;
|
|
24
|
+
? apiPath `/v1/agents/${input.agentId}/sessions`
|
|
25
|
+
: apiPath `/v1/agents/${input.agentId}/sessions/${input.sessionId}`;
|
|
26
26
|
const response = await requestStream(config, path, {
|
|
27
27
|
json: body,
|
|
28
28
|
method: "POST",
|
|
@@ -42,7 +42,7 @@ export async function chat(config, input) {
|
|
|
42
42
|
* @returns The Session ID promise and continuation SSE accessors.
|
|
43
43
|
*/
|
|
44
44
|
export async function continueChat(config, input) {
|
|
45
|
-
const response = await requestStream(config, `/v1/agents/${input.agentId}/sessions/${input.sessionId}/tool-approvals/continue`, {
|
|
45
|
+
const response = await requestStream(config, apiPath `/v1/agents/${input.agentId}/sessions/${input.sessionId}/tool-approvals/continue`, {
|
|
46
46
|
json: {
|
|
47
47
|
decisions: input.decisions,
|
|
48
48
|
...(input.functions === undefined
|
|
@@ -79,37 +79,23 @@ export function withFilteredBody(response, filter) {
|
|
|
79
79
|
* Builds a chat request body from messages or a stored Prompt.
|
|
80
80
|
*/
|
|
81
81
|
function buildChatBody(input) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
// Stryker disable next-line ConditionalExpression: JSON serialization omits an undefined message id.
|
|
88
|
-
if (input.messageId !== undefined) {
|
|
89
|
-
base.messageId = input.messageId;
|
|
90
|
-
}
|
|
82
|
+
const body = {
|
|
83
|
+
trigger: input.trigger,
|
|
84
|
+
messageId: input.messageId,
|
|
85
|
+
};
|
|
91
86
|
if ("message" in input) {
|
|
92
|
-
|
|
87
|
+
body.messages = [input.message];
|
|
93
88
|
}
|
|
94
89
|
else if ("messages" in input) {
|
|
95
|
-
|
|
90
|
+
body.messages = input.messages;
|
|
96
91
|
}
|
|
97
92
|
else {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (input.variables !== undefined) {
|
|
101
|
-
base.variables = input.variables;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// Stryker disable next-line ConditionalExpression: JSON serialization omits an undefined user id.
|
|
105
|
-
if (input.userId !== undefined) {
|
|
106
|
-
base.userId = input.userId;
|
|
107
|
-
}
|
|
108
|
-
// Stryker disable next-line ConditionalExpression: JSON serialization omits undefined metadata.
|
|
109
|
-
if (input.metadata !== undefined) {
|
|
110
|
-
base.metadata = input.metadata;
|
|
93
|
+
body.promptId = input.promptId;
|
|
94
|
+
body.variables = input.variables;
|
|
111
95
|
}
|
|
112
|
-
|
|
96
|
+
body.userId = input.userId;
|
|
97
|
+
body.metadata = input.metadata;
|
|
98
|
+
return body;
|
|
113
99
|
}
|
|
114
100
|
/**
|
|
115
101
|
* Extracts the server-minted `ss_` id from the `Location` header on the
|
|
@@ -190,9 +176,8 @@ function buildChatResult(config, response, resumeSessionId, dispatch) {
|
|
|
190
176
|
* Creates single-owner SSE response and byte-stream accessors.
|
|
191
177
|
* @param response - Upstream HTTP response.
|
|
192
178
|
* @param resourceName - Resource label used in stream errors.
|
|
193
|
-
* @param filter - Transforms upstream SSE bytes before exposing them to the caller.
|
|
194
179
|
*/
|
|
195
|
-
export function buildTerminalStreamResult(response, resourceName
|
|
180
|
+
export function buildTerminalStreamResult(response, resourceName) {
|
|
196
181
|
const requestId = response.headers.get("x-request-id") ?? undefined;
|
|
197
182
|
const location = response.headers.get("location");
|
|
198
183
|
const turnId = response.headers.get("x-ba-turn-id");
|
|
@@ -203,17 +188,11 @@ export function buildTerminalStreamResult(response, resourceName, filter) {
|
|
|
203
188
|
*/
|
|
204
189
|
const claimBody = () => {
|
|
205
190
|
if (bodyClaimed) {
|
|
206
|
-
|
|
207
|
-
const cause = new Error(message);
|
|
208
|
-
throw new BlazingAgentsError({
|
|
209
|
-
code: "stream_error",
|
|
210
|
-
message,
|
|
211
|
-
requestId,
|
|
212
|
-
}, { cause });
|
|
191
|
+
throw alreadyClaimedError(resourceName, requestId);
|
|
213
192
|
}
|
|
214
193
|
bodyClaimed = true;
|
|
215
194
|
const body = responseBodyStream(response, requestId, resourceName);
|
|
216
|
-
return normalizeStreamErrors(
|
|
195
|
+
return normalizeStreamErrors(body, requestId, `The ${resourceName} response stream failed.`);
|
|
217
196
|
};
|
|
218
197
|
return {
|
|
219
198
|
requestId,
|
|
@@ -239,6 +218,25 @@ export function buildTerminalStreamResult(response, resourceName, filter) {
|
|
|
239
218
|
},
|
|
240
219
|
};
|
|
241
220
|
}
|
|
221
|
+
function alreadyClaimedError(resourceName, requestId) {
|
|
222
|
+
const message = `The ${resourceName} response body has already been claimed.`;
|
|
223
|
+
return new BlazingAgentsError({ code: "stream_error", message, requestId }, { cause: new Error(message) });
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Parses the complete generated text, reporting malformed JSON as a stream error.
|
|
227
|
+
*/
|
|
228
|
+
function parseFinalJson(text, requestId) {
|
|
229
|
+
try {
|
|
230
|
+
return JSON.parse(text);
|
|
231
|
+
}
|
|
232
|
+
catch (cause) {
|
|
233
|
+
throw new BlazingAgentsError({
|
|
234
|
+
code: "stream_error",
|
|
235
|
+
message: "The agent produced invalid JSON.",
|
|
236
|
+
requestId,
|
|
237
|
+
}, { cause });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
242
240
|
/**
|
|
243
241
|
* Preserves a matching stream error or wraps a failure with request correlation.
|
|
244
242
|
*/
|
|
@@ -354,19 +352,10 @@ function buildStatelessGenerationBody(input, output) {
|
|
|
354
352
|
}
|
|
355
353
|
else {
|
|
356
354
|
body.promptId = input.promptId;
|
|
357
|
-
|
|
358
|
-
if (input.variables !== undefined) {
|
|
359
|
-
body.variables = input.variables;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
// Stryker disable next-line ConditionalExpression: JSON serialization omits an undefined user id.
|
|
363
|
-
if (input.userId !== undefined) {
|
|
364
|
-
body.userId = input.userId;
|
|
365
|
-
}
|
|
366
|
-
// Stryker disable next-line ConditionalExpression: JSON serialization omits undefined metadata.
|
|
367
|
-
if (input.metadata !== undefined) {
|
|
368
|
-
body.metadata = input.metadata;
|
|
355
|
+
body.variables = input.variables;
|
|
369
356
|
}
|
|
357
|
+
body.userId = input.userId;
|
|
358
|
+
body.metadata = input.metadata;
|
|
370
359
|
return body;
|
|
371
360
|
}
|
|
372
361
|
/**
|
|
@@ -377,7 +366,7 @@ function buildStatelessGenerationBody(input, output) {
|
|
|
377
366
|
*/
|
|
378
367
|
export async function completion(config, input) {
|
|
379
368
|
const body = buildStatelessGenerationBody(input, { type: "text" });
|
|
380
|
-
const path = `/v1/agents/${input.agentId}/generation`;
|
|
369
|
+
const path = apiPath `/v1/agents/${input.agentId}/generation`;
|
|
381
370
|
const response = await requestStream(config, path, {
|
|
382
371
|
json: body,
|
|
383
372
|
method: "POST",
|
|
@@ -419,7 +408,7 @@ export async function objectGeneration(config, input) {
|
|
|
419
408
|
type: "object",
|
|
420
409
|
schema: input.schema,
|
|
421
410
|
});
|
|
422
|
-
const path = `/v1/agents/${input.agentId}/generation`;
|
|
411
|
+
const path = apiPath `/v1/agents/${input.agentId}/generation`;
|
|
423
412
|
const response = await requestStream(config, path, {
|
|
424
413
|
json: body,
|
|
425
414
|
method: "POST",
|
|
@@ -449,16 +438,7 @@ function buildObjectResult(response) {
|
|
|
449
438
|
* Rejects malformed final JSON when the text stream ends.
|
|
450
439
|
*/
|
|
451
440
|
flush() {
|
|
452
|
-
|
|
453
|
-
JSON.parse(accumulatedText);
|
|
454
|
-
}
|
|
455
|
-
catch (cause) {
|
|
456
|
-
throw new BlazingAgentsError({
|
|
457
|
-
code: "stream_error",
|
|
458
|
-
message: "The agent produced invalid JSON.",
|
|
459
|
-
requestId,
|
|
460
|
-
}, { cause });
|
|
461
|
-
}
|
|
441
|
+
parseFinalJson(accumulatedText, requestId);
|
|
462
442
|
},
|
|
463
443
|
}));
|
|
464
444
|
const objectPromise = (async () => {
|
|
@@ -466,16 +446,7 @@ function buildObjectResult(response) {
|
|
|
466
446
|
for await (const delta of finalStream) {
|
|
467
447
|
text += delta;
|
|
468
448
|
}
|
|
469
|
-
|
|
470
|
-
return JSON.parse(text);
|
|
471
|
-
}
|
|
472
|
-
catch (cause) {
|
|
473
|
-
throw new BlazingAgentsError({
|
|
474
|
-
code: "stream_error",
|
|
475
|
-
message: "The agent produced invalid JSON.",
|
|
476
|
-
requestId,
|
|
477
|
-
}, { cause });
|
|
478
|
-
}
|
|
449
|
+
return parseFinalJson(text, requestId);
|
|
479
450
|
})();
|
|
480
451
|
objectPromise.catch(() => {
|
|
481
452
|
/* no-op — prevents unhandled rejection if the caller never awaits */
|
|
@@ -509,12 +480,7 @@ function buildStatelessGenerationStreams(response, resourceName) {
|
|
|
509
480
|
/** Claims the response relay once. */
|
|
510
481
|
toResponse: () => {
|
|
511
482
|
if (responseBodyClaimed) {
|
|
512
|
-
|
|
513
|
-
throw new BlazingAgentsError({
|
|
514
|
-
code: "stream_error",
|
|
515
|
-
message,
|
|
516
|
-
requestId,
|
|
517
|
-
}, { cause: new Error(message) });
|
|
483
|
+
throw alreadyClaimedError(resourceName, requestId);
|
|
518
484
|
}
|
|
519
485
|
responseBodyClaimed = true;
|
|
520
486
|
const headers = replacementResponseHeaders(requestId, location, null);
|
package/dist/http.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { BlazingAgentsError } from "./errors.ts";
|
|
2
2
|
import type { HttpConfig, RequestOptions } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Builds an endpoint path, encoding each interpolated value so it stays inside
|
|
5
|
+
* one path segment or query value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function apiPath(template: TemplateStringsArray, ...values: string[]): string;
|
|
3
8
|
/**
|
|
4
9
|
* Performs a request and returns the parsed JSON body for success (status
|
|
5
10
|
* 2xx). API errors preserve the tolerant wire envelope; malformed responses
|
|
@@ -37,13 +42,3 @@ export declare function isRequestAborted(cause: unknown, signal?: AbortSignal):
|
|
|
37
42
|
* @returns A request_aborted error retaining the cause.
|
|
38
43
|
*/
|
|
39
44
|
export declare function requestAbortedError(cause: unknown): BlazingAgentsError;
|
|
40
|
-
/**
|
|
41
|
-
* Decodes a response body with the tolerant consumer schema. Unknown future
|
|
42
|
-
* codes and fields remain valid; malformed responses never infer a domain
|
|
43
|
-
* code from HTTP status.
|
|
44
|
-
* @param bodyText - Response body as text.
|
|
45
|
-
* @param status - HTTP response status.
|
|
46
|
-
* @param headers - Response headers to preserve or inspect.
|
|
47
|
-
* @returns The server error, or invalid_response when the envelope is malformed.
|
|
48
|
-
*/
|
|
49
|
-
export declare function parseErrorEnvelope(bodyText: string, status: number, headers: Headers): BlazingAgentsError;
|
package/dist/http.js
CHANGED
|
@@ -4,6 +4,13 @@ const DIAGNOSTIC_BODY_LIMIT_BYTES = 64 * 1024;
|
|
|
4
4
|
const INVALID_RESPONSE_MESSAGE = "The server returned an invalid response.";
|
|
5
5
|
const NETWORK_ERROR_MESSAGE = "Network request failed (fetch threw before any HTTP exchange).";
|
|
6
6
|
const REQUEST_ABORTED_MESSAGE = "The request was aborted before any HTTP response.";
|
|
7
|
+
/**
|
|
8
|
+
* Builds an endpoint path, encoding each interpolated value so it stays inside
|
|
9
|
+
* one path segment or query value.
|
|
10
|
+
*/
|
|
11
|
+
export function apiPath(template, ...values) {
|
|
12
|
+
return String.raw({ raw: template }, ...values.map(encodeURIComponent));
|
|
13
|
+
}
|
|
7
14
|
/**
|
|
8
15
|
* Appends query values while omitting null and undefined entries.
|
|
9
16
|
*/
|
|
@@ -305,7 +312,7 @@ function decodeChunks(chunks, byteLength, truncated) {
|
|
|
305
312
|
* @param headers - Response headers to preserve or inspect.
|
|
306
313
|
* @returns The server error, or invalid_response when the envelope is malformed.
|
|
307
314
|
*/
|
|
308
|
-
|
|
315
|
+
function parseErrorEnvelope(bodyText, status, headers) {
|
|
309
316
|
let parsed;
|
|
310
317
|
if (bodyText.length === 0) {
|
|
311
318
|
parsed = null;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export { AGENT_TOOL_FILE_ACCESS_TAGS, AGENT_TOOL_GROUPS, AGENT_TOOL_TAGS, AGENT_
|
|
|
11
11
|
export type { Agent, AgentConfig, AgentResponse, AgentsListQuery, AgentsResponse, CreateAgentBody, UpdateAgentBody, } from "./contracts/entities/agents.ts";
|
|
12
12
|
export { agentConfigSchema } from "./contracts/entities/agents.ts";
|
|
13
13
|
export type { ArtifactDownloadUrlResponse, ArtifactListItem, ArtifactsListResponse, } from "./contracts/entities/artifacts.ts";
|
|
14
|
-
export type { ChatConfiguration, ChatConnection, ChatConnectionsResponse, ChatCredentials, ChatDeliveriesResponse, ChatDelivery, ChatDeliveryListStatus, ChatDeliveryStatus, ChatHealth, ChatIdentity, CreateChatConnectionBody, RotateChatConnectionBody, TenantChatDelivery, UpdateChatConnectionBody, } from "./contracts/entities/chat-connections.ts";
|
|
15
|
-
export type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResponse, McpConnectionAuthType,
|
|
14
|
+
export type { ChatConfiguration, ChatConnection, ChatConnectionsResponse, ChatCredentials, ChatDeliveriesResponse, ChatDelivery, ChatDeliveryList, ChatDeliveryListStatus, ChatDeliveryResult, ChatDeliveryStatus, ChatHealth, ChatIdentity, CreateChatConnectionBody, RepairChatDeliveryBody, RotateChatConnectionBody, TenantChatDelivery, UpdateChatConnectionBody, } from "./contracts/entities/chat-connections.ts";
|
|
15
|
+
export type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResponse, McpConnectionAuthType, McpConnectionReconnectResult, McpConnectionResponse, McpConnectionStatus, McpConnectionTestResponse, ReconnectMcpConnectionBody, UpdateMcpAttachmentBody, UpdateMcpConnectionBody, } from "./contracts/entities/mcp-connections.ts";
|
|
16
16
|
export type { CreateMerchantConnectionBody, MerchantBindingResponse, MerchantBindingsResponse, MerchantConnection, MerchantConnectionResponse, MerchantCustomerBinding, MerchantGuard, MerchantProviderKind, MerchantUsageEvent, MerchantUsageEventResponse, MerchantUsageEventStatus, MerchantUsageEventsResponse, MerchantUsageSummary, MerchantUsageSummaryResponse, UpdateMerchantConnectionBody, UpsertMerchantBindingBody, } from "./contracts/entities/merchant.ts";
|
|
17
17
|
export type { CreatePromptBody, PromptResponse, PromptsListQuery, PromptsResponse, UpdatePromptBody, } from "./contracts/entities/prompts.ts";
|
|
18
18
|
export type { CreateProviderBody, ProviderListItem, ProviderModel, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ProviderType, ThinkingLevelsResponse, UpdateProviderBody, } from "./contracts/entities/providers.ts";
|
package/dist/resources/agents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { agentResponseSchema, agentsResponseSchema, } from "../contracts/entities/agents.js";
|
|
2
2
|
import { mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, } from "../contracts/entities/mcp-connections.js";
|
|
3
3
|
import { spendingLimitResponseSchema } from "../contracts/entities/spending-limits.js";
|
|
4
|
-
import { requestJson } from "../http.js";
|
|
4
|
+
import { apiPath, requestJson } from "../http.js";
|
|
5
5
|
/**
|
|
6
6
|
* Builds the Agents operations, including the spending limits that need tenant authority.
|
|
7
7
|
* @param config - Shared authentication and transport configuration.
|
|
@@ -12,11 +12,11 @@ export function createAgentsResource(config) {
|
|
|
12
12
|
...createUserAgentsResource(config),
|
|
13
13
|
/** Retrieves the model spending limit using tenant authority. */
|
|
14
14
|
async getSpendingLimit({ agentId, abortSignal }) {
|
|
15
|
-
return await requestJson(config, `/v1/agents/${agentId}/spending-limit`, { signal: abortSignal }, spendingLimitResponseSchema);
|
|
15
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/spending-limit`, { signal: abortSignal }, spendingLimitResponseSchema);
|
|
16
16
|
},
|
|
17
17
|
/** Sets the model spending limit. Null disables it. Requires tenant authority. */
|
|
18
18
|
async updateSpendingLimit({ agentId, abortSignal, ...body }) {
|
|
19
|
-
return await requestJson(config, `/v1/agents/${agentId}/spending-limit`, { method: "PUT", json: body, signal: abortSignal }, spendingLimitResponseSchema);
|
|
19
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/spending-limit`, { method: "PUT", json: body, signal: abortSignal }, spendingLimitResponseSchema);
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -29,7 +29,7 @@ export function createUserAgentsResource(config) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Updates agents.
|
|
31
31
|
*/
|
|
32
|
-
const update = async ({ agentId, abortSignal, ...body }) => requestJson(config, `/v1/agents/${agentId}`, {
|
|
32
|
+
const update = async ({ agentId, abortSignal, ...body }) => requestJson(config, apiPath `/v1/agents/${agentId}`, {
|
|
33
33
|
json: body,
|
|
34
34
|
signal: abortSignal,
|
|
35
35
|
method: "PUT",
|
|
@@ -63,38 +63,38 @@ export function createUserAgentsResource(config) {
|
|
|
63
63
|
* Retrieves agents.
|
|
64
64
|
*/
|
|
65
65
|
async get({ agentId, abortSignal }) {
|
|
66
|
-
return await requestJson(config, `/v1/agents/${agentId}`, { signal: abortSignal }, agentResponseSchema);
|
|
66
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}`, { signal: abortSignal }, agentResponseSchema);
|
|
67
67
|
},
|
|
68
68
|
/**
|
|
69
69
|
* Disables agents.
|
|
70
70
|
*/
|
|
71
71
|
async disable({ agentId, abortSignal }) {
|
|
72
|
-
return await requestJson(config, `/v1/agents/${agentId}/disable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
72
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/disable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
73
73
|
},
|
|
74
74
|
/**
|
|
75
75
|
* Enables agents.
|
|
76
76
|
*/
|
|
77
77
|
async enable({ agentId, abortSignal }) {
|
|
78
|
-
return await requestJson(config, `/v1/agents/${agentId}/enable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
78
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/enable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
79
79
|
},
|
|
80
80
|
/**
|
|
81
81
|
* Lists the Agent MCP attachments.
|
|
82
82
|
*/
|
|
83
83
|
async listMcpAttachments({ agentId, abortSignal }) {
|
|
84
|
-
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments`, { signal: abortSignal }, mcpAttachmentsResponseSchema);
|
|
84
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/mcp-attachments`, { signal: abortSignal }, mcpAttachmentsResponseSchema);
|
|
85
85
|
},
|
|
86
86
|
update,
|
|
87
87
|
/**
|
|
88
88
|
* Updates one Agent MCP attachment.
|
|
89
89
|
*/
|
|
90
90
|
async updateMcpAttachment({ agentId, mcpConnectionId, abortSignal, ...body }) {
|
|
91
|
-
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments/${mcpConnectionId}`, { json: body, method: "PATCH", signal: abortSignal }, mcpAttachmentResponseSchema);
|
|
91
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/mcp-attachments/${mcpConnectionId}`, { json: body, method: "PATCH", signal: abortSignal }, mcpAttachmentResponseSchema);
|
|
92
92
|
},
|
|
93
93
|
/**
|
|
94
94
|
* Deletes agents.
|
|
95
95
|
*/
|
|
96
96
|
async delete({ agentId, includeArtifacts, abortSignal }) {
|
|
97
|
-
await requestJson(config, `/v1/agents/${agentId}`, {
|
|
97
|
+
await requestJson(config, apiPath `/v1/agents/${agentId}`, {
|
|
98
98
|
method: "DELETE",
|
|
99
99
|
query: { includeArtifacts },
|
|
100
100
|
signal: abortSignal,
|
|
@@ -106,7 +106,7 @@ export function createUserAgentsResource(config) {
|
|
|
106
106
|
async uploadAvatar({ agentId, file, abortSignal }) {
|
|
107
107
|
const form = new FormData();
|
|
108
108
|
form.append("file", file);
|
|
109
|
-
return await requestJson(config, `/v1/agents/${agentId}/avatar`, {
|
|
109
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/avatar`, {
|
|
110
110
|
body: form,
|
|
111
111
|
signal: abortSignal,
|
|
112
112
|
method: "POST",
|
|
@@ -116,7 +116,7 @@ export function createUserAgentsResource(config) {
|
|
|
116
116
|
* Removes the Agent avatar.
|
|
117
117
|
*/
|
|
118
118
|
async removeAvatar({ agentId, abortSignal }) {
|
|
119
|
-
return await requestJson(config, `/v1/agents/${agentId}/avatar`, { method: "DELETE", signal: abortSignal }, agentResponseSchema);
|
|
119
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/avatar`, { method: "DELETE", signal: abortSignal }, agentResponseSchema);
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
122
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "../contracts/entities/artifacts.js";
|
|
2
|
-
import { requestJson } from "../http.js";
|
|
2
|
+
import { apiPath, requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* `client.artifacts` — Tenant-level metadata and direct download URLs.
|
|
5
5
|
* @param config - Shared authentication and transport configuration.
|
|
@@ -11,13 +11,13 @@ export function createArtifactsResource(config) {
|
|
|
11
11
|
* Creates a temporary Artifact download URL.
|
|
12
12
|
*/
|
|
13
13
|
async createDownloadUrl({ artifactId, abortSignal }) {
|
|
14
|
-
return await requestJson(config, `/v1/artifacts/${artifactId}/download-url`, { method: "POST", signal: abortSignal }, artifactDownloadUrlResponseSchema);
|
|
14
|
+
return await requestJson(config, apiPath `/v1/artifacts/${artifactId}/download-url`, { method: "POST", signal: abortSignal }, artifactDownloadUrlResponseSchema);
|
|
15
15
|
},
|
|
16
16
|
/**
|
|
17
17
|
* Retrieves artifacts.
|
|
18
18
|
*/
|
|
19
19
|
async get({ artifactId, abortSignal }) {
|
|
20
|
-
return await requestJson(config, `/v1/artifacts/${artifactId}`, { signal: abortSignal }, artifactListItemSchema);
|
|
20
|
+
return await requestJson(config, apiPath `/v1/artifacts/${artifactId}`, { signal: abortSignal }, artifactListItemSchema);
|
|
21
21
|
},
|
|
22
22
|
/**
|
|
23
23
|
* Lists one page of artifacts.
|
|
@@ -36,7 +36,7 @@ export function createArtifactsResource(config) {
|
|
|
36
36
|
* Deletes artifacts.
|
|
37
37
|
*/
|
|
38
38
|
async delete({ artifactId, abortSignal }) {
|
|
39
|
-
await requestJson(config, `/v1/artifacts/${artifactId}`, {
|
|
39
|
+
await requestJson(config, apiPath `/v1/artifacts/${artifactId}`, {
|
|
40
40
|
method: "DELETE",
|
|
41
41
|
signal: abortSignal,
|
|
42
42
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { chatConnectionSchema, chatConnectionsResponseSchema, } from "../contracts/entities/chat-connections.js";
|
|
2
|
-
import { requestJson } from "../http.js";
|
|
1
|
+
import { chatConnectionSchema, chatConnectionsResponseSchema, chatDeliveryListSchema, chatDeliveryResultSchema, } from "../contracts/entities/chat-connections.js";
|
|
2
|
+
import { apiPath, requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* Builds the Chat Connections operations using the shared HTTP configuration.
|
|
5
5
|
* @param config - Shared authentication and transport configuration.
|
|
@@ -23,43 +23,55 @@ export function createChatConnectionsResource(config) {
|
|
|
23
23
|
* Retrieves chat connections.
|
|
24
24
|
*/
|
|
25
25
|
async get({ chatConnectionId, abortSignal }) {
|
|
26
|
-
return await requestJson(config, `/v1/chat-connections/${
|
|
26
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "GET" }, chatConnectionSchema);
|
|
27
27
|
},
|
|
28
28
|
/**
|
|
29
29
|
* Updates chat connections.
|
|
30
30
|
*/
|
|
31
31
|
async update({ chatConnectionId, abortSignal, ...body }) {
|
|
32
|
-
return await requestJson(config, `/v1/chat-connections/${
|
|
32
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "PATCH", json: body }, chatConnectionSchema);
|
|
33
33
|
},
|
|
34
34
|
/**
|
|
35
35
|
* Replaces the Chat Connection credentials.
|
|
36
36
|
*/
|
|
37
37
|
async rotateCredentials({ chatConnectionId, abortSignal, ...body }) {
|
|
38
|
-
return await requestJson(config, `/v1/chat-connections/${
|
|
38
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/credentials`, { signal: abortSignal, method: "POST", json: body }, chatConnectionSchema);
|
|
39
39
|
},
|
|
40
40
|
/**
|
|
41
41
|
* Checks the Chat Connection health.
|
|
42
42
|
*/
|
|
43
43
|
async checkHealth({ chatConnectionId, abortSignal }) {
|
|
44
|
-
return await requestJson(config, `/v1/chat-connections/${
|
|
44
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/health`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Lists one page of the Chat Connection's deliveries.
|
|
48
|
+
*/
|
|
49
|
+
async listDeliveries({ chatConnectionId, abortSignal, ...query }) {
|
|
50
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries`, { signal: abortSignal, query }, chatDeliveryListSchema);
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Sends a stuck Chat delivery again.
|
|
54
|
+
*/
|
|
55
|
+
async repairDelivery({ chatConnectionId, deliveryId, abortSignal, ...body }) {
|
|
56
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries/${deliveryId}/repair`, { signal: abortSignal, method: "POST", json: body }, chatDeliveryResultSchema);
|
|
45
57
|
},
|
|
46
58
|
/**
|
|
47
59
|
* Enables chat connections.
|
|
48
60
|
*/
|
|
49
61
|
async enable({ chatConnectionId, abortSignal }) {
|
|
50
|
-
return await requestJson(config, `/v1/chat-connections/${
|
|
62
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/enable`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
51
63
|
},
|
|
52
64
|
/**
|
|
53
65
|
* Disables chat connections.
|
|
54
66
|
*/
|
|
55
67
|
async disable({ chatConnectionId, abortSignal }) {
|
|
56
|
-
return await requestJson(config, `/v1/chat-connections/${
|
|
68
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/disable`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
57
69
|
},
|
|
58
70
|
/**
|
|
59
71
|
* Deletes chat connections.
|
|
60
72
|
*/
|
|
61
73
|
async delete({ chatConnectionId, abortSignal }) {
|
|
62
|
-
await requestJson(config, `/v1/chat-connections/${
|
|
74
|
+
await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "DELETE" });
|
|
63
75
|
},
|
|
64
76
|
};
|
|
65
77
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requestJson } from "../http.js";
|
|
1
|
+
import { mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionsResponseSchema, mcpConnectionTestResponseSchema, reconnectMcpConnectionBodySchema, updateMcpConnectionBodySchema, } from "../contracts/entities/mcp-connections.js";
|
|
2
|
+
import { apiPath, requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* Builds the Mcp Connections operations using the shared HTTP configuration.
|
|
5
5
|
* @param config - Shared authentication and transport configuration.
|
|
@@ -12,12 +12,6 @@ export function createMcpConnectionsResource(config) {
|
|
|
12
12
|
method: "POST",
|
|
13
13
|
}, mcpConnectionResponseSchema));
|
|
14
14
|
return {
|
|
15
|
-
/**
|
|
16
|
-
* Starts OAuth authorization for mcp connections.
|
|
17
|
-
*/
|
|
18
|
-
async connect({ mcpConnectionId, abortSignal }) {
|
|
19
|
-
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}/connect`, { method: "POST", signal: abortSignal }, mcpConnectionOauthConnectResponseSchema);
|
|
20
|
-
},
|
|
21
15
|
create,
|
|
22
16
|
/**
|
|
23
17
|
* Lists one page of mcp connections.
|
|
@@ -29,13 +23,13 @@ export function createMcpConnectionsResource(config) {
|
|
|
29
23
|
* Retrieves mcp connections.
|
|
30
24
|
*/
|
|
31
25
|
async get({ mcpConnectionId, abortSignal }) {
|
|
32
|
-
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}`, { signal: abortSignal }, mcpConnectionResponseSchema);
|
|
26
|
+
return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, { signal: abortSignal }, mcpConnectionResponseSchema);
|
|
33
27
|
},
|
|
34
28
|
/**
|
|
35
29
|
* Updates mcp connections.
|
|
36
30
|
*/
|
|
37
31
|
async update({ mcpConnectionId, abortSignal, ...body }) {
|
|
38
|
-
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}`, {
|
|
32
|
+
return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, {
|
|
39
33
|
json: updateMcpConnectionBodySchema.parse(body),
|
|
40
34
|
signal: abortSignal,
|
|
41
35
|
method: "PATCH",
|
|
@@ -45,7 +39,7 @@ export function createMcpConnectionsResource(config) {
|
|
|
45
39
|
* Deletes mcp connections.
|
|
46
40
|
*/
|
|
47
41
|
async delete({ mcpConnectionId, abortSignal }) {
|
|
48
|
-
await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}`, {
|
|
42
|
+
await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, {
|
|
49
43
|
method: "DELETE",
|
|
50
44
|
signal: abortSignal,
|
|
51
45
|
});
|
|
@@ -54,13 +48,13 @@ export function createMcpConnectionsResource(config) {
|
|
|
54
48
|
* Tests mcp connections.
|
|
55
49
|
*/
|
|
56
50
|
async test({ mcpConnectionId, abortSignal }) {
|
|
57
|
-
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}/test`, { method: "POST", signal: abortSignal }, mcpConnectionTestResponseSchema);
|
|
51
|
+
return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}/test`, { method: "POST", signal: abortSignal }, mcpConnectionTestResponseSchema);
|
|
58
52
|
},
|
|
59
53
|
/**
|
|
60
54
|
* Reconnects mcp connections.
|
|
61
55
|
*/
|
|
62
56
|
async reconnect({ mcpConnectionId, abortSignal, ...body }) {
|
|
63
|
-
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}/reconnect`, {
|
|
57
|
+
return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}/reconnect`, {
|
|
64
58
|
json: reconnectMcpConnectionBodySchema.parse(body),
|
|
65
59
|
signal: abortSignal,
|
|
66
60
|
method: "POST",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memoriesListResponseSchema, memoryResponseSchema, } from "../contracts/entities/memories.js";
|
|
2
|
-
import { requestJson } from "../http.js";
|
|
2
|
+
import { apiPath, requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* `client.memories` — CRUD and query over `/v1/agents/:agentId/memories`.
|
|
5
5
|
* Memories are Agent-nested; `userId` is stamped at creation and immutable,
|
|
@@ -13,7 +13,7 @@ export function createMemoriesResource(config) {
|
|
|
13
13
|
* Lists one page of memories.
|
|
14
14
|
*/
|
|
15
15
|
async list({ agentId, abortSignal, ...options }) {
|
|
16
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories`, {
|
|
16
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/memories`, {
|
|
17
17
|
signal: abortSignal,
|
|
18
18
|
query: {
|
|
19
19
|
...(options.userId === undefined ? {} : { userId: options.userId }),
|
|
@@ -27,25 +27,25 @@ export function createMemoriesResource(config) {
|
|
|
27
27
|
* Creates memories.
|
|
28
28
|
*/
|
|
29
29
|
async create({ agentId, abortSignal, ...body }) {
|
|
30
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories`, { json: body, signal: abortSignal, method: "POST" }, memoryResponseSchema);
|
|
30
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/memories`, { json: body, signal: abortSignal, method: "POST" }, memoryResponseSchema);
|
|
31
31
|
},
|
|
32
32
|
/**
|
|
33
33
|
* Retrieves memories.
|
|
34
34
|
*/
|
|
35
35
|
async get({ agentId, memoryId, abortSignal }) {
|
|
36
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { signal: abortSignal }, memoryResponseSchema);
|
|
36
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/memories/${memoryId}`, { signal: abortSignal }, memoryResponseSchema);
|
|
37
37
|
},
|
|
38
38
|
/**
|
|
39
39
|
* Updates memories.
|
|
40
40
|
*/
|
|
41
41
|
async update({ agentId, memoryId, abortSignal, ...body }) {
|
|
42
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { json: body, signal: abortSignal, method: "PATCH" }, memoryResponseSchema);
|
|
42
|
+
return await requestJson(config, apiPath `/v1/agents/${agentId}/memories/${memoryId}`, { json: body, signal: abortSignal, method: "PATCH" }, memoryResponseSchema);
|
|
43
43
|
},
|
|
44
44
|
/**
|
|
45
45
|
* Deletes memories.
|
|
46
46
|
*/
|
|
47
47
|
async delete({ agentId, memoryId, abortSignal }) {
|
|
48
|
-
await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { method: "DELETE", signal: abortSignal });
|
|
48
|
+
await requestJson(config, apiPath `/v1/agents/${agentId}/memories/${memoryId}`, { method: "DELETE", signal: abortSignal });
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { merchantBindingResponseSchema, merchantBindingsResponseSchema, } from "../contracts/entities/merchant.js";
|
|
2
|
-
import { requestJson } from "../http.js";
|
|
2
|
+
import { apiPath, requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* `client.merchantBindings` — list/put/delete over
|
|
5
5
|
* `/v1/merchant-connection/bindings`. `put` upserts the end user's provider
|
|
@@ -20,13 +20,13 @@ export function createMerchantBindingsResource(config) {
|
|
|
20
20
|
* Validates and saves merchant bindings.
|
|
21
21
|
*/
|
|
22
22
|
async put({ userId, abortSignal, ...body }) {
|
|
23
|
-
return await requestJson(config, `/v1/merchant-connection/bindings/${
|
|
23
|
+
return await requestJson(config, apiPath `/v1/merchant-connection/bindings/${userId}`, { json: body, method: "PUT", signal: abortSignal }, merchantBindingResponseSchema);
|
|
24
24
|
},
|
|
25
25
|
/**
|
|
26
26
|
* Deletes merchant bindings.
|
|
27
27
|
*/
|
|
28
28
|
async delete({ userId, abortSignal }) {
|
|
29
|
-
await requestJson(config, `/v1/merchant-connection/bindings/${
|
|
29
|
+
await requestJson(config, apiPath `/v1/merchant-connection/bindings/${userId}`, { method: "DELETE", signal: abortSignal });
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
32
|
}
|