@huaqiu/hardware-artifacts 0.7.17 → 0.7.19
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/lib/index.d.mts +61 -8
- package/lib/index.mjs +2610 -6
- package/lib/routes-D78ML_ef.d.mts +438 -0
- package/lib/routes.d.mts +2 -18
- package/lib/routes.mjs +156 -41
- package/lib/{service-CtVn7z8b.d.mts → service-BGecln85.d.mts} +119 -28
- package/lib/{service-Yrc2C_eo.mjs → service-Bo58tzXv.mjs} +570 -167
- package/lib/service.d.mts +1 -1
- package/lib/service.mjs +1 -1
- package/package.json +2 -1
- package/src/index.ts +124 -5
- package/src/order.ts +22 -0
- package/src/package.ts +282 -0
- package/src/routes.ts +127 -48
- package/src/service.ts +1635 -1651
- package/src/toolchain/dialog.ts +240 -0
- package/src/toolchain/discovery.ts +266 -0
- package/src/toolchain/index.ts +36 -0
- package/src/toolchain/install.ts +430 -0
- package/src/toolchain/lzma.ts +384 -0
- package/src/toolchain/manager.ts +594 -0
- package/src/toolchain/manifest.ts +234 -0
- package/src/toolchain/resolve.ts +325 -0
- package/src/toolchain/zip.ts +495 -0
- package/src/tools.ts +470 -0
package/lib/routes.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
//#region src/routes.ts
|
|
3
3
|
const HARDWARE_ROUTE_PREFIX = "/api/v1/hardware";
|
|
4
|
+
/** Prefix owned by the toolchain capability, beside the artifact routes. */
|
|
5
|
+
const TOOLCHAIN_ROUTE_PREFIX = `${HARDWARE_ROUTE_PREFIX}/toolchain`;
|
|
4
6
|
function sendJson(res, status, body) {
|
|
5
7
|
const text = JSON.stringify(body);
|
|
6
8
|
res.writeHead(status, {
|
|
@@ -42,40 +44,157 @@ function failure(error) {
|
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
/** Roots a request may read: the caller's workspace, then the host's own. */
|
|
46
|
-
function rootsOf(body) {
|
|
47
|
-
if (body === null || typeof body !== "object") return [];
|
|
48
|
-
return [asString(body.cwd), asString(body.workspace)].filter((value) => value !== void 0);
|
|
49
|
-
}
|
|
50
47
|
/** The DSH session a request belongs to: a query field for reads, a body field for writes. */
|
|
51
48
|
function sessionOf(url, body) {
|
|
52
49
|
return (body === null || typeof body !== "object" ? void 0 : asString(body.session)) ?? asString(url.searchParams.get("session") ?? void 0);
|
|
53
50
|
}
|
|
51
|
+
/** Narrow one request field to a toolchain id. */
|
|
52
|
+
function toolOf(value) {
|
|
53
|
+
return value === "kicad" || value === "solidcraft" ? value : void 0;
|
|
54
|
+
}
|
|
55
|
+
/** The source vocabulary the save route accepts (`detected` is written by discovery). */
|
|
56
|
+
function sourceOf(value) {
|
|
57
|
+
return value === "manual" || value === "browse" || value === "download" || value === "detected" ? value : void 0;
|
|
58
|
+
}
|
|
54
59
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
60
|
+
* The toolchain surface: status, validate, save, browse, install, cancel,
|
|
61
|
+
* discover, capabilities.
|
|
57
62
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
63
|
+
* Every handler answers a JSON envelope the client can render without guessing,
|
|
64
|
+
* and every failure keeps a stable `code` so the UI can localise it (the same
|
|
65
|
+
* vocabulary the installer uses, §7.2/§17). Nothing here starts work the caller
|
|
66
|
+
* did not ask for: discovery and install are explicit POSTs.
|
|
67
|
+
* @returns true when the request was answered.
|
|
62
68
|
*/
|
|
63
|
-
async function
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
roots,
|
|
77
|
-
sessionId
|
|
69
|
+
async function handleToolchain(req, res, url, manager) {
|
|
70
|
+
const path = url.pathname;
|
|
71
|
+
if (!path.startsWith(TOOLCHAIN_ROUTE_PREFIX)) return false;
|
|
72
|
+
const route = path.slice(TOOLCHAIN_ROUTE_PREFIX.length);
|
|
73
|
+
const badRequest = (message) => {
|
|
74
|
+
sendJson(res, 400, {
|
|
75
|
+
ok: false,
|
|
76
|
+
error: {
|
|
77
|
+
code: "invalid-request",
|
|
78
|
+
message
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return true;
|
|
78
82
|
};
|
|
83
|
+
if (req.method === "GET" && route === "/status") {
|
|
84
|
+
const jobIds = (url.searchParams.get("job") ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
85
|
+
sendJson(res, 200, {
|
|
86
|
+
ok: true,
|
|
87
|
+
...await manager.status(jobIds.length === 0 ? void 0 : jobIds)
|
|
88
|
+
});
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
if (req.method === "GET" && route === "/capabilities") {
|
|
92
|
+
sendJson(res, 200, {
|
|
93
|
+
ok: true,
|
|
94
|
+
...await manager.capabilities()
|
|
95
|
+
});
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if (req.method === "GET" && route === "/job") {
|
|
99
|
+
const id = asString(url.searchParams.get("id") ?? void 0);
|
|
100
|
+
const job = id === void 0 ? void 0 : manager.job(id);
|
|
101
|
+
if (job === void 0) {
|
|
102
|
+
sendJson(res, 404, {
|
|
103
|
+
ok: false,
|
|
104
|
+
error: {
|
|
105
|
+
code: "unknown-job",
|
|
106
|
+
message: "no such installation job"
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
sendJson(res, 200, {
|
|
112
|
+
ok: true,
|
|
113
|
+
job
|
|
114
|
+
});
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (req.method !== "POST") {
|
|
118
|
+
sendJson(res, 405, {
|
|
119
|
+
ok: false,
|
|
120
|
+
error: {
|
|
121
|
+
code: "method-not-allowed",
|
|
122
|
+
message: "method not allowed"
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
const body = await readJson(req);
|
|
128
|
+
if (route === "/validate" || route === "/save") {
|
|
129
|
+
const tool = toolOf(body.tool);
|
|
130
|
+
const input = asString(body.path);
|
|
131
|
+
if (tool === void 0) return badRequest("tool must be kicad or solidcraft");
|
|
132
|
+
if (input === void 0) return badRequest("path is required");
|
|
133
|
+
const source = sourceOf(body.source) ?? "manual";
|
|
134
|
+
sendJson(res, 200, {
|
|
135
|
+
tool,
|
|
136
|
+
...route === "/save" ? await manager.save(tool, input, source) : await manager.validate(tool, input)
|
|
137
|
+
});
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (route === "/browse") {
|
|
141
|
+
const tool = toolOf(body.tool);
|
|
142
|
+
if (tool === void 0) return badRequest("tool must be kicad or solidcraft");
|
|
143
|
+
const abort = new AbortController();
|
|
144
|
+
const timer = setTimeout(() => {
|
|
145
|
+
abort.abort();
|
|
146
|
+
}, 9e5);
|
|
147
|
+
timer.unref?.();
|
|
148
|
+
try {
|
|
149
|
+
sendJson(res, 200, {
|
|
150
|
+
ok: true,
|
|
151
|
+
tool,
|
|
152
|
+
...await manager.browse(tool, abort.signal)
|
|
153
|
+
});
|
|
154
|
+
} finally {
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (route === "/install") {
|
|
160
|
+
const tool = toolOf(body.tool);
|
|
161
|
+
if (tool === void 0) return badRequest("tool must be kicad or solidcraft");
|
|
162
|
+
const started = await manager.install(tool);
|
|
163
|
+
if (started.error !== void 0) {
|
|
164
|
+
sendJson(res, 200, {
|
|
165
|
+
ok: false,
|
|
166
|
+
tool,
|
|
167
|
+
error: started.error
|
|
168
|
+
});
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
sendJson(res, 200, {
|
|
172
|
+
ok: true,
|
|
173
|
+
tool,
|
|
174
|
+
job: started.snapshot
|
|
175
|
+
});
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (route === "/cancel") {
|
|
179
|
+
const id = asString(body.id);
|
|
180
|
+
if (id === void 0) return badRequest("id is required");
|
|
181
|
+
sendJson(res, 200, {
|
|
182
|
+
ok: true,
|
|
183
|
+
cancelled: manager.cancel(id)
|
|
184
|
+
});
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (route === "/discover") {
|
|
188
|
+
const tool = body.tool === void 0 ? void 0 : toolOf(body.tool);
|
|
189
|
+
if (body.tool !== void 0 && tool === void 0) return badRequest("tool must be kicad or solidcraft");
|
|
190
|
+
sendJson(res, 200, {
|
|
191
|
+
ok: true,
|
|
192
|
+
...manager.startDiscovery(tool)
|
|
193
|
+
});
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
badRequest(`unknown toolchain route ${route}`);
|
|
197
|
+
return true;
|
|
79
198
|
}
|
|
80
199
|
function createHardwareHandler(service, options = {}) {
|
|
81
200
|
return (req, res) => {
|
|
@@ -93,6 +212,7 @@ function createHardwareHandler(service, options = {}) {
|
|
|
93
212
|
try {
|
|
94
213
|
const url = new URL(req.url ?? "/", "http://dsh.internal");
|
|
95
214
|
const p = url.pathname;
|
|
215
|
+
if (options.toolchain !== void 0 && await handleToolchain(req, res, url, options.toolchain)) return;
|
|
96
216
|
if (req.method === "GET" && p === `/api/v1/hardware/projects`) {
|
|
97
217
|
const sessionId = asString(url.searchParams.get("session") ?? void 0);
|
|
98
218
|
let workspace = asString(url.searchParams.get("cwd") ?? void 0);
|
|
@@ -136,14 +256,13 @@ function createHardwareHandler(service, options = {}) {
|
|
|
136
256
|
return;
|
|
137
257
|
}
|
|
138
258
|
const revision = asString(url.searchParams.get("revision") ?? void 0);
|
|
139
|
-
const
|
|
259
|
+
const sessionId = sessionOf(url);
|
|
140
260
|
try {
|
|
141
261
|
sendJson(res, 200, {
|
|
142
262
|
ok: true,
|
|
143
263
|
...await service.readSource({
|
|
144
264
|
artifactPath,
|
|
145
265
|
...revision === void 0 ? {} : { expectedRevision: revision },
|
|
146
|
-
roots,
|
|
147
266
|
...sessionId === void 0 ? {} : { sessionId }
|
|
148
267
|
})
|
|
149
268
|
});
|
|
@@ -174,12 +293,11 @@ function createHardwareHandler(service, options = {}) {
|
|
|
174
293
|
return;
|
|
175
294
|
}
|
|
176
295
|
const schematic = asString(body.schematic);
|
|
177
|
-
const
|
|
296
|
+
const sessionId = sessionOf(url, body);
|
|
178
297
|
try {
|
|
179
298
|
const prepared = await service.fabricate({
|
|
180
299
|
boardPath: artifactPath,
|
|
181
300
|
...schematic === void 0 ? {} : { schematicPath: schematic },
|
|
182
|
-
roots,
|
|
183
301
|
...sessionId === void 0 ? {} : { sessionId }
|
|
184
302
|
});
|
|
185
303
|
sendJson(res, 200, {
|
|
@@ -189,6 +307,7 @@ function createHardwareHandler(service, options = {}) {
|
|
|
189
307
|
generatedAt: prepared.generatedAt,
|
|
190
308
|
facts: prepared.facts,
|
|
191
309
|
archive: prepared.archive,
|
|
310
|
+
validation: prepared.validation,
|
|
192
311
|
...prepared.assembly === void 0 ? {} : { assembly: prepared.assembly }
|
|
193
312
|
});
|
|
194
313
|
} catch (error) {
|
|
@@ -221,7 +340,7 @@ function createHardwareHandler(service, options = {}) {
|
|
|
221
340
|
return;
|
|
222
341
|
}
|
|
223
342
|
const schematic = asString(body.schematic);
|
|
224
|
-
const
|
|
343
|
+
const sessionId = sessionOf(url, body);
|
|
225
344
|
try {
|
|
226
345
|
sendJson(res, 200, {
|
|
227
346
|
ok: true,
|
|
@@ -229,10 +348,9 @@ function createHardwareHandler(service, options = {}) {
|
|
|
229
348
|
kind: "pcb",
|
|
230
349
|
boardPath: artifactPath,
|
|
231
350
|
...schematic === void 0 ? {} : { schematicPath: schematic },
|
|
232
|
-
roots,
|
|
233
351
|
...sessionId === void 0 ? {} : { sessionId },
|
|
234
352
|
...typeof body.quantity === "number" ? { quantity: body.quantity } : {},
|
|
235
|
-
...body.launch ===
|
|
353
|
+
...body.launch === true ? { launch: true } : {}
|
|
236
354
|
})
|
|
237
355
|
});
|
|
238
356
|
} catch (error) {
|
|
@@ -265,7 +383,7 @@ function createHardwareHandler(service, options = {}) {
|
|
|
265
383
|
return;
|
|
266
384
|
}
|
|
267
385
|
const schematic = asString(body.schematic);
|
|
268
|
-
const
|
|
386
|
+
const sessionId = sessionOf(url, body);
|
|
269
387
|
try {
|
|
270
388
|
sendJson(res, 200, {
|
|
271
389
|
ok: true,
|
|
@@ -273,10 +391,9 @@ function createHardwareHandler(service, options = {}) {
|
|
|
273
391
|
kind: "smt",
|
|
274
392
|
boardPath: artifactPath,
|
|
275
393
|
...schematic === void 0 ? {} : { schematicPath: schematic },
|
|
276
|
-
roots,
|
|
277
394
|
...sessionId === void 0 ? {} : { sessionId },
|
|
278
395
|
...typeof body.quantity === "number" ? { quantity: body.quantity } : {},
|
|
279
|
-
...body.launch ===
|
|
396
|
+
...body.launch === true ? { launch: true } : {}
|
|
280
397
|
})
|
|
281
398
|
});
|
|
282
399
|
} catch (error) {
|
|
@@ -321,13 +438,12 @@ function createHardwareHandler(service, options = {}) {
|
|
|
321
438
|
});
|
|
322
439
|
return;
|
|
323
440
|
}
|
|
324
|
-
const
|
|
441
|
+
const sessionId = sessionOf(url, body);
|
|
325
442
|
try {
|
|
326
443
|
sendJson(res, 200, {
|
|
327
444
|
ok: true,
|
|
328
445
|
...await service.exportBom({
|
|
329
446
|
artifactPath,
|
|
330
|
-
roots,
|
|
331
447
|
...sessionId === void 0 ? {} : { sessionId }
|
|
332
448
|
})
|
|
333
449
|
});
|
|
@@ -350,11 +466,10 @@ function createHardwareHandler(service, options = {}) {
|
|
|
350
466
|
});
|
|
351
467
|
return;
|
|
352
468
|
}
|
|
353
|
-
const
|
|
469
|
+
const sessionId = sessionOf(url, body);
|
|
354
470
|
try {
|
|
355
471
|
const glb = await service.exportGlb({
|
|
356
472
|
artifactPath,
|
|
357
|
-
roots,
|
|
358
473
|
...sessionId === void 0 ? {} : { sessionId }
|
|
359
474
|
});
|
|
360
475
|
const query = new URLSearchParams({
|
|
@@ -461,4 +576,4 @@ function createHardwareHandler(service, options = {}) {
|
|
|
461
576
|
};
|
|
462
577
|
}
|
|
463
578
|
//#endregion
|
|
464
|
-
export { HARDWARE_ROUTE_PREFIX, createHardwareHandler };
|
|
579
|
+
export { HARDWARE_ROUTE_PREFIX, TOOLCHAIN_ROUTE_PREFIX, createHardwareHandler };
|
|
@@ -23,6 +23,20 @@ interface BoardFacts {
|
|
|
23
23
|
readonly innerOz?: number;
|
|
24
24
|
/** Placed pads, used for the assembly form's `patch_pad_number`. */
|
|
25
25
|
readonly padCount?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Display names the board gives its copper layers, canonical name as value
|
|
28
|
+
* (`{ top_copper: 'F_Cu' }`).
|
|
29
|
+
*
|
|
30
|
+
* A board may rename `F.Cu`/`In*.Cu`/`B.Cu`, and KiCad then writes that name
|
|
31
|
+
* into the plot's filename. The package validator needs the mapping to
|
|
32
|
+
* recognise the board's own copper. Only renamed layers appear.
|
|
33
|
+
*/
|
|
34
|
+
readonly copperAliases?: Readonly<Record<string, string>>;
|
|
35
|
+
}
|
|
36
|
+
/** One file inside the fabrication zip. */
|
|
37
|
+
interface PackageFile {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly bytes: number;
|
|
26
40
|
}
|
|
27
41
|
/**
|
|
28
42
|
* Derive the fabrication facts the order form needs from a saved board.
|
|
@@ -144,6 +158,44 @@ declare function smtOrderUrl(pageBase: string, ids: {
|
|
|
144
158
|
*/
|
|
145
159
|
declare function smtOrderUrlFromBackend(orderUrl: string, token: string | undefined): string | undefined;
|
|
146
160
|
//#endregion
|
|
161
|
+
//#region src/package.d.ts
|
|
162
|
+
/** Every way a package can be judged unfit to fabricate. */
|
|
163
|
+
type PackageIssueCode = 'no-copper' | 'missing-copper-layer' | 'unexpected-copper-layer' | 'no-board-outline' | 'zero-area' | 'no-drill' | 'empty-file' | 'unexpected-file';
|
|
164
|
+
interface PackageIssue {
|
|
165
|
+
readonly code: PackageIssueCode;
|
|
166
|
+
/** `error` blocks an order; `warning` is reported and left to the user. */
|
|
167
|
+
readonly severity: 'error' | 'warning';
|
|
168
|
+
readonly message: string;
|
|
169
|
+
readonly file?: string;
|
|
170
|
+
}
|
|
171
|
+
interface PackageValidation {
|
|
172
|
+
/** True when no issue is an error; warnings may still be present. */
|
|
173
|
+
readonly ok: boolean;
|
|
174
|
+
readonly checkedAt: string;
|
|
175
|
+
readonly errors: readonly PackageIssue[];
|
|
176
|
+
readonly warnings: readonly PackageIssue[];
|
|
177
|
+
/** Copper layers found in the package, in the file's own naming. */
|
|
178
|
+
readonly copperLayers: readonly string[];
|
|
179
|
+
/** Layers the stackup expects but the package does not contain. */
|
|
180
|
+
readonly missingLayers: readonly string[];
|
|
181
|
+
readonly hasOutline: boolean;
|
|
182
|
+
readonly hasDrill: boolean;
|
|
183
|
+
}
|
|
184
|
+
/** The copper layers a KiCad stackup of this size must contain, in order. */
|
|
185
|
+
declare function expectedCopperLayers(layers: number): string[];
|
|
186
|
+
/**
|
|
187
|
+
* Judge one package against the board facts it was plotted from.
|
|
188
|
+
*
|
|
189
|
+
* `facts` must come from the same board file (`readBoardFacts`); measuring a
|
|
190
|
+
* package against another board's stackup is the very mistake this catches.
|
|
191
|
+
*
|
|
192
|
+
* @param files - every member of the archive, with its uncompressed size.
|
|
193
|
+
* @param facts - geometry and stackup declared by the source board.
|
|
194
|
+
*/
|
|
195
|
+
declare function validateFabricationPackage(files: readonly PackageFile[], facts: BoardFacts): PackageValidation;
|
|
196
|
+
/** One sentence a human or agent can act on, or `undefined` when valid. */
|
|
197
|
+
declare function validationSummary(validation: PackageValidation): string | undefined;
|
|
198
|
+
//#endregion
|
|
147
199
|
//#region src/service.d.ts
|
|
148
200
|
type ArtifactKind = 'schematic' | 'pcb' | 'pcb-3d' | 'bom' | 'mechanical-3d';
|
|
149
201
|
/** Native handoff is KiCad-only in this POC; SolidCraft stays agent context. */
|
|
@@ -217,12 +269,7 @@ interface OpenArtifactResult {
|
|
|
217
269
|
interface SourceRequest {
|
|
218
270
|
readonly artifactPath: string;
|
|
219
271
|
readonly expectedRevision?: string;
|
|
220
|
-
/**
|
|
221
|
-
* Roots the caller names. They are *added* to the roots the host resolved
|
|
222
|
-
* for {@link sessionId}; naming one never revokes another.
|
|
223
|
-
*/
|
|
224
|
-
readonly roots?: readonly string[];
|
|
225
|
-
/** DSH session the read belongs to; its workspace is the authorization base. */
|
|
272
|
+
/** DSH session the read belongs to, used only to scope the discovery cache. */
|
|
226
273
|
readonly sessionId?: string;
|
|
227
274
|
}
|
|
228
275
|
interface SourceResult {
|
|
@@ -235,7 +282,6 @@ interface SourceResult {
|
|
|
235
282
|
}
|
|
236
283
|
interface GlbRequest {
|
|
237
284
|
readonly artifactPath: string;
|
|
238
|
-
readonly roots?: readonly string[];
|
|
239
285
|
readonly sessionId?: string;
|
|
240
286
|
readonly signal?: AbortSignal;
|
|
241
287
|
}
|
|
@@ -279,6 +325,11 @@ interface FabricationResult {
|
|
|
279
325
|
readonly generatedAt: string;
|
|
280
326
|
readonly facts: BoardFacts;
|
|
281
327
|
readonly archive: OrderPackageSummary;
|
|
328
|
+
/**
|
|
329
|
+
* Whether the archive is actually fabricable. Present on every result: a
|
|
330
|
+
* package can be prepared and refused, and the caller needs the reason.
|
|
331
|
+
*/
|
|
332
|
+
readonly validation: PackageValidation;
|
|
282
333
|
/** Assembly inputs, present when a schematic was supplied. */
|
|
283
334
|
readonly assembly?: {
|
|
284
335
|
readonly positions: number;
|
|
@@ -298,11 +349,16 @@ interface PlaceOrderRequest {
|
|
|
298
349
|
readonly kind: 'pcb' | 'smt';
|
|
299
350
|
readonly boardPath: string;
|
|
300
351
|
readonly schematicPath?: string;
|
|
301
|
-
readonly roots?: readonly string[];
|
|
302
352
|
readonly sessionId?: string;
|
|
303
353
|
readonly quantity?: number;
|
|
304
354
|
readonly signal?: AbortSignal;
|
|
305
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Hand the resulting page to the OS default browser.
|
|
357
|
+
*
|
|
358
|
+
* Off by default: a DSH client opens the page in its own Browser tab, and
|
|
359
|
+
* opening both would leave the user with two copies of the same page. Only a
|
|
360
|
+
* caller with no client (a script, a foreign MCP host) wants this on.
|
|
361
|
+
*/
|
|
306
362
|
readonly launch?: boolean;
|
|
307
363
|
}
|
|
308
364
|
interface PlaceOrderResult {
|
|
@@ -319,6 +375,8 @@ interface PlaceOrderResult {
|
|
|
319
375
|
readonly endpoint: string;
|
|
320
376
|
readonly facts: BoardFacts;
|
|
321
377
|
readonly archive: OrderPackageSummary;
|
|
378
|
+
/** The package judgement the order was placed with. */
|
|
379
|
+
readonly validation: PackageValidation;
|
|
322
380
|
readonly assembly?: FabricationResult['assembly'];
|
|
323
381
|
}
|
|
324
382
|
interface HardwareArtifactsOptions {
|
|
@@ -359,7 +417,7 @@ interface HardwareArtifactsOptions {
|
|
|
359
417
|
readonly orderBaseUrl?: string;
|
|
360
418
|
readonly accessToken?: string;
|
|
361
419
|
};
|
|
362
|
-
readonly probeVersion?: (executable: string) => string | undefined;
|
|
420
|
+
readonly probeVersion?: (executable: string, tool?: 'kicad' | 'solidcraft') => string | undefined;
|
|
363
421
|
readonly spawnProcess?: (command: string, args: readonly string[], options: {
|
|
364
422
|
cwd: string;
|
|
365
423
|
detached: boolean;
|
|
@@ -420,7 +478,13 @@ declare class HardwareArtifactService {
|
|
|
420
478
|
constructor(config?: HardwareArtifactsOptions);
|
|
421
479
|
/** Configured roots, read live so a settings write is visible immediately. */
|
|
422
480
|
private roots;
|
|
423
|
-
/**
|
|
481
|
+
/**
|
|
482
|
+
* Resolve configured installations from validated absolute paths only.
|
|
483
|
+
*
|
|
484
|
+
* Resolution is delegated to the toolchain capability's one resolver
|
|
485
|
+
* (`./toolchain/resolve.ts`) so the settings panel, background discovery and
|
|
486
|
+
* the export path cannot disagree about what "configured" means.
|
|
487
|
+
*/
|
|
424
488
|
installations(): Installations;
|
|
425
489
|
/** Paths passed to agent child processes. Never assign these globally. */
|
|
426
490
|
childEnvironment(): Record<string, string>;
|
|
@@ -446,20 +510,20 @@ declare class HardwareArtifactService {
|
|
|
446
510
|
/** Validate and launch a native application without a shell. */
|
|
447
511
|
open(request: OpenArtifactRequest): OpenArtifactResult;
|
|
448
512
|
/**
|
|
449
|
-
*
|
|
450
|
-
* the caller named.
|
|
513
|
+
* Resolve one artifact path: canonical, real, of an expected type.
|
|
451
514
|
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
515
|
+
* There is deliberately **no workspace fence**. This service only runs on the
|
|
516
|
+
* machine whose files it reads, under the same authority as the user's own
|
|
517
|
+
* editor, so a root check never protected anything the user could not already
|
|
518
|
+
* open — it only produced `403 artifact is outside the authorized workspace`
|
|
519
|
+
* whenever a panel and an agent call disagreed about a root, which is a
|
|
520
|
+
* configuration puzzle disguised as a security boundary.
|
|
521
|
+
*
|
|
522
|
+
* What remains is what makes the answer trustworthy rather than merely
|
|
523
|
+
* permitted: the path must be absolute, exist, be a regular file, be of a type
|
|
524
|
+
* this service renders, and be resolved through symlinks before anything
|
|
525
|
+
* reads it.
|
|
526
|
+
* @param artifactPath - absolute path supplied by a client or an agent tool.
|
|
463
527
|
*/
|
|
464
528
|
private authorize;
|
|
465
529
|
/** Saved source text plus a content-addressed revision. */
|
|
@@ -486,7 +550,6 @@ declare class HardwareArtifactService {
|
|
|
486
550
|
*/
|
|
487
551
|
exportBom(request: {
|
|
488
552
|
readonly artifactPath: string;
|
|
489
|
-
readonly roots?: readonly string[];
|
|
490
553
|
readonly sessionId?: string;
|
|
491
554
|
readonly signal?: AbortSignal;
|
|
492
555
|
}): Promise<BomResult>;
|
|
@@ -513,7 +576,6 @@ declare class HardwareArtifactService {
|
|
|
513
576
|
fabricate(request: {
|
|
514
577
|
readonly boardPath: string;
|
|
515
578
|
readonly schematicPath?: string;
|
|
516
|
-
readonly roots?: readonly string[];
|
|
517
579
|
readonly sessionId?: string;
|
|
518
580
|
readonly signal?: AbortSignal;
|
|
519
581
|
}): Promise<FabricationResult & {
|
|
@@ -524,8 +586,37 @@ declare class HardwareArtifactService {
|
|
|
524
586
|
};
|
|
525
587
|
}>;
|
|
526
588
|
/**
|
|
527
|
-
*
|
|
589
|
+
* Write one prepared package into a directory.
|
|
590
|
+
*
|
|
591
|
+
* The package is normally kept in memory: the order panel shows it, the
|
|
592
|
+
* submit uploads it, and neither needs a file. A caller that has to hand the
|
|
593
|
+
* archive to someone else does — and re-running the plotter for that would
|
|
594
|
+
* produce a different revision than the one already validated. This writes
|
|
595
|
+
* exactly the bytes that were validated.
|
|
596
|
+
*
|
|
597
|
+
* Files are overwritten by design: the directory holds derived output, and a
|
|
598
|
+
* rebuild of the same board replaces the previous export rather than
|
|
599
|
+
* accumulating copies beside it. Nothing outside `directory` is touched.
|
|
528
600
|
*
|
|
601
|
+
* @param prepared - the value `fabricate` returned, archive bytes included.
|
|
602
|
+
* @param directory - target directory, created when missing.
|
|
603
|
+
*/
|
|
604
|
+
writePackage(prepared: FabricationResult & {
|
|
605
|
+
readonly archiveData: Uint8Array;
|
|
606
|
+
readonly assemblyFiles?: {
|
|
607
|
+
readonly positions: string;
|
|
608
|
+
readonly bom: string;
|
|
609
|
+
};
|
|
610
|
+
}, directory: string): {
|
|
611
|
+
directory: string;
|
|
612
|
+
files: readonly {
|
|
613
|
+
name: string;
|
|
614
|
+
path: string;
|
|
615
|
+
bytes: number;
|
|
616
|
+
}[];
|
|
617
|
+
};
|
|
618
|
+
/**
|
|
619
|
+
* Submit one order to the Huaqiu openapi, exactly as the KiCad action does.
|
|
529
620
|
* PCB: every `PCB_FORM` field plus the gerber/drill archive as `file`.
|
|
530
621
|
* SMT: `pcbFile` + `coordFile` + `bomFile` and `reqParseVO`, with the caller's
|
|
531
622
|
* access token in `authorization`. The backend owns the order; this method
|
|
@@ -565,4 +656,4 @@ declare function parseCsv(text: string): string[][];
|
|
|
565
656
|
*/
|
|
566
657
|
declare function groupBomRows(table: readonly string[][]): BomRow[];
|
|
567
658
|
//#endregion
|
|
568
|
-
export {
|
|
659
|
+
export { validationSummary as A, parsePositions as B, groupBomRows as C, PackageValidation as D, PackageIssueCode as E, ORDER_SOURCE_TID as F, smtOrderForm as G, pcbOrderUrl as H, PositionRow as I, snapHoleTier as J, smtOrderUrl as K, orderBomCsv as L, DEFAULT_ORDER_BASE_URL as M, DEFAULT_ORDER_PAGE_BASE as N, expectedCopperLayers as O, ORDER_PATHS as P, orderBomRows as R, SourceResult as S, PackageIssue as T, positionsCsv as U, pcbOrderForm as V, readBoardFacts as W, snapTraceTier as X, snapThickness as Y, OrderConfigInfo as _, FabricationResult as a, PlaceOrderResult as b, HardwareArtifact as c, HardwareProject as d, InstallationInfo as f, OpenArtifactResult as g, OpenArtifactRequest as h, DiscoveryResult as i, BoardFacts as j, validateFabricationPackage as k, HardwareArtifactService as l, NativeApplication as m, BomResult as n, GlbRequest as o, Installations as p, smtOrderUrlFromBackend as q, BomRow as r, GlbResult as s, ArtifactKind as t, HardwareArtifactsOptions as u, OrderPackageSummary as v, parseCsv as w, SourceRequest as x, PlaceOrderRequest as y, orderIdsFromUrl as z };
|