@blazingagents/sdk 0.7.0 → 0.9.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 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, usage, and Tenant settings.
19
+ Sessions, Artifacts, Slack and Telegram Chat Connections, usage, and Tenant settings.
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.
@@ -184,3 +184,57 @@ await client.agents.update({
184
184
  compactionReserveTokens: 32768,
185
185
  });
186
186
  ```
187
+
188
+ ### Tool approval policies (0.8.0)
189
+
190
+ Agents and immutable Agent Versions expose separate `approvalInChat` and
191
+ `approvalInTasks` policies. Create and update them through the ordinary Agent API:
192
+
193
+ ```ts
194
+ await client.agents.update({
195
+ agentId,
196
+ approvalInChat: {
197
+ default: "full",
198
+ overrides: [
199
+ { tool: { type: "builtin", name: "bash" }, decision: "manual" },
200
+ {
201
+ tool: { type: "mcp", connectionId: "mcp_0123456789abcdef", name: "send_mail" },
202
+ decision: "auto",
203
+ },
204
+ ],
205
+ },
206
+ approvalInTasks: { default: "deny", overrides: [] },
207
+ });
208
+ ```
209
+
210
+ An exact tool override wins over the default. Both policies default to `full`
211
+ with no overrides. `full` allows available tools, `deny` blocks execution,
212
+ `manual` requires human review, and `auto` uses backend LLM review. Review errors
213
+ block execution; escalation without an available human also blocks execution.
214
+ Policies do not grant tool access. MCP references use the original remote tool
215
+ name and connection ID; the backend validates attachment and discovery.
216
+
217
+ Omitting a policy from an update preserves it. Supplying one replaces that whole
218
+ policy; omitted or empty `overrides` clears its overrides. `restoreVersion`
219
+ restores both policies alongside the other versioned fields.
220
+
221
+ Interactive Sessions reuse `client.sessions.toolApprovals`,
222
+ `client.sessions.decideToolApproval`, and
223
+ `client.sessions.joinToolApprovalContinuation`. A configured backend human
224
+ reviewer path is required. Tasks and stateless generations have no human
225
+ continuation path and block manual or escalated calls; stateless generation uses
226
+ `approvalInChat`. The SDK does not run an approval reviewer.
227
+
228
+ Approval rows retain optional `tool`, `assistantMessageId`, `createdAt`, and
229
+ `decidedAt` metadata. `tool` and `decidedAt` may be null (admin tools have no
230
+ ordinary-policy reference). Persisted approval decisions remain
231
+ `pending | approved | denied`; policy modes are `full | deny | manual | auto`.
232
+ The root package exports `ApprovalDecision`, `ApprovalPolicy`, `ToolReference`,
233
+ and `ToolApprovalState`; runtime policy schemas are exported from
234
+ `@blazingagents/sdk/contracts`.
235
+
236
+ ## Slack and Telegram
237
+
238
+ Use the [connection example](https://github.com/blazingagents/typescript-sdk/blob/main/examples/chat-integrations.md) to connect an existing
239
+ Agent through REST. BA hosts the Chat SDK runtime, conversation history, and
240
+ approval cards; no additional SDK resource is required.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, 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, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, WorkspacesResource } from "./types.ts";
2
2
  export declare class BlazingAgents {
3
3
  private readonly config;
4
+ readonly chatConnections: ChatConnectionsResource;
4
5
  readonly agents: AgentsResource;
5
6
  readonly sessions: SessionsResource;
6
7
  readonly providers: ProvidersResource;
package/dist/client.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { chat, completion, objectGeneration } from "./generation.js";
2
2
  import { createAgentsResource } from "./resources/agents.js";
3
3
  import { createArtifactsResource } from "./resources/artifacts.js";
4
+ import { createChatConnectionsResource } from "./resources/chat-connections.js";
4
5
  import { createMcpConnectionsResource } from "./resources/mcp-connections.js";
5
6
  import { createMemoriesResource } from "./resources/memories.js";
6
7
  import { createPromptsResource } from "./resources/prompts.js";
@@ -15,6 +16,7 @@ const DEFAULT_BASE_URL = "https://api.blazingagents.com";
15
16
  const TRAILING_SLASH_RE = /\/+$/;
16
17
  export class BlazingAgents {
17
18
  config;
19
+ chatConnections;
18
20
  agents;
19
21
  sessions;
20
22
  providers;
@@ -36,6 +38,7 @@ export class BlazingAgents {
36
38
  : { clientRequestId: options.clientRequestId }),
37
39
  onResponse: options.onResponse,
38
40
  };
41
+ this.chatConnections = createChatConnectionsResource(this.config);
39
42
  this.agents = createAgentsResource(this.config);
40
43
  this.sessions = createSessionsResource(this.config);
41
44
  this.providers = createProvidersResource(this.config);
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ export declare const approvalDecisionSchema: z.ZodEnum<{
3
+ auto: "auto";
4
+ deny: "deny";
5
+ full: "full";
6
+ manual: "manual";
7
+ }>;
8
+ export declare const toolReferenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ type: z.ZodLiteral<"builtin">;
10
+ name: z.ZodEnum<{
11
+ activate_skill: "activate_skill";
12
+ bash: "bash";
13
+ delete_memory: "delete_memory";
14
+ edit: "edit";
15
+ get_memory: "get_memory";
16
+ glob: "glob";
17
+ grep: "grep";
18
+ publish_artifacts: "publish_artifacts";
19
+ read: "read";
20
+ save_memory: "save_memory";
21
+ search_memories: "search_memories";
22
+ update_memory: "update_memory";
23
+ write: "write";
24
+ write_todos: "write_todos";
25
+ }>;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ type: z.ZodLiteral<"mcp">;
28
+ connectionId: z.ZodString;
29
+ name: z.ZodString;
30
+ }, z.core.$strict>], "type">;
31
+ export declare const approvalPolicySchema: z.ZodObject<{
32
+ default: z.ZodEnum<{
33
+ auto: "auto";
34
+ deny: "deny";
35
+ full: "full";
36
+ manual: "manual";
37
+ }>;
38
+ overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
39
+ tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
40
+ type: z.ZodLiteral<"builtin">;
41
+ name: z.ZodEnum<{
42
+ activate_skill: "activate_skill";
43
+ bash: "bash";
44
+ delete_memory: "delete_memory";
45
+ edit: "edit";
46
+ get_memory: "get_memory";
47
+ glob: "glob";
48
+ grep: "grep";
49
+ publish_artifacts: "publish_artifacts";
50
+ read: "read";
51
+ save_memory: "save_memory";
52
+ search_memories: "search_memories";
53
+ update_memory: "update_memory";
54
+ write: "write";
55
+ write_todos: "write_todos";
56
+ }>;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ type: z.ZodLiteral<"mcp">;
59
+ connectionId: z.ZodString;
60
+ name: z.ZodString;
61
+ }, z.core.$strict>], "type">;
62
+ decision: z.ZodEnum<{
63
+ auto: "auto";
64
+ deny: "deny";
65
+ full: "full";
66
+ manual: "manual";
67
+ }>;
68
+ }, z.core.$strict>>>;
69
+ }, z.core.$strict>;
70
+ export type ApprovalPolicy = z.infer<typeof approvalPolicySchema>;
71
+ export type ToolReference = z.infer<typeof toolReferenceSchema>;
72
+ export type ApprovalDecision = z.infer<typeof approvalDecisionSchema>;
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ import { mcpConnectionIdSchema } from "../ids.js";
3
+ import { AGENT_TOOL_CATALOG } from "./agent-tools.js";
4
+ export const approvalDecisionSchema = z.enum([
5
+ "full",
6
+ "deny",
7
+ "manual",
8
+ "auto",
9
+ ]);
10
+ export const toolReferenceSchema = z.discriminatedUnion("type", [
11
+ z
12
+ .object({
13
+ type: z.literal("builtin"),
14
+ name: z.enum([
15
+ ...AGENT_TOOL_CATALOG.flatMap((group) => group.tools),
16
+ "activate_skill",
17
+ ]),
18
+ })
19
+ .strict(),
20
+ z
21
+ .object({
22
+ type: z.literal("mcp"),
23
+ connectionId: mcpConnectionIdSchema,
24
+ name: z.string().min(1),
25
+ })
26
+ .strict(),
27
+ ]);
28
+ export const approvalPolicySchema = z
29
+ .object({
30
+ default: approvalDecisionSchema,
31
+ overrides: z
32
+ .array(z
33
+ .object({
34
+ tool: toolReferenceSchema,
35
+ decision: approvalDecisionSchema,
36
+ })
37
+ .strict())
38
+ .default([]),
39
+ })
40
+ .strict()
41
+ .superRefine((policy, ctx) => {
42
+ const seen = new Set();
43
+ for (const [index, rule] of policy.overrides.entries()) {
44
+ const key = JSON.stringify(rule.tool);
45
+ if (seen.has(key)) {
46
+ ctx.addIssue({
47
+ code: "custom",
48
+ message: "Tool overrides must be unique within each policy.",
49
+ path: ["overrides", index, "tool"],
50
+ });
51
+ }
52
+ seen.add(key);
53
+ }
54
+ });