@instruments/materialgraph 1.4.0 → 2.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.
@@ -15,8 +15,7 @@
15
15
  *
16
16
  * Keyed by OpenAPI `operationId`, the same id `SDK_OPERATIONS` pairs with each
17
17
  * client method. Schemas are JSON Schema 2020-12 and describe the parsed body
18
- * the client method returns. `list_public_run_events` is absent: it streams
19
- * Server-Sent Events rather than returning one JSON body.
18
+ * the client method returns.
20
19
  *
21
20
  * Objects accept properties the schema does not declare, so a field the API
22
21
  * adds later never makes a pinned consumer reject a live response; enums and
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Hand-mirrored wire types for the MaterialGraph source-material upload. Like
3
+ * {@link ./types.ts}, these interfaces carry NO runtime dependency on any
4
+ * `@materialgraph/*` package — they mirror `upload_source_material` in
5
+ * `apps/web/public/openapi.yaml`.
6
+ *
7
+ * TOLERANT-PARSING CONTRACT: response enums are widened with {@link OpenEnum}
8
+ * so a new server value still type-checks, and objects are read structurally —
9
+ * unknown keys pass through untouched.
10
+ */
11
+ import type { BatchId, SourceFileId } from "./identifiers.js";
12
+ import type { OpenEnum } from "./types.js";
13
+ /**
14
+ * A file to upload. Two forms so the SDK is ergonomic on BOTH Node route
15
+ * handlers and modern runtimes: pass a platform `Blob`/`File` directly, or the
16
+ * bytes plus a filename. The SDK builds the multipart body internally — callers
17
+ * never touch `FormData` or wrestle a `string`-typed binary field.
18
+ */
19
+ export type FileInput = Blob | {
20
+ /** Raw file bytes. */
21
+ data: Uint8Array | ArrayBuffer;
22
+ /** Filename recorded on the multipart part (drives the stored receipt filename). */
23
+ filename: string;
24
+ /** Optional MIME type; the server re-validates by magic bytes regardless. */
25
+ contentType?: string;
26
+ };
27
+ /**
28
+ * Input for {@link MaterialGraphClient.uploadSourceMaterial}: a heterogeneous
29
+ * pile of source files (multipart field `files`, repeatable), any mix of PDF,
30
+ * plain-text/markdown, and images (≥1, ≤16). The server classifies each file
31
+ * and assigns its receipt {@link SourceMaterialReceiptFile.role}.
32
+ */
33
+ export type UploadSourceMaterialInput = {
34
+ files: FileInput[];
35
+ };
36
+ /** One stored file in an upload receipt. */
37
+ export type SourceMaterialReceiptFile = {
38
+ /** The stored file id (`smf_…`). Opaque — the prefix is a reading aid, not a contract. */
39
+ sourceId: SourceFileId;
40
+ /**
41
+ * The pipeline-assigned role. The vocabulary grows over time; {@link OpenEnum}
42
+ * keeps a newer server value type-checking. `unclassified` is a legitimate
43
+ * terminal value when the pipeline could not place the file.
44
+ */
45
+ role: OpenEnum<"brief" | "reference_image" | "document" | "document_image" | "inspiration_image" | "unclassified">;
46
+ filename: string;
47
+ mediaType: string;
48
+ /** Lowercase hex SHA-256 of the stored bytes. */
49
+ sha256: string;
50
+ bytes: number;
51
+ /** PDF page count; null for images. */
52
+ pages: number | null;
53
+ };
54
+ /** The `201` receipt from `POST /api/v1/source-material`. */
55
+ export type SourceMaterialBatchReceipt = {
56
+ /** The stored batch id (`smb_…`). Opaque. */
57
+ batchId: BatchId;
58
+ sources: SourceMaterialReceiptFile[];
59
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { HttpTransport } from "./http-transport.js";
2
+ import type { SourceMaterialBatchReceipt, UploadSourceMaterialInput } from "./source-material-types.js";
3
+ /**
4
+ * Upload one atomic source-material batch (`POST /api/v1/source-material`).
5
+ * Each entry of `{ files }` becomes one part of the repeatable multipart
6
+ * `files` field.
7
+ */
8
+ export declare const uploadSourceMaterial: (transport: HttpTransport, input: UploadSourceMaterialInput, signal?: AbortSignal) => Promise<SourceMaterialBatchReceipt>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The source-material upload, over the shared {@link HttpTransport}.
3
+ * `MaterialGraphClient.uploadSourceMaterial` is a thin wrapper over it.
4
+ */
5
+ import { MaterialGraphError } from "./errors.js";
6
+ import { findSdkOperation, operationPath } from "./operations.js";
7
+ const hasSourceIdentity = (source) => typeof source === "object" &&
8
+ source !== null &&
9
+ "sourceId" in source &&
10
+ typeof source.sourceId === "string" &&
11
+ "role" in source &&
12
+ typeof source.role === "string" &&
13
+ "filename" in source &&
14
+ typeof source.filename === "string" &&
15
+ "mediaType" in source &&
16
+ typeof source.mediaType === "string";
17
+ const hasSourceMeasurements = (source) => typeof source === "object" &&
18
+ source !== null &&
19
+ "sha256" in source &&
20
+ typeof source.sha256 === "string" &&
21
+ "bytes" in source &&
22
+ typeof source.bytes === "number" &&
23
+ "pages" in source &&
24
+ (source.pages === null || typeof source.pages === "number");
25
+ const isSourceReceipt = (value) => typeof value === "object" &&
26
+ value !== null &&
27
+ "batchId" in value &&
28
+ typeof value.batchId === "string" &&
29
+ "sources" in value &&
30
+ Array.isArray(value.sources) &&
31
+ value.sources.every((source) => typeof source === "object" &&
32
+ source !== null &&
33
+ hasSourceIdentity(source) &&
34
+ hasSourceMeasurements(source));
35
+ const sdkOperation = (operationId) => {
36
+ const match = findSdkOperation(operationId);
37
+ if (!match) {
38
+ throw MaterialGraphError.unexpected(`Unknown SDK operation: ${operationId}`);
39
+ }
40
+ return { ...match, operationId };
41
+ };
42
+ /** Build a `Blob` from raw bytes, normalizing to an ArrayBuffer-backed view. */
43
+ const bytesToBlob = (input) => {
44
+ const type = input.contentType !== undefined && input.contentType !== ""
45
+ ? { type: input.contentType }
46
+ : {};
47
+ if (input.data instanceof ArrayBuffer) {
48
+ return new Blob([input.data], type);
49
+ }
50
+ // A Uint8Array may be SharedArrayBuffer-backed; copy into a fresh view so the
51
+ // Blob part is unambiguously ArrayBuffer-backed (no cast needed).
52
+ const copy = new Uint8Array(input.data.byteLength);
53
+ copy.set(input.data);
54
+ return new Blob([copy], type);
55
+ };
56
+ /** Append one file to the multipart body, from either input form. */
57
+ const appendFile = (form, field, input) => {
58
+ if (input instanceof Blob) {
59
+ if (input instanceof File) {
60
+ form.append(field, input, input.name);
61
+ }
62
+ else {
63
+ form.append(field, input);
64
+ }
65
+ return;
66
+ }
67
+ form.append(field, bytesToBlob(input), input.filename);
68
+ };
69
+ /**
70
+ * Upload one atomic source-material batch (`POST /api/v1/source-material`).
71
+ * Each entry of `{ files }` becomes one part of the repeatable multipart
72
+ * `files` field.
73
+ */
74
+ export const uploadSourceMaterial = async (transport, input, signal) => {
75
+ const form = new FormData();
76
+ for (const file of input.files) {
77
+ appendFile(form, "files", file);
78
+ }
79
+ const url = transport.buildUrl(operationPath(sdkOperation("upload_source_material")));
80
+ // No Content-Type header: fetch sets multipart/form-data with the boundary.
81
+ const { parsed } = await transport.send({
82
+ body: form,
83
+ headers: transport.authHeaders(),
84
+ method: "POST",
85
+ signal,
86
+ url,
87
+ });
88
+ if (!isSourceReceipt(parsed)) {
89
+ throw MaterialGraphError.unexpected("MaterialGraph source-material upload returned an invalid receipt");
90
+ }
91
+ return parsed;
92
+ };
@@ -1,7 +1,7 @@
1
1
  const json = [
2
- "[{\"annotations\":{\"readOnlyHint\":true,\"untrustedContentHint\":true},\"description\":\"Reads `query` into filters, runs them through `list_variants` and answers with what was understood beside a page of variants. `understood` says what each phrase became: a hard `filter`, a ranking `preference`, or `not_applied` when nothing could serve it. `filters`, `optionalFilters` and `name` are exactly what ran, so the three can be sent to `list_variants` to narrow or widen the same search. A phrase with more than one meaning is answered with one and listed in `choices`: send its `handle` with an alternative's `group` and `id` in `selections` to switch it. `unresolved` lists words nothing in the vocabulary could read. A query that applies nothing returns no items, never the whole catalog; a preference alone still ranks it. `cursor` is the previous page's `pageInfo.endCursor`, tied to the vocabulary version the query was read against; it pages this operation only, not `list_variants`. Requires the `mg:read` bearer scope.\",\"inputSchema\":{\"$ref\":\"#/$defs/schema0\",\"$defs\":{\"schema0\":{\"type\":\"object\",\"properties\":{\"attributes\":{\"description\":\"Attribute/block ids to add; id fields always return.\",\"maxItems\":50,\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"cursor\":{\"type\":\"string\"},\"leaveOut\":{\"maxItems\":8,\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"limit\":{\"description\":\"5-10 for examples.\",\"type\":\"integer\",\"minimum\":1,\"maximum\":50},\"query\":{\"type\":\"string\",\"minLength\":1,\"maxLength\":200,\"description\":\"What to find, in plain words.\"},\"selections\":{\"description\":\"Switch a choice: handle, alternative group and id.\",\"maxItems\":8,\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"group\":{\"type\":\"string\"},\"handle\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"}},\"required\":[\"group\",\"handle\",\"id\"],\"additionalProperties\":false}},\"searchCatalogSubset\":{\"description\":\"Only this corpus scope. Absent or all: every variant.\",\"type\":\"string\",\"enum\":[\"all\",\"samplizeCatalog\",\"materialBankOrderable\",\"materialBankNaOrderable\",\"materialBankNaAndCatalog\",\"materialBankEuOrderable\",\"designShopOrderable\"]},\"include\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"enum\":[\"image\",\"url\"]}}},\"required\":[\"query\"],\"additionalProperties\":false}}},\"method\":\"POST\",\"name\":\"search\",\"operationId\":\"search_variants\",\"outputSchema\":{\"$ref\":\"#/$defs/schema0\",\"$defs\":{\"schema1\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"number\"},{\"type\":\"boolean\"},{\"type\":\"null\"},{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/schema1\"}},{\"type\":\"object\",\"propertyNames\":{\"type\":\"string\"},\"additionalProperties\":{\"$ref\":\"#/$defs/schema1\"}}]},\"schema0\":{\"type\":\"object\",\"properties\":{\"excludedBySearchCatalogSubset\":{\"description\":\"Filtered variant ids outside the materials catalog.\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"items\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"category\":{\"anyOf\":[{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},{\"type\":\"null\"}],\"description\":\"The first original source category, or null when unknown.\"},\"categories\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},\"description\":\"All original source categories in source order.\"},\"productType\":{\"anyOf\":[{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},{\"type\":\"null\"}],\"description\":\"The accepted primary specification type, or null for a color sample or unresolved subject.\"},\"sampleSubject\":{\"type\":\"string\",\"enum\":[\"material\",\"paint_color_sample\",\"unknown\",\"conflict\"]},\"colorOptionValueId\":{\"type\":[\"string\",\"null\"]},\"hasDeclaredColor\":{\"type\":\"boolean\",\"description\":\"True for a paint color card, paint line, primer or coating: the card is the brand's declared hex, never a photo.\"},\"code\":{\"description\":\"The brand's item code.\",\"type\":[\"string\",\"null\"]},\"hex\":{\"description\":\"The settled card color hex, or null when unknown. Paint cards show this color and never a ph",
3
- "oto.\",\"type\":[\"string\",\"null\"]},\"image\":{\"anyOf\":[{\"type\":\"object\",\"properties\":{\"alt\":{\"type\":\"string\"},\"url\":{\"type\":\"string\"}},\"required\":[\"alt\",\"url\"],\"additionalProperties\":false},{\"type\":\"null\"}],\"description\":\"The settled material card image. Always null for paint color samples and paint/coating product types.\"},\"brand\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false,\"description\":\"The brand. `id` is the slug get_brand takes.\"},\"name\":{\"type\":\"string\",\"description\":\"The unambiguous variant name, including its source label when needed.\"},\"variantLabel\":{\"description\":\"The source variant label, trimmed; null when unknown or for a paint color sample, whose own name identifies its color. Separate from surface finish, color family and derived color names.\",\"type\":[\"string\",\"null\"]},\"product\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},\"url\":{\"description\":\"The brand's page for it, or null when none is known.\",\"type\":[\"string\",\"null\"]},\"variantId\":{\"type\":\"string\"},\"materialBankId\":{\"description\":\"The variant's Material Bank SKU. Absent: none recorded.\",\"type\":\"string\"},\"notApplicable\":{\"type\":\"object\",\"properties\":{\"attributes\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"blocks\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false,\"description\":\"Requested blocks or attributes this product type does not carry.\"},\"preference\":{\"type\":\"object\",\"properties\":{\"matched\":{\"type\":\"array\",\"items\":{\"type\":\"number\"}},\"score\":{\"type\":\"number\"}},\"required\":[\"matched\",\"score\"],\"additionalProperties\":false},\"specifications\":{\"type\":\"object\",\"propertyNames\":{\"type\":\"string\"},\"additionalProperties\":{\"type\":\"object\",\"propertyNames\":{\"type\":\"string\"},\"additionalProperties\":{\"$ref\":\"#/$defs/schema1\"}}},\"variantCount\":{\"description\":\"Eligible variants of this product. Absent: none counted.\",\"type\":\"integer\",\"exclusiveMinimum\":0,\"maximum\":9007199254740991}},\"required\":[\"category\",\"categories\",\"productType\",\"sampleSubject\",\"colorOptionValueId\",\"hasDeclaredColor\",\"code\",\"brand\",\"name\",\"variantLabel\",\"product\",\"variantId\"],\"additionalProperties\":false}},\"nameWords\":{\"description\":\"Empty name lookup: each word, and whether a name in scope starts it. Unmatched words were left out unless all or none matched.\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"matched\":{\"type\":\"boolean\"},\"word\":{\"type\":\"string\"}},\"required\":[\"matched\",\"word\"],\"additionalProperties\":false}},\"pageInfo\":{\"type\":\"object\",\"properties\":{\"endCursor\":{\"type\":[\"string\",\"null\"]},\"hasNextPage\":{\"type\":\"boolean\"}},\"required\":[\"endCursor\",\"hasNextPage\"],\"additionalProperties\":false},\"preferenceMatchesRemain\":{\"description\":\"False: nothing from this page on meets any optionalFilter.\",\"type\":\"boolean\"},\"unavailableVariantIds\":{\"description\":\"Filtered ids in the catalog this list can't show, e.g. retired.\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"unresolvedVariantIds\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"unstated\":{\"description\":\"Filtered attributes no variant in scope states at all.\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"words\":{\"description\":\"Each word asked for, and whether any variant in scope names it.\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"matched\":{\"type\":\"boolean\"},\"word\":{\"type\":\"string\"}},\"required\":[\"matched\",\"word\"],\"additionalProperties\":false}},\"choices\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"alternatives\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"group\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"kind\":{\"type\":\"string\"},\"label\":{\"type\":\"string\"}},\"required\":[\"group\",\"id\",\"kind\",\"label\"],\"additionalProperties\":false}},\"basis\":{\"type\":\"string\"},\"handle\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"selected\":{\"type\":\"object\",\"properties\":{\"group\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"kind\":{\"type\":\"string\"},\"label\":{\"type\":\"string\"}},\"required\":[\"group\",\"id\",\"kind\",\"label\"],\"additionalProperties\":false},\"te",
4
- "xt\":{\"type\":\"string\"}},\"required\":[\"alternatives\",\"basis\",\"handle\",\"reason\",\"selected\",\"text\"],\"additionalProperties\":false}},\"colors\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"hex\":{\"type\":\"string\",\"pattern\":\"^#[\\\\da-f]{6}$\",\"description\":\"The color's own point in the region; it orders matches.\"},\"intent\":{\"type\":\"string\",\"enum\":[\"required\",\"preferred\"]},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"range\":{\"type\":\"object\",\"properties\":{\"chroma\":{\"type\":\"array\",\"prefixItems\":[{\"type\":\"number\"},{\"type\":\"number\"}],\"items\":false,\"minItems\":2,\"maxItems\":2},\"hue\":{\"anyOf\":[{\"type\":\"array\",\"prefixItems\":[{\"type\":\"number\"},{\"type\":\"number\"}],\"items\":false,\"minItems\":2,\"maxItems\":2},{\"type\":\"null\"}]},\"lightness\":{\"type\":\"array\",\"prefixItems\":[{\"type\":\"number\"},{\"type\":\"number\"}],\"items\":false,\"minItems\":2,\"maxItems\":2}},\"required\":[\"chroma\",\"hue\",\"lightness\"],\"additionalProperties\":false}},\"required\":[\"hex\",\"op\",\"range\"],\"additionalProperties\":false},\"description\":\"The color regions that ran.\"},\"corrections\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"correction\":{\"type\":\"string\"},\"word\":{\"type\":\"string\"}},\"required\":[\"correction\",\"word\"],\"additionalProperties\":false}},\"filters\":{\"type\":\"object\",\"properties\":{\"anyField\":{\"description\":\"One of values in any of fields (term attributes).\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"fields\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"fields\",\"op\",\"values\"],\"additionalProperties\":false}},\"numbers\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"eq\",\"gt\",\"gte\",\"lt\",\"lte\"]},\"value\":{\"type\":\"number\"}},\"required\":[\"field\",\"op\",\"value\"],\"additionalProperties\":false}},\"presence\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"exists\",\"missing\"]}},\"required\":[\"field\",\"op\"],\"additionalProperties\":false}},\"terms\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"all\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"field\",\"op\",\"values\"],\"additionalProperties\":false}}},\"additionalProperties\":false,\"description\":\"The filters that ran, the scope among them.\"},\"name\":{\"type\":\"string\",\"description\":\"The paint name looked up.\"},\"oneRowPer\":{\"type\":\"string\",\"enum\":[\"product\",\"variant\",\"paint_variant_or_product\"],\"description\":\"A row per product, per variant, or per exact paint variant followed by other products.\"},\"optionalFilters\":{\"type\":\"object\",\"properties\":{\"anyField\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"fields\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"fields\",\"op\",\"values\",\"weight\"],\"additionalProperties\":false}},\"numbers\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"eq\",\"gt\",\"gte\",\"lt\",\"lte\"]},\"value\":{\"type\":\"number\"},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"field\",\"op\",\"value\",\"weight\"],\"additionalProperties\":false}},\"presence\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"exists\",\"missing\"]},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"field\",\"op\",\"weight\"],\"additionalProperties\":false}},\"terms\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"all\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"field\",\"op\",\"values\",\"weight\"",
5
- "],\"additionalProperties\":false}}},\"additionalProperties\":false,\"description\":\"The preferences that ran.\"},\"outcome\":{\"type\":\"string\",\"enum\":[\"page\",\"partial_match\",\"no_match\",\"nothing_understood\",\"out_of_scope\",\"brand_not_in_catalog\"],\"description\":\"How the search ended.\"},\"scope\":{\"type\":\"object\",\"properties\":{\"anyField\":{\"description\":\"One of values in any of fields (term attributes).\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"fields\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"fields\",\"op\",\"values\"],\"additionalProperties\":false}},\"numbers\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"eq\",\"gt\",\"gte\",\"lt\",\"lte\"]},\"value\":{\"type\":\"number\"}},\"required\":[\"field\",\"op\",\"value\"],\"additionalProperties\":false}},\"presence\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"exists\",\"missing\"]}},\"required\":[\"field\",\"op\"],\"additionalProperties\":false}},\"terms\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"all\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"field\",\"op\",\"values\"],\"additionalProperties\":false}}},\"additionalProperties\":false,\"description\":\"The fixed scope, repeated in filters.\"},\"understood\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"applied\":{\"type\":\"string\",\"enum\":[\"filter\",\"preference\",\"not_applied\"],\"description\":\"filter narrows; preference only ranks; not_applied did neither.\"},\"id\":{\"type\":\"string\",\"description\":\"The parser's condition id.\"},\"kind\":{\"type\":\"string\",\"enum\":[\"category\",\"brand\",\"term\",\"number\",\"color\",\"paint\",\"name\"]},\"label\":{\"type\":\"string\",\"description\":\"What the words were read as.\"},\"note\":{\"type\":\"string\"},\"text\":{\"type\":\"string\",\"description\":\"The query words it came from.\"}},\"required\":[\"applied\",\"id\",\"kind\",\"label\",\"text\"],\"additionalProperties\":false}},\"unresolved\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"items\",\"pageInfo\",\"oneRowPer\",\"outcome\",\"understood\"],\"additionalProperties\":false}}},\"path\":\"/api/v1/variants/search\",\"requiredHeaders\":[],\"requiresVisibleConfirmation\":false}]",
2
+ "[{\"annotations\":{\"readOnlyHint\":true,\"untrustedContentHint\":true},\"description\":\"Reads `query` into filters, runs them through `list_variants` and answers with what was understood beside a page of variants. `understood` says what each phrase became: a hard `filter`, a ranking `preference`, or `not_applied` when nothing could serve it. `filters`, `optionalFilters` and `name` are exactly what ran, so the three can be sent to `list_variants` to narrow or widen the same search. A phrase with more than one meaning is answered with one and listed in `choices`: send its `handle` with an alternative's `group` and `id` in `selections` to switch it. `unresolved` lists words nothing in the vocabulary could read. A query that applies nothing returns no items, never the whole catalog; a preference alone still ranks it. `cursor` is the previous page's `pageInfo.endCursor`, tied to the vocabulary version the query was read against; it pages this operation only, not `list_variants`. Requires the `mg:read` bearer scope.\",\"inputSchema\":{\"$ref\":\"#/$defs/schema0\",\"$defs\":{\"schema0\":{\"type\":\"object\",\"properties\":{\"attributes\":{\"description\":\"Attribute/block ids to add; id fields always return.\",\"maxItems\":50,\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"cursor\":{\"type\":\"string\"},\"leaveOut\":{\"maxItems\":8,\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"limit\":{\"description\":\"5-10 for examples.\",\"type\":\"integer\",\"minimum\":1,\"maximum\":50},\"query\":{\"type\":\"string\",\"minLength\":1,\"maxLength\":200,\"description\":\"What to find, in plain words.\"},\"searchCatalogSubset\":{\"description\":\"Only this corpus scope.\",\"type\":\"string\",\"enum\":[\"all\",\"samplizeCatalog\",\"materialBankOrderable\",\"materialBankNaOrderable\",\"materialBankNaAndCatalog\",\"materialBankEuOrderable\",\"designShopOrderable\"]},\"selections\":{\"description\":\"Switch a choice: handle, alternative group and id.\",\"maxItems\":8,\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"group\":{\"type\":\"string\"},\"handle\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"}},\"required\":[\"group\",\"handle\",\"id\"],\"additionalProperties\":false}},\"include\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"enum\":[\"image\",\"url\"]}}},\"required\":[\"query\"],\"additionalProperties\":false}}},\"method\":\"POST\",\"name\":\"search\",\"operationId\":\"search_variants\",\"outputSchema\":{\"$ref\":\"#/$defs/schema0\",\"$defs\":{\"schema1\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"number\"},{\"type\":\"boolean\"},{\"type\":\"null\"},{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/schema1\"}},{\"type\":\"object\",\"propertyNames\":{\"type\":\"string\"},\"additionalProperties\":{\"$ref\":\"#/$defs/schema1\"}}]},\"schema0\":{\"type\":\"object\",\"properties\":{\"excludedBySearchCatalogSubset\":{\"description\":\"Filtered variant ids outside the materials catalog.\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"items\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"category\":{\"anyOf\":[{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},{\"type\":\"null\"}],\"description\":\"The first original source category, or null when unknown.\"},\"categories\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},\"description\":\"All original source categories in source order.\"},\"productType\":{\"anyOf\":[{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},{\"type\":\"null\"}],\"description\":\"The accepted primary specification type, or null for a color sample or unresolved subject.\"},\"sampleSubject\":{\"type\":\"string\",\"enum\":[\"material\",\"paint_color_sample\",\"unknown\",\"conflict\"]},\"colorOptionValueId\":{\"type\":[\"string\",\"null\"]},\"hasDeclaredColor\":{\"type\":\"boolean\",\"description\":\"True for a paint color card, paint line, primer or coating: the card is the brand's declared hex, never a photo.\"},\"code\":{\"description\":\"The brand's item code.\",\"type\":[\"string\",\"null\"]},\"hex\":{\"description\":\"The settled card color hex, or null when unknown. Paint cards show this color and never a photo.\",\"type\":[\"string\",\"null\"]",
3
+ "},\"image\":{\"anyOf\":[{\"type\":\"object\",\"properties\":{\"alt\":{\"type\":\"string\"},\"url\":{\"type\":\"string\"}},\"required\":[\"alt\",\"url\"],\"additionalProperties\":false},{\"type\":\"null\"}],\"description\":\"The settled material card image. Always null for paint color samples and paint/coating product types.\"},\"brand\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false,\"description\":\"The brand. `id` is the slug get_brand takes.\"},\"name\":{\"type\":\"string\",\"description\":\"The unambiguous variant name, including its source label when needed.\"},\"variantLabel\":{\"description\":\"The source variant label, trimmed; null when unknown or for a paint color sample, whose own name identifies its color. Separate from surface finish, color family and derived color names.\",\"type\":[\"string\",\"null\"]},\"product\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\",\"name\"],\"additionalProperties\":false},\"url\":{\"description\":\"The brand's page for it, or null when none is known.\",\"type\":[\"string\",\"null\"]},\"variantId\":{\"type\":\"string\"},\"materialBankId\":{\"description\":\"The variant's Material Bank SKU. Absent: none recorded.\",\"type\":\"string\"},\"notApplicable\":{\"type\":\"object\",\"properties\":{\"attributes\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"blocks\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"additionalProperties\":false,\"description\":\"Requested blocks or attributes this product type does not carry.\"},\"preference\":{\"type\":\"object\",\"properties\":{\"matched\":{\"type\":\"array\",\"items\":{\"type\":\"number\"}},\"score\":{\"type\":\"number\"}},\"required\":[\"matched\",\"score\"],\"additionalProperties\":false},\"specifications\":{\"type\":\"object\",\"propertyNames\":{\"type\":\"string\"},\"additionalProperties\":{\"type\":\"object\",\"propertyNames\":{\"type\":\"string\"},\"additionalProperties\":{\"$ref\":\"#/$defs/schema1\"}}},\"variantCount\":{\"description\":\"Eligible variants of this product. Absent: none counted.\",\"type\":\"integer\",\"exclusiveMinimum\":0,\"maximum\":9007199254740991}},\"required\":[\"category\",\"categories\",\"productType\",\"sampleSubject\",\"colorOptionValueId\",\"hasDeclaredColor\",\"code\",\"brand\",\"name\",\"variantLabel\",\"product\",\"variantId\"],\"additionalProperties\":false}},\"nameWords\":{\"description\":\"Empty name lookup: each word, and whether a name in scope starts it. Unmatched words were left out unless all or none matched.\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"matched\":{\"type\":\"boolean\"},\"word\":{\"type\":\"string\"}},\"required\":[\"matched\",\"word\"],\"additionalProperties\":false}},\"pageInfo\":{\"type\":\"object\",\"properties\":{\"endCursor\":{\"type\":[\"string\",\"null\"]},\"hasNextPage\":{\"type\":\"boolean\"}},\"required\":[\"endCursor\",\"hasNextPage\"],\"additionalProperties\":false},\"preferenceMatchesRemain\":{\"description\":\"False: nothing from this page on meets any optionalFilter.\",\"type\":\"boolean\"},\"unavailableVariantIds\":{\"description\":\"Filtered ids in the catalog this list can't show, e.g. retired.\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"unresolvedVariantIds\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"unstated\":{\"description\":\"Filtered attributes no variant in scope states at all.\",\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"words\":{\"description\":\"Each word asked for, and whether any variant in scope names it.\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"matched\":{\"type\":\"boolean\"},\"word\":{\"type\":\"string\"}},\"required\":[\"matched\",\"word\"],\"additionalProperties\":false}},\"choices\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"alternatives\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"group\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"kind\":{\"type\":\"string\"},\"label\":{\"type\":\"string\"}},\"required\":[\"group\",\"id\",\"kind\",\"label\"],\"additionalProperties\":false}},\"basis\":{\"type\":\"string\"},\"handle\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"selected\":{\"type\":\"object\",\"properties\":{\"group\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"kind\":{\"type\":\"string\"},\"label\":{\"type\":\"string\"}},\"required\":[\"group\",\"id\",\"kind\",\"label\"],\"additionalProperties\":false},\"text\":{\"type\":\"string\"}},\"requir",
4
+ "ed\":[\"alternatives\",\"basis\",\"handle\",\"reason\",\"selected\",\"text\"],\"additionalProperties\":false}},\"colors\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"hex\":{\"type\":\"string\",\"pattern\":\"^#[\\\\da-f]{6}$\",\"description\":\"The color's own point in the region; it orders matches.\"},\"intent\":{\"type\":\"string\",\"enum\":[\"required\",\"preferred\"]},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"range\":{\"type\":\"object\",\"properties\":{\"chroma\":{\"type\":\"array\",\"prefixItems\":[{\"type\":\"number\"},{\"type\":\"number\"}],\"items\":false,\"minItems\":2,\"maxItems\":2},\"hue\":{\"anyOf\":[{\"type\":\"array\",\"prefixItems\":[{\"type\":\"number\"},{\"type\":\"number\"}],\"items\":false,\"minItems\":2,\"maxItems\":2},{\"type\":\"null\"}]},\"lightness\":{\"type\":\"array\",\"prefixItems\":[{\"type\":\"number\"},{\"type\":\"number\"}],\"items\":false,\"minItems\":2,\"maxItems\":2}},\"required\":[\"chroma\",\"hue\",\"lightness\"],\"additionalProperties\":false}},\"required\":[\"hex\",\"op\",\"range\"],\"additionalProperties\":false},\"description\":\"The color regions that ran.\"},\"corrections\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"correction\":{\"type\":\"string\"},\"word\":{\"type\":\"string\"}},\"required\":[\"correction\",\"word\"],\"additionalProperties\":false}},\"filters\":{\"type\":\"object\",\"properties\":{\"anyField\":{\"description\":\"One of values in any of fields (term attributes).\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"fields\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"fields\",\"op\",\"values\"],\"additionalProperties\":false}},\"numbers\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"eq\",\"gt\",\"gte\",\"lt\",\"lte\"]},\"value\":{\"type\":\"number\"}},\"required\":[\"field\",\"op\",\"value\"],\"additionalProperties\":false}},\"presence\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"exists\",\"missing\"]}},\"required\":[\"field\",\"op\"],\"additionalProperties\":false}},\"terms\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"all\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"field\",\"op\",\"values\"],\"additionalProperties\":false}}},\"additionalProperties\":false,\"description\":\"The filters that ran, the scope among them.\"},\"name\":{\"type\":\"string\",\"description\":\"The paint name looked up.\"},\"oneRowPer\":{\"type\":\"string\",\"enum\":[\"product\",\"variant\",\"paint_variant_or_product\"],\"description\":\"A row per product, per variant, or per exact paint variant followed by other products.\"},\"optionalFilters\":{\"type\":\"object\",\"properties\":{\"anyField\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"fields\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"fields\",\"op\",\"values\",\"weight\"],\"additionalProperties\":false}},\"numbers\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"eq\",\"gt\",\"gte\",\"lt\",\"lte\"]},\"value\":{\"type\":\"number\"},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"field\",\"op\",\"value\",\"weight\"],\"additionalProperties\":false}},\"presence\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"exists\",\"missing\"]},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"field\",\"op\",\"weight\"],\"additionalProperties\":false}},\"terms\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"all\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"weight\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":10}},\"required\":[\"field\",\"op\",\"values\",\"weight\"],\"additionalProperties\":false",
5
+ "}}},\"additionalProperties\":false,\"description\":\"The preferences that ran.\"},\"outcome\":{\"type\":\"string\",\"enum\":[\"page\",\"partial_match\",\"no_match\",\"nothing_understood\",\"out_of_scope\",\"brand_not_in_catalog\"],\"description\":\"How the search ended.\"},\"scope\":{\"type\":\"object\",\"properties\":{\"anyField\":{\"description\":\"One of values in any of fields (term attributes).\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"fields\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"fields\",\"op\",\"values\"],\"additionalProperties\":false}},\"numbers\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"eq\",\"gt\",\"gte\",\"lt\",\"lte\"]},\"value\":{\"type\":\"number\"}},\"required\":[\"field\",\"op\",\"value\"],\"additionalProperties\":false}},\"presence\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"exists\",\"missing\"]}},\"required\":[\"field\",\"op\"],\"additionalProperties\":false}},\"terms\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"op\":{\"type\":\"string\",\"enum\":[\"in\",\"all\",\"not_in\"]},\"orText\":{\"type\":\"string\"},\"unstated\":{\"type\":\"string\",\"const\":\"pass\"},\"values\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"field\",\"op\",\"values\"],\"additionalProperties\":false}}},\"additionalProperties\":false,\"description\":\"The fixed scope, repeated in filters.\"},\"understood\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"applied\":{\"type\":\"string\",\"enum\":[\"filter\",\"preference\",\"not_applied\"],\"description\":\"filter narrows; preference only ranks; not_applied did neither.\"},\"id\":{\"type\":\"string\",\"description\":\"The parser's condition id.\"},\"kind\":{\"type\":\"string\",\"enum\":[\"category\",\"brand\",\"term\",\"number\",\"color\",\"paint\",\"name\",\"scope\"]},\"label\":{\"type\":\"string\",\"description\":\"What the words were read as.\"},\"note\":{\"type\":\"string\"},\"text\":{\"type\":\"string\",\"description\":\"The query words it came from.\"}},\"required\":[\"applied\",\"id\",\"kind\",\"label\",\"text\"],\"additionalProperties\":false}},\"unresolved\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"items\",\"pageInfo\",\"oneRowPer\",\"outcome\",\"understood\"],\"additionalProperties\":false}}},\"path\":\"/api/v1/variants/search\",\"requiredHeaders\":[],\"requiresVisibleConfirmation\":false}]",
6
6
  ].join("");
7
7
  export const WEBMCP_TOOLS = JSON.parse(json);
package/run-types.d.ts DELETED
@@ -1,161 +0,0 @@
1
- /**
2
- * Hand-mirrored wire types for the MaterialGraph workflow Run + source-material
3
- * surface. Like {@link ./types.ts}, these interfaces carry NO runtime
4
- * dependency on any `@materialgraph/*` package — they mirror the shapes in
5
- * `apps/web/public/openapi.yaml` (`create_public_run`, `get_public_run`,
6
- * `list_public_run_events`, `upload_source_material`).
7
- *
8
- * TOLERANT-PARSING CONTRACT: response enums are widened with {@link OpenEnum}
9
- * so a new server value still type-checks, and objects are read structurally —
10
- * unknown keys pass through untouched.
11
- */
12
- import type { BatchId, RunId, SourceFileId } from "./identifiers.js";
13
- import type { OpenEnum } from "./types.js";
14
- /**
15
- * A file to upload. Two forms so the SDK is ergonomic on BOTH Node route
16
- * handlers and modern runtimes: pass a platform `Blob`/`File` directly, or the
17
- * bytes plus a filename. The SDK builds the multipart body internally — callers
18
- * never touch `FormData` or wrestle a `string`-typed binary field.
19
- */
20
- export type FileInput = Blob | {
21
- /** Raw file bytes. */
22
- data: Uint8Array | ArrayBuffer;
23
- /** Filename recorded on the multipart part (drives the stored receipt filename). */
24
- filename: string;
25
- /** Optional MIME type; the server re-validates by magic bytes regardless. */
26
- contentType?: string;
27
- };
28
- /**
29
- * Input for {@link MaterialGraphClient.uploadSourceMaterial}: a heterogeneous
30
- * pile of source files (multipart field `files`, repeatable), any mix of PDF,
31
- * plain-text/markdown, and images (≥1, ≤16). The server classifies each file
32
- * and assigns its receipt {@link SourceMaterialReceiptFile.role}.
33
- */
34
- export type UploadSourceMaterialInput = {
35
- files: FileInput[];
36
- };
37
- /** One stored file in an upload receipt. */
38
- export type SourceMaterialReceiptFile = {
39
- /** The stored file id (`smf_…`). Opaque — the prefix is a reading aid, not a contract. */
40
- sourceId: SourceFileId;
41
- /**
42
- * The pipeline-assigned role. The vocabulary grows over time; {@link OpenEnum}
43
- * keeps a newer server value type-checking. `unclassified` is a legitimate
44
- * terminal value when the pipeline could not place the file.
45
- */
46
- role: OpenEnum<"brief" | "reference_image" | "document" | "document_image" | "inspiration_image" | "unclassified">;
47
- filename: string;
48
- mediaType: string;
49
- /** Lowercase hex SHA-256 of the stored bytes. */
50
- sha256: string;
51
- bytes: number;
52
- /** PDF page count; null for images. */
53
- pages: number | null;
54
- };
55
- /** The `201` receipt from `POST /api/v1/source-material`. */
56
- export type SourceMaterialBatchReceipt = {
57
- /** The stored batch id (`smb_…`). Opaque — hand it straight to a compose Run. */
58
- batchId: BatchId;
59
- sources: SourceMaterialReceiptFile[];
60
- };
61
- export type PublicRunStatus = OpenEnum<"queued" | "claimed" | "running" | "suspended" | "succeeded" | "failed" | "canceled">;
62
- export type PublicRunFailure = {
63
- code: string;
64
- message: string;
65
- retryable: boolean;
66
- detail?: Record<string, unknown>;
67
- };
68
- export type PublicRunArtifactRef = {
69
- kind: string;
70
- ref: string;
71
- };
72
- /**
73
- * The caller-owned, redacted Run ledger record. Prompts, raw model messages,
74
- * reasoning, credentials, provider payloads, and source-document contents are
75
- * never returned — inputs and outputs are the `redacted*Json` projections.
76
- */
77
- export type PublicRun = {
78
- /** Opaque — round-trip verbatim into every other Run call. */
79
- id: RunId;
80
- /** The workflow this Run belongs to, e.g. `edit-collection`: the id its path names. */
81
- workflowId: string;
82
- clientReference: string | null;
83
- /** `suspended` is a QUESTION, not a failure — see `suspensionStepId`. */
84
- status: PublicRunStatus;
85
- redactedInputJson: Record<string, unknown>;
86
- redactedOutputJson: Record<string, unknown> | null;
87
- usageJson: Record<string, unknown> | null;
88
- artifactRefs: PublicRunArtifactRef[] | null;
89
- failureJson: PublicRunFailure | null;
90
- /** The current typed question payload while this Run is suspended. */
91
- suspensionPayload: Record<string, unknown> | null;
92
- /**
93
- * The step awaiting input while `status` is `suspended`.
94
- *
95
- * Read `suspensionPayload` for the current typed question. The same payload is
96
- * also retained on the `suspended` ledger event; composition-specific events
97
- * remain available as historical progress records.
98
- */
99
- suspensionStepId: string | null;
100
- eventCursor: number;
101
- attempts: number;
102
- startedAt: string | null;
103
- cancellationRequestedAt: string | null;
104
- completedAt: string | null;
105
- createdAt: string;
106
- updatedAt: string;
107
- };
108
- /**
109
- * Body for `POST /api/v1/workflows/{workflowId}/runs`
110
- * ({@link WorkflowsClient.start}). The workflow is named by the path, never the
111
- * body.
112
- */
113
- export type CreatePublicRunRequest = {
114
- /** The workflow input, validated server-side against its live input schema. */
115
- inputJson: Record<string, unknown>;
116
- /**
117
- * Stable caller key making Run creation idempotent across retries. Supply it:
118
- * without one, a retried POST starts a SECOND Run rather than replaying the
119
- * first (`replayed` on the response tells you which happened).
120
- */
121
- idempotencyKey?: string;
122
- /** Free-form caller correlation reference, echoed back on the Run. */
123
- clientReference?: string;
124
- };
125
- /** The start response (`200` replay or `202` accepted). */
126
- export type CreatePublicRunResponse = {
127
- accepted: boolean;
128
- replayed: boolean;
129
- workflowRunId: string;
130
- run: PublicRun;
131
- };
132
- /** The `GET /api/v1/workflows/{workflowId}/runs/{runId}` response envelope. */
133
- export type PublicRunResponse = {
134
- run: PublicRun;
135
- };
136
- /**
137
- * One redacted Run event, decoded from an SSE `data:` frame. The stream yields
138
- * these in ascending {@link RunEvent.sequence} order. `payloadJson` is read
139
- * structurally; use {@link parseRunEvent} to narrow the composition family.
140
- */
141
- export type RunEvent = {
142
- sequence: number;
143
- type: string;
144
- payloadJson: unknown;
145
- };
146
- /** Run event types that close the stream — a terminal event ends a drain. */
147
- export declare const TERMINAL_RUN_EVENT_TYPES: ReadonlySet<string>;
148
- /** Options for {@link WorkflowsClient.streamRunEvents}. */
149
- export type StreamRunEventsOptions = {
150
- /** Resume the stream after this sequence (exclusive). Omitted starts at 0. */
151
- after?: number;
152
- /** Abort the stream; iteration stops cleanly. */
153
- signal?: AbortSignal;
154
- };
155
- /** Options for {@link WorkflowsClient.drainRunEvents}. */
156
- export type DrainRunEventsOptions = {
157
- /** Resume after this sequence (exclusive). */
158
- after?: number;
159
- /** Stop collecting after this many milliseconds even without a terminal event. */
160
- deadlineMs: number;
161
- };
package/run-types.js DELETED
@@ -1,6 +0,0 @@
1
- /** Run event types that close the stream — a terminal event ends a drain. */
2
- export const TERMINAL_RUN_EVENT_TYPES = new Set([
3
- "succeeded",
4
- "failed",
5
- "canceled",
6
- ]);
package/runs.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import type { HttpTransport } from "./http-transport.js";
2
- import type { CreatePublicRunRequest, CreatePublicRunResponse, DrainRunEventsOptions, PublicRunResponse, RunEvent, SourceMaterialBatchReceipt, StreamRunEventsOptions, UploadSourceMaterialInput } from "./run-types.js";
3
- /**
4
- * Upload one atomic source-material batch (`POST /api/v1/source-material`).
5
- * Each entry of `{ files }` becomes one part of the repeatable multipart
6
- * `files` field.
7
- */
8
- export declare const uploadSourceMaterial: (transport: HttpTransport, input: UploadSourceMaterialInput, signal?: AbortSignal) => Promise<SourceMaterialBatchReceipt>;
9
- /** Start an asynchronous Run of one workflow (`POST /api/v1/workflows/{workflowId}/runs`). */
10
- export declare const startWorkflowRun: (transport: HttpTransport, workflowId: string, body: CreatePublicRunRequest, signal?: AbortSignal) => Promise<CreatePublicRunResponse>;
11
- /** Get a Run's current state (`GET /api/v1/workflows/{workflowId}/runs/{runId}`). */
12
- export declare const getWorkflowRun: (transport: HttpTransport, workflowId: string, runId: string, signal?: AbortSignal) => Promise<PublicRunResponse>;
13
- /**
14
- * Stream ordered Run events as an async iterator (`GET
15
- * /api/v1/workflows/{workflowId}/runs/{runId}/events`, SSE). Iterates until the stream ends or
16
- * `signal` aborts. One connection is bounded server-side (~25s or a terminal
17
- * event); pass `after` to resume from the last observed sequence.
18
- * @yields {RunEvent} Each usable Run event from the stream.
19
- */
20
- export declare const streamRunEvents: (transport: HttpTransport, workflowId: string, runId: string, options?: StreamRunEventsOptions) => AsyncGenerator<RunEvent, void, unknown>;
21
- /**
22
- * Collect Run events until a terminal event, the deadline, or the stream ends —
23
- * the bounded events-log pattern the console uses. A single pass over
24
- * {@link streamRunEvents}; the deadline is enforced by aborting the stream.
25
- *
26
- * The deadline abort is this drain's OWN, expected termination — not a failure.
27
- * Where it lands decides how {@link streamRunEvents} surfaces it: mid-read it
28
- * ends the iterator cleanly, but while the underlying `fetch` is still pending —
29
- * the common case for a poll whose upstream has flushed no bytes yet (no new
30
- * events after the cursor, so no immediate SSE frame) — it rejects with an
31
- * `aborted` {@link MaterialGraphError}. Both mean the same thing here, so the
32
- * self-inflicted abort is swallowed and the collected events returned. Any other
33
- * failure (a real 4xx/5xx or transport error) still propagates, keeping the
34
- * fail-fast surface for genuine upstream problems.
35
- */
36
- export declare const drainRunEvents: (transport: HttpTransport, workflowId: string, runId: string, options: DrainRunEventsOptions) => Promise<RunEvent[]>;