@deeeed/metamask-harness 0.20.0 → 0.21.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 +10 -0
- package/adapters/core/inject.sh +1 -3
- package/adapters/extension/inject.mjs +1 -1
- package/adapters/mobile/inject.sh +1 -1
- package/dist/commands/call.js +1 -1
- package/dist/commands/manifest.js +15 -21
- package/dist/manifest.js +85 -101
- package/dist/runner.js +9 -4
- package/docs/RECIPES.md +2 -11
- package/library/manifests/core.action-manifest.json +316 -501
- package/library/manifests/extension.action-manifest.json +609 -920
- package/library/manifests/mobile.action-manifest.json +630 -954
- package/package.json +4 -4
- package/library/library.json +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.21.0 - 2026-07-24
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Simplified action manifests to one schema-backed keyed action map; action kind,
|
|
10
|
+
library identity, categories, and provenance are inferred from authoritative
|
|
11
|
+
runtime inputs.
|
|
12
|
+
- Updated the Farmslot protocol, agent runtime, and recipe harness dependencies
|
|
13
|
+
for Recipe Protocol v1 trace consistency.
|
|
14
|
+
|
|
5
15
|
## 0.20.0 - 2026-07-24
|
|
6
16
|
|
|
7
17
|
### Added
|
package/adapters/core/inject.sh
CHANGED
|
@@ -111,9 +111,7 @@ install_v1_runner_assets() {
|
|
|
111
111
|
rsync -a --delete "$METAMASK_RUNNER_DIR/library/recipes/" "$HARNESS_DIR/runner/recipes/"
|
|
112
112
|
fi
|
|
113
113
|
rm -rf "$HARNESS_DIR/runner/flows"
|
|
114
|
-
|
|
115
|
-
cp "$METAMASK_RUNNER_DIR/library/library.json" "$HARNESS_DIR/runner/library.json"
|
|
116
|
-
fi
|
|
114
|
+
rm -f "$HARNESS_DIR/runner/library.json"
|
|
117
115
|
if [ ! -x "$HARNESS_DIR/runner/bin/mm-harness" ]; then
|
|
118
116
|
echo "Refusing core recipe harness install: failed to make runner executable." >&2
|
|
119
117
|
return 1
|
|
@@ -90,8 +90,8 @@ copyFile(path.join(runnerDir, 'library/manifests/mobile.action-manifest.json'),
|
|
|
90
90
|
copyFile(path.join(runnerDir, 'library/manifests/extension.action-manifest.json'), path.join(harnessDir, 'runner/manifests/extension.action-manifest.json'));
|
|
91
91
|
copyFile(path.join(runnerDir, 'library/manifests/extension.action-manifest.json'), path.join(harnessDir, 'action-manifest.json'));
|
|
92
92
|
copyDir(path.join(runnerDir, 'library/recipes'), path.join(harnessDir, 'runner/recipes'));
|
|
93
|
-
copyFile(path.join(runnerDir, 'library/library.json'), path.join(harnessDir, 'runner/library.json'));
|
|
94
93
|
fs.rmSync(path.join(harnessDir, 'runner/flows'), { recursive: true, force: true });
|
|
94
|
+
fs.rmSync(path.join(harnessDir, 'runner/library.json'), { force: true });
|
|
95
95
|
// The installed overlay has a flat scripts/ runtime API independent of the
|
|
96
96
|
// package's source layout.
|
|
97
97
|
copyFile(path.join(runnerDir, 'adapters/extension/launch-browser.cjs'), path.join(harnessDir, 'scripts/launch-browser.cjs'));
|
|
@@ -74,8 +74,8 @@ cp "$RUNNER_DIR/library/manifests/mobile.action-manifest.json" "$HARNESS_DIR/act
|
|
|
74
74
|
cp "$RUNNER_DIR/library/manifests/mobile.action-manifest.json" "$HARNESS_DIR/runner/manifests/mobile.action-manifest.json"
|
|
75
75
|
cp "$RUNNER_DIR/library/manifests/extension.action-manifest.json" "$HARNESS_DIR/runner/manifests/extension.action-manifest.json"
|
|
76
76
|
rsync -a --delete "$RUNNER_DIR/library/recipes/" "$HARNESS_DIR/runner/recipes/"
|
|
77
|
-
cp "$RUNNER_DIR/library/library.json" "$HARNESS_DIR/runner/library.json"
|
|
78
77
|
rm -rf "$HARNESS_DIR/runner/flows"
|
|
78
|
+
rm -f "$HARNESS_DIR/runner/library.json"
|
|
79
79
|
cp "$RUNNER_DIR/adapters/mobile/verify.sh" "$HARNESS_DIR/scripts/verify.sh"
|
|
80
80
|
cp "$RUNNER_DIR/adapters/shared/harness-path.sh" "$HARNESS_DIR/scripts/lib/harness-path.sh"
|
|
81
81
|
cp "$RUNNER_DIR/adapters/shared/path-defaults.json" "$HARNESS_DIR/scripts/lib/path-defaults.json"
|
package/dist/commands/call.js
CHANGED
|
@@ -470,7 +470,7 @@ function renderCallExamples(short, examples) {
|
|
|
470
470
|
if (!Array.isArray(examples)) return [];
|
|
471
471
|
const out = [];
|
|
472
472
|
for (const example of examples.slice(0, 2)) {
|
|
473
|
-
const node = isRecord(example)
|
|
473
|
+
const node = isRecord(example) ? example : void 0;
|
|
474
474
|
if (!node) continue;
|
|
475
475
|
const tokens = Object.entries(node).filter(([key]) => key !== "action" && key !== "intent").map(([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`);
|
|
476
476
|
out.push(`mm-harness call ${short} ${tokens.join(" ")}`.trim());
|
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
import { resolveMetaMaskLibrarySources } from "./run-engine.js";
|
|
13
13
|
import { isSensitiveKey, redactStructuredValue } from "../command-journal.js";
|
|
14
14
|
import {
|
|
15
|
+
OFFICIAL_RECIPE_ACTIONS,
|
|
15
16
|
officialRecipeActionCapabilities
|
|
16
17
|
} from "@farmslot/protocol";
|
|
17
18
|
import { metaMaskActionExecutionCapabilities } from "../recipe-security.js";
|
|
18
19
|
import { closest } from "../command-contract.js";
|
|
20
|
+
const OFFICIAL_ACTIONS = new Set(OFFICIAL_RECIPE_ACTIONS);
|
|
19
21
|
async function handleActions({ options, positional }) {
|
|
20
22
|
const { adapter, target } = resolveAdapter(options);
|
|
21
23
|
const librarySources = await resolveMetaMaskLibrarySources(optionStrings(options, "library"));
|
|
@@ -211,7 +213,7 @@ function authoredExampleNode(examples, preferredValues, schema) {
|
|
|
211
213
|
if (!Array.isArray(examples)) return void 0;
|
|
212
214
|
if (preferredValues && Object.keys(preferredValues).length > 0) {
|
|
213
215
|
const normalizedValues = normalizePreferredValues(preferredValues, schema);
|
|
214
|
-
const nodes = examples.
|
|
216
|
+
const nodes = examples.filter(isRecord);
|
|
215
217
|
if (nodes.length === 0) return void 0;
|
|
216
218
|
const ranked = nodes.map((node) => ({
|
|
217
219
|
node,
|
|
@@ -226,7 +228,7 @@ function authoredExampleNode(examples, preferredValues, schema) {
|
|
|
226
228
|
return { ...ranked[0].node, ...normalizedValues };
|
|
227
229
|
}
|
|
228
230
|
for (const example of examples) {
|
|
229
|
-
if (isRecord(example)
|
|
231
|
+
if (isRecord(example)) return example;
|
|
230
232
|
}
|
|
231
233
|
return void 0;
|
|
232
234
|
}
|
|
@@ -305,22 +307,15 @@ function summarizeActionCategories(actions) {
|
|
|
305
307
|
}
|
|
306
308
|
function describeManifestActions(manifest, actionSources = /* @__PURE__ */ new Map()) {
|
|
307
309
|
const manifestRecord = isRecord(manifest) ? manifest : {};
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
return [];
|
|
319
|
-
}) : [];
|
|
320
|
-
return [
|
|
321
|
-
...official.map((name) => describeManifestAction(name, "official", metadata[name], actionSources.get(name))),
|
|
322
|
-
...custom.map((entry) => describeManifestAction(entry.name, "custom", entry.metadata, actionSources.get(entry.name)))
|
|
323
|
-
];
|
|
310
|
+
const actions = isRecord(manifestRecord.actions) ? manifestRecord.actions : {};
|
|
311
|
+
return Object.entries(actions).map(
|
|
312
|
+
([name, metadata]) => describeManifestAction(
|
|
313
|
+
name,
|
|
314
|
+
OFFICIAL_ACTIONS.has(name) ? "official" : "custom",
|
|
315
|
+
metadata,
|
|
316
|
+
actionSources.get(name)
|
|
317
|
+
)
|
|
318
|
+
);
|
|
324
319
|
}
|
|
325
320
|
function describeManifestAction(name, kind, metadata, source) {
|
|
326
321
|
const record = isRecord(metadata) ? metadata : {};
|
|
@@ -330,7 +325,7 @@ function describeManifestAction(name, kind, metadata, source) {
|
|
|
330
325
|
return {
|
|
331
326
|
name,
|
|
332
327
|
kind,
|
|
333
|
-
category: actionCategory(name
|
|
328
|
+
category: actionCategory(name),
|
|
334
329
|
description: typeof record.description === "string" ? record.description : "",
|
|
335
330
|
fields: properties,
|
|
336
331
|
schema,
|
|
@@ -347,8 +342,7 @@ function describeManifestAction(name, kind, metadata, source) {
|
|
|
347
342
|
])]
|
|
348
343
|
};
|
|
349
344
|
}
|
|
350
|
-
function actionCategory(name
|
|
351
|
-
if (typeof configured === "string" && configured.trim()) return configured.trim().toLowerCase();
|
|
345
|
+
function actionCategory(name) {
|
|
352
346
|
const segments = name.split(".");
|
|
353
347
|
if (segments[0] === "metamask" && segments.length > 2) return segments[1] ?? "metamask";
|
|
354
348
|
if (segments[0] === "app" || segments[0] === "cdp") return "runtime";
|
package/dist/manifest.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { OFFICIAL_RECIPE_ACTIONS } from "@farmslot/protocol";
|
|
3
4
|
import { manifestPath, readJson, importRecipeProtocol } from "./paths.js";
|
|
4
|
-
import {
|
|
5
|
-
actionSourceIntegrity,
|
|
6
|
-
metaMaskActionExecutionCapabilities
|
|
7
|
-
} from "./recipe-security.js";
|
|
5
|
+
import { actionSourceIntegrity } from "./recipe-security.js";
|
|
8
6
|
function loadMetaMaskMobileActionManifest() {
|
|
9
7
|
return asActionManifest(readJson(manifestPath("mobile")));
|
|
10
8
|
}
|
|
@@ -26,12 +24,12 @@ async function resolveActionManifest(adapter, overridePath, librarySources, task
|
|
|
26
24
|
const implementationRoot = path.resolve(
|
|
27
25
|
taskActionRoot ?? defaultImplementationRoot(manifestPath2)
|
|
28
26
|
);
|
|
29
|
-
const manifest =
|
|
27
|
+
const manifest = loadActionManifest(adapter, manifestPath2);
|
|
30
28
|
await validateManifest(manifest);
|
|
31
29
|
const integrity = await actionSourceIntegrity(manifestPath2, "task", implementationRoot);
|
|
32
30
|
return {
|
|
33
31
|
manifest,
|
|
34
|
-
actionSources: describeManifestSources(manifest, {
|
|
32
|
+
actionSources: await describeManifestSources(manifest, {
|
|
35
33
|
name: "task",
|
|
36
34
|
tier: "task",
|
|
37
35
|
manifestPath: manifestPath2,
|
|
@@ -41,109 +39,125 @@ async function resolveActionManifest(adapter, overridePath, librarySources, task
|
|
|
41
39
|
})
|
|
42
40
|
};
|
|
43
41
|
}
|
|
44
|
-
const canonicalPath = manifestPath(adapter);
|
|
45
|
-
const
|
|
42
|
+
const canonicalPath = path.resolve(manifestPath(adapter));
|
|
43
|
+
const canonicalRoot = path.dirname(path.dirname(canonicalPath));
|
|
44
|
+
const sources = librarySources?.length ? librarySources : [{ name: "metamask", root: canonicalRoot }];
|
|
46
45
|
const manifests = [];
|
|
47
46
|
for (const source of sources) {
|
|
48
|
-
const file = path.
|
|
47
|
+
const file = path.resolve(source.root, "manifests", `${adapter}.action-manifest.json`);
|
|
49
48
|
if (!fs.existsSync(file)) continue;
|
|
50
49
|
const manifest = asActionManifest(readJson(file));
|
|
51
50
|
await validateManifest(manifest);
|
|
52
51
|
manifests.push({ source, file, manifest });
|
|
53
52
|
}
|
|
54
|
-
if (!manifests.some((entry) =>
|
|
53
|
+
if (!manifests.some((entry) => entry.file === canonicalPath)) {
|
|
55
54
|
const manifest = loadActionManifest(adapter);
|
|
56
55
|
await validateManifest(manifest);
|
|
57
|
-
manifests.push({
|
|
56
|
+
manifests.push({
|
|
57
|
+
source: { name: "metamask", root: canonicalRoot },
|
|
58
|
+
file: canonicalPath,
|
|
59
|
+
manifest
|
|
60
|
+
});
|
|
58
61
|
}
|
|
59
|
-
const canonical = manifests.find((entry) => entry.
|
|
62
|
+
const canonical = manifests.find((entry) => entry.file === canonicalPath);
|
|
60
63
|
if (!canonical) throw new Error(`No ${adapter} action manifest could be resolved.`);
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
const official = new Set(OFFICIAL_RECIPE_ACTIONS);
|
|
65
|
+
const canonicalActions = actionsOf(canonical.manifest);
|
|
66
|
+
const mergedActions = {};
|
|
67
|
+
for (const [name, entry] of Object.entries(canonicalActions)) {
|
|
68
|
+
if (official.has(name)) mergedActions[name] = entry;
|
|
69
|
+
}
|
|
66
70
|
const canonicalImplementationRoot = path.join(canonical.source.root, "actions");
|
|
67
71
|
const canonicalIntegrity = await actionSourceIntegrity(
|
|
68
72
|
canonical.file,
|
|
69
73
|
"canonical",
|
|
70
74
|
canonicalImplementationRoot
|
|
71
75
|
);
|
|
72
|
-
const actionSources =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
const actionSources = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const name of Object.keys(mergedActions)) {
|
|
78
|
+
actionSources.set(name, {
|
|
79
|
+
name: "official",
|
|
80
|
+
tier: "official",
|
|
81
|
+
manifestPath: canonical.file
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const custom = /* @__PURE__ */ new Set();
|
|
85
|
+
const ordered = [
|
|
86
|
+
...manifests.filter((entry) => entry.file !== canonicalPath),
|
|
87
|
+
canonical
|
|
88
|
+
];
|
|
89
|
+
for (const entry of ordered) {
|
|
90
|
+
const isCanonical = entry.file === canonicalPath;
|
|
91
|
+
if (!isCanonical && entry.manifest.observers?.length) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Library manifest ${entry.file} declares observers, but external library observers are not executable; remove observers or use an explicit task action manifest.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const sourceName = isCanonical ? "metamask" : entry.source.name ?? path.basename(entry.source.root);
|
|
97
|
+
const tier = isCanonical ? "canonical" : sourceName === "personal" ? "personal" : "team";
|
|
83
98
|
const implementationRoot = path.join(entry.source.root, "actions");
|
|
84
|
-
const integrity = await actionSourceIntegrity(entry.file, tier, implementationRoot);
|
|
99
|
+
const integrity = isCanonical ? canonicalIntegrity : await actionSourceIntegrity(entry.file, tier, implementationRoot);
|
|
85
100
|
const sourceInfo = {
|
|
86
101
|
name: sourceName,
|
|
87
102
|
tier,
|
|
88
103
|
manifestPath: entry.file,
|
|
89
104
|
implementationRoot,
|
|
90
|
-
trust: entry.source.provenance?.trust ?? (
|
|
105
|
+
trust: entry.source.provenance?.trust ?? (isCanonical ? "trusted" : "unknown"),
|
|
91
106
|
...integrity
|
|
92
107
|
};
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
for (const [name, action] of Object.entries(actionsOf(entry.manifest))) {
|
|
109
|
+
if (official.has(name)) {
|
|
110
|
+
if (!isCanonical) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Library action ${name} from ${entry.file} conflicts with an official action; team libraries may declare namespaced custom actions only.`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
98
116
|
}
|
|
99
|
-
if (custom.has(
|
|
100
|
-
const existing = actionSources.get(
|
|
117
|
+
if (custom.has(name)) {
|
|
118
|
+
const existing = actionSources.get(name);
|
|
101
119
|
if (existing && existing.name !== sourceName) {
|
|
102
120
|
existing.shadows = [...existing.shadows ?? [], sourceName];
|
|
103
121
|
}
|
|
104
122
|
continue;
|
|
105
123
|
}
|
|
106
|
-
custom.
|
|
107
|
-
|
|
108
|
-
actionSources.set(
|
|
109
|
-
}
|
|
110
|
-
for (const binding of objectArray(manifestRecord.native_bindings)) {
|
|
111
|
-
const action = typeof binding.action === "string" ? binding.action : void 0;
|
|
112
|
-
if (action && !bindings.has(action)) bindings.set(action, binding);
|
|
124
|
+
custom.add(name);
|
|
125
|
+
mergedActions[name] = action;
|
|
126
|
+
actionSources.set(name, { ...sourceInfo });
|
|
113
127
|
}
|
|
114
128
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
return {
|
|
130
|
+
manifest: {
|
|
131
|
+
$schema: canonical.manifest.$schema,
|
|
132
|
+
actions: mergedActions,
|
|
133
|
+
...canonical.manifest.observers ? { observers: canonical.manifest.observers } : {}
|
|
134
|
+
},
|
|
135
|
+
actionSources
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function actionsOf(manifest) {
|
|
139
|
+
return manifest.actions;
|
|
140
|
+
}
|
|
141
|
+
async function describeManifestSources(manifest, customSource) {
|
|
142
|
+
const official = new Set(OFFICIAL_RECIPE_ACTIONS);
|
|
143
|
+
const sources = /* @__PURE__ */ new Map();
|
|
144
|
+
for (const name of Object.keys(actionsOf(manifest))) {
|
|
145
|
+
if (official.has(name)) {
|
|
146
|
+
sources.set(name, {
|
|
147
|
+
name: "official",
|
|
148
|
+
tier: "official",
|
|
149
|
+
manifestPath: customSource.manifestPath
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
sources.set(name, { ...customSource });
|
|
120
154
|
}
|
|
121
|
-
|
|
122
|
-
baseRecord.native_bindings = [...bindings.values()];
|
|
123
|
-
return { manifest: withMetaMaskExecutionCapabilities(base), actionSources };
|
|
155
|
+
return sources;
|
|
124
156
|
}
|
|
125
157
|
function defaultImplementationRoot(selectedManifestPath) {
|
|
126
158
|
const manifestDirectory = path.dirname(selectedManifestPath);
|
|
127
159
|
return path.basename(manifestDirectory) === "manifests" ? path.join(path.dirname(manifestDirectory), "actions") : path.join(manifestDirectory, "actions");
|
|
128
160
|
}
|
|
129
|
-
function withMetaMaskExecutionCapabilities(manifest) {
|
|
130
|
-
const result = cloneManifest(manifest);
|
|
131
|
-
const record = recordOf(result);
|
|
132
|
-
if (!Array.isArray(record.custom_actions)) return result;
|
|
133
|
-
record.custom_actions = record.custom_actions.map((entry) => {
|
|
134
|
-
const name = typeof entry === "string" ? entry : recordOf(entry).name;
|
|
135
|
-
if (typeof name !== "string") return entry;
|
|
136
|
-
const capabilities = metaMaskActionExecutionCapabilities(name);
|
|
137
|
-
if (capabilities.length === 0) return entry;
|
|
138
|
-
const declaredValue = typeof entry === "string" ? void 0 : recordOf(entry).execution_capabilities;
|
|
139
|
-
const declared = Array.isArray(declaredValue) ? declaredValue.filter(
|
|
140
|
-
(capability) => typeof capability === "string"
|
|
141
|
-
) : [];
|
|
142
|
-
const executionCapabilities = [.../* @__PURE__ */ new Set([...declared, ...capabilities])];
|
|
143
|
-
return typeof entry === "string" ? { name, execution_capabilities: executionCapabilities } : { ...recordOf(entry), execution_capabilities: executionCapabilities };
|
|
144
|
-
});
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
161
|
async function validateManifest(manifest) {
|
|
148
162
|
const { validateRecipeActionManifestDocument } = await importRecipeProtocol();
|
|
149
163
|
const result = validateRecipeActionManifestDocument(manifest);
|
|
@@ -157,41 +171,11 @@ async function validateManifest(manifest) {
|
|
|
157
171
|
function asActionManifest(value) {
|
|
158
172
|
return value;
|
|
159
173
|
}
|
|
160
|
-
function cloneManifest(value) {
|
|
161
|
-
return JSON.parse(JSON.stringify(value));
|
|
162
|
-
}
|
|
163
|
-
function recordOf(value) {
|
|
164
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
165
|
-
}
|
|
166
|
-
function stringArray(value) {
|
|
167
|
-
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
168
|
-
}
|
|
169
|
-
function objectArray(value) {
|
|
170
|
-
return Array.isArray(value) ? value.filter((entry) => Boolean(entry) && typeof entry === "object" && !Array.isArray(entry)) : [];
|
|
171
|
-
}
|
|
172
|
-
function customActions(value) {
|
|
173
|
-
if (!Array.isArray(value)) return [];
|
|
174
|
-
return value.flatMap((entry) => {
|
|
175
|
-
if (typeof entry === "string") return [{ name: entry, value: entry }];
|
|
176
|
-
const record = recordOf(entry);
|
|
177
|
-
return typeof record.name === "string" ? [{ name: record.name, value: entry }] : [];
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function describeManifestSources(manifest, customSource) {
|
|
181
|
-
const record = recordOf(manifest);
|
|
182
|
-
const sources = /* @__PURE__ */ new Map();
|
|
183
|
-
for (const name of stringArray(record.supported_official_actions)) {
|
|
184
|
-
sources.set(name, { name: "official", tier: "official", manifestPath: customSource.manifestPath });
|
|
185
|
-
}
|
|
186
|
-
for (const action of customActions(record.custom_actions)) sources.set(action.name, { ...customSource });
|
|
187
|
-
return sources;
|
|
188
|
-
}
|
|
189
174
|
export {
|
|
190
175
|
loadActionManifest,
|
|
191
176
|
loadMetaMaskCoreActionManifest,
|
|
192
177
|
loadMetaMaskExtensionActionManifest,
|
|
193
178
|
loadMetaMaskMobileActionManifest,
|
|
194
179
|
resolveActionManifest,
|
|
195
|
-
validateManifest
|
|
196
|
-
withMetaMaskExecutionCapabilities
|
|
180
|
+
validateManifest
|
|
197
181
|
};
|
package/dist/runner.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
|
+
import { OFFICIAL_RECIPE_ACTIONS } from "@farmslot/protocol";
|
|
2
3
|
import { createMetaMaskAdapters, createMetaMaskUiTransport } from "./adapters.js";
|
|
3
4
|
import {
|
|
4
5
|
mobileSourceFingerprint,
|
|
@@ -6,11 +7,13 @@ import {
|
|
|
6
7
|
} from "./adapters/mobile/source-freshness.js";
|
|
7
8
|
import { resolveMetaMaskMobileLifecycleTarget } from "./app-lifecycle.js";
|
|
8
9
|
import { loadMetaMaskExtensionActionManifest, loadMetaMaskMobileActionManifest } from "./manifest.js";
|
|
10
|
+
import { metaMaskActionExecutionCapabilities } from "./recipe-security.js";
|
|
9
11
|
import {
|
|
10
12
|
prepareLiveAdapterScript
|
|
11
13
|
} from "./live-adapter-contract.js";
|
|
12
14
|
import { createMetaMaskRecordingTargetProvider } from "./recording-target.js";
|
|
13
15
|
import { importRecipeHarness, importRecipeHarnessAppLifecycle, importRecipeHarnessRuntimeCdp, importRecipeHarnessRuntimeReactNativeBridge, runnerDir } from "./paths.js";
|
|
16
|
+
const OFFICIAL_ACTIONS = new Set(OFFICIAL_RECIPE_ACTIONS);
|
|
14
17
|
async function createMetaMaskMobileRunner(options = {}) {
|
|
15
18
|
return createMetaMaskRunner(
|
|
16
19
|
"mobile",
|
|
@@ -32,9 +35,8 @@ async function createMetaMaskRunner(adapter, actionManifest, options = {}) {
|
|
|
32
35
|
const { createCdpWebUiTransport } = await importRecipeHarnessRuntimeCdp();
|
|
33
36
|
const { createReactNativeBridgeUiTransport } = await importRecipeHarnessRuntimeReactNativeBridge();
|
|
34
37
|
const { createAppLifecycleAdapters } = await importRecipeHarnessAppLifecycle();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
+
const actions = Object.keys(actionManifest.actions);
|
|
39
|
+
const customActions = actions.filter((action) => !OFFICIAL_ACTIONS.has(action));
|
|
38
40
|
const actionSources = options.actionSources ? new Map([...options.actionSources].map(([action, source]) => [action, { ...source }])) : void 0;
|
|
39
41
|
const preparedLiveAdapters = await prepareLiveAdapterImplementations(
|
|
40
42
|
adapter,
|
|
@@ -42,7 +44,6 @@ async function createMetaMaskRunner(adapter, actionManifest, options = {}) {
|
|
|
42
44
|
actionSources,
|
|
43
45
|
options.trustTaskActions
|
|
44
46
|
);
|
|
45
|
-
const actions = [...actionManifest.supported_official_actions, ...customActions];
|
|
46
47
|
const declaredActions = new Set(actions);
|
|
47
48
|
const core = createStandardCoreAdapters({ actions });
|
|
48
49
|
const projectOwnedOfficialActions = /* @__PURE__ */ new Set(["app.status", "app.lifecycle"]);
|
|
@@ -144,8 +145,10 @@ async function prepareLiveAdapterImplementations(platform, actions, sources, tru
|
|
|
144
145
|
}
|
|
145
146
|
function adapterSecurity(action, sources, trustTaskActions = false) {
|
|
146
147
|
const source = sources?.get(action);
|
|
148
|
+
const capabilities = !OFFICIAL_ACTIONS.has(action) ? { capabilities: metaMaskActionExecutionCapabilities(action) } : {};
|
|
147
149
|
if (source?.tier === "task") {
|
|
148
150
|
return {
|
|
151
|
+
...capabilities,
|
|
149
152
|
source: {
|
|
150
153
|
kind: "custom-adapter",
|
|
151
154
|
trust: trustTaskActions ? "trusted" : "untrusted",
|
|
@@ -158,6 +161,7 @@ function adapterSecurity(action, sources, trustTaskActions = false) {
|
|
|
158
161
|
}
|
|
159
162
|
if (source && source.tier !== "official") {
|
|
160
163
|
return {
|
|
164
|
+
...capabilities,
|
|
161
165
|
source: {
|
|
162
166
|
kind: source.tier === "canonical" ? "bundled" : "custom-adapter",
|
|
163
167
|
trust: source.trust ?? (source.tier === "canonical" ? "trusted" : "unknown"),
|
|
@@ -169,6 +173,7 @@ function adapterSecurity(action, sources, trustTaskActions = false) {
|
|
|
169
173
|
};
|
|
170
174
|
}
|
|
171
175
|
return {
|
|
176
|
+
...capabilities,
|
|
172
177
|
source: {
|
|
173
178
|
kind: "bundled",
|
|
174
179
|
trust: "trusted",
|
package/docs/RECIPES.md
CHANGED
|
@@ -89,21 +89,11 @@ The protocol is authoritative:
|
|
|
89
89
|
|
|
90
90
|
```text
|
|
91
91
|
team-recipes/
|
|
92
|
-
library.json
|
|
93
92
|
manifests/extension.action-manifest.json
|
|
94
93
|
actions/extension/wallet/ensure_ready.mjs
|
|
95
94
|
recipes/onboarding/smoke.extension.recipe.json
|
|
96
95
|
```
|
|
97
96
|
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"kind": "recipe-library",
|
|
101
|
-
"schema_version": 1,
|
|
102
|
-
"name": "wallet-team",
|
|
103
|
-
"owner": "wallet-team"
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
97
|
```bash
|
|
108
98
|
export RECIPE_LIBRARY_PATH="wallet=$HOME/shared-library/wallet-team"
|
|
109
99
|
mm-harness run --list
|
|
@@ -111,7 +101,8 @@ mm-harness run onboarding.smoke --describe
|
|
|
111
101
|
mm-harness run onboarding.smoke --plan
|
|
112
102
|
```
|
|
113
103
|
|
|
114
|
-
Use `--library wallet=/path/to/library` for one command.
|
|
104
|
+
Use `--library wallet=/path/to/library` for one command. The alias is the
|
|
105
|
+
source name; without one, the directory name is used. Resolution follows the
|
|
115
106
|
explicit library order, then bundled MetaMask. Adapter-specific variants are
|
|
116
107
|
selected deterministically. Every run records the root recipe, exact resolved
|
|
117
108
|
dependency documents, their digests, call edges, selected sources, and shadows.
|