@huaqiu/hardware-artifacts 0.7.22 → 0.7.24
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 +70 -3
- package/lib/index.mjs +183 -7
- package/lib/{routes-CzTSZSfL.d.mts → routes-DgdeewkN.d.mts} +23 -5
- package/lib/routes.d.mts +1 -1
- package/lib/routes.mjs +3 -3
- package/lib/{service-DQV0soSK.d.mts → service-DDUXPMvb.d.mts} +289 -9
- package/lib/{service-JazWEnwB.mjs → service-DFQ0q0uR.mjs} +734 -53
- package/lib/service.d.mts +2 -2
- package/lib/service.mjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +14 -0
- package/src/kicad-inputs.ts +45 -0
- package/src/order.ts +52 -3
- package/src/quote.ts +488 -0
- package/src/routes.ts +6 -3
- package/src/service.ts +442 -57
- package/src/solidcraft-inputs.ts +44 -0
- package/src/toolchain/manager.ts +36 -6
- package/src/toolchain/resolve.ts +41 -9
- package/src/tools.ts +199 -1
package/src/toolchain/manager.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from './discovery.js'
|
|
22
22
|
import { ToolchainInstaller, type InstallJobSnapshot, type InstallOutcome } from './install.js'
|
|
23
23
|
import { fetchManifest, MANIFEST_URL, type ManifestEntry, type ManifestFailure, type ToolchainManifest } from './manifest.js'
|
|
24
|
+
import { SOLIDCRAFT_INPUT_FORMATS } from '../solidcraft-inputs.js'
|
|
24
25
|
import {
|
|
25
26
|
canonicalPath, installationRootOf, label, normalizeVersion, resolveToolchain,
|
|
26
27
|
type ToolchainId, type ToolchainResolution, type ToolchainSource,
|
|
@@ -60,6 +61,10 @@ export interface ToolStatus {
|
|
|
60
61
|
readonly installPath?: string
|
|
61
62
|
readonly cliPath?: string
|
|
62
63
|
readonly appPath?: string
|
|
64
|
+
/** GUI half present, judged on its own (§6.2). */
|
|
65
|
+
readonly guiAvailable: boolean
|
|
66
|
+
/** CLI half present, judged on its own (§6.2). */
|
|
67
|
+
readonly cliAvailable: boolean
|
|
63
68
|
readonly version?: string
|
|
64
69
|
readonly source?: ToolchainSource
|
|
65
70
|
readonly validatedAt?: number
|
|
@@ -67,6 +72,11 @@ export interface ToolStatus {
|
|
|
67
72
|
readonly discovery: ToolDiscovery
|
|
68
73
|
/** Manifest entry this host could install, when one is available. */
|
|
69
74
|
readonly download?: { readonly version: string; readonly url: string }
|
|
75
|
+
/**
|
|
76
|
+
* Suffixes this tool opens natively, when that is a verified fact rather than
|
|
77
|
+
* an inference. Only SolidCraft publishes one (see `../solidcraft-inputs.ts`).
|
|
78
|
+
*/
|
|
79
|
+
readonly inputFormats?: readonly string[]
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
/** Everything the settings/wizard surface needs, in one poll. */
|
|
@@ -254,6 +264,11 @@ export class ToolchainManager {
|
|
|
254
264
|
const base = {
|
|
255
265
|
tool,
|
|
256
266
|
discovery: this.discovery[tool],
|
|
267
|
+
guiAvailable: resolution.guiAvailable,
|
|
268
|
+
cliAvailable: resolution.cliAvailable,
|
|
269
|
+
// The input list belongs to the tool, not to its installation state: it is
|
|
270
|
+
// a fact about the program, not about this machine.
|
|
271
|
+
...(tool === 'solidcraft' ? { inputFormats: SOLIDCRAFT_INPUT_FORMATS } : {}),
|
|
257
272
|
...(entry === undefined ? {} : { download: { version: entry.version, url: entry.url } }),
|
|
258
273
|
}
|
|
259
274
|
if (resolution.configured) {
|
|
@@ -570,15 +585,28 @@ export class ToolchainManager {
|
|
|
570
585
|
}
|
|
571
586
|
|
|
572
587
|
/**
|
|
573
|
-
* Compact capability facts for the agent (§12.1
|
|
588
|
+
* Compact capability facts for the agent (§12.1 of the toolchain spec, §8 of
|
|
589
|
+
* the 3D/SolidCraft task).
|
|
574
590
|
*
|
|
575
|
-
* Versions and availability only: an agent needs to know whether an export
|
|
576
|
-
* possible, not where the binary lives, and the tools resolve
|
|
577
|
-
* themselves from the same configuration.
|
|
591
|
+
* Versions and availability only: an agent needs to know whether an export or
|
|
592
|
+
* a hand-off is possible, not where the binary lives, and the tools resolve
|
|
593
|
+
* the executable themselves from the same configuration. SolidCraft answers
|
|
594
|
+
* per half — `guiLaunch` is "the document action can hand a file over",
|
|
595
|
+
* `cliAvailable` is "a command can be run" — and lists the formats that are
|
|
596
|
+
* verified inputs rather than the formats this product can preview.
|
|
578
597
|
*/
|
|
579
598
|
async capabilities(): Promise<{
|
|
580
599
|
readonly kicad: { readonly available: boolean; readonly version?: string }
|
|
581
|
-
readonly solidcraft: {
|
|
600
|
+
readonly solidcraft: {
|
|
601
|
+
readonly available: boolean
|
|
602
|
+
readonly version?: string
|
|
603
|
+
/** GUI launch is possible: the executable is present in the configured root. */
|
|
604
|
+
readonly guiLaunch: boolean
|
|
605
|
+
/** The CLI is present and answered its version probe. */
|
|
606
|
+
readonly cliAvailable: boolean
|
|
607
|
+
/** Verified native inputs; never inferred from the document previewer. */
|
|
608
|
+
readonly inputFormats: readonly string[]
|
|
609
|
+
}
|
|
582
610
|
}> {
|
|
583
611
|
const [kicad, solidcraft] = await Promise.all([this.toolStatus('kicad'), this.toolStatus('solidcraft')])
|
|
584
612
|
return {
|
|
@@ -589,7 +617,9 @@ export class ToolchainManager {
|
|
|
589
617
|
solidcraft: {
|
|
590
618
|
available: solidcraft.state === 'configured',
|
|
591
619
|
...(solidcraft.version === undefined ? {} : { version: solidcraft.version }),
|
|
592
|
-
|
|
620
|
+
guiLaunch: solidcraft.state === 'configured' && solidcraft.guiAvailable,
|
|
621
|
+
cliAvailable: solidcraft.state === 'configured' && solidcraft.cliAvailable,
|
|
622
|
+
inputFormats: SOLIDCRAFT_INPUT_FORMATS,
|
|
593
623
|
},
|
|
594
624
|
}
|
|
595
625
|
}
|
package/src/toolchain/resolve.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type ToolchainSource = 'manual' | 'browse' | 'download' | 'detected'
|
|
|
26
26
|
|
|
27
27
|
/** Everything one tool's configuration resolves to. */
|
|
28
28
|
export interface ToolchainResolution {
|
|
29
|
-
/** True only when the
|
|
29
|
+
/** True only when the installation is usable for at least one of its two halves. */
|
|
30
30
|
readonly configured: boolean
|
|
31
31
|
/** Installation root the executables are resolved from. */
|
|
32
32
|
readonly installPath?: string
|
|
@@ -36,6 +36,17 @@ export interface ToolchainResolution {
|
|
|
36
36
|
readonly version?: string
|
|
37
37
|
/** GUI application, when the distribution ships one. */
|
|
38
38
|
readonly app?: string
|
|
39
|
+
/**
|
|
40
|
+
* Whether the GUI half is present, judged independently of the CLI (§6.2).
|
|
41
|
+
*
|
|
42
|
+
* The two executables fail independently in practice — a portable SolidCraft
|
|
43
|
+
* archive can lose `solidcraft-cli.exe` and still open files, and a CLI-only
|
|
44
|
+
* extraction must not be reported as "no installation". `configured` is their
|
|
45
|
+
* union; a caller that needs one half asks about that half.
|
|
46
|
+
*/
|
|
47
|
+
readonly guiAvailable: boolean
|
|
48
|
+
/** Whether the command-line half is present. Independent of {@link guiAvailable}. */
|
|
49
|
+
readonly cliAvailable: boolean
|
|
39
50
|
/** KiCad project manager (`kicad`). */
|
|
40
51
|
readonly projectManager?: string
|
|
41
52
|
/** KiCad schematic editor (`eeschema`). */
|
|
@@ -224,11 +235,12 @@ function isDirectory(path: string): boolean {
|
|
|
224
235
|
/**
|
|
225
236
|
* Resolve one configured root into its executables and validated state.
|
|
226
237
|
*
|
|
227
|
-
* A candidate is configured only after its primary CLI exists *and*
|
|
228
|
-
* version probe (§5.3).
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
238
|
+
* A KiCad candidate is configured only after its primary CLI exists *and*
|
|
239
|
+
* answers a version probe (§5.3). SolidCraft is judged per half: its GUI counts
|
|
240
|
+
* on presence (probing it would open a window) and its CLI on a real `--version`
|
|
241
|
+
* probe, and either half alone keeps the installation usable (§3.1, §6.2 of the
|
|
242
|
+
* 3D/SolidCraft task). `configured` is the union of the two; `guiAvailable` and
|
|
243
|
+
* `cliAvailable` answer "can I launch it" and "can I run it" separately.
|
|
232
244
|
* @param tool - which toolchain to resolve.
|
|
233
245
|
* @param root - configured installation root.
|
|
234
246
|
* @param internals - platform/probe injection.
|
|
@@ -240,7 +252,10 @@ export function resolveToolchain(
|
|
|
240
252
|
internals: ResolveInternals = {},
|
|
241
253
|
): ToolchainResolution {
|
|
242
254
|
if (root === undefined || root.trim() === '') {
|
|
243
|
-
return {
|
|
255
|
+
return {
|
|
256
|
+
configured: false, guiAvailable: false, cliAvailable: false,
|
|
257
|
+
error: `${label(tool)} installation is not configured`,
|
|
258
|
+
}
|
|
244
259
|
}
|
|
245
260
|
const installPath = canonicalPath(root)
|
|
246
261
|
const candidates = executableCandidates(tool, installPath, internals)
|
|
@@ -256,9 +271,15 @@ export function resolveToolchain(
|
|
|
256
271
|
}
|
|
257
272
|
|
|
258
273
|
if (tool === 'kicad') {
|
|
274
|
+
// KiCad's GUI half is its editors; a distribution can ship `kicad-cli` alone
|
|
275
|
+
// (the CI package does), so the two halves are still answered separately.
|
|
276
|
+
const guiAvailable = projectManager !== undefined || pcbEditor !== undefined || schematicEditor !== undefined
|
|
277
|
+
|| app !== undefined
|
|
259
278
|
if (cli === undefined) {
|
|
260
279
|
return {
|
|
261
280
|
configured: false,
|
|
281
|
+
guiAvailable,
|
|
282
|
+
cliAvailable: false,
|
|
262
283
|
installPath,
|
|
263
284
|
...(app === undefined ? {} : { app }),
|
|
264
285
|
...editors,
|
|
@@ -269,6 +290,8 @@ export function resolveToolchain(
|
|
|
269
290
|
if (version === undefined) {
|
|
270
291
|
return {
|
|
271
292
|
configured: false,
|
|
293
|
+
guiAvailable,
|
|
294
|
+
cliAvailable: true,
|
|
272
295
|
installPath,
|
|
273
296
|
cli,
|
|
274
297
|
...(app === undefined ? {} : { app }),
|
|
@@ -278,6 +301,8 @@ export function resolveToolchain(
|
|
|
278
301
|
}
|
|
279
302
|
return {
|
|
280
303
|
configured: true,
|
|
304
|
+
guiAvailable,
|
|
305
|
+
cliAvailable: true,
|
|
281
306
|
installPath,
|
|
282
307
|
cli,
|
|
283
308
|
version,
|
|
@@ -286,13 +311,20 @@ export function resolveToolchain(
|
|
|
286
311
|
}
|
|
287
312
|
}
|
|
288
313
|
|
|
289
|
-
|
|
290
|
-
|
|
314
|
+
// SolidCraft: two independent halves (§6.2). The CLI is *probed*; the GUI is
|
|
315
|
+
// accepted on presence, because probing it would start a window. A CLI that
|
|
316
|
+
// fails its probe does not remove the GUI from the answer.
|
|
317
|
+
const guiAvailable = app !== undefined
|
|
318
|
+
const cliAvailable = cli !== undefined
|
|
319
|
+
if (!guiAvailable && !cliAvailable) {
|
|
320
|
+
return { configured: false, guiAvailable, cliAvailable, installPath, error: `no solidcraft executable under ${installPath}` }
|
|
291
321
|
}
|
|
292
322
|
const probeTarget = cli ?? app
|
|
293
323
|
const version = probeTarget === undefined ? undefined : internals.probeVersion?.(probeTarget, tool)
|
|
294
324
|
return {
|
|
295
325
|
configured: true,
|
|
326
|
+
guiAvailable,
|
|
327
|
+
cliAvailable,
|
|
296
328
|
installPath,
|
|
297
329
|
...(cli === undefined ? {} : { cli }),
|
|
298
330
|
...(app === undefined ? {} : { app }),
|
package/src/tools.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* hardware_projects which projects/boards this workspace has, and
|
|
5
5
|
* whether a `kicad-cli` can export from them
|
|
6
6
|
* hardware_bom the grouped BOM of one root schematic
|
|
7
|
+
* hardware_quote_pcb real-time PCB fabrication price (no order)
|
|
8
|
+
* hardware_quote_smt real-time SMT assembly price (no order)
|
|
7
9
|
* hardware_fabricate gerber + drill (+ assembly inputs), validated
|
|
8
10
|
* hardware_place_pcb_order upload the package and enter the hqpcb order flow
|
|
9
11
|
* hardware_place_smt_order the same for assembly (board zip + BOM + positions)
|
|
@@ -16,6 +18,12 @@
|
|
|
16
18
|
* how a working order turned into `403 artifact is outside the authorized
|
|
17
19
|
* workspace`.
|
|
18
20
|
*
|
|
21
|
+
* The two quote tools answer "how much?" without touching any of that: they
|
|
22
|
+
* read the board file, post the form to the vendor's anonymous valuation
|
|
23
|
+
* endpoint and return the itemized price. No `kicad-cli`, no upload, no order,
|
|
24
|
+
* no confirmation — asking what something costs must never cost the user an
|
|
25
|
+
* order page.
|
|
26
|
+
*
|
|
19
27
|
* Every name is prefixed with this plugin's own `hardware_` namespace. The
|
|
20
28
|
* order tools deliberately do not reuse `@huaqiu/dsh-tool-quote`'s bare
|
|
21
29
|
* `place_pcb_order`/`place_smt_order`: that plugin drives the EDA host's own
|
|
@@ -39,7 +47,7 @@
|
|
|
39
47
|
|
|
40
48
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
41
49
|
import { isAbsolute, resolve } from 'node:path'
|
|
42
|
-
import type { HardwareArtifactService, HardwareProject } from './service.js'
|
|
50
|
+
import type { HardwareArtifactService, HardwareProject, QuotePcbResult, QuoteSmtResult } from './service.js'
|
|
43
51
|
|
|
44
52
|
/** Structural alias of the DSH `JsonValue`. */
|
|
45
53
|
type Json = string | number | boolean | null | Json[] | { [key: string]: Json }
|
|
@@ -163,6 +171,73 @@ function placedOrderJson(placed: {
|
|
|
163
171
|
})
|
|
164
172
|
}
|
|
165
173
|
|
|
174
|
+
/** One line an agent can relay without re-doing the arithmetic. */
|
|
175
|
+
function priceLine(
|
|
176
|
+
symbol: string,
|
|
177
|
+
quantity: number,
|
|
178
|
+
totalPrice: number,
|
|
179
|
+
unitPrice: number,
|
|
180
|
+
what: string,
|
|
181
|
+
leadTimeDays?: number,
|
|
182
|
+
): string {
|
|
183
|
+
const each = quantity > 1 ? ` (${symbol}${unitPrice.toFixed(2)} each)` : ''
|
|
184
|
+
const lead = leadTimeDays === undefined ? '' : `, lead time ${String(leadTimeDays)} days`
|
|
185
|
+
return `${symbol}${totalPrice.toFixed(2)} for ${String(quantity)} ${quantity === 1 ? 'board' : 'boards'}${what}${each}${lead}`
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** A PCB price: the price, the facts it came from, and the form that was sent. */
|
|
189
|
+
function pcbQuoteJson(quote: QuotePcbResult): Json {
|
|
190
|
+
return asJson({
|
|
191
|
+
ok: true,
|
|
192
|
+
kind: quote.kind,
|
|
193
|
+
summary: priceLine(
|
|
194
|
+
quote.currencySymbol, quote.quantity, quote.totalPrice, quote.unitPrice, '',
|
|
195
|
+
quote.leadTimeDays,
|
|
196
|
+
),
|
|
197
|
+
boardPath: quote.boardPath,
|
|
198
|
+
generatedAt: quote.generatedAt,
|
|
199
|
+
endpoint: quote.endpoint,
|
|
200
|
+
price: {
|
|
201
|
+
currency: quote.currency,
|
|
202
|
+
currencySymbol: quote.currencySymbol,
|
|
203
|
+
quantity: quote.quantity,
|
|
204
|
+
totalPrice: quote.totalPrice,
|
|
205
|
+
unitPrice: quote.unitPrice,
|
|
206
|
+
...(quote.shipping === undefined ? {} : { shipping: quote.shipping }),
|
|
207
|
+
...(quote.leadTimeDays === undefined ? {} : { leadTimeDays: quote.leadTimeDays }),
|
|
208
|
+
items: quote.items,
|
|
209
|
+
delivery: quote.delivery,
|
|
210
|
+
},
|
|
211
|
+
facts: quote.facts,
|
|
212
|
+
form: quote.form,
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** An assembly price. The tax split the CN body reports is kept explicit. */
|
|
217
|
+
function smtQuoteJson(quote: QuoteSmtResult): Json {
|
|
218
|
+
return asJson({
|
|
219
|
+
ok: true,
|
|
220
|
+
kind: quote.kind,
|
|
221
|
+
summary: priceLine(
|
|
222
|
+
quote.currencySymbol, quote.quantity, quote.totalPrice, quote.unitPrice, ' assembled',
|
|
223
|
+
),
|
|
224
|
+
boardPath: quote.boardPath,
|
|
225
|
+
generatedAt: quote.generatedAt,
|
|
226
|
+
endpoint: quote.endpoint,
|
|
227
|
+
price: {
|
|
228
|
+
currency: quote.currency,
|
|
229
|
+
currencySymbol: quote.currencySymbol,
|
|
230
|
+
quantity: quote.quantity,
|
|
231
|
+
totalPrice: quote.totalPrice,
|
|
232
|
+
unitPrice: quote.unitPrice,
|
|
233
|
+
items: quote.items,
|
|
234
|
+
smt: quote.smt,
|
|
235
|
+
},
|
|
236
|
+
facts: quote.facts,
|
|
237
|
+
form: quote.form,
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
|
|
166
241
|
export function createHardwareTools(env: HardwareToolEnv) {
|
|
167
242
|
const { service } = env
|
|
168
243
|
|
|
@@ -274,6 +349,127 @@ export function createHardwareTools(env: HardwareToolEnv) {
|
|
|
274
349
|
}
|
|
275
350
|
},
|
|
276
351
|
}),
|
|
352
|
+
defineTool({
|
|
353
|
+
name: 'hardware_quote_pcb',
|
|
354
|
+
description:
|
|
355
|
+
'Get the real-time PCB fabrication price of one .kicad_pcb. Price only: nothing is ' +
|
|
356
|
+
'uploaded, no order is created, and no confirmation is needed — use this whenever the ' +
|
|
357
|
+
'user asks what a board would cost ("多少钱", "报价", "打样价格", "how much"), or wants to ' +
|
|
358
|
+
'compare quantity, layer count, thickness, colour or finish. Reads the board file itself ' +
|
|
359
|
+
'(outline size, copper layers, design thickness, min track, min hole, copper weight), so ' +
|
|
360
|
+
'no KiCad installation and no `kicad-cli` run are involved. Prices through Huaqiu China ' +
|
|
361
|
+
'(¥), the same origin hardware_place_pcb_order submits to, and the total INCLUDES ' +
|
|
362
|
+
'shipping. Returns summary (one relay-able line), price.totalPrice, price.unitPrice, ' +
|
|
363
|
+
'price.leadTimeDays, the itemized fees under the vendor\'s own keys, the delivery options, ' +
|
|
364
|
+
'and the effective `form`. Inspect that form and re-query with an override rather than ' +
|
|
365
|
+
'guessing: `layers` prices a what-if stack-up, `quantity` a different run size. Always ' +
|
|
366
|
+
'state the quantity the total covers. This is a quote, not an order — when the user ' +
|
|
367
|
+
'decides to buy, that is hardware_place_pcb_order with confirm true.',
|
|
368
|
+
parameters: {
|
|
369
|
+
path: {
|
|
370
|
+
type: 'string' as const,
|
|
371
|
+
required: true as const,
|
|
372
|
+
description: 'Board (.kicad_pcb) path, absolute or relative to the workspace.',
|
|
373
|
+
},
|
|
374
|
+
quantity: {
|
|
375
|
+
type: 'integer' as const,
|
|
376
|
+
description:
|
|
377
|
+
'Boards to price (default 5). `price.totalPrice` covers this many boards and ' +
|
|
378
|
+
'`price.unitPrice` is per board.',
|
|
379
|
+
},
|
|
380
|
+
layers: {
|
|
381
|
+
type: 'integer' as const,
|
|
382
|
+
description:
|
|
383
|
+
'Price a different copper layer count than the file has, e.g. 4 for a 2-layer design. ' +
|
|
384
|
+
'The thickness menu, inner copper and TG grade follow that count. Omit to price the ' +
|
|
385
|
+
'board as designed.',
|
|
386
|
+
},
|
|
387
|
+
thickness_mm: {
|
|
388
|
+
type: 'number' as const,
|
|
389
|
+
description:
|
|
390
|
+
'Board thickness in mm, snapped onto the fabricator\'s menu for the layer count. ' +
|
|
391
|
+
'Omit to use the thickness recorded in the board file.',
|
|
392
|
+
},
|
|
393
|
+
color: {
|
|
394
|
+
type: 'string' as const,
|
|
395
|
+
enum: ['green', 'red', 'yellow', 'blue', 'white', 'black', 'matte_black'],
|
|
396
|
+
description: 'Solder mask colour. Default green (the order form\'s default).',
|
|
397
|
+
},
|
|
398
|
+
surface_finish: {
|
|
399
|
+
type: 'string' as const,
|
|
400
|
+
enum: ['hasl_lf', 'hasl_lead', 'enig', 'osp'],
|
|
401
|
+
description:
|
|
402
|
+
'Surface finish. Default hasl_lf (lead-free HASL); enig (ENIG) is the pricier upgrade ' +
|
|
403
|
+
'a user usually asks about.',
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
output: { schema: { type: 'json' }, render: renderJson },
|
|
407
|
+
async execute(args: unknown, exec: ToolExecLike): Promise<Json> {
|
|
408
|
+
const a = (args ?? {}) as Record<string, unknown>
|
|
409
|
+
try {
|
|
410
|
+
const cwd = await workspaceOf(env, exec)
|
|
411
|
+
const quote = await service.quotePcb({
|
|
412
|
+
boardPath: resolveUnder(cwd, a.path),
|
|
413
|
+
...(typeof a.quantity === 'number' ? { quantity: a.quantity } : {}),
|
|
414
|
+
...(typeof a.layers === 'number' ? { layers: a.layers } : {}),
|
|
415
|
+
...(typeof a.thickness_mm === 'number' ? { thicknessMm: a.thickness_mm } : {}),
|
|
416
|
+
...(typeof a.color === 'string' ? { color: a.color as never } : {}),
|
|
417
|
+
...(typeof a.surface_finish === 'string' ? { surfaceFinish: a.surface_finish as never } : {}),
|
|
418
|
+
...(exec.signal === undefined ? {} : { signal: exec.signal }),
|
|
419
|
+
})
|
|
420
|
+
return pcbQuoteJson(quote)
|
|
421
|
+
} catch (error) {
|
|
422
|
+
return failure(error)
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
}),
|
|
426
|
+
defineTool({
|
|
427
|
+
name: 'hardware_quote_smt',
|
|
428
|
+
description:
|
|
429
|
+
'Get the real-time SMT assembly price of one .kicad_pcb. Price only: no BOM is required, ' +
|
|
430
|
+
'nothing is uploaded and no order is created. Use when the user asks about assembly or ' +
|
|
431
|
+
'placement cost ("贴片多少钱", "SMT 报价", "焊接费用", "assembly cost"). The pad counts ' +
|
|
432
|
+
'(SMD pads, plated holes) and the distinct value/footprint pairs are read from the ' +
|
|
433
|
+
'board\'s own footprints, so no BOM export, no KiCad installation and no `kicad-cli` run ' +
|
|
434
|
+
'are involved. Prices through Huaqiu China (¥). Returns price.totalPrice (tax included), ' +
|
|
435
|
+
'price.unitPrice, the itemized assembly fees (stencil, placement, soldering, X-ray …) and ' +
|
|
436
|
+
'`price.smt` with the endpoint\'s net/tax split, plus the effective `form`. The price is ' +
|
|
437
|
+
'labour + fixtures for the quantity given: it does NOT include component cost, because no ' +
|
|
438
|
+
'part list is supplied — say so instead of implying a complete turnkey quote. Quote, not ' +
|
|
439
|
+
'order: hardware_place_smt_order places it.',
|
|
440
|
+
parameters: {
|
|
441
|
+
path: {
|
|
442
|
+
type: 'string' as const,
|
|
443
|
+
required: true as const,
|
|
444
|
+
description: 'Board (.kicad_pcb) path, absolute or relative to the workspace.',
|
|
445
|
+
},
|
|
446
|
+
quantity: {
|
|
447
|
+
type: 'integer' as const,
|
|
448
|
+
description: 'Assembled quantity (default 5). totalPrice covers this many boards.',
|
|
449
|
+
},
|
|
450
|
+
sides: {
|
|
451
|
+
type: 'string' as const,
|
|
452
|
+
enum: ['single', 'double'],
|
|
453
|
+
description: 'Single-side or double-side assembly. Default double (the reference default).',
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
output: { schema: { type: 'json' }, render: renderJson },
|
|
457
|
+
async execute(args: unknown, exec: ToolExecLike): Promise<Json> {
|
|
458
|
+
const a = (args ?? {}) as Record<string, unknown>
|
|
459
|
+
try {
|
|
460
|
+
const cwd = await workspaceOf(env, exec)
|
|
461
|
+
const quote = await service.quoteSmt({
|
|
462
|
+
boardPath: resolveUnder(cwd, a.path),
|
|
463
|
+
...(typeof a.quantity === 'number' ? { quantity: a.quantity } : {}),
|
|
464
|
+
...(a.sides === 'single' || a.sides === 'double' ? { sides: a.sides } : {}),
|
|
465
|
+
...(exec.signal === undefined ? {} : { signal: exec.signal }),
|
|
466
|
+
})
|
|
467
|
+
return smtQuoteJson(quote)
|
|
468
|
+
} catch (error) {
|
|
469
|
+
return failure(error)
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
}),
|
|
277
473
|
defineTool({
|
|
278
474
|
name: 'hardware_fabricate',
|
|
279
475
|
description:
|
|
@@ -459,6 +655,8 @@ export function hardwareToolNames(): string[] {
|
|
|
459
655
|
return [
|
|
460
656
|
'hardware_projects',
|
|
461
657
|
'hardware_bom',
|
|
658
|
+
'hardware_quote_pcb',
|
|
659
|
+
'hardware_quote_smt',
|
|
462
660
|
'hardware_fabricate',
|
|
463
661
|
'hardware_place_pcb_order',
|
|
464
662
|
'hardware_place_smt_order',
|