@powerhousedao/host-core 6.2.3-dev.100
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/LICENSE +661 -0
- package/dist/compound-DO_mvh0O.mjs +3296 -0
- package/dist/compound-DO_mvh0O.mjs.map +1 -0
- package/dist/compound-eW-6nGxK.d.mts +2509 -0
- package/dist/compound-eW-6nGxK.d.mts.map +1 -0
- package/dist/env-substitution-BXGohOGN.mjs +660 -0
- package/dist/env-substitution-BXGohOGN.mjs.map +1 -0
- package/dist/env-substitution-C_fVirPh.d.mts +17 -0
- package/dist/env-substitution-C_fVirPh.d.mts.map +1 -0
- package/dist/host-schemas-BM7F21lf.d.mts +2193 -0
- package/dist/host-schemas-BM7F21lf.d.mts.map +1 -0
- package/dist/index.d.mts +1304 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1181 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugins-Uk84BRay.d.mts +182 -0
- package/dist/plugins-Uk84BRay.d.mts.map +1 -0
- package/dist/plugins.d.mts +3 -0
- package/dist/plugins.mjs +174 -0
- package/dist/plugins.mjs.map +1 -0
- package/dist/projection.d.mts +651 -0
- package/dist/projection.d.mts.map +1 -0
- package/dist/projection.mjs +1633 -0
- package/dist/projection.mjs.map +1 -0
- package/dist/runners/compound.d.mts +286 -0
- package/dist/runners/compound.d.mts.map +1 -0
- package/dist/runners/compound.mjs +42 -0
- package/dist/runners/compound.mjs.map +1 -0
- package/dist/schema.d.mts +146 -0
- package/dist/schema.d.mts.map +1 -0
- package/dist/schema.mjs +98 -0
- package/dist/schema.mjs.map +1 -0
- package/package.json +67 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1304 @@
|
|
|
1
|
+
import { $ as HostDefinition, $t as TokenFor, A as knownVerbIssues, At as reactorBackendKindSchema, B as envSitesOf, Bt as ConcatToken, C as RunnerVerb, Ct as emittedHostSchemas, D as hostSchemaIssues, Dt as originOrUrlSchema, E as getVerb, Et as makeHostSchemas, F as DeclaredIssue, Ft as refineConnectReactor, G as CONNECT_PRIMARY_MESSAGE, Gt as OutputPath, H as outputSitesOf, Ht as ItemToken, I as OutputRef, It as refineStartOrder, J as CompoundHostInput, Jt as RefFn, K as ChildWrapper, Kt as OutputToken, L as OutputsSchemaLookup, Lt as runnerBaseSchema, M as resolveRunnerModule, Mt as reactorHostSchema, N as validateDeclaredHost, Nt as reactorProtocolSchema, O as isSchemaLike, Ot as placementKeyIssues, P as validateHost, Pt as reactorSchema, Q as HOST_NAME_PATTERN, Qt as Token, R as checkOutputPaths, Rt as runnerKindSchema, S as RunnerModule, St as emitHostJsonSchema, T as ValidateHostOptions, Tt as hostNameSchema, U as refKey, Ut as KeyToken, V as outputRefsOf, Vt as EnvToken, W as schemaAtPath, Wt as MapToken, X as HOST_NAME_MAX_LENGTH, Xt as TOKEN_KEYS, Y as CompoundWiring, Yt as TOKEN_ESCAPE_KEY, Z as HOST_NAME_MESSAGE, Zt as Template, _ as HostSchemaLike, _t as compoundWiringSchema, a as RunnerHandleData, an as envTokenable, at as ReactorConfig, b as RunnerError, bt as declaredHostSchemas, c as toStartedHandle, cn as isToken, ct as ReactorPackageConfig, d as BootCheckContext, dn as mapTokenSchema, dt as ReactorStorageConfig, en as TokenKey, et as HostSchemas, f as BootIssue, fn as outputTokenSchema, ft as RunnerBase, g as HostSchemaIssues, gn as tokenable, gt as compoundHostSchema, h as HostSchemaIssue, hn as tokenSchema, ht as childrenSchema, i as RunnerHandle, in as envTokenSchema, it as ReactorBackendKind, j as listVerbs, jt as reactorBackendSchema, k as kindShapeIssues, kt as profileSchema, l as MemberDraft, ln as itemTokenSchema, lt as ReactorProtocol, m as DeclaredHostOptions, mn as tokenKeyOf, mt as childWrapperSchema, n as RunCompoundResult, nn as TokenableSchema, nt as Profile, o as StartedHandle, on as findToken, ot as ReactorHost, p as CONNECT_RUNNER, pn as ref, pt as RunnerKind, q as CompoundHost, qt as RecordMapToken, r as runCompound, rn as concatTokenSchema, rt as ReactorBackend, s as runnerHandleSchema, sn as forbidRef, st as ReactorHostInput, t as RunCompoundOptions, tn as TokenMode, tt as PlacementKeyIssue, u as applyChildWrapper, un as keyTokenSchema, ut as ReactorRemoteConfig, v as ONE_SHOT_VERBS, vt as connectReactorIssues, w as SchemaIssue, wt as genericCompoundHostSchema, x as RunnerIssue, xt as defineHostSchemas, y as RunnerContext, yt as declaredGenericCompoundHostSchema, z as checkTokenSites, zt as ArrayMapToken } from "./compound-eW-6nGxK.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SwitchboardDrive, driveAddressMessage, switchboardOfDrive } from "@powerhousedao/shared/host-tokens";
|
|
4
|
+
import { ORIGIN_PLACEHOLDER, SWITCHBOARD_PROXY_PATHS, isHtmlNavigation, isOriginPlaceholderUrl, isSwitchboardProxyPath, resolveOriginPlaceholders, toOriginPlaceholder, withOriginPlaceholders } from "@powerhousedao/shared/connect/origin-placeholder";
|
|
5
|
+
import { PHConnectCollection, PHConnectDefaultDrive, PHConnectRuntimeConfig, PHConnectRuntimeDefaultDrive } from "@powerhousedao/shared/clis";
|
|
6
|
+
//#region src/host-loader.d.ts
|
|
7
|
+
export declare class HostLoadError extends Error {
|
|
8
|
+
constructor(message: string, hint?: string);
|
|
9
|
+
}
|
|
10
|
+
type HostsFolderStatus = {
|
|
11
|
+
kind: "absent";
|
|
12
|
+
} | {
|
|
13
|
+
kind: "empty";
|
|
14
|
+
dir: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "present";
|
|
17
|
+
dir: string;
|
|
18
|
+
hosts: string[];
|
|
19
|
+
};
|
|
20
|
+
/** A `hosts/` folder with no `<name>/host.js` inside is "empty" — the guard
|
|
21
|
+
* state: callers warn loudly and fall back to legacy rather than activating
|
|
22
|
+
* the new architecture off a stray `mkdir hosts`. */
|
|
23
|
+
export declare function probeHostsFolder(projectRoot: string): HostsFolderStatus;
|
|
24
|
+
/** The generated per-host token tree (`ph generate hosts`). */
|
|
25
|
+
export declare const OUTPUTS_FILE = "outputs.js";
|
|
26
|
+
/** Blank out `//` and block comments, keeping string and template literals
|
|
27
|
+
* (URLs contain `//`) and every newline, so line-anchored checks still see
|
|
28
|
+
* the code's own lines. A JSDoc `import("…")` type is a comment, not code. */
|
|
29
|
+
export declare function stripComments(source: string): string;
|
|
30
|
+
/** The imports a host file makes, after linting it. */
|
|
31
|
+
interface HostImports {
|
|
32
|
+
/** Sibling hosts whose `host.js` the file imports. */
|
|
33
|
+
hosts: string[];
|
|
34
|
+
/** Sibling hosts whose generated `outputs.js` the file imports. */
|
|
35
|
+
outputs: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Lints a host file and returns what it imports. Rejects every import
|
|
38
|
+
* except the project's powerhouse.config.json, SIBLING host files (R1:
|
|
39
|
+
* derived compositions) and sibling generated outputs.js token trees; any
|
|
40
|
+
* dynamic `import(...)` or `require(...)`; and any `process.` access.
|
|
41
|
+
* Source-level enforcement: the JSON round trip below is the hard gate; this
|
|
42
|
+
* one produces the better error. */
|
|
43
|
+
export declare function scanHostImports(rawSource: string, file: string): HostImports;
|
|
44
|
+
/** {@link scanHostImports}, returning only the sibling host names (for cycle
|
|
45
|
+
* detection). */
|
|
46
|
+
export declare function lintHostImports(rawSource: string, file: string): string[];
|
|
47
|
+
/** A generated `outputs.js` is plain data: no imports of any kind, no
|
|
48
|
+
* dynamic import/require, no `process.`. */
|
|
49
|
+
export declare function lintOutputsFile(rawSource: string, file: string): void;
|
|
50
|
+
/** Walks the sibling-import graph from `hostName`, linting every visited file
|
|
51
|
+
* (and every outputs.js it imports) and failing on a cycle (an ESM circular
|
|
52
|
+
* would otherwise surface as an undefined default export with no useful
|
|
53
|
+
* message). Returns the hosts whose outputs.js the graph imports, sorted. */
|
|
54
|
+
export declare function lintHostImportGraph(hostsDir: string, hostName: string): string[];
|
|
55
|
+
/** Returns the path of the first value that would not survive a JSON round
|
|
56
|
+
* trip, or undefined when the object is fully static. */
|
|
57
|
+
export declare function findNonStaticValue(value: unknown, trail?: string): string | undefined;
|
|
58
|
+
interface LoadedHost {
|
|
59
|
+
name: string;
|
|
60
|
+
dir: string;
|
|
61
|
+
file: string;
|
|
62
|
+
host: HostDefinition;
|
|
63
|
+
}
|
|
64
|
+
export declare function loadHost(projectRoot: string, hostName: string): Promise<LoadedHost>;
|
|
65
|
+
/** What `ph generate hosts` derives a host's outputs.js from, plus the hash
|
|
66
|
+
* of exactly those inputs (embedded in the file; the loader recomputes it). */
|
|
67
|
+
interface HostOutputsDescription {
|
|
68
|
+
/** The producer's folder name: the `host` of every `$output` token. */
|
|
69
|
+
host: string;
|
|
70
|
+
runnerModule: string;
|
|
71
|
+
/** JSON Schema of the runner's `outputsSchema` (output side, no `$schema`). */
|
|
72
|
+
outputsSchema: Record<string, unknown>;
|
|
73
|
+
/** Declared LOCAL drive slugs: `reactor.drives` without remote drives,
|
|
74
|
+
* plus drives the host's plugins contribute (any verb). Sorted, unique.
|
|
75
|
+
* These are the known keys of the `drives` record output. */
|
|
76
|
+
drives: string[];
|
|
77
|
+
hash: string;
|
|
78
|
+
}
|
|
79
|
+
/** The hash a generated outputs.js carries, or undefined. */
|
|
80
|
+
export declare function readOutputsFileHash(source: string): string | undefined;
|
|
81
|
+
/** sha256 over the canonical JSON of the generator's inputs. The host name
|
|
82
|
+
* is one: every token in the file carries it, so a copied or renamed host
|
|
83
|
+
* folder makes its outputs.js stale. */
|
|
84
|
+
export declare function computeOutputsHash(input: {
|
|
85
|
+
host: string;
|
|
86
|
+
runnerModule: string;
|
|
87
|
+
outputsSchema: Record<string, unknown>;
|
|
88
|
+
drives: readonly string[];
|
|
89
|
+
}): string;
|
|
90
|
+
/**
|
|
91
|
+
* Describes the outputs a host's creation produces, for `ph generate hosts`
|
|
92
|
+
* and the loader's staleness check: the runner's `outputsSchema` as JSON
|
|
93
|
+
* Schema and the host's declared local drives (the keys `drives.<slug>` of a
|
|
94
|
+
* switchboard-like runner). Returns undefined when the runner exports no
|
|
95
|
+
* `outputsSchema` (the host produces nothing a token can reference).
|
|
96
|
+
*
|
|
97
|
+
* Plugin-contributed drives are collected across every verb (verb scoping
|
|
98
|
+
* is ignored: a drive any verb serves is referenceable). Plugins the project
|
|
99
|
+
* tree cannot resolve contribute nothing, exactly as at boot. The implicit
|
|
100
|
+
* default drive a switchboard serves when it declares none is NOT a known
|
|
101
|
+
* key (it is not declared); reach it with a literal `$output` token.
|
|
102
|
+
*/
|
|
103
|
+
export declare function describeHostOutputs(projectRoot: string, hostName: string): Promise<HostOutputsDescription | undefined>;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/run-record-schema.d.ts
|
|
106
|
+
export declare const runRecordMemberSchema: z.ZodObject<{
|
|
107
|
+
host: z.ZodString;
|
|
108
|
+
runnerModule: z.ZodString;
|
|
109
|
+
kind: z.ZodEnum<{
|
|
110
|
+
compound: "compound";
|
|
111
|
+
reactor: "reactor";
|
|
112
|
+
}>;
|
|
113
|
+
verb: z.ZodString;
|
|
114
|
+
outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
115
|
+
}, z.core.$strict>;
|
|
116
|
+
export declare const runRecordSchema: z.ZodObject<{
|
|
117
|
+
version: z.ZodLiteral<2>;
|
|
118
|
+
host: z.ZodString;
|
|
119
|
+
projectName: z.ZodString;
|
|
120
|
+
kind: z.ZodEnum<{
|
|
121
|
+
compound: "compound";
|
|
122
|
+
reactor: "reactor";
|
|
123
|
+
}>;
|
|
124
|
+
verb: z.ZodString;
|
|
125
|
+
pid: z.ZodNumber;
|
|
126
|
+
startedAt: z.ZodString;
|
|
127
|
+
outputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
128
|
+
members: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
129
|
+
host: z.ZodString;
|
|
130
|
+
runnerModule: z.ZodString;
|
|
131
|
+
kind: z.ZodEnum<{
|
|
132
|
+
compound: "compound";
|
|
133
|
+
reactor: "reactor";
|
|
134
|
+
}>;
|
|
135
|
+
verb: z.ZodString;
|
|
136
|
+
outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
137
|
+
}, z.core.$strict>>>;
|
|
138
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
139
|
+
}, z.core.$strict>;
|
|
140
|
+
type RunRecord = z.infer<typeof runRecordSchema>;
|
|
141
|
+
type RunRecordMember = z.infer<typeof runRecordMemberSchema>;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/run-record.d.ts
|
|
144
|
+
/**
|
|
145
|
+
* Record I/O for `.ph/run/<host>.json`, keyed by host name so N hosts
|
|
146
|
+
* (vetra, desktop, …) coexist. The record shape is run-record-schema.ts (v2).
|
|
147
|
+
*/
|
|
148
|
+
type RunProbe = {
|
|
149
|
+
status: "none";
|
|
150
|
+
} | {
|
|
151
|
+
status: "stale";
|
|
152
|
+
record: RunRecord;
|
|
153
|
+
} | {
|
|
154
|
+
status: "live";
|
|
155
|
+
record: RunRecord;
|
|
156
|
+
} | {
|
|
157
|
+
status: "foreign";
|
|
158
|
+
record: RunRecord;
|
|
159
|
+
};
|
|
160
|
+
type Env$1 = Readonly<Record<string, string | undefined>>;
|
|
161
|
+
export declare function readRunRecord(projectDir: string, hostName: string, env?: Env$1): RunRecord | undefined;
|
|
162
|
+
/** Every valid v2 record under `.ph/run/` (invalid and v1 files skipped). */
|
|
163
|
+
export declare function listRunRecords(projectDir: string, env?: Env$1): RunRecord[];
|
|
164
|
+
/** The project identity the live/foreign probe compares: package.json
|
|
165
|
+
* `name`, else the folder name. */
|
|
166
|
+
export declare function readProjectName(projectDir: string): string;
|
|
167
|
+
export declare function writeRunRecord(projectDir: string, record: RunRecord): void;
|
|
168
|
+
export declare function clearRunRecord(projectDir: string, hostName: string, env?: Env$1): void;
|
|
169
|
+
export declare function isPidAlive(pid: number): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Decide whether the recorded instance is this project's live host.
|
|
172
|
+
*
|
|
173
|
+
* pid liveness alone proves nothing (pids are reused), and the recorded
|
|
174
|
+
* projectName is what separates "my instance" from "a different project that
|
|
175
|
+
* happens to hold this storage root" — the confusion the vetra lock exists to
|
|
176
|
+
* prevent. A stale record (dead pid) is reported so the caller can clear it; a
|
|
177
|
+
* foreign one (live pid, different project) is left alone.
|
|
178
|
+
*/
|
|
179
|
+
export declare function probeRun(projectDir: string, hostName: string, projectName: string, env?: Env$1): RunProbe;
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/spawn-host.d.ts
|
|
182
|
+
interface SpawnHostOptions {
|
|
183
|
+
projectRoot: string;
|
|
184
|
+
/** Folder name under hosts/. */
|
|
185
|
+
host: string;
|
|
186
|
+
/** The child's PH_USER_DATA_DIR (created if missing). */
|
|
187
|
+
dataDir: string;
|
|
188
|
+
verb?: string;
|
|
189
|
+
/** Merged over the clean base env; may not set PH_USER_DATA_DIR. */
|
|
190
|
+
env?: Record<string, string>;
|
|
191
|
+
/** ph-cli entry; default: the project's `@powerhousedao/ph-cli/dist/cli.mjs`. */
|
|
192
|
+
cli?: string;
|
|
193
|
+
readyTimeoutMs?: number;
|
|
194
|
+
stopTimeoutMs?: number;
|
|
195
|
+
/** Before ready: stop and reject. After: stop. */
|
|
196
|
+
signal?: AbortSignal;
|
|
197
|
+
onOutput?: (stream: "stdout" | "stderr", chunk: string) => void;
|
|
198
|
+
/** Appends both streams. */
|
|
199
|
+
logFile?: string;
|
|
200
|
+
}
|
|
201
|
+
interface HostExit {
|
|
202
|
+
code: number | null;
|
|
203
|
+
signal: NodeJS.Signals | null;
|
|
204
|
+
/** SIGKILL after stopTimeoutMs. */
|
|
205
|
+
forced: boolean;
|
|
206
|
+
}
|
|
207
|
+
interface SpawnedHost {
|
|
208
|
+
pid: number;
|
|
209
|
+
dataDir: string;
|
|
210
|
+
record: RunRecord;
|
|
211
|
+
outputs: Record<string, unknown> | undefined;
|
|
212
|
+
members: RunRecord["members"];
|
|
213
|
+
/** Resolves (never rejects) when the child exits. */
|
|
214
|
+
exited: Promise<HostExit>;
|
|
215
|
+
/** SIGTERM, SIGKILL after stopTimeoutMs, clear a leftover record. */
|
|
216
|
+
stop(): Promise<HostExit>;
|
|
217
|
+
}
|
|
218
|
+
type SpawnHostPhase = "exited" | "timeout" | "aborted";
|
|
219
|
+
/** The tail line before which a timed-out or aborted run's output is its own. */
|
|
220
|
+
export declare const SPAWN_STOPPING_NOTE = "spawnHost: stopping it";
|
|
221
|
+
export declare class SpawnHostError extends Error {
|
|
222
|
+
readonly phase: SpawnHostPhase;
|
|
223
|
+
readonly outputTail: string;
|
|
224
|
+
readonly exit?: HostExit | undefined;
|
|
225
|
+
constructor(message: string, phase: SpawnHostPhase, outputTail: string, exit?: HostExit | undefined);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* `ph run <host> [verb]` as a child; ready when its run record appears.
|
|
229
|
+
*
|
|
230
|
+
* The child shares this process's group, so a terminal Ctrl-C reaches both.
|
|
231
|
+
* It runs the project's own ph-cli: one older than PH_NO_DOTENV reads the
|
|
232
|
+
* project's `.env` anyway.
|
|
233
|
+
*/
|
|
234
|
+
export declare function spawnHost(options: SpawnHostOptions): Promise<SpawnedHost>;
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/host-issues.d.ts
|
|
237
|
+
/** Where in the `ph run` pipeline a host check found an issue. */
|
|
238
|
+
type CheckStage = "load" | "declared" | "resolve" | "resolved" | "boot";
|
|
239
|
+
interface HostIssue {
|
|
240
|
+
stage: CheckStage;
|
|
241
|
+
/** A compound's issues come from its members' files too. */
|
|
242
|
+
file: string;
|
|
243
|
+
/** Empty when the issue concerns the file as a whole. */
|
|
244
|
+
path: string;
|
|
245
|
+
message: string;
|
|
246
|
+
hint?: string;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/env-substitution.d.ts
|
|
250
|
+
/**
|
|
251
|
+
* Pure built-in `$env` substitution: the `"${userData}"` / `"${projectRoot}"`
|
|
252
|
+
* string sugar, deep-applied to a JSON-shaped value. No node imports, so it
|
|
253
|
+
* ships in `./schema`; the node default for userData is placeholders.ts.
|
|
254
|
+
*/
|
|
255
|
+
interface BuiltinEnv {
|
|
256
|
+
userData?: string;
|
|
257
|
+
projectRoot?: string;
|
|
258
|
+
}
|
|
259
|
+
/** The always-resolvable `$env` names (also the `"${name}"` sugar). */
|
|
260
|
+
export declare const BUILTIN_ENV_NAMES: readonly (keyof BuiltinEnv)[];
|
|
261
|
+
export declare function isBuiltinEnvName(name: string): name is keyof BuiltinEnv;
|
|
262
|
+
/** Deep-substitute the built-ins that `env` provides in every string; an
|
|
263
|
+
* absent built-in is left as written. The input is never mutated. */
|
|
264
|
+
export declare function substituteBuiltinEnv<T>(value: T, env: BuiltinEnv): T;
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/resolve/resolve.d.ts
|
|
267
|
+
/**
|
|
268
|
+
* The resolver (pipeline step 5): replaces every token in a declared host
|
|
269
|
+
* with its value. `$output` reads the producer's outputs through an
|
|
270
|
+
* `OutputSource` (live compound members, or a standalone run record: the
|
|
271
|
+
* node adapters in ./node.ts); `$env` reads the environment map of the
|
|
272
|
+
* resolving process; `$map` renders its `to` template once per element of
|
|
273
|
+
* its `over` (arrays in order, records key-sorted; `$item`/`$key` read the
|
|
274
|
+
* element being rendered); the `"${userData}"`/`"${projectRoot}"` string
|
|
275
|
+
* sugar is substituted on the way. An `$output`/`$item` that reads a field
|
|
276
|
+
* absent from the data but optional in the producer's schema (codegen's
|
|
277
|
+
* `OutputToken<T | undefined>`) omits its enclosing property, like an unset
|
|
278
|
+
* optional `$env`. Pure and browser-safe.
|
|
279
|
+
*/
|
|
280
|
+
type OutputLookup = {
|
|
281
|
+
status: "available";
|
|
282
|
+
outputs: unknown;
|
|
283
|
+
/** The producer's `outputsSchema`, when known: an absent field it
|
|
284
|
+
* marks optional omits the consuming property instead of failing. */
|
|
285
|
+
schema?: unknown;
|
|
286
|
+
} |
|
|
287
|
+
/** `message` is the complete, user-facing reason (e.g. "connect needs
|
|
288
|
+
* outputs from host "switchboard", which is not running. …"). */
|
|
289
|
+
{
|
|
290
|
+
status: "unavailable";
|
|
291
|
+
message: string;
|
|
292
|
+
};
|
|
293
|
+
interface OutputSource {
|
|
294
|
+
lookup(ref: OutputRef): OutputLookup;
|
|
295
|
+
}
|
|
296
|
+
interface ResolveSources {
|
|
297
|
+
/** Where `$output` tokens read. Absent: any `$output` fails. */
|
|
298
|
+
outputs?: OutputSource;
|
|
299
|
+
/** The resolving process's environment (`$env`). */
|
|
300
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
301
|
+
/** `userData`/`projectRoot`: always resolvable `$env` names and string
|
|
302
|
+
* sugar. */
|
|
303
|
+
builtins?: BuiltinEnv;
|
|
304
|
+
/** The host file named in errors (`hosts/connect/host.js`). */
|
|
305
|
+
where?: string;
|
|
306
|
+
}
|
|
307
|
+
export declare class TokenResolutionError extends Error {
|
|
308
|
+
/** The host path that failed and the reason, without the file prefix. */
|
|
309
|
+
readonly detail?: {
|
|
310
|
+
path: string;
|
|
311
|
+
reason: string;
|
|
312
|
+
};
|
|
313
|
+
constructor(message: string, detail?: {
|
|
314
|
+
path: string;
|
|
315
|
+
reason: string;
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The `$map` elements an issue path (from resolved validation of a resolved
|
|
320
|
+
* host) passes through, as text: `$map element "workflows"`. Undefined when
|
|
321
|
+
* the path crosses no `$map`-rendered array. Walk the SAME object
|
|
322
|
+
* `resolveHostOutputs` returned (provenance is by identity).
|
|
323
|
+
*/
|
|
324
|
+
export declare function describeMapElements(host: unknown, path: readonly PropertyKey[]): string | undefined;
|
|
325
|
+
/** A compound's own member set, for `deferSelf`. */
|
|
326
|
+
interface SelfMembers {
|
|
327
|
+
/** The compound's members: key (`children.<key>`) and host folder. */
|
|
328
|
+
members: readonly {
|
|
329
|
+
key: string;
|
|
330
|
+
host: string;
|
|
331
|
+
}[];
|
|
332
|
+
}
|
|
333
|
+
/** A token in a compound's own fields that reads one of its members. */
|
|
334
|
+
interface DeferredToken {
|
|
335
|
+
/** Host path (`config.agents.assistant.url`). */
|
|
336
|
+
path: string;
|
|
337
|
+
/** The member keys whose outputs it needs. */
|
|
338
|
+
members: string[];
|
|
339
|
+
}
|
|
340
|
+
interface DeferredResolution<T> {
|
|
341
|
+
/** The host with every token resolved EXCEPT the deferred ones (still in
|
|
342
|
+
* place) and the `children` wrappers (member-level: each member resolves
|
|
343
|
+
* its own). */
|
|
344
|
+
host: T;
|
|
345
|
+
deferred: DeferredToken[];
|
|
346
|
+
/** The member keys any deferred token needs (start them first). */
|
|
347
|
+
needs: string[];
|
|
348
|
+
/** Resolve the deferred tokens once those members have started, from
|
|
349
|
+
* their live outputs (e.g. `compoundOutputSource`); returns the fully
|
|
350
|
+
* resolved host (children still untouched). */
|
|
351
|
+
finish(outputs: OutputSource): T;
|
|
352
|
+
}
|
|
353
|
+
interface ResolveOptions {
|
|
354
|
+
/** Resolving a COMPOUND's own fields: tokens that read one of its members
|
|
355
|
+
* are deferred until those members have started (see
|
|
356
|
+
* `DeferredResolution`); `children` is left for the members. `"outputs"`
|
|
357
|
+
* defers every `$output` (its `members` are the producers' ref keys). */
|
|
358
|
+
deferSelf: SelfMembers | "outputs";
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Resolve every token in a declared host (or any JSON-shaped value): the
|
|
362
|
+
* result has the same shape with tokens replaced by values, optional unset
|
|
363
|
+
* `$env` properties omitted and the built-in string sugar substituted (`$$`
|
|
364
|
+
* escapes are kept; validateHost unwraps them). Throws `TokenResolutionError` naming the host path;
|
|
365
|
+
* an `$output` whose producer is not running fails with the source's
|
|
366
|
+
* message (no fallback, no waiting).
|
|
367
|
+
*
|
|
368
|
+
* With `{ deferSelf }` (a compound resolving its own fields), returns a
|
|
369
|
+
* `DeferredResolution` instead: everything but the self-references now,
|
|
370
|
+
* and `finish(outputs)` for the rest once the members it needs run.
|
|
371
|
+
*/
|
|
372
|
+
export declare function resolveHostOutputs<T>(host: T, sources: ResolveSources): T;
|
|
373
|
+
export declare function resolveHostOutputs<T>(host: T, sources: ResolveSources, options: ResolveOptions): DeferredResolution<T>;
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/check-host.d.ts
|
|
376
|
+
interface CheckHostOptions {
|
|
377
|
+
projectRoot: string;
|
|
378
|
+
/** The environment `ph run` would resolve against; `process.env` is never read. */
|
|
379
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
380
|
+
/** Default `run`, as `ph run <name>`. */
|
|
381
|
+
verb?: string;
|
|
382
|
+
/** Producers' outputs. Absent: `$output` tokens are checked declared-only. */
|
|
383
|
+
outputs?: OutputSource;
|
|
384
|
+
}
|
|
385
|
+
interface CheckDeferred extends DeferredToken {
|
|
386
|
+
file: string;
|
|
387
|
+
}
|
|
388
|
+
interface CheckHostResult {
|
|
389
|
+
issues: HostIssue[];
|
|
390
|
+
/** What `ph run` survives but the user should know; never fails a check. */
|
|
391
|
+
warnings: HostIssue[];
|
|
392
|
+
/** `$output` tokens left unresolved because no `outputs` were given. */
|
|
393
|
+
deferred: CheckDeferred[];
|
|
394
|
+
}
|
|
395
|
+
/** The `ph run` pipeline up to the verb, collecting every issue; starts nothing. */
|
|
396
|
+
export declare function checkHost(name: string, options: CheckHostOptions): Promise<CheckHostResult>;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/host-export-schema.d.ts
|
|
399
|
+
/** `ph host export`: a declared host plus its members, keyed by folder. */
|
|
400
|
+
export declare const hostExportSchema: z.ZodObject<{
|
|
401
|
+
format: z.ZodLiteral<"ph-host-export">;
|
|
402
|
+
version: z.ZodLiteral<1>;
|
|
403
|
+
project: z.ZodObject<{
|
|
404
|
+
name: z.ZodString;
|
|
405
|
+
root: z.ZodString;
|
|
406
|
+
}, z.core.$strict>;
|
|
407
|
+
name: z.ZodString;
|
|
408
|
+
host: z.ZodCustom<HostDefinition, HostDefinition>;
|
|
409
|
+
members: z.ZodRecord<z.ZodString, z.ZodCustom<HostDefinition, HostDefinition>>;
|
|
410
|
+
}, z.core.$strict>;
|
|
411
|
+
type HostExport = z.input<typeof hostExportSchema>;
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region src/host-export.d.ts
|
|
414
|
+
/** A host as declared and every member it reaches, raw `loadHost` bodies. */
|
|
415
|
+
export declare function exportHost(projectRoot: string, name: string): Promise<HostExport>;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/placeholders.d.ts
|
|
418
|
+
/**
|
|
419
|
+
* `${userData}` resolution for host files (desktop shape): storage paths in a
|
|
420
|
+
* host must not derive from the instance name (renames must stay safe), so
|
|
421
|
+
* the host file writes `${userData}/.ph/reactor-storage` and the RUNNER
|
|
422
|
+
* resolves it at start. `${userData}` is a PROJECT-SHAPED root: its `.ph`
|
|
423
|
+
* subtree carries the same names the classic commands use under
|
|
424
|
+
* `<project>/.ph` (see `resolvePhDir`). In the CLI it IS the project root, so
|
|
425
|
+
* `ph run desktop` in a project shares the one `.ph` tree `ph vetra` uses;
|
|
426
|
+
* a shell (Tauri) points it at the OS profile via PH_USER_DATA_DIR, and the
|
|
427
|
+
* whole `.ph` tree — stores, identity, run records — follows.
|
|
428
|
+
*/
|
|
429
|
+
export declare function defaultUserDataDir(projectRoot: string, env?: Record<string, string | undefined>): string;
|
|
430
|
+
/** Deep-substitute `${userData}` in every string of a JSON-shaped value.
|
|
431
|
+
* Non-strings pass through; the input is never mutated. */
|
|
432
|
+
export declare function resolveUserDataPlaceholders<T>(value: T, userData: string): T;
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/host-types.d.ts
|
|
435
|
+
declare global {
|
|
436
|
+
/** `"<runner specifier>": { host: <z.input of its hostSchema>; outputs:
|
|
437
|
+
* <z.infer of its outputsSchema> }`, one entry per runner module. */
|
|
438
|
+
interface PHHostRunners {}
|
|
439
|
+
/** `"<plugin specifier>": <z.input of its configSchema>`. */
|
|
440
|
+
interface PHPluginConfigs {}
|
|
441
|
+
}
|
|
442
|
+
type RunnerSpecifier = keyof PHHostRunners & string;
|
|
443
|
+
type PluginSpecifier = keyof PHPluginConfigs & string;
|
|
444
|
+
/** A runner's host input with `runner.plugins` typed as authoring
|
|
445
|
+
* {@link PluginEntry}s (the zod input type only knows the untyped data
|
|
446
|
+
* shape), so a known plugin's config is checked against its own type. */
|
|
447
|
+
type WithTypedPlugins<H, M extends string> = H extends {
|
|
448
|
+
runner: infer R;
|
|
449
|
+
} ? Omit<H, "runner"> & {
|
|
450
|
+
runner: Omit<R, "module" | "plugins"> & {
|
|
451
|
+
module: M;
|
|
452
|
+
plugins?: PluginEntry[];
|
|
453
|
+
};
|
|
454
|
+
} : never;
|
|
455
|
+
/** Any host file, discriminated by `runner.module`. `never` until a runner
|
|
456
|
+
* package augments PHHostRunners. */
|
|
457
|
+
type PHHost = { [M in RunnerSpecifier]: PHHostRunners[M] extends {
|
|
458
|
+
host: infer H;
|
|
459
|
+
} ? WithTypedPlugins<H, M> : never; }[RunnerSpecifier];
|
|
460
|
+
/** The outputs a runner's creation produces, by specifier. */
|
|
461
|
+
type PHHostOutputs<M extends RunnerSpecifier> = PHHostRunners[M] extends {
|
|
462
|
+
outputs: infer O;
|
|
463
|
+
} ? O : never;
|
|
464
|
+
interface PluginEntryObject<M extends string, C> {
|
|
465
|
+
module: M;
|
|
466
|
+
/** Presence is activation by default; false is the explicit off-switch. */
|
|
467
|
+
enabled?: boolean;
|
|
468
|
+
/** "*" (default) or the run verbs this entry is active for. */
|
|
469
|
+
verbs?: "*" | string[];
|
|
470
|
+
config?: C;
|
|
471
|
+
}
|
|
472
|
+
type KnownPluginEntry = { [M in PluginSpecifier]: M | PluginEntryObject<M, PHPluginConfigs[M]>; }[PluginSpecifier];
|
|
473
|
+
/** A `runner.plugins` entry as an author writes it. A known specifier (one
|
|
474
|
+
* a package augments PHPluginConfigs with) carries its plugin's config type,
|
|
475
|
+
* and only that: the object fallback for other specifiers takes no config,
|
|
476
|
+
* because TS cannot express "any string but the known ones" and a
|
|
477
|
+
* `Record<string, unknown>` fallback would admit a known specifier with a
|
|
478
|
+
* wrong config. Any specifier may still be named bare, or as an object
|
|
479
|
+
* without config; a third-party plugin that takes config augments
|
|
480
|
+
* PHPluginConfigs (in its package, or in the project's hosts/types.d.ts). */
|
|
481
|
+
type PluginEntry = KnownPluginEntry | string | PluginEntryObject<string, undefined>;
|
|
482
|
+
declare global {
|
|
483
|
+
interface PHHostRunners {
|
|
484
|
+
"@powerhousedao/host-core/runners/compound": {
|
|
485
|
+
host: z.input<typeof declaredGenericCompoundHostSchema>;
|
|
486
|
+
outputs: Record<string, never>;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/plugins.d.ts
|
|
492
|
+
/**
|
|
493
|
+
* R1 — the host plugin framework (bridge-runners-to-plugins plan,
|
|
494
|
+
* customization-references/host-core as the blueprint).
|
|
495
|
+
*
|
|
496
|
+
* A plugin is hooks + contributions; hooks are boot wiring (main realm only),
|
|
497
|
+
* contributions are declarative, serializable surface. Host RUNTIMES define
|
|
498
|
+
* the hook vocabulary and interleave their own wiring between stages — they
|
|
499
|
+
* are never plugins themselves.
|
|
500
|
+
*
|
|
501
|
+
* host.js carries the COMPOSITION as `runner.plugins` entries:
|
|
502
|
+
* string | { module, enabled?, verbs?, config? }
|
|
503
|
+
* Presence is activation (enabled defaults true); `verbs` scopes an entry to
|
|
504
|
+
* matching run verbs; `config` is validated against the plugin's declared
|
|
505
|
+
* zod schema. Entries resolve from the PROJECT's dependency tree exactly
|
|
506
|
+
* like runner modules.
|
|
507
|
+
*/
|
|
508
|
+
export declare class PluginError extends Error {
|
|
509
|
+
constructor(message: string, hint?: string);
|
|
510
|
+
}
|
|
511
|
+
export declare const pluginEntryObjectSchema: z.ZodObject<{
|
|
512
|
+
module: z.ZodString;
|
|
513
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
514
|
+
verbs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
515
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
516
|
+
}, z.core.$strict>;
|
|
517
|
+
export declare const pluginEntrySchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
518
|
+
module: z.ZodString;
|
|
519
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
520
|
+
verbs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
521
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
522
|
+
}, z.core.$strict>]>;
|
|
523
|
+
/** The validated (runtime) entry shape. Authors write `PluginEntry`
|
|
524
|
+
* (host-types.ts), which types known plugins' configs. */
|
|
525
|
+
type PluginEntryData = z.infer<typeof pluginEntrySchema>;
|
|
526
|
+
interface NormalizedPluginEntry {
|
|
527
|
+
module: string;
|
|
528
|
+
enabled: boolean;
|
|
529
|
+
verbs: "*" | string[];
|
|
530
|
+
config: Record<string, unknown>;
|
|
531
|
+
}
|
|
532
|
+
export declare function normalizePluginEntry(entry: PluginEntryData): NormalizedPluginEntry;
|
|
533
|
+
/** Module is the identity key: a duplicate makes override targeting and
|
|
534
|
+
* ordering ambiguous, so it fails loudly. */
|
|
535
|
+
export declare function normalizePluginEntries(entries: readonly PluginEntryData[], where: string): NormalizedPluginEntry[];
|
|
536
|
+
export declare function entryActiveForVerb(entry: NormalizedPluginEntry, verb: string): boolean;
|
|
537
|
+
export declare function registerHostType(id: string, parent: string | null): void;
|
|
538
|
+
export declare function hostTypeSatisfies(hostType: string, appliesTo: string): boolean;
|
|
539
|
+
/** Hook kinds (v1 §2.2). The hook VOCABULARY is defined by host runtimes;
|
|
540
|
+
* plugins implement subsets of it. */
|
|
541
|
+
type Provide<T, C> = (ctx: C) => T | Promise<T>;
|
|
542
|
+
type Transform<T, C> = (value: T, ctx: C) => T | Promise<T>;
|
|
543
|
+
type Observe<C> = (ctx: C) => void | Promise<void>;
|
|
544
|
+
/**
|
|
545
|
+
* Core contributions — declarative, serializable, realm-crossing. Host
|
|
546
|
+
* runtimes extend this with their own kinds (UI slots live in connect-host,
|
|
547
|
+
* never here). `drives` entries use the drive declaration shape from
|
|
548
|
+
* drives.ts; kept as unknown here to avoid a cycle — the merge is shape-blind.
|
|
549
|
+
*/
|
|
550
|
+
interface Contributions {
|
|
551
|
+
drives?: unknown[];
|
|
552
|
+
packages?: string[];
|
|
553
|
+
configDeclarations?: {
|
|
554
|
+
name: string;
|
|
555
|
+
type?: string;
|
|
556
|
+
description?: string;
|
|
557
|
+
}[];
|
|
558
|
+
[kind: string]: unknown[] | undefined;
|
|
559
|
+
}
|
|
560
|
+
interface HostPlugin<THooks = Record<string, unknown>, TConfig = unknown> {
|
|
561
|
+
/** Stable id; used in ordering, dependsOn, and every diagnostic. */
|
|
562
|
+
name: string;
|
|
563
|
+
/** Host-type requirement; the entry is rejected on a host outside the
|
|
564
|
+
* hierarchy branch. Default: "reactor". */
|
|
565
|
+
appliesTo?: string;
|
|
566
|
+
/** Coarse ordering bucket (Vite-style). Default: "normal". */
|
|
567
|
+
enforce?: "pre" | "post";
|
|
568
|
+
/** Hard dependencies on OTHER PLUGINS — the host runtime is implied and
|
|
569
|
+
* never named. Missing dependency or cycle fails boot naming both sides. */
|
|
570
|
+
dependsOn?: string[];
|
|
571
|
+
/** Declared config shape; entry config is validated against it. A plugin
|
|
572
|
+
* without a schema accepts no config (passing one is a boot error). */
|
|
573
|
+
configSchema?: z.ZodType<TConfig>;
|
|
574
|
+
hooks?: Partial<THooks>;
|
|
575
|
+
contributions?: Contributions;
|
|
576
|
+
}
|
|
577
|
+
/** A plugin module default-exports either a HostPlugin object (no config
|
|
578
|
+
* accepted) or a factory `(config) => HostPlugin`. */
|
|
579
|
+
type HostPluginModule<THooks = Record<string, unknown>, TConfig = unknown> = HostPlugin<THooks, TConfig> | ((config: TConfig) => HostPlugin<THooks, TConfig>);
|
|
580
|
+
interface ResolvedPlugin<THooks = Record<string, unknown>> {
|
|
581
|
+
entry: NormalizedPluginEntry;
|
|
582
|
+
plugin: HostPlugin<THooks>;
|
|
583
|
+
/** Provenance for contribution merge ordering. */
|
|
584
|
+
provenance: "built-in" | "local" | "dependency";
|
|
585
|
+
}
|
|
586
|
+
/** Registration order, bucketed pre → normal → post (stable within buckets),
|
|
587
|
+
* then dependsOn topo-sorted within the bucketed order. */
|
|
588
|
+
export declare function resolveOrder<THooks>(plugins: readonly HostPlugin<THooks>[]): HostPlugin<THooks>[];
|
|
589
|
+
export declare function runProvideHook<T, C>(name: string, plugins: readonly HostPlugin[], ctx: C): Promise<T | undefined>;
|
|
590
|
+
export declare function runTransformHook<T, C>(name: string, plugins: readonly HostPlugin[], ctx: C, seed: T): Promise<T>;
|
|
591
|
+
/** Sequential observe, in plugin order — for lifecycle moments whose order
|
|
592
|
+
* is load-bearing (teardown: the switchboard stops privacy before workflows
|
|
593
|
+
* before the api, per the carve map). */
|
|
594
|
+
export declare function runObserveHookSequential<C>(name: string, plugins: readonly HostPlugin[], ctx: C): Promise<void>;
|
|
595
|
+
export declare function runObserveHook<C>(name: string, plugins: readonly HostPlugin[], ctx: C): Promise<void>;
|
|
596
|
+
interface ContributionSource {
|
|
597
|
+
pluginName: string;
|
|
598
|
+
provenance: "built-in" | "local" | "dependency";
|
|
599
|
+
}
|
|
600
|
+
interface MergedContribution<T = unknown> {
|
|
601
|
+
value: T;
|
|
602
|
+
source: ContributionSource;
|
|
603
|
+
}
|
|
604
|
+
/** Array kinds concatenate in provenance-then-order sequence (built-in first,
|
|
605
|
+
* so later sources read as overrides where consumers want last-wins). */
|
|
606
|
+
export declare function mergeContributions(resolved: readonly {
|
|
607
|
+
plugin: HostPlugin;
|
|
608
|
+
provenance: ContributionSource["provenance"];
|
|
609
|
+
}[]): Record<string, MergedContribution[]>;
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/plugins-resolve.d.ts
|
|
612
|
+
/**
|
|
613
|
+
* Resolve host.js plugin entries into live plugins for one host boot:
|
|
614
|
+
* verb-filter → module resolution from the project tree (default condition,
|
|
615
|
+
* like runners) → factory/object contract → config validation → appliesTo.
|
|
616
|
+
*/
|
|
617
|
+
export declare function resolveHostPlugins<THooks = Record<string, unknown>>(projectRoot: string, hostType: string, verb: string, entries: readonly PluginEntryData[], where: string): Promise<ResolvedPlugin<THooks>[]>;
|
|
618
|
+
/** A drive a plugin contributes: its declaration (drives.ts shape, validated
|
|
619
|
+
* by the consumer) and the plugin it came from. */
|
|
620
|
+
interface ContributedDrive {
|
|
621
|
+
declaration: Record<string, unknown>;
|
|
622
|
+
source: string;
|
|
623
|
+
}
|
|
624
|
+
interface PluginContributionsPlan {
|
|
625
|
+
drives: ContributedDrive[];
|
|
626
|
+
/** Entries whose module the project tree cannot resolve (e.g. Connect's
|
|
627
|
+
* browser built-ins, which have no Node-resolvable identity module). */
|
|
628
|
+
unresolved: string[];
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* LENIENT resolution for diagnostics (`ph run <host> --explain drives`):
|
|
632
|
+
* collects the drive contributions of the entries active for `verb`. Unlike
|
|
633
|
+
* resolveHostPlugins it does not know the host type (so appliesTo is not
|
|
634
|
+
* checked) and does not fail on a specifier the project tree cannot resolve
|
|
635
|
+
* — the entry is listed under `unresolved` instead. Config is still validated
|
|
636
|
+
* against the plugin's schema, so a bad entry surfaces here too.
|
|
637
|
+
*/
|
|
638
|
+
export declare function resolvePluginContributions(projectRoot: string, verb: string, entries: readonly PluginEntryData[], where: string): Promise<PluginContributionsPlan>;
|
|
639
|
+
/** One Connect config value a built-in Connect plugin owns. */
|
|
640
|
+
interface OwnedConfigSlice {
|
|
641
|
+
/** Dot path inside the connect config block, e.g. "drives.allowAddDrive". */
|
|
642
|
+
path: string;
|
|
643
|
+
/** What Connect serves at `path` while the owning plugin is absent from a
|
|
644
|
+
* declared composition (apps/connect plugin-host.ts zeroAbsentSlices). */
|
|
645
|
+
absent: unknown;
|
|
646
|
+
/** The owning plugin's entry config key that sets this value, when the
|
|
647
|
+
* plugin takes it as config; omitted where presence alone is the switch. */
|
|
648
|
+
entryKey?: string;
|
|
649
|
+
}
|
|
650
|
+
interface ConnectPluginSlices {
|
|
651
|
+
slices: OwnedConfigSlice[];
|
|
652
|
+
/** A slice whose unset or `absent` value leaves every slice of this plugin
|
|
653
|
+
* inert (OpenPanel tracking does nothing without a clientId), so nothing
|
|
654
|
+
* of it is reported as dead. */
|
|
655
|
+
inertUnless?: string;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* The connect config slices each built-in Connect plugin owns, by specifier
|
|
659
|
+
* (typed-host-configs 1.6). Under a declared composition Connect zeroes a
|
|
660
|
+
* slice whose plugin is absent — presence is activation — so an authored
|
|
661
|
+
* value there is dead config. Connect's built-ins are browser modules with no
|
|
662
|
+
* Node-resolvable identity, so their ownership is declared here as data; a
|
|
663
|
+
* Connect test pins it to plugin-host's zeroing.
|
|
664
|
+
*/
|
|
665
|
+
export declare const CONNECT_PLUGIN_OWNED_SLICES: Readonly<Record<string, ConnectPluginSlices>>;
|
|
666
|
+
interface DeadConfigWarning {
|
|
667
|
+
/** Dot path inside the connect config block. */
|
|
668
|
+
path: string;
|
|
669
|
+
/** The authored value. */
|
|
670
|
+
value: unknown;
|
|
671
|
+
/** What Connect serves instead. */
|
|
672
|
+
served: unknown;
|
|
673
|
+
/** The specifier of the plugin that owns the slice. */
|
|
674
|
+
owner: string;
|
|
675
|
+
message: string;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Dead-config warnings for a Connect host (typed-host-configs 1.6): an
|
|
679
|
+
* authored connect config value whose owning plugin is not in the
|
|
680
|
+
* composition active for `verb`. Connect zeroes such a slice, so the value
|
|
681
|
+
* has no effect — e.g. Sektar's `connect.drives.allowAddDrive: true` without
|
|
682
|
+
* the generic plugin.
|
|
683
|
+
*
|
|
684
|
+
* Nothing is reported when the host declares no composition
|
|
685
|
+
* (`runner.plugins` absent: the classic boot serves the config as is), or
|
|
686
|
+
* when Connect already serves every leaf of the authored value. Warnings, not
|
|
687
|
+
* errors: the host still boots, it just does not do what the value says.
|
|
688
|
+
*/
|
|
689
|
+
export declare function findDeadConnectConfig(config: Record<string, unknown> | undefined, entries: readonly PluginEntryData[] | undefined, verb: string, where: string): DeadConfigWarning[];
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/drive-schema.d.ts
|
|
692
|
+
/**
|
|
693
|
+
* The schema half of drives.ts, zod only so `./schema` stays neutral.
|
|
694
|
+
* - slug: the SEEDING KEY (idempotence); id optional (stable identity).
|
|
695
|
+
* - preferredEditor: stored at header.meta.preferredEditor; Connect config's
|
|
696
|
+
* `app` is the legacy alias.
|
|
697
|
+
* - remote.url: a drive served elsewhere; local fields are ignored for it.
|
|
698
|
+
* Token-able (`$output` on a producer's `drives.<slug>.url`).
|
|
699
|
+
*/
|
|
700
|
+
export declare function buildDriveDeclarationSchema(urlField: (schema: z.ZodString) => TokenableSchema<z.ZodString>): z.ZodObject<{
|
|
701
|
+
slug: z.ZodString;
|
|
702
|
+
id: z.ZodOptional<z.ZodString>;
|
|
703
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
704
|
+
documentType: z.ZodOptional<z.ZodEnum<{
|
|
705
|
+
"powerhouse/document-drive": "powerhouse/document-drive";
|
|
706
|
+
"powerhouse/reactor-drive": "powerhouse/reactor-drive";
|
|
707
|
+
}>>;
|
|
708
|
+
name: z.ZodOptional<z.ZodString>;
|
|
709
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
710
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
711
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
712
|
+
private: "private";
|
|
713
|
+
public: "public";
|
|
714
|
+
shared: "shared";
|
|
715
|
+
}>>;
|
|
716
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
717
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
718
|
+
url: TokenableSchema<z.ZodString>;
|
|
719
|
+
}, z.core.$strict>>;
|
|
720
|
+
}, z.core.$strict>;
|
|
721
|
+
export declare const driveDeclarationSchema: z.ZodObject<{
|
|
722
|
+
slug: z.ZodString;
|
|
723
|
+
id: z.ZodOptional<z.ZodString>;
|
|
724
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
725
|
+
documentType: z.ZodOptional<z.ZodEnum<{
|
|
726
|
+
"powerhouse/document-drive": "powerhouse/document-drive";
|
|
727
|
+
"powerhouse/reactor-drive": "powerhouse/reactor-drive";
|
|
728
|
+
}>>;
|
|
729
|
+
name: z.ZodOptional<z.ZodString>;
|
|
730
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
731
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
732
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
733
|
+
private: "private";
|
|
734
|
+
public: "public";
|
|
735
|
+
shared: "shared";
|
|
736
|
+
}>>;
|
|
737
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
738
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
739
|
+
url: TokenableSchema<z.ZodString>;
|
|
740
|
+
}, z.core.$strict>>;
|
|
741
|
+
}, z.core.$strict>;
|
|
742
|
+
type DriveDeclaration = z.infer<typeof driveDeclarationSchema>;
|
|
743
|
+
export declare const drivesSchema: z.ZodArray<z.ZodObject<{
|
|
744
|
+
slug: z.ZodString;
|
|
745
|
+
id: z.ZodOptional<z.ZodString>;
|
|
746
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
747
|
+
documentType: z.ZodOptional<z.ZodEnum<{
|
|
748
|
+
"powerhouse/document-drive": "powerhouse/document-drive";
|
|
749
|
+
"powerhouse/reactor-drive": "powerhouse/reactor-drive";
|
|
750
|
+
}>>;
|
|
751
|
+
name: z.ZodOptional<z.ZodString>;
|
|
752
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
753
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
754
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
755
|
+
private: "private";
|
|
756
|
+
public: "public";
|
|
757
|
+
shared: "shared";
|
|
758
|
+
}>>;
|
|
759
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
760
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
761
|
+
url: TokenableSchema<z.ZodString>;
|
|
762
|
+
}, z.core.$strict>>;
|
|
763
|
+
}, z.core.$strict>>;
|
|
764
|
+
/** The project-hashed drive id (`${slug}-${sha256(projectRoot)[0..8]}`) with
|
|
765
|
+
* the hash function injected, so neutral consumers (a browser monitor) can
|
|
766
|
+
* pass `crypto.subtle`-derived or precomputed hex. drives.ts binds it to
|
|
767
|
+
* node:crypto as `projectDriveId`. */
|
|
768
|
+
export declare function projectDriveIdWith(sha256Hex: (input: string) => string, projectRoot: string, slug: string): string;
|
|
769
|
+
//#endregion
|
|
770
|
+
//#region src/drives.d.ts
|
|
771
|
+
export declare function projectDriveId(projectRoot: string, slug: string): string;
|
|
772
|
+
interface ResolvedDrive {
|
|
773
|
+
kind: "local" | "remote";
|
|
774
|
+
/** A fixed id; absent, the reactor generates it. The slug is the name. */
|
|
775
|
+
id?: string;
|
|
776
|
+
slug: string;
|
|
777
|
+
documentType?: DriveDeclaration["documentType"];
|
|
778
|
+
name: string;
|
|
779
|
+
icon?: string;
|
|
780
|
+
preferredEditor?: string;
|
|
781
|
+
sharingType: "public" | "private" | "shared";
|
|
782
|
+
availableOffline: boolean;
|
|
783
|
+
remoteUrl?: string;
|
|
784
|
+
}
|
|
785
|
+
export declare function resolveDriveDeclaration(projectRoot: string, decl: DriveDeclaration): ResolvedDrive;
|
|
786
|
+
/** The minimal client surface the seeder needs — runners adapt their reactor
|
|
787
|
+
* clients (IReactorClient, addDefaultDrive-style helpers) onto it. */
|
|
788
|
+
interface DriveSeederClient {
|
|
789
|
+
/** Return the existing drive's id for a slug, or undefined. */
|
|
790
|
+
findDriveBySlug(slug: string): Promise<string | undefined>;
|
|
791
|
+
/** Create a local drive; preferredEditor lands on header.meta. */
|
|
792
|
+
createDrive(drive: ResolvedDrive): Promise<void>;
|
|
793
|
+
/** Attach a remote drive by URL (idempotent on the client side). */
|
|
794
|
+
attachRemoteDrive(url: string): Promise<void>;
|
|
795
|
+
}
|
|
796
|
+
interface SeedResult {
|
|
797
|
+
created: string[];
|
|
798
|
+
existing: string[];
|
|
799
|
+
attached: string[];
|
|
800
|
+
}
|
|
801
|
+
/** Idempotent, slug-keyed: an existing slug is left untouched (never
|
|
802
|
+
* recreated, never mutated — preserveStrategy refinements live here later). */
|
|
803
|
+
export declare function seedDrives(client: DriveSeederClient, drives: readonly ResolvedDrive[]): Promise<SeedResult>;
|
|
804
|
+
interface DrivePlanEntry {
|
|
805
|
+
drive: ResolvedDrive;
|
|
806
|
+
/** "host" for host.js declarations; a plugin name for contributions. */
|
|
807
|
+
source: string;
|
|
808
|
+
}
|
|
809
|
+
/** Merge host-declared drives with plugin contributions, slug-keyed — the
|
|
810
|
+
* host file wins on conflicts (it is the most explicit source). */
|
|
811
|
+
export declare function mergeDrivePlan(projectRoot: string, hostDeclared: readonly DriveDeclaration[], contributed: readonly {
|
|
812
|
+
declaration: DriveDeclaration;
|
|
813
|
+
source: string;
|
|
814
|
+
}[]): DrivePlanEntry[];
|
|
815
|
+
export declare function explainDrivePlan(plan: readonly DrivePlanEntry[]): string;
|
|
816
|
+
//#endregion
|
|
817
|
+
//#region src/backend-projection.d.ts
|
|
818
|
+
/**
|
|
819
|
+
* Phase 4 (track R): project named host backends onto reactor-monitor's
|
|
820
|
+
* `ReactorDescriptor` shape — the input `provision()` takes. Pure and
|
|
821
|
+
* dependency-free; a type-assignability test pins the output to the real
|
|
822
|
+
* `ReactorDescriptor` so an upstream field rename fails this package's tests
|
|
823
|
+
* instead of silently drifting (D2.b: aligned locally, upstreaming not
|
|
824
|
+
* blocked on).
|
|
825
|
+
*/
|
|
826
|
+
/** The browser-provisionable storage union — reactor-monitor's
|
|
827
|
+
* `ReactorStorageConfig` shape. `postgres` is the SERVER extension (D2.b): a
|
|
828
|
+
* switchboard backend's storage, never a provisioned browser reactor's. */
|
|
829
|
+
type ProjectedStorage = {
|
|
830
|
+
kind: "idb";
|
|
831
|
+
} | {
|
|
832
|
+
kind: "memory";
|
|
833
|
+
} | {
|
|
834
|
+
kind: "path";
|
|
835
|
+
dataDir: string;
|
|
836
|
+
};
|
|
837
|
+
interface ProjectedDescriptor {
|
|
838
|
+
kind: "in-process" | "worker" | "remote";
|
|
839
|
+
name: string;
|
|
840
|
+
storage?: ProjectedStorage;
|
|
841
|
+
packages?: {
|
|
842
|
+
cdnUrl?: string;
|
|
843
|
+
specs?: string[];
|
|
844
|
+
dynamic?: boolean;
|
|
845
|
+
};
|
|
846
|
+
featureFlags?: {
|
|
847
|
+
documentDecisions?: boolean;
|
|
848
|
+
authEnforcement?: boolean;
|
|
849
|
+
authGroups?: boolean;
|
|
850
|
+
authConditions?: boolean;
|
|
851
|
+
undoV3?: boolean;
|
|
852
|
+
};
|
|
853
|
+
remote?: {
|
|
854
|
+
url: string;
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
/** One backend → one descriptor. The protocol's featureFlags ride every
|
|
858
|
+
* descriptor (they are fleet consensus, not per-backend). A remote backend
|
|
859
|
+
* must carry remote.url — provision() requires it. */
|
|
860
|
+
export declare function backendToDescriptor(name: string, backend: ReactorBackend, protocol?: ReactorProtocol): ProjectedDescriptor;
|
|
861
|
+
/** All named backends, in placement-primary-first order (the order a
|
|
862
|
+
* createReactorClients step would provision them). */
|
|
863
|
+
export declare function backendsToDescriptors(reactor: ReactorConfig | undefined): ProjectedDescriptor[];
|
|
864
|
+
/**
|
|
865
|
+
* Structural multi-reactor (phase 4): true when the block names BOTH a local
|
|
866
|
+
* backend (in-process/worker — the tab's own reactor) and a remote one. This
|
|
867
|
+
* is the shape Connect's routing client serves; a lone remote backend is an
|
|
868
|
+
* attach-only host (assistant/agent shape), not a routed tab.
|
|
869
|
+
*/
|
|
870
|
+
export declare function isStructuralMultiReactor(reactor: ReactorConfig | undefined): boolean;
|
|
871
|
+
/** The remote backends' drive addresses, placement order. */
|
|
872
|
+
export declare function remoteBackendUrls(reactor: ReactorConfig | undefined): string[];
|
|
873
|
+
/** A switchboard as Connect's served config names it, with its connection settings. */
|
|
874
|
+
type ServedRemoteBackend = {
|
|
875
|
+
name: string;
|
|
876
|
+
url: string;
|
|
877
|
+
} & Omit<NonNullable<ReactorBackend["remote"]>, "url">;
|
|
878
|
+
/**
|
|
879
|
+
* The remote backends by host key, placement order, each with the
|
|
880
|
+
* connection settings it sets. A url that is not a string yet (an output
|
|
881
|
+
* token, unresolved when a host builds) is skipped, as in remoteBackendUrls.
|
|
882
|
+
*/
|
|
883
|
+
export declare function remoteBackends(reactor: ReactorConfig | undefined): ServedRemoteBackend[];
|
|
884
|
+
//#endregion
|
|
885
|
+
//#region src/reactor-config.d.ts
|
|
886
|
+
/** A switchboard host's own store. Prefers placement.primary, else
|
|
887
|
+
* "main"/"local", else the first. Connect refuses placement.primary: its
|
|
888
|
+
* reactor is {@link browserBackend}. */
|
|
889
|
+
export declare function primaryBackend(reactor: ReactorConfig | undefined): ReactorBackend | undefined;
|
|
890
|
+
/** The env vars a protocol block maps onto, with their string values. Only
|
|
891
|
+
* keys the block actually sets appear. */
|
|
892
|
+
export declare function protocolEnv(protocol: ReactorProtocol | undefined): Record<string, string>;
|
|
893
|
+
/** The switchboard config layer a reactor block maps to (the shape of
|
|
894
|
+
* `@powerhousedao/switchboard/config`'s input). Only keys the block sets. */
|
|
895
|
+
interface SwitchboardReactorLayer {
|
|
896
|
+
storage?: {
|
|
897
|
+
reactor?: {
|
|
898
|
+
url: string;
|
|
899
|
+
};
|
|
900
|
+
readModel?: {
|
|
901
|
+
url: string;
|
|
902
|
+
};
|
|
903
|
+
};
|
|
904
|
+
protocol?: ReactorProtocol;
|
|
905
|
+
packages?: {
|
|
906
|
+
dynamic: true;
|
|
907
|
+
};
|
|
908
|
+
features?: {
|
|
909
|
+
workflows: boolean;
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
/** The reactor block as a switchboard config layer. The reactor store and the
|
|
913
|
+
* read model are separate fields: `readModel.url` never moves the reactor. */
|
|
914
|
+
export declare function reactorBlockToSwitchboardConfig(reactor: ReactorConfig | undefined): SwitchboardReactorLayer;
|
|
915
|
+
/** The four reactor-client shapes a Connect host can select (mirrors the
|
|
916
|
+
* shared PHReactorClientMode; kept local to avoid an import cycle). */
|
|
917
|
+
type ReactorClientMode = "in-process" | "worker" | "remote" | "router";
|
|
918
|
+
/** Connect's browser reactor: its first in-process or worker backend. */
|
|
919
|
+
export declare function browserBackend(reactor: ReactorConfig | undefined): (ReactorBackend & {
|
|
920
|
+
name: string;
|
|
921
|
+
}) | undefined;
|
|
922
|
+
/**
|
|
923
|
+
* Which reactor client the backend topology asks for:
|
|
924
|
+
* - local (in-process/worker) AND remote backends -> `router`
|
|
925
|
+
* - remote backend(s) only -> `remote`
|
|
926
|
+
* - a worker backend -> `worker`
|
|
927
|
+
* - anything else local -> `in-process`
|
|
928
|
+
* `undefined` when no backends are declared — the caller then keeps the
|
|
929
|
+
* legacy reactorWorker/multiReactor behaviour untouched.
|
|
930
|
+
*/
|
|
931
|
+
export declare function reactorClientMode(reactor: ReactorConfig | undefined): ReactorClientMode | undefined;
|
|
932
|
+
/** The router settings Connect serves: only the keys the host sets. */
|
|
933
|
+
interface ConnectRouterSettings {
|
|
934
|
+
/** A remote backend's host key; absent, the browser reactor (or the only switchboard). */
|
|
935
|
+
newDrives?: string;
|
|
936
|
+
probeTimeoutMs?: number;
|
|
937
|
+
provisionalRouteMs?: number;
|
|
938
|
+
}
|
|
939
|
+
/** The stores a browser reactor can keep: IndexedDB or none. */
|
|
940
|
+
type ConnectStorageKind = "idb" | "memory";
|
|
941
|
+
/** Why the browser reactor's declared store can't be served: Connect keeps
|
|
942
|
+
* IndexedDB instead of a folder or Postgres. */
|
|
943
|
+
export declare function unservedConnectStorage(reactor: ReactorConfig | undefined): string | undefined;
|
|
944
|
+
interface ConnectReactorProjection {
|
|
945
|
+
/** Patch merged into the connect runtime config (connect.*). */
|
|
946
|
+
connect: {
|
|
947
|
+
reactor?: ReactorProtocol;
|
|
948
|
+
instance?: {
|
|
949
|
+
reactorWorker?: boolean;
|
|
950
|
+
reactorClient?: ReactorClientMode;
|
|
951
|
+
storage?: ConnectStorageKind;
|
|
952
|
+
remoteBackends?: ServedRemoteBackend[];
|
|
953
|
+
router?: ConnectRouterSettings;
|
|
954
|
+
};
|
|
955
|
+
app?: {
|
|
956
|
+
workflowsEnabled?: boolean;
|
|
957
|
+
};
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
/** Project the reactor block onto the Connect runtime config: protocol →
|
|
961
|
+
* connect.reactor (same shape), backend topology → instance.reactorWorker
|
|
962
|
+
* (the browser reactor's kind), instance.reactorClient, instance.storage
|
|
963
|
+
* (the browser reactor's store), and with a
|
|
964
|
+
* switchboard instance.remoteBackends and instance.router, workflows →
|
|
965
|
+
* app.workflowsEnabled. */
|
|
966
|
+
export declare function projectReactorToConnect(reactor: ReactorConfig | undefined): ConnectReactorProjection;
|
|
967
|
+
/** Whether an env value means what the host's value does. The switchboard
|
|
968
|
+
* reads REACTOR_UNDO_V3 as on unless it is exactly "false". */
|
|
969
|
+
export declare function protocolEnvAgrees(varName: string, envValue: string, hostValue: string): boolean;
|
|
970
|
+
/** Each pre-set env var that CONTRADICTS the host's protocol block, as a
|
|
971
|
+
* message naming the var, the host value and the env value. An env var that
|
|
972
|
+
* merely matches, or is unset, is fine. */
|
|
973
|
+
export declare function protocolConflicts(protocol: ReactorProtocol | undefined, env: Readonly<Record<string, string | undefined>>, hostFile?: string): string[];
|
|
974
|
+
/**
|
|
975
|
+
* The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS
|
|
976
|
+
* the host's protocol block, fail loudly naming the var, the host value, and
|
|
977
|
+
* the env value (phase-2 transition keeps an operator's explicit env as an
|
|
978
|
+
* escape hatch unless it disagrees with the protocol — see the WBS
|
|
979
|
+
* precedence note).
|
|
980
|
+
*/
|
|
981
|
+
export declare function assertProtocolConsistency(protocol: ReactorProtocol | undefined, env: Record<string, string | undefined>, hostFile?: string): void;
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/connect-projection.d.ts
|
|
984
|
+
/**
|
|
985
|
+
* Concatenate groups of `connect.drives.defaultDrives` in the order given,
|
|
986
|
+
* de-duplicating by drive identity (URL for remote entries, id for local
|
|
987
|
+
* ones). The first occurrence of a drive wins, so earlier groups keep their
|
|
988
|
+
* position and metadata — e.g. the Vetra drive `ph vetra` starts stays first
|
|
989
|
+
* even when the project's `powerhouse.config.json` lists the same drive.
|
|
990
|
+
*/
|
|
991
|
+
export declare function mergeDefaultDrives(...groups: PHConnectDefaultDrive[][]): PHConnectDefaultDrive[];
|
|
992
|
+
/**
|
|
993
|
+
* Rebase a local drive URL onto a public base: keeps the /d/<slug> path,
|
|
994
|
+
* swaps the loopback origin for the public base. Browser clients behind a
|
|
995
|
+
* reverse proxy can't reach http://localhost:<port>. Non-loopback URLs
|
|
996
|
+
* (e.g. a remote drive) are already public and pass through unchanged, as do
|
|
997
|
+
* unparseable ones.
|
|
998
|
+
*/
|
|
999
|
+
export declare function rebaseDriveUrl(driveUrl: string, publicBase: string): string;
|
|
1000
|
+
interface DriveProjectionInput {
|
|
1001
|
+
/** Drive URLs the compound's reactor member created, in display order
|
|
1002
|
+
* (e.g. vetra, preview, workflows). Null/undefined entries are skipped. */
|
|
1003
|
+
createdDriveUrls: (string | null | undefined)[];
|
|
1004
|
+
/** The project's configured `connect.drives.defaultDrives`. */
|
|
1005
|
+
configuredDefaultDrives?: PHConnectDefaultDrive[];
|
|
1006
|
+
/** `--drives-public-base`: advertise proxy-reachable URLs to the browser. */
|
|
1007
|
+
publicBase?: string | null;
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* The compound's drives projection: created drives first (rebased onto the
|
|
1011
|
+
* public base when given), then the project's configured drives, de-duplicated
|
|
1012
|
+
* — and `preserve-all`, because compound-injected drive lists change per
|
|
1013
|
+
* launch context and must never detach drives the user added by hand.
|
|
1014
|
+
*/
|
|
1015
|
+
export declare function projectDrivesIntoConnect(input: DriveProjectionInput): Pick<PHConnectRuntimeConfig, "drives">;
|
|
1016
|
+
interface PlacedConnectDrives {
|
|
1017
|
+
defaultDrives: PHConnectRuntimeDefaultDrive[];
|
|
1018
|
+
collections?: Record<string, PHConnectCollection>;
|
|
1019
|
+
}
|
|
1020
|
+
/** Annotates remote default drives with their backend (`sync: false` when placed on it); other remote placements become collections. */
|
|
1021
|
+
export declare function placeConnectDrives(reactor: ReactorConfig | undefined, defaultDrives: readonly PHConnectDefaultDrive[]): PlacedConnectDrives;
|
|
1022
|
+
//#endregion
|
|
1023
|
+
//#region src/resolve/plan.d.ts
|
|
1024
|
+
/**
|
|
1025
|
+
* The dependency plan (pipeline step 4): which compound member consumes
|
|
1026
|
+
* which member's outputs, and the start order that follows. Producers start
|
|
1027
|
+
* before consumers; `config.startOrder` is optional and, when given, must
|
|
1028
|
+
* agree with the tokens. Cycles fail. Pure.
|
|
1029
|
+
*/
|
|
1030
|
+
export declare class PlanError extends Error {
|
|
1031
|
+
constructor(message: string);
|
|
1032
|
+
}
|
|
1033
|
+
interface PlanMember {
|
|
1034
|
+
/** The member key (`children.<key>`). */
|
|
1035
|
+
key: string;
|
|
1036
|
+
/** The member's host folder (`children.<key>.host`). */
|
|
1037
|
+
host: string;
|
|
1038
|
+
/** The producers its tokens name, with the host path of one token each. */
|
|
1039
|
+
refs: {
|
|
1040
|
+
ref: OutputRef;
|
|
1041
|
+
path: string;
|
|
1042
|
+
}[];
|
|
1043
|
+
}
|
|
1044
|
+
interface PlanEdge {
|
|
1045
|
+
consumer: string;
|
|
1046
|
+
producer: string;
|
|
1047
|
+
/** Host path in the consumer of the (first) token behind this edge. */
|
|
1048
|
+
path: string;
|
|
1049
|
+
}
|
|
1050
|
+
interface CompoundPlan {
|
|
1051
|
+
/** Member keys in start order. */
|
|
1052
|
+
order: string[];
|
|
1053
|
+
edges: PlanEdge[];
|
|
1054
|
+
/** "tokens": derived from the dependencies; "startOrder": the declared
|
|
1055
|
+
* order, checked against them. */
|
|
1056
|
+
source: "tokens" | "startOrder";
|
|
1057
|
+
}
|
|
1058
|
+
/** The member a ref names: the unique member running `ref.host`, or the
|
|
1059
|
+
* member `ref.member` when given (it must run `ref.host`). */
|
|
1060
|
+
export declare function memberForRef(ref: OutputRef, members: readonly Pick<PlanMember, "key" | "host">[]): {
|
|
1061
|
+
key: string;
|
|
1062
|
+
} | {
|
|
1063
|
+
error: string;
|
|
1064
|
+
};
|
|
1065
|
+
export declare function planCompound(members: readonly PlanMember[], startOrder?: readonly string[]): CompoundPlan;
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region src/resolve/removed-forms.d.ts
|
|
1068
|
+
/**
|
|
1069
|
+
* The cross-host forms removed in T3 (typed-host-configs 3.7), detected
|
|
1070
|
+
* before schema validation so the error names the token form that replaces
|
|
1071
|
+
* each one instead of a bare "Unrecognized key". clint's `agents.*.host` and
|
|
1072
|
+
* proxy `routes.*.member` are checked by the clint runner schemas.
|
|
1073
|
+
*/
|
|
1074
|
+
interface RemovedForm {
|
|
1075
|
+
/** Host path of the removed value. */
|
|
1076
|
+
path: string;
|
|
1077
|
+
message: string;
|
|
1078
|
+
}
|
|
1079
|
+
/** Every removed form in a host file (reactor or compound), in document
|
|
1080
|
+
* order. Compound wrappers are checked too. */
|
|
1081
|
+
export declare function findRemovedForms(host: unknown): RemovedForm[];
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/resolve/sources.d.ts
|
|
1084
|
+
/**
|
|
1085
|
+
* The compound output source: a member's `$output` tokens read the live
|
|
1086
|
+
* `RunnerHandle.outputs` of the members started before it. `schemas` (member
|
|
1087
|
+
* key → its runner's `outputsSchema`) lets an absent optional output field
|
|
1088
|
+
* omit the consuming property. Pure (the run-record source for standalone
|
|
1089
|
+
* hosts is node: ./node.ts).
|
|
1090
|
+
*/
|
|
1091
|
+
export declare function compoundOutputSource(members: readonly {
|
|
1092
|
+
key: string;
|
|
1093
|
+
host: string;
|
|
1094
|
+
}[], started: ReadonlyMap<string, unknown>, compound: string, schemas?: ReadonlyMap<string, unknown>): OutputSource;
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/resolve/walk.d.ts
|
|
1097
|
+
/**
|
|
1098
|
+
* Token discovery over a declared (JSON-shaped) host: where every operator
|
|
1099
|
+
* sits and in which syntactic position, which is what declared validation
|
|
1100
|
+
* (`$env` optional placement), the dependency plan and `--explain outputs`
|
|
1101
|
+
* read. Pure: no node imports.
|
|
1102
|
+
*/
|
|
1103
|
+
/** Where a token sits: the direct value of an object property, an array
|
|
1104
|
+
* element, the whole value, a `$concat` part, a `$map`'s `over`, or the
|
|
1105
|
+
* whole `to` template of a `$map` (the top of the rendered element). */
|
|
1106
|
+
type TokenPosition = "property" | "element" | "root" | "concat" | "over" | "template";
|
|
1107
|
+
/** An enclosing `$map`, as seen from a token inside its `to` template. */
|
|
1108
|
+
interface MapScope {
|
|
1109
|
+
/** Host path of the `$map` token. */
|
|
1110
|
+
path: OutputPath;
|
|
1111
|
+
/** Its binding name (`$map.as`), if any. */
|
|
1112
|
+
as?: string;
|
|
1113
|
+
/** The `$map` token itself. */
|
|
1114
|
+
token: Record<string, unknown>;
|
|
1115
|
+
}
|
|
1116
|
+
interface TokenSite {
|
|
1117
|
+
/** Property keys and array indices from the host root to the token
|
|
1118
|
+
* (`$map` operands appear as `…$map.over` / `…$map.to…`). */
|
|
1119
|
+
path: OutputPath;
|
|
1120
|
+
key: TokenKey;
|
|
1121
|
+
/** The token object itself (`{ $output: … }`, …). */
|
|
1122
|
+
token: Record<string, unknown>;
|
|
1123
|
+
position: TokenPosition;
|
|
1124
|
+
/** The `$map`s whose template holds this token, outermost first (the
|
|
1125
|
+
* innermost binding is last). A map's own `over` is in its OUTER scope. */
|
|
1126
|
+
scopes: readonly MapScope[];
|
|
1127
|
+
}
|
|
1128
|
+
/** `a.b[2].c` (or `<root>`). */
|
|
1129
|
+
export declare function formatPath(path: readonly (string | number)[]): string;
|
|
1130
|
+
/** Every token in `value`, in document order. `$concat` parts and `$map`
|
|
1131
|
+
* operands (`over`, then the `to` template) are visited: they may hold tokens
|
|
1132
|
+
* themselves. Each site carries the `$map` scopes it sits in. A `$$` escape
|
|
1133
|
+
* hides its operand. */
|
|
1134
|
+
export declare function collectTokenSites(value: unknown): TokenSite[];
|
|
1135
|
+
/** A one-line human rendering of a token, for `--explain` and messages. */
|
|
1136
|
+
export declare function describeToken(token: unknown): string;
|
|
1137
|
+
/** A display copy of `value` with every token replaced by `«description»`
|
|
1138
|
+
* (for printing declared hosts, e.g. `--explain drives`). */
|
|
1139
|
+
export declare function renderTokens<T>(value: T): T;
|
|
1140
|
+
/** A copy of `value` with every `$$` escape replaced by its operand (the
|
|
1141
|
+
* literal it protects). Run after the no-token walk. */
|
|
1142
|
+
export declare function unwrapEscapes<T>(value: T): T;
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region src/resolve/node.d.ts
|
|
1145
|
+
/**
|
|
1146
|
+
* Node adapters for the resolver: producer discovery (a token names a host
|
|
1147
|
+
* by FOLDER; run records are keyed by the host's `name`, so the producer's
|
|
1148
|
+
* host.js is loaded to map one to the other), the standalone run-record
|
|
1149
|
+
* output source, and the process environment.
|
|
1150
|
+
*/
|
|
1151
|
+
interface ProducerInfo {
|
|
1152
|
+
/** The folder a token names (`hosts/<folder>/`). */
|
|
1153
|
+
folder: string;
|
|
1154
|
+
/** The producer host's `name` (its run-record key). */
|
|
1155
|
+
name: string;
|
|
1156
|
+
specifier: string;
|
|
1157
|
+
runner: RunnerModule;
|
|
1158
|
+
}
|
|
1159
|
+
/** Producers by folder; a folder that fails to load carries its error. */
|
|
1160
|
+
type ProducerMap = ReadonlyMap<string, ProducerInfo | {
|
|
1161
|
+
error: string;
|
|
1162
|
+
}>;
|
|
1163
|
+
/** Load every producer host a set of refs names (each once). */
|
|
1164
|
+
export declare function loadProducers(projectRoot: string, refs: readonly OutputRef[]): Promise<ProducerMap>;
|
|
1165
|
+
/** The outputs schema of a runner module, or why it has none. */
|
|
1166
|
+
export declare function runnerOutputsSchema(runner: RunnerModule, specifier: string, label: string): OutputsSchemaLookup;
|
|
1167
|
+
/** Declared-validation lookup for a standalone host's producers. */
|
|
1168
|
+
export declare function producerOutputsSchemas(producers: ProducerMap): (ref: OutputRef) => OutputsSchemaLookup;
|
|
1169
|
+
/** Further `.ph` roots whose live run records a standalone `$output` reads
|
|
1170
|
+
* (`path.delimiter`-separated): a launcher that gives each child its own
|
|
1171
|
+
* PH_USER_DATA_DIR names its siblings' here. Locks never read them. */
|
|
1172
|
+
export declare const OUTPUT_DATA_DIRS_ENV = "PH_OUTPUT_DATA_DIRS";
|
|
1173
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Standalone `$output` source: the producer's live v2 run record. Its own
|
|
1176
|
+
* standalone record under the process's `.ph` root first (keyed by the
|
|
1177
|
+
* producer's `name`); else exactly one of: a standalone record under a
|
|
1178
|
+
* PH_OUTPUT_DATA_DIRS root, or a member running that host in a live compound
|
|
1179
|
+
* of this project under any root. A missing, stale, foreign or output-less
|
|
1180
|
+
* record means "not running", and the lookup fails naming the producer and
|
|
1181
|
+
* how to start it (no fallback to the producer's declared config, no
|
|
1182
|
+
* waiting).
|
|
1183
|
+
*/
|
|
1184
|
+
export declare function runRecordOutputSource(projectRoot: string, options: {
|
|
1185
|
+
consumer: string;
|
|
1186
|
+
producers: ProducerMap;
|
|
1187
|
+
projectName: string;
|
|
1188
|
+
env?: Env;
|
|
1189
|
+
}): OutputSource;
|
|
1190
|
+
/** The resolving process's `$env` inputs: its environment plus the
|
|
1191
|
+
* always-resolvable built-ins (`userData` honours PH_USER_DATA_DIR). */
|
|
1192
|
+
export declare function processResolveEnv(projectRoot: string, env?: Readonly<Record<string, string | undefined>>): Pick<ResolveSources, "env" | "builtins">;
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region src/expect-host.d.ts
|
|
1195
|
+
/**
|
|
1196
|
+
* What a host amounts to once its pipeline has run (typed-host-configs G2,
|
|
1197
|
+
* 2.2): the reactor-client shape its backends select, the drives it serves
|
|
1198
|
+
* or attaches, the producers whose outputs it consumes and, for a compound,
|
|
1199
|
+
* the start order and each member's expectation. Pure and platform-neutral:
|
|
1200
|
+
* the caller runs load → declared validation → resolve → resolved
|
|
1201
|
+
* validation (and plugin contribution discovery) and hands over the
|
|
1202
|
+
* results. The returned value is JSON-only, so it can be pinned in a test
|
|
1203
|
+
* table or shipped to another process (a future reactor-monitor).
|
|
1204
|
+
*/
|
|
1205
|
+
/** One backend, in placement-primary-first order. */
|
|
1206
|
+
interface ExpectedBackend {
|
|
1207
|
+
name: string;
|
|
1208
|
+
kind: ReactorBackendKind;
|
|
1209
|
+
storage?: ReactorStorageConfig["kind"];
|
|
1210
|
+
/** The RESOLVED storage dir (`"${userData}"` sugar and `$env` applied). */
|
|
1211
|
+
dataDir?: string;
|
|
1212
|
+
/** Why a provisioned reactor (a browser tab, reactor-monitor) cannot be
|
|
1213
|
+
* built from this backend (`backendToDescriptor`): e.g. postgres storage
|
|
1214
|
+
* is server-side only, a remote backend needs `remote.url`. Absent when
|
|
1215
|
+
* it can. A switchboard's own backend may legitimately carry one. */
|
|
1216
|
+
provisionError?: string;
|
|
1217
|
+
}
|
|
1218
|
+
/** One drive of the merged plan: plugin contributions first, then the
|
|
1219
|
+
* host's own declarations (the host wins a slug). Identity is the DECLARED
|
|
1220
|
+
* slug: a `projectHash` drive reports the flag, not a hashed id, so the
|
|
1221
|
+
* expectation does not depend on where the project lives. */
|
|
1222
|
+
interface ExpectedDrive {
|
|
1223
|
+
slug: string;
|
|
1224
|
+
kind: "local" | "remote";
|
|
1225
|
+
/** "host" for `reactor.drives`; the plugin name for a contribution. */
|
|
1226
|
+
source: string;
|
|
1227
|
+
/** A remote drive's resolved URL. */
|
|
1228
|
+
url?: string;
|
|
1229
|
+
id?: string;
|
|
1230
|
+
projectHash?: boolean | "id";
|
|
1231
|
+
}
|
|
1232
|
+
/** One `$output` token in the declared host. */
|
|
1233
|
+
interface ConsumedOutput {
|
|
1234
|
+
/** Host path of the token (`reactor.backends.sb.remote.url`). */
|
|
1235
|
+
at: string;
|
|
1236
|
+
host: string;
|
|
1237
|
+
member?: string;
|
|
1238
|
+
path: OutputPath;
|
|
1239
|
+
}
|
|
1240
|
+
interface HostExpectation {
|
|
1241
|
+
name: string;
|
|
1242
|
+
kind: RunnerKind;
|
|
1243
|
+
/** The verb this host runs at: `runner.defaultVerb ?? "run"` standalone;
|
|
1244
|
+
* for a compound member, its own effective verb under the compound's. */
|
|
1245
|
+
verb: string;
|
|
1246
|
+
/** Reactor hosts with backends: `reactorClientMode`. */
|
|
1247
|
+
clientMode?: ReactorClientMode;
|
|
1248
|
+
/** Reactor hosts: local AND remote backends (Connect's routing client). */
|
|
1249
|
+
multiReactor?: boolean;
|
|
1250
|
+
backends?: ExpectedBackend[];
|
|
1251
|
+
/** The resolved URLs of the remote backends, placement order. */
|
|
1252
|
+
remotes?: string[];
|
|
1253
|
+
drives?: ExpectedDrive[];
|
|
1254
|
+
/** Producers its own tokens read (`host` or `host#member`), sorted. */
|
|
1255
|
+
dependsOn: string[];
|
|
1256
|
+
consumes: ConsumedOutput[];
|
|
1257
|
+
/** `$env` names its own tokens read, sorted (values are not recorded). */
|
|
1258
|
+
env: string[];
|
|
1259
|
+
/** Compound: member keys in start order. */
|
|
1260
|
+
startOrder?: string[];
|
|
1261
|
+
/** Compound: each member's expectation. */
|
|
1262
|
+
members?: Record<string, MemberExpectation>;
|
|
1263
|
+
}
|
|
1264
|
+
interface MemberExpectation extends Omit<HostExpectation, "startOrder" | "members"> {
|
|
1265
|
+
/** The member's host folder (`children.<key>.host`). */
|
|
1266
|
+
host: string;
|
|
1267
|
+
/** Member keys this member consumes (it starts after them), sorted. */
|
|
1268
|
+
after: string[];
|
|
1269
|
+
}
|
|
1270
|
+
/** A drive a plugin contributes, as plugin contribution discovery reports
|
|
1271
|
+
* it (`resolvePluginContributions`). */
|
|
1272
|
+
interface ContributedDriveInput {
|
|
1273
|
+
declaration: Record<string, unknown>;
|
|
1274
|
+
source: string;
|
|
1275
|
+
}
|
|
1276
|
+
interface ExpectHostInput {
|
|
1277
|
+
kind: RunnerKind;
|
|
1278
|
+
/** The host as declared (tokens in place); a compound member's draft
|
|
1279
|
+
* (its host.js with the wrapper applied). */
|
|
1280
|
+
declared: Record<string, unknown>;
|
|
1281
|
+
/** The resolved (and parsed) host. Default: `declared`. */
|
|
1282
|
+
resolved?: Record<string, unknown>;
|
|
1283
|
+
/** Drives the host's plugins contribute at its verb. */
|
|
1284
|
+
contributed?: readonly ContributedDriveInput[];
|
|
1285
|
+
/** Compound: its members, any order (the plan orders them). */
|
|
1286
|
+
members?: readonly MemberInput[];
|
|
1287
|
+
/** Compound: the dependency plan (`planCompound`). */
|
|
1288
|
+
plan?: CompoundPlan;
|
|
1289
|
+
}
|
|
1290
|
+
interface MemberInput extends Omit<ExpectHostInput, "members" | "plan"> {
|
|
1291
|
+
key: string;
|
|
1292
|
+
host: string;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* The expectation for one host. A reactor host's comes from its resolved
|
|
1296
|
+
* reactor block and contributed drives; a compound's lists its members in
|
|
1297
|
+
* plan order, each with the verb it runs at under the compound's own verb
|
|
1298
|
+
* and the members it starts after.
|
|
1299
|
+
*/
|
|
1300
|
+
export declare function expectHost(input: ExpectHostInput): HostExpectation;
|
|
1301
|
+
//#endregion
|
|
1302
|
+
export { type ArrayMapToken, type BootCheckContext, type BootIssue, type BuiltinEnv, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, type CheckDeferred, type CheckHostOptions, type CheckHostResult, type CheckStage, type ChildWrapper, type CompoundHost, type CompoundHostInput, type CompoundPlan, type CompoundWiring, type ConcatToken, type ConnectPluginSlices, type ConnectReactorProjection, type ConnectRouterSettings, type ConnectStorageKind, type ConsumedOutput, type ContributedDrive, type ContributedDriveInput, type ContributionSource, type Contributions, type DeadConfigWarning, type DeclaredHostOptions, type DeclaredIssue, type DeferredResolution, type DeferredToken, type DriveDeclaration, type DrivePlanEntry, type DriveProjectionInput, type DriveSeederClient, type EnvToken, type ExpectHostInput, type ExpectedBackend, type ExpectedDrive, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, type HostDefinition, type HostExit, type HostExpectation, type HostExport, type HostImports, type HostIssue, type HostOutputsDescription, type HostPlugin, type HostPluginModule, type HostSchemaIssue, type HostSchemaIssues, type HostSchemaLike, type HostSchemas, type HostsFolderStatus, type ItemToken, type KeyToken, type LoadedHost, type MapToken, type MemberDraft, type MemberExpectation, type MemberInput, type MergedContribution, type NormalizedPluginEntry, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, type Observe, type OutputLookup, type OutputPath, type OutputRef, type OutputSource, type OutputToken, type OutputsSchemaLookup, type OwnedConfigSlice, type PHHost, type PHHostOutputs, type PlacedConnectDrives, type PlacementKeyIssue, type PlanEdge, type PlanMember, type PluginContributionsPlan, type PluginEntry, type PluginEntryData, type ProducerInfo, type ProducerMap, type Profile, type ProjectedDescriptor, type ProjectedStorage, type Provide, type ReactorBackend, type ReactorBackendKind, type ReactorClientMode, type ReactorConfig, type ReactorHost, type ReactorHostInput, type ReactorPackageConfig, type ReactorProtocol, type ReactorRemoteConfig, type ReactorStorageConfig, type RecordMapToken, type RefFn, type RemovedForm, type ResolveOptions, type ResolveSources, type ResolvedDrive, type ResolvedPlugin, type RunCompoundOptions, type RunCompoundResult, type RunProbe, type RunRecord, type RunRecordMember, type RunnerBase, type RunnerContext, RunnerError, type RunnerHandle, type RunnerHandleData, type RunnerIssue, type RunnerKind, type RunnerModule, type RunnerVerb, SWITCHBOARD_PROXY_PATHS, type SchemaIssue, type SeedResult, type SelfMembers, type ServedRemoteBackend, type SpawnHostOptions, type SpawnHostPhase, type SpawnedHost, type StartedHandle, type SwitchboardDrive, type SwitchboardReactorLayer, TOKEN_ESCAPE_KEY, TOKEN_KEYS, type Template, type Token, type TokenFor, type TokenKey, type TokenMode, type TokenPosition, type TokenSite, type TokenableSchema, type Transform, type ValidateHostOptions, applyChildWrapper, checkOutputPaths, checkTokenSites, childWrapperSchema, childrenSchema, compoundHostSchema, compoundWiringSchema, concatTokenSchema, connectReactorIssues, declaredGenericCompoundHostSchema, declaredHostSchemas, defineHostSchemas, driveAddressMessage, emitHostJsonSchema, emittedHostSchemas, envSitesOf, envTokenSchema, envTokenable, findToken, forbidRef, genericCompoundHostSchema, getVerb, hostNameSchema, hostSchemaIssues, isHtmlNavigation, isOriginPlaceholderUrl, isSchemaLike, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, kindShapeIssues, knownVerbIssues, listVerbs, makeHostSchemas, mapTokenSchema, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, placementKeyIssues, profileSchema, reactorBackendKindSchema, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, ref, refKey, refineConnectReactor, refineStartOrder, resolveOriginPlaceholders, resolveRunnerModule, runCompound, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, schemaAtPath, switchboardOfDrive, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, validateDeclaredHost, validateHost, withOriginPlaceholders };
|
|
1303
|
+
export {};
|
|
1304
|
+
//# sourceMappingURL=index.d.mts.map
|