@powerhousedao/ph-cli 6.2.3-dev.70 → 6.2.3-dev.71
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/{cli-connect-override-Cf7WutqU.mjs → cli-connect-override-CEJhQWRX.mjs} +5 -5
- package/dist/cli-connect-override-CEJhQWRX.mjs.map +1 -0
- package/dist/cli.mjs +4 -4
- package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs +2459 -0
- package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs.map +1 -0
- package/dist/{connect-build-BtKpvcQK.mjs → connect-build-BfhOGbha.mjs} +4 -4
- package/dist/{connect-build-BtKpvcQK.mjs.map → connect-build-BfhOGbha.mjs.map} +1 -1
- package/dist/{connect-config-9EZB_0H_.mjs → connect-config-DblqJgxR.mjs} +4 -4
- package/dist/{connect-config-9EZB_0H_.mjs.map → connect-config-DblqJgxR.mjs.map} +1 -1
- package/dist/connect-plugin-configs-D2fwYpMw.mjs +50 -0
- package/dist/connect-plugin-configs-D2fwYpMw.mjs.map +1 -0
- package/dist/{connect-studio-Bhlc77WI.mjs → connect-studio-DX7r4iyI.mjs} +5 -4
- package/dist/{connect-studio-Bhlc77WI.mjs.map → connect-studio-DX7r4iyI.mjs.map} +1 -1
- package/dist/{connect-studio-BehPZzN7.mjs → connect-studio-DmjcV8I2.mjs} +3 -3
- package/dist/{dist-BqeDFgEy.mjs → dist-CCLkwpTS.mjs} +199 -109
- package/dist/dist-CCLkwpTS.mjs.map +1 -0
- package/dist/explain-DUXbB9jf.mjs +241 -0
- package/dist/explain-DUXbB9jf.mjs.map +1 -0
- package/dist/{generate-all-C_sPGBuk.mjs → generate-all-Dgyy_kT-.mjs} +7 -3
- package/dist/generate-all-Dgyy_kT-.mjs.map +1 -0
- package/dist/{generate-desktop-shell-BBSGpmud.mjs → generate-desktop-shell-Bj_3bJDL.mjs} +112 -7
- package/dist/generate-desktop-shell-Bj_3bJDL.mjs.map +1 -0
- package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
- package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
- package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
- package/dist/{index-CspiP73o.d.mts → index-BIbx17vt.d.mts} +178 -14
- package/dist/index-BIbx17vt.d.mts.map +1 -0
- package/dist/ph-cli-commands-BhzvcuzR.mjs +4 -0
- package/dist/{ph-cli-commands-3ptdQ0NI.mjs → ph-cli-commands-pyxDifSE.mjs} +155 -138
- package/dist/ph-cli-commands-pyxDifSE.mjs.map +1 -0
- package/dist/{run-sugar-BdjKTPGO.mjs → run-sugar-Ns53R6lU.mjs} +4 -4
- package/dist/{run-sugar-BdjKTPGO.mjs.map → run-sugar-Ns53R6lU.mjs.map} +1 -1
- package/dist/runners/connect.d.mts +1054 -26
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +121 -49
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +170 -28
- package/dist/runners/switchboard.d.mts.map +1 -1
- package/dist/runners/switchboard.mjs +171 -49
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/{schemas-BQSPev1x.mjs → schemas-D5N5U_Mf.mjs} +205 -4
- package/dist/{schemas-BQSPev1x.mjs.map → schemas-D5N5U_Mf.mjs.map} +1 -1
- package/dist/scripts/emit-runner-schemas.ts +24 -0
- package/dist/start-run-BIaYSpHh.mjs +124 -0
- package/dist/start-run-BIaYSpHh.mjs.map +1 -0
- package/dist/{superseded-config-9D7BdLvd.mjs → superseded-config-CbSTFun2.mjs} +4 -4
- package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
- package/dist/switchboard-h4-XgP1h.mjs +2 -2
- package/dist/switchboard-h4-XgP1h.mjs.map +1 -1
- package/dist/utils-DAux4Ga7.mjs +4 -0
- package/dist/{vetra-BD-34wGs.mjs → vetra-CnrGDPX0.mjs} +10 -10
- package/dist/vetra-CnrGDPX0.mjs.map +1 -0
- package/package.json +15 -20
- package/dist/cli-connect-override-Cf7WutqU.mjs.map +0 -1
- package/dist/dist-BqeDFgEy.mjs.map +0 -1
- package/dist/explain-BDHmXgw3.mjs +0 -27
- package/dist/explain-BDHmXgw3.mjs.map +0 -1
- package/dist/generate-all-C_sPGBuk.mjs.map +0 -1
- package/dist/generate-desktop-shell-BBSGpmud.mjs.map +0 -1
- package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs +0 -493
- package/dist/host-schemas-CtPNRr5v-BQyKKFbS.mjs.map +0 -1
- package/dist/index-CspiP73o.d.mts.map +0 -1
- package/dist/ph-cli-commands-3ptdQ0NI.mjs.map +0 -1
- package/dist/ph-cli-commands-Dx8hNj6W.mjs +0 -4
- package/dist/plugins-CHVv4qup.mjs +0 -91
- package/dist/plugins-CHVv4qup.mjs.map +0 -1
- package/dist/reactor-env-BbR86_Li.mjs +0 -29
- package/dist/reactor-env-BbR86_Li.mjs.map +0 -1
- package/dist/reactor-env-D_EvBtLB.mjs +0 -4
- package/dist/runners/compound.d.mts +0 -127
- package/dist/runners/compound.d.mts.map +0 -1
- package/dist/runners/compound.mjs +0 -72
- package/dist/runners/compound.mjs.map +0 -1
- package/dist/start-run-CmDxyMw0.mjs +0 -36
- package/dist/start-run-CmDxyMw0.mjs.map +0 -1
- package/dist/superseded-config-9D7BdLvd.mjs.map +0 -1
- package/dist/utils-TO9lB8Xs.mjs +0 -4
- package/dist/vetra-BD-34wGs.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-CCLkwpTS.mjs","sources":["../../../packages/host-core/dist/index.mjs"],"sourcesContent":["import { $ as envSitesOf, $t as PluginError, A as probeHostsFolder, At as driveDeclarationSchema, B as resolveRunnerModule, Bt as isToken, C as computeOutputsHash, Ct as reactorHostSchema, D as lintHostImports, Dt as runnerBaseSchema, E as lintHostImportGraph, Et as refineStartOrder, F as ONE_SHOT_VERBS, Ft as concatTokenSchema, G as resolveHostOutputs, Gt as ref, H as validateHost, Ht as keyTokenSchema, I as RunnerError, It as envTokenSchema, J as planCompound, Jt as tokenable, K as PlanError, Kt as tokenKeyOf, L as getVerb, Lt as envTokenable, M as scanHostImports, Mt as projectDriveIdWith, N as stripComments, Nt as TOKEN_ESCAPE_KEY, O as lintOutputsFile, Ot as runnerKindSchema, P as CONNECT_RUNNER, Pt as TOKEN_KEYS, Q as checkTokenSites, Qt as resolvePluginContributions, R as isSchemaLike, Rt as findToken, S as OUTPUTS_FILE, St as reactorBackendSchema, T as findNonStaticValue, Tt as reactorSchema, U as TokenResolutionError, Ut as mapTokenSchema, V as validateDeclaredHost, Vt as itemTokenSchema, W as describeMapElements, Wt as outputTokenSchema, X as findRemovedForms, Xt as findDeadConnectConfig, Y as substituteBuiltinEnv, Yt as CONNECT_PLUGIN_OWNED_SLICES, Z as checkOutputPaths, Zt as resolveHostPlugins, _ as readRunRecord, _t as emittedHostSchemas, a as loadProducers, an as pluginEntryObjectSchema, at as describeToken, b as runRecordSchema, bt as profileSchema, c as runRecordOutputSource, cn as resolveOrder, ct as unwrapEscapes, d as resolveUserDataPlaceholders, dn as runProvideHook, dt as compoundHostSchema, en as entryActiveForVerb, et as outputRefsOf, f as clearRunRecord, fn as runTransformHook, ft as compoundWiringSchema, g as readProjectName, gt as emitHostJsonSchema, h as probeRun, ht as defineHostSchemas, i as compoundOutputSource, in as normalizePluginEntry, it as collectTokenSites, j as readOutputsFileHash, jt as drivesSchema, k as loadHost, kt as buildDriveDeclarationSchema, l as runnerOutputsSchema, ln as runObserveHook, lt as childWrapperSchema, m as listRunRecords, mt as declaredHostSchemas, n as runnerHandleSchema, nn as mergeContributions, nt as refKey, o as processResolveEnv, on as pluginEntrySchema, ot as formatPath, p as isPidAlive, pt as declaredGenericCompoundHostSchema, q as memberForRef, qt as tokenSchema, r as toStartedHandle, rn as normalizePluginEntries, rt as schemaAtPath, s as producerOutputsSchemas, sn as registerHostType, st as renderTokens, t as runCompound, tn as hostTypeSatisfies, tt as outputSitesOf, u as defaultUserDataDir, un as runObserveHookSequential, ut as childrenSchema, v as writeRunRecord, vt as genericCompoundHostSchema, w as describeHostOutputs, wt as reactorProtocolSchema, x as HostLoadError, xt as reactorBackendKindSchema, y as runRecordMemberSchema, yt as makeHostSchemas, z as listVerbs, zt as forbidRef } from \"./compound-B6RZMA0Y.mjs\";\nimport crypto from \"node:crypto\";\nimport { DRIVE_ICON_MAX_BYTES, resolveImageRef } from \"@powerhousedao/shared/connect/image-ref\";\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 ?? decl.slug;\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\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\treturn ` ${drive.slug} (${kind}, id=${drive.id}${editor}) [${source}]`;\n\t})].join(\"\\n\");\n}\n//#endregion\n//#region src/reactor-config.ts\n/** The single primary backend for phase-2 projection (multi-backend routing is\n* track R). Prefers placement.primary, else \"main\"/\"local\", else the first. */\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};\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/** Project the reactor block onto the switchboard's env + options. */\nfunction projectReactorToSwitchboard(reactor) {\n\tconst env = protocolEnv(reactor?.protocol);\n\tconst backend = primaryBackend(reactor);\n\tconst options = {};\n\tif (backend?.storage) {\n\t\tconst s = backend.storage;\n\t\tconst dbUrl = s.kind === \"postgres\" ? s.url : s.dataDir;\n\t\tif (dbUrl) env.PH_REACTOR_DATABASE_URL = dbUrl;\n\t}\n\tif (backend?.readModel?.url) options.dbPath = backend.readModel.url;\n\tif (backend?.packages?.dynamic) env.DYNAMIC_MODEL_LOADING = \"true\";\n\tif (reactor?.workflows !== void 0) env.PH_WORKFLOWS_ENABLED = reactor.workflows ? \"1\" : \"0\";\n\treturn {\n\t\tenv,\n\t\toptions\n\t};\n}\nconst LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set([\"in-process\", \"worker\"]);\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 — the caller then keeps the\n* legacy reactorWorker/multiReactor behaviour untouched.\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 primaryBackend(reactor)?.kind === \"worker\" ? \"worker\" : \"in-process\";\n}\n/** Project the reactor block onto the Connect runtime config: protocol →\n* connect.reactor (same shape), backend topology → instance.reactorWorker\n* (legacy) + instance.reactorClient (the explicit 4-way selector),\n* workflows → app.workflowsEnabled. */\nfunction projectReactorToConnect(reactor) {\n\tconst connect = {};\n\tif (reactor?.protocol) connect.reactor = reactor.protocol;\n\tconst backend = primaryBackend(reactor);\n\tconst mode = reactorClientMode(reactor);\n\tif (backend?.kind !== void 0 || mode !== void 0) connect.instance = {\n\t\t...backend?.kind !== void 0 ? { reactorWorker: backend.kind === \"worker\" } : {},\n\t\t...mode !== void 0 ? { reactorClient: mode } : {}\n\t};\n\tif (reactor?.workflows !== void 0) connect.app = { workflowsEnabled: reactor.workflows };\n\treturn { connect };\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. An env var that merely matches, or is unset, is fine (phase-2\n* transition keeps an operator's explicit env as an escape hatch unless it\n* disagrees with the protocol — see the WBS precedence note).\n*/\nfunction assertProtocolConsistency(protocol, env, hostFile = \"the host file\") {\n\tif (!protocol) return;\n\tconst expected = protocolEnv(protocol);\n\tfor (const [varName, hostValue] of Object.entries(expected)) {\n\t\tconst envValue = env[varName];\n\t\tif (envValue !== void 0 && envValue !== hostValue) throw new Error(`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//#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' urls, placement order — what the routing client dials. */\nfunction remoteBackendUrls(reactor) {\n\treturn backendsToDescriptors(reactor).filter((d) => d.kind === \"remote\").map((d) => d.remote?.url).filter((u) => typeof u === \"string\");\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 vetra` 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//#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 { CONNECT_PLUGIN_OWNED_SLICES, CONNECT_RUNNER, HostLoadError, ONE_SHOT_VERBS, OUTPUTS_FILE, PlanError, PluginError, RunnerError, TOKEN_ESCAPE_KEY, TOKEN_KEYS, TokenResolutionError, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, buildDriveDeclarationSchema, checkOutputPaths, checkTokenSites, childWrapperSchema, childrenSchema, clearRunRecord, collectTokenSites, compoundHostSchema, compoundOutputSource, compoundWiringSchema, computeOutputsHash, concatTokenSchema, declaredGenericCompoundHostSchema, declaredHostSchemas, defaultUserDataDir, defineHostSchemas, describeHostOutputs, describeMapElements, describeToken, driveDeclarationSchema, drivesSchema, emitHostJsonSchema, emittedHostSchemas, entryActiveForVerb, envSitesOf, envTokenSchema, envTokenable, expectHost, explainDrivePlan, findDeadConnectConfig, findNonStaticValue, findRemovedForms, findToken, forbidRef, formatPath, genericCompoundHostSchema, getVerb, hostTypeSatisfies, isPidAlive, isSchemaLike, isStructuralMultiReactor, isToken, itemTokenSchema, keyTokenSchema, lintHostImportGraph, lintHostImports, lintOutputsFile, listRunRecords, listVerbs, loadHost, loadProducers, makeHostSchemas, mapTokenSchema, memberForRef, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, outputRefsOf, outputSitesOf, outputTokenSchema, planCompound, pluginEntryObjectSchema, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, processResolveEnv, producerOutputsSchemas, profileSchema, projectDriveId, projectDriveIdWith, projectDrivesIntoConnect, projectReactorToConnect, projectReactorToSwitchboard, protocolEnv, reactorBackendKindSchema, reactorBackendSchema, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readOutputsFileHash, readProjectName, readRunRecord, rebaseDriveUrl, ref, refKey, refineStartOrder, registerHostType, remoteBackendUrls, renderTokens, resolveDriveDeclaration, resolveHostOutputs, resolveHostPlugins, resolveOrder, resolvePluginContributions, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runRecordMemberSchema, runRecordOutputSource, runRecordSchema, runTransformHook, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, runnerOutputsSchema, scanHostImports, schemaAtPath, seedDrives, stripComments, substituteBuiltinEnv, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, unwrapEscapes, validateDeclaredHost, validateHost, writeRunRecord };\n\n//# sourceMappingURL=index.mjs.map"],"names":[],"mappings":";;;;;;AAIA,MAAM,aAAa,UAAU,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;AACnF,SAAS,eAAe,aAAa,MAAM;CAC1C,OAAO,mBAAmB,WAAW,aAAa,IAAI;AACvD;AACA,SAAS,wBAAwB,aAAa,MAAM;CACnD,MAAM,KAAK,KAAK,cAAc,eAAe,aAAa,KAAK,IAAI,IAAI,KAAK,MAAM,KAAK;CACvF,MAAM,OAAO,KAAK,gBAAgB,OAAO,KAAK,KAAK;CACnD,IAAI,KAAK,QAAQ,OAAO;EACvB,MAAM;EACN;EACA;EACA,MAAM,KAAK,QAAQ,KAAK;EACxB,WAAW,KAAK,OAAO;EACvB,aAAa,KAAK,eAAe;EACjC,kBAAkB,KAAK,oBAAoB;CAC5C;CACA,OAAO;EACN,MAAM;EACN;EACA;EACA,MAAM,KAAK,QAAQ,KAAK;EACxB,MAAM,gBAAgB,aAAa,KAAK,MAAM;GAC7C,UAAU;GACV,OAAO,MAAM,QAAQ,KAAK,CAAC;EAC5B,CAAC;EACD,iBAAiB,KAAK;EACtB,aAAa,KAAK,eAAe;EACjC,kBAAkB,KAAK,oBAAoB;CAC5C;AACD;;;AAGA,eAAe,WAAW,QAAQ,QAAQ;CACzC,MAAM,SAAS;EACd,SAAS,CAAC;EACV,UAAU,CAAC;EACX,UAAU,CAAC;CACZ;CACA,KAAK,MAAM,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AM,2BAA2B,CAAC,CAAC;EACxC,kBAAkB;CACnB,EAAE;AACH","debug_id":"ed6e9a99-bbeb-54b3-986e-46c7a47cc5bc"}
|
|
@@ -0,0 +1,241 @@
|
|
|
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]="12291c6c-c10c-513b-bb73-4a9e8362c0b4")}catch(e){}}();
|
|
3
|
+
import { A as readProjectName, B as validateDeclaredHost, C as outputSitesOf, D as processResolveEnv, E as probeRun, F as resolvePluginContributions, I as resolveRunnerModule, L as runRecordOutputSource, M as renderTokens, N as resolveHostOutputs, O as producerOutputsSchemas, R as runnerOutputsSchema, S as outputRefsOf, V as validateHost, _ as isToken, a as collectTokenSites, b as memberForRef, f as envSitesOf, l as describeToken, m as formatPath, o as compoundOutputSource, p as findDeadConnectConfig, s as declaredHostSchemas, u as drivesSchema, v as loadHost, w as planCompound, y as loadProducers } from "./compound-B6RZMA0Y-Cv3XMQ3Y.mjs";
|
|
4
|
+
import { a as mergeDrivePlan, n as explainDrivePlan } from "./dist-CCLkwpTS.mjs";
|
|
5
|
+
//#region src/services/run/explain.ts
|
|
6
|
+
const TOPICS = ["drives", "outputs"];
|
|
7
|
+
async function loadView(projectRoot, name) {
|
|
8
|
+
const loaded = await loadHost(projectRoot, name);
|
|
9
|
+
const specifier = loaded.host.runner.module;
|
|
10
|
+
const runner = await resolveRunnerModule(projectRoot, specifier);
|
|
11
|
+
const file = `hosts/${name}/host.js`;
|
|
12
|
+
if (runner.kind !== "compound") {
|
|
13
|
+
const producers = await loadProducers(projectRoot, outputRefsOf(loaded.host));
|
|
14
|
+
validateDeclaredHost(runner, specifier, loaded.host, file, { outputsSchemaOf: producerOutputsSchemas(producers) });
|
|
15
|
+
const source = runRecordOutputSource(projectRoot, {
|
|
16
|
+
consumer: name,
|
|
17
|
+
producers,
|
|
18
|
+
projectName: readProjectName(projectRoot)
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
host: loaded.host,
|
|
22
|
+
runner,
|
|
23
|
+
specifier,
|
|
24
|
+
file,
|
|
25
|
+
source
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
validateDeclaredHost(runner, specifier, loaded.host, file);
|
|
29
|
+
validateHost(runner, specifier, loaded.host, file, { tokens: "allow" });
|
|
30
|
+
const children = declaredHostSchemas.childrenSchema.parse(loaded.host.children);
|
|
31
|
+
const members = [];
|
|
32
|
+
for (const [key, wrapper] of Object.entries(children)) {
|
|
33
|
+
const base = (await loadHost(projectRoot, wrapper.host)).host;
|
|
34
|
+
const reactor = wrapper.reactor ?? base.reactor;
|
|
35
|
+
const config = wrapper.config ?? base.config;
|
|
36
|
+
const host = {
|
|
37
|
+
name: base.name,
|
|
38
|
+
runner: {
|
|
39
|
+
...base.runner,
|
|
40
|
+
...wrapper.runner
|
|
41
|
+
},
|
|
42
|
+
...config !== void 0 ? { config } : {},
|
|
43
|
+
...reactor !== void 0 ? { reactor } : {}
|
|
44
|
+
};
|
|
45
|
+
const memberSpecifier = host.runner.module;
|
|
46
|
+
members.push({
|
|
47
|
+
key,
|
|
48
|
+
wrapper,
|
|
49
|
+
host,
|
|
50
|
+
runner: await resolveRunnerModule(projectRoot, memberSpecifier),
|
|
51
|
+
specifier: memberSpecifier,
|
|
52
|
+
file: `hosts/${wrapper.host}/host.js`,
|
|
53
|
+
configWhere: wrapper.config !== void 0 ? `hosts/${name}/host.js (children.${key}.config)` : `hosts/${wrapper.host}/host.js`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const refs = members.map((m) => ({
|
|
57
|
+
key: m.key,
|
|
58
|
+
host: m.wrapper.host
|
|
59
|
+
}));
|
|
60
|
+
for (const m of members) validateDeclaredHost(m.runner, m.specifier, m.host, m.file, { outputsSchemaOf: (ref) => {
|
|
61
|
+
const target = memberForRef(ref, refs);
|
|
62
|
+
if ("error" in target) return { error: target.error };
|
|
63
|
+
const producer = members.find((p) => p.key === target.key);
|
|
64
|
+
return producer ? runnerOutputsSchema(producer.runner, producer.specifier, `member "${producer.key}"`) : { error: `names member "${target.key}", which is not declared.` };
|
|
65
|
+
} });
|
|
66
|
+
const probe = probeRun(projectRoot, loaded.host.name, readProjectName(projectRoot));
|
|
67
|
+
const live = /* @__PURE__ */ new Map();
|
|
68
|
+
if (probe.status === "live") for (const [key, member] of Object.entries(probe.record.members ?? {})) live.set(key, member.outputs);
|
|
69
|
+
const source = probe.status === "live" ? compoundOutputSource(refs, live, loaded.host.name) : void 0;
|
|
70
|
+
return {
|
|
71
|
+
host: loaded.host,
|
|
72
|
+
runner,
|
|
73
|
+
specifier,
|
|
74
|
+
file,
|
|
75
|
+
members,
|
|
76
|
+
source
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** A token's value from running producers, or undefined (producer not
|
|
80
|
+
* running, or the token reads the environment: `$env` values may be
|
|
81
|
+
* secrets, so explain never prints them). */
|
|
82
|
+
function currentValue(token, source) {
|
|
83
|
+
if (!source) return void 0;
|
|
84
|
+
if (collectTokenSites(token).some((site) => site.key === "$env")) return;
|
|
85
|
+
try {
|
|
86
|
+
return resolveHostOutputs(token, { outputs: source });
|
|
87
|
+
} catch {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function explainHost(options) {
|
|
92
|
+
if (!TOPICS.includes(options.topic)) throw new Error(`Unknown --explain topic "${options.topic}" (supported: ${TOPICS.join(", ")}).`);
|
|
93
|
+
const projectRoot = process.cwd();
|
|
94
|
+
const view = await loadView(projectRoot, options.host);
|
|
95
|
+
if (options.topic === "outputs") {
|
|
96
|
+
explainOutputs(options.host, view);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (view.members) {
|
|
100
|
+
const verb = view.host.runner.defaultVerb ?? "run";
|
|
101
|
+
for (const m of view.members) await explainDrives(projectRoot, `${options.host} › ${m.key} (${m.wrapper.host})`, m.host, verb, m.file, m.configWhere, view.source);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
await explainDrives(projectRoot, options.host, view.host, "run", view.file, view.file, view.source);
|
|
105
|
+
}
|
|
106
|
+
async function explainDrives(projectRoot, label, host, verb, where, configWhere, source) {
|
|
107
|
+
const entries = host.runner.plugins ?? [];
|
|
108
|
+
const contributions = entries.length > 0 ? await resolvePluginContributions(projectRoot, verb, entries, where) : {
|
|
109
|
+
drives: [],
|
|
110
|
+
unresolved: []
|
|
111
|
+
};
|
|
112
|
+
const contributed = contributions.drives.map(({ declaration, source }) => {
|
|
113
|
+
const parsed = drivesSchema.safeParse([declaration]);
|
|
114
|
+
if (!parsed.success) throw new Error(`${where}: plugin "${source}" contributes an invalid drive declaration.`);
|
|
115
|
+
return {
|
|
116
|
+
declaration: parsed.data[0],
|
|
117
|
+
source
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
const rawDrives = host.reactor?.drives ?? [];
|
|
121
|
+
let listed = rawDrives;
|
|
122
|
+
let listNote;
|
|
123
|
+
if (isToken(rawDrives)) {
|
|
124
|
+
const value = currentValue(rawDrives, source);
|
|
125
|
+
listed = Array.isArray(value) ? value : [];
|
|
126
|
+
listNote = ` reactor.drives ← «${describeToken(rawDrives)}»${Array.isArray(value) ? " (rendered from the running producer's outputs)" : " (rendered at ph run from the producer's live outputs; its producer is not running now, so the plan below leaves them out)"}`;
|
|
127
|
+
}
|
|
128
|
+
const parsed = drivesSchema.safeParse(renderTokens(listed));
|
|
129
|
+
if (!parsed.success && listNote === void 0) throw parsed.error;
|
|
130
|
+
const declared = parsed.success ? parsed.data : [];
|
|
131
|
+
console.log(`[${label}]`);
|
|
132
|
+
if (listNote) console.log(listNote);
|
|
133
|
+
if (!parsed.success) console.log(` the rendered drives fail the drive schema (ph run rejects them): ${parsed.error.issues.map((i) => `${i.path.map(String).join(".") || "<root>"}: ${i.message}`).join("; ")}`);
|
|
134
|
+
console.log(explainDrivePlan(mergeDrivePlan(projectRoot, declared, contributed)));
|
|
135
|
+
for (const module of contributions.unresolved) {
|
|
136
|
+
const entry = entries.map((e) => typeof e === "string" ? { module: e } : e).find((e) => e.module === module);
|
|
137
|
+
const drive = entry && "config" in entry ? entry.config?.drive : void 0;
|
|
138
|
+
const attached = typeof drive === "string" ? ` attaches ${drive}` : isToken(drive) ? ` attaches «${describeToken(drive)}»` : "";
|
|
139
|
+
console.log(` (browser plugin ${module}: not resolvable from the project tree)${attached}`);
|
|
140
|
+
}
|
|
141
|
+
if (host.runner.module === "@powerhousedao/ph-cli/runners/connect") for (const warning of findDeadConnectConfig(host.config, host.runner.plugins, verb, configWhere)) console.warn(warning.message);
|
|
142
|
+
}
|
|
143
|
+
function outputKeys(runner) {
|
|
144
|
+
const schema = runner.outputsSchema;
|
|
145
|
+
if (typeof schema !== "object" || schema === null) return "(no outputs)";
|
|
146
|
+
const shape = "shape" in schema && typeof schema.shape === "object" && schema.shape ? Object.keys(schema.shape) : [];
|
|
147
|
+
return shape.length ? shape.join(", ") : "(declared)";
|
|
148
|
+
}
|
|
149
|
+
function printConsumes(host, indent, producerNote, source) {
|
|
150
|
+
const outputs = outputSitesOf(host);
|
|
151
|
+
const env = envSitesOf(host);
|
|
152
|
+
if (outputs.length === 0 && env.length === 0) {
|
|
153
|
+
console.log(`${indent}consumes: nothing (no $output or $env tokens)`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const valueLine = (token) => {
|
|
157
|
+
const value = currentValue(token, source);
|
|
158
|
+
if (value !== void 0) console.log(`${indent} = ${JSON.stringify(value)}`);
|
|
159
|
+
};
|
|
160
|
+
for (const site of outputs) {
|
|
161
|
+
const token = { $output: {
|
|
162
|
+
...site.ref,
|
|
163
|
+
path: site.outputPath
|
|
164
|
+
} };
|
|
165
|
+
console.log(`${indent}${site.path} ← ${describeToken(token)}${producerNote(site.ref.host, site.ref.member)}`);
|
|
166
|
+
valueLine(token);
|
|
167
|
+
}
|
|
168
|
+
for (const site of collectTokenSites(host)) {
|
|
169
|
+
if (site.scopes.length > 0 || site.position === "concat" || site.position === "over" || site.key !== "$concat" && site.key !== "$map") continue;
|
|
170
|
+
console.log(`${indent}${formatPath(site.path)} ← ${describeToken(site.token)}`);
|
|
171
|
+
valueLine(site.token);
|
|
172
|
+
}
|
|
173
|
+
const { env: processEnv } = processResolveEnv(process.cwd());
|
|
174
|
+
for (const site of env) {
|
|
175
|
+
const state = site.name === "userData" || site.name === "projectRoot" || processEnv?.[site.name] !== void 0 ? "set" : site.optional ? "unset: the property is omitted" : "UNSET: ph run fails";
|
|
176
|
+
console.log(`${indent}${site.path} ← $env ${site.name}${site.optional ? " (optional)" : ""} [${state}]`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function explainOutputs(name, view) {
|
|
180
|
+
if (!view.members) {
|
|
181
|
+
const source = view.source;
|
|
182
|
+
console.log(`[${name}] ${view.specifier}`);
|
|
183
|
+
console.log(` produces: ${outputKeys(view.runner)}`);
|
|
184
|
+
printConsumes(view.host, " ", (folder, member) => {
|
|
185
|
+
const ref = member === void 0 ? { host: folder } : {
|
|
186
|
+
host: folder,
|
|
187
|
+
member
|
|
188
|
+
};
|
|
189
|
+
return source?.lookup(ref).status === "available" ? ` (host "${folder}": running)` : ` (host "${folder}": not running; start it first: ph run ${folder})`;
|
|
190
|
+
}, source);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const members = view.members;
|
|
194
|
+
const refs = members.map((x) => ({
|
|
195
|
+
key: x.key,
|
|
196
|
+
host: x.wrapper.host
|
|
197
|
+
}));
|
|
198
|
+
const config = view.host.config;
|
|
199
|
+
const startOrder = typeof config === "object" && config !== null && "startOrder" in config && Array.isArray(config.startOrder) ? config.startOrder.filter((k) => typeof k === "string") : void 0;
|
|
200
|
+
const plan = planCompound(members.map((m) => ({
|
|
201
|
+
key: m.key,
|
|
202
|
+
host: m.wrapper.host,
|
|
203
|
+
refs: outputSitesOf(m.host).map(({ ref, path }) => ({
|
|
204
|
+
ref,
|
|
205
|
+
path
|
|
206
|
+
}))
|
|
207
|
+
})), startOrder);
|
|
208
|
+
console.log(`[${name}] start order (${plan.source === "tokens" ? "from the output tokens" : "config.startOrder, checked against the tokens"}):`);
|
|
209
|
+
plan.order.forEach((key, index) => {
|
|
210
|
+
const m = members.find((x) => x.key === key);
|
|
211
|
+
const needs = plan.edges.filter((e) => e.consumer === key).map((e) => e.producer);
|
|
212
|
+
console.log(` ${index + 1}. ${key} (${m?.wrapper.host ?? "?"})${needs.length ? ` after ${needs.join(", ")}` : ""}`);
|
|
213
|
+
});
|
|
214
|
+
console.log(" Ctrl-C stops members in reverse order (consumers first).");
|
|
215
|
+
for (const key of plan.order) {
|
|
216
|
+
const m = members.find((x) => x.key === key);
|
|
217
|
+
if (!m) continue;
|
|
218
|
+
console.log(`[${name} › ${key} (${m.wrapper.host})] ${m.specifier}`);
|
|
219
|
+
console.log(` produces: ${outputKeys(m.runner)}`);
|
|
220
|
+
printConsumes(m.host, " ", (folder, member) => {
|
|
221
|
+
const target = memberForRef(member === void 0 ? { host: folder } : {
|
|
222
|
+
host: folder,
|
|
223
|
+
member
|
|
224
|
+
}, refs);
|
|
225
|
+
return "key" in target ? ` (member "${target.key}", live outputs)` : "";
|
|
226
|
+
}, view.source);
|
|
227
|
+
}
|
|
228
|
+
const own = {
|
|
229
|
+
...view.host,
|
|
230
|
+
children: void 0
|
|
231
|
+
};
|
|
232
|
+
if (outputSitesOf(own).length > 0 || envSitesOf(own).length > 0) {
|
|
233
|
+
console.log(`[${name}] the compound's own fields:`);
|
|
234
|
+
printConsumes(own, " ", () => "");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { explainHost };
|
|
239
|
+
|
|
240
|
+
//# sourceMappingURL=explain-DUXbB9jf.mjs.map
|
|
241
|
+
//# debugId=12291c6c-c10c-513b-bb73-4a9e8362c0b4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain-DUXbB9jf.mjs","sources":["../src/services/run/explain.ts"],"sourcesContent":["import {\n collectTokenSites,\n compoundOutputSource,\n CONNECT_RUNNER,\n declaredHostSchemas,\n describeToken,\n drivesSchema,\n envSitesOf,\n explainDrivePlan,\n findDeadConnectConfig,\n formatPath,\n isToken,\n loadHost,\n loadProducers,\n memberForRef,\n mergeDrivePlan,\n outputRefsOf,\n outputSitesOf,\n planCompound,\n probeRun,\n processResolveEnv,\n producerOutputsSchemas,\n readProjectName,\n renderTokens,\n resolveHostOutputs,\n resolvePluginContributions,\n resolveRunnerModule,\n runnerOutputsSchema,\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, the compound\n * start order the tokens imply, which 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 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 /** 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 const loaded = await loadHost(projectRoot, name);\n const specifier = loaded.host.runner.module;\n const runner = await resolveRunnerModule(projectRoot, specifier);\n const file = `hosts/${name}/host.js`;\n if (runner.kind !== \"compound\") {\n const producers = await loadProducers(\n projectRoot,\n outputRefsOf(loaded.host),\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 { host: loaded.host, runner, specifier, file, source };\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 base = (await loadHost(projectRoot, wrapper.host)).host;\n const reactor = wrapper.reactor ?? base.reactor;\n const config = wrapper.config ?? base.config;\n const host: ReactorView = {\n name: base.name,\n runner: { ...base.runner, ...wrapper.runner },\n ...(config !== undefined ? { config } : {}),\n ...(reactor !== undefined ? { reactor } : {}),\n };\n const memberSpecifier = host.runner.module;\n members.push({\n key,\n wrapper,\n host,\n runner: await resolveRunnerModule(projectRoot, memberSpecifier),\n specifier: memberSpecifier,\n file: `hosts/${wrapper.host}/host.js`,\n configWhere:\n wrapper.config !== undefined\n ? `hosts/${name}/host.js (children.${key}.config)`\n : `hosts/${wrapper.host}/host.js`,\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 loaded.host.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 { host: loaded.host, runner, specifier, file, members, source };\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,\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,\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 projectRoot: string,\n label: string,\n host: ReactorView,\n verb: string,\n where: string,\n configWhere: string,\n source?: OutputSource,\n): Promise<void> {\n const entries: PluginEntryData[] = host.runner.plugins ?? [];\n const contributions =\n entries.length > 0\n ? await resolvePluginContributions(projectRoot, 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 = site.name === \"userData\" || site.name === \"projectRoot\";\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\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 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 console.log(\n `[${name}] start order (${plan.source === \"tokens\" ? \"from the output tokens\" : \"config.startOrder, checked against the tokens\"}):`,\n );\n plan.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(\", \")}` : \"\"}`,\n );\n });\n console.log(\" Ctrl-C stops members in reverse order (consumers first).\");\n for (const key of plan.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 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":";;;;;AAyDA,MAAM,SAAS,CAAC,UAAU,SAAS;AAoCnC,eAAe,SACb,aACA,MACqB;CACrB,MAAM,SAAS,MAAM,SAAS,aAAa,IAAI;CAC/C,MAAM,YAAY,OAAO,KAAK,OAAO;CACrC,MAAM,SAAS,MAAM,oBAAoB,aAAa,SAAS;CAC/D,MAAM,OAAO,SAAS,KAAK;CAC3B,IAAI,OAAO,SAAS,YAAY;EAC9B,MAAM,YAAY,MAAM,cACtB,aACA,aAAa,OAAO,IAAI,CAC1B;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;GAAE,MAAM,OAAO;GAAM;GAAQ;GAAW;GAAM;EAAO;CAC9D;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,QAAQ,MAAM,SAAS,aAAa,QAAQ,IAAI,EAAA,CAAG;EACzD,MAAM,UAAU,QAAQ,WAAW,KAA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AAS,KAAK,WAAW,GAAG,CAAC,CAAC,SAAS,GAAG;EAC/D,QAAQ,IAAI,IAAI,KAAK,6BAA6B;EAClD,cAAc,KAAK,YAAY,EAAE;CACnC;AACF","debug_id":"12291c6c-c10c-513b-bb73-4a9e8362c0b4"}
|
|
@@ -1,6 +1,9 @@
|
|
|
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]="9447b850-b9e5-5086-9f44-7f1ebc256fd9")}catch(e){}}();
|
|
3
|
+
import { t as isUniformRunnersEnabled } from "./feature-flags-xwqcHEWC.mjs";
|
|
4
|
+
import { T as probeHostsFolder } from "./compound-B6RZMA0Y-Cv3XMQ3Y.mjs";
|
|
3
5
|
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BOHBmThq.mjs";
|
|
6
|
+
import { t as startGenerateHosts } from "./generate-hosts-BFmPIW2X.mjs";
|
|
4
7
|
import { generateAll } from "@powerhousedao/codegen";
|
|
5
8
|
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
6
9
|
import { extractAllDocuments, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
@@ -24,9 +27,10 @@ async function startGenerateAll(args, projectDir) {
|
|
|
24
27
|
await generateAll(project);
|
|
25
28
|
await project.save();
|
|
26
29
|
await warnSubgraphTypeConflicts(projectDir);
|
|
30
|
+
if (isUniformRunnersEnabled() && probeHostsFolder(projectDir).kind === "present" && !await startGenerateHosts(projectDir)) process.exitCode = 1;
|
|
27
31
|
}
|
|
28
32
|
//#endregion
|
|
29
33
|
export { startGenerateAll };
|
|
30
34
|
|
|
31
|
-
//# sourceMappingURL=generate-all-
|
|
32
|
-
//# debugId=
|
|
35
|
+
//# sourceMappingURL=generate-all-Dgyy_kT-.mjs.map
|
|
36
|
+
//# debugId=9447b850-b9e5-5086-9f44-7f1ebc256fd9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-all-Dgyy_kT-.mjs","sources":["../src/services/generate-all.ts"],"sourcesContent":["import { generateAll } from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport { extractAllDocuments, saveSpec } from \"@powerhousedao/vetra/codegen\";\nimport { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport { isUniformRunnersEnabled } from \"../utils/feature-flags.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { startGenerateHosts } from \"./generate-hosts.js\";\n\nexport async function startGenerateAll(\n args: { extract?: boolean },\n projectDir: string,\n) {\n const project = buildTsMorphProject(projectDir);\n if (args.extract) {\n const all = extractAllDocuments(project);\n for (const doc of [\n ...all.documentModels,\n ...all.editors,\n ...all.processors,\n ...all.subgraphs,\n ...all.apps,\n ]) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n await generateAll(project);\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n if (\n isUniformRunnersEnabled() &&\n probeHostsFolder(projectDir).kind === \"present\" &&\n !(await startGenerateHosts(projectDir))\n ) {\n process.exitCode = 1;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAQA,eAAsB,iBACpB,MACA,YACA;CACA,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,KAAK,SAAS;EAChB,MAAM,MAAM,oBAAoB,OAAO;EACvC,KAAK,MAAM,OAAO;GAChB,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;GACP,GAAG,IAAI;EACT,GAAG;GACD,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,MAAM,YAAY,OAAO;CACzB,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;CAC1C,IACE,wBAAwB,KACxB,iBAAiB,UAAU,CAAC,CAAC,SAAS,aACtC,CAAE,MAAM,mBAAmB,UAAU,GAErC,QAAQ,WAAW;AAEvB","debug_id":"9447b850-b9e5-5086-9f44-7f1ebc256fd9"}
|
|
@@ -1,13 +1,15 @@
|
|
|
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 { c as strictObject, l as string, n as array, o as number, r as boolean } from "./schemas-
|
|
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]="83a7fd74-e533-5c28-9ec4-ec39f4e5c0f1")}catch(e){}}();
|
|
3
|
+
import { c as strictObject, l as string, n as array, o as number, r as boolean, u as union } from "./schemas-D5N5U_Mf.mjs";
|
|
4
4
|
import "node:module";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import "node:child_process";
|
|
8
|
+
import { isPassthroughImageRef } from "@powerhousedao/shared/connect/image-ref";
|
|
8
9
|
import "node:url";
|
|
10
|
+
import { mapBackgroundImages, validateBackground } from "@powerhousedao/shared/connect";
|
|
9
11
|
import { deflateSync } from "node:zlib";
|
|
10
|
-
//#region ../../packages/desktop/dist/shell-
|
|
12
|
+
//#region ../../packages/desktop/dist/shell-CfgLhSXp.mjs
|
|
11
13
|
/**
|
|
12
14
|
* `hosts/desktop/app.json` — the builder's desktop identity (phase 7, mode 1:
|
|
13
15
|
* the builder ships under THEIR identity without writing Rust). It is the ONE
|
|
@@ -20,8 +22,72 @@ const windowSchema = strictObject({
|
|
|
20
22
|
title: string().min(1).optional(),
|
|
21
23
|
width: number().int().positive().optional(),
|
|
22
24
|
height: number().int().positive().optional(),
|
|
23
|
-
resizable: boolean().optional()
|
|
25
|
+
resizable: boolean().optional(),
|
|
26
|
+
/** Smallest size the window can be dragged to (logical pixels). */
|
|
27
|
+
minWidth: number().int().positive().optional(),
|
|
28
|
+
minHeight: number().int().positive().optional()
|
|
24
29
|
}).optional();
|
|
30
|
+
const cssColorSchema = string().regex(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, "use a hex color (#rgb, #rgba, #rrggbb or #rrggbbaa)");
|
|
31
|
+
/** The loading page's colors. */
|
|
32
|
+
const loadingColorsSchema = strictObject({
|
|
33
|
+
/** Page background (default #0f1115). */
|
|
34
|
+
background: cssColorSchema.nullable().optional(),
|
|
35
|
+
/** Status text color (default #e6e8eb). */
|
|
36
|
+
color: cssColorSchema.nullable().optional(),
|
|
37
|
+
/** The pulsing status dot (default #4ade80). */
|
|
38
|
+
accent: cssColorSchema.nullable().optional()
|
|
39
|
+
});
|
|
40
|
+
/** The loading page's look, so the window opens in the app's own colors
|
|
41
|
+
* instead of the default dark page. Every field is optional, and `null`
|
|
42
|
+
* means the default (the scaffold lists the fields that way). */
|
|
43
|
+
const loadingSchema = loadingColorsSchema.extend({
|
|
44
|
+
/** Status line under the art (default "Starting <productName>…"). */
|
|
45
|
+
message: string().min(1).nullable().optional(),
|
|
46
|
+
/** Colors for `prefers-color-scheme: dark`; without it the page keeps
|
|
47
|
+
* the light colors in both schemes. */
|
|
48
|
+
dark: loadingColorsSchema.nullable().optional(),
|
|
49
|
+
/** Deprecated: a decoration pinned to the bottom-right corner, relative
|
|
50
|
+
* to app.json, with `artDark` its dark-scheme counterpart. Superseded by
|
|
51
|
+
* the top-level `background`, which ignores these when set. */
|
|
52
|
+
art: string().min(1).nullable().optional(),
|
|
53
|
+
artDark: string().min(1).nullable().optional()
|
|
54
|
+
}).nullable().optional();
|
|
55
|
+
const imageRefSchema = string().min(1);
|
|
56
|
+
const schemedImageSchema = union([imageRefSchema, strictObject({
|
|
57
|
+
light: imageRefSchema,
|
|
58
|
+
dark: imageRefSchema.nullable().optional()
|
|
59
|
+
})]);
|
|
60
|
+
const lengthSchema = union([number(), string().min(1)]).nullable().optional();
|
|
61
|
+
const edgesSchema = strictObject({
|
|
62
|
+
top: lengthSchema,
|
|
63
|
+
right: lengthSchema,
|
|
64
|
+
bottom: lengthSchema,
|
|
65
|
+
left: lengthSchema
|
|
66
|
+
}).nullable().optional();
|
|
67
|
+
const backgroundLayerSchema = strictObject({
|
|
68
|
+
src: schemedImageSchema,
|
|
69
|
+
position: edgesSchema,
|
|
70
|
+
width: lengthSchema,
|
|
71
|
+
height: lengthSchema,
|
|
72
|
+
minWidth: lengthSchema,
|
|
73
|
+
minHeight: lengthSchema,
|
|
74
|
+
maxWidth: lengthSchema,
|
|
75
|
+
maxHeight: lengthSchema,
|
|
76
|
+
opacity: number().min(0).max(1).nullable().optional(),
|
|
77
|
+
fade: edgesSchema
|
|
78
|
+
});
|
|
79
|
+
const backgroundSchema = union([imageRefSchema, strictObject({
|
|
80
|
+
color: union([string().min(1), strictObject({
|
|
81
|
+
light: string().min(1),
|
|
82
|
+
dark: string().min(1).nullable().optional()
|
|
83
|
+
})]).nullable().optional(),
|
|
84
|
+
layers: array(backgroundLayerSchema)
|
|
85
|
+
})]).superRefine((background, ctx) => {
|
|
86
|
+
for (const problem of validateBackground(background, "background")) ctx.addIssue({
|
|
87
|
+
code: "custom",
|
|
88
|
+
message: problem
|
|
89
|
+
});
|
|
90
|
+
}).nullable().optional();
|
|
25
91
|
const fileAssociationSchema = strictObject({
|
|
26
92
|
/** Extensions WITHOUT the leading dot ("phd", not ".phd"). */
|
|
27
93
|
ext: array(string().min(1).regex(/^[^.]/, "drop the leading dot")).min(1),
|
|
@@ -47,6 +113,18 @@ const appJsonSchema = strictObject({
|
|
|
47
113
|
/** Single source image (square PNG, 1024×1024 recommended); the icon set
|
|
48
114
|
* for every platform is generated from it via `tauri icon`. */
|
|
49
115
|
icon: string().min(1),
|
|
116
|
+
/** The loading page's background: images positioned and sized over a
|
|
117
|
+
* page colour (`{ color, layers }`), or one image pinned bottom-right.
|
|
118
|
+
* The status line stays centred above them. `ph generate desktop-shell`
|
|
119
|
+
* copies Connect's `connect.branding.homeBackground` here. null or
|
|
120
|
+
* omitted: the app icon (or `splash`) above the status line. */
|
|
121
|
+
background: backgroundSchema,
|
|
122
|
+
/** Deprecated in favour of `background`: a wide splash image shown above
|
|
123
|
+
* the status line instead of the square icon. Relative to this file. */
|
|
124
|
+
splash: string().min(1).nullable().optional(),
|
|
125
|
+
/** Deprecated with `splash`: its `prefers-color-scheme: dark` variant. */
|
|
126
|
+
splashDark: string().min(1).nullable().optional(),
|
|
127
|
+
loading: loadingSchema,
|
|
50
128
|
window: windowSchema,
|
|
51
129
|
fileAssociations: array(fileAssociationSchema).optional(),
|
|
52
130
|
shell: shellSourceSchema
|
|
@@ -54,6 +132,19 @@ const appJsonSchema = strictObject({
|
|
|
54
132
|
const APP_JSON_FILE = "app.json";
|
|
55
133
|
//#endregion
|
|
56
134
|
//#region ../../packages/desktop/dist/index.mjs
|
|
135
|
+
/**
|
|
136
|
+
* A background whose project-relative paths are rewritten to be relative to
|
|
137
|
+
* another directory (powerhouse.config.json's root -> hosts/desktop, where
|
|
138
|
+
* app.json resolves them from). URLs and data URIs are left as they are.
|
|
139
|
+
*/
|
|
140
|
+
function rebaseBackground(background, fromDir, toDir) {
|
|
141
|
+
const rebase = (ref) => {
|
|
142
|
+
if (isPassthroughImageRef(ref)) return ref;
|
|
143
|
+
const rel = path.relative(toDir, path.resolve(fromDir, ref)).split(path.sep).join("/");
|
|
144
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
145
|
+
};
|
|
146
|
+
return typeof background === "string" ? rebase(background) : mapBackgroundImages(background, rebase);
|
|
147
|
+
}
|
|
57
148
|
/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid
|
|
58
149
|
* source. Pure Node (zlib); no binary asset ships in the package. The builder
|
|
59
150
|
* replaces it with their real 1024×1024 artwork. */
|
|
@@ -136,6 +227,8 @@ function scaffoldDesktopShell(hostDir, options) {
|
|
|
136
227
|
identifier: options.identifier,
|
|
137
228
|
productName: options.productName,
|
|
138
229
|
icon: `./${iconFile}`,
|
|
230
|
+
background: options.background ?? null,
|
|
231
|
+
loading: null,
|
|
139
232
|
window: {
|
|
140
233
|
title: options.productName,
|
|
141
234
|
width: 1440,
|
|
@@ -183,6 +276,15 @@ function scaffoldDesktopShell(hostDir, options) {
|
|
|
183
276
|
function projectSlug(pkgName) {
|
|
184
277
|
return (pkgName ?? "app").replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "app";
|
|
185
278
|
}
|
|
279
|
+
/** `connect.home.background` of the project's powerhouse.config.json, if
|
|
280
|
+
* any (absent or unreadable config: none). */
|
|
281
|
+
function readHomeBackground(cwd) {
|
|
282
|
+
try {
|
|
283
|
+
return JSON.parse(fs.readFileSync(path.join(cwd, "powerhouse.config.json"), "utf8")).connect?.home?.background ?? null;
|
|
284
|
+
} catch {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
186
288
|
/** `ph generate desktop-shell`: write hosts/desktop/app.json + a placeholder
|
|
187
289
|
* icon + .gitignore. Defaults product name / identifier from the project. */
|
|
188
290
|
function startGenerateDesktopShell(args, cwd) {
|
|
@@ -194,13 +296,16 @@ function startGenerateDesktopShell(args, cwd) {
|
|
|
194
296
|
const productName = args.name ?? pkgName?.replace(/^@[^/]+\//, "") ?? "App";
|
|
195
297
|
const identifier = args.identifier ?? `inc.powerhouse.desktop.${slug}`;
|
|
196
298
|
const hostDir = path.join(cwd, "hosts", "desktop");
|
|
299
|
+
const homeBackground = readHomeBackground(cwd);
|
|
197
300
|
const result = scaffoldDesktopShell(hostDir, {
|
|
198
301
|
identifier,
|
|
199
302
|
productName,
|
|
200
|
-
force: args.force
|
|
303
|
+
force: args.force,
|
|
304
|
+
background: homeBackground ? rebaseBackground(homeBackground, cwd, hostDir) : null
|
|
201
305
|
});
|
|
202
306
|
const rel = (p) => path.relative(cwd, p).replace(/\\/g, "/");
|
|
203
307
|
for (const f of result.created) console.log(` created ${rel(f)}`);
|
|
308
|
+
if (homeBackground && result.created.some((f) => f.endsWith("app.json"))) console.log(" copied connect.home.background -> hosts/desktop/app.json background");
|
|
204
309
|
for (const f of result.skipped) console.log(` skipped ${rel(f)} (exists — pass --force to overwrite)`);
|
|
205
310
|
if (!fs.existsSync(path.join(hostDir, "host.js"))) console.log("\nNote: hosts/desktop/host.js not found. Add a desktop host (see the desktop topology from `ph init`) so `ph run desktop` can supervise the stack; app.json then gives it a native window.");
|
|
206
311
|
console.log(`\nIdentity: ${productName} (${identifier}).\n• Replace hosts/desktop/icon.png with your 1024×1024 icon.\n• \`ph run desktop dev\` opens the native window (needs Rust + the Tauri CLI).\n• \`ph run desktop build\` produces installers for this OS.`);
|
|
@@ -208,5 +313,5 @@ function startGenerateDesktopShell(args, cwd) {
|
|
|
208
313
|
//#endregion
|
|
209
314
|
export { startGenerateDesktopShell };
|
|
210
315
|
|
|
211
|
-
//# sourceMappingURL=generate-desktop-shell-
|
|
212
|
-
//# debugId=
|
|
316
|
+
//# sourceMappingURL=generate-desktop-shell-Bj_3bJDL.mjs.map
|
|
317
|
+
//# debugId=83a7fd74-e533-5c28-9ec4-ec39f4e5c0f1
|