@blazingagents/sdk 0.31.0 → 0.33.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 +3 -0
- package/dist/chat-transport.js +1 -3
- package/dist/client.d.ts +1 -1
- package/dist/client.js +25 -25
- package/dist/contracts/entities/chat-connections.d.ts +51 -0
- package/dist/contracts/entities/chat-connections.js +24 -0
- package/dist/contracts/entities/chat.d.ts +2 -0
- package/dist/contracts/entities/mcp-connections.d.ts +0 -4
- package/dist/contracts/entities/mcp-connections.js +0 -16
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +2 -2
- package/dist/direct-chat-transport.js +28 -40
- package/dist/errors.js +0 -2
- package/dist/functions.js +2 -2
- package/dist/generation.d.ts +1 -2
- package/dist/generation.js +45 -79
- package/dist/http.d.ts +5 -10
- package/dist/http.js +8 -1
- package/dist/index.d.ts +2 -2
- package/dist/resources/agents.js +12 -12
- package/dist/resources/artifacts.js +4 -4
- package/dist/resources/chat-connections.js +21 -9
- package/dist/resources/mcp-connections.js +7 -13
- package/dist/resources/memories.js +6 -6
- package/dist/resources/merchant-bindings.js +3 -3
- package/dist/resources/merchant-usage-events.js +5 -5
- package/dist/resources/prompts.js +4 -4
- package/dist/resources/providers.js +6 -6
- package/dist/resources/sessions.js +13 -17
- package/dist/resources/skills.js +9 -8
- package/dist/resources/tasks.js +10 -11
- package/dist/resources/usage.js +2 -2
- package/dist/resources/workspaces.js +4 -4
- package/dist/types.d.ts +31 -11
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/chat-transport.js
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, ContinueChatInput, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, UserClient, WorkspacesResource } from "./types.ts";
|
|
2
2
|
export declare class BlazingAgents {
|
|
3
|
-
private
|
|
3
|
+
#private;
|
|
4
4
|
readonly chatConnections: ChatConnectionsResource;
|
|
5
5
|
readonly chatDeliveries: ChatDeliveriesResource;
|
|
6
6
|
readonly agents: AgentsResource;
|
package/dist/client.js
CHANGED
|
@@ -58,7 +58,7 @@ function createUserClient(config) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
export class BlazingAgents {
|
|
61
|
-
config;
|
|
61
|
+
#config;
|
|
62
62
|
chatConnections;
|
|
63
63
|
chatDeliveries;
|
|
64
64
|
agents;
|
|
@@ -80,7 +80,7 @@ export class BlazingAgents {
|
|
|
80
80
|
* @param options - Configuration for this operation.
|
|
81
81
|
*/
|
|
82
82
|
constructor(options) {
|
|
83
|
-
this
|
|
83
|
+
this.#config = {
|
|
84
84
|
apiKey: options.apiKey,
|
|
85
85
|
baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(TRAILING_SLASH_RE, ""),
|
|
86
86
|
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
@@ -89,29 +89,29 @@ export class BlazingAgents {
|
|
|
89
89
|
: { clientRequestId: options.clientRequestId }),
|
|
90
90
|
onResponse: options.onResponse,
|
|
91
91
|
};
|
|
92
|
-
this.chatConnections = createChatConnectionsResource(this
|
|
93
|
-
this.chatDeliveries = createChatDeliveriesResource(this
|
|
94
|
-
this.agents = createAgentsResource(this
|
|
95
|
-
this.sessions = createSessionsResource(this
|
|
96
|
-
this.providers = createProvidersResource(this
|
|
97
|
-
this.mcpConnections = createMcpConnectionsResource(this
|
|
98
|
-
this.memories = createMemoriesResource(this
|
|
99
|
-
this.prompts = createPromptsResource(this
|
|
100
|
-
this.usage = createUsageResource(this
|
|
101
|
-
this.artifacts = createArtifactsResource(this
|
|
102
|
-
this.tasks = createTasksResource(this
|
|
103
|
-
this.tenant = createTenantResource(this
|
|
104
|
-
this.workspaces = createWorkspacesResource(this
|
|
105
|
-
this.merchantConnection = createMerchantConnectionResource(this
|
|
106
|
-
this.merchantBindings = createMerchantBindingsResource(this
|
|
107
|
-
this.merchantUsageEvents = createMerchantUsageEventsResource(this
|
|
92
|
+
this.chatConnections = createChatConnectionsResource(this.#config);
|
|
93
|
+
this.chatDeliveries = createChatDeliveriesResource(this.#config);
|
|
94
|
+
this.agents = createAgentsResource(this.#config);
|
|
95
|
+
this.sessions = createSessionsResource(this.#config);
|
|
96
|
+
this.providers = createProvidersResource(this.#config);
|
|
97
|
+
this.mcpConnections = createMcpConnectionsResource(this.#config);
|
|
98
|
+
this.memories = createMemoriesResource(this.#config);
|
|
99
|
+
this.prompts = createPromptsResource(this.#config);
|
|
100
|
+
this.usage = createUsageResource(this.#config);
|
|
101
|
+
this.artifacts = createArtifactsResource(this.#config);
|
|
102
|
+
this.tasks = createTasksResource(this.#config);
|
|
103
|
+
this.tenant = createTenantResource(this.#config);
|
|
104
|
+
this.workspaces = createWorkspacesResource(this.#config);
|
|
105
|
+
this.merchantConnection = createMerchantConnectionResource(this.#config);
|
|
106
|
+
this.merchantBindings = createMerchantBindingsResource(this.#config);
|
|
107
|
+
this.merchantUsageEvents = createMerchantUsageEventsResource(this.#config);
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* Returns the Skill operations for the selected Agent.
|
|
111
111
|
* @returns The selected Agent Skill client.
|
|
112
112
|
*/
|
|
113
113
|
agent({ agentId }) {
|
|
114
|
-
return { skills: createAgentSkillsResource(this
|
|
114
|
+
return { skills: createAgentSkillsResource(this.#config, agentId) };
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces.
|
|
@@ -121,7 +121,7 @@ export class BlazingAgents {
|
|
|
121
121
|
*/
|
|
122
122
|
forUser(userId) {
|
|
123
123
|
return createUserClient({
|
|
124
|
-
...this
|
|
124
|
+
...this.#config,
|
|
125
125
|
scopeUserId: scopedUserIdSchema.parse(userId),
|
|
126
126
|
});
|
|
127
127
|
}
|
|
@@ -133,7 +133,7 @@ export class BlazingAgents {
|
|
|
133
133
|
* @returns The Session ID promise and single-owner SSE accessors.
|
|
134
134
|
*/
|
|
135
135
|
chat(input) {
|
|
136
|
-
return chat(this
|
|
136
|
+
return chat(this.#config, input);
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Records a complete Tool approval round and streams its continuation.
|
|
@@ -142,7 +142,7 @@ export class BlazingAgents {
|
|
|
142
142
|
* @returns The Session ID promise and continuation SSE accessors.
|
|
143
143
|
*/
|
|
144
144
|
continueChat(input) {
|
|
145
|
-
return continueChat(this
|
|
145
|
+
return continueChat(this.#config, input);
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* `POST /v1/agents/:agentId/generation` — stateless one-shot text
|
|
@@ -151,7 +151,7 @@ export class BlazingAgents {
|
|
|
151
151
|
* @returns Independent text stream, final text promise, and response relay.
|
|
152
152
|
*/
|
|
153
153
|
completion(input) {
|
|
154
|
-
return completion(this
|
|
154
|
+
return completion(this.#config, input);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* `POST /v1/agents/:agentId/generation` — stateless structured output.
|
|
@@ -160,7 +160,7 @@ export class BlazingAgents {
|
|
|
160
160
|
* @returns Partial JSON objects, a final JSON promise, and a text response relay.
|
|
161
161
|
*/
|
|
162
162
|
object(input) {
|
|
163
|
-
return objectGeneration(this
|
|
163
|
+
return objectGeneration(this.#config, input);
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
166
|
* Returns a lightweight client view whose resource and generation calls
|
|
@@ -170,7 +170,7 @@ export class BlazingAgents {
|
|
|
170
170
|
*/
|
|
171
171
|
withOptions(options) {
|
|
172
172
|
return new BlazingAgents({
|
|
173
|
-
...this
|
|
173
|
+
...this.#config,
|
|
174
174
|
clientRequestId: options.clientRequestId,
|
|
175
175
|
});
|
|
176
176
|
}
|
|
@@ -286,3 +286,54 @@ export declare const chatDeliveriesResponseSchema: z.ZodObject<{
|
|
|
286
286
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
287
287
|
}, z.core.$strip>;
|
|
288
288
|
export type ChatDeliveriesResponse = z.infer<typeof chatDeliveriesResponseSchema>;
|
|
289
|
+
export declare const chatDeliveryListSchema: z.ZodObject<{
|
|
290
|
+
data: z.ZodArray<z.ZodObject<{
|
|
291
|
+
id: z.ZodString;
|
|
292
|
+
kind: z.ZodEnum<{
|
|
293
|
+
card: "card";
|
|
294
|
+
reply: "reply";
|
|
295
|
+
}>;
|
|
296
|
+
status: z.ZodEnum<{
|
|
297
|
+
ambiguous: "ambiguous";
|
|
298
|
+
confirmed: "confirmed";
|
|
299
|
+
failed: "failed";
|
|
300
|
+
pending: "pending";
|
|
301
|
+
}>;
|
|
302
|
+
attempt: z.ZodNumber;
|
|
303
|
+
credentialVersion: z.ZodNumber;
|
|
304
|
+
representation: z.ZodString;
|
|
305
|
+
diagnostic: z.ZodNullable<z.ZodString>;
|
|
306
|
+
receipts: z.ZodOptional<z.ZodUnknown>;
|
|
307
|
+
sessionId: z.ZodString;
|
|
308
|
+
messageId: z.ZodNullable<z.ZodString>;
|
|
309
|
+
approvalId: z.ZodNullable<z.ZodString>;
|
|
310
|
+
threadId: z.ZodString;
|
|
311
|
+
createdAt: z.ZodString;
|
|
312
|
+
updatedAt: z.ZodString;
|
|
313
|
+
}, z.core.$strip>>;
|
|
314
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
315
|
+
}, z.core.$strip>;
|
|
316
|
+
export type ChatDeliveryList = z.infer<typeof chatDeliveryListSchema>;
|
|
317
|
+
export declare const repairChatDeliveryBodySchema: z.ZodObject<{
|
|
318
|
+
expectedAttempt: z.ZodNumber;
|
|
319
|
+
previousSenderStopped: z.ZodLiteral<true>;
|
|
320
|
+
acceptDuplicateRisk: z.ZodLiteral<true>;
|
|
321
|
+
}, z.core.$strict>;
|
|
322
|
+
export type RepairChatDeliveryBody = z.input<typeof repairChatDeliveryBodySchema>;
|
|
323
|
+
export declare const chatDeliveryResultSchema: z.ZodObject<{
|
|
324
|
+
id: z.ZodString;
|
|
325
|
+
sessionId: z.ZodString;
|
|
326
|
+
threadId: z.ZodString;
|
|
327
|
+
connectionId: z.ZodString;
|
|
328
|
+
kind: z.ZodEnum<{
|
|
329
|
+
card: "card";
|
|
330
|
+
reply: "reply";
|
|
331
|
+
}>;
|
|
332
|
+
status: z.ZodEnum<{
|
|
333
|
+
ambiguous: "ambiguous";
|
|
334
|
+
confirmed: "confirmed";
|
|
335
|
+
failed: "failed";
|
|
336
|
+
}>;
|
|
337
|
+
attempt: z.ZodNumber;
|
|
338
|
+
}, z.core.$strip>;
|
|
339
|
+
export type ChatDeliveryResult = z.infer<typeof chatDeliveryResultSchema>;
|
|
@@ -173,3 +173,27 @@ export const chatDeliveriesResponseSchema = z
|
|
|
173
173
|
nextCursor: z.string().nullable(),
|
|
174
174
|
})
|
|
175
175
|
.strip();
|
|
176
|
+
export const chatDeliveryListSchema = z
|
|
177
|
+
.object({
|
|
178
|
+
data: z.array(chatDeliverySchema),
|
|
179
|
+
nextCursor: z.string().nullable(),
|
|
180
|
+
})
|
|
181
|
+
.strip();
|
|
182
|
+
export const repairChatDeliveryBodySchema = z
|
|
183
|
+
.object({
|
|
184
|
+
expectedAttempt: z.number().int().min(0).max(99),
|
|
185
|
+
previousSenderStopped: z.literal(true),
|
|
186
|
+
acceptDuplicateRisk: z.literal(true),
|
|
187
|
+
})
|
|
188
|
+
.strict();
|
|
189
|
+
export const chatDeliveryResultSchema = z
|
|
190
|
+
.object({
|
|
191
|
+
id: chatDeliveryIdSchema,
|
|
192
|
+
sessionId: z.string(),
|
|
193
|
+
threadId: z.string(),
|
|
194
|
+
connectionId: chatConnectionIdSchema,
|
|
195
|
+
kind: z.enum(["reply", "card"]),
|
|
196
|
+
status: z.enum(["confirmed", "failed", "ambiguous"]),
|
|
197
|
+
attempt: z.number().int().nonnegative(),
|
|
198
|
+
})
|
|
199
|
+
.strip();
|
|
@@ -317,6 +317,8 @@ export type ChatFunctionDefinition = z.infer<typeof chatFunctionDefinitionSchema
|
|
|
317
317
|
export type ChatFunctionDefinitions = z.infer<typeof chatFunctionDefinitionsSchema>;
|
|
318
318
|
export type ChatFunctionCallEvent = z.infer<typeof chatFunctionCallEventSchema>;
|
|
319
319
|
export type ChatFunctionOutcome = z.infer<typeof chatFunctionOutcomeSchema>;
|
|
320
|
+
export type ChatRequestBody = z.input<typeof chatRequestBodySchema>;
|
|
321
|
+
export type GenerationRequestBody = z.input<typeof generationRequestBodySchema>;
|
|
320
322
|
export type ClaimChatFunctionBody = z.infer<typeof claimChatFunctionBodySchema>;
|
|
321
323
|
export type ResolveChatFunctionBody = z.infer<typeof resolveChatFunctionBodySchema>;
|
|
322
324
|
export {};
|
|
@@ -142,9 +142,6 @@ export declare const reconnectMcpConnectionBodySchema: z.ZodDiscriminatedUnion<[
|
|
|
142
142
|
scope: z.ZodOptional<z.ZodString>;
|
|
143
143
|
url: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
144
144
|
}, z.core.$strict>], "authType">;
|
|
145
|
-
export declare const mcpConnectionOauthConnectResponseSchema: z.ZodObject<{
|
|
146
|
-
authorizationUrl: z.ZodString;
|
|
147
|
-
}, z.core.$strip>;
|
|
148
145
|
export declare const mcpOauthAuthorizationLaunchResponseSchema: z.ZodObject<{
|
|
149
146
|
authorizationUrl: z.ZodString;
|
|
150
147
|
}, z.core.$strip>;
|
|
@@ -249,7 +246,6 @@ export type UpdateMcpConnectionBody = z.infer<typeof updateMcpConnectionBodySche
|
|
|
249
246
|
export type ReconnectMcpConnectionBody = z.infer<typeof reconnectMcpConnectionBodySchema>;
|
|
250
247
|
export type McpConnectionTestResponse = z.infer<typeof mcpConnectionTestResponseSchema>;
|
|
251
248
|
export type McpConnectionReconnectResult = z.infer<typeof mcpConnectionReconnectResultSchema>;
|
|
252
|
-
export type McpConnectionOauthConnectResponse = z.infer<typeof mcpConnectionOauthConnectResponseSchema>;
|
|
253
249
|
export type McpAttachmentResponse = z.infer<typeof mcpAttachmentResponseSchema>;
|
|
254
250
|
export type McpAttachmentsResponse = z.infer<typeof mcpAttachmentsResponseSchema>;
|
|
255
251
|
export type UpdateMcpAttachmentBody = z.infer<typeof updateMcpAttachmentBodySchema>;
|
|
@@ -212,22 +212,6 @@ export const reconnectMcpConnectionBodySchema = z
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
|
-
export const mcpConnectionOauthConnectResponseSchema = z
|
|
216
|
-
.object({
|
|
217
|
-
authorizationUrl: z
|
|
218
|
-
.string()
|
|
219
|
-
.url()
|
|
220
|
-
.refine((value) => {
|
|
221
|
-
const url = new URL(value);
|
|
222
|
-
return (url.pathname === "/app/mcp-connections" &&
|
|
223
|
-
url.username === "" &&
|
|
224
|
-
url.password === "" &&
|
|
225
|
-
url.hash === "" &&
|
|
226
|
-
url.searchParams.size === 1 &&
|
|
227
|
-
OPAQUE_MCP_OAUTH_TOKEN_PATTERN.test(url.searchParams.get("mcpOAuthSetup") ?? ""));
|
|
228
|
-
}),
|
|
229
|
-
})
|
|
230
|
-
.strip();
|
|
231
215
|
export const mcpOauthAuthorizationLaunchResponseSchema = z
|
|
232
216
|
.object({
|
|
233
217
|
authorizationUrl: z
|
|
@@ -9,8 +9,8 @@ export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsLis
|
|
|
9
9
|
export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.ts";
|
|
10
10
|
export type { ChatFunctionCallEvent, ChatFunctionDefinition, ChatFunctionDefinitions, ChatFunctionOutcome, ClaimChatFunctionBody, PromptVariables, ResolveChatFunctionBody, UsageSummary, } from "./entities/chat.ts";
|
|
11
11
|
export { blazingAgentsChatMessageMetadataSchema, chatFunctionCallEventSchema, chatFunctionDefinitionSchema, chatFunctionDefinitionsSchema, chatFunctionOutcomeSchema, chatModeSchema, chatRequestBodySchema, chatTriggerSchema, claimChatFunctionBodySchema, claimChatFunctionResponseSchema, generationRequestBodySchema, jsonSchemaShapeSchema, MAX_CHAT_FUNCTION_DEFINITIONS_BYTES, MAX_CHAT_FUNCTION_PAYLOAD_BYTES, MAX_CHAT_FUNCTIONS, promptVariablesSchema, resolveChatFunctionBodySchema, resolveChatFunctionResponseSchema, usageSummarySchema, } from "./entities/chat.ts";
|
|
12
|
-
export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseSchema, chatCredentialsSchema, chatDeliveriesResponseSchema, chatDeliveryListStatusSchema, chatDeliverySchema, chatDeliveryStatusSchema, chatHealthCheckSchema, chatHealthSchema, chatIdentitySchema, createChatConnectionBodySchema, rotateChatConnectionBodySchema, tenantChatDeliverySchema, updateChatConnectionBodySchema, } from "./entities/chat-connections.ts";
|
|
13
|
-
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema,
|
|
12
|
+
export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseSchema, chatCredentialsSchema, chatDeliveriesResponseSchema, chatDeliveryListSchema, chatDeliveryListStatusSchema, chatDeliveryResultSchema, chatDeliverySchema, chatDeliveryStatusSchema, chatHealthCheckSchema, chatHealthSchema, chatIdentitySchema, createChatConnectionBodySchema, repairChatDeliveryBodySchema, rotateChatConnectionBodySchema, tenantChatDeliverySchema, updateChatConnectionBodySchema, } from "./entities/chat-connections.ts";
|
|
13
|
+
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.ts";
|
|
14
14
|
export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.ts";
|
|
15
15
|
export { createMerchantConnectionBodySchema, merchantBindingResponseSchema, merchantBindingsResponseSchema, merchantConnectionResponseSchema, merchantConnectionSchema, merchantConnectionStatusSchema, merchantCustomerBindingSchema, merchantEnvironmentSchema, merchantGuardSchema, merchantProviderSchema, merchantUsageEventNextAction, merchantUsageEventNextActionSchema, merchantUsageEventSchema, merchantUsageEventStatusSchema, merchantUsageEventsResponseSchema, merchantUsageSummaryQuerySchema, merchantUsageSummaryResponseSchema, merchantUsageSummarySchema, merchantWorkflowIssueSchema, updateMerchantConnectionBodySchema, upsertMerchantBindingBodySchema, } from "./entities/merchant.ts";
|
|
16
16
|
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
|
package/dist/contracts/index.js
CHANGED
|
@@ -7,8 +7,8 @@ export { agentConfigSchema, agentResponseSchema, agentStatusSchema, agentsListQu
|
|
|
7
7
|
export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.js";
|
|
8
8
|
export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.js";
|
|
9
9
|
export { blazingAgentsChatMessageMetadataSchema, chatFunctionCallEventSchema, chatFunctionDefinitionSchema, chatFunctionDefinitionsSchema, chatFunctionOutcomeSchema, chatModeSchema, chatRequestBodySchema, chatTriggerSchema, claimChatFunctionBodySchema, claimChatFunctionResponseSchema, generationRequestBodySchema, jsonSchemaShapeSchema, MAX_CHAT_FUNCTION_DEFINITIONS_BYTES, MAX_CHAT_FUNCTION_PAYLOAD_BYTES, MAX_CHAT_FUNCTIONS, promptVariablesSchema, resolveChatFunctionBodySchema, resolveChatFunctionResponseSchema, usageSummarySchema, } from "./entities/chat.js";
|
|
10
|
-
export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseSchema, chatCredentialsSchema, chatDeliveriesResponseSchema, chatDeliveryListStatusSchema, chatDeliverySchema, chatDeliveryStatusSchema, chatHealthCheckSchema, chatHealthSchema, chatIdentitySchema, createChatConnectionBodySchema, rotateChatConnectionBodySchema, tenantChatDeliverySchema, updateChatConnectionBodySchema, } from "./entities/chat-connections.js";
|
|
11
|
-
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema,
|
|
10
|
+
export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseSchema, chatCredentialsSchema, chatDeliveriesResponseSchema, chatDeliveryListSchema, chatDeliveryListStatusSchema, chatDeliveryResultSchema, chatDeliverySchema, chatDeliveryStatusSchema, chatHealthCheckSchema, chatHealthSchema, chatIdentitySchema, createChatConnectionBodySchema, repairChatDeliveryBodySchema, rotateChatConnectionBodySchema, tenantChatDeliverySchema, updateChatConnectionBodySchema, } from "./entities/chat-connections.js";
|
|
11
|
+
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.js";
|
|
12
12
|
export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.js";
|
|
13
13
|
export { createMerchantConnectionBodySchema, merchantBindingResponseSchema, merchantBindingsResponseSchema, merchantConnectionResponseSchema, merchantConnectionSchema, merchantConnectionStatusSchema, merchantCustomerBindingSchema, merchantEnvironmentSchema, merchantGuardSchema, merchantProviderSchema, merchantUsageEventNextAction, merchantUsageEventNextActionSchema, merchantUsageEventSchema, merchantUsageEventStatusSchema, merchantUsageEventsResponseSchema, merchantUsageSummaryQuerySchema, merchantUsageSummaryResponseSchema, merchantUsageSummarySchema, merchantWorkflowIssueSchema, updateMerchantConnectionBodySchema, upsertMerchantBindingBodySchema, } from "./entities/merchant.js";
|
|
14
14
|
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.js";
|
|
@@ -59,38 +59,31 @@ export class BlazingAgentsDirectChatTransport extends ChatStreamTransport {
|
|
|
59
59
|
abortSignal: input.abortSignal,
|
|
60
60
|
};
|
|
61
61
|
let result;
|
|
62
|
-
if (this.#sessionId
|
|
63
|
-
|
|
62
|
+
if (this.#sessionId !== undefined) {
|
|
63
|
+
result = await client.chat({
|
|
64
|
+
...common,
|
|
65
|
+
message: lastUserMessage(input.messages),
|
|
66
|
+
sessionId: this.#sessionId,
|
|
67
|
+
trigger: input.trigger,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (this.#options.promptId === undefined) {
|
|
71
|
+
result = await client.chat({
|
|
64
72
|
...common,
|
|
65
73
|
trigger: "submit-message",
|
|
66
74
|
userId: this.#options.userId,
|
|
67
75
|
metadata: this.#options.metadata,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const message = input.messages.findLast((item) => item.role === "user");
|
|
71
|
-
if (!message) {
|
|
72
|
-
throw new Error("Chat submission requires a user message.");
|
|
73
|
-
}
|
|
74
|
-
result = await client.chat({ ...create, message });
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
result = await client.chat({
|
|
78
|
-
...create,
|
|
79
|
-
promptId: this.#options.promptId,
|
|
80
|
-
variables: this.#options.variables,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
76
|
+
message: lastUserMessage(input.messages),
|
|
77
|
+
});
|
|
83
78
|
}
|
|
84
79
|
else {
|
|
85
|
-
const message = input.messages.findLast((item) => item.role === "user");
|
|
86
|
-
if (!message) {
|
|
87
|
-
throw new Error("Chat submission requires a user message.");
|
|
88
|
-
}
|
|
89
80
|
result = await client.chat({
|
|
90
81
|
...common,
|
|
91
|
-
message,
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
trigger: "submit-message",
|
|
83
|
+
userId: this.#options.userId,
|
|
84
|
+
metadata: this.#options.metadata,
|
|
85
|
+
promptId: this.#options.promptId,
|
|
86
|
+
variables: this.#options.variables,
|
|
94
87
|
});
|
|
95
88
|
}
|
|
96
89
|
return this.#processChatResult(result);
|
|
@@ -107,7 +100,10 @@ export class BlazingAgentsDirectChatTransport extends ChatStreamTransport {
|
|
|
107
100
|
this.#sessionId = sessionId;
|
|
108
101
|
await this.#options.onSessionId?.(sessionId);
|
|
109
102
|
}
|
|
110
|
-
await
|
|
103
|
+
const turnId = await result.turnId.catch(() => undefined);
|
|
104
|
+
if (turnId !== undefined) {
|
|
105
|
+
await this.#options.onTurnId?.(turnId);
|
|
106
|
+
}
|
|
111
107
|
}
|
|
112
108
|
catch (error) {
|
|
113
109
|
await stream.cancel(error).catch(() => undefined);
|
|
@@ -143,21 +139,13 @@ export class BlazingAgentsDirectChatTransport extends ChatStreamTransport {
|
|
|
143
139
|
decisions,
|
|
144
140
|
functions: this.#options.functions ?? {},
|
|
145
141
|
});
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
await this.#reportTurnId(continuation);
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
await stream.cancel(error).catch(() => undefined);
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
return this.processResponseStream(stream);
|
|
142
|
+
return this.#processChatResult(continuation);
|
|
155
143
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
144
|
+
}
|
|
145
|
+
function lastUserMessage(messages) {
|
|
146
|
+
const message = messages.findLast((item) => item.role === "user");
|
|
147
|
+
if (!message) {
|
|
148
|
+
throw new Error("Chat submission requires a user message.");
|
|
162
149
|
}
|
|
150
|
+
return message;
|
|
163
151
|
}
|
package/dist/errors.js
CHANGED
|
@@ -18,7 +18,6 @@ export class BlazingAgentsError extends Error {
|
|
|
18
18
|
responseBody;
|
|
19
19
|
responseBodyTruncated;
|
|
20
20
|
status;
|
|
21
|
-
// Stryker disable BooleanLiteral: cross-realm identity depends on marker presence, not its value.
|
|
22
21
|
/**
|
|
23
22
|
* Marker property used by `isInstance` for cross-realm `instanceof`
|
|
24
23
|
* checks — the symbol is checked via `in`, not direct property access,
|
|
@@ -26,7 +25,6 @@ export class BlazingAgentsError extends Error {
|
|
|
26
25
|
* biome-ignore lint/correctness/noUnusedPrivateClassMembers: marker pattern
|
|
27
26
|
*/
|
|
28
27
|
[BLAZING_AGENTS_ERROR_SYMBOL] = true;
|
|
29
|
-
// Stryker restore BooleanLiteral
|
|
30
28
|
/**
|
|
31
29
|
* Creates an SDK error with its code, diagnostics, and optional cause.
|
|
32
30
|
* @param options - Configuration for this operation.
|
package/dist/functions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { chatFunctionCallEventSchema, chatFunctionDefinitionsSchema, chatFunctionOutcomeSchema, claimChatFunctionResponseSchema, resolveChatFunctionResponseSchema, } from "./contracts/entities/chat.js";
|
|
3
3
|
import { BlazingAgentsError } from "./errors.js";
|
|
4
|
-
import { requestJson } from "./http.js";
|
|
4
|
+
import { apiPath, requestJson } from "./http.js";
|
|
5
5
|
/**
|
|
6
6
|
* Declares a caller-local function whose handler input is inferred from its Zod schema.
|
|
7
7
|
* @param definition - Description, input schema, and local handler.
|
|
@@ -313,7 +313,7 @@ export function dispatchChatFunctions(config, target, body) {
|
|
|
313
313
|
* Claims a function call, runs its handler, and posts the result within its retry budget.
|
|
314
314
|
*/
|
|
315
315
|
const runCall = async (call) => {
|
|
316
|
-
const path = `/v1/agents/${target.agentId}/sessions/${target.sessionId}/function-calls/${call.id}`;
|
|
316
|
+
const path = apiPath `/v1/agents/${target.agentId}/sessions/${target.sessionId}/function-calls/${call.id}`;
|
|
317
317
|
const claimRequestId = crypto.randomUUID();
|
|
318
318
|
const deadline = Date.parse(call.deadlineAt);
|
|
319
319
|
const claim = await postWithRetry(config, `${path}/claim`, { claimRequestId }, claimChatFunctionResponseSchema, deadline, handlers.signal);
|
package/dist/generation.d.ts
CHANGED
|
@@ -24,9 +24,8 @@ export declare function withFilteredBody(response: Response, filter: (body: Read
|
|
|
24
24
|
* Creates single-owner SSE response and byte-stream accessors.
|
|
25
25
|
* @param response - Upstream HTTP response.
|
|
26
26
|
* @param resourceName - Resource label used in stream errors.
|
|
27
|
-
* @param filter - Transforms upstream SSE bytes before exposing them to the caller.
|
|
28
27
|
*/
|
|
29
|
-
export declare function buildTerminalStreamResult(response: Response, resourceName: string
|
|
28
|
+
export declare function buildTerminalStreamResult(response: Response, resourceName: string): TerminalStreamResult;
|
|
30
29
|
/**
|
|
31
30
|
* Starts stateless text generation with independent final, incremental, and response outputs.
|
|
32
31
|
* @param config - Authentication, base URL, and transport configuration.
|