@powerhousedao/ph-cli 6.4.0-next.3 → 6.4.0-next.5
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/auth-5bqHASGL.mjs +4 -0
- package/dist/auth-DYknkWfW.mjs +23 -0
- package/dist/auth-DYknkWfW.mjs.map +1 -0
- package/dist/{build-B-rPwjM8.mjs → build-CBKlv5E3.mjs} +8 -8
- package/dist/{build-B-rPwjM8.mjs.map → build-CBKlv5E3.mjs.map} +1 -1
- package/dist/build-Dr1lnv4h.mjs +4 -0
- package/dist/{check-B7C3Vi_b.mjs → check-CW81vbe9.mjs} +4 -4
- package/dist/{check-B7C3Vi_b.mjs.map → check-CW81vbe9.mjs.map} +1 -1
- package/dist/{check-DM7UdFTK.mjs → check-Cx_AeBQe.mjs} +7 -7
- package/dist/check-Cx_AeBQe.mjs.map +1 -0
- package/dist/{check-DeUTd514.mjs → check-DhFd9tO8.mjs} +3 -3
- package/dist/{cli-connect-override-Bx_g3-ZE.mjs → cli-connect-override-DKxY3lCi.mjs} +4 -4
- package/dist/{cli-connect-override-Bx_g3-ZE.mjs.map → cli-connect-override-DKxY3lCi.mjs.map} +1 -1
- package/dist/cli.mjs +9 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-Q9sZSEZF-DQvtoigb.mjs → compound-g6x_KkWp-Bs7olmlI.mjs} +465 -361
- package/dist/compound-g6x_KkWp-Bs7olmlI.mjs.map +1 -0
- package/dist/{connect-build-CaTxdYcc.mjs → connect-build-DpGUrtct.mjs} +5 -5
- package/dist/{connect-build-CaTxdYcc.mjs.map → connect-build-DpGUrtct.mjs.map} +1 -1
- package/dist/{connect-config-A-U83U8U.mjs → connect-config-BpzwJln3.mjs} +4 -4
- package/dist/{connect-config-A-U83U8U.mjs.map → connect-config-BpzwJln3.mjs.map} +1 -1
- package/dist/{connect-preview-BvxXGo_W.mjs → connect-preview-B_E4SIV6.mjs} +21 -4
- package/dist/connect-preview-B_E4SIV6.mjs.map +1 -0
- package/dist/connect-studio-BPZOcwUM.mjs +214 -0
- package/dist/connect-studio-BPZOcwUM.mjs.map +1 -0
- package/dist/credentials-CmtYywgk.mjs +132 -0
- package/dist/credentials-CmtYywgk.mjs.map +1 -0
- package/dist/definitions-worker.mjs +4 -4
- package/dist/definitions-worker.mjs.map +1 -1
- package/dist/{dev-host-RhWeATKB.mjs → dev-host-CM-Jg2kY.mjs} +4 -4
- package/dist/{dev-host-RhWeATKB.mjs.map → dev-host-CM-Jg2kY.mjs.map} +1 -1
- package/dist/{dist-D_UjZsgt.mjs → dist-DPj_FB8H.mjs} +5 -5
- package/dist/dist-DPj_FB8H.mjs.map +1 -0
- package/dist/{explain-DbbHpa61.mjs → explain-DQ5ymlco.mjs} +5 -5
- package/dist/{explain-DbbHpa61.mjs.map → explain-DQ5ymlco.mjs.map} +1 -1
- package/dist/{export-FduYVQEM.mjs → export-CzeF8pob.mjs} +4 -4
- package/dist/{export-FduYVQEM.mjs.map → export-CzeF8pob.mjs.map} +1 -1
- package/dist/{files-DEHg350R.mjs → files-D6_euBBn.mjs} +4 -4
- package/dist/{files-DEHg350R.mjs.map → files-D6_euBBn.mjs.map} +1 -1
- package/dist/{generate-all-BE8UmbJv.mjs → generate-all-B9MwWXlq.mjs} +4 -4
- package/dist/{generate-all-BE8UmbJv.mjs.map → generate-all-B9MwWXlq.mjs.map} +1 -1
- package/dist/{generate-document-model-DSYPTMZg.mjs → generate-document-model-D3LKY1D7.mjs} +6 -8
- package/dist/generate-document-model-D3LKY1D7.mjs.map +1 -0
- package/dist/{generate-subgraph-EQ2ZjMp9.mjs → generate-subgraph-Q1VLh3SC.mjs} +10 -17
- package/dist/generate-subgraph-Q1VLh3SC.mjs.map +1 -0
- package/dist/{get-version-7oKMD8Gt.mjs → get-version-CTP__ORu.mjs} +4 -4
- package/dist/{get-version-7oKMD8Gt.mjs.map → get-version-CTP__ORu.mjs.map} +1 -1
- package/dist/identity-DXZFeQfC.mjs +137 -0
- package/dist/identity-DXZFeQfC.mjs.map +1 -0
- package/dist/{index-Bs1PfL3W.d.mts → index-aosqo7aM.d.mts} +5 -4
- package/dist/index-aosqo7aM.d.mts.map +1 -0
- package/dist/{inspect-CulIpVsF.mjs → inspect-BgKI8Fhd.mjs} +6 -6
- package/dist/{inspect-CulIpVsF.mjs.map → inspect-BgKI8Fhd.mjs.map} +1 -1
- package/dist/{keyframes-bFo9iDhT.mjs → keyframes-BkeORfEu.mjs} +4 -4
- package/dist/{keyframes-bFo9iDhT.mjs.map → keyframes-BkeORfEu.mjs.map} +1 -1
- package/dist/{mcp-CcZT9zT9.mjs → mcp-gcG7SW9L.mjs} +149 -7
- package/dist/mcp-gcG7SW9L.mjs.map +1 -0
- package/dist/{migrate-Ddr7YAtM.mjs → migrate-BaWZhorc.mjs} +4 -4
- package/dist/{migrate-Ddr7YAtM.mjs.map → migrate-BaWZhorc.mjs.map} +1 -1
- package/dist/{migrate-document-models-X_mVTljj.mjs → migrate-document-models-DYmkJzq3.mjs} +5 -6
- package/dist/migrate-document-models-DYmkJzq3.mjs.map +1 -0
- package/dist/{migrate-subgraphs-Ffwwm7Oy.mjs → migrate-subgraphs-BUgTeHcm.mjs} +6 -7
- package/dist/migrate-subgraphs-BUgTeHcm.mjs.map +1 -0
- package/dist/migrate-subgraphs-ChhXynqd.mjs +4 -0
- package/dist/{ph-cli-commands-D4Z6YSwd.mjs → ph-cli-commands-B5VkGW99.mjs} +161 -107
- package/dist/ph-cli-commands-B5VkGW99.mjs.map +1 -0
- package/dist/ph-cli-commands-CGXSo1wx.mjs +4 -0
- package/dist/{registry-auth-Bm5AR-fB.mjs → registry-auth-C8D5cno2.mjs} +4 -4
- package/dist/{registry-auth-Bm5AR-fB.mjs.map → registry-auth-C8D5cno2.mjs.map} +1 -1
- package/dist/render-BQE20Cnd.mjs +4 -0
- package/dist/{render-SVfj3m8A.mjs → render-CQdi685k.mjs} +6 -6
- package/dist/render-CQdi685k.mjs.map +1 -0
- package/dist/{run-LRGy7zGo.mjs → run-C6Vha5VN.mjs} +3 -3
- package/dist/{run--de_-WAz.mjs → run-sVzTTEUx.mjs} +5 -36
- package/dist/run-sVzTTEUx.mjs.map +1 -0
- package/dist/{run-sugar-CkuGJuPg.mjs → run-sugar-BuxOaRzE.mjs} +5 -5
- package/dist/{run-sugar-CkuGJuPg.mjs.map → run-sugar-BuxOaRzE.mjs.map} +1 -1
- package/dist/{run-sugar-Dd_Mu058.mjs → run-sugar-Dz-rpeMO.mjs} +3 -3
- package/dist/runners/connect.d.mts +20 -3
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +37 -15
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +3 -3
- package/dist/scripts/generate-commands-docs.ts +12 -0
- package/dist/{subgraphs-7OYWwP-C.mjs → subgraphs-Bm9NHTCn.mjs} +5 -38
- package/dist/subgraphs-Bm9NHTCn.mjs.map +1 -0
- package/dist/{sugar-checks-CAtgUIem.mjs → sugar-checks-DL-J3l2y.mjs} +6 -6
- package/dist/{sugar-checks-CAtgUIem.mjs.map → sugar-checks-DL-J3l2y.mjs.map} +1 -1
- package/dist/{verify-DXrs0JUp.mjs → verify-BLn76w09.mjs} +5 -5
- package/dist/{verify-DXrs0JUp.mjs.map → verify-BLn76w09.mjs.map} +1 -1
- package/dist/{vetra-gateway-BHuz7pvS.mjs → vetra-gateway-D30pZgha.mjs} +5 -5
- package/dist/{vetra-gateway-BHuz7pvS.mjs.map → vetra-gateway-D30pZgha.mjs.map} +1 -1
- package/dist/vetra-gateway-DE5Hc0Fp.mjs +4 -0
- package/dist/vetra-host-0rSW35_r.mjs +230 -0
- package/dist/vetra-host-0rSW35_r.mjs.map +1 -0
- package/dist/{vetra-launcher-B5L3yXPo.mjs → vetra-launcher-6NKfi6Au.mjs} +45 -5
- package/dist/vetra-launcher-6NKfi6Au.mjs.map +1 -0
- package/dist/vetra-launcher-XMk_Hv0c.mjs +4 -0
- package/package.json +17 -15
- package/dist/auth-BFUq7CvE.mjs +0 -18
- package/dist/auth-BFUq7CvE.mjs.map +0 -1
- package/dist/auth-CNhbN5UM.mjs +0 -4
- package/dist/build-DuwAPWMY.mjs +0 -4
- package/dist/check-DM7UdFTK.mjs.map +0 -1
- package/dist/compound-Q9sZSEZF-DQvtoigb.mjs.map +0 -1
- package/dist/connect-preview-BvxXGo_W.mjs.map +0 -1
- package/dist/connect-studio-B2gugCJU.mjs +0 -106
- package/dist/connect-studio-B2gugCJU.mjs.map +0 -1
- package/dist/dist-D_UjZsgt.mjs.map +0 -1
- package/dist/generate-document-model-DSYPTMZg.mjs.map +0 -1
- package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +0 -1
- package/dist/index-Bs1PfL3W.d.mts.map +0 -1
- package/dist/mcp-CcZT9zT9.mjs.map +0 -1
- package/dist/migrate-document-models-X_mVTljj.mjs.map +0 -1
- package/dist/migrate-subgraphs-DEqWkLoh.mjs +0 -4
- package/dist/migrate-subgraphs-Ffwwm7Oy.mjs.map +0 -1
- package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +0 -1
- package/dist/ph-cli-commands-p9cO6MsE.mjs +0 -4
- package/dist/render-3M3DwFzO.mjs +0 -4
- package/dist/render-SVfj3m8A.mjs.map +0 -1
- package/dist/run--de_-WAz.mjs.map +0 -1
- package/dist/subgraphs-7OYWwP-C.mjs.map +0 -1
- package/dist/vetra-gateway-ag33E_Ta.mjs +0 -4
- package/dist/vetra-host-CYdbd3J3.mjs +0 -111
- package/dist/vetra-host-CYdbd3J3.mjs.map +0 -1
- package/dist/vetra-launcher-B5L3yXPo.mjs.map +0 -1
- package/dist/vetra-launcher-BUO9e74r.mjs +0 -4
|
@@ -0,0 +1,132 @@
|
|
|
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]="9b3856e7-8619-510e-9720-2b08baf11e13")}catch(e){}}();
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { listCredentialRecords, listCredentialWithdrawals, pruneCredentialRecords, withdrawCredentialRecords } from "@powerhousedao/shared/clis/credential-records";
|
|
5
|
+
import { identityDataDir, shortAddress } from "@powerhousedao/shared/clis/identity";
|
|
6
|
+
//#region src/services/credentials.ts
|
|
7
|
+
function dataDirOf(args) {
|
|
8
|
+
return args.dataDir ? path.resolve(args.dataDir) : identityDataDir();
|
|
9
|
+
}
|
|
10
|
+
async function stateOf(record, now) {
|
|
11
|
+
const { checkCredentialFor, expandCarriedCredential } = await import("@renown/sdk/node");
|
|
12
|
+
const credential = expandCarriedCredential(record.credential);
|
|
13
|
+
const network = record.credential.issuer.id.split(":")[2] ?? "";
|
|
14
|
+
if (!credential) return "does not verify";
|
|
15
|
+
const check = await checkCredentialFor(credential, {
|
|
16
|
+
address: record.address,
|
|
17
|
+
chainId: record.chainId,
|
|
18
|
+
networkId: network,
|
|
19
|
+
sessionDid: record.sessionDid
|
|
20
|
+
}, now);
|
|
21
|
+
return check === "ok" ? "valid" : check === "expired" ? "expired" : "does not verify";
|
|
22
|
+
}
|
|
23
|
+
const day = (date) => (date ?? "").slice(0, 10) || "-";
|
|
24
|
+
function table(rows) {
|
|
25
|
+
const widths = rows[0].map((_, i) => Math.max(...rows.map((row) => row[i].length)));
|
|
26
|
+
return rows.map((row) => row.map((cell, i) => i === row.length - 1 ? cell : cell.padEnd(widths[i])).join(" ").trimEnd());
|
|
27
|
+
}
|
|
28
|
+
async function runCredentialsList(args, print = console.log) {
|
|
29
|
+
const dataDir = dataDirOf(args);
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
const records = await Promise.all(listCredentialRecords({ dataDir }).map(async (record) => ({
|
|
32
|
+
record,
|
|
33
|
+
state: await stateOf(record, now)
|
|
34
|
+
})));
|
|
35
|
+
const withdrawn = args.all ? listCredentialWithdrawals({ dataDir }) : [];
|
|
36
|
+
if (args.json) {
|
|
37
|
+
print(JSON.stringify({
|
|
38
|
+
dataDir,
|
|
39
|
+
records: records.map(({ record, state }) => ({
|
|
40
|
+
id: record.id,
|
|
41
|
+
address: record.address,
|
|
42
|
+
chainId: record.chainId,
|
|
43
|
+
sessionDid: record.sessionDid,
|
|
44
|
+
label: record.label,
|
|
45
|
+
source: record.source,
|
|
46
|
+
createdAt: record.createdAt,
|
|
47
|
+
expiresAt: record.credential.expirationDate ?? null,
|
|
48
|
+
state
|
|
49
|
+
})),
|
|
50
|
+
...args.all ? { withdrawn } : {}
|
|
51
|
+
}, null, 2));
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
if (records.length === 0) print(`No credential records in ${dataDir}.`);
|
|
55
|
+
else for (const line of table([[
|
|
56
|
+
"ID",
|
|
57
|
+
"WHO",
|
|
58
|
+
"LABEL",
|
|
59
|
+
"SOURCE",
|
|
60
|
+
"EXPIRES",
|
|
61
|
+
"STATE"
|
|
62
|
+
], ...records.map(({ record, state }) => [
|
|
63
|
+
record.id.slice(0, 8),
|
|
64
|
+
shortAddress(record.address),
|
|
65
|
+
record.label,
|
|
66
|
+
record.source,
|
|
67
|
+
day(record.credential.expirationDate),
|
|
68
|
+
state
|
|
69
|
+
])])) print(line);
|
|
70
|
+
if (args.all) {
|
|
71
|
+
print("");
|
|
72
|
+
if (withdrawn.length === 0) print("No withdrawn credentials.");
|
|
73
|
+
else {
|
|
74
|
+
print("Withdrawn:");
|
|
75
|
+
for (const line of table([[
|
|
76
|
+
"ID",
|
|
77
|
+
"WHO",
|
|
78
|
+
"LABEL",
|
|
79
|
+
"BY",
|
|
80
|
+
"WITHDRAWN"
|
|
81
|
+
], ...withdrawn.map((w) => [
|
|
82
|
+
w.id.slice(0, 8),
|
|
83
|
+
shortAddress(w.address),
|
|
84
|
+
w.label ?? "",
|
|
85
|
+
w.by,
|
|
86
|
+
day(w.withdrawnAt)
|
|
87
|
+
])])) print(line);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
/** The records `target` names: an id prefix, an address, or a label. */
|
|
93
|
+
function matches(records, target) {
|
|
94
|
+
const lower = target.toLowerCase();
|
|
95
|
+
return records.filter((record) => /^[0-9a-f]{4,32}$/.test(lower) && record.id.startsWith(lower) || record.address === lower || record.label === target);
|
|
96
|
+
}
|
|
97
|
+
function runCredentialsWithdraw(args, print = console.log) {
|
|
98
|
+
const dataDir = dataDirOf(args);
|
|
99
|
+
if (args.targets.length === 0 && !args.expired) {
|
|
100
|
+
print("Name the records to withdraw (an id prefix, an address or a label), or pass --expired.");
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
let status = 0;
|
|
104
|
+
if (args.expired) {
|
|
105
|
+
const { records, withdrawals } = pruneCredentialRecords({ dataDir });
|
|
106
|
+
print(`Removed ${records.length} expired record${records.length === 1 ? "" : "s"} and ${withdrawals.length} old tombstone${withdrawals.length === 1 ? "" : "s"}.`);
|
|
107
|
+
}
|
|
108
|
+
const records = listCredentialRecords({ dataDir });
|
|
109
|
+
const ids = [];
|
|
110
|
+
for (const target of args.targets) {
|
|
111
|
+
const found = matches(records, target);
|
|
112
|
+
if (found.length === 0) {
|
|
113
|
+
print(`No record matches ${target}.`);
|
|
114
|
+
status = 1;
|
|
115
|
+
} else if (found.length > 1) {
|
|
116
|
+
print(`${target} matches ${found.length} records; name one by its id:`);
|
|
117
|
+
for (const record of found) print(` ${record.id.slice(0, 8)} ${shortAddress(record.address)} ${record.label}`);
|
|
118
|
+
status = 1;
|
|
119
|
+
} else ids.push(found[0].id);
|
|
120
|
+
}
|
|
121
|
+
for (const withdrawal of withdrawCredentialRecords({
|
|
122
|
+
dataDir,
|
|
123
|
+
ids,
|
|
124
|
+
by: "command"
|
|
125
|
+
})) print(`Withdrew ${withdrawal.id.slice(0, 8)} (${shortAddress(withdrawal.address)}, "${withdrawal.label ?? ""}"). A running host refuses it from its next request.`);
|
|
126
|
+
return status;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { runCredentialsList, runCredentialsWithdraw };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=credentials-CmtYywgk.mjs.map
|
|
132
|
+
//# debugId=9b3856e7-8619-510e-9720-2b08baf11e13
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials-CmtYywgk.mjs","sources":["../src/services/credentials.ts"],"sourcesContent":["import {\n listCredentialRecords,\n listCredentialWithdrawals,\n pruneCredentialRecords,\n withdrawCredentialRecords,\n type CredentialRecord,\n} from \"@powerhousedao/shared/clis/credential-records\";\nimport {\n identityDataDir,\n shortAddress,\n} from \"@powerhousedao/shared/clis/identity\";\nimport path from \"node:path\";\n\n/**\n * `ph credentials`: the credentials this store's host accepts by its own\n * record (`<dataDir>/.ph/credentials`), and their withdrawal. Runs as the OS\n * user on the files; a running host refuses a withdrawn one at its next request.\n */\n\ntype Print = (line: string) => void;\n\ntype State = \"valid\" | \"expired\" | \"does not verify\";\n\nfunction dataDirOf(args: { dataDir?: string }): string {\n return args.dataDir ? path.resolve(args.dataDir) : identityDataDir();\n}\n\nasync function stateOf(record: CredentialRecord, now: number): Promise<State> {\n const { checkCredentialFor, expandCarriedCredential } =\n await import(\"@renown/sdk/node\");\n const credential = expandCarriedCredential(record.credential);\n const network = record.credential.issuer.id.split(\":\")[2] ?? \"\";\n if (!credential) return \"does not verify\";\n const check = await checkCredentialFor(\n credential,\n {\n address: record.address,\n chainId: record.chainId,\n networkId: network,\n sessionDid: record.sessionDid,\n },\n now,\n );\n return check === \"ok\"\n ? \"valid\"\n : check === \"expired\"\n ? \"expired\"\n : \"does not verify\";\n}\n\nconst day = (date: string | undefined) => (date ?? \"\").slice(0, 10) || \"-\";\n\nfunction table(rows: string[][]): string[] {\n const widths = rows[0].map((_, i) =>\n Math.max(...rows.map((row) => row[i].length)),\n );\n return rows.map((row) =>\n row\n .map((cell, i) => (i === row.length - 1 ? cell : cell.padEnd(widths[i])))\n .join(\" \")\n .trimEnd(),\n );\n}\n\nexport async function runCredentialsList(\n args: { dataDir?: string; all?: boolean; json?: boolean },\n print: Print = console.log,\n): Promise<number> {\n const dataDir = dataDirOf(args);\n const now = Date.now();\n const records = await Promise.all(\n listCredentialRecords({ dataDir }).map(async (record) => ({\n record,\n state: await stateOf(record, now),\n })),\n );\n const withdrawn = args.all ? listCredentialWithdrawals({ dataDir }) : [];\n if (args.json) {\n print(\n JSON.stringify(\n {\n dataDir,\n records: records.map(({ record, state }) => ({\n id: record.id,\n address: record.address,\n chainId: record.chainId,\n sessionDid: record.sessionDid,\n label: record.label,\n source: record.source,\n createdAt: record.createdAt,\n expiresAt: record.credential.expirationDate ?? null,\n state,\n })),\n ...(args.all ? { withdrawn } : {}),\n },\n null,\n 2,\n ),\n );\n return 0;\n }\n if (records.length === 0) {\n print(`No credential records in ${dataDir}.`);\n } else {\n for (const line of table([\n [\"ID\", \"WHO\", \"LABEL\", \"SOURCE\", \"EXPIRES\", \"STATE\"],\n ...records.map(({ record, state }) => [\n record.id.slice(0, 8),\n shortAddress(record.address),\n record.label,\n record.source,\n day(record.credential.expirationDate),\n state,\n ]),\n ])) {\n print(line);\n }\n }\n if (args.all) {\n print(\"\");\n if (withdrawn.length === 0) {\n print(\"No withdrawn credentials.\");\n } else {\n print(\"Withdrawn:\");\n for (const line of table([\n [\"ID\", \"WHO\", \"LABEL\", \"BY\", \"WITHDRAWN\"],\n ...withdrawn.map((w) => [\n w.id.slice(0, 8),\n shortAddress(w.address),\n w.label ?? \"\",\n w.by,\n day(w.withdrawnAt),\n ]),\n ])) {\n print(line);\n }\n }\n }\n return 0;\n}\n\n/** The records `target` names: an id prefix, an address, or a label. */\nfunction matches(records: CredentialRecord[], target: string) {\n const lower = target.toLowerCase();\n return records.filter(\n (record) =>\n (/^[0-9a-f]{4,32}$/.test(lower) && record.id.startsWith(lower)) ||\n record.address === lower ||\n record.label === target,\n );\n}\n\nexport function runCredentialsWithdraw(\n args: { targets: string[]; expired?: boolean; dataDir?: string },\n print: Print = console.log,\n): number {\n const dataDir = dataDirOf(args);\n if (args.targets.length === 0 && !args.expired) {\n print(\n \"Name the records to withdraw (an id prefix, an address or a label), or pass --expired.\",\n );\n return 1;\n }\n let status = 0;\n if (args.expired) {\n const { records, withdrawals } = pruneCredentialRecords({ dataDir });\n print(\n `Removed ${records.length} expired record${records.length === 1 ? \"\" : \"s\"} and ${withdrawals.length} old tombstone${withdrawals.length === 1 ? \"\" : \"s\"}.`,\n );\n }\n const records = listCredentialRecords({ dataDir });\n const ids: string[] = [];\n for (const target of args.targets) {\n const found = matches(records, target);\n if (found.length === 0) {\n print(`No record matches ${target}.`);\n status = 1;\n } else if (found.length > 1) {\n print(`${target} matches ${found.length} records; name one by its id:`);\n for (const record of found) {\n print(\n ` ${record.id.slice(0, 8)} ${shortAddress(record.address)} ${record.label}`,\n );\n }\n status = 1;\n } else {\n ids.push(found[0].id);\n }\n }\n for (const withdrawal of withdrawCredentialRecords({\n dataDir,\n ids,\n by: \"command\",\n })) {\n print(\n `Withdrew ${withdrawal.id.slice(0, 8)} (${shortAddress(withdrawal.address)}, \"${withdrawal.label ?? \"\"}\"). A running host refuses it from its next request.`,\n );\n }\n return status;\n}\n"],"names":[],"mappings":";;;;;;AAuBA,SAAS,UAAU,MAAoC;CACrD,OAAO,KAAK,UAAU,KAAK,QAAQ,KAAK,OAAO,IAAI,gBAAgB;AACrE;AAEA,eAAe,QAAQ,QAA0B,KAA6B;CAC5E,MAAM,EAAE,oBAAoB,4BAC1B,MAAM,OAAO;CACf,MAAM,aAAa,wBAAwB,OAAO,UAAU;CAC5D,MAAM,UAAU,OAAO,WAAW,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM;CAC7D,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,QAAQ,MAAM,mBAClB,YACA;EACE,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,WAA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IAAI,EAC3J;CACF;CACA,MAAM,UAAU,sBAAsB,EAAE,QAAQ,CAAC;CACjD,MAAM,MAAgB,CAAC;CACvB,KAAK,MAAM,UAAU,KAAK,SAAS;EACjC,MAAM,QAAQ,QAAQ,SAAS,MAAM;EACrC,IAAI,MAAM,WAAW,GAAG;GACtB,MAAM,qBAAqB,OAAO,EAAE;GACpC,SAAS;EACX,OAAO,IAAI,MAAM,SAAS,GAAG;GAC3B,MAAM,GAAG,OAAO,WAAW,MAAM,OAAO,8BAA8B;GACtE,KAAK,MAAM,UAAU,OACnB,MACE,KAAK,OAAO,GAAG,MAAM,GAAG,CAAC,EAAE,IAAI,aAAa,OAAO,OAAO,EAAE,IAAI,OAAO,OACzE;GAEF,SAAS;EACX,OACE,IAAI,KAAK,MAAM,EAAE,CAAC,EAAE;CAExB;CACA,KAAK,MAAM,cAAc,0BAA0B;EACjD;EACA;EACA,IAAI;CACN,CAAC,GACC,MACE,YAAY,WAAW,GAAG,MAAM,GAAG,CAAC,EAAE,IAAI,aAAa,WAAW,OAAO,EAAE,KAAK,WAAW,SAAS,GAAG,qDACzG;CAEF,OAAO;AACT","debug_id":"9b3856e7-8619-510e-9720-2b08baf11e13"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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]="
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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]="a0173a8f-a81f-5cf8-9ce3-157981a85936")}catch(e){}}();
|
|
3
|
+
import { t as definitionChecks } from "./check-Cx_AeBQe.mjs";
|
|
4
|
+
import { readProjectDefinitions } from "@powerhousedao/codegen/utils";
|
|
5
5
|
//#region src/services/model/definitions-worker.ts
|
|
6
6
|
async function check(projectRoot, profile) {
|
|
7
7
|
const read = definitionChecks[profile];
|
|
@@ -25,4 +25,4 @@ process.send(reply, () => process.exit(0));
|
|
|
25
25
|
export {};
|
|
26
26
|
|
|
27
27
|
//# sourceMappingURL=definitions-worker.mjs.map
|
|
28
|
-
//# debugId=
|
|
28
|
+
//# debugId=a0173a8f-a81f-5cf8-9ce3-157981a85936
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions-worker.mjs","sources":["../src/services/model/definitions-worker.ts"],"sourcesContent":["import type { DefinitionCheckReport } from \"@powerhousedao/shared/document-model\";\nimport type { ReleaseCheck } from \"../release/evidence.js\";\nimport { definitionChecks } from \"./check.js\";\nimport { readProjectDefinitions } from \"
|
|
1
|
+
{"version":3,"file":"definitions-worker.mjs","sources":["../src/services/model/definitions-worker.ts"],"sourcesContent":["import type { DefinitionCheckReport } from \"@powerhousedao/shared/document-model\";\nimport type { ReleaseCheck } from \"../release/evidence.js\";\nimport { definitionChecks } from \"./check.js\";\nimport { readProjectDefinitions } from \"@powerhousedao/codegen/utils\";\n\n/**\n * What the definitions worker reports for each profile. `ph build` forks the\n * worker so the package's own modules never run in the build process.\n */\nexport type DefinitionsResults = {\n readonly edit: DefinitionCheckReport;\n readonly release: ReleaseCheck;\n};\n\nexport type DefinitionsProfile = keyof DefinitionsResults;\n\n/** The worker's one IPC message: the check's result, or why it could not run. */\nexport type DefinitionsReply<P extends DefinitionsProfile> =\n | { readonly ok: true; readonly result: DefinitionsResults[P] }\n | { readonly ok: false; readonly message: string };\n\nasync function check(\n projectRoot: string,\n profile: DefinitionsProfile,\n): Promise<DefinitionsReply<DefinitionsProfile>> {\n const read: (\n ...args: Parameters<typeof definitionChecks.release>\n ) => Promise<DefinitionsResults[DefinitionsProfile]> =\n definitionChecks[profile];\n try {\n return {\n ok: true,\n result: await readProjectDefinitions(projectRoot, read, {\n allowMissingConfig: true,\n }),\n };\n } catch (error) {\n return {\n ok: false,\n message: error instanceof Error ? error.message : String(error),\n };\n }\n}\n\n// The build that forked this worker has gone: nothing is left to report to.\nprocess.on(\"disconnect\", () => process.exit(1));\nconst [projectRoot, profile] = process.argv.slice(2) as [\n string,\n DefinitionsProfile,\n];\nconst reply = await check(projectRoot, profile);\n// Exit once the reply is sent: a module's timer must not keep the worker alive.\nprocess.send!(reply, () => process.exit(0));\n"],"names":[],"mappings":";;;;;AAqBA,eAAe,MACb,aACA,SAC+C;CAC/C,MAAM,OAGJ,iBAAiB;CACnB,IAAI;EACF,OAAO;GACL,IAAI;GACJ,QAAQ,MAAM,uBAAuB,aAAa,MAAM,EACtD,oBAAoB,KACtB,CAAC;EACH;CACF,SAAS,OAAO;EACd,OAAO;GACL,IAAI;GACJ,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAChE;CACF;AACF;AAGA,QAAQ,GAAG,oBAAoB,QAAQ,KAAK,CAAC,CAAC;AAC9C,MAAM,CAAC,aAAa,WAAW,QAAQ,KAAK,MAAM,CAAC;AAInD,MAAM,QAAQ,MAAM,MAAM,aAAa,OAAO;AAE9C,QAAQ,KAAM,aAAa,QAAQ,KAAK,CAAC,CAAC","debug_id":"a0173a8f-a81f-5cf8-9ce3-157981a85936"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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]="
|
|
3
|
-
import {
|
|
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]="19d12356-23a4-5854-9bbb-a4a22e354454")}catch(e){}}();
|
|
3
|
+
import { R as probeHostsFolder } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
4
4
|
import { DEV_HOST, LEGACY_DEV_HOST } from "@powerhousedao/shared/clis/constants";
|
|
5
5
|
//#region src/utils/dev-host.ts
|
|
6
6
|
const isDevHost = (host) => host === DEV_HOST || host === LEGACY_DEV_HOST;
|
|
@@ -15,5 +15,5 @@ function devHostOf(projectRoot) {
|
|
|
15
15
|
//#endregion
|
|
16
16
|
export { isDevHost as n, devHostOf as t };
|
|
17
17
|
|
|
18
|
-
//# sourceMappingURL=dev-host-
|
|
19
|
-
//# debugId=
|
|
18
|
+
//# sourceMappingURL=dev-host-CM-Jg2kY.mjs.map
|
|
19
|
+
//# debugId=19d12356-23a4-5854-9bbb-a4a22e354454
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-host-
|
|
1
|
+
{"version":3,"file":"dev-host-CM-Jg2kY.mjs","sources":["../src/utils/dev-host.ts"],"sourcesContent":["import { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport {\n DEV_HOST,\n LEGACY_DEV_HOST,\n} from \"@powerhousedao/shared/clis/constants\";\n\n/** A host `ph dev` runs: the compound over a switchboard and a Connect. */\nexport type DevHost = typeof DEV_HOST | typeof LEGACY_DEV_HOST;\n\nexport const isDevHost = (host: string): host is DevHost =>\n host === DEV_HOST || host === LEGACY_DEV_HOST;\n\n/**\n * The host `ph dev` and `ph mcp` run in this project: hosts/dev, or\n * hosts/vetra in a project that has it and no hosts/dev.\n */\nexport function devHostOf(projectRoot: string): DevHost {\n const probe = probeHostsFolder(projectRoot);\n return probe.kind === \"present\" &&\n probe.hosts.includes(LEGACY_DEV_HOST) &&\n !probe.hosts.includes(DEV_HOST)\n ? LEGACY_DEV_HOST\n : DEV_HOST;\n}\n"],"names":[],"mappings":";;;;;AASA,MAAa,aAAa,SACxB,SAAS,YAAY,SAAS;;;;;AAMhC,SAAgB,UAAU,aAA8B;CACtD,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,OAAO,MAAM,SAAS,aACpB,MAAM,MAAM,SAAS,eAAe,KACpC,CAAC,MAAM,MAAM,SAAS,QAAQ,IAC5B,kBACA;AACN","debug_id":"19d12356-23a4-5854-9bbb-a4a22e354454"}
|
|
@@ -1,12 +1,12 @@
|
|
|
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]="f3758d76-dca8-526b-924e-5a9ca8eeacba")}catch(e){}}();
|
|
3
3
|
import { a as custom, b as prettifyError, c as literal, f as record, m as string, p as strictObject } from "./schemas-DzgKfQIx.mjs";
|
|
4
|
-
import { A as
|
|
4
|
+
import { $ as unsetEnvMessage, A as memberVerbOf, B as producerOutputsSchemas, C as isPlainObject, D as memberCycle, E as loadProducers, F as planCompound, H as resolveHostOutputs, I as planForeground, J as runnerOutputsSchema, K as resolveRunnerModule, L as prepareMember, M as outputRefsOf, N as outputSitesOf, O as memberForRef, P as packageBuildRefusal, Q as takesCspRegistrySync, S as isBuiltinEnvName, T as loadHost, Z as substituteBuiltinEnv, _ as findRemovedForms, b as hostFileLabel, ft as projectDriveIdWith, h as envSitesOf, it as declaredHostSchemas, j as moduleRootOf, l as checkOutputPaths, n as HostLoadError, o as TokenResolutionError, p as compoundStartVerb, pt as readProjectName, r as ONE_SHOT_VERBS, u as checkTokenSites, w as kindShapeIssues, x as hostSchemaIssues, y as getVerb, z as processResolveEnv } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
5
5
|
import { DEFAULT_CONNECT_STUDIO_PORT, DEFAULT_SWITCHBOARD_PORT } from "@powerhousedao/shared/clis/constants";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import crypto from "node:crypto";
|
|
8
7
|
import "@powerhousedao/shared/host-tokens";
|
|
9
8
|
import "@powerhousedao/shared/connect/origin-placeholder";
|
|
9
|
+
import crypto from "node:crypto";
|
|
10
10
|
import { DRIVE_ICON_MAX_BYTES, resolveImageRef } from "@powerhousedao/shared/connect/image-ref";
|
|
11
11
|
//#region ../../packages/host-core/dist/index.mjs
|
|
12
12
|
/** The `ph run` pipeline up to the verb, collecting every issue; starts
|
|
@@ -485,5 +485,5 @@ function mergeDefaultDrives(...groups) {
|
|
|
485
485
|
//#endregion
|
|
486
486
|
export { mergeDrivePlan as a, mergeDefaultDrives as i, explainDrivePlan as n, projectDriveId as o, exportHost as r, resolveDriveDeclaration as s, checkHost as t };
|
|
487
487
|
|
|
488
|
-
//# sourceMappingURL=dist-
|
|
489
|
-
//# debugId=
|
|
488
|
+
//# sourceMappingURL=dist-DPj_FB8H.mjs.map
|
|
489
|
+
//# debugId=f3758d76-dca8-526b-924e-5a9ca8eeacba
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-DPj_FB8H.mjs","sources":["../../../packages/host-core/dist/index.mjs"],"sourcesContent":["import { $ as refineStartOrder, A as childWrapperSchema, At as mapTokenSchema, B as genericCompoundHostSchema, C as CONNECT_PRIMARY_MESSAGE, Ct as envTokenSchema, D as HOST_REF_MESSAGE, Dt as isToken, E as HOST_NAME_PATTERN, Et as forbidRef, F as declaredGenericCompoundHostSchema, Ft as tokenable, G as placementKeyIssues, H as makeHostSchemas, I as declaredHostSchemas, J as reactorBackendSchema, K as profileSchema, L as defineHostSchemas, M as compoundHostSchema, Mt as ref, N as compoundWiringSchema, Nt as tokenKeyOf, O as HOST_REF_PATTERN, Ot as itemTokenSchema, P as connectReactorIssues, Pt as tokenSchema, Q as refineConnectReactor, R as emitHostJsonSchema, S as instanceServicesDir, St as concatTokenSchema, T as HOST_NAME_MESSAGE, Tt as findToken, U as memberProcessSchema, V as hostNameSchema, W as originOrUrlSchema, X as reactorProtocolSchema, Y as reactorHostSchema, Z as reactorSchema, _ as writeOwnerOnlyFile, _t as driveDeclarationSchema, at as mergeContributions, b as instancePhDir, bt as TOKEN_ESCAPE_KEY, c as recordKeyOf, ct as pluginEntryObjectSchema, d as writeRunRecord, dt as resolveOrder, et as runnerBaseSchema, f as runRecordMemberSchema, ft as runObserveHook, g as restrictFileToOwner, gt as buildDriveDeclarationSchema, h as fileAccessList, ht as runTransformHook, i as probeRun, it as hostTypeSatisfies, j as childrenSchema, jt as outputTokenSchema, k as PACKAGE_NAME_PATTERN, kt as keyTokenSchema, l as runRecordKey, lt as pluginEntrySchema, m as createOwnerOnlyFile, mt as runProvideHook, n as isPidAlive, nt as PluginError, o as readProjectName, ot as normalizePluginEntries, p as runRecordSchema, pt as runObserveHookSequential, q as reactorBackendKindSchema, r as listRunRecords, rt as entryActiveForVerb, s as readRunRecord, st as normalizePluginEntry, t as clearRunRecord, tt as runnerKindSchema, u as runRecordPath, ut as registerHostType, v as instanceDataDir, vt as drivesSchema, w as HOST_NAME_MAX_LENGTH, wt as envTokenable, x as instanceRunDir, xt as TOKEN_KEYS, y as instanceKey, yt as projectDriveIdWith, z as emittedHostSchemas } from \"./run-record-C6oTZF_C.mjs\";\nimport { $ as ONE_SHOT_VERBS, A as signInLinksOf, At as schemaAtPath, B as findNonStaticValue, Bt as HostLoadError, C as applyChildWrapper, Ct as findRemovedForms, D as COMPOUND_MEMBER_ENV, Dt as outputRefsOf, E as spawnHost, Et as envSitesOf, F as splitCompoundArgv, Ft as renderTokens, G as loadHostFresh, Gt as parseHostRef, H as lintHostImports, Ht as formatHostRef, I as splitRunArgv, It as unwrapEscapes, J as readOutputsFileHash, Jt as defaultConnectComposition, K as moduleRootOf, Kt as resolvePackageRoot, L as OUTPUTS_FILE, Lt as findDeadConnectConfig, M as signInSecretOf, Mt as describeToken, N as checkRunnerArgv, Nt as formatPath, O as takeCompoundMember, Ot as outputSitesOf, P as isRunnerArgsSchema, Pt as isPlainObject, Q as CONNECT_RUNNER, R as computeOutputsHash, Rt as resolveHostPlugins, S as resolveUserDataPlaceholders, St as substituteBuiltinEnv, T as SpawnHostError, Tt as checkTokenSites, U as lintOutputsFile, Ut as hostFileLabel, V as lintHostImportGraph, Vt as findHostPackage, W as loadHost, Wt as locateHost, X as stripComments, Y as scanHostImports, Z as withoutHostsMessage, _ as processResolveEnv, _t as PlanError, a as memberProcessOf, at as kindShapeIssues, b as runnerOutputsSchema, bt as BUILTIN_ENV_NAMES, c as prepareMember, ct as packageBuildRefusal, d as takesCspRegistrySync, dt as validateHost, et as RunnerError, f as runnerHandleSchema, ft as TokenResolutionError, g as loadProducers, gt as unsetEnvMessage, h as OUTPUT_DATA_DIRS_ENV, ht as resolveHostOutputs, i as memberCycle, it as isSchemaLike, j as signInMembersOf, jt as collectTokenSites, k as announceSignInLinks, kt as refKey, l as runCompound, lt as resolveRunnerModule, m as compoundOutputSource, mt as emptyMaps, n as compoundStartVerb, nt as getVerb, o as memberVerbOf, ot as knownVerbIssues, p as toStartedHandle, pt as describeMapElements, q as probeHostsFolder, qt as CONNECT_PLUGIN_OWNED_SLICES, r as holdStopRequests, rt as hostSchemaIssues, s as planForeground, st as listVerbs, t as STOP_STREAM_LIMIT_MS, tt as STORE_VERBS, u as stopStreamOf, ut as validateDeclaredHost, v as producerOutputsSchemas, vt as memberForRef, w as SPAWN_STOPPING_NOTE, wt as checkOutputPaths, x as defaultUserDataDir, xt as isBuiltinEnvName, y as runRecordOutputSource, yt as planCompound, z as describeHostOutputs, zt as resolvePluginContributions } from \"./compound-g6x_KkWp.mjs\";\nimport { ASK_TIMEOUT_MS, CONTROL_PROTOCOL, ControlError, MAX_LINE_BYTES, callControl, closeProcessControlChannel, controlProtocolOf, controlRecordOf, controlRecordSchema, ensureProcessControlChannel, openControlChannel, ownerOnlyPipeAccess, pipeAccessList, processControlChannel, protocolMismatch } from \"./control-channel.mjs\";\nimport { describeInstance, findRunningInstance, instanceOfRecord, isAlreadyRunning, listRunningInstances, restartDecision, runningInstance, supervisedFactLines } from \"./instance.mjs\";\nimport { a as STOP_ON_STDIN_ENV, c as installStopChannel, d as stopChannelPath, f as stopRun, l as listenForStop, o as STOP_RUN_TIMEOUT_MS, s as askToStop, u as requestStop } from \"./host-entry-B8n_590_.mjs\";\nimport { killTree } from \"./kill-tree.mjs\";\nimport crypto from \"node:crypto\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\nimport { driveAddressMessage, switchboardOfDrive, switchboardOfDrive as switchboardOfDrive$1 } from \"@powerhousedao/shared/host-tokens\";\nimport { ORIGIN_PLACEHOLDER, SWITCHBOARD_PROXY_PATHS, isHtmlNavigation, isOriginPlaceholderUrl, isSwitchboardProxyPath, resolveOriginPlaceholders, toOriginPlaceholder, withOriginPlaceholders } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport { DEFAULT_CONNECT_STUDIO_PORT, DEFAULT_SWITCHBOARD_PORT } from \"@powerhousedao/shared/clis/constants\";\nimport { DRIVE_ICON_MAX_BYTES, resolveImageRef } from \"@powerhousedao/shared/connect/image-ref\";\n//#region src/check-host.ts\n/** The `ph run` pipeline up to the verb, collecting every issue; starts\n* nothing. `name` is a ref: a project host, or `<package>/<host>`. */\nasync function checkHost(name, options) {\n\tconst result = {\n\t\tissues: [],\n\t\twarnings: [],\n\t\tdeferred: []\n\t};\n\tlet file = `hosts/${name}/host.js`;\n\tconst verb = options.verb ?? \"run\";\n\tlet host;\n\tlet runner;\n\tlet hostPackage;\n\ttry {\n\t\tconst loaded = await loadHost(options.projectRoot, name);\n\t\thost = loaded.host;\n\t\thostPackage = loaded.package;\n\t\tfile = hostFileLabel(loaded.name, hostPackage);\n\t\trunner = await resolveRunnerModule(moduleRootOf(options.projectRoot, loaded), host.runner.module);\n\t} catch (error) {\n\t\tissuer(result, file)(\"load\", \"\", error);\n\t\treturn result;\n\t}\n\tconst specifier = host.runner.module;\n\tif (hostPackage && ONE_SHOT_VERBS.has(verb)) {\n\t\tissuer(result, file)(\"declared\", packageBuildRefusal(name, hostPackage, verb));\n\t\treturn result;\n\t}\n\tif (runner.kind === \"compound\") {\n\t\tawait checkCompound(result, options, {\n\t\t\tfile,\n\t\t\thost,\n\t\t\trunner,\n\t\t\tspecifier,\n\t\t\tverb,\n\t\t\thostPackage\n\t\t});\n\t\treturn result;\n\t}\n\tconst refs = outputRefsOf(host);\n\tconst producers = await loadProducers(options.projectRoot, refs, hostPackage);\n\tawait checkSubject(result, options, {\n\t\tfile,\n\t\thost,\n\t\trunner,\n\t\tspecifier,\n\t\tverb,\n\t\thostPackage,\n\t\toutputsSchemaOf: producerOutputsSchemas(producers),\n\t\tself: \"outputs\"\n\t});\n\treturn result;\n}\n/** Declared validation; returns whether its tokens and its shape passed. */\nfunction checkDeclared(result, subject, outputsSchemaOf) {\n\tconst issue = issuer(result, subject.file);\n\tconst { host, runner, specifier } = subject;\n\ttry {\n\t\tgetVerb(runner, specifier, subject.verb);\n\t} catch (error) {\n\t\tissue(\"declared\", \"\", error);\n\t}\n\tconst tokenIssues = [\n\t\t...findRemovedForms(host),\n\t\t...checkTokenSites(host),\n\t\t...outputsSchemaOf ? checkOutputPaths(host, outputsSchemaOf) : []\n\t];\n\tfor (const i of tokenIssues) issue(\"declared\", i);\n\tconst shapeIssues = runner.declaredHostSchema ? schemaIssuesOf(runner, runner.declaredHostSchema, specifier, host, true) : kindShapeIssues(runner.kind, specifier, host);\n\tfor (const i of shapeIssues) issue(\"declared\", i);\n\treturn {\n\t\ttokens: tokenIssues.length === 0,\n\t\tshape: shapeIssues.length === 0\n\t};\n}\nfunction schemaIssuesOf(runner, schema, specifier, host, allowTokens) {\n\tconst checked = hostSchemaIssues(runner, schema, specifier, host, { tokens: allowTokens ? \"allow\" : \"forbid\" });\n\treturn [...checked.issues, ...checked.schemaIssues ?? []];\n}\nasync function checkSubject(result, options, subject) {\n\tconst issue = issuer(result, subject.file);\n\tconst { runner, specifier, file } = subject;\n\tconst declared = checkDeclared(result, subject, subject.outputsSchemaOf);\n\tconst resolveEnv = processResolveEnv(options.projectRoot, options.env, subject.hostPackage);\n\tconst patch = subject.patch ?? ((host) => host);\n\tif (ONE_SHOT_VERBS.has(subject.verb)) {\n\t\tif (!declared.tokens || !declared.shape) return;\n\t\tconst host = patch(substituteBuiltinEnv(subject.host, resolveEnv.builtins ?? {}));\n\t\tconst schema = runner.declaredHostSchema ?? runner.hostSchema;\n\t\tfor (const i of schemaIssuesOf(runner, schema, specifier, host, true)) issue(\"resolved\", i);\n\t\treturn;\n\t}\n\tconst unset = envSitesOf(subject.host).filter((site) => !site.optional && !isBuiltinEnvName(site.name) && options.env[site.name] === void 0);\n\tfor (const site of unset) issue(\"resolve\", {\n\t\tpath: site.path,\n\t\tmessage: unsetEnvMessage(site.name)\n\t});\n\tif (!declared.tokens || unset.length > 0) return;\n\tlet resolved;\n\tlet deferred = [];\n\ttry {\n\t\tif (options.outputs) resolved = resolveHostOutputs(subject.host, {\n\t\t\toutputs: options.outputs,\n\t\t\t...resolveEnv\n\t\t});\n\t\telse {\n\t\t\tconst partial = resolveHostOutputs(subject.host, resolveEnv, { deferSelf: subject.self });\n\t\t\tresolved = partial.host;\n\t\t\tdeferred = partial.deferred;\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof TokenResolutionError && error.detail) issue(\"resolve\", {\n\t\t\tpath: error.detail.path,\n\t\t\tmessage: error.detail.reason\n\t\t});\n\t\telse issue(\"resolve\", \"\", error);\n\t\treturn;\n\t}\n\tresult.deferred.push(...deferred.map((d) => ({\n\t\t...d,\n\t\tfile\n\t})));\n\tif (!declared.shape) return;\n\tconst allow = deferred.length > 0;\n\tconst schema = allow ? runner.declaredHostSchema ?? runner.hostSchema : runner.hostSchema;\n\tconst checked = hostSchemaIssues(runner, schema, specifier, patch(resolved), { tokens: allow ? \"allow\" : \"forbid\" });\n\tconst resolvedIssues = [...checked.issues, ...checked.schemaIssues ?? []];\n\tfor (const i of resolvedIssues) issue(\"resolved\", i);\n\tif (resolvedIssues.length > 0 || !runner.checkBoot) return;\n\ttry {\n\t\tconst boot = await runner.checkBoot(checked.data, {\n\t\t\tprojectRoot: options.projectRoot,\n\t\t\tverb: subject.verb,\n\t\t\tenv: options.env,\n\t\t\tfile\n\t\t});\n\t\tfor (const i of boot) issue(\"boot\", {\n\t\t\t...i,\n\t\t\tpath: i.path ?? \"\"\n\t\t});\n\t} catch (error) {\n\t\tissue(\"boot\", \"\", error);\n\t}\n}\nasync function checkCompound(result, options, subject) {\n\tconst issue = issuer(result, subject.file);\n\tconst { host, runner, specifier } = subject;\n\tconst declared = checkDeclared(result, subject);\n\tif (!declared.tokens || !declared.shape) return;\n\tif (!runner.declaredHostSchema) {\n\t\tconst own = schemaIssuesOf(runner, runner.hostSchema, specifier, host, true);\n\t\tfor (const i of own) issue(\"resolved\", i);\n\t\tif (own.length > 0) return;\n\t}\n\tconst children = isPlainObject(host.children) ? host.children : {};\n\tconst wiring = isPlainObject(host.config) ? host.config : {};\n\tconst verb = compoundStartVerb(subject.verb, host.runner);\n\tconst prepared = [];\n\tfor (const [key, member] of Object.entries(children)) try {\n\t\tprepared.push(await prepareMember(options.projectRoot, key, member, subject.hostPackage));\n\t} catch (error) {\n\t\tissuer(result, `hosts/${member.host}/host.js`)(\"load\", \"\", error);\n\t}\n\ttry {\n\t\tconst cycle = await memberCycle(options.projectRoot, prepared);\n\t\tif (cycle) issue(\"declared\", {\n\t\t\tpath: \"children\",\n\t\t\tmessage: `compound member cycle: ${cycle.join(\" -> \")}.`,\n\t\t\thint: \"A compound cannot run itself, directly or through another compound.\"\n\t\t});\n\t} catch (error) {\n\t\tissue(\"load\", \"children\", error);\n\t}\n\tconst members = Object.entries(children).map(([key, m]) => ({\n\t\tkey,\n\t\thost: m.host\n\t}));\n\tlet foreground;\n\tif (prepared.length === members.length) try {\n\t\tconst plan = planCompound(prepared.map((m) => ({\n\t\t\tkey: m.key,\n\t\t\thost: m.member.host,\n\t\t\trefs: outputSitesOf(m.draft).map(({ ref, path }) => ({\n\t\t\t\tref,\n\t\t\t\tpath\n\t\t\t}))\n\t\t})), wiring.startOrder);\n\t\tconst planned = planForeground(prepared, plan, wiring);\n\t\tfor (const i of planned.issues) issue(\"declared\", i);\n\t\tforeground = planned.foreground;\n\t} catch (error) {\n\t\tissue(\"declared\", \"\", error);\n\t}\n\tresult.warnings.push(...sharedPortWarnings(subject.file, prepared));\n\tconst byKey = new Map(prepared.map((m) => [m.key, m]));\n\tconst outputsSchemaOf = (ref) => {\n\t\tconst target = memberForRef(ref, members);\n\t\tif (\"error\" in target) return { error: target.error };\n\t\tconst producer = byKey.get(target.key);\n\t\treturn producer ? runnerOutputsSchema(producer.runner, producer.specifier, `member \"${target.key}\"`) : { error: `names member \"${target.key}\", which was not prepared.` };\n\t};\n\tfor (const m of prepared) {\n\t\tconst isForeground = m.key === foreground;\n\t\tif (isForeground && ONE_SHOT_VERBS.has(verb)) continue;\n\t\tif (m.hostPackage && ONE_SHOT_VERBS.has(verb)) {\n\t\t\tissue(\"declared\", {\n\t\t\t\t...packageBuildRefusal(m.ref, m.hostPackage, verb),\n\t\t\t\tpath: `children.${m.key}`\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst csp = wiring.cspRegistrySync === true && takesCspRegistrySync(m);\n\t\tawait checkSubject(result, options, {\n\t\t\tfile: m.file,\n\t\t\thost: m.draft,\n\t\t\trunner: m.runner,\n\t\t\tspecifier: m.specifier,\n\t\t\t...m.hostPackage ? { hostPackage: m.hostPackage } : {},\n\t\t\tverb: isForeground ? m.draft.runner.defaultVerb ?? \"run\" : memberVerbOf(verb, m.draft.runner),\n\t\t\toutputsSchemaOf,\n\t\t\tself: { members },\n\t\t\t...csp ? { patch: (resolved) => ({\n\t\t\t\t...resolved,\n\t\t\t\trunner: {\n\t\t\t\t\t...resolved.runner,\n\t\t\t\t\tcspRegistrySync: true\n\t\t\t\t}\n\t\t\t}) } : {}\n\t\t});\n\t}\n}\nconst SWITCHBOARD_RUNNER = \"@powerhousedao/ph-cli/runners/switchboard\";\n/** The port a member binds: its own literal, else its ph-cli runner's default. */\nfunction boundPortOf(m) {\n\tconst port = m.draft.runner.port;\n\tif (port === void 0) {\n\t\tif (m.specifier === \"@powerhousedao/ph-cli/runners/connect\") return DEFAULT_CONNECT_STUDIO_PORT;\n\t\tif (m.specifier === SWITCHBOARD_RUNNER) return DEFAULT_SWITCHBOARD_PORT;\n\t\treturn;\n\t}\n\treturn typeof port === \"number\" && Number.isInteger(port) && port > 0 ? port : void 0;\n}\n/** Members binding one port: under `ph run` the later one moves or fails. */\nfunction sharedPortWarnings(file, prepared) {\n\tconst owners = /* @__PURE__ */ new Map();\n\tconst warnings = [];\n\tfor (const m of prepared) {\n\t\tconst port = boundPortOf(m);\n\t\tif (port === void 0) continue;\n\t\tconst other = owners.get(port);\n\t\tif (!other) {\n\t\t\towners.set(port, m);\n\t\t\tcontinue;\n\t\t}\n\t\tconst connects = m.specifier === \"@powerhousedao/ph-cli/runners/connect\" && other.specifier === \"@powerhousedao/ph-cli/runners/connect\";\n\t\twarnings.push({\n\t\t\tstage: \"declared\",\n\t\t\tfile,\n\t\t\tpath: `children.${m.key}.runner.port`,\n\t\t\tmessage: connects ? `${other.key} and ${m.key} both use port ${port}. One will move to the next free port and lose its browser data.` : `${other.key} and ${m.key} both use port ${port}. One will move to the next free port or fail to start.`\n\t\t});\n\t}\n\treturn warnings;\n}\nfunction issuer(result, file) {\n\treturn (stage, found, error) => {\n\t\tif (typeof found !== \"string\") {\n\t\t\tconst { path, message, hint } = found;\n\t\t\tresult.issues.push({\n\t\t\t\tstage,\n\t\t\t\tfile,\n\t\t\t\tpath,\n\t\t\t\tmessage,\n\t\t\t\t...hint ? { hint } : {}\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst [message, hint] = (error instanceof Error ? error.message : String(error)).split(\"\\n Hint: \");\n\t\tresult.issues.push({\n\t\t\tstage,\n\t\t\tfile,\n\t\t\tpath: found,\n\t\t\tmessage,\n\t\t\t...hint ? { hint } : {}\n\t\t});\n\t};\n}\n//#endregion\n//#region src/host-export-schema.ts\nfunction isRecord$1(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction childFolders$1(host) {\n\tif (!isRecord$1(host) || !isRecord$1(host.children)) return [];\n\treturn Object.entries(host.children).flatMap(([key, child]) => isRecord$1(child) && typeof child.host === \"string\" ? [[key, child.host]] : []);\n}\nconst declaredHostSchema = z.custom().superRefine((host, ctx) => {\n\tconst result = (isRecord$1(host) && \"children\" in host ? declaredHostSchemas.compoundHostSchema : declaredHostSchemas.reactorHostSchema).safeParse(host);\n\tif (result.success) return;\n\tfor (const issue of result.error.issues) ctx.addIssue({\n\t\tcode: \"custom\",\n\t\tmessage: issue.message,\n\t\tpath: issue.path\n\t});\n});\n/** `ph host export`: a declared host plus its members, keyed by folder. */\nconst hostExportSchema = z.strictObject({\n\tformat: z.literal(\"ph-host-export\"),\n\tversion: z.literal(1),\n\tproject: z.strictObject({\n\t\tname: z.string().min(1),\n\t\troot: z.string().min(1)\n\t}),\n\tname: z.string().min(1),\n\thost: declaredHostSchema,\n\tmembers: z.record(z.string(), declaredHostSchema)\n}).superRefine((value, ctx) => {\n\tconst reached = /* @__PURE__ */ new Set();\n\tconst pending = [[[\"host\"], value.host]];\n\tfor (let next = pending.shift(); next; next = pending.shift()) {\n\t\tconst [at, host] = next;\n\t\tfor (const [key, folder] of childFolders$1(host)) {\n\t\t\tif (!(folder in value.members)) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [\n\t\t\t\t\t\t...at,\n\t\t\t\t\t\t\"children\",\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\"host\"\n\t\t\t\t\t],\n\t\t\t\t\tmessage: `Member folder \"${folder}\" is missing from members.`\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (reached.has(folder)) continue;\n\t\t\treached.add(folder);\n\t\t\tpending.push([[\"members\", folder], value.members[folder]]);\n\t\t}\n\t}\n\tfor (const folder of Object.keys(value.members)) {\n\t\tif (reached.has(folder)) continue;\n\t\tctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tpath: [\"members\", folder],\n\t\t\tmessage: `Member \"${folder}\" is not reached from the host's children.`\n\t\t});\n\t}\n});\n//#endregion\n//#region src/host-export.ts\nfunction checkHint(name) {\n\treturn `Run \\`ph host check ${name}\\`.`;\n}\nfunction childFolders(host, name) {\n\tif (!(\"children\" in host)) return [];\n\tconst parsed = declaredHostSchemas.childrenSchema.safeParse(host.children);\n\tif (!parsed.success) throw new HostLoadError(`hosts/${name}/host.js: invalid \\`children\\`:\\n${z.prettifyError(parsed.error)}`, checkHint(name));\n\treturn Object.values(parsed.data).map((child) => child.host);\n}\n/** A host as declared and every member it reaches, raw `loadHost` bodies. */\nasync function exportHost(projectRoot, name) {\n\tconst root = path.resolve(projectRoot);\n\tconst { host } = await loadHost(root, name);\n\tconst members = {};\n\tconst visit = async (folders) => {\n\t\tfor (const folder of folders) {\n\t\t\tif (folder in members) continue;\n\t\t\tconst member = (await loadHost(root, folder)).host;\n\t\t\tmembers[folder] = member;\n\t\t\tawait visit(childFolders(member, folder));\n\t\t}\n\t};\n\tawait visit(childFolders(host, name));\n\tconst envelope = {\n\t\tformat: \"ph-host-export\",\n\t\tversion: 1,\n\t\tproject: {\n\t\t\tname: readProjectName(root),\n\t\t\troot\n\t\t},\n\t\tname,\n\t\thost,\n\t\tmembers\n\t};\n\tconst parsed = hostExportSchema.safeParse(JSON.parse(JSON.stringify(envelope)));\n\tif (!parsed.success) throw new HostLoadError(`hosts/${name}/host.js: the export is not a valid host export:\\n${z.prettifyError(parsed.error)}`, checkHint(name));\n\treturn envelope;\n}\n//#endregion\n//#region src/drives.ts\nconst sha256Hex = (input) => crypto.createHash(\"sha256\").update(input).digest(\"hex\");\nfunction projectDriveId(projectRoot, slug) {\n\treturn projectDriveIdWith(sha256Hex, projectRoot, slug);\n}\nfunction resolveDriveDeclaration(projectRoot, decl) {\n\tconst id = decl.projectHash ? projectDriveId(projectRoot, decl.slug) : decl.id;\n\tconst slug = decl.projectHash === true ? id : decl.slug;\n\tif (decl.remote) return {\n\t\tkind: \"remote\",\n\t\tid,\n\t\tslug,\n\t\tname: decl.name ?? decl.slug,\n\t\tremoteUrl: decl.remote.url,\n\t\tsharingType: decl.sharingType ?? \"public\",\n\t\tavailableOffline: decl.availableOffline ?? true\n\t};\n\treturn {\n\t\tkind: \"local\",\n\t\tid,\n\t\tslug,\n\t\tdocumentType: decl.documentType,\n\t\tname: decl.name ?? decl.slug,\n\t\ticon: resolveImageRef(projectRoot, decl.icon, {\n\t\t\tmaxBytes: DRIVE_ICON_MAX_BYTES,\n\t\t\twarn: (m) => console.warn(m)\n\t\t}),\n\t\tpreferredEditor: decl.preferredEditor,\n\t\tsharingType: decl.sharingType ?? \"public\",\n\t\tavailableOffline: decl.availableOffline ?? true\n\t};\n}\n/** Idempotent, slug-keyed: an existing slug is left untouched (never\n* recreated, never mutated — preserveStrategy refinements live here later). */\nasync function seedDrives(client, drives) {\n\tconst result = {\n\t\tcreated: [],\n\t\texisting: [],\n\t\tattached: []\n\t};\n\tfor (const drive of drives) {\n\t\tif (drive.kind === \"remote\") {\n\t\t\tawait client.attachRemoteDrive(drive.remoteUrl);\n\t\t\tresult.attached.push(drive.slug);\n\t\t\tcontinue;\n\t\t}\n\t\tif (await client.findDriveBySlug(drive.slug) !== void 0) {\n\t\t\tresult.existing.push(drive.slug);\n\t\t\tcontinue;\n\t\t}\n\t\tawait client.createDrive(drive);\n\t\tresult.created.push(drive.slug);\n\t}\n\treturn result;\n}\n/** Merge host-declared drives with plugin contributions, slug-keyed — the\n* host file wins on conflicts (it is the most explicit source). */\nfunction mergeDrivePlan(projectRoot, hostDeclared, contributed) {\n\tconst plan = /* @__PURE__ */ new Map();\n\tfor (const { declaration, source } of contributed) {\n\t\tconst drive = resolveDriveDeclaration(projectRoot, declaration);\n\t\tplan.set(drive.slug, {\n\t\t\tdrive,\n\t\t\tsource\n\t\t});\n\t}\n\tfor (const declaration of hostDeclared) {\n\t\tconst drive = resolveDriveDeclaration(projectRoot, declaration);\n\t\tplan.set(drive.slug, {\n\t\t\tdrive,\n\t\t\tsource: \"host\"\n\t\t});\n\t}\n\treturn [...plan.values()];\n}\nfunction explainDrivePlan(plan) {\n\tif (plan.length === 0) return \"(no drives declared)\";\n\treturn [\"drives:\", ...plan.map(({ drive, source }) => {\n\t\tconst kind = drive.kind === \"remote\" ? `remote ${drive.remoteUrl}` : \"local\";\n\t\tconst editor = drive.preferredEditor ? ` editor=${drive.preferredEditor}` : \"\";\n\t\tconst id = drive.id ?? \"generated\";\n\t\treturn ` ${drive.slug} (${kind}, id=${id}${editor}) [${source}]`;\n\t})].join(\"\\n\");\n}\n//#endregion\n//#region src/backend-projection.ts\nfunction projectStorage(name, storage) {\n\tswitch (storage.kind) {\n\t\tcase \"idb\": return { kind: \"idb\" };\n\t\tcase \"memory\": return { kind: \"memory\" };\n\t\tcase \"path\":\n\t\t\tif (!storage.dataDir) throw new Error(`Backend \"${name}\": storage kind \"path\" requires dataDir.`);\n\t\t\treturn {\n\t\t\t\tkind: \"path\",\n\t\t\t\tdataDir: storage.dataDir\n\t\t\t};\n\t\tcase \"postgres\": throw new Error(`Backend \"${name}\": storage kind \"postgres\" is server-side only — a provisioned (in-process/worker) reactor cannot use it. Point a \"remote\" backend at the switchboard that owns that database instead.`);\n\t}\n}\n/** One backend → one descriptor. The protocol's featureFlags ride every\n* descriptor (they are fleet consensus, not per-backend). A remote backend\n* must carry remote.url — provision() requires it. */\nfunction backendToDescriptor(name, backend, protocol) {\n\tconst descriptor = {\n\t\tkind: backend.kind,\n\t\tname\n\t};\n\tif (descriptor.kind === \"remote\") {\n\t\tconst url = backend.remote?.url;\n\t\tif (!url) throw new Error(`Backend \"${name}\" is kind \"remote\" but has no remote.url — a remote descriptor attaches to an already-running reactor by URL.`);\n\t\tdescriptor.remote = { url };\n\t\treturn descriptor;\n\t}\n\tif (backend.storage) descriptor.storage = projectStorage(name, backend.storage);\n\tif (backend.packages) descriptor.packages = backend.packages;\n\tif (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;\n\treturn descriptor;\n}\n/** All named backends, in placement-primary-first order (the order a\n* createReactorClients step would provision them). */\nfunction backendsToDescriptors(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return [];\n\tconst names = Object.keys(backends);\n\tconst primary = reactor.placement?.primary;\n\treturn (primary && names.includes(primary) ? [primary, ...names.filter((n) => n !== primary)] : names).map((name) => backendToDescriptor(name, backends[name], reactor.protocol));\n}\nconst LOCAL_KINDS = /* @__PURE__ */ new Set([\"in-process\", \"worker\"]);\n/**\n* Structural multi-reactor (phase 4): true when the block names BOTH a local\n* backend (in-process/worker — the tab's own reactor) and a remote one. This\n* is the shape Connect's routing client serves; a lone remote backend is an\n* attach-only host (assistant/agent shape), not a routed tab.\n*/\nfunction isStructuralMultiReactor(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return false;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\treturn kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === \"remote\");\n}\n/** The remote backends' drive addresses, placement order. */\nfunction remoteBackendUrls(reactor) {\n\treturn backendsToDescriptors(reactor).filter((d) => d.kind === \"remote\").map((d) => d.remote?.url).filter((u) => typeof u === \"string\");\n}\n/**\n* The remote backends by host key, placement order, each with the\n* connection settings it sets. A url that is not a string yet (an output\n* token, unresolved when a host builds) is skipped, as in remoteBackendUrls.\n*/\nfunction remoteBackends(reactor) {\n\treturn backendsToDescriptors(reactor).flatMap((d) => {\n\t\tconst remote = reactor?.backends?.[d.name]?.remote;\n\t\tif (d.kind !== \"remote\" || typeof d.remote?.url !== \"string\" || !remote) return [];\n\t\tconst { requestTimeoutMs, breaker, realtime } = remote;\n\t\treturn [{\n\t\t\tname: d.name,\n\t\t\turl: d.remote.url,\n\t\t\t...requestTimeoutMs !== void 0 ? { requestTimeoutMs } : {},\n\t\t\t...breaker !== void 0 ? { breaker } : {},\n\t\t\t...realtime !== void 0 ? { realtime } : {}\n\t\t}];\n\t});\n}\n//#endregion\n//#region src/reactor-config.ts\n/**\n* The shared `reactor` host-config block and its projections onto the\n* Switchboard config / Connect runtime config. Phase 2 of uniform-runners: makes\n* the reactor block live through the bridge runners, BEFORE track R replaces\n* the projection with reactor-monitor's provision(). The headline is\n* single-sourced `reactor.protocol` — both projections read the same block, so\n* client and server cannot diverge, and a contradicting pre-set env fails boot.\n*/\n/** A switchboard host's own store. Prefers placement.primary, else\n* \"main\"/\"local\", else the first. Connect refuses placement.primary: its\n* reactor is {@link browserBackend}. */\nfunction primaryBackend(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst names = Object.keys(backends);\n\tif (names.length === 0) return void 0;\n\treturn backends[reactor.placement?.primary ?? (names.includes(\"main\") ? \"main\" : names.includes(\"local\") ? \"local\" : names[0])];\n}\nconst FLAG_ENV = {\n\tdocumentDecisions: \"REACTOR_DOCUMENT_DECISIONS\",\n\tauthEnforcement: \"REACTOR_AUTH_ENFORCEMENT\",\n\tauthGroups: \"REACTOR_AUTH_GROUPS\",\n\tauthConditions: \"REACTOR_AUTH_CONDITIONS\",\n\tundoV3: \"REACTOR_UNDO_V3\"\n};\n/** The env vars a protocol block maps onto, with their string values. Only\n* keys the block actually sets appear. */\nfunction protocolEnv(protocol) {\n\tconst env = {};\n\tif (!protocol) return env;\n\tfor (const [key, varName] of Object.entries(FLAG_ENV)) {\n\t\tconst value = protocol.featureFlags?.[key];\n\t\tif (value !== void 0) env[varName] = value ? \"true\" : \"false\";\n\t}\n\tif (protocol.createSignaturePolicy !== void 0) env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;\n\tif (protocol.unsupportedStoredDocuments !== void 0) env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS = protocol.unsupportedStoredDocuments;\n\treturn env;\n}\n/** The reactor block as a switchboard config layer. The reactor store and the\n* read model are separate fields: `readModel.url` never moves the reactor. */\nfunction reactorBlockToSwitchboardConfig(reactor) {\n\tconst layer = {};\n\tconst backend = primaryBackend(reactor);\n\tconst storage = backend?.storage;\n\tconst reactorUrl = storage?.kind === \"postgres\" ? storage.url : storage?.dataDir;\n\tconst readModelUrl = backend?.readModel?.url;\n\tif (reactorUrl || readModelUrl) layer.storage = {\n\t\t...reactorUrl ? { reactor: { url: reactorUrl } } : {},\n\t\t...readModelUrl ? { readModel: { url: readModelUrl } } : {}\n\t};\n\tif (reactor?.protocol) layer.protocol = reactor.protocol;\n\tif (backend?.packages?.dynamic) layer.packages = { dynamic: true };\n\treturn layer;\n}\nconst LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set([\"in-process\", \"worker\"]);\n/** Connect's browser reactor: its first in-process or worker backend. */\nfunction browserBackend(reactor) {\n\tconst entry = Object.entries(reactor?.backends ?? {}).find(([, backend]) => LOCAL_BACKEND_KINDS.has(backend.kind));\n\treturn entry ? {\n\t\t...entry[1],\n\t\tname: entry[0]\n\t} : void 0;\n}\n/**\n* Which reactor client the backend topology asks for:\n* - local (in-process/worker) AND remote backends -> `router`\n* - remote backend(s) only -> `remote`\n* - a worker backend -> `worker`\n* - anything else local -> `in-process`\n* `undefined` when no backends are declared: Connect then runs `in-process`.\n*/\nfunction reactorClientMode(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\tif (kinds.length === 0) return void 0;\n\tconst hasLocal = kinds.some((k) => LOCAL_BACKEND_KINDS.has(k));\n\tconst hasRemote = kinds.some((k) => k === \"remote\");\n\tif (hasLocal && hasRemote) return \"router\";\n\tif (hasRemote) return \"remote\";\n\treturn browserBackend(reactor)?.kind === \"worker\" ? \"worker\" : \"in-process\";\n}\n/** Served only when `newDrives` names a served remote backend: a local one\n* is the default, and Connect refuses one it has no address for. */\nfunction connectRouterSettings(reactor, served) {\n\tconst newDrives = reactor?.placement?.newDrives;\n\tconst { probeTimeoutMs, provisionalRouteMs } = reactor?.router ?? {};\n\tconst router = {\n\t\t...newDrives !== void 0 && served.some((remote) => remote.name === newDrives) ? { newDrives } : {},\n\t\t...probeTimeoutMs !== void 0 ? { probeTimeoutMs } : {},\n\t\t...provisionalRouteMs !== void 0 ? { provisionalRouteMs } : {}\n\t};\n\treturn Object.keys(router).length > 0 ? router : void 0;\n}\nfunction connectStorage(backend) {\n\tconst kind = backend?.storage?.kind;\n\treturn kind === \"idb\" || kind === \"memory\" ? kind : void 0;\n}\n/** Why the browser reactor's declared store can't be served: Connect keeps\n* IndexedDB instead of a folder or Postgres. */\nfunction unservedConnectStorage(reactor) {\n\tconst browser = browserBackend(reactor);\n\tconst kind = browser?.storage?.kind;\n\tif (!browser || !kind || connectStorage(browser)) return void 0;\n\treturn `reactor.backends.${browser.name}.storage \"${kind}\": Connect's browser reactor can't use it and keeps IndexedDB instead.`;\n}\n/** Project the reactor block onto the Connect runtime config: protocol →\n* connect.reactor (same shape), backend topology → instance.reactorWorker\n* (the browser reactor's kind), instance.reactorClient, instance.storage\n* (the browser reactor's store), and with a\n* switchboard instance.remoteBackends and instance.router. */\nfunction projectReactorToConnect(reactor) {\n\tconst connect = {};\n\tif (reactor?.protocol) connect.reactor = reactor.protocol;\n\tconst mode = reactorClientMode(reactor);\n\tif (mode !== void 0) {\n\t\tconst routed = mode === \"router\" || mode === \"remote\";\n\t\tconst served = routed ? remoteBackends(reactor) : [];\n\t\tconst router = routed ? connectRouterSettings(reactor, served) : void 0;\n\t\tconst browser = browserBackend(reactor);\n\t\tconst storage = connectStorage(browser);\n\t\tconnect.instance = {\n\t\t\treactorWorker: browser?.kind === \"worker\",\n\t\t\treactorClient: mode,\n\t\t\t...storage ? { storage } : {},\n\t\t\t...routed ? { remoteBackends: served } : {},\n\t\t\t...router ? { router } : {}\n\t\t};\n\t}\n\treturn { connect };\n}\n/** Whether an env value means what the host's value does. The switchboard\n* reads REACTOR_UNDO_V3 as on unless it is exactly \"false\". */\nfunction protocolEnvAgrees(varName, envValue, hostValue) {\n\tif (varName === FLAG_ENV.undoV3) return envValue !== \"false\" === (hostValue === \"true\");\n\treturn envValue === hostValue;\n}\n/** Each pre-set env var that CONTRADICTS the host's protocol block, as a\n* message naming the var, the host value and the env value. An env var that\n* merely matches, or is unset, is fine. */\nfunction protocolConflicts(protocol, env, hostFile = \"the host file\") {\n\tif (!protocol) return [];\n\treturn Object.entries(protocolEnv(protocol)).flatMap(([varName, hostValue]) => {\n\t\tconst envValue = env[varName];\n\t\tif (envValue === void 0 || protocolEnvAgrees(varName, envValue, hostValue)) return [];\n\t\treturn [`reactor.protocol conflict: ${varName} is \"${envValue}\" in the environment but \"${hostValue}\" in ${hostFile}. These are fleet-consensus settings — a mismatch would diverge replay. Remove the env override or align the host.`];\n\t});\n}\n/**\n* The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS\n* the host's protocol block, fail loudly naming the var, the host value, and\n* the env value (phase-2 transition keeps an operator's explicit env as an\n* escape hatch unless it disagrees with the protocol — see the WBS\n* precedence note).\n*/\nfunction assertProtocolConsistency(protocol, env, hostFile = \"the host file\") {\n\tconst conflict = protocolConflicts(protocol, env, hostFile).at(0);\n\tif (conflict) throw new Error(conflict);\n}\n//#endregion\n//#region src/connect-projection.ts\n/**\n* Instance-fact projection for compound hosts: the drives a compound's\n* reactor member created, projected into the Connect member's runtime-config\n* override. Pure functions, moved from ph-cli's vetra service so the generic\n* compound and the classic path share one implementation.\n*/\nfunction isLocalDrive(drive) {\n\treturn \"local\" in drive;\n}\nconst driveKey = (drive) => isLocalDrive(drive) ? `local:${drive.id}` : drive.url;\n/**\n* Concatenate groups of `connect.drives.defaultDrives` in the order given,\n* de-duplicating by drive identity (URL for remote entries, id for local\n* ones). The first occurrence of a drive wins, so earlier groups keep their\n* position and metadata — e.g. the Vetra drive `ph dev` starts stays first\n* even when the project's `powerhouse.config.json` lists the same drive.\n*/\nfunction mergeDefaultDrives(...groups) {\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst out = [];\n\tfor (const group of groups) for (const drive of group) {\n\t\tconst key = driveKey(drive);\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tout.push(drive);\n\t}\n\treturn out;\n}\n/**\n* Rebase a local drive URL onto a public base: keeps the /d/<slug> path,\n* swaps the loopback origin for the public base. Browser clients behind a\n* reverse proxy can't reach http://localhost:<port>. Non-loopback URLs\n* (e.g. a remote drive) are already public and pass through unchanged, as do\n* unparseable ones.\n*/\nfunction rebaseDriveUrl(driveUrl, publicBase) {\n\tlet url;\n\ttry {\n\t\turl = new URL(driveUrl);\n\t} catch {\n\t\treturn driveUrl;\n\t}\n\tif (![\n\t\t\"localhost\",\n\t\t\"127.0.0.1\",\n\t\t\"[::1]\"\n\t].includes(url.hostname)) return driveUrl;\n\treturn `${publicBase.replace(/\\/+$/, \"\")}${url.pathname}`;\n}\n/**\n* The compound's drives projection: created drives first (rebased onto the\n* public base when given), then the project's configured drives, de-duplicated\n* — and `preserve-all`, because compound-injected drive lists change per\n* launch context and must never detach drives the user added by hand.\n*/\nfunction projectDrivesIntoConnect(input) {\n\treturn { drives: {\n\t\tdefaultDrives: mergeDefaultDrives(input.createdDriveUrls.filter((url) => typeof url === \"string\" && url.length > 0).map((url) => ({\n\t\t\turl: input.publicBase ? rebaseDriveUrl(url, input.publicBase) : url,\n\t\t\tname: null,\n\t\t\ticon: null\n\t\t})), input.configuredDefaultDrives ?? []),\n\t\tpreserveStrategy: \"preserve-all\"\n\t} };\n}\n/** A served slug names a declared one as is, or hashed (`<slug>-<8 hex>`). */\nfunction servesSlug(declared, served) {\n\treturn served === declared || served.startsWith(`${declared}-`) && /^[0-9a-f]{8}$/.test(served.slice(declared.length + 1));\n}\n/** Annotates remote default drives with their backend (`sync: false` when placed on it); other remote placements become collections. */\nfunction placeConnectDrives(reactor, defaultDrives) {\n\tconst remotes = remoteBackends(reactor).flatMap(({ name, url }) => {\n\t\tconst at = switchboardOfDrive$1(url);\n\t\treturn at ? [{\n\t\t\tname,\n\t\t\tbase: at.base\n\t\t}] : [];\n\t});\n\tif (remotes.length === 0) return { defaultDrives: [...defaultDrives] };\n\tconst placement = Object.entries(reactor?.placement?.drives ?? {});\n\tconst matched = /* @__PURE__ */ new Set();\n\tconst placed = defaultDrives.map((drive) => {\n\t\tif (!(\"url\" in drive)) return drive;\n\t\tconst at = switchboardOfDrive$1(drive.url);\n\t\tconst backend = remotes.find((remote) => remote.base === at?.base)?.name;\n\t\tif (!at || !backend) return drive;\n\t\tconst entry = placement.find(([slug]) => servesSlug(slug, at.slug));\n\t\tif (entry) matched.add(entry[0]);\n\t\treturn entry?.[1] === backend ? {\n\t\t\t...drive,\n\t\t\tbackend,\n\t\t\tsync: false\n\t\t} : {\n\t\t\t...drive,\n\t\t\tbackend\n\t\t};\n\t});\n\tconst names = new Set(remotes.map((remote) => remote.name));\n\tconst collections = Object.fromEntries(placement.filter(([slug, backend]) => !matched.has(slug) && names.has(backend)).map(([slug, backend]) => [slug, {\n\t\tbackend,\n\t\tsync: false\n\t}]));\n\treturn Object.keys(collections).length > 0 ? {\n\t\tdefaultDrives: placed,\n\t\tcollections\n\t} : { defaultDrives: placed };\n}\n//#endregion\n//#region src/expect-host.ts\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction runnerOf(host) {\n\treturn isRecord(host.runner) ? host.runner : {};\n}\nfunction defaultVerbOf(host) {\n\tconst verb = runnerOf(host).defaultVerb;\n\treturn typeof verb === \"string\" ? verb : void 0;\n}\n/** At compound verb \"run\" each member runs its own defaultVerb; any other\n* compound verb is forwarded uniformly (compound.ts `memberVerbOf`). */\nfunction memberVerb(compoundVerb, member) {\n\treturn compoundVerb === \"run\" ? defaultVerbOf(member) ?? \"run\" : compoundVerb;\n}\n/** Backend names, placement-primary first (`backendsToDescriptors` order). */\nfunction orderedBackends(reactor) {\n\tconst backends = Object.entries(reactor.backends ?? {});\n\tconst primary = reactor.placement?.primary;\n\treturn [...backends.filter(([name]) => name === primary), ...backends.filter(([name]) => name !== primary)];\n}\nfunction expectBackend(name, backend, reactor) {\n\tconst out = {\n\t\tname,\n\t\tkind: backend.kind\n\t};\n\tif (backend.storage) out.storage = backend.storage.kind;\n\tif (typeof backend.storage?.dataDir === \"string\") out.dataDir = backend.storage.dataDir;\n\ttry {\n\t\tbackendToDescriptor(name, backend, reactor.protocol);\n\t} catch (error) {\n\t\tout.provisionError = error instanceof Error ? error.message : String(error);\n\t}\n\treturn out;\n}\nfunction expectDrive(declaration, source) {\n\tif (typeof declaration.slug !== \"string\") return void 0;\n\tconst remote = isRecord(declaration.remote) ? declaration.remote : void 0;\n\tconst drive = {\n\t\tslug: declaration.slug,\n\t\tkind: remote ? \"remote\" : \"local\",\n\t\tsource\n\t};\n\tif (remote && typeof remote.url === \"string\") drive.url = remote.url;\n\tif (typeof declaration.id === \"string\") drive.id = declaration.id;\n\tconst projectHash = declaration.projectHash;\n\tif (typeof projectHash === \"boolean\" || projectHash === \"id\") drive.projectHash = projectHash;\n\treturn drive;\n}\n/** The key `mergeDrivePlan` merges on: the SERVED slug, which for\n* `projectHash: true` is the hashed id (never equal to a plain slug). */\nfunction servedSlugKey(drive) {\n\treturn drive.projectHash === true ? `${drive.slug}\\0hashed` : drive.slug;\n}\n/** Contributions first, then host declarations; keyed by served slug, the\n* host wins (and keeps the contribution's position), like `mergeDrivePlan`. */\nfunction drivePlan(reactor, contributed) {\n\tconst plan = /* @__PURE__ */ new Map();\n\tfor (const { declaration, source } of contributed) {\n\t\tconst drive = expectDrive(declaration, source);\n\t\tif (drive) plan.set(servedSlugKey(drive), drive);\n\t}\n\tfor (const declaration of reactor?.drives ?? []) {\n\t\tconst drive = expectDrive(declaration, \"host\");\n\t\tif (drive) plan.set(servedSlugKey(drive), drive);\n\t}\n\treturn [...plan.values()];\n}\n/** Token facts of the host's OWN fields (a compound's `children` are its\n* members' own). */\nfunction tokenFacts(declared, kind) {\n\tconst own = kind === \"compound\" ? Object.fromEntries(Object.entries(declared).filter(([key]) => key !== \"children\")) : declared;\n\tconst sites = outputSitesOf(own);\n\tconst consumes = sites.map(({ path, ref, outputPath }) => ({\n\t\tat: path,\n\t\thost: ref.host,\n\t\t...ref.member !== void 0 ? { member: ref.member } : {},\n\t\tpath: outputPath\n\t}));\n\treturn {\n\t\tdependsOn: [...new Set(sites.map(({ ref }) => refKey(ref)))].sort(),\n\t\tconsumes,\n\t\tenv: [...new Set(envSitesOf(own).map(({ name }) => name))].sort()\n\t};\n}\nfunction expectOwn(input, verb) {\n\tconst resolved = input.resolved ?? input.declared;\n\tconst expectation = {\n\t\tname: typeof resolved.name === \"string\" ? resolved.name : \"\",\n\t\tkind: input.kind,\n\t\tverb,\n\t\t...tokenFacts(input.declared, input.kind)\n\t};\n\tif (input.kind !== \"reactor\") return expectation;\n\tconst reactor = isRecord(resolved.reactor) ? resolved.reactor : void 0;\n\tconst mode = reactorClientMode(reactor);\n\tif (mode !== void 0) expectation.clientMode = mode;\n\texpectation.multiReactor = isStructuralMultiReactor(reactor);\n\tconst backends = reactor ? orderedBackends(reactor) : [];\n\tif (reactor && backends.length > 0) {\n\t\texpectation.backends = backends.map(([name, backend]) => expectBackend(name, backend, reactor));\n\t\texpectation.remotes = backends.flatMap(([, backend]) => backend.kind === \"remote\" && typeof backend.remote?.url === \"string\" ? [backend.remote.url] : []);\n\t}\n\texpectation.drives = drivePlan(reactor, input.contributed ?? []);\n\treturn expectation;\n}\n/**\n* The expectation for one host. A reactor host's comes from its resolved\n* reactor block and contributed drives; a compound's lists its members in\n* plan order, each with the verb it runs at under the compound's own verb\n* and the members it starts after.\n*/\nfunction expectHost(input) {\n\tconst verb = defaultVerbOf(input.declared) ?? \"run\";\n\tconst expectation = expectOwn(input, verb);\n\tif (input.kind !== \"compound\" || !input.members) return expectation;\n\tconst order = input.plan?.order ?? input.members.map((m) => m.key);\n\tconst edges = input.plan?.edges ?? [];\n\tconst byKey = new Map(input.members.map((m) => [m.key, m]));\n\tconst members = {};\n\tfor (const key of order) {\n\t\tconst member = byKey.get(key);\n\t\tif (!member) continue;\n\t\tmembers[key] = {\n\t\t\thost: member.host,\n\t\t\t...expectOwn(member, memberVerb(verb, member.declared)),\n\t\t\tafter: [...new Set(edges.filter((e) => e.consumer === key).map((e) => e.producer))].sort()\n\t\t};\n\t}\n\texpectation.startOrder = order.filter((key) => byKey.has(key));\n\texpectation.members = members;\n\treturn expectation;\n}\n//#endregion\nexport { ASK_TIMEOUT_MS, BUILTIN_ENV_NAMES, COMPOUND_MEMBER_ENV, CONNECT_PLUGIN_OWNED_SLICES, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, CONTROL_PROTOCOL, ControlError, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, HOST_REF_MESSAGE, HOST_REF_PATTERN, HostLoadError, MAX_LINE_BYTES, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, OUTPUTS_FILE, OUTPUT_DATA_DIRS_ENV, PACKAGE_NAME_PATTERN, PlanError, PluginError, RunnerError, SPAWN_STOPPING_NOTE, STOP_ON_STDIN_ENV, STOP_RUN_TIMEOUT_MS, STOP_STREAM_LIMIT_MS, STORE_VERBS, SWITCHBOARD_PROXY_PATHS, SpawnHostError, TOKEN_ESCAPE_KEY, TOKEN_KEYS, TokenResolutionError, announceSignInLinks, applyChildWrapper, askToStop, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, browserBackend, buildDriveDeclarationSchema, callControl, checkHost, checkOutputPaths, checkRunnerArgv, checkTokenSites, childWrapperSchema, childrenSchema, clearRunRecord, closeProcessControlChannel, collectTokenSites, compoundHostSchema, compoundOutputSource, compoundWiringSchema, computeOutputsHash, concatTokenSchema, connectReactorIssues, controlProtocolOf, controlRecordOf, controlRecordSchema, createOwnerOnlyFile, declaredGenericCompoundHostSchema, declaredHostSchemas, defaultConnectComposition, defaultUserDataDir, defineHostSchemas, describeHostOutputs, describeInstance, describeMapElements, describeToken, driveAddressMessage, driveDeclarationSchema, drivesSchema, emitHostJsonSchema, emittedHostSchemas, emptyMaps, ensureProcessControlChannel, entryActiveForVerb, envSitesOf, envTokenSchema, envTokenable, expectHost, explainDrivePlan, exportHost, fileAccessList, findDeadConnectConfig, findHostPackage, findNonStaticValue, findRemovedForms, findRunningInstance, findToken, forbidRef, formatHostRef, formatPath, genericCompoundHostSchema, getVerb, holdStopRequests, hostExportSchema, hostFileLabel, hostNameSchema, hostSchemaIssues, hostTypeSatisfies, installStopChannel, instanceDataDir, instanceKey, instanceOfRecord, instancePhDir, instanceRunDir, instanceServicesDir, isAlreadyRunning, isBuiltinEnvName, isHtmlNavigation, isOriginPlaceholderUrl, isPidAlive, isRunnerArgsSchema, isSchemaLike, isStructuralMultiReactor, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, killTree, kindShapeIssues, knownVerbIssues, lintHostImportGraph, lintHostImports, lintOutputsFile, listRunRecords, listRunningInstances, listVerbs, listenForStop, loadHost, loadHostFresh, loadProducers, locateHost, makeHostSchemas, mapTokenSchema, memberCycle, memberForRef, memberProcessOf, memberProcessSchema, mergeContributions, mergeDefaultDrives, mergeDrivePlan, moduleRootOf, normalizePluginEntries, normalizePluginEntry, openControlChannel, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, ownerOnlyPipeAccess, packageBuildRefusal, parseHostRef, pipeAccessList, placeConnectDrives, placementKeyIssues, planCompound, planForeground, pluginEntryObjectSchema, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, processControlChannel, processResolveEnv, producerOutputsSchemas, profileSchema, projectDriveId, projectDriveIdWith, projectDrivesIntoConnect, projectReactorToConnect, protocolConflicts, protocolEnv, protocolEnvAgrees, protocolMismatch, reactorBackendKindSchema, reactorBackendSchema, reactorBlockToSwitchboardConfig, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readOutputsFileHash, readProjectName, readRunRecord, rebaseDriveUrl, recordKeyOf, ref, refKey, refineConnectReactor, refineStartOrder, registerHostType, remoteBackendUrls, remoteBackends, renderTokens, requestStop, resolveDriveDeclaration, resolveHostOutputs, resolveHostPlugins, resolveOrder, resolveOriginPlaceholders, resolvePackageRoot, resolvePluginContributions, resolveRunnerModule, resolveUserDataPlaceholders, restartDecision, restrictFileToOwner, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runRecordKey, runRecordMemberSchema, runRecordOutputSource, runRecordPath, runRecordSchema, runTransformHook, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, runnerOutputsSchema, runningInstance, scanHostImports, schemaAtPath, seedDrives, signInLinksOf, signInMembersOf, signInSecretOf, spawnHost, splitCompoundArgv, splitRunArgv, stopChannelPath, stopRun, stopStreamOf, stripComments, substituteBuiltinEnv, supervisedFactLines, switchboardOfDrive, takeCompoundMember, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, unservedConnectStorage, unwrapEscapes, validateDeclaredHost, validateHost, withOriginPlaceholders, withoutHostsMessage, writeOwnerOnlyFile, writeRunRecord };\n\n//# sourceMappingURL=index.mjs.map"],"names":["z.custom","z.strictObject","z.literal","z.string","z.record","z.prettifyError"],"mappings":";;;;;;;;;;;;;AAgBA,eAAe,UAAU,MAAM,SAAS;CACvC,MAAM,SAAS;EACd,QAAQ,CAAC;EACT,UAAU,CAAC;EACX,UAAU,CAAC;CACZ;CACA,IAAI,OAAO,SAAS,KAAK;CACzB,MAAM,OAAO,QAAQ,QAAQ;CAC7B,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;EACH,MAAM,SAAS,MAAM,SAAS,QAAQ,aAAa,IAAI;EACvD,OAAO,OAAO;EACd,cAAc,OAAO;EACrB,OAAO,cAAc,OAAO,MAAM,WAAW;EAC7C,SAAS,MAAM,oBAAoB,aAAa,QAAQ,aAAa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AAS,KAAK;EAC1B,IAAI,KAAK,IAAI,GAAG,GAAG;EACnB,KAAK,IAAI,GAAG;EACZ,IAAI,KAAK,KAAK;CACf;CACA,OAAO;AACR","debug_id":"f3758d76-dca8-526b-924e-5a9ca8eeacba"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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]="
|
|
3
|
-
import {
|
|
4
|
-
import { a as mergeDrivePlan, n as explainDrivePlan } from "./dist-
|
|
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]="ef74fd4c-a22e-5841-a2be-234e655488ef")}catch(e){}}();
|
|
3
|
+
import { B as producerOutputsSchemas, E as loadProducers, F as planCompound, G as resolvePluginContributions, H as resolveHostOutputs, I as planForeground, J as runnerOutputsSchema, K as resolveRunnerModule, M as outputRefsOf, N as outputSitesOf, O as memberForRef, S as isBuiltinEnvName, T as loadHost, V as renderTokens, at as drivesSchema, b as hostFileLabel, c as applyChildWrapper, ct as isToken, d as collectTokenSites, dt as probeRun, et as validateDeclaredHost, f as compoundOutputSource, g as findDeadConnectConfig, h as envSitesOf, ht as runRecordKey, i as RunnerError, it as declaredHostSchemas, j as moduleRootOf, k as memberProcessOf, m as describeToken, pt as readProjectName, q as runRecordOutputSource, tt as validateHost, v as formatPath, z as processResolveEnv } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
4
|
+
import { a as mergeDrivePlan, n as explainDrivePlan } from "./dist-DPj_FB8H.mjs";
|
|
5
5
|
//#region src/services/run/explain.ts
|
|
6
6
|
const TOPICS = ["drives", "outputs"];
|
|
7
7
|
async function loadView(projectRoot, name) {
|
|
@@ -272,5 +272,5 @@ function explainOutputs(name, view) {
|
|
|
272
272
|
//#endregion
|
|
273
273
|
export { explainHost };
|
|
274
274
|
|
|
275
|
-
//# sourceMappingURL=explain-
|
|
276
|
-
//# debugId=
|
|
275
|
+
//# sourceMappingURL=explain-DQ5ymlco.mjs.map
|
|
276
|
+
//# debugId=ef74fd4c-a22e-5841-a2be-234e655488ef
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explain-DbbHpa61.mjs","sources":["../src/services/run/explain.ts"],"sourcesContent":["import {\n applyChildWrapper,\n collectTokenSites,\n compoundOutputSource,\n CONNECT_RUNNER,\n declaredHostSchemas,\n describeToken,\n drivesSchema,\n envSitesOf,\n explainDrivePlan,\n findDeadConnectConfig,\n formatPath,\n hostFileLabel,\n isBuiltinEnvName,\n isToken,\n loadHost,\n loadProducers,\n memberForRef,\n memberProcessOf,\n mergeDrivePlan,\n moduleRootOf,\n outputRefsOf,\n outputSitesOf,\n planCompound,\n planForeground,\n probeRun,\n processResolveEnv,\n producerOutputsSchemas,\n readProjectName,\n renderTokens,\n resolveHostOutputs,\n resolvePluginContributions,\n resolveRunnerModule,\n RunnerError,\n runnerOutputsSchema,\n runRecordKey,\n runRecordOutputSource,\n validateDeclaredHost,\n validateHost,\n type ChildWrapper,\n type DriveDeclaration,\n type HostDefinition,\n type OutputSource,\n type PluginEntryData,\n type ReactorHostInput,\n type RunnerModule,\n} from \"@powerhousedao/host-core\";\n\n/**\n * `ph run <host> --explain <topic>`: print instead of running, after the\n * same declared validation `ph run` does first (so a printed explain is a\n * host that loads). `drives`: the merged drive plan with provenance\n * (browser-only plugins listed as unresolvable). `outputs`: the resolution\n * plan — consumed outputs and their producers, `$env` names, where\n * `${package}` points, the compound start order the tokens imply, which\n * producers are running and, for a\n * running producer, the value each token resolves to now. A `$map` in\n * `reactor.drives` is shown as the token and, when its producer runs, as the\n * drives it renders.\n */\n\ninterface ExplainOptions {\n host: string;\n topic: string;\n}\n\nconst TOPICS = [\"drives\", \"outputs\"];\n\n/** A reactor host as explained: a standalone host, or a compound member\n * with its wrapper applied (declared form). */\ninterface ReactorView {\n name: string;\n runner: HostDefinition[\"runner\"];\n config?: Record<string, unknown>;\n reactor?: ReactorHostInput[\"reactor\"];\n}\n\ninterface MemberView {\n key: string;\n wrapper: ChildWrapper;\n host: ReactorView;\n runner: RunnerModule;\n specifier: string;\n file: string;\n /** Where its plugin specifiers resolve from: its package, else the\n * project. Also what `${package}` is in it. */\n moduleRoot: string;\n /** The package that supplies its host. */\n packageName?: string;\n /** Where the effective `config` lives (a wrapper `config` is a full\n * statement in the compound's file). */\n configWhere: string;\n}\n\ninterface LoadedView {\n host: HostDefinition;\n runner: RunnerModule;\n specifier: string;\n file: string;\n /** Where its plugin specifiers resolve from, and `${package}`. */\n moduleRoot: string;\n /** The package that supplies the host. */\n packageName?: string;\n /** Set for a compound. */\n members?: MemberView[];\n /** Where tokens resolve NOW (for printing values): a standalone host's\n * producers' live run records; a compound's own live record (its members'\n * outputs), or none when it is not running. */\n source?: OutputSource;\n}\n\nasync function loadView(\n projectRoot: string,\n name: string,\n): Promise<LoadedView> {\n // As `ph run` finds it: a package's host resolves its modules there, and\n // its compound's bare members look there first.\n const loaded = await loadHost(projectRoot, name);\n const scope = loaded.package;\n const moduleRoot = moduleRootOf(projectRoot, loaded);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(moduleRoot, specifier);\n const file = hostFileLabel(loaded.name, scope);\n if (runner.kind !== \"compound\") {\n const producers = await loadProducers(\n projectRoot,\n outputRefsOf(loaded.host),\n scope,\n );\n validateDeclaredHost(runner, specifier, loaded.host, file, {\n outputsSchemaOf: producerOutputsSchemas(producers),\n });\n // The same lookup `ph run` resolves through.\n const source = runRecordOutputSource(projectRoot, {\n consumer: name,\n producers,\n projectName: readProjectName(projectRoot),\n });\n return {\n host: loaded.host,\n runner,\n specifier,\n file,\n moduleRoot,\n ...(scope ? { packageName: scope.name } : {}),\n source,\n };\n }\n validateDeclaredHost(runner, specifier, loaded.host, file);\n validateHost(runner, specifier, loaded.host, file, { tokens: \"allow\" });\n // The compound runner's schema owns `config`; `children` is shared.\n const children = declaredHostSchemas.childrenSchema.parse(\n loaded.host.children,\n );\n const members: MemberView[] = [];\n for (const [key, wrapper] of Object.entries(children)) {\n const member = await loadHost(projectRoot, wrapper.host, { scope });\n const host: ReactorView = applyChildWrapper(member.host, wrapper);\n const memberSpecifier = host.runner.module;\n const memberRoot = moduleRootOf(projectRoot, member);\n const memberFile = hostFileLabel(member.name, member.package);\n members.push({\n key,\n wrapper,\n host,\n runner: await resolveRunnerModule(memberRoot, memberSpecifier),\n specifier: memberSpecifier,\n file: memberFile,\n moduleRoot: memberRoot,\n ...(member.package ? { packageName: member.package.name } : {}),\n configWhere:\n wrapper.config !== undefined\n ? `${file} (children.${key}.config)`\n : memberFile,\n });\n }\n const refs = members.map((m) => ({ key: m.key, host: m.wrapper.host }));\n for (const m of members) {\n validateDeclaredHost(m.runner, m.specifier, m.host, m.file, {\n outputsSchemaOf: (ref) => {\n const target = memberForRef(ref, refs);\n if (\"error\" in target) return { error: target.error };\n const producer = members.find((p) => p.key === target.key);\n return producer\n ? runnerOutputsSchema(\n producer.runner,\n producer.specifier,\n `member \"${producer.key}\"`,\n )\n : { error: `names member \"${target.key}\", which is not declared.` };\n },\n });\n }\n // Members read each other's live outputs: shown only while this\n // compound runs (its record carries every member's outputs).\n const probe = probeRun(\n projectRoot,\n runRecordKey(loaded.host.name, scope?.name),\n readProjectName(projectRoot),\n );\n const live = new Map<string, unknown>();\n if (probe.status === \"live\") {\n for (const [key, member] of Object.entries(probe.record.members ?? {})) {\n live.set(key, member.outputs);\n }\n }\n const source =\n probe.status === \"live\"\n ? compoundOutputSource(refs, live, loaded.host.name)\n : undefined;\n return {\n host: loaded.host,\n runner,\n specifier,\n file,\n moduleRoot,\n ...(scope ? { packageName: scope.name } : {}),\n members,\n source,\n };\n}\n\n/** A token's value from running producers, or undefined (producer not\n * running, or the token reads the environment: `$env` values may be\n * secrets, so explain never prints them). */\nfunction currentValue(token: unknown, source?: OutputSource): unknown {\n if (!source) return undefined;\n if (collectTokenSites(token).some((site) => site.key === \"$env\")) {\n return undefined;\n }\n try {\n return resolveHostOutputs(token, { outputs: source });\n } catch {\n return undefined;\n }\n}\n\nexport async function explainHost(options: ExplainOptions): Promise<void> {\n if (!TOPICS.includes(options.topic)) {\n throw new Error(\n `Unknown --explain topic \"${options.topic}\" (supported: ${TOPICS.join(\", \")}).`,\n );\n }\n const projectRoot = process.cwd();\n const view = await loadView(projectRoot, options.host);\n if (options.topic === \"outputs\") {\n explainOutputs(options.host, view);\n return;\n }\n\n if (view.members) {\n // One plan per member, with the wrapper's full-statement semantics.\n const verb = view.host.runner.defaultVerb ?? \"run\";\n for (const m of view.members) {\n await explainDrives(\n { projectRoot, moduleRoot: m.moduleRoot },\n `${options.host} › ${m.key} (${m.wrapper.host})`,\n m.host,\n verb,\n m.file,\n m.configWhere,\n view.source,\n );\n }\n return;\n }\n await explainDrives(\n { projectRoot, moduleRoot: view.moduleRoot },\n options.host,\n view.host,\n \"run\",\n view.file,\n view.file,\n view.source,\n );\n}\n\n/* ------------------------------------------------------------------ drives */\n\nasync function explainDrives(\n /** Drive ids are the project's; plugin specifiers resolve from\n * `moduleRoot` (a package's host: the package). */\n roots: { projectRoot: string; moduleRoot: string },\n label: string,\n host: ReactorView,\n verb: string,\n where: string,\n configWhere: string,\n source?: OutputSource,\n): Promise<void> {\n const { projectRoot } = roots;\n const entries: PluginEntryData[] = host.runner.plugins ?? [];\n const contributions =\n entries.length > 0\n ? await resolvePluginContributions(roots.moduleRoot, verb, entries, where)\n : { drives: [], unresolved: [] };\n const contributed = contributions.drives.map(({ declaration, source }) => {\n const parsed = drivesSchema.safeParse([declaration]);\n if (!parsed.success) {\n throw new Error(\n `${where}: plugin \"${source}\" contributes an invalid drive declaration.`,\n );\n }\n return { declaration: parsed.data[0], source };\n });\n // Declared drives may carry output tokens (a remote url): shown as\n // «$output …», resolved only at `ph run`. The whole list may be a token\n // (`$map` over a producer's drives): rendered from the running producer\n // when there is one, otherwise named and left out of the plan.\n const rawDrives: unknown = host.reactor?.drives ?? [];\n let listed: unknown = rawDrives;\n let listNote: string | undefined;\n if (isToken(rawDrives)) {\n const value = currentValue(rawDrives, source);\n listed = Array.isArray(value) ? value : [];\n listNote = ` reactor.drives ← «${describeToken(rawDrives)}»${\n Array.isArray(value)\n ? \" (rendered from the running producer's outputs)\"\n : \" (rendered at ph run from the producer's live outputs; its producer is not running now, so the plan below leaves them out)\"\n }`;\n }\n const parsed = drivesSchema.safeParse(renderTokens(listed));\n if (!parsed.success && listNote === undefined) {\n // a literal list: declared validation already ran; keep its error\n throw parsed.error;\n }\n const declared: DriveDeclaration[] = parsed.success ? parsed.data : [];\n console.log(`[${label}]`);\n if (listNote) console.log(listNote);\n if (!parsed.success) {\n console.log(\n ` the rendered drives fail the drive schema (ph run rejects them): ${parsed.error.issues\n .map((i) => `${i.path.map(String).join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"; \")}`,\n );\n }\n console.log(\n explainDrivePlan(mergeDrivePlan(projectRoot, declared, contributed)),\n );\n for (const module of contributions.unresolved) {\n const entry = entries\n .map((e) => (typeof e === \"string\" ? { module: e } : e))\n .find((e) => e.module === module);\n const drive: unknown =\n entry && \"config\" in entry ? entry.config?.drive : undefined;\n const attached =\n typeof drive === \"string\"\n ? ` attaches ${drive}`\n : isToken(drive)\n ? ` attaches «${describeToken(drive)}»`\n : \"\";\n console.log(\n ` (browser plugin ${module}: not resolvable from the project tree)${attached}`,\n );\n }\n // The same dead-config warnings the connect runner prints at boot,\n // naming the file the config lives in.\n if (host.runner.module === CONNECT_RUNNER) {\n for (const warning of findDeadConnectConfig(\n host.config,\n host.runner.plugins,\n verb,\n configWhere,\n )) {\n console.warn(warning.message);\n }\n }\n}\n\n/* ----------------------------------------------------------------- outputs */\n\nfunction outputKeys(runner: RunnerModule): string {\n const schema = runner.outputsSchema;\n if (typeof schema !== \"object\" || schema === null) return \"(no outputs)\";\n const shape =\n \"shape\" in schema && typeof schema.shape === \"object\" && schema.shape\n ? Object.keys(schema.shape)\n : [];\n return shape.length ? shape.join(\", \") : \"(declared)\";\n}\n\nfunction printConsumes(\n host: unknown,\n indent: string,\n producerNote: (folder: string, member?: string) => string,\n source?: OutputSource,\n): void {\n const outputs = outputSitesOf(host);\n const env = envSitesOf(host);\n if (outputs.length === 0 && env.length === 0) {\n console.log(`${indent}consumes: nothing (no $output or $env tokens)`);\n return;\n }\n const valueLine = (token: unknown) => {\n const value = currentValue(token, source);\n if (value !== undefined) {\n console.log(`${indent} = ${JSON.stringify(value)}`);\n }\n };\n for (const site of outputs) {\n const token = { $output: { ...site.ref, path: site.outputPath } };\n console.log(\n `${indent}${site.path} ← ${describeToken(token)}${producerNote(site.ref.host, site.ref.member)}`,\n );\n valueLine(token);\n }\n // Composite tokens (`$concat`, `$map`) outside any template: the value\n // the field gets, once its producers run.\n for (const site of collectTokenSites(host)) {\n const nested =\n site.scopes.length > 0 ||\n site.position === \"concat\" ||\n site.position === \"over\";\n if (nested || (site.key !== \"$concat\" && site.key !== \"$map\")) continue;\n console.log(\n `${indent}${formatPath(site.path)} ← ${describeToken(site.token)}`,\n );\n valueLine(site.token);\n }\n const { env: processEnv } = processResolveEnv(process.cwd());\n for (const site of env) {\n const builtin = isBuiltinEnvName(site.name);\n const state =\n builtin || processEnv?.[site.name] !== undefined\n ? \"set\"\n : site.optional\n ? \"unset: the property is omitted\"\n : \"UNSET: ph run fails\";\n console.log(\n `${indent}${site.path} ← $env ${site.name}${site.optional ? \" (optional)\" : \"\"} [${state}]`,\n );\n }\n}\n\n/** Where `${package}` points, for a host that names it (as `\"${package}\"`\n * sugar or `{ $env: \"package\" }`): a path, never a secret. */\nfunction printPackageRoot(\n host: unknown,\n indent: string,\n view: { moduleRoot: string; packageName?: string },\n): void {\n const named =\n JSON.stringify(host).includes(\"${package}\") ||\n envSitesOf(host).some((site) => site.name === \"package\");\n if (!named) return;\n const whose = view.packageName\n ? `the root of ${view.packageName}, which supplies the host`\n : \"the project root: a project host\";\n console.log(`${indent}\\${package} = ${view.moduleRoot} (${whose})`);\n}\n\nfunction explainOutputs(name: string, view: LoadedView): void {\n if (!view.members) {\n const source = view.source;\n console.log(`[${name}] ${view.specifier}`);\n console.log(` produces: ${outputKeys(view.runner)}`);\n printPackageRoot(view.host, \" \", view);\n printConsumes(\n view.host,\n \" \",\n (folder, member) => {\n const ref =\n member === undefined ? { host: folder } : { host: folder, member };\n return source?.lookup(ref).status === \"available\"\n ? ` (host \"${folder}\": running)`\n : ` (host \"${folder}\": not running; start it first: ph run ${folder})`;\n },\n source,\n );\n return;\n }\n\n const members = view.members;\n const refs = members.map((x) => ({ key: x.key, host: x.wrapper.host }));\n const config: unknown = view.host.config;\n const startOrder =\n typeof config === \"object\" &&\n config !== null &&\n \"startOrder\" in config &&\n Array.isArray(config.startOrder)\n ? config.startOrder.filter((k): k is string => typeof k === \"string\")\n : undefined;\n const plan = planCompound(\n members.map((m) => ({\n key: m.key,\n host: m.wrapper.host,\n refs: outputSitesOf(m.host).map(({ ref, path }) => ({ ref, path })),\n })),\n startOrder,\n );\n // The member that owns the terminal starts last, as `ph run` starts it;\n // a compound that breaks its rules fails here as it would there.\n const planned = planForeground(\n members.map((m) => ({\n key: m.key,\n specifier: m.specifier,\n member: m.wrapper,\n runner: m.runner,\n })),\n plan,\n startOrder ? { startOrder } : {},\n );\n const broken = planned.issues.at(0);\n if (broken) {\n throw new RunnerError(`hosts/${name}: ${broken.message}`, broken.hint);\n }\n const processes = new Map(\n members.map((m) => [\n m.key,\n memberProcessOf(m.wrapper, {\n foreground: m.key === planned.foreground,\n besideForeground: planned.foreground !== undefined,\n oneShot: false,\n }),\n ]),\n );\n // Where each member runs, once that is not the compound's process alone.\n const showWhere =\n planned.foreground !== undefined || [...processes.values()].includes(\"own\");\n const whereOf = (key: string) => {\n if (!showWhere) return \"\";\n if (key === planned.foreground) {\n return \" [in front: owns the terminal; its end ends the stack]\";\n }\n return processes.get(key) === \"own\"\n ? \" [own process]\"\n : \" [in the compound's process]\";\n };\n console.log(\n `[${name}] start order (${plan.source === \"tokens\" ? \"from the output tokens\" : \"config.startOrder, checked against the tokens\"}):`,\n );\n planned.order.forEach((key, index) => {\n const m = members.find((x) => x.key === key);\n const needs = plan.edges\n .filter((e) => e.consumer === key)\n .map((e) => e.producer);\n console.log(\n ` ${index + 1}. ${key} (${m?.wrapper.host ?? \"?\"})${needs.length ? ` after ${needs.join(\", \")}` : \"\"}${whereOf(key)}`,\n );\n });\n console.log(\" Ctrl-C stops members in reverse order (consumers first).\");\n for (const key of planned.order) {\n const m = members.find((x) => x.key === key);\n if (!m) continue;\n console.log(`[${name} › ${key} (${m.wrapper.host})] ${m.specifier}`);\n console.log(` produces: ${outputKeys(m.runner)}`);\n printPackageRoot(m.host, \" \", m);\n printConsumes(\n m.host,\n \" \",\n (folder, member) => {\n const ref =\n member === undefined ? { host: folder } : { host: folder, member };\n const target = memberForRef(ref, refs);\n return \"key\" in target\n ? ` (member \"${target.key}\", live outputs)`\n : \"\";\n },\n view.source,\n );\n }\n const own = { ...view.host, children: undefined };\n if (outputSitesOf(own).length > 0 || envSitesOf(own).length > 0) {\n console.log(`[${name}] the compound's own fields:`);\n printConsumes(own, \" \", () => \"\");\n }\n}\n"],"names":[],"mappings":";;;;;AAkEA,MAAM,SAAS,CAAC,UAAU,SAAS;AA6CnC,eAAe,SACb,aACA,MACqB;CAGrB,MAAM,SAAS,MAAM,SAAS,aAAa,IAAI;CAC/C,MAAM,QAAQ,OAAO;CACrB,MAAM,aAAa,aAAa,aAAa,MAAM;CACnD,MAAM,YAAY,OAAO,KAAK,OAAO;CACrC,MAAM,SAAS,MAAM,oBAAoB,YAAY,SAAS;CAC9D,MAAM,OAAO,cAAc,OAAO,MAAM,KAAK;CAC7C,IAAI,OAAO,SAAS,YAAY;EAC9B,MAAM,Y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C;CACD,QAAQ,IAAI,4DAA4D;CACxE,KAAK,MAAM,OAAO,QAAQ,OAAO;EAC/B,MAAM,IAAI,QAAQ,MAAM,MAAM,EAAE,QAAQ,GAAG;EAC3C,IAAI,CAAC,GAAG;EACR,QAAQ,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,EAAE,QAAQ,KAAK,KAAK,EAAE,WAAW;EACnE,QAAQ,IAAI,eAAe,WAAW,EAAE,MAAM,GAAG;EACjD,iBAAiB,EAAE,MAAM,MAAM,CAAC;EAChC,cACE,EAAE,MACF,OACC,QAAQ,WAAW;GAGlB,MAAM,SAAS,aADb,WAAW,KAAA,IAAY,EAAE,MAAM,OAAO,IAAI;IAAE,MAAM;IAAQ;GAAO,GAClC,IAAI;GACrC,OAAO,SAAS,SACZ,cAAc,OAAO,IAAI,oBACzB;EACN,GACA,KAAK,MACP;CACF;CACA,MAAM,MAAM;EAAE,GAAG,KAAK;EAAM,UAAU,KAAA;CAAU;CAChD,IAAI,cAAc,GAAG,CAAC,CAAC,SAAS,KAAK,WAAW,GAAG,CAAC,CAAC,SAAS,GAAG;EAC/D,QAAQ,IAAI,IAAI,KAAK,6BAA6B;EAClD,cAAc,KAAK,YAAY,EAAE;CACnC;AACF","debug_id":"99430780-2e8f-52f4-826d-c826555b5b79"}
|
|
1
|
+
{"version":3,"file":"explain-DQ5ymlco.mjs","sources":["../src/services/run/explain.ts"],"sourcesContent":["import {\n applyChildWrapper,\n collectTokenSites,\n compoundOutputSource,\n CONNECT_RUNNER,\n declaredHostSchemas,\n describeToken,\n drivesSchema,\n envSitesOf,\n explainDrivePlan,\n findDeadConnectConfig,\n formatPath,\n hostFileLabel,\n isBuiltinEnvName,\n isToken,\n loadHost,\n loadProducers,\n memberForRef,\n memberProcessOf,\n mergeDrivePlan,\n moduleRootOf,\n outputRefsOf,\n outputSitesOf,\n planCompound,\n planForeground,\n probeRun,\n processResolveEnv,\n producerOutputsSchemas,\n readProjectName,\n renderTokens,\n resolveHostOutputs,\n resolvePluginContributions,\n resolveRunnerModule,\n RunnerError,\n runnerOutputsSchema,\n runRecordKey,\n runRecordOutputSource,\n validateDeclaredHost,\n validateHost,\n type ChildWrapper,\n type DriveDeclaration,\n type HostDefinition,\n type OutputSource,\n type PluginEntryData,\n type ReactorHostInput,\n type RunnerModule,\n} from \"@powerhousedao/host-core\";\n\n/**\n * `ph run <host> --explain <topic>`: print instead of running, after the\n * same declared validation `ph run` does first (so a printed explain is a\n * host that loads). `drives`: the merged drive plan with provenance\n * (browser-only plugins listed as unresolvable). `outputs`: the resolution\n * plan — consumed outputs and their producers, `$env` names, where\n * `${package}` points, the compound start order the tokens imply, which\n * producers are running and, for a\n * running producer, the value each token resolves to now. A `$map` in\n * `reactor.drives` is shown as the token and, when its producer runs, as the\n * drives it renders.\n */\n\ninterface ExplainOptions {\n host: string;\n topic: string;\n}\n\nconst TOPICS = [\"drives\", \"outputs\"];\n\n/** A reactor host as explained: a standalone host, or a compound member\n * with its wrapper applied (declared form). */\ninterface ReactorView {\n name: string;\n runner: HostDefinition[\"runner\"];\n config?: Record<string, unknown>;\n reactor?: ReactorHostInput[\"reactor\"];\n}\n\ninterface MemberView {\n key: string;\n wrapper: ChildWrapper;\n host: ReactorView;\n runner: RunnerModule;\n specifier: string;\n file: string;\n /** Where its plugin specifiers resolve from: its package, else the\n * project. Also what `${package}` is in it. */\n moduleRoot: string;\n /** The package that supplies its host. */\n packageName?: string;\n /** Where the effective `config` lives (a wrapper `config` is a full\n * statement in the compound's file). */\n configWhere: string;\n}\n\ninterface LoadedView {\n host: HostDefinition;\n runner: RunnerModule;\n specifier: string;\n file: string;\n /** Where its plugin specifiers resolve from, and `${package}`. */\n moduleRoot: string;\n /** The package that supplies the host. */\n packageName?: string;\n /** Set for a compound. */\n members?: MemberView[];\n /** Where tokens resolve NOW (for printing values): a standalone host's\n * producers' live run records; a compound's own live record (its members'\n * outputs), or none when it is not running. */\n source?: OutputSource;\n}\n\nasync function loadView(\n projectRoot: string,\n name: string,\n): Promise<LoadedView> {\n // As `ph run` finds it: a package's host resolves its modules there, and\n // its compound's bare members look there first.\n const loaded = await loadHost(projectRoot, name);\n const scope = loaded.package;\n const moduleRoot = moduleRootOf(projectRoot, loaded);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(moduleRoot, specifier);\n const file = hostFileLabel(loaded.name, scope);\n if (runner.kind !== \"compound\") {\n const producers = await loadProducers(\n projectRoot,\n outputRefsOf(loaded.host),\n scope,\n );\n validateDeclaredHost(runner, specifier, loaded.host, file, {\n outputsSchemaOf: producerOutputsSchemas(producers),\n });\n // The same lookup `ph run` resolves through.\n const source = runRecordOutputSource(projectRoot, {\n consumer: name,\n producers,\n projectName: readProjectName(projectRoot),\n });\n return {\n host: loaded.host,\n runner,\n specifier,\n file,\n moduleRoot,\n ...(scope ? { packageName: scope.name } : {}),\n source,\n };\n }\n validateDeclaredHost(runner, specifier, loaded.host, file);\n validateHost(runner, specifier, loaded.host, file, { tokens: \"allow\" });\n // The compound runner's schema owns `config`; `children` is shared.\n const children = declaredHostSchemas.childrenSchema.parse(\n loaded.host.children,\n );\n const members: MemberView[] = [];\n for (const [key, wrapper] of Object.entries(children)) {\n const member = await loadHost(projectRoot, wrapper.host, { scope });\n const host: ReactorView = applyChildWrapper(member.host, wrapper);\n const memberSpecifier = host.runner.module;\n const memberRoot = moduleRootOf(projectRoot, member);\n const memberFile = hostFileLabel(member.name, member.package);\n members.push({\n key,\n wrapper,\n host,\n runner: await resolveRunnerModule(memberRoot, memberSpecifier),\n specifier: memberSpecifier,\n file: memberFile,\n moduleRoot: memberRoot,\n ...(member.package ? { packageName: member.package.name } : {}),\n configWhere:\n wrapper.config !== undefined\n ? `${file} (children.${key}.config)`\n : memberFile,\n });\n }\n const refs = members.map((m) => ({ key: m.key, host: m.wrapper.host }));\n for (const m of members) {\n validateDeclaredHost(m.runner, m.specifier, m.host, m.file, {\n outputsSchemaOf: (ref) => {\n const target = memberForRef(ref, refs);\n if (\"error\" in target) return { error: target.error };\n const producer = members.find((p) => p.key === target.key);\n return producer\n ? runnerOutputsSchema(\n producer.runner,\n producer.specifier,\n `member \"${producer.key}\"`,\n )\n : { error: `names member \"${target.key}\", which is not declared.` };\n },\n });\n }\n // Members read each other's live outputs: shown only while this\n // compound runs (its record carries every member's outputs).\n const probe = probeRun(\n projectRoot,\n runRecordKey(loaded.host.name, scope?.name),\n readProjectName(projectRoot),\n );\n const live = new Map<string, unknown>();\n if (probe.status === \"live\") {\n for (const [key, member] of Object.entries(probe.record.members ?? {})) {\n live.set(key, member.outputs);\n }\n }\n const source =\n probe.status === \"live\"\n ? compoundOutputSource(refs, live, loaded.host.name)\n : undefined;\n return {\n host: loaded.host,\n runner,\n specifier,\n file,\n moduleRoot,\n ...(scope ? { packageName: scope.name } : {}),\n members,\n source,\n };\n}\n\n/** A token's value from running producers, or undefined (producer not\n * running, or the token reads the environment: `$env` values may be\n * secrets, so explain never prints them). */\nfunction currentValue(token: unknown, source?: OutputSource): unknown {\n if (!source) return undefined;\n if (collectTokenSites(token).some((site) => site.key === \"$env\")) {\n return undefined;\n }\n try {\n return resolveHostOutputs(token, { outputs: source });\n } catch {\n return undefined;\n }\n}\n\nexport async function explainHost(options: ExplainOptions): Promise<void> {\n if (!TOPICS.includes(options.topic)) {\n throw new Error(\n `Unknown --explain topic \"${options.topic}\" (supported: ${TOPICS.join(\", \")}).`,\n );\n }\n const projectRoot = process.cwd();\n const view = await loadView(projectRoot, options.host);\n if (options.topic === \"outputs\") {\n explainOutputs(options.host, view);\n return;\n }\n\n if (view.members) {\n // One plan per member, with the wrapper's full-statement semantics.\n const verb = view.host.runner.defaultVerb ?? \"run\";\n for (const m of view.members) {\n await explainDrives(\n { projectRoot, moduleRoot: m.moduleRoot },\n `${options.host} › ${m.key} (${m.wrapper.host})`,\n m.host,\n verb,\n m.file,\n m.configWhere,\n view.source,\n );\n }\n return;\n }\n await explainDrives(\n { projectRoot, moduleRoot: view.moduleRoot },\n options.host,\n view.host,\n \"run\",\n view.file,\n view.file,\n view.source,\n );\n}\n\n/* ------------------------------------------------------------------ drives */\n\nasync function explainDrives(\n /** Drive ids are the project's; plugin specifiers resolve from\n * `moduleRoot` (a package's host: the package). */\n roots: { projectRoot: string; moduleRoot: string },\n label: string,\n host: ReactorView,\n verb: string,\n where: string,\n configWhere: string,\n source?: OutputSource,\n): Promise<void> {\n const { projectRoot } = roots;\n const entries: PluginEntryData[] = host.runner.plugins ?? [];\n const contributions =\n entries.length > 0\n ? await resolvePluginContributions(roots.moduleRoot, verb, entries, where)\n : { drives: [], unresolved: [] };\n const contributed = contributions.drives.map(({ declaration, source }) => {\n const parsed = drivesSchema.safeParse([declaration]);\n if (!parsed.success) {\n throw new Error(\n `${where}: plugin \"${source}\" contributes an invalid drive declaration.`,\n );\n }\n return { declaration: parsed.data[0], source };\n });\n // Declared drives may carry output tokens (a remote url): shown as\n // «$output …», resolved only at `ph run`. The whole list may be a token\n // (`$map` over a producer's drives): rendered from the running producer\n // when there is one, otherwise named and left out of the plan.\n const rawDrives: unknown = host.reactor?.drives ?? [];\n let listed: unknown = rawDrives;\n let listNote: string | undefined;\n if (isToken(rawDrives)) {\n const value = currentValue(rawDrives, source);\n listed = Array.isArray(value) ? value : [];\n listNote = ` reactor.drives ← «${describeToken(rawDrives)}»${\n Array.isArray(value)\n ? \" (rendered from the running producer's outputs)\"\n : \" (rendered at ph run from the producer's live outputs; its producer is not running now, so the plan below leaves them out)\"\n }`;\n }\n const parsed = drivesSchema.safeParse(renderTokens(listed));\n if (!parsed.success && listNote === undefined) {\n // a literal list: declared validation already ran; keep its error\n throw parsed.error;\n }\n const declared: DriveDeclaration[] = parsed.success ? parsed.data : [];\n console.log(`[${label}]`);\n if (listNote) console.log(listNote);\n if (!parsed.success) {\n console.log(\n ` the rendered drives fail the drive schema (ph run rejects them): ${parsed.error.issues\n .map((i) => `${i.path.map(String).join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"; \")}`,\n );\n }\n console.log(\n explainDrivePlan(mergeDrivePlan(projectRoot, declared, contributed)),\n );\n for (const module of contributions.unresolved) {\n const entry = entries\n .map((e) => (typeof e === \"string\" ? { module: e } : e))\n .find((e) => e.module === module);\n const drive: unknown =\n entry && \"config\" in entry ? entry.config?.drive : undefined;\n const attached =\n typeof drive === \"string\"\n ? ` attaches ${drive}`\n : isToken(drive)\n ? ` attaches «${describeToken(drive)}»`\n : \"\";\n console.log(\n ` (browser plugin ${module}: not resolvable from the project tree)${attached}`,\n );\n }\n // The same dead-config warnings the connect runner prints at boot,\n // naming the file the config lives in.\n if (host.runner.module === CONNECT_RUNNER) {\n for (const warning of findDeadConnectConfig(\n host.config,\n host.runner.plugins,\n verb,\n configWhere,\n )) {\n console.warn(warning.message);\n }\n }\n}\n\n/* ----------------------------------------------------------------- outputs */\n\nfunction outputKeys(runner: RunnerModule): string {\n const schema = runner.outputsSchema;\n if (typeof schema !== \"object\" || schema === null) return \"(no outputs)\";\n const shape =\n \"shape\" in schema && typeof schema.shape === \"object\" && schema.shape\n ? Object.keys(schema.shape)\n : [];\n return shape.length ? shape.join(\", \") : \"(declared)\";\n}\n\nfunction printConsumes(\n host: unknown,\n indent: string,\n producerNote: (folder: string, member?: string) => string,\n source?: OutputSource,\n): void {\n const outputs = outputSitesOf(host);\n const env = envSitesOf(host);\n if (outputs.length === 0 && env.length === 0) {\n console.log(`${indent}consumes: nothing (no $output or $env tokens)`);\n return;\n }\n const valueLine = (token: unknown) => {\n const value = currentValue(token, source);\n if (value !== undefined) {\n console.log(`${indent} = ${JSON.stringify(value)}`);\n }\n };\n for (const site of outputs) {\n const token = { $output: { ...site.ref, path: site.outputPath } };\n console.log(\n `${indent}${site.path} ← ${describeToken(token)}${producerNote(site.ref.host, site.ref.member)}`,\n );\n valueLine(token);\n }\n // Composite tokens (`$concat`, `$map`) outside any template: the value\n // the field gets, once its producers run.\n for (const site of collectTokenSites(host)) {\n const nested =\n site.scopes.length > 0 ||\n site.position === \"concat\" ||\n site.position === \"over\";\n if (nested || (site.key !== \"$concat\" && site.key !== \"$map\")) continue;\n console.log(\n `${indent}${formatPath(site.path)} ← ${describeToken(site.token)}`,\n );\n valueLine(site.token);\n }\n const { env: processEnv } = processResolveEnv(process.cwd());\n for (const site of env) {\n const builtin = isBuiltinEnvName(site.name);\n const state =\n builtin || processEnv?.[site.name] !== undefined\n ? \"set\"\n : site.optional\n ? \"unset: the property is omitted\"\n : \"UNSET: ph run fails\";\n console.log(\n `${indent}${site.path} ← $env ${site.name}${site.optional ? \" (optional)\" : \"\"} [${state}]`,\n );\n }\n}\n\n/** Where `${package}` points, for a host that names it (as `\"${package}\"`\n * sugar or `{ $env: \"package\" }`): a path, never a secret. */\nfunction printPackageRoot(\n host: unknown,\n indent: string,\n view: { moduleRoot: string; packageName?: string },\n): void {\n const named =\n JSON.stringify(host).includes(\"${package}\") ||\n envSitesOf(host).some((site) => site.name === \"package\");\n if (!named) return;\n const whose = view.packageName\n ? `the root of ${view.packageName}, which supplies the host`\n : \"the project root: a project host\";\n console.log(`${indent}\\${package} = ${view.moduleRoot} (${whose})`);\n}\n\nfunction explainOutputs(name: string, view: LoadedView): void {\n if (!view.members) {\n const source = view.source;\n console.log(`[${name}] ${view.specifier}`);\n console.log(` produces: ${outputKeys(view.runner)}`);\n printPackageRoot(view.host, \" \", view);\n printConsumes(\n view.host,\n \" \",\n (folder, member) => {\n const ref =\n member === undefined ? { host: folder } : { host: folder, member };\n return source?.lookup(ref).status === \"available\"\n ? ` (host \"${folder}\": running)`\n : ` (host \"${folder}\": not running; start it first: ph run ${folder})`;\n },\n source,\n );\n return;\n }\n\n const members = view.members;\n const refs = members.map((x) => ({ key: x.key, host: x.wrapper.host }));\n const config: unknown = view.host.config;\n const startOrder =\n typeof config === \"object\" &&\n config !== null &&\n \"startOrder\" in config &&\n Array.isArray(config.startOrder)\n ? config.startOrder.filter((k): k is string => typeof k === \"string\")\n : undefined;\n const plan = planCompound(\n members.map((m) => ({\n key: m.key,\n host: m.wrapper.host,\n refs: outputSitesOf(m.host).map(({ ref, path }) => ({ ref, path })),\n })),\n startOrder,\n );\n // The member that owns the terminal starts last, as `ph run` starts it;\n // a compound that breaks its rules fails here as it would there.\n const planned = planForeground(\n members.map((m) => ({\n key: m.key,\n specifier: m.specifier,\n member: m.wrapper,\n runner: m.runner,\n })),\n plan,\n startOrder ? { startOrder } : {},\n );\n const broken = planned.issues.at(0);\n if (broken) {\n throw new RunnerError(`hosts/${name}: ${broken.message}`, broken.hint);\n }\n const processes = new Map(\n members.map((m) => [\n m.key,\n memberProcessOf(m.wrapper, {\n foreground: m.key === planned.foreground,\n besideForeground: planned.foreground !== undefined,\n oneShot: false,\n }),\n ]),\n );\n // Where each member runs, once that is not the compound's process alone.\n const showWhere =\n planned.foreground !== undefined || [...processes.values()].includes(\"own\");\n const whereOf = (key: string) => {\n if (!showWhere) return \"\";\n if (key === planned.foreground) {\n return \" [in front: owns the terminal; its end ends the stack]\";\n }\n return processes.get(key) === \"own\"\n ? \" [own process]\"\n : \" [in the compound's process]\";\n };\n console.log(\n `[${name}] start order (${plan.source === \"tokens\" ? \"from the output tokens\" : \"config.startOrder, checked against the tokens\"}):`,\n );\n planned.order.forEach((key, index) => {\n const m = members.find((x) => x.key === key);\n const needs = plan.edges\n .filter((e) => e.consumer === key)\n .map((e) => e.producer);\n console.log(\n ` ${index + 1}. ${key} (${m?.wrapper.host ?? \"?\"})${needs.length ? ` after ${needs.join(\", \")}` : \"\"}${whereOf(key)}`,\n );\n });\n console.log(\" Ctrl-C stops members in reverse order (consumers first).\");\n for (const key of planned.order) {\n const m = members.find((x) => x.key === key);\n if (!m) continue;\n console.log(`[${name} › ${key} (${m.wrapper.host})] ${m.specifier}`);\n console.log(` produces: ${outputKeys(m.runner)}`);\n printPackageRoot(m.host, \" \", m);\n printConsumes(\n m.host,\n \" \",\n (folder, member) => {\n const ref =\n member === undefined ? { host: folder } : { host: folder, member };\n const target = memberForRef(ref, refs);\n return \"key\" in target\n ? ` (member \"${target.key}\", live outputs)`\n : \"\";\n },\n view.source,\n );\n }\n const own = { ...view.host, children: undefined };\n if (outputSitesOf(own).length > 0 || envSitesOf(own).length > 0) {\n console.log(`[${name}] the compound's own fields:`);\n printConsumes(own, \" \", () => \"\");\n }\n}\n"],"names":[],"mappings":";;;;;AAkEA,MAAM,SAAS,CAAC,UAAU,SAAS;AA6CnC,eAAe,SACb,aACA,MACqB;CAGrB,MAAM,SAAS,MAAM,SAAS,aAAa,IAAI;CAC/C,MAAM,QAAQ,OAAO;CACrB,MAAM,aAAa,aAAa,aAAa,MAAM;CACnD,MAAM,YAAY,OAAO,KAAK,OAAO;CACrC,MAAM,SAAS,MAAM,oBAAoB,YAAY,SAAS;CAC9D,MAAM,OAAO,cAAc,OAAO,MAAM,KAAK;CAC7C,IAAI,OAAO,SAAS,YAAY;EAC9B,MAAM,YAAY,MAAM,cACtB,aACA,aAAa,OAAO,IAAI,GACxB,KACF;EACA,qBAAqB,QAAQ,WAAW,OAAO,MAAM,MAAM,EACzD,iBAAiB,uBAAuB,SAAS,EACnD,CAAC;EAED,MAAM,SAAS,sBAAsB,aAAa;GAChD,UAAU;GACV;GACA,aAAa,gBAAgB,WAAW;EAC1C,CAAC;EACD,OAAO;GACL,MAAM,OAAO;GACb;GACA;GACA;GACA;GACA,GAAI,QAAQ,EAAE,aAAa,MAAM,KAAK,IAAI,CAAC;GAC3C;EACF;CACF;CACA,qBAAqB,QAAQ,WAAW,OAAO,MAAM,IAAI;CACzD,aAAa,QAAQ,WAAW,OAAO,MAAM,MAAM,EAAE,QAAQ,QAAQ,CAAC;CAEtE,MAAM,WAAW,oBAAoB,eAAe,MAClD,OAAO,KAAK,QACd;CACA,MAAM,UAAwB,CAAC;CAC/B,KAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,QAAQ,GAAG;EACrD,MAAM,SAAS,MAAM,SAAS,aAAa,QAAQ,MAAM,EAAE,MAAM,CAAC;EAClE,MAAM,OAAoB,kBAAkB,OAAO,MAAM,OAAO;EAChE,MA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6B;EAClD,cAAc,KAAK,YAAY,EAAE;CACnC;AACF","debug_id":"ef74fd4c-a22e-5841-a2be-234e655488ef"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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]="
|
|
3
|
-
import { r as exportHost } from "./dist-
|
|
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]="f1a04b44-ca69-553d-9bb0-1f940da1609f")}catch(e){}}();
|
|
3
|
+
import { r as exportHost } from "./dist-DPj_FB8H.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { CALLER_CWD_ENV } from "@powerhousedao/shared/clis/command-names";
|
|
6
6
|
import { writeFile } from "node:fs/promises";
|
|
@@ -38,5 +38,5 @@ async function runHostExport(args) {
|
|
|
38
38
|
//#endregion
|
|
39
39
|
export { runHostExport };
|
|
40
40
|
|
|
41
|
-
//# sourceMappingURL=export-
|
|
42
|
-
//# debugId=
|
|
41
|
+
//# sourceMappingURL=export-CzeF8pob.mjs.map
|
|
42
|
+
//# debugId=f1a04b44-ca69-553d-9bb0-1f940da1609f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-
|
|
1
|
+
{"version":3,"file":"export-CzeF8pob.mjs","sources":["../src/services/host/export.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { exportHost, type HostExport } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\n\nexport interface HostExportArgs {\n host: string;\n out?: string;\n projectRoot?: string;\n}\n\nexport interface HostExportResult {\n stdout?: string;\n stderr?: string;\n exitCode: number;\n}\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** `ph host export <host>`: the declared host and its members as JSON. */\nexport async function runHostExport(\n args: HostExportArgs,\n): Promise<HostExportResult> {\n let exported: HostExport;\n try {\n exported = await exportHost(args.projectRoot ?? process.cwd(), args.host);\n } catch (error) {\n return { stderr: `${message(error)}\\n`, exitCode: 1 };\n }\n const json = `${JSON.stringify(exported, null, 2)}\\n`;\n if (args.out === undefined) return { stdout: json, exitCode: 0 };\n try {\n const from = process.env[CALLER_CWD_ENV] ?? process.cwd();\n await writeFile(path.resolve(from, args.out), json);\n } catch (error) {\n return {\n stderr: `Cannot write ${args.out}: ${message(error)}\\n`,\n exitCode: 1,\n };\n }\n return { exitCode: 0 };\n}\n"],"names":[],"mappings":";;;;;;;AAiBA,SAAS,QAAQ,OAAwB;CACvC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;AAGA,eAAsB,cACpB,MAC2B;CAC3B,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,WAAW,KAAK,eAAe,QAAQ,IAAI,GAAG,KAAK,IAAI;CAC1E,SAAS,OAAO;EACd,OAAO;GAAE,QAAQ,GAAG,QAAQ,KAAK,EAAE;GAAK,UAAU;EAAE;CACtD;CACA,MAAM,OAAO,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,EAAE;CAClD,IAAI,KAAK,QAAQ,KAAA,GAAW,OAAO;EAAE,QAAQ;EAAM,UAAU;CAAE;CAC/D,IAAI;EACF,MAAM,OAAO,QAAQ,IAAI,mBAAmB,QAAQ,IAAI;EACxD,MAAM,UAAU,KAAK,QAAQ,MAAM,KAAK,GAAG,GAAG,IAAI;CACpD,SAAS,OAAO;EACd,OAAO;GACL,QAAQ,gBAAgB,KAAK,IAAI,IAAI,QAAQ,KAAK,EAAE;GACpD,UAAU;EACZ;CACF;CACA,OAAO,EAAE,UAAU,EAAE;AACvB","debug_id":"f1a04b44-ca69-553d-9bb0-1f940da1609f"}
|