@huaqiu/hardware-artifacts 0.0.0-stage → 0.7.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 深圳华秋智联股份有限公司
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # @huaqiu/hardware-artifacts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Hardware Engineering host capability. It is a local Cordis plugin, not a daemon and not an HQ Edge dependency.
4
+
5
+ - Deterministically discovers one selected `.kicad_pro`, its schematic hierarchy, boards and mechanical models. Multiple projects/boards require explicit selection; the package never silently takes the first match.
6
+ - Resolves configured KiCad and SolidCraft installations from user-scoped settings. KiCad CLI and GUI editors are resolved from one installation root; SolidCraft stays disabled when unconfigured.
7
+ - Launches the exact displayed artifact with explicit `argv`, the artifact's parent as cwd, no shell, and a detached process.
8
+ - Exposes a compact `<hardware_environment>` prompt context and `HUAQIU_*` child-process environment values without mutating global `process.env`.
9
+ - Serves read-only same-origin routes under `/api/v1/hardware`.
10
+
11
+ Native KiCad files remain authoritative. The service stores path pointers only.
@@ -0,0 +1,10 @@
1
+ # dsh bundle patch: Hardware Engineering host capability.
2
+ #
3
+ # The row waits on the local web server and the prompt-context service it
4
+ # contributes to. Filesystem, settings and subprocess access stay defensive.
5
+ # No row here injects hqEdge: installation resolution and native launch are
6
+ # local and shell-free by construction.
7
+ - insert:
8
+ - id: hardware-artifacts
9
+ name: '@huaqiu/hardware-artifacts'
10
+ inject: ['webServer', 'systemPrompt']
@@ -0,0 +1,27 @@
1
+ import { ArtifactKind, DiscoveryResult, HardwareArtifact, HardwareArtifactService, HardwareArtifactsOptions, HardwareProject, InstallationInfo, Installations, NativeApplication, OpenArtifactRequest, OpenArtifactResult } from "./service.mjs";
2
+ import { HARDWARE_ROUTE_PREFIX, createHardwareHandler } from "./routes.mjs";
3
+ import Schema from "@deepseek-ai/schemastery";
4
+ import { Context } from "@deepseek-ai/cordis";
5
+ //#region src/index.d.ts
6
+ declare const name = "@huaqiu/hardware-artifacts";
7
+ declare const inject: readonly ["webServer", "systemPrompt"];
8
+ /** User-scoped installation settings persisted by DSH's host-backed config. */
9
+ declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
10
+ kicadRoot: Schema<string, string, "defined">;
11
+ solidcraftRoot: Schema<string, string, "defined">;
12
+ }>>, Schemastery.ObjectT<NoInfer<{
13
+ kicadRoot: Schema<string, string, "defined">;
14
+ solidcraftRoot: Schema<string, string, "defined">;
15
+ }>>, "plain">;
16
+ interface HardwareArtifactsPluginConfig {
17
+ readonly kicadRoot?: string;
18
+ readonly solidcraftRoot?: string;
19
+ }
20
+ declare module '@deepseek-ai/cordis' {
21
+ interface Context {
22
+ hardwareArtifacts: HardwareArtifactService;
23
+ }
24
+ }
25
+ declare function apply(ctx: Context, config?: HardwareArtifactsPluginConfig): void;
26
+ //#endregion
27
+ export { type ArtifactKind, Config, type DiscoveryResult, HARDWARE_ROUTE_PREFIX, type HardwareArtifact, HardwareArtifactService, type HardwareArtifactsOptions, HardwareArtifactsPluginConfig, type HardwareProject, type InstallationInfo, type Installations, type NativeApplication, type OpenArtifactRequest, type OpenArtifactResult, apply, createHardwareHandler, inject, name };
package/lib/index.mjs ADDED
@@ -0,0 +1,32 @@
1
+ import { HARDWARE_ROUTE_PREFIX, createHardwareHandler } from "./routes.mjs";
2
+ import { HardwareArtifactService } from "./service.mjs";
3
+ import Schema from "@deepseek-ai/schemastery";
4
+ //#region src/index.ts
5
+ const name = "@huaqiu/hardware-artifacts";
6
+ const inject = ["webServer", "systemPrompt"];
7
+ /** User-scoped installation settings persisted by DSH's host-backed config. */
8
+ const Config = Schema.object({
9
+ kicadRoot: Schema.string().default(""),
10
+ solidcraftRoot: Schema.string().default("")
11
+ });
12
+ function apply(ctx, config = {}) {
13
+ const service = new HardwareArtifactService({
14
+ ...config.kicadRoot ? { kicadRoot: config.kicadRoot } : {},
15
+ ...config.solidcraftRoot ? { solidcraftRoot: config.solidcraftRoot } : {}
16
+ });
17
+ ctx.effect(() => ctx.provide("hardwareArtifacts", service));
18
+ if (ctx.webServer !== void 0) ctx.effect(() => ctx.webServer.register({
19
+ kind: "prefix",
20
+ path: HARDWARE_ROUTE_PREFIX,
21
+ handler: createHardwareHandler(service)
22
+ }), "hardware-artifacts: local read/launch routes");
23
+ const prompt = ctx.systemPrompt;
24
+ if (prompt !== void 0 && typeof prompt.context === "function") ctx.effect(() => prompt.context({
25
+ name: "hardware-environment",
26
+ order: 42,
27
+ interpolate: false,
28
+ text: () => service.environmentText()
29
+ }), "hardware-artifacts: compact agent environment");
30
+ }
31
+ //#endregion
32
+ export { Config, HARDWARE_ROUTE_PREFIX, HardwareArtifactService, apply, createHardwareHandler, inject, name };
@@ -0,0 +1,7 @@
1
+ import { HardwareArtifactService } from "./service.mjs";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
3
+ //#region src/routes.d.ts
4
+ declare const HARDWARE_ROUTE_PREFIX = "/api/v1/hardware";
5
+ declare function createHardwareHandler(service: HardwareArtifactService): (req: IncomingMessage, res: ServerResponse) => void;
6
+ //#endregion
7
+ export { HARDWARE_ROUTE_PREFIX, createHardwareHandler };
package/lib/routes.mjs ADDED
@@ -0,0 +1,269 @@
1
+ import { readFileSync } from "node:fs";
2
+ //#region src/routes.ts
3
+ const HARDWARE_ROUTE_PREFIX = "/api/v1/hardware";
4
+ function sendJson(res, status, body) {
5
+ const text = JSON.stringify(body);
6
+ res.writeHead(status, {
7
+ "content-type": "application/json; charset=utf-8",
8
+ "content-length": Buffer.byteLength(text)
9
+ });
10
+ res.end(text);
11
+ }
12
+ function isTrustedRequest(req) {
13
+ const host = String(req.headers.host ?? "");
14
+ if (!/^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/.test(host)) return false;
15
+ const origin = req.headers.origin;
16
+ return origin === void 0 || /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/.test(String(origin));
17
+ }
18
+ async function readJson(req, maxBytes = 65536) {
19
+ const chunks = [];
20
+ let size = 0;
21
+ for await (const chunk of req) {
22
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
23
+ size += buffer.byteLength;
24
+ if (size > maxBytes) throw Object.assign(/* @__PURE__ */ new Error("request body too large"), { status: 413 });
25
+ chunks.push(buffer);
26
+ }
27
+ return JSON.parse(Buffer.concat(chunks).toString("utf8"));
28
+ }
29
+ function asString(value) {
30
+ return typeof value === "string" && value.length > 0 ? value : void 0;
31
+ }
32
+ function failure(error) {
33
+ const code = typeof error.code === "string" ? String(error.code) : "internal";
34
+ return {
35
+ status: typeof error.status === "number" ? Number(error.status) : 500,
36
+ body: {
37
+ ok: false,
38
+ error: {
39
+ code,
40
+ message: error instanceof Error ? error.message : String(error)
41
+ }
42
+ }
43
+ };
44
+ }
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
+ function createHardwareHandler(service) {
51
+ let lastDiscovery;
52
+ return (req, res) => {
53
+ if (!isTrustedRequest(req)) {
54
+ sendJson(res, 403, {
55
+ ok: false,
56
+ error: {
57
+ code: "forbidden",
58
+ message: "forbidden"
59
+ }
60
+ });
61
+ return;
62
+ }
63
+ (async () => {
64
+ try {
65
+ const url = new URL(req.url ?? "/", "http://dsh.internal");
66
+ const p = url.pathname;
67
+ if (req.method === "GET" && p === `/api/v1/hardware/projects`) {
68
+ const result = service.discover(asString(url.searchParams.get("cwd") ?? void 0) ?? process.cwd(), asString(url.searchParams.get("project") ?? void 0));
69
+ lastDiscovery = result;
70
+ sendJson(res, 200, {
71
+ ok: true,
72
+ ...result
73
+ });
74
+ return;
75
+ }
76
+ if (req.method === "GET" && p === `/api/v1/hardware/installations`) {
77
+ sendJson(res, 200, {
78
+ ok: true,
79
+ ...service.installations()
80
+ });
81
+ return;
82
+ }
83
+ if (req.method === "GET" && p === `/api/v1/hardware/environment`) {
84
+ sendJson(res, 200, {
85
+ ok: true,
86
+ text: service.environmentText(lastDiscovery ?? service.discovery()),
87
+ childEnv: service.childEnvironment()
88
+ });
89
+ return;
90
+ }
91
+ if (req.method === "GET" && p === `/api/v1/hardware/source`) {
92
+ const artifactPath = asString(url.searchParams.get("path"));
93
+ if (artifactPath === void 0) {
94
+ sendJson(res, 400, {
95
+ ok: false,
96
+ error: {
97
+ code: "invalid-request",
98
+ message: "path is required"
99
+ }
100
+ });
101
+ return;
102
+ }
103
+ const cwd = asString(url.searchParams.get("cwd") ?? void 0);
104
+ const revision = asString(url.searchParams.get("revision") ?? void 0);
105
+ try {
106
+ sendJson(res, 200, {
107
+ ok: true,
108
+ ...await service.readSource({
109
+ artifactPath,
110
+ ...revision === void 0 ? {} : { expectedRevision: revision },
111
+ ...cwd === void 0 ? {} : { roots: [cwd] }
112
+ })
113
+ });
114
+ } catch (error) {
115
+ const { status, body } = failure(error);
116
+ sendJson(res, status, body);
117
+ }
118
+ return;
119
+ }
120
+ if (req.method === "POST" && p === `/api/v1/hardware/bom`) {
121
+ const body = await readJson(req);
122
+ const artifactPath = asString(body.path);
123
+ if (artifactPath === void 0) {
124
+ sendJson(res, 400, {
125
+ ok: false,
126
+ error: {
127
+ code: "invalid-request",
128
+ message: "path is required"
129
+ }
130
+ });
131
+ return;
132
+ }
133
+ try {
134
+ sendJson(res, 200, {
135
+ ok: true,
136
+ ...await service.exportBom({
137
+ artifactPath,
138
+ roots: rootsOf(body)
139
+ })
140
+ });
141
+ } catch (error) {
142
+ const { status, body } = failure(error);
143
+ sendJson(res, status, body);
144
+ }
145
+ return;
146
+ }
147
+ if (req.method === "POST" && p === `/api/v1/hardware/glb`) {
148
+ const body = await readJson(req);
149
+ const artifactPath = asString(body.path);
150
+ if (artifactPath === void 0) {
151
+ sendJson(res, 400, {
152
+ ok: false,
153
+ error: {
154
+ code: "invalid-request",
155
+ message: "path is required"
156
+ }
157
+ });
158
+ return;
159
+ }
160
+ try {
161
+ const glb = await service.exportGlb({
162
+ artifactPath,
163
+ roots: rootsOf(body)
164
+ });
165
+ const query = new URLSearchParams({
166
+ path: glb.path,
167
+ revision: glb.revision
168
+ });
169
+ sendJson(res, 200, {
170
+ ok: true,
171
+ path: glb.path,
172
+ revision: glb.revision,
173
+ bytes: glb.bytes,
174
+ generatedAt: glb.generatedAt,
175
+ cached: glb.cached,
176
+ url: `/api/v1/hardware/glb-file?${query.toString()}`
177
+ });
178
+ } catch (error) {
179
+ const { status, body } = failure(error);
180
+ sendJson(res, status, body);
181
+ }
182
+ return;
183
+ }
184
+ if (req.method === "GET" && p === `/api/v1/hardware/glb-file`) {
185
+ const artifactPath = asString(url.searchParams.get("path"));
186
+ const revision = asString(url.searchParams.get("revision"));
187
+ if (artifactPath === void 0 || revision === void 0) {
188
+ sendJson(res, 400, {
189
+ ok: false,
190
+ error: {
191
+ code: "invalid-request",
192
+ message: "path and revision are required"
193
+ }
194
+ });
195
+ return;
196
+ }
197
+ try {
198
+ const file = service.glbFile(artifactPath, revision);
199
+ const bytes = readFileSync(file);
200
+ res.writeHead(200, {
201
+ "content-type": "model/gltf-binary",
202
+ "content-length": bytes.byteLength,
203
+ "cache-control": "no-store",
204
+ "x-huaqiu-source-revision": revision
205
+ });
206
+ res.end(bytes);
207
+ } catch (error) {
208
+ const { status, body } = failure(error);
209
+ sendJson(res, status, body);
210
+ }
211
+ return;
212
+ }
213
+ if (req.method === "POST" && p === `/api/v1/hardware/open`) {
214
+ const body = await readJson(req);
215
+ const application = asString(body.application);
216
+ const artifactPath = asString(body.artifactPath);
217
+ const kind = asString(body.kind);
218
+ if (application !== "kicad") {
219
+ sendJson(res, 400, {
220
+ error: {
221
+ code: "invalid-application",
222
+ message: "application must be kicad"
223
+ },
224
+ ok: false
225
+ });
226
+ return;
227
+ }
228
+ if (artifactPath === void 0 || kind === void 0) {
229
+ sendJson(res, 400, {
230
+ ok: false,
231
+ error: {
232
+ code: "invalid-request",
233
+ message: "artifactPath and kind are required"
234
+ }
235
+ });
236
+ return;
237
+ }
238
+ try {
239
+ sendJson(res, 200, {
240
+ ok: true,
241
+ ...service.open({
242
+ application,
243
+ artifactPath,
244
+ kind,
245
+ ...asString(body.projectPath) === void 0 ? {} : { projectPath: asString(body.projectPath) }
246
+ })
247
+ });
248
+ } catch (error) {
249
+ const { status, body } = failure(error);
250
+ sendJson(res, status, body);
251
+ }
252
+ return;
253
+ }
254
+ sendJson(res, 404, {
255
+ ok: false,
256
+ error: {
257
+ code: "not-found",
258
+ message: "unknown hardware route"
259
+ }
260
+ });
261
+ } catch (error) {
262
+ const { status, body } = failure(error);
263
+ sendJson(res, status, body);
264
+ }
265
+ })();
266
+ };
267
+ }
268
+ //#endregion
269
+ export { HARDWARE_ROUTE_PREFIX, createHardwareHandler };
@@ -0,0 +1,226 @@
1
+ import { ChildProcess } from "node:child_process";
2
+ //#region src/service.d.ts
3
+ type ArtifactKind = 'schematic' | 'pcb' | 'pcb-3d' | 'bom' | 'mechanical-3d';
4
+ /** Native handoff is KiCad-only in this POC; SolidCraft stays agent context. */
5
+ type NativeApplication = 'kicad';
6
+ interface HardwareArtifact {
7
+ readonly id: string;
8
+ readonly kind: ArtifactKind;
9
+ readonly path: string;
10
+ readonly projectPath?: string;
11
+ /** BOM keeps its schematic; PCB 3D keeps its board; sheets keep their root. */
12
+ readonly sourcePath?: string;
13
+ readonly title: string;
14
+ readonly format: string;
15
+ /** Content hash of the saved source, filled when the source is read. */
16
+ readonly revision?: string;
17
+ }
18
+ interface HardwareProject {
19
+ readonly path: string;
20
+ readonly name: string;
21
+ /** Root schematic: the authoritative project entry point. */
22
+ readonly rootSheet?: HardwareArtifact;
23
+ readonly schematic?: HardwareArtifact;
24
+ /** Semantic views; both keep the identity of their source artifact. */
25
+ readonly bom?: HardwareArtifact;
26
+ readonly pcb3d?: HardwareArtifact;
27
+ readonly sheets: readonly HardwareArtifact[];
28
+ /** Deterministic default board, only when ownership is unambiguous. */
29
+ readonly defaultBoard?: string;
30
+ readonly boards: readonly HardwareArtifact[];
31
+ readonly mechanical: readonly HardwareArtifact[];
32
+ readonly selectionRequired: boolean;
33
+ }
34
+ interface DiscoveryResult {
35
+ readonly cwd: string;
36
+ readonly manifestPath?: string;
37
+ readonly projects: readonly HardwareProject[];
38
+ readonly selected?: HardwareProject;
39
+ readonly issue?: {
40
+ readonly code: string;
41
+ readonly message: string;
42
+ };
43
+ }
44
+ interface InstallationInfo {
45
+ readonly configured: boolean;
46
+ readonly root?: string;
47
+ readonly cli?: string;
48
+ readonly projectManager?: string;
49
+ readonly pcbEditor?: string;
50
+ readonly schematicEditor?: string;
51
+ readonly executable?: string;
52
+ readonly version?: string;
53
+ readonly error?: string;
54
+ }
55
+ interface Installations {
56
+ readonly kicad: InstallationInfo;
57
+ readonly solidcraft: InstallationInfo;
58
+ }
59
+ interface OpenArtifactRequest {
60
+ readonly application: NativeApplication;
61
+ readonly artifactPath: string;
62
+ readonly kind: ArtifactKind;
63
+ readonly projectPath?: string;
64
+ }
65
+ interface OpenArtifactResult {
66
+ readonly launched: true;
67
+ readonly command: string;
68
+ readonly args: readonly string[];
69
+ readonly cwd: string;
70
+ readonly pid?: number;
71
+ }
72
+ interface SourceRequest {
73
+ readonly artifactPath: string;
74
+ readonly expectedRevision?: string;
75
+ /** Workspace roots the caller is currently authorized to read. */
76
+ readonly roots?: readonly string[];
77
+ }
78
+ interface SourceResult {
79
+ readonly path: string;
80
+ readonly kind: 'schematic' | 'pcb';
81
+ readonly revision: string;
82
+ readonly bytes: number;
83
+ readonly mtimeMs: number;
84
+ readonly text: string;
85
+ }
86
+ interface GlbRequest {
87
+ readonly artifactPath: string;
88
+ readonly roots?: readonly string[];
89
+ readonly signal?: AbortSignal;
90
+ }
91
+ interface GlbResult {
92
+ readonly path: string;
93
+ readonly revision: string;
94
+ readonly bytes: number;
95
+ readonly generatedAt: string;
96
+ readonly cached: boolean;
97
+ readonly file: string;
98
+ }
99
+ /** One grouped BOM line, as KiCad's own BOM export groups it. */
100
+ interface BomRow {
101
+ readonly references: readonly string[];
102
+ readonly quantity: number;
103
+ readonly value: string;
104
+ readonly footprint: string;
105
+ readonly dnp: boolean;
106
+ readonly fields: Readonly<Record<string, string>>;
107
+ }
108
+ interface BomResult {
109
+ readonly path: string;
110
+ readonly revision: string;
111
+ readonly generatedAt: string;
112
+ readonly cached: boolean;
113
+ readonly rows: readonly BomRow[];
114
+ readonly source: 'kicad-cli-bom';
115
+ }
116
+ interface HardwareArtifactsOptions {
117
+ readonly kicadRoot?: string;
118
+ readonly solidcraftRoot?: string;
119
+ readonly probeVersion?: (executable: string) => string | undefined;
120
+ readonly spawnProcess?: (command: string, args: readonly string[], options: {
121
+ cwd: string;
122
+ detached: boolean;
123
+ stdio: 'ignore';
124
+ windowsHide: boolean;
125
+ shell: false;
126
+ }) => Pick<ChildProcess, 'pid'>;
127
+ /** Runs one short-lived CLI command and returns its exit facts. */
128
+ readonly runCommand?: (command: string, args: readonly string[], options: {
129
+ cwd: string;
130
+ timeoutMs: number;
131
+ signal?: AbortSignal;
132
+ }) => Promise<{
133
+ exitCode: number | null;
134
+ stdout: string;
135
+ stderr: string;
136
+ timedOut: boolean;
137
+ }>;
138
+ /** Cache directory for derived outputs; defaults to a temp subdirectory. */
139
+ readonly cacheRoot?: string;
140
+ readonly glbTimeoutMs?: number;
141
+ /** Source text limit; protects the host from pathological files. */
142
+ readonly maxSourceBytes?: number;
143
+ }
144
+ /** Small, immutable host capability implementation. */
145
+ declare class HardwareArtifactService {
146
+ private readonly config;
147
+ private readonly options;
148
+ private readonly cacheRoot;
149
+ private readonly glbTimeoutMs;
150
+ private readonly maxSourceBytes;
151
+ private lastDiscovery?;
152
+ /** Completed GLB exports keyed by `sourcePath:revision`. */
153
+ private readonly glbCache;
154
+ /** In-flight GLB exports keyed by the same key, so concurrent callers share one run. */
155
+ private readonly glbPending;
156
+ /** BOM projections keyed by `sourcePath:revision`. */
157
+ private readonly bomCache;
158
+ constructor(config?: HardwareArtifactsOptions);
159
+ /** Resolve configured installations from validated absolute paths only. */
160
+ installations(): Installations;
161
+ /** Paths passed to agent child processes. Never assign these globally. */
162
+ childEnvironment(): Record<string, string>;
163
+ /** Compact agent context: validated paths only, no project inventory dump. */
164
+ environmentText(current?: DiscoveryResult): string;
165
+ /**
166
+ * Deterministic discovery. An explicit project or manifest wins; otherwise
167
+ * exactly one `.kicad_pro` may be selected automatically. Ambiguity is
168
+ * returned as a selection requirement, never resolved by taking the first.
169
+ */
170
+ discover(cwdInput: string, explicitProject?: string): DiscoveryResult;
171
+ /** The most recent discovery, used to authorize source reads. */
172
+ discovery(): DiscoveryResult | undefined;
173
+ private projectFrom;
174
+ /** Validate and launch a native application without a shell. */
175
+ open(request: OpenArtifactRequest): OpenArtifactResult;
176
+ /** Workspace roots a read may target: explicit request, last discovery, config. */
177
+ private authorizedRoots;
178
+ /**
179
+ * Authorize one artifact path: canonical, realpath-checked, inside a
180
+ * workspace root, and of an expected type. A browser request cannot turn
181
+ * this into an arbitrary filesystem read, even from loopback.
182
+ */
183
+ private authorize;
184
+ /** Saved source text plus a content-addressed revision. */
185
+ readSource(request: SourceRequest): Promise<SourceResult>;
186
+ private sourceRevision;
187
+ /** Cache directory for one board's derived outputs. */
188
+ private glbDirectory;
189
+ /**
190
+ * Generate (or reuse) the GLB for one board.
191
+ *
192
+ * - cache key includes the source content hash, so same-size/same-mtime edits invalidate
193
+ * - one in-flight export is shared by concurrent callers for the same revision
194
+ * - output is written to a temp file and renamed only after it validates
195
+ * - a timeout or abort leaves no partial file behind
196
+ */
197
+ exportGlb(request: GlbRequest): Promise<GlbResult>;
198
+ /**
199
+ * Grouped BOM for one saved root schematic.
200
+ *
201
+ * Reuses KiCad's own BOM extraction (`kicad-cli sch export bom`), the same
202
+ * authoritative source `analyze_kicad_module` consumes, rather than building a
203
+ * second component analyser. Grouping key is every non-reference column, so
204
+ * different MPNs never merge and DNP stays explicit.
205
+ */
206
+ exportBom(request: {
207
+ readonly artifactPath: string;
208
+ readonly roots?: readonly string[];
209
+ readonly signal?: AbortSignal;
210
+ }): Promise<BomResult>;
211
+ /** Serve a generated GLB file, re-validating the cache entry first. */ glbFile(boardPath: string, revision: string): string;
212
+ /** Drop cached derived outputs for one board (or all of them). */
213
+ clearCache(boardPath?: string): void;
214
+ }
215
+ /** RFC4180-style CSV reader: quoted fields, doubled quotes, CRLF rows. */
216
+ declare function parseCsv(text: string): string[][];
217
+ /**
218
+ * Group KiCad's per-reference BOM rows.
219
+ *
220
+ * Identity is every column except the reference and quantity columns, so a
221
+ * different MPN or a DNP flag always produces a separate line; ordering follows
222
+ * the first reference seen, which keeps the table stable between reads.
223
+ */
224
+ declare function groupBomRows(table: readonly string[][]): BomRow[];
225
+ //#endregion
226
+ export { ArtifactKind, BomResult, BomRow, DiscoveryResult, GlbRequest, GlbResult, HardwareArtifact, HardwareArtifactService, HardwareArtifactsOptions, HardwareProject, InstallationInfo, Installations, NativeApplication, OpenArtifactRequest, OpenArtifactResult, SourceRequest, SourceResult, groupBomRows, parseCsv };