@huaqiu/dsh-engineering-workbench 0.7.26 → 0.7.27
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/README.md +12 -4
- package/lib/client.js +34314 -787
- package/lib/host.mjs +7809 -0
- package/package.json +6 -5
- package/src/navigation.mjs +0 -31
- package/src/tool.mjs +0 -24
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaqiu/dsh-engineering-workbench",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "华秋工程工作台 · 设计、评审与制造",
|
|
6
|
-
"main": "./
|
|
6
|
+
"main": "./lib/host.mjs",
|
|
7
7
|
"exports": {
|
|
8
|
-
".": "./
|
|
8
|
+
".": "./lib/host.mjs",
|
|
9
9
|
"./client": "./lib/client.js",
|
|
10
10
|
"./package.json": "./package.json",
|
|
11
11
|
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"lib/client.js",
|
|
28
|
-
"
|
|
29
|
-
"src/navigation.mjs",
|
|
28
|
+
"lib/host.mjs",
|
|
30
29
|
"cordis.patch.yml",
|
|
31
30
|
"README.md"
|
|
32
31
|
],
|
|
@@ -34,6 +33,8 @@
|
|
|
34
33
|
"@testing-library/react": "^16.3.2",
|
|
35
34
|
"@types/react": "~18.3.1",
|
|
36
35
|
"@types/react-dom": "^18.3.7",
|
|
36
|
+
"fflate": "0.8.3",
|
|
37
|
+
"gerber-to-svg": "^4.2.8",
|
|
37
38
|
"react": "^18.3.1",
|
|
38
39
|
"react-dom": "^18.3.1"
|
|
39
40
|
},
|
package/src/navigation.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const TOOL = 'hardware_open_workbench'
|
|
2
|
-
export const KIND = 'huaqiu-engineering-workbench'
|
|
3
|
-
export const MODES = ['design', 'review', 'manufacture']
|
|
4
|
-
|
|
5
|
-
export function validRequest(value) {
|
|
6
|
-
return !!value && MODES.includes(value.view)
|
|
7
|
-
&& (value.action === undefined || ['open','suggest'].includes(value.action))
|
|
8
|
-
&& [value.path, value.project, value.reference].every(s => s === undefined || (typeof s === 'string' && s.trim() && s.length <= 4096))
|
|
9
|
-
&& (value.path === undefined || /\.kicad_(pcb|sch)$/i.test(value.path))
|
|
10
|
-
&& (value.project === undefined || /\.kicad_pro$/i.test(value.project))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Read only successful results from our own tool. Identifiers are generated by the host half.
|
|
14
|
-
export function requestsIn(nodes) {
|
|
15
|
-
const requests = new Map()
|
|
16
|
-
const visit = node => {
|
|
17
|
-
if (!node || typeof node !== 'object') return
|
|
18
|
-
if (node.kind === 'tool-result' && node.call?.name === TOOL && Array.isArray(node.content)) {
|
|
19
|
-
for (const block of node.content) {
|
|
20
|
-
if (block.type !== 'text') continue
|
|
21
|
-
try {
|
|
22
|
-
const value = JSON.parse(block.text)
|
|
23
|
-
if (validRequest(value) && typeof value.requestId === 'string' && Number.isFinite(value.issuedAt)) requests.set(value.requestId, value)
|
|
24
|
-
} catch { /* Other presentation blocks carry no navigation. */ }
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
for (const key of ['children', 'nodes', 'subCalls']) if (Array.isArray(node[key])) node[key].forEach(visit)
|
|
28
|
-
}
|
|
29
|
-
nodes.forEach(visit)
|
|
30
|
-
return [...requests.values()]
|
|
31
|
-
}
|
package/src/tool.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto'
|
|
2
|
-
import { TOOL, MODES, validRequest } from './navigation.mjs'
|
|
3
|
-
|
|
4
|
-
export const name = '@huaqiu/dsh-engineering-workbench'
|
|
5
|
-
export const inject = ['tools']
|
|
6
|
-
|
|
7
|
-
export function apply(ctx) {
|
|
8
|
-
ctx.effect(() => ctx.tools.register({
|
|
9
|
-
name: TOOL,
|
|
10
|
-
description: 'Open the engineering workbench in the current conversation’s right pane. Use only when the user asks to open, show, compare or locate an engineering artifact. Choose design for a schematic/PCB, review for side-by-side, manufacture for BOM. Never use for general questions. This is navigation only and does not place orders. Supply the project when multiple KiCad projects exist.',
|
|
11
|
-
parameters: { type: 'object', additionalProperties: false, required: ['view'], properties: {
|
|
12
|
-
view: { type: 'string', enum: MODES },
|
|
13
|
-
action: { type: 'string', enum: ['open','suggest'], description: 'open when explicitly requested; suggest displays a button that the engineer can choose.' },
|
|
14
|
-
path: { type: 'string', description: 'Exact board or sheet path in this workspace, if known.' },
|
|
15
|
-
project: { type: 'string', description: 'Exact KiCad project file, if known.' },
|
|
16
|
-
reference: { type: 'string', description: 'Component reference to inspect or select, such as J1.' },
|
|
17
|
-
}},
|
|
18
|
-
output: { schema: {}, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] },
|
|
19
|
-
async execute(args) {
|
|
20
|
-
if (!validRequest(args)) throw new Error('请选择有效视图和 KiCad 工程文件。')
|
|
21
|
-
return { ...args, requestId: randomUUID(), issuedAt: Date.now() }
|
|
22
|
-
},
|
|
23
|
-
}), 'workbench navigation tool')
|
|
24
|
-
}
|