@blazingagents/sdk 0.2.2 → 0.4.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 +38 -5
- package/dist/client.d.ts +3 -1
- package/dist/client.js +1 -1
- package/dist/contracts/entities/sessions.d.ts +32 -0
- package/dist/contracts/entities/sessions.js +10 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/direct-chat-transport.js +1 -1
- package/dist/generation.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/relay.js +2 -2
- package/dist/resources/agents.js +33 -23
- package/dist/resources/artifacts.js +8 -7
- package/dist/resources/mcp-connections.js +19 -15
- package/dist/resources/memories.js +10 -10
- package/dist/resources/prompts.js +10 -7
- package/dist/resources/providers.js +16 -13
- package/dist/resources/sessions.js +24 -13
- package/dist/resources/skills.js +21 -17
- package/dist/resources/tasks.js +19 -16
- package/dist/resources/tenant.js +4 -3
- package/dist/resources/usage.js +4 -4
- package/dist/resources/workspaces.js +10 -9
- package/dist/types.d.ts +232 -106
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "../contracts/entities/sessions.js";
|
|
1
|
+
import { latestSessionsListResponseSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "../contracts/entities/sessions.js";
|
|
2
2
|
import { buildTerminalStreamResult } from "../generation.js";
|
|
3
3
|
import { requestJson, requestStream } from "../http.js";
|
|
4
4
|
/**
|
|
@@ -9,16 +9,16 @@ import { requestJson, requestStream } from "../http.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export function createSessionsResource(config) {
|
|
11
11
|
return {
|
|
12
|
-
async decideToolApproval(agentId, sessionId, approvalId,
|
|
12
|
+
async decideToolApproval({ agentId, sessionId, approvalId, abortSignal, ...decision }) {
|
|
13
13
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals/${approvalId}`, {
|
|
14
14
|
json: decision,
|
|
15
15
|
method: "POST",
|
|
16
|
-
|
|
16
|
+
signal: abortSignal,
|
|
17
17
|
}, toolApprovalDecisionResponseSchema);
|
|
18
18
|
},
|
|
19
|
-
async list(agentId, options
|
|
19
|
+
async list({ agentId, ...options }) {
|
|
20
20
|
return await requestJson(config, `/v1/agents/${agentId}/sessions`, {
|
|
21
|
-
signal: options.
|
|
21
|
+
signal: options.abortSignal,
|
|
22
22
|
query: {
|
|
23
23
|
cursor: options.cursor,
|
|
24
24
|
limit: options.limit,
|
|
@@ -27,9 +27,20 @@ export function createSessionsResource(config) {
|
|
|
27
27
|
},
|
|
28
28
|
}, sessionsListResponseSchema);
|
|
29
29
|
},
|
|
30
|
-
async
|
|
30
|
+
async listLatest(options = {}) {
|
|
31
|
+
return await requestJson(config, "/v1/sessions/latest", {
|
|
32
|
+
signal: options.abortSignal,
|
|
33
|
+
query: {
|
|
34
|
+
cursor: options.cursor,
|
|
35
|
+
limit: options.limit,
|
|
36
|
+
// Stryker disable next-line ConditionalExpression: URL serialization omits an undefined query value.
|
|
37
|
+
...(options.userId === undefined ? {} : { userId: options.userId }),
|
|
38
|
+
},
|
|
39
|
+
}, latestSessionsListResponseSchema);
|
|
40
|
+
},
|
|
41
|
+
async messages({ agentId, sessionId, ...options }) {
|
|
31
42
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/messages`, {
|
|
32
|
-
signal: options.
|
|
43
|
+
signal: options.abortSignal,
|
|
33
44
|
query: {
|
|
34
45
|
cursor: options.cursor,
|
|
35
46
|
after: options.after,
|
|
@@ -37,15 +48,15 @@ export function createSessionsResource(config) {
|
|
|
37
48
|
},
|
|
38
49
|
}, sessionMessagesResponseSchema);
|
|
39
50
|
},
|
|
40
|
-
async joinToolApprovalContinuation(agentId, sessionId, continuationId,
|
|
41
|
-
const response = await requestStream(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approval-continuations/${continuationId}`,
|
|
51
|
+
async joinToolApprovalContinuation({ agentId, sessionId, continuationId, abortSignal, }) {
|
|
52
|
+
const response = await requestStream(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approval-continuations/${continuationId}`, { signal: abortSignal });
|
|
42
53
|
return buildTerminalStreamResult(response, "continuation");
|
|
43
54
|
},
|
|
44
|
-
async toolApprovals(agentId, sessionId,
|
|
45
|
-
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals`,
|
|
55
|
+
async toolApprovals({ agentId, sessionId, abortSignal }) {
|
|
56
|
+
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals`, { signal: abortSignal }, toolApprovalsResponseSchema);
|
|
46
57
|
},
|
|
47
|
-
async delete(agentId, sessionId, deleteArtifacts) {
|
|
48
|
-
await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { method: "DELETE", query: { deleteArtifacts } });
|
|
58
|
+
async delete({ agentId, sessionId, deleteArtifacts, abortSignal }) {
|
|
59
|
+
await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { method: "DELETE", query: { deleteArtifacts }, signal: abortSignal });
|
|
49
60
|
},
|
|
50
61
|
};
|
|
51
62
|
}
|
package/dist/resources/skills.js
CHANGED
|
@@ -6,52 +6,56 @@ function fileUrl(agentId, input) {
|
|
|
6
6
|
}
|
|
7
7
|
export function createAgentSkillsResource(config, agentId) {
|
|
8
8
|
return {
|
|
9
|
-
async copy({ skillId, to }) {
|
|
10
|
-
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}/copies`, { json: to, method: "POST" }, skillCopyResultsSchema);
|
|
9
|
+
async copy({ skillId, to, abortSignal }) {
|
|
10
|
+
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}/copies`, { json: to, method: "POST", signal: abortSignal }, skillCopyResultsSchema);
|
|
11
11
|
},
|
|
12
|
-
async create(body) {
|
|
13
|
-
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills`, { json: body, method: "POST" }, skillDetailSchema);
|
|
12
|
+
async create({ abortSignal, ...body }) {
|
|
13
|
+
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills`, { json: body, method: "POST", signal: abortSignal }, skillDetailSchema);
|
|
14
14
|
},
|
|
15
|
-
async delete({ skillId }) {
|
|
16
|
-
await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}`, { method: "DELETE" });
|
|
15
|
+
async delete({ skillId, abortSignal }) {
|
|
16
|
+
await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}`, { method: "DELETE", signal: abortSignal });
|
|
17
17
|
},
|
|
18
|
-
async deleteFile(input) {
|
|
18
|
+
async deleteFile({ abortSignal, ...input }) {
|
|
19
19
|
return await requestJson(config, fileUrl(agentId, input), {
|
|
20
20
|
method: "DELETE",
|
|
21
|
+
signal: abortSignal,
|
|
21
22
|
}, skillDetailSchema);
|
|
22
23
|
},
|
|
23
|
-
async get({ skillId
|
|
24
|
-
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}`,
|
|
24
|
+
async get({ skillId, abortSignal }) {
|
|
25
|
+
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/${encodeURIComponent(skillId)}`, { signal: abortSignal }, skillDetailSchema);
|
|
25
26
|
},
|
|
26
|
-
async getFile(
|
|
27
|
-
const response = await requestStream(config, fileUrl(agentId, input),
|
|
27
|
+
async getFile({ abortSignal, ...input }) {
|
|
28
|
+
const response = await requestStream(config, fileUrl(agentId, input), {
|
|
29
|
+
signal: abortSignal,
|
|
30
|
+
});
|
|
28
31
|
try {
|
|
29
32
|
return new Uint8Array(await response.arrayBuffer());
|
|
30
33
|
}
|
|
31
34
|
catch (cause) {
|
|
32
|
-
if (isRequestAborted(cause,
|
|
35
|
+
if (isRequestAborted(cause, abortSignal)) {
|
|
33
36
|
throw requestAbortedError(cause);
|
|
34
37
|
}
|
|
35
38
|
throw cause;
|
|
36
39
|
}
|
|
37
40
|
},
|
|
38
|
-
async list({ cursor, limit,
|
|
39
|
-
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills`, { signal, query: { cursor, limit } }, skillsListResponseSchema);
|
|
41
|
+
async list({ cursor, limit, abortSignal } = {}) {
|
|
42
|
+
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills`, { signal: abortSignal, query: { cursor, limit } }, skillsListResponseSchema);
|
|
40
43
|
},
|
|
41
|
-
async putFile({ content, ...input }) {
|
|
44
|
+
async putFile({ content, abortSignal, ...input }) {
|
|
42
45
|
return await requestJson(config, fileUrl(agentId, input), {
|
|
43
46
|
body: content,
|
|
44
47
|
method: "PUT",
|
|
48
|
+
signal: abortSignal,
|
|
45
49
|
}, skillDetailSchema);
|
|
46
50
|
},
|
|
47
|
-
async upload({ source }) {
|
|
51
|
+
async upload({ source, abortSignal }) {
|
|
48
52
|
const form = new FormData();
|
|
49
53
|
form.set("type", source.type);
|
|
50
54
|
const file = source.file instanceof Blob
|
|
51
55
|
? source.file
|
|
52
56
|
: new Blob([source.file]);
|
|
53
57
|
form.set("file", file, `skill.${source.type}`);
|
|
54
|
-
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/upload`, { body: form, method: "POST" }, skillDetailSchema);
|
|
58
|
+
return await requestJson(config, `/v1/agents/${encodeURIComponent(agentId)}/skills/upload`, { body: form, method: "POST", signal: abortSignal }, skillDetailSchema);
|
|
55
59
|
},
|
|
56
60
|
};
|
|
57
61
|
}
|
package/dist/resources/tasks.js
CHANGED
|
@@ -7,15 +7,16 @@ import { requestJson } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export function createTasksResource(config) {
|
|
9
9
|
return {
|
|
10
|
-
async create(body) {
|
|
10
|
+
async create({ abortSignal, ...body }) {
|
|
11
11
|
return await requestJson(config, "/v1/tasks", {
|
|
12
12
|
json: body,
|
|
13
|
+
signal: abortSignal,
|
|
13
14
|
method: "POST",
|
|
14
15
|
}, createTaskResponseSchema);
|
|
15
16
|
},
|
|
16
17
|
async list(options = {}) {
|
|
17
18
|
return await requestJson(config, "/v1/tasks", {
|
|
18
|
-
signal: options.
|
|
19
|
+
signal: options.abortSignal,
|
|
19
20
|
query: {
|
|
20
21
|
agentId: options.agentId,
|
|
21
22
|
cursor: options.cursor,
|
|
@@ -25,35 +26,37 @@ export function createTasksResource(config) {
|
|
|
25
26
|
},
|
|
26
27
|
}, tasksListResponseSchema);
|
|
27
28
|
},
|
|
28
|
-
async get(taskId,
|
|
29
|
-
return await requestJson(config, `/v1/tasks/${taskId}`,
|
|
29
|
+
async get({ taskId, abortSignal }) {
|
|
30
|
+
return await requestJson(config, `/v1/tasks/${taskId}`, { signal: abortSignal }, taskResponseSchema);
|
|
30
31
|
},
|
|
31
|
-
async update(taskId, body) {
|
|
32
|
+
async update({ taskId, abortSignal, ...body }) {
|
|
32
33
|
return await requestJson(config, `/v1/tasks/${taskId}`, {
|
|
33
34
|
json: body,
|
|
35
|
+
signal: abortSignal,
|
|
34
36
|
method: "PATCH",
|
|
35
37
|
}, taskResponseSchema);
|
|
36
38
|
},
|
|
37
|
-
async delete(taskId) {
|
|
39
|
+
async delete({ taskId, abortSignal }) {
|
|
38
40
|
await requestJson(config, `/v1/tasks/${taskId}`, {
|
|
39
41
|
method: "DELETE",
|
|
42
|
+
signal: abortSignal,
|
|
40
43
|
});
|
|
41
44
|
},
|
|
42
|
-
async createRun(taskId, body
|
|
43
|
-
return await requestJson(config, `/v1/tasks/${taskId}/runs`, { json: body, method: "POST" }, createTaskRunResponseSchema);
|
|
45
|
+
async createRun({ taskId, abortSignal, ...body }) {
|
|
46
|
+
return await requestJson(config, `/v1/tasks/${taskId}/runs`, { json: body, method: "POST", signal: abortSignal }, createTaskRunResponseSchema);
|
|
44
47
|
},
|
|
45
|
-
async listRuns(taskId, options
|
|
48
|
+
async listRuns({ taskId, ...options }) {
|
|
46
49
|
return await requestJson(config, `/v1/tasks/${taskId}/runs`, {
|
|
47
|
-
signal: options.
|
|
50
|
+
signal: options.abortSignal,
|
|
48
51
|
query: { cursor: options.cursor, limit: options.limit },
|
|
49
52
|
}, taskRunsListResponseSchema);
|
|
50
53
|
},
|
|
51
|
-
async getRun(taskId, runId,
|
|
52
|
-
return await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}`,
|
|
54
|
+
async getRun({ taskId, runId, abortSignal }) {
|
|
55
|
+
return await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}`, { signal: abortSignal }, taskRunResponseSchema);
|
|
53
56
|
},
|
|
54
|
-
async runMessages(taskId, runId, options
|
|
57
|
+
async runMessages({ taskId, runId, ...options }) {
|
|
55
58
|
return await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}/messages`, {
|
|
56
|
-
signal: options.
|
|
59
|
+
signal: options.abortSignal,
|
|
57
60
|
query: {
|
|
58
61
|
cursor: options.cursor,
|
|
59
62
|
after: options.after,
|
|
@@ -61,8 +64,8 @@ export function createTasksResource(config) {
|
|
|
61
64
|
},
|
|
62
65
|
}, taskRunMessagesResponseSchema);
|
|
63
66
|
},
|
|
64
|
-
async cancelRun(taskId, runId) {
|
|
65
|
-
await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}/cancel`, { method: "POST" });
|
|
67
|
+
async cancelRun({ taskId, runId, abortSignal }) {
|
|
68
|
+
await requestJson(config, `/v1/tasks/${taskId}/runs/${runId}/cancel`, { method: "POST", signal: abortSignal });
|
|
66
69
|
},
|
|
67
70
|
};
|
|
68
71
|
}
|
package/dist/resources/tenant.js
CHANGED
|
@@ -6,12 +6,13 @@ import { requestJson } from "../http.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export function createTenantResource(config) {
|
|
8
8
|
return {
|
|
9
|
-
async get(
|
|
10
|
-
return await requestJson(config, "/v1/tenant",
|
|
9
|
+
async get({ abortSignal } = {}) {
|
|
10
|
+
return await requestJson(config, "/v1/tenant", { signal: abortSignal }, tenantSettingsResponseSchema);
|
|
11
11
|
},
|
|
12
|
-
async patch(body) {
|
|
12
|
+
async patch({ abortSignal, ...body }) {
|
|
13
13
|
return await requestJson(config, "/v1/tenant", {
|
|
14
14
|
json: body,
|
|
15
|
+
signal: abortSignal,
|
|
15
16
|
method: "PATCH",
|
|
16
17
|
}, tenantSettingsResponseSchema);
|
|
17
18
|
},
|
package/dist/resources/usage.js
CHANGED
|
@@ -7,14 +7,14 @@ import { requestJson } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export function createUsageResource(config) {
|
|
9
9
|
return {
|
|
10
|
-
async get({
|
|
10
|
+
async get({ abortSignal, ...query } = {}) {
|
|
11
11
|
return await requestJson(config, "/v1/usage", {
|
|
12
12
|
query,
|
|
13
|
-
signal,
|
|
13
|
+
signal: abortSignal,
|
|
14
14
|
}, usageResponseSchema);
|
|
15
15
|
},
|
|
16
|
-
async getForAgent(agentId,
|
|
17
|
-
return await requestJson(config, `/v1/agents/${agentId}/usage`, { query, signal }, usageResponseSchema);
|
|
16
|
+
async getForAgent({ agentId, abortSignal, ...query }) {
|
|
17
|
+
return await requestJson(config, `/v1/agents/${agentId}/usage`, { query, signal: abortSignal }, usageResponseSchema);
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -2,22 +2,23 @@ import { workspaceSchema, workspacesListResponseSchema, } from "../contracts/ent
|
|
|
2
2
|
import { requestJson, requestStream } from "../http.js";
|
|
3
3
|
export function createWorkspacesResource(config) {
|
|
4
4
|
return {
|
|
5
|
-
async create(body = {}) {
|
|
5
|
+
async create({ abortSignal, ...body } = {}) {
|
|
6
6
|
return await requestJson(config, "/v1/workspaces", {
|
|
7
7
|
json: body,
|
|
8
|
+
signal: abortSignal,
|
|
8
9
|
method: "POST",
|
|
9
10
|
}, workspaceSchema);
|
|
10
11
|
},
|
|
11
|
-
async delete({ workspaceId }) {
|
|
12
|
-
const response = await requestStream(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { method: "DELETE" });
|
|
12
|
+
async delete({ workspaceId, abortSignal }) {
|
|
13
|
+
const response = await requestStream(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { method: "DELETE", signal: abortSignal });
|
|
13
14
|
return response.status === 202 ? "pending" : "completed";
|
|
14
15
|
},
|
|
15
|
-
async get({ workspaceId
|
|
16
|
-
return await requestJson(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`,
|
|
16
|
+
async get({ workspaceId, abortSignal }) {
|
|
17
|
+
return await requestJson(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { signal: abortSignal }, workspaceSchema);
|
|
17
18
|
},
|
|
18
|
-
async list(options = {}) {
|
|
19
|
+
async list({ abortSignal, ...options } = {}) {
|
|
19
20
|
return await requestJson(config, "/v1/workspaces", {
|
|
20
|
-
signal:
|
|
21
|
+
signal: abortSignal,
|
|
21
22
|
query: {
|
|
22
23
|
cursor: options.cursor,
|
|
23
24
|
limit: options.limit,
|
|
@@ -25,8 +26,8 @@ export function createWorkspacesResource(config) {
|
|
|
25
26
|
},
|
|
26
27
|
}, workspacesListResponseSchema);
|
|
27
28
|
},
|
|
28
|
-
async update({ workspaceId, ...body }) {
|
|
29
|
-
return await requestJson(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { json: body, method: "PUT" }, workspaceSchema);
|
|
29
|
+
async update({ workspaceId, abortSignal, ...body }) {
|
|
30
|
+
return await requestJson(config, `/v1/workspaces/${encodeURIComponent(workspaceId)}`, { json: body, signal: abortSignal, method: "PUT" }, workspaceSchema);
|
|
30
31
|
},
|
|
31
32
|
};
|
|
32
33
|
}
|