@kvell007/embed-labs-local-bridge 0.1.0-alpha.0

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 ADDED
@@ -0,0 +1,130 @@
1
+ # @embed-labs/local-bridge
2
+
3
+ Local HTTP bridge service for Embed Labs Cloud hardware discovery, bounded local
4
+ operations, and guarded flash planning.
5
+
6
+ ## Package Status
7
+
8
+ This package is a publish candidate, but it is not ready for public npm publish
9
+ yet. The workspace manifest intentionally remains marked `private: true` until
10
+ package names, license, npm scope ownership, support URLs, and release approval
11
+ are complete.
12
+
13
+ ## What It Provides
14
+
15
+ - `embed-local-bridge` binary.
16
+ - `startServer()` library entry point.
17
+ - Local health endpoint.
18
+ - Device discovery for serial ports, RP2350-compatible UF2 volumes, Rockchip
19
+ USB Loader/Maskrom style devices, and the current TaishanPi USB ECM probe.
20
+ - Bounded TCP, serial path, serial capture, and SSH command probes.
21
+ - Non-destructive debug tool availability scans for OpenOCD, probe-rs, pyOCD,
22
+ and SEGGER J-Link command-line tools.
23
+ - Flash plan endpoints and local job tracking.
24
+ - Shared response contracts from `@embed-labs/protocol`.
25
+
26
+ ## Install
27
+
28
+ After the package is approved for public release:
29
+
30
+ ```bash
31
+ npm install -g @embed-labs/local-bridge
32
+ ```
33
+
34
+ Internal workspace usage:
35
+
36
+ ```bash
37
+ npm run build
38
+ node packages/local-bridge/dist/index.js
39
+ ```
40
+
41
+ ## Start the Bridge
42
+
43
+ ```bash
44
+ embed-local-bridge
45
+ ```
46
+
47
+ The bridge listens on `127.0.0.1:18083` by default.
48
+
49
+ ```bash
50
+ EMBED_BRIDGE_HOST=127.0.0.1 EMBED_BRIDGE_PORT=18083 embed-local-bridge
51
+ ```
52
+
53
+ Library usage:
54
+
55
+ ```ts
56
+ import { startServer } from "@embed-labs/local-bridge";
57
+
58
+ const server = startServer({ host: "127.0.0.1", port: 18083 });
59
+ ```
60
+
61
+ ## HTTP Surface
62
+
63
+ - `GET /healthz`
64
+ - `GET /v1/devices`
65
+ - `GET /v1/debug/tools`
66
+ - `POST /v1/devices/probe`
67
+ - `GET /v1/serial/ports`
68
+ - `POST /v1/serial/capture`
69
+ - `POST /v1/ssh/run`
70
+ - `POST /v1/flash/plan`
71
+ - `POST /v1/flash/run`
72
+ - `GET /v1/jobs`
73
+ - `GET /v1/jobs/<local_job_id>`
74
+
75
+ Examples:
76
+
77
+ ```bash
78
+ curl -fsS http://127.0.0.1:18083/healthz
79
+ curl -fsS http://127.0.0.1:18083/v1/devices
80
+ curl -fsS http://127.0.0.1:18083/v1/debug/tools
81
+ curl -fsS http://127.0.0.1:18083/v1/devices/probe \
82
+ -H 'content-type: application/json' \
83
+ -d '{"host":"198.19.77.2","ports":[22,15301],"timeout_ms":1000}'
84
+ ```
85
+
86
+ ## Hardware Support Boundary
87
+
88
+ Current local behavior is intentionally narrow:
89
+
90
+ - Device discovery can report serial ports, RP2350 UF2 boot volumes,
91
+ Rockchip-style USB Loader/Maskrom matches, and TaishanPi USB ECM reachability
92
+ at the current default probe address.
93
+ - Debug tool scans only check PATH and bounded version/help command evidence;
94
+ they do not open probes, start GDB servers, or create debug sessions.
95
+ - RP2350 UF2 flashing copies a `.uf2` artifact to a mounted UF2 volume only
96
+ after a ready flash plan and explicit approval.
97
+ - TaishanPi image-set planning can check required image files and
98
+ `rkdeveloptool` availability, but real destructive TaishanPi flashing is
99
+ guarded and not enabled. The bridge returns a blocked job until the exact
100
+ hardware profile and Board Pack command templates are accepted.
101
+
102
+ These behaviors are local evidence and planning tools, not broad board support
103
+ claims.
104
+
105
+ ## Operational Boundaries
106
+
107
+ - The default bind address is localhost. Do not expose the bridge on a shared
108
+ network without an approved authentication and network access design.
109
+ - JSON request bodies are bounded.
110
+ - Serial capture and SSH operations are time-bounded.
111
+ - Windows serial capture is not implemented in the current no-native-helper
112
+ path.
113
+ - Destructive operations must remain approval-gated.
114
+
115
+ ## Runtime Requirements
116
+
117
+ - Node.js 20 or newer.
118
+ - Optional platform tools depending on the requested action, such as OpenSSH
119
+ for `POST /v1/ssh/run`, `rkdeveloptool` for TaishanPi planning checks, and
120
+ debug tools such as `openocd`, `probe-rs`, `pyocd`, `JLinkExe`, and
121
+ `JLinkGDBServerCLExe` for `GET /v1/debug/tools` evidence.
122
+
123
+ ## Publish Readiness
124
+
125
+ Before public publish, confirm the runbook checklist in
126
+ `docs/runbooks/CLI_NPM_PACKAGING.md`, including approved SPDX license metadata,
127
+ repository, issue tracker, homepage, support metadata, changelog or release
128
+ notes, final npm scope ownership, executable verification for
129
+ `embed-local-bridge`, and removal of `private: true` only in an approved
130
+ metadata task.
@@ -0,0 +1,2 @@
1
+ import type { DebugToolScanResult } from "@embed-labs/protocol";
2
+ export declare function scanDebugTools(): Promise<DebugToolScanResult>;
@@ -0,0 +1,124 @@
1
+ import { resolveCommand, runCommand, tailLines } from "../process.js";
2
+ const VERSION_TIMEOUT_MS = 2500;
3
+ const DEBUG_TOOLS = [
4
+ {
5
+ tool_id: "openocd",
6
+ display_name: "OpenOCD",
7
+ command: "openocd",
8
+ version_args: ["--version"]
9
+ },
10
+ {
11
+ tool_id: "probe-rs",
12
+ display_name: "probe-rs",
13
+ command: "probe-rs",
14
+ version_args: ["--version"]
15
+ },
16
+ {
17
+ tool_id: "pyocd",
18
+ display_name: "pyOCD",
19
+ command: "pyocd",
20
+ version_args: ["--version"]
21
+ },
22
+ {
23
+ tool_id: "jlink-commander",
24
+ display_name: "SEGGER J-Link Commander",
25
+ command: "JLinkExe",
26
+ version_args: ["-?"]
27
+ },
28
+ {
29
+ tool_id: "jlink-gdb-server",
30
+ display_name: "SEGGER J-Link GDB Server",
31
+ command: "JLinkGDBServerCLExe",
32
+ version_args: ["-?"]
33
+ }
34
+ ];
35
+ export async function scanDebugTools() {
36
+ const observedAt = new Date().toISOString();
37
+ const tools = await Promise.all(DEBUG_TOOLS.map((tool) => scanDebugTool(tool, observedAt)));
38
+ const availableCount = tools.filter((tool) => tool.available).length;
39
+ return {
40
+ tools,
41
+ observed_at: observedAt,
42
+ summary_for_user: `Debug tool scan finished: ${availableCount}/${tools.length} tools available. No debug sessions or probe connections were opened.`
43
+ };
44
+ }
45
+ async function scanDebugTool(spec, observedAt) {
46
+ const evidence = [];
47
+ const resolvedPath = await resolveCommand(spec.command);
48
+ evidence.push({
49
+ evidence_id: evidenceId(spec.tool_id, "path", observedAt),
50
+ tool_id: spec.tool_id,
51
+ kind: "path_lookup",
52
+ command: spec.command,
53
+ observed_at: observedAt,
54
+ available: resolvedPath !== undefined,
55
+ resolved_path: resolvedPath,
56
+ summary: resolvedPath
57
+ ? `Found ${spec.command} on PATH.`
58
+ : `${spec.command} was not found on PATH.`
59
+ });
60
+ if (!resolvedPath) {
61
+ return {
62
+ tool_id: spec.tool_id,
63
+ display_name: spec.display_name,
64
+ command: spec.command,
65
+ available: false,
66
+ evidence,
67
+ summary_for_user: `${spec.display_name} is not available on PATH.`
68
+ };
69
+ }
70
+ const versionResult = await runCommand(resolvedPath, spec.version_args, VERSION_TIMEOUT_MS);
71
+ const stdoutTail = tailLines(versionResult.stdout, 8);
72
+ const stderrTail = tailLines(versionResult.stderr, 8);
73
+ const version = extractVersionLine(`${versionResult.stdout}\n${versionResult.stderr}`);
74
+ evidence.push({
75
+ evidence_id: evidenceId(spec.tool_id, "version", observedAt),
76
+ tool_id: spec.tool_id,
77
+ kind: "version_command",
78
+ command: spec.command,
79
+ args: spec.version_args,
80
+ observed_at: observedAt,
81
+ exit_code: versionResult.exit_code,
82
+ timed_out: versionResult.timed_out,
83
+ stdout_tail: stdoutTail.length > 0 ? stdoutTail : undefined,
84
+ stderr_tail: stderrTail.length > 0 ? stderrTail : undefined,
85
+ error_code: versionResult.timed_out
86
+ ? "version_command_timeout"
87
+ : versionResult.exit_code === 0
88
+ ? undefined
89
+ : "version_command_nonzero",
90
+ error_message: versionResult.timed_out
91
+ ? `Version/help command exceeded ${VERSION_TIMEOUT_MS}ms.`
92
+ : versionResult.exit_code === 0
93
+ ? undefined
94
+ : `Version/help command exited with code ${versionResult.exit_code ?? "unknown"}.`,
95
+ summary: versionResult.timed_out
96
+ ? `${spec.command} was found, but the bounded version/help command timed out.`
97
+ : versionResult.exit_code === 0
98
+ ? `${spec.command} version/help command completed.`
99
+ : `${spec.command} was found, but its version/help command exited non-zero.`
100
+ });
101
+ return {
102
+ tool_id: spec.tool_id,
103
+ display_name: spec.display_name,
104
+ command: spec.command,
105
+ available: true,
106
+ version,
107
+ evidence,
108
+ summary_for_user: version
109
+ ? `${spec.display_name} is available (${version}).`
110
+ : `${spec.display_name} is available; version output was not recognized.`
111
+ };
112
+ }
113
+ function extractVersionLine(output) {
114
+ return output
115
+ .split(/\r?\n/)
116
+ .map((line) => line.trim())
117
+ .find((line) => line.length > 0)
118
+ ?.slice(0, 160);
119
+ }
120
+ function evidenceId(toolId, kind, observedAt) {
121
+ const stableTime = observedAt.replace(/[^0-9]/g, "");
122
+ return `debug_${toolId}_${kind}_${stableTime}`;
123
+ }
124
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/adapters/debug.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAStE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,WAAW,GAAoB;IACnC;QACE,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,SAAS;QACvB,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,CAAC,WAAW,CAAC;KAC5B;IACD;QACE,OAAO,EAAE,UAAU;QACnB,YAAY,EAAE,UAAU;QACxB,OAAO,EAAE,UAAU;QACnB,YAAY,EAAE,CAAC,WAAW,CAAC;KAC5B;IACD;QACE,OAAO,EAAE,OAAO;QAChB,YAAY,EAAE,OAAO;QACrB,OAAO,EAAE,OAAO;QAChB,YAAY,EAAE,CAAC,WAAW,CAAC;KAC5B;IACD;QACE,OAAO,EA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AE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,UAAU,CAAC,MAAmB,EAAE,IAAY,EAAE,UAAkB;IACvE,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,SAAS,MAAM,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;AACjD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { BoardDeployRequest, BoardDeployResult, ErrorEnvelope } from "@embed-labs/protocol";
2
+ export declare function deployTaishanPiArtifact(request: BoardDeployRequest): Promise<BoardDeployResult | {
3
+ ok: false;
4
+ error: ErrorEnvelope;
5
+ }>;
@@ -0,0 +1,132 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { posix } from "node:path";
3
+ import { commandExists, runCommand, tailLines } from "../process.js";
4
+ const DEFAULT_REMOTE_PATH = "/userdata/embed-labs/apps/app";
5
+ const REMOTE_ROOT = "/userdata/embed-labs/apps";
6
+ const MAX_ARTIFACT_BYTES = 16 * 1024 * 1024;
7
+ export async function deployTaishanPiArtifact(request) {
8
+ const observedAt = new Date().toISOString();
9
+ if (request.board_id !== "taishanpi") {
10
+ return failDeploy("unsupported_board", `board_id must be taishanpi, got ${request.board_id}.`);
11
+ }
12
+ const host = request.host.trim();
13
+ const user = request.user?.trim() || "root";
14
+ const remotePath = normalizeRemotePath(request.remote_path ?? DEFAULT_REMOTE_PATH);
15
+ const timeoutSeconds = clampTimeoutSeconds(request.timeout_seconds);
16
+ if (!remotePath) {
17
+ return failDeploy("invalid_remote_path", `remote_path must stay under ${REMOTE_ROOT} and contain only safe path characters.`);
18
+ }
19
+ if (!/^[A-Za-z0-9._-]{1,64}$/.test(user)) {
20
+ return failDeploy("invalid_user", "SSH user must contain only letters, numbers, dots, underscores, or hyphens.");
21
+ }
22
+ if (!await commandExists("ssh")) {
23
+ return failDeploy("ssh_not_found", "ssh binary was not found on PATH.", "Install OpenSSH client or add ssh to PATH.");
24
+ }
25
+ const artifactStat = await stat(request.artifact_path).catch(() => undefined);
26
+ if (!artifactStat?.isFile()) {
27
+ return failDeploy("artifact_file_not_found", `Local artifact file is not available: ${request.artifact_path}`);
28
+ }
29
+ if (artifactStat.size > MAX_ARTIFACT_BYTES) {
30
+ return failDeploy("artifact_file_too_large", `Local Bridge deploy currently accepts artifacts up to ${MAX_ARTIFACT_BYTES} bytes on the SSH/base64 MVP path.`);
31
+ }
32
+ const artifactBytes = await readFile(request.artifact_path);
33
+ const remoteDir = posix.dirname(remotePath);
34
+ const tmpPath = `${remotePath}.tmp.${Date.now()}`;
35
+ const logPath = `${remotePath}.log`;
36
+ const pidPath = `${remotePath}.pid`;
37
+ const upload = await ssh(host, user, [
38
+ `mkdir -p ${shellQuote(remoteDir)}`,
39
+ "umask 077",
40
+ `base64 -d > ${shellQuote(tmpPath)}`,
41
+ `chmod 0755 ${shellQuote(tmpPath)}`,
42
+ `mv -f ${shellQuote(tmpPath)} ${shellQuote(remotePath)}`
43
+ ].join(" && "), timeoutSeconds, artifactBytes.toString("base64"));
44
+ if (upload.exit_code !== 0) {
45
+ return commandFailure(upload.timed_out ? "artifact_upload_timeout" : "artifact_upload_failed", "Failed to upload the artifact to the board over SSH/base64.", upload);
46
+ }
47
+ let runResult;
48
+ if (request.run === true) {
49
+ runResult = await ssh(host, user, [
50
+ `cd ${shellQuote(remoteDir)}`,
51
+ `(nohup ${shellQuote(remotePath)} > ${shellQuote(logPath)} 2>&1 < /dev/null & printf '%s' "$!" > ${shellQuote(pidPath)})`,
52
+ "sleep 1",
53
+ "printf 'pid='",
54
+ `cat ${shellQuote(pidPath)}`,
55
+ "printf '\\n'",
56
+ `tail -n 40 ${shellQuote(logPath)} 2>/dev/null || true`
57
+ ].join(" && "), timeoutSeconds);
58
+ if (runResult.exit_code !== 0) {
59
+ return commandFailure(runResult.timed_out ? "artifact_run_timeout" : "artifact_run_failed", "The artifact was deployed, but the start/log command failed.", runResult);
60
+ }
61
+ }
62
+ return {
63
+ board_id: "taishanpi",
64
+ host,
65
+ user,
66
+ artifact_path: request.artifact_path,
67
+ artifact_size_bytes: artifactStat.size,
68
+ remote_path: remotePath,
69
+ deployed: true,
70
+ ran: request.run === true && runResult?.exit_code === 0,
71
+ remote_pid: runResult ? extractPid(runResult.stdout) : undefined,
72
+ log_path: logPath,
73
+ exit_code: runResult?.exit_code,
74
+ stdout: runResult?.stdout,
75
+ stderr: runResult?.stderr,
76
+ output_tail: runResult ? tailLines(`${runResult.stdout}\n${runResult.stderr}`) : tailLines(`${upload.stdout}\n${upload.stderr}`),
77
+ observed_at: observedAt
78
+ };
79
+ }
80
+ async function ssh(host, user, command, timeoutSeconds, stdin) {
81
+ return runCommand("ssh", [
82
+ "-o", "BatchMode=yes",
83
+ "-o", "UserKnownHostsFile=/dev/null",
84
+ "-o", "StrictHostKeyChecking=no",
85
+ "-o", `ConnectTimeout=${Math.max(1, Math.min(timeoutSeconds, 30))}`,
86
+ `${user}@${host}`,
87
+ command
88
+ ], timeoutSeconds * 1000 + 1000, stdin);
89
+ }
90
+ function normalizeRemotePath(input) {
91
+ if (!input.startsWith("/") || /[\u0000-\u001f\u007f]/.test(input)) {
92
+ return undefined;
93
+ }
94
+ const normalized = posix.normalize(input);
95
+ if (normalized === REMOTE_ROOT || !normalized.startsWith(`${REMOTE_ROOT}/`)) {
96
+ return undefined;
97
+ }
98
+ if (!/^\/[A-Za-z0-9._/-]+$/.test(normalized) || normalized.endsWith("/")) {
99
+ return undefined;
100
+ }
101
+ return normalized;
102
+ }
103
+ function clampTimeoutSeconds(value) {
104
+ const timeout = Number.isFinite(value) ? Number(value) : 30;
105
+ return Math.max(5, Math.min(Math.trunc(timeout), 120));
106
+ }
107
+ function failDeploy(code, message, remediation) {
108
+ return { ok: false, error: { code, message, remediation } };
109
+ }
110
+ function commandFailure(code, message, result) {
111
+ return {
112
+ ok: false,
113
+ error: {
114
+ code,
115
+ message,
116
+ details: {
117
+ exit_code: result.exit_code,
118
+ stdout: result.stdout,
119
+ stderr: result.stderr,
120
+ timed_out: result.timed_out
121
+ }
122
+ }
123
+ };
124
+ }
125
+ function shellQuote(value) {
126
+ return `'${value.replace(/'/g, "'\\''")}'`;
127
+ }
128
+ function extractPid(stdout) {
129
+ const match = stdout.match(/^pid=(\d+)/m);
130
+ return match?.[1];
131
+ }
132
+ //# sourceMappingURL=deploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/adapters/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,mBAAmB,GAAG,+BAA+B,CAAC;AAC5D,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAChD,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAA2B;IACvE,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,UAAU,CAAC,mBAAmB,EAAE,mCAAmC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC;IAC5C,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAC;IACnF,MAAM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M;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B;SACF;KACO,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AAC7C,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC1C,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FlashPlan, FlashPlanRequest } from "@embed-labs/protocol";
2
+ export declare function buildFlashPlan(request: FlashPlanRequest): Promise<FlashPlan>;
3
+ export declare function executeRp2350Uf2Flash(plan: FlashPlan): Promise<Record<string, unknown>>;
@@ -0,0 +1,169 @@
1
+ import { createHash } from "node:crypto";
2
+ import { createReadStream } from "node:fs";
3
+ import { copyFile, stat } from "node:fs/promises";
4
+ import { basename, join } from "node:path";
5
+ import { commandExists } from "../process.js";
6
+ import { findUf2Volumes } from "./uf2.js";
7
+ export async function buildFlashPlan(request) {
8
+ if (request.board_id === "rp2350") {
9
+ return buildRp2350FlashPlan(request);
10
+ }
11
+ if (request.board_id === "taishanpi") {
12
+ return buildTaishanPiFlashPlan(request);
13
+ }
14
+ return {
15
+ plan_id: `plan_${Date.now()}`,
16
+ board_id: request.board_id,
17
+ profile_id: request.profile_id ?? "unknown",
18
+ destructive: true,
19
+ approval_required: true,
20
+ ready: false,
21
+ summary: `No flash planner is available for board_id=${request.board_id}.`,
22
+ warnings: [{
23
+ code: "board_not_supported",
24
+ message: `No local bridge flash planner is available for ${request.board_id}.`
25
+ }]
26
+ };
27
+ }
28
+ export async function executeRp2350Uf2Flash(plan) {
29
+ if (!plan.artifact_path || !plan.target_volume_path) {
30
+ throw new Error("RP2350 UF2 flash requires artifact_path and target_volume_path.");
31
+ }
32
+ const target = join(plan.target_volume_path, basename(plan.artifact_path));
33
+ await copyFile(plan.artifact_path, target);
34
+ return {
35
+ copied_to: target,
36
+ summary_for_user: `Copied UF2 artifact to ${plan.target_volume_path}. The board should reboot automatically if the UF2 volume accepted the file.`
37
+ };
38
+ }
39
+ async function buildRp2350FlashPlan(request) {
40
+ const missingFiles = [];
41
+ const artifactPath = request.artifact_path;
42
+ if (!artifactPath) {
43
+ missingFiles.push("artifact_path");
44
+ }
45
+ else if (!artifactPath.endsWith(".uf2")) {
46
+ missingFiles.push(`${artifactPath} must be a .uf2 artifact`);
47
+ }
48
+ else {
49
+ try {
50
+ await stat(artifactPath);
51
+ }
52
+ catch {
53
+ missingFiles.push(artifactPath);
54
+ }
55
+ }
56
+ const volumes = request.target_volume_path ? [request.target_volume_path] : await findUf2Volumes();
57
+ const targetVolumePath = volumes[0];
58
+ if (!targetVolumePath) {
59
+ missingFiles.push("RP2350 UF2 boot volume");
60
+ }
61
+ return {
62
+ plan_id: `plan_${Date.now()}_rp2350`,
63
+ board_id: "rp2350",
64
+ variant_id: request.variant_id,
65
+ profile_id: request.profile_id ?? "uf2-flash-local",
66
+ destructive: true,
67
+ approval_required: true,
68
+ ready: missingFiles.length === 0,
69
+ summary: missingFiles.length === 0
70
+ ? `Ready to copy ${artifactPath} to RP2350 UF2 volume ${targetVolumePath}.`
71
+ : "RP2350 UF2 flash is not ready.",
72
+ artifact_path: artifactPath,
73
+ target_volume_path: targetVolumePath,
74
+ missing_files: missingFiles,
75
+ warnings: missingFiles.length > 0 ? [{
76
+ code: "flash_plan_not_ready",
77
+ message: "RP2350 UF2 flash requires a .uf2 artifact and a mounted BOOTSEL/UF2 volume."
78
+ }] : undefined
79
+ };
80
+ }
81
+ async function buildTaishanPiFlashPlan(request) {
82
+ const imageDir = request.image_dir;
83
+ const missingFiles = [];
84
+ const required = [
85
+ "MiniLoaderAll.bin",
86
+ "parameter.txt",
87
+ "uboot.img",
88
+ "boot.img",
89
+ "rootfs.img",
90
+ "userdata.img"
91
+ ];
92
+ const optional = ["misc.img", "recovery.img", "oem.img"];
93
+ const partitions = [];
94
+ if (!imageDir) {
95
+ missingFiles.push("image_dir");
96
+ }
97
+ else {
98
+ for (const name of required) {
99
+ const path = join(imageDir, name);
100
+ try {
101
+ const fileStat = await stat(path);
102
+ partitions.push({
103
+ partition: partitionName(name),
104
+ image_path: path,
105
+ required: true,
106
+ size_bytes: fileStat.size,
107
+ sha256: await sha256(path)
108
+ });
109
+ }
110
+ catch {
111
+ missingFiles.push(path);
112
+ }
113
+ }
114
+ for (const name of optional) {
115
+ const path = join(imageDir, name);
116
+ try {
117
+ const fileStat = await stat(path);
118
+ partitions.push({
119
+ partition: partitionName(name),
120
+ image_path: path,
121
+ required: false,
122
+ size_bytes: fileStat.size,
123
+ sha256: await sha256(path)
124
+ });
125
+ }
126
+ catch {
127
+ // Optional image.
128
+ }
129
+ }
130
+ }
131
+ const missingTools = [];
132
+ if (!await commandExists("rkdeveloptool")) {
133
+ missingTools.push("rkdeveloptool");
134
+ }
135
+ return {
136
+ plan_id: `plan_${Date.now()}_taishanpi`,
137
+ board_id: "taishanpi",
138
+ variant_id: request.variant_id,
139
+ hardware_profile_id: request.hardware_profile_id,
140
+ profile_id: request.profile_id ?? "rk356x-full-image-local",
141
+ destructive: true,
142
+ approval_required: true,
143
+ ready: missingFiles.length === 0 && missingTools.length === 0,
144
+ summary: missingFiles.length === 0 && missingTools.length === 0
145
+ ? `TaishanPi image set is complete. Destructive flash still requires explicit approval.`
146
+ : "TaishanPi flash plan is not ready; missing images or local tools.",
147
+ partitions,
148
+ required_tools: ["rkdeveloptool"],
149
+ missing_tools: missingTools,
150
+ missing_files: missingFiles,
151
+ warnings: [{
152
+ code: "taishanpi_flash_guardrail",
153
+ message: "TaishanPi real flashing is intentionally blocked until exact hardware_profile and Board Pack command templates are accepted.",
154
+ remediation: "Use this plan as validation evidence. Enable real TaishanPi flash only after EL-010 profile commands are reviewed."
155
+ }]
156
+ };
157
+ }
158
+ function partitionName(fileName) {
159
+ return fileName.replace(/\.img$|\.bin$|\.txt$/g, "").replace("MiniLoaderAll", "loader");
160
+ }
161
+ async function sha256(path) {
162
+ const hash = createHash("sha256");
163
+ const stream = createReadStream(path);
164
+ for await (const chunk of stream) {
165
+ hash.update(chunk);
166
+ }
167
+ return hash.digest("hex");
168
+ }
169
+ //# sourceMappingURL=flash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flash.js","sourceRoot":"","sources":["../../src/adapters/flash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAM3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAyB;IAC5D,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO;QACL,OAAO,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,SAAS;QAC3C,WAAW,EAAE,IAAI;QACjB,iBAAiB,EAAE,IAAI;QACvB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,8CAA8C,OAAO,CAAC,QAAQ,GAAG;QAC1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IAC/B,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { TcpProbeEvidence } from "@embed-labs/protocol";
2
+ export declare function probeTcp(host: string, port: number, timeoutMs: number): Promise<boolean>;
3
+ export declare function probeTcpWithEvidence(host: string, port: number, timeoutMs: number, observedAt: string): Promise<TcpProbeEvidence>;
4
+ export declare function runBoundedSsh(host: string, user: string, command: string, timeoutSeconds?: number): Promise<{
5
+ readonly ok: false;
6
+ readonly error: {
7
+ readonly code: "ssh_not_found";
8
+ readonly message: "ssh binary was not found on PATH.";
9
+ readonly remediation: "Install OpenSSH client or add ssh to PATH.";
10
+ };
11
+ exit_code?: undefined;
12
+ stdout?: undefined;
13
+ stderr?: undefined;
14
+ output_tail?: undefined;
15
+ } | {
16
+ ok: boolean;
17
+ exit_code: number | null;
18
+ stdout: string;
19
+ stderr: string;
20
+ output_tail: string[];
21
+ readonly error?: undefined;
22
+ }>;