@cat-factory/contracts 0.174.0 → 0.176.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.
@@ -0,0 +1,235 @@
1
+ import * as v from 'valibot';
2
+ /** The time window every breakdown aggregates over. */
3
+ export declare const reportWindowSchema: v.PicklistSchema<["24h", "7d", "30d", "90d"], undefined>;
4
+ export type ReportWindow = v.InferOutput<typeof reportWindowSchema>;
5
+ /**
6
+ * What a SPEND breakdown groups by. `model` keys on the canonical `provider:model`
7
+ * id; `agentKind` on the metered call's agent kind; the remaining three resolve
8
+ * through the call's run (`workspace` directly, `service`/`taskType` via the run
9
+ * and its block).
10
+ */
11
+ export declare const reportSpendDimensionSchema: v.PicklistSchema<["model", "agentKind", "workspace", "service", "taskType"], undefined>;
12
+ export type ReportSpendDimension = v.InferOutput<typeof reportSpendDimensionSchema>;
13
+ /**
14
+ * What an ACTIVITY breakdown groups by. A run carries no single agent kind or model
15
+ * (those are per-step facts, which is what the spend breakdowns key on), so the
16
+ * activity axis is deliberately narrower than the spend axis.
17
+ */
18
+ export declare const reportActivityDimensionSchema: v.PicklistSchema<["workspace", "service", "taskType"], undefined>;
19
+ export type ReportActivityDimension = v.InferOutput<typeof reportActivityDimensionSchema>;
20
+ /**
21
+ * One slice of a spend breakdown. `key` is the raw dimension value and the row's
22
+ * identity; EMPTY means unattributed (a call whose run, service, or task type could
23
+ * not be resolved) — a real bucket, rendered as such, never dropped.
24
+ *
25
+ * The two costs are kept apart on purpose and must never be summed blindly: only
26
+ * `meteredCost` is real money. `subscriptionCost` is what the same tokens WOULD have
27
+ * cost on the metered API — illustrative for a flat-rate quota harness (Claude Code /
28
+ * Codex / GLM / pooled Kimi & DeepSeek), which is why the spend gate excludes it.
29
+ */
30
+ export declare const reportSpendRowSchema: v.ObjectSchema<{
31
+ readonly key: v.StringSchema<undefined>;
32
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
33
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
34
+ readonly inputTokens: v.NumberSchema<undefined>;
35
+ readonly outputTokens: v.NumberSchema<undefined>;
36
+ /** Number of metered LLM calls in this slice (both billing kinds). */
37
+ readonly calls: v.NumberSchema<undefined>;
38
+ /** Real per-token cost, in the deployment's spend currency. */
39
+ readonly meteredCost: v.NumberSchema<undefined>;
40
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
41
+ readonly subscriptionCost: v.NumberSchema<undefined>;
42
+ }, undefined>;
43
+ export type ReportSpendRow = v.InferOutput<typeof reportSpendRowSchema>;
44
+ /**
45
+ * One slice of an activity breakdown, over the agent runs CREATED in the window — every
46
+ * kind of run (task pipelines, repo bootstraps, env-config repairs), so this half of a row
47
+ * covers the same population whose LLM calls the spend half reports.
48
+ */
49
+ export declare const reportActivityRowSchema: v.ObjectSchema<{
50
+ readonly key: v.StringSchema<undefined>;
51
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
52
+ /** All runs created in the window in this slice. */
53
+ readonly runs: v.NumberSchema<undefined>;
54
+ readonly done: v.NumberSchema<undefined>;
55
+ readonly failed: v.NumberSchema<undefined>;
56
+ /** Runs still in flight (`running`). */
57
+ readonly running: v.NumberSchema<undefined>;
58
+ /** Every other status (`blocked` / `paused` / `pending`). */
59
+ readonly other: v.NumberSchema<undefined>;
60
+ /** Mean wall-clock duration over this slice's TERMINAL runs (ms); null when none. */
61
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
62
+ }, undefined>;
63
+ export type ReportActivityRow = v.InferOutput<typeof reportActivityRowSchema>;
64
+ /** One contiguous time bucket of the spend trend (zero-filled, oldest first). */
65
+ export declare const reportTrendPointSchema: v.ObjectSchema<{
66
+ /** Epoch-ms start of the bucket. */
67
+ readonly start: v.NumberSchema<undefined>;
68
+ readonly meteredCost: v.NumberSchema<undefined>;
69
+ readonly subscriptionCost: v.NumberSchema<undefined>;
70
+ readonly calls: v.NumberSchema<undefined>;
71
+ readonly inputTokens: v.NumberSchema<undefined>;
72
+ readonly outputTokens: v.NumberSchema<undefined>;
73
+ }, undefined>;
74
+ export type ReportTrendPoint = v.InferOutput<typeof reportTrendPointSchema>;
75
+ /** Window-wide totals, folded from the `model` breakdown (no extra query). */
76
+ export declare const reportTotalsSchema: v.ObjectSchema<{
77
+ readonly inputTokens: v.NumberSchema<undefined>;
78
+ readonly outputTokens: v.NumberSchema<undefined>;
79
+ readonly calls: v.NumberSchema<undefined>;
80
+ readonly meteredCost: v.NumberSchema<undefined>;
81
+ readonly subscriptionCost: v.NumberSchema<undefined>;
82
+ }, undefined>;
83
+ export type ReportTotals = v.InferOutput<typeof reportTotalsSchema>;
84
+ /** The complete reports projection the SPA renders. */
85
+ export declare const reportsViewSchema: v.ObjectSchema<{
86
+ readonly window: v.PicklistSchema<["24h", "7d", "30d", "90d"], undefined>;
87
+ /** When the projection was computed (epoch ms). */
88
+ readonly generatedAt: v.NumberSchema<undefined>;
89
+ /**
90
+ * Start of the window (epoch ms): `generatedAt - window`, snapped DOWN to a trend-bucket
91
+ * edge so the chart's first column is a complete bucket rather than a short one that reads
92
+ * as a quiet period. A window therefore covers up to one bucket more than its nominal
93
+ * length, and this is the real span every number in the projection was computed over.
94
+ */
95
+ readonly since: v.NumberSchema<undefined>;
96
+ /** The single workspace every breakdown was narrowed to, or null for the whole account. */
97
+ readonly workspaceId: v.NullableSchema<v.StringSchema<undefined>, undefined>;
98
+ /** The deployment's spend currency, so the SPA formats costs without a second call. */
99
+ readonly currency: v.StringSchema<undefined>;
100
+ readonly totals: v.ObjectSchema<{
101
+ readonly inputTokens: v.NumberSchema<undefined>;
102
+ readonly outputTokens: v.NumberSchema<undefined>;
103
+ readonly calls: v.NumberSchema<undefined>;
104
+ readonly meteredCost: v.NumberSchema<undefined>;
105
+ readonly subscriptionCost: v.NumberSchema<undefined>;
106
+ }, undefined>;
107
+ /** Spend sliced every way, each heaviest-first. */
108
+ readonly spend: v.ObjectSchema<{
109
+ readonly byModel: v.ArraySchema<v.ObjectSchema<{
110
+ readonly key: v.StringSchema<undefined>;
111
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
112
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
113
+ readonly inputTokens: v.NumberSchema<undefined>;
114
+ readonly outputTokens: v.NumberSchema<undefined>;
115
+ /** Number of metered LLM calls in this slice (both billing kinds). */
116
+ readonly calls: v.NumberSchema<undefined>;
117
+ /** Real per-token cost, in the deployment's spend currency. */
118
+ readonly meteredCost: v.NumberSchema<undefined>;
119
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
120
+ readonly subscriptionCost: v.NumberSchema<undefined>;
121
+ }, undefined>, undefined>;
122
+ readonly byAgentKind: v.ArraySchema<v.ObjectSchema<{
123
+ readonly key: v.StringSchema<undefined>;
124
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
125
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
126
+ readonly inputTokens: v.NumberSchema<undefined>;
127
+ readonly outputTokens: v.NumberSchema<undefined>;
128
+ /** Number of metered LLM calls in this slice (both billing kinds). */
129
+ readonly calls: v.NumberSchema<undefined>;
130
+ /** Real per-token cost, in the deployment's spend currency. */
131
+ readonly meteredCost: v.NumberSchema<undefined>;
132
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
133
+ readonly subscriptionCost: v.NumberSchema<undefined>;
134
+ }, undefined>, undefined>;
135
+ readonly byWorkspace: v.ArraySchema<v.ObjectSchema<{
136
+ readonly key: v.StringSchema<undefined>;
137
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
138
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
139
+ readonly inputTokens: v.NumberSchema<undefined>;
140
+ readonly outputTokens: v.NumberSchema<undefined>;
141
+ /** Number of metered LLM calls in this slice (both billing kinds). */
142
+ readonly calls: v.NumberSchema<undefined>;
143
+ /** Real per-token cost, in the deployment's spend currency. */
144
+ readonly meteredCost: v.NumberSchema<undefined>;
145
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
146
+ readonly subscriptionCost: v.NumberSchema<undefined>;
147
+ }, undefined>, undefined>;
148
+ readonly byService: v.ArraySchema<v.ObjectSchema<{
149
+ readonly key: v.StringSchema<undefined>;
150
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
151
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
152
+ readonly inputTokens: v.NumberSchema<undefined>;
153
+ readonly outputTokens: v.NumberSchema<undefined>;
154
+ /** Number of metered LLM calls in this slice (both billing kinds). */
155
+ readonly calls: v.NumberSchema<undefined>;
156
+ /** Real per-token cost, in the deployment's spend currency. */
157
+ readonly meteredCost: v.NumberSchema<undefined>;
158
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
159
+ readonly subscriptionCost: v.NumberSchema<undefined>;
160
+ }, undefined>, undefined>;
161
+ readonly byTaskType: v.ArraySchema<v.ObjectSchema<{
162
+ readonly key: v.StringSchema<undefined>;
163
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
164
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
165
+ readonly inputTokens: v.NumberSchema<undefined>;
166
+ readonly outputTokens: v.NumberSchema<undefined>;
167
+ /** Number of metered LLM calls in this slice (both billing kinds). */
168
+ readonly calls: v.NumberSchema<undefined>;
169
+ /** Real per-token cost, in the deployment's spend currency. */
170
+ readonly meteredCost: v.NumberSchema<undefined>;
171
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
172
+ readonly subscriptionCost: v.NumberSchema<undefined>;
173
+ }, undefined>, undefined>;
174
+ }, undefined>;
175
+ /** Run activity sliced every way, each busiest-first. */
176
+ readonly activity: v.ObjectSchema<{
177
+ readonly byWorkspace: v.ArraySchema<v.ObjectSchema<{
178
+ readonly key: v.StringSchema<undefined>;
179
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
180
+ /** All runs created in the window in this slice. */
181
+ readonly runs: v.NumberSchema<undefined>;
182
+ readonly done: v.NumberSchema<undefined>;
183
+ readonly failed: v.NumberSchema<undefined>;
184
+ /** Runs still in flight (`running`). */
185
+ readonly running: v.NumberSchema<undefined>;
186
+ /** Every other status (`blocked` / `paused` / `pending`). */
187
+ readonly other: v.NumberSchema<undefined>;
188
+ /** Mean wall-clock duration over this slice's TERMINAL runs (ms); null when none. */
189
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
190
+ }, undefined>, undefined>;
191
+ readonly byService: v.ArraySchema<v.ObjectSchema<{
192
+ readonly key: v.StringSchema<undefined>;
193
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
194
+ /** All runs created in the window in this slice. */
195
+ readonly runs: v.NumberSchema<undefined>;
196
+ readonly done: v.NumberSchema<undefined>;
197
+ readonly failed: v.NumberSchema<undefined>;
198
+ /** Runs still in flight (`running`). */
199
+ readonly running: v.NumberSchema<undefined>;
200
+ /** Every other status (`blocked` / `paused` / `pending`). */
201
+ readonly other: v.NumberSchema<undefined>;
202
+ /** Mean wall-clock duration over this slice's TERMINAL runs (ms); null when none. */
203
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
204
+ }, undefined>, undefined>;
205
+ readonly byTaskType: v.ArraySchema<v.ObjectSchema<{
206
+ readonly key: v.StringSchema<undefined>;
207
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
208
+ /** All runs created in the window in this slice. */
209
+ readonly runs: v.NumberSchema<undefined>;
210
+ readonly done: v.NumberSchema<undefined>;
211
+ readonly failed: v.NumberSchema<undefined>;
212
+ /** Runs still in flight (`running`). */
213
+ readonly running: v.NumberSchema<undefined>;
214
+ /** Every other status (`blocked` / `paused` / `pending`). */
215
+ readonly other: v.NumberSchema<undefined>;
216
+ /** Mean wall-clock duration over this slice's TERMINAL runs (ms); null when none. */
217
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
218
+ }, undefined>, undefined>;
219
+ }, undefined>;
220
+ /** Spend over time at `bucketMs` resolution. */
221
+ readonly trend: v.ObjectSchema<{
222
+ readonly bucketMs: v.NumberSchema<undefined>;
223
+ readonly points: v.ArraySchema<v.ObjectSchema<{
224
+ /** Epoch-ms start of the bucket. */
225
+ readonly start: v.NumberSchema<undefined>;
226
+ readonly meteredCost: v.NumberSchema<undefined>;
227
+ readonly subscriptionCost: v.NumberSchema<undefined>;
228
+ readonly calls: v.NumberSchema<undefined>;
229
+ readonly inputTokens: v.NumberSchema<undefined>;
230
+ readonly outputTokens: v.NumberSchema<undefined>;
231
+ }, undefined>, undefined>;
232
+ }, undefined>;
233
+ }, undefined>;
234
+ export type ReportsView = v.InferOutput<typeof reportsViewSchema>;
235
+ //# sourceMappingURL=reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../src/reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAe5B,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,0DAA0C,CAAA;AACzE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,yFAMrC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAEnF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,mEAAmD,CAAA;AAC7F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEzF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;;IAE/B,mGAAmG;;;;IAInG,sEAAsE;;IAEtE,+DAA+D;;IAE/D,0FAA0F;;aAE1F,CAAA;AACF,MAAM,MAAM,cAAc,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;YARrF,oDAAoD;;;;YAIpD,wCAAwC;;YAExC,6DAA6D;;YAE7D,qFAAqF;;;;IA0DrF,gDAAgD;;;;YAnDhD,oCAAoC;;;;;;;;;aAwDpC,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -0,0 +1,132 @@
1
+ import * as v from 'valibot';
2
+ // ---------------------------------------------------------------------------
3
+ // Reports: the cross-cutting analytics projection an operator reads to answer
4
+ // "where is the money and the work going". Where `platformObservabilitySchema`
5
+ // answers "is the deployment HEALTHY" (outcomes, failures, latency), this answers
6
+ // "how is it being USED" — spend sliced by model / agent kind, and both spend and
7
+ // run activity sliced by workspace / service / task type, plus a spend trend.
8
+ //
9
+ // Every number is a SQL rollup behind the kernel `ReportsRepository` port (one
10
+ // GROUP BY per breakdown, run in parallel — never rows reduced in JS). Account
11
+ // scoped and admin-gated like the operator dashboard, with an optional single
12
+ // workspace filter that narrows every breakdown at once.
13
+ // ---------------------------------------------------------------------------
14
+ /** The time window every breakdown aggregates over. */
15
+ export const reportWindowSchema = v.picklist(['24h', '7d', '30d', '90d']);
16
+ /**
17
+ * What a SPEND breakdown groups by. `model` keys on the canonical `provider:model`
18
+ * id; `agentKind` on the metered call's agent kind; the remaining three resolve
19
+ * through the call's run (`workspace` directly, `service`/`taskType` via the run
20
+ * and its block).
21
+ */
22
+ export const reportSpendDimensionSchema = v.picklist([
23
+ 'model',
24
+ 'agentKind',
25
+ 'workspace',
26
+ 'service',
27
+ 'taskType',
28
+ ]);
29
+ /**
30
+ * What an ACTIVITY breakdown groups by. A run carries no single agent kind or model
31
+ * (those are per-step facts, which is what the spend breakdowns key on), so the
32
+ * activity axis is deliberately narrower than the spend axis.
33
+ */
34
+ export const reportActivityDimensionSchema = v.picklist(['workspace', 'service', 'taskType']);
35
+ /**
36
+ * One slice of a spend breakdown. `key` is the raw dimension value and the row's
37
+ * identity; EMPTY means unattributed (a call whose run, service, or task type could
38
+ * not be resolved) — a real bucket, rendered as such, never dropped.
39
+ *
40
+ * The two costs are kept apart on purpose and must never be summed blindly: only
41
+ * `meteredCost` is real money. `subscriptionCost` is what the same tokens WOULD have
42
+ * cost on the metered API — illustrative for a flat-rate quota harness (Claude Code /
43
+ * Codex / GLM / pooled Kimi & DeepSeek), which is why the spend gate excludes it.
44
+ */
45
+ export const reportSpendRowSchema = v.object({
46
+ key: v.string(),
47
+ /** Human-readable name for `key` when the store can resolve one (workspace/service); else null. */
48
+ label: v.nullable(v.string()),
49
+ inputTokens: v.number(),
50
+ outputTokens: v.number(),
51
+ /** Number of metered LLM calls in this slice (both billing kinds). */
52
+ calls: v.number(),
53
+ /** Real per-token cost, in the deployment's spend currency. */
54
+ meteredCost: v.number(),
55
+ /** Illustrative equivalent-API cost of flat-rate subscription usage. Never real spend. */
56
+ subscriptionCost: v.number(),
57
+ });
58
+ /**
59
+ * One slice of an activity breakdown, over the agent runs CREATED in the window — every
60
+ * kind of run (task pipelines, repo bootstraps, env-config repairs), so this half of a row
61
+ * covers the same population whose LLM calls the spend half reports.
62
+ */
63
+ export const reportActivityRowSchema = v.object({
64
+ key: v.string(),
65
+ label: v.nullable(v.string()),
66
+ /** All runs created in the window in this slice. */
67
+ runs: v.number(),
68
+ done: v.number(),
69
+ failed: v.number(),
70
+ /** Runs still in flight (`running`). */
71
+ running: v.number(),
72
+ /** Every other status (`blocked` / `paused` / `pending`). */
73
+ other: v.number(),
74
+ /** Mean wall-clock duration over this slice's TERMINAL runs (ms); null when none. */
75
+ avgDurationMs: v.nullable(v.number()),
76
+ });
77
+ /** One contiguous time bucket of the spend trend (zero-filled, oldest first). */
78
+ export const reportTrendPointSchema = v.object({
79
+ /** Epoch-ms start of the bucket. */
80
+ start: v.number(),
81
+ meteredCost: v.number(),
82
+ subscriptionCost: v.number(),
83
+ calls: v.number(),
84
+ inputTokens: v.number(),
85
+ outputTokens: v.number(),
86
+ });
87
+ /** Window-wide totals, folded from the `model` breakdown (no extra query). */
88
+ export const reportTotalsSchema = v.object({
89
+ inputTokens: v.number(),
90
+ outputTokens: v.number(),
91
+ calls: v.number(),
92
+ meteredCost: v.number(),
93
+ subscriptionCost: v.number(),
94
+ });
95
+ /** The complete reports projection the SPA renders. */
96
+ export const reportsViewSchema = v.object({
97
+ window: reportWindowSchema,
98
+ /** When the projection was computed (epoch ms). */
99
+ generatedAt: v.number(),
100
+ /**
101
+ * Start of the window (epoch ms): `generatedAt - window`, snapped DOWN to a trend-bucket
102
+ * edge so the chart's first column is a complete bucket rather than a short one that reads
103
+ * as a quiet period. A window therefore covers up to one bucket more than its nominal
104
+ * length, and this is the real span every number in the projection was computed over.
105
+ */
106
+ since: v.number(),
107
+ /** The single workspace every breakdown was narrowed to, or null for the whole account. */
108
+ workspaceId: v.nullable(v.string()),
109
+ /** The deployment's spend currency, so the SPA formats costs without a second call. */
110
+ currency: v.string(),
111
+ totals: reportTotalsSchema,
112
+ /** Spend sliced every way, each heaviest-first. */
113
+ spend: v.object({
114
+ byModel: v.array(reportSpendRowSchema),
115
+ byAgentKind: v.array(reportSpendRowSchema),
116
+ byWorkspace: v.array(reportSpendRowSchema),
117
+ byService: v.array(reportSpendRowSchema),
118
+ byTaskType: v.array(reportSpendRowSchema),
119
+ }),
120
+ /** Run activity sliced every way, each busiest-first. */
121
+ activity: v.object({
122
+ byWorkspace: v.array(reportActivityRowSchema),
123
+ byService: v.array(reportActivityRowSchema),
124
+ byTaskType: v.array(reportActivityRowSchema),
125
+ }),
126
+ /** Spend over time at `bucketMs` resolution. */
127
+ trend: v.object({
128
+ bucketMs: v.number(),
129
+ points: v.array(reportTrendPointSchema),
130
+ }),
131
+ });
132
+ //# sourceMappingURL=reports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.js","sourceRoot":"","sources":["../src/reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;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;IACH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,2FAA2F;IAC3F,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,uFAAuF;IACvF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,kBAAkB;IAC1B,mDAAmD;IACnD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;QACtC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;QAC1C,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;QAC1C,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;QACxC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;KAC1C,CAAC;IACF,yDAAyD;IACzD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;QAC7C,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;QAC3C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;KAC7C,CAAC;IACF,gDAAgD;IAChD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC;KACxC,CAAC;CACH,CAAC,CAAA"}
@@ -153,7 +153,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
153
153
  readonly pipelineId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 120, undefined>]>;
154
154
  readonly agentConfig: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 400, undefined>]>, undefined>;
155
155
  readonly provisioning: v.ObjectSchema<{
156
- readonly type: v.PicklistSchema<["kubernetes", "docker-compose", "custom", "infraless"], undefined>;
156
+ readonly type: v.PicklistSchema<["kubernetes", "docker-compose", "cloudflare", "custom", "infraless"], undefined>;
157
157
  readonly manifestSource: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
158
158
  readonly type: v.LiteralSchema<"colocated", undefined>;
159
159
  readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 500, undefined>]>;
@@ -444,7 +444,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
444
444
  readonly pipelineId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 120, undefined>]>, undefined>;
445
445
  readonly agentConfig: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 400, undefined>]>, undefined>, undefined>;
446
446
  readonly provisioning: v.OptionalSchema<v.ObjectSchema<{
447
- readonly type: v.PicklistSchema<["kubernetes", "docker-compose", "custom", "infraless"], undefined>;
447
+ readonly type: v.PicklistSchema<["kubernetes", "docker-compose", "cloudflare", "custom", "infraless"], undefined>;
448
448
  readonly manifestSource: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
449
449
  readonly type: v.LiteralSchema<"colocated", undefined>;
450
450
  readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 500, undefined>]>;
@@ -737,7 +737,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
737
737
  [x: string]: string;
738
738
  } | undefined;
739
739
  provisioning?: {
740
- type: "custom" | "docker-compose" | "infraless" | "kubernetes";
740
+ type: "cloudflare" | "custom" | "docker-compose" | "infraless" | "kubernetes";
741
741
  manifestSource?: {
742
742
  type: "colocated";
743
743
  path: string;
@@ -997,7 +997,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
997
997
  [x: string]: string;
998
998
  } | undefined;
999
999
  provisioning?: {
1000
- type: "custom" | "docker-compose" | "infraless" | "kubernetes";
1000
+ type: "cloudflare" | "custom" | "docker-compose" | "infraless" | "kubernetes";
1001
1001
  manifestSource?: {
1002
1002
  type: "colocated";
1003
1003
  path: string;
@@ -1258,7 +1258,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
1258
1258
  [x: string]: string;
1259
1259
  } | undefined;
1260
1260
  provisioning?: {
1261
- type: "custom" | "docker-compose" | "infraless" | "kubernetes";
1261
+ type: "cloudflare" | "custom" | "docker-compose" | "infraless" | "kubernetes";
1262
1262
  manifestSource?: {
1263
1263
  type: "colocated";
1264
1264
  path: string;
@@ -1543,7 +1543,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
1543
1543
  [x: string]: string;
1544
1544
  } | undefined;
1545
1545
  provisioning?: {
1546
- type: "custom" | "docker-compose" | "infraless" | "kubernetes";
1546
+ type: "cloudflare" | "custom" | "docker-compose" | "infraless" | "kubernetes";
1547
1547
  manifestSource?: {
1548
1548
  type: "colocated";
1549
1549
  path: string;
@@ -1804,7 +1804,7 @@ export declare const updateBlockSchema: Omit<v.ObjectSchema<{
1804
1804
  [x: string]: string;
1805
1805
  } | undefined;
1806
1806
  provisioning?: {
1807
- type: "custom" | "docker-compose" | "infraless" | "kubernetes";
1807
+ type: "cloudflare" | "custom" | "docker-compose" | "infraless" | "kubernetes";
1808
1808
  manifestSource?: {
1809
1809
  type: "colocated";
1810
1810
  path: string;
@@ -1003,4 +1003,145 @@ export declare const getPlatformObservabilityContract: {
1003
1003
  }, undefined>;
1004
1004
  };
1005
1005
  };
1006
+ export declare const getReportsContract: {
1007
+ readonly method: "get";
1008
+ readonly requestPathParamsSchema: v.ObjectSchema<{
1009
+ accountId: v.StringSchema<undefined>;
1010
+ }, undefined> & import("@toad-contracts/core").StandardObjectKeysV1<unknown, unknown>;
1011
+ readonly requestQuerySchema: v.ObjectSchema<{
1012
+ readonly window: v.OptionalSchema<v.PicklistSchema<["24h", "7d", "30d", "90d"], undefined>, undefined>;
1013
+ readonly workspaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1014
+ }, undefined>;
1015
+ readonly pathResolver: ({ accountId }: {
1016
+ accountId: string;
1017
+ }) => string;
1018
+ readonly responsesByStatusCode: {
1019
+ readonly '4xx': v.ObjectSchema<{
1020
+ readonly error: v.ObjectSchema<{
1021
+ readonly code: v.StringSchema<undefined>;
1022
+ readonly message: v.StringSchema<undefined>;
1023
+ readonly details: v.OptionalSchema<v.UnknownSchema, undefined>;
1024
+ readonly issues: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
1025
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1026
+ readonly message: v.StringSchema<undefined>;
1027
+ }, undefined>, undefined>, undefined>;
1028
+ }, undefined>;
1029
+ }, undefined>;
1030
+ readonly '5xx': v.ObjectSchema<{
1031
+ readonly error: v.ObjectSchema<{
1032
+ readonly code: v.StringSchema<undefined>;
1033
+ readonly message: v.StringSchema<undefined>;
1034
+ readonly details: v.OptionalSchema<v.UnknownSchema, undefined>;
1035
+ readonly issues: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
1036
+ readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1037
+ readonly message: v.StringSchema<undefined>;
1038
+ }, undefined>, undefined>, undefined>;
1039
+ }, undefined>;
1040
+ }, undefined>;
1041
+ readonly 200: v.ObjectSchema<{
1042
+ readonly window: v.PicklistSchema<["24h", "7d", "30d", "90d"], undefined>;
1043
+ readonly generatedAt: v.NumberSchema<undefined>;
1044
+ readonly since: v.NumberSchema<undefined>;
1045
+ readonly workspaceId: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1046
+ readonly currency: v.StringSchema<undefined>;
1047
+ readonly totals: v.ObjectSchema<{
1048
+ readonly inputTokens: v.NumberSchema<undefined>;
1049
+ readonly outputTokens: v.NumberSchema<undefined>;
1050
+ readonly calls: v.NumberSchema<undefined>;
1051
+ readonly meteredCost: v.NumberSchema<undefined>;
1052
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1053
+ }, undefined>;
1054
+ readonly spend: v.ObjectSchema<{
1055
+ readonly byModel: v.ArraySchema<v.ObjectSchema<{
1056
+ readonly key: v.StringSchema<undefined>;
1057
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1058
+ readonly inputTokens: v.NumberSchema<undefined>;
1059
+ readonly outputTokens: v.NumberSchema<undefined>;
1060
+ readonly calls: v.NumberSchema<undefined>;
1061
+ readonly meteredCost: v.NumberSchema<undefined>;
1062
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1063
+ }, undefined>, undefined>;
1064
+ readonly byAgentKind: v.ArraySchema<v.ObjectSchema<{
1065
+ readonly key: v.StringSchema<undefined>;
1066
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1067
+ readonly inputTokens: v.NumberSchema<undefined>;
1068
+ readonly outputTokens: v.NumberSchema<undefined>;
1069
+ readonly calls: v.NumberSchema<undefined>;
1070
+ readonly meteredCost: v.NumberSchema<undefined>;
1071
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1072
+ }, undefined>, undefined>;
1073
+ readonly byWorkspace: v.ArraySchema<v.ObjectSchema<{
1074
+ readonly key: v.StringSchema<undefined>;
1075
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1076
+ readonly inputTokens: v.NumberSchema<undefined>;
1077
+ readonly outputTokens: v.NumberSchema<undefined>;
1078
+ readonly calls: v.NumberSchema<undefined>;
1079
+ readonly meteredCost: v.NumberSchema<undefined>;
1080
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1081
+ }, undefined>, undefined>;
1082
+ readonly byService: v.ArraySchema<v.ObjectSchema<{
1083
+ readonly key: v.StringSchema<undefined>;
1084
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1085
+ readonly inputTokens: v.NumberSchema<undefined>;
1086
+ readonly outputTokens: v.NumberSchema<undefined>;
1087
+ readonly calls: v.NumberSchema<undefined>;
1088
+ readonly meteredCost: v.NumberSchema<undefined>;
1089
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1090
+ }, undefined>, undefined>;
1091
+ readonly byTaskType: v.ArraySchema<v.ObjectSchema<{
1092
+ readonly key: v.StringSchema<undefined>;
1093
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1094
+ readonly inputTokens: v.NumberSchema<undefined>;
1095
+ readonly outputTokens: v.NumberSchema<undefined>;
1096
+ readonly calls: v.NumberSchema<undefined>;
1097
+ readonly meteredCost: v.NumberSchema<undefined>;
1098
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1099
+ }, undefined>, undefined>;
1100
+ }, undefined>;
1101
+ readonly activity: v.ObjectSchema<{
1102
+ readonly byWorkspace: v.ArraySchema<v.ObjectSchema<{
1103
+ readonly key: v.StringSchema<undefined>;
1104
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1105
+ readonly runs: v.NumberSchema<undefined>;
1106
+ readonly done: v.NumberSchema<undefined>;
1107
+ readonly failed: v.NumberSchema<undefined>;
1108
+ readonly running: v.NumberSchema<undefined>;
1109
+ readonly other: v.NumberSchema<undefined>;
1110
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
1111
+ }, undefined>, undefined>;
1112
+ readonly byService: v.ArraySchema<v.ObjectSchema<{
1113
+ readonly key: v.StringSchema<undefined>;
1114
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1115
+ readonly runs: v.NumberSchema<undefined>;
1116
+ readonly done: v.NumberSchema<undefined>;
1117
+ readonly failed: v.NumberSchema<undefined>;
1118
+ readonly running: v.NumberSchema<undefined>;
1119
+ readonly other: v.NumberSchema<undefined>;
1120
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
1121
+ }, undefined>, undefined>;
1122
+ readonly byTaskType: v.ArraySchema<v.ObjectSchema<{
1123
+ readonly key: v.StringSchema<undefined>;
1124
+ readonly label: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1125
+ readonly runs: v.NumberSchema<undefined>;
1126
+ readonly done: v.NumberSchema<undefined>;
1127
+ readonly failed: v.NumberSchema<undefined>;
1128
+ readonly running: v.NumberSchema<undefined>;
1129
+ readonly other: v.NumberSchema<undefined>;
1130
+ readonly avgDurationMs: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
1131
+ }, undefined>, undefined>;
1132
+ }, undefined>;
1133
+ readonly trend: v.ObjectSchema<{
1134
+ readonly bucketMs: v.NumberSchema<undefined>;
1135
+ readonly points: v.ArraySchema<v.ObjectSchema<{
1136
+ readonly start: v.NumberSchema<undefined>;
1137
+ readonly meteredCost: v.NumberSchema<undefined>;
1138
+ readonly subscriptionCost: v.NumberSchema<undefined>;
1139
+ readonly calls: v.NumberSchema<undefined>;
1140
+ readonly inputTokens: v.NumberSchema<undefined>;
1141
+ readonly outputTokens: v.NumberSchema<undefined>;
1142
+ }, undefined>, undefined>;
1143
+ }, undefined>;
1144
+ }, undefined>;
1145
+ };
1146
+ };
1006
1147
  //# sourceMappingURL=accounts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/routes/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAqC,MAAM,yBAAyB,CAAA;AAC3F,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AA+C5B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAI/B,CAAA;AAEF,eAAO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6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMxC,CAAA;AAMF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAM3C,CAAA;AAQF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS7B,CAAA"}
@@ -4,6 +4,7 @@ import { accountInvitationSchema, accountMemberSchema, accountSchema, addMemberS
4
4
  import { accountSettingsViewSchema, updateAccountSettingsSchema } from '../accountSettings.js';
5
5
  import { addApiKeySchema, apiKeyListResultSchema, apiKeySchema, updateApiKeySchema, } from '../api-keys.js';
6
6
  import { platformObservabilitySchema, platformObservabilityWindowSchema } from '../observability.js';
7
+ import { reportWindowSchema, reportsViewSchema } from '../reports.js';
7
8
  import { errorResponses, singleStringParam } from './_shared.js';
8
9
  // ---------------------------------------------------------------------------
9
10
  // Account tenancy route contracts. See AccountController in @cat-factory/server.
@@ -160,4 +161,19 @@ export const getPlatformObservabilityContract = defineApiContract({
160
161
  pathResolver: ({ accountId }) => `/accounts/${accountId}/observability/platform`,
161
162
  responsesByStatusCode: { 200: platformObservabilitySchema, ...errorResponses },
162
163
  });
164
+ // ---- reports (admin-only) -------------------------------------------------
165
+ // Cross-cutting usage analytics for the account: spend per model / agent kind, and
166
+ // spend + run activity per workspace / service / task type, over a time window. Admin
167
+ // gated for the same reason as the dashboard above (cross-workspace operational data).
168
+ // `workspaceId` narrows EVERY breakdown to one board; absent ⇒ the whole account.
169
+ export const getReportsContract = defineApiContract({
170
+ method: 'get',
171
+ requestPathParamsSchema: accountIdParams,
172
+ requestQuerySchema: v.object({
173
+ window: v.optional(reportWindowSchema),
174
+ workspaceId: v.optional(v.string()),
175
+ }),
176
+ pathResolver: ({ accountId }) => `/accounts/${accountId}/reports`,
177
+ responsesByStatusCode: { 200: reportsViewSchema, ...errorResponses },
178
+ });
163
179
  //# sourceMappingURL=accounts.js.map