@blazingagents/sdk 0.14.0 → 0.15.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 +5 -231
- package/dist/client.d.ts +3 -1
- package/dist/client.js +32 -0
- package/dist/contracts/api.d.ts +6 -9
- package/dist/contracts/api.js +2 -3
- package/dist/contracts/entities/agents.d.ts +4 -1
- package/dist/contracts/entities/agents.js +9 -6
- package/dist/contracts/entities/prompts.d.ts +9 -1
- package/dist/contracts/entities/prompts.js +14 -4
- package/dist/contracts/entities/tasks.d.ts +4 -6
- package/dist/contracts/entities/tasks.js +4 -6
- package/dist/contracts/entities/usage.d.ts +18 -0
- package/dist/contracts/entities/usage.js +28 -0
- package/dist/contracts/index.d.ts +5 -5
- package/dist/contracts/index.js +4 -4
- package/dist/contracts/limitations.d.ts +4 -4
- package/dist/contracts/limitations.js +4 -4
- package/dist/http.js +3 -0
- package/dist/index.d.ts +4 -3
- package/dist/resources/agents.d.ts +0 -6
- package/dist/resources/agents.js +2 -6
- package/dist/resources/prompts.d.ts +0 -4
- package/dist/resources/prompts.js +2 -6
- package/dist/resources/usage.js +9 -1
- package/dist/types.d.ts +24 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -21,14 +21,17 @@ requires Node.js 24 or newer.
|
|
|
21
21
|
- Public Zod contracts for validating API requests and responses.
|
|
22
22
|
- Cursor pagination and binary transfers.
|
|
23
23
|
- Request correlation and a typed, forward-compatible error model.
|
|
24
|
+
- End-user scoped clients for user-owned resources and generation.
|
|
24
25
|
|
|
25
26
|
## Installation
|
|
26
27
|
|
|
27
28
|
```console
|
|
28
|
-
npm install @blazingagents/sdk ai
|
|
29
|
+
npm install @blazingagents/sdk ai@^7.0.84 zod@^4.5.4
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
`ai`
|
|
32
|
+
`ai` (`^7.0.84`) and `zod` (`^4.5.4`) are peer dependencies. The SDK
|
|
33
|
+
re-exports AI SDK message types and Zod schemas, so consumers share these
|
|
34
|
+
dependencies with the SDK.
|
|
32
35
|
|
|
33
36
|
## Quick start
|
|
34
37
|
|
|
@@ -70,232 +73,3 @@ npm run test:consumer
|
|
|
70
73
|
## License
|
|
71
74
|
|
|
72
75
|
[MIT](LICENSE)
|
|
73
|
-
|
|
74
|
-
### Thinking level
|
|
75
|
-
|
|
76
|
-
Agent create/update accepts `thinkingLevel: "high"`, `"off"`, `"max"`, or
|
|
77
|
-
another nonempty string supported by the selected Model. Omission on creation
|
|
78
|
-
means Provider default; omission on update preserves the saved value, while
|
|
79
|
-
`thinkingLevel: null` clears it. Agent and Version responses include the
|
|
80
|
-
selection, and `restoreVersion` restores it through ordinary validation.
|
|
81
|
-
Use `client.providers.getThinkingLevels({ providerId, model })` to read
|
|
82
|
-
`{ known, levels }`. Unknown capabilities permit custom values that can still
|
|
83
|
-
be rejected during execution. Levels control reasoning, not a token/cost cap.
|
|
84
|
-
|
|
85
|
-
For native clients whose `Response` constructor does not support streaming bodies,
|
|
86
|
-
use `result.toStream()` on chat or terminal continuation results to read the
|
|
87
|
-
original SSE bytes. It shares one-shot ownership with `toResponse()`; choose one
|
|
88
|
-
accessor per result. Stream errors and cancellation retain the same behavior.
|
|
89
|
-
|
|
90
|
-
### Relay browser chat
|
|
91
|
-
|
|
92
|
-
Tenant browser apps use `BlazingAgentsChatTransport` with their own backend.
|
|
93
|
-
The backend holds the Tenant API key and authorizes each Session. The transport
|
|
94
|
-
sends the newest user message and resumes with the server-minted Session ID.
|
|
95
|
-
|
|
96
|
-
### Direct chat with the SDK
|
|
97
|
-
|
|
98
|
-
For the platform dashboard or another runtime with an authorized credential,
|
|
99
|
-
use `BlazingAgentsDirectChatTransport` with AI SDK `useChat`. It sends through
|
|
100
|
-
`client.chat()` and decodes the stream without constructing a streaming
|
|
101
|
-
`Response`. Inject a native streaming fetch implementation into `BlazingAgents`
|
|
102
|
-
when the runtime requires one.
|
|
103
|
-
|
|
104
|
-
```tsx
|
|
105
|
-
import { useMemo } from "react";
|
|
106
|
-
import { useChat } from "@ai-sdk/react";
|
|
107
|
-
import { BlazingAgents, BlazingAgentsDirectChatTransport } from "@blazingagents/sdk";
|
|
108
|
-
|
|
109
|
-
function Chat({ getCredential, agentId, initialSessionId, saveSessionId }) {
|
|
110
|
-
const transport = useMemo(
|
|
111
|
-
() => new BlazingAgentsDirectChatTransport({
|
|
112
|
-
getClient: async () => new BlazingAgents({ apiKey: await getCredential() }),
|
|
113
|
-
agentId,
|
|
114
|
-
sessionId: initialSessionId,
|
|
115
|
-
onSessionId: saveSessionId,
|
|
116
|
-
}),
|
|
117
|
-
[getCredential, agentId, initialSessionId, saveSessionId],
|
|
118
|
-
);
|
|
119
|
-
const chat = useChat({ transport });
|
|
120
|
-
// Render chat.messages and submit using chat.sendMessage({ text }).
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Install `@ai-sdk/react` for the React hook. Keep the transport stable for one
|
|
125
|
-
Session; remount the chat with a new transport when switching Agents or
|
|
126
|
-
Sessions. `getClient` runs before each request, so it can read a current
|
|
127
|
-
dashboard credential. Return a `BlazingAgents` client with that credential.
|
|
128
|
-
|
|
129
|
-
On Session creation, `version` pins the Agent Version, and `userId` and
|
|
130
|
-
`metadata` set attribution. To invoke a stored Prompt, pass `promptId` and
|
|
131
|
-
optional `variables` to the transport. Its first Turn sends those fields in
|
|
132
|
-
place of the `useChat` user message. Later Turns send user messages and omit
|
|
133
|
-
the create options, including `version`.
|
|
134
|
-
|
|
135
|
-
`onSessionId` runs once for a newly created Session before stream consumption,
|
|
136
|
-
so it can be saved even if streaming later fails. The transport preserves user
|
|
137
|
-
message IDs, regeneration targets, and `useChat` cancellation. Regeneration
|
|
138
|
-
requires an existing Session. When `useChat` submits tool approval responses,
|
|
139
|
-
the transport sends each decision in order and streams the continuation. After
|
|
140
|
-
reload, `reconnectToStream` joins a queued or running continuation for the
|
|
141
|
-
supplied `sessionId`. It returns `null` when there is no active continuation.
|
|
142
|
-
It does not retry an interrupted ordinary Turn.
|
|
143
|
-
|
|
144
|
-
### Cancel requests
|
|
145
|
-
|
|
146
|
-
Pass an optional `abortSignal` in the request object for reads, writes, uploads,
|
|
147
|
-
and generation:
|
|
148
|
-
|
|
149
|
-
```ts
|
|
150
|
-
const controller = new AbortController();
|
|
151
|
-
const agents = client.agents.list({ abortSignal: controller.signal });
|
|
152
|
-
controller.abort();
|
|
153
|
-
await agents; // Rejects with the SDK's typed cancellation error.
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
SDK response parsing strips unknown object fields while validating required
|
|
157
|
-
fields and known field types. Request validation remains strict.
|
|
158
|
-
|
|
159
|
-
### Migrating from 0.2.x to 0.3.0
|
|
160
|
-
|
|
161
|
-
Resource and generation methods take a single request object, optional when no
|
|
162
|
-
fields are required. Move positional identifiers, body fields, and request
|
|
163
|
-
options into that object. Use `abortSignal` instead of
|
|
164
|
-
`signal`; custom fetch implementations still receive the native `signal`.
|
|
165
|
-
|
|
166
|
-
```ts
|
|
167
|
-
// Before (0.2.x)
|
|
168
|
-
client.agents.update(agentId, { name: "Builder" });
|
|
169
|
-
client.sessions.messages(agentId, sessionId, { signal });
|
|
170
|
-
client.agent(agentId).skills.list();
|
|
171
|
-
|
|
172
|
-
// After (0.3.0)
|
|
173
|
-
client.agents.update({ agentId, name: "Builder", abortSignal: signal });
|
|
174
|
-
client.sessions.messages({ agentId, sessionId, abortSignal: signal });
|
|
175
|
-
client.agent({ agentId }).skills.list({ abortSignal: signal });
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
`ResourceRequestOptions` replaces `ResourceReadOptions`. Cancellation stops the
|
|
179
|
-
request; it does not roll back a mutation already accepted by the server.
|
|
180
|
-
|
|
181
|
-
## Interactive resend
|
|
182
|
-
|
|
183
|
-
Successful interactive exchanges are saved together. Failed or canceled execution
|
|
184
|
-
leaves saved history unchanged, including the previous answer during regeneration;
|
|
185
|
-
executed usage and Tool effects remain. Retain submitted text/images until success
|
|
186
|
-
and resend edited or unchanged input through ordinary chat with a fresh message ID.
|
|
187
|
-
Stop requests cancellation; a lost response can hide a saved exchange. Reuse the
|
|
188
|
-
returned Session ID and load history normally on return. No outcome polling or
|
|
189
|
-
automatic generation retry is needed. See the [chatbot guide](https://docs.blazingagents.com/getting-started/chatbot)
|
|
190
|
-
and [working examples](https://github.com/blazingagents/examples).
|
|
191
|
-
|
|
192
|
-
## Automatic context compaction
|
|
193
|
-
|
|
194
|
-
Agents enable automatic compaction by default with a 16,384-token reserve.
|
|
195
|
-
A larger reserve compacts earlier. Settings are included in Agent Versions.
|
|
196
|
-
Compaction summarizes older history for the model while retaining the full
|
|
197
|
-
Session transcript; summarization calls contribute to token usage.
|
|
198
|
-
|
|
199
|
-
```ts
|
|
200
|
-
await client.agents.update({
|
|
201
|
-
agentId: "ag_...",
|
|
202
|
-
autoCompaction: true,
|
|
203
|
-
compactionReserveTokens: 32768,
|
|
204
|
-
});
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Tool approval policies (0.8.0)
|
|
208
|
-
|
|
209
|
-
Agents and immutable Agent Versions expose separate `approvalInChat` and
|
|
210
|
-
`approvalInTasks` policies. Create and update them through the ordinary Agent API:
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
await client.agents.update({
|
|
214
|
-
agentId,
|
|
215
|
-
approvalInChat: {
|
|
216
|
-
default: "full",
|
|
217
|
-
overrides: [
|
|
218
|
-
{ tool: { type: "builtin", name: "bash" }, decision: "manual" },
|
|
219
|
-
{
|
|
220
|
-
tool: { type: "mcp", connectionId: "mcp_0123456789abcdef", name: "send_mail" },
|
|
221
|
-
decision: "auto",
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
},
|
|
225
|
-
approvalInTasks: { default: "deny", overrides: [] },
|
|
226
|
-
});
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
An exact tool override wins over the default. Both policies default to `full`
|
|
230
|
-
with no overrides. `full` allows available tools, `deny` blocks execution,
|
|
231
|
-
`manual` requires human review, and `auto` uses backend LLM review. Review errors
|
|
232
|
-
block execution; escalation without an available human also blocks execution.
|
|
233
|
-
Policies do not grant tool access. MCP references use the original remote tool
|
|
234
|
-
name and connection ID; the backend validates attachment and discovery.
|
|
235
|
-
|
|
236
|
-
Omitting a policy from an update preserves it. Supplying one replaces that whole
|
|
237
|
-
policy; omitted or empty `overrides` clears its overrides. `restoreVersion`
|
|
238
|
-
restores both policies alongside the other versioned fields.
|
|
239
|
-
|
|
240
|
-
Interactive Sessions reuse `client.sessions.toolApprovals`,
|
|
241
|
-
`client.sessions.decideToolApproval`, and
|
|
242
|
-
`client.sessions.joinToolApprovalContinuation`. A configured backend human
|
|
243
|
-
reviewer path is required. Tasks and stateless generations have no human
|
|
244
|
-
continuation path and block manual or escalated calls; stateless generation uses
|
|
245
|
-
`approvalInChat`. The SDK does not run an approval reviewer.
|
|
246
|
-
|
|
247
|
-
Approval rows retain optional `tool`, `assistantMessageId`, `createdAt`, and
|
|
248
|
-
`decidedAt` metadata. `tool` and `decidedAt` may be null (admin tools have no
|
|
249
|
-
ordinary-policy reference). Persisted approval decisions remain
|
|
250
|
-
`pending | approved | denied`; policy modes are `full | deny | manual | auto`.
|
|
251
|
-
The root package exports `ApprovalDecision`, `ApprovalPolicy`, `ToolReference`,
|
|
252
|
-
and `ToolApprovalState`; runtime policy schemas are exported from
|
|
253
|
-
`@blazingagents/sdk/contracts`.
|
|
254
|
-
|
|
255
|
-
## Slack and Telegram
|
|
256
|
-
|
|
257
|
-
Use the [connection example](https://github.com/blazingagents/typescript-sdk/blob/main/examples/chat-integrations.md) to connect an existing
|
|
258
|
-
Agent through REST. BA hosts the Chat SDK runtime, conversation history, and
|
|
259
|
-
approval cards; no additional SDK resource is required.
|
|
260
|
-
|
|
261
|
-
`client.chatDeliveries.list` reads the Tenant-wide delivery feed across all
|
|
262
|
-
Chat Connections, newest first. `status` accepts `failed` and/or `ambiguous`;
|
|
263
|
-
omitting it returns both. For example, the failed and ambiguous deliveries
|
|
264
|
-
since a timestamp:
|
|
265
|
-
|
|
266
|
-
```ts
|
|
267
|
-
const page = await client.chatDeliveries.list({
|
|
268
|
-
status: ["failed", "ambiguous"],
|
|
269
|
-
since: "2026-09-01T00:00:00.000Z",
|
|
270
|
-
});
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Merchant monetization
|
|
274
|
-
|
|
275
|
-
Bill your own customers for model-token usage through your Polar or Dodo
|
|
276
|
-
merchant account. Blazing Agents records usage per Turn and delivers it to
|
|
277
|
-
your provider; your provider owns billing.
|
|
278
|
-
|
|
279
|
-
```ts
|
|
280
|
-
const client = new BlazingAgents({ apiKey: "ba_..." });
|
|
281
|
-
|
|
282
|
-
// One-time: connect your merchant account (dashboard or API).
|
|
283
|
-
await client.merchantConnection.create({
|
|
284
|
-
provider: "polar",
|
|
285
|
-
environment: "sandbox",
|
|
286
|
-
credential: "polar_oat_...", // organization access token
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// On user onboarding in your backend: bind your user id to the
|
|
290
|
-
// provider-side customer so usage is attributed correctly.
|
|
291
|
-
await client.merchantBindings.put({
|
|
292
|
-
userId: "user_123",
|
|
293
|
-
customerId: "cust_polar_...",
|
|
294
|
-
});
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
`client.merchantUsageEvents` exposes the delivery ledger (`list`, `get`,
|
|
298
|
-
`summary`) and the operator actions `retry`, `release`, and `discard`. The
|
|
299
|
-
optional eligibility guard (`guard` on the connection) refuses new
|
|
300
|
-
executions when the bound customer lacks the required subscription or
|
|
301
|
-
balance; it is a provider-reported check, not a spending lock.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, WorkspacesResource } from "./types.ts";
|
|
1
|
+
import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, 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
3
|
private readonly config;
|
|
4
4
|
readonly chatConnections: ChatConnectionsResource;
|
|
@@ -21,6 +21,8 @@ export declare class BlazingAgents {
|
|
|
21
21
|
agent({ agentId }: {
|
|
22
22
|
agentId: string;
|
|
23
23
|
}): AgentClient;
|
|
24
|
+
/** Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces. */
|
|
25
|
+
forUser(userId: string): UserClient;
|
|
24
26
|
/**
|
|
25
27
|
* `POST /v1/agents/:agentId/sessions` (create, no `sessionId`) or
|
|
26
28
|
* `POST /v1/agents/:agentId/sessions/:sessionId` (resume). Returns the
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { chat, completion, objectGeneration } from "./generation.js";
|
|
2
3
|
import { createAgentsResource } from "./resources/agents.js";
|
|
3
4
|
import { createArtifactsResource } from "./resources/artifacts.js";
|
|
@@ -18,6 +19,30 @@ import { createUsageResource } from "./resources/usage.js";
|
|
|
18
19
|
import { createWorkspacesResource } from "./resources/workspaces.js";
|
|
19
20
|
const DEFAULT_BASE_URL = "https://api.blazingagents.com";
|
|
20
21
|
const TRAILING_SLASH_RE = /\/+$/;
|
|
22
|
+
const scopedUserIdSchema = z
|
|
23
|
+
.string()
|
|
24
|
+
.max(256)
|
|
25
|
+
.regex(/^[\x21-\x7E](?:[\x20-\x7E]*[\x21-\x7E])?$/);
|
|
26
|
+
function createUserClient(config) {
|
|
27
|
+
const usage = createUsageResource(config);
|
|
28
|
+
return {
|
|
29
|
+
agents: createAgentsResource(config),
|
|
30
|
+
sessions: createSessionsResource(config),
|
|
31
|
+
prompts: createPromptsResource(config),
|
|
32
|
+
tasks: createTasksResource(config),
|
|
33
|
+
artifacts: createArtifactsResource(config),
|
|
34
|
+
workspaces: createWorkspacesResource(config),
|
|
35
|
+
memories: createMemoriesResource(config),
|
|
36
|
+
usage: { get: usage.get, sessions: usage.sessions },
|
|
37
|
+
agent: ({ agentId }) => ({
|
|
38
|
+
skills: createAgentSkillsResource(config, agentId),
|
|
39
|
+
}),
|
|
40
|
+
chat: (input) => chat(config, input),
|
|
41
|
+
completion: (input) => completion(config, input),
|
|
42
|
+
object: (input) => objectGeneration(config, input),
|
|
43
|
+
withOptions: (options) => createUserClient({ ...config, clientRequestId: options.clientRequestId }),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
21
46
|
export class BlazingAgents {
|
|
22
47
|
config;
|
|
23
48
|
chatConnections;
|
|
@@ -66,6 +91,13 @@ export class BlazingAgents {
|
|
|
66
91
|
agent({ agentId }) {
|
|
67
92
|
return { skills: createAgentSkillsResource(this.config, agentId) };
|
|
68
93
|
}
|
|
94
|
+
/** Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces. */
|
|
95
|
+
forUser(userId) {
|
|
96
|
+
return createUserClient({
|
|
97
|
+
...this.config,
|
|
98
|
+
scopeUserId: scopedUserIdSchema.parse(userId),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
69
101
|
/**
|
|
70
102
|
* `POST /v1/agents/:agentId/sessions` (create, no `sessionId`) or
|
|
71
103
|
* `POST /v1/agents/:agentId/sessions/:sessionId` (resume). Returns the
|
package/dist/contracts/api.d.ts
CHANGED
|
@@ -23,13 +23,14 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
23
23
|
agent_disabled: "agent_disabled";
|
|
24
24
|
agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
|
|
25
25
|
agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
|
|
26
|
-
agent_name_conflict: "agent_name_conflict";
|
|
27
26
|
agent_version_not_found: "agent_version_not_found";
|
|
28
27
|
api_key_limit_reached: "api_key_limit_reached";
|
|
29
28
|
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
30
29
|
chat_webhook_conflict: "chat_webhook_conflict";
|
|
31
30
|
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
32
31
|
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
32
|
+
forbidden: "forbidden";
|
|
33
|
+
idempotency_conflict: "idempotency_conflict";
|
|
33
34
|
internal: "internal";
|
|
34
35
|
invalid_cursor: "invalid_cursor";
|
|
35
36
|
invalid_request: "invalid_request";
|
|
@@ -59,8 +60,6 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
59
60
|
model_not_found: "model_not_found";
|
|
60
61
|
model_validation_unavailable: "model_validation_unavailable";
|
|
61
62
|
not_found: "not_found";
|
|
62
|
-
prompt_limit_reached: "prompt_limit_reached";
|
|
63
|
-
prompt_name_conflict: "prompt_name_conflict";
|
|
64
63
|
prompt_variable_missing: "prompt_variable_missing";
|
|
65
64
|
prompt_variable_unknown: "prompt_variable_unknown";
|
|
66
65
|
provider_historical_use: "provider_historical_use";
|
|
@@ -102,13 +101,14 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
102
101
|
agent_disabled: "agent_disabled";
|
|
103
102
|
agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
|
|
104
103
|
agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
|
|
105
|
-
agent_name_conflict: "agent_name_conflict";
|
|
106
104
|
agent_version_not_found: "agent_version_not_found";
|
|
107
105
|
api_key_limit_reached: "api_key_limit_reached";
|
|
108
106
|
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
109
107
|
chat_webhook_conflict: "chat_webhook_conflict";
|
|
110
108
|
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
111
109
|
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
110
|
+
forbidden: "forbidden";
|
|
111
|
+
idempotency_conflict: "idempotency_conflict";
|
|
112
112
|
internal: "internal";
|
|
113
113
|
invalid_cursor: "invalid_cursor";
|
|
114
114
|
invalid_request: "invalid_request";
|
|
@@ -138,8 +138,6 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
138
138
|
model_not_found: "model_not_found";
|
|
139
139
|
model_validation_unavailable: "model_validation_unavailable";
|
|
140
140
|
not_found: "not_found";
|
|
141
|
-
prompt_limit_reached: "prompt_limit_reached";
|
|
142
|
-
prompt_name_conflict: "prompt_name_conflict";
|
|
143
141
|
prompt_variable_missing: "prompt_variable_missing";
|
|
144
142
|
prompt_variable_unknown: "prompt_variable_unknown";
|
|
145
143
|
provider_historical_use: "provider_historical_use";
|
|
@@ -186,13 +184,14 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
186
184
|
agent_disabled: "agent_disabled";
|
|
187
185
|
agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
|
|
188
186
|
agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
|
|
189
|
-
agent_name_conflict: "agent_name_conflict";
|
|
190
187
|
agent_version_not_found: "agent_version_not_found";
|
|
191
188
|
api_key_limit_reached: "api_key_limit_reached";
|
|
192
189
|
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
193
190
|
chat_webhook_conflict: "chat_webhook_conflict";
|
|
194
191
|
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
195
192
|
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
193
|
+
forbidden: "forbidden";
|
|
194
|
+
idempotency_conflict: "idempotency_conflict";
|
|
196
195
|
internal: "internal";
|
|
197
196
|
invalid_cursor: "invalid_cursor";
|
|
198
197
|
invalid_request: "invalid_request";
|
|
@@ -222,8 +221,6 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
222
221
|
model_not_found: "model_not_found";
|
|
223
222
|
model_validation_unavailable: "model_validation_unavailable";
|
|
224
223
|
not_found: "not_found";
|
|
225
|
-
prompt_limit_reached: "prompt_limit_reached";
|
|
226
|
-
prompt_name_conflict: "prompt_name_conflict";
|
|
227
224
|
prompt_variable_missing: "prompt_variable_missing";
|
|
228
225
|
prompt_variable_unknown: "prompt_variable_unknown";
|
|
229
226
|
provider_historical_use: "provider_historical_use";
|
package/dist/contracts/api.js
CHANGED
|
@@ -18,8 +18,10 @@ export const apiErrorIssueSchema = z
|
|
|
18
18
|
*/
|
|
19
19
|
export const apiErrorCodeSchema = z.enum([
|
|
20
20
|
"invalid_request",
|
|
21
|
+
"idempotency_conflict",
|
|
21
22
|
"validation_failed",
|
|
22
23
|
"unauthorized",
|
|
24
|
+
"forbidden",
|
|
23
25
|
"not_found",
|
|
24
26
|
"quota_exceeded",
|
|
25
27
|
"subscription_required",
|
|
@@ -33,14 +35,11 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
33
35
|
"agent_version_not_found",
|
|
34
36
|
"agent_mcp_connection_not_found",
|
|
35
37
|
"agent_mcp_connections_invalid",
|
|
36
|
-
"agent_name_conflict",
|
|
37
38
|
"provider_required",
|
|
38
39
|
"api_key_limit_reached",
|
|
39
40
|
"artifact_session_cap_reached",
|
|
40
41
|
"invalid_cursor",
|
|
41
42
|
"message_not_found",
|
|
42
|
-
"prompt_limit_reached",
|
|
43
|
-
"prompt_name_conflict",
|
|
44
43
|
"prompt_variable_missing",
|
|
45
44
|
"prompt_variable_unknown",
|
|
46
45
|
"provider_in_use",
|
|
@@ -121,7 +121,7 @@ export declare const agentSchema: z.ZodObject<{
|
|
|
121
121
|
}>;
|
|
122
122
|
}, z.core.$strip>;
|
|
123
123
|
export declare const agentsResponseSchema: z.ZodObject<{
|
|
124
|
-
|
|
124
|
+
data: z.ZodArray<z.ZodObject<{
|
|
125
125
|
approvalInChat: z.ZodDefault<z.ZodObject<{
|
|
126
126
|
default: z.ZodEnum<{
|
|
127
127
|
auto: "auto";
|
|
@@ -228,6 +228,7 @@ export declare const agentsResponseSchema: z.ZodObject<{
|
|
|
228
228
|
disabled: "disabled";
|
|
229
229
|
}>;
|
|
230
230
|
}, z.core.$strip>>;
|
|
231
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
231
232
|
}, z.core.$strip>;
|
|
232
233
|
export declare const agentResponseSchema: z.ZodObject<{
|
|
233
234
|
approvalInChat: z.ZodDefault<z.ZodObject<{
|
|
@@ -337,6 +338,8 @@ export declare const agentResponseSchema: z.ZodObject<{
|
|
|
337
338
|
}>;
|
|
338
339
|
}, z.core.$strip>;
|
|
339
340
|
export declare const agentsListQuerySchema: z.ZodObject<{
|
|
341
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
342
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
340
343
|
userId: z.ZodOptional<z.ZodString>;
|
|
341
344
|
workspaceId: z.ZodOptional<z.ZodString>;
|
|
342
345
|
}, z.core.$strict>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { cursorSchema, paginatedResponseSchema } from "../api.js";
|
|
3
3
|
import { agentIdSchema, mcpConnectionIdSchema, providerIdSchema, tenantIdSchema, workspaceIdSchema, } from "../ids.js";
|
|
4
|
-
import { DEFAULT_AGENT_VERSIONS_LIST_LIMIT, MAX_AGENT_INSTRUCTIONS_LENGTH, MAX_AGENT_NAME_LENGTH, MAX_AGENT_VERSIONS_LIST_LIMIT, MAX_MCP_CONNECTIONS_PER_AGENT, } from "../limitations.js";
|
|
4
|
+
import { DEFAULT_AGENT_VERSIONS_LIST_LIMIT, DEFAULT_AGENTS_LIST_LIMIT, MAX_AGENT_INSTRUCTIONS_LENGTH, MAX_AGENT_NAME_LENGTH, MAX_AGENT_VERSIONS_LIST_LIMIT, MAX_AGENTS_LIST_LIMIT, MAX_MCP_CONNECTIONS_PER_AGENT, } from "../limitations.js";
|
|
5
5
|
import { atLeastOneFieldMessage, hasObjectKeys, hasUniqueValues, } from "../utils.js";
|
|
6
6
|
import { approvalPolicySchema } from "./agent-approval.js";
|
|
7
7
|
import { agentToolGroupIds } from "./agent-tools.js";
|
|
@@ -77,14 +77,17 @@ export const agentSchema = z
|
|
|
77
77
|
message: providerModelPairMessage,
|
|
78
78
|
path: ["providerId"],
|
|
79
79
|
});
|
|
80
|
-
export const agentsResponseSchema =
|
|
81
|
-
.object({
|
|
82
|
-
agents: z.array(agentSchema),
|
|
83
|
-
})
|
|
84
|
-
.strip();
|
|
80
|
+
export const agentsResponseSchema = paginatedResponseSchema(agentSchema);
|
|
85
81
|
export const agentResponseSchema = agentSchema;
|
|
86
82
|
export const agentsListQuerySchema = z
|
|
87
83
|
.object({
|
|
84
|
+
cursor: cursorSchema.optional(),
|
|
85
|
+
limit: z.coerce
|
|
86
|
+
.number()
|
|
87
|
+
.int()
|
|
88
|
+
.min(1)
|
|
89
|
+
.max(MAX_AGENTS_LIST_LIMIT)
|
|
90
|
+
.default(DEFAULT_AGENTS_LIST_LIMIT),
|
|
88
91
|
userId: userIdSchema.optional(),
|
|
89
92
|
workspaceId: workspaceIdSchema.optional(),
|
|
90
93
|
})
|
|
@@ -20,7 +20,7 @@ export declare const promptSchema: z.ZodObject<{
|
|
|
20
20
|
updatedAt: z.ZodISODateTime;
|
|
21
21
|
}, z.core.$strip>;
|
|
22
22
|
export declare const promptsResponseSchema: z.ZodObject<{
|
|
23
|
-
|
|
23
|
+
data: z.ZodArray<z.ZodObject<{
|
|
24
24
|
id: z.ZodString;
|
|
25
25
|
tenantId: z.ZodString;
|
|
26
26
|
agentId: z.ZodNullable<z.ZodString>;
|
|
@@ -32,7 +32,14 @@ export declare const promptsResponseSchema: z.ZodObject<{
|
|
|
32
32
|
createdAt: z.ZodISODateTime;
|
|
33
33
|
updatedAt: z.ZodISODateTime;
|
|
34
34
|
}, z.core.$strip>>;
|
|
35
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
35
36
|
}, z.core.$strip>;
|
|
37
|
+
export declare const promptsListQuerySchema: z.ZodObject<{
|
|
38
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
39
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
40
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strict>;
|
|
36
43
|
export declare const promptResponseSchema: z.ZodObject<{
|
|
37
44
|
id: z.ZodString;
|
|
38
45
|
tenantId: z.ZodString;
|
|
@@ -61,6 +68,7 @@ export declare const updatePromptBodySchema: z.ZodObject<{
|
|
|
61
68
|
export declare function renderPromptTemplate(template: string, values: Record<string, string>): string;
|
|
62
69
|
export type Prompt = z.infer<typeof promptSchema>;
|
|
63
70
|
export type PromptsResponse = z.infer<typeof promptsResponseSchema>;
|
|
71
|
+
export type PromptsListQuery = z.infer<typeof promptsListQuerySchema>;
|
|
64
72
|
export type PromptResponse = z.infer<typeof promptResponseSchema>;
|
|
65
73
|
export type CreatePromptBody = z.input<typeof createPromptBodySchema>;
|
|
66
74
|
export type UpdatePromptBody = z.infer<typeof updatePromptBodySchema>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { cursorSchema, paginatedResponseSchema } from "../api.js";
|
|
2
3
|
import { agentIdSchema, promptIdSchema, tenantIdSchema } from "../ids.js";
|
|
3
|
-
import { MAX_PROMPT_NAME_LENGTH, MAX_PROMPT_TEMPLATE_BYTES, MAX_PROMPT_VARIABLES, } from "../limitations.js";
|
|
4
|
+
import { DEFAULT_PROMPTS_LIST_LIMIT, MAX_PROMPT_NAME_LENGTH, MAX_PROMPT_TEMPLATE_BYTES, MAX_PROMPT_VARIABLES, MAX_PROMPTS_LIST_LIMIT, } from "../limitations.js";
|
|
4
5
|
import { atLeastOneFieldMessage, hasObjectKeys } from "../utils.js";
|
|
5
6
|
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
6
7
|
export const promptVariableTokenPattern = /{{([\s\S]*?)}}/g;
|
|
@@ -59,11 +60,20 @@ export const promptSchema = z
|
|
|
59
60
|
updatedAt: z.iso.datetime({ offset: true }),
|
|
60
61
|
})
|
|
61
62
|
.strip();
|
|
62
|
-
export const promptsResponseSchema =
|
|
63
|
+
export const promptsResponseSchema = paginatedResponseSchema(promptSchema);
|
|
64
|
+
export const promptsListQuerySchema = z
|
|
63
65
|
.object({
|
|
64
|
-
|
|
66
|
+
cursor: cursorSchema.optional(),
|
|
67
|
+
limit: z.coerce
|
|
68
|
+
.number()
|
|
69
|
+
.int()
|
|
70
|
+
.min(1)
|
|
71
|
+
.max(MAX_PROMPTS_LIST_LIMIT)
|
|
72
|
+
.default(DEFAULT_PROMPTS_LIST_LIMIT),
|
|
73
|
+
userId: userIdSchema.optional(),
|
|
74
|
+
agentId: agentIdSchema.optional(),
|
|
65
75
|
})
|
|
66
|
-
.
|
|
76
|
+
.strict();
|
|
67
77
|
export const promptResponseSchema = promptSchema;
|
|
68
78
|
export const createPromptBodySchema = z
|
|
69
79
|
.object({
|
|
@@ -44,12 +44,9 @@ export declare const taskScheduleInputSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
44
44
|
export type TaskScheduleInput = z.infer<typeof taskScheduleInputSchema>;
|
|
45
45
|
/**
|
|
46
46
|
* `POST /v1/tasks` — schedule present = scheduled task; absent = on-demand.
|
|
47
|
-
* `submit: true` enqueues a run immediately
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* idempotency, use `POST /v1/tasks/{taskId}/runs` with an idempotency key
|
|
51
|
-
* (the task must already exist so the deterministic run id is stable
|
|
52
|
-
* across replays).
|
|
47
|
+
* `submit: true` enqueues a run immediately. An optional `idempotencyKey`
|
|
48
|
+
* makes retries return the original Task and initial run id. Without a key,
|
|
49
|
+
* each call creates a new Task. Run creation has its own idempotency key.
|
|
53
50
|
*/
|
|
54
51
|
export declare const createTaskBodySchema: z.ZodObject<{
|
|
55
52
|
agentId: z.ZodString;
|
|
@@ -76,6 +73,7 @@ export declare const createTaskBodySchema: z.ZodObject<{
|
|
|
76
73
|
}, z.core.$strict>], "kind">>>;
|
|
77
74
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
75
|
submit: z.ZodDefault<z.ZodBoolean>;
|
|
76
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
79
77
|
userId: z.ZodDefault<z.ZodString>;
|
|
80
78
|
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
81
79
|
}, z.core.$strict>;
|
|
@@ -106,12 +106,9 @@ const taskNameSchema = z.string().trim().min(1).max(MAX_TASK_NAME_LENGTH);
|
|
|
106
106
|
const taskPromptSchema = z.string().trim().min(1).max(MAX_TASK_PROMPT_LENGTH);
|
|
107
107
|
/**
|
|
108
108
|
* `POST /v1/tasks` — schedule present = scheduled task; absent = on-demand.
|
|
109
|
-
* `submit: true` enqueues a run immediately
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* idempotency, use `POST /v1/tasks/{taskId}/runs` with an idempotency key
|
|
113
|
-
* (the task must already exist so the deterministic run id is stable
|
|
114
|
-
* across replays).
|
|
109
|
+
* `submit: true` enqueues a run immediately. An optional `idempotencyKey`
|
|
110
|
+
* makes retries return the original Task and initial run id. Without a key,
|
|
111
|
+
* each call creates a new Task. Run creation has its own idempotency key.
|
|
115
112
|
*/
|
|
116
113
|
export const createTaskBodySchema = z
|
|
117
114
|
.object({
|
|
@@ -122,6 +119,7 @@ export const createTaskBodySchema = z
|
|
|
122
119
|
schedule: taskScheduleInputSchema.nullable().default(null),
|
|
123
120
|
enabled: z.boolean().default(true),
|
|
124
121
|
submit: z.boolean().default(false),
|
|
122
|
+
idempotencyKey: z.string().trim().min(1).optional(),
|
|
125
123
|
userId: userIdSchema.default(""),
|
|
126
124
|
metadata: metadataSchema.default({}),
|
|
127
125
|
})
|
|
@@ -77,6 +77,22 @@ export declare const usageTotalsSchema: z.ZodObject<{
|
|
|
77
77
|
requestCount: z.ZodNumber;
|
|
78
78
|
durationMs: z.ZodNumber;
|
|
79
79
|
}, z.core.$strip>;
|
|
80
|
+
export declare const sessionUsageQuerySchema: z.ZodObject<{
|
|
81
|
+
sessionIds: z.ZodArray<z.ZodString>;
|
|
82
|
+
from: z.ZodOptional<z.ZodISODate>;
|
|
83
|
+
to: z.ZodOptional<z.ZodISODate>;
|
|
84
|
+
}, z.core.$strict>;
|
|
85
|
+
export declare const sessionUsageResponseSchema: z.ZodObject<{
|
|
86
|
+
data: z.ZodArray<z.ZodObject<{
|
|
87
|
+
sessionId: z.ZodString;
|
|
88
|
+
totals: z.ZodObject<{
|
|
89
|
+
inputTokens: z.ZodNumber;
|
|
90
|
+
outputTokens: z.ZodNumber;
|
|
91
|
+
requestCount: z.ZodNumber;
|
|
92
|
+
durationMs: z.ZodNumber;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
80
96
|
export declare const usageResponseSchema: z.ZodObject<{
|
|
81
97
|
buckets: z.ZodArray<z.ZodObject<{
|
|
82
98
|
day: z.ZodNullable<z.ZodString>;
|
|
@@ -224,3 +240,5 @@ export type UsageTotals = z.infer<typeof usageTotalsSchema>;
|
|
|
224
240
|
export type UsageResponse = z.infer<typeof usageResponseSchema>;
|
|
225
241
|
export type UsageOverviewQuery = z.infer<typeof usageOverviewQuerySchema>;
|
|
226
242
|
export type UsageOverviewResponse = z.infer<typeof usageOverviewResponseSchema>;
|
|
243
|
+
export type SessionUsageQuery = z.infer<typeof sessionUsageQuerySchema>;
|
|
244
|
+
export type SessionUsageResponse = z.infer<typeof sessionUsageResponseSchema>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { agentIdSchema, sessionIdSchema } from "../ids.js";
|
|
3
3
|
import { DEFAULT_USAGE_OVERVIEW_TOP_N, DEFAULT_USAGE_RANGE_DAYS, DEFAULT_USAGE_SESSION_TOP_N, MAX_USAGE_OVERVIEW_TOP_N, MAX_USAGE_RANGE_DAYS, MAX_USAGE_SESSION_TOP_N, } from "../limitations.js";
|
|
4
|
+
import { hasUniqueValues } from "../utils.js";
|
|
4
5
|
import { userIdSchema } from "./attribution.js";
|
|
5
6
|
function validateUsageRange(value, ctx) {
|
|
6
7
|
if ((value.from === undefined) !== (value.to === undefined)) {
|
|
@@ -122,6 +123,33 @@ export const usageTotalsSchema = z
|
|
|
122
123
|
durationMs: z.number().int().nonnegative(),
|
|
123
124
|
})
|
|
124
125
|
.strip();
|
|
126
|
+
export const sessionUsageQuerySchema = z
|
|
127
|
+
.object({
|
|
128
|
+
sessionIds: z
|
|
129
|
+
.array(sessionIdSchema)
|
|
130
|
+
.min(1)
|
|
131
|
+
.max(100)
|
|
132
|
+
.refine(hasUniqueValues, {
|
|
133
|
+
message: "Session ids must be unique.",
|
|
134
|
+
}),
|
|
135
|
+
from: z.iso.date().optional(),
|
|
136
|
+
to: z.iso.date().optional(),
|
|
137
|
+
})
|
|
138
|
+
.strict()
|
|
139
|
+
.superRefine(validateUsageRange);
|
|
140
|
+
export const sessionUsageResponseSchema = z
|
|
141
|
+
.object({
|
|
142
|
+
data: z
|
|
143
|
+
.array(z
|
|
144
|
+
.object({
|
|
145
|
+
sessionId: sessionIdSchema,
|
|
146
|
+
totals: usageTotalsSchema,
|
|
147
|
+
})
|
|
148
|
+
.strip())
|
|
149
|
+
.min(1)
|
|
150
|
+
.max(100),
|
|
151
|
+
})
|
|
152
|
+
.strip();
|
|
125
153
|
export const usageResponseSchema = z
|
|
126
154
|
.object({
|
|
127
155
|
buckets: z.array(usageBucketSchema),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { receivedApiErrorResponseSchema } from "./api.ts";
|
|
3
3
|
export type { ApprovalDecision, ApprovalPolicy, ToolReference, } from "./entities/agent-approval.ts";
|
|
4
4
|
export { approvalDecisionSchema, approvalPolicySchema, toolReferenceSchema, } from "./entities/agent-approval.ts";
|
|
5
|
-
export { agentResponseSchema, agentSchema, agentStatusSchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.ts";
|
|
5
|
+
export { agentResponseSchema, agentSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.ts";
|
|
6
6
|
export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.ts";
|
|
7
7
|
export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.ts";
|
|
8
8
|
export type { PromptVariables, UsageSummary } from "./entities/chat.ts";
|
|
@@ -11,14 +11,14 @@ export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseS
|
|
|
11
11
|
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.ts";
|
|
12
12
|
export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.ts";
|
|
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.ts";
|
|
14
|
-
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
|
|
14
|
+
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
|
|
15
15
|
export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.ts";
|
|
16
16
|
export type { ToolApprovalDecisionResponse, ToolApprovalsResponse, } from "./entities/sessions.ts";
|
|
17
17
|
export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
|
|
18
18
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
|
|
19
|
-
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
|
|
19
|
+
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
|
|
20
20
|
export { quotaSchema, subscriptionStatusSchema, tenantDeletionSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.ts";
|
|
21
|
-
export type { UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageResponse, UsageTotals, } from "./entities/usage.ts";
|
|
22
|
-
export { usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.ts";
|
|
21
|
+
export type { SessionUsageQuery, SessionUsageResponse, UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageResponse, UsageTotals, } from "./entities/usage.ts";
|
|
22
|
+
export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.ts";
|
|
23
23
|
export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.ts";
|
|
24
24
|
export { agentIdSchema, apiKeyTokenSchema, isAdminAgentId, promptIdSchema, sessionIdSchema, } from "./ids.ts";
|
package/dist/contracts/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// biome-ignore lint/performance/noBarrelFile: public contract entry point
|
|
3
3
|
export { receivedApiErrorResponseSchema } from "./api.js";
|
|
4
4
|
export { approvalDecisionSchema, approvalPolicySchema, toolReferenceSchema, } from "./entities/agent-approval.js";
|
|
5
|
-
export { agentResponseSchema, agentSchema, agentStatusSchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.js";
|
|
5
|
+
export { agentResponseSchema, agentSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.js";
|
|
6
6
|
export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.js";
|
|
7
7
|
export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.js";
|
|
8
8
|
export { blazingAgentsChatMessageMetadataSchema, chatModeSchema, chatRequestBodySchema, chatTriggerSchema, generationRequestBodySchema, jsonSchemaShapeSchema, promptVariablesSchema, usageSummarySchema, } from "./entities/chat.js";
|
|
@@ -10,12 +10,12 @@ export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseS
|
|
|
10
10
|
export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.js";
|
|
11
11
|
export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.js";
|
|
12
12
|
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";
|
|
13
|
-
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.js";
|
|
13
|
+
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.js";
|
|
14
14
|
export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.js";
|
|
15
15
|
export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.js";
|
|
16
16
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.js";
|
|
17
|
-
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
|
|
17
|
+
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
|
|
18
18
|
export { quotaSchema, subscriptionStatusSchema, tenantDeletionSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.js";
|
|
19
|
-
export { usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.js";
|
|
19
|
+
export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.js";
|
|
20
20
|
export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.js";
|
|
21
21
|
export { agentIdSchema, apiKeyTokenSchema, isAdminAgentId, promptIdSchema, sessionIdSchema, } from "./ids.js";
|
|
@@ -29,10 +29,8 @@ export declare const MAX_SKILL_COMPATIBILITY_LENGTH = 500;
|
|
|
29
29
|
export declare const MAX_SKILL_COPY_DESTINATIONS = 30;
|
|
30
30
|
export declare const DEFAULT_SKILLS_LIST_LIMIT = 50;
|
|
31
31
|
export declare const MAX_SKILLS_LIST_LIMIT = 100;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
export declare const MAX_PROMPTS_PER_TENANT = 100;
|
|
32
|
+
export declare const DEFAULT_PROMPTS_LIST_LIMIT = 50;
|
|
33
|
+
export declare const MAX_PROMPTS_LIST_LIMIT = 100;
|
|
36
34
|
export declare const MAX_PROMPT_TEMPLATE_BYTES: number;
|
|
37
35
|
export declare const MAX_PROMPT_VARIABLES = 10;
|
|
38
36
|
export declare const MAX_PROMPT_NAME_LENGTH = 80;
|
|
@@ -73,6 +71,8 @@ export declare const MAX_MCP_ATTACHMENT_METADATA_KEY_LENGTH = 64;
|
|
|
73
71
|
export declare const MAX_MCP_REQUEST_CONTEXT_BYTES: number;
|
|
74
72
|
/** Agents — name ≤ 80, instructions ≤ 3000. */
|
|
75
73
|
export declare const MAX_AGENT_NAME_LENGTH = 80;
|
|
74
|
+
export declare const DEFAULT_AGENTS_LIST_LIMIT = 50;
|
|
75
|
+
export declare const MAX_AGENTS_LIST_LIMIT = 100;
|
|
76
76
|
export declare const MAX_AGENT_INSTRUCTIONS_LENGTH = 3000;
|
|
77
77
|
export declare const DEFAULT_AGENT_VERSIONS_LIST_LIMIT = 50;
|
|
78
78
|
export declare const MAX_AGENT_VERSIONS_LIST_LIMIT = 200;
|
|
@@ -30,10 +30,8 @@ export const MAX_SKILL_COMPATIBILITY_LENGTH = 500;
|
|
|
30
30
|
export const MAX_SKILL_COPY_DESTINATIONS = 30;
|
|
31
31
|
export const DEFAULT_SKILLS_LIST_LIMIT = 50;
|
|
32
32
|
export const MAX_SKILLS_LIST_LIMIT = 100;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
export const MAX_PROMPTS_PER_TENANT = 100;
|
|
33
|
+
export const DEFAULT_PROMPTS_LIST_LIMIT = 50;
|
|
34
|
+
export const MAX_PROMPTS_LIST_LIMIT = 100;
|
|
37
35
|
export const MAX_PROMPT_TEMPLATE_BYTES = 10 * 1024;
|
|
38
36
|
export const MAX_PROMPT_VARIABLES = 10;
|
|
39
37
|
export const MAX_PROMPT_NAME_LENGTH = 80;
|
|
@@ -74,6 +72,8 @@ export const MAX_MCP_ATTACHMENT_METADATA_KEY_LENGTH = 64;
|
|
|
74
72
|
export const MAX_MCP_REQUEST_CONTEXT_BYTES = 16 * 1024;
|
|
75
73
|
/** Agents — name ≤ 80, instructions ≤ 3000. */
|
|
76
74
|
export const MAX_AGENT_NAME_LENGTH = 80;
|
|
75
|
+
export const DEFAULT_AGENTS_LIST_LIMIT = 50;
|
|
76
|
+
export const MAX_AGENTS_LIST_LIMIT = 100;
|
|
77
77
|
export const MAX_AGENT_INSTRUCTIONS_LENGTH = 3000;
|
|
78
78
|
export const DEFAULT_AGENT_VERSIONS_LIST_LIMIT = 50;
|
|
79
79
|
export const MAX_AGENT_VERSIONS_LIST_LIMIT = 200;
|
package/dist/http.js
CHANGED
|
@@ -76,6 +76,9 @@ async function rawRequest(config, path, options) {
|
|
|
76
76
|
...(clientRequestId === undefined
|
|
77
77
|
? {}
|
|
78
78
|
: { "x-client-request-id": clientRequestId }),
|
|
79
|
+
...(config.scopeUserId === undefined
|
|
80
|
+
? {}
|
|
81
|
+
: { "X-BA-User-Id": config.scopeUserId }),
|
|
79
82
|
};
|
|
80
83
|
let body = options.body ?? null;
|
|
81
84
|
if (options.json !== undefined) {
|
package/dist/index.d.ts
CHANGED
|
@@ -7,17 +7,18 @@ export type { UIMessage } from "ai";
|
|
|
7
7
|
export { BlazingAgentsChatTransport, type BlazingAgentsChatTransportOptions, } from "./chat-transport.ts";
|
|
8
8
|
export { BlazingAgents } from "./client.ts";
|
|
9
9
|
export type { ApprovalDecision, ApprovalPolicy, ToolReference, } from "./contracts/entities/agent-approval.ts";
|
|
10
|
-
export type { Agent, AgentResponse, AgentsResponse, AgentVersion, AgentVersionsListQuery, AgentVersionsResponse, CreateAgentBody, UpdateAgentBody, } from "./contracts/entities/agents.ts";
|
|
10
|
+
export type { Agent, AgentResponse, AgentsListQuery, AgentsResponse, AgentVersion, AgentVersionsListQuery, AgentVersionsResponse, CreateAgentBody, UpdateAgentBody, } from "./contracts/entities/agents.ts";
|
|
11
11
|
export type { ArtifactDownloadUrlResponse, ArtifactListItem, ArtifactsListResponse, } from "./contracts/entities/artifacts.ts";
|
|
12
12
|
export type { ChatConfiguration, ChatConnection, ChatConnectionsResponse, ChatCredentials, ChatDeliveriesResponse, ChatDelivery, ChatDeliveryListStatus, ChatDeliveryStatus, ChatHealth, ChatIdentity, CreateChatConnectionBody, RotateChatConnectionBody, TenantChatDelivery, UpdateChatConnectionBody, } from "./contracts/entities/chat-connections.ts";
|
|
13
13
|
export type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResponse, McpConnectionAuthType, McpConnectionOauthConnectResponse, McpConnectionReconnectResult, McpConnectionResponse, McpConnectionStatus, McpConnectionTestResponse, ReconnectMcpConnectionBody, UpdateMcpAttachmentBody, UpdateMcpConnectionBody, } from "./contracts/entities/mcp-connections.ts";
|
|
14
14
|
export type { CreateMerchantConnectionBody, MerchantBindingResponse, MerchantBindingsResponse, MerchantConnection, MerchantConnectionResponse, MerchantCustomerBinding, MerchantGuard, MerchantProviderKind, MerchantUsageEvent, MerchantUsageEventResponse, MerchantUsageEventStatus, MerchantUsageEventsResponse, MerchantUsageSummary, MerchantUsageSummaryResponse, UpdateMerchantConnectionBody, UpsertMerchantBindingBody, } from "./contracts/entities/merchant.ts";
|
|
15
|
+
export type { CreatePromptBody, PromptResponse, PromptsListQuery, PromptsResponse, UpdatePromptBody, } from "./contracts/entities/prompts.ts";
|
|
15
16
|
export type { CreateProviderBody, ProviderListItem, ProviderModel, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ProviderType, ThinkingLevelsResponse, UpdateProviderBody, } from "./contracts/entities/providers.ts";
|
|
16
17
|
export type { ToolApprovalDecisionResponse, ToolApprovalState, ToolApprovalsResponse, } from "./contracts/entities/sessions.ts";
|
|
17
18
|
export type { CreateSkillBody, Skill, SkillArchiveType, SkillCopyResult, SkillCopyResults, SkillDetail, SkillFile, SkillsListResponse, } from "./contracts/entities/skills.ts";
|
|
18
|
-
export type { UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageTotals, } from "./contracts/entities/usage.ts";
|
|
19
|
+
export type { SessionUsageQuery, SessionUsageResponse, UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageTotals, } from "./contracts/entities/usage.ts";
|
|
19
20
|
export type { CreateWorkspaceBody, UpdateWorkspaceBody, Workspace, WorkspaceNetworkPolicy, WorkspacesListResponse, } from "./contracts/entities/workspaces.ts";
|
|
20
21
|
export { BlazingAgentsDirectChatTransport, type BlazingAgentsDirectChatTransportOptions, } from "./direct-chat-transport.ts";
|
|
21
22
|
export { BlazingAgentsError } from "./errors.ts";
|
|
22
23
|
export { createChatRelay, createCompletionRelay, type RelayContext, type SessionOwnershipStore, } from "./relay.ts";
|
|
23
|
-
export type { AgentClient, AgentSkillsResource, AgentsListOptions, AgentsResource, AgentVersionsListOptions, ArtifactsResource, AttributionInput, BlazingAgentsErrorCode, BlazingAgentsOptions, BlazingAgentsRequestOptions, BlazingAgentsUIMessage, BlazingAgentsUIMessageChunk, ChatConnectionsResource, ChatDeliveriesListOptions, ChatDeliveriesResource, ChatInput, ChatMessageInput, ChatPromptInput, ChatResult, ChatTrigger, CompletionInput, CompletionPromptIdInput, CompletionPromptInput, CompletionResult, KnownBlazingAgentsErrorCode, LatestSessionsListOptions, McpConnectionsResource, MemoriesListOptions, MemoriesResource, MerchantBindingsListOptions, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsListOptions, MerchantUsageEventsResource, ObjectInput, ObjectPromptIdInput, ObjectPromptInput, ObjectResult, PromptsResource, ProvidersResource, ResourceRequestOptions, ResponseObservation, SessionsResource, SkillsListOptions, TasksResource, TenantResource, TerminalStreamResult, UsageResource, WorkspacesListOptions, WorkspacesResource, } from "./types.ts";
|
|
24
|
+
export type { AgentClient, AgentSkillsResource, AgentsListOptions, AgentsResource, AgentVersionsListOptions, ArtifactsResource, AttributionInput, BlazingAgentsErrorCode, BlazingAgentsOptions, BlazingAgentsRequestOptions, BlazingAgentsUIMessage, BlazingAgentsUIMessageChunk, ChatConnectionsResource, ChatDeliveriesListOptions, ChatDeliveriesResource, ChatInput, ChatMessageInput, ChatPromptInput, ChatResult, ChatTrigger, CompletionInput, CompletionPromptIdInput, CompletionPromptInput, CompletionResult, KnownBlazingAgentsErrorCode, LatestSessionsListOptions, McpConnectionsResource, MemoriesListOptions, MemoriesResource, MerchantBindingsListOptions, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsListOptions, MerchantUsageEventsResource, ObjectInput, ObjectPromptIdInput, ObjectPromptInput, ObjectResult, PromptsResource, ProvidersResource, ResourceRequestOptions, ResponseObservation, SessionsResource, SkillsListOptions, TasksResource, TenantResource, TerminalStreamResult, UsageResource, UserClient, WorkspacesListOptions, WorkspacesResource, } from "./types.ts";
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import type { AgentsResource, HttpConfig } from "../types.ts";
|
|
2
|
-
/**
|
|
3
|
-
* `client.agents` — full CRUD over `/v1/agents`. The list endpoint is
|
|
4
|
-
* unpaginated (bounded by the 100/tenant cap); create/update bodies are
|
|
5
|
-
* the core zod contracts' input shapes. Responses are parsed against the
|
|
6
|
-
* core wire schemas (parse-on-read).
|
|
7
|
-
*/
|
|
8
2
|
export declare function createAgentsResource(config: HttpConfig): AgentsResource;
|
package/dist/resources/agents.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { agentResponseSchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, } from "../contracts/entities/agents.js";
|
|
2
2
|
import { mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, } from "../contracts/entities/mcp-connections.js";
|
|
3
3
|
import { requestJson } from "../http.js";
|
|
4
|
-
/**
|
|
5
|
-
* `client.agents` — full CRUD over `/v1/agents`. The list endpoint is
|
|
6
|
-
* unpaginated (bounded by the 100/tenant cap); create/update bodies are
|
|
7
|
-
* the core zod contracts' input shapes. Responses are parsed against the
|
|
8
|
-
* core wire schemas (parse-on-read).
|
|
9
|
-
*/
|
|
10
4
|
export function createAgentsResource(config) {
|
|
11
5
|
const getVersion = async ({ agentId, version, abortSignal, }) => requestJson(config, `/v1/agents/${agentId}/versions/${version}`, { signal: abortSignal }, agentVersionSchema);
|
|
12
6
|
const update = async ({ agentId, abortSignal, ...body }) => requestJson(config, `/v1/agents/${agentId}`, {
|
|
@@ -26,6 +20,8 @@ export function createAgentsResource(config) {
|
|
|
26
20
|
return await requestJson(config, "/v1/agents", {
|
|
27
21
|
signal: options.abortSignal,
|
|
28
22
|
query: {
|
|
23
|
+
cursor: options.cursor,
|
|
24
|
+
limit: options.limit,
|
|
29
25
|
userId: options.userId,
|
|
30
26
|
workspaceId: options.workspaceId,
|
|
31
27
|
},
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import type { HttpConfig, PromptsResource } from "../types.ts";
|
|
2
|
-
/**
|
|
3
|
-
* `client.prompts` — CRUD over `/v1/prompts`. The list endpoint is
|
|
4
|
-
* unpaginated (bounded by the 100/tenant cap).
|
|
5
|
-
*/
|
|
6
2
|
export declare function createPromptsResource(config: HttpConfig): PromptsResource;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { promptResponseSchema, promptsResponseSchema, } from "../contracts/entities/prompts.js";
|
|
2
2
|
import { requestJson } from "../http.js";
|
|
3
|
-
/**
|
|
4
|
-
* `client.prompts` — CRUD over `/v1/prompts`. The list endpoint is
|
|
5
|
-
* unpaginated (bounded by the 100/tenant cap).
|
|
6
|
-
*/
|
|
7
3
|
export function createPromptsResource(config) {
|
|
8
4
|
return {
|
|
9
5
|
async create({ abortSignal, ...body }) {
|
|
@@ -13,10 +9,10 @@ export function createPromptsResource(config) {
|
|
|
13
9
|
method: "POST",
|
|
14
10
|
}, promptResponseSchema);
|
|
15
11
|
},
|
|
16
|
-
async list({ userId, agentId, abortSignal } = {}) {
|
|
12
|
+
async list({ userId, agentId, cursor, limit, abortSignal } = {}) {
|
|
17
13
|
return await requestJson(config, "/v1/prompts", {
|
|
18
14
|
signal: abortSignal,
|
|
19
|
-
query: { userId, agentId },
|
|
15
|
+
query: { userId, agentId, cursor, limit },
|
|
20
16
|
}, promptsResponseSchema);
|
|
21
17
|
},
|
|
22
18
|
async get({ promptId, abortSignal }) {
|
package/dist/resources/usage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { usageOverviewResponseSchemaForQuery, usageResponseSchema, } from "../contracts/entities/usage.js";
|
|
1
|
+
import { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewResponseSchemaForQuery, usageResponseSchema, } from "../contracts/entities/usage.js";
|
|
2
2
|
import { requestJson } from "../http.js";
|
|
3
3
|
/**
|
|
4
4
|
* `client.usage` — get over `/v1/usage` (tenant-wide) and
|
|
@@ -7,6 +7,14 @@ import { requestJson } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export function createUsageResource(config) {
|
|
9
9
|
return {
|
|
10
|
+
async sessions({ abortSignal, ...input }) {
|
|
11
|
+
const body = sessionUsageQuerySchema.parse(input);
|
|
12
|
+
return await requestJson(config, "/v1/usage/sessions", {
|
|
13
|
+
method: "POST",
|
|
14
|
+
json: body,
|
|
15
|
+
signal: abortSignal,
|
|
16
|
+
}, sessionUsageResponseSchema);
|
|
17
|
+
},
|
|
10
18
|
async get({ abortSignal, ...query } = {}) {
|
|
11
19
|
return await requestJson(config, "/v1/usage", {
|
|
12
20
|
query,
|
package/dist/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { DecideToolApprovalBody, LatestSessionsListResponse, SessionMessage
|
|
|
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
|
-
import type { UsageOverviewQuery, UsageOverviewResponse, UsageQuery, UsageResponse } from "./contracts/entities/usage.ts";
|
|
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
18
|
export type KnownBlazingAgentsErrorCode = ApiErrorCode | "invalid_response" | "network_error" | "request_aborted" | "stream_error";
|
|
19
19
|
export type BlazingAgentsErrorCode = KnownBlazingAgentsErrorCode | (string & {});
|
|
@@ -46,6 +46,7 @@ export interface HttpConfig {
|
|
|
46
46
|
clientRequestId?: string;
|
|
47
47
|
fetch?: BlazingAgentsFetch;
|
|
48
48
|
onResponse?: ((response: ResponseObservation) => void) | undefined;
|
|
49
|
+
scopeUserId?: string;
|
|
49
50
|
}
|
|
50
51
|
export interface BlazingAgentsOptions {
|
|
51
52
|
apiKey: string;
|
|
@@ -57,6 +58,23 @@ export interface BlazingAgentsOptions {
|
|
|
57
58
|
export interface BlazingAgentsRequestOptions {
|
|
58
59
|
clientRequestId: string;
|
|
59
60
|
}
|
|
61
|
+
export interface UserClient {
|
|
62
|
+
agent(input: {
|
|
63
|
+
agentId: string;
|
|
64
|
+
}): AgentClient;
|
|
65
|
+
readonly agents: AgentsResource;
|
|
66
|
+
readonly artifacts: ArtifactsResource;
|
|
67
|
+
chat(input: ChatInput): Promise<ChatResult>;
|
|
68
|
+
completion(input: CompletionInput): Promise<CompletionResult>;
|
|
69
|
+
readonly memories: MemoriesResource;
|
|
70
|
+
object(input: ObjectInput): Promise<ObjectResult>;
|
|
71
|
+
readonly prompts: PromptsResource;
|
|
72
|
+
readonly sessions: SessionsResource;
|
|
73
|
+
readonly tasks: TasksResource;
|
|
74
|
+
readonly usage: Pick<UsageResource, "get" | "sessions">;
|
|
75
|
+
withOptions(options: BlazingAgentsRequestOptions): UserClient;
|
|
76
|
+
readonly workspaces: WorkspacesResource;
|
|
77
|
+
}
|
|
60
78
|
export interface ResponseObservation {
|
|
61
79
|
clientRequestId?: string;
|
|
62
80
|
durationMs: number;
|
|
@@ -234,6 +252,8 @@ export interface AgentClient {
|
|
|
234
252
|
readonly skills: AgentSkillsResource;
|
|
235
253
|
}
|
|
236
254
|
export interface AgentsListOptions extends ResourceRequestOptions {
|
|
255
|
+
cursor?: string;
|
|
256
|
+
limit?: number;
|
|
237
257
|
userId?: string;
|
|
238
258
|
workspaceId?: string;
|
|
239
259
|
}
|
|
@@ -313,6 +333,8 @@ export interface PromptsResource {
|
|
|
313
333
|
list(input?: {
|
|
314
334
|
userId?: string;
|
|
315
335
|
agentId?: string;
|
|
336
|
+
cursor?: string;
|
|
337
|
+
limit?: number;
|
|
316
338
|
} & ResourceRequestOptions): Promise<PromptsResponse>;
|
|
317
339
|
update(input: UpdatePromptBody & {
|
|
318
340
|
promptId: string;
|
|
@@ -506,6 +528,7 @@ export interface UsageResource {
|
|
|
506
528
|
} & ResourceRequestOptions): Promise<UsageResponse>;
|
|
507
529
|
/** Returns totals, daily usage, and bounded Agent, user, and model rankings. */
|
|
508
530
|
overview(input?: Partial<UsageOverviewQuery> & ResourceRequestOptions): Promise<UsageOverviewResponse>;
|
|
531
|
+
sessions(input: SessionUsageQuery & ResourceRequestOptions): Promise<SessionUsageResponse>;
|
|
509
532
|
}
|
|
510
533
|
/**
|
|
511
534
|
* `client.merchantConnection` — the tenant's own Polar/Dodo merchant
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazingagents/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "TypeScript SDK for the Blazing Agents API",
|
|
5
5
|
"homepage": "https://docs.blazingagents.com",
|
|
6
6
|
"bugs": {
|
|
@@ -35,26 +35,28 @@
|
|
|
35
35
|
"lint": "ultracite check",
|
|
36
36
|
"prepack": "npm run build",
|
|
37
37
|
"test": "vitest run --coverage",
|
|
38
|
-
"test:consumer": "
|
|
38
|
+
"test:consumer": "node test-consumer.mjs",
|
|
39
39
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.tests.json"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"croner": "10.0.1",
|
|
43
43
|
"nanoid": "6.0.1",
|
|
44
|
-
"yaml": "2.9.0"
|
|
45
|
-
"zod": "4.5.4"
|
|
44
|
+
"yaml": "2.9.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@biomejs/biome": "^2.5.8",
|
|
48
|
+
"@types/json-schema": "7.0.15",
|
|
49
49
|
"@types/node": "^26.4.0",
|
|
50
50
|
"@vitest/coverage-v8": "^4.1.10",
|
|
51
51
|
"ai": "^7.0.84",
|
|
52
52
|
"typescript": "^7.0.2",
|
|
53
53
|
"ultracite": "^7.10.2",
|
|
54
|
-
"vitest": "^4.1.10"
|
|
54
|
+
"vitest": "^4.1.10",
|
|
55
|
+
"zod": "4.5.4"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"ai": "^7.0.84"
|
|
58
|
+
"ai": "^7.0.84",
|
|
59
|
+
"zod": "^4.5.4"
|
|
58
60
|
},
|
|
59
61
|
"engines": {
|
|
60
62
|
"node": ">=24"
|