@deeeed/metamask-harness 0.57.0 → 0.58.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.
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
3
3
  import fs, { constants as fsConstants } from "node:fs";
4
4
  import path from "node:path";
5
5
  import { mobileSourceFingerprint } from "./adapters/mobile/source-freshness.js";
6
+ import { indexArtifactManifest } from "./artifact-files.js";
6
7
  import { importRecipeProtocol, runnerDir } from "./paths.js";
7
8
  const gitContexts = /* @__PURE__ */ new Map();
8
9
  let protocolPromise;
@@ -102,7 +103,7 @@ function executionProvenanceDrift(start, current) {
102
103
  }
103
104
  return drift;
104
105
  }
105
- function writeExecutionProvenance(artifactsDir, snapshots, drift, artifactManifestPath) {
106
+ async function writeExecutionProvenance(artifactsDir, snapshots, drift, artifactManifestPath) {
106
107
  const provenancePath = path.join(path.resolve(artifactsDir), "execution-provenance.json");
107
108
  const record = {
108
109
  schemaVersion: 1,
@@ -113,7 +114,20 @@ function writeExecutionProvenance(artifactsDir, snapshots, drift, artifactManife
113
114
  fs.mkdirSync(path.dirname(provenancePath), { recursive: true });
114
115
  fs.writeFileSync(provenancePath, `${JSON.stringify(record, null, 2)}
115
116
  `);
116
- if (artifactManifestPath) indexProvenanceArtifact(artifactManifestPath, record);
117
+ if (artifactManifestPath) {
118
+ await indexArtifactManifest(artifactManifestPath, [
119
+ {
120
+ path: "execution-provenance.json",
121
+ type: "json",
122
+ label: "Execution provenance",
123
+ category: "system",
124
+ metadata: {
125
+ valid: record.valid,
126
+ errorCode: record.valid ? null : "PROVENANCE_DRIFT"
127
+ }
128
+ }
129
+ ]);
130
+ }
117
131
  return provenancePath;
118
132
  }
119
133
  function recipeFileDigest(protocol, recipePath) {
@@ -309,32 +323,6 @@ function compareSource(drift, phase, prefix, start, current) {
309
323
  function compare(drift, phase, field, start, current) {
310
324
  if (start !== current) drift.push({ phase, field, start, current });
311
325
  }
312
- function indexProvenanceArtifact(artifactManifestPath, record) {
313
- let manifest;
314
- try {
315
- manifest = JSON.parse(fs.readFileSync(artifactManifestPath, "utf8"));
316
- } catch {
317
- return;
318
- }
319
- if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) return;
320
- const document = manifest;
321
- const artifacts = Array.isArray(document.artifacts) ? document.artifacts : [];
322
- document.artifacts = [
323
- ...artifacts.filter((artifact) => !artifact || typeof artifact !== "object" || Array.isArray(artifact) || artifact.path !== "execution-provenance.json"),
324
- {
325
- path: "execution-provenance.json",
326
- type: "json",
327
- label: "Execution provenance",
328
- category: "system",
329
- metadata: {
330
- valid: record.valid,
331
- errorCode: record.valid ? null : "PROVENANCE_DRIFT"
332
- }
333
- }
334
- ];
335
- fs.writeFileSync(artifactManifestPath, `${JSON.stringify(document, null, 2)}
336
- `);
337
- }
338
326
  export {
339
327
  ProvenanceDriftError,
340
328
  captureExecutionProvenance,
package/dist/harness.js CHANGED
@@ -259,6 +259,9 @@ Next: mm-harness install --platform core --target ${target}`
259
259
  }
260
260
  return { command: delegate, prefixArgs: ["doctor", "--adapter", "core"] };
261
261
  }
262
+ if (adapter === "mobile" && action === "verify") {
263
+ return { inProcess: "mobile-verify" };
264
+ }
262
265
  const installedScript = path.join(recipeHarnessPath(target, adapter), "scripts", `${action}.sh`);
263
266
  if (fs.existsSync(installedScript)) {
264
267
  return { command: installedScript, prefixArgs: [] };
@@ -336,6 +339,29 @@ async function handleHarness(argv) {
336
339
  console.error(colorHumanMessage(`\u2192 ${harnessAction} (${adapter}${detected}) \u2014 target: ${target}`));
337
340
  }
338
341
  const start = Date.now();
342
+ if ("inProcess" in dispatch) {
343
+ const { runMobileVerify } = await import("./adapters/mobile/verify.js");
344
+ let exitCode;
345
+ try {
346
+ exitCode = await runMobileVerify(forwardArgs, {
347
+ out: quiet ? () => {
348
+ } : (line) => {
349
+ (json ? process.stderr : process.stdout).write(`${line}
350
+ `);
351
+ },
352
+ err: quiet ? () => {
353
+ } : (line) => {
354
+ process.stderr.write(`${line}
355
+ `);
356
+ }
357
+ });
358
+ } catch (error) {
359
+ if (!quiet) process.stderr.write(`${error instanceof Error ? error.message : String(error)}
360
+ `);
361
+ exitCode = 1;
362
+ }
363
+ return reportHarnessOutcome(harnessAction, adapter, target, exitCode, autoDetected, json, quiet, start);
364
+ }
339
365
  if (shellLeafMissing(dispatch.command)) {
340
366
  const message = missingShellLeafMessage(dispatch.command);
341
367
  if (quiet) {
@@ -363,7 +389,6 @@ async function handleHarness(argv) {
363
389
  stdio: quiet ? "ignore" : json ? ["inherit", 2, "inherit"] : "inherit",
364
390
  env: process.env
365
391
  });
366
- const seconds = ((Date.now() - start) / 1e3).toFixed(1);
367
392
  if (result.error) {
368
393
  if (quiet) {
369
394
  return 1;
@@ -381,27 +406,30 @@ async function handleHarness(argv) {
381
406
  }
382
407
  return 1;
383
408
  }
384
- const exitCode = result.status ?? 1;
409
+ return reportHarnessOutcome(harnessAction, adapter, target, result.status ?? 1, autoDetected, json, quiet, start);
410
+ }
411
+ function reportHarnessOutcome(action, adapter, target, exitCode, autoDetected, json, quiet, start) {
412
+ const seconds = ((Date.now() - start) / 1e3).toFixed(1);
385
413
  if (quiet) {
386
414
  return exitCode;
387
415
  } else if (json) {
388
416
  console.log(
389
417
  harnessSummary(
390
- harnessAction,
418
+ action,
391
419
  adapter,
392
420
  target,
393
421
  exitCode === 0 ? "pass" : "fail",
394
422
  exitCode,
395
423
  autoDetected,
396
- exitCode === 0 ? void 0 : { code: "HARNESS_FAILED", message: `${harnessAction} ${adapter} failed (exit ${exitCode})`, userAction: failureHint(adapter, harnessAction) }
424
+ exitCode === 0 ? void 0 : { code: "HARNESS_FAILED", message: `${action} ${adapter} failed (exit ${exitCode})`, userAction: failureHint(adapter, action) }
397
425
  )
398
426
  );
399
427
  } else if (exitCode === 0) {
400
- console.error(colorHumanMessage(`\u2713 ${harnessAction} ${adapter} passed (${seconds}s)
401
- Next: ${successNext(adapter, harnessAction, target)}`));
428
+ console.error(colorHumanMessage(`\u2713 ${action} ${adapter} passed (${seconds}s)
429
+ Next: ${successNext(adapter, action, target)}`));
402
430
  } else {
403
- console.error(colorHumanMessage(`\u2717 ${harnessAction} ${adapter} failed (exit ${exitCode}, ${seconds}s)
404
- ${failureHint(adapter, harnessAction)}`));
431
+ console.error(colorHumanMessage(`\u2717 ${action} ${adapter} failed (exit ${exitCode}, ${seconds}s)
432
+ ${failureHint(adapter, action)}`));
405
433
  }
406
434
  return exitCode;
407
435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeeed/metamask-harness",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mm-harness": "bin/mm-harness"
@@ -20,7 +20,7 @@
20
20
  "check:syntax": "find . -name '*.mjs' -print0 | xargs -0 -n1 node --check"
21
21
  },
22
22
  "dependencies": {
23
- "@farmslot/agent-runtime": "0.11.0",
23
+ "@farmslot/agent-runtime": "0.12.0",
24
24
  "@farmslot/expo-recipe": "0.10.0",
25
25
  "@farmslot/handoff": "^0.3.1",
26
26
  "@farmslot/protocol": "0.29.0",