@ingram-cloud/sdk 1.2.0 → 1.5.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 (49) hide show
  1. package/dist/client.js +185 -14
  2. package/dist/index.js +4 -0
  3. package/dist/scopes.js +52 -0
  4. package/dist/zod/_actor.js +33 -0
  5. package/dist/zod/_page.js +18 -4
  6. package/dist/zod/agents.js +17 -3
  7. package/dist/zod/billing.js +136 -0
  8. package/dist/zod/budgets.js +2 -3
  9. package/dist/zod/connections.js +2 -3
  10. package/dist/zod/conversations.js +4 -11
  11. package/dist/zod/deployments.js +32 -0
  12. package/dist/zod/files.js +2 -9
  13. package/dist/zod/index.js +3 -0
  14. package/dist/zod/mcp.js +20 -14
  15. package/dist/zod/observability.js +39 -19
  16. package/dist/zod/projects.js +4 -4
  17. package/dist/zod/runs.js +16 -4
  18. package/dist/zod/schedules.js +2 -7
  19. package/dist/zod/skills.js +73 -0
  20. package/dist/zod/smith-revisions.js +7 -5
  21. package/dist/zod/smiths.js +14 -0
  22. package/dist/zod/tenant.js +41 -4
  23. package/dist/zod/vector-stores.js +36 -23
  24. package/package.json +6 -8
  25. package/ts/client.ts +431 -50
  26. package/ts/index.ts +4 -0
  27. package/ts/responses.ts +40 -2
  28. package/ts/scopes.ts +57 -0
  29. package/ts/zod/.impeccable/hook.cache.json +1 -0
  30. package/ts/zod/_actor.ts +36 -0
  31. package/ts/zod/_page.ts +19 -4
  32. package/ts/zod/agents.ts +17 -3
  33. package/ts/zod/billing.ts +168 -0
  34. package/ts/zod/budgets.ts +2 -3
  35. package/ts/zod/connections.ts +2 -3
  36. package/ts/zod/conversations.ts +7 -11
  37. package/ts/zod/deployments.ts +36 -0
  38. package/ts/zod/files.ts +2 -9
  39. package/ts/zod/index.ts +3 -0
  40. package/ts/zod/mcp.ts +20 -15
  41. package/ts/zod/observability.ts +75 -24
  42. package/ts/zod/projects.ts +4 -4
  43. package/ts/zod/runs.ts +18 -4
  44. package/ts/zod/schedules.ts +2 -7
  45. package/ts/zod/skills.ts +85 -0
  46. package/ts/zod/smith-revisions.ts +7 -5
  47. package/ts/zod/smiths.ts +14 -0
  48. package/ts/zod/tenant.ts +52 -5
  49. package/ts/zod/vector-stores.ts +41 -23
@@ -12,6 +12,7 @@
12
12
  * `#/components/schemas/<id>` rather than inlining it.
13
13
  */
14
14
  import { z } from "zod";
15
+ import { pageOut } from "./_page.js";
15
16
  /** What a budget caps; `agent`/`smith`/`customer` budgets carry the id in
16
17
  * `scope_id` (an agent design, a single smith, or one of your customers). */
17
18
  export const BudgetScope = z.enum(["tenant", "agent", "smith", "customer"]);
@@ -40,9 +41,7 @@ export const BudgetStatusOut = BudgetOut.extend({
40
41
  pct: z.number(),
41
42
  over: z.boolean(),
42
43
  }).meta({ id: "BudgetStatusOut" });
43
- export const BudgetListOut = z
44
- .object({ data: z.array(BudgetOut) })
45
- .meta({ id: "BudgetListOut" });
44
+ export const BudgetListOut = pageOut(BudgetOut, "BudgetListOut");
46
45
  // ── Request bodies ──────────────────────────────────────────────────────────
47
46
  export const BudgetIn = z
48
47
  .object({
@@ -18,6 +18,7 @@
18
18
  * `#/components/schemas/<id>` rather than inlining it.
19
19
  */
20
20
  import { z } from "zod";
21
+ import { pageOut } from "./_page.js";
21
22
  /** OAuth token material the tenant pushes in; IC stores it encrypted and never
22
23
  * echoes it back. Only `kind: "oauth_tokens"` is accepted. */
23
24
  export const Credential = z
@@ -41,9 +42,7 @@ export const ConnectionOut = z
41
42
  created_at: z.string().nullable(),
42
43
  })
43
44
  .meta({ id: "ConnectionOut" });
44
- export const ConnectionListOut = z
45
- .object({ data: z.array(ConnectionOut) })
46
- .meta({ id: "ConnectionListOut" });
45
+ export const ConnectionListOut = pageOut(ConnectionOut, "ConnectionListOut");
47
46
  // ── Request bodies ──────────────────────────────────────────────────────────
48
47
  export const ConnectionIn = z
49
48
  .object({
@@ -17,7 +17,7 @@
17
17
  * endpoint.
18
18
  */
19
19
  import { z } from "zod";
20
- import { pageOut } from "./_page.js";
20
+ import { oaiListOut } from "./_page.js";
21
21
  /** A conversation — the OpenAI Conversations object + IC extensions. */
22
22
  export const ConversationOut = z
23
23
  .object({
@@ -35,7 +35,8 @@ export const ConversationOut = z
35
35
  metadata: z.record(z.string(), z.unknown()),
36
36
  })
37
37
  .meta({ id: "ConversationOut" });
38
- export const ConversationListOut = pageOut(ConversationOut, "ConversationListOut");
38
+ /** The conversation list, in OpenAI's `list` envelope (page with `?after=`). */
39
+ export const ConversationListOut = oaiListOut(ConversationOut, "ConversationListOut");
39
40
  /** The delete acknowledgement, in OpenAI's `*.deleted` shape. */
40
41
  export const ConversationDeleted = z
41
42
  .object({
@@ -66,15 +67,7 @@ export const ConversationItem = z
66
67
  })
67
68
  .meta({ id: "ConversationItem" });
68
69
  /** A conversation's items, in OpenAI's `list` envelope (not the IC cursor page). */
69
- export const ConversationItemListOut = z
70
- .object({
71
- object: z.literal("list"),
72
- data: z.array(ConversationItem),
73
- first_id: z.string().nullable(),
74
- last_id: z.string().nullable(),
75
- has_more: z.boolean(),
76
- })
77
- .meta({ id: "ConversationItemListOut" });
70
+ export const ConversationItemListOut = oaiListOut(ConversationItem, "ConversationItemListOut");
78
71
  /** Create body — OpenAI accepts `metadata`; `title` is the IC extension. */
79
72
  export const ConversationCreate = z
80
73
  .object({
@@ -103,3 +103,35 @@ export const DeploymentPatch = z
103
103
  owner_email: z.string().nullish(),
104
104
  })
105
105
  .meta({ id: "DeploymentPatch" });
106
+ // ── Inbound events ───────────────────────────────────────────────────────────
107
+ /**
108
+ * One message as it arrived, before anything interpreted it — the immutable
109
+ * ingest record behind every channel-triggered run, in CloudEvents terms
110
+ * (`source` / `type` / `subject` / `data`).
111
+ *
112
+ * It is recorded before resolution, so an event that matched no smith is here
113
+ * too, with `smith_id: ""` — "the webhook fired and nothing happened" is a
114
+ * readable answer, not an absence. `idempotency_key` is the provider's own
115
+ * delivery id (`Message-Id`, `X-GitHub-Delivery`); a re-delivery of the same key
116
+ * records once, so this log is also the dedup ledger. `""` throughout means the
117
+ * source supplied nothing, never "unknown".
118
+ */
119
+ export const InboundEventOut = z
120
+ .object({
121
+ id: z.string(),
122
+ /** The channel it arrived on: `email`, `telegram`, `slack`, `whatsapp`, … */
123
+ source: z.string(),
124
+ /** The provider's event name (`email.received`); `""` if it names none. */
125
+ type: z.string(),
126
+ /** The addressed resource — inbox address, channel, repo. */
127
+ subject: z.string(),
128
+ /** The provider's delivery id, and this log's dedup key. */
129
+ idempotency_key: z.string(),
130
+ /** The smith it woke; `""` when the sender resolved to none. */
131
+ smith_id: z.string(),
132
+ /** The provider payload as received. */
133
+ data: z.record(z.string(), z.unknown()),
134
+ created_at: z.string().nullable(),
135
+ })
136
+ .meta({ id: "InboundEventOut" });
137
+ export const InboundEventListOut = pageOut(InboundEventOut, "InboundEventListOut");
package/dist/zod/files.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * listed.
12
12
  */
13
13
  import { z } from "zod";
14
+ import { oaiListOut } from "./_page.js";
14
15
  /** OpenAI's upload purposes. Vector-store source files are `assistants`. */
15
16
  export const FilePurpose = z.enum([
16
17
  "assistants",
@@ -36,15 +37,7 @@ export const FileOut = z
36
37
  })
37
38
  .meta({ id: "FileOut" });
38
39
  /** Files, in OpenAI's `list` envelope (not the IC cursor page). */
39
- export const FileListOut = z
40
- .object({
41
- object: z.literal("list"),
42
- data: z.array(FileOut),
43
- first_id: z.string().nullable(),
44
- last_id: z.string().nullable(),
45
- has_more: z.boolean(),
46
- })
47
- .meta({ id: "FileListOut" });
40
+ export const FileListOut = oaiListOut(FileOut, "FileListOut");
48
41
  /** The delete acknowledgement, in OpenAI's `*.deleted` shape. */
49
42
  export const FileDeleted = z
50
43
  .object({
package/dist/zod/index.js CHANGED
@@ -8,9 +8,11 @@
8
8
  * when the last one lands, the generated file and the `openapi-zod-client` step
9
9
  * are deleted and this becomes the sole `schemas` source.
10
10
  */
11
+ export * from "./_actor.js";
11
12
  export * from "./_page.js";
12
13
  export * from "./agents.js";
13
14
  export * from "./approvals.js";
15
+ export * from "./billing.js";
14
16
  export * from "./budgets.js";
15
17
  export * from "./catalog.js";
16
18
  export * from "./connections.js";
@@ -26,6 +28,7 @@ export * from "./observability.js";
26
28
  export * from "./projects.js";
27
29
  export * from "./runs.js";
28
30
  export * from "./schedules.js";
31
+ export * from "./skills.js";
29
32
  export * from "./slack.js";
30
33
  export * from "./smith-revisions.js";
31
34
  export * from "./smiths.js";
package/dist/zod/mcp.js CHANGED
@@ -14,6 +14,7 @@
14
14
  * emit as `$ref` components rather than inlined objects.
15
15
  */
16
16
  import { z } from "zod";
17
+ import { pageOut } from "./_page.js";
17
18
  /** One approval-policy rule: a name glob that gates matching tools behind a
18
19
  * human approval. `require` is always `"approval"` today (the only supported
19
20
  * value); arg-conditional (`when`) gating is rejected, not stored. */
@@ -66,26 +67,29 @@ export const McpServerOut = z
66
67
  tool_allowlist: z.array(z.string()).nullish(),
67
68
  approval_policy: z.array(ApprovalRule).optional(),
68
69
  tools: z.array(McpTool),
70
+ /** How many tools this registration currently holds — what a run is offered,
71
+ * before the allow-list gate each tool's own `enabled` reports. Same number on
72
+ * a read as on the register/refresh response that produced it. */
73
+ tools_discovered: z.number().int(),
69
74
  tools_refreshed_at: z.string().nullable(),
70
- /** `degraded` when the edge failed discovery or its secret can't be decoded
71
- * at run time; otherwise the stored lifecycle status. */
75
+ /** `degraded` when the edge failed discovery, its secret can't be decoded at
76
+ * run time, or its last `tools/call` failed at the transport level;
77
+ * otherwise the stored lifecycle status. */
72
78
  status: z.string(),
73
- /** Last discovery/runtime-load failure, or null when the edge is healthy. */
79
+ /** Last discovery/runtime-load failure, or null when discovery is healthy. */
74
80
  discovery_error: z.string().nullable(),
81
+ /** Last transport-level `tools/call` failure (network / HTTP status), or
82
+ * null. Discovery can succeed while calls fail — this catches that. Cleared
83
+ * by a successful call or a re-PUT. */
84
+ last_call_error: z.string().nullable(),
85
+ last_call_error_at: z.string().nullable(),
75
86
  created_at: z.string().nullable(),
76
87
  })
77
88
  .meta({ id: "McpServerOut" });
78
- export const McpServerListOut = z
79
- .object({ data: z.array(McpServerOut) })
80
- .meta({ id: "McpServerListOut" });
81
- /** Register/replace and refresh echo the server back plus the count of tools
82
- * discovered in the just-run `tools/list`. */
83
- export const McpServerWriteOut = McpServerOut.extend({
84
- tools_discovered: z.number().int(),
85
- }).meta({ id: "McpServerWriteOut" });
89
+ export const McpServerListOut = pageOut(McpServerOut, "McpServerListOut");
86
90
  // ── Request bodies ──────────────────────────────────────────────────────────
87
- /** Auth block on a register/replace body. `secret` is write-only (a static
88
- * bearer) — never echoed back. */
91
+ /** Auth block on a register/replace body. `kind` is `none` | `bearer` | `oauth`;
92
+ * `secret` (the shared bearer token) is write-only — never echoed back. */
89
93
  export const McpAuthIn = z
90
94
  .object({
91
95
  kind: z.string().nullish(),
@@ -95,7 +99,9 @@ export const McpAuthIn = z
95
99
  })
96
100
  .meta({ id: "McpAuthIn" });
97
101
  /** Register or replace a server: supply a raw `url` + `auth`, or a `catalog`
98
- * slug (catalog defaults are stamped down, body fields override). */
102
+ * slug (catalog defaults are stamped down, body fields override). PUT is a
103
+ * full replace and `auth.kind` is required unless a catalog preset supplies
104
+ * it — there is no implicit `none`. */
99
105
  export const McpServerIn = z
100
106
  .object({
101
107
  url: z.string().nullish(),
@@ -23,14 +23,7 @@ import { pageOut } from "./_page.js";
23
23
  /** Span kinds emitted by the observability backend. `retrieval` covers vector-store
24
24
  * search (the hosted `file_search` tool, and externally-pushed RAG spans). */
25
25
  export const ICSpanKindEnum = z
26
- .enum([
27
- "run",
28
- "model_call",
29
- "tool_call",
30
- "memory_op",
31
- "retrieval",
32
- "runtime_event",
33
- ])
26
+ .enum(["run", "model_call", "tool_call", "memory_op", "retrieval", "runtime_event"])
34
27
  .meta({ id: "SpanKind" });
35
28
  /** A single timed unit of work inside a trace. */
36
29
  export const SpanOut = z
@@ -61,8 +54,12 @@ export const SpanNodeOut = SpanOut.extend({
61
54
  export const TraceOut = z
62
55
  .object({
63
56
  id: z.string(),
64
- smith_id: z.string(),
57
+ /** Null for a trace no smith owns — an external `/v1/traces:ingest` under a
58
+ * tenant token attributes to none. Such a trace is tenant-scope only: a
59
+ * smith-bound token cannot read it. */
60
+ smith_id: z.string().nullable(),
65
61
  app_id: z.string().nullable(),
62
+ run_id: z.string().nullable(),
66
63
  root_kind: ICSpanKindEnum,
67
64
  name: z.string(),
68
65
  status: z.string(),
@@ -81,24 +78,32 @@ export const TraceDetailOut = TraceOut.extend({
81
78
  }).meta({ id: "TraceDetailOut" });
82
79
  export const TraceListOut = pageOut(TraceOut, "TraceListOut");
83
80
  /** Aggregated usage grouped by app, smith, model, or customer. */
81
+ /** The token/cost amounts a usage bucket reports. `tokens` is the grand total
82
+ * (input + output); `input_tokens` is the input slice, and `cache_read_tokens`
83
+ * / `cache_write_tokens` are sub-slices of input (reads served from the
84
+ * provider's prompt cache, writes billed at the cache-write premium). The cache
85
+ * hit rate is `cache_read_tokens / input_tokens`. */
86
+ const UsageAmounts = z.object({
87
+ tokens: z.number(),
88
+ input_tokens: z.number(),
89
+ cache_read_tokens: z.number(),
90
+ cache_write_tokens: z.number(),
91
+ cost: z.number(),
92
+ run_count: z.number(),
93
+ });
84
94
  export const UsageBreakdownOut = z
85
95
  .object({
86
96
  group_by: z.enum(["app", "smith", "model", "customer"]),
87
- totals: z.object({
88
- tokens: z.number(),
89
- cost: z.number(),
90
- run_count: z.number(),
91
- }),
92
- groups: z.array(z.object({
97
+ totals: UsageAmounts,
98
+ groups: z.array(z
99
+ .object({
93
100
  app: z.string().nullable().optional(),
94
101
  smith: z.string().nullable().optional(),
95
102
  model: z.string().nullable().optional(),
96
103
  // Customer-grouped views label unassigned usage `principal:<smith id>`.
97
104
  customer: z.string().nullable().optional(),
98
- tokens: z.number(),
99
- cost: z.number(),
100
- run_count: z.number(),
101
- })),
105
+ })
106
+ .extend(UsageAmounts.shape)),
102
107
  /** Custom billable events aggregated per meter over the same filters. */
103
108
  meters: z
104
109
  .array(z.object({
@@ -131,3 +136,18 @@ export const UsageEventListOut = z
131
136
  has_more: z.boolean(),
132
137
  })
133
138
  .meta({ id: "UsageEventListOut" });
139
+ // ── Span ingestion (POST /v1/traces:ingest) ─────────────────────────────────
140
+ /** The request body for span ingestion (externally-pushed spans / OTel).
141
+ *
142
+ * Deliberately permissive: the handler normalizes rather than rejects — an
143
+ * unrecognized `kind` degrades to `runtime_event`, missing ids and timestamps
144
+ * are generated. Validating {@link ICSpanIn} here would 422 exactly the sloppy
145
+ * exporter payloads the endpoint exists to absorb. `ICSpanIn` documents the
146
+ * shape for callers; the wire stays open. */
147
+ export const TraceIngestIn = z
148
+ .object({ spans: z.array(z.record(z.string(), z.unknown())).optional() })
149
+ .meta({ id: "TraceIngestIn" });
150
+ /** The 202 ack for span ingestion: how many spans were written. */
151
+ export const TraceIngestOut = z
152
+ .object({ accepted: z.number().int() })
153
+ .meta({ id: "TraceIngestOut" });
@@ -12,6 +12,7 @@
12
12
  * `#/components/schemas/<id>` rather than inlining it.
13
13
  */
14
14
  import { z } from "zod";
15
+ import { pageOut } from "./_page.js";
15
16
  export const ProjectOut = z
16
17
  .object({
17
18
  id: z.string(),
@@ -24,9 +25,7 @@ export const ProjectOut = z
24
25
  archived_at: z.string().nullable(),
25
26
  })
26
27
  .meta({ id: "ProjectOut" });
27
- export const ProjectListOut = z
28
- .object({ data: z.array(ProjectOut) })
29
- .meta({ id: "ProjectListOut" });
28
+ export const ProjectListOut = pageOut(ProjectOut, "ProjectListOut");
30
29
  /**
31
30
  * The secret minted when an org mints a project (tenant-admin) token. Shape
32
31
  * matches `mintToken`'s return; the `tenant` module owns the canonical
@@ -52,7 +51,8 @@ export const ProjectIn = z
52
51
  .meta({ id: "ProjectIn" });
53
52
  export const ProjectTokenIn = z
54
53
  .object({
55
- ttl_seconds: z.number().int().nullish(),
54
+ // Same bounds as `TokenIn.ttl_seconds` — this mints a `tenant:*` token too.
55
+ ttl_seconds: z.number().int().positive().max(315_360_000).nullish(),
56
56
  name: z.string().nullish(),
57
57
  })
58
58
  .meta({ id: "ProjectTokenIn" });
package/dist/zod/runs.js CHANGED
@@ -20,6 +20,7 @@
20
20
  * are deliberately not modelled.
21
21
  */
22
22
  import { z } from "zod";
23
+ import { Actor } from "./_actor.js";
23
24
  import { pageOut } from "./_page.js";
24
25
  /** One message in a run's `input`. `content` is a plain string for a text-only
25
26
  * turn, or an array of content parts (`{type:"text"|"file"|"image", …}`) for a
@@ -28,10 +29,7 @@ import { pageOut } from "./_page.js";
28
29
  export const InputMessage = z
29
30
  .object({
30
31
  role: z.string(),
31
- content: z.union([
32
- z.string(),
33
- z.array(z.record(z.string(), z.unknown())),
34
- ]),
32
+ content: z.union([z.string(), z.array(z.record(z.string(), z.unknown()))]),
35
33
  })
36
34
  .meta({ id: "InputMessage" });
37
35
  /** One run's own token usage (the `usage` map on a run). Distinct from the
@@ -49,6 +47,16 @@ export const RunUsage = z
49
47
  cost: z.number().optional(),
50
48
  })
51
49
  .meta({ id: "RunUsage" });
50
+ /** One thing that went wrong during a run without ending it — today, a tool source
51
+ * the run could not reach. A run that lost its tools still answers, and the answer
52
+ * is shaped like a healthy one, so this rides the run's own summary fields rather
53
+ * than a nested metadata key nobody reads. */
54
+ export const RunWarning = z
55
+ .object({
56
+ code: z.string(),
57
+ message: z.string(),
58
+ })
59
+ .meta({ id: "RunWarning" });
52
60
  export const RunOut = z
53
61
  .object({
54
62
  id: z.string(),
@@ -75,8 +83,12 @@ export const RunOut = z
75
83
  })
76
84
  .nullable(),
77
85
  stop_reason: z.string().nullable(),
86
+ // Always present, `[]` on a clean run: absence must never read as "fine".
87
+ warnings: z.array(RunWarning),
78
88
  usage: RunUsage.nullable(),
79
89
  metadata: z.record(z.string(), z.unknown()).optional(),
90
+ /** Who started this run. Null on runs created before attribution shipped. */
91
+ actor: Actor.nullable(),
80
92
  created_at: z.string().nullable(),
81
93
  updated_at: z.string().nullable(),
82
94
  })
@@ -13,6 +13,7 @@
13
13
  * `#/components/schemas/<id>` rather than inlining it.
14
14
  */
15
15
  import { z } from "zod";
16
+ import { pageOut } from "./_page.js";
16
17
  /** A schedule's stored input: messages replayed as the run input on each fire. */
17
18
  const ScheduleInput = z.array(z.record(z.string(), z.unknown()));
18
19
  export const ScheduleOut = z
@@ -25,17 +26,13 @@ export const ScheduleOut = z
25
26
  input: ScheduleInput,
26
27
  /** Thread the fired runs append to; null mints a fresh thread per fire. */
27
28
  thread_id: z.string().nullable(),
28
- /** Max overlapping fired runs before new fires are skipped. */
29
- max_concurrent: z.number().int(),
30
29
  enabled: z.boolean(),
31
30
  next_fire_at: z.string().nullable(),
32
31
  last_fire_at: z.string().nullable(),
33
32
  created_at: z.string().nullable(),
34
33
  })
35
34
  .meta({ id: "ScheduleOut" });
36
- export const ScheduleListOut = z
37
- .object({ data: z.array(ScheduleOut) })
38
- .meta({ id: "ScheduleListOut" });
35
+ export const ScheduleListOut = pageOut(ScheduleOut, "ScheduleListOut");
39
36
  /** `POST .../:sid/run_now` — the fire is enqueued onto the smith's serial delivery
40
37
  * lane (not run inline), so the response acknowledges the queued delivery rather
41
38
  * than a completed run. Poll `/v1/events` or the smith's runs for the outcome. */
@@ -54,7 +51,6 @@ export const ScheduleIn = z
54
51
  timezone: z.string().default("UTC"),
55
52
  input: ScheduleInput.default([]),
56
53
  thread_id: z.string().nullish(),
57
- max_concurrent: z.number().int().default(1),
58
54
  enabled: z.boolean().default(true),
59
55
  })
60
56
  .meta({ id: "ScheduleIn" });
@@ -65,7 +61,6 @@ export const SchedulePatch = z
65
61
  timezone: z.string().nullish(),
66
62
  input: ScheduleInput.nullish(),
67
63
  thread_id: z.string().nullish(),
68
- max_concurrent: z.number().int().nullish(),
69
64
  enabled: z.boolean().nullish(),
70
65
  })
71
66
  .meta({ id: "SchedulePatch" });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Agent Skills (#175) — a folder anchored by SKILL.md, per the Agent Skills
3
+ * specification, stored as an immutable version and attached to an agent.
4
+ *
5
+ * A version's bytes never appear on the wire: `files` lists each path with its
6
+ * size and content hash, so a tenant can see exactly what they installed.
7
+ */
8
+ import { z } from "zod";
9
+ /** One file in a skill version, as the caller uploaded it. */
10
+ export const SkillFile = z
11
+ .object({
12
+ path: z.string(),
13
+ size: z.number().int(),
14
+ sha256: z.string(),
15
+ media_type: z.string(),
16
+ })
17
+ .meta({ id: "SkillFile" });
18
+ /** One published agent version that froze a reference to this skill version.
19
+ * A frozen reference is the only kind that blocks a delete, so this is the
20
+ * list a `409 skill_in_use` would name. */
21
+ export const SkillReference = z
22
+ .object({ agent_id: z.string(), version: z.number().int() })
23
+ .meta({ id: "SkillReference" });
24
+ /** An immutable published version of a skill. */
25
+ export const SkillVersion = z
26
+ .object({
27
+ skill_id: z.string(),
28
+ version: z.number().int(),
29
+ description: z.string(),
30
+ license: z.string().nullable(),
31
+ compatibility: z.unknown().nullable(),
32
+ metadata: z.record(z.string(), z.unknown()).nullable(),
33
+ references: z.array(z.string()),
34
+ scripts: z.array(z.string()),
35
+ assets: z.array(z.string()),
36
+ files: z.array(SkillFile),
37
+ /** Published agent versions holding this one frozen. Always present, `[]`
38
+ * when nothing does. */
39
+ referenced_by: z.array(SkillReference),
40
+ bytes: z.number().int(),
41
+ created_at: z.string(),
42
+ })
43
+ .meta({ id: "SkillVersion" });
44
+ /** The skill resource. `default_version` is what an agent gets when it names none. */
45
+ export const Skill = z
46
+ .object({
47
+ id: z.string(),
48
+ object: z.literal("skill"),
49
+ name: z.string(),
50
+ description: z.string(),
51
+ default_version: z.number().int(),
52
+ created_at: z.string(),
53
+ updated_at: z.string(),
54
+ })
55
+ .meta({ id: "Skill" });
56
+ export const SkillListOut = z
57
+ .object({ object: z.literal("list"), data: z.array(Skill) })
58
+ .meta({ id: "SkillListOut" });
59
+ export const SkillVersionListOut = z
60
+ .object({ object: z.literal("list"), data: z.array(SkillVersion) })
61
+ .meta({ id: "SkillVersionListOut" });
62
+ /** Move the skill's `default_version` to an existing version. */
63
+ export const SkillUpdateIn = z
64
+ .object({ default_version: z.number().int().positive() })
65
+ .meta({ id: "SkillUpdateIn" });
66
+ /** One skill reference in an agent's `skills` config. Omitted `version` resolves
67
+ * to the skill's `default_version` and is frozen at publish. */
68
+ export const SkillRef = z
69
+ .object({
70
+ skill_id: z.string(),
71
+ version: z.number().int().positive().optional(),
72
+ })
73
+ .meta({ id: "SkillRef" });
@@ -16,6 +16,7 @@
16
16
  * `#/components/schemas/<id>` rather than inlining it.
17
17
  */
18
18
  import { z } from "zod";
19
+ import { pageOut } from "./_page.js";
19
20
  /** An immutable snapshot of a smith's effective behaviour config at one revision. */
20
21
  export const SmithRevisionOut = z
21
22
  .object({
@@ -25,17 +26,18 @@ export const SmithRevisionOut = z
25
26
  model: z.string().nullish(),
26
27
  enabled_hosted_tools: z.array(z.string()).optional(),
27
28
  vector_store_ids: z.array(z.string()).optional(),
28
- auto_memory: z.boolean().optional(),
29
- memory_consolidation: z.boolean().optional(),
29
+ mcp_servers: z.array(z.string()).nullish(),
30
+ // Nullish: a snapshot taken while the smith inherited a sparse agent
31
+ // version carries null (= the default) for these.
32
+ auto_memory: z.boolean().nullish(),
33
+ memory_consolidation: z.boolean().nullish(),
30
34
  }),
31
35
  created_by: z.string().nullish(),
32
36
  note: z.string().nullish(),
33
37
  created_at: z.string().nullish(),
34
38
  })
35
39
  .meta({ id: "SmithRevisionOut" });
36
- export const RevisionListOut = z
37
- .object({ data: z.array(SmithRevisionOut) })
38
- .meta({ id: "RevisionListOut" });
40
+ export const RevisionListOut = pageOut(SmithRevisionOut, "RevisionListOut");
39
41
  // ── Request bodies ──────────────────────────────────────────────────────────
40
42
  export const RestoreIn = z
41
43
  .object({ note: z.string().nullish() })
@@ -17,6 +17,7 @@
17
17
  * `#/components/schemas/<id>` rather than inlining it.
18
18
  */
19
19
  import { z } from "zod";
20
+ import { SkillRef } from "./skills.js";
20
21
  // ── Smith response ───────────────────────────────────────────────────────────
21
22
  export const SmithOut = z
22
23
  .object({
@@ -36,6 +37,9 @@ export const SmithOut = z
36
37
  rendered_instructions: z.string().nullish(),
37
38
  enabled_hosted_tools: z.array(z.string()).optional(),
38
39
  vector_store_ids: z.array(z.string()).optional(),
40
+ /** Registered MCP servers this smith's runs load, by name. Null = all. */
41
+ mcp_servers: z.array(z.string()).nullish(),
42
+ skills: z.array(SkillRef).optional(),
39
43
  auto_memory: z.boolean().optional(),
40
44
  memory_consolidation: z.boolean().optional(),
41
45
  /** How the config resolved: by reference, with overrides, or embedded. */
@@ -55,6 +59,8 @@ export const SmithOut = z
55
59
  instructions: z.string().nullable(),
56
60
  enabled_hosted_tools: z.array(z.string()),
57
61
  vector_store_ids: z.array(z.string()),
62
+ mcp_servers: z.array(z.string()).nullable(),
63
+ skills: z.array(SkillRef),
58
64
  auto_memory: z.boolean().nullable(),
59
65
  memory_consolidation: z.boolean().nullable(),
60
66
  })
@@ -85,6 +91,9 @@ export const SmithCreate = z
85
91
  instructions: z.string().nullish(),
86
92
  enabled_hosted_tools: z.array(z.string()).nullish(),
87
93
  vector_store_ids: z.array(z.string()).nullish(),
94
+ /** Scope this smith's runs to these registered MCP servers (by name). */
95
+ mcp_servers: z.array(z.string()).nullish(),
96
+ skills: z.array(SkillRef).nullish(),
88
97
  auto_memory: z.boolean().nullish(),
89
98
  memory_consolidation: z.boolean().nullish(),
90
99
  })
@@ -102,6 +111,11 @@ export const SmithPatch = z
102
111
  instructions: z.string().nullish(),
103
112
  enabled_hosted_tools: z.array(z.string()).nullish(),
104
113
  vector_store_ids: z.array(z.string()).nullish(),
114
+ /** Scope this smith's runs to these registered MCP servers (by name).
115
+ * Null clears the per-smith override (re-inherit the agent's value). */
116
+ mcp_servers: z.array(z.string()).nullish(),
117
+ /** Null clears the per-smith override (re-inherit the agent's value). */
118
+ skills: z.array(SkillRef).nullish(),
105
119
  auto_memory: z.boolean().nullish(),
106
120
  memory_consolidation: z.boolean().nullish(),
107
121
  })
@@ -12,6 +12,7 @@
12
12
  * `#/components/schemas/<id>` rather than inlining it.
13
13
  */
14
14
  import { z } from "zod";
15
+ import { Actor } from "./_actor.js";
15
16
  import { pageOut } from "./_page.js";
16
17
  // ── Events (poll mirror of the webhook firehose) ─────────────────────────────
17
18
  /** One event in the `/v1/events` feed — the `{v:1}` envelope (sans `tenant_id`,
@@ -24,6 +25,8 @@ export const EventOut = z
24
25
  type: z.string(),
25
26
  smith_id: z.string().nullable(),
26
27
  data: z.record(z.string(), z.unknown()),
28
+ /** Who acted. Null on events recorded before attribution shipped. */
29
+ actor: Actor.nullable(),
27
30
  created_at: z.string().nullable(),
28
31
  })
29
32
  .meta({ id: "EventOut" });
@@ -50,9 +53,7 @@ export const WebhookCreateOut = z
50
53
  })
51
54
  .meta({ id: "WebhookCreateOut" });
52
55
  /** The patch/delete-adjacent ack shape (just the id). */
53
- export const WebhookIdOut = z
54
- .object({ id: z.string() })
55
- .meta({ id: "WebhookIdOut" });
56
+ export const WebhookIdOut = z.object({ id: z.string() }).meta({ id: "WebhookIdOut" });
56
57
  export const WebhookIn = z
57
58
  .object({
58
59
  url: z.string(),
@@ -67,6 +68,23 @@ export const WebhookPatch = z
67
68
  active: z.boolean().nullish(),
68
69
  })
69
70
  .meta({ id: "WebhookPatch" });
71
+ /** Rotate a webhook's signing secret. `grace_seconds` keeps the outgoing secret
72
+ * valid for an overlap window (default 24h, 0 = cut over immediately, max 7d);
73
+ * during it every delivery is signed with both the new and old secret. */
74
+ export const WebhookRotateIn = z
75
+ .object({
76
+ grace_seconds: z.number().int().min(0).max(604800).default(86400),
77
+ })
78
+ .meta({ id: "WebhookRotateIn" });
79
+ /** The rotate response — the new signing `secret` is returned EXACTLY ONCE, here.
80
+ * `previous_secret_expires_at` is when the old secret stops being accepted. */
81
+ export const WebhookRotateOut = z
82
+ .object({
83
+ id: z.string(),
84
+ secret: z.string(),
85
+ previous_secret_expires_at: z.string().nullable(),
86
+ })
87
+ .meta({ id: "WebhookRotateOut" });
70
88
  /** One persisted delivery attempt record for a webhook — the audit trail behind
71
89
  * durable, retried delivery. `status` is `pending` | `succeeded` | `dead`. */
72
90
  export const WebhookDeliveryOut = z
@@ -125,7 +143,9 @@ export const TokenIn = z
125
143
  scope: z.string().default("smith"),
126
144
  smith_id: z.string().nullish(),
127
145
  permissions: z.array(z.string()).nullish(),
128
- ttl_seconds: z.number().int().nullish(),
146
+ // Positive and bounded: `0` used to read as "no expiry" and mint a permanent
147
+ // admin token, and a ttl past year 275760 overflows the `Date` we serialize.
148
+ ttl_seconds: z.number().int().positive().max(315_360_000).nullish(),
129
149
  name: z.string().nullish(),
130
150
  })
131
151
  .meta({ id: "TokenIn" });
@@ -270,3 +290,20 @@ export const HostedToolOut = z
270
290
  export const HostedToolsListOut = z
271
291
  .object({ data: z.array(HostedToolOut) })
272
292
  .meta({ id: "HostedToolsListOut" });
293
+ // ── Sandbox secrets (env a tenant's sandboxes carry) ─────────────────────────
294
+ /** One secret by name. The value is NEVER echoed — only that it is set. */
295
+ export const SandboxSecretOut = z
296
+ .object({
297
+ name: z.string(),
298
+ updated_at: z.string().nullable(),
299
+ })
300
+ .meta({ id: "SandboxSecretOut" });
301
+ export const SandboxSecretListOut = z
302
+ .object({ data: z.array(SandboxSecretOut) })
303
+ .meta({ id: "SandboxSecretListOut" });
304
+ export const SandboxSecretIn = z
305
+ .object({ value: z.string() })
306
+ .meta({ id: "SandboxSecretIn" });
307
+ export const SandboxSecretConfiguredOut = z
308
+ .object({ name: z.string(), configured: z.boolean() })
309
+ .meta({ id: "SandboxSecretConfiguredOut" });