@blazingagents/sdk 0.2.2 → 0.3.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 +27 -5
- package/dist/client.d.ts +3 -1
- package/dist/client.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 +12 -12
- 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 +220 -105
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ another nonempty string supported by the selected Model. Omission on creation
|
|
|
78
78
|
means Provider default; omission on update preserves the saved value, while
|
|
79
79
|
`thinkingLevel: null` clears it. Agent and Version responses include the
|
|
80
80
|
selection, and `restoreVersion` restores it through ordinary validation.
|
|
81
|
-
Use `client.providers.getThinkingLevels(providerId, model)` to read
|
|
81
|
+
Use `client.providers.getThinkingLevels({ providerId, model })` to read
|
|
82
82
|
`{ known, levels }`. Unknown capabilities permit custom values that can still
|
|
83
83
|
be rejected during execution. Levels control reasoning, not a token/cost cap.
|
|
84
84
|
|
|
@@ -122,17 +122,39 @@ preserves user message IDs, regeneration targets, and `useChat` cancellation.
|
|
|
122
122
|
Regeneration requires an existing Session. Reconnection returns `null`; the
|
|
123
123
|
adapter does not retry interrupted Turns or resume their streams.
|
|
124
124
|
|
|
125
|
-
### Cancel
|
|
125
|
+
### Cancel requests
|
|
126
126
|
|
|
127
|
-
Pass an optional `
|
|
128
|
-
|
|
127
|
+
Pass an optional `abortSignal` in the request object for reads, writes, uploads,
|
|
128
|
+
and generation:
|
|
129
129
|
|
|
130
130
|
```ts
|
|
131
131
|
const controller = new AbortController();
|
|
132
|
-
const agents = client.agents.list({
|
|
132
|
+
const agents = client.agents.list({ abortSignal: controller.signal });
|
|
133
133
|
controller.abort();
|
|
134
134
|
await agents; // Rejects with the SDK's typed cancellation error.
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
SDK response parsing strips unknown object fields while validating required
|
|
138
138
|
fields and known field types. Request validation remains strict.
|
|
139
|
+
|
|
140
|
+
### Migrating from 0.2.x to 0.3.0
|
|
141
|
+
|
|
142
|
+
Resource and generation methods take a single request object, optional when no
|
|
143
|
+
fields are required. Move positional identifiers, body fields, and request
|
|
144
|
+
options into that object. Use `abortSignal` instead of
|
|
145
|
+
`signal`; custom fetch implementations still receive the native `signal`.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
// Before (0.2.x)
|
|
149
|
+
client.agents.update(agentId, { name: "Builder" });
|
|
150
|
+
client.sessions.messages(agentId, sessionId, { signal });
|
|
151
|
+
client.agent(agentId).skills.list();
|
|
152
|
+
|
|
153
|
+
// After (0.3.0)
|
|
154
|
+
client.agents.update({ agentId, name: "Builder", abortSignal: signal });
|
|
155
|
+
client.sessions.messages({ agentId, sessionId, abortSignal: signal });
|
|
156
|
+
client.agent({ agentId }).skills.list({ abortSignal: signal });
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`ResourceRequestOptions` replaces `ResourceReadOptions`. Cancellation stops the
|
|
160
|
+
request; it does not roll back a mutation already accepted by the server.
|
package/dist/client.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export declare class BlazingAgents {
|
|
|
13
13
|
readonly tenant: TenantResource;
|
|
14
14
|
readonly workspaces: WorkspacesResource;
|
|
15
15
|
constructor(options: BlazingAgentsOptions);
|
|
16
|
-
agent(agentId
|
|
16
|
+
agent({ agentId }: {
|
|
17
|
+
agentId: string;
|
|
18
|
+
}): AgentClient;
|
|
17
19
|
/**
|
|
18
20
|
* `POST /v1/agents/:agentId/sessions` (create, no `sessionId`) or
|
|
19
21
|
* `POST /v1/agents/:agentId/sessions/:sessionId` (resume). Returns the
|
package/dist/client.js
CHANGED
|
@@ -48,7 +48,7 @@ export class BlazingAgents {
|
|
|
48
48
|
this.tenant = createTenantResource(this.config);
|
|
49
49
|
this.workspaces = createWorkspacesResource(this.config);
|
|
50
50
|
}
|
|
51
|
-
agent(agentId) {
|
|
51
|
+
agent({ agentId }) {
|
|
52
52
|
return { skills: createAgentSkillsResource(this.config, agentId) };
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -27,7 +27,7 @@ export class BlazingAgentsDirectChatTransport extends DefaultChatTransport {
|
|
|
27
27
|
...(this.#sessionId === undefined
|
|
28
28
|
? { trigger: "submit-message" }
|
|
29
29
|
: { sessionId: this.#sessionId, trigger: input.trigger }),
|
|
30
|
-
|
|
30
|
+
abortSignal: input.abortSignal,
|
|
31
31
|
});
|
|
32
32
|
const stream = result.toStream();
|
|
33
33
|
try {
|
package/dist/generation.js
CHANGED
|
@@ -18,7 +18,7 @@ export async function chat(config, input) {
|
|
|
18
18
|
json: body,
|
|
19
19
|
method: "POST",
|
|
20
20
|
clientRequestId: input.clientRequestId,
|
|
21
|
-
...(input.
|
|
21
|
+
...(input.abortSignal ? { signal: input.abortSignal } : {}),
|
|
22
22
|
});
|
|
23
23
|
return buildChatResult(response, input.sessionId);
|
|
24
24
|
}
|
|
@@ -267,7 +267,7 @@ export async function completion(config, input) {
|
|
|
267
267
|
json: body,
|
|
268
268
|
method: "POST",
|
|
269
269
|
clientRequestId: input.clientRequestId,
|
|
270
|
-
...(input.
|
|
270
|
+
...(input.abortSignal ? { signal: input.abortSignal } : {}),
|
|
271
271
|
});
|
|
272
272
|
return buildCompletionResult(response);
|
|
273
273
|
}
|
|
@@ -306,7 +306,7 @@ export async function objectGeneration(config, input) {
|
|
|
306
306
|
json: body,
|
|
307
307
|
method: "POST",
|
|
308
308
|
clientRequestId: input.clientRequestId,
|
|
309
|
-
...(input.
|
|
309
|
+
...(input.abortSignal ? { signal: input.abortSignal } : {}),
|
|
310
310
|
});
|
|
311
311
|
return buildObjectResult(response);
|
|
312
312
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export type { CreateWorkspaceBody, UpdateWorkspaceBody, Workspace, WorkspaceNetw
|
|
|
18
18
|
export { BlazingAgentsDirectChatTransport, type BlazingAgentsDirectChatTransportOptions, } from "./direct-chat-transport.ts";
|
|
19
19
|
export { BlazingAgentsError } from "./errors.ts";
|
|
20
20
|
export { createChatRelay, createCompletionRelay, type RelayContext, type SessionOwnershipStore, } from "./relay.ts";
|
|
21
|
-
export type { AgentClient, AgentSkillsResource, AgentsListOptions, AgentsResource, AgentVersionsListOptions, ArtifactsResource, AttributionInput, BlazingAgentsErrorCode, BlazingAgentsOptions, BlazingAgentsRequestOptions, BlazingAgentsUIMessage, BlazingAgentsUIMessageChunk, ChatInput, ChatMessageInput, ChatPromptInput, ChatResult, ChatTrigger, CompletionInput, CompletionPromptIdInput, CompletionPromptInput, CompletionResult, KnownBlazingAgentsErrorCode, McpConnectionsResource, MemoriesListOptions, MemoriesResource, ObjectInput, ObjectPromptIdInput, ObjectPromptInput, ObjectResult, PromptsResource, ProvidersResource,
|
|
21
|
+
export type { AgentClient, AgentSkillsResource, AgentsListOptions, AgentsResource, AgentVersionsListOptions, ArtifactsResource, AttributionInput, BlazingAgentsErrorCode, BlazingAgentsOptions, BlazingAgentsRequestOptions, BlazingAgentsUIMessage, BlazingAgentsUIMessageChunk, ChatInput, ChatMessageInput, ChatPromptInput, ChatResult, ChatTrigger, CompletionInput, CompletionPromptIdInput, CompletionPromptInput, CompletionResult, KnownBlazingAgentsErrorCode, McpConnectionsResource, MemoriesListOptions, MemoriesResource, ObjectInput, ObjectPromptIdInput, ObjectPromptInput, ObjectResult, PromptsResource, ProvidersResource, ResourceRequestOptions, ResponseObservation, SessionsResource, SkillsListOptions, TasksResource, TenantResource, TerminalStreamResult, UsageResource, WorkspacesListOptions, WorkspacesResource, } from "./types.ts";
|
package/dist/relay.js
CHANGED
|
@@ -34,7 +34,7 @@ export function createChatRelay(options) {
|
|
|
34
34
|
message: validated.data[0],
|
|
35
35
|
messageId: body.messageId,
|
|
36
36
|
metadata: context.metadata,
|
|
37
|
-
|
|
37
|
+
abortSignal: request.signal,
|
|
38
38
|
userId: context.userId,
|
|
39
39
|
};
|
|
40
40
|
const result = await options.client.chat(body.sessionId === undefined
|
|
@@ -80,7 +80,7 @@ export function createCompletionRelay(options) {
|
|
|
80
80
|
agentId: context.agentId,
|
|
81
81
|
metadata: context.metadata,
|
|
82
82
|
prompt: body.prompt,
|
|
83
|
-
|
|
83
|
+
abortSignal: request.signal,
|
|
84
84
|
userId: context.userId,
|
|
85
85
|
version: context.version,
|
|
86
86
|
});
|
package/dist/resources/agents.js
CHANGED
|
@@ -8,49 +8,57 @@ import { requestJson } from "../http.js";
|
|
|
8
8
|
* core wire schemas (parse-on-read).
|
|
9
9
|
*/
|
|
10
10
|
export function createAgentsResource(config) {
|
|
11
|
-
const getVersion = async (agentId, version,
|
|
12
|
-
const update = async (agentId, body) => requestJson(config, `/v1/agents/${agentId}`, {
|
|
11
|
+
const getVersion = async ({ agentId, version, abortSignal, }) => requestJson(config, `/v1/agents/${agentId}/versions/${version}`, { signal: abortSignal }, agentVersionSchema);
|
|
12
|
+
const update = async ({ agentId, abortSignal, ...body }) => requestJson(config, `/v1/agents/${agentId}`, {
|
|
13
13
|
json: body,
|
|
14
|
+
signal: abortSignal,
|
|
14
15
|
method: "PUT",
|
|
15
16
|
}, agentResponseSchema);
|
|
16
17
|
return {
|
|
17
|
-
async create(body) {
|
|
18
|
+
async create({ abortSignal, ...body }) {
|
|
18
19
|
return await requestJson(config, "/v1/agents", {
|
|
19
20
|
json: body,
|
|
21
|
+
signal: abortSignal,
|
|
20
22
|
method: "POST",
|
|
21
23
|
}, agentResponseSchema);
|
|
22
24
|
},
|
|
23
25
|
async list(options = {}) {
|
|
24
26
|
return await requestJson(config, "/v1/agents", {
|
|
25
|
-
signal: options.
|
|
27
|
+
signal: options.abortSignal,
|
|
26
28
|
query: {
|
|
27
29
|
userId: options.userId,
|
|
28
30
|
workspaceId: options.workspaceId,
|
|
29
31
|
},
|
|
30
32
|
}, agentsResponseSchema);
|
|
31
33
|
},
|
|
32
|
-
async get(agentId,
|
|
33
|
-
return await requestJson(config, `/v1/agents/${agentId}`,
|
|
34
|
+
async get({ agentId, abortSignal }) {
|
|
35
|
+
return await requestJson(config, `/v1/agents/${agentId}`, { signal: abortSignal }, agentResponseSchema);
|
|
34
36
|
},
|
|
35
|
-
async disable(agentId) {
|
|
36
|
-
return await requestJson(config, `/v1/agents/${agentId}/disable`, { method: "POST" }, agentResponseSchema);
|
|
37
|
+
async disable({ agentId, abortSignal }) {
|
|
38
|
+
return await requestJson(config, `/v1/agents/${agentId}/disable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
37
39
|
},
|
|
38
|
-
async enable(agentId) {
|
|
39
|
-
return await requestJson(config, `/v1/agents/${agentId}/enable`, { method: "POST" }, agentResponseSchema);
|
|
40
|
+
async enable({ agentId, abortSignal }) {
|
|
41
|
+
return await requestJson(config, `/v1/agents/${agentId}/enable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
40
42
|
},
|
|
41
43
|
getVersion,
|
|
42
|
-
async listVersions(agentId, options
|
|
44
|
+
async listVersions({ agentId, ...options }) {
|
|
43
45
|
return await requestJson(config, `/v1/agents/${agentId}/versions`, {
|
|
44
|
-
signal: options.
|
|
46
|
+
signal: options.abortSignal,
|
|
45
47
|
query: { cursor: options.cursor, limit: options.limit },
|
|
46
48
|
}, agentVersionsResponseSchema);
|
|
47
49
|
},
|
|
48
|
-
async listMcpAttachments(agentId,
|
|
49
|
-
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments`,
|
|
50
|
+
async listMcpAttachments({ agentId, abortSignal }) {
|
|
51
|
+
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments`, { signal: abortSignal }, mcpAttachmentsResponseSchema);
|
|
50
52
|
},
|
|
51
|
-
async restoreVersion(agentId, versionNumber) {
|
|
52
|
-
const version = await getVersion(
|
|
53
|
-
|
|
53
|
+
async restoreVersion({ agentId, version: versionNumber, abortSignal }) {
|
|
54
|
+
const version = await getVersion({
|
|
55
|
+
agentId,
|
|
56
|
+
version: versionNumber,
|
|
57
|
+
abortSignal,
|
|
58
|
+
});
|
|
59
|
+
return update({
|
|
60
|
+
agentId,
|
|
61
|
+
abortSignal,
|
|
54
62
|
name: version.name,
|
|
55
63
|
model: version.model,
|
|
56
64
|
thinkingLevel: version.thinkingLevel,
|
|
@@ -63,25 +71,27 @@ export function createAgentsResource(config) {
|
|
|
63
71
|
});
|
|
64
72
|
},
|
|
65
73
|
update,
|
|
66
|
-
async updateMcpAttachment(agentId, mcpConnectionId, body) {
|
|
67
|
-
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments/${mcpConnectionId}`, { json: body, method: "PATCH" }, mcpAttachmentResponseSchema);
|
|
74
|
+
async updateMcpAttachment({ agentId, mcpConnectionId, abortSignal, ...body }) {
|
|
75
|
+
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments/${mcpConnectionId}`, { json: body, method: "PATCH", signal: abortSignal }, mcpAttachmentResponseSchema);
|
|
68
76
|
},
|
|
69
|
-
async delete(agentId, includeArtifacts) {
|
|
77
|
+
async delete({ agentId, includeArtifacts, abortSignal }) {
|
|
70
78
|
await requestJson(config, `/v1/agents/${agentId}`, {
|
|
71
79
|
method: "DELETE",
|
|
72
80
|
query: { includeArtifacts },
|
|
81
|
+
signal: abortSignal,
|
|
73
82
|
});
|
|
74
83
|
},
|
|
75
|
-
async uploadAvatar(agentId, file) {
|
|
84
|
+
async uploadAvatar({ agentId, file, abortSignal }) {
|
|
76
85
|
const form = new FormData();
|
|
77
86
|
form.append("file", file);
|
|
78
87
|
return await requestJson(config, `/v1/agents/${agentId}/avatar`, {
|
|
79
88
|
body: form,
|
|
89
|
+
signal: abortSignal,
|
|
80
90
|
method: "POST",
|
|
81
91
|
}, agentResponseSchema);
|
|
82
92
|
},
|
|
83
|
-
async removeAvatar(agentId) {
|
|
84
|
-
return await requestJson(config, `/v1/agents/${agentId}/avatar`, { method: "DELETE" }, agentResponseSchema);
|
|
93
|
+
async removeAvatar({ agentId, abortSignal }) {
|
|
94
|
+
return await requestJson(config, `/v1/agents/${agentId}/avatar`, { method: "DELETE", signal: abortSignal }, agentResponseSchema);
|
|
85
95
|
},
|
|
86
96
|
};
|
|
87
97
|
}
|
|
@@ -5,15 +5,15 @@ import { requestJson } from "../http.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export function createArtifactsResource(config) {
|
|
7
7
|
return {
|
|
8
|
-
async createDownloadUrl(artifactId) {
|
|
9
|
-
return await requestJson(config, `/v1/artifacts/${artifactId}/download-url`, { method: "POST" }, artifactDownloadUrlResponseSchema);
|
|
8
|
+
async createDownloadUrl({ artifactId, abortSignal }) {
|
|
9
|
+
return await requestJson(config, `/v1/artifacts/${artifactId}/download-url`, { method: "POST", signal: abortSignal }, artifactDownloadUrlResponseSchema);
|
|
10
10
|
},
|
|
11
|
-
async get(artifactId,
|
|
12
|
-
return await requestJson(config, `/v1/artifacts/${artifactId}`,
|
|
11
|
+
async get({ artifactId, abortSignal }) {
|
|
12
|
+
return await requestJson(config, `/v1/artifacts/${artifactId}`, { signal: abortSignal }, artifactListItemSchema);
|
|
13
13
|
},
|
|
14
|
-
async list(options = {}) {
|
|
14
|
+
async list({ abortSignal, ...options } = {}) {
|
|
15
15
|
return await requestJson(config, "/v1/artifacts", {
|
|
16
|
-
signal:
|
|
16
|
+
signal: abortSignal,
|
|
17
17
|
query: {
|
|
18
18
|
agentId: options.agentId,
|
|
19
19
|
sessionId: options.sessionId,
|
|
@@ -21,9 +21,10 @@ export function createArtifactsResource(config) {
|
|
|
21
21
|
},
|
|
22
22
|
}, artifactsListResponseSchema);
|
|
23
23
|
},
|
|
24
|
-
async delete(artifactId) {
|
|
24
|
+
async delete({ artifactId, abortSignal }) {
|
|
25
25
|
await requestJson(config, `/v1/artifacts/${artifactId}`, {
|
|
26
26
|
method: "DELETE",
|
|
27
|
+
signal: abortSignal,
|
|
27
28
|
});
|
|
28
29
|
},
|
|
29
30
|
};
|
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
import { mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionsResponseSchema, mcpConnectionTestResponseSchema, reconnectMcpConnectionBodySchema, updateMcpConnectionBodySchema, } from "../contracts/entities/mcp-connections.js";
|
|
2
2
|
import { requestJson } from "../http.js";
|
|
3
3
|
export function createMcpConnectionsResource(config) {
|
|
4
|
-
const create = (async (body) => requestJson(config, "/v1/mcp-connections", {
|
|
4
|
+
const create = (async ({ abortSignal, ...body }) => requestJson(config, "/v1/mcp-connections", {
|
|
5
5
|
json: body,
|
|
6
|
+
signal: abortSignal,
|
|
6
7
|
method: "POST",
|
|
7
8
|
}, mcpConnectionResponseSchema));
|
|
8
9
|
return {
|
|
9
|
-
async connect(
|
|
10
|
-
return await requestJson(config, `/v1/mcp-connections/${
|
|
10
|
+
async connect({ mcpConnectionId, abortSignal }) {
|
|
11
|
+
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}/connect`, { method: "POST", signal: abortSignal }, mcpConnectionOauthConnectResponseSchema);
|
|
11
12
|
},
|
|
12
13
|
create,
|
|
13
|
-
async list(
|
|
14
|
-
return await requestJson(config, "/v1/mcp-connections",
|
|
14
|
+
async list({ abortSignal } = {}) {
|
|
15
|
+
return await requestJson(config, "/v1/mcp-connections", { signal: abortSignal }, mcpConnectionsResponseSchema);
|
|
15
16
|
},
|
|
16
|
-
async get(
|
|
17
|
-
return await requestJson(config, `/v1/mcp-connections/${
|
|
17
|
+
async get({ mcpConnectionId, abortSignal }) {
|
|
18
|
+
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}`, { signal: abortSignal }, mcpConnectionResponseSchema);
|
|
18
19
|
},
|
|
19
|
-
async update(
|
|
20
|
-
return await requestJson(config, `/v1/mcp-connections/${
|
|
20
|
+
async update({ mcpConnectionId, abortSignal, ...body }) {
|
|
21
|
+
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}`, {
|
|
21
22
|
json: updateMcpConnectionBodySchema.parse(body),
|
|
23
|
+
signal: abortSignal,
|
|
22
24
|
method: "PATCH",
|
|
23
25
|
}, mcpConnectionResponseSchema);
|
|
24
26
|
},
|
|
25
|
-
async delete(
|
|
26
|
-
await requestJson(config, `/v1/mcp-connections/${
|
|
27
|
+
async delete({ mcpConnectionId, abortSignal }) {
|
|
28
|
+
await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}`, {
|
|
27
29
|
method: "DELETE",
|
|
30
|
+
signal: abortSignal,
|
|
28
31
|
});
|
|
29
32
|
},
|
|
30
|
-
async test(
|
|
31
|
-
return await requestJson(config, `/v1/mcp-connections/${
|
|
33
|
+
async test({ mcpConnectionId, abortSignal }) {
|
|
34
|
+
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}/test`, { method: "POST", signal: abortSignal }, mcpConnectionTestResponseSchema);
|
|
32
35
|
},
|
|
33
|
-
async reconnect(
|
|
34
|
-
return await requestJson(config, `/v1/mcp-connections/${
|
|
36
|
+
async reconnect({ mcpConnectionId, abortSignal, ...body }) {
|
|
37
|
+
return await requestJson(config, `/v1/mcp-connections/${mcpConnectionId}/reconnect`, {
|
|
35
38
|
json: reconnectMcpConnectionBodySchema.parse(body),
|
|
39
|
+
signal: abortSignal,
|
|
36
40
|
method: "POST",
|
|
37
41
|
}, mcpConnectionReconnectResultSchema);
|
|
38
42
|
},
|
|
@@ -7,9 +7,9 @@ import { requestJson } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export function createMemoriesResource(config) {
|
|
9
9
|
return {
|
|
10
|
-
async list(agentId, options
|
|
10
|
+
async list({ agentId, abortSignal, ...options }) {
|
|
11
11
|
return await requestJson(config, `/v1/agents/${agentId}/memories`, {
|
|
12
|
-
signal:
|
|
12
|
+
signal: abortSignal,
|
|
13
13
|
query: {
|
|
14
14
|
...(options.userId === undefined ? {} : { userId: options.userId }),
|
|
15
15
|
search: options.search,
|
|
@@ -18,17 +18,17 @@ export function createMemoriesResource(config) {
|
|
|
18
18
|
},
|
|
19
19
|
}, memoriesListResponseSchema);
|
|
20
20
|
},
|
|
21
|
-
async create(agentId, body) {
|
|
22
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories`, { json: body, method: "POST" }, memoryResponseSchema);
|
|
21
|
+
async create({ agentId, abortSignal, ...body }) {
|
|
22
|
+
return await requestJson(config, `/v1/agents/${agentId}/memories`, { json: body, signal: abortSignal, method: "POST" }, memoryResponseSchema);
|
|
23
23
|
},
|
|
24
|
-
async get(agentId, memoryId,
|
|
25
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`,
|
|
24
|
+
async get({ agentId, memoryId, abortSignal }) {
|
|
25
|
+
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { signal: abortSignal }, memoryResponseSchema);
|
|
26
26
|
},
|
|
27
|
-
async update(agentId, memoryId, body) {
|
|
28
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { json: body, method: "PATCH" }, memoryResponseSchema);
|
|
27
|
+
async update({ agentId, memoryId, abortSignal, ...body }) {
|
|
28
|
+
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { json: body, signal: abortSignal, method: "PATCH" }, memoryResponseSchema);
|
|
29
29
|
},
|
|
30
|
-
async delete(agentId, memoryId) {
|
|
31
|
-
await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { method: "DELETE" });
|
|
30
|
+
async delete({ agentId, memoryId, abortSignal }) {
|
|
31
|
+
await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { method: "DELETE", signal: abortSignal });
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -6,31 +6,34 @@ import { requestJson } from "../http.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export function createPromptsResource(config) {
|
|
8
8
|
return {
|
|
9
|
-
async create(body) {
|
|
9
|
+
async create({ abortSignal, ...body }) {
|
|
10
10
|
return await requestJson(config, "/v1/prompts", {
|
|
11
11
|
json: body,
|
|
12
|
+
signal: abortSignal,
|
|
12
13
|
method: "POST",
|
|
13
14
|
}, promptResponseSchema);
|
|
14
15
|
},
|
|
15
|
-
async list(userId,
|
|
16
|
+
async list({ userId, abortSignal } = {}) {
|
|
16
17
|
return await requestJson(config, "/v1/prompts", {
|
|
17
|
-
|
|
18
|
+
signal: abortSignal,
|
|
18
19
|
// Stryker disable next-line ConditionalExpression: URL serialization omits an undefined query value.
|
|
19
20
|
...(userId === undefined ? {} : { query: { userId } }),
|
|
20
21
|
}, promptsResponseSchema);
|
|
21
22
|
},
|
|
22
|
-
async get(promptId,
|
|
23
|
-
return await requestJson(config, `/v1/prompts/${promptId}`,
|
|
23
|
+
async get({ promptId, abortSignal }) {
|
|
24
|
+
return await requestJson(config, `/v1/prompts/${promptId}`, { signal: abortSignal }, promptResponseSchema);
|
|
24
25
|
},
|
|
25
|
-
async update(promptId, body) {
|
|
26
|
+
async update({ promptId, abortSignal, ...body }) {
|
|
26
27
|
return await requestJson(config, `/v1/prompts/${promptId}`, {
|
|
27
28
|
json: body,
|
|
29
|
+
signal: abortSignal,
|
|
28
30
|
method: "PATCH",
|
|
29
31
|
}, promptResponseSchema);
|
|
30
32
|
},
|
|
31
|
-
async delete(promptId) {
|
|
33
|
+
async delete({ promptId, abortSignal }) {
|
|
32
34
|
await requestJson(config, `/v1/prompts/${promptId}`, {
|
|
33
35
|
method: "DELETE",
|
|
36
|
+
signal: abortSignal,
|
|
34
37
|
});
|
|
35
38
|
},
|
|
36
39
|
};
|
|
@@ -5,33 +5,36 @@ import { requestJson } from "../http.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export function createProvidersResource(config) {
|
|
7
7
|
return {
|
|
8
|
-
async create(body) {
|
|
8
|
+
async create({ abortSignal, ...body }) {
|
|
9
9
|
return await requestJson(config, "/v1/providers", {
|
|
10
10
|
json: body,
|
|
11
|
+
signal: abortSignal,
|
|
11
12
|
method: "POST",
|
|
12
13
|
}, providerResponseSchema);
|
|
13
14
|
},
|
|
14
|
-
async list(
|
|
15
|
-
return await requestJson(config, "/v1/providers",
|
|
15
|
+
async list({ abortSignal } = {}) {
|
|
16
|
+
return await requestJson(config, "/v1/providers", { signal: abortSignal }, providersResponseSchema);
|
|
16
17
|
},
|
|
17
|
-
async get(
|
|
18
|
-
return await requestJson(config, `/v1/providers/${
|
|
18
|
+
async get({ providerId, abortSignal }) {
|
|
19
|
+
return await requestJson(config, `/v1/providers/${providerId}`, { signal: abortSignal }, providerResponseSchema);
|
|
19
20
|
},
|
|
20
|
-
async listModels(
|
|
21
|
-
return await requestJson(config, `/v1/providers/${
|
|
21
|
+
async listModels({ providerId, abortSignal }) {
|
|
22
|
+
return await requestJson(config, `/v1/providers/${providerId}/models`, { signal: abortSignal }, providerModelsResponseSchema);
|
|
22
23
|
},
|
|
23
|
-
async getThinkingLevels(
|
|
24
|
-
return await requestJson(config, `/v1/providers/${
|
|
24
|
+
async getThinkingLevels({ providerId, model, abortSignal }) {
|
|
25
|
+
return await requestJson(config, `/v1/providers/${providerId}/thinking-levels`, { signal: abortSignal, query: { model } }, thinkingLevelsResponseSchema);
|
|
25
26
|
},
|
|
26
|
-
async update(
|
|
27
|
-
return await requestJson(config, `/v1/providers/${
|
|
27
|
+
async update({ providerId, abortSignal, ...body }) {
|
|
28
|
+
return await requestJson(config, `/v1/providers/${providerId}`, {
|
|
28
29
|
json: body,
|
|
30
|
+
signal: abortSignal,
|
|
29
31
|
method: "PATCH",
|
|
30
32
|
}, providerResponseSchema);
|
|
31
33
|
},
|
|
32
|
-
async delete(
|
|
33
|
-
await requestJson(config, `/v1/providers/${
|
|
34
|
+
async delete({ providerId, abortSignal, ...options }) {
|
|
35
|
+
await requestJson(config, `/v1/providers/${providerId}`, {
|
|
34
36
|
method: "DELETE",
|
|
37
|
+
signal: abortSignal,
|
|
35
38
|
query: {
|
|
36
39
|
confirmVersionInvalidation: options.confirmVersionInvalidation,
|
|
37
40
|
},
|
|
@@ -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,9 @@ export function createSessionsResource(config) {
|
|
|
27
27
|
},
|
|
28
28
|
}, sessionsListResponseSchema);
|
|
29
29
|
},
|
|
30
|
-
async messages(agentId, sessionId, options
|
|
30
|
+
async messages({ agentId, sessionId, ...options }) {
|
|
31
31
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/messages`, {
|
|
32
|
-
signal: options.
|
|
32
|
+
signal: options.abortSignal,
|
|
33
33
|
query: {
|
|
34
34
|
cursor: options.cursor,
|
|
35
35
|
after: options.after,
|
|
@@ -37,15 +37,15 @@ export function createSessionsResource(config) {
|
|
|
37
37
|
},
|
|
38
38
|
}, sessionMessagesResponseSchema);
|
|
39
39
|
},
|
|
40
|
-
async joinToolApprovalContinuation(agentId, sessionId, continuationId,
|
|
41
|
-
const response = await requestStream(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approval-continuations/${continuationId}`,
|
|
40
|
+
async joinToolApprovalContinuation({ agentId, sessionId, continuationId, abortSignal, }) {
|
|
41
|
+
const response = await requestStream(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approval-continuations/${continuationId}`, { signal: abortSignal });
|
|
42
42
|
return buildTerminalStreamResult(response, "continuation");
|
|
43
43
|
},
|
|
44
|
-
async toolApprovals(agentId, sessionId,
|
|
45
|
-
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals`,
|
|
44
|
+
async toolApprovals({ agentId, sessionId, abortSignal }) {
|
|
45
|
+
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals`, { signal: abortSignal }, toolApprovalsResponseSchema);
|
|
46
46
|
},
|
|
47
|
-
async delete(agentId, sessionId, deleteArtifacts) {
|
|
48
|
-
await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { method: "DELETE", query: { deleteArtifacts } });
|
|
47
|
+
async delete({ agentId, sessionId, deleteArtifacts, abortSignal }) {
|
|
48
|
+
await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { method: "DELETE", query: { deleteArtifacts }, signal: abortSignal });
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
}
|
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
|
}
|