@huaqiu/dsh-analytics 0.6.8 → 0.6.10
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 +1 -1
- package/lib/index.mjs +35 -5
- package/package.json +3 -3
- package/src/generated/builtin-tools.ts +21 -0
- package/src/index.ts +2 -2
- package/src/tool-events.ts +17 -4
package/lib/index.d.mts
CHANGED
|
@@ -5,7 +5,6 @@ interface AnalyticsEvent {
|
|
|
5
5
|
event: string;
|
|
6
6
|
properties?: Record<string, unknown>;
|
|
7
7
|
}
|
|
8
|
-
declare function isTrackedTool(name: string): boolean;
|
|
9
8
|
interface ToolExecutionLike {
|
|
10
9
|
callId: string | {
|
|
11
10
|
toString(): string;
|
|
@@ -13,6 +12,7 @@ interface ToolExecutionLike {
|
|
|
13
12
|
name: string;
|
|
14
13
|
arguments?: unknown;
|
|
15
14
|
}
|
|
15
|
+
declare function isTrackedTool(tool: string | ToolExecutionLike): boolean;
|
|
16
16
|
interface ToolResultLike {
|
|
17
17
|
isError: boolean;
|
|
18
18
|
error?: {
|
package/lib/index.mjs
CHANGED
|
@@ -18,6 +18,13 @@ function createAnalyticsHandler(queue) {
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/generated/builtin-tools.ts
|
|
20
20
|
const BUILTIN_TOOLS = [
|
|
21
|
+
"analyze_kicad_module",
|
|
22
|
+
"create_kicad_hierarchy",
|
|
23
|
+
"download_eda_module_schematic",
|
|
24
|
+
"eda_module_category_search",
|
|
25
|
+
"eda_module_precise_search",
|
|
26
|
+
"eda_module_rag_search",
|
|
27
|
+
"edit_kicad_flat_schematic",
|
|
21
28
|
"generate_footprint_from_dimensions",
|
|
22
29
|
"generate_footprint_from_image",
|
|
23
30
|
"generate_symbol_from_image",
|
|
@@ -28,10 +35,16 @@ const BUILTIN_TOOLS = [
|
|
|
28
35
|
"get_hqsch_part",
|
|
29
36
|
"get_hqsch_part_models",
|
|
30
37
|
"get_hqsch_supply_chain",
|
|
38
|
+
"get_kicad_component_models",
|
|
39
|
+
"get_kicad_datasheet",
|
|
40
|
+
"get_kicad_module_ports",
|
|
31
41
|
"get_pcb_board",
|
|
32
42
|
"get_pcb_selection",
|
|
33
43
|
"get_project_netlist",
|
|
34
44
|
"get_selection_netlist",
|
|
45
|
+
"import_kicad_component",
|
|
46
|
+
"import_kicad_symbol",
|
|
47
|
+
"kicad_drc_run",
|
|
35
48
|
"kicad_ipc_diagnose",
|
|
36
49
|
"kicad_ipc_verify_live",
|
|
37
50
|
"kicad_pcb_add_footprint_from_template",
|
|
@@ -42,14 +55,22 @@ const BUILTIN_TOOLS = [
|
|
|
42
55
|
"kicad_pcb_refill_zones",
|
|
43
56
|
"kicad_pcb_remove_selected_items",
|
|
44
57
|
"kicad_pcb_update_selected_track_width",
|
|
58
|
+
"localize_kicad_module_footprints",
|
|
45
59
|
"match_bom",
|
|
60
|
+
"pcb_cancel_route",
|
|
61
|
+
"pcb_confirm_board_checked",
|
|
46
62
|
"pcb_preview",
|
|
63
|
+
"pcb_repair_route",
|
|
64
|
+
"pcb_route",
|
|
65
|
+
"pcb_route_nets",
|
|
47
66
|
"place_pcb_order",
|
|
48
67
|
"place_smt_order",
|
|
49
68
|
"quote_pcb",
|
|
50
69
|
"quote_smt",
|
|
70
|
+
"render_kicad_module_preview",
|
|
51
71
|
"run_erc",
|
|
52
|
-
"search_hqsch_parts"
|
|
72
|
+
"search_hqsch_parts",
|
|
73
|
+
"sync_schematic_to_pcb"
|
|
53
74
|
];
|
|
54
75
|
//#endregion
|
|
55
76
|
//#region src/tool-events.ts
|
|
@@ -61,14 +82,23 @@ function createTrackedToolSet(builtinTools, extraTools, excludedTools) {
|
|
|
61
82
|
return tracked;
|
|
62
83
|
}
|
|
63
84
|
const TRACKED_TOOLS = createTrackedToolSet(BUILTIN_TOOLS, EXTRA_TRACKED_TOOLS, EXCLUDED_TRACKED_TOOLS);
|
|
64
|
-
|
|
65
|
-
|
|
85
|
+
const TRACKED_SKILLS = /* @__PURE__ */ new Set(["pcb-initial-placement"]);
|
|
86
|
+
function skillName(exec) {
|
|
87
|
+
if (exec.name !== "skill" || typeof exec.arguments !== "object" || exec.arguments === null) return;
|
|
88
|
+
const name = exec.arguments.name;
|
|
89
|
+
return typeof name === "string" && name.length > 0 ? name : void 0;
|
|
90
|
+
}
|
|
91
|
+
function isTrackedTool(tool) {
|
|
92
|
+
if (typeof tool === "string") return TRACKED_TOOLS.has(tool);
|
|
93
|
+
return TRACKED_TOOLS.has(tool.name) || TRACKED_SKILLS.has(skillName(tool) ?? "");
|
|
66
94
|
}
|
|
67
95
|
function toToolAnalyticsEvent(exec, result, responseTime) {
|
|
96
|
+
const skill = skillName(exec);
|
|
68
97
|
return {
|
|
69
98
|
event: "tool_call",
|
|
70
99
|
properties: {
|
|
71
100
|
tool_name: exec.name,
|
|
101
|
+
...skill === void 0 ? {} : { skill_name: skill },
|
|
72
102
|
success: !result.isError,
|
|
73
103
|
response_time: responseTime,
|
|
74
104
|
err_msg: result.isError ? String(result.error?.message ?? "") : ""
|
|
@@ -105,11 +135,11 @@ function apply(ctx) {
|
|
|
105
135
|
handler: createAnalyticsHandler(queue)
|
|
106
136
|
}));
|
|
107
137
|
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
108
|
-
if (isTrackedTool(exec
|
|
138
|
+
if (isTrackedTool(exec)) toolStartTimes.set(exec, Date.now());
|
|
109
139
|
return next();
|
|
110
140
|
});
|
|
111
141
|
ctx.on("tools/result", (exec, result) => {
|
|
112
|
-
if (!isTrackedTool(exec
|
|
142
|
+
if (!isTrackedTool(exec)) return;
|
|
113
143
|
const startedAt = toolStartTimes.get(exec);
|
|
114
144
|
toolStartTimes.delete(exec);
|
|
115
145
|
const event = toToolAnalyticsEvent(exec, result, startedAt === void 0 ? 0 : Date.now() - startedAt);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaqiu/dsh-analytics",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Huaqiu Sensors Analytics integration for DeepSeek Harness",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.mjs",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"sa-sdk-javascript": "1.16.16",
|
|
38
|
-
"@huaqiu/dsh-
|
|
39
|
-
"@huaqiu/dsh-
|
|
38
|
+
"@huaqiu/dsh-plugin-log": "0.6.10",
|
|
39
|
+
"@huaqiu/dsh-auth": "0.6.10"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"lib",
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
// Generated by scripts/generate-analytics-tools.mjs. Do not edit by hand.
|
|
2
2
|
export const BUILTIN_TOOLS = [
|
|
3
|
+
"analyze_kicad_module",
|
|
4
|
+
"create_kicad_hierarchy",
|
|
5
|
+
"download_eda_module_schematic",
|
|
6
|
+
"eda_module_category_search",
|
|
7
|
+
"eda_module_precise_search",
|
|
8
|
+
"eda_module_rag_search",
|
|
9
|
+
"edit_kicad_flat_schematic",
|
|
3
10
|
"generate_footprint_from_dimensions",
|
|
4
11
|
"generate_footprint_from_image",
|
|
5
12
|
"generate_symbol_from_image",
|
|
@@ -10,10 +17,16 @@ export const BUILTIN_TOOLS = [
|
|
|
10
17
|
"get_hqsch_part",
|
|
11
18
|
"get_hqsch_part_models",
|
|
12
19
|
"get_hqsch_supply_chain",
|
|
20
|
+
"get_kicad_component_models",
|
|
21
|
+
"get_kicad_datasheet",
|
|
22
|
+
"get_kicad_module_ports",
|
|
13
23
|
"get_pcb_board",
|
|
14
24
|
"get_pcb_selection",
|
|
15
25
|
"get_project_netlist",
|
|
16
26
|
"get_selection_netlist",
|
|
27
|
+
"import_kicad_component",
|
|
28
|
+
"import_kicad_symbol",
|
|
29
|
+
"kicad_drc_run",
|
|
17
30
|
"kicad_ipc_diagnose",
|
|
18
31
|
"kicad_ipc_verify_live",
|
|
19
32
|
"kicad_pcb_add_footprint_from_template",
|
|
@@ -24,12 +37,20 @@ export const BUILTIN_TOOLS = [
|
|
|
24
37
|
"kicad_pcb_refill_zones",
|
|
25
38
|
"kicad_pcb_remove_selected_items",
|
|
26
39
|
"kicad_pcb_update_selected_track_width",
|
|
40
|
+
"localize_kicad_module_footprints",
|
|
27
41
|
"match_bom",
|
|
42
|
+
"pcb_cancel_route",
|
|
43
|
+
"pcb_confirm_board_checked",
|
|
28
44
|
"pcb_preview",
|
|
45
|
+
"pcb_repair_route",
|
|
46
|
+
"pcb_route",
|
|
47
|
+
"pcb_route_nets",
|
|
29
48
|
"place_pcb_order",
|
|
30
49
|
"place_smt_order",
|
|
31
50
|
"quote_pcb",
|
|
32
51
|
"quote_smt",
|
|
52
|
+
"render_kicad_module_preview",
|
|
33
53
|
"run_erc",
|
|
34
54
|
"search_hqsch_parts",
|
|
55
|
+
"sync_schematic_to_pcb",
|
|
35
56
|
] as const
|
package/src/index.ts
CHANGED
|
@@ -35,12 +35,12 @@ export function apply(ctx: Context): void {
|
|
|
35
35
|
handler: createAnalyticsHandler(queue),
|
|
36
36
|
}))
|
|
37
37
|
ctx.on('tools/pre-execute', async (exec, next) => {
|
|
38
|
-
const tracked = isTrackedTool(exec
|
|
38
|
+
const tracked = isTrackedTool(exec)
|
|
39
39
|
if (tracked) toolStartTimes.set(exec, Date.now())
|
|
40
40
|
return next()
|
|
41
41
|
})
|
|
42
42
|
ctx.on('tools/result', (exec, result) => {
|
|
43
|
-
const tracked = isTrackedTool(exec
|
|
43
|
+
const tracked = isTrackedTool(exec)
|
|
44
44
|
if (!tracked) return
|
|
45
45
|
const startedAt = toolStartTimes.get(exec)
|
|
46
46
|
toolStartTimes.delete(exec)
|
package/src/tool-events.ts
CHANGED
|
@@ -28,16 +28,27 @@ const TRACKED_TOOLS = createTrackedToolSet(
|
|
|
28
28
|
EXCLUDED_TRACKED_TOOLS,
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
export function isTrackedTool(name: string): boolean {
|
|
32
|
-
return TRACKED_TOOLS.has(name)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
31
|
interface ToolExecutionLike {
|
|
36
32
|
callId: string | { toString(): string }
|
|
37
33
|
name: string
|
|
38
34
|
arguments?: unknown
|
|
39
35
|
}
|
|
40
36
|
|
|
37
|
+
const TRACKED_SKILLS = new Set(['pcb-initial-placement'])
|
|
38
|
+
|
|
39
|
+
function skillName(exec: ToolExecutionLike): string | undefined {
|
|
40
|
+
if (exec.name !== 'skill' || typeof exec.arguments !== 'object' || exec.arguments === null) {
|
|
41
|
+
return undefined
|
|
42
|
+
}
|
|
43
|
+
const name = (exec.arguments as { name?: unknown }).name
|
|
44
|
+
return typeof name === 'string' && name.length > 0 ? name : undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isTrackedTool(tool: string | ToolExecutionLike): boolean {
|
|
48
|
+
if (typeof tool === 'string') return TRACKED_TOOLS.has(tool)
|
|
49
|
+
return TRACKED_TOOLS.has(tool.name) || TRACKED_SKILLS.has(skillName(tool) ?? '')
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
interface ToolResultLike {
|
|
42
53
|
isError: boolean
|
|
43
54
|
error?: { message?: unknown }
|
|
@@ -49,10 +60,12 @@ export function toToolAnalyticsEvent(
|
|
|
49
60
|
result: ToolResultLike,
|
|
50
61
|
responseTime: number,
|
|
51
62
|
): AnalyticsEvent {
|
|
63
|
+
const skill = skillName(exec)
|
|
52
64
|
return {
|
|
53
65
|
event: 'tool_call',
|
|
54
66
|
properties: {
|
|
55
67
|
tool_name: exec.name,
|
|
68
|
+
...(skill === undefined ? {} : { skill_name: skill }),
|
|
56
69
|
success: !result.isError,
|
|
57
70
|
response_time: responseTime,
|
|
58
71
|
err_msg: result.isError ? String(result.error?.message ?? '') : '',
|