@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
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,50 @@ 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.
|
|
161
|
+
|
|
162
|
+
## Interactive resend
|
|
163
|
+
|
|
164
|
+
Successful interactive exchanges are saved together. Failed or canceled execution
|
|
165
|
+
leaves saved history unchanged, including the previous answer during regeneration;
|
|
166
|
+
executed usage and Tool effects remain. Retain submitted text/images until success
|
|
167
|
+
and resend edited or unchanged input through ordinary chat with a fresh message ID.
|
|
168
|
+
Stop requests cancellation; a lost response can hide a saved exchange. Reuse the
|
|
169
|
+
returned Session ID and load history normally on return. No outcome polling or
|
|
170
|
+
automatic generation retry is needed. See the [chatbot guide](https://docs.blazingagents.com/getting-started/chatbot)
|
|
171
|
+
and [working examples](https://github.com/blazingagents/examples).
|
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
|
/**
|
|
@@ -29,6 +29,36 @@ export declare const sessionsListResponseSchema: z.ZodObject<{
|
|
|
29
29
|
}, z.core.$strip>>;
|
|
30
30
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
31
31
|
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* `GET /v1/sessions/latest` list item — one per Agent: the Agent's most
|
|
34
|
+
* recently updated Session (optionally among one end user's Sessions).
|
|
35
|
+
* Carries `agentId` because the list spans the whole Tenant.
|
|
36
|
+
*/
|
|
37
|
+
export declare const latestSessionListItemSchema: z.ZodObject<{
|
|
38
|
+
agentVersion: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
messageCount: z.ZodNumber;
|
|
41
|
+
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
42
|
+
userId: z.ZodString;
|
|
43
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
44
|
+
createdAt: z.ZodISODateTime;
|
|
45
|
+
updatedAt: z.ZodISODateTime;
|
|
46
|
+
agentId: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export declare const latestSessionsListResponseSchema: z.ZodObject<{
|
|
49
|
+
data: z.ZodArray<z.ZodObject<{
|
|
50
|
+
agentVersion: z.ZodNullable<z.ZodNumber>;
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
messageCount: z.ZodNumber;
|
|
53
|
+
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
54
|
+
userId: z.ZodString;
|
|
55
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
56
|
+
createdAt: z.ZodISODateTime;
|
|
57
|
+
updatedAt: z.ZodISODateTime;
|
|
58
|
+
agentId: z.ZodString;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>;
|
|
32
62
|
/**
|
|
33
63
|
* `GET /v1/agents/{agentId}/sessions/{sessionId}/messages` — transcript as
|
|
34
64
|
* `UIMessage[]` verbatim, paginated backwards (newest page first) with an
|
|
@@ -146,6 +176,8 @@ export declare const toolApprovalDecisionResponseSchema: z.ZodObject<{
|
|
|
146
176
|
}, z.core.$strip>;
|
|
147
177
|
export type SessionListItem = z.infer<typeof sessionListItemSchema>;
|
|
148
178
|
export type SessionsListResponse = z.infer<typeof sessionsListResponseSchema>;
|
|
179
|
+
export type LatestSessionListItem = z.infer<typeof latestSessionListItemSchema>;
|
|
180
|
+
export type LatestSessionsListResponse = z.infer<typeof latestSessionsListResponseSchema>;
|
|
149
181
|
export type SessionMessage = z.infer<typeof sessionMessageSchema>;
|
|
150
182
|
export type SessionMessagesResponse = z.infer<typeof sessionMessagesResponseSchema>;
|
|
151
183
|
export type SessionMessagesQuery = z.infer<typeof sessionMessagesQuerySchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { paginatedResponseSchema } from "../api.js";
|
|
3
|
-
import { sessionIdSchema } from "../ids.js";
|
|
3
|
+
import { agentIdSchema, sessionIdSchema } from "../ids.js";
|
|
4
4
|
import { DEFAULT_SESSION_MESSAGES_LIMIT, MAX_SESSION_MESSAGES_LIMIT, } from "../limitations.js";
|
|
5
5
|
import { agentVersionNumberSchema } from "./agents.js";
|
|
6
6
|
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
@@ -24,6 +24,15 @@ export const sessionListItemSchema = z
|
|
|
24
24
|
})
|
|
25
25
|
.strip();
|
|
26
26
|
export const sessionsListResponseSchema = paginatedResponseSchema(sessionListItemSchema);
|
|
27
|
+
/**
|
|
28
|
+
* `GET /v1/sessions/latest` list item — one per Agent: the Agent's most
|
|
29
|
+
* recently updated Session (optionally among one end user's Sessions).
|
|
30
|
+
* Carries `agentId` because the list spans the whole Tenant.
|
|
31
|
+
*/
|
|
32
|
+
export const latestSessionListItemSchema = sessionListItemSchema
|
|
33
|
+
.extend({ agentId: agentIdSchema })
|
|
34
|
+
.strip();
|
|
35
|
+
export const latestSessionsListResponseSchema = paginatedResponseSchema(latestSessionListItemSchema);
|
|
27
36
|
/**
|
|
28
37
|
* `GET /v1/agents/{agentId}/sessions/{sessionId}/messages` — transcript as
|
|
29
38
|
* `UIMessage[]` verbatim, paginated backwards (newest page first) with an
|
|
@@ -10,7 +10,7 @@ export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchem
|
|
|
10
10
|
export { createPromptBodySchema, promptResponseSchema, promptSchema, promptsResponseSchema, updatePromptBodySchema, } from "./entities/prompts.ts";
|
|
11
11
|
export { createProviderBodySchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.ts";
|
|
12
12
|
export type { ToolApprovalDecisionResponse, ToolApprovalsResponse, } from "./entities/sessions.ts";
|
|
13
|
-
export { decideToolApprovalBodySchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
|
|
13
|
+
export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
|
|
14
14
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
|
|
15
15
|
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
|
|
16
16
|
export { quotaSchema, subscriptionStatusSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.ts";
|
package/dist/contracts/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema,
|
|
|
9
9
|
export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.js";
|
|
10
10
|
export { createPromptBodySchema, promptResponseSchema, promptSchema, promptsResponseSchema, updatePromptBodySchema, } from "./entities/prompts.js";
|
|
11
11
|
export { createProviderBodySchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.js";
|
|
12
|
-
export { decideToolApprovalBodySchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.js";
|
|
12
|
+
export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.js";
|
|
13
13
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.js";
|
|
14
14
|
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
|
|
15
15
|
export { quotaSchema, subscriptionStatusSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.js";
|
|
@@ -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, LatestSessionsListOptions, 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
|
},
|