@blazingagents/sdk 0.2.1 → 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 +115 -344
- package/dist/client.d.ts +3 -1
- package/dist/client.js +1 -1
- package/dist/contracts/api.d.ts +1 -1
- package/dist/contracts/api.js +1 -1
- package/dist/contracts/entities/agents.d.ts +14 -7
- package/dist/contracts/entities/agents.js +7 -3
- package/dist/contracts/entities/artifacts.d.ts +9 -9
- package/dist/contracts/entities/artifacts.js +5 -5
- package/dist/contracts/entities/chat.d.ts +7 -7
- package/dist/contracts/entities/chat.js +5 -5
- package/dist/contracts/entities/mcp-connections.d.ts +18 -18
- package/dist/contracts/entities/mcp-connections.js +13 -13
- package/dist/contracts/entities/memories.d.ts +5 -5
- package/dist/contracts/entities/memories.js +2 -2
- package/dist/contracts/entities/prompts.d.ts +4 -4
- package/dist/contracts/entities/prompts.js +2 -2
- package/dist/contracts/entities/providers.d.ts +12 -7
- package/dist/contracts/entities/providers.js +12 -6
- package/dist/contracts/entities/sessions.d.ts +10 -10
- package/dist/contracts/entities/sessions.js +6 -6
- package/dist/contracts/entities/skills.d.ts +18 -18
- package/dist/contracts/entities/skills.js +6 -6
- package/dist/contracts/entities/tasks.d.ts +56 -46
- package/dist/contracts/entities/tasks.js +25 -16
- package/dist/contracts/entities/tenants.d.ts +6 -6
- package/dist/contracts/entities/tenants.js +4 -4
- package/dist/contracts/entities/usage.d.ts +5 -5
- package/dist/contracts/entities/usage.js +3 -3
- package/dist/contracts/entities/workspaces.d.ts +9 -9
- package/dist/contracts/entities/workspaces.js +7 -2
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/direct-chat-transport.d.ts +16 -0
- package/dist/direct-chat-transport.js +49 -0
- package/dist/generation.js +4 -3
- package/dist/http.d.ts +2 -0
- package/dist/http.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/relay.js +2 -2
- package/dist/resources/agents.js +37 -22
- package/dist/resources/artifacts.js +8 -6
- package/dist/resources/mcp-connections.js +19 -15
- package/dist/resources/memories.js +10 -9
- package/dist/resources/prompts.js +10 -6
- package/dist/resources/providers.js +18 -12
- package/dist/resources/sessions.js +12 -10
- package/dist/resources/skills.js +33 -21
- package/dist/resources/tasks.js +22 -14
- package/dist/resources/tenant.js +4 -3
- package/dist/resources/usage.js +4 -3
- package/dist/resources/workspaces.js +10 -8
- package/dist/types.d.ts +225 -104
- package/package.json +2 -2
|
@@ -61,13 +61,13 @@ export declare const usageBucketSchema: z.ZodObject<{
|
|
|
61
61
|
outputTokens: z.ZodNumber;
|
|
62
62
|
requestCount: z.ZodNumber;
|
|
63
63
|
durationMs: z.ZodNumber;
|
|
64
|
-
}, z.core.$
|
|
64
|
+
}, z.core.$strip>;
|
|
65
65
|
export declare const usageTotalsSchema: z.ZodObject<{
|
|
66
66
|
inputTokens: z.ZodNumber;
|
|
67
67
|
outputTokens: z.ZodNumber;
|
|
68
68
|
requestCount: z.ZodNumber;
|
|
69
69
|
durationMs: z.ZodNumber;
|
|
70
|
-
}, z.core.$
|
|
70
|
+
}, z.core.$strip>;
|
|
71
71
|
export declare const usageResponseSchema: z.ZodObject<{
|
|
72
72
|
buckets: z.ZodArray<z.ZodObject<{
|
|
73
73
|
day: z.ZodNullable<z.ZodString>;
|
|
@@ -80,14 +80,14 @@ export declare const usageResponseSchema: z.ZodObject<{
|
|
|
80
80
|
outputTokens: z.ZodNumber;
|
|
81
81
|
requestCount: z.ZodNumber;
|
|
82
82
|
durationMs: z.ZodNumber;
|
|
83
|
-
}, z.core.$
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
84
|
totals: z.ZodObject<{
|
|
85
85
|
inputTokens: z.ZodNumber;
|
|
86
86
|
outputTokens: z.ZodNumber;
|
|
87
87
|
requestCount: z.ZodNumber;
|
|
88
88
|
durationMs: z.ZodNumber;
|
|
89
|
-
}, z.core.$
|
|
90
|
-
}, z.core.$
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
91
|
export type UsageGroupBy = z.infer<typeof usageGroupBySchema>;
|
|
92
92
|
export type UsageQuery = z.infer<typeof usageQuerySchema>;
|
|
93
93
|
export type UsageBucket = z.infer<typeof usageBucketSchema>;
|
|
@@ -100,7 +100,7 @@ export const usageBucketSchema = z
|
|
|
100
100
|
requestCount: z.number().int().nonnegative(),
|
|
101
101
|
durationMs: z.number().int().nonnegative(),
|
|
102
102
|
})
|
|
103
|
-
.
|
|
103
|
+
.strip();
|
|
104
104
|
export const usageTotalsSchema = z
|
|
105
105
|
.object({
|
|
106
106
|
inputTokens: z.number().int().nonnegative(),
|
|
@@ -108,10 +108,10 @@ export const usageTotalsSchema = z
|
|
|
108
108
|
requestCount: z.number().int().nonnegative(),
|
|
109
109
|
durationMs: z.number().int().nonnegative(),
|
|
110
110
|
})
|
|
111
|
-
.
|
|
111
|
+
.strip();
|
|
112
112
|
export const usageResponseSchema = z
|
|
113
113
|
.object({
|
|
114
114
|
buckets: z.array(usageBucketSchema),
|
|
115
115
|
totals: usageTotalsSchema,
|
|
116
116
|
})
|
|
117
|
-
.
|
|
117
|
+
.strip();
|
|
@@ -21,15 +21,15 @@ export declare const workspaceSchema: z.ZodObject<{
|
|
|
21
21
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
22
22
|
networkPolicy: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
23
23
|
mode: z.ZodLiteral<"unrestricted">;
|
|
24
|
-
}, z.core.$
|
|
24
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
25
25
|
allowedHosts: z.ZodArray<z.ZodString>;
|
|
26
26
|
mode: z.ZodLiteral<"allowlist">;
|
|
27
|
-
}, z.core.$
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
28
|
mode: z.ZodLiteral<"offline">;
|
|
29
|
-
}, z.core.$
|
|
29
|
+
}, z.core.$strip>], "mode">;
|
|
30
30
|
createdAt: z.ZodISODateTime;
|
|
31
31
|
updatedAt: z.ZodISODateTime;
|
|
32
|
-
}, z.core.$
|
|
32
|
+
}, z.core.$strip>;
|
|
33
33
|
export declare const createWorkspaceBodySchema: z.ZodObject<{
|
|
34
34
|
name: z.ZodOptional<z.ZodString>;
|
|
35
35
|
userId: z.ZodDefault<z.ZodString>;
|
|
@@ -69,17 +69,17 @@ export declare const workspacesListResponseSchema: z.ZodObject<{
|
|
|
69
69
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
70
70
|
networkPolicy: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
71
71
|
mode: z.ZodLiteral<"unrestricted">;
|
|
72
|
-
}, z.core.$
|
|
72
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
73
73
|
allowedHosts: z.ZodArray<z.ZodString>;
|
|
74
74
|
mode: z.ZodLiteral<"allowlist">;
|
|
75
|
-
}, z.core.$
|
|
75
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
76
76
|
mode: z.ZodLiteral<"offline">;
|
|
77
|
-
}, z.core.$
|
|
77
|
+
}, z.core.$strip>], "mode">;
|
|
78
78
|
createdAt: z.ZodISODateTime;
|
|
79
79
|
updatedAt: z.ZodISODateTime;
|
|
80
|
-
}, z.core.$
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
81
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
82
|
-
}, z.core.$
|
|
82
|
+
}, z.core.$strip>;
|
|
83
83
|
export type Workspace = z.infer<typeof workspaceSchema>;
|
|
84
84
|
export type WorkspaceBackup = z.infer<typeof workspaceBackupSchema>;
|
|
85
85
|
export type WorkspaceNetworkPolicy = z.infer<typeof workspaceNetworkPolicySchema>;
|
|
@@ -26,6 +26,11 @@ export const workspaceNetworkPolicySchema = z.discriminatedUnion("mode", [
|
|
|
26
26
|
.strict(),
|
|
27
27
|
z.object({ mode: z.literal("offline") }).strict(),
|
|
28
28
|
]);
|
|
29
|
+
const workspaceNetworkPolicyResponseSchema = z.discriminatedUnion("mode", [
|
|
30
|
+
workspaceNetworkPolicySchema.options[0].strip(),
|
|
31
|
+
workspaceNetworkPolicySchema.options[1].strip(),
|
|
32
|
+
workspaceNetworkPolicySchema.options[2].strip(),
|
|
33
|
+
]);
|
|
29
34
|
export const workspaceSchema = z
|
|
30
35
|
.object({
|
|
31
36
|
id: workspaceIdSchema,
|
|
@@ -33,11 +38,11 @@ export const workspaceSchema = z
|
|
|
33
38
|
name: workspaceNameSchema.nullable(),
|
|
34
39
|
userId: userIdSchema,
|
|
35
40
|
metadata: metadataSchema,
|
|
36
|
-
networkPolicy:
|
|
41
|
+
networkPolicy: workspaceNetworkPolicyResponseSchema,
|
|
37
42
|
createdAt: z.iso.datetime({ offset: true }),
|
|
38
43
|
updatedAt: z.iso.datetime({ offset: true }),
|
|
39
44
|
})
|
|
40
|
-
.
|
|
45
|
+
.strip();
|
|
41
46
|
export const createWorkspaceBodySchema = z
|
|
42
47
|
.object({
|
|
43
48
|
name: workspaceNameSchema.optional(),
|
|
@@ -8,7 +8,7 @@ export { blazingAgentsChatMessageMetadataSchema, chatModeSchema, chatRequestBody
|
|
|
8
8
|
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.ts";
|
|
9
9
|
export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.ts";
|
|
10
10
|
export { createPromptBodySchema, promptResponseSchema, promptSchema, promptsResponseSchema, updatePromptBodySchema, } from "./entities/prompts.ts";
|
|
11
|
-
export { createProviderBodySchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, updateProviderBodySchema, } from "./entities/providers.ts";
|
|
11
|
+
export { createProviderBodySchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.ts";
|
|
12
12
|
export type { ToolApprovalDecisionResponse, ToolApprovalsResponse, } from "./entities/sessions.ts";
|
|
13
13
|
export { decideToolApprovalBodySchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
|
|
14
14
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
|
package/dist/contracts/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { blazingAgentsChatMessageMetadataSchema, chatModeSchema, chatRequestBody
|
|
|
8
8
|
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.js";
|
|
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
|
-
export { createProviderBodySchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, updateProviderBodySchema, } from "./entities/providers.js";
|
|
11
|
+
export { createProviderBodySchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.js";
|
|
12
12
|
export { decideToolApprovalBodySchema, 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";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ChatTransport, DefaultChatTransport, type UIMessage } from "ai";
|
|
2
|
+
import type { BlazingAgents } from "./client.ts";
|
|
3
|
+
export interface BlazingAgentsDirectChatTransportOptions {
|
|
4
|
+
agentId: string;
|
|
5
|
+
client: BlazingAgents;
|
|
6
|
+
/** Receives the Session ID before the response stream is consumed. */
|
|
7
|
+
onSessionId?: (sessionId: string) => Promise<void> | void;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Connects useChat directly to the SDK, including native streaming fetch clients. */
|
|
11
|
+
export declare class BlazingAgentsDirectChatTransport<UI_MESSAGE extends UIMessage = UIMessage> extends DefaultChatTransport<UI_MESSAGE> {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(options: BlazingAgentsDirectChatTransportOptions);
|
|
14
|
+
sendMessages(input: Parameters<ChatTransport<UI_MESSAGE>["sendMessages"]>[0]): Promise<ReadableStream<import("ai").UIMessageChunk<unknown, import("ai").UIDataTypes>>>;
|
|
15
|
+
reconnectToStream(_input: Parameters<ChatTransport<UI_MESSAGE>["reconnectToStream"]>[0]): Promise<null>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DefaultChatTransport } from "ai";
|
|
2
|
+
import { sessionIdSchema } from "./contracts/ids.js";
|
|
3
|
+
/** Connects useChat directly to the SDK, including native streaming fetch clients. */
|
|
4
|
+
export class BlazingAgentsDirectChatTransport extends DefaultChatTransport {
|
|
5
|
+
#options;
|
|
6
|
+
#sessionId;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super();
|
|
9
|
+
this.#options = options;
|
|
10
|
+
this.#sessionId =
|
|
11
|
+
options.sessionId === undefined
|
|
12
|
+
? undefined
|
|
13
|
+
: sessionIdSchema.parse(options.sessionId);
|
|
14
|
+
}
|
|
15
|
+
async sendMessages(input) {
|
|
16
|
+
if (input.trigger === "regenerate-message" && !this.#sessionId) {
|
|
17
|
+
throw new Error("Regeneration requires an existing Session.");
|
|
18
|
+
}
|
|
19
|
+
const message = input.messages.findLast((item) => item.role === "user");
|
|
20
|
+
if (!message) {
|
|
21
|
+
throw new Error("Chat submission requires a user message.");
|
|
22
|
+
}
|
|
23
|
+
const result = await this.#options.client.chat({
|
|
24
|
+
agentId: this.#options.agentId,
|
|
25
|
+
message,
|
|
26
|
+
messageId: input.messageId,
|
|
27
|
+
...(this.#sessionId === undefined
|
|
28
|
+
? { trigger: "submit-message" }
|
|
29
|
+
: { sessionId: this.#sessionId, trigger: input.trigger }),
|
|
30
|
+
abortSignal: input.abortSignal,
|
|
31
|
+
});
|
|
32
|
+
const stream = result.toStream();
|
|
33
|
+
try {
|
|
34
|
+
const sessionId = await result.sessionId;
|
|
35
|
+
if (this.#sessionId === undefined) {
|
|
36
|
+
this.#sessionId = sessionId;
|
|
37
|
+
await this.#options.onSessionId?.(sessionId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
await stream.cancel(error).catch(() => undefined);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
return this.processResponseStream(stream);
|
|
45
|
+
}
|
|
46
|
+
reconnectToStream(_input) {
|
|
47
|
+
return Promise.resolve(null);
|
|
48
|
+
}
|
|
49
|
+
}
|
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
|
}
|
|
@@ -131,6 +131,7 @@ export function buildTerminalStreamResult(response, resourceName) {
|
|
|
131
131
|
};
|
|
132
132
|
return {
|
|
133
133
|
requestId,
|
|
134
|
+
toStream: claimBody,
|
|
134
135
|
toResponse: () => {
|
|
135
136
|
const headers = replacementResponseHeaders(requestId, location);
|
|
136
137
|
headers.set("content-type", "text/event-stream");
|
|
@@ -266,7 +267,7 @@ export async function completion(config, input) {
|
|
|
266
267
|
json: body,
|
|
267
268
|
method: "POST",
|
|
268
269
|
clientRequestId: input.clientRequestId,
|
|
269
|
-
...(input.
|
|
270
|
+
...(input.abortSignal ? { signal: input.abortSignal } : {}),
|
|
270
271
|
});
|
|
271
272
|
return buildCompletionResult(response);
|
|
272
273
|
}
|
|
@@ -305,7 +306,7 @@ export async function objectGeneration(config, input) {
|
|
|
305
306
|
json: body,
|
|
306
307
|
method: "POST",
|
|
307
308
|
clientRequestId: input.clientRequestId,
|
|
308
|
-
...(input.
|
|
309
|
+
...(input.abortSignal ? { signal: input.abortSignal } : {}),
|
|
309
310
|
});
|
|
310
311
|
return buildObjectResult(response);
|
|
311
312
|
}
|
package/dist/http.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare function requestJson<T>(config: HttpConfig, path: string, options
|
|
|
13
13
|
* Non-2xx bodies are decoded before a caller can observe a streaming body.
|
|
14
14
|
*/
|
|
15
15
|
export declare function requestStream(config: HttpConfig, path: string, options?: RequestOptions): Promise<Response>;
|
|
16
|
+
export declare function isRequestAborted(cause: unknown, signal?: AbortSignal): boolean;
|
|
17
|
+
export declare function requestAbortedError(cause: unknown): BlazingAgentsError;
|
|
16
18
|
/**
|
|
17
19
|
* Decodes a response body with the tolerant consumer schema. Unknown future
|
|
18
20
|
* codes and fields remain valid; malformed responses never infer a domain
|
package/dist/http.js
CHANGED
|
@@ -135,14 +135,14 @@ async function errorFromResponse(response, signal) {
|
|
|
135
135
|
}
|
|
136
136
|
return parseErrorEnvelope(read.diagnosticBody, response.status, headers);
|
|
137
137
|
}
|
|
138
|
-
function isRequestAborted(cause, signal) {
|
|
138
|
+
export function isRequestAborted(cause, signal) {
|
|
139
139
|
return (signal?.aborted === true ||
|
|
140
140
|
(cause !== null &&
|
|
141
141
|
typeof cause === "object" &&
|
|
142
142
|
"name" in cause &&
|
|
143
143
|
cause.name === "AbortError"));
|
|
144
144
|
}
|
|
145
|
-
function requestAbortedError(cause) {
|
|
145
|
+
export function requestAbortedError(cause) {
|
|
146
146
|
return new BlazingAgentsError({
|
|
147
147
|
code: "request_aborted",
|
|
148
148
|
message: cause instanceof Error ? cause.message : REQUEST_ABORTED_MESSAGE,
|
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ export { BlazingAgents } from "./client.ts";
|
|
|
12
12
|
export type { Agent, AgentResponse, AgentsResponse, AgentVersion, AgentVersionsListQuery, AgentVersionsResponse, CreateAgentBody, UpdateAgentBody, } from "./contracts/entities/agents.ts";
|
|
13
13
|
export type { ArtifactDownloadUrlResponse, ArtifactListItem, ArtifactsListResponse, } from "./contracts/entities/artifacts.ts";
|
|
14
14
|
export type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResponse, McpConnectionAuthType, McpConnectionOauthConnectResponse, McpConnectionReconnectResult, McpConnectionResponse, McpConnectionStatus, McpConnectionTestResponse, ReconnectMcpConnectionBody, UpdateMcpAttachmentBody, UpdateMcpConnectionBody, } from "./contracts/entities/mcp-connections.ts";
|
|
15
|
-
export type { CreateProviderBody, ProviderModel, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ProviderType, UpdateProviderBody, } from "./contracts/entities/providers.ts";
|
|
15
|
+
export type { CreateProviderBody, ProviderModel, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ProviderType, ThinkingLevelsResponse, UpdateProviderBody, } from "./contracts/entities/providers.ts";
|
|
16
16
|
export type { CreateSkillBody, Skill, SkillArchiveType, SkillCopyResult, SkillCopyResults, SkillDetail, SkillFile, SkillsListResponse, } from "./contracts/entities/skills.ts";
|
|
17
17
|
export type { CreateWorkspaceBody, UpdateWorkspaceBody, Workspace, WorkspaceNetworkPolicy, WorkspacesListResponse, } from "./contracts/entities/workspaces.ts";
|
|
18
|
+
export { BlazingAgentsDirectChatTransport, type BlazingAgentsDirectChatTransportOptions, } from "./direct-chat-transport.ts";
|
|
18
19
|
export { BlazingAgentsError } from "./errors.ts";
|
|
19
20
|
export { createChatRelay, createCompletionRelay, type RelayContext, type SessionOwnershipStore, } from "./relay.ts";
|
|
20
|
-
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, ResponseObservation, SessionsResource, SkillsListOptions, TasksResource, TenantResource, TerminalStreamResult, UsageResource, WorkspacesListOptions, WorkspacesResource, } from "./types.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, ResourceRequestOptions, ResponseObservation, SessionsResource, SkillsListOptions, TasksResource, TenantResource, TerminalStreamResult, UsageResource, WorkspacesListOptions, WorkspacesResource, } from "./types.ts";
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,6 @@
|
|
|
9
9
|
// biome-ignore lint/performance/noBarrelFile: package entry point
|
|
10
10
|
export { BlazingAgentsChatTransport, } from "./chat-transport.js";
|
|
11
11
|
export { BlazingAgents } from "./client.js";
|
|
12
|
+
export { BlazingAgentsDirectChatTransport, } from "./direct-chat-transport.js";
|
|
12
13
|
export { BlazingAgentsError } from "./errors.js";
|
|
13
14
|
export { createChatRelay, createCompletionRelay, } from "./relay.js";
|
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,47 +8,60 @@ 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) => requestJson(config, `/v1/agents/${agentId}/versions/${version}`, {}, agentVersionSchema);
|
|
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", {
|
|
27
|
+
signal: options.abortSignal,
|
|
25
28
|
query: {
|
|
26
29
|
userId: options.userId,
|
|
27
30
|
workspaceId: options.workspaceId,
|
|
28
31
|
},
|
|
29
32
|
}, agentsResponseSchema);
|
|
30
33
|
},
|
|
31
|
-
async get(agentId) {
|
|
32
|
-
return await requestJson(config, `/v1/agents/${agentId}`, {}, agentResponseSchema);
|
|
34
|
+
async get({ agentId, abortSignal }) {
|
|
35
|
+
return await requestJson(config, `/v1/agents/${agentId}`, { signal: abortSignal }, agentResponseSchema);
|
|
33
36
|
},
|
|
34
|
-
async disable(agentId) {
|
|
35
|
-
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);
|
|
36
39
|
},
|
|
37
|
-
async enable(agentId) {
|
|
38
|
-
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);
|
|
39
42
|
},
|
|
40
43
|
getVersion,
|
|
41
|
-
async listVersions(agentId, options
|
|
42
|
-
return await requestJson(config, `/v1/agents/${agentId}/versions`, {
|
|
44
|
+
async listVersions({ agentId, ...options }) {
|
|
45
|
+
return await requestJson(config, `/v1/agents/${agentId}/versions`, {
|
|
46
|
+
signal: options.abortSignal,
|
|
47
|
+
query: { cursor: options.cursor, limit: options.limit },
|
|
48
|
+
}, agentVersionsResponseSchema);
|
|
43
49
|
},
|
|
44
|
-
async listMcpAttachments(agentId) {
|
|
45
|
-
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments`, {}, mcpAttachmentsResponseSchema);
|
|
50
|
+
async listMcpAttachments({ agentId, abortSignal }) {
|
|
51
|
+
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments`, { signal: abortSignal }, mcpAttachmentsResponseSchema);
|
|
46
52
|
},
|
|
47
|
-
async restoreVersion(agentId, versionNumber) {
|
|
48
|
-
const version = await getVersion(
|
|
49
|
-
|
|
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,
|
|
50
62
|
name: version.name,
|
|
51
63
|
model: version.model,
|
|
64
|
+
thinkingLevel: version.thinkingLevel,
|
|
52
65
|
providerId: version.providerId,
|
|
53
66
|
memoryInjectionEnabled: version.memoryInjectionEnabled,
|
|
54
67
|
tools: version.tools,
|
|
@@ -58,25 +71,27 @@ export function createAgentsResource(config) {
|
|
|
58
71
|
});
|
|
59
72
|
},
|
|
60
73
|
update,
|
|
61
|
-
async updateMcpAttachment(agentId, mcpConnectionId, body) {
|
|
62
|
-
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);
|
|
63
76
|
},
|
|
64
|
-
async delete(agentId, includeArtifacts) {
|
|
77
|
+
async delete({ agentId, includeArtifacts, abortSignal }) {
|
|
65
78
|
await requestJson(config, `/v1/agents/${agentId}`, {
|
|
66
79
|
method: "DELETE",
|
|
67
80
|
query: { includeArtifacts },
|
|
81
|
+
signal: abortSignal,
|
|
68
82
|
});
|
|
69
83
|
},
|
|
70
|
-
async uploadAvatar(agentId, file) {
|
|
84
|
+
async uploadAvatar({ agentId, file, abortSignal }) {
|
|
71
85
|
const form = new FormData();
|
|
72
86
|
form.append("file", file);
|
|
73
87
|
return await requestJson(config, `/v1/agents/${agentId}/avatar`, {
|
|
74
88
|
body: form,
|
|
89
|
+
signal: abortSignal,
|
|
75
90
|
method: "POST",
|
|
76
91
|
}, agentResponseSchema);
|
|
77
92
|
},
|
|
78
|
-
async removeAvatar(agentId) {
|
|
79
|
-
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);
|
|
80
95
|
},
|
|
81
96
|
};
|
|
82
97
|
}
|
|
@@ -5,14 +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}`, {}, artifactListItemSchema);
|
|
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: abortSignal,
|
|
16
17
|
query: {
|
|
17
18
|
agentId: options.agentId,
|
|
18
19
|
sessionId: options.sessionId,
|
|
@@ -20,9 +21,10 @@ export function createArtifactsResource(config) {
|
|
|
20
21
|
},
|
|
21
22
|
}, artifactsListResponseSchema);
|
|
22
23
|
},
|
|
23
|
-
async delete(artifactId) {
|
|
24
|
+
async delete({ artifactId, abortSignal }) {
|
|
24
25
|
await requestJson(config, `/v1/artifacts/${artifactId}`, {
|
|
25
26
|
method: "DELETE",
|
|
27
|
+
signal: abortSignal,
|
|
26
28
|
});
|
|
27
29
|
},
|
|
28
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", {}, mcpConnectionsResponseSchema);
|
|
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,8 +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: abortSignal,
|
|
12
13
|
query: {
|
|
13
14
|
...(options.userId === undefined ? {} : { userId: options.userId }),
|
|
14
15
|
search: options.search,
|
|
@@ -17,17 +18,17 @@ export function createMemoriesResource(config) {
|
|
|
17
18
|
},
|
|
18
19
|
}, memoriesListResponseSchema);
|
|
19
20
|
},
|
|
20
|
-
async create(agentId, body) {
|
|
21
|
-
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);
|
|
22
23
|
},
|
|
23
|
-
async get(agentId, memoryId) {
|
|
24
|
-
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, {}, memoryResponseSchema);
|
|
24
|
+
async get({ agentId, memoryId, abortSignal }) {
|
|
25
|
+
return await requestJson(config, `/v1/agents/${agentId}/memories/${memoryId}`, { signal: abortSignal }, memoryResponseSchema);
|
|
25
26
|
},
|
|
26
|
-
async update(agentId, memoryId, body) {
|
|
27
|
-
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);
|
|
28
29
|
},
|
|
29
|
-
async delete(agentId, memoryId) {
|
|
30
|
-
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 });
|
|
31
32
|
},
|
|
32
33
|
};
|
|
33
34
|
}
|
|
@@ -6,30 +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", {
|
|
18
|
+
signal: abortSignal,
|
|
17
19
|
// Stryker disable next-line ConditionalExpression: URL serialization omits an undefined query value.
|
|
18
20
|
...(userId === undefined ? {} : { query: { userId } }),
|
|
19
21
|
}, promptsResponseSchema);
|
|
20
22
|
},
|
|
21
|
-
async get(promptId) {
|
|
22
|
-
return await requestJson(config, `/v1/prompts/${promptId}`, {}, promptResponseSchema);
|
|
23
|
+
async get({ promptId, abortSignal }) {
|
|
24
|
+
return await requestJson(config, `/v1/prompts/${promptId}`, { signal: abortSignal }, promptResponseSchema);
|
|
23
25
|
},
|
|
24
|
-
async update(promptId, body) {
|
|
26
|
+
async update({ promptId, abortSignal, ...body }) {
|
|
25
27
|
return await requestJson(config, `/v1/prompts/${promptId}`, {
|
|
26
28
|
json: body,
|
|
29
|
+
signal: abortSignal,
|
|
27
30
|
method: "PATCH",
|
|
28
31
|
}, promptResponseSchema);
|
|
29
32
|
},
|
|
30
|
-
async delete(promptId) {
|
|
33
|
+
async delete({ promptId, abortSignal }) {
|
|
31
34
|
await requestJson(config, `/v1/prompts/${promptId}`, {
|
|
32
35
|
method: "DELETE",
|
|
36
|
+
signal: abortSignal,
|
|
33
37
|
});
|
|
34
38
|
},
|
|
35
39
|
};
|