@powerhousedao/ph-cli 6.2.3-dev.72 → 6.2.3-dev.74
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/dist/check-9KDSF1Wj.mjs +53 -0
- package/dist/check-9KDSF1Wj.mjs.map +1 -0
- package/dist/{cli-connect-override-CEJhQWRX.mjs → cli-connect-override-BrS-X8Rs.mjs} +4 -4
- package/dist/{cli-connect-override-CEJhQWRX.mjs.map → cli-connect-override-BrS-X8Rs.mjs.map} +1 -1
- package/dist/cli.mjs +11 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-B6RZMA0Y-Cv3XMQ3Y.mjs → compound-Gjt5rBfF-BmSW1XPB.mjs} +178 -43
- package/dist/compound-Gjt5rBfF-BmSW1XPB.mjs.map +1 -0
- package/dist/{connect-build-BfhOGbha.mjs → connect-build-B5nYqlLc.mjs} +4 -4
- package/dist/{connect-build-BfhOGbha.mjs.map → connect-build-B5nYqlLc.mjs.map} +1 -1
- package/dist/{connect-config-DblqJgxR.mjs → connect-config-Bi95JhNG.mjs} +4 -4
- package/dist/{connect-config-DblqJgxR.mjs.map → connect-config-Bi95JhNG.mjs.map} +1 -1
- package/dist/{connect-plugin-configs-D2fwYpMw.mjs → connect-plugin-configs-BwYEbQSY.mjs} +4 -4
- package/dist/{connect-plugin-configs-D2fwYpMw.mjs.map → connect-plugin-configs-BwYEbQSY.mjs.map} +1 -1
- package/dist/{connect-studio-BS26pchr.mjs → connect-studio-Co_UNyEC.mjs} +3 -3
- package/dist/{connect-studio-B1_4TNEb.mjs → connect-studio-DGWUidCV.mjs} +4 -4
- package/dist/{connect-studio-B1_4TNEb.mjs.map → connect-studio-DGWUidCV.mjs.map} +1 -1
- package/dist/{dist-CCLkwpTS.mjs → dist-BVqNlv1z.mjs} +243 -14
- package/dist/dist-BVqNlv1z.mjs.map +1 -0
- package/dist/{explain-DUXbB9jf.mjs → explain-CPD1tzoV.mjs} +5 -5
- package/dist/{explain-DUXbB9jf.mjs.map → explain-CPD1tzoV.mjs.map} +1 -1
- package/dist/{generate-all-Dgyy_kT-.mjs → generate-all-CaAHbviS.mjs} +4 -4
- package/dist/{generate-all-Dgyy_kT-.mjs.map → generate-all-CaAHbviS.mjs.map} +1 -1
- package/dist/generate-app-hm6CJ_4O.mjs +72 -0
- package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
- package/dist/{generate-document-model-BfFIQ35q.mjs → generate-document-model-CiW13Vf7.mjs} +23 -9
- package/dist/generate-document-model-CiW13Vf7.mjs.map +1 -0
- package/dist/generate-editor-kTiUOmDW.mjs +64 -0
- package/dist/generate-editor-kTiUOmDW.mjs.map +1 -0
- package/dist/{generate-piece-QTt-ddt2.mjs → generate-piece-U3tP-Sex.mjs} +14 -6
- package/dist/generate-piece-U3tP-Sex.mjs.map +1 -0
- package/dist/{generate-processor-DBtTkgo5.mjs → generate-processor-B9Umgjy9.mjs} +18 -7
- package/dist/generate-processor-B9Umgjy9.mjs.map +1 -0
- package/dist/generate-subgraph-DRrInOOv.mjs +64 -0
- package/dist/generate-subgraph-DRrInOOv.mjs.map +1 -0
- package/dist/{index-BIbx17vt.d.mts → index-7hbcAZpm.d.mts} +17 -3
- package/dist/{index-BIbx17vt.d.mts.map → index-7hbcAZpm.d.mts.map} +1 -1
- package/dist/migrate-b38W7NH_.mjs +177 -0
- package/dist/migrate-b38W7NH_.mjs.map +1 -0
- package/dist/module-dir-1avCXsBi.mjs +17 -0
- package/dist/module-dir-1avCXsBi.mjs.map +1 -0
- package/dist/ph-cli-commands-D4y7NPxI.mjs +4 -0
- package/dist/{ph-cli-commands-DSAhaETu.mjs → ph-cli-commands-kLUOOYuy.mjs} +59 -35
- package/dist/ph-cli-commands-kLUOOYuy.mjs.map +1 -0
- package/dist/{run-sugar-Ns53R6lU.mjs → run-sugar-BJxPKwlM.mjs} +4 -4
- package/dist/{run-sugar-Ns53R6lU.mjs.map → run-sugar-BJxPKwlM.mjs.map} +1 -1
- package/dist/runners/connect.d.mts +1 -1
- package/dist/runners/connect.mjs +5 -5
- package/dist/runners/switchboard.d.mts +3 -1
- package/dist/runners/switchboard.d.mts.map +1 -1
- package/dist/runners/switchboard.mjs +48 -10
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/{start-run-BIaYSpHh.mjs → start-run-CDZ3YAr9.mjs} +4 -4
- package/dist/{start-run-BIaYSpHh.mjs.map → start-run-CDZ3YAr9.mjs.map} +1 -1
- package/dist/{vetra-UQsfYM_Q.mjs → vetra-DO5eUgAo.mjs} +6 -6
- package/dist/{vetra-UQsfYM_Q.mjs.map → vetra-DO5eUgAo.mjs.map} +1 -1
- package/package.json +14 -13
- package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs.map +0 -1
- package/dist/dist-CCLkwpTS.mjs.map +0 -1
- package/dist/generate-app-BTs1u-9l.mjs +0 -50
- package/dist/generate-app-BTs1u-9l.mjs.map +0 -1
- package/dist/generate-document-model-BfFIQ35q.mjs.map +0 -1
- package/dist/generate-editor-CW7Do69u.mjs +0 -50
- package/dist/generate-editor-CW7Do69u.mjs.map +0 -1
- package/dist/generate-piece-QTt-ddt2.mjs.map +0 -1
- package/dist/generate-processor-DBtTkgo5.mjs.map +0 -1
- package/dist/generate-subgraph-CVlTo7qk.mjs +0 -44
- package/dist/generate-subgraph-CVlTo7qk.mjs.map +0 -1
- package/dist/migrate-DK4HK7Dn.mjs +0 -83
- package/dist/migrate-DK4HK7Dn.mjs.map +0 -1
- package/dist/ph-cli-commands-DSAhaETu.mjs.map +0 -1
- package/dist/ph-cli-commands-d5XjMWW0.mjs +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ff5a7d8c-3e69-574e-b5e3-29245ef73905")}catch(e){}}();
|
|
3
3
|
import { a as looseObject, c as strictObject, d as unknown, f as url, i as literal, l as string, m as prettifyError, n as array, o as number, p as toJSONSchema, r as boolean, s as record, t as _enum, u as union } from "./schemas-D5N5U_Mf.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import fs, { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
@@ -8,7 +8,7 @@ import { createHash } from "node:crypto";
|
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
9
9
|
import { TOKEN_ESCAPE_KEY, envTokenable, findToken, isToken, tokenKeyOf, tokenSchema, tokenable } from "@powerhousedao/shared/host-tokens";
|
|
10
10
|
import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
|
|
11
|
-
//#region ../../packages/host-core/dist/compound-
|
|
11
|
+
//#region ../../packages/host-core/dist/compound-Gjt5rBfF.mjs
|
|
12
12
|
/**
|
|
13
13
|
* R1 — the host plugin framework (bridge-runners-to-plugins plan,
|
|
14
14
|
* customization-references/host-core as the blueprint).
|
|
@@ -956,6 +956,17 @@ function schemaAtPath(schema, path) {
|
|
|
956
956
|
schema: current
|
|
957
957
|
};
|
|
958
958
|
}
|
|
959
|
+
/** Whether the object schema at `path` names `key` in its shape (a
|
|
960
|
+
* catchall does not count): what a runner's schema explicitly declares,
|
|
961
|
+
* e.g. `runner.cspRegistrySync`. A union declares a key any member does. */
|
|
962
|
+
function declaresKey(schema, path, key) {
|
|
963
|
+
const at = schemaAtPath(schema, path);
|
|
964
|
+
if (!at.ok) return false;
|
|
965
|
+
const def = defOf(at.schema);
|
|
966
|
+
if (def?.type === "object") return isPlainObjectLike(def.shape) && key in def.shape;
|
|
967
|
+
if (def?.type === "union" && Array.isArray(def.options)) return def.options.some((option) => declaresKey(option, [], key));
|
|
968
|
+
return false;
|
|
969
|
+
}
|
|
959
970
|
/** Whether a (property) schema admits an absent value on the OUTPUT side:
|
|
960
971
|
* `.optional()` does; `.default()`/`.prefault()` fill it in, and
|
|
961
972
|
* `.nonoptional()` forbids it. */
|
|
@@ -1227,7 +1238,12 @@ function findRemovedForms(host) {
|
|
|
1227
1238
|
}
|
|
1228
1239
|
return found;
|
|
1229
1240
|
}
|
|
1230
|
-
|
|
1241
|
+
/** The always-resolvable `$env` names (also the `"${name}"` sugar). */
|
|
1242
|
+
const BUILTIN_ENV_NAMES = ["userData", "projectRoot"];
|
|
1243
|
+
function isBuiltinEnvName(name) {
|
|
1244
|
+
return BUILTIN_ENV_NAMES.includes(name);
|
|
1245
|
+
}
|
|
1246
|
+
const BUILTIN = new RegExp(`\\$\\{(${BUILTIN_ENV_NAMES.join("|")})\\}`, "g");
|
|
1231
1247
|
function substitute(text, env) {
|
|
1232
1248
|
return text.replace(BUILTIN, (match, name) => env[name] ?? match);
|
|
1233
1249
|
}
|
|
@@ -1338,11 +1354,18 @@ function planCompound(members, startOrder) {
|
|
|
1338
1354
|
};
|
|
1339
1355
|
}
|
|
1340
1356
|
var TokenResolutionError = class extends Error {
|
|
1341
|
-
|
|
1357
|
+
/** The host path that failed and the reason, without the file prefix. */
|
|
1358
|
+
detail;
|
|
1359
|
+
constructor(message, detail) {
|
|
1342
1360
|
super(message);
|
|
1343
1361
|
this.name = "TokenResolutionError";
|
|
1362
|
+
if (detail) this.detail = detail;
|
|
1344
1363
|
}
|
|
1345
1364
|
};
|
|
1365
|
+
/** Why a required `$env` cannot resolve. */
|
|
1366
|
+
function unsetEnvMessage(name) {
|
|
1367
|
+
return `reads $env ${name}, which is not set. Set ${name} in the environment of the process that resolves this host (or declare { $env: { name: "${name}", optional: true } } to omit the property when unset).`;
|
|
1368
|
+
}
|
|
1346
1369
|
/** A resolved `{ $env: { name, optional: true } }` whose variable is unset,
|
|
1347
1370
|
* or an `$output`/`$item` reading an absent optional field: its enclosing
|
|
1348
1371
|
* property is omitted. */
|
|
@@ -1442,6 +1465,10 @@ var Resolver = class {
|
|
|
1442
1465
|
host: operand.host,
|
|
1443
1466
|
member: operand.member
|
|
1444
1467
|
} : { host: operand.host };
|
|
1468
|
+
if (this.self === "outputs") {
|
|
1469
|
+
keys.add(refKey(ref));
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1445
1472
|
if (!this.self.members.some((m) => m.host === ref.host)) continue;
|
|
1446
1473
|
const target = memberForRef(ref, this.self.members);
|
|
1447
1474
|
if ("error" in target) this.fail([...trail, ...site.path], `in a compound ${target.error}`);
|
|
@@ -1452,7 +1479,11 @@ var Resolver = class {
|
|
|
1452
1479
|
fail(trail, message, scope = []) {
|
|
1453
1480
|
const where = this.sources.where ? `${this.sources.where}: ` : "";
|
|
1454
1481
|
const inside = scope.length ? ` (rendering $map element ${scope.map(elementText).join(" › ")})` : "";
|
|
1455
|
-
|
|
1482
|
+
const path = formatPath(trail);
|
|
1483
|
+
throw new TokenResolutionError(`${where}\`${path}\` ${message}${inside}`, {
|
|
1484
|
+
path,
|
|
1485
|
+
reason: `${message}${inside}`
|
|
1486
|
+
});
|
|
1456
1487
|
}
|
|
1457
1488
|
value(value, trail, scope = []) {
|
|
1458
1489
|
if (typeof value === "string") return this.sources.builtins ? substituteBuiltinEnv(value, this.sources.builtins) : value;
|
|
@@ -1477,7 +1508,7 @@ var Resolver = class {
|
|
|
1477
1508
|
}
|
|
1478
1509
|
const out = {};
|
|
1479
1510
|
for (const [key, child] of Object.entries(value)) {
|
|
1480
|
-
if (this.self && trail.length === 0 && key === "children") {
|
|
1511
|
+
if (typeof this.self === "object" && trail.length === 0 && key === "children") {
|
|
1481
1512
|
out[key] = child;
|
|
1482
1513
|
continue;
|
|
1483
1514
|
}
|
|
@@ -1603,7 +1634,15 @@ var Resolver = class {
|
|
|
1603
1634
|
const path = pathSegments(Array.isArray(operand.path) ? operand.path : []);
|
|
1604
1635
|
if (!this.sources.outputs) return this.fail(trail, `reads ${describeToken(token)}, but no outputs are available here.`, scope);
|
|
1605
1636
|
const lookup = this.sources.outputs.lookup(ref);
|
|
1606
|
-
if (lookup.status === "unavailable")
|
|
1637
|
+
if (lookup.status === "unavailable") {
|
|
1638
|
+
const where = this.sources.where ? `${this.sources.where}: ` : "";
|
|
1639
|
+
const path = formatPath(trail);
|
|
1640
|
+
const reason = `${lookup.message}\n (needed by \`${path}\`: ${describeToken(token)})`;
|
|
1641
|
+
throw new TokenResolutionError(`${where}${reason}`, {
|
|
1642
|
+
path,
|
|
1643
|
+
reason
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1607
1646
|
const hit = walkPath(lookup.outputs, path);
|
|
1608
1647
|
if (!hit.ok) {
|
|
1609
1648
|
if (lookup.schema !== void 0 && isOptionalField(lookup.schema, path, hit.at)) return this.omit("an absent optional output");
|
|
@@ -1622,11 +1661,11 @@ var Resolver = class {
|
|
|
1622
1661
|
const name = optional ? operand.name : operand;
|
|
1623
1662
|
if (typeof name !== "string") return this.fail(trail, "is a malformed $env token.", scope);
|
|
1624
1663
|
const builtins = this.sources.builtins;
|
|
1625
|
-
if ((name
|
|
1664
|
+
if (isBuiltinEnvName(name) && builtins?.[name]) return builtins[name];
|
|
1626
1665
|
const value = this.sources.env?.[name];
|
|
1627
1666
|
if (value !== void 0) return value;
|
|
1628
1667
|
if (optional) return this.omit("an optional $env").value;
|
|
1629
|
-
return this.fail(trail,
|
|
1668
|
+
return this.fail(trail, unsetEnvMessage(name), scope);
|
|
1630
1669
|
}
|
|
1631
1670
|
concat(parts, trail, scope = []) {
|
|
1632
1671
|
if (!Array.isArray(parts)) return this.fail(trail, "is a malformed $concat token.", scope);
|
|
@@ -1711,6 +1750,7 @@ const NON_VERB_EXPORTS = /* @__PURE__ */ new Set([
|
|
|
1711
1750
|
"outputsSchema",
|
|
1712
1751
|
"verbs",
|
|
1713
1752
|
"kind",
|
|
1753
|
+
"checkBoot",
|
|
1714
1754
|
"default"
|
|
1715
1755
|
]);
|
|
1716
1756
|
async function resolveRunnerModule(projectRoot, specifier) {
|
|
@@ -1727,6 +1767,7 @@ async function resolveRunnerModule(projectRoot, specifier) {
|
|
|
1727
1767
|
if (!hostSchema || typeof hostSchema.safeParse !== "function") throw new RunnerError(`Runner "${specifier}" does not export a \`hostSchema\` — runners validate their own host shape.`);
|
|
1728
1768
|
const declared = module.declaredHostSchema;
|
|
1729
1769
|
if (declared !== void 0 && typeof declared.safeParse !== "function") throw new RunnerError(`Runner "${specifier}" exports a \`declaredHostSchema\` without safeParse.`);
|
|
1770
|
+
if (module.checkBoot !== void 0 && typeof module.checkBoot !== "function") throw new RunnerError(`Runner "${specifier}" exports a \`checkBoot\` that is not a function.`);
|
|
1730
1771
|
const verbs = module.verbs;
|
|
1731
1772
|
if (verbs !== void 0 && (!Array.isArray(verbs) || !verbs.every((verb) => typeof verb === "string" && typeof module[verb] === "function"))) throw new RunnerError(`Runner "${specifier}" exports \`verbs\` ${JSON.stringify(verbs)}, which must list names of exported functions.`);
|
|
1732
1773
|
if (!runnerKindSchema.safeParse(module.kind).success) throw new RunnerError(`Runner "${specifier}" does not export a valid \`kind\` (got ${JSON.stringify(module.kind)}; expected "reactor" | "compound").`);
|
|
@@ -1750,24 +1791,44 @@ function isRecord$2(value) {
|
|
|
1750
1791
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1751
1792
|
}
|
|
1752
1793
|
/** reactor XOR children, decided by the runner's declared `kind`. */
|
|
1794
|
+
function kindShapeIssues(kind, specifier, host) {
|
|
1795
|
+
if (kind === "reactor" && host.children !== void 0) return [{
|
|
1796
|
+
path: "children",
|
|
1797
|
+
message: `"${specifier}" is a reactor runner, so the host must not declare \`children\`.`,
|
|
1798
|
+
hint: "`children` belongs to compound hosts; a reactor host configures its own `reactor` block."
|
|
1799
|
+
}];
|
|
1800
|
+
if (kind === "compound" && host.reactor !== void 0) return [{
|
|
1801
|
+
path: "reactor",
|
|
1802
|
+
message: `"${specifier}" is a compound runner, so the host must not declare \`reactor\`.`,
|
|
1803
|
+
hint: "A compound's reactors are its members': configure them in the member host or a wrapper's `reactor` override."
|
|
1804
|
+
}];
|
|
1805
|
+
return [];
|
|
1806
|
+
}
|
|
1753
1807
|
function assertKindShape(kind, specifier, host, file) {
|
|
1754
|
-
|
|
1755
|
-
if (
|
|
1808
|
+
const issue = kindShapeIssues(kind, specifier, host).at(0);
|
|
1809
|
+
if (issue) throw new RunnerError(`${file}: ${issue.message}`, issue.hint);
|
|
1756
1810
|
}
|
|
1757
1811
|
/** `runner.defaultVerb` and every plugin entry's `verbs` must name verbs
|
|
1758
1812
|
* this runner exports. */
|
|
1759
|
-
function
|
|
1813
|
+
function knownVerbIssues(runner, specifier, host) {
|
|
1760
1814
|
const options = host.runner;
|
|
1761
|
-
if (!isRecord$2(options)) return;
|
|
1815
|
+
if (!isRecord$2(options)) return [];
|
|
1762
1816
|
const verbs = listVerbs(runner);
|
|
1763
1817
|
const unknownVerb = (verb) => typeof verb === "string" && !verbs.includes(verb);
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1818
|
+
const issues = [];
|
|
1819
|
+
if (unknownVerb(options.defaultVerb)) issues.push({
|
|
1820
|
+
path: "runner.defaultVerb",
|
|
1821
|
+
message: `runner.defaultVerb "${options.defaultVerb}" is not a verb of "${specifier}". Supported verbs: ${verbs.join(", ")}.`
|
|
1822
|
+
});
|
|
1823
|
+
(Array.isArray(options.plugins) ? options.plugins : []).forEach((entry, index) => {
|
|
1824
|
+
if (!isRecord$2(entry) || !Array.isArray(entry.verbs)) return;
|
|
1825
|
+
const scoped = entry.verbs;
|
|
1826
|
+
for (const bad of scoped.filter(unknownVerb)) issues.push({
|
|
1827
|
+
path: `runner.plugins[${index}].verbs`,
|
|
1828
|
+
message: `plugin "${String(entry.module)}" is scoped to verb "${bad}", which "${specifier}" does not export. Supported verbs: ${verbs.join(", ")}.`
|
|
1829
|
+
});
|
|
1830
|
+
});
|
|
1831
|
+
return issues;
|
|
1771
1832
|
}
|
|
1772
1833
|
function formatIssues(issues) {
|
|
1773
1834
|
return issues.map((i) => ` - ${i.path}: ${i.message}`).join("\n");
|
|
@@ -1788,21 +1849,46 @@ function valueAt(host, path) {
|
|
|
1788
1849
|
function validateHost(runner, specifier, host, file, options = {}) {
|
|
1789
1850
|
return parseHost(runner, options.tokens === "allow" ? runner.declaredHostSchema ?? runner.hostSchema : runner.hostSchema, specifier, host, file, options);
|
|
1790
1851
|
}
|
|
1791
|
-
|
|
1852
|
+
/** What `validateHost` checks, as data: nothing throws. */
|
|
1853
|
+
function hostSchemaIssues(runner, schema, specifier, host, options = {}) {
|
|
1854
|
+
const issues = [];
|
|
1792
1855
|
if (isRecord$2(host)) {
|
|
1793
|
-
|
|
1856
|
+
issues.push(...kindShapeIssues(runner.kind, specifier, host));
|
|
1794
1857
|
if (options.tokens !== "allow") {
|
|
1795
1858
|
const token = findToken(host);
|
|
1796
|
-
if (token)
|
|
1859
|
+
if (token) issues.push({
|
|
1860
|
+
path: token.path,
|
|
1861
|
+
message: `\`${token.path}\` is an unresolved output token (${token.key}).`,
|
|
1862
|
+
hint: "Resolve the host (resolveHostOutputs) before validating it for a verb; `ph run` does this."
|
|
1863
|
+
});
|
|
1797
1864
|
}
|
|
1798
|
-
|
|
1865
|
+
issues.push(...knownVerbIssues(runner, specifier, host));
|
|
1799
1866
|
}
|
|
1800
1867
|
const result = schema.safeParse(unwrapEscapes(host));
|
|
1801
|
-
if (
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
}
|
|
1805
|
-
return
|
|
1868
|
+
if (result.success) return {
|
|
1869
|
+
issues,
|
|
1870
|
+
data: result.data
|
|
1871
|
+
};
|
|
1872
|
+
return {
|
|
1873
|
+
issues,
|
|
1874
|
+
schemaIssues: result.error.issues.map((issue) => {
|
|
1875
|
+
const element = describeMapElements(host, issue.path);
|
|
1876
|
+
const dotted = (issue.path.map(String).join(".") || "<root>") + (element ? ` (${element})` : "");
|
|
1877
|
+
const message = tokenKeyOf(valueAt(host, issue.path)) ? "this field does not take an output token (it is not token-able); spell the value literally." : issue.message;
|
|
1878
|
+
return {
|
|
1879
|
+
path: formatPath(issue.path.filter((key) => typeof key === "string" || typeof key === "number")),
|
|
1880
|
+
message: element ? `${message} (${element})` : message,
|
|
1881
|
+
printed: `${dotted}: ${message}`
|
|
1882
|
+
};
|
|
1883
|
+
})
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
function parseHost(runner, schema, specifier, host, file, options) {
|
|
1887
|
+
const checked = hostSchemaIssues(runner, schema, specifier, host, options);
|
|
1888
|
+
const first = checked.issues.at(0);
|
|
1889
|
+
if (first) throw new RunnerError(`${file}: ${first.message}`, first.hint);
|
|
1890
|
+
if (checked.schemaIssues) throw new RunnerError(`${file} failed validation against the hostSchema of "${specifier}":\n${checked.schemaIssues.map((issue) => ` - ${issue.printed}`).join("\n") || " (no details reported)"}`);
|
|
1891
|
+
return checked.data;
|
|
1806
1892
|
}
|
|
1807
1893
|
/**
|
|
1808
1894
|
* Declared validation (pipeline step 3): the removed cross-host forms
|
|
@@ -2215,12 +2301,12 @@ const runRecordSchema = strictObject({
|
|
|
2215
2301
|
/** Host-specific extras (e.g. mcpUrl) a runner wants in the record. */
|
|
2216
2302
|
extra: record(string(), unknown()).optional()
|
|
2217
2303
|
});
|
|
2218
|
-
const runDir = (projectDir) => path.join(resolvePhDir(projectDir), "run");
|
|
2219
|
-
const recordPath = (projectDir, hostName) => path.join(runDir(projectDir), `${hostName}.json`);
|
|
2220
|
-
function readRunRecord(projectDir, hostName) {
|
|
2304
|
+
const runDir = (projectDir, env = process.env) => path.join(resolvePhDir(projectDir, env), "run");
|
|
2305
|
+
const recordPath = (projectDir, hostName, env) => path.join(runDir(projectDir, env), `${hostName}.json`);
|
|
2306
|
+
function readRunRecord(projectDir, hostName, env = process.env) {
|
|
2221
2307
|
let raw;
|
|
2222
2308
|
try {
|
|
2223
|
-
raw = JSON.parse(fs.readFileSync(recordPath(projectDir, hostName), "utf8"));
|
|
2309
|
+
raw = JSON.parse(fs.readFileSync(recordPath(projectDir, hostName, env), "utf8"));
|
|
2224
2310
|
} catch {
|
|
2225
2311
|
return;
|
|
2226
2312
|
}
|
|
@@ -2228,15 +2314,15 @@ function readRunRecord(projectDir, hostName) {
|
|
|
2228
2314
|
return parsed.success ? parsed.data : void 0;
|
|
2229
2315
|
}
|
|
2230
2316
|
/** Every valid v2 record under `.ph/run/` (invalid and v1 files skipped). */
|
|
2231
|
-
function listRunRecords(projectDir) {
|
|
2317
|
+
function listRunRecords(projectDir, env = process.env) {
|
|
2232
2318
|
let files;
|
|
2233
2319
|
try {
|
|
2234
|
-
files = fs.readdirSync(runDir(projectDir));
|
|
2320
|
+
files = fs.readdirSync(runDir(projectDir, env));
|
|
2235
2321
|
} catch {
|
|
2236
2322
|
return [];
|
|
2237
2323
|
}
|
|
2238
2324
|
return files.filter((file) => file.endsWith(".json")).flatMap((file) => {
|
|
2239
|
-
const record = readRunRecord(projectDir, file.slice(0, -5));
|
|
2325
|
+
const record = readRunRecord(projectDir, file.slice(0, -5), env);
|
|
2240
2326
|
return record ? [record] : [];
|
|
2241
2327
|
});
|
|
2242
2328
|
}
|
|
@@ -2255,9 +2341,9 @@ function writeRunRecord(projectDir, record) {
|
|
|
2255
2341
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2256
2342
|
fs.writeFileSync(target, `${JSON.stringify(valid, null, 2)}\n`);
|
|
2257
2343
|
}
|
|
2258
|
-
function clearRunRecord(projectDir, hostName) {
|
|
2344
|
+
function clearRunRecord(projectDir, hostName, env = process.env) {
|
|
2259
2345
|
try {
|
|
2260
|
-
fs.rmSync(recordPath(projectDir, hostName));
|
|
2346
|
+
fs.rmSync(recordPath(projectDir, hostName, env));
|
|
2261
2347
|
} catch {}
|
|
2262
2348
|
}
|
|
2263
2349
|
function isPidAlive(pid) {
|
|
@@ -2277,8 +2363,8 @@ function isPidAlive(pid) {
|
|
|
2277
2363
|
* prevent. A stale record (dead pid) is reported so the caller can clear it; a
|
|
2278
2364
|
* foreign one (live pid, different project) is left alone.
|
|
2279
2365
|
*/
|
|
2280
|
-
function probeRun(projectDir, hostName, projectName) {
|
|
2281
|
-
const record = readRunRecord(projectDir, hostName);
|
|
2366
|
+
function probeRun(projectDir, hostName, projectName, env = process.env) {
|
|
2367
|
+
const record = readRunRecord(projectDir, hostName, env);
|
|
2282
2368
|
if (!record) return { status: "none" };
|
|
2283
2369
|
if (!isPidAlive(record.pid)) return {
|
|
2284
2370
|
status: "stale",
|
|
@@ -2452,8 +2538,57 @@ function toStartedHandle(value, where) {
|
|
|
2452
2538
|
...isCallable(shutdown) ? { shutdown: () => shutdown.call(value) } : {}
|
|
2453
2539
|
};
|
|
2454
2540
|
}
|
|
2541
|
+
/** Build the member host object the member runner sees: the member's own
|
|
2542
|
+
* host.js with the wrapper applied. A wrapper SECTION is a FULL STATEMENT —
|
|
2543
|
+
* `reactor` and `config`, when present on the wrapper, replace the member's
|
|
2544
|
+
* wholesale; `runner` key-merges (wrappers override port, host, plugins…). */
|
|
2545
|
+
async function memberDraft(projectRoot, member) {
|
|
2546
|
+
const base = (await loadHost(projectRoot, member.host)).host;
|
|
2547
|
+
const reactor = member.reactor ?? base.reactor;
|
|
2548
|
+
const config = member.config ?? base.config;
|
|
2549
|
+
return {
|
|
2550
|
+
...base,
|
|
2551
|
+
runner: {
|
|
2552
|
+
...base.runner,
|
|
2553
|
+
...member.runner
|
|
2554
|
+
},
|
|
2555
|
+
...config !== void 0 ? { config } : {},
|
|
2556
|
+
...reactor !== void 0 ? { reactor } : {}
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
/** Whether a member receives the compound's `cspRegistrySync` wiring (as
|
|
2560
|
+
* `runner.cspRegistrySync`): its runner declares that option (any specifier
|
|
2561
|
+
* that reaches the Connect runner), or it names the Connect runner. A
|
|
2562
|
+
* member's role is its runner, not its folder. */
|
|
2563
|
+
function takesCspRegistrySync(m) {
|
|
2564
|
+
return m.specifier === "@powerhousedao/ph-cli/runners/connect" || declaresKey(m.runner.hostSchema, ["runner"], "cspRegistrySync");
|
|
2565
|
+
}
|
|
2566
|
+
/** The verb the generic compound starts its members at for its own `verb`:
|
|
2567
|
+
* `run` follows the compound's defaultVerb. */
|
|
2568
|
+
function compoundStartVerb(verb, runner) {
|
|
2569
|
+
return verb === "run" ? runner.defaultVerb ?? "run" : verb;
|
|
2570
|
+
}
|
|
2571
|
+
/** At compound verb "run" each member runs its own (merged) defaultVerb —
|
|
2572
|
+
* what lets a desktop compound pair a switchboard at `run` with a connect at
|
|
2573
|
+
* `serve`. An explicit forwarded verb stays uniform across members. */
|
|
2574
|
+
function memberVerbOf(compoundVerb, runner) {
|
|
2575
|
+
return compoundVerb === "run" ? runner.defaultVerb ?? "run" : compoundVerb;
|
|
2576
|
+
}
|
|
2577
|
+
/** One member's draft and runner. */
|
|
2578
|
+
async function prepareMember(projectRoot, key, member) {
|
|
2579
|
+
const draft = await memberDraft(projectRoot, member);
|
|
2580
|
+
const specifier = draft.runner.module;
|
|
2581
|
+
return {
|
|
2582
|
+
key,
|
|
2583
|
+
member,
|
|
2584
|
+
draft,
|
|
2585
|
+
specifier,
|
|
2586
|
+
runner: await resolveRunnerModule(projectRoot, specifier),
|
|
2587
|
+
file: `hosts/${member.host}/host.js`
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2455
2590
|
//#endregion
|
|
2456
|
-
export {
|
|
2591
|
+
export { unsetEnvMessage as $, memberVerbOf as A, projectDriveIdWith as B, isPlainObject as C, loadHost as D, kindShapeIssues as E, prepareMember as F, resolveHostPlugins as G, readRunRecord as H, probeHostsFolder as I, runRecordOutputSource as J, resolvePluginContributions as K, probeRun as L, outputRefsOf as M, outputSitesOf as N, loadProducers as O, planCompound as P, toStartedHandle as Q, processResolveEnv as R, isBuiltinEnvName as S, isToken as T, renderTokens as U, readProjectName as V, resolveHostOutputs as W, substituteBuiltinEnv as X, runnerOutputsSchema as Y, takesCspRegistrySync as Z, findDeadConnectConfig as _, checkOutputPaths as a, getVerb as b, collectTokenSites as c, declaredHostSchemas as d, validateDeclaredHost as et, defineHostSchemas as f, envSitesOf as g, entryActiveForVerb as h, TokenResolutionError as i, normalizePluginEntries as j, memberForRef as k, compoundOutputSource as l, drivesSchema as m, ONE_SHOT_VERBS as n, writeRunRecord as nt, checkTokenSites as o, describeToken as p, resolveRunnerModule as q, PluginError as r, clearRunRecord as s, CONNECT_RUNNER as t, validateHost as tt, compoundStartVerb as u, findRemovedForms as v, isSchemaLike as w, hostSchemaIssues as x, formatPath as y, producerOutputsSchemas as z };
|
|
2457
2592
|
|
|
2458
|
-
//# sourceMappingURL=compound-
|
|
2459
|
-
//# debugId=
|
|
2593
|
+
//# sourceMappingURL=compound-Gjt5rBfF-BmSW1XPB.mjs.map
|
|
2594
|
+
//# debugId=ff5a7d8c-3e69-574e-b5e3-29245ef73905
|