@ingram-tech/ingram-cloud-sdk 0.1.1 → 0.2.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 +16 -16
- package/package.json +5 -7
- package/ts/index.ts +9 -10
- package/ts/responses.ts +62 -437
- package/ts/schemas.ts +4 -1101
- package/ts/zod/agents.ts +132 -0
- package/ts/zod/approvals.ts +45 -0
- package/ts/zod/budgets.ts +70 -0
- package/ts/zod/catalog.ts +57 -0
- package/ts/zod/channels.ts +84 -0
- package/ts/zod/connections.ts +87 -0
- package/ts/zod/customers.ts +62 -0
- package/ts/zod/email.ts +52 -0
- package/ts/zod/index.ts +30 -0
- package/ts/zod/mcp.ts +123 -0
- package/ts/zod/memories.ts +98 -0
- package/ts/zod/observability.ts +156 -0
- package/ts/zod/projects.ts +68 -0
- package/ts/zod/runs.ts +115 -0
- package/ts/zod/schedules.ts +83 -0
- package/ts/zod/slack.ts +79 -0
- package/ts/zod/smith-revisions.ts +48 -0
- package/ts/zod/smiths.ts +131 -0
- package/ts/zod/telegram.ts +43 -0
- package/ts/zod/tenant.ts +272 -0
- package/ts/zod/whatsapp.ts +55 -0
- package/openapi.json +0 -10835
package/ts/zod/mcp.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `mcp` resource — the tenant config plane for
|
|
3
|
+
* registering third-party MCP tool servers (`/v1/tenant/mcp/...`).
|
|
4
|
+
*
|
|
5
|
+
* One source, three outputs: the API imports these into its `createRoute`
|
|
6
|
+
* definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
|
|
7
|
+
* types are `z.infer`red from them here and re-exported by `../responses`. No
|
|
8
|
+
* Zod is pulled into a type-only consumer — `responses.ts` re-exports these as
|
|
9
|
+
* `export type`.
|
|
10
|
+
*
|
|
11
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
12
|
+
* `#/components/schemas/<id>` rather than inlining it. `ApprovalRule` and
|
|
13
|
+
* `McpTool` are standalone named schemas referenced by `McpServerOut`, so they
|
|
14
|
+
* emit as `$ref` components rather than inlined objects.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
|
|
18
|
+
/** One approval-policy rule: a name glob that gates matching tools behind a
|
|
19
|
+
* human approval. `require` is always `"approval"` today (the only supported
|
|
20
|
+
* value); arg-conditional (`when`) gating is rejected, not stored. */
|
|
21
|
+
export const ApprovalRule = z
|
|
22
|
+
.object({
|
|
23
|
+
match: z.string(),
|
|
24
|
+
require: z.string().optional(),
|
|
25
|
+
})
|
|
26
|
+
.meta({ id: "ApprovalRule" });
|
|
27
|
+
|
|
28
|
+
/** The rule shape on *input* (`McpServerIn.approval_policy`). Loose, so unknown
|
|
29
|
+
* clauses (e.g. an arg-conditional `when`) reach the handler, which rejects them
|
|
30
|
+
* with its own `unsupported_policy_rule` (422) rather than being silently
|
|
31
|
+
* stripped by a strict object. */
|
|
32
|
+
export const ApprovalRuleIn = z.looseObject({
|
|
33
|
+
match: z.string(),
|
|
34
|
+
require: z.string().optional(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** A discovered MCP tool, with its *effective* gating folded in by the
|
|
38
|
+
* serializer: `enabled` reflects the default-deny `tool_allowlist`,
|
|
39
|
+
* `requires_approval` folds the server's destructive hint with the approval
|
|
40
|
+
* policy. */
|
|
41
|
+
export const McpTool = z
|
|
42
|
+
.object({
|
|
43
|
+
name: z.string(),
|
|
44
|
+
description: z.string().nullable(),
|
|
45
|
+
/** Effective gate: server destructiveHint OR an approval_policy match. */
|
|
46
|
+
requires_approval: z.boolean(),
|
|
47
|
+
/** Passes the default-deny tool_allowlist (always true when no allow-list). */
|
|
48
|
+
enabled: z.boolean(),
|
|
49
|
+
})
|
|
50
|
+
.meta({ id: "McpTool" });
|
|
51
|
+
|
|
52
|
+
/** Secret-free auth descriptor returned for a registered server. */
|
|
53
|
+
export const McpAuth = z
|
|
54
|
+
.object({
|
|
55
|
+
kind: z.string(),
|
|
56
|
+
provider: z.string().nullable(),
|
|
57
|
+
client_mode: z.string().optional(),
|
|
58
|
+
})
|
|
59
|
+
.meta({ id: "McpAuth" });
|
|
60
|
+
|
|
61
|
+
export const McpServerOut = z
|
|
62
|
+
.object({
|
|
63
|
+
id: z.string(),
|
|
64
|
+
name: z.string(),
|
|
65
|
+
url: z.string(),
|
|
66
|
+
auth: McpAuth,
|
|
67
|
+
/** tenant_owned | tenant_registered | catalog. */
|
|
68
|
+
origin: z.string().optional(),
|
|
69
|
+
catalog_slug: z.string().nullish(),
|
|
70
|
+
/** null = expose all discovered tools; otherwise the default-deny set. */
|
|
71
|
+
tool_allowlist: z.array(z.string()).nullish(),
|
|
72
|
+
approval_policy: z.array(ApprovalRule).optional(),
|
|
73
|
+
tools: z.array(McpTool),
|
|
74
|
+
tools_refreshed_at: z.string().nullable(),
|
|
75
|
+
/** `degraded` when the edge failed discovery or its secret can't be decoded
|
|
76
|
+
* at run time; otherwise the stored lifecycle status. */
|
|
77
|
+
status: z.string(),
|
|
78
|
+
/** Last discovery/runtime-load failure, or null when the edge is healthy. */
|
|
79
|
+
discovery_error: z.string().nullable(),
|
|
80
|
+
created_at: z.string().nullable(),
|
|
81
|
+
})
|
|
82
|
+
.meta({ id: "McpServerOut" });
|
|
83
|
+
|
|
84
|
+
export const McpServerListOut = z
|
|
85
|
+
.object({ data: z.array(McpServerOut) })
|
|
86
|
+
.meta({ id: "McpServerListOut" });
|
|
87
|
+
|
|
88
|
+
/** Register/replace and refresh echo the server back plus the count of tools
|
|
89
|
+
* discovered in the just-run `tools/list`. */
|
|
90
|
+
export const McpServerWriteOut = McpServerOut.extend({
|
|
91
|
+
tools_discovered: z.number().int(),
|
|
92
|
+
}).meta({ id: "McpServerWriteOut" });
|
|
93
|
+
|
|
94
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
/** Auth block on a register/replace body. `secret` is write-only (a static
|
|
97
|
+
* bearer) — never echoed back. */
|
|
98
|
+
export const McpAuthIn = z
|
|
99
|
+
.object({
|
|
100
|
+
kind: z.string().nullish(),
|
|
101
|
+
provider: z.string().nullish(),
|
|
102
|
+
secret: z.string().nullish(),
|
|
103
|
+
client_mode: z.string().nullish(),
|
|
104
|
+
})
|
|
105
|
+
.meta({ id: "McpAuthIn" });
|
|
106
|
+
|
|
107
|
+
/** Register or replace a server: supply a raw `url` + `auth`, or a `catalog`
|
|
108
|
+
* slug (catalog defaults are stamped down, body fields override). */
|
|
109
|
+
export const McpServerIn = z
|
|
110
|
+
.object({
|
|
111
|
+
url: z.string().nullish(),
|
|
112
|
+
catalog: z.string().nullish(),
|
|
113
|
+
auth: McpAuthIn.nullish(),
|
|
114
|
+
tool_allowlist: z.array(z.string()).nullish(),
|
|
115
|
+
approval_policy: z.array(ApprovalRuleIn).nullish(),
|
|
116
|
+
})
|
|
117
|
+
.meta({ id: "McpServerIn" });
|
|
118
|
+
|
|
119
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
120
|
+
|
|
121
|
+
export type ICMcpTool = z.infer<typeof McpTool>;
|
|
122
|
+
export type ICApprovalRule = z.infer<typeof ApprovalRule>;
|
|
123
|
+
export type ICMcpServer = z.infer<typeof McpServerOut>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `memories` resource — the wire's source of
|
|
3
|
+
* truth, replacing the loose generated `schemas.ts` shapes for this resource.
|
|
4
|
+
*
|
|
5
|
+
* One source, three outputs: the API imports these into its `createRoute`
|
|
6
|
+
* definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
|
|
7
|
+
* types are `z.infer`red from them here and re-exported by `../responses`. No
|
|
8
|
+
* Zod is pulled into a type-only consumer — `responses.ts` re-exports these as
|
|
9
|
+
* `export type`.
|
|
10
|
+
*
|
|
11
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
12
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
13
|
+
*
|
|
14
|
+
* Two derived response views share one stored shape: `score` is present ONLY on
|
|
15
|
+
* search hits, so it's `.optional()` on `MemoryOut`. The list envelope is
|
|
16
|
+
* paginated (`{ data, has_more }`); search returns just `{ data }`.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
|
|
20
|
+
/** A durable, typed fact about a smith. `score` rides only on search hits. */
|
|
21
|
+
export const MemoryOut = z
|
|
22
|
+
.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
category: z.string().nullable(),
|
|
25
|
+
subject: z.string().nullable(),
|
|
26
|
+
content: z.string(),
|
|
27
|
+
source: z.string().nullable(),
|
|
28
|
+
/** Extraction confidence (0–1); null when not scored. */
|
|
29
|
+
confidence: z.number().nullish(),
|
|
30
|
+
/** Relevance score — only present on `/memories/search` hits. */
|
|
31
|
+
score: z.number().nullish(),
|
|
32
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
33
|
+
created_at: z.string().nullable(),
|
|
34
|
+
updated_at: z.string().nullable(),
|
|
35
|
+
})
|
|
36
|
+
.meta({ id: "MemoryOut" });
|
|
37
|
+
|
|
38
|
+
/** Paginated list envelope. */
|
|
39
|
+
export const MemoryListOut = z
|
|
40
|
+
.object({
|
|
41
|
+
data: z.array(MemoryOut),
|
|
42
|
+
has_more: z.boolean(),
|
|
43
|
+
})
|
|
44
|
+
.meta({ id: "MemoryListOut" });
|
|
45
|
+
|
|
46
|
+
/** Search envelope — ranked hits, each carrying a `score`. */
|
|
47
|
+
export const MemorySearchOut = z
|
|
48
|
+
.object({ data: z.array(MemoryOut) })
|
|
49
|
+
.meta({ id: "MemorySearchOut" });
|
|
50
|
+
|
|
51
|
+
/** Result of a batch create. */
|
|
52
|
+
export const MemoryBatchOut = z
|
|
53
|
+
.object({ memories: z.array(MemoryOut) })
|
|
54
|
+
.meta({ id: "MemoryBatchOut" });
|
|
55
|
+
|
|
56
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
/** One memory to create. `content` is the only required field. */
|
|
59
|
+
export const MemoryIn = z
|
|
60
|
+
.object({
|
|
61
|
+
category: z.string().nullish(),
|
|
62
|
+
subject: z.string().nullish(),
|
|
63
|
+
content: z.string(),
|
|
64
|
+
source: z.string().nullish(),
|
|
65
|
+
confidence: z.number().nullish(),
|
|
66
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
67
|
+
})
|
|
68
|
+
.meta({ id: "MemoryIn" });
|
|
69
|
+
|
|
70
|
+
/** Batch create body. */
|
|
71
|
+
export const MemoryBatch = z
|
|
72
|
+
.object({ memories: z.array(MemoryIn) })
|
|
73
|
+
.meta({ id: "MemoryBatch" });
|
|
74
|
+
|
|
75
|
+
/** Partial update — every field optional; nulls clear where the column allows. */
|
|
76
|
+
export const MemoryPatch = z
|
|
77
|
+
.object({
|
|
78
|
+
category: z.string().nullish(),
|
|
79
|
+
subject: z.string().nullish(),
|
|
80
|
+
content: z.string().nullish(),
|
|
81
|
+
source: z.string().nullish(),
|
|
82
|
+
confidence: z.number().nullish(),
|
|
83
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
84
|
+
})
|
|
85
|
+
.meta({ id: "MemoryPatch" });
|
|
86
|
+
|
|
87
|
+
/** Semantic/keyword search body. */
|
|
88
|
+
export const SearchBody = z
|
|
89
|
+
.object({
|
|
90
|
+
query: z.string(),
|
|
91
|
+
categories: z.array(z.string()).nullish(),
|
|
92
|
+
limit: z.number().int().default(10),
|
|
93
|
+
})
|
|
94
|
+
.meta({ id: "SearchBody" });
|
|
95
|
+
|
|
96
|
+
// ── Inferred consumer-facing type (re-exported by ../responses) ──────────────
|
|
97
|
+
|
|
98
|
+
export type ICMemory = z.infer<typeof MemoryOut>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `observability` resource — traces, spans,
|
|
3
|
+
* and the usage breakdown. The wire's source of truth, replacing the loose
|
|
4
|
+
* generated shapes for this resource.
|
|
5
|
+
*
|
|
6
|
+
* One source, three outputs: the API imports these into its `createRoute`
|
|
7
|
+
* definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
|
|
8
|
+
* types are `z.infer`red from them here and re-exported by `../responses`. No
|
|
9
|
+
* Zod is pulled into a type-only consumer — `responses.ts` re-exports these as
|
|
10
|
+
* `export type`.
|
|
11
|
+
*
|
|
12
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
13
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
14
|
+
*
|
|
15
|
+
* Shapes follow the `responses.ts` interfaces (the source of truth), not the
|
|
16
|
+
* relic's looser `SpanOut`/`TraceOut`: the relic flattened `children`, `spans`,
|
|
17
|
+
* and `span_tree` onto every span/trace and made `kind`/timestamps nullable. We
|
|
18
|
+
* split them — `SpanOut` has no `children`, the recursive `SpanNodeOut` adds
|
|
19
|
+
* it; `TraceOut` carries no `spans`/`span_tree`, `TraceDetailOut` adds them.
|
|
20
|
+
*/
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
|
|
23
|
+
/** Span kinds emitted by the observability backend. */
|
|
24
|
+
export const ICSpanKindEnum = z
|
|
25
|
+
.enum([
|
|
26
|
+
"run",
|
|
27
|
+
"model_call",
|
|
28
|
+
"tool_call",
|
|
29
|
+
"memory_op",
|
|
30
|
+
"retrieval",
|
|
31
|
+
"sub_agent",
|
|
32
|
+
"runtime_event",
|
|
33
|
+
])
|
|
34
|
+
.meta({ id: "SpanKind" });
|
|
35
|
+
|
|
36
|
+
/** A single timed unit of work inside a trace. */
|
|
37
|
+
export const SpanOut = z
|
|
38
|
+
.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
trace_id: z.string(),
|
|
41
|
+
parent_span_id: z.string().nullable(),
|
|
42
|
+
kind: ICSpanKindEnum,
|
|
43
|
+
name: z.string(),
|
|
44
|
+
status: z.string(),
|
|
45
|
+
started_at: z.string(),
|
|
46
|
+
ended_at: z.string().nullable(),
|
|
47
|
+
duration_ms: z.number().int().nullable(),
|
|
48
|
+
model: z.string().nullable(),
|
|
49
|
+
input_tokens: z.number().int().nullable(),
|
|
50
|
+
output_tokens: z.number().int().nullable(),
|
|
51
|
+
cost: z.number().nullable(),
|
|
52
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
53
|
+
})
|
|
54
|
+
.meta({ id: "SpanOut" });
|
|
55
|
+
|
|
56
|
+
/** A span node in the nested `span_tree` (same shape + recursive children). */
|
|
57
|
+
export const SpanNodeOut = SpanOut.extend({
|
|
58
|
+
get children() {
|
|
59
|
+
return z.array(SpanNodeOut);
|
|
60
|
+
},
|
|
61
|
+
}).meta({ id: "SpanNodeOut" });
|
|
62
|
+
|
|
63
|
+
/** Top-level trace — one end-to-end agent operation. */
|
|
64
|
+
export const TraceOut = z
|
|
65
|
+
.object({
|
|
66
|
+
id: z.string(),
|
|
67
|
+
smith_id: z.string(),
|
|
68
|
+
app_id: z.string().nullable(),
|
|
69
|
+
root_kind: ICSpanKindEnum,
|
|
70
|
+
name: z.string(),
|
|
71
|
+
status: z.string(),
|
|
72
|
+
started_at: z.string(),
|
|
73
|
+
ended_at: z.string().nullable(),
|
|
74
|
+
duration_ms: z.number().int().nullable(),
|
|
75
|
+
total_tokens: z.number().int().nullable(),
|
|
76
|
+
total_cost: z.number().nullable(),
|
|
77
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
78
|
+
})
|
|
79
|
+
.meta({ id: "TraceOut" });
|
|
80
|
+
|
|
81
|
+
/** A trace plus its flat spans and nested tree. */
|
|
82
|
+
export const TraceDetailOut = TraceOut.extend({
|
|
83
|
+
spans: z.array(SpanOut),
|
|
84
|
+
span_tree: z.array(SpanNodeOut),
|
|
85
|
+
}).meta({ id: "TraceDetailOut" });
|
|
86
|
+
|
|
87
|
+
export const TraceListOut = z
|
|
88
|
+
.object({ data: z.array(TraceOut) })
|
|
89
|
+
.meta({ id: "TraceListOut" });
|
|
90
|
+
|
|
91
|
+
/** Aggregated usage grouped by app, smith, model, or customer. */
|
|
92
|
+
export const UsageBreakdownOut = z
|
|
93
|
+
.object({
|
|
94
|
+
group_by: z.enum(["app", "smith", "model", "customer"]),
|
|
95
|
+
totals: z.object({
|
|
96
|
+
tokens: z.number(),
|
|
97
|
+
cost: z.number(),
|
|
98
|
+
run_count: z.number(),
|
|
99
|
+
}),
|
|
100
|
+
groups: z.array(
|
|
101
|
+
z.object({
|
|
102
|
+
app: z.string().nullable().optional(),
|
|
103
|
+
smith: z.string().nullable().optional(),
|
|
104
|
+
model: z.string().nullable().optional(),
|
|
105
|
+
// Customer-grouped views label unassigned usage `principal:<smith id>`.
|
|
106
|
+
customer: z.string().nullable().optional(),
|
|
107
|
+
tokens: z.number(),
|
|
108
|
+
cost: z.number(),
|
|
109
|
+
run_count: z.number(),
|
|
110
|
+
}),
|
|
111
|
+
),
|
|
112
|
+
/** Custom billable events aggregated per meter over the same filters. */
|
|
113
|
+
meters: z
|
|
114
|
+
.array(
|
|
115
|
+
z.object({
|
|
116
|
+
meter: z.string(),
|
|
117
|
+
customer: z.string().nullable().optional(),
|
|
118
|
+
quantity: z.number(),
|
|
119
|
+
events: z.number(),
|
|
120
|
+
}),
|
|
121
|
+
)
|
|
122
|
+
.optional(),
|
|
123
|
+
})
|
|
124
|
+
.meta({ id: "UsageBreakdownOut" });
|
|
125
|
+
|
|
126
|
+
/** One recorded billable usage event. */
|
|
127
|
+
export const UsageEventOut = z
|
|
128
|
+
.object({
|
|
129
|
+
id: z.string(),
|
|
130
|
+
smith_id: z.string(),
|
|
131
|
+
customer_id: z.string().nullable(),
|
|
132
|
+
meter: z.string(),
|
|
133
|
+
quantity: z.number(),
|
|
134
|
+
day: z.string(),
|
|
135
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
136
|
+
created_at: z.string().nullable(),
|
|
137
|
+
})
|
|
138
|
+
.meta({ id: "UsageEventOut" });
|
|
139
|
+
|
|
140
|
+
/** A page of usage events (keyset pagination). */
|
|
141
|
+
export const UsageEventListOut = z
|
|
142
|
+
.object({
|
|
143
|
+
data: z.array(UsageEventOut),
|
|
144
|
+
next_cursor: z.string().nullable(),
|
|
145
|
+
has_more: z.boolean(),
|
|
146
|
+
})
|
|
147
|
+
.meta({ id: "UsageEventListOut" });
|
|
148
|
+
|
|
149
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
150
|
+
|
|
151
|
+
export type ICSpanKind = z.infer<typeof ICSpanKindEnum>;
|
|
152
|
+
export type ICSpan = z.infer<typeof SpanOut>;
|
|
153
|
+
export type ICSpanNode = z.infer<typeof SpanNodeOut>;
|
|
154
|
+
export type ICTrace = z.infer<typeof TraceOut>;
|
|
155
|
+
export type ICTraceDetail = z.infer<typeof TraceDetailOut>;
|
|
156
|
+
export type ICUsageBreakdown = z.infer<typeof UsageBreakdownOut>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `projects` resource — the org control-plane
|
|
3
|
+
* surface (`/v1/organization/projects`). A project's `id` is the `tenant` that
|
|
4
|
+
* scopes all of its runtime data.
|
|
5
|
+
*
|
|
6
|
+
* Source of truth is the handler (`api/src/routes/projects.ts`): `serialize`
|
|
7
|
+
* emits the project shape, and minting (`api/src/tokens.ts::mintToken`) returns
|
|
8
|
+
* the token shape. The relic `sdk/openapi.json` supplied field/required hints
|
|
9
|
+
* only.
|
|
10
|
+
*
|
|
11
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
12
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
|
|
16
|
+
export const ProjectOut = z
|
|
17
|
+
.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
organization: z.string(),
|
|
20
|
+
name: z.string(),
|
|
21
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
22
|
+
/** ISO timestamp; null only if the row predates the column being set. */
|
|
23
|
+
created_at: z.string().nullable(),
|
|
24
|
+
/** Set when the project is archived (soft-deleted); null while live. */
|
|
25
|
+
archived_at: z.string().nullable(),
|
|
26
|
+
})
|
|
27
|
+
.meta({ id: "ProjectOut" });
|
|
28
|
+
|
|
29
|
+
export const ProjectListOut = z
|
|
30
|
+
.object({ data: z.array(ProjectOut) })
|
|
31
|
+
.meta({ id: "ProjectListOut" });
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The secret minted when an org mints a project (tenant-admin) token. Shape
|
|
35
|
+
* matches `mintToken`'s return; the `tenant` module owns the canonical
|
|
36
|
+
* `ICMintedToken` re-export, so this stays project-named and project-scoped.
|
|
37
|
+
*/
|
|
38
|
+
export const ProjectTokenOut = z
|
|
39
|
+
.object({
|
|
40
|
+
id: z.string(),
|
|
41
|
+
/** The branded secret handle (`tha_live_…`). Shown once. */
|
|
42
|
+
token: z.string(),
|
|
43
|
+
scope: z.string(),
|
|
44
|
+
sub: z.string(),
|
|
45
|
+
scopes: z.array(z.string()),
|
|
46
|
+
expires_at: z.string().nullable(),
|
|
47
|
+
})
|
|
48
|
+
.meta({ id: "ProjectTokenOut" });
|
|
49
|
+
|
|
50
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
export const ProjectIn = z
|
|
53
|
+
.object({
|
|
54
|
+
name: z.string(),
|
|
55
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
56
|
+
})
|
|
57
|
+
.meta({ id: "ProjectIn" });
|
|
58
|
+
|
|
59
|
+
export const ProjectTokenIn = z
|
|
60
|
+
.object({
|
|
61
|
+
ttl_seconds: z.number().int().nullish(),
|
|
62
|
+
name: z.string().nullish(),
|
|
63
|
+
})
|
|
64
|
+
.meta({ id: "ProjectTokenIn" });
|
|
65
|
+
|
|
66
|
+
// ── Inferred consumer-facing type ────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
export type ICProject = z.infer<typeof ProjectOut>;
|
package/ts/zod/runs.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `runs` resource — the wire's source of
|
|
3
|
+
* truth, replacing the inline `IC*` run shapes previously declared in
|
|
4
|
+
* `../responses`.
|
|
5
|
+
*
|
|
6
|
+
* One source, three outputs: the API imports these into its `createRoute`
|
|
7
|
+
* definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
|
|
8
|
+
* types are `z.infer`red from them here and re-exported by `../responses`. No
|
|
9
|
+
* Zod is pulled into a type-only consumer — `responses.ts` re-exports these as
|
|
10
|
+
* `export type`.
|
|
11
|
+
*
|
|
12
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
13
|
+
* `#/components/schemas/<id>` rather than inlining it. `ToolCall` and
|
|
14
|
+
* `RunUsage` are standalone (`$ref`'d) so the inferred `ICToolCall`/`ICRunUsage`
|
|
15
|
+
* come out identical to their hand-written interface ancestors.
|
|
16
|
+
*
|
|
17
|
+
* Only the JSON shapes are modelled here: the run object, the run list, run
|
|
18
|
+
* events + their list, and the create/submit request bodies. The streaming
|
|
19
|
+
* surfaces emit the native `{v:1}` SSE envelope (not a single JSON schema) and
|
|
20
|
+
* are deliberately not modelled.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
|
|
24
|
+
/** A tool call attached to a run's output. */
|
|
25
|
+
export const ToolCall = z
|
|
26
|
+
.object({
|
|
27
|
+
tool_call_id: z.string(),
|
|
28
|
+
tool: z.string(),
|
|
29
|
+
args: z.record(z.string(), z.unknown()),
|
|
30
|
+
execution: z.string(),
|
|
31
|
+
})
|
|
32
|
+
.meta({ id: "ToolCall" });
|
|
33
|
+
|
|
34
|
+
/** One run's own token usage (the `usage` map on a run). Distinct from the
|
|
35
|
+
* tenant's aggregated billing summary. */
|
|
36
|
+
export const RunUsage = z
|
|
37
|
+
.object({
|
|
38
|
+
input_tokens: z.number().int(),
|
|
39
|
+
output_tokens: z.number().int(),
|
|
40
|
+
total_tokens: z.number().int(),
|
|
41
|
+
})
|
|
42
|
+
.meta({ id: "RunUsage" });
|
|
43
|
+
|
|
44
|
+
export const RunOut = z
|
|
45
|
+
.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
smith_id: z.string(),
|
|
48
|
+
thread_id: z.string(),
|
|
49
|
+
status: z.string(),
|
|
50
|
+
channel: z.string(),
|
|
51
|
+
input: z.array(z.object({ role: z.string(), content: z.string() })),
|
|
52
|
+
output: z
|
|
53
|
+
.object({
|
|
54
|
+
content: z.string().optional(),
|
|
55
|
+
tool_calls: z.array(ToolCall).optional(),
|
|
56
|
+
})
|
|
57
|
+
.nullable(),
|
|
58
|
+
stop_reason: z.string().nullable(),
|
|
59
|
+
usage: RunUsage.nullable(),
|
|
60
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
61
|
+
created_at: z.string().nullable(),
|
|
62
|
+
updated_at: z.string().nullable(),
|
|
63
|
+
})
|
|
64
|
+
.meta({ id: "RunOut" });
|
|
65
|
+
|
|
66
|
+
export const RunListOut = z
|
|
67
|
+
.object({ data: z.array(RunOut) })
|
|
68
|
+
.meta({ id: "RunListOut" });
|
|
69
|
+
|
|
70
|
+
/** One recorded run event, as replayed from the event log. */
|
|
71
|
+
export const RunEventOut = z
|
|
72
|
+
.object({
|
|
73
|
+
seq: z.number().int(),
|
|
74
|
+
type: z.string(),
|
|
75
|
+
data: z.record(z.string(), z.unknown()),
|
|
76
|
+
created_at: z.string().nullable(),
|
|
77
|
+
})
|
|
78
|
+
.meta({ id: "RunEventOut" });
|
|
79
|
+
|
|
80
|
+
export const RunEventListOut = z
|
|
81
|
+
.object({ data: z.array(RunEventOut) })
|
|
82
|
+
.meta({ id: "RunEventListOut" });
|
|
83
|
+
|
|
84
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
export const RunIn = z
|
|
87
|
+
.object({
|
|
88
|
+
input: z.array(z.object({ role: z.string(), content: z.string() })).optional(),
|
|
89
|
+
thread_id: z.string().nullish(),
|
|
90
|
+
stream: z.boolean().optional(),
|
|
91
|
+
channel: z.string().optional(),
|
|
92
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
93
|
+
response_format: z.record(z.string(), z.unknown()).nullish(),
|
|
94
|
+
})
|
|
95
|
+
.meta({ id: "RunIn" });
|
|
96
|
+
|
|
97
|
+
export const Submit = z
|
|
98
|
+
.object({
|
|
99
|
+
kind: z.string(),
|
|
100
|
+
tool_call_id: z.string().nullish(),
|
|
101
|
+
result: z.record(z.string(), z.unknown()).nullish(),
|
|
102
|
+
approval_id: z.string().nullish(),
|
|
103
|
+
decision: z.string().nullish(),
|
|
104
|
+
actor: z.string().nullish(),
|
|
105
|
+
reason: z.string().nullish(),
|
|
106
|
+
stream: z.boolean().optional(),
|
|
107
|
+
})
|
|
108
|
+
.meta({ id: "Submit" });
|
|
109
|
+
|
|
110
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
111
|
+
|
|
112
|
+
export type ICToolCall = z.infer<typeof ToolCall>;
|
|
113
|
+
export type ICRunUsage = z.infer<typeof RunUsage>;
|
|
114
|
+
export type ICRun = z.infer<typeof RunOut>;
|
|
115
|
+
export type ICRunEvent = z.infer<typeof RunEventOut>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `schedules` resource — cron-triggered runs
|
|
3
|
+
* on a smith's agent — the wire's source of truth, replacing the loose
|
|
4
|
+
* generated `schemas.ts` shapes for this resource.
|
|
5
|
+
*
|
|
6
|
+
* One source, three outputs: the API imports these into its `createRoute`
|
|
7
|
+
* definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
|
|
8
|
+
* types are `z.infer`red from them here and re-exported by `../responses`. No
|
|
9
|
+
* Zod is pulled into a type-only consumer — `responses.ts` re-exports these as
|
|
10
|
+
* `export type`.
|
|
11
|
+
*
|
|
12
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
13
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
/** A schedule's stored input: messages replayed as the run input on each fire. */
|
|
18
|
+
const ScheduleInput = z.array(z.record(z.string(), z.unknown()));
|
|
19
|
+
|
|
20
|
+
export const ScheduleOut = z
|
|
21
|
+
.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
name: z.string().nullable(),
|
|
24
|
+
cron: z.string(),
|
|
25
|
+
timezone: z.string(),
|
|
26
|
+
/** Messages replayed as the run input on each fire. */
|
|
27
|
+
input: ScheduleInput,
|
|
28
|
+
/** Thread the fired runs append to; null mints a fresh thread per fire. */
|
|
29
|
+
thread_id: z.string().nullable(),
|
|
30
|
+
/** Max overlapping fired runs before new fires are skipped. */
|
|
31
|
+
max_concurrent: z.number().int(),
|
|
32
|
+
/** What a failed fire does next (e.g. `continue`, `pause`). */
|
|
33
|
+
on_failure: z.string(),
|
|
34
|
+
enabled: z.boolean(),
|
|
35
|
+
next_fire_at: z.string().nullable(),
|
|
36
|
+
last_fire_at: z.string().nullable(),
|
|
37
|
+
created_at: z.string().nullable(),
|
|
38
|
+
})
|
|
39
|
+
.meta({ id: "ScheduleOut" });
|
|
40
|
+
|
|
41
|
+
export const ScheduleListOut = z
|
|
42
|
+
.object({ data: z.array(ScheduleOut) })
|
|
43
|
+
.meta({ id: "ScheduleListOut" });
|
|
44
|
+
|
|
45
|
+
/** `POST .../:sid/run_now` — the schedule's id plus the run it just fired. */
|
|
46
|
+
export const ScheduleRunNowOut = z
|
|
47
|
+
.object({
|
|
48
|
+
schedule_id: z.string(),
|
|
49
|
+
run: z.record(z.string(), z.unknown()),
|
|
50
|
+
})
|
|
51
|
+
.meta({ id: "ScheduleRunNowOut" });
|
|
52
|
+
|
|
53
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
export const ScheduleIn = z
|
|
56
|
+
.object({
|
|
57
|
+
cron: z.string(),
|
|
58
|
+
name: z.string().nullish(),
|
|
59
|
+
timezone: z.string().default("UTC"),
|
|
60
|
+
input: ScheduleInput.default([]),
|
|
61
|
+
thread_id: z.string().nullish(),
|
|
62
|
+
max_concurrent: z.number().int().default(1),
|
|
63
|
+
on_failure: z.string().default("webhook"),
|
|
64
|
+
enabled: z.boolean().default(true),
|
|
65
|
+
})
|
|
66
|
+
.meta({ id: "ScheduleIn" });
|
|
67
|
+
|
|
68
|
+
export const SchedulePatch = z
|
|
69
|
+
.object({
|
|
70
|
+
name: z.string().nullish(),
|
|
71
|
+
cron: z.string().nullish(),
|
|
72
|
+
timezone: z.string().nullish(),
|
|
73
|
+
input: ScheduleInput.nullish(),
|
|
74
|
+
thread_id: z.string().nullish(),
|
|
75
|
+
max_concurrent: z.number().int().nullish(),
|
|
76
|
+
on_failure: z.string().nullish(),
|
|
77
|
+
enabled: z.boolean().nullish(),
|
|
78
|
+
})
|
|
79
|
+
.meta({ id: "SchedulePatch" });
|
|
80
|
+
|
|
81
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
82
|
+
|
|
83
|
+
export type ICSchedule = z.infer<typeof ScheduleOut>;
|