@blazingagents/sdk 0.15.0 → 0.17.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/dist/approvals.d.ts +15 -0
- package/dist/approvals.js +20 -0
- package/dist/chat-transport.js +9 -2
- package/dist/client.d.ts +6 -1
- package/dist/client.js +9 -1
- package/dist/contracts/api.d.ts +3 -3
- package/dist/contracts/api.js +1 -1
- package/dist/contracts/entities/agent-approval.d.ts +32 -0
- package/dist/contracts/entities/agent-approval.js +12 -1
- package/dist/contracts/entities/agent-tools.d.ts +6 -0
- package/dist/contracts/entities/agent-tools.js +13 -0
- package/dist/contracts/entities/agents.d.ts +2 -118
- package/dist/contracts/entities/agents.js +2 -24
- package/dist/contracts/entities/chat.d.ts +95 -24
- package/dist/contracts/entities/chat.js +105 -39
- package/dist/contracts/entities/providers.d.ts +2 -6
- package/dist/contracts/entities/providers.js +2 -9
- package/dist/contracts/entities/sessions.d.ts +112 -5
- package/dist/contracts/entities/sessions.js +7 -5
- package/dist/contracts/entities/tasks.d.ts +285 -10
- package/dist/contracts/entities/tasks.js +2 -5
- package/dist/contracts/ids.d.ts +1 -0
- package/dist/contracts/ids.js +1 -0
- package/dist/contracts/index.d.ts +8 -7
- package/dist/contracts/index.js +6 -5
- package/dist/contracts/limitations.d.ts +0 -2
- package/dist/contracts/limitations.js +0 -2
- package/dist/direct-chat-transport.d.ts +3 -1
- package/dist/direct-chat-transport.js +20 -23
- package/dist/functions.d.ts +38 -0
- package/dist/functions.js +299 -0
- package/dist/generation.d.ts +7 -1
- package/dist/generation.js +64 -20
- package/dist/index.d.ts +7 -4
- package/dist/index.js +3 -0
- package/dist/relay.d.ts +11 -5
- package/dist/relay.js +41 -3
- package/dist/resources/agents.js +1 -33
- package/dist/resources/providers.js +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/sessions.js +9 -4
- package/dist/types.d.ts +22 -23
- package/package.json +1 -1
package/dist/resources/agents.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { agentResponseSchema, agentsResponseSchema,
|
|
1
|
+
import { agentResponseSchema, agentsResponseSchema, } from "../contracts/entities/agents.js";
|
|
2
2
|
import { mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, } from "../contracts/entities/mcp-connections.js";
|
|
3
3
|
import { requestJson } from "../http.js";
|
|
4
4
|
export function createAgentsResource(config) {
|
|
5
|
-
const getVersion = async ({ agentId, version, abortSignal, }) => requestJson(config, `/v1/agents/${agentId}/versions/${version}`, { signal: abortSignal }, agentVersionSchema);
|
|
6
5
|
const update = async ({ agentId, abortSignal, ...body }) => requestJson(config, `/v1/agents/${agentId}`, {
|
|
7
6
|
json: body,
|
|
8
7
|
signal: abortSignal,
|
|
@@ -36,40 +35,9 @@ export function createAgentsResource(config) {
|
|
|
36
35
|
async enable({ agentId, abortSignal }) {
|
|
37
36
|
return await requestJson(config, `/v1/agents/${agentId}/enable`, { method: "POST", signal: abortSignal }, agentResponseSchema);
|
|
38
37
|
},
|
|
39
|
-
getVersion,
|
|
40
|
-
async listVersions({ agentId, ...options }) {
|
|
41
|
-
return await requestJson(config, `/v1/agents/${agentId}/versions`, {
|
|
42
|
-
signal: options.abortSignal,
|
|
43
|
-
query: { cursor: options.cursor, limit: options.limit },
|
|
44
|
-
}, agentVersionsResponseSchema);
|
|
45
|
-
},
|
|
46
38
|
async listMcpAttachments({ agentId, abortSignal }) {
|
|
47
39
|
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments`, { signal: abortSignal }, mcpAttachmentsResponseSchema);
|
|
48
40
|
},
|
|
49
|
-
async restoreVersion({ agentId, version: versionNumber, abortSignal }) {
|
|
50
|
-
const version = await getVersion({
|
|
51
|
-
agentId,
|
|
52
|
-
version: versionNumber,
|
|
53
|
-
abortSignal,
|
|
54
|
-
});
|
|
55
|
-
return update({
|
|
56
|
-
agentId,
|
|
57
|
-
abortSignal,
|
|
58
|
-
approvalInChat: version.approvalInChat,
|
|
59
|
-
approvalInTasks: version.approvalInTasks,
|
|
60
|
-
name: version.name,
|
|
61
|
-
model: version.model,
|
|
62
|
-
thinkingLevel: version.thinkingLevel,
|
|
63
|
-
autoCompaction: version.autoCompaction,
|
|
64
|
-
compactionReserveTokens: version.compactionReserveTokens,
|
|
65
|
-
providerId: version.providerId,
|
|
66
|
-
memoryInjectionEnabled: version.memoryInjectionEnabled,
|
|
67
|
-
tools: version.tools,
|
|
68
|
-
instructions: version.instructions,
|
|
69
|
-
metadata: version.metadata,
|
|
70
|
-
mcpConnectionIds: version.mcpConnectionIds,
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
41
|
update,
|
|
74
42
|
async updateMcpAttachment({ agentId, mcpConnectionId, abortSignal, ...body }) {
|
|
75
43
|
return await requestJson(config, `/v1/agents/${agentId}/mcp-attachments/${mcpConnectionId}`, { json: body, method: "PATCH", signal: abortSignal }, mcpAttachmentResponseSchema);
|
|
@@ -36,7 +36,7 @@ export function createProvidersResource(config) {
|
|
|
36
36
|
method: "DELETE",
|
|
37
37
|
signal: abortSignal,
|
|
38
38
|
query: {
|
|
39
|
-
|
|
39
|
+
confirmSnapshotInvalidation: options.confirmSnapshotInvalidation,
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
42
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpConfig, SessionsResource } from "../types.ts";
|
|
2
2
|
/**
|
|
3
|
-
* `client.sessions`
|
|
3
|
+
* `client.sessions` reads, paginates, and deletes Sessions under
|
|
4
4
|
* `/v1/agents/:agentId/sessions`. Pagination is manual: the SDK returns
|
|
5
5
|
* the page as-is (`{ data, nextCursor }` verbatim); the caller passes
|
|
6
6
|
* `nextCursor` back as `cursor` on the next call.
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { latestSessionsListResponseSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "../contracts/entities/sessions.js";
|
|
2
|
-
import {
|
|
1
|
+
import { latestSessionsListResponseSchema, sessionMessagesResponseSchema, sessionResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "../contracts/entities/sessions.js";
|
|
2
|
+
import { stripFunctionEvents } from "../functions.js";
|
|
3
|
+
import { buildTerminalStreamResult, withFilteredBody } from "../generation.js";
|
|
3
4
|
import { requestJson, requestStream } from "../http.js";
|
|
4
5
|
/**
|
|
5
|
-
* `client.sessions`
|
|
6
|
+
* `client.sessions` reads, paginates, and deletes Sessions under
|
|
6
7
|
* `/v1/agents/:agentId/sessions`. Pagination is manual: the SDK returns
|
|
7
8
|
* the page as-is (`{ data, nextCursor }` verbatim); the caller passes
|
|
8
9
|
* `nextCursor` back as `cursor` on the next call.
|
|
9
10
|
*/
|
|
10
11
|
export function createSessionsResource(config) {
|
|
11
12
|
return {
|
|
13
|
+
async get({ agentId, sessionId, abortSignal }) {
|
|
14
|
+
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { signal: abortSignal }, sessionResponseSchema);
|
|
15
|
+
},
|
|
12
16
|
async decideToolApproval({ agentId, sessionId, approvalId, abortSignal, ...decision }) {
|
|
13
17
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals/${approvalId}`, {
|
|
14
18
|
json: decision,
|
|
@@ -53,7 +57,8 @@ export function createSessionsResource(config) {
|
|
|
53
57
|
},
|
|
54
58
|
async joinToolApprovalContinuation({ agentId, sessionId, continuationId, abortSignal, }) {
|
|
55
59
|
const response = await requestStream(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approval-continuations/${continuationId}`, { signal: abortSignal });
|
|
56
|
-
|
|
60
|
+
/** Observers never execute calls; private events are removed unclaimed. */
|
|
61
|
+
return buildTerminalStreamResult(withFilteredBody(response, stripFunctionEvents), "continuation");
|
|
57
62
|
},
|
|
58
63
|
async toolApprovals({ agentId, sessionId, abortSignal }) {
|
|
59
64
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals`, { signal: abortSignal }, toolApprovalsResponseSchema);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UIMessage, UIMessageChunk } from "ai";
|
|
2
2
|
import type { ApiErrorCode } from "./contracts/api.ts";
|
|
3
|
-
import type { Agent, AgentsResponse,
|
|
3
|
+
import type { Agent, AgentsResponse, CreateAgentBody, UpdateAgentBody } from "./contracts/entities/agents.ts";
|
|
4
4
|
import type { ArtifactDownloadUrlResponse, ArtifactListItem, ArtifactsListResponse } from "./contracts/entities/artifacts.ts";
|
|
5
5
|
import type { BlazingAgentsChatMessageMetadata } from "./contracts/entities/chat.ts";
|
|
6
6
|
import type { ChatConnection, ChatConnectionsResponse, ChatDeliveriesResponse, ChatDeliveryListStatus, CreateChatConnectionBody, RotateChatConnectionBody, UpdateChatConnectionBody } from "./contracts/entities/chat-connections.ts";
|
|
@@ -9,12 +9,13 @@ import type { CreateMemoryBody, MemoriesListResponse, MemoryResponse, UpdateMemo
|
|
|
9
9
|
import type { CreateMerchantConnectionBody, MerchantBindingResponse, MerchantBindingsResponse, MerchantConnectionResponse, MerchantUsageEventResponse, MerchantUsageEventStatus, MerchantUsageEventsResponse, MerchantUsageSummaryResponse, UpdateMerchantConnectionBody, UpsertMerchantBindingBody } from "./contracts/entities/merchant.ts";
|
|
10
10
|
import type { CreatePromptBody, PromptResponse, PromptsResponse, UpdatePromptBody } from "./contracts/entities/prompts.ts";
|
|
11
11
|
import type { CreateProviderBody, DeleteProviderOptions, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ThinkingLevelsResponse, UpdateProviderBody } from "./contracts/entities/providers.ts";
|
|
12
|
-
import type { DecideToolApprovalBody, LatestSessionsListResponse, SessionMessagesResponse, SessionsListResponse, ToolApprovalDecisionResponse, ToolApprovalsResponse } from "./contracts/entities/sessions.ts";
|
|
12
|
+
import type { DecideToolApprovalBody, LatestSessionsListResponse, SessionMessagesResponse, SessionResponse, SessionsListResponse, ToolApprovalDecisionResponse, ToolApprovalsResponse } from "./contracts/entities/sessions.ts";
|
|
13
13
|
import type { CreateSkillBody, SkillArchiveType, SkillCopyResults, SkillDetail, SkillsListResponse } from "./contracts/entities/skills.ts";
|
|
14
14
|
import type { CreateTaskBody, CreateTaskResponse, CreateTaskRunBody, CreateTaskRunResponse, TaskResponse, TaskRunMessagesResponse, TaskRunResponse, TaskRunsListResponse, TasksListResponse, UpdateTaskBody } from "./contracts/entities/tasks.ts";
|
|
15
15
|
import type { TenantSettingsResponse, UpdateTenantSettingsBody } from "./contracts/entities/tenants.ts";
|
|
16
16
|
import type { SessionUsageQuery, SessionUsageResponse, UsageOverviewQuery, UsageOverviewResponse, UsageQuery, UsageResponse } from "./contracts/entities/usage.ts";
|
|
17
17
|
import type { CreateWorkspaceBody, UpdateWorkspaceBody, Workspace, WorkspacesListResponse } from "./contracts/entities/workspaces.ts";
|
|
18
|
+
import type { ChatFunctions } from "./functions.ts";
|
|
18
19
|
export type KnownBlazingAgentsErrorCode = ApiErrorCode | "invalid_response" | "network_error" | "request_aborted" | "stream_error";
|
|
19
20
|
export type BlazingAgentsErrorCode = KnownBlazingAgentsErrorCode | (string & {});
|
|
20
21
|
export type BlazingAgentsFetch = (input: string, init?: BlazingAgentsRequestInit) => Promise<Response>;
|
|
@@ -69,6 +70,7 @@ export interface UserClient {
|
|
|
69
70
|
readonly memories: MemoriesResource;
|
|
70
71
|
object(input: ObjectInput): Promise<ObjectResult>;
|
|
71
72
|
readonly prompts: PromptsResource;
|
|
73
|
+
resumeChat(input: ResumeChatInput): Promise<ChatResult>;
|
|
72
74
|
readonly sessions: SessionsResource;
|
|
73
75
|
readonly tasks: TasksResource;
|
|
74
76
|
readonly usage: Pick<UsageResource, "get" | "sessions">;
|
|
@@ -101,17 +103,17 @@ interface CorrelatedRequestInput {
|
|
|
101
103
|
interface NewSessionInput {
|
|
102
104
|
sessionId?: never;
|
|
103
105
|
trigger?: "submit-message";
|
|
104
|
-
version?: number;
|
|
105
106
|
}
|
|
106
107
|
interface ExistingSessionInput {
|
|
107
108
|
sessionId: string;
|
|
108
109
|
trigger?: ChatTrigger;
|
|
109
|
-
version?: never;
|
|
110
110
|
}
|
|
111
111
|
type ChatSessionInput = NewSessionInput | ExistingSessionInput;
|
|
112
112
|
interface ChatMessageContentInput extends AttributionInput, CorrelatedRequestInput {
|
|
113
113
|
abortSignal?: AbortSignal;
|
|
114
114
|
agentId: string;
|
|
115
|
+
/** Caller-local functions for this invocation; handlers run in this process. */
|
|
116
|
+
functions?: ChatFunctions;
|
|
115
117
|
message: UIMessage;
|
|
116
118
|
messageId?: string;
|
|
117
119
|
promptId?: never;
|
|
@@ -120,6 +122,8 @@ interface ChatMessageContentInput extends AttributionInput, CorrelatedRequestInp
|
|
|
120
122
|
interface ChatPromptContentInput extends AttributionInput, CorrelatedRequestInput {
|
|
121
123
|
abortSignal?: AbortSignal;
|
|
122
124
|
agentId: string;
|
|
125
|
+
/** Caller-local functions for this invocation; handlers run in this process. */
|
|
126
|
+
functions?: ChatFunctions;
|
|
123
127
|
message?: never;
|
|
124
128
|
messageId?: string;
|
|
125
129
|
promptId: string;
|
|
@@ -128,6 +132,15 @@ interface ChatPromptContentInput extends AttributionInput, CorrelatedRequestInpu
|
|
|
128
132
|
export type ChatMessageInput = ChatMessageContentInput & ChatSessionInput;
|
|
129
133
|
export type ChatPromptInput = ChatPromptContentInput & ChatSessionInput;
|
|
130
134
|
export type ChatInput = ChatMessageInput | ChatPromptInput;
|
|
135
|
+
/** Reattaches handlers to a Session's tool-approval continuation. */
|
|
136
|
+
export interface ResumeChatInput extends CorrelatedRequestInput {
|
|
137
|
+
abortSignal?: AbortSignal;
|
|
138
|
+
agentId: string;
|
|
139
|
+
/** The decided continuation; omitted, the Session's queued or running one is resumed. */
|
|
140
|
+
continuationId?: string;
|
|
141
|
+
functions: ChatFunctions;
|
|
142
|
+
sessionId: string;
|
|
143
|
+
}
|
|
131
144
|
export interface ChatResult {
|
|
132
145
|
requestId?: string;
|
|
133
146
|
/**
|
|
@@ -147,9 +160,7 @@ export interface TerminalStreamResult {
|
|
|
147
160
|
/** Claims the SSE bytes once, without constructing a Response. Shares ownership with toResponse(). */
|
|
148
161
|
toStream: () => ReadableStream<Uint8Array>;
|
|
149
162
|
}
|
|
150
|
-
|
|
151
|
-
version?: number;
|
|
152
|
-
}
|
|
163
|
+
type StatelessGenerationInput = AttributionInput & CorrelatedRequestInput;
|
|
153
164
|
export interface CompletionPromptInput extends StatelessGenerationInput {
|
|
154
165
|
abortSignal?: AbortSignal;
|
|
155
166
|
agentId: string;
|
|
@@ -216,25 +227,13 @@ export interface AgentsResource {
|
|
|
216
227
|
get(input: {
|
|
217
228
|
agentId: string;
|
|
218
229
|
} & ResourceRequestOptions): Promise<Agent>;
|
|
219
|
-
getVersion(input: {
|
|
220
|
-
agentId: string;
|
|
221
|
-
version: number;
|
|
222
|
-
} & ResourceRequestOptions): Promise<AgentVersion>;
|
|
223
230
|
list(input?: AgentsListOptions): Promise<AgentsResponse>;
|
|
224
231
|
listMcpAttachments(input: {
|
|
225
232
|
agentId: string;
|
|
226
233
|
} & ResourceRequestOptions): Promise<McpAttachmentsResponse>;
|
|
227
|
-
listVersions(input: {
|
|
228
|
-
agentId: string;
|
|
229
|
-
} & AgentVersionsListOptions): Promise<AgentVersionsResponse>;
|
|
230
234
|
removeAvatar(input: {
|
|
231
235
|
agentId: string;
|
|
232
236
|
} & ResourceRequestOptions): Promise<Agent>;
|
|
233
|
-
/** Copies an immutable Version into the Agent, creating a new latest Version. */
|
|
234
|
-
restoreVersion(input: {
|
|
235
|
-
agentId: string;
|
|
236
|
-
version: number;
|
|
237
|
-
} & ResourceRequestOptions): Promise<Agent>;
|
|
238
237
|
/** A concrete `workspaceId` switches the Agent; detachment is unsupported. */
|
|
239
238
|
update(input: UpdateAgentBody & {
|
|
240
239
|
agentId: string;
|
|
@@ -275,10 +274,6 @@ export interface WorkspacesListOptions extends ResourceRequestOptions {
|
|
|
275
274
|
limit?: number;
|
|
276
275
|
userId?: string;
|
|
277
276
|
}
|
|
278
|
-
export interface AgentVersionsListOptions extends ResourceRequestOptions {
|
|
279
|
-
cursor?: string;
|
|
280
|
-
limit?: number;
|
|
281
|
-
}
|
|
282
277
|
export interface ArtifactsListOptions extends ResourceRequestOptions {
|
|
283
278
|
agentId?: string;
|
|
284
279
|
cursor?: string;
|
|
@@ -409,6 +404,10 @@ export interface SessionsResource {
|
|
|
409
404
|
sessionId: string;
|
|
410
405
|
deleteArtifacts: boolean;
|
|
411
406
|
} & ResourceRequestOptions): Promise<void>;
|
|
407
|
+
get(input: {
|
|
408
|
+
agentId: string;
|
|
409
|
+
sessionId: string;
|
|
410
|
+
} & ResourceRequestOptions): Promise<SessionResponse>;
|
|
412
411
|
joinToolApprovalContinuation(input: {
|
|
413
412
|
agentId: string;
|
|
414
413
|
sessionId: string;
|