@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,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `memory` resource — the wire's source of
|
|
3
|
+
* truth, imported by the API's `createRoute` definitions (validation + emitted
|
|
4
|
+
* OpenAPI) and `z.infer`red into the consumer-facing `IC*` types re-exported by
|
|
5
|
+
* `../responses`.
|
|
6
|
+
*
|
|
7
|
+
* Memory is Mastra-native (workstream #65): a smith has one **working-memory**
|
|
8
|
+
* doc (structured, auto-maintained) plus automatic **semantic recall** over its
|
|
9
|
+
* past messages. There is no standalone "file a fact" CRUD — recall is over the
|
|
10
|
+
* conversation history the smith already produced.
|
|
11
|
+
*
|
|
12
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
13
|
+
* `#/components/schemas/<id>`.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
/** A smith's working-memory doc — the structured text the agent maintains about
|
|
18
|
+
* its end user, shared across the smith's threads (resource-scoped). */
|
|
19
|
+
export const WorkingMemoryOut = z
|
|
20
|
+
.object({ content: z.string() })
|
|
21
|
+
.meta({ id: "WorkingMemoryOut" });
|
|
22
|
+
|
|
23
|
+
/** Replace a smith's working-memory doc. */
|
|
24
|
+
export const WorkingMemorySet = z
|
|
25
|
+
.object({ content: z.string() })
|
|
26
|
+
.meta({ id: "WorkingMemorySet" });
|
|
27
|
+
|
|
28
|
+
/** Recall query over a smith's past messages. */
|
|
29
|
+
export const RecallBody = z
|
|
30
|
+
.object({
|
|
31
|
+
query: z.string(),
|
|
32
|
+
limit: z.number().int().default(10),
|
|
33
|
+
})
|
|
34
|
+
.meta({ id: "RecallBody" });
|
|
35
|
+
|
|
36
|
+
/** One recall hit — a relevant past message range with its similarity `score`. */
|
|
37
|
+
export const RecallHit = z
|
|
38
|
+
.object({
|
|
39
|
+
thread_id: z.string(),
|
|
40
|
+
content: z.string(),
|
|
41
|
+
score: z.number(),
|
|
42
|
+
})
|
|
43
|
+
.meta({ id: "RecallHit" });
|
|
44
|
+
|
|
45
|
+
/** Recall response envelope — ranked hits. */
|
|
46
|
+
export const RecallOut = z
|
|
47
|
+
.object({ data: z.array(RecallHit) })
|
|
48
|
+
.meta({ id: "RecallOut" });
|
|
49
|
+
|
|
50
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
51
|
+
|
|
52
|
+
export type ICWorkingMemory = z.infer<typeof WorkingMemoryOut>;
|
|
53
|
+
export type ICRecallHit = z.infer<typeof RecallHit>;
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
import { pageOut } from "./_page.js";
|
|
23
|
+
|
|
24
|
+
/** Span kinds emitted by the observability backend. `retrieval` covers vector-store
|
|
25
|
+
* search (the hosted `file_search` tool, and externally-pushed RAG spans). */
|
|
26
|
+
export const ICSpanKindEnum = z
|
|
27
|
+
.enum([
|
|
28
|
+
"run",
|
|
29
|
+
"model_call",
|
|
30
|
+
"tool_call",
|
|
31
|
+
"memory_op",
|
|
32
|
+
"retrieval",
|
|
33
|
+
"runtime_event",
|
|
34
|
+
])
|
|
35
|
+
.meta({ id: "SpanKind" });
|
|
36
|
+
|
|
37
|
+
/** A single timed unit of work inside a trace. */
|
|
38
|
+
export const SpanOut = z
|
|
39
|
+
.object({
|
|
40
|
+
id: z.string(),
|
|
41
|
+
trace_id: z.string(),
|
|
42
|
+
parent_span_id: z.string().nullable(),
|
|
43
|
+
kind: ICSpanKindEnum,
|
|
44
|
+
name: z.string(),
|
|
45
|
+
status: z.string(),
|
|
46
|
+
started_at: z.string(),
|
|
47
|
+
ended_at: z.string().nullable(),
|
|
48
|
+
duration_ms: z.number().int().nullable(),
|
|
49
|
+
model: z.string().nullable(),
|
|
50
|
+
input_tokens: z.number().int().nullable(),
|
|
51
|
+
output_tokens: z.number().int().nullable(),
|
|
52
|
+
cost: z.number().nullable(),
|
|
53
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
54
|
+
})
|
|
55
|
+
.meta({ id: "SpanOut" });
|
|
56
|
+
|
|
57
|
+
/** A span node in the nested `span_tree` (same shape + recursive children). */
|
|
58
|
+
export const SpanNodeOut = SpanOut.extend({
|
|
59
|
+
get children() {
|
|
60
|
+
return z.array(SpanNodeOut);
|
|
61
|
+
},
|
|
62
|
+
}).meta({ id: "SpanNodeOut" });
|
|
63
|
+
|
|
64
|
+
/** Top-level trace — one end-to-end agent operation. */
|
|
65
|
+
export const TraceOut = z
|
|
66
|
+
.object({
|
|
67
|
+
id: z.string(),
|
|
68
|
+
smith_id: z.string(),
|
|
69
|
+
app_id: z.string().nullable(),
|
|
70
|
+
root_kind: ICSpanKindEnum,
|
|
71
|
+
name: z.string(),
|
|
72
|
+
status: z.string(),
|
|
73
|
+
started_at: z.string(),
|
|
74
|
+
ended_at: z.string().nullable(),
|
|
75
|
+
duration_ms: z.number().int().nullable(),
|
|
76
|
+
total_tokens: z.number().int().nullable(),
|
|
77
|
+
total_cost: z.number().nullable(),
|
|
78
|
+
attributes: z.record(z.string(), z.unknown()),
|
|
79
|
+
})
|
|
80
|
+
.meta({ id: "TraceOut" });
|
|
81
|
+
|
|
82
|
+
/** A trace plus its flat spans and nested tree. */
|
|
83
|
+
export const TraceDetailOut = TraceOut.extend({
|
|
84
|
+
spans: z.array(SpanOut),
|
|
85
|
+
span_tree: z.array(SpanNodeOut),
|
|
86
|
+
}).meta({ id: "TraceDetailOut" });
|
|
87
|
+
|
|
88
|
+
export const TraceListOut = pageOut(TraceOut, "TraceListOut");
|
|
89
|
+
|
|
90
|
+
/** Aggregated usage grouped by app, smith, model, or customer. */
|
|
91
|
+
export const UsageBreakdownOut = z
|
|
92
|
+
.object({
|
|
93
|
+
group_by: z.enum(["app", "smith", "model", "customer"]),
|
|
94
|
+
totals: z.object({
|
|
95
|
+
tokens: z.number(),
|
|
96
|
+
cost: z.number(),
|
|
97
|
+
run_count: z.number(),
|
|
98
|
+
}),
|
|
99
|
+
groups: z.array(
|
|
100
|
+
z.object({
|
|
101
|
+
app: z.string().nullable().optional(),
|
|
102
|
+
smith: z.string().nullable().optional(),
|
|
103
|
+
model: z.string().nullable().optional(),
|
|
104
|
+
// Customer-grouped views label unassigned usage `principal:<smith id>`.
|
|
105
|
+
customer: z.string().nullable().optional(),
|
|
106
|
+
tokens: z.number(),
|
|
107
|
+
cost: z.number(),
|
|
108
|
+
run_count: z.number(),
|
|
109
|
+
}),
|
|
110
|
+
),
|
|
111
|
+
/** Custom billable events aggregated per meter over the same filters. */
|
|
112
|
+
meters: z
|
|
113
|
+
.array(
|
|
114
|
+
z.object({
|
|
115
|
+
meter: z.string(),
|
|
116
|
+
customer: z.string().nullable().optional(),
|
|
117
|
+
quantity: z.number(),
|
|
118
|
+
events: z.number(),
|
|
119
|
+
}),
|
|
120
|
+
)
|
|
121
|
+
.optional(),
|
|
122
|
+
})
|
|
123
|
+
.meta({ id: "UsageBreakdownOut" });
|
|
124
|
+
|
|
125
|
+
/** One recorded billable usage event. */
|
|
126
|
+
export const UsageEventOut = z
|
|
127
|
+
.object({
|
|
128
|
+
id: z.string(),
|
|
129
|
+
smith_id: z.string(),
|
|
130
|
+
customer_id: z.string().nullable(),
|
|
131
|
+
meter: z.string(),
|
|
132
|
+
quantity: z.number(),
|
|
133
|
+
day: z.string(),
|
|
134
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
135
|
+
created_at: z.string().nullable(),
|
|
136
|
+
})
|
|
137
|
+
.meta({ id: "UsageEventOut" });
|
|
138
|
+
|
|
139
|
+
/** A page of usage events (keyset pagination). */
|
|
140
|
+
export const UsageEventListOut = z
|
|
141
|
+
.object({
|
|
142
|
+
data: z.array(UsageEventOut),
|
|
143
|
+
next_cursor: z.string().nullable(),
|
|
144
|
+
has_more: z.boolean(),
|
|
145
|
+
})
|
|
146
|
+
.meta({ id: "UsageEventListOut" });
|
|
147
|
+
|
|
148
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
149
|
+
|
|
150
|
+
export type ICSpanKind = z.infer<typeof ICSpanKindEnum>;
|
|
151
|
+
export type ICSpan = z.infer<typeof SpanOut>;
|
|
152
|
+
export type ICSpanNode = z.infer<typeof SpanNodeOut>;
|
|
153
|
+
export type ICTrace = z.infer<typeof TraceOut>;
|
|
154
|
+
export type ICTraceDetail = z.infer<typeof TraceDetailOut>;
|
|
155
|
+
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,135 @@
|
|
|
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. `RunUsage` is standalone
|
|
14
|
+
* (`$ref`'d) so the inferred `ICRunUsage` comes out identical to its hand-written
|
|
15
|
+
* interface ancestor.
|
|
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
|
+
import { pageOut } from "./_page.js";
|
|
24
|
+
|
|
25
|
+
/** One message in a run's `input`. `content` is a plain string for a text-only
|
|
26
|
+
* turn, or an array of content parts (`{type:"text"|"file"|"image", …}`) for a
|
|
27
|
+
* multimodal turn — the OpenAI-compatible surface and inline-file offloading both
|
|
28
|
+
* persist the array form, so the read schema must accept both. */
|
|
29
|
+
export const InputMessage = z
|
|
30
|
+
.object({
|
|
31
|
+
role: z.string(),
|
|
32
|
+
content: z.union([
|
|
33
|
+
z.string(),
|
|
34
|
+
z.array(z.record(z.string(), z.unknown())),
|
|
35
|
+
]),
|
|
36
|
+
})
|
|
37
|
+
.meta({ id: "InputMessage" });
|
|
38
|
+
|
|
39
|
+
/** One run's own token usage (the `usage` map on a run). Distinct from the
|
|
40
|
+
* tenant's aggregated billing summary. Plain numbers, not ints: provider/cache
|
|
41
|
+
* token math can be fractional, and an int assertion on a read surface buys
|
|
42
|
+
* nothing but a 500 risk. */
|
|
43
|
+
export const RunUsage = z
|
|
44
|
+
.object({
|
|
45
|
+
input_tokens: z.number(),
|
|
46
|
+
output_tokens: z.number(),
|
|
47
|
+
total_tokens: z.number(),
|
|
48
|
+
// This turn's priced cost in the account currency, computed at finish from the
|
|
49
|
+
// model's price book entry. Optional: runs metered before pricing landed — and
|
|
50
|
+
// any turn with no resolvable model — carry tokens but no `cost`.
|
|
51
|
+
cost: z.number().optional(),
|
|
52
|
+
})
|
|
53
|
+
.meta({ id: "RunUsage" });
|
|
54
|
+
|
|
55
|
+
export const RunOut = z
|
|
56
|
+
.object({
|
|
57
|
+
id: z.string(),
|
|
58
|
+
smith_id: z.string(),
|
|
59
|
+
thread_id: z.string(),
|
|
60
|
+
status: z.string(),
|
|
61
|
+
channel: z.string(),
|
|
62
|
+
input: z.array(InputMessage),
|
|
63
|
+
// `tool_calls` is an array of surface-specific call objects: the OpenAI
|
|
64
|
+
// `{id,type,function}` shape for a client-tools turn, a pending-call dict for
|
|
65
|
+
// an approval pause. Modelled loosely on purpose — a single strict struct here
|
|
66
|
+
// would 500 the read surface on the shapes actually stored.
|
|
67
|
+
output: z
|
|
68
|
+
.object({
|
|
69
|
+
content: z.string().optional(),
|
|
70
|
+
// Set by a structured (`response_format`) run: the media type of `content`
|
|
71
|
+
// (e.g. `application/json`), so a reader knows to parse it.
|
|
72
|
+
content_type: z.string().optional(),
|
|
73
|
+
tool_calls: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
74
|
+
// Quick-reply chips the agent offered for this reply (via the
|
|
75
|
+
// `suggest_replies` tool). Channels with native support render them as
|
|
76
|
+
// tappable buttons; a tap arrives as the user's next message.
|
|
77
|
+
suggested_replies: z.array(z.string()).optional(),
|
|
78
|
+
})
|
|
79
|
+
.nullable(),
|
|
80
|
+
stop_reason: z.string().nullable(),
|
|
81
|
+
usage: RunUsage.nullable(),
|
|
82
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
83
|
+
created_at: z.string().nullable(),
|
|
84
|
+
updated_at: z.string().nullable(),
|
|
85
|
+
})
|
|
86
|
+
.meta({ id: "RunOut" });
|
|
87
|
+
|
|
88
|
+
export const RunListOut = pageOut(RunOut, "RunListOut");
|
|
89
|
+
|
|
90
|
+
/** One recorded run event, as replayed from the event log. */
|
|
91
|
+
export const RunEventOut = z
|
|
92
|
+
.object({
|
|
93
|
+
seq: z.number().int(),
|
|
94
|
+
type: z.string(),
|
|
95
|
+
data: z.record(z.string(), z.unknown()),
|
|
96
|
+
created_at: z.string().nullable(),
|
|
97
|
+
})
|
|
98
|
+
.meta({ id: "RunEventOut" });
|
|
99
|
+
|
|
100
|
+
export const RunEventListOut = z
|
|
101
|
+
.object({ data: z.array(RunEventOut) })
|
|
102
|
+
.meta({ id: "RunEventListOut" });
|
|
103
|
+
|
|
104
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
export const RunIn = z
|
|
107
|
+
.object({
|
|
108
|
+
input: z.array(InputMessage).optional(),
|
|
109
|
+
thread_id: z.string().nullish(),
|
|
110
|
+
stream: z.boolean().optional(),
|
|
111
|
+
channel: z.string().optional(),
|
|
112
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
113
|
+
response_format: z.record(z.string(), z.unknown()).nullish(),
|
|
114
|
+
})
|
|
115
|
+
.meta({ id: "RunIn" });
|
|
116
|
+
|
|
117
|
+
export const Submit = z
|
|
118
|
+
.object({
|
|
119
|
+
kind: z.string(),
|
|
120
|
+
tool_call_id: z.string().nullish(),
|
|
121
|
+
result: z.record(z.string(), z.unknown()).nullish(),
|
|
122
|
+
approval_id: z.string().nullish(),
|
|
123
|
+
decision: z.string().nullish(),
|
|
124
|
+
actor: z.string().nullish(),
|
|
125
|
+
reason: z.string().nullish(),
|
|
126
|
+
stream: z.boolean().optional(),
|
|
127
|
+
})
|
|
128
|
+
.meta({ id: "Submit" });
|
|
129
|
+
|
|
130
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
131
|
+
|
|
132
|
+
export type ICInputMessage = z.infer<typeof InputMessage>;
|
|
133
|
+
export type ICRunUsage = z.infer<typeof RunUsage>;
|
|
134
|
+
export type ICRun = z.infer<typeof RunOut>;
|
|
135
|
+
export type ICRunEvent = z.infer<typeof RunEventOut>;
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
enabled: z.boolean(),
|
|
33
|
+
next_fire_at: z.string().nullable(),
|
|
34
|
+
last_fire_at: z.string().nullable(),
|
|
35
|
+
created_at: z.string().nullable(),
|
|
36
|
+
})
|
|
37
|
+
.meta({ id: "ScheduleOut" });
|
|
38
|
+
|
|
39
|
+
export const ScheduleListOut = z
|
|
40
|
+
.object({ data: z.array(ScheduleOut) })
|
|
41
|
+
.meta({ id: "ScheduleListOut" });
|
|
42
|
+
|
|
43
|
+
/** `POST .../:sid/run_now` — the fire is enqueued onto the smith's serial delivery
|
|
44
|
+
* lane (not run inline), so the response acknowledges the queued delivery rather
|
|
45
|
+
* than a completed run. Poll `/v1/events` or the smith's runs for the outcome. */
|
|
46
|
+
export const ScheduleRunNowOut = z
|
|
47
|
+
.object({
|
|
48
|
+
schedule_id: z.string(),
|
|
49
|
+
delivery_id: z.string(),
|
|
50
|
+
status: z.literal("queued"),
|
|
51
|
+
})
|
|
52
|
+
.meta({ id: "ScheduleRunNowOut" });
|
|
53
|
+
|
|
54
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
export const ScheduleIn = z
|
|
57
|
+
.object({
|
|
58
|
+
cron: z.string(),
|
|
59
|
+
name: z.string().nullish(),
|
|
60
|
+
timezone: z.string().default("UTC"),
|
|
61
|
+
input: ScheduleInput.default([]),
|
|
62
|
+
thread_id: z.string().nullish(),
|
|
63
|
+
max_concurrent: z.number().int().default(1),
|
|
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
|
+
enabled: z.boolean().nullish(),
|
|
77
|
+
})
|
|
78
|
+
.meta({ id: "SchedulePatch" });
|
|
79
|
+
|
|
80
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
81
|
+
|
|
82
|
+
export type ICSchedule = z.infer<typeof ScheduleOut>;
|
package/ts/zod/slack.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `slack` channel-config resource — the
|
|
3
|
+
* wire's source of truth for `PUT/GET /v1/tenant/slack`.
|
|
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 here and re-exported by `../responses`. No Zod is pulled
|
|
8
|
+
* into a type-only consumer — `responses.ts` re-exports this as `export type`.
|
|
9
|
+
*
|
|
10
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
11
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
|
|
15
|
+
// ── Config status (GET/PUT response) ─────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
/** App factory posture: whether the tenant has minted-app credentials stored. */
|
|
18
|
+
export const SlackFactoryStatus = z
|
|
19
|
+
.object({ configured: z.boolean() })
|
|
20
|
+
.meta({ id: "SlackFactoryStatus" });
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The tenant's Slack posture, as `tenantStatus` builds it. `configured`,
|
|
24
|
+
* `factory`, and `oauth_redirect_url` are always emitted; the shared-app
|
|
25
|
+
* details (`bot_user_id`, `team_id`, `events_url`, `oauth_ready`) only appear
|
|
26
|
+
* once a shared app is configured, and `return_url` only when one is set.
|
|
27
|
+
*/
|
|
28
|
+
export const SlackAppOut = z
|
|
29
|
+
.object({
|
|
30
|
+
configured: z.boolean(),
|
|
31
|
+
bot_user_id: z.string().optional(),
|
|
32
|
+
team_id: z.string().optional(),
|
|
33
|
+
events_url: z.string().optional(),
|
|
34
|
+
/** Shared app's OAuth client is set — "Add to Slack" installs work. */
|
|
35
|
+
oauth_ready: z.boolean().optional(),
|
|
36
|
+
oauth_redirect_url: z.string().optional(),
|
|
37
|
+
/** Where the OAuth redirect sends installers back (?slack=… appended). */
|
|
38
|
+
return_url: z.string().optional(),
|
|
39
|
+
/** App factory: mints per-smith Slack apps from the manifest template. */
|
|
40
|
+
factory: SlackFactoryStatus.optional(),
|
|
41
|
+
})
|
|
42
|
+
.meta({ id: "SlackAppOut" });
|
|
43
|
+
|
|
44
|
+
// ── Request bodies (PUT /v1/tenant/slack) ────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The app-factory block: a delegated app-config token pair plus the Slack app
|
|
48
|
+
* manifest template that minted per-smith apps are instantiated from.
|
|
49
|
+
*/
|
|
50
|
+
export const SlackFactoryIn = z
|
|
51
|
+
.object({
|
|
52
|
+
config_token: z.string(),
|
|
53
|
+
config_refresh_token: z.string().nullish(),
|
|
54
|
+
manifest_template: z.record(z.string(), z.unknown()),
|
|
55
|
+
})
|
|
56
|
+
.meta({ id: "SlackFactoryIn" });
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Register or rotate the tenant's Slack posture: a shared app (bot_token +
|
|
60
|
+
* signing_secret, optionally the OAuth client fields), a factory block, and/or
|
|
61
|
+
* the return_url. Every field is optional — the handler applies whichever
|
|
62
|
+
* blocks are present.
|
|
63
|
+
*/
|
|
64
|
+
export const SlackAppIn = z
|
|
65
|
+
.object({
|
|
66
|
+
bot_token: z.string().nullish(),
|
|
67
|
+
signing_secret: z.string().nullish(),
|
|
68
|
+
client_id: z.string().nullish(),
|
|
69
|
+
client_secret: z.string().nullish(),
|
|
70
|
+
oauth_scopes: z.string().nullish(),
|
|
71
|
+
oauth_user_scopes: z.string().nullish(),
|
|
72
|
+
return_url: z.string().nullish(),
|
|
73
|
+
factory: SlackFactoryIn.nullish(),
|
|
74
|
+
})
|
|
75
|
+
.meta({ id: "SlackAppIn" });
|
|
76
|
+
|
|
77
|
+
// ── Inferred consumer-facing type (re-exported by ../responses) ──────────────
|
|
78
|
+
|
|
79
|
+
export type ICSlackApp = z.infer<typeof SlackAppOut>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-authored Zod schemas for the `smith-revisions` resource — the wire's
|
|
3
|
+
* source of truth for `/v1/smiths/{id}/revisions`.
|
|
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 as types.
|
|
9
|
+
*
|
|
10
|
+
* A smith's behaviour config (instructions / model / hosted tools / auto-memory)
|
|
11
|
+
* is mutable; every change is snapshotted as an immutable *revision* and an
|
|
12
|
+
* operator can roll back. History is append-only — a *restore* re-applies an old
|
|
13
|
+
* snapshot as a brand-new revision.
|
|
14
|
+
*
|
|
15
|
+
* `.meta({ id })` names the component so the emitted OpenAPI references it as
|
|
16
|
+
* `#/components/schemas/<id>` rather than inlining it.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
|
|
20
|
+
/** An immutable snapshot of a smith's effective behaviour config at one revision. */
|
|
21
|
+
export const SmithRevisionOut = z
|
|
22
|
+
.object({
|
|
23
|
+
version: z.number().int(),
|
|
24
|
+
snapshot: z.object({
|
|
25
|
+
instructions: z.string().nullish(),
|
|
26
|
+
model: z.string().nullish(),
|
|
27
|
+
enabled_hosted_tools: z.array(z.string()).optional(),
|
|
28
|
+
vector_store_ids: z.array(z.string()).optional(),
|
|
29
|
+
auto_memory: z.boolean().optional(),
|
|
30
|
+
memory_consolidation: z.boolean().optional(),
|
|
31
|
+
}),
|
|
32
|
+
created_by: z.string().nullish(),
|
|
33
|
+
note: z.string().nullish(),
|
|
34
|
+
created_at: z.string().nullish(),
|
|
35
|
+
})
|
|
36
|
+
.meta({ id: "SmithRevisionOut" });
|
|
37
|
+
|
|
38
|
+
export const RevisionListOut = z
|
|
39
|
+
.object({ data: z.array(SmithRevisionOut) })
|
|
40
|
+
.meta({ id: "RevisionListOut" });
|
|
41
|
+
|
|
42
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
export const RestoreIn = z
|
|
45
|
+
.object({ note: z.string().nullish() })
|
|
46
|
+
.meta({ id: "RestoreIn" });
|
|
47
|
+
|
|
48
|
+
// ── Inferred consumer-facing types (re-exported by ../responses) ─────────────
|
|
49
|
+
|
|
50
|
+
export type ICSmithRevision = z.infer<typeof SmithRevisionOut>;
|