@deeeed/metamask-harness 0.82.1 → 0.84.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/CHANGELOG.md +48 -0
- package/README.md +8 -1
- package/adapters/core/cleanup.sh +5 -29
- package/adapters/core/controller-import-probe.mjs +26 -0
- package/adapters/manifest.json +22 -102
- package/adapters/shared/session-lock.mjs +43 -0
- package/adapters/web-dapp/metamask-signer.mjs +212 -0
- package/dist/adapters/core/actions.js +0 -3
- package/dist/adapters/core/overlay.js +1 -5
- package/dist/adapters/core/readiness.js +133 -2
- package/dist/adapters/core/surface.js +53 -41
- package/dist/adapters/extension/extension-id.js +1 -0
- package/dist/adapters/extension/fixtures.js +60 -1
- package/dist/adapters/extension/network-observer.js +19 -206
- package/dist/adapters/extension/run.js +5 -3
- package/dist/adapters/extension/runtime.js +112 -20
- package/dist/adapters/mobile/android-gfxinfo-performance.js +3 -1
- package/dist/adapters/mobile/devices.js +5 -1
- package/dist/adapters/mobile/performance-observer.js +9 -6
- package/dist/adapters/mobile/run.js +1 -1
- package/dist/adapters/mobile/surface.js +1 -2
- package/dist/adapters/performance/trace-kinds.js +36 -0
- package/dist/adapters/plugin-surface.js +34 -34
- package/dist/adapters/session-lock.js +23 -0
- package/dist/adapters/web-dapp/console-capture.js +2 -20
- package/dist/adapters/web-dapp/run.js +31 -25
- package/dist/adapters/web-dapp/surface.js +32 -108
- package/dist/command-contract.js +1363 -630
- package/dist/commands/core-readiness.js +1 -9
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/launch/device.js +1 -1
- package/dist/doctor.js +5 -2
- package/dist/mm-harness-cli.js +228 -1210
- package/dist/performance-observation.js +28 -5
- package/docs/CONTRIBUTING.md +6 -4
- package/docs/cli-contract.md +1 -1
- package/docs/feature-guard.md +1 -1
- package/library/actions/core/perps/_controller.mjs +10 -0
- package/library/actions/extension/wallet/import.mjs +21 -4
- package/library/actions/extension/wallet/visible-session.mjs +32 -12
- package/library/actions/shared/console-collector.mjs +1 -1
- package/library/actions/web-dapp/app/launch.mjs +1 -1
- package/library/actions/web-dapp/platform/adapter-web-lib.mjs +18 -0
- package/library/actions/web-dapp/platform/hud.mjs +1 -1
- package/library/actions/web-dapp/platform/page.mjs +2 -3
- package/library/actions/web-dapp/platform/runtime.mjs +29 -178
- package/package.json +7 -6
- package/scripts/completions.sh +1 -1
- package/adapters/web-dapp/cleanup.mjs +0 -69
- package/adapters/web-dapp/inject.mjs +0 -75
- package/adapters/web-dapp/launch.mjs +0 -631
- package/adapters/web-dapp/lib/blocked-hosts.mjs +0 -24
- package/adapters/web-dapp/lib/cdp-client.mjs +0 -84
- package/adapters/web-dapp/lib/display.mjs +0 -115
- package/adapters/web-dapp/lib/hud.mjs +0 -148
- package/adapters/web-dapp/lib/policy.mjs +0 -79
- package/adapters/web-dapp/lib/processes.mjs +0 -187
- package/adapters/web-dapp/lib/readiness.mjs +0 -272
- package/adapters/web-dapp/stop.mjs +0 -38
- package/adapters/web-dapp/verify.mjs +0 -51
- package/adapters/web-dapp/wallet-host.mjs +0 -520
- package/dist/adapters/core/live-script-env.js +0 -36
- package/dist/adapters/extension/browser-cdp.js +0 -174
- package/dist/adapters/extension/performance-observer.js +0 -75
- package/dist/adapters/performance/cdp-trace.js +0 -406
- package/dist/adapters/performance/js-task-metrics.js +0 -35
- package/dist/adapters/web-dapp/doctor-checks.js +0 -33
- package/dist/adapters/web-dapp/launch.js +0 -87
- package/dist/adapters/web-dapp/overlay.js +0 -21
- package/dist/adapters/web-dapp/readiness.js +0 -10
- package/dist/adapters/web-dapp/stop.js +0 -20
- package/dist/async.js +0 -19
- package/dist/cli.js +0 -202
|
@@ -1,82 +1,38 @@
|
|
|
1
|
-
import { shellQuote } from "@farmslot/recipe-cli/harness";
|
|
2
1
|
import path from "node:path";
|
|
3
2
|
import { defineAdapter } from "@farmslot/adapter-sdk";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
bindWebDappPolicy as bindPolicy,
|
|
5
|
+
createWebDappAdapter,
|
|
6
|
+
POLICY_ENV,
|
|
7
|
+
SIGNER_MODULE_ENV,
|
|
8
|
+
webDappAdapterId,
|
|
9
|
+
webDappPolicy
|
|
10
|
+
} from "@farmslot/adapter-web/web-dapp";
|
|
11
|
+
import { runnerDir } from "../../paths.js";
|
|
8
12
|
import { adapterRegistry } from "../registry.js";
|
|
9
13
|
import { webDappActions } from "./actions.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { webDappDiagnostics, webDappObservation } from "./run.js";
|
|
13
|
-
function portFromEnv(...names) {
|
|
14
|
-
for (const name of names) {
|
|
15
|
-
const raw = process.env[name];
|
|
16
|
-
if (raw && /^\d+$/u.test(raw)) return Number(raw);
|
|
17
|
-
}
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
20
|
-
function webDappAppPort() {
|
|
21
|
-
return portFromEnv("TERMINAL_APP_PORT", "RECIPE_WATCHER_PORT", "WATCHER_PORT");
|
|
22
|
-
}
|
|
23
|
-
function webDappCdpPort() {
|
|
24
|
-
return portFromEnv("RECIPE_CDP_PORT", "CDP_PORT");
|
|
25
|
-
}
|
|
26
|
-
function webDappSignerFor(target) {
|
|
27
|
-
try {
|
|
28
|
-
const state = JSON.parse(fs.readFileSync(webDappRuntimeFile(target, "browser.json"), "utf8"));
|
|
29
|
-
if (typeof state.signer === "string") return state.signer;
|
|
30
|
-
} catch {
|
|
31
|
-
}
|
|
32
|
-
return process.env.TERMINAL_SIGNER || "extension";
|
|
33
|
-
}
|
|
14
|
+
import { webDappDiagnostics, webDappObservation, webDappRun } from "./run.js";
|
|
15
|
+
const METAMASK_SIGNER_MODULE = path.join(runnerDir, "adapters", "web-dapp", "metamask-signer.mjs");
|
|
34
16
|
function bindWebDappPolicy(adapter) {
|
|
17
|
+
bindPolicy(adapter);
|
|
35
18
|
if (adapter.extends === "web-dapp" && typeof adapter.policy?.module === "string") {
|
|
36
|
-
process.env[
|
|
19
|
+
process.env[SIGNER_MODULE_ENV] = METAMASK_SIGNER_MODULE;
|
|
37
20
|
}
|
|
38
21
|
return adapter;
|
|
39
22
|
}
|
|
40
|
-
const
|
|
23
|
+
const generic = createWebDappAdapter({
|
|
41
24
|
id: "web-dapp",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
deps: "missing",
|
|
54
|
-
devServer: { label: "next", status: "down" }
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const policy = webDappPolicy();
|
|
58
|
-
const { webDappReadiness: webDappReadiness2 } = await import("../../../adapters/web-dapp/lib/readiness.mjs");
|
|
59
|
-
const report = await webDappReadiness2({
|
|
60
|
-
policy,
|
|
61
|
-
target: path.resolve(target),
|
|
62
|
-
appPort: webDappAppPort(),
|
|
63
|
-
cdpPort: webDappCdpPort(),
|
|
64
|
-
signer: process.env.TERMINAL_SIGNER || "extension"
|
|
65
|
-
});
|
|
66
|
-
const blocking = report.checks.filter((check) => check.required && check.status === "fail");
|
|
67
|
-
const devServer = report.checks.find((check) => check.id === "app-dev-server");
|
|
68
|
-
return {
|
|
69
|
-
decision: blocking.length === 0 ? "ready" : "blocked",
|
|
70
|
-
reasonCode: blocking[0]?.id,
|
|
71
|
-
reasons: (blocking.length ? blocking : report.checks).map((check) => `${check.id}: ${check.detail}`),
|
|
72
|
-
nextAction: blocking.length === 0 ? void 0 : blocking[0].id === "app-dev-server" || blocking[0].id === "testnet-forced" ? "start the slot dev server with testnet forced (Farmslot preflight), then retry" : `mm-harness doctor --adapter ${policy.adapterId} --target ${shellQuote(path.resolve(target))} --json`,
|
|
73
|
-
deps: report.checks.find((check) => check.id === "dependencies")?.status === "pass" ? "current" : "missing",
|
|
74
|
-
devServer: {
|
|
75
|
-
label: "next",
|
|
76
|
-
status: devServer?.status === "pass" ? "up" : "down"
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
},
|
|
25
|
+
signerModule: METAMASK_SIGNER_MODULE,
|
|
26
|
+
cli: "mm-harness",
|
|
27
|
+
hooks: {
|
|
28
|
+
actions: webDappActions,
|
|
29
|
+
run: webDappRun,
|
|
30
|
+
diagnostics: webDappDiagnostics,
|
|
31
|
+
observation: webDappObservation
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const webDappSurface = defineAdapter({
|
|
35
|
+
...generic,
|
|
80
36
|
runwayProvision: {
|
|
81
37
|
async run(target, options) {
|
|
82
38
|
return {
|
|
@@ -94,41 +50,12 @@ const webDappSurface = defineAdapter({
|
|
|
94
50
|
};
|
|
95
51
|
}
|
|
96
52
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return { kind: "stopped", status: result.status, summary: result.summary, output: result.output };
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
logSources(target) {
|
|
106
|
-
return [
|
|
107
|
-
{ label: "app-console", path: webDappRuntimeFile(target, WEB_DAPP_CONSOLE_FILES.app) },
|
|
108
|
-
...webDappSignerFor(target) === "extension" ? [{ label: "extension-console", path: webDappRuntimeFile(target, WEB_DAPP_CONSOLE_FILES.extension) }] : [],
|
|
109
|
-
{ label: "wallet-requests", path: webDappRuntimeFile(target, "wallet-requests.jsonl") },
|
|
110
|
-
{ label: "wallet-host", path: webDappRuntimeFile(target, "wallet-host.log") },
|
|
111
|
-
{ label: "browser", path: webDappRuntimeFile(target, "browser.log") },
|
|
112
|
-
{ label: "next", path: path.join(target, "temp/farmslot/next-dev.log") }
|
|
113
|
-
];
|
|
114
|
-
},
|
|
115
|
-
// The app page's console and uncaught exceptions, as the Extension's
|
|
116
|
-
// diagnostics read the extension console: errors make a run REVIEW.
|
|
117
|
-
appLogSource(target) {
|
|
118
|
-
return { label: "app-console", path: webDappRuntimeFile(target, WEB_DAPP_CONSOLE_FILES.app) };
|
|
119
|
-
},
|
|
120
|
-
flags: { launch: ["freshProfile", "headless", "headful"] },
|
|
121
|
-
hints: {
|
|
122
|
-
// Bare web-dapp has no venue: every hint names the adapter that extends it.
|
|
123
|
-
launch: "pass --adapter <the adapter that extends web-dapp>, e.g. --adapter terminal, with its recipe library on RECIPE_LIBRARY_PATH",
|
|
124
|
-
relaunch: "pass --adapter <the adapter that extends web-dapp>, e.g. --adapter terminal, with --fresh-profile",
|
|
125
|
-
runtimeProbeRecovery: () => "pass --adapter <the adapter that extends web-dapp>, e.g. --adapter terminal, with its recipe library on RECIPE_LIBRARY_PATH"
|
|
53
|
+
// adapter-web's slot readiness (with MetaMask's own checks) and capture providers.
|
|
54
|
+
readiness: {
|
|
55
|
+
liveChecks: generic.readiness.liveChecks,
|
|
56
|
+
captureProviders: generic.readiness.captureProviders,
|
|
57
|
+
compatibilityMode: (target) => process.env[POLICY_ENV] && webDappPolicy().checkout.matches(target) ? "slot browser over CDP (website; no product bridge)" : "unsupported/no bridge"
|
|
126
58
|
},
|
|
127
|
-
launch: async (context) => (await import("./launch.js")).launchWebDapp(context),
|
|
128
|
-
actions: webDappActions,
|
|
129
|
-
harness: webDappHarness,
|
|
130
|
-
runtimeContext: webDappRuntimeContext,
|
|
131
|
-
readiness: webDappReadiness,
|
|
132
59
|
fixtures: { operations: ["init", "sync", "set"] },
|
|
133
60
|
debug: {
|
|
134
61
|
args: ({ devMenu }) => [
|
|
@@ -136,14 +63,11 @@ const webDappSurface = defineAdapter({
|
|
|
136
63
|
"--action",
|
|
137
64
|
devMenu ? "dev-menu" : "debug"
|
|
138
65
|
]
|
|
139
|
-
}
|
|
140
|
-
diagnostics: webDappDiagnostics,
|
|
141
|
-
observation: webDappObservation
|
|
66
|
+
}
|
|
142
67
|
});
|
|
143
68
|
adapterRegistry.register(webDappSurface);
|
|
144
69
|
export {
|
|
70
|
+
METAMASK_SIGNER_MODULE,
|
|
145
71
|
bindWebDappPolicy,
|
|
146
|
-
webDappAppPort,
|
|
147
|
-
webDappCdpPort,
|
|
148
72
|
webDappSurface
|
|
149
73
|
};
|