@blazingagents/sdk 0.15.0 → 0.17.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.
Files changed (43) hide show
  1. package/dist/approvals.d.ts +15 -0
  2. package/dist/approvals.js +20 -0
  3. package/dist/chat-transport.js +9 -2
  4. package/dist/client.d.ts +6 -1
  5. package/dist/client.js +9 -1
  6. package/dist/contracts/api.d.ts +3 -3
  7. package/dist/contracts/api.js +1 -1
  8. package/dist/contracts/entities/agent-approval.d.ts +32 -0
  9. package/dist/contracts/entities/agent-approval.js +12 -1
  10. package/dist/contracts/entities/agent-tools.d.ts +6 -0
  11. package/dist/contracts/entities/agent-tools.js +13 -0
  12. package/dist/contracts/entities/agents.d.ts +2 -118
  13. package/dist/contracts/entities/agents.js +2 -24
  14. package/dist/contracts/entities/chat.d.ts +95 -24
  15. package/dist/contracts/entities/chat.js +105 -39
  16. package/dist/contracts/entities/providers.d.ts +2 -6
  17. package/dist/contracts/entities/providers.js +2 -9
  18. package/dist/contracts/entities/sessions.d.ts +112 -5
  19. package/dist/contracts/entities/sessions.js +7 -5
  20. package/dist/contracts/entities/tasks.d.ts +285 -10
  21. package/dist/contracts/entities/tasks.js +2 -5
  22. package/dist/contracts/ids.d.ts +1 -0
  23. package/dist/contracts/ids.js +1 -0
  24. package/dist/contracts/index.d.ts +8 -7
  25. package/dist/contracts/index.js +6 -5
  26. package/dist/contracts/limitations.d.ts +0 -2
  27. package/dist/contracts/limitations.js +0 -2
  28. package/dist/direct-chat-transport.d.ts +3 -1
  29. package/dist/direct-chat-transport.js +20 -23
  30. package/dist/functions.d.ts +38 -0
  31. package/dist/functions.js +299 -0
  32. package/dist/generation.d.ts +7 -1
  33. package/dist/generation.js +64 -20
  34. package/dist/index.d.ts +7 -4
  35. package/dist/index.js +3 -0
  36. package/dist/relay.d.ts +11 -5
  37. package/dist/relay.js +41 -3
  38. package/dist/resources/agents.js +1 -33
  39. package/dist/resources/providers.js +1 -1
  40. package/dist/resources/sessions.d.ts +1 -1
  41. package/dist/resources/sessions.js +9 -4
  42. package/dist/types.d.ts +22 -23
  43. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import { type UIMessage } from "ai";
2
+ import type { BlazingAgents } from "./client.ts";
3
+ interface ApprovalTarget {
4
+ abortSignal?: AbortSignal;
5
+ agentId: string;
6
+ sessionId: string;
7
+ }
8
+ /**
9
+ * Records each approval response in the assistant message's last step and
10
+ * returns the continuation they decide, or `undefined` when there are none.
11
+ */
12
+ export declare function decideApprovalResponses(client: Pick<BlazingAgents, "sessions">, { message, ...target }: ApprovalTarget & {
13
+ message: UIMessage;
14
+ }): Promise<string | undefined>;
15
+ export {};
@@ -0,0 +1,20 @@
1
+ import { isToolUIPart } from "ai";
2
+ /**
3
+ * Records each approval response in the assistant message's last step and
4
+ * returns the continuation they decide, or `undefined` when there are none.
5
+ */
6
+ export async function decideApprovalResponses(client, { message, ...target }) {
7
+ const lastStep = message.parts.findLastIndex((part) => part.type === "step-start");
8
+ let continuationId;
9
+ for (const part of message.parts.slice(lastStep + 1)) {
10
+ if (isToolUIPart(part) && part.state === "approval-responded") {
11
+ ({ continuationId } = await client.sessions.decideToolApproval({
12
+ ...target,
13
+ approvalId: part.approval.id,
14
+ approved: part.approval.approved,
15
+ reason: part.approval.reason,
16
+ }));
17
+ }
18
+ }
19
+ return continuationId;
20
+ }
@@ -1,4 +1,4 @@
1
- import { DefaultChatTransport, } from "ai";
1
+ import { DefaultChatTransport, lastAssistantMessageIsCompleteWithApprovalResponses, } from "ai";
2
2
  import { sessionIdSchema } from "./contracts/ids.js";
3
3
  /**
4
4
  * Adapts AI SDK chat requests to the Blazing Agents backend-relay shape and
@@ -31,7 +31,14 @@ export class BlazingAgentsChatTransport {
31
31
  return response;
32
32
  },
33
33
  prepareSendMessagesRequest: ({ body, messageId, messages, trigger }) => {
34
- const message = messages.findLast((candidate) => candidate.role === "user");
34
+ const approvals = messages.at(-1)?.role === "assistant" &&
35
+ lastAssistantMessageIsCompleteWithApprovalResponses({ messages });
36
+ if (approvals && this.#sessionId === undefined) {
37
+ throw new Error("Tool approval requires an existing Session.");
38
+ }
39
+ const message = approvals
40
+ ? messages.at(-1)
41
+ : messages.findLast((candidate) => candidate.role === "user");
35
42
  if (!message) {
36
43
  throw new Error("Chat submission requires a user message.");
37
44
  }
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, UserClient, 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, ResumeChatInput, 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;
@@ -29,6 +29,11 @@ export declare class BlazingAgents {
29
29
  * session id and a byte-compatible SSE relay for `useChat`.
30
30
  */
31
31
  chat(input: ChatInput): Promise<ChatResult>;
32
+ /**
33
+ * Reattaches function handlers after human tool approval and starts or
34
+ * joins the Session's continuation. Returns the continuation SSE relay.
35
+ */
36
+ resumeChat(input: ResumeChatInput): Promise<ChatResult>;
32
37
  /**
33
38
  * `POST /v1/agents/:agentId/generation` — stateless one-shot text
34
39
  * stream. Returns `textStream` + `await result.text` + `toResponse()`.
package/dist/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { chat, completion, objectGeneration } from "./generation.js";
2
+ import { chat, completion, objectGeneration, resumeChat, } from "./generation.js";
3
3
  import { createAgentsResource } from "./resources/agents.js";
4
4
  import { createArtifactsResource } from "./resources/artifacts.js";
5
5
  import { createChatConnectionsResource } from "./resources/chat-connections.js";
@@ -40,6 +40,7 @@ function createUserClient(config) {
40
40
  chat: (input) => chat(config, input),
41
41
  completion: (input) => completion(config, input),
42
42
  object: (input) => objectGeneration(config, input),
43
+ resumeChat: (input) => resumeChat(config, input),
43
44
  withOptions: (options) => createUserClient({ ...config, clientRequestId: options.clientRequestId }),
44
45
  };
45
46
  }
@@ -106,6 +107,13 @@ export class BlazingAgents {
106
107
  chat(input) {
107
108
  return chat(this.config, input);
108
109
  }
110
+ /**
111
+ * Reattaches function handlers after human tool approval and starts or
112
+ * joins the Session's continuation. Returns the continuation SSE relay.
113
+ */
114
+ resumeChat(input) {
115
+ return resumeChat(this.config, input);
116
+ }
109
117
  /**
110
118
  * `POST /v1/agents/:agentId/generation` — stateless one-shot text
111
119
  * stream. Returns `textStream` + `await result.text` + `toResponse()`.
@@ -23,13 +23,13 @@ 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_version_not_found: "agent_version_not_found";
27
26
  api_key_limit_reached: "api_key_limit_reached";
28
27
  artifact_session_cap_reached: "artifact_session_cap_reached";
29
28
  chat_webhook_conflict: "chat_webhook_conflict";
30
29
  chat_webhook_registration_failed: "chat_webhook_registration_failed";
31
30
  checkout_evidence_mismatch: "checkout_evidence_mismatch";
32
31
  forbidden: "forbidden";
32
+ function_call_conflict: "function_call_conflict";
33
33
  idempotency_conflict: "idempotency_conflict";
34
34
  internal: "internal";
35
35
  invalid_cursor: "invalid_cursor";
@@ -101,13 +101,13 @@ export declare const apiErrorSchema: z.ZodObject<{
101
101
  agent_disabled: "agent_disabled";
102
102
  agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
103
103
  agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
104
- agent_version_not_found: "agent_version_not_found";
105
104
  api_key_limit_reached: "api_key_limit_reached";
106
105
  artifact_session_cap_reached: "artifact_session_cap_reached";
107
106
  chat_webhook_conflict: "chat_webhook_conflict";
108
107
  chat_webhook_registration_failed: "chat_webhook_registration_failed";
109
108
  checkout_evidence_mismatch: "checkout_evidence_mismatch";
110
109
  forbidden: "forbidden";
110
+ function_call_conflict: "function_call_conflict";
111
111
  idempotency_conflict: "idempotency_conflict";
112
112
  internal: "internal";
113
113
  invalid_cursor: "invalid_cursor";
@@ -184,13 +184,13 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
184
184
  agent_disabled: "agent_disabled";
185
185
  agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
186
186
  agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
187
- agent_version_not_found: "agent_version_not_found";
188
187
  api_key_limit_reached: "api_key_limit_reached";
189
188
  artifact_session_cap_reached: "artifact_session_cap_reached";
190
189
  chat_webhook_conflict: "chat_webhook_conflict";
191
190
  chat_webhook_registration_failed: "chat_webhook_registration_failed";
192
191
  checkout_evidence_mismatch: "checkout_evidence_mismatch";
193
192
  forbidden: "forbidden";
193
+ function_call_conflict: "function_call_conflict";
194
194
  idempotency_conflict: "idempotency_conflict";
195
195
  internal: "internal";
196
196
  invalid_cursor: "invalid_cursor";
@@ -32,7 +32,6 @@ export const apiErrorCodeSchema = z.enum([
32
32
  "checkout_evidence_mismatch",
33
33
  "agent_disabled",
34
34
  "admin_agent_managed",
35
- "agent_version_not_found",
36
35
  "agent_mcp_connection_not_found",
37
36
  "agent_mcp_connections_invalid",
38
37
  "provider_required",
@@ -65,6 +64,7 @@ export const apiErrorCodeSchema = z.enum([
65
64
  "session_version_mismatch",
66
65
  "tool_approval_continuation_not_found",
67
66
  "tool_approval_decision_conflict",
67
+ "function_call_conflict",
68
68
  "skill_invalid_archive",
69
69
  "skill_invalid_markdown",
70
70
  "skill_limit_reached",
@@ -28,6 +28,37 @@ export declare const toolReferenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
28
28
  connectionId: z.ZodString;
29
29
  name: z.ZodString;
30
30
  }, z.core.$strict>], "type">;
31
+ /**
32
+ * Identifies the tool behind one execution or approval record. Caller-local
33
+ * functions appear here for display and audit only; approval policies keep
34
+ * `toolReferenceSchema`, so function names never become Agent configuration.
35
+ */
36
+ export declare const toolExecutionReferenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
37
+ type: z.ZodLiteral<"builtin">;
38
+ name: z.ZodEnum<{
39
+ activate_skill: "activate_skill";
40
+ bash: "bash";
41
+ delete_memory: "delete_memory";
42
+ edit: "edit";
43
+ get_memory: "get_memory";
44
+ glob: "glob";
45
+ grep: "grep";
46
+ publish_artifacts: "publish_artifacts";
47
+ read: "read";
48
+ save_memory: "save_memory";
49
+ search_memories: "search_memories";
50
+ update_memory: "update_memory";
51
+ write: "write";
52
+ write_todos: "write_todos";
53
+ }>;
54
+ }, z.core.$strict>, z.ZodObject<{
55
+ type: z.ZodLiteral<"mcp">;
56
+ connectionId: z.ZodString;
57
+ name: z.ZodString;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ type: z.ZodLiteral<"function">;
60
+ name: z.ZodString;
61
+ }, z.core.$strict>], "type">;
31
62
  export declare const approvalPolicySchema: z.ZodObject<{
32
63
  default: z.ZodEnum<{
33
64
  auto: "auto";
@@ -69,4 +100,5 @@ export declare const approvalPolicySchema: z.ZodObject<{
69
100
  }, z.core.$strict>;
70
101
  export type ApprovalPolicy = z.infer<typeof approvalPolicySchema>;
71
102
  export type ToolReference = z.infer<typeof toolReferenceSchema>;
103
+ export type ToolExecutionReference = z.infer<typeof toolExecutionReferenceSchema>;
72
104
  export type ApprovalDecision = z.infer<typeof approvalDecisionSchema>;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { mcpConnectionIdSchema } from "../ids.js";
3
- import { AGENT_TOOL_CATALOG } from "./agent-tools.js";
3
+ import { AGENT_TOOL_CATALOG, chatFunctionNameSchema } from "./agent-tools.js";
4
4
  export const approvalDecisionSchema = z.enum([
5
5
  "full",
6
6
  "deny",
@@ -25,6 +25,17 @@ export const toolReferenceSchema = z.discriminatedUnion("type", [
25
25
  })
26
26
  .strict(),
27
27
  ]);
28
+ /**
29
+ * Identifies the tool behind one execution or approval record. Caller-local
30
+ * functions appear here for display and audit only; approval policies keep
31
+ * `toolReferenceSchema`, so function names never become Agent configuration.
32
+ */
33
+ export const toolExecutionReferenceSchema = z.discriminatedUnion("type", [
34
+ ...toolReferenceSchema.options,
35
+ z
36
+ .object({ type: z.literal("function"), name: chatFunctionNameSchema })
37
+ .strict(),
38
+ ]);
28
39
  export const approvalPolicySchema = z
29
40
  .object({
30
41
  default: approvalDecisionSchema,
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  /** Tool groups an Agent can attach. File operations use its durable Workspace. */
2
3
  export declare const agentToolGroupIds: readonly ["workspace", "write_todos", "memory"];
3
4
  export type AgentToolGroupId = (typeof agentToolGroupIds)[number];
@@ -24,3 +25,8 @@ export declare const AGENT_TOOL_CATALOG: readonly [{
24
25
  readonly tools: readonly ["save_memory", "get_memory", "search_memories", "update_memory", "delete_memory"];
25
26
  }];
26
27
  export declare function expandToolGroups(ids: Iterable<string>): Set<string>;
28
+ /**
29
+ * A model-facing tool name. Built-in tool names and the `mcp__` prefix used
30
+ * for MCP tools are reserved so a caller function never shadows them.
31
+ */
32
+ export declare const chatFunctionNameSchema: z.ZodString;
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  /** Tool groups an Agent can attach. File operations use its durable Workspace. */
2
3
  export const agentToolGroupIds = [
3
4
  "workspace",
@@ -50,3 +51,15 @@ export function expandToolGroups(ids) {
50
51
  }
51
52
  return result;
52
53
  }
54
+ const RESERVED_CHAT_FUNCTION_NAMES = new Set([
55
+ ...AGENT_TOOL_CATALOG.flatMap((group) => group.tools),
56
+ "activate_skill",
57
+ ]);
58
+ /**
59
+ * A model-facing tool name. Built-in tool names and the `mcp__` prefix used
60
+ * for MCP tools are reserved so a caller function never shadows them.
61
+ */
62
+ export const chatFunctionNameSchema = z
63
+ .string()
64
+ .regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/)
65
+ .refine((name) => !(RESERVED_CHAT_FUNCTION_NAMES.has(name) || name.startsWith("mcp__")), { message: "Function name is reserved for a built-in or MCP tool." });
@@ -8,7 +8,6 @@ export declare const agentToolsSchema: z.ZodArray<z.ZodEnum<{
8
8
  write_todos: "write_todos";
9
9
  }>>;
10
10
  export declare const agentMcpConnectionIdsSchema: z.ZodArray<z.ZodString>;
11
- export declare const agentVersionNumberSchema: z.ZodNumber;
12
11
  export declare const agentStatusSchema: z.ZodEnum<{
13
12
  active: "active";
14
13
  disabled: "disabled";
@@ -114,7 +113,6 @@ export declare const agentSchema: z.ZodObject<{
114
113
  avatarUrl: z.ZodNullable<z.ZodURL>;
115
114
  createdAt: z.ZodISODateTime;
116
115
  updatedAt: z.ZodISODateTime;
117
- version: z.ZodNumber;
118
116
  status: z.ZodEnum<{
119
117
  active: "active";
120
118
  disabled: "disabled";
@@ -222,7 +220,6 @@ export declare const agentsResponseSchema: z.ZodObject<{
222
220
  avatarUrl: z.ZodNullable<z.ZodURL>;
223
221
  createdAt: z.ZodISODateTime;
224
222
  updatedAt: z.ZodISODateTime;
225
- version: z.ZodNumber;
226
223
  status: z.ZodEnum<{
227
224
  active: "active";
228
225
  disabled: "disabled";
@@ -331,7 +328,6 @@ export declare const agentResponseSchema: z.ZodObject<{
331
328
  avatarUrl: z.ZodNullable<z.ZodURL>;
332
329
  createdAt: z.ZodISODateTime;
333
330
  updatedAt: z.ZodISODateTime;
334
- version: z.ZodNumber;
335
331
  status: z.ZodEnum<{
336
332
  active: "active";
337
333
  disabled: "disabled";
@@ -343,7 +339,7 @@ export declare const agentsListQuerySchema: z.ZodObject<{
343
339
  userId: z.ZodOptional<z.ZodString>;
344
340
  workspaceId: z.ZodOptional<z.ZodString>;
345
341
  }, z.core.$strict>;
346
- export declare const agentVersionSchema: z.ZodObject<{
342
+ export declare const agentConfigSchema: z.ZodObject<{
347
343
  approvalInChat: z.ZodDefault<z.ZodObject<{
348
344
  default: z.ZodEnum<{
349
345
  auto: "auto";
@@ -422,9 +418,6 @@ export declare const agentVersionSchema: z.ZodObject<{
422
418
  }>;
423
419
  }, z.core.$strict>>>;
424
420
  }, z.core.$strict>>;
425
- agentId: z.ZodString;
426
- tenantId: z.ZodString;
427
- version: z.ZodNumber;
428
421
  name: z.ZodString;
429
422
  model: z.ZodNullable<z.ZodString>;
430
423
  thinkingLevel: z.ZodNullable<z.ZodString>;
@@ -440,113 +433,6 @@ export declare const agentVersionSchema: z.ZodObject<{
440
433
  instructions: z.ZodString;
441
434
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
442
435
  mcpConnectionIds: z.ZodArray<z.ZodString>;
443
- createdAt: z.ZodISODateTime;
444
- }, z.core.$strip>;
445
- export declare const agentVersionsListQuerySchema: z.ZodObject<{
446
- cursor: z.ZodOptional<z.ZodString>;
447
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
448
- }, z.core.$strict>;
449
- export declare const agentVersionsResponseSchema: z.ZodObject<{
450
- data: z.ZodArray<z.ZodObject<{
451
- approvalInChat: z.ZodDefault<z.ZodObject<{
452
- default: z.ZodEnum<{
453
- auto: "auto";
454
- deny: "deny";
455
- full: "full";
456
- manual: "manual";
457
- }>;
458
- overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
459
- tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
460
- type: z.ZodLiteral<"builtin">;
461
- name: z.ZodEnum<{
462
- activate_skill: "activate_skill";
463
- bash: "bash";
464
- delete_memory: "delete_memory";
465
- edit: "edit";
466
- get_memory: "get_memory";
467
- glob: "glob";
468
- grep: "grep";
469
- publish_artifacts: "publish_artifacts";
470
- read: "read";
471
- save_memory: "save_memory";
472
- search_memories: "search_memories";
473
- update_memory: "update_memory";
474
- write: "write";
475
- write_todos: "write_todos";
476
- }>;
477
- }, z.core.$strict>, z.ZodObject<{
478
- type: z.ZodLiteral<"mcp">;
479
- connectionId: z.ZodString;
480
- name: z.ZodString;
481
- }, z.core.$strict>], "type">;
482
- decision: z.ZodEnum<{
483
- auto: "auto";
484
- deny: "deny";
485
- full: "full";
486
- manual: "manual";
487
- }>;
488
- }, z.core.$strict>>>;
489
- }, z.core.$strict>>;
490
- approvalInTasks: z.ZodDefault<z.ZodObject<{
491
- default: z.ZodEnum<{
492
- auto: "auto";
493
- deny: "deny";
494
- full: "full";
495
- manual: "manual";
496
- }>;
497
- overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
498
- tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
499
- type: z.ZodLiteral<"builtin">;
500
- name: z.ZodEnum<{
501
- activate_skill: "activate_skill";
502
- bash: "bash";
503
- delete_memory: "delete_memory";
504
- edit: "edit";
505
- get_memory: "get_memory";
506
- glob: "glob";
507
- grep: "grep";
508
- publish_artifacts: "publish_artifacts";
509
- read: "read";
510
- save_memory: "save_memory";
511
- search_memories: "search_memories";
512
- update_memory: "update_memory";
513
- write: "write";
514
- write_todos: "write_todos";
515
- }>;
516
- }, z.core.$strict>, z.ZodObject<{
517
- type: z.ZodLiteral<"mcp">;
518
- connectionId: z.ZodString;
519
- name: z.ZodString;
520
- }, z.core.$strict>], "type">;
521
- decision: z.ZodEnum<{
522
- auto: "auto";
523
- deny: "deny";
524
- full: "full";
525
- manual: "manual";
526
- }>;
527
- }, z.core.$strict>>>;
528
- }, z.core.$strict>>;
529
- agentId: z.ZodString;
530
- tenantId: z.ZodString;
531
- version: z.ZodNumber;
532
- name: z.ZodString;
533
- model: z.ZodNullable<z.ZodString>;
534
- thinkingLevel: z.ZodNullable<z.ZodString>;
535
- providerId: z.ZodNullable<z.ZodString>;
536
- autoCompaction: z.ZodBoolean;
537
- compactionReserveTokens: z.ZodNumber;
538
- memoryInjectionEnabled: z.ZodBoolean;
539
- tools: z.ZodArray<z.ZodEnum<{
540
- memory: "memory";
541
- workspace: "workspace";
542
- write_todos: "write_todos";
543
- }>>;
544
- instructions: z.ZodString;
545
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
546
- mcpConnectionIds: z.ZodArray<z.ZodString>;
547
- createdAt: z.ZodISODateTime;
548
- }, z.core.$strip>>;
549
- nextCursor: z.ZodNullable<z.ZodString>;
550
436
  }, z.core.$strip>;
551
437
  export declare const createAgentBodySchema: z.ZodObject<{
552
438
  approvalInChat: z.ZodDefault<z.ZodObject<{
@@ -745,9 +631,7 @@ export type Agent = z.infer<typeof agentSchema>;
745
631
  export type AgentsResponse = z.infer<typeof agentsResponseSchema>;
746
632
  export type AgentResponse = z.infer<typeof agentResponseSchema>;
747
633
  export type AgentsListQuery = z.infer<typeof agentsListQuerySchema>;
748
- export type AgentVersion = z.infer<typeof agentVersionSchema>;
634
+ export type AgentConfig = z.infer<typeof agentConfigSchema>;
749
635
  export type AgentStatus = z.infer<typeof agentStatusSchema>;
750
- export type AgentVersionsListQuery = z.infer<typeof agentVersionsListQuerySchema>;
751
- export type AgentVersionsResponse = z.infer<typeof agentVersionsResponseSchema>;
752
636
  export type CreateAgentBody = z.input<typeof createAgentBodySchema>;
753
637
  export type UpdateAgentBody = z.input<typeof updateAgentBodySchema>;
@@ -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, 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";
4
+ import { DEFAULT_AGENTS_LIST_LIMIT, MAX_AGENT_INSTRUCTIONS_LENGTH, MAX_AGENT_NAME_LENGTH, 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";
@@ -33,11 +33,6 @@ export const agentMcpConnectionIdsSchema = z
33
33
  .refine(hasUniqueValues, {
34
34
  message: "MCP connection ids must be unique.",
35
35
  });
36
- export const agentVersionNumberSchema = z
37
- .number()
38
- .int()
39
- .min(1)
40
- .max(2_147_483_647);
41
36
  export const agentStatusSchema = z.enum(["active", "disabled"]);
42
37
  const providerModelPairMessage = "Provider and model must either both be set or both be null.";
43
38
  function hasProviderModelPair(input) {
@@ -69,7 +64,6 @@ export const agentSchema = z
69
64
  avatarUrl: z.url().nullable(),
70
65
  createdAt: z.iso.datetime({ offset: true }),
71
66
  updatedAt: z.iso.datetime({ offset: true }),
72
- version: agentVersionNumberSchema,
73
67
  status: agentStatusSchema,
74
68
  })
75
69
  .strip()
@@ -92,12 +86,9 @@ export const agentsListQuerySchema = z
92
86
  workspaceId: workspaceIdSchema.optional(),
93
87
  })
94
88
  .strict();
95
- export const agentVersionSchema = z
89
+ export const agentConfigSchema = z
96
90
  .object({
97
91
  ...approvalFields,
98
- agentId: agentIdSchema,
99
- tenantId: tenantIdSchema,
100
- version: agentVersionNumberSchema,
101
92
  name: agentSchema.shape.name,
102
93
  model: agentSchema.shape.model,
103
94
  thinkingLevel: agentSchema.shape.thinkingLevel,
@@ -109,25 +100,12 @@ export const agentVersionSchema = z
109
100
  instructions: agentSchema.shape.instructions,
110
101
  metadata: agentSchema.shape.metadata,
111
102
  mcpConnectionIds: agentSchema.shape.mcpConnectionIds,
112
- createdAt: agentSchema.shape.createdAt,
113
103
  })
114
104
  .strip()
115
105
  .refine(hasProviderModelPair, {
116
106
  message: providerModelPairMessage,
117
107
  path: ["providerId"],
118
108
  });
119
- export const agentVersionsListQuerySchema = z
120
- .object({
121
- cursor: cursorSchema.optional(),
122
- limit: z.coerce
123
- .number()
124
- .int()
125
- .min(1)
126
- .max(MAX_AGENT_VERSIONS_LIST_LIMIT)
127
- .default(DEFAULT_AGENT_VERSIONS_LIST_LIMIT),
128
- })
129
- .strict();
130
- export const agentVersionsResponseSchema = paginatedResponseSchema(agentVersionSchema);
131
109
  export const createAgentBodySchema = z
132
110
  .object({
133
111
  ...approvalFields,