@pipelex/sdk 0.16.0 → 0.18.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.
@@ -1,24 +1,32 @@
1
1
  /**
2
2
  * `prepareInputs` — signature-driven input preparation. Resolves the target
3
- * pipe's declared inputs via the explicit inputs template, interprets the
4
- * caller's inputs top-down against it, uploads the file-bearing values, and
5
- * returns rewritten inputs (canonical content carrying `pipelex-storage://` in
6
- * `url`) plus one upload record per prepared asset.
3
+ * pipe's declared inputs from the **input-form descriptor** on the validate
4
+ * report, interprets the caller's inputs top-down against it, uploads the
5
+ * file-bearing values, and returns rewritten inputs (canonical content carrying
6
+ * `pipelex-storage://` in `url`) plus one upload record per prepared asset.
7
+ *
8
+ * The method is named the same three ways every other method-taking operation
9
+ * takes it — inline `files`, a `method_ref` address, or a stored `method_id` —
10
+ * exactly one per call. All three are pass-throughs to `POST /v1/validate`,
11
+ * which resolves an address on the runner and an id on the platform, so nothing
12
+ * is expanded client-side.
7
13
  *
8
14
  * Per input, the caller may submit EITHER the **compact** value (a bare source /
9
- * canonical `{url}` content) OR the explicit `{ concept, content }` envelope that
10
- * `buildInputs({ explicit: true })` hands back — its `content` is interpreted
11
- * exactly as the compact value would be, and the envelope is preserved on output
12
- * (the `concept` annotation rides through; the runtime accepts it — see
13
- * `pipelex`'s `input_shaper.py` `_is_explicit` / `input_normalizer.py`).
15
+ * canonical `{url}` content) OR the explicit `{ concept, content }` envelope —
16
+ * its `content` is interpreted exactly as the compact value would be, and the
17
+ * envelope is preserved on output (the `concept` annotation rides through; the
18
+ * runtime accepts it — see `pipelex`'s `input_shaper.py` `_is_explicit` /
19
+ * `input_normalizer.py`).
14
20
  *
15
- * The classification mirrors the runtime: `pipelex`'s `input_normalizer` walks
16
- * Image/Document contents (recognized by their `url`-bearing shape, incl. nested
17
- * in structured content) and `resolve_uri` decides upload vs pass-through. The
18
- * declared signature comes from the explicit template (`buildInputs`,
19
- * `explicit: true`), whose canonical content shape is the classifier — the file
20
- * signal is a value that is a dict containing a `url` key. See the shared
21
- * behavior matrix (`wip/upload/behavior-matrix.md`) and `docs/input-preparation.md`.
21
+ * **The descriptor is the classifier, never the value's shape.** `input_form`
22
+ * (the MTHDS standard's artifact, opted into with `views: ["input_form"]`)
23
+ * states the kind at every depth — `document` / `image` mark a file position,
24
+ * `object` recurses through `fields`, `list` through `item`, everything else
25
+ * passes through. That is what makes an OPTIONAL nested file field prepare like
26
+ * a required one, and a `text` field merely *named* `url` stay untouched: both
27
+ * were misread while the signature came from the rendered inputs template, whose
28
+ * file signal was a `url`-bearing dict. See `docs/input-preparation.md` and the
29
+ * shared behavior matrix (`wip/upload/behavior-matrix.md`).
22
30
  */
23
31
  import { InputPreparationError } from "./errors.js";
24
32
  import { uploadFile } from "./upload.js";
@@ -28,16 +36,26 @@ const HTTP_URL_RE = /^https?:\/\//i;
28
36
  function isPlainObject(value) {
29
37
  return Object.prototype.toString.call(value) === "[object Object]";
30
38
  }
31
- /** A canonical Image/Document content is a plain object carrying a `url` key. */
39
+ /** A trimmed non-empty string, or `undefined` — the "empty is absent" rule. */
40
+ function nonEmptyString(value) {
41
+ if (typeof value !== "string")
42
+ return undefined;
43
+ const trimmed = value.trim();
44
+ return trimmed.length > 0 ? trimmed : undefined;
45
+ }
46
+ /**
47
+ * A canonical Image/Document content is a plain object carrying a `url` key.
48
+ * A VALUE-shape helper only: it is consulted at a position the descriptor has
49
+ * already declared a file, never as the signal that one is there.
50
+ */
32
51
  function isFileContent(node) {
33
52
  return isPlainObject(node) && "url" in node;
34
53
  }
35
54
  /**
36
- * The explicit-template envelope: a plain object whose keys are EXACTLY `concept`
37
- * and `content` — the shape `buildInputs({ explicit: true })` returns per input.
38
- * Matches the runtime's `_is_explicit` (`pipelex`'s `input_shaper.py`): exact
39
- * keys, not a superset, so a structured-content input that merely happens to carry
40
- * both fields is not misread as an envelope.
55
+ * The explicit envelope: a plain object whose keys are EXACTLY `concept` and
56
+ * `content`. Matches the runtime's `_is_explicit` (`pipelex`'s
57
+ * `input_shaper.py`): exact keys, not a superset, so a structured-content input
58
+ * that merely happens to carry both fields is not misread as an envelope.
41
59
  */
42
60
  function isExplicitEnvelope(value) {
43
61
  if (!isPlainObject(value))
@@ -133,46 +151,166 @@ async function resolveFilePosition(ctx, callerValue) {
133
151
  const resolved = await resolveSource(ctx, callerValue);
134
152
  return { url: resolved };
135
153
  }
136
- /** Template-guided walk: a template node that is canonical file content marks a file position. */
137
- async function resolveNode(ctx, templateNode, callerValue) {
138
- if (isFileContent(templateNode)) {
139
- return resolveFilePosition(ctx, callerValue);
140
- }
141
- if (Array.isArray(templateNode) && templateNode.length > 0) {
142
- const elementTemplate = templateNode[0];
143
- if (Array.isArray(callerValue)) {
144
- return Promise.all(callerValue.map((item) => resolveNode(ctx, elementTemplate, item)));
145
- }
146
- return callerValue; // shape mismatch — leave it for the run to reject
147
- }
148
- if (isPlainObject(templateNode) && isPlainObject(callerValue)) {
149
- const result = { ...callerValue };
150
- for (const key of Object.keys(templateNode)) {
151
- if (key in callerValue) {
152
- result[key] = await resolveNode(ctx, templateNode[key], callerValue[key]);
154
+ /**
155
+ * Descriptor-guided walk, discriminated on the node's `kind`:
156
+ *
157
+ * - `document` / `image` — a file position, whatever the value's shape;
158
+ * - `object` — walk the declared `fields` by name; keys the descriptor does not
159
+ * name are copied through untouched;
160
+ * - `list` — walk `item` against each element;
161
+ * - every other kind (`text`, `prose`, `date`, `number`, `boolean`, `enum`,
162
+ * `unknown`) — pass through at any depth. `unknown` is the standard's escape
163
+ * hatch for a `Dynamic` / `Composite` input, and it is NOT interpreted: the
164
+ * signature declares no file there, and uploading by value shape is the defect
165
+ * this walk removes. A caller with such an input uploads with `uploadFile`
166
+ * first and passes the storage URI.
167
+ *
168
+ * A caller value whose shape disagrees with the node (a scalar at an `object`, a
169
+ * non-array at a `list`) passes through for the run to reject — preparation never
170
+ * second-guesses the signature.
171
+ */
172
+ async function resolveNode(ctx, node, callerValue) {
173
+ switch (node.kind) {
174
+ case "document":
175
+ case "image":
176
+ return resolveFilePosition(ctx, callerValue);
177
+ case "object": {
178
+ if (!isPlainObject(callerValue))
179
+ return callerValue;
180
+ const result = { ...callerValue };
181
+ for (const field of node.fields) {
182
+ if (Object.hasOwn(callerValue, field.name)) {
183
+ result[field.name] = await resolveNode(ctx, field, callerValue[field.name]);
184
+ }
153
185
  }
186
+ return result;
187
+ }
188
+ case "list": {
189
+ if (!Array.isArray(callerValue))
190
+ return callerValue;
191
+ return Promise.all(callerValue.map((element) => resolveNode(ctx, node.item, element)));
154
192
  }
155
- return result;
193
+ default:
194
+ return callerValue;
156
195
  }
157
- return callerValue; // scalar (text/number/…) or shape mismatch — pass through
158
196
  }
159
197
  /**
160
- * Read the request's closure `files`, guarding the untyped-caller shapes the
161
- * type system already forbids: a missing closure (`files` is required), and the
162
- * retired by-id form (`method_id` was a client-side expansion leg, deleted when
163
- * the tooling routes gained native by-id — expand a stored method with
164
- * `getMethodClosure` instead).
198
+ * Normalize and check the three selectors. Empty is absent (`files: []`,
199
+ * `method_ref: ""`, `method_id: " "`), mirroring the run options' rule and the
200
+ * Python `CrateRequestBase` normalisers, and exactly one must remain — the check
201
+ * lives here because this helper is the one that composes the `validate` call.
202
+ * The illegal shapes are compile errors for typed callers; this backs them up for
203
+ * untyped (JS) ones with a typed `InputPreparationError`.
165
204
  */
166
- function resolveClosureFiles(request) {
167
- if (request["method_id"] !== undefined) {
168
- throw new InputPreparationError("Cannot prepare inputs: `method_id` is not a prepareInputs field. Expand the stored method " +
169
- "first — prepareInputs({ files: await client.getMethodClosure(methodId), … }).");
205
+ function resolveSelector(request) {
206
+ const raw = request;
207
+ const files = Array.isArray(raw["files"]) && raw["files"].length > 0
208
+ ? raw["files"]
209
+ : undefined;
210
+ const methodRef = nonEmptyString(raw["method_ref"]);
211
+ const methodId = nonEmptyString(raw["method_id"]);
212
+ const given = [];
213
+ if (files !== undefined)
214
+ given.push("`files`");
215
+ if (methodRef !== undefined)
216
+ given.push("`method_ref`");
217
+ if (methodId !== undefined)
218
+ given.push("`method_id`");
219
+ if (given.length === 0) {
220
+ throw new InputPreparationError("Cannot prepare inputs: no method selector. Supply exactly one of `files` (an inline MTHDS " +
221
+ "closure), `method_ref` (a published method's address) or `method_id` (a stored method's " +
222
+ "catalog id).");
170
223
  }
171
- if (request.files == null) {
172
- throw new InputPreparationError("Cannot prepare inputs: supply `files` (the inline MTHDS closure). A stored method's closure " +
173
- "comes from client.getMethodClosure(methodId).");
224
+ if (given.length > 1) {
225
+ throw new InputPreparationError(`Cannot prepare inputs: ${given.join(" and ")} were both given. Supply exactly one method ` +
226
+ "selector — `files`, `method_ref` or `method_id`.");
174
227
  }
175
- return request.files;
228
+ if (files !== undefined)
229
+ return { files };
230
+ if (methodRef !== undefined)
231
+ return { method_ref: methodRef };
232
+ return { method_id: methodId };
233
+ }
234
+ /**
235
+ * Ask `validate` for the signature, whatever the selector, and hand back the
236
+ * valid report.
237
+ *
238
+ * `allowSignatures: true` on purpose: preparation needs a pipe's DECLARED inputs,
239
+ * and a bundle mid-authoring with an unresolved signature elsewhere must not be
240
+ * refused inputs for a pipe whose inputs are declared. Whether the bundle runs is
241
+ * the run's verdict, not preparation's. The `is_valid: false` arm still means the
242
+ * closure does not load, which is a preparation failure.
243
+ */
244
+ async function fetchSignature(client, selector) {
245
+ let result;
246
+ if ("files" in selector) {
247
+ const contents = selector.files.map((file) => file.content);
248
+ // `validateFiles`' rule: label every content once any file names a source, so
249
+ // the server never sees a length-mismatched `mthds_sources` array.
250
+ const hasAnySource = selector.files.some((file) => file.source !== undefined);
251
+ const sources = hasAnySource
252
+ ? selector.files.map((file, index) => file.source ?? `inline://file-${index + 1}.mthds`)
253
+ : undefined;
254
+ result = await client.validate(contents, true, sources, undefined, ["input_form"]);
255
+ }
256
+ else {
257
+ result = await client.validate(selector, true, undefined, undefined, ["input_form"]);
258
+ }
259
+ if (!result.is_valid) {
260
+ const first = result.validation_errors[0]?.message ?? result.message;
261
+ throw new InputPreparationError(`Cannot prepare inputs: the method signature did not resolve — ${first}`);
262
+ }
263
+ return result;
264
+ }
265
+ /**
266
+ * Pick the pipe whose descriptor guides the walk, in the order `docs/input-preparation.md`
267
+ * documents: an explicit qualified `pipe_ref`, then the report's typed resolved
268
+ * default, then the bundle's declared `main_pipe`, then the single pipe — else an
269
+ * error naming the candidates.
270
+ */
271
+ function selectPipeRef(report, inputForm, requested) {
272
+ const refs = Object.keys(inputForm);
273
+ const candidates = refs.length > 0 ? refs.join(", ") : "(none — the closure declares no pipes)";
274
+ if (requested !== undefined) {
275
+ if (!requested.includes(".")) {
276
+ throw new InputPreparationError(`Cannot prepare inputs: \`pipe_ref\` must be qualified (\`domain.pipe_code\`), got the bare ` +
277
+ `"${requested}". The method declares: ${candidates}.`);
278
+ }
279
+ if (!(requested in inputForm)) {
280
+ throw new InputPreparationError(`Cannot prepare inputs: the method declares no pipe "${requested}". It declares: ${candidates}.`);
281
+ }
282
+ return requested;
283
+ }
284
+ // The typed resolved default, when the runner serves it (manifest-aware for a
285
+ // `method_ref` package, which is why it outranks the blueprint read below).
286
+ const typedDefault = nonEmptyString(report.default_pipe_ref);
287
+ if (typedDefault !== undefined && typedDefault in inputForm)
288
+ return typedDefault;
289
+ // `bundle_blueprint` is opaque transport in this SDK on purpose, so read it
290
+ // defensively and fall through rather than trust it.
291
+ const blueprintDefault = readBlueprintMainPipeRef(report.bundle_blueprint);
292
+ if (blueprintDefault !== undefined && blueprintDefault in inputForm)
293
+ return blueprintDefault;
294
+ if (refs.length === 1)
295
+ return refs[0];
296
+ throw new InputPreparationError(`Cannot prepare inputs: the method declares no single default pipe, so \`pipe_ref\` is required. ` +
297
+ `It declares: ${candidates}.`);
298
+ }
299
+ /**
300
+ * The bundle blueprint's declared `main_pipe`, qualified by its `domain` when it
301
+ * is authored bare. Every read is defensive: the blueprint is typed
302
+ * `Record<string, unknown>` because its schema is the runtime's, not this SDK's.
303
+ */
304
+ function readBlueprintMainPipeRef(blueprint) {
305
+ if (!isPlainObject(blueprint))
306
+ return undefined;
307
+ const mainPipe = nonEmptyString(blueprint["main_pipe"]);
308
+ if (mainPipe === undefined)
309
+ return undefined;
310
+ if (mainPipe.includes("."))
311
+ return mainPipe;
312
+ const domain = nonEmptyString(blueprint["domain"]);
313
+ return domain === undefined ? undefined : `${domain}.${mainPipe}`;
176
314
  }
177
315
  /**
178
316
  * Prepare a pipe's inputs: upload local/byte/data-URL assets at the signature's
@@ -180,45 +318,44 @@ function resolveClosureFiles(request) {
180
318
  * records. HTTP(S) URLs and existing `pipelex-storage://` URIs pass through
181
319
  * unchanged. All failures are raised before any run is created.
182
320
  *
183
- * The declared signature is resolved from the closure; a closure that does not
184
- * resolve throws {@link InputPreparationError}. No-verdict conditions from the
185
- * signature route (unknown `pipe_ref`, auth, server fault) surface as the build
186
- * route's `ApiResponseError`.
321
+ * The signature comes from one `POST /v1/validate` with `views: ["input_form"]`,
322
+ * whatever the selector — inline `files`, a `method_ref` the runner resolves, or
323
+ * a `method_id` the platform resolves. A closure that does not load, an unknown
324
+ * `pipe_ref`, no default pipe, or a report with no descriptor throw
325
+ * {@link InputPreparationError}; a no-verdict condition from the route (a
326
+ * malformed selector, an unknown or foreign-org id, no package at the address,
327
+ * auth, a server fault) surfaces as `ApiResponseError`, unchanged.
187
328
  */
188
329
  export async function prepareInputs(client, request) {
189
- const files = resolveClosureFiles(request);
190
- const report = await client.buildInputs({
191
- files,
192
- ...(request.pipe_ref === undefined ? {} : { pipe_ref: request.pipe_ref }),
193
- format: "json",
194
- explicit: true,
195
- });
196
- if (!report.is_valid) {
197
- const first = report.validation_errors[0]?.message ?? report.message;
198
- throw new InputPreparationError(`Cannot prepare inputs: the method signature did not resolve — ${first}`);
199
- }
200
- // We requested `format: "json"`, so the valid arm carries the envelope in `inputs`.
201
- if (report.format !== "json") {
202
- throw new InputPreparationError(`Cannot prepare inputs: expected a JSON inputs template, got "${report.format}".`);
330
+ const selector = resolveSelector(request);
331
+ const report = await fetchSignature(client, selector);
332
+ const inputForm = report.input_form;
333
+ if (inputForm === undefined) {
334
+ // Never a silent degrade to "no uploads": without the descriptor there is no
335
+ // signature to prepare against.
336
+ throw new InputPreparationError("Cannot prepare inputs: the validate report carries no `input_form` descriptor — the signature " +
337
+ 'preparation reads. The descriptor rides `views: ["input_form"]` on pipelex-api >= 0.18.0; ' +
338
+ "point the client at a runner that serves it.");
203
339
  }
204
- const template = report.inputs;
340
+ const pipeRef = selectPipeRef(report, inputForm, nonEmptyString(request.pipe_ref));
341
+ const descriptor = inputForm[pipeRef];
342
+ const declared = new Map(descriptor.fields.map((field) => [field.name, field]));
205
343
  const ctx = { client, uploads: [], dedup: new Map() };
206
344
  const rewritten = { ...request.inputs };
207
345
  for (const [name, callerValue] of Object.entries(request.inputs)) {
208
- const entry = template[name];
209
- if (!isPlainObject(entry) || !("content" in entry)) {
210
- // Not a declared input (or an unexpected envelope) — pass through untouched.
211
- continue;
346
+ const field = declared.get(name);
347
+ if (field === undefined) {
348
+ continue; // Not a declared input — pass through untouched, as today.
212
349
  }
213
350
  if (isExplicitEnvelope(callerValue)) {
214
- // The caller filled the explicit `{ concept, content }` template: walk the
215
- // inner content against the compact signature, then re-wrap so the concept
351
+ // The caller filled the explicit `{ concept, content }` envelope: walk the
352
+ // inner content against the same node, then re-wrap so the concept
216
353
  // annotation rides through to the run (the runtime accepts the envelope).
217
- const walked = await resolveNode(ctx, entry.content, callerValue.content);
354
+ const walked = await resolveNode(ctx, field, callerValue.content);
218
355
  rewritten[name] = { ...callerValue, content: walked };
219
356
  }
220
357
  else {
221
- rewritten[name] = await resolveNode(ctx, entry.content, callerValue);
358
+ rewritten[name] = await resolveNode(ctx, field, callerValue);
222
359
  }
223
360
  }
224
361
  return { inputs: rewritten, uploads: ctx.uploads };
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-inputs.js","sourceRoot":"","sources":["../src/prepare-inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;A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AAC"}
package/dist/runs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DictPipeOutput } from "./models.js";
1
+ import type { DictPipeOutput, DictWorkingMemory } from "./models.js";
2
2
  /**
3
3
  * Run-lifecycle types + polling for the hosted polling surface (`/v1/runs/*`).
4
4
  *
@@ -131,12 +131,43 @@ export interface RunResults {
131
131
  * output to an object) and may be a valid falsy value (empty array, `0`); it is never absent.
132
132
  */
133
133
  main_stuff: unknown;
134
- /** Method graph spec (`graphspec.json`); null if missing mid-write or on the bare-runner path. */
134
+ /**
135
+ * The run's working memory — every named stuff of the run (`{ root, aliases }`), the inputs it
136
+ * was given and the intermediates it produced as well as the main output, each stuff carried as
137
+ * its concept ref and its content. It reads the same on both paths: the hosted path relays the
138
+ * `working_memory.json` artifact verbatim, and on the blocking path the SDK lifts it off
139
+ * `pipe_output`. `main_stuff` is the content of one of its entries, already resolved. Null on the
140
+ * hosted path when the artifact was not yet written. `DictWorkingMemory` mirrors the MTHDS
141
+ * standard's `DictWorkingMemory` field for field. A run delivered by a runtime older than
142
+ * pipelex 0.60.0 carries each `concept` as the concept object instead, and a stored artifact is
143
+ * relayed as written, never migrated: the type stays the standard's `string`, so read `concept`
144
+ * as `unknown` when a run may predate that release. See `docs/run-results.md`.
145
+ */
146
+ working_memory?: DictWorkingMemory | null;
147
+ /**
148
+ * The executed graph — the same document a local run writes as `graphspec.json`: `meta.mode`
149
+ * `"live"`, one node per pipe with its status, its timings and its own usage. It reaches the client on both
150
+ * paths: the hosted path relays the `graphspec.json` artifact verbatim, and on the blocking path
151
+ * the SDK lifts it off `pipe_output`. Null when the runner assembled no graph (see
152
+ * `graph_assembly_error`) or, on the hosted path, when the artifact was not yet written. Typed
153
+ * `unknown` on purpose — the canonical declaration is `GraphSpec` in `@pipelex/mthds-ui`, which
154
+ * carries a React peer dependency this server-side SDK does not take. See `docs/run-results.md`.
155
+ */
135
156
  graph_spec?: unknown;
136
157
  /**
137
- * Bare runner's native pipe output — the full working memory (`{ root, aliases }`),
138
- * blocking-execute path only; null on the hosted path. Supplementary to `main_stuff`,
139
- * which is already resolved out of it; kept for consumers that need the whole working memory.
158
+ * Non-null when the runner's graph assembly failed for the run — the graph's twin of
159
+ * `usage_assembly_error`, and the only thing that separates "the graph broke" from "this run
160
+ * produced no graph". Lifted off `pipe_output` on the blocking path; the hosted results body
161
+ * carries nothing of the kind yet, so on that path the field is absent until the platform writes
162
+ * and relays it.
163
+ */
164
+ graph_assembly_error?: string | null;
165
+ /**
166
+ * Bare runner's native pipe output, blocking-execute path only; absent on the hosted path, whose
167
+ * results body carries no such key, so it reads `undefined` there. Supplementary: `main_stuff`,
168
+ * `working_memory`, the graph pair and the usage pair are all lifted out of it onto their own
169
+ * fields, which read the same on both paths. Read `working_memory` for the run's named stuffs;
170
+ * `pipe_output` is the runner's output as it arrived, extension fields included.
140
171
  */
141
172
  pipe_output?: DictPipeOutput | null;
142
173
  /**
package/dist/runs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwC9D,MAAM,qBAAqB,GAA2B,IAAI,GAAG,CAAY;IACvE,WAAW;IACX,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,WAAW;CACZ,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,OAAO,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,OAAO,MAAM,KAAK,WAAW,CAAC;AAChC,CAAC;AAkKD,uEAAuE;AAEvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC,CAAC,0DAA0D;AAQ5G;;;;;;;;G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AED,SAAS,UAAU,CAAC,MAAoB;IACtC,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC;IAC9B,IAAI,MAAM,YAAY,KAAK;QAAE,OAAO,MAAM,CAAC;IAC3C,OAAO,IAAI,YAAY,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;AACrE,CAAC;AAED,iFAAiF;AACjF,SAAS,KAAK,CAAC,EAAU,EAAE,MAAoB;IAC7C,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACZ,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,OAAO;YACT,CAAC;YACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { RunResults } from "./runs.js";
2
+ /**
3
+ * `summarizeUsage` — one run-level reading of a run's usage pair.
4
+ *
5
+ * A completed run reports usage as `RunResults.tokens_usages` (one record per inference call)
6
+ * beside `RunResults.usage_assembly_error`, and the wire carries no run-level aggregate. This
7
+ * module folds the pair into a single summary under the rules `docs/run-usage.md` states, so
8
+ * every consumer reads the same totals instead of re-deriving them:
9
+ *
10
+ * - a `null` cost is unrated (the model has no rate table), a `0` cost is priced at zero;
11
+ * - `input` and `output` are the only additive token categories (`input_cached` is a subset of
12
+ * `input`, and summing every category double-counts);
13
+ * - a null list means usage is unavailable, and only `usage_assembly_error` says it broke;
14
+ * - an empty list is a run that did no inference, which costs `0`, not `null`.
15
+ *
16
+ * Pure: no I/O, no client, and the input is never mutated.
17
+ */
18
+ /**
19
+ * Which of the three readings of `tokens_usages` the summary describes:
20
+ * - `records` — a non-empty list: the totals are folded from it.
21
+ * - `no_inference` — `[]`: usage assembly ran and no inference happened, so the cost is `0`
22
+ * and the token totals are zero.
23
+ * - `unavailable` — the list is null or absent: usage assembly was off, it broke (then
24
+ * `assembly_error` is non-null), or on the hosted path the run was delivered before the
25
+ * usage artifact existed. Nothing is known, so the cost and the token totals are `null`.
26
+ */
27
+ export type UsageSummaryState = "records" | "no_inference" | "unavailable";
28
+ /**
29
+ * The two additive token totals. Each is the sum of that category over the records that
30
+ * reported it, and `null` when no record reported it at all — which is different from a
31
+ * reported `0`.
32
+ */
33
+ export interface UsageTokenTotals {
34
+ input: number | null;
35
+ output: number | null;
36
+ }
37
+ /** One pipe's share of a run's usage — the same fold as the run level, over its calls only. */
38
+ export interface PipeUsageSummary {
39
+ /** The pipe that made the calls; `null` groups the calls the runtime did not attribute. */
40
+ pipe_code: string | null;
41
+ /** Sum of the priced calls' costs in USD; `null` when none of this pipe's calls was priced. */
42
+ total_cost_usd: number | null;
43
+ /** True when this pipe mixes priced and unrated calls, so `total_cost_usd` is a lower bound. */
44
+ cost_partial: boolean;
45
+ tokens: UsageTokenTotals;
46
+ /** Number of inference calls this pipe made. */
47
+ calls: number;
48
+ }
49
+ /** A run's usage pair folded into one null-aware reading. */
50
+ export interface UsageSummary {
51
+ state: UsageSummaryState;
52
+ /**
53
+ * Sum of the priced calls' costs in USD. `0` for `no_inference`. `null` for `records` when no
54
+ * call was priced (unrated), and for `unavailable`, where nothing is known — read `state`
55
+ * first to tell the two apart.
56
+ */
57
+ total_cost_usd: number | null;
58
+ /**
59
+ * True when priced and unrated calls are mixed, so `total_cost_usd` covers the priced calls
60
+ * only and is a lower bound. Never true outside `records`.
61
+ */
62
+ cost_partial: boolean;
63
+ tokens: UsageTokenTotals;
64
+ /** Number of usage records summarized — one per inference call; `0` outside `records`. */
65
+ calls: number;
66
+ /**
67
+ * `usage_assembly_error` as relayed: non-null when the runner's usage assembly failed, which
68
+ * is the only thing that separates a broken assembly from an `unavailable` one that was off.
69
+ */
70
+ assembly_error: string | null;
71
+ /**
72
+ * Per-pipe rollup, most expensive first: priced pipes by cost descending, then unrated pipes,
73
+ * with ties broken by call count (descending) and then by pipe code. Empty outside `records`.
74
+ */
75
+ by_pipe: PipeUsageSummary[];
76
+ }
77
+ /** The part of `RunResults` the summary reads — a whole `RunResults` is accepted as is. */
78
+ export type RunUsagePair = Pick<RunResults, "tokens_usages" | "usage_assembly_error">;
79
+ /**
80
+ * Fold a run's usage pair into one summary: run totals, the call count, the assembly error and
81
+ * a per-pipe rollup. See `docs/run-usage.md` for the rules it applies.
82
+ *
83
+ * Pre-contract records, relayed verbatim from artifacts written before the usage contract,
84
+ * carry no `cost` and no `pipe_code`: they count as unrated and unattributed. The legacy
85
+ * `job_metadata` / `unit_costs` fields are relics and are never read.
86
+ */
87
+ export declare function summarizeUsage(results: RunUsagePair): UsageSummary;