@blazingagents/sdk 0.30.0 → 0.32.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.
@@ -1,10 +1,10 @@
1
1
  import { skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "../contracts/entities/skills.js";
2
- import { isRequestAborted, requestAbortedError, requestJson, requestStream, } from "../http.js";
2
+ import { apiPath, isRequestAborted, requestAbortedError, requestJson, requestStream, } from "../http.js";
3
3
  /**
4
4
  * Builds a Skill file URL with encoded Agent, Skill, and file path values.
5
5
  */
6
6
  function fileUrl(agentId, input) {
7
- return `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(input.skillId)}/files?path=${encodeURIComponent(input.path)}`;
7
+ return apiPath `/v1/agents/${agentId}/skills/${input.skillId}/files?path=${input.path}`;
8
8
  }
9
9
  /**
10
10
  * Builds the Agent Skills operations using the shared HTTP configuration.
@@ -17,19 +17,19 @@ export function createAgentSkillsResource(config, agentId) {
17
17
  * Copies skills.
18
18
  */
19
19
  async copy({ skillId, to, abortSignal }) {
20
- return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}/copies`, { json: to, method: "POST", signal: abortSignal }, skillCopyResultsSchema);
20
+ return await requestJson(config, apiPath `/v1/agents/${agentId}/skills/${skillId}/copies`, { json: to, method: "POST", signal: abortSignal }, skillCopyResultsSchema);
21
21
  },
22
22
  /**
23
23
  * Creates skills.
24
24
  */
25
25
  async create({ abortSignal, ...body }) {
26
- return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills`, { json: body, method: "POST", signal: abortSignal }, skillDetailSchema);
26
+ return await requestJson(config, apiPath `/v1/agents/${agentId}/skills`, { json: body, method: "POST", signal: abortSignal }, skillDetailSchema);
27
27
  },
28
28
  /**
29
29
  * Deletes skills.
30
30
  */
31
31
  async delete({ skillId, abortSignal }) {
32
- await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}`, { method: "DELETE", signal: abortSignal });
32
+ await requestJson(config, apiPath `/v1/agents/${agentId}/skills/${skillId}`, { method: "DELETE", signal: abortSignal });
33
33
  },
34
34
  /**
35
35
  * Deletes a Skill file.
@@ -44,7 +44,7 @@ export function createAgentSkillsResource(config, agentId) {
44
44
  * Retrieves skills.
45
45
  */
46
46
  async get({ skillId, abortSignal }) {
47
- return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}`, { signal: abortSignal }, skillDetailSchema);
47
+ return await requestJson(config, apiPath `/v1/agents/${agentId}/skills/${skillId}`, { signal: abortSignal }, skillDetailSchema);
48
48
  },
49
49
  /**
50
50
  * Reads Skill file bytes.
@@ -67,7 +67,7 @@ export function createAgentSkillsResource(config, agentId) {
67
67
  * Lists one page of skills.
68
68
  */
69
69
  async list({ cursor, limit, abortSignal } = {}) {
70
- return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills`, { signal: abortSignal, query: { cursor, limit } }, skillsListResponseSchema);
70
+ return await requestJson(config, apiPath `/v1/agents/${agentId}/skills`, { signal: abortSignal, query: { cursor, limit } }, skillsListResponseSchema);
71
71
  },
72
72
  /**
73
73
  * Replaces a Skill file with the supplied content.
@@ -75,6 +75,7 @@ export function createAgentSkillsResource(config, agentId) {
75
75
  async putFile({ content, abortSignal, ...input }) {
76
76
  return await requestJson(config, fileUrl(agentId, input), {
77
77
  body: content,
78
+ headers: { "content-type": "application/octet-stream" },
78
79
  method: "PUT",
79
80
  signal: abortSignal,
80
81
  }, skillDetailSchema);
@@ -89,7 +90,7 @@ export function createAgentSkillsResource(config, agentId) {
89
90
  ? source.file
90
91
  : new Blob([source.file]);
91
92
  form.set("file", file, `skill.${source.type}`);
92
- return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/upload`, { body: form, method: "POST", signal: abortSignal }, skillDetailSchema);
93
+ return await requestJson(config, apiPath `/v1/agents/${agentId}/skills/upload`, { body: form, method: "POST", signal: abortSignal }, skillDetailSchema);
93
94
  },
94
95
  };
95
96
  }
@@ -1,5 +1,5 @@
1
1
  import { createTaskResponseSchema, createTaskRunResponseSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunsListResponseSchema, tasksListResponseSchema, } from "../contracts/entities/tasks.js";
2
- import { requestJson } from "../http.js";
2
+ import { apiPath, requestJson } from "../http.js";
3
3
  /**
4
4
  * `client.tasks` — CRUD + runs over `/v1/tasks`. Runs are listed/get/
5
5
  * canceled/transcripted via `/v1/tasks/:taskId/runs/...`. All lists are
@@ -29,8 +29,7 @@ export function createTasksResource(config) {
29
29
  agentId: options.agentId,
30
30
  cursor: options.cursor,
31
31
  limit: options.limit,
32
- // Stryker disable next-line ConditionalExpression: URL serialization omits an undefined query value.
33
- ...(options.userId === undefined ? {} : { userId: options.userId }),
32
+ userId: options.userId,
34
33
  },
35
34
  }, tasksListResponseSchema);
36
35
  },
@@ -38,13 +37,13 @@ export function createTasksResource(config) {
38
37
  * Retrieves tasks.
39
38
  */
40
39
  async get({ taskId, abortSignal }) {
41
- return await requestJson(config, `/v1/tasks/${taskId}`, { signal: abortSignal }, taskResponseSchema);
40
+ return await requestJson(config, apiPath `/v1/tasks/${taskId}`, { signal: abortSignal }, taskResponseSchema);
42
41
  },
43
42
  /**
44
43
  * Updates tasks.
45
44
  */
46
45
  async update({ taskId, abortSignal, ...body }) {
47
- return await requestJson(config, `/v1/tasks/${taskId}`, {
46
+ return await requestJson(config, apiPath `/v1/tasks/${taskId}`, {
48
47
  json: body,
49
48
  signal: abortSignal,
50
49
  method: "PATCH",
@@ -54,7 +53,7 @@ export function createTasksResource(config) {
54
53
  * Deletes tasks.
55
54
  */
56
55
  async delete({ taskId, abortSignal }) {
57
- await requestJson(config, `/v1/tasks/${taskId}`, {
56
+ await requestJson(config, apiPath `/v1/tasks/${taskId}`, {
58
57
  method: "DELETE",
59
58
  signal: abortSignal,
60
59
  });
@@ -63,13 +62,13 @@ export function createTasksResource(config) {
63
62
  * Creates a Task run.
64
63
  */
65
64
  async createRun({ taskId, abortSignal, ...body }) {
66
- return await requestJson(config, `/v1/tasks/${taskId}/runs`, { json: body, method: "POST", signal: abortSignal }, createTaskRunResponseSchema);
65
+ return await requestJson(config, apiPath `/v1/tasks/${taskId}/runs`, { json: body, method: "POST", signal: abortSignal }, createTaskRunResponseSchema);
67
66
  },
68
67
  /**
69
68
  * Lists one page of Task runs.
70
69
  */
71
70
  async listRuns({ taskId, ...options }) {
72
- return await requestJson(config, `/v1/tasks/${taskId}/runs`, {
71
+ return await requestJson(config, apiPath `/v1/tasks/${taskId}/runs`, {
73
72
  signal: options.abortSignal,
74
73
  query: { cursor: options.cursor, limit: options.limit },
75
74
  }, taskRunsListResponseSchema);
@@ -78,13 +77,13 @@ export function createTasksResource(config) {
78
77
  * Retrieves a Task run.
79
78
  */
80
79
  async getRun({ taskId, runId, abortSignal }) {
81
- return await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}`, { signal: abortSignal }, taskRunResponseSchema);
80
+ return await requestJson(config, apiPath `/v1/tasks/${taskId}/runs/${runId}`, { signal: abortSignal }, taskRunResponseSchema);
82
81
  },
83
82
  /**
84
83
  * Lists one page of Task run messages.
85
84
  */
86
85
  async runMessages({ taskId, runId, ...options }) {
87
- return await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}/messages`, {
86
+ return await requestJson(config, apiPath `/v1/tasks/${taskId}/runs/${runId}/messages`, {
88
87
  signal: options.abortSignal,
89
88
  query: {
90
89
  cursor: options.cursor,
@@ -97,7 +96,7 @@ export function createTasksResource(config) {
97
96
  * Requests cancellation of a Task run.
98
97
  */
99
98
  async cancelRun({ taskId, runId, abortSignal }) {
100
- await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}/cancel`, { method: "POST", signal: abortSignal });
99
+ await requestJson(config, apiPath `/v1/tasks/${taskId}/runs/${runId}/cancel`, { method: "POST", signal: abortSignal });
101
100
  },
102
101
  };
103
102
  }
@@ -1,5 +1,5 @@
1
1
  import { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewResponseSchemaForQuery, usageResponseSchema, } from "../contracts/entities/usage.js";
2
- import { requestJson } from "../http.js";
2
+ import { apiPath, requestJson } from "../http.js";
3
3
  /**
4
4
  * `client.usage` — get over `/v1/usage` (tenant-wide) and
5
5
  * `/v1/agents/:agentId/usage` (per-agent). The query shape is `UsageQuery`;
@@ -33,7 +33,7 @@ export function createUsageResource(config) {
33
33
  * Retrieves usage for one Agent.
34
34
  */
35
35
  async getForAgent({ agentId, abortSignal, ...query }) {
36
- return await requestJson(config, `/v1/agents/${agentId}/usage`, { query, signal: abortSignal }, usageResponseSchema);
36
+ return await requestJson(config, apiPath `/v1/agents/${agentId}/usage`, { query, signal: abortSignal }, usageResponseSchema);
37
37
  },
38
38
  /**
39
39
  * Retrieves usage totals, daily usage, and bounded rankings.
@@ -1,5 +1,5 @@
1
1
  import { workspaceSchema, workspacesListResponseSchema, } from "../contracts/entities/workspaces.js";
2
- import { requestJson, requestStream } from "../http.js";
2
+ import { apiPath, requestJson, requestStream } from "../http.js";
3
3
  /**
4
4
  * Builds the Workspaces operations using the shared HTTP configuration.
5
5
  * @param config - Shared authentication and transport configuration.
@@ -21,14 +21,14 @@ export function createWorkspacesResource(config) {
21
21
  * Deletes workspaces.
22
22
  */
23
23
  async delete({ workspaceId, abortSignal }) {
24
- const response = await requestStream(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { method: "DELETE", signal: abortSignal });
24
+ const response = await requestStream(config, apiPath `/v1/workspaces/${workspaceId}`, { method: "DELETE", signal: abortSignal });
25
25
  return response.status === 202 ? "pending" : "completed";
26
26
  },
27
27
  /**
28
28
  * Retrieves workspaces.
29
29
  */
30
30
  async get({ workspaceId, abortSignal }) {
31
- return await requestJson(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { signal: abortSignal }, workspaceSchema);
31
+ return await requestJson(config, apiPath `/v1/workspaces/${workspaceId}`, { signal: abortSignal }, workspaceSchema);
32
32
  },
33
33
  /**
34
34
  * Lists one page of workspaces.
@@ -47,7 +47,7 @@ export function createWorkspacesResource(config) {
47
47
  * Updates workspaces.
48
48
  */
49
49
  async update({ workspaceId, abortSignal, ...body }) {
50
- return await requestJson(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { json: body, signal: abortSignal, method: "PUT" }, workspaceSchema);
50
+ return await requestJson(config, apiPath `/v1/workspaces/${workspaceId}`, { json: body, signal: abortSignal, method: "PUT" }, workspaceSchema);
51
51
  },
52
52
  };
53
53
  }
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { ApiErrorCode } from "./contracts/api.ts";
3
3
  import type { Agent, AgentsResponse, CreateAgentBody, UpdateAgentBody } from "./contracts/entities/agents.ts";
4
4
  import type { ArtifactDownloadUrlResponse, ArtifactListItem, ArtifactsListResponse } from "./contracts/entities/artifacts.ts";
5
5
  import type { BlazingAgentsChatMessageMetadata } from "./contracts/entities/chat.ts";
6
- import type { ChatConnection, ChatConnectionsResponse, ChatDeliveriesResponse, ChatDeliveryListStatus, CreateChatConnectionBody, RotateChatConnectionBody, UpdateChatConnectionBody } from "./contracts/entities/chat-connections.ts";
6
+ import type { ChatConnection, ChatConnectionsResponse, ChatDeliveriesResponse, ChatDeliveryList, ChatDeliveryListStatus, ChatDeliveryResult, CreateChatConnectionBody, RepairChatDeliveryBody, RotateChatConnectionBody, UpdateChatConnectionBody } from "./contracts/entities/chat-connections.ts";
7
7
  import type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResponse, McpConnectionOauthConnectResponse, McpConnectionReconnectResult, McpConnectionResponse, McpConnectionsResponse, McpConnectionTestResponse, ReconnectMcpConnectionBody, UpdateMcpAttachmentBody, UpdateMcpConnectionBody } from "./contracts/entities/mcp-connections.ts";
8
8
  import type { CreateMemoryBody, MemoriesListResponse, MemoryResponse, UpdateMemoryBody } from "./contracts/entities/memories.ts";
9
9
  import type { CreateMerchantConnectionBody, MerchantBindingResponse, MerchantBindingsResponse, MerchantConnectionResponse, MerchantUsageEventResponse, MerchantUsageEventStatus, MerchantUsageEventsResponse, MerchantUsageSummaryResponse, UpdateMerchantConnectionBody, UpsertMerchantBindingBody } from "./contracts/entities/merchant.ts";
@@ -61,24 +61,8 @@ export interface BlazingAgentsOptions {
61
61
  export interface BlazingAgentsRequestOptions {
62
62
  clientRequestId: string;
63
63
  }
64
- /**
65
- * Agent operations on a user-scoped client. The API refuses the spending limit
66
- * methods for user-scoped callers.
67
- */
68
- export interface UserAgentsResource extends Omit<AgentsResource, "getSpendingLimit" | "updateSpendingLimit"> {
69
- /**
70
- * @deprecated The API always refuses this for user-scoped callers with
71
- * `forbidden` (403). Call it on the tenant client instead. It is removed
72
- * from user-scoped clients in a later release.
73
- */
74
- getSpendingLimit: AgentsResource["getSpendingLimit"];
75
- /**
76
- * @deprecated The API always refuses this for user-scoped callers with
77
- * `forbidden` (403). Call it on the tenant client instead. It is removed
78
- * from user-scoped clients in a later release.
79
- */
80
- updateSpendingLimit: AgentsResource["updateSpendingLimit"];
81
- }
64
+ /** Agent operations on a user-scoped client, which has no spending limits. */
65
+ export type UserAgentsResource = Omit<AgentsResource, "getSpendingLimit" | "updateSpendingLimit">;
82
66
  export interface UserClient {
83
67
  /**
84
68
  * Returns the Skill operations for the selected Agent.
@@ -673,7 +657,9 @@ export interface ProvidersResource {
673
657
  }
674
658
  export interface McpConnectionsResource {
675
659
  /**
676
- * Starts OAuth authorization for the MCP Connection.
660
+ * Starts OAuth authorization for the MCP Connection. The API serves this
661
+ * route only to a dashboard session (`DashboardJwt`) and refuses an API
662
+ * key, so a client built with an API key gets an error.
677
663
  * @param input - `mcpConnectionId`; optional abortSignal.
678
664
  * @returns The mcp connection oauth connect response.
679
665
  * @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
@@ -1307,6 +1293,35 @@ export interface ChatConnectionsResource {
1307
1293
  * @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
1308
1294
  */
1309
1295
  list(input?: ResourceRequestOptions): Promise<ChatConnectionsResponse>;
1296
+ /**
1297
+ * Lists one page of the replies and approval cards the Chat Connection has
1298
+ * sent or tried to send, newest first, in every status. Pass `nextCursor`
1299
+ * as `cursor` to fetch older records.
1300
+ * @param input - `chatConnectionId`; optional `cursor`, `limit` (1 to 100, default 100), and abortSignal.
1301
+ * @returns The page of chat deliveries.
1302
+ * @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
1303
+ */
1304
+ listDeliveries(input: {
1305
+ chatConnectionId: string;
1306
+ cursor?: string;
1307
+ limit?: number;
1308
+ } & ResourceRequestOptions): Promise<ChatDeliveryList>;
1309
+ /**
1310
+ * Sends a stuck reply or approval card again, without running a turn or
1311
+ * tool. Use it when the previous send stopped before its outcome was known.
1312
+ * Pass the delivery's current `attempt` as `expectedAttempt`; the repair is
1313
+ * refused if it has changed. `previousSenderStopped` and
1314
+ * `acceptDuplicateRisk` must be `true`: the message can appear twice. The
1315
+ * connection must be enabled. Check `status` in the result, because a
1316
+ * successful request does not by itself mean the message was delivered.
1317
+ * @param input - `chatConnectionId`, `deliveryId`, the repair confirmations, and optional abortSignal.
1318
+ * @returns The delivery outcome.
1319
+ * @throws BlazingAgentsError - If the request fails, is aborted, or returns an invalid response.
1320
+ */
1321
+ repairDelivery(input: RepairChatDeliveryBody & {
1322
+ chatConnectionId: string;
1323
+ deliveryId: string;
1324
+ } & ResourceRequestOptions): Promise<ChatDeliveryResult>;
1310
1325
  /**
1311
1326
  * Replaces the Chat Connection credentials.
1312
1327
  * @param input - `chatConnectionId`; fields to change; optional abortSignal.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazingagents/sdk",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "TypeScript SDK for the Blazing Agents API",
5
5
  "homepage": "https://docs.blazingagents.com",
6
6
  "bugs": {
@@ -35,7 +35,7 @@
35
35
  "fix": "ultracite fix",
36
36
  "lint": "ultracite check",
37
37
  "prepack": "npm run build",
38
- "test": "vitest run --coverage",
38
+ "test": "node scripts/check-test-imports.ts && vitest run --coverage",
39
39
  "test:consumer": "node test-consumer.mjs",
40
40
  "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.tests.json",
41
41
  "unused": "knip && knip --production --include exports,types,duplicates"