@blazingagents/sdk 0.34.0 → 0.36.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/chat-transport.js +4 -1
- package/dist/client.d.ts +18 -2
- package/dist/client.js +16 -15
- package/dist/contracts/entities/agents.d.ts +7 -6
- package/dist/contracts/entities/agents.js +129 -36
- package/dist/contracts/entities/chat-connections.d.ts +9 -8
- package/dist/contracts/entities/chat-connections.js +70 -40
- package/dist/contracts/entities/chat.d.ts +8 -4
- package/dist/contracts/entities/chat.js +102 -28
- package/dist/contracts/entities/mcp-connections.d.ts +2 -0
- package/dist/contracts/entities/mcp-connections.js +36 -23
- package/dist/contracts/entities/memories.d.ts +1 -0
- package/dist/contracts/entities/memories.js +5 -3
- package/dist/contracts/entities/merchant.js +28 -9
- package/dist/contracts/entities/prompts.d.ts +2 -2
- package/dist/contracts/entities/prompts.js +42 -15
- package/dist/contracts/entities/providers.js +14 -6
- package/dist/contracts/entities/sessions.d.ts +10 -4
- package/dist/contracts/entities/sessions.js +5 -4
- package/dist/contracts/entities/skills.js +6 -3
- package/dist/contracts/entities/tasks.d.ts +4 -7
- package/dist/contracts/entities/tasks.js +45 -15
- package/dist/contracts/entities/tenants.d.ts +2 -28
- package/dist/contracts/entities/tenants.js +15 -22
- package/dist/contracts/entities/usage.d.ts +1 -1
- package/dist/contracts/entities/usage.js +16 -6
- package/dist/contracts/entities/workspaces.d.ts +1 -1
- package/dist/contracts/entities/workspaces.js +26 -10
- package/dist/contracts/index.d.ts +18 -13
- package/dist/contracts/index.js +12 -12
- package/dist/contracts/limitations.d.ts +2 -4
- package/dist/contracts/limitations.js +2 -4
- package/dist/direct-chat-transport.js +2 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +21 -0
- package/dist/http.d.ts +3 -1
- package/dist/http.js +74 -2
- package/dist/index.d.ts +18 -1
- package/dist/resources/agents.d.ts +120 -1
- package/dist/resources/agents.js +1 -33
- package/dist/resources/artifacts.d.ts +42 -1
- package/dist/resources/artifacts.js +0 -12
- package/dist/resources/chat-connections.d.ts +110 -1
- package/dist/resources/chat-connections.js +31 -44
- package/dist/resources/chat-deliveries.d.ts +23 -1
- package/dist/resources/chat-deliveries.js +2 -4
- package/dist/resources/mcp-connections.d.ts +63 -1
- package/dist/resources/mcp-connections.js +10 -24
- package/dist/resources/memories.d.ts +58 -1
- package/dist/resources/memories.js +0 -15
- package/dist/resources/merchant-bindings.d.ts +39 -1
- package/dist/resources/merchant-bindings.js +0 -9
- package/dist/resources/merchant-connection.d.ts +37 -1
- package/dist/resources/merchant-connection.js +15 -16
- package/dist/resources/merchant-usage-events.d.ts +66 -1
- package/dist/resources/merchant-usage-events.js +0 -18
- package/dist/resources/prompts.d.ts +50 -1
- package/dist/resources/prompts.js +0 -15
- package/dist/resources/providers.d.ts +64 -1
- package/dist/resources/providers.js +7 -25
- package/dist/resources/sessions.d.ts +124 -1
- package/dist/resources/sessions.js +5 -36
- package/dist/resources/skills.d.ts +95 -1
- package/dist/resources/skills.js +0 -27
- package/dist/resources/tasks.d.ts +107 -1
- package/dist/resources/tasks.js +0 -30
- package/dist/resources/tenant.d.ts +23 -1
- package/dist/resources/tenant.js +2 -10
- package/dist/resources/usage.d.ts +34 -1
- package/dist/resources/usage.js +2 -15
- package/dist/resources/workspaces.d.ts +50 -1
- package/dist/resources/workspaces.js +0 -15
- package/dist/types.d.ts +17 -1083
- package/package.json +1 -2
package/dist/http.js
CHANGED
|
@@ -4,11 +4,38 @@ 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
|
+
/** Fields no credential-bearing operation's response may contain. */
|
|
8
|
+
const CREDENTIAL_KEYS = new Set([
|
|
9
|
+
"apiKey",
|
|
10
|
+
"api_key",
|
|
11
|
+
"botToken",
|
|
12
|
+
"bot_token",
|
|
13
|
+
"signingSecret",
|
|
14
|
+
"signing_secret",
|
|
15
|
+
"webhookSecret",
|
|
16
|
+
"webhook_secret",
|
|
17
|
+
"bearerToken",
|
|
18
|
+
"bearer_token",
|
|
19
|
+
"clientSecret",
|
|
20
|
+
"client_secret",
|
|
21
|
+
"credential",
|
|
22
|
+
]);
|
|
23
|
+
const DOT_OR_EMPTY_SEGMENTS = new Set(["", ".", ".."]);
|
|
7
24
|
/**
|
|
8
25
|
* Builds an endpoint path, encoding each interpolated value so it stays inside
|
|
9
|
-
* one path segment
|
|
26
|
+
* one path segment. `encodeURIComponent` leaves `.` and `..` unchanged, and
|
|
27
|
+
* URL normalization would resolve them against the parent path, so those and
|
|
28
|
+
* the empty segment are rejected.
|
|
10
29
|
*/
|
|
11
30
|
export function apiPath(template, ...values) {
|
|
31
|
+
for (const value of values) {
|
|
32
|
+
if (DOT_OR_EMPTY_SEGMENTS.has(value)) {
|
|
33
|
+
throw new BlazingAgentsError({
|
|
34
|
+
code: "invalid_request",
|
|
35
|
+
message: `Invalid path segment ${JSON.stringify(value)}.`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
12
39
|
return String.raw({ raw: template }, ...values.map(encodeURIComponent));
|
|
13
40
|
}
|
|
14
41
|
/**
|
|
@@ -59,14 +86,59 @@ export async function requestJson(config, path, options = {}, schema) {
|
|
|
59
86
|
}
|
|
60
87
|
throw invalidResponseError(headers, response.status, read.diagnosticBody, true, read.cause);
|
|
61
88
|
}
|
|
89
|
+
let json;
|
|
90
|
+
try {
|
|
91
|
+
json = JSON.parse(read.bodyText);
|
|
92
|
+
}
|
|
93
|
+
catch (cause) {
|
|
94
|
+
throw invalidResponseError(headers, response.status, read.diagnosticBody, read.diagnosticBodyTruncated, cause);
|
|
95
|
+
}
|
|
96
|
+
const echoed = options.credentialBearing
|
|
97
|
+
? findCredentialKey(json)
|
|
98
|
+
: undefined;
|
|
99
|
+
if (echoed !== undefined) {
|
|
100
|
+
throw new BlazingAgentsError({
|
|
101
|
+
code: "credential_echo",
|
|
102
|
+
details: { field: echoed },
|
|
103
|
+
headers,
|
|
104
|
+
message: `The server echoed credential field ${JSON.stringify(echoed)}; the response body was discarded.`,
|
|
105
|
+
requestId: headers.get("x-request-id") ?? undefined,
|
|
106
|
+
status: response.status,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
62
109
|
try {
|
|
63
|
-
const json = JSON.parse(read.bodyText);
|
|
64
110
|
return schema === undefined ? json : schema.parse(json);
|
|
65
111
|
}
|
|
66
112
|
catch (cause) {
|
|
67
113
|
throw invalidResponseError(headers, response.status, read.diagnosticBody, read.diagnosticBodyTruncated, cause);
|
|
68
114
|
}
|
|
69
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns the first credential field found anywhere in a decoded JSON value.
|
|
118
|
+
*/
|
|
119
|
+
function findCredentialKey(value) {
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
for (const item of value) {
|
|
122
|
+
const key = findCredentialKey(item);
|
|
123
|
+
if (key !== undefined) {
|
|
124
|
+
return key;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (value === null || typeof value !== "object") {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
for (const [key, item] of Object.entries(value)) {
|
|
133
|
+
if (CREDENTIAL_KEYS.has(key)) {
|
|
134
|
+
return key;
|
|
135
|
+
}
|
|
136
|
+
const nested = findCredentialKey(item);
|
|
137
|
+
if (nested !== undefined) {
|
|
138
|
+
return nested;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
70
142
|
/**
|
|
71
143
|
* Performs a request and returns the raw `Response` for streaming paths.
|
|
72
144
|
* Non-2xx bodies are decoded before a caller can observe a streaming body.
|
package/dist/index.d.ts
CHANGED
|
@@ -28,4 +28,21 @@ export { BlazingAgentsDirectChatTransport, type BlazingAgentsDirectChatTransport
|
|
|
28
28
|
export { BlazingAgentsError } from "./errors.ts";
|
|
29
29
|
export { type ChatFunction, type ChatFunctionContext, type ChatFunctions, defineFunction, } from "./functions.ts";
|
|
30
30
|
export { createChatRelay, createCompletionRelay, type RelayContext, type SessionOwnershipStore, } from "./relay.ts";
|
|
31
|
-
export type {
|
|
31
|
+
export type { AgentsListOptions, AgentsResource, UserAgentsResource, } from "./resources/agents.ts";
|
|
32
|
+
export type { ArtifactsResource } from "./resources/artifacts.ts";
|
|
33
|
+
export type { ChatConnectionsResource } from "./resources/chat-connections.ts";
|
|
34
|
+
export type { ChatDeliveriesListOptions, ChatDeliveriesResource, } from "./resources/chat-deliveries.ts";
|
|
35
|
+
export type { McpConnectionsResource } from "./resources/mcp-connections.ts";
|
|
36
|
+
export type { MemoriesListOptions, MemoriesResource, } from "./resources/memories.ts";
|
|
37
|
+
export type { MerchantBindingsListOptions, MerchantBindingsResource, } from "./resources/merchant-bindings.ts";
|
|
38
|
+
export type { MerchantConnectionResource } from "./resources/merchant-connection.ts";
|
|
39
|
+
export type { MerchantUsageEventsListOptions, MerchantUsageEventsResource, } from "./resources/merchant-usage-events.ts";
|
|
40
|
+
export type { PromptsResource } from "./resources/prompts.ts";
|
|
41
|
+
export type { ProvidersResource } from "./resources/providers.ts";
|
|
42
|
+
export type { LatestSessionsListOptions, SessionsResource, } from "./resources/sessions.ts";
|
|
43
|
+
export type { AgentSkillsResource, SkillsListOptions, } from "./resources/skills.ts";
|
|
44
|
+
export type { TasksResource } from "./resources/tasks.ts";
|
|
45
|
+
export type { TenantResource } from "./resources/tenant.ts";
|
|
46
|
+
export type { UsageResource } from "./resources/usage.ts";
|
|
47
|
+
export type { WorkspacesListOptions, WorkspacesResource, } from "./resources/workspaces.ts";
|
|
48
|
+
export type { AgentClient, AttributionInput, BlazingAgentsErrorCode, BlazingAgentsOptions, BlazingAgentsRequestOptions, BlazingAgentsUIMessage, BlazingAgentsUIMessageChunk, BlazingAgentsUIMessageData, ChatInput, ChatMessageInput, ChatMessagesInput, ChatPromptInput, ChatResult, ChatTrigger, CompletionInput, CompletionPromptIdInput, CompletionPromptInput, CompletionResult, ContinueChatInput, KnownBlazingAgentsErrorCode, ObjectInput, ObjectPromptIdInput, ObjectPromptInput, ObjectResult, ResourceRequestOptions, ResponseObservation, TerminalStreamResult, UserClient, } from "./types.ts";
|
|
@@ -1,4 +1,123 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Agent, type AgentsResponse, type CreateAgentBody, type UpdateAgentBody } from "../contracts/entities/agents.ts";
|
|
2
|
+
import { type McpAttachmentResponse, type McpAttachmentsResponse, type UpdateMcpAttachmentBody } from "../contracts/entities/mcp-connections.ts";
|
|
3
|
+
import { type SpendingLimitResponse, type UpdateSpendingLimitBody } from "../contracts/entities/spending-limits.ts";
|
|
4
|
+
import type { HttpConfig, ResourceRequestOptions } from "../types.ts";
|
|
5
|
+
/** Agent operations on a user-scoped client, which has no spending limits. */
|
|
6
|
+
export type UserAgentsResource = Omit<AgentsResource, "getSpendingLimit" | "updateSpendingLimit">;
|
|
7
|
+
export interface AgentsResource {
|
|
8
|
+
/**
|
|
9
|
+
* Creates the Agent. Omitting `workspaceId` creates a Core Workspace by default. `workspaceTier` selects its immutable tier and conflicts with `workspaceId`.
|
|
10
|
+
* @param input - creation fields; optional abortSignal.
|
|
11
|
+
* @returns The agent.
|
|
12
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
13
|
+
*/
|
|
14
|
+
create(input: CreateAgentBody & ResourceRequestOptions): Promise<Agent>;
|
|
15
|
+
/**
|
|
16
|
+
* Deletes the Agent while preserving its attached Workspace.
|
|
17
|
+
* @param input - `agentId`; optional abortSignal; includeArtifacts controls Artifact deletion.
|
|
18
|
+
* @returns Resolves when the operation completes.
|
|
19
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
20
|
+
*/
|
|
21
|
+
delete(input: {
|
|
22
|
+
agentId: string;
|
|
23
|
+
includeArtifacts: boolean;
|
|
24
|
+
} & ResourceRequestOptions): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Disables the Agent.
|
|
27
|
+
* @param input - `agentId`; optional abortSignal.
|
|
28
|
+
* @returns The agent.
|
|
29
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
30
|
+
*/
|
|
31
|
+
disable(input: {
|
|
32
|
+
agentId: string;
|
|
33
|
+
} & ResourceRequestOptions): Promise<Agent>;
|
|
34
|
+
/**
|
|
35
|
+
* Enables the Agent.
|
|
36
|
+
* @param input - `agentId`; optional abortSignal.
|
|
37
|
+
* @returns The agent.
|
|
38
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
39
|
+
*/
|
|
40
|
+
enable(input: {
|
|
41
|
+
agentId: string;
|
|
42
|
+
} & ResourceRequestOptions): Promise<Agent>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the Agent.
|
|
45
|
+
* @param input - `agentId`; optional abortSignal.
|
|
46
|
+
* @returns The agent.
|
|
47
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
48
|
+
*/
|
|
49
|
+
get(input: {
|
|
50
|
+
agentId: string;
|
|
51
|
+
} & ResourceRequestOptions): Promise<Agent>;
|
|
52
|
+
/** Retrieves the Agent model spending limit. Requires tenant authority. */
|
|
53
|
+
getSpendingLimit(input: {
|
|
54
|
+
agentId: string;
|
|
55
|
+
} & ResourceRequestOptions): Promise<SpendingLimitResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Lists available Agent records.
|
|
58
|
+
* @param input - filters and pagination options.
|
|
59
|
+
* @returns Matching Agents. This response has no pagination cursor.
|
|
60
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
61
|
+
*/
|
|
62
|
+
list(input?: AgentsListOptions): Promise<AgentsResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Lists the Agent MCP attachments.
|
|
65
|
+
* @param input - `agentId`; optional abortSignal.
|
|
66
|
+
* @returns The mcp attachments response.
|
|
67
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
68
|
+
*/
|
|
69
|
+
listMcpAttachments(input: {
|
|
70
|
+
agentId: string;
|
|
71
|
+
} & ResourceRequestOptions): Promise<McpAttachmentsResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Removes the Agent avatar.
|
|
74
|
+
* @param input - `agentId`; optional abortSignal.
|
|
75
|
+
* @returns The agent.
|
|
76
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
77
|
+
*/
|
|
78
|
+
removeAvatar(input: {
|
|
79
|
+
agentId: string;
|
|
80
|
+
} & ResourceRequestOptions): Promise<Agent>;
|
|
81
|
+
/**
|
|
82
|
+
* Updates the Agent. A concrete `workspaceId` switches the Agent; detachment is unsupported.
|
|
83
|
+
* @param input - `agentId`; fields to change; optional abortSignal.
|
|
84
|
+
* @returns The agent.
|
|
85
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
86
|
+
*/
|
|
87
|
+
update(input: UpdateAgentBody & {
|
|
88
|
+
agentId: string;
|
|
89
|
+
} & ResourceRequestOptions): Promise<Agent>;
|
|
90
|
+
/**
|
|
91
|
+
* Updates one Agent MCP attachment.
|
|
92
|
+
* @param input - `agentId`, `mcpConnectionId`; fields to change; optional abortSignal.
|
|
93
|
+
* @returns The mcp attachment response.
|
|
94
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
95
|
+
*/
|
|
96
|
+
updateMcpAttachment(input: UpdateMcpAttachmentBody & {
|
|
97
|
+
agentId: string;
|
|
98
|
+
mcpConnectionId: string;
|
|
99
|
+
} & ResourceRequestOptions): Promise<McpAttachmentResponse>;
|
|
100
|
+
/** Sets the Agent model spending limit. Pass null to disable it. Requires tenant authority. */
|
|
101
|
+
updateSpendingLimit(input: UpdateSpendingLimitBody & {
|
|
102
|
+
agentId: string;
|
|
103
|
+
} & ResourceRequestOptions): Promise<SpendingLimitResponse>;
|
|
104
|
+
/**
|
|
105
|
+
* Uploads an Agent avatar as multipart form data.
|
|
106
|
+
* @param input - Target `agentId`, image `file`, and optional abortSignal.
|
|
107
|
+
* @returns The agent.
|
|
108
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
109
|
+
*/
|
|
110
|
+
uploadAvatar(input: {
|
|
111
|
+
agentId: string;
|
|
112
|
+
file: File;
|
|
113
|
+
} & ResourceRequestOptions): Promise<Agent>;
|
|
114
|
+
}
|
|
115
|
+
export interface AgentsListOptions extends ResourceRequestOptions {
|
|
116
|
+
cursor?: string;
|
|
117
|
+
limit?: number;
|
|
118
|
+
userId?: string;
|
|
119
|
+
workspaceId?: string;
|
|
120
|
+
}
|
|
2
121
|
/**
|
|
3
122
|
* Builds the Agents operations, including the spending limits that need tenant authority.
|
|
4
123
|
* @param config - Shared authentication and transport configuration.
|
package/dist/resources/agents.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { agentResponseSchema, agentsResponseSchema, } from "../contracts/entities/agents.js";
|
|
2
2
|
import { mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, } from "../contracts/entities/mcp-connections.js";
|
|
3
|
-
import { spendingLimitResponseSchema } from "../contracts/entities/spending-limits.js";
|
|
3
|
+
import { spendingLimitResponseSchema, } from "../contracts/entities/spending-limits.js";
|
|
4
4
|
import { apiPath, requestJson } from "../http.js";
|
|
5
5
|
/**
|
|
6
6
|
* Builds the Agents operations, including the spending limits that need tenant authority.
|
|
@@ -10,11 +10,9 @@ import { apiPath, requestJson } from "../http.js";
|
|
|
10
10
|
export function createAgentsResource(config) {
|
|
11
11
|
return {
|
|
12
12
|
...createUserAgentsResource(config),
|
|
13
|
-
/** Retrieves the model spending limit using tenant authority. */
|
|
14
13
|
async getSpendingLimit({ agentId, abortSignal }) {
|
|
15
14
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/spending-limit`, { signal: abortSignal }, spendingLimitResponseSchema);
|
|
16
15
|
},
|
|
17
|
-
/** Sets the model spending limit. Null disables it. Requires tenant authority. */
|
|
18
16
|
async updateSpendingLimit({ agentId, abortSignal, ...body }) {
|
|
19
17
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/spending-limit`, { method: "PUT", json: body, signal: abortSignal }, spendingLimitResponseSchema);
|
|
20
18
|
},
|
|
@@ -35,9 +33,6 @@ export function createUserAgentsResource(config) {
|
|
|
35
33
|
method: "PUT",
|
|
36
34
|
}, agentResponseSchema);
|
|
37
35
|
return {
|
|
38
|
-
/**
|
|
39
|
-
* Creates agents.
|
|
40
|
-
*/
|
|
41
36
|
async create({ abortSignal, ...body }) {
|
|
42
37
|
return await requestJson(config, "/v1/agents", {
|
|
43
38
|
json: body,
|
|
@@ -45,9 +40,6 @@ export function createUserAgentsResource(config) {
|
|
|
45
40
|
method: "POST",
|
|
46
41
|
}, agentResponseSchema);
|
|
47
42
|
},
|
|
48
|
-
/**
|
|
49
|
-
* Lists one page of agents.
|
|
50
|
-
*/
|
|
51
43
|
async list(options = {}) {
|
|
52
44
|
return await requestJson(config, "/v1/agents", {
|
|
53
45
|
signal: options.abortSignal,
|
|
@@ -59,40 +51,22 @@ export function createUserAgentsResource(config) {
|
|
|
59
51
|
},
|
|
60
52
|
}, agentsResponseSchema);
|
|
61
53
|
},
|
|
62
|
-
/**
|
|
63
|
-
* Retrieves agents.
|
|
64
|
-
*/
|
|
65
54
|
async get({ agentId, abortSignal }) {
|
|
66
55
|
return await requestJson(config, apiPath `/v1/agents/${agentId}`, { signal: abortSignal }, agentResponseSchema);
|
|
67
56
|
},
|
|
68
|
-
/**
|
|
69
|
-
* Disables agents.
|
|
70
|
-
*/
|
|
71
57
|
async disable({ agentId, abortSignal }) {
|
|
72
58
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/disable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
73
59
|
},
|
|
74
|
-
/**
|
|
75
|
-
* Enables agents.
|
|
76
|
-
*/
|
|
77
60
|
async enable({ agentId, abortSignal }) {
|
|
78
61
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/enable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
79
62
|
},
|
|
80
|
-
/**
|
|
81
|
-
* Lists the Agent MCP attachments.
|
|
82
|
-
*/
|
|
83
63
|
async listMcpAttachments({ agentId, abortSignal }) {
|
|
84
64
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/mcp-attachments`, { signal: abortSignal }, mcpAttachmentsResponseSchema);
|
|
85
65
|
},
|
|
86
66
|
update,
|
|
87
|
-
/**
|
|
88
|
-
* Updates one Agent MCP attachment.
|
|
89
|
-
*/
|
|
90
67
|
async updateMcpAttachment({ agentId, mcpConnectionId, abortSignal, ...body }) {
|
|
91
68
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/mcp-attachments/${mcpConnectionId}`, { json: body, method: "PATCH", signal: abortSignal }, mcpAttachmentResponseSchema);
|
|
92
69
|
},
|
|
93
|
-
/**
|
|
94
|
-
* Deletes agents.
|
|
95
|
-
*/
|
|
96
70
|
async delete({ agentId, includeArtifacts, abortSignal }) {
|
|
97
71
|
await requestJson(config, apiPath `/v1/agents/${agentId}`, {
|
|
98
72
|
method: "DELETE",
|
|
@@ -100,9 +74,6 @@ export function createUserAgentsResource(config) {
|
|
|
100
74
|
signal: abortSignal,
|
|
101
75
|
});
|
|
102
76
|
},
|
|
103
|
-
/**
|
|
104
|
-
* Uploads an Agent avatar as multipart form data.
|
|
105
|
-
*/
|
|
106
77
|
async uploadAvatar({ agentId, file, abortSignal }) {
|
|
107
78
|
const form = new FormData();
|
|
108
79
|
form.append("file", file);
|
|
@@ -112,9 +83,6 @@ export function createUserAgentsResource(config) {
|
|
|
112
83
|
method: "POST",
|
|
113
84
|
}, agentResponseSchema);
|
|
114
85
|
},
|
|
115
|
-
/**
|
|
116
|
-
* Removes the Agent avatar.
|
|
117
|
-
*/
|
|
118
86
|
async removeAvatar({ agentId, abortSignal }) {
|
|
119
87
|
return await requestJson(config, apiPath `/v1/agents/${agentId}/avatar`, { method: "DELETE", signal: abortSignal }, agentResponseSchema);
|
|
120
88
|
},
|
|
@@ -1,4 +1,45 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ArtifactDownloadUrlResponse, type ArtifactListItem, type ArtifactsListResponse } from "../contracts/entities/artifacts.ts";
|
|
2
|
+
import type { HttpConfig, ResourceRequestOptions } from "../types.ts";
|
|
3
|
+
export interface ArtifactsListOptions extends ResourceRequestOptions {
|
|
4
|
+
agentId?: string;
|
|
5
|
+
cursor?: string;
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ArtifactsResource {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a temporary Artifact download URL.
|
|
11
|
+
* @param input - `artifactId`; optional abortSignal.
|
|
12
|
+
* @returns The artifact download url response.
|
|
13
|
+
*/
|
|
14
|
+
createDownloadUrl(input: {
|
|
15
|
+
artifactId: string;
|
|
16
|
+
} & ResourceRequestOptions): Promise<ArtifactDownloadUrlResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Deletes the Artifact.
|
|
19
|
+
* @param input - `artifactId`; optional abortSignal.
|
|
20
|
+
* @returns Resolves when the operation completes.
|
|
21
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
22
|
+
*/
|
|
23
|
+
delete(input: {
|
|
24
|
+
artifactId: string;
|
|
25
|
+
} & ResourceRequestOptions): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the Artifact.
|
|
28
|
+
* @param input - `artifactId`; optional abortSignal.
|
|
29
|
+
* @returns The artifact list item.
|
|
30
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
31
|
+
*/
|
|
32
|
+
get(input: {
|
|
33
|
+
artifactId: string;
|
|
34
|
+
} & ResourceRequestOptions): Promise<ArtifactListItem>;
|
|
35
|
+
/**
|
|
36
|
+
* Lists one page of Artifact records.
|
|
37
|
+
* @param input - filters and pagination options.
|
|
38
|
+
* @returns The artifacts list response.
|
|
39
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
40
|
+
*/
|
|
41
|
+
list(input?: ArtifactsListOptions): Promise<ArtifactsListResponse>;
|
|
42
|
+
}
|
|
2
43
|
/**
|
|
3
44
|
* `client.artifacts` — Tenant-level metadata and direct download URLs.
|
|
4
45
|
* @param config - Shared authentication and transport configuration.
|
|
@@ -7,21 +7,12 @@ import { apiPath, requestJson } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export function createArtifactsResource(config) {
|
|
9
9
|
return {
|
|
10
|
-
/**
|
|
11
|
-
* Creates a temporary Artifact download URL.
|
|
12
|
-
*/
|
|
13
10
|
async createDownloadUrl({ artifactId, abortSignal }) {
|
|
14
11
|
return await requestJson(config, apiPath `/v1/artifacts/${artifactId}/download-url`, { method: "POST", signal: abortSignal }, artifactDownloadUrlResponseSchema);
|
|
15
12
|
},
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves artifacts.
|
|
18
|
-
*/
|
|
19
13
|
async get({ artifactId, abortSignal }) {
|
|
20
14
|
return await requestJson(config, apiPath `/v1/artifacts/${artifactId}`, { signal: abortSignal }, artifactListItemSchema);
|
|
21
15
|
},
|
|
22
|
-
/**
|
|
23
|
-
* Lists one page of artifacts.
|
|
24
|
-
*/
|
|
25
16
|
async list({ abortSignal, ...options } = {}) {
|
|
26
17
|
return await requestJson(config, "/v1/artifacts", {
|
|
27
18
|
signal: abortSignal,
|
|
@@ -32,9 +23,6 @@ export function createArtifactsResource(config) {
|
|
|
32
23
|
},
|
|
33
24
|
}, artifactsListResponseSchema);
|
|
34
25
|
},
|
|
35
|
-
/**
|
|
36
|
-
* Deletes artifacts.
|
|
37
|
-
*/
|
|
38
26
|
async delete({ artifactId, abortSignal }) {
|
|
39
27
|
await requestJson(config, apiPath `/v1/artifacts/${artifactId}`, {
|
|
40
28
|
method: "DELETE",
|
|
@@ -1,4 +1,113 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChatConnection, type ChatConnectionsResponse, type ChatDeliveryList, type ChatDeliveryResult, type CreateChatConnectionBody, type RepairChatDeliveryBody, type RotateChatConnectionBody, type UpdateChatConnectionBody } from "../contracts/entities/chat-connections.ts";
|
|
2
|
+
import type { HttpConfig, ResourceRequestOptions } from "../types.ts";
|
|
3
|
+
export interface ChatConnectionsResource {
|
|
4
|
+
/**
|
|
5
|
+
* Checks the Chat Connection health.
|
|
6
|
+
* @param input - `chatConnectionId`; optional abortSignal.
|
|
7
|
+
* @returns The chat connection.
|
|
8
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
9
|
+
*/
|
|
10
|
+
checkHealth(input: {
|
|
11
|
+
chatConnectionId: string;
|
|
12
|
+
} & ResourceRequestOptions): Promise<ChatConnection>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates the Chat Connection.
|
|
15
|
+
* @param input - creation fields; optional abortSignal.
|
|
16
|
+
* @returns The chat connection.
|
|
17
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
18
|
+
*/
|
|
19
|
+
create(input: CreateChatConnectionBody & ResourceRequestOptions): Promise<ChatConnection>;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes the Chat Connection.
|
|
22
|
+
* @param input - `chatConnectionId`; optional abortSignal.
|
|
23
|
+
* @returns Resolves when the operation completes.
|
|
24
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
25
|
+
*/
|
|
26
|
+
delete(input: {
|
|
27
|
+
chatConnectionId: string;
|
|
28
|
+
} & ResourceRequestOptions): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Disables the Chat Connection.
|
|
31
|
+
* @param input - `chatConnectionId`; optional abortSignal.
|
|
32
|
+
* @returns The chat connection.
|
|
33
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
34
|
+
*/
|
|
35
|
+
disable(input: {
|
|
36
|
+
chatConnectionId: string;
|
|
37
|
+
} & ResourceRequestOptions): Promise<ChatConnection>;
|
|
38
|
+
/**
|
|
39
|
+
* Enables the Chat Connection.
|
|
40
|
+
* @param input - `chatConnectionId`; optional abortSignal.
|
|
41
|
+
* @returns The chat connection.
|
|
42
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
43
|
+
*/
|
|
44
|
+
enable(input: {
|
|
45
|
+
chatConnectionId: string;
|
|
46
|
+
} & ResourceRequestOptions): Promise<ChatConnection>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the Chat Connection.
|
|
49
|
+
* @param input - `chatConnectionId`; optional abortSignal.
|
|
50
|
+
* @returns The chat connection.
|
|
51
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
52
|
+
*/
|
|
53
|
+
get(input: {
|
|
54
|
+
chatConnectionId: string;
|
|
55
|
+
} & ResourceRequestOptions): Promise<ChatConnection>;
|
|
56
|
+
/**
|
|
57
|
+
* Lists available Chat Connection records.
|
|
58
|
+
* @param input - optional abortSignal.
|
|
59
|
+
* @returns The chat connections response.
|
|
60
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
61
|
+
*/
|
|
62
|
+
list(input?: ResourceRequestOptions): Promise<ChatConnectionsResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Lists one page of the replies and approval cards the Chat Connection has
|
|
65
|
+
* sent or tried to send, newest first, in every status. Pass `nextCursor`
|
|
66
|
+
* as `cursor` to fetch older records.
|
|
67
|
+
* @param input - `chatConnectionId`; optional `cursor`, `limit` (1 to 100, default 100), and abortSignal.
|
|
68
|
+
* @returns The page of chat deliveries.
|
|
69
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
70
|
+
*/
|
|
71
|
+
listDeliveries(input: {
|
|
72
|
+
chatConnectionId: string;
|
|
73
|
+
cursor?: string;
|
|
74
|
+
limit?: number;
|
|
75
|
+
} & ResourceRequestOptions): Promise<ChatDeliveryList>;
|
|
76
|
+
/**
|
|
77
|
+
* Sends a stuck reply or approval card again, without running a turn or
|
|
78
|
+
* tool. Use it when the previous send stopped before its outcome was known.
|
|
79
|
+
* Pass the delivery's current `attempt` as `expectedAttempt`; the repair is
|
|
80
|
+
* refused if it has changed. `previousSenderStopped` and
|
|
81
|
+
* `acceptDuplicateRisk` must be `true`: the message can appear twice. The
|
|
82
|
+
* connection must be enabled. Check `status` in the result, because a
|
|
83
|
+
* successful request does not by itself mean the message was delivered.
|
|
84
|
+
* @param input - `chatConnectionId`, `deliveryId`, the repair confirmations, and optional abortSignal.
|
|
85
|
+
* @returns The delivery outcome.
|
|
86
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
87
|
+
*/
|
|
88
|
+
repairDelivery(input: RepairChatDeliveryBody & {
|
|
89
|
+
chatConnectionId: string;
|
|
90
|
+
deliveryId: string;
|
|
91
|
+
} & ResourceRequestOptions): Promise<ChatDeliveryResult>;
|
|
92
|
+
/**
|
|
93
|
+
* Replaces the Chat Connection credentials.
|
|
94
|
+
* @param input - `chatConnectionId`; fields to change; optional abortSignal.
|
|
95
|
+
* @returns The chat connection.
|
|
96
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
97
|
+
*/
|
|
98
|
+
rotateCredentials(input: RotateChatConnectionBody & {
|
|
99
|
+
chatConnectionId: string;
|
|
100
|
+
} & ResourceRequestOptions): Promise<ChatConnection>;
|
|
101
|
+
/**
|
|
102
|
+
* Updates the Chat Connection.
|
|
103
|
+
* @param input - `chatConnectionId`; fields to change; optional abortSignal.
|
|
104
|
+
* @returns The chat connection.
|
|
105
|
+
* @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
|
|
106
|
+
*/
|
|
107
|
+
update(input: UpdateChatConnectionBody & {
|
|
108
|
+
chatConnectionId: string;
|
|
109
|
+
} & ResourceRequestOptions): Promise<ChatConnection>;
|
|
110
|
+
}
|
|
2
111
|
/**
|
|
3
112
|
* Builds the Chat Connections operations using the shared HTTP configuration.
|
|
4
113
|
* @param config - Shared authentication and transport configuration.
|
|
@@ -7,71 +7,58 @@ import { apiPath, requestJson } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export function createChatConnectionsResource(config) {
|
|
9
9
|
return {
|
|
10
|
-
/**
|
|
11
|
-
* Lists one page of chat connections.
|
|
12
|
-
*/
|
|
13
10
|
async list({ abortSignal } = {}) {
|
|
14
|
-
return await requestJson(config, "/v1/chat-connections", { signal: abortSignal }, chatConnectionsResponseSchema);
|
|
11
|
+
return await requestJson(config, "/v1/chat-connections", { credentialBearing: true, signal: abortSignal }, chatConnectionsResponseSchema);
|
|
15
12
|
},
|
|
16
|
-
/**
|
|
17
|
-
* Creates chat connections.
|
|
18
|
-
*/
|
|
19
13
|
async create({ abortSignal, ...body }) {
|
|
20
|
-
return await requestJson(config, "/v1/chat-connections", {
|
|
14
|
+
return await requestJson(config, "/v1/chat-connections", {
|
|
15
|
+
credentialBearing: true,
|
|
16
|
+
signal: abortSignal,
|
|
17
|
+
method: "POST",
|
|
18
|
+
json: body,
|
|
19
|
+
}, chatConnectionSchema);
|
|
21
20
|
},
|
|
22
|
-
/**
|
|
23
|
-
* Retrieves chat connections.
|
|
24
|
-
*/
|
|
25
21
|
async get({ chatConnectionId, abortSignal }) {
|
|
26
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "GET" }, chatConnectionSchema);
|
|
22
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { credentialBearing: true, signal: abortSignal, method: "GET" }, chatConnectionSchema);
|
|
27
23
|
},
|
|
28
|
-
/**
|
|
29
|
-
* Updates chat connections.
|
|
30
|
-
*/
|
|
31
24
|
async update({ chatConnectionId, abortSignal, ...body }) {
|
|
32
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, {
|
|
25
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, {
|
|
26
|
+
credentialBearing: true,
|
|
27
|
+
signal: abortSignal,
|
|
28
|
+
method: "PATCH",
|
|
29
|
+
json: body,
|
|
30
|
+
}, chatConnectionSchema);
|
|
33
31
|
},
|
|
34
|
-
/**
|
|
35
|
-
* Replaces the Chat Connection credentials.
|
|
36
|
-
*/
|
|
37
32
|
async rotateCredentials({ chatConnectionId, abortSignal, ...body }) {
|
|
38
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/credentials`, {
|
|
33
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/credentials`, {
|
|
34
|
+
credentialBearing: true,
|
|
35
|
+
signal: abortSignal,
|
|
36
|
+
method: "POST",
|
|
37
|
+
json: body,
|
|
38
|
+
}, chatConnectionSchema);
|
|
39
39
|
},
|
|
40
|
-
/**
|
|
41
|
-
* Checks the Chat Connection health.
|
|
42
|
-
*/
|
|
43
40
|
async checkHealth({ chatConnectionId, abortSignal }) {
|
|
44
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/health`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
41
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/health`, { credentialBearing: true, signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
45
42
|
},
|
|
46
|
-
/**
|
|
47
|
-
* Lists one page of the Chat Connection's deliveries.
|
|
48
|
-
*/
|
|
49
43
|
async listDeliveries({ chatConnectionId, abortSignal, ...query }) {
|
|
50
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries`, { signal: abortSignal, query }, chatDeliveryListSchema);
|
|
44
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries`, { credentialBearing: true, signal: abortSignal, query }, chatDeliveryListSchema);
|
|
51
45
|
},
|
|
52
|
-
/**
|
|
53
|
-
* Sends a stuck Chat delivery again.
|
|
54
|
-
*/
|
|
55
46
|
async repairDelivery({ chatConnectionId, deliveryId, abortSignal, ...body }) {
|
|
56
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries/${deliveryId}/repair`, {
|
|
47
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries/${deliveryId}/repair`, {
|
|
48
|
+
credentialBearing: true,
|
|
49
|
+
signal: abortSignal,
|
|
50
|
+
method: "POST",
|
|
51
|
+
json: body,
|
|
52
|
+
}, chatDeliveryResultSchema);
|
|
57
53
|
},
|
|
58
|
-
/**
|
|
59
|
-
* Enables chat connections.
|
|
60
|
-
*/
|
|
61
54
|
async enable({ chatConnectionId, abortSignal }) {
|
|
62
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/enable`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
55
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/enable`, { credentialBearing: true, signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
63
56
|
},
|
|
64
|
-
/**
|
|
65
|
-
* Disables chat connections.
|
|
66
|
-
*/
|
|
67
57
|
async disable({ chatConnectionId, abortSignal }) {
|
|
68
|
-
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/disable`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
58
|
+
return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/disable`, { credentialBearing: true, signal: abortSignal, method: "POST" }, chatConnectionSchema);
|
|
69
59
|
},
|
|
70
|
-
/**
|
|
71
|
-
* Deletes chat connections.
|
|
72
|
-
*/
|
|
73
60
|
async delete({ chatConnectionId, abortSignal }) {
|
|
74
|
-
await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "DELETE" });
|
|
61
|
+
await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { credentialBearing: true, signal: abortSignal, method: "DELETE" });
|
|
75
62
|
},
|
|
76
63
|
};
|
|
77
64
|
}
|