@blazingagents/sdk 0.16.0 → 0.18.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/contracts/api.d.ts +6 -3
- package/dist/contracts/api.js +2 -1
- package/dist/contracts/entities/agents.d.ts +2 -118
- package/dist/contracts/entities/agents.js +2 -24
- package/dist/contracts/entities/chat.d.ts +0 -12
- package/dist/contracts/entities/chat.js +1 -4
- package/dist/contracts/entities/providers.d.ts +2 -6
- package/dist/contracts/entities/providers.js +2 -9
- package/dist/contracts/entities/session-inputs.d.ts +235 -0
- package/dist/contracts/entities/session-inputs.js +80 -0
- package/dist/contracts/entities/sessions.d.ts +106 -5
- package/dist/contracts/entities/sessions.js +5 -3
- package/dist/contracts/entities/tasks.d.ts +285 -10
- package/dist/contracts/entities/tasks.js +2 -5
- package/dist/contracts/index.d.ts +4 -2
- package/dist/contracts/index.js +3 -2
- package/dist/contracts/limitations.d.ts +0 -2
- package/dist/contracts/limitations.js +0 -2
- package/dist/direct-chat-transport.d.ts +7 -1
- package/dist/direct-chat-transport.js +26 -1
- package/dist/generation.d.ts +1 -1
- package/dist/generation.js +3 -10
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2 -0
- package/dist/relay.d.ts +0 -1
- package/dist/relay.js +0 -2
- 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 +50 -3
- package/dist/types.d.ts +52 -23
- package/package.json +1 -1
package/dist/relay.js
CHANGED
|
@@ -57,7 +57,6 @@ export function createChatRelay(options) {
|
|
|
57
57
|
? {
|
|
58
58
|
...chatInput,
|
|
59
59
|
trigger: "submit-message",
|
|
60
|
-
version: context.version,
|
|
61
60
|
}
|
|
62
61
|
: {
|
|
63
62
|
...chatInput,
|
|
@@ -122,7 +121,6 @@ export function createCompletionRelay(options) {
|
|
|
122
121
|
prompt: body.prompt,
|
|
123
122
|
abortSignal: request.signal,
|
|
124
123
|
userId: context.userId,
|
|
125
|
-
version: context.version,
|
|
126
124
|
});
|
|
127
125
|
return result.toResponse();
|
|
128
126
|
}
|
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,15 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resumeSessionInputsResponseSchema, sessionInputRequestIdSchema, sessionInputResponseSchema, sessionInputsResponseSchema, stopSessionResponseSchema, } from "../contracts/entities/session-inputs.js";
|
|
2
|
+
import { latestSessionsListResponseSchema, sessionMessagesResponseSchema, sessionResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "../contracts/entities/sessions.js";
|
|
3
|
+
import { agentIdSchema, sessionIdSchema, turnIdSchema, } from "../contracts/ids.js";
|
|
4
|
+
import { dispatchChatFunctions, stripFunctionEvents, toChatFunctionDefinitions, } from "../functions.js";
|
|
3
5
|
import { buildTerminalStreamResult, withFilteredBody } from "../generation.js";
|
|
4
6
|
import { requestJson, requestStream } from "../http.js";
|
|
5
7
|
/**
|
|
6
|
-
* `client.sessions`
|
|
8
|
+
* `client.sessions` reads, paginates, and deletes Sessions under
|
|
7
9
|
* `/v1/agents/:agentId/sessions`. Pagination is manual: the SDK returns
|
|
8
10
|
* the page as-is (`{ data, nextCursor }` verbatim); the caller passes
|
|
9
11
|
* `nextCursor` back as `cursor` on the next call.
|
|
10
12
|
*/
|
|
11
13
|
export function createSessionsResource(config) {
|
|
12
14
|
return {
|
|
15
|
+
async joinInputTurn({ agentId, sessionId, turnId, functions, abortSignal, }) {
|
|
16
|
+
const response = await requestStream(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/input-turns/${turnIdSchema.parse(turnId)}`, { signal: abortSignal });
|
|
17
|
+
return buildTerminalStreamResult(response, "input Turn", (body) => functions
|
|
18
|
+
? dispatchChatFunctions(config, { agentId, sessionId, functions, abortSignal }, body)
|
|
19
|
+
: stripFunctionEvents(body));
|
|
20
|
+
},
|
|
21
|
+
async runInputs({ agentId, sessionId, functions, abortSignal }) {
|
|
22
|
+
const response = await requestStream(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/run`, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
json: functions === undefined
|
|
25
|
+
? {}
|
|
26
|
+
: { functions: toChatFunctionDefinitions(functions) },
|
|
27
|
+
signal: abortSignal,
|
|
28
|
+
});
|
|
29
|
+
return buildTerminalStreamResult(response, "input Turn", (body) => functions
|
|
30
|
+
? dispatchChatFunctions(config, { agentId, sessionId, functions, abortSignal }, body)
|
|
31
|
+
: stripFunctionEvents(body));
|
|
32
|
+
},
|
|
33
|
+
async submitInput({ agentId, sessionId, abortSignal, ...body }) {
|
|
34
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs`, { method: "POST", json: body, signal: abortSignal }, sessionInputResponseSchema);
|
|
35
|
+
},
|
|
36
|
+
async inputs({ agentId, sessionId, abortSignal, ...query }) {
|
|
37
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs`, { query, signal: abortSignal }, sessionInputsResponseSchema);
|
|
38
|
+
},
|
|
39
|
+
async promoteInput({ agentId, sessionId, requestId, abortSignal }) {
|
|
40
|
+
const inputId = sessionInputRequestIdSchema.parse(requestId);
|
|
41
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/${encodeURIComponent(inputId)}/promote`, { method: "POST", signal: abortSignal }, sessionInputResponseSchema);
|
|
42
|
+
},
|
|
43
|
+
async deleteInput({ agentId, sessionId, requestId, abortSignal }) {
|
|
44
|
+
const inputId = sessionInputRequestIdSchema.parse(requestId);
|
|
45
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/${encodeURIComponent(inputId)}`, { method: "DELETE", signal: abortSignal }, sessionInputResponseSchema);
|
|
46
|
+
},
|
|
47
|
+
async stop({ agentId, sessionId, turnId, abortSignal }) {
|
|
48
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/stop`, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
json: { turnId: turnIdSchema.parse(turnId) },
|
|
51
|
+
signal: abortSignal,
|
|
52
|
+
}, stopSessionResponseSchema);
|
|
53
|
+
},
|
|
54
|
+
async resumeInputs({ agentId, sessionId, abortSignal }) {
|
|
55
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/resume`, { method: "POST", signal: abortSignal }, resumeSessionInputsResponseSchema);
|
|
56
|
+
},
|
|
57
|
+
async get({ agentId, sessionId, abortSignal }) {
|
|
58
|
+
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { signal: abortSignal }, sessionResponseSchema);
|
|
59
|
+
},
|
|
13
60
|
async decideToolApproval({ agentId, sessionId, approvalId, abortSignal, ...decision }) {
|
|
14
61
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}/tool-approvals/${approvalId}`, {
|
|
15
62
|
json: decision,
|
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,7 +9,8 @@ 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 {
|
|
12
|
+
import type { ResumeSessionInputsResponse, SessionInputResponse, SessionInputsQuery, SessionInputsResponse, StopSessionBody, StopSessionResponse, SubmitSessionInputBody } from "./contracts/entities/session-inputs.ts";
|
|
13
|
+
import type { DecideToolApprovalBody, LatestSessionsListResponse, SessionMessagesResponse, SessionResponse, SessionsListResponse, ToolApprovalDecisionResponse, ToolApprovalsResponse } from "./contracts/entities/sessions.ts";
|
|
13
14
|
import type { CreateSkillBody, SkillArchiveType, SkillCopyResults, SkillDetail, SkillsListResponse } from "./contracts/entities/skills.ts";
|
|
14
15
|
import type { CreateTaskBody, CreateTaskResponse, CreateTaskRunBody, CreateTaskRunResponse, TaskResponse, TaskRunMessagesResponse, TaskRunResponse, TaskRunsListResponse, TasksListResponse, UpdateTaskBody } from "./contracts/entities/tasks.ts";
|
|
15
16
|
import type { TenantSettingsResponse, UpdateTenantSettingsBody } from "./contracts/entities/tenants.ts";
|
|
@@ -103,12 +104,10 @@ interface CorrelatedRequestInput {
|
|
|
103
104
|
interface NewSessionInput {
|
|
104
105
|
sessionId?: never;
|
|
105
106
|
trigger?: "submit-message";
|
|
106
|
-
version?: number;
|
|
107
107
|
}
|
|
108
108
|
interface ExistingSessionInput {
|
|
109
109
|
sessionId: string;
|
|
110
110
|
trigger?: ChatTrigger;
|
|
111
|
-
version?: never;
|
|
112
111
|
}
|
|
113
112
|
type ChatSessionInput = NewSessionInput | ExistingSessionInput;
|
|
114
113
|
interface ChatMessageContentInput extends AttributionInput, CorrelatedRequestInput {
|
|
@@ -162,9 +161,7 @@ export interface TerminalStreamResult {
|
|
|
162
161
|
/** Claims the SSE bytes once, without constructing a Response. Shares ownership with toResponse(). */
|
|
163
162
|
toStream: () => ReadableStream<Uint8Array>;
|
|
164
163
|
}
|
|
165
|
-
|
|
166
|
-
version?: number;
|
|
167
|
-
}
|
|
164
|
+
type StatelessGenerationInput = AttributionInput & CorrelatedRequestInput;
|
|
168
165
|
export interface CompletionPromptInput extends StatelessGenerationInput {
|
|
169
166
|
abortSignal?: AbortSignal;
|
|
170
167
|
agentId: string;
|
|
@@ -231,25 +228,13 @@ export interface AgentsResource {
|
|
|
231
228
|
get(input: {
|
|
232
229
|
agentId: string;
|
|
233
230
|
} & ResourceRequestOptions): Promise<Agent>;
|
|
234
|
-
getVersion(input: {
|
|
235
|
-
agentId: string;
|
|
236
|
-
version: number;
|
|
237
|
-
} & ResourceRequestOptions): Promise<AgentVersion>;
|
|
238
231
|
list(input?: AgentsListOptions): Promise<AgentsResponse>;
|
|
239
232
|
listMcpAttachments(input: {
|
|
240
233
|
agentId: string;
|
|
241
234
|
} & ResourceRequestOptions): Promise<McpAttachmentsResponse>;
|
|
242
|
-
listVersions(input: {
|
|
243
|
-
agentId: string;
|
|
244
|
-
} & AgentVersionsListOptions): Promise<AgentVersionsResponse>;
|
|
245
235
|
removeAvatar(input: {
|
|
246
236
|
agentId: string;
|
|
247
237
|
} & ResourceRequestOptions): Promise<Agent>;
|
|
248
|
-
/** Copies an immutable Version into the Agent, creating a new latest Version. */
|
|
249
|
-
restoreVersion(input: {
|
|
250
|
-
agentId: string;
|
|
251
|
-
version: number;
|
|
252
|
-
} & ResourceRequestOptions): Promise<Agent>;
|
|
253
238
|
/** A concrete `workspaceId` switches the Agent; detachment is unsupported. */
|
|
254
239
|
update(input: UpdateAgentBody & {
|
|
255
240
|
agentId: string;
|
|
@@ -290,10 +275,6 @@ export interface WorkspacesListOptions extends ResourceRequestOptions {
|
|
|
290
275
|
limit?: number;
|
|
291
276
|
userId?: string;
|
|
292
277
|
}
|
|
293
|
-
export interface AgentVersionsListOptions extends ResourceRequestOptions {
|
|
294
|
-
cursor?: string;
|
|
295
|
-
limit?: number;
|
|
296
|
-
}
|
|
297
278
|
export interface ArtifactsListOptions extends ResourceRequestOptions {
|
|
298
279
|
agentId?: string;
|
|
299
280
|
cursor?: string;
|
|
@@ -424,6 +405,27 @@ export interface SessionsResource {
|
|
|
424
405
|
sessionId: string;
|
|
425
406
|
deleteArtifacts: boolean;
|
|
426
407
|
} & ResourceRequestOptions): Promise<void>;
|
|
408
|
+
deleteInput(input: {
|
|
409
|
+
agentId: string;
|
|
410
|
+
sessionId: string;
|
|
411
|
+
requestId: string;
|
|
412
|
+
} & ResourceRequestOptions): Promise<SessionInputResponse>;
|
|
413
|
+
get(input: {
|
|
414
|
+
agentId: string;
|
|
415
|
+
sessionId: string;
|
|
416
|
+
} & ResourceRequestOptions): Promise<SessionResponse>;
|
|
417
|
+
/** Poll from the first page for state changes; cursor only paginates receipts. */
|
|
418
|
+
inputs(input: {
|
|
419
|
+
agentId: string;
|
|
420
|
+
sessionId: string;
|
|
421
|
+
} & SessionInputsQuery & ResourceRequestOptions): Promise<SessionInputsResponse>;
|
|
422
|
+
/** Replays an admitted input Turn. Supplying functions opts into executor claims. */
|
|
423
|
+
joinInputTurn(input: {
|
|
424
|
+
agentId: string;
|
|
425
|
+
sessionId: string;
|
|
426
|
+
turnId: string;
|
|
427
|
+
functions?: ChatFunctions;
|
|
428
|
+
} & ResourceRequestOptions): Promise<TerminalStreamResult>;
|
|
427
429
|
joinToolApprovalContinuation(input: {
|
|
428
430
|
agentId: string;
|
|
429
431
|
sessionId: string;
|
|
@@ -442,6 +444,33 @@ export interface SessionsResource {
|
|
|
442
444
|
agentId: string;
|
|
443
445
|
sessionId: string;
|
|
444
446
|
} & SessionMessagesOptions): Promise<SessionMessagesResponse>;
|
|
447
|
+
promoteInput(input: {
|
|
448
|
+
agentId: string;
|
|
449
|
+
sessionId: string;
|
|
450
|
+
requestId: string;
|
|
451
|
+
} & ResourceRequestOptions): Promise<SessionInputResponse>;
|
|
452
|
+
/** Resume accepted inputs after a pause. Uncertain inputs are never replayed. */
|
|
453
|
+
resumeInputs(input: {
|
|
454
|
+
agentId: string;
|
|
455
|
+
sessionId: string;
|
|
456
|
+
} & ResourceRequestOptions): Promise<ResumeSessionInputsResponse>;
|
|
457
|
+
/** Admits the pending batch without resubmitting its messages. */
|
|
458
|
+
runInputs(input: {
|
|
459
|
+
agentId: string;
|
|
460
|
+
sessionId: string;
|
|
461
|
+
functions?: ChatFunctions;
|
|
462
|
+
} & ResourceRequestOptions): Promise<TerminalStreamResult>;
|
|
463
|
+
/** Wait for settlement of the named Turn. A queued Turn may already be running. */
|
|
464
|
+
stop(input: {
|
|
465
|
+
agentId: string;
|
|
466
|
+
sessionId: string;
|
|
467
|
+
} & StopSessionBody & ResourceRequestOptions): Promise<StopSessionResponse>;
|
|
468
|
+
/** Retry an uncertain acknowledgement with the same requestId and payload. */
|
|
469
|
+
submitInput(input: Omit<SubmitSessionInputBody, "message"> & {
|
|
470
|
+
agentId: string;
|
|
471
|
+
sessionId: string;
|
|
472
|
+
message: UIMessage;
|
|
473
|
+
} & ResourceRequestOptions): Promise<SessionInputResponse>;
|
|
445
474
|
toolApprovals(input: {
|
|
446
475
|
agentId: string;
|
|
447
476
|
sessionId: string;
|