@hpmicro-tools/hpmmfgctl 0.0.0-stage → 0.0.1

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -2
  3. package/README.zh-CN.md +197 -0
  4. package/dist/command/arguments.d.ts +3 -0
  5. package/dist/command/arguments.js +18 -0
  6. package/dist/command/arguments.js.map +1 -0
  7. package/dist/command/runner.d.ts +22 -0
  8. package/dist/command/runner.js +119 -0
  9. package/dist/command/runner.js.map +1 -0
  10. package/dist/command/types.d.ts +37 -0
  11. package/dist/command/types.js +2 -0
  12. package/dist/command/types.js.map +1 -0
  13. package/dist/command/validate.d.ts +4 -0
  14. package/dist/command/validate.js +48 -0
  15. package/dist/command/validate.js.map +1 -0
  16. package/dist/config/config-path.d.ts +8 -0
  17. package/dist/config/config-path.js +27 -0
  18. package/dist/config/config-path.js.map +1 -0
  19. package/dist/config/config-store.d.ts +13 -0
  20. package/dist/config/config-store.js +61 -0
  21. package/dist/config/config-store.js.map +1 -0
  22. package/dist/config/config-type.d.ts +5 -0
  23. package/dist/config/config-type.js +2 -0
  24. package/dist/config/config-type.js.map +1 -0
  25. package/dist/device/enumerator.d.ts +12 -0
  26. package/dist/device/enumerator.js +65 -0
  27. package/dist/device/enumerator.js.map +1 -0
  28. package/dist/device/types.d.ts +22 -0
  29. package/dist/device/types.js +2 -0
  30. package/dist/device/types.js.map +1 -0
  31. package/dist/hpm-mfg-service.d.ts +37 -0
  32. package/dist/hpm-mfg-service.js +155 -0
  33. package/dist/hpm-mfg-service.js.map +1 -0
  34. package/dist/main.d.ts +2 -0
  35. package/dist/main.js +23 -0
  36. package/dist/main.js.map +1 -0
  37. package/dist/mcp/configuration.d.ts +4 -0
  38. package/dist/mcp/configuration.js +30 -0
  39. package/dist/mcp/configuration.js.map +1 -0
  40. package/dist/mcp/discovery.d.ts +4 -0
  41. package/dist/mcp/discovery.js +30 -0
  42. package/dist/mcp/discovery.js.map +1 -0
  43. package/dist/mcp/mcp-type.d.ts +11 -0
  44. package/dist/mcp/mcp-type.js +2 -0
  45. package/dist/mcp/mcp-type.js.map +1 -0
  46. package/dist/mcp/operations.d.ts +4 -0
  47. package/dist/mcp/operations.js +17 -0
  48. package/dist/mcp/operations.js.map +1 -0
  49. package/dist/mcp/registration.d.ts +15 -0
  50. package/dist/mcp/registration.js +23 -0
  51. package/dist/mcp/registration.js.map +1 -0
  52. package/dist/mcp/responses.d.ts +5 -0
  53. package/dist/mcp/responses.js +20 -0
  54. package/dist/mcp/responses.js.map +1 -0
  55. package/dist/mcp/schemas.d.ts +155 -0
  56. package/dist/mcp/schemas.js +253 -0
  57. package/dist/mcp/schemas.js.map +1 -0
  58. package/dist/mcp/server.d.ts +4 -0
  59. package/dist/mcp/server.js +16 -0
  60. package/dist/mcp/server.js.map +1 -0
  61. package/dist/operations/rom.d.ts +5 -0
  62. package/dist/operations/rom.js +81 -0
  63. package/dist/operations/rom.js.map +1 -0
  64. package/dist/service-type.d.ts +13 -0
  65. package/dist/service-type.js +2 -0
  66. package/dist/service-type.js.map +1 -0
  67. package/package.json +51 -4
@@ -0,0 +1,11 @@
1
+ import type { z as zod } from "zod";
2
+ import type { romSchemas } from "./schemas.js";
3
+ /** ROM operation names used by registration, timeout selection, and command building. */
4
+ export type ROMName = keyof typeof romSchemas;
5
+ /** Validated ROM input inferred from the schemas used to register MCP tools. */
6
+ export type ROMInput = zod.infer<(typeof romSchemas)[ROMName]>;
7
+ /** Parsed ROM request and the single ROM command string passed to CMD. */
8
+ export interface ROMCommand {
9
+ input: ROMInput;
10
+ command: string;
11
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mcp-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-type.js","sourceRoot":"","sources":["../../src/mcp/mcp-type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/server";
2
+ import type { Service } from "../hpm-mfg-service.js";
3
+ /** Registers ROM tools with the same constraints used by command construction. */
4
+ export declare function registerOperationTools(server: McpServer, service: Service): void;
@@ -0,0 +1,17 @@
1
+ import { romSchemas } from "./schemas.js";
2
+ import { registerTool } from "./registration.js";
3
+ /** Registers ROM tools with the same constraints used by command construction. */
4
+ export function registerOperationTools(server, service) {
5
+ for (const name of Object.keys(romSchemas)) {
6
+ const readOnly = /^(query|read|verify)/.test(name) && name !== "read_memory_to_file";
7
+ const destructive = !/^(query|read|verify)/.test(name) || name === "read_memory_to_file";
8
+ const fileWarning = name === "read_memory_to_file" ? "; writes a local file and may overwrite it" : "";
9
+ registerTool(server, `rom.${name}`, {
10
+ description: `${name.replaceAll("_", " ")} through the installed Manufacturing CMD${fileWarning}`,
11
+ inputSchema: romSchemas[name],
12
+ readOnly,
13
+ destructive,
14
+ }, (input, signal) => service.rom(name, input, signal));
15
+ }
16
+ }
17
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/mcp/operations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CAAC,MAAiB,EAAE,OAAgB;IACxE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAc,EAAE,CAAC;QACxD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,qBAAqB,CAAC;QACrF,MAAM,WAAW,GAAG,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,qBAAqB,CAAC;QACzF,MAAM,WAAW,GACf,IAAI,KAAK,qBAAqB,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,EAAE,CAAC;QAErF,YAAY,CACV,MAAM,EACN,OAAO,IAAI,EAAE,EACb;YACE,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,2CAA2C,WAAW,EAAE;YACjG,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC;YAC7B,QAAQ;YACR,WAAW;SACZ,EACD,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CACpD,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { McpServer } from "@modelcontextprotocol/server";
2
+ import type { z as zod } from "zod";
3
+ /** Tool metadata kept separate from its business operation. */
4
+ export interface ToolDefinition<Schema extends zod.ZodObject> {
5
+ /** Human-readable tool behavior shown to the agent. */
6
+ description: string;
7
+ /** Runtime validation and JSON schema source for tool inputs. */
8
+ inputSchema: Schema;
9
+ /** Whether the operation leaves hardware and local files unchanged. */
10
+ readOnly: boolean;
11
+ /** Whether the operation can alter hardware state or overwrite local data. */
12
+ destructive: boolean;
13
+ }
14
+ /** Registers a typed operation with shared input validation and response formatting. */
15
+ export declare function registerTool<Schema extends zod.ZodObject>(server: McpServer, name: string, definition: ToolDefinition<Schema>, handler: (input: zod.infer<Schema>, signal?: AbortSignal) => Promise<Record<string, unknown>> | Record<string, unknown>): void;
@@ -0,0 +1,23 @@
1
+ import { errorResponse, structuredResponse } from "./responses.js";
2
+ /** Registers a typed operation with shared input validation and response formatting. */
3
+ export function registerTool(server, name, definition, handler) {
4
+ const callback = async (input, context) => {
5
+ try {
6
+ const validatedInput = definition.inputSchema.parse(input);
7
+ return structuredResponse(await handler(validatedInput, context.mcpReq.signal));
8
+ }
9
+ catch (error) {
10
+ return errorResponse(error);
11
+ }
12
+ };
13
+ server.registerTool(name, {
14
+ description: definition.description,
15
+ inputSchema: definition.inputSchema,
16
+ annotations: {
17
+ readOnlyHint: definition.readOnly,
18
+ destructiveHint: definition.destructive,
19
+ openWorldHint: false,
20
+ },
21
+ }, callback);
22
+ }
23
+ //# sourceMappingURL=registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/mcp/registration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAcnE,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAC1B,MAAiB,EACjB,IAAY,EACZ,UAAkC,EAClC,OAG+D;IAE/D,MAAM,QAAQ,GAAgC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACrE,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAsB,CAAC;YAChF,OAAO,kBAAkB,CAAC,MAAM,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,IAAI,EACJ;QACE,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,UAAU,CAAC,WAA4B;QACpD,WAAW,EAAE;YACX,YAAY,EAAE,UAAU,CAAC,QAAQ;YACjC,eAAe,EAAE,UAAU,CAAC,WAAW;YACvC,aAAa,EAAE,KAAK;SACrB;KACF,EACD,QAAQ,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { CallToolResult } from "@modelcontextprotocol/server";
2
+ /** Formats structured tool data, process logs, and consistent MCP error status. */
3
+ export declare function structuredResponse(responseData: Record<string, unknown>): CallToolResult;
4
+ /** Converts precondition failures and exceptions to readable, structured MCP errors. */
5
+ export declare function errorResponse(error: unknown): CallToolResult;
@@ -0,0 +1,20 @@
1
+ /** Formats structured tool data, process logs, and consistent MCP error status. */
2
+ export function structuredResponse(responseData) {
3
+ const validation = responseData.validation;
4
+ const text = typeof responseData.log === "string" ? responseData.log : JSON.stringify(responseData, null, 2);
5
+ return {
6
+ structuredContent: responseData,
7
+ content: [{ type: "text", text }],
8
+ isError: responseData.success === false || validation?.compatible === false,
9
+ };
10
+ }
11
+ /** Converts precondition failures and exceptions to readable, structured MCP errors. */
12
+ export function errorResponse(error) {
13
+ const message = error instanceof Error ? error.message : String(error);
14
+ return {
15
+ structuredContent: { error: message },
16
+ content: [{ type: "text", text: message }],
17
+ isError: true,
18
+ };
19
+ }
20
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/mcp/responses.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,MAAM,UAAU,kBAAkB,CAAC,YAAqC;IACtE,MAAM,UAAU,GAAG,YAAY,CAAC,UAAiD,CAAC;IAClF,MAAM,IAAI,GACR,OAAO,YAAY,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAElG,OAAO;QACL,iBAAiB,EAAE,YAAY;QAC/B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,OAAO,EAAE,YAAY,CAAC,OAAO,KAAK,KAAK,IAAI,UAAU,EAAE,UAAU,KAAK,KAAK;KAC5E,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvE,OAAO;QACL,iBAAiB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QACrC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,155 @@
1
+ import { z as zod } from "zod";
2
+ /** Management tools without input parameters. */
3
+ export declare const emptyInputSchema: zod.ZodObject<{}, zod.core.$strip>;
4
+ /** Installed CMD path; compatibility validation happens before persistence. */
5
+ export declare const cmdSetSchema: zod.ZodObject<{
6
+ path: zod.ZodString;
7
+ }, zod.core.$strip>;
8
+ /** OS discovery filters; serial discovery ignores USB vendor and product IDs. */
9
+ export declare const deviceDiscoverSchema: zod.ZodObject<{
10
+ transport: zod.ZodEnum<{
11
+ serial: "serial";
12
+ hid: "hid";
13
+ }>;
14
+ vid: zod.ZodOptional<zod.ZodNumber>;
15
+ pid: zod.ZodOptional<zod.ZodNumber>;
16
+ }, zod.core.$strip>;
17
+ /** Connection settings used to probe and register a process-local ROM target. */
18
+ export declare const targetCreateSchema: zod.ZodObject<{
19
+ transport: zod.ZodEnum<{
20
+ serial: "serial";
21
+ hid: "hid";
22
+ }>;
23
+ vid: zod.ZodOptional<zod.ZodNumber>;
24
+ pid: zod.ZodOptional<zod.ZodNumber>;
25
+ port: zod.ZodOptional<zod.ZodString>;
26
+ baudRate: zod.ZodOptional<zod.ZodNumber>;
27
+ path: zod.ZodOptional<zod.ZodString>;
28
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
29
+ }, zod.core.$strip>;
30
+ /** Registered target selected for deletion. */
31
+ export declare const targetDeleteSchema: zod.ZodObject<{
32
+ targetId: zod.ZodString;
33
+ }, zod.core.$strip>;
34
+ /**
35
+ * ROM inputs aligned with hpm_manufacturing_tool's build/debug/console_instruction.
36
+ * Shared shapes document inherited target, timeout, memory, and address fields.
37
+ * File/array variants expose the same CMD command as separate MCP tools.
38
+ * Image creation and production package export are separate CMD modes, outside this ROM group.
39
+ */
40
+ export declare const romSchemas: {
41
+ /** query-rte <id> [<param>]: query ROM features, memory properties, or supported commands. */
42
+ query_rte: zod.ZodObject<{
43
+ rteId: zod.ZodUnion<readonly [zod.ZodLiteral<0>, zod.ZodLiteral<4>, zod.ZodLiteral<5>]>;
44
+ argument: zod.ZodOptional<zod.ZodString>;
45
+ targetId: zod.ZodString;
46
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
47
+ }, zod.core.$strip>;
48
+ /**
49
+ * config-rte <peripheral-mask> <baud-rate>: existing runtime serial configuration tool.
50
+ * Not listed in the reference console_instruction; mask bit meanings are not documented there.
51
+ */
52
+ config_rte: zod.ZodObject<{
53
+ peripheralMask: zod.ZodString;
54
+ baudRate: zod.ZodNumber;
55
+ targetId: zod.ZodString;
56
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
57
+ }, zod.core.$strip>;
58
+ /**
59
+ * config-memory <memory-id> <config-address>: configure external NOR or SDXC memory.
60
+ * Write the configuration data into device memory before passing its address here.
61
+ */
62
+ config_memory: zod.ZodObject<{
63
+ memoryId: zod.ZodString;
64
+ address: zod.ZodString;
65
+ targetId: zod.ZodString;
66
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
67
+ }, zod.core.$strip>;
68
+ /** read-memory without a file: read data into CMD output; wrapper caps requests at 65536 bytes. */
69
+ read_memory: zod.ZodObject<{
70
+ length: zod.ZodNumber;
71
+ memoryId: zod.ZodString;
72
+ address: zod.ZodString;
73
+ targetId: zod.ZodString;
74
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
75
+ }, zod.core.$strip>;
76
+ /** read-memory with a file: read bytes from the device into a local output file. */
77
+ read_memory_to_file: zod.ZodObject<{
78
+ length: zod.ZodNumber;
79
+ filePath: zod.ZodString;
80
+ overwrite: zod.ZodOptional<zod.ZodBoolean>;
81
+ memoryId: zod.ZodString;
82
+ address: zod.ZodString;
83
+ targetId: zod.ZodString;
84
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
85
+ }, zod.core.$strip>;
86
+ /** write-memory with an array: write four-byte hex words; can also program OTP. */
87
+ write_memory: zod.ZodObject<{
88
+ data: zod.ZodString;
89
+ memoryId: zod.ZodString;
90
+ address: zod.ZodString;
91
+ targetId: zod.ZodString;
92
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
93
+ }, zod.core.$strip>;
94
+ /** write-memory with a file: write an existing local regular file into the selected memory. */
95
+ write_memory_from_file: zod.ZodObject<{
96
+ filePath: zod.ZodString;
97
+ memoryId: zod.ZodString;
98
+ address: zod.ZodString;
99
+ targetId: zod.ZodString;
100
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
101
+ }, zod.core.$strip>;
102
+ /** verify-checksum with an array: verify device data against four-byte hex words; excludes OTP. */
103
+ verify_checksum: zod.ZodObject<{
104
+ data: zod.ZodString;
105
+ memoryId: zod.ZodString;
106
+ address: zod.ZodString;
107
+ targetId: zod.ZodString;
108
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
109
+ }, zod.core.$strip>;
110
+ /** verify-checksum with a file: verify device data against an existing local file; excludes OTP. */
111
+ verify_checksum_from_file: zod.ZodObject<{
112
+ filePath: zod.ZodString;
113
+ memoryId: zod.ZodString;
114
+ address: zod.ZodString;
115
+ targetId: zod.ZodString;
116
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
117
+ }, zod.core.$strip>;
118
+ /** erase-region <memory-id> <address> <byte-count>: erase a region of XPI0/1 NOR. */
119
+ erase_region: zod.ZodObject<{
120
+ length: zod.ZodNumber;
121
+ memoryId: zod.ZodString;
122
+ address: zod.ZodString;
123
+ targetId: zod.ZodString;
124
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
125
+ }, zod.core.$strip>;
126
+ /** erase-chip <memory-id>: erase the entire selected XPI0/1 NOR device. */
127
+ erase_chip: zod.ZodObject<{
128
+ memoryId: zod.ZodString;
129
+ targetId: zod.ZodString;
130
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
131
+ }, zod.core.$strip>;
132
+ /** load-image <image-path>: load an image into a connected device supporting serial boot. */
133
+ load_image: zod.ZodObject<{
134
+ filePath: zod.ZodString;
135
+ targetId: zod.ZodString;
136
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
137
+ }, zod.core.$strip>;
138
+ /**
139
+ * load-blfw <soc-series> <isSigned>: CMD wrapper around load-image for bootloader firmware.
140
+ * Device resets automatically on success. Combining load-blfw and load-image for bootloader
141
+ * firmware in the same operation may fail according to console_instruction.
142
+ */
143
+ load_bootloader_firmware: zod.ZodObject<{
144
+ series: zod.ZodString;
145
+ signed: zod.ZodBoolean;
146
+ targetId: zod.ZodString;
147
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
148
+ }, zod.core.$strip>;
149
+ /** reset <reset-type>: reset the connected device using the selected reset mode. */
150
+ reset: zod.ZodObject<{
151
+ resetType: zod.ZodNumber;
152
+ targetId: zod.ZodString;
153
+ timeoutMs: zod.ZodOptional<zod.ZodNumber>;
154
+ }, zod.core.$strip>;
155
+ };
@@ -0,0 +1,253 @@
1
+ import { isAbsolute } from "node:path";
2
+ import { z as zod } from "zod";
3
+ /** Management tools without input parameters. */
4
+ export const emptyInputSchema = zod.object({});
5
+ /** Installed CMD path; compatibility validation happens before persistence. */
6
+ export const cmdSetSchema = zod.object({
7
+ path: zod
8
+ .string()
9
+ .describe("Absolute path to hpm_manufacturing_cmd.exe on Windows or hpm_manufacturing_cmd on Linux"),
10
+ });
11
+ const transportSchema = zod.enum(["serial", "hid"]).describe("Device transport");
12
+ const vendorIdSchema = zod
13
+ .number()
14
+ .int()
15
+ .min(0)
16
+ .max(65535)
17
+ .optional()
18
+ .describe("USB vendor ID; defaults to 13495 (0x34B7)");
19
+ const productIdSchema = zod
20
+ .number()
21
+ .int()
22
+ .min(0)
23
+ .max(65535)
24
+ .optional()
25
+ .describe("USB product ID; zero matches any PID");
26
+ /** OS discovery filters; serial discovery ignores USB vendor and product IDs. */
27
+ export const deviceDiscoverSchema = zod.object({
28
+ transport: transportSchema,
29
+ vid: vendorIdSchema,
30
+ pid: productIdSchema,
31
+ });
32
+ /** Connection settings used to probe and register a process-local ROM target. */
33
+ export const targetCreateSchema = zod.object({
34
+ transport: transportSchema,
35
+ vid: vendorIdSchema,
36
+ pid: productIdSchema,
37
+ port: zod.string().min(1).optional().describe("Serial port; omitted requires exactly one device"),
38
+ baudRate: zod
39
+ .number()
40
+ .int()
41
+ .min(0)
42
+ .max(0xffffffff)
43
+ .optional()
44
+ .describe("Serial baud rate; zero defaults to 115200"),
45
+ path: zod
46
+ .string()
47
+ .min(1)
48
+ .optional()
49
+ .describe("HID interface path; omitted requires exactly one accessible device"),
50
+ timeoutMs: zod
51
+ .number()
52
+ .int()
53
+ .min(1000)
54
+ .max(1800000)
55
+ .optional()
56
+ .describe("Probe timeout; defaults to 10000 ms"),
57
+ });
58
+ /** Registered target selected for deletion. */
59
+ export const targetDeleteSchema = zod.object({
60
+ targetId: zod.string().min(1).describe("Registered target ID"),
61
+ });
62
+ /** Unsigned 32-bit value accepted in decimal or hexadecimal form. */
63
+ const unsignedNumberSchema = zod
64
+ .string()
65
+ .regex(/^(?:0[xX][0-9a-fA-F]+|[0-9]+)$/)
66
+ .refine((value) => Number(value) <= 0xffffffff, "Must be a 32-bit unsigned number");
67
+ /** CMD memory selectors: ILM, DLM, XPI0/1 NOR, OTP, and SDXC0/1. */
68
+ const allMemoryIds = [0, 1, 0x10000, 0x10001, 0x20000, 0x30000, 0x30001];
69
+ /** Human-readable names retained in the MCP input schema for each allowed selector. */
70
+ const memoryNames = {
71
+ 0: "ILM",
72
+ 1: "DLM",
73
+ 0x10000: "XPI0 NOR",
74
+ 0x10001: "XPI1 NOR",
75
+ 0x20000: "OTP",
76
+ 0x30000: "SDXC0",
77
+ 0x30001: "SDXC1",
78
+ };
79
+ /** Restricts decimal/hexadecimal selectors to the memories supported by an operation. */
80
+ const memoryIdSchema = (ids) => unsignedNumberSchema
81
+ .refine((value) => ids.includes(Number(value)), "Unsupported memory ID")
82
+ .describe(`Memory ID as a decimal or hexadecimal string: ${ids
83
+ .map((id) => `0x${id.toString(16)} (${memoryNames[id]})`)
84
+ .join(", ")}`);
85
+ /** Process-local target and optional CMD deadline shared by every ROM request. */
86
+ const baseROMShape = {
87
+ /** Returned by device.create; targets must be recreated after the MCP process restarts. */
88
+ targetId: zod
89
+ .string()
90
+ .min(1)
91
+ .describe("Target ID returned by device.create; valid only in this MCP process"),
92
+ /** 1000-1800000 ms; defaults: erase_chip 1800000, erase/write/file-read/load 600000, others 30000. */
93
+ timeoutMs: zod
94
+ .number()
95
+ .int()
96
+ .min(1000)
97
+ .max(1800000)
98
+ .optional()
99
+ .describe("CMD timeout, 1000-1800000 ms; defaults: erase_chip 1800000; erase/write/read_memory_to_file/load 600000; other operations 30000"),
100
+ };
101
+ /** Transfer address; CMD interprets this as a sector index for eMMC on SDXC. */
102
+ const address = unsignedNumberSchema.describe("32-bit decimal or hexadecimal string: memory address, or sector index for eMMC on SDXC0/SDXC1");
103
+ /** Wrapper requires absolute paths; CMD's internal ROM parser cannot safely accept whitespace. */
104
+ const path = zod
105
+ .string()
106
+ .min(1)
107
+ .refine((value) => {
108
+ // CMD splits ROM text internally; reject whitespace and control bytes before invocation.
109
+ // eslint-disable-next-line no-control-regex
110
+ return isAbsolute(value) && !/[\s\x00-\x1f\x7f]/u.test(value);
111
+ }, "File path must be absolute and contain no whitespace or control characters")
112
+ .describe("Absolute file path without whitespace or control characters");
113
+ /** Each hexadecimal word contributes four bytes; buildROM adds omitted double brackets. */
114
+ const data = zod
115
+ .string()
116
+ .regex(/^(?:\[\[)?0[xX][0-9a-fA-F]{1,8}(?:,0[xX][0-9a-fA-F]{1,8})*(?:\]\])?$/)
117
+ .refine((value) => value.startsWith("[[") === value.endsWith("]]"), "Brackets must be paired")
118
+ .describe("Comma-separated hexadecimal words, four bytes per word; optional paired [[...]] brackets; no whitespace, e.g. [[0xfcf90001,0x05,0x0,0x0]]");
119
+ /** Byte count, including when an eMMC transfer starts at a sector index. */
120
+ const length = zod.number().int().min(1).max(0xffffffff).describe("Positive byte length");
121
+ /** All readable/writable memory selectors and their transfer address. */
122
+ const memoryAddressShape = {
123
+ /** Select ILM, DLM, XPI0/1 NOR, OTP, or SDXC0/1 using a decimal/hex string. */
124
+ memoryId: memoryIdSchema(allMemoryIds),
125
+ /** Memory address, or eMMC sector index for transfers through SDXC. */
126
+ address,
127
+ };
128
+ /** Checksum verification supports all transfer memories except OTP. */
129
+ const checksumMemoryShape = {
130
+ ...memoryAddressShape,
131
+ /** OTP is not supported by verify-checksum. */
132
+ memoryId: memoryIdSchema(allMemoryIds.filter((id) => id !== 0x20000)),
133
+ };
134
+ /** Erase operations are limited to XPI0 NOR and XPI1 NOR. */
135
+ const norMemoryShape = {
136
+ ...memoryAddressShape,
137
+ /** Only external XPI NOR devices support erase-region and erase-chip. */
138
+ memoryId: memoryIdSchema([0x10000, 0x10001]),
139
+ };
140
+ /**
141
+ * ROM inputs aligned with hpm_manufacturing_tool's build/debug/console_instruction.
142
+ * Shared shapes document inherited target, timeout, memory, and address fields.
143
+ * File/array variants expose the same CMD command as separate MCP tools.
144
+ * Image creation and production package export are separate CMD modes, outside this ROM group.
145
+ */
146
+ export const romSchemas = {
147
+ /** query-rte <id> [<param>]: query ROM features, memory properties, or supported commands. */
148
+ query_rte: zod.object({
149
+ ...baseROMShape,
150
+ /** 0: ROM features; 4: selected memory properties; 5: supported command list. */
151
+ rteId: zod
152
+ .union([zod.literal(0), zod.literal(4), zod.literal(5)])
153
+ .describe("0: ROM features; 4: memory properties; 5: command list"),
154
+ /** Required for rteId=4 and forbidden otherwise; buildROM enforces this dependency. */
155
+ argument: memoryIdSchema(allMemoryIds)
156
+ .optional()
157
+ .describe("Required only for rteId=4; forbidden for 0/5. Decimal/hex string: 0 ILM, 1 DLM, 0x10000 XPI0 NOR, 0x10001 XPI1 NOR, 0x20000 OTP, 0x30000 SDXC0, 0x30001 SDXC1"),
158
+ }),
159
+ /**
160
+ * config-rte <peripheral-mask> <baud-rate>: existing runtime serial configuration tool.
161
+ * Not listed in the reference console_instruction; mask bit meanings are not documented there.
162
+ */
163
+ config_rte: zod.object({
164
+ ...baseROMShape,
165
+ /** Unsigned 32-bit decimal/hex string; supported peripheral bits depend on the ROM/CMD. */
166
+ peripheralMask: unsignedNumberSchema.describe("Serial peripheral mask"),
167
+ /** Requested serial baud rate, 1-4294967295; distinct from target connection settings. */
168
+ baudRate: zod.number().int().min(1).max(0xffffffff).describe("Serial baud rate"),
169
+ }),
170
+ /**
171
+ * config-memory <memory-id> <config-address>: configure external NOR or SDXC memory.
172
+ * Write the configuration data into device memory before passing its address here.
173
+ */
174
+ config_memory: zod.object({
175
+ ...baseROMShape,
176
+ ...memoryAddressShape,
177
+ /** External memories only: XPI0/1 NOR or SDXC0/1. */
178
+ memoryId: memoryIdSchema([0x10000, 0x10001, 0x30000, 0x30001]),
179
+ /** Address of configuration data in device memory, rather than the transfer destination. */
180
+ address: unsignedNumberSchema.describe("32-bit decimal or hexadecimal string: address of memory configuration data already written into device memory; not a transfer destination or sector index"),
181
+ }),
182
+ /** read-memory without a file: read data into CMD output; wrapper caps requests at 65536 bytes. */
183
+ read_memory: zod.object({
184
+ ...baseROMShape,
185
+ ...memoryAddressShape,
186
+ /** Positive byte count; the 64 KiB cap is a wrapper constraint, not a documented ROM limit. */
187
+ length: length.max(65536).describe("Byte count, 1-65536; wrapper limit for inline CMD output"),
188
+ }),
189
+ /** read-memory with a file: read bytes from the device into a local output file. */
190
+ read_memory_to_file: zod.object({
191
+ ...baseROMShape,
192
+ ...memoryAddressShape,
193
+ /** Positive byte count, 1-4294967295. */
194
+ length,
195
+ /** Output file; parent directory must exist. Existing files require overwrite=true. */
196
+ filePath: path.describe("Absolute output file path without whitespace/control characters; parent directory must exist"),
197
+ /** Wrapper-only permission flag; not passed as a ROM command argument. */
198
+ overwrite: zod
199
+ .boolean()
200
+ .optional()
201
+ .describe("Allow overwriting an existing output file; defaults to false"),
202
+ }),
203
+ /** write-memory with an array: write four-byte hex words; can also program OTP. */
204
+ write_memory: zod.object({ ...baseROMShape, ...memoryAddressShape, data }),
205
+ /** write-memory with a file: write an existing local regular file into the selected memory. */
206
+ write_memory_from_file: zod.object({
207
+ ...baseROMShape,
208
+ ...memoryAddressShape,
209
+ /** Existing input file; the file's contents supply the data and transfer length. */
210
+ filePath: path.describe("Absolute existing input file path without whitespace/control characters"),
211
+ }),
212
+ /** verify-checksum with an array: verify device data against four-byte hex words; excludes OTP. */
213
+ verify_checksum: zod.object({ ...baseROMShape, ...checksumMemoryShape, data }),
214
+ /** verify-checksum with a file: verify device data against an existing local file; excludes OTP. */
215
+ verify_checksum_from_file: zod.object({
216
+ ...baseROMShape,
217
+ ...checksumMemoryShape,
218
+ /** Existing regular file containing the expected data. */
219
+ filePath: path.describe("Absolute existing reference file path without whitespace/control characters"),
220
+ }),
221
+ /** erase-region <memory-id> <address> <byte-count>: erase a region of XPI0/1 NOR. */
222
+ erase_region: zod.object({ ...baseROMShape, ...norMemoryShape, length }),
223
+ /** erase-chip <memory-id>: erase the entire selected XPI0/1 NOR device. */
224
+ erase_chip: zod.object({ ...baseROMShape, memoryId: norMemoryShape.memoryId }),
225
+ /** load-image <image-path>: load an image into a connected device supporting serial boot. */
226
+ load_image: zod.object({
227
+ ...baseROMShape,
228
+ /** Existing image file; this command loads an image rather than creating one. */
229
+ filePath: path.describe("Absolute existing image path without whitespace/control characters; device must support serial boot"),
230
+ }),
231
+ /**
232
+ * load-blfw <soc-series> <isSigned>: CMD wrapper around load-image for bootloader firmware.
233
+ * Device resets automatically on success. Combining load-blfw and load-image for bootloader
234
+ * firmware in the same operation may fail according to console_instruction.
235
+ */
236
+ load_bootloader_firmware: zod.object({
237
+ ...baseROMShape,
238
+ /** CMD-supported series token, e.g. HPM6700, HPM6400, HPM5300, HPM6200, or HPM6300. */
239
+ series: zod
240
+ .string()
241
+ .regex(/^[A-Za-z0-9_-]+$/)
242
+ .describe("SoC series supported by installed CMD, e.g. HPM6700, HPM6400, HPM5300, HPM6200, HPM6300; device automatically resets after loading"),
243
+ /** Maps false to isSigned=0 (unsigned) and true to isSigned=1 (signed). */
244
+ signed: zod.boolean().describe("false: unsigned firmware (0); true: signed firmware (1)"),
245
+ }),
246
+ /** reset <reset-type>: reset the connected device using the selected reset mode. */
247
+ reset: zod.object({
248
+ ...baseROMShape,
249
+ /** 0: default reset; 1: hot reset; 2: cold reset. */
250
+ resetType: zod.number().int().min(0).max(2).describe("0: default; 1: hot; 2: cold reset"),
251
+ }),
252
+ };
253
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,CAAC,IAAI,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,iDAAiD;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE/C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,GAAG;SACN,MAAM,EAAE;SACR,QAAQ,CACP,yFAAyF,CAC1F;CACJ,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AACjF,MAAM,cAAc,GAAG,GAAG;KACvB,MAAM,EAAE;KACR,GAAG,EAAE;KACL,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,KAAK,CAAC;KACV,QAAQ,EAAE;KACV,QAAQ,CAAC,2CAA2C,CAAC,CAAC;AACzD,MAAM,eAAe,GAAG,GAAG;KACxB,MAAM,EAAE;KACR,GAAG,EAAE;KACL,GAAG,CAAC,CAAC,CAAC;KAC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AAG,CAAC,MAAM,CAAC,EAAE,GAAG,YAAY,EAAE,GAAG,cAAc,EAAE,MAAM,EAAE,CAAC;IACxE,2EAA2E;IAC3E,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC;IAC9E,6FAA6F;IAC7F,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC;QACrB,GAAG,YAAY;QACf,iFAAiF;QACjF,QAAQ,EAAE,IAAI,CAAC,QAAQ,CACrB,qGAAqG,CACtG;KACF,CAAC;IACF;;;;OAIG;IACH,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAAC;QACnC,GAAG,YAAY;QACf,uFAAuF;QACvF,MAAM,EAAE,GAAG;aACR,MAAM,EAAE;aACR,KAAK,CAAC,kBAAkB,CAAC;aACzB,QAAQ,CACP,oIAAoI,CACrI;QACH,2EAA2E;QAC3E,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,yDAAyD,CAAC;KAC1F,CAAC;IACF,oFAAoF;IACpF,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;QAChB,GAAG,YAAY;QACf,qDAAqD;QACrD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;KAC1F,CAAC;CACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
+ import { Service } from "../hpm-mfg-service.js";
3
+ /** Creates and registers MCP tools without starting external processes. */
4
+ export declare function createServer(service?: Service): McpServer;
@@ -0,0 +1,16 @@
1
+ import { McpServer } from "@modelcontextprotocol/server";
2
+ import { Service } from "../hpm-mfg-service.js";
3
+ import { registerConfigurationTools } from "./configuration.js";
4
+ import { registerDiscoveryTools } from "./discovery.js";
5
+ import { registerOperationTools } from "./operations.js";
6
+ /** Creates and registers MCP tools without starting external processes. */
7
+ export function createServer(service = new Service()) {
8
+ const server = new McpServer({ name: "hpmmfgctl", title: "HPM Manufacturing", version: "0.1.0" }, {
9
+ instructions: "Run mfg.doctor first. Create a target before ROM operations. Confirm target, address, length and file before destructive operations unless already authorized. ROM file paths cannot contain whitespace.",
10
+ });
11
+ registerConfigurationTools(server, service);
12
+ registerDiscoveryTools(server, service);
13
+ registerOperationTools(server, service);
14
+ return server;
15
+ }
16
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,UAAmB,IAAI,OAAO,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,EACnE;QACE,YAAY,EACV,0MAA0M;KAC7M,CACF,CAAC;IAEF,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ROMCommand, ROMName } from "../mcp/mcp-type.js";
2
+ /** Selects default CMD deadlines for query, transfer, and erase operations. */
3
+ export declare function defaultTimeout(name: ROMName): number;
4
+ /** Validates a ROM request and file preconditions before constructing CMD text. */
5
+ export declare function buildROM(name: ROMName, raw: unknown): Promise<ROMCommand>;