@blazingagents/sdk 0.49.0 → 0.50.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/client-config.d.ts +4 -0
- package/dist/client-config.js +8 -0
- package/dist/client.d.ts +3 -45
- package/dist/client.js +15 -75
- package/dist/contracts/entities/chat.d.ts +2 -1
- package/dist/contracts/entities/chat.js +10 -2
- package/dist/contracts/entities/tasks.js +3 -1
- package/dist/http.js +33 -10
- package/dist/rest-client.d.ts +53 -0
- package/dist/rest-client.js +87 -0
- package/dist/rest.d.ts +8 -0
- package/dist/rest.js +8 -0
- package/package.json +5 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HttpConfig } from "./types.ts";
|
|
2
|
+
/** Keeps a client's transport configuration off its enumerable surface. */
|
|
3
|
+
export declare function setClientConfig(client: object, config: HttpConfig): void;
|
|
4
|
+
export declare function clientConfig(client: object): HttpConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const CONFIG = Symbol("blazingAgents.config");
|
|
2
|
+
/** Keeps a client's transport configuration off its enumerable surface. */
|
|
3
|
+
export function setClientConfig(client, config) {
|
|
4
|
+
Object.defineProperty(client, CONFIG, { value: config });
|
|
5
|
+
}
|
|
6
|
+
export function clientConfig(client) {
|
|
7
|
+
return client[CONFIG];
|
|
8
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { type McpConnectionsResource } from "./resources/mcp-connections.ts";
|
|
5
|
-
import { type MemoriesResource } from "./resources/memories.ts";
|
|
6
|
-
import { type MerchantBindingsResource } from "./resources/merchant-bindings.ts";
|
|
7
|
-
import { type MerchantConnectionResource } from "./resources/merchant-connection.ts";
|
|
8
|
-
import { type MerchantUsageEventsResource } from "./resources/merchant-usage-events.ts";
|
|
9
|
-
import { type PromptsResource } from "./resources/prompts.ts";
|
|
10
|
-
import { type ProvidersResource } from "./resources/providers.ts";
|
|
11
|
-
import { type SessionsResource } from "./resources/sessions.ts";
|
|
12
|
-
import { type TasksResource } from "./resources/tasks.ts";
|
|
13
|
-
import { type TenantResource } from "./resources/tenant.ts";
|
|
14
|
-
import { type UsageResource } from "./resources/usage.ts";
|
|
15
|
-
import { type WorkspacesResource } from "./resources/workspaces.ts";
|
|
16
|
-
import type { AgentClient, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatInput, ChatResult, CompletionInput, CompletionResult, ContinueChatInput, ObjectInput, ObjectResult, UserClient } from "./types.ts";
|
|
17
|
-
export declare class BlazingAgents {
|
|
18
|
-
#private;
|
|
19
|
-
readonly chatConnections: ChatConnectionsResource;
|
|
20
|
-
readonly agents: AgentsResource;
|
|
21
|
-
readonly sessions: SessionsResource;
|
|
22
|
-
readonly providers: ProvidersResource;
|
|
23
|
-
readonly mcpConnections: McpConnectionsResource;
|
|
24
|
-
readonly memories: MemoriesResource;
|
|
25
|
-
readonly prompts: PromptsResource;
|
|
26
|
-
readonly usage: UsageResource;
|
|
27
|
-
readonly artifacts: ArtifactsResource;
|
|
28
|
-
readonly tasks: TasksResource;
|
|
29
|
-
readonly tenant: TenantResource;
|
|
30
|
-
readonly workspaces: WorkspacesResource;
|
|
31
|
-
readonly merchantConnection: MerchantConnectionResource;
|
|
32
|
-
readonly merchantBindings: MerchantBindingsResource;
|
|
33
|
-
readonly merchantUsageEvents: MerchantUsageEventsResource;
|
|
34
|
-
/**
|
|
35
|
-
* Creates a client. Defaults to the hosted API and removes trailing base URL slashes.
|
|
36
|
-
* @param options - Configuration for this operation.
|
|
37
|
-
*/
|
|
38
|
-
constructor(options: BlazingAgentsOptions);
|
|
39
|
-
/**
|
|
40
|
-
* Returns the Skill operations for the selected Agent.
|
|
41
|
-
* @returns The selected Agent Skill client.
|
|
42
|
-
*/
|
|
43
|
-
agent({ agentId }: {
|
|
44
|
-
agentId: string;
|
|
45
|
-
}): AgentClient;
|
|
1
|
+
import { BlazingAgentsRest } from "./rest-client.ts";
|
|
2
|
+
import type { BlazingAgentsRequestOptions, ChatInput, ChatResult, CompletionInput, CompletionResult, ContinueChatInput, ObjectInput, ObjectResult, UserClient } from "./types.ts";
|
|
3
|
+
export declare class BlazingAgents extends BlazingAgentsRest {
|
|
46
4
|
/**
|
|
47
5
|
* Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces.
|
|
48
6
|
* @param userId - Printable ASCII end-user ID, at most 256 characters with no surrounding spaces.
|
package/dist/client.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { clientConfig } from "./client-config.js";
|
|
2
3
|
import { parseClientInput } from "./errors.js";
|
|
3
4
|
import { chat, completion, continueChat, objectGeneration, } from "./generation.js";
|
|
4
|
-
import {
|
|
5
|
-
import { createArtifactsResource
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { createMerchantBindingsResource, } from "./resources/merchant-bindings.js";
|
|
10
|
-
import { createMerchantConnectionResource, } from "./resources/merchant-connection.js";
|
|
11
|
-
import { createMerchantUsageEventsResource, } from "./resources/merchant-usage-events.js";
|
|
12
|
-
import { createPromptsResource, } from "./resources/prompts.js";
|
|
13
|
-
import { createProvidersResource, } from "./resources/providers.js";
|
|
14
|
-
import { createSessionsResource, } from "./resources/sessions.js";
|
|
5
|
+
import { createUserAgentsResource } from "./resources/agents.js";
|
|
6
|
+
import { createArtifactsResource } from "./resources/artifacts.js";
|
|
7
|
+
import { createMemoriesResource } from "./resources/memories.js";
|
|
8
|
+
import { createPromptsResource } from "./resources/prompts.js";
|
|
9
|
+
import { createSessionsResource } from "./resources/sessions.js";
|
|
15
10
|
import { createAgentSkillsResource } from "./resources/skills.js";
|
|
16
11
|
import { createTasksResource } from "./resources/tasks.js";
|
|
17
|
-
import { createTenantResource, } from "./resources/tenant.js";
|
|
18
12
|
import { createUsageResource } from "./resources/usage.js";
|
|
19
|
-
import { createWorkspacesResource
|
|
20
|
-
|
|
21
|
-
const TRAILING_SLASH_RE = /\/+$/;
|
|
13
|
+
import { createWorkspacesResource } from "./resources/workspaces.js";
|
|
14
|
+
import { BlazingAgentsRest } from "./rest-client.js";
|
|
22
15
|
const scopedUserIdSchema = z
|
|
23
16
|
.string()
|
|
24
17
|
.max(256)
|
|
@@ -57,60 +50,7 @@ function createUserClient(config) {
|
|
|
57
50
|
withOptions: (options) => createUserClient({ ...config, clientRequestId: options.clientRequestId }),
|
|
58
51
|
};
|
|
59
52
|
}
|
|
60
|
-
export class BlazingAgents {
|
|
61
|
-
#config;
|
|
62
|
-
chatConnections;
|
|
63
|
-
agents;
|
|
64
|
-
sessions;
|
|
65
|
-
providers;
|
|
66
|
-
mcpConnections;
|
|
67
|
-
memories;
|
|
68
|
-
prompts;
|
|
69
|
-
usage;
|
|
70
|
-
artifacts;
|
|
71
|
-
tasks;
|
|
72
|
-
tenant;
|
|
73
|
-
workspaces;
|
|
74
|
-
merchantConnection;
|
|
75
|
-
merchantBindings;
|
|
76
|
-
merchantUsageEvents;
|
|
77
|
-
/**
|
|
78
|
-
* Creates a client. Defaults to the hosted API and removes trailing base URL slashes.
|
|
79
|
-
* @param options - Configuration for this operation.
|
|
80
|
-
*/
|
|
81
|
-
constructor(options) {
|
|
82
|
-
this.#config = {
|
|
83
|
-
apiKey: options.apiKey,
|
|
84
|
-
baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(TRAILING_SLASH_RE, ""),
|
|
85
|
-
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
86
|
-
...(options.clientRequestId === undefined
|
|
87
|
-
? {}
|
|
88
|
-
: { clientRequestId: options.clientRequestId }),
|
|
89
|
-
onResponse: options.onResponse,
|
|
90
|
-
};
|
|
91
|
-
this.chatConnections = createChatConnectionsResource(this.#config);
|
|
92
|
-
this.agents = createAgentsResource(this.#config);
|
|
93
|
-
this.sessions = createSessionsResource(this.#config);
|
|
94
|
-
this.providers = createProvidersResource(this.#config);
|
|
95
|
-
this.mcpConnections = createMcpConnectionsResource(this.#config);
|
|
96
|
-
this.memories = createMemoriesResource(this.#config);
|
|
97
|
-
this.prompts = createPromptsResource(this.#config);
|
|
98
|
-
this.usage = createUsageResource(this.#config);
|
|
99
|
-
this.artifacts = createArtifactsResource(this.#config);
|
|
100
|
-
this.tasks = createTasksResource(this.#config);
|
|
101
|
-
this.tenant = createTenantResource(this.#config);
|
|
102
|
-
this.workspaces = createWorkspacesResource(this.#config);
|
|
103
|
-
this.merchantConnection = createMerchantConnectionResource(this.#config);
|
|
104
|
-
this.merchantBindings = createMerchantBindingsResource(this.#config);
|
|
105
|
-
this.merchantUsageEvents = createMerchantUsageEventsResource(this.#config);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Returns the Skill operations for the selected Agent.
|
|
109
|
-
* @returns The selected Agent Skill client.
|
|
110
|
-
*/
|
|
111
|
-
agent({ agentId }) {
|
|
112
|
-
return { skills: createAgentSkillsResource(this.#config, agentId) };
|
|
113
|
-
}
|
|
53
|
+
export class BlazingAgents extends BlazingAgentsRest {
|
|
114
54
|
/**
|
|
115
55
|
* Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces.
|
|
116
56
|
* @param userId - Printable ASCII end-user ID, at most 256 characters with no surrounding spaces.
|
|
@@ -119,7 +59,7 @@ export class BlazingAgents {
|
|
|
119
59
|
*/
|
|
120
60
|
forUser(userId) {
|
|
121
61
|
return createUserClient({
|
|
122
|
-
...this
|
|
62
|
+
...clientConfig(this),
|
|
123
63
|
scopeUserId: parseClientInput(scopedUserIdSchema, userId, "userId"),
|
|
124
64
|
});
|
|
125
65
|
}
|
|
@@ -131,7 +71,7 @@ export class BlazingAgents {
|
|
|
131
71
|
* @returns The Session ID promise and single-owner SSE accessors.
|
|
132
72
|
*/
|
|
133
73
|
chat(input) {
|
|
134
|
-
return chat(this
|
|
74
|
+
return chat(clientConfig(this), input);
|
|
135
75
|
}
|
|
136
76
|
/**
|
|
137
77
|
* Records a complete Tool approval round and streams its continuation.
|
|
@@ -140,7 +80,7 @@ export class BlazingAgents {
|
|
|
140
80
|
* @returns The Session ID promise and continuation SSE accessors.
|
|
141
81
|
*/
|
|
142
82
|
continueChat(input) {
|
|
143
|
-
return continueChat(this
|
|
83
|
+
return continueChat(clientConfig(this), input);
|
|
144
84
|
}
|
|
145
85
|
/**
|
|
146
86
|
* `POST /v1/agents/:agentId/generation` — stateless one-shot text
|
|
@@ -149,7 +89,7 @@ export class BlazingAgents {
|
|
|
149
89
|
* @returns Independent text stream, final text promise, and response relay.
|
|
150
90
|
*/
|
|
151
91
|
completion(input) {
|
|
152
|
-
return completion(this
|
|
92
|
+
return completion(clientConfig(this), input);
|
|
153
93
|
}
|
|
154
94
|
/**
|
|
155
95
|
* `POST /v1/agents/:agentId/generation` — stateless structured output.
|
|
@@ -158,7 +98,7 @@ export class BlazingAgents {
|
|
|
158
98
|
* @returns Partial JSON objects, a final JSON promise, and a text response relay.
|
|
159
99
|
*/
|
|
160
100
|
object(input) {
|
|
161
|
-
return objectGeneration(this
|
|
101
|
+
return objectGeneration(clientConfig(this), input);
|
|
162
102
|
}
|
|
163
103
|
/**
|
|
164
104
|
* Returns a lightweight client view whose resource and generation calls
|
|
@@ -168,7 +108,7 @@ export class BlazingAgents {
|
|
|
168
108
|
*/
|
|
169
109
|
withOptions(options) {
|
|
170
110
|
return new BlazingAgents({
|
|
171
|
-
...this
|
|
111
|
+
...clientConfig(this),
|
|
172
112
|
clientRequestId: options.clientRequestId,
|
|
173
113
|
});
|
|
174
114
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
/**
|
|
3
4
|
* Re-exported AI SDK types — every service, the SDK, and the dashboard
|
|
@@ -78,7 +79,7 @@ export declare const blazingAgentsChatMessageMetadataSchema: z.ZodObject<{
|
|
|
78
79
|
tenantId: z.ZodString;
|
|
79
80
|
userId: z.ZodString;
|
|
80
81
|
}, z.core.$strip>;
|
|
81
|
-
compactedContext: z.ZodOptional<z.ZodArray<z.
|
|
82
|
+
compactedContext: z.ZodOptional<z.ZodArray<z.ZodCustom<ModelMessage, ModelMessage>>>;
|
|
82
83
|
}, z.core.$strip>;
|
|
83
84
|
}, z.core.$strip>;
|
|
84
85
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { modelMessageSchema } from "ai";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { agentIdSchema, functionCallIdSchema, promptIdSchema, sessionIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
|
|
4
3
|
import { chatFunctionNameSchema } from "./agent-tools.js";
|
|
@@ -53,12 +52,21 @@ export const usageSummarySchema = z
|
|
|
53
52
|
userId: z.string(),
|
|
54
53
|
})
|
|
55
54
|
.strip();
|
|
55
|
+
/**
|
|
56
|
+
* A compacted model message, typed as the AI SDK's `ModelMessage`. The shape
|
|
57
|
+
* is the server's own output, so only its role is checked here; that keeps
|
|
58
|
+
* the contracts free of the `ai` runtime.
|
|
59
|
+
*/
|
|
60
|
+
const compactedMessageSchema = z.custom((value) => typeof value === "object" &&
|
|
61
|
+
value !== null &&
|
|
62
|
+
"role" in value &&
|
|
63
|
+
typeof value.role === "string");
|
|
56
64
|
export const blazingAgentsChatMessageMetadataSchema = z
|
|
57
65
|
.object({
|
|
58
66
|
blazingAgents: z
|
|
59
67
|
.object({
|
|
60
68
|
usage: usageSummarySchema,
|
|
61
|
-
compactedContext: z.array(
|
|
69
|
+
compactedContext: z.array(compactedMessageSchema).optional(),
|
|
62
70
|
})
|
|
63
71
|
.strip(),
|
|
64
72
|
})
|
|
@@ -70,7 +70,9 @@ export const taskCronConfigSchema = z
|
|
|
70
70
|
paused: true,
|
|
71
71
|
timezone: config.timezone,
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
// A five-field expression repeats, so a run after the epoch exists
|
|
74
|
+
// exactly when one after now does; this keeps parsing off the clock.
|
|
75
|
+
if (cron.nextRun(new Date(0)) === null) {
|
|
74
76
|
throw new Error("no next run");
|
|
75
77
|
}
|
|
76
78
|
}
|
package/dist/http.js
CHANGED
|
@@ -204,7 +204,7 @@ async function rawRequest(config, path, options) {
|
|
|
204
204
|
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
205
205
|
const url = buildUrl(config.baseUrl, path, options.query);
|
|
206
206
|
const method = options.method ?? "GET";
|
|
207
|
-
const startedAt = performance.now();
|
|
207
|
+
const startedAt = config.onResponse ? performance.now() : 0;
|
|
208
208
|
const clientRequestId = options.clientRequestId ?? config.clientRequestId;
|
|
209
209
|
const headers = {
|
|
210
210
|
authorization: `Bearer ${config.apiKey}`,
|
|
@@ -310,6 +310,23 @@ async function readResponseBody(response, stopAtDiagnosticLimit) {
|
|
|
310
310
|
readFailed: false,
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
+
// A fetch without body streams (Exact's native hosts) still reads whole.
|
|
314
|
+
if (response.body === undefined) {
|
|
315
|
+
let bytes;
|
|
316
|
+
try {
|
|
317
|
+
bytes = new Uint8Array(await response.arrayBuffer());
|
|
318
|
+
}
|
|
319
|
+
catch (cause) {
|
|
320
|
+
return {
|
|
321
|
+
bodyText: "",
|
|
322
|
+
cause,
|
|
323
|
+
diagnosticBody: "",
|
|
324
|
+
diagnosticBodyTruncated: true,
|
|
325
|
+
readFailed: true,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return completedBody([bytes], bytes.byteLength, stopAtDiagnosticLimit);
|
|
329
|
+
}
|
|
313
330
|
let reader;
|
|
314
331
|
try {
|
|
315
332
|
reader = response.body.getReader();
|
|
@@ -341,15 +358,7 @@ async function readResponseBody(response, stopAtDiagnosticLimit) {
|
|
|
341
358
|
};
|
|
342
359
|
}
|
|
343
360
|
if (read.done) {
|
|
344
|
-
|
|
345
|
-
return {
|
|
346
|
-
bodyText: stopAtDiagnosticLimit
|
|
347
|
-
? diagnostic.body
|
|
348
|
-
: decodeChunks(chunks, byteLength, false),
|
|
349
|
-
diagnosticBody: diagnostic.body,
|
|
350
|
-
diagnosticBodyTruncated: diagnostic.truncated,
|
|
351
|
-
readFailed: false,
|
|
352
|
-
};
|
|
361
|
+
return completedBody(chunks, byteLength, stopAtDiagnosticLimit);
|
|
353
362
|
}
|
|
354
363
|
const chunk = read.value;
|
|
355
364
|
if (stopAtDiagnosticLimit &&
|
|
@@ -365,6 +374,20 @@ async function readResponseBody(response, stopAtDiagnosticLimit) {
|
|
|
365
374
|
byteLength += chunk.byteLength;
|
|
366
375
|
}
|
|
367
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* The read result for a body received whole.
|
|
379
|
+
*/
|
|
380
|
+
function completedBody(chunks, byteLength, stopAtDiagnosticLimit) {
|
|
381
|
+
const diagnostic = decodeDiagnosticChunks(chunks, Math.min(byteLength, DIAGNOSTIC_BODY_LIMIT_BYTES), byteLength > DIAGNOSTIC_BODY_LIMIT_BYTES);
|
|
382
|
+
return {
|
|
383
|
+
bodyText: stopAtDiagnosticLimit
|
|
384
|
+
? diagnostic.body
|
|
385
|
+
: decodeChunks(chunks, byteLength, false),
|
|
386
|
+
diagnosticBody: diagnostic.body,
|
|
387
|
+
diagnosticBodyTruncated: diagnostic.truncated,
|
|
388
|
+
readFailed: false,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
368
391
|
/**
|
|
369
392
|
* Cancels an oversized error body and retains its bounded diagnostic prefix.
|
|
370
393
|
*/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type AgentsResource } from "./resources/agents.ts";
|
|
2
|
+
import { type ArtifactsResource } from "./resources/artifacts.ts";
|
|
3
|
+
import { type ChatConnectionsResource } from "./resources/chat-connections.ts";
|
|
4
|
+
import { type McpConnectionsResource } from "./resources/mcp-connections.ts";
|
|
5
|
+
import { type MemoriesResource } from "./resources/memories.ts";
|
|
6
|
+
import { type MerchantBindingsResource } from "./resources/merchant-bindings.ts";
|
|
7
|
+
import { type MerchantConnectionResource } from "./resources/merchant-connection.ts";
|
|
8
|
+
import { type MerchantUsageEventsResource } from "./resources/merchant-usage-events.ts";
|
|
9
|
+
import { type PromptsResource } from "./resources/prompts.ts";
|
|
10
|
+
import { type ProvidersResource } from "./resources/providers.ts";
|
|
11
|
+
import { type SessionsResource } from "./resources/sessions.ts";
|
|
12
|
+
import { type TasksResource } from "./resources/tasks.ts";
|
|
13
|
+
import { type TenantResource } from "./resources/tenant.ts";
|
|
14
|
+
import { type UsageResource } from "./resources/usage.ts";
|
|
15
|
+
import { type WorkspacesResource } from "./resources/workspaces.ts";
|
|
16
|
+
import type { AgentClient, BlazingAgentsOptions, BlazingAgentsRequestOptions } from "./types.ts";
|
|
17
|
+
/** Every `/v1` resource, without chat or generation. */
|
|
18
|
+
export declare class BlazingAgentsRest {
|
|
19
|
+
readonly chatConnections: ChatConnectionsResource;
|
|
20
|
+
readonly agents: AgentsResource;
|
|
21
|
+
readonly sessions: SessionsResource;
|
|
22
|
+
readonly providers: ProvidersResource;
|
|
23
|
+
readonly mcpConnections: McpConnectionsResource;
|
|
24
|
+
readonly memories: MemoriesResource;
|
|
25
|
+
readonly prompts: PromptsResource;
|
|
26
|
+
readonly usage: UsageResource;
|
|
27
|
+
readonly artifacts: ArtifactsResource;
|
|
28
|
+
readonly tasks: TasksResource;
|
|
29
|
+
readonly tenant: TenantResource;
|
|
30
|
+
readonly workspaces: WorkspacesResource;
|
|
31
|
+
readonly merchantConnection: MerchantConnectionResource;
|
|
32
|
+
readonly merchantBindings: MerchantBindingsResource;
|
|
33
|
+
readonly merchantUsageEvents: MerchantUsageEventsResource;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a client. Defaults to the hosted API and removes trailing base URL slashes.
|
|
36
|
+
* @param options - Configuration for this operation.
|
|
37
|
+
*/
|
|
38
|
+
constructor(options: BlazingAgentsOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Returns the Skill operations for the selected Agent.
|
|
41
|
+
* @returns The selected Agent Skill client.
|
|
42
|
+
*/
|
|
43
|
+
agent({ agentId }: {
|
|
44
|
+
agentId: string;
|
|
45
|
+
}): AgentClient;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a lightweight client view whose resource calls carry
|
|
48
|
+
* caller-owned correlation without raw header manipulation.
|
|
49
|
+
* @param options - Caller-owned request correlation ID for subsequent calls.
|
|
50
|
+
* @returns A new client carrying the supplied correlation ID.
|
|
51
|
+
*/
|
|
52
|
+
withOptions(options: BlazingAgentsRequestOptions): BlazingAgentsRest;
|
|
53
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { clientConfig, setClientConfig } from "./client-config.js";
|
|
2
|
+
import { createAgentsResource, } from "./resources/agents.js";
|
|
3
|
+
import { createArtifactsResource, } from "./resources/artifacts.js";
|
|
4
|
+
import { createChatConnectionsResource, } from "./resources/chat-connections.js";
|
|
5
|
+
import { createMcpConnectionsResource, } from "./resources/mcp-connections.js";
|
|
6
|
+
import { createMemoriesResource, } from "./resources/memories.js";
|
|
7
|
+
import { createMerchantBindingsResource, } from "./resources/merchant-bindings.js";
|
|
8
|
+
import { createMerchantConnectionResource, } from "./resources/merchant-connection.js";
|
|
9
|
+
import { createMerchantUsageEventsResource, } from "./resources/merchant-usage-events.js";
|
|
10
|
+
import { createPromptsResource, } from "./resources/prompts.js";
|
|
11
|
+
import { createProvidersResource, } from "./resources/providers.js";
|
|
12
|
+
import { createSessionsResource, } from "./resources/sessions.js";
|
|
13
|
+
import { createAgentSkillsResource } from "./resources/skills.js";
|
|
14
|
+
import { createTasksResource } from "./resources/tasks.js";
|
|
15
|
+
import { createTenantResource, } from "./resources/tenant.js";
|
|
16
|
+
import { createUsageResource } from "./resources/usage.js";
|
|
17
|
+
import { createWorkspacesResource, } from "./resources/workspaces.js";
|
|
18
|
+
const DEFAULT_BASE_URL = "https://api.blazingagents.com";
|
|
19
|
+
const TRAILING_SLASH_RE = /\/+$/;
|
|
20
|
+
/** Every `/v1` resource, without chat or generation. */
|
|
21
|
+
export class BlazingAgentsRest {
|
|
22
|
+
chatConnections;
|
|
23
|
+
agents;
|
|
24
|
+
sessions;
|
|
25
|
+
providers;
|
|
26
|
+
mcpConnections;
|
|
27
|
+
memories;
|
|
28
|
+
prompts;
|
|
29
|
+
usage;
|
|
30
|
+
artifacts;
|
|
31
|
+
tasks;
|
|
32
|
+
tenant;
|
|
33
|
+
workspaces;
|
|
34
|
+
merchantConnection;
|
|
35
|
+
merchantBindings;
|
|
36
|
+
merchantUsageEvents;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a client. Defaults to the hosted API and removes trailing base URL slashes.
|
|
39
|
+
* @param options - Configuration for this operation.
|
|
40
|
+
*/
|
|
41
|
+
constructor(options) {
|
|
42
|
+
const config = {
|
|
43
|
+
apiKey: options.apiKey,
|
|
44
|
+
baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(TRAILING_SLASH_RE, ""),
|
|
45
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
46
|
+
...(options.clientRequestId === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { clientRequestId: options.clientRequestId }),
|
|
49
|
+
onResponse: options.onResponse,
|
|
50
|
+
};
|
|
51
|
+
setClientConfig(this, config);
|
|
52
|
+
this.chatConnections = createChatConnectionsResource(config);
|
|
53
|
+
this.agents = createAgentsResource(config);
|
|
54
|
+
this.sessions = createSessionsResource(config);
|
|
55
|
+
this.providers = createProvidersResource(config);
|
|
56
|
+
this.mcpConnections = createMcpConnectionsResource(config);
|
|
57
|
+
this.memories = createMemoriesResource(config);
|
|
58
|
+
this.prompts = createPromptsResource(config);
|
|
59
|
+
this.usage = createUsageResource(config);
|
|
60
|
+
this.artifacts = createArtifactsResource(config);
|
|
61
|
+
this.tasks = createTasksResource(config);
|
|
62
|
+
this.tenant = createTenantResource(config);
|
|
63
|
+
this.workspaces = createWorkspacesResource(config);
|
|
64
|
+
this.merchantConnection = createMerchantConnectionResource(config);
|
|
65
|
+
this.merchantBindings = createMerchantBindingsResource(config);
|
|
66
|
+
this.merchantUsageEvents = createMerchantUsageEventsResource(config);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the Skill operations for the selected Agent.
|
|
70
|
+
* @returns The selected Agent Skill client.
|
|
71
|
+
*/
|
|
72
|
+
agent({ agentId }) {
|
|
73
|
+
return { skills: createAgentSkillsResource(clientConfig(this), agentId) };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns a lightweight client view whose resource calls carry
|
|
77
|
+
* caller-owned correlation without raw header manipulation.
|
|
78
|
+
* @param options - Caller-owned request correlation ID for subsequent calls.
|
|
79
|
+
* @returns A new client carrying the supplied correlation ID.
|
|
80
|
+
*/
|
|
81
|
+
withOptions(options) {
|
|
82
|
+
return new BlazingAgentsRest({
|
|
83
|
+
...clientConfig(this),
|
|
84
|
+
clientRequestId: options.clientRequestId,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
package/dist/rest.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@blazingagents/sdk/rest` — every `/v1` resource without chat or
|
|
3
|
+
* generation, so it loads without the `ai` peer dependency (React Native
|
|
4
|
+
* hosts without DOM or Node APIs, Exact data modules).
|
|
5
|
+
*/
|
|
6
|
+
export { BlazingAgentsError } from "./errors.ts";
|
|
7
|
+
export { BlazingAgentsRest } from "./rest-client.ts";
|
|
8
|
+
export type { BlazingAgentsOptions, HttpConfig } from "./types.ts";
|
package/dist/rest.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@blazingagents/sdk/rest` — every `/v1` resource without chat or
|
|
3
|
+
* generation, so it loads without the `ai` peer dependency (React Native
|
|
4
|
+
* hosts without DOM or Node APIs, Exact data modules).
|
|
5
|
+
*/
|
|
6
|
+
// biome-ignore lint/performance/noBarrelFile: package entry point
|
|
7
|
+
export { BlazingAgentsError } from "./errors.js";
|
|
8
|
+
export { BlazingAgentsRest } from "./rest-client.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazingagents/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "TypeScript SDK for the Blazing Agents API",
|
|
5
5
|
"homepage": "https://docs.blazingagents.com",
|
|
6
6
|
"bugs": {
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"./contracts": {
|
|
22
22
|
"types": "./dist/contracts/index.d.ts",
|
|
23
23
|
"import": "./dist/contracts/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./rest": {
|
|
26
|
+
"types": "./dist/rest.d.ts",
|
|
27
|
+
"import": "./dist/rest.js"
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"types": "./dist/index.d.ts",
|