@blazingagents/sdk 0.55.1 → 0.56.1

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.
@@ -388,7 +388,6 @@ export declare const agentConfigSchema: z.ZodObject<{
388
388
  write_todos: "write_todos";
389
389
  }>>;
390
390
  instructions: z.ZodString;
391
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
392
391
  mcpConnectionIds: z.ZodArray<z.ZodString>;
393
392
  }, z.core.$strip>;
394
393
  export declare const createAgentBodySchema: z.ZodObject<{
@@ -123,7 +123,6 @@ export const agentConfigSchema = z
123
123
  memoryInjectionEnabled: agentResponseSchema.shape.memoryInjectionEnabled,
124
124
  tools: agentResponseSchema.shape.tools,
125
125
  instructions: agentResponseSchema.shape.instructions,
126
- metadata: agentResponseSchema.shape.metadata,
127
126
  mcpConnectionIds: agentResponseSchema.shape.mcpConnectionIds,
128
127
  })
129
128
  .strip()
@@ -150,7 +149,7 @@ const agentFieldDescriptions = {
150
149
  tools: "Built-in tools the agent can use. Each tool is enabled individually and is off until listed. File tools such as `read` and `bash` run in the attached workspace.",
151
150
  instructions: "Instructions the agent follows on every turn.",
152
151
  userId: "Your end user's ID, used for attribution. An empty string means a tenant-level agent. It cannot change after creation.",
153
- metadata: "Your own key-value data, returned unchanged.",
152
+ metadata: "Your own key-value data, returned unchanged. At most 128 KiB as JSON.",
154
153
  mcpConnectionIds: "IDs of the MCP connections attached to the agent.",
155
154
  };
156
155
  export const createAgentBodySchema = z
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { MAX_METADATA_BYTES } from "../limitations.js";
2
3
  /**
3
4
  * End-user attribution — the uniform ownership dimension on every
4
5
  * tenant-owned product resource (ADR-0001). `userId` is an opaque
@@ -11,7 +12,10 @@ import { z } from "zod";
11
12
  * sessions, tasks, task runs, artifacts, and usage rows.
12
13
  */
13
14
  export const userIdSchema = z.string();
14
- export const metadataSchema = z.record(z.string(), z.unknown());
15
+ export const metadataSchema = z
16
+ .record(z.string(), z.unknown())
17
+ .refine((metadata) => new TextEncoder().encode(JSON.stringify(metadata)).length <=
18
+ MAX_METADATA_BYTES, { message: "Metadata must be at most 128 KiB as JSON." });
15
19
  /**
16
20
  * The create-body shape for an attributed resource: both fields optional
17
21
  * with tenant-level defaults (`userId: ''`, `metadata: {}`). `userId` is
@@ -256,7 +256,7 @@ export const chatRequestBodySchema = z
256
256
  .describe("Your end user's ID. Starting a session records it on the session, and every turn in that session keeps the session's end user."),
257
257
  metadata: metadataSchema
258
258
  .optional()
259
- .describe("Your own key-value data. Recorded on a new session and on the turn's usage. An omitted value records the session's metadata on the turn's usage."),
259
+ .describe("Your own key-value data. Recorded on a new session and on the turn's usage. An omitted value records the session's metadata on the turn's usage. At most 128 KiB as JSON."),
260
260
  /**
261
261
  * `chatFunctionDefinitionsSchema` validates the value; `z.custom` is opaque
262
262
  * to the OpenAPI generator, so `meta` declares the wire shape.
@@ -327,7 +327,7 @@ export const generationRequestBodySchema = z
327
327
  .describe("Your end user's ID, used for usage attribution."),
328
328
  metadata: metadataSchema
329
329
  .default({})
330
- .describe("Your own key-value data, recorded with the usage."),
330
+ .describe("Your own key-value data, recorded with the usage. At most 128 KiB as JSON."),
331
331
  })
332
332
  .strict()
333
333
  .refine((body) => body.prompt === undefined
@@ -70,7 +70,7 @@ const promptFieldDescriptions = {
70
70
  name: "Display name, 1 to 80 characters.",
71
71
  template: "Message template, up to 10,240 characters. Mark each variable as `{{name}}`; names match `[A-Za-z_][A-Za-z0-9_]*`, and a template can use up to 10 of them.",
72
72
  agentId: "ID of an agent in your tenant to link the prompt to, or `null` for no link. Deleting the agent also deletes its linked prompts.",
73
- metadata: "Your own key-value data, returned unchanged.",
73
+ metadata: "Your own key-value data, returned unchanged. At most 128 KiB as JSON.",
74
74
  };
75
75
  export const promptsListQuerySchema = z
76
76
  .object({
@@ -145,7 +145,6 @@ export declare const sessionResponseSchema: z.ZodObject<{
145
145
  write_todos: "write_todos";
146
146
  }>>;
147
147
  instructions: z.ZodString;
148
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
149
148
  mcpConnectionIds: z.ZodArray<z.ZodString>;
150
149
  }, z.core.$strip>;
151
150
  forkedFrom: z.ZodNullable<z.ZodObject<{
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { calendarDateSchema } from "../utils.js";
2
3
  export const spendingLimitResetIntervalSchema = z.enum([
3
4
  "daily",
4
5
  "weekly",
@@ -8,7 +9,7 @@ export const spendingLimitResetIntervalSchema = z.enum([
8
9
  export const spendingLimitSchema = z
9
10
  .object({
10
11
  amountUsd: z.number().positive().max(1_000_000_000).multipleOf(0.000_001),
11
- resetStartDate: z.iso.date(),
12
+ resetStartDate: calendarDateSchema,
12
13
  resetInterval: spendingLimitResetIntervalSchema,
13
14
  })
14
15
  .strict()
@@ -371,7 +371,6 @@ export declare const taskRunResponseSchema: z.ZodObject<{
371
371
  write_todos: "write_todos";
372
372
  }>>;
373
373
  instructions: z.ZodString;
374
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
375
374
  mcpConnectionIds: z.ZodArray<z.ZodString>;
376
375
  }, z.core.$strip>;
377
376
  sessionId: z.ZodNullable<z.ZodString>;
@@ -510,7 +509,6 @@ export declare const taskRunsListResponseSchema: z.ZodObject<{
510
509
  write_todos: "write_todos";
511
510
  }>>;
512
511
  instructions: z.ZodString;
513
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
514
512
  mcpConnectionIds: z.ZodArray<z.ZodString>;
515
513
  }, z.core.$strip>;
516
514
  sessionId: z.ZodNullable<z.ZodString>;
@@ -101,7 +101,7 @@ const taskFieldDescriptions = {
101
101
  enabled: "Whether the schedule fires. A disabled task can still be started on demand.",
102
102
  submit: "Start a run as soon as the task is created.",
103
103
  userId: "Your end user's ID, used for attribution. An empty string means a tenant-level task. It cannot change after creation.",
104
- metadata: "Your own key-value data, returned unchanged and copied to each run.",
104
+ metadata: "Your own key-value data, returned unchanged and copied to each run. At most 128 KiB as JSON.",
105
105
  };
106
106
  export const createTaskBodySchema = z
107
107
  .object({
@@ -138,7 +138,7 @@ export const updateTaskBodySchema = z
138
138
  enabled: z.boolean().optional().describe(taskFieldDescriptions.enabled),
139
139
  metadata: metadataSchema
140
140
  .optional()
141
- .describe("Your own key-value data. Replaces the current metadata."),
141
+ .describe("Your own key-value data. Replaces the current metadata. At most 128 KiB as JSON."),
142
142
  })
143
143
  .strict()
144
144
  .refine(hasObjectKeys, {
@@ -1,7 +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, MAX_USAGE_OVERVIEW_TOP_N, MAX_USAGE_RANGE_DAYS, } from "../limitations.js";
4
- import { hasUniqueValues } from "../utils.js";
4
+ import { calendarDateSchema, hasUniqueValues } from "../utils.js";
5
5
  import { userIdSchema } from "./attribution.js";
6
6
  /**
7
7
  * Adds a validation issue when the usage date range is invalid.
@@ -35,12 +35,10 @@ function validateUsageRange(value, ctx) {
35
35
  }
36
36
  }
37
37
  const usageRangeFields = {
38
- from: z.iso
39
- .date()
38
+ from: calendarDateSchema
40
39
  .optional()
41
40
  .describe("First UTC day to include, as `YYYY-MM-DD`. Send it with `to`, or leave both out for the last 30 days ending today."),
42
- to: z.iso
43
- .date()
41
+ to: calendarDateSchema
44
42
  .optional()
45
43
  .describe(`Last UTC day to include, as \`YYYY-MM-DD\`. It must not be before \`from\` and can be at most ${MAX_USAGE_RANGE_DAYS} days after it.`),
46
44
  };
@@ -52,7 +52,7 @@ export const createWorkspaceBodySchema = z
52
52
  .describe('Your own ID for the end user who owns the workspace. `""` means a tenant-level workspace. It cannot be changed later.'),
53
53
  metadata: metadataSchema
54
54
  .default({})
55
- .describe("Your own key-value data, returned as sent."),
55
+ .describe("Your own key-value data, returned as sent. At most 128 KiB as JSON."),
56
56
  networkPolicy: workspaceNetworkPolicySchema
57
57
  .default({ mode: "unrestricted" })
58
58
  .describe(networkPolicyDescription),
@@ -66,7 +66,7 @@ export const updateWorkspaceBodySchema = z
66
66
  .describe(`New display name, up to ${MAX_WORKSPACE_NAME_LENGTH} characters, or \`null\` to clear it.`),
67
67
  metadata: metadataSchema
68
68
  .optional()
69
- .describe("Replaces the workspace's metadata."),
69
+ .describe("Replaces the workspace's metadata. At most 128 KiB as JSON."),
70
70
  networkPolicy: workspaceNetworkPolicySchema
71
71
  .optional()
72
72
  .describe(`Replaces the network policy. ${networkPolicyDescription}`),
@@ -35,3 +35,4 @@ export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuery
35
35
  export type { WorkspaceTier } from "./entities/workspaces.ts";
36
36
  export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceNetworkPolicySchema, workspaceSchema, workspacesListResponseSchema, workspaceTierSchema, } from "./entities/workspaces.ts";
37
37
  export { agentIdSchema, apiKeyTokenSchema, functionCallIdSchema, isAdminAgentId, merchantUsageEventIdSchema, promptIdSchema, sessionIdSchema, } from "./ids.ts";
38
+ export { calendarDateSchema } from "./utils.ts";
@@ -23,3 +23,4 @@ export { tenantDeletionSchema, tenantSettingsResponseSchema, updateTenantSetting
23
23
  export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.js";
24
24
  export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceNetworkPolicySchema, workspaceSchema, workspacesListResponseSchema, workspaceTierSchema, } from "./entities/workspaces.js";
25
25
  export { agentIdSchema, apiKeyTokenSchema, functionCallIdSchema, isAdminAgentId, merchantUsageEventIdSchema, promptIdSchema, sessionIdSchema, } from "./ids.js";
26
+ export { calendarDateSchema } from "./utils.js";
@@ -39,6 +39,8 @@ export declare const MAX_MCP_ATTACHMENT_METADATA_KEY_LENGTH = 64;
39
39
  /** Agents — name ≤ 80, instructions ≤ 3000. */
40
40
  export declare const MAX_AGENT_NAME_LENGTH = 80;
41
41
  export declare const MAX_AGENT_INSTRUCTIONS_LENGTH = 3000;
42
+ /** Metadata — 128 KiB of compact JSON on every resource that takes it. */
43
+ export declare const MAX_METADATA_BYTES: number;
42
44
  /** Artifacts — 10 MiB per file. */
43
45
  export declare const MAX_ARTIFACT_BYTES: number;
44
46
  /** Memories — 10 KiB of text per memory. */
@@ -39,6 +39,8 @@ export const MAX_MCP_ATTACHMENT_METADATA_KEY_LENGTH = 64;
39
39
  /** Agents — name ≤ 80, instructions ≤ 3000. */
40
40
  export const MAX_AGENT_NAME_LENGTH = 80;
41
41
  export const MAX_AGENT_INSTRUCTIONS_LENGTH = 3000;
42
+ /** Metadata — 128 KiB of compact JSON on every resource that takes it. */
43
+ export const MAX_METADATA_BYTES = 128 * 1024;
42
44
  /** Artifacts — 10 MiB per file. */
43
45
  export const MAX_ARTIFACT_BYTES = 10 * 1024 * 1024;
44
46
  /** Memories — 10 KiB of text per memory. */
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  export declare const atLeastOneFieldMessage = "At least one field must be provided.";
2
3
  /**
3
4
  * Checks whether the object has at least one own enumerable key.
@@ -11,3 +12,9 @@ export declare function hasObjectKeys(value: object): boolean;
11
12
  * @returns Whether no string occurs more than once.
12
13
  */
13
14
  export declare function hasUniqueValues(values: string[]): boolean;
15
+ /**
16
+ * A `YYYY-MM-DD` date that PostgreSQL's `date` holds. `z.iso.date()` accepts
17
+ * `0000-01-01`, but PostgreSQL has no year 0 and refuses the cast, so a route
18
+ * that passes the date on would answer 500 instead of `validation_failed`.
19
+ */
20
+ export declare const calendarDateSchema: z.ZodISODate;
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  export const atLeastOneFieldMessage = "At least one field must be provided.";
2
3
  /**
3
4
  * Checks whether the object has at least one own enumerable key.
@@ -15,3 +16,13 @@ export function hasObjectKeys(value) {
15
16
  export function hasUniqueValues(values) {
16
17
  return new Set(values).size === values.length;
17
18
  }
19
+ /**
20
+ * A `YYYY-MM-DD` date that PostgreSQL's `date` holds. `z.iso.date()` accepts
21
+ * `0000-01-01`, but PostgreSQL has no year 0 and refuses the cast, so a route
22
+ * that passes the date on would answer 500 instead of `validation_failed`.
23
+ */
24
+ export const calendarDateSchema = z.iso
25
+ .date()
26
+ .refine((date) => !date.startsWith("0000-"), {
27
+ message: "Year 0000 does not exist.",
28
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazingagents/sdk",
3
- "version": "0.55.1",
3
+ "version": "0.56.1",
4
4
  "description": "TypeScript SDK for the Blazing Agents API",
5
5
  "homepage": "https://docs.blazingagents.com",
6
6
  "bugs": {