@ingram-cloud/sdk 1.0.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 +74 -0
- package/dist/client.js +460 -0
- package/dist/events.js +108 -0
- package/dist/index.js +19 -0
- package/dist/responses.js +12 -0
- package/dist/schemas.js +4 -0
- package/dist/zod/_page.js +17 -0
- package/dist/zod/agents.js +176 -0
- package/dist/zod/approvals.js +38 -0
- package/dist/zod/budgets.js +62 -0
- package/dist/zod/catalog.js +49 -0
- package/dist/zod/connections.js +75 -0
- package/dist/zod/conversations.js +91 -0
- package/dist/zod/customers.js +53 -0
- package/dist/zod/deployments.js +81 -0
- package/dist/zod/discord.js +32 -0
- package/dist/zod/email.js +45 -0
- package/dist/zod/files.js +55 -0
- package/dist/zod/index.js +35 -0
- package/dist/zod/mcp.js +107 -0
- package/dist/zod/memories.js +43 -0
- package/dist/zod/observability.js +133 -0
- package/dist/zod/projects.js +58 -0
- package/dist/zod/runs.js +119 -0
- package/dist/zod/schedules.js +71 -0
- package/dist/zod/slack.js +69 -0
- package/dist/zod/smith-revisions.js +42 -0
- package/dist/zod/smiths.js +108 -0
- package/dist/zod/telegram.js +36 -0
- package/dist/zod/tenant.js +219 -0
- package/dist/zod/vector-stores.js +251 -0
- package/dist/zod/whatsapp.js +47 -0
- package/package.json +56 -0
- package/ts/client.ts +1187 -0
- package/ts/events.ts +119 -0
- package/ts/index.ts +20 -0
- package/ts/responses.ts +83 -0
- package/ts/schemas.ts +4 -0
- package/ts/zod/_page.ts +18 -0
- package/ts/zod/agents.ts +202 -0
- package/ts/zod/approvals.ts +44 -0
- package/ts/zod/budgets.ts +75 -0
- package/ts/zod/catalog.ts +57 -0
- package/ts/zod/connections.ts +87 -0
- package/ts/zod/conversations.ts +103 -0
- package/ts/zod/customers.ts +62 -0
- package/ts/zod/deployments.ts +93 -0
- package/ts/zod/discord.ts +39 -0
- package/ts/zod/email.ts +52 -0
- package/ts/zod/files.ts +62 -0
- package/ts/zod/index.ts +35 -0
- package/ts/zod/mcp.ts +123 -0
- package/ts/zod/memories.ts +53 -0
- package/ts/zod/observability.ts +155 -0
- package/ts/zod/projects.ts +68 -0
- package/ts/zod/runs.ts +135 -0
- package/ts/zod/schedules.ts +82 -0
- package/ts/zod/slack.ts +79 -0
- package/ts/zod/smith-revisions.ts +50 -0
- package/ts/zod/smiths.ts +118 -0
- package/ts/zod/telegram.ts +43 -0
- package/ts/zod/tenant.ts +267 -0
- package/ts/zod/vector-stores.ts +296 -0
- package/ts/zod/whatsapp.ts +54 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types for the `/v1` JSON response bodies — the consumer-facing
|
|
3
|
+
* companion to the wire schemas, imported by API consumers (e.g. the console) to
|
|
4
|
+
* type the JSON they read back.
|
|
5
|
+
*
|
|
6
|
+
* The `IC*` types are `z.infer`red from the hand-authored Zod in
|
|
7
|
+
* `./zod/<resource>` (the wire's source of truth) and re-exported here as
|
|
8
|
+
* **types** — so this module stays Zod-free for `import type` consumers. Only the
|
|
9
|
+
* list-envelope generics ({@link ICList}/{@link ICPaginatedResponse}) are
|
|
10
|
+
* declared inline, since they're generic over any resource.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The wire's Zod schema map — the hand-authored schemas in ./zod, keyed by
|
|
2
|
+
* export name. Source of truth; consumed by the api test suite to validate
|
|
3
|
+
* wire shapes. (Replaces the former openapi-zod-client-generated file.) */
|
|
4
|
+
export * as schemas from "./zod/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared cursor-paginated list envelope. One definition so every paginated
|
|
3
|
+
* `/v1` list reads back the same shape: `data` + the opaque `next_cursor` (null
|
|
4
|
+
* on the last page) + `has_more`. The cursor is an opaque, short-lived token —
|
|
5
|
+
* pass it straight back as `?cursor=`, never parse it.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/** Wrap an item schema as a cursor-paginated list out, named `id` in the spec. */
|
|
9
|
+
export function pageOut(item, id) {
|
|
10
|
+
return z
|
|
11
|
+
.object({
|
|
12
|
+
data: z.array(item),
|
|
13
|
+
next_cursor: z.string().nullish(),
|
|
14
|
+
has_more: z.boolean(),
|
|
15
|
+
})
|
|
16
|
+
.meta({ id });
|
|
17
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `agents` 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
|
+
import { z } from "zod";
|
|
15
|
+
import { pageOut } from "./_page.js";
|
|
16
|
+
/** A per-smith variable an agent declares; bound at run time. */
|
|
17
|
+
export const AgentVariable = z
|
|
18
|
+
.object({
|
|
19
|
+
name: z.string(),
|
|
20
|
+
default: z.string().nullish(),
|
|
21
|
+
description: z.string().nullish(),
|
|
22
|
+
required: z.boolean().optional(),
|
|
23
|
+
})
|
|
24
|
+
.meta({ id: "AgentVariable" });
|
|
25
|
+
/** A predeclared UI-backed capability (Rung 2) bound to a UI template — the MCP
|
|
26
|
+
* host's model calls it as a typed tool and the template renders the result. */
|
|
27
|
+
export const UiResourceTool = z
|
|
28
|
+
.object({
|
|
29
|
+
description: z.string(),
|
|
30
|
+
/** JSON Schema for the tool's arguments (host-supplied). */
|
|
31
|
+
input_schema: z.record(z.string(), z.unknown()).optional(),
|
|
32
|
+
/** Scoped instruction the smith runs with when this tool is called. */
|
|
33
|
+
instruction: z.string().nullish(),
|
|
34
|
+
/** Writes gate through approval; reads flow freely (OpenUI Query/Mutation). */
|
|
35
|
+
mutating: z.boolean().optional(),
|
|
36
|
+
})
|
|
37
|
+
.meta({ id: "UiResourceTool" });
|
|
38
|
+
/** CSP domain allowlists for the sandboxed iframe — the MCP Apps `_meta.ui.csp`
|
|
39
|
+
* shape (each key a list of allowed origins), passed through to the host verbatim. */
|
|
40
|
+
export const UiCsp = z
|
|
41
|
+
.object({
|
|
42
|
+
connectDomains: z.array(z.string()).optional(),
|
|
43
|
+
resourceDomains: z.array(z.string()).optional(),
|
|
44
|
+
frameDomains: z.array(z.string()).optional(),
|
|
45
|
+
baseUriDomains: z.array(z.string()).optional(),
|
|
46
|
+
})
|
|
47
|
+
.meta({ id: "UiCsp" });
|
|
48
|
+
/** A tenant-authored interactive UI template (MCP Apps, SEP-1865) attached to an
|
|
49
|
+
* agent. The HTML bundle lives in blob storage; this is its wire metadata (the
|
|
50
|
+
* internal blob ref is never exposed). `csp`/`permissions` mirror the standard
|
|
51
|
+
* `_meta.ui` shape and are echoed to the host on `resources/read`. */
|
|
52
|
+
export const UiResource = z
|
|
53
|
+
.object({
|
|
54
|
+
name: z.string(),
|
|
55
|
+
content_hash: z.string(),
|
|
56
|
+
csp: UiCsp.optional(),
|
|
57
|
+
/** Host permissions the template requests, a Permissions-Policy-style map
|
|
58
|
+
* (e.g. `{ "camera": {}, "microphone": {} }`). */
|
|
59
|
+
permissions: z.record(z.string(), z.unknown()).optional(),
|
|
60
|
+
tool: UiResourceTool.nullish(),
|
|
61
|
+
})
|
|
62
|
+
.meta({ id: "UiResource" });
|
|
63
|
+
/** The mutable draft head — what the next publish snapshots. */
|
|
64
|
+
export const AgentDraft = z
|
|
65
|
+
.object({
|
|
66
|
+
instructions: z.string().nullable(),
|
|
67
|
+
model: z.string().nullable(),
|
|
68
|
+
enabled_hosted_tools: z.array(z.string()),
|
|
69
|
+
vector_store_ids: z.array(z.string()),
|
|
70
|
+
auto_memory: z.boolean().nullable(),
|
|
71
|
+
memory_consolidation: z.boolean().nullable(),
|
|
72
|
+
variables: z.array(AgentVariable),
|
|
73
|
+
ui_resources: z.array(UiResource),
|
|
74
|
+
})
|
|
75
|
+
.meta({ id: "AgentDraft" });
|
|
76
|
+
export const AgentOut = z
|
|
77
|
+
.object({
|
|
78
|
+
id: z.string(),
|
|
79
|
+
/** Immutable, project-unique IaC reconcile key. Null for the default agent. */
|
|
80
|
+
slug: z.string().nullable(),
|
|
81
|
+
/** Free, mutable display label (not unique). */
|
|
82
|
+
name: z.string(),
|
|
83
|
+
/** True for the lazily-created default agent (can't be deleted). */
|
|
84
|
+
is_default: z.boolean(),
|
|
85
|
+
draft: AgentDraft,
|
|
86
|
+
active_version: z.number().int().nullable(),
|
|
87
|
+
rollout_version: z.number().int().nullable(),
|
|
88
|
+
rollout_percent: z.number().int(),
|
|
89
|
+
smith_count: z.number().int().optional(),
|
|
90
|
+
created_at: z.string().nullable(),
|
|
91
|
+
updated_at: z.string().nullable(),
|
|
92
|
+
})
|
|
93
|
+
.meta({ id: "AgentOut" });
|
|
94
|
+
export const AgentListOut = pageOut(AgentOut, "AgentListOut");
|
|
95
|
+
/** A published, immutable version snapshot of an agent. */
|
|
96
|
+
export const AgentVersionOut = z
|
|
97
|
+
.object({
|
|
98
|
+
version: z.number().int(),
|
|
99
|
+
snapshot: z.object({
|
|
100
|
+
instructions: z.string().nullish(),
|
|
101
|
+
model: z.string().nullish(),
|
|
102
|
+
enabled_hosted_tools: z.array(z.string()).optional(),
|
|
103
|
+
vector_store_ids: z.array(z.string()).optional(),
|
|
104
|
+
auto_memory: z.boolean().nullish(),
|
|
105
|
+
memory_consolidation: z.boolean().nullish(),
|
|
106
|
+
variables: z.array(AgentVariable).optional(),
|
|
107
|
+
ui_resources: z.array(UiResource).optional(),
|
|
108
|
+
}),
|
|
109
|
+
created_by: z.string().nullable(),
|
|
110
|
+
note: z.string().nullable(),
|
|
111
|
+
created_at: z.string().nullable(),
|
|
112
|
+
})
|
|
113
|
+
.meta({ id: "AgentVersionOut" });
|
|
114
|
+
export const AgentVersionListOut = z
|
|
115
|
+
.object({ data: z.array(AgentVersionOut) })
|
|
116
|
+
.meta({ id: "AgentVersionListOut" });
|
|
117
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
118
|
+
export const AgentIn = z
|
|
119
|
+
.object({
|
|
120
|
+
name: z.string(),
|
|
121
|
+
slug: z.string().nullish(),
|
|
122
|
+
instructions: z.string().nullish(),
|
|
123
|
+
model: z.string().nullish(),
|
|
124
|
+
enabled_hosted_tools: z.array(z.string()).nullish(),
|
|
125
|
+
vector_store_ids: z.array(z.string()).nullish(),
|
|
126
|
+
auto_memory: z.boolean().nullish(),
|
|
127
|
+
memory_consolidation: z.boolean().nullish(),
|
|
128
|
+
variables: z.array(AgentVariable).nullish(),
|
|
129
|
+
})
|
|
130
|
+
.meta({ id: "AgentIn" });
|
|
131
|
+
export const AgentPatch = z
|
|
132
|
+
.object({
|
|
133
|
+
name: z.string().nullish(),
|
|
134
|
+
instructions: z.string().nullish(),
|
|
135
|
+
model: z.string().nullish(),
|
|
136
|
+
enabled_hosted_tools: z.array(z.string()).nullish(),
|
|
137
|
+
vector_store_ids: z.array(z.string()).nullish(),
|
|
138
|
+
auto_memory: z.boolean().nullish(),
|
|
139
|
+
memory_consolidation: z.boolean().nullish(),
|
|
140
|
+
variables: z.array(AgentVariable).nullish(),
|
|
141
|
+
})
|
|
142
|
+
.meta({ id: "AgentPatch" });
|
|
143
|
+
export const RolloutIn = z
|
|
144
|
+
.object({
|
|
145
|
+
version: z.number().int(),
|
|
146
|
+
percent: z.number().int().min(0).max(100).default(100),
|
|
147
|
+
})
|
|
148
|
+
.meta({ id: "RolloutIn" });
|
|
149
|
+
export const PublishIn = z
|
|
150
|
+
.object({ note: z.string().nullish() })
|
|
151
|
+
.meta({ id: "PublishIn" });
|
|
152
|
+
export const ImportIn = z
|
|
153
|
+
.object({ from_smith: z.string(), name: z.string() })
|
|
154
|
+
.meta({ id: "ImportIn" });
|
|
155
|
+
export const AttachIn = z
|
|
156
|
+
.object({
|
|
157
|
+
all: z.boolean().default(false),
|
|
158
|
+
smith_ids: z.array(z.string()).nullish(),
|
|
159
|
+
})
|
|
160
|
+
.meta({ id: "AttachIn" });
|
|
161
|
+
/** The JSON `metadata` part of a UI-template multipart upload (the HTML bundle
|
|
162
|
+
* rides the `file` part). */
|
|
163
|
+
export const UiResourceIn = z
|
|
164
|
+
.object({
|
|
165
|
+
name: z
|
|
166
|
+
.string()
|
|
167
|
+
.regex(/^[a-z0-9][a-z0-9_-]*$/, "lowercase letters, digits, - and _")
|
|
168
|
+
.max(63),
|
|
169
|
+
csp: UiCsp.nullish(),
|
|
170
|
+
permissions: z.record(z.string(), z.unknown()).nullish(),
|
|
171
|
+
tool: UiResourceTool.nullish(),
|
|
172
|
+
})
|
|
173
|
+
.meta({ id: "UiResourceIn" });
|
|
174
|
+
export const UiResourceListOut = z
|
|
175
|
+
.object({ data: z.array(UiResource) })
|
|
176
|
+
.meta({ id: "UiResourceListOut" });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `approvals` 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
|
+
* The approvals route is read-only (list + get); there is no decision/submit
|
|
15
|
+
* body here — approvals are resolved on the standard tool-call channel via the
|
|
16
|
+
* run's `/submit`, not a bespoke endpoint.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import { pageOut } from "./_page.js";
|
|
20
|
+
/** A first-class human-in-the-loop decision raised by a paused run. */
|
|
21
|
+
export const ApprovalOut = z
|
|
22
|
+
.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
run_id: z.string().nullable(),
|
|
25
|
+
smith_id: z.string().nullable(),
|
|
26
|
+
tool_call_id: z.string().nullable(),
|
|
27
|
+
tool: z.string().nullable(),
|
|
28
|
+
/** The tool-call arguments awaiting a decision; `{}` when none. */
|
|
29
|
+
args: z.record(z.string(), z.unknown()),
|
|
30
|
+
/** pending | approved | rejected. */
|
|
31
|
+
status: z.string(),
|
|
32
|
+
actor: z.string().nullable(),
|
|
33
|
+
reason: z.string().nullable(),
|
|
34
|
+
created_at: z.string().nullable(),
|
|
35
|
+
resolved_at: z.string().nullable(),
|
|
36
|
+
})
|
|
37
|
+
.meta({ id: "ApprovalOut" });
|
|
38
|
+
export const ApprovalListOut = pageOut(ApprovalOut, "ApprovalListOut");
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `budgets` 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
|
+
import { z } from "zod";
|
|
15
|
+
/** What a budget caps; `agent`/`smith`/`customer` budgets carry the id in
|
|
16
|
+
* `scope_id` (an agent design, a single smith, or one of your customers). */
|
|
17
|
+
export const BudgetScope = z.enum(["tenant", "agent", "smith", "customer"]);
|
|
18
|
+
/** Whether crossing the cap warns or blocks new runs. */
|
|
19
|
+
export const BudgetAction = z.enum(["warn", "block"]);
|
|
20
|
+
/** A monthly spend cap on a scope. `limit` is in `currency` — the platform billing
|
|
21
|
+
* currency (EUR by default), not necessarily USD; the field is currency-agnostic. */
|
|
22
|
+
export const BudgetOut = z
|
|
23
|
+
.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
scope: BudgetScope,
|
|
26
|
+
scope_id: z.string().nullish(),
|
|
27
|
+
period: z.string(),
|
|
28
|
+
limit: z.number(),
|
|
29
|
+
// ISO-4217, lower-case. The denomination of `limit` and `/status`'s `spent`.
|
|
30
|
+
currency: z.string(),
|
|
31
|
+
action: BudgetAction,
|
|
32
|
+
created_at: z.string().nullish(),
|
|
33
|
+
})
|
|
34
|
+
.meta({ id: "BudgetOut" });
|
|
35
|
+
/** A budget plus its month-to-date spend, computed by `/status`. */
|
|
36
|
+
export const BudgetStatusOut = BudgetOut.extend({
|
|
37
|
+
period_start: z.string(),
|
|
38
|
+
period_key: z.string(),
|
|
39
|
+
spent: z.number(),
|
|
40
|
+
pct: z.number(),
|
|
41
|
+
over: z.boolean(),
|
|
42
|
+
}).meta({ id: "BudgetStatusOut" });
|
|
43
|
+
export const BudgetListOut = z
|
|
44
|
+
.object({ data: z.array(BudgetOut) })
|
|
45
|
+
.meta({ id: "BudgetListOut" });
|
|
46
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
47
|
+
export const BudgetIn = z
|
|
48
|
+
.object({
|
|
49
|
+
scope: z.string(),
|
|
50
|
+
scope_id: z.string().nullish(),
|
|
51
|
+
// The cap, in the platform billing currency (EUR by default).
|
|
52
|
+
limit: z.number(),
|
|
53
|
+
action: z.string().default("warn"),
|
|
54
|
+
period: z.string().default("monthly"),
|
|
55
|
+
})
|
|
56
|
+
.meta({ id: "BudgetIn" });
|
|
57
|
+
export const BudgetPatch = z
|
|
58
|
+
.object({
|
|
59
|
+
limit: z.number().nullish(),
|
|
60
|
+
action: z.string().nullish(),
|
|
61
|
+
})
|
|
62
|
+
.meta({ id: "BudgetPatch" });
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `catalog` resource — the Ingram-curated MCP
|
|
3
|
+
* integration presets exposed at `GET /v1/catalog`.
|
|
4
|
+
*
|
|
5
|
+
* One source, three outputs: the API imports these into its `createRoute`
|
|
6
|
+
* definitions (validation + emitted OpenAPI), and the consumer-facing `IC*`
|
|
7
|
+
* type is `z.infer`red from them here and re-exported by `../responses`. No Zod
|
|
8
|
+
* 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
|
+
import { z } from "zod";
|
|
15
|
+
/**
|
|
16
|
+
* The approval-rule shape a catalog entry carries as its `default_approval_policy`.
|
|
17
|
+
*
|
|
18
|
+
* Defined inline (not imported from `./mcp`) to keep this module independent of
|
|
19
|
+
* the parallel mcp authoring. It mirrors the canonical mcp `ApprovalRule`:
|
|
20
|
+
* a tool-name `match` glob and an optional `require` mode.
|
|
21
|
+
*/
|
|
22
|
+
const ApprovalRule = z.object({
|
|
23
|
+
match: z.string(),
|
|
24
|
+
require: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
/** How a catalog integration authenticates; surfaced flattened on the wire. */
|
|
27
|
+
const CatalogAuth = z.object({
|
|
28
|
+
kind: z.string(),
|
|
29
|
+
provider: z.string().nullable(),
|
|
30
|
+
client_mode: z.string(),
|
|
31
|
+
});
|
|
32
|
+
export const CatalogEntryOut = z
|
|
33
|
+
.object({
|
|
34
|
+
slug: z.string(),
|
|
35
|
+
display_name: z.string(),
|
|
36
|
+
description: z.string(),
|
|
37
|
+
mcp_url: z.string(),
|
|
38
|
+
auth: CatalogAuth,
|
|
39
|
+
scopes: z.array(z.string()),
|
|
40
|
+
/** null = expose all discovered tools; otherwise the default-deny set. */
|
|
41
|
+
default_allowlist: z.array(z.string()).nullable(),
|
|
42
|
+
default_approval_policy: z.array(ApprovalRule),
|
|
43
|
+
logo_url: z.string().nullable(),
|
|
44
|
+
docs_url: z.string().nullable(),
|
|
45
|
+
})
|
|
46
|
+
.meta({ id: "CatalogEntryOut" });
|
|
47
|
+
export const CatalogListOut = z
|
|
48
|
+
.object({ data: z.array(CatalogEntryOut) })
|
|
49
|
+
.meta({ id: "CatalogListOut" });
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `connections` resource — per-smith OAuth
|
|
3
|
+
* grants under `/v1/smiths/:pid/connections`. The wire's source of truth,
|
|
4
|
+
* replacing the loose 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
|
+
* SECURITY INVARIANT: `ConnectionOut` NEVER carries the secret credential
|
|
13
|
+
* material — only `id`, `provider`, `scopes`, `status`, `expires_at`,
|
|
14
|
+
* `metadata`, `created_at`. The handler's `toPublic` serializer is validated
|
|
15
|
+
* against this schema.
|
|
16
|
+
*
|
|
17
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
18
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
/** OAuth token material the tenant pushes in; IC stores it encrypted and never
|
|
22
|
+
* echoes it back. Only `kind: "oauth_tokens"` is accepted. */
|
|
23
|
+
export const Credential = z
|
|
24
|
+
.object({
|
|
25
|
+
kind: z.string().optional(),
|
|
26
|
+
access_token: z.string().nullish(),
|
|
27
|
+
refresh_token: z.string().nullish(),
|
|
28
|
+
expires_at: z.string().nullish(),
|
|
29
|
+
token_uri: z.string().nullish(),
|
|
30
|
+
})
|
|
31
|
+
.meta({ id: "Credential" });
|
|
32
|
+
/** A connection WITHOUT the secret credential material. */
|
|
33
|
+
export const ConnectionOut = z
|
|
34
|
+
.object({
|
|
35
|
+
id: z.string(),
|
|
36
|
+
provider: z.string(),
|
|
37
|
+
scopes: z.array(z.string()),
|
|
38
|
+
status: z.string(),
|
|
39
|
+
expires_at: z.string().nullable(),
|
|
40
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
41
|
+
created_at: z.string().nullable(),
|
|
42
|
+
})
|
|
43
|
+
.meta({ id: "ConnectionOut" });
|
|
44
|
+
export const ConnectionListOut = z
|
|
45
|
+
.object({ data: z.array(ConnectionOut) })
|
|
46
|
+
.meta({ id: "ConnectionListOut" });
|
|
47
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
48
|
+
export const ConnectionIn = z
|
|
49
|
+
.object({
|
|
50
|
+
provider: z.string(),
|
|
51
|
+
scopes: z.array(z.string()).optional(),
|
|
52
|
+
credential: Credential,
|
|
53
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
54
|
+
})
|
|
55
|
+
.meta({ id: "ConnectionIn" });
|
|
56
|
+
export const ConnectionPatch = z
|
|
57
|
+
.object({
|
|
58
|
+
scopes: z.array(z.string()).nullish(),
|
|
59
|
+
credential: Credential.nullish(),
|
|
60
|
+
status: z.string().nullish(),
|
|
61
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
62
|
+
})
|
|
63
|
+
.meta({ id: "ConnectionPatch" });
|
|
64
|
+
/** The `authorize` 200 body: the minted authorize URL + echoed provider. */
|
|
65
|
+
export const AuthorizeOut = z
|
|
66
|
+
.object({ authorize_url: z.string().nullable(), provider: z.string() })
|
|
67
|
+
.meta({ id: "AuthorizeOut" });
|
|
68
|
+
/** Body for the OAuth consent broker: `POST …/connections/authorize`. */
|
|
69
|
+
export const AuthorizeIn = z
|
|
70
|
+
.object({
|
|
71
|
+
provider: z.string(),
|
|
72
|
+
return_url: z.string().nullish(),
|
|
73
|
+
mcp_server: z.string().nullish(),
|
|
74
|
+
})
|
|
75
|
+
.meta({ id: "AuthorizeIn" });
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `conversations` resource — the wire's source
|
|
3
|
+
* of truth, mapped onto the OpenAI **Conversations API** so an OpenAI client
|
|
4
|
+
* library talks to it unchanged.
|
|
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 here and re-exported by `../responses`.
|
|
9
|
+
*
|
|
10
|
+
* Standards mapping: the object matches OpenAI's `conversation`
|
|
11
|
+
* (`id`/`object`/`created_at`/`metadata`); `title`, `smith_id`, and `updated_at`
|
|
12
|
+
* are documented IC extensions OpenAI omits (OpenAI has no title and no list
|
|
13
|
+
* endpoint, both of which a console conversation list needs). `created_at`/
|
|
14
|
+
* `updated_at` are unix-second integers like every OpenAI object, not the ISO
|
|
15
|
+
* strings the native `ic_*` resources use. Items are read-only and reconstructed
|
|
16
|
+
* from the conversation's runs — they accrue from `/v1/responses`, not a write
|
|
17
|
+
* endpoint.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
import { pageOut } from "./_page.js";
|
|
21
|
+
/** A conversation — the OpenAI Conversations object + IC extensions. */
|
|
22
|
+
export const ConversationOut = z
|
|
23
|
+
.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
object: z.literal("conversation"),
|
|
26
|
+
/** Unix seconds, like every OpenAI object. */
|
|
27
|
+
created_at: z.number().int(),
|
|
28
|
+
/** Unix seconds of the last run in the conversation (IC extension). */
|
|
29
|
+
updated_at: z.number().int(),
|
|
30
|
+
/** Auto-set from the first user turn of a Responses-API run that names this
|
|
31
|
+
* conversation; null until then. Set it yourself any time. IC extension. */
|
|
32
|
+
title: z.string().nullable(),
|
|
33
|
+
/** The smith that owns this conversation. IC extension. */
|
|
34
|
+
smith_id: z.string(),
|
|
35
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
36
|
+
})
|
|
37
|
+
.meta({ id: "ConversationOut" });
|
|
38
|
+
export const ConversationListOut = pageOut(ConversationOut, "ConversationListOut");
|
|
39
|
+
/** The delete acknowledgement, in OpenAI's `*.deleted` shape. */
|
|
40
|
+
export const ConversationDeleted = z
|
|
41
|
+
.object({
|
|
42
|
+
id: z.string(),
|
|
43
|
+
object: z.literal("conversation.deleted"),
|
|
44
|
+
deleted: z.literal(true),
|
|
45
|
+
})
|
|
46
|
+
.meta({ id: "ConversationDeleted" });
|
|
47
|
+
/** One reconstructed item in a conversation. Modelled loosely on the Responses
|
|
48
|
+
* output items: a `message` carries `content` parts (`input_text`/`output_text`);
|
|
49
|
+
* the tool-step items mirror their wire shapes — `function_call`
|
|
50
|
+
* (`call_id`/`name`/`arguments`) and `function_call_output` (`call_id`/`output`) for
|
|
51
|
+
* client-side tools, `mcp_call` (`name`/`arguments`/`output`/`server_label`) for a
|
|
52
|
+
* tool the run loop executed server-side. */
|
|
53
|
+
export const ConversationItem = z
|
|
54
|
+
.object({
|
|
55
|
+
id: z.string(),
|
|
56
|
+
type: z.string(),
|
|
57
|
+
role: z.string().optional(),
|
|
58
|
+
status: z.string().optional(),
|
|
59
|
+
content: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
60
|
+
// Tool-step fields (present on function_call / function_call_output / mcp_call).
|
|
61
|
+
call_id: z.string().optional(),
|
|
62
|
+
name: z.string().optional(),
|
|
63
|
+
arguments: z.string().optional(),
|
|
64
|
+
output: z.string().optional(),
|
|
65
|
+
server_label: z.string().optional(),
|
|
66
|
+
})
|
|
67
|
+
.meta({ id: "ConversationItem" });
|
|
68
|
+
/** 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" });
|
|
78
|
+
/** Create body — OpenAI accepts `metadata`; `title` is the IC extension. */
|
|
79
|
+
export const ConversationCreate = z
|
|
80
|
+
.object({
|
|
81
|
+
title: z.string().optional(),
|
|
82
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
83
|
+
})
|
|
84
|
+
.meta({ id: "ConversationCreate" });
|
|
85
|
+
/** Update body — set the title and/or merge metadata. */
|
|
86
|
+
export const ConversationUpdate = z
|
|
87
|
+
.object({
|
|
88
|
+
title: z.string().optional(),
|
|
89
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
90
|
+
})
|
|
91
|
+
.meta({ id: "ConversationUpdate" });
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `customers` resource — the wire's source of
|
|
3
|
+
* truth, replacing the loose generated 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
|
+
* A customer is the *tenant's* billable party for its smiths (never ours); many
|
|
12
|
+
* smiths roll up to one customer, so `smith_count` is a correlated count.
|
|
13
|
+
*
|
|
14
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
15
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
export const CustomerOut = z
|
|
19
|
+
.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
name: z.string(),
|
|
22
|
+
/** Opaque external system → id map (e.g. CRM/billing keys). */
|
|
23
|
+
external_ids: z.record(z.string(), z.string()),
|
|
24
|
+
/** Free-form tenant annotations. */
|
|
25
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
26
|
+
/** Active smiths rolling up to this customer; present on single-customer reads. */
|
|
27
|
+
smith_count: z.number().int().optional(),
|
|
28
|
+
created_at: z.string().nullable(),
|
|
29
|
+
})
|
|
30
|
+
.meta({ id: "CustomerOut" });
|
|
31
|
+
/** Paginated list envelope: keyset cursor over `created_at, id` (desc). */
|
|
32
|
+
export const CustomerListOut = z
|
|
33
|
+
.object({
|
|
34
|
+
data: z.array(CustomerOut),
|
|
35
|
+
next_cursor: z.string().nullable(),
|
|
36
|
+
has_more: z.boolean(),
|
|
37
|
+
})
|
|
38
|
+
.meta({ id: "CustomerListOut" });
|
|
39
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
40
|
+
export const CustomerCreate = z
|
|
41
|
+
.object({
|
|
42
|
+
name: z.string(),
|
|
43
|
+
external_ids: z.record(z.string(), z.string()).optional(),
|
|
44
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
45
|
+
})
|
|
46
|
+
.meta({ id: "CustomerCreate" });
|
|
47
|
+
export const CustomerPatch = z
|
|
48
|
+
.object({
|
|
49
|
+
name: z.string().nullish(),
|
|
50
|
+
external_ids: z.record(z.string(), z.string()).nullish(),
|
|
51
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
52
|
+
})
|
|
53
|
+
.meta({ id: "CustomerPatch" });
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `deployments` resource — messaging endpoints
|
|
3
|
+
* attached to a smith (Telegram/WhatsApp/Slack/SMS/voice/email).
|
|
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 response shapes on purpose: `DeploymentOut` is the plain serializer
|
|
15
|
+
* (`api/src/runtime/deployments.ts::publicDeployment`) returned by GET/list, PATCH,
|
|
16
|
+
* and the email `provision` create. `DeploymentCreatedOut` is the richer create
|
|
17
|
+
* response — the deferred-setup gateways (telegram/whatsapp `start_token`,
|
|
18
|
+
* slack `provision`/`oauth_install`) hand back binding affordances on top of
|
|
19
|
+
* the base shape (`start_token` + `deep_link`, slack's `install_url`/`state`,
|
|
20
|
+
* …). The relic `DeploymentOut` did NOT document these create-only fields; the
|
|
21
|
+
* handler is the truth, so they live here as optionals.
|
|
22
|
+
*/
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
import { pageOut } from "./_page.js";
|
|
25
|
+
/** A deployment's target: a fixed `smith` (one running clone) or an `agent`
|
|
26
|
+
* catch-all that mints a fresh smith per inbound sender. */
|
|
27
|
+
export const DeploymentTarget = z
|
|
28
|
+
.object({ type: z.enum(["smith", "agent"]), id: z.string() })
|
|
29
|
+
.meta({ id: "DeploymentTarget" });
|
|
30
|
+
export const DeploymentOut = z
|
|
31
|
+
.object({
|
|
32
|
+
id: z.string(),
|
|
33
|
+
target: DeploymentTarget,
|
|
34
|
+
kind: z.string(),
|
|
35
|
+
address: z.string().nullable(),
|
|
36
|
+
provider: z.string().nullable(),
|
|
37
|
+
provider_metadata: z.record(z.string(), z.unknown()).optional(),
|
|
38
|
+
/** Names of the encrypted secret fields that are set (values never returned). */
|
|
39
|
+
secret_keys: z.array(z.string()).optional(),
|
|
40
|
+
status: z.string(),
|
|
41
|
+
created_at: z.string().nullable(),
|
|
42
|
+
})
|
|
43
|
+
.meta({ id: "DeploymentOut" });
|
|
44
|
+
export const DeploymentListOut = pageOut(DeploymentOut, "DeploymentListOut");
|
|
45
|
+
/**
|
|
46
|
+
* The richer create response. Beyond the base `DeploymentOut`, the setup gateways
|
|
47
|
+
* attach provider-specific binding affordances:
|
|
48
|
+
* - telegram `start_token`: `start_token`, `deep_link` (t.me link).
|
|
49
|
+
* - whatsapp `start_token`: `start_token`, `prefilled_message`, `deep_link` (wa.me link).
|
|
50
|
+
* - slack `provision`/`oauth_install`: `install_url`, `state`, optional `slack_app_id`.
|
|
51
|
+
* - email `provision`: no extras (plain `DeploymentOut`).
|
|
52
|
+
* All are optional — which appear depends on the kind + setup mode.
|
|
53
|
+
*/
|
|
54
|
+
export const DeploymentCreatedOut = DeploymentOut.extend({
|
|
55
|
+
start_token: z.string().optional(),
|
|
56
|
+
deep_link: z.string().optional(),
|
|
57
|
+
prefilled_message: z.string().optional(),
|
|
58
|
+
install_url: z.string().optional(),
|
|
59
|
+
state: z.string().optional(),
|
|
60
|
+
slack_app_id: z.string().optional(),
|
|
61
|
+
}).meta({ id: "DeploymentCreatedOut" });
|
|
62
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
63
|
+
export const DeploymentIn = z
|
|
64
|
+
.object({
|
|
65
|
+
/** Who the deployment binds: a `smith` (fixed) or an `agent` (mints a smith
|
|
66
|
+
* per inbound sender). A smith token may only target its own smith. */
|
|
67
|
+
target: DeploymentTarget,
|
|
68
|
+
kind: z.string(),
|
|
69
|
+
address: z.string().nullish(),
|
|
70
|
+
provider: z.string().nullish(),
|
|
71
|
+
provider_metadata: z.record(z.string(), z.unknown()).optional(),
|
|
72
|
+
secrets: z.record(z.string(), z.unknown()).optional(),
|
|
73
|
+
setup: z.record(z.string(), z.unknown()).nullish(),
|
|
74
|
+
})
|
|
75
|
+
.meta({ id: "DeploymentIn" });
|
|
76
|
+
export const DeploymentPatch = z
|
|
77
|
+
.object({
|
|
78
|
+
display_name: z.string().nullish(),
|
|
79
|
+
owner_email: z.string().nullish(),
|
|
80
|
+
})
|
|
81
|
+
.meta({ id: "DeploymentPatch" });
|