@instruments/materialgraph 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/association-types.d.ts +38 -27
- package/associations-client.d.ts +4 -4
- package/associations-client.js +3 -10
- package/attribution-types.d.ts +4 -4
- package/brand-types.d.ts +14 -6
- package/brands-client.d.ts +7 -38
- package/brands-client.js +10 -40
- package/by-colour-types.d.ts +58 -31
- package/by-spec-types.d.ts +6 -73
- package/by-spec-types.js +7 -5
- package/catalog-discovery-types.d.ts +11 -26
- package/catalogue-client.d.ts +16 -35
- package/catalogue-client.js +32 -67
- package/catalogue-types.d.ts +44 -4
- package/categories-client.d.ts +63 -0
- package/categories-client.js +48 -0
- package/category-types.d.ts +114 -0
- package/citation-types.d.ts +4 -4
- package/client-config.d.ts +4 -6
- package/client-config.js +2 -4
- package/client-source-material-comments.d.ts +4 -4
- package/client-source-material-comments.js +4 -38
- package/client-vocabulary.d.ts +7 -9
- package/client-vocabulary.js +22 -30
- package/client.d.ts +110 -244
- package/client.js +217 -387
- package/codes-client.d.ts +2 -2
- package/codes-client.js +8 -8
- package/codes-types.d.ts +55 -34
- package/colour-aggregate-types.d.ts +24 -24
- package/colours-client.d.ts +6 -11
- package/colours-client.js +11 -19
- package/coordinate-client.d.ts +2 -2
- package/coordinate-client.js +1 -13
- package/corpus-scope-types.d.ts +3 -3
- package/corpus-scope-types.js +1 -25
- package/demand-batch-types.d.ts +18 -18
- package/demand-types.d.ts +24 -24
- package/errors.d.ts +13 -13
- package/errors.js +54 -52
- package/http-transport.d.ts +13 -21
- package/http-transport.js +31 -28
- package/identify-types.d.ts +54 -44
- package/identify-types.js +5 -3
- package/index.d.ts +11 -27
- package/index.js +4 -6
- package/list-variant-facets-types.d.ts +60 -0
- package/list-variants-types.d.ts +142 -0
- package/list-variants-types.js +12 -0
- package/match-stream-types.d.ts +45 -32
- package/match-stream-types.js +2 -0
- package/match-stream.d.ts +2 -2
- package/match-stream.js +67 -49
- package/match-types.d.ts +32 -8
- package/material-asset-types.d.ts +89 -69
- package/material-block-types.d.ts +8 -6
- package/material-composition-client.d.ts +21 -0
- package/material-composition-client.js +13 -0
- package/material-composition-types.d.ts +403 -0
- package/material-query-plan-types.d.ts +61 -145
- package/material-resources-client.d.ts +12 -10
- package/material-resources-client.js +27 -22
- package/material-types.d.ts +16 -24
- package/ndjson.js +16 -8
- package/operations.d.ts +6 -6
- package/operations.js +29 -156
- package/package.json +5 -1
- package/palette-search-types.d.ts +87 -52
- package/query-understanding-types.d.ts +65 -40
- package/resolve-client.d.ts +8 -12
- package/resolve-client.js +9 -13
- package/resolve-colour-types.d.ts +8 -8
- package/resolve-types.d.ts +10 -10
- package/response-schemas.d.ts +20 -0
- package/response-schemas.generated.d.ts +5 -0
- package/response-schemas.generated.js +160 -0
- package/response-schemas.js +113 -0
- package/run-types.d.ts +64 -145
- package/runs.d.ts +9 -58
- package/runs.js +60 -149
- package/samplize-catalogue-types.d.ts +18 -18
- package/samplize-colorvec.d.ts +20 -20
- package/samplize-colorvec.js +66 -42
- package/schema-resource-types.d.ts +52 -39
- package/schema-resource-types.js +5 -5
- package/search-card-types.d.ts +26 -4
- package/search-index-plan-types.d.ts +70 -0
- package/search-refinement-types.d.ts +10 -40
- package/search-refinement-types.js +1 -0
- package/search-request-types.d.ts +121 -204
- package/search-response-receipt-types.d.ts +13 -253
- package/search-response-types.d.ts +2 -2
- package/search-result-validation.d.ts +3 -19
- package/search-result-validation.js +42 -183
- package/source-material-validation.d.ts +3 -3
- package/source-material-validation.js +35 -39
- package/spec-facet-types.d.ts +11 -16
- package/spec-types.d.ts +23 -16
- package/spec-types.js +8 -7
- package/specifications.d.ts +14 -72
- package/specifications.js +39 -89
- package/sse.d.ts +2 -2
- package/sse.js +32 -16
- package/substitute-types.d.ts +22 -22
- package/suggest-types.d.ts +11 -17
- package/suggest-types.js +3 -3
- package/taxonomy-coverage-types.d.ts +8 -8
- package/types.d.ts +202 -405
- package/validation.d.ts +26 -26
- package/validation.js +97 -92
- package/webmcp.d.ts +3 -3
- package/webmcp.generated.js +10 -93
- package/brand-most-sampled-types.d.ts +0 -33
- package/browse-types.d.ts +0 -236
- package/client-browse.d.ts +0 -78
- package/client-browse.js +0 -72
- package/client-exploration.d.ts +0 -9
- package/client-exploration.js +0 -7
- package/compare-types.d.ts +0 -89
- package/composition-client.d.ts +0 -33
- package/composition-client.js +0 -27
- package/composition-types.d.ts +0 -455
- package/composition-types.js +0 -10
- package/correction-types.d.ts +0 -88
- package/exploration-types.d.ts +0 -118
- package/exploration-types.js +0 -1
- package/fan-deck-types.d.ts +0 -42
- package/fan-deck-types.js +0 -9
- package/match-rejection-types.d.ts +0 -43
- package/match-rejection-types.js +0 -7
- package/palette-completion-types.d.ts +0 -115
- package/palette-completion-types.js +0 -1
- package/project-types.d.ts +0 -79
- package/project-types.js +0 -9
- package/projects.d.ts +0 -13
- package/projects.js +0 -46
- package/render-assets-types.d.ts +0 -65
- package/render-assets-types.js +0 -1
- package/run-events.d.ts +0 -106
- package/run-events.js +0 -32
- package/schedule-reference-types.d.ts +0 -46
- package/schedule-reference-types.js +0 -1
- package/schedule-references-client.d.ts +0 -14
- package/schedule-references-client.js +0 -26
- package/schedule-types.d.ts +0 -261
- package/schedule-types.js +0 -1
- package/search-collapse-types.d.ts +0 -69
- package/search-collapse-types.js +0 -1
- package/search-mood-types.d.ts +0 -6
- package/search-mood-types.js +0 -1
- package/search-window-types.d.ts +0 -25
- package/search-window-types.js +0 -1
- package/slot-pool-types.d.ts +0 -372
- package/slot-pool-types.js +0 -1
- /package/{brand-most-sampled-types.js → category-types.js} +0 -0
- /package/{browse-types.js → list-variant-facets-types.js} +0 -0
- /package/{compare-types.js → material-composition-types.js} +0 -0
- /package/{correction-types.js → search-index-plan-types.js} +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime response contracts: the JSON Schema of each operation's success body.
|
|
3
|
+
*
|
|
4
|
+
* The schemas are the producer's own. They are projected from the served
|
|
5
|
+
* OpenAPI document, whose response bodies are generated from the Zod contracts
|
|
6
|
+
* the routes validate against, so a consumer never has to re-describe a large,
|
|
7
|
+
* partly open payload and watch it drift. Hand one to anything that takes a
|
|
8
|
+
* JSON Schema, such as a Mastra tool's `outputSchema`:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { responseSchema } from "@instruments/materialgraph/response-schemas";
|
|
12
|
+
*
|
|
13
|
+
* createTool({ outputSchema: responseSchema("search_materials_post"), … });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Keyed by OpenAPI `operationId`, the same id `SDK_OPERATIONS` pairs with each
|
|
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.
|
|
20
|
+
*
|
|
21
|
+
* Objects accept properties the schema does not declare, so a field the API
|
|
22
|
+
* adds later never makes a pinned consumer reject a live response; enums and
|
|
23
|
+
* constants stay closed. That is why these are more lenient than the WebMCP
|
|
24
|
+
* `outputSchema`s, which describe what the API sends rather than what a
|
|
25
|
+
* consumer should tolerate.
|
|
26
|
+
*
|
|
27
|
+
* This is its own entry point because the catalogue is large; importing the
|
|
28
|
+
* client does not load it, and it is parsed on the first `responseSchema()`
|
|
29
|
+
* call rather than on import.
|
|
30
|
+
*/
|
|
31
|
+
import { MaterialGraphError } from "./errors.js";
|
|
32
|
+
import { RESPONSE_SCHEMA_CATALOGUE_JSON } from "./response-schemas.generated.js";
|
|
33
|
+
export { RESPONSE_SCHEMA_API_VERSION, RESPONSE_SCHEMA_OPERATION_IDS, } from "./response-schemas.generated.js";
|
|
34
|
+
const JSON_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
35
|
+
const DEFINITION_PREFIX = "#/$defs/";
|
|
36
|
+
const isJsonSchemaMap = (value) => typeof value === "object" &&
|
|
37
|
+
value !== null &&
|
|
38
|
+
Object.values(value).every((schema) => typeof schema === "object" && schema !== null && !Array.isArray(schema));
|
|
39
|
+
const isCatalogue = (value) => typeof value === "object" &&
|
|
40
|
+
value !== null &&
|
|
41
|
+
"definitions" in value &&
|
|
42
|
+
isJsonSchemaMap(value.definitions) &&
|
|
43
|
+
"operations" in value &&
|
|
44
|
+
isJsonSchemaMap(value.operations);
|
|
45
|
+
let parsedCatalogue;
|
|
46
|
+
const loadCatalogue = () => {
|
|
47
|
+
if (parsedCatalogue === undefined) {
|
|
48
|
+
const parsed = JSON.parse(RESPONSE_SCHEMA_CATALOGUE_JSON);
|
|
49
|
+
if (!isCatalogue(parsed)) {
|
|
50
|
+
throw MaterialGraphError.unexpected("The response schema catalogue is malformed");
|
|
51
|
+
}
|
|
52
|
+
parsedCatalogue = parsed;
|
|
53
|
+
}
|
|
54
|
+
return parsedCatalogue;
|
|
55
|
+
};
|
|
56
|
+
/** Add every definition `value` reaches, transitively, to `into`. */
|
|
57
|
+
const collectReferences = (catalogue, value, into) => {
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
for (const item of value) {
|
|
60
|
+
collectReferences(catalogue, item, into);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (typeof value !== "object" || value === null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
for (const [key, child] of Object.entries(value)) {
|
|
68
|
+
if (key === "$ref" &&
|
|
69
|
+
typeof child === "string" &&
|
|
70
|
+
child.startsWith(DEFINITION_PREFIX)) {
|
|
71
|
+
const name = child
|
|
72
|
+
.slice(DEFINITION_PREFIX.length)
|
|
73
|
+
.replaceAll("~1", "/")
|
|
74
|
+
.replaceAll("~0", "~");
|
|
75
|
+
if (!into.has(name)) {
|
|
76
|
+
into.add(name);
|
|
77
|
+
collectReferences(catalogue, catalogue.definitions[name], into);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
collectReferences(catalogue, child, into);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The success-response schema for one operation, self-contained and carrying
|
|
87
|
+
* only the definitions it reaches. Each call returns a fresh copy, so a caller
|
|
88
|
+
* that annotates or mutates it cannot change what the next caller gets.
|
|
89
|
+
*/
|
|
90
|
+
export const responseSchema = (operationId) => {
|
|
91
|
+
const catalogue = loadCatalogue();
|
|
92
|
+
const root = Object.hasOwn(catalogue.operations, operationId)
|
|
93
|
+
? catalogue.operations[operationId]
|
|
94
|
+
: undefined;
|
|
95
|
+
if (root === undefined) {
|
|
96
|
+
throw MaterialGraphError.unexpected(`No response schema for operation: ${operationId}`);
|
|
97
|
+
}
|
|
98
|
+
const names = new Set();
|
|
99
|
+
collectReferences(catalogue, root, names);
|
|
100
|
+
const definitions = {};
|
|
101
|
+
for (const name of [...names].toSorted()) {
|
|
102
|
+
const definition = catalogue.definitions[name];
|
|
103
|
+
if (definition !== undefined) {
|
|
104
|
+
definitions[name] = definition;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const schema = {
|
|
108
|
+
$schema: JSON_SCHEMA_DIALECT,
|
|
109
|
+
...root,
|
|
110
|
+
...(names.size > 0 ? { $defs: definitions } : {}),
|
|
111
|
+
};
|
|
112
|
+
return structuredClone(schema);
|
|
113
|
+
};
|
package/run-types.d.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Hand-mirrored wire types for the MaterialGraph public Run + source-material
|
|
3
3
|
* surface (spec 0.7.0). Like {@link ./types.ts}, these interfaces carry NO
|
|
4
4
|
* runtime dependency on any `@materialgraph/*` package — they mirror the shapes
|
|
5
|
-
* in `apps/web/public/openapi.yaml` (`
|
|
6
|
-
* `
|
|
7
|
-
* `resume_public_run`, `cancel_public_run`, `upload_source_material`).
|
|
5
|
+
* in `apps/web/public/openapi.yaml` (`create_public_run`, `get_public_run`,
|
|
6
|
+
* `list_public_run_events`, `upload_source_material`).
|
|
8
7
|
*
|
|
9
8
|
* TOLERANT-PARSING CONTRACT: response enums are widened with {@link OpenEnum}
|
|
10
9
|
* so a new server value still type-checks, and objects are read structurally —
|
|
@@ -32,27 +31,27 @@ export type FileInput = Blob | {
|
|
|
32
31
|
* classifies each file and assigns its receipt {@link SourceMaterialReceiptFile.role};
|
|
33
32
|
* the caller no longer pre-sorts a brief from its references.
|
|
34
33
|
*/
|
|
35
|
-
export
|
|
34
|
+
export type UploadSourceMaterialFilesInput = {
|
|
36
35
|
files: FileInput[];
|
|
37
|
-
}
|
|
36
|
+
};
|
|
38
37
|
/**
|
|
39
38
|
* The legacy pre-classified shape — a single PDF `brief` plus optional image
|
|
40
39
|
* `references` (multipart fields `brief` + `references`). Still accepted by the
|
|
41
40
|
* server, folded into the pile. Prefer {@link UploadSourceMaterialFilesInput}.
|
|
42
41
|
*/
|
|
43
|
-
export
|
|
42
|
+
export type UploadSourceMaterialLegacyInput = {
|
|
44
43
|
/** The single PDF brief for the batch (multipart field `brief`). */
|
|
45
44
|
brief: FileInput;
|
|
46
45
|
/** Up to 12 reference images (multipart field `references`, repeatable). */
|
|
47
46
|
references?: FileInput[];
|
|
48
|
-
}
|
|
47
|
+
};
|
|
49
48
|
/**
|
|
50
49
|
* Input for {@link MaterialGraphClient.uploadSourceMaterial} — either the
|
|
51
50
|
* pile-of-files shape or the legacy brief+references shape.
|
|
52
51
|
*/
|
|
53
52
|
export type UploadSourceMaterialInput = UploadSourceMaterialFilesInput | UploadSourceMaterialLegacyInput;
|
|
54
53
|
/** One stored file in an upload receipt. */
|
|
55
|
-
export
|
|
54
|
+
export type SourceMaterialReceiptFile = {
|
|
56
55
|
/** The stored file id (`smf_…`). Opaque — the prefix is a reading aid, not a contract. */
|
|
57
56
|
sourceId: SourceFileId;
|
|
58
57
|
/**
|
|
@@ -68,13 +67,13 @@ export interface SourceMaterialReceiptFile {
|
|
|
68
67
|
bytes: number;
|
|
69
68
|
/** PDF page count; null for images. */
|
|
70
69
|
pages: number | null;
|
|
71
|
-
}
|
|
70
|
+
};
|
|
72
71
|
/** The `201` receipt from `POST /api/v1/source-material`. */
|
|
73
|
-
export
|
|
72
|
+
export type SourceMaterialBatchReceipt = {
|
|
74
73
|
/** The stored batch id (`smb_…`). Opaque — hand it straight to a compose Run. */
|
|
75
74
|
batchId: BatchId;
|
|
76
75
|
sources: SourceMaterialReceiptFile[];
|
|
77
|
-
}
|
|
76
|
+
};
|
|
78
77
|
/**
|
|
79
78
|
* One analysis computed over an uploaded image's bytes.
|
|
80
79
|
*
|
|
@@ -84,7 +83,7 @@ export interface SourceMaterialBatchReceipt {
|
|
|
84
83
|
* sharing is by design and discloses nothing — you only ever see analyses of
|
|
85
84
|
* images you hold yourself.
|
|
86
85
|
*/
|
|
87
|
-
export
|
|
86
|
+
export type SourceImageAnalysis = {
|
|
88
87
|
/** The kind of read. {@link OpenEnum} keeps a newer server value type-checking. */
|
|
89
88
|
kind: OpenEnum<"scene_match">;
|
|
90
89
|
/** The model version that produced {@link SourceImageAnalysis.result}. */
|
|
@@ -104,9 +103,9 @@ export interface SourceImageAnalysis {
|
|
|
104
103
|
result: Record<string, JsonValue>;
|
|
105
104
|
/** ISO-8601 timestamp of the most recent analysis. */
|
|
106
105
|
analysedAt: string;
|
|
107
|
-
}
|
|
106
|
+
};
|
|
108
107
|
/** Who a comment is from, as you SUBMIT it. Not the API principal posting it. */
|
|
109
|
-
export
|
|
108
|
+
export type SourceMaterialCommentAuthorInput = {
|
|
110
109
|
/** Trimmed, 1–160 characters. Longer or blank is refused by the server. */
|
|
111
110
|
name: string;
|
|
112
111
|
/**
|
|
@@ -114,7 +113,7 @@ export interface SourceMaterialCommentAuthorInput {
|
|
|
114
113
|
* Trimmed, 1–160 characters when present. Nullable, not optional.
|
|
115
114
|
*/
|
|
116
115
|
organisation: string | null;
|
|
117
|
-
}
|
|
116
|
+
};
|
|
118
117
|
/**
|
|
119
118
|
* Who a comment is from, as you READ IT BACK.
|
|
120
119
|
*
|
|
@@ -122,28 +121,28 @@ export interface SourceMaterialCommentAuthorInput {
|
|
|
122
121
|
* "recorded as from X", never as a statement X signed — the identity that IS
|
|
123
122
|
* verified is {@link SourceMaterialCommentReply.recordedBy}.
|
|
124
123
|
*/
|
|
125
|
-
export
|
|
124
|
+
export type SourceMaterialCommentAuthor = {
|
|
126
125
|
/**
|
|
127
126
|
* How the name got here. `reported` means a caller typed it. {@link OpenEnum}
|
|
128
127
|
* keeps a newer server value type-checking; treat anything unfamiliar as
|
|
129
128
|
* unverified.
|
|
130
129
|
*/
|
|
131
130
|
attribution: OpenEnum<"reported">;
|
|
132
|
-
}
|
|
131
|
+
} & SourceMaterialCommentAuthorInput;
|
|
133
132
|
/** The authenticated principal that recorded a comment. */
|
|
134
|
-
export
|
|
133
|
+
export type SourceMaterialCommentRecorder = {
|
|
135
134
|
/**
|
|
136
135
|
* The principal that wrote the row. Comments can only be posted against a
|
|
137
136
|
* batch the poster owns, so on every comment you can read this is your own.
|
|
138
137
|
*/
|
|
139
138
|
principalId: string;
|
|
140
|
-
}
|
|
139
|
+
};
|
|
141
140
|
/**
|
|
142
141
|
* One reply on a source-material file. A reply carries no replies of its own:
|
|
143
142
|
* threads are one level deep because the database makes a reply-to-reply
|
|
144
143
|
* unstorable, and this type says so rather than implying a tree.
|
|
145
144
|
*/
|
|
146
|
-
export
|
|
145
|
+
export type SourceMaterialCommentReply = {
|
|
147
146
|
/** The stored comment id (`smc_…`). Opaque. */
|
|
148
147
|
commentId: string;
|
|
149
148
|
author: SourceMaterialCommentAuthor;
|
|
@@ -152,14 +151,14 @@ export interface SourceMaterialCommentReply {
|
|
|
152
151
|
body: string;
|
|
153
152
|
/** ISO-8601 timestamp of the posting. */
|
|
154
153
|
createdAt: string;
|
|
155
|
-
}
|
|
154
|
+
};
|
|
156
155
|
/** One root remark with the replies that answer it. */
|
|
157
|
-
export
|
|
156
|
+
export type SourceMaterialComment = {
|
|
158
157
|
/** ALWAYS an array. `[]` means nobody answered — never a missing field. */
|
|
159
158
|
replies: SourceMaterialCommentReply[];
|
|
160
|
-
}
|
|
159
|
+
} & SourceMaterialCommentReply;
|
|
161
160
|
/** The `200` body of `GET …/sources/{sourceId}/comments`. */
|
|
162
|
-
export
|
|
161
|
+
export type SourceMaterialCommentThread = {
|
|
163
162
|
/** The file the thread hangs off (`smf_…`). Opaque. */
|
|
164
163
|
sourceId: string;
|
|
165
164
|
/**
|
|
@@ -172,9 +171,9 @@ export interface SourceMaterialCommentThread {
|
|
|
172
171
|
* so `comments` is the oldest of them rather than all of them.
|
|
173
172
|
*/
|
|
174
173
|
truncated: boolean;
|
|
175
|
-
}
|
|
174
|
+
};
|
|
176
175
|
/** The body of `POST …/sources/{sourceId}/comments`. */
|
|
177
|
-
export
|
|
176
|
+
export type PostSourceMaterialCommentInput = {
|
|
178
177
|
author: SourceMaterialCommentAuthorInput;
|
|
179
178
|
/** Trimmed, 1–4000 characters. */
|
|
180
179
|
body: string;
|
|
@@ -189,17 +188,17 @@ export interface PostSourceMaterialCommentInput {
|
|
|
189
188
|
* rather than a permanent duplicate. Scoped to the file.
|
|
190
189
|
*/
|
|
191
190
|
idempotencyKey?: string | null;
|
|
192
|
-
}
|
|
191
|
+
};
|
|
193
192
|
/** A comment the server just stored, as a root. */
|
|
194
|
-
export
|
|
193
|
+
export type StoredSourceMaterialRootComment = {
|
|
195
194
|
kind: "root";
|
|
196
|
-
}
|
|
195
|
+
} & SourceMaterialComment;
|
|
197
196
|
/** A comment the server just stored, as a reply to a root. */
|
|
198
|
-
export
|
|
197
|
+
export type StoredSourceMaterialReplyComment = {
|
|
199
198
|
kind: "reply";
|
|
200
199
|
/** The root this answers. Present because a reply always has one. */
|
|
201
200
|
parentCommentId: string;
|
|
202
|
-
}
|
|
201
|
+
} & SourceMaterialCommentReply;
|
|
203
202
|
/**
|
|
204
203
|
* What a POST returns, discriminated on `kind`. Switch on it: a `root` carries
|
|
205
204
|
* an empty `replies`, a `reply` carries `parentCommentId` and no `replies` at
|
|
@@ -207,13 +206,13 @@ export interface StoredSourceMaterialReplyComment extends SourceMaterialCommentR
|
|
|
207
206
|
*/
|
|
208
207
|
export type StoredSourceMaterialComment = StoredSourceMaterialRootComment | StoredSourceMaterialReplyComment;
|
|
209
208
|
/** The `201` body of `POST …/sources/{sourceId}/comments`. */
|
|
210
|
-
export
|
|
209
|
+
export type PostSourceMaterialCommentResult = {
|
|
211
210
|
/** The file the comment hangs off (`smf_…`). Opaque. */
|
|
212
211
|
sourceId: string;
|
|
213
212
|
comment: StoredSourceMaterialComment;
|
|
214
|
-
}
|
|
213
|
+
};
|
|
215
214
|
/** One file as `GET /api/v1/source-material/{batchId}` returns it. */
|
|
216
|
-
export
|
|
215
|
+
export type SourceMaterialBatchFile = {
|
|
217
216
|
/** Fetchable URL for the stored bytes. */
|
|
218
217
|
url: string;
|
|
219
218
|
/**
|
|
@@ -234,79 +233,43 @@ export interface SourceMaterialBatchFile extends SourceMaterialReceiptFile {
|
|
|
234
233
|
* you have, including one nobody has commented on.
|
|
235
234
|
*/
|
|
236
235
|
commentsTruncated: boolean;
|
|
237
|
-
}
|
|
236
|
+
} & SourceMaterialReceiptFile;
|
|
238
237
|
/**
|
|
239
238
|
* The `200` body of `GET /api/v1/source-material/{batchId}` — the batch, every
|
|
240
239
|
* file it holds, and the analyses computed over each file's bytes.
|
|
241
240
|
*/
|
|
242
|
-
export
|
|
241
|
+
export type SourceMaterialBatchDetail = {
|
|
243
242
|
/** The stored batch id (`smb_…`). Opaque. */
|
|
244
243
|
batchId: BatchId;
|
|
245
244
|
/** ISO-8601 timestamp of the upload. */
|
|
246
245
|
createdAt: string;
|
|
247
246
|
sources: SourceMaterialBatchFile[];
|
|
248
|
-
}
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Still carried on {@link PublicRun.capabilityKind}, so a Run created before
|
|
250
|
+
* MG-2252 reads back as `"agent"`. The rest of the public capability manifest
|
|
251
|
+
* shape retired with `GET /api/v1/capabilities`.
|
|
252
|
+
*/
|
|
249
253
|
export type CapabilityKind = OpenEnum<"agent" | "tool" | "workflow">;
|
|
250
|
-
|
|
251
|
-
export type
|
|
252
|
-
export type CapabilitySideEffectClass = OpenEnum<"read_only" | "browser_local" | "external_read" | "writes_proposed" | "writes_persisted" | "planned_only">;
|
|
253
|
-
export interface CapabilityRetryPolicy {
|
|
254
|
-
maxAttempts: number;
|
|
255
|
-
backoff: OpenEnum<"none" | "fixed" | "exponential">;
|
|
256
|
-
}
|
|
257
|
-
export interface CapabilityInvokeLink {
|
|
258
|
-
href: string;
|
|
259
|
-
method: OpenEnum<"GET" | "POST">;
|
|
260
|
-
}
|
|
261
|
-
/** One human-input checkpoint exposed by a workflow capability. */
|
|
262
|
-
export interface PublicCapabilitySuspension {
|
|
263
|
-
stepId: string;
|
|
264
|
-
suspend: Record<string, unknown>;
|
|
265
|
-
resume: Record<string, unknown>;
|
|
266
|
-
}
|
|
267
|
-
/** One invocable capability from the governed public manifest. */
|
|
268
|
-
export interface PublicCapabilityMetadata {
|
|
269
|
-
publicId: string;
|
|
270
|
-
runtimeId: string;
|
|
271
|
-
kind: CapabilityKind;
|
|
272
|
-
exposure: CapabilityExposure;
|
|
273
|
-
name: string;
|
|
274
|
-
description: string;
|
|
275
|
-
schemas: {
|
|
276
|
-
input: Record<string, unknown>;
|
|
277
|
-
output: Record<string, unknown>;
|
|
278
|
-
suspensions?: PublicCapabilitySuspension[];
|
|
279
|
-
};
|
|
280
|
-
sideEffectClass: CapabilitySideEffectClass;
|
|
281
|
-
scopes: CapabilityScope[];
|
|
282
|
-
timeoutMs: number;
|
|
283
|
-
retryPolicy: CapabilityRetryPolicy;
|
|
284
|
-
tags: string[];
|
|
285
|
-
links: {
|
|
286
|
-
invoke: CapabilityInvokeLink;
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
/** The `GET /api/v1/capabilities` response envelope. */
|
|
290
|
-
export interface CapabilityManifestResponse {
|
|
291
|
-
capabilities: PublicCapabilityMetadata[];
|
|
292
|
-
}
|
|
254
|
+
/** What `POST /api/v1/runs` admits: never an agent since MG-2252. */
|
|
255
|
+
export type CreatableCapabilityKind = "tool" | "workflow";
|
|
293
256
|
export type PublicRunStatus = OpenEnum<"queued" | "claimed" | "running" | "suspended" | "succeeded" | "failed" | "canceled">;
|
|
294
|
-
export
|
|
257
|
+
export type PublicRunFailure = {
|
|
295
258
|
code: string;
|
|
296
259
|
message: string;
|
|
297
260
|
retryable: boolean;
|
|
298
261
|
detail?: Record<string, unknown>;
|
|
299
|
-
}
|
|
300
|
-
export
|
|
262
|
+
};
|
|
263
|
+
export type PublicRunArtifactRef = {
|
|
301
264
|
kind: string;
|
|
302
265
|
ref: string;
|
|
303
|
-
}
|
|
266
|
+
};
|
|
304
267
|
/**
|
|
305
268
|
* The caller-owned, redacted Run ledger record. Prompts, raw model messages,
|
|
306
269
|
* reasoning, credentials, provider payloads, and source-document contents are
|
|
307
270
|
* never returned — inputs and outputs are the `redacted*Json` projections.
|
|
308
271
|
*/
|
|
309
|
-
export
|
|
272
|
+
export type PublicRun = {
|
|
310
273
|
/** Opaque — round-trip verbatim into every other Run call. */
|
|
311
274
|
id: RunId;
|
|
312
275
|
capabilityKind: CapabilityKind;
|
|
@@ -322,9 +285,7 @@ export interface PublicRun {
|
|
|
322
285
|
/** The current typed question payload while this Run is suspended. */
|
|
323
286
|
suspensionPayload: Record<string, unknown> | null;
|
|
324
287
|
/**
|
|
325
|
-
* The step awaiting input while `status` is `suspended`.
|
|
326
|
-
* {@link ResumeRunOptions.stepId} so a stale client cannot resume a step the
|
|
327
|
-
* Run has already moved past.
|
|
288
|
+
* The step awaiting input while `status` is `suspended`.
|
|
328
289
|
*
|
|
329
290
|
* Read `suspensionPayload` for the current typed question. The same payload is
|
|
330
291
|
* also retained on the `suspended` ledger event; composition-specific events
|
|
@@ -338,10 +299,10 @@ export interface PublicRun {
|
|
|
338
299
|
completedAt: string | null;
|
|
339
300
|
createdAt: string;
|
|
340
301
|
updatedAt: string;
|
|
341
|
-
}
|
|
302
|
+
};
|
|
342
303
|
/** Body for `POST /api/v1/runs` ({@link MaterialGraphClient.createRun}). */
|
|
343
|
-
export
|
|
344
|
-
capabilityKind:
|
|
304
|
+
export type CreatePublicRunRequest = {
|
|
305
|
+
capabilityKind: CreatableCapabilityKind;
|
|
345
306
|
capabilityId: string;
|
|
346
307
|
/** The capability input, validated server-side against its live input schema. */
|
|
347
308
|
inputJson: unknown;
|
|
@@ -353,83 +314,41 @@ export interface CreatePublicRunRequest {
|
|
|
353
314
|
idempotencyKey?: string;
|
|
354
315
|
/** Free-form caller correlation reference, echoed back on the Run. */
|
|
355
316
|
clientReference?: string;
|
|
356
|
-
}
|
|
317
|
+
};
|
|
357
318
|
/** The `POST /api/v1/runs` response (`200` replay or `202` accepted). */
|
|
358
|
-
export
|
|
319
|
+
export type CreatePublicRunResponse = {
|
|
359
320
|
accepted: boolean;
|
|
360
321
|
replayed: boolean;
|
|
361
322
|
workflowRunId: string;
|
|
362
323
|
run: PublicRun;
|
|
363
|
-
}
|
|
364
|
-
/** The `GET /api/v1/runs/{runId}`
|
|
365
|
-
export
|
|
324
|
+
};
|
|
325
|
+
/** The `GET /api/v1/runs/{runId}` response envelope. */
|
|
326
|
+
export type PublicRunResponse = {
|
|
366
327
|
run: PublicRun;
|
|
367
|
-
}
|
|
368
|
-
/** Query for `GET /api/v1/runs` ({@link MaterialGraphClient.listRuns}). */
|
|
369
|
-
export interface ListRunsOptions {
|
|
370
|
-
/**
|
|
371
|
-
* Return only Runs in this status. `"suspended"` is the recovery question:
|
|
372
|
-
* which of my Runs is still waiting on an answer?
|
|
373
|
-
*/
|
|
374
|
-
status?: PublicRunStatus;
|
|
375
|
-
/** Page size, 1–100. Defaults to 20 server-side. */
|
|
376
|
-
limit?: number;
|
|
377
|
-
/**
|
|
378
|
-
* The previous page's {@link PublicRunListResponse.nextCursor}, round-tripped
|
|
379
|
-
* VERBATIM. It is opaque — never parse or construct one.
|
|
380
|
-
*/
|
|
381
|
-
cursor?: string;
|
|
382
|
-
signal?: AbortSignal;
|
|
383
|
-
}
|
|
384
|
-
/** The `GET /api/v1/runs` response envelope — one page, newest first. */
|
|
385
|
-
export interface PublicRunListResponse {
|
|
386
|
-
runs: PublicRun[];
|
|
387
|
-
/**
|
|
388
|
-
* Pass as {@link ListRunsOptions.cursor} for the next page. ABSENT — not
|
|
389
|
-
* empty-string, not null — once the last page has been served.
|
|
390
|
-
*/
|
|
391
|
-
nextCursor?: string;
|
|
392
|
-
}
|
|
393
|
-
/** Body for `POST /api/v1/runs/{runId}/resume`. */
|
|
394
|
-
export interface ResumePublicRunRequest {
|
|
395
|
-
/** The resume payload, validated against the suspended step's resume schema. */
|
|
396
|
-
resumeData: unknown;
|
|
397
|
-
}
|
|
328
|
+
};
|
|
398
329
|
/**
|
|
399
330
|
* One redacted Run event, decoded from an SSE `data:` frame. The stream yields
|
|
400
331
|
* these in ascending {@link RunEvent.sequence} order. `payloadJson` is read
|
|
401
332
|
* structurally; use {@link parseRunEvent} to narrow the composition family.
|
|
402
333
|
*/
|
|
403
|
-
export
|
|
334
|
+
export type RunEvent = {
|
|
404
335
|
sequence: number;
|
|
405
336
|
type: string;
|
|
406
337
|
payloadJson: unknown;
|
|
407
|
-
}
|
|
338
|
+
};
|
|
408
339
|
/** Run event types that close the stream — a terminal event ends a drain. */
|
|
409
340
|
export declare const TERMINAL_RUN_EVENT_TYPES: ReadonlySet<string>;
|
|
410
341
|
/** Options for {@link MaterialGraphClient.streamRunEvents}. */
|
|
411
|
-
export
|
|
342
|
+
export type StreamRunEventsOptions = {
|
|
412
343
|
/** Resume the stream after this sequence (exclusive). Omitted starts at 0. */
|
|
413
344
|
after?: number;
|
|
414
345
|
/** Abort the stream; iteration stops cleanly. */
|
|
415
346
|
signal?: AbortSignal;
|
|
416
|
-
}
|
|
347
|
+
};
|
|
417
348
|
/** Options for {@link MaterialGraphClient.drainRunEvents}. */
|
|
418
|
-
export
|
|
349
|
+
export type DrainRunEventsOptions = {
|
|
419
350
|
/** Resume after this sequence (exclusive). */
|
|
420
351
|
after?: number;
|
|
421
352
|
/** Stop collecting after this many milliseconds even without a terminal event. */
|
|
422
353
|
deadlineMs: number;
|
|
423
|
-
}
|
|
424
|
-
/** Options for {@link MaterialGraphClient.resumeRun}. */
|
|
425
|
-
export interface ResumeRunOptions {
|
|
426
|
-
/**
|
|
427
|
-
* The step the caller believes is suspended. When it mismatches the run
|
|
428
|
-
* doc's live `suspensionStepId` the API answers RFC-7807 409 (MG-608) —
|
|
429
|
-
* which is what stops a stale client resuming a step the run has already
|
|
430
|
-
* moved past. Omitted, the resume is unguarded, exactly as before.
|
|
431
|
-
*/
|
|
432
|
-
stepId?: string;
|
|
433
|
-
/** Abort the request. */
|
|
434
|
-
signal?: AbortSignal;
|
|
435
|
-
}
|
|
354
|
+
};
|
package/runs.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { HttpTransport } from "./http-transport.js";
|
|
2
|
-
import
|
|
3
|
-
import type { FinishScheduleResponse, GetRunScheduleOptions } from "./schedule-types.js";
|
|
1
|
+
import type { HttpTransport } from "./http-transport.js";
|
|
2
|
+
import type { CreatePublicRunRequest, CreatePublicRunResponse, DrainRunEventsOptions, PostSourceMaterialCommentInput, PostSourceMaterialCommentResult, PublicRunResponse, RunEvent, SourceMaterialBatchDetail, SourceMaterialBatchReceipt, SourceMaterialCommentThread, StreamRunEventsOptions, UploadSourceMaterialInput } from "./run-types.js";
|
|
4
3
|
/**
|
|
5
4
|
* Upload one atomic source-material batch (`POST /api/v1/source-material`).
|
|
6
5
|
* Accepts the pile-of-files shape (`{ files }` → repeatable `files` field) or
|
|
7
6
|
* the legacy `{ brief, references }` shape (→ `brief` + repeatable `references`
|
|
8
7
|
* fields). Both wire to multipart the server accepts.
|
|
9
8
|
*/
|
|
10
|
-
export declare
|
|
9
|
+
export declare const uploadSourceMaterial: (transport: HttpTransport, input: UploadSourceMaterialInput, signal?: AbortSignal) => Promise<SourceMaterialBatchReceipt>;
|
|
11
10
|
/**
|
|
12
11
|
* Read back one uploaded batch (`GET /api/v1/source-material/{batchId}`): every
|
|
13
12
|
* file with a fetchable `url`, and every analysis computed over its bytes
|
|
@@ -20,7 +19,7 @@ export declare function uploadSourceMaterial(transport: HttpTransport, input: Up
|
|
|
20
19
|
* the server's Zod contract so a malformed response fails here with a path into
|
|
21
20
|
* the payload rather than as an undefined three frames away in caller code.
|
|
22
21
|
*/
|
|
23
|
-
export declare
|
|
22
|
+
export declare const getSourceMaterialBatch: (transport: HttpTransport, batchId: string, signal?: AbortSignal) => Promise<SourceMaterialBatchDetail>;
|
|
24
23
|
/**
|
|
25
24
|
* Read one file's comment thread
|
|
26
25
|
* (`GET /api/v1/source-material/{batchId}/sources/{sourceId}/comments`).
|
|
@@ -38,7 +37,7 @@ export declare function getSourceMaterialBatch(transport: HttpTransport, batchId
|
|
|
38
37
|
* A file that is not in that batch, or a batch you do not own, raises the same
|
|
39
38
|
* 404 as a file that never existed.
|
|
40
39
|
*/
|
|
41
|
-
export declare
|
|
40
|
+
export declare const listSourceMaterialComments: (transport: HttpTransport, batchId: string, sourceId: string, signal?: AbortSignal) => Promise<SourceMaterialCommentThread>;
|
|
42
41
|
/**
|
|
43
42
|
* Add one remark to a file's thread
|
|
44
43
|
* (`POST /api/v1/source-material/{batchId}/sources/{sourceId}/comments`).
|
|
@@ -54,59 +53,11 @@ export declare function listSourceMaterialComments(transport: HttpTransport, bat
|
|
|
54
53
|
* The result is discriminated on `kind`: switch on it rather than reaching for
|
|
55
54
|
* `replies`, which a `reply` does not have.
|
|
56
55
|
*/
|
|
57
|
-
export declare
|
|
58
|
-
/** List invocable agents, workflows, and tools (`GET /api/v1/capabilities`). */
|
|
59
|
-
export declare function capabilities(transport: HttpTransport, signal?: AbortSignal): Promise<CapabilityManifestResponse>;
|
|
56
|
+
export declare const postSourceMaterialComment: (transport: HttpTransport, batchId: string, sourceId: string, input: PostSourceMaterialCommentInput, signal?: AbortSignal) => Promise<PostSourceMaterialCommentResult>;
|
|
60
57
|
/** Start an asynchronous capability Run (`POST /api/v1/runs`). */
|
|
61
|
-
export declare
|
|
62
|
-
/**
|
|
63
|
-
* List your own Runs, newest first (`GET /api/v1/runs`).
|
|
64
|
-
*
|
|
65
|
-
* The recovery path for a client that still holds its API key but has lost a Run
|
|
66
|
-
* id — a reinstalled app, or a crash before the id from {@link createRun} was
|
|
67
|
-
* persisted. `{ status: "suspended" }` finds the Run still waiting on an answer.
|
|
68
|
-
*
|
|
69
|
-
* Only the calling principal's own Runs are ever returned; there is no
|
|
70
|
-
* cross-principal listing.
|
|
71
|
-
*
|
|
72
|
-
* Page by following `nextCursor` until it is ABSENT — a full page is not the
|
|
73
|
-
* signal to stop, and an absent cursor is the only one.
|
|
74
|
-
*/
|
|
75
|
-
export declare function listRuns(transport: HttpTransport, options?: ListRunsOptions): Promise<PublicRunListResponse>;
|
|
58
|
+
export declare const createRun: (transport: HttpTransport, body: CreatePublicRunRequest, signal?: AbortSignal) => Promise<CreatePublicRunResponse>;
|
|
76
59
|
/** Get a Run's current state (`GET /api/v1/runs/{runId}`). */
|
|
77
|
-
export declare
|
|
78
|
-
/**
|
|
79
|
-
* Export a completed compose Run's scheme as a finish schedule — one row per
|
|
80
|
-
* slot, every attribute value carrying its source and verification state
|
|
81
|
-
* (`GET /api/v1/runs/{runId}/schedule`).
|
|
82
|
-
*
|
|
83
|
-
* The `.xlsx` form of the same export is deliberately NOT an SDK method: this
|
|
84
|
-
* transport parses every response as text/JSON and has no binary read path, so
|
|
85
|
-
* a bytes-returning method would mean a second transport surface for one file.
|
|
86
|
-
* Fetch `GET /api/v1/runs/{runId}/schedule.xlsx` directly with the same bearer
|
|
87
|
-
* key when you want the workbook.
|
|
88
|
-
*/
|
|
89
|
-
export declare function getRunSchedule(transport: HttpTransport, runId: string, options?: GetRunScheduleOptions): Promise<FinishScheduleResponse>;
|
|
90
|
-
/**
|
|
91
|
-
* Resume a suspended Run (`POST /api/v1/runs/{runId}/resume`).
|
|
92
|
-
*
|
|
93
|
-
* The third argument takes either an `AbortSignal` (legacy) or
|
|
94
|
-
* {@link ResumeRunOptions}.
|
|
95
|
-
*
|
|
96
|
-
* `stepId` is forwarded whenever it is PRESENT — `!== undefined`, not truthy.
|
|
97
|
-
* An empty string is a present-but-malformed value and must reach the server
|
|
98
|
-
* so its schema rejects it; treating it as absent would silently downgrade a
|
|
99
|
-
* guarded resume into an unguarded one, which is the exact failure this guard
|
|
100
|
-
* exists to prevent.
|
|
101
|
-
*
|
|
102
|
-
* Omitting it sends a body byte-identical to what this sent before. Note the
|
|
103
|
-
* wire cannot distinguish `{ stepId: undefined }` from no key at all —
|
|
104
|
-
* `JSON.stringify` drops both — so the distinction here is construction
|
|
105
|
-
* intent, kept so the serialised body is provably unchanged for old callers.
|
|
106
|
-
*/
|
|
107
|
-
export declare function resumeRun(transport: HttpTransport, runId: string, resumeData: unknown, signalOrOptions?: AbortSignal | ResumeRunOptions): Promise<PublicRunResponse>;
|
|
108
|
-
/** Request durable Run cancellation (`POST /api/v1/runs/{runId}/cancel`). */
|
|
109
|
-
export declare function cancelRun(transport: HttpTransport, runId: string, signal?: AbortSignal): Promise<PublicRunResponse>;
|
|
60
|
+
export declare const getRun: (transport: HttpTransport, runId: string, signal?: AbortSignal) => Promise<PublicRunResponse>;
|
|
110
61
|
/**
|
|
111
62
|
* Stream ordered Run events as an async iterator (`GET
|
|
112
63
|
* /api/v1/runs/{runId}/events`, SSE). Iterates until the stream ends or
|
|
@@ -129,4 +80,4 @@ export declare function streamRunEvents(transport: HttpTransport, runId: string,
|
|
|
129
80
|
* failure (a real 4xx/5xx or transport error) still propagates, keeping the
|
|
130
81
|
* fail-fast surface for genuine upstream problems.
|
|
131
82
|
*/
|
|
132
|
-
export declare
|
|
83
|
+
export declare const drainRunEvents: (transport: HttpTransport, runId: string, options: DrainRunEventsOptions) => Promise<RunEvent[]>;
|