@deeeed/metamask-harness 0.80.0 → 0.82.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 +43 -0
- package/adapters/manifest.json +48 -64
- package/adapters/{terminal → web-dapp}/cleanup.mjs +9 -9
- package/adapters/{terminal → web-dapp}/inject.mjs +14 -14
- package/adapters/{terminal → web-dapp}/launch.mjs +27 -24
- package/adapters/web-dapp/lib/blocked-hosts.mjs +24 -0
- package/adapters/{terminal → web-dapp}/lib/cdp-client.mjs +1 -1
- package/adapters/{terminal → web-dapp}/lib/display.mjs +1 -1
- package/adapters/{terminal → web-dapp}/lib/hud.mjs +1 -1
- package/adapters/web-dapp/lib/policy.mjs +79 -0
- package/adapters/{terminal → web-dapp}/lib/processes.mjs +8 -8
- package/adapters/{terminal → web-dapp}/lib/readiness.mjs +32 -34
- package/adapters/{terminal → web-dapp}/stop.mjs +5 -4
- package/adapters/{terminal → web-dapp}/verify.mjs +9 -6
- package/adapters/{terminal → web-dapp}/wallet-host.mjs +44 -227
- package/dist/adapters/core/actions.js +4 -1
- package/dist/adapters/extension/actions.js +6 -2
- package/dist/adapters/extension/network-observer.js +13 -0
- package/dist/adapters/extension/run.js +115 -31
- package/dist/adapters/mobile/actions.js +4 -1
- package/dist/adapters/mobile/network-observer.js +68 -0
- package/dist/adapters/mobile/performance-observer.js +1 -3
- package/dist/adapters/mobile/run.js +32 -9
- package/dist/adapters/perps-order-inputs.js +36 -0
- package/dist/adapters/plugin-surface.js +98 -0
- package/dist/adapters/proof-failure.js +11 -0
- package/dist/adapters/surface.js +1 -1
- package/dist/adapters/{terminal → web-dapp}/actions.js +11 -8
- package/dist/adapters/web-dapp/console-capture.js +63 -0
- package/dist/adapters/web-dapp/doctor-checks.js +33 -0
- package/dist/adapters/{terminal → web-dapp}/launch.js +21 -19
- package/dist/adapters/web-dapp/overlay.js +21 -0
- package/dist/adapters/web-dapp/readiness.js +10 -0
- package/dist/adapters/{terminal → web-dapp}/run.js +22 -17
- package/dist/adapters/{terminal → web-dapp}/stop.js +5 -4
- package/dist/adapters/web-dapp/surface.js +149 -0
- package/dist/adapters.js +20 -4
- package/dist/cli.js +34 -6
- package/dist/command-contract.js +29 -7
- package/dist/commands/check.js +32 -8
- package/dist/commands/completion-candidates.js +5 -5
- package/dist/commands/doctor.js +19 -2
- package/dist/commands/farmslot-ready.js +1 -0
- package/dist/commands/help.js +1 -1
- package/dist/commands/launch/device.js +5 -5
- package/dist/commands/self-test.js +10 -5
- package/dist/engine.js +47 -0
- package/dist/funding-execution-context.js +81 -0
- package/dist/manifest.js +48 -24
- package/dist/mm-harness-cli.js +20 -3
- package/dist/performance-observation.js +7 -15
- package/dist/recipe-assistance-context.js +6 -7
- package/dist/runner.js +28 -8
- package/docs/CONTRIBUTING.md +4 -2
- package/docs/RECIPES.md +31 -3
- package/docs/cli-contract.md +5 -3
- package/library/actions/core/perps/_controller.mjs +24 -28
- package/library/actions/core/perps/_rewards.mjs +186 -0
- package/library/actions/core/perps/close_positions.mjs +1 -1
- package/library/actions/core/perps/place_order.mjs +167 -45
- package/library/actions/core/perps/quote_fees.mjs +7 -4
- package/library/actions/core/wallet/list_accounts.mjs +1 -1
- package/library/actions/extension/perps/close_visible_position.mjs +5 -0
- package/library/actions/extension/perps/edit_margin.mjs +4 -0
- package/library/actions/extension/perps/mutation-receipt.mjs +95 -3
- package/library/actions/extension/perps/perps.mjs +320 -3
- package/library/actions/extension/perps/place_order.mjs +3 -1
- package/library/actions/extension/perps/update_position_tpsl.mjs +4 -0
- package/library/actions/extension/platform/cdp.mjs +71 -3
- package/library/actions/mobile/perps/perps.mjs +216 -11
- package/library/actions/mobile/perps/place_order.mjs +3 -1
- package/library/actions/shared/console-collector.mjs +1 -1
- package/library/actions/shared/perps/order-policy.mjs +177 -0
- package/library/actions/{core/wallet/_fixture-accounts.mjs → shared/wallet/fixture-accounts.mjs} +18 -3
- package/library/actions/{terminal → web-dapp}/app/assert_no_console_errors.mjs +4 -4
- package/library/actions/{terminal → web-dapp}/app/launch.mjs +8 -7
- package/library/actions/{terminal → web-dapp}/platform/hud.mjs +7 -6
- package/library/actions/{terminal → web-dapp}/platform/page.mjs +13 -12
- package/library/actions/{terminal → web-dapp}/platform/runtime.mjs +16 -12
- package/library/actions/web-dapp/ui/navigate.mjs +24 -0
- package/library/actions/web-dapp/wallet/_signature-log.mjs +32 -0
- package/library/actions/{terminal → web-dapp}/wallet/assert_signatures.mjs +8 -14
- package/library/actions/{terminal → web-dapp}/wallet/list_accounts.mjs +2 -2
- package/library/actions/web-dapp/wallet/read_signatures.mjs +38 -0
- package/library/manifests/core.action-manifest.json +6 -2
- package/library/manifests/extension.action-manifest.json +4 -0
- package/library/manifests/mobile.action-manifest.json +12 -0
- package/library/manifests/{terminal.action-manifest.json → web-dapp.action-manifest.json} +18 -702
- package/package.json +6 -6
- package/site/assets/help-recipes.json +1 -0
- package/adapters/terminal/lib/mainnet-guard.mjs +0 -177
- package/adapters/terminal/lib/origin.mjs +0 -30
- package/adapters/terminal/lib/page-script.mjs +0 -246
- package/adapters/terminal/lib/strict-wallet.mjs +0 -138
- package/dist/adapters/terminal/console-capture.js +0 -59
- package/dist/adapters/terminal/doctor-checks.js +0 -22
- package/dist/adapters/terminal/overlay.js +0 -18
- package/dist/adapters/terminal/readiness.js +0 -11
- package/dist/adapters/terminal/surface.js +0 -133
- package/dist/commands/call.js +0 -671
- package/dist/commands/list-executables.js +0 -245
- package/dist/commands/manifest.js +0 -477
- package/dist/commands/run-engine.js +0 -1301
- package/dist/commands/run.js +0 -730
- package/dist/discovery.js +0 -15
- package/dist/metamask-action-validation.js +0 -68
- package/dist/network-observation.js +0 -290
- package/library/actions/terminal/perps/_venue.mjs +0 -242
- package/library/actions/terminal/perps/assert_orders.mjs +0 -54
- package/library/actions/terminal/perps/assert_positions.mjs +0 -40
- package/library/actions/terminal/perps/read_orders.mjs +0 -26
- package/library/actions/terminal/perps/read_positions.mjs +0 -25
- package/library/actions/terminal/perps/read_snapshot.mjs +0 -40
- package/library/actions/terminal/perps/revoke_agent.mjs +0 -58
- package/library/actions/terminal/perps/teardown_state.mjs +0 -104
- package/library/actions/terminal/ui/navigate.mjs +0 -31
- package/library/actions/terminal/wallet/_signature-log.mjs +0 -177
- package/library/actions/terminal/wallet/read_signatures.mjs +0 -37
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { recipeRuntimePath } from "@farmslot/recipe-cli/harness";
|
|
4
|
-
import { verifyCapture } from "../../../library/actions/shared/console-collector.mjs";
|
|
5
|
-
import { ensureConsoleCollector } from "../console-capture.js";
|
|
6
|
-
const TERMINAL_CONSOLE_FILES = Object.freeze({
|
|
7
|
-
app: "app-console.log",
|
|
8
|
-
extension: "extension-console.log",
|
|
9
|
-
collectorLog: "console-tail.log",
|
|
10
|
-
pidFile: "console-tail.pid"
|
|
11
|
-
});
|
|
12
|
-
function terminalRuntimeFile(target, name) {
|
|
13
|
-
let root = path.resolve(target);
|
|
14
|
-
try {
|
|
15
|
-
root = fs.realpathSync(root);
|
|
16
|
-
} catch {
|
|
17
|
-
}
|
|
18
|
-
return recipeRuntimePath(root, "terminal", name);
|
|
19
|
-
}
|
|
20
|
-
function terminalCaptureFiles(target) {
|
|
21
|
-
return {
|
|
22
|
-
extensionLog: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.extension),
|
|
23
|
-
pageLog: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.app),
|
|
24
|
-
collectorLog: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.collectorLog),
|
|
25
|
-
pidFile: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.pidFile)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function terminalCdpPort() {
|
|
29
|
-
return process.env.RECIPE_CDP_PORT ?? process.env.CDP_PORT;
|
|
30
|
-
}
|
|
31
|
-
async function ensureTerminalConsoleCapture(target) {
|
|
32
|
-
const cdpPort = terminalCdpPort();
|
|
33
|
-
if (!cdpPort) throw new Error("Terminal console capture requires the slot CDP port.");
|
|
34
|
-
await ensureConsoleCollector({
|
|
35
|
-
cdpPort,
|
|
36
|
-
...terminalCaptureFiles(target),
|
|
37
|
-
waitForAttachment: false,
|
|
38
|
-
cwd: target
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async function verifyTerminalConsoleControl(capture) {
|
|
42
|
-
let browser = null;
|
|
43
|
-
try {
|
|
44
|
-
const value = JSON.parse(fs.readFileSync(terminalRuntimeFile(capture.projectRoot, "browser.json"), "utf8"));
|
|
45
|
-
browser = typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
46
|
-
} catch {
|
|
47
|
-
browser = null;
|
|
48
|
-
}
|
|
49
|
-
if (typeof browser?.appOrigin !== "string") return { ok: false, detail: "no slot browser state (browser.json) to verify the page console capture against" };
|
|
50
|
-
return verifyCapture({ cdpPort: capture.cdpPort, log: capture.pageLog, target: "page", appOrigin: browser.appOrigin });
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
TERMINAL_CONSOLE_FILES,
|
|
54
|
-
ensureTerminalConsoleCapture,
|
|
55
|
-
terminalCaptureFiles,
|
|
56
|
-
terminalCdpPort,
|
|
57
|
-
terminalRuntimeFile,
|
|
58
|
-
verifyTerminalConsoleControl
|
|
59
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { terminalAppPort, terminalCdpPort } from "./surface.js";
|
|
2
|
-
async function terminalDoctorChecks(target) {
|
|
3
|
-
const { terminalReadiness } = await import("../../../adapters/terminal/lib/readiness.mjs");
|
|
4
|
-
const { resolveBrowser } = await import("../../../adapters/terminal/launch.mjs");
|
|
5
|
-
const report = await terminalReadiness({
|
|
6
|
-
target,
|
|
7
|
-
appPort: terminalAppPort(),
|
|
8
|
-
cdpPort: terminalCdpPort(),
|
|
9
|
-
signer: process.env.TERMINAL_SIGNER || "extension",
|
|
10
|
-
account: process.env.TERMINAL_ACCOUNT || "dev1",
|
|
11
|
-
probeBrowser: resolveBrowser
|
|
12
|
-
});
|
|
13
|
-
return report.checks.map((check) => ({
|
|
14
|
-
id: `terminal-${check.id}`,
|
|
15
|
-
status: check.status === "pass" ? "pass" : "fail",
|
|
16
|
-
required: check.required,
|
|
17
|
-
message: check.detail
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
terminalDoctorChecks
|
|
22
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { runnerDir } from "../../paths.js";
|
|
3
|
-
const terminalHarness = {
|
|
4
|
-
install: { entry: "adapters/terminal/inject.mjs", fallback: "adapters/terminal/inject.mjs", node: true },
|
|
5
|
-
cleanup: { entry: "adapters/terminal/cleanup.mjs", fallback: "adapters/terminal/cleanup.mjs", node: true },
|
|
6
|
-
verify: () => ({ command: process.execPath, prefixArgs: [path.join(runnerDir, "adapters", "terminal", "verify.mjs")] }),
|
|
7
|
-
restart: "mm-harness launch"
|
|
8
|
-
};
|
|
9
|
-
const terminalRuntimeContext = {
|
|
10
|
-
forbiddenFields: ["metroPort", "simulator", "simulatorUdid", "adbSerial", "extensionId"],
|
|
11
|
-
resources: ({ existing, defaults, envPort }) => ({
|
|
12
|
-
cdpPort: envPort("RECIPE_CDP_PORT", "CDP_PORT") ?? existing.cdpPort ?? defaults.cdpPort
|
|
13
|
-
})
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
terminalHarness,
|
|
17
|
-
terminalRuntimeContext
|
|
18
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const terminalReadiness = {
|
|
4
|
-
compatibilityMode: (target) => fs.existsSync(path.join(target, "src/features/perpetuals")) ? "slot browser over CDP (website; no product bridge)" : "unsupported/no bridge",
|
|
5
|
-
liveChecks: async (target) => (await import("./doctor-checks.js")).terminalDoctorChecks(target),
|
|
6
|
-
// Screenshots come from the slot browser over CDP.
|
|
7
|
-
captureProviders: ["cdp"]
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
terminalReadiness
|
|
11
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { shellQuote } from "@farmslot/recipe-cli/harness";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { defineAdapter } from "@farmslot/adapter-sdk";
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
import { TERMINAL_CONSOLE_FILES, terminalRuntimeFile } from "./console-capture.js";
|
|
6
|
-
import { stopTerminalBrowserSync } from "./stop.js";
|
|
7
|
-
import { adapterRegistry } from "../registry.js";
|
|
8
|
-
import { terminalActions } from "./actions.js";
|
|
9
|
-
import { terminalHarness, terminalRuntimeContext } from "./overlay.js";
|
|
10
|
-
import { terminalReadiness } from "./readiness.js";
|
|
11
|
-
import { terminalDiagnostics, terminalObservation } from "./run.js";
|
|
12
|
-
import { checkoutHas, checkoutHasDir } from "../checkout-files.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 terminalAppPort() {
|
|
21
|
-
return portFromEnv("TERMINAL_APP_PORT", "RECIPE_WATCHER_PORT", "WATCHER_PORT");
|
|
22
|
-
}
|
|
23
|
-
function terminalCdpPort() {
|
|
24
|
-
return portFromEnv("RECIPE_CDP_PORT", "CDP_PORT");
|
|
25
|
-
}
|
|
26
|
-
function terminalSignerFor(target) {
|
|
27
|
-
try {
|
|
28
|
-
const state = JSON.parse(fs.readFileSync(terminalRuntimeFile(target, "browser.json"), "utf8"));
|
|
29
|
-
if (typeof state.signer === "string") return state.signer;
|
|
30
|
-
} catch {
|
|
31
|
-
}
|
|
32
|
-
return process.env.TERMINAL_SIGNER || "extension";
|
|
33
|
-
}
|
|
34
|
-
const terminalSurface = defineAdapter({
|
|
35
|
-
id: "terminal",
|
|
36
|
-
sdkVersion: 1,
|
|
37
|
-
headless: false,
|
|
38
|
-
resolveSlotPorts() {
|
|
39
|
-
},
|
|
40
|
-
async runtimeStatus(target) {
|
|
41
|
-
const { terminalReadiness: terminalReadiness2 } = await import("../../../adapters/terminal/lib/readiness.mjs");
|
|
42
|
-
const report = await terminalReadiness2({
|
|
43
|
-
target: path.resolve(target),
|
|
44
|
-
appPort: terminalAppPort(),
|
|
45
|
-
cdpPort: terminalCdpPort(),
|
|
46
|
-
signer: process.env.TERMINAL_SIGNER || "extension"
|
|
47
|
-
});
|
|
48
|
-
const blocking = report.checks.filter((check) => check.required && check.status === "fail");
|
|
49
|
-
const devServer = report.checks.find((check) => check.id === "app-dev-server");
|
|
50
|
-
return {
|
|
51
|
-
decision: blocking.length === 0 ? "ready" : "blocked",
|
|
52
|
-
reasonCode: blocking[0]?.id,
|
|
53
|
-
reasons: (blocking.length ? blocking : report.checks).map((check) => `${check.id}: ${check.detail}`),
|
|
54
|
-
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 terminal --target ${shellQuote(path.resolve(target))} --json`,
|
|
55
|
-
deps: report.checks.find((check) => check.id === "dependencies")?.status === "pass" ? "current" : "missing",
|
|
56
|
-
devServer: {
|
|
57
|
-
label: "next",
|
|
58
|
-
status: devServer?.status === "pass" ? "up" : "down"
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
runwayProvision: {
|
|
63
|
-
async run(target, options) {
|
|
64
|
-
return {
|
|
65
|
-
schemaVersion: 1,
|
|
66
|
-
command: "provision",
|
|
67
|
-
adapter: "terminal",
|
|
68
|
-
target: path.resolve(target),
|
|
69
|
-
status: "fail",
|
|
70
|
-
exitCode: 2,
|
|
71
|
-
error: {
|
|
72
|
-
code: "UNSUPPORTED_ADAPTER",
|
|
73
|
-
message: "the Web Terminal is a website; there is no simulator or build to provision.",
|
|
74
|
-
userAction: options.rerunCommand || "mm-harness launch --adapter terminal"
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
devServer: {
|
|
80
|
-
label: "browser",
|
|
81
|
-
describe: () => "terminal slot browser and wallet host (the Next.js dev server belongs to the slot)",
|
|
82
|
-
stop(target) {
|
|
83
|
-
const result = stopTerminalBrowserSync(target);
|
|
84
|
-
return { kind: "stopped", status: result.status, summary: result.summary, output: result.output };
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
logSources(target) {
|
|
88
|
-
return [
|
|
89
|
-
{ label: "app-console", path: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.app) },
|
|
90
|
-
...terminalSignerFor(target) === "extension" ? [{ label: "extension-console", path: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.extension) }] : [],
|
|
91
|
-
{ label: "wallet-requests", path: terminalRuntimeFile(target, "wallet-requests.jsonl") },
|
|
92
|
-
{ label: "wallet-host", path: terminalRuntimeFile(target, "wallet-host.log") },
|
|
93
|
-
{ label: "browser", path: terminalRuntimeFile(target, "browser.log") },
|
|
94
|
-
{ label: "next", path: path.join(target, "temp/farmslot/next-dev.log") }
|
|
95
|
-
];
|
|
96
|
-
},
|
|
97
|
-
// The terminal page's console and uncaught exceptions, as the Extension's
|
|
98
|
-
// diagnostics read the extension console: errors make a run REVIEW.
|
|
99
|
-
appLogSource(target) {
|
|
100
|
-
return { label: "app-console", path: terminalRuntimeFile(target, TERMINAL_CONSOLE_FILES.app) };
|
|
101
|
-
},
|
|
102
|
-
detect: {
|
|
103
|
-
remote: (url) => url.includes("va-mmcx-terminal"),
|
|
104
|
-
files: (target) => checkoutHasDir(target, "src/features/perpetuals") && ["next.config.ts", "next.config.mjs", "next.config.js"].some((file) => checkoutHas(target, file))
|
|
105
|
-
},
|
|
106
|
-
flags: { launch: ["freshProfile", "headless", "headful"] },
|
|
107
|
-
hints: {
|
|
108
|
-
launch: "mm-harness launch --adapter terminal --cdp-port <port> --watcher-port <app port>",
|
|
109
|
-
relaunch: "mm-harness launch --adapter terminal --fresh-profile",
|
|
110
|
-
runtimeProbeRecovery: (target) => `mm-harness doctor --adapter terminal --target ${shellQuote(path.resolve(target))}`
|
|
111
|
-
},
|
|
112
|
-
launch: async (context) => (await import("./launch.js")).launchTerminal(context),
|
|
113
|
-
actions: terminalActions,
|
|
114
|
-
harness: terminalHarness,
|
|
115
|
-
runtimeContext: terminalRuntimeContext,
|
|
116
|
-
readiness: terminalReadiness,
|
|
117
|
-
fixtures: { operations: ["init", "sync", "set"] },
|
|
118
|
-
debug: {
|
|
119
|
-
args: ({ devMenu }) => [
|
|
120
|
-
...process.env.WATCHER_PORT ? ["--port", process.env.WATCHER_PORT] : [],
|
|
121
|
-
"--action",
|
|
122
|
-
devMenu ? "dev-menu" : "debug"
|
|
123
|
-
]
|
|
124
|
-
},
|
|
125
|
-
diagnostics: terminalDiagnostics,
|
|
126
|
-
observation: terminalObservation
|
|
127
|
-
});
|
|
128
|
-
adapterRegistry.register(terminalSurface);
|
|
129
|
-
export {
|
|
130
|
-
terminalAppPort,
|
|
131
|
-
terminalCdpPort,
|
|
132
|
-
terminalSurface
|
|
133
|
-
};
|