@blazingagents/sdk 0.9.2 → 0.10.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 +31 -1
- package/dist/client.d.ts +4 -1
- package/dist/client.js +9 -0
- package/dist/contracts/api.d.ts +57 -0
- package/dist/contracts/api.js +19 -0
- package/dist/contracts/entities/chat-connections.d.ts +15 -28
- package/dist/contracts/entities/chat-connections.js +28 -28
- package/dist/contracts/entities/chat.d.ts +2 -0
- package/dist/contracts/entities/chat.js +6 -0
- package/dist/contracts/entities/merchant.d.ts +448 -0
- package/dist/contracts/entities/merchant.js +237 -0
- package/dist/contracts/entities/tenants.d.ts +17 -0
- package/dist/contracts/entities/tenants.js +19 -1
- package/dist/contracts/ids.d.ts +2 -0
- package/dist/contracts/ids.js +6 -0
- package/dist/contracts/index.d.ts +2 -1
- package/dist/contracts/index.js +2 -1
- package/dist/contracts/limitations.d.ts +9 -0
- package/dist/contracts/limitations.js +9 -0
- package/dist/index.d.ts +2 -1
- package/dist/resources/merchant-bindings.d.ts +8 -0
- package/dist/resources/merchant-bindings.js +21 -0
- package/dist/resources/merchant-connection.d.ts +7 -0
- package/dist/resources/merchant-connection.js +26 -0
- package/dist/resources/merchant-usage-events.d.ts +7 -0
- package/dist/resources/merchant-usage-events.js +29 -0
- package/dist/resources/skills.js +1 -2
- package/dist/types.d.ts +60 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ requires Node.js 24 or newer.
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
18
|
- Typed clients for Agents, Workspaces, Skills, Providers, Prompts, Tasks,
|
|
19
|
-
Sessions, Artifacts, Slack and Telegram Chat Connections, usage, and
|
|
19
|
+
Sessions, Artifacts, Slack and Telegram Chat Connections, usage, Tenant settings, and merchant monetization.
|
|
20
20
|
- Stateful chat and stateless text or structured-object generation.
|
|
21
21
|
- Public Zod contracts for validating API requests and responses.
|
|
22
22
|
- Cursor pagination and binary transfers.
|
|
@@ -238,3 +238,33 @@ and `ToolApprovalState`; runtime policy schemas are exported from
|
|
|
238
238
|
Use the [connection example](https://github.com/blazingagents/typescript-sdk/blob/main/examples/chat-integrations.md) to connect an existing
|
|
239
239
|
Agent through REST. BA hosts the Chat SDK runtime, conversation history, and
|
|
240
240
|
approval cards; no additional SDK resource is required.
|
|
241
|
+
|
|
242
|
+
## Merchant monetization
|
|
243
|
+
|
|
244
|
+
Bill your own customers for model-token usage through your Polar or Dodo
|
|
245
|
+
merchant account. Blazing Agents records usage per Turn and delivers it to
|
|
246
|
+
your provider; your provider owns billing.
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
const client = new BlazingAgents({ apiKey: "ba_..." });
|
|
250
|
+
|
|
251
|
+
// One-time: connect your merchant account (dashboard or API).
|
|
252
|
+
await client.merchantConnection.create({
|
|
253
|
+
provider: "polar",
|
|
254
|
+
environment: "sandbox",
|
|
255
|
+
credential: "polar_oat_...", // organization access token
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// On user onboarding in your backend: bind your user id to the
|
|
259
|
+
// provider-side customer so usage is attributed correctly.
|
|
260
|
+
await client.merchantBindings.put({
|
|
261
|
+
userId: "user_123",
|
|
262
|
+
customerId: "cust_polar_...",
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
`client.merchantUsageEvents` exposes the delivery ledger (`list`, `get`,
|
|
267
|
+
`summary`) and the operator actions `retry`, `release`, and `discard`. The
|
|
268
|
+
optional eligibility guard (`guard` on the connection) refuses new
|
|
269
|
+
executions when the bound customer lacks the required subscription or
|
|
270
|
+
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, ChatInput, ChatResult, CompletionInput, CompletionResult, McpConnectionsResource, MemoriesResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, WorkspacesResource } from "./types.ts";
|
|
1
|
+
import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatInput, ChatResult, CompletionInput, CompletionResult, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, WorkspacesResource } from "./types.ts";
|
|
2
2
|
export declare class BlazingAgents {
|
|
3
3
|
private readonly config;
|
|
4
4
|
readonly chatConnections: ChatConnectionsResource;
|
|
@@ -13,6 +13,9 @@ export declare class BlazingAgents {
|
|
|
13
13
|
readonly tasks: TasksResource;
|
|
14
14
|
readonly tenant: TenantResource;
|
|
15
15
|
readonly workspaces: WorkspacesResource;
|
|
16
|
+
readonly merchantConnection: MerchantConnectionResource;
|
|
17
|
+
readonly merchantBindings: MerchantBindingsResource;
|
|
18
|
+
readonly merchantUsageEvents: MerchantUsageEventsResource;
|
|
16
19
|
constructor(options: BlazingAgentsOptions);
|
|
17
20
|
agent({ agentId }: {
|
|
18
21
|
agentId: string;
|
package/dist/client.js
CHANGED
|
@@ -4,6 +4,9 @@ import { createArtifactsResource } from "./resources/artifacts.js";
|
|
|
4
4
|
import { createChatConnectionsResource } from "./resources/chat-connections.js";
|
|
5
5
|
import { createMcpConnectionsResource } from "./resources/mcp-connections.js";
|
|
6
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";
|
|
7
10
|
import { createPromptsResource } from "./resources/prompts.js";
|
|
8
11
|
import { createProvidersResource } from "./resources/providers.js";
|
|
9
12
|
import { createSessionsResource } from "./resources/sessions.js";
|
|
@@ -28,6 +31,9 @@ export class BlazingAgents {
|
|
|
28
31
|
tasks;
|
|
29
32
|
tenant;
|
|
30
33
|
workspaces;
|
|
34
|
+
merchantConnection;
|
|
35
|
+
merchantBindings;
|
|
36
|
+
merchantUsageEvents;
|
|
31
37
|
constructor(options) {
|
|
32
38
|
this.config = {
|
|
33
39
|
apiKey: options.apiKey,
|
|
@@ -50,6 +56,9 @@ export class BlazingAgents {
|
|
|
50
56
|
this.tasks = createTasksResource(this.config);
|
|
51
57
|
this.tenant = createTenantResource(this.config);
|
|
52
58
|
this.workspaces = createWorkspacesResource(this.config);
|
|
59
|
+
this.merchantConnection = createMerchantConnectionResource(this.config);
|
|
60
|
+
this.merchantBindings = createMerchantBindingsResource(this.config);
|
|
61
|
+
this.merchantUsageEvents = createMerchantUsageEventsResource(this.config);
|
|
53
62
|
}
|
|
54
63
|
agent({ agentId }) {
|
|
55
64
|
return { skills: createAgentSkillsResource(this.config, agentId) };
|
package/dist/contracts/api.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
27
27
|
agent_version_not_found: "agent_version_not_found";
|
|
28
28
|
api_key_limit_reached: "api_key_limit_reached";
|
|
29
29
|
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
30
|
+
chat_webhook_conflict: "chat_webhook_conflict";
|
|
31
|
+
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
30
32
|
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
31
33
|
internal: "internal";
|
|
32
34
|
invalid_cursor: "invalid_cursor";
|
|
@@ -39,6 +41,19 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
39
41
|
mcp_connection_name_conflict: "mcp_connection_name_conflict";
|
|
40
42
|
mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
|
|
41
43
|
mcp_connection_unreachable: "mcp_connection_unreachable";
|
|
44
|
+
merchant_account_mismatch: "merchant_account_mismatch";
|
|
45
|
+
merchant_balance_required: "merchant_balance_required";
|
|
46
|
+
merchant_binding_not_found: "merchant_binding_not_found";
|
|
47
|
+
merchant_binding_required: "merchant_binding_required";
|
|
48
|
+
merchant_connection_not_found: "merchant_connection_not_found";
|
|
49
|
+
merchant_credential_invalid: "merchant_credential_invalid";
|
|
50
|
+
merchant_customer_not_found: "merchant_customer_not_found";
|
|
51
|
+
merchant_customer_unmapped: "merchant_customer_unmapped";
|
|
52
|
+
merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
|
|
53
|
+
merchant_event_not_found: "merchant_event_not_found";
|
|
54
|
+
merchant_event_state_conflict: "merchant_event_state_conflict";
|
|
55
|
+
merchant_provider_unavailable: "merchant_provider_unavailable";
|
|
56
|
+
merchant_subscription_required: "merchant_subscription_required";
|
|
42
57
|
message_not_found: "message_not_found";
|
|
43
58
|
model_discovery_unsupported: "model_discovery_unsupported";
|
|
44
59
|
model_not_found: "model_not_found";
|
|
@@ -68,6 +83,10 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
68
83
|
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
69
84
|
subscription_required: "subscription_required";
|
|
70
85
|
task_active_run_exists: "task_active_run_exists";
|
|
86
|
+
tenant_deleting: "tenant_deleting";
|
|
87
|
+
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
88
|
+
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
89
|
+
tenant_not_deleting: "tenant_not_deleting";
|
|
71
90
|
tool_approval_continuation_not_found: "tool_approval_continuation_not_found";
|
|
72
91
|
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
73
92
|
unauthorized: "unauthorized";
|
|
@@ -87,6 +106,8 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
87
106
|
agent_version_not_found: "agent_version_not_found";
|
|
88
107
|
api_key_limit_reached: "api_key_limit_reached";
|
|
89
108
|
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
109
|
+
chat_webhook_conflict: "chat_webhook_conflict";
|
|
110
|
+
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
90
111
|
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
91
112
|
internal: "internal";
|
|
92
113
|
invalid_cursor: "invalid_cursor";
|
|
@@ -99,6 +120,19 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
99
120
|
mcp_connection_name_conflict: "mcp_connection_name_conflict";
|
|
100
121
|
mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
|
|
101
122
|
mcp_connection_unreachable: "mcp_connection_unreachable";
|
|
123
|
+
merchant_account_mismatch: "merchant_account_mismatch";
|
|
124
|
+
merchant_balance_required: "merchant_balance_required";
|
|
125
|
+
merchant_binding_not_found: "merchant_binding_not_found";
|
|
126
|
+
merchant_binding_required: "merchant_binding_required";
|
|
127
|
+
merchant_connection_not_found: "merchant_connection_not_found";
|
|
128
|
+
merchant_credential_invalid: "merchant_credential_invalid";
|
|
129
|
+
merchant_customer_not_found: "merchant_customer_not_found";
|
|
130
|
+
merchant_customer_unmapped: "merchant_customer_unmapped";
|
|
131
|
+
merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
|
|
132
|
+
merchant_event_not_found: "merchant_event_not_found";
|
|
133
|
+
merchant_event_state_conflict: "merchant_event_state_conflict";
|
|
134
|
+
merchant_provider_unavailable: "merchant_provider_unavailable";
|
|
135
|
+
merchant_subscription_required: "merchant_subscription_required";
|
|
102
136
|
message_not_found: "message_not_found";
|
|
103
137
|
model_discovery_unsupported: "model_discovery_unsupported";
|
|
104
138
|
model_not_found: "model_not_found";
|
|
@@ -128,6 +162,10 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
128
162
|
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
129
163
|
subscription_required: "subscription_required";
|
|
130
164
|
task_active_run_exists: "task_active_run_exists";
|
|
165
|
+
tenant_deleting: "tenant_deleting";
|
|
166
|
+
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
167
|
+
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
168
|
+
tenant_not_deleting: "tenant_not_deleting";
|
|
131
169
|
tool_approval_continuation_not_found: "tool_approval_continuation_not_found";
|
|
132
170
|
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
133
171
|
unauthorized: "unauthorized";
|
|
@@ -152,6 +190,8 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
152
190
|
agent_version_not_found: "agent_version_not_found";
|
|
153
191
|
api_key_limit_reached: "api_key_limit_reached";
|
|
154
192
|
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
193
|
+
chat_webhook_conflict: "chat_webhook_conflict";
|
|
194
|
+
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
155
195
|
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
156
196
|
internal: "internal";
|
|
157
197
|
invalid_cursor: "invalid_cursor";
|
|
@@ -164,6 +204,19 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
164
204
|
mcp_connection_name_conflict: "mcp_connection_name_conflict";
|
|
165
205
|
mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
|
|
166
206
|
mcp_connection_unreachable: "mcp_connection_unreachable";
|
|
207
|
+
merchant_account_mismatch: "merchant_account_mismatch";
|
|
208
|
+
merchant_balance_required: "merchant_balance_required";
|
|
209
|
+
merchant_binding_not_found: "merchant_binding_not_found";
|
|
210
|
+
merchant_binding_required: "merchant_binding_required";
|
|
211
|
+
merchant_connection_not_found: "merchant_connection_not_found";
|
|
212
|
+
merchant_credential_invalid: "merchant_credential_invalid";
|
|
213
|
+
merchant_customer_not_found: "merchant_customer_not_found";
|
|
214
|
+
merchant_customer_unmapped: "merchant_customer_unmapped";
|
|
215
|
+
merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
|
|
216
|
+
merchant_event_not_found: "merchant_event_not_found";
|
|
217
|
+
merchant_event_state_conflict: "merchant_event_state_conflict";
|
|
218
|
+
merchant_provider_unavailable: "merchant_provider_unavailable";
|
|
219
|
+
merchant_subscription_required: "merchant_subscription_required";
|
|
167
220
|
message_not_found: "message_not_found";
|
|
168
221
|
model_discovery_unsupported: "model_discovery_unsupported";
|
|
169
222
|
model_not_found: "model_not_found";
|
|
@@ -193,6 +246,10 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
193
246
|
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
194
247
|
subscription_required: "subscription_required";
|
|
195
248
|
task_active_run_exists: "task_active_run_exists";
|
|
249
|
+
tenant_deleting: "tenant_deleting";
|
|
250
|
+
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
251
|
+
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
252
|
+
tenant_not_deleting: "tenant_not_deleting";
|
|
196
253
|
tool_approval_continuation_not_found: "tool_approval_continuation_not_found";
|
|
197
254
|
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
198
255
|
unauthorized: "unauthorized";
|
package/dist/contracts/api.js
CHANGED
|
@@ -74,6 +74,25 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
74
74
|
"skill_too_many_files",
|
|
75
75
|
"skill_uncompressed_too_large",
|
|
76
76
|
"task_active_run_exists",
|
|
77
|
+
"chat_webhook_conflict",
|
|
78
|
+
"chat_webhook_registration_failed",
|
|
79
|
+
"merchant_connection_not_found",
|
|
80
|
+
"merchant_credential_invalid",
|
|
81
|
+
"merchant_provider_unavailable",
|
|
82
|
+
"merchant_customer_not_found",
|
|
83
|
+
"merchant_binding_not_found",
|
|
84
|
+
"merchant_binding_required",
|
|
85
|
+
"merchant_account_mismatch",
|
|
86
|
+
"merchant_event_not_found",
|
|
87
|
+
"merchant_event_state_conflict",
|
|
88
|
+
"merchant_customer_unmapped",
|
|
89
|
+
"merchant_subscription_required",
|
|
90
|
+
"merchant_balance_required",
|
|
91
|
+
"merchant_eligibility_unavailable",
|
|
92
|
+
"tenant_deleting",
|
|
93
|
+
"tenant_deletion_in_progress",
|
|
94
|
+
"tenant_deletion_not_ready",
|
|
95
|
+
"tenant_not_deleting",
|
|
77
96
|
]);
|
|
78
97
|
export const apiErrorSchema = z
|
|
79
98
|
.object({
|
|
@@ -6,17 +6,12 @@ export declare const chatCredentialsSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
6
6
|
}, z.core.$strict>, z.ZodObject<{
|
|
7
7
|
platform: z.ZodLiteral<"telegram">;
|
|
8
8
|
botToken: z.ZodString;
|
|
9
|
-
webhookSecret: z.ZodString;
|
|
10
9
|
}, z.core.$strict>], "platform">;
|
|
11
10
|
export declare const chatConfigurationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
-
teamId: z.ZodString;
|
|
13
|
-
appId: z.ZodString;
|
|
14
|
-
webhookUrl: z.ZodURL;
|
|
15
11
|
channelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
16
12
|
platform: z.ZodLiteral<"slack">;
|
|
17
13
|
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
-
|
|
19
|
-
webhookUrl: z.ZodURL;
|
|
14
|
+
businessMode: z.ZodDefault<z.ZodBoolean>;
|
|
20
15
|
chatIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
21
16
|
platform: z.ZodLiteral<"telegram">;
|
|
22
17
|
}, z.core.$strict>], "platform">;
|
|
@@ -25,12 +20,9 @@ export declare const createChatConnectionBodySchema: z.ZodDiscriminatedUnion<[z.
|
|
|
25
20
|
name: z.ZodString;
|
|
26
21
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
27
22
|
platform: z.ZodLiteral<"slack">;
|
|
28
|
-
configuration: z.ZodObject<{
|
|
29
|
-
teamId: z.ZodString;
|
|
30
|
-
appId: z.ZodString;
|
|
31
|
-
webhookUrl: z.ZodURL;
|
|
23
|
+
configuration: z.ZodPrefault<z.ZodObject<{
|
|
32
24
|
channelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
33
|
-
}, z.core.$strict
|
|
25
|
+
}, z.core.$strict>>;
|
|
34
26
|
credentials: z.ZodObject<{
|
|
35
27
|
botToken: z.ZodString;
|
|
36
28
|
signingSecret: z.ZodString;
|
|
@@ -40,14 +32,12 @@ export declare const createChatConnectionBodySchema: z.ZodDiscriminatedUnion<[z.
|
|
|
40
32
|
name: z.ZodString;
|
|
41
33
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
42
34
|
platform: z.ZodLiteral<"telegram">;
|
|
43
|
-
configuration: z.ZodObject<{
|
|
44
|
-
|
|
45
|
-
webhookUrl: z.ZodURL;
|
|
35
|
+
configuration: z.ZodPrefault<z.ZodObject<{
|
|
36
|
+
businessMode: z.ZodDefault<z.ZodBoolean>;
|
|
46
37
|
chatIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
47
|
-
}, z.core.$strict
|
|
38
|
+
}, z.core.$strict>>;
|
|
48
39
|
credentials: z.ZodObject<{
|
|
49
40
|
botToken: z.ZodString;
|
|
50
|
-
webhookSecret: z.ZodString;
|
|
51
41
|
}, z.core.$strict>;
|
|
52
42
|
}, z.core.$strict>], "platform">;
|
|
53
43
|
export declare const rotateChatConnectionBodySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -57,11 +47,14 @@ export declare const rotateChatConnectionBodySchema: z.ZodDiscriminatedUnion<[z.
|
|
|
57
47
|
}, z.core.$strict>, z.ZodObject<{
|
|
58
48
|
platform: z.ZodLiteral<"telegram">;
|
|
59
49
|
botToken: z.ZodString;
|
|
60
|
-
webhookSecret: z.ZodString;
|
|
61
50
|
}, z.core.$strict>], "platform">;
|
|
62
51
|
export declare const updateChatConnectionBodySchema: z.ZodObject<{
|
|
63
52
|
name: z.ZodOptional<z.ZodString>;
|
|
64
|
-
|
|
53
|
+
configuration: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
businessMode: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
chatIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
+
channelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
65
58
|
}, z.core.$strict>;
|
|
66
59
|
export declare const chatConnectionParamsSchema: z.ZodObject<{
|
|
67
60
|
id: z.ZodString;
|
|
@@ -106,17 +99,14 @@ export declare const chatConnectionSchema: z.ZodObject<{
|
|
|
106
99
|
}>;
|
|
107
100
|
enabled: z.ZodBoolean;
|
|
108
101
|
configuration: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
109
|
-
teamId: z.ZodString;
|
|
110
|
-
appId: z.ZodString;
|
|
111
|
-
webhookUrl: z.ZodURL;
|
|
112
102
|
channelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
113
103
|
platform: z.ZodLiteral<"slack">;
|
|
114
104
|
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
-
|
|
116
|
-
webhookUrl: z.ZodURL;
|
|
105
|
+
businessMode: z.ZodDefault<z.ZodBoolean>;
|
|
117
106
|
chatIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
118
107
|
platform: z.ZodLiteral<"telegram">;
|
|
119
108
|
}, z.core.$strip>], "platform">;
|
|
109
|
+
webhookUrl: z.ZodURL;
|
|
120
110
|
identity: z.ZodObject<{
|
|
121
111
|
botId: z.ZodString;
|
|
122
112
|
botUserId: z.ZodString;
|
|
@@ -161,17 +151,14 @@ export declare const chatConnectionsResponseSchema: z.ZodObject<{
|
|
|
161
151
|
}>;
|
|
162
152
|
enabled: z.ZodBoolean;
|
|
163
153
|
configuration: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
164
|
-
teamId: z.ZodString;
|
|
165
|
-
appId: z.ZodString;
|
|
166
|
-
webhookUrl: z.ZodURL;
|
|
167
154
|
channelIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
168
155
|
platform: z.ZodLiteral<"slack">;
|
|
169
156
|
}, z.core.$strip>, z.ZodObject<{
|
|
170
|
-
|
|
171
|
-
webhookUrl: z.ZodURL;
|
|
157
|
+
businessMode: z.ZodDefault<z.ZodBoolean>;
|
|
172
158
|
chatIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
173
159
|
platform: z.ZodLiteral<"telegram">;
|
|
174
160
|
}, z.core.$strip>], "platform">;
|
|
161
|
+
webhookUrl: z.ZodURL;
|
|
175
162
|
identity: z.ZodObject<{
|
|
176
163
|
botId: z.ZodString;
|
|
177
164
|
botUserId: z.ZodString;
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { agentIdSchema, chatConnectionIdSchema, tenantIdSchema, } from "../ids.js";
|
|
3
|
-
const webhookUrl = z
|
|
4
|
-
.url()
|
|
5
|
-
.max(2048)
|
|
6
|
-
.refine((value) => {
|
|
7
|
-
const url = new URL(value);
|
|
8
|
-
return (url.protocol === "https:" &&
|
|
9
|
-
!url.username &&
|
|
10
|
-
!url.password &&
|
|
11
|
-
!url.search &&
|
|
12
|
-
!url.hash);
|
|
13
|
-
}, "Use an HTTPS callback URL without credentials, query or fragment");
|
|
14
3
|
const secret = z
|
|
15
4
|
.string()
|
|
16
5
|
.min(8)
|
|
@@ -28,19 +17,11 @@ export const chatCredentialsSchema = z.discriminatedUnion("platform", [
|
|
|
28
17
|
.object({
|
|
29
18
|
platform: z.literal("telegram"),
|
|
30
19
|
botToken: z.string().regex(/^\d+:[A-Za-z0-9_-]+$/),
|
|
31
|
-
webhookSecret: z
|
|
32
|
-
.string()
|
|
33
|
-
.min(1)
|
|
34
|
-
.max(256)
|
|
35
|
-
.regex(/^[A-Za-z0-9_-]+$/),
|
|
36
20
|
})
|
|
37
21
|
.strict(),
|
|
38
22
|
]);
|
|
39
23
|
const slackConfiguration = z
|
|
40
24
|
.object({
|
|
41
|
-
teamId: z.string().regex(/^T[A-Z0-9]+$/),
|
|
42
|
-
appId: z.string().regex(/^A[A-Z0-9]+$/),
|
|
43
|
-
webhookUrl,
|
|
44
25
|
channelIds: z
|
|
45
26
|
.array(z.string().regex(/^[CG][A-Z0-9]+$/))
|
|
46
27
|
.max(20)
|
|
@@ -49,8 +30,7 @@ const slackConfiguration = z
|
|
|
49
30
|
.strict();
|
|
50
31
|
const telegramConfiguration = z
|
|
51
32
|
.object({
|
|
52
|
-
|
|
53
|
-
webhookUrl,
|
|
33
|
+
businessMode: z.boolean().default(false),
|
|
54
34
|
chatIds: z
|
|
55
35
|
.array(z.string().regex(/^-?\d+$/))
|
|
56
36
|
.max(20)
|
|
@@ -71,7 +51,7 @@ export const createChatConnectionBodySchema = z.discriminatedUnion("platform", [
|
|
|
71
51
|
.object({
|
|
72
52
|
...common,
|
|
73
53
|
platform: z.literal("slack"),
|
|
74
|
-
configuration: slackConfiguration,
|
|
54
|
+
configuration: slackConfiguration.prefault({}),
|
|
75
55
|
credentials: chatCredentialsSchema.options[0].omit({ platform: true }),
|
|
76
56
|
})
|
|
77
57
|
.strict(),
|
|
@@ -79,18 +59,37 @@ export const createChatConnectionBodySchema = z.discriminatedUnion("platform", [
|
|
|
79
59
|
.object({
|
|
80
60
|
...common,
|
|
81
61
|
platform: z.literal("telegram"),
|
|
82
|
-
configuration: telegramConfiguration,
|
|
62
|
+
configuration: telegramConfiguration.prefault({}),
|
|
83
63
|
credentials: chatCredentialsSchema.options[1].omit({ platform: true }),
|
|
84
64
|
})
|
|
85
65
|
.strict(),
|
|
86
66
|
]);
|
|
87
|
-
export const rotateChatConnectionBodySchema =
|
|
67
|
+
export const rotateChatConnectionBodySchema = z.discriminatedUnion("platform", [
|
|
68
|
+
chatCredentialsSchema.options[0],
|
|
69
|
+
chatCredentialsSchema.options[1],
|
|
70
|
+
]);
|
|
88
71
|
export const updateChatConnectionBodySchema = z
|
|
89
|
-
.object({
|
|
72
|
+
.object({
|
|
73
|
+
name: common.name.optional(),
|
|
74
|
+
configuration: z
|
|
75
|
+
.object({
|
|
76
|
+
businessMode: z.boolean().optional(),
|
|
77
|
+
chatIds: z
|
|
78
|
+
.array(z.string().regex(/^-?\d+$/))
|
|
79
|
+
.max(20)
|
|
80
|
+
.optional(),
|
|
81
|
+
channelIds: z
|
|
82
|
+
.array(z.string().regex(/^[CG][A-Z0-9]+$/))
|
|
83
|
+
.max(20)
|
|
84
|
+
.optional(),
|
|
85
|
+
})
|
|
86
|
+
.strict()
|
|
87
|
+
.optional(),
|
|
88
|
+
})
|
|
90
89
|
.strict()
|
|
91
|
-
.refine((body) => body.name !== undefined ||
|
|
92
|
-
|
|
93
|
-
});
|
|
90
|
+
.refine((body) => body.name !== undefined ||
|
|
91
|
+
(body.configuration !== undefined &&
|
|
92
|
+
Object.keys(body.configuration).length > 0), { message: "Provide a name or a configuration change" });
|
|
94
93
|
export const chatConnectionParamsSchema = z.object({
|
|
95
94
|
id: chatConnectionIdSchema,
|
|
96
95
|
});
|
|
@@ -129,6 +128,7 @@ export const chatConnectionSchema = z
|
|
|
129
128
|
chatConfigurationSchema.options[0].strip(),
|
|
130
129
|
chatConfigurationSchema.options[1].strip(),
|
|
131
130
|
]),
|
|
131
|
+
webhookUrl: z.url(),
|
|
132
132
|
identity: chatIdentitySchema,
|
|
133
133
|
health: chatHealthSchema,
|
|
134
134
|
credentialFragment: z.string().max(4),
|
|
@@ -25,6 +25,7 @@ export declare const usageSummarySchema: z.ZodObject<{
|
|
|
25
25
|
durationMs: z.ZodNumber;
|
|
26
26
|
errorMessage: z.ZodNullable<z.ZodString>;
|
|
27
27
|
inputTokens: z.ZodNumber;
|
|
28
|
+
measurementComplete: z.ZodBoolean;
|
|
28
29
|
modelDurationMs: z.ZodNumber;
|
|
29
30
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
30
31
|
modelId: z.ZodString;
|
|
@@ -55,6 +56,7 @@ export declare const blazingAgentsChatMessageMetadataSchema: z.ZodObject<{
|
|
|
55
56
|
durationMs: z.ZodNumber;
|
|
56
57
|
errorMessage: z.ZodNullable<z.ZodString>;
|
|
57
58
|
inputTokens: z.ZodNumber;
|
|
59
|
+
measurementComplete: z.ZodBoolean;
|
|
58
60
|
modelDurationMs: z.ZodNumber;
|
|
59
61
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
60
62
|
modelId: z.ZodString;
|
|
@@ -21,6 +21,12 @@ export const usageSummarySchema = z
|
|
|
21
21
|
durationMs: z.number().int().min(0),
|
|
22
22
|
errorMessage: z.string().nullable(),
|
|
23
23
|
inputTokens: z.number().int().min(0),
|
|
24
|
+
/**
|
|
25
|
+
* True only when every measured inference for this Turn reported
|
|
26
|
+
* input/output totals. Provider omissions stay unknown — a zero is never
|
|
27
|
+
* substituted for a missing measurement (ADR-0048).
|
|
28
|
+
*/
|
|
29
|
+
measurementComplete: z.boolean(),
|
|
24
30
|
modelDurationMs: z.number().int().min(0),
|
|
25
31
|
metadata: z.record(z.string(), z.unknown()),
|
|
26
32
|
modelId: agentModelIdSchema,
|