@powerhousedao/host-core 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.
Files changed (36) hide show
  1. package/dist/compound-B6RZMA0Y.mjs +2804 -0
  2. package/dist/compound-B6RZMA0Y.mjs.map +1 -0
  3. package/dist/compound-PhoVeqe1.d.mts +2401 -0
  4. package/dist/compound-PhoVeqe1.d.mts.map +1 -0
  5. package/dist/env-substitution-C_fVirPh.d.mts +17 -0
  6. package/dist/env-substitution-C_fVirPh.d.mts.map +1 -0
  7. package/dist/env-substitution-Dj3pdsut.mjs +330 -0
  8. package/dist/env-substitution-Dj3pdsut.mjs.map +1 -0
  9. package/dist/host-schemas-mqOYNGot.d.mts +2153 -0
  10. package/dist/host-schemas-mqOYNGot.d.mts.map +1 -0
  11. package/dist/index.d.mts +908 -691
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/index.mjs +335 -109
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/plugins-XL6WsvTL.d.mts +182 -0
  16. package/dist/plugins-XL6WsvTL.d.mts.map +1 -0
  17. package/dist/plugins.d.mts +2 -120
  18. package/dist/plugins.mjs.map +1 -1
  19. package/dist/projection.d.mts +586 -0
  20. package/dist/projection.d.mts.map +1 -0
  21. package/dist/projection.mjs +1505 -0
  22. package/dist/projection.mjs.map +1 -0
  23. package/dist/runners/compound.d.mts +157 -12
  24. package/dist/runners/compound.d.mts.map +1 -1
  25. package/dist/runners/compound.mjs +5 -13
  26. package/dist/runners/compound.mjs.map +1 -1
  27. package/dist/schema.d.mts +105 -0
  28. package/dist/schema.d.mts.map +1 -0
  29. package/dist/schema.mjs +35 -0
  30. package/dist/schema.mjs.map +1 -0
  31. package/package.json +16 -4
  32. package/dist/compound-C8P0kvPJ.d.mts +0 -157
  33. package/dist/compound-C8P0kvPJ.d.mts.map +0 -1
  34. package/dist/host-schemas-CtPNRr5v.mjs +0 -720
  35. package/dist/host-schemas-CtPNRr5v.mjs.map +0 -1
  36. package/dist/plugins.d.mts.map +0 -1
@@ -0,0 +1,586 @@
1
+ import { G as OutputPath, c as ReactorBackend, et as TokenKey, g as ReactorStorageConfig, l as ReactorBackendKind, m as ReactorProtocol, u as ReactorConfig, v as RunnerKind } from "./host-schemas-mqOYNGot.mjs";
2
+ import { t as BuiltinEnv } from "./env-substitution-C_fVirPh.mjs";
3
+ import { z } from "zod";
4
+ import { PHConnectDefaultDrive, PHConnectRuntimeConfig } from "@powerhousedao/shared/clis";
5
+ //#region src/reactor-config.d.ts
6
+ /** The single primary backend for phase-2 projection (multi-backend routing is
7
+ * track R). Prefers placement.primary, else "main"/"local", else the first. */
8
+ export declare function primaryBackend(reactor: ReactorConfig | undefined): ReactorBackend | undefined;
9
+ /** The env vars a protocol block maps onto, with their string values. Only
10
+ * keys the block actually sets appear. */
11
+ export declare function protocolEnv(protocol: ReactorProtocol | undefined): Record<string, string>;
12
+ interface SwitchboardReactorProjection {
13
+ /** Env the switchboard server reads at boot. Only keys the block sets. */
14
+ env: Record<string, string>;
15
+ /** Options passed to startSwitchboard (DB path). */
16
+ options: {
17
+ dbPath?: string;
18
+ };
19
+ }
20
+ /** Project the reactor block onto the switchboard's env + options. */
21
+ export declare function projectReactorToSwitchboard(reactor: ReactorConfig | undefined): SwitchboardReactorProjection;
22
+ /** The four reactor-client shapes a Connect host can select (mirrors the
23
+ * shared PHReactorClientMode; kept local to avoid an import cycle). */
24
+ type ReactorClientMode = "in-process" | "worker" | "remote" | "router";
25
+ /**
26
+ * Which reactor client the backend topology asks for:
27
+ * - local (in-process/worker) AND remote backends -> `router`
28
+ * - remote backend(s) only -> `remote`
29
+ * - a worker backend -> `worker`
30
+ * - anything else local -> `in-process`
31
+ * `undefined` when no backends are declared — the caller then keeps the
32
+ * legacy reactorWorker/multiReactor behaviour untouched.
33
+ */
34
+ export declare function reactorClientMode(reactor: ReactorConfig | undefined): ReactorClientMode | undefined;
35
+ interface ConnectReactorProjection {
36
+ /** Patch merged into the connect runtime config (connect.*). */
37
+ connect: {
38
+ reactor?: ReactorProtocol;
39
+ instance?: {
40
+ reactorWorker?: boolean;
41
+ reactorClient?: ReactorClientMode;
42
+ };
43
+ app?: {
44
+ workflowsEnabled?: boolean;
45
+ };
46
+ };
47
+ }
48
+ /** Project the reactor block onto the Connect runtime config: protocol →
49
+ * connect.reactor (same shape), backend topology → instance.reactorWorker
50
+ * (legacy) + instance.reactorClient (the explicit 4-way selector),
51
+ * workflows → app.workflowsEnabled. */
52
+ export declare function projectReactorToConnect(reactor: ReactorConfig | undefined): ConnectReactorProjection;
53
+ /**
54
+ * The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS
55
+ * the host's protocol block, fail loudly naming the var, the host value, and
56
+ * the env value. An env var that merely matches, or is unset, is fine (phase-2
57
+ * transition keeps an operator's explicit env as an escape hatch unless it
58
+ * disagrees with the protocol — see the WBS precedence note).
59
+ */
60
+ export declare function assertProtocolConsistency(protocol: ReactorProtocol | undefined, env: Record<string, string | undefined>, hostFile?: string): void;
61
+ //#endregion
62
+ //#region src/backend-projection.d.ts
63
+ /**
64
+ * Phase 4 (track R): project named host backends onto reactor-monitor's
65
+ * `ReactorDescriptor` shape — the input `provision()` takes. Pure and
66
+ * dependency-free; a type-assignability test pins the output to the real
67
+ * `ReactorDescriptor` so an upstream field rename fails this package's tests
68
+ * instead of silently drifting (D2.b: aligned locally, upstreaming not
69
+ * blocked on).
70
+ */
71
+ /** The browser-provisionable storage union — reactor-monitor's
72
+ * `ReactorStorageConfig` shape. `postgres` is the SERVER extension (D2.b): a
73
+ * switchboard backend's storage, never a provisioned browser reactor's. */
74
+ type ProjectedStorage = {
75
+ kind: "idb";
76
+ } | {
77
+ kind: "memory";
78
+ } | {
79
+ kind: "path";
80
+ dataDir: string;
81
+ };
82
+ interface ProjectedDescriptor {
83
+ kind: "in-process" | "worker" | "remote";
84
+ name: string;
85
+ storage?: ProjectedStorage;
86
+ packages?: {
87
+ cdnUrl?: string;
88
+ specs?: string[];
89
+ dynamic?: boolean;
90
+ };
91
+ featureFlags?: {
92
+ documentDecisions?: boolean;
93
+ authEnforcement?: boolean;
94
+ authGroups?: boolean;
95
+ authConditions?: boolean;
96
+ };
97
+ remote?: {
98
+ url: string;
99
+ };
100
+ }
101
+ /** One backend → one descriptor. The protocol's featureFlags ride every
102
+ * descriptor (they are fleet consensus, not per-backend). A remote backend
103
+ * must carry remote.url — provision() requires it. */
104
+ export declare function backendToDescriptor(name: string, backend: ReactorBackend, protocol?: ReactorProtocol): ProjectedDescriptor;
105
+ /** All named backends, in placement-primary-first order (the order a
106
+ * createReactorClients step would provision them). */
107
+ export declare function backendsToDescriptors(reactor: ReactorConfig | undefined): ProjectedDescriptor[];
108
+ /**
109
+ * Structural multi-reactor (phase 4): true when the block names BOTH a local
110
+ * backend (in-process/worker — the tab's own reactor) and a remote one. This
111
+ * is the shape Connect's routing client serves; a lone remote backend is an
112
+ * attach-only host (assistant/agent shape), not a routed tab.
113
+ */
114
+ export declare function isStructuralMultiReactor(reactor: ReactorConfig | undefined): boolean;
115
+ /** The remote backends' urls, placement order — what the routing client dials. */
116
+ export declare function remoteBackendUrls(reactor: ReactorConfig | undefined): string[];
117
+ //#endregion
118
+ //#region src/connect-projection.d.ts
119
+ /**
120
+ * Concatenate groups of `connect.drives.defaultDrives` in the order given,
121
+ * de-duplicating by drive identity (URL for remote entries, id for local
122
+ * ones). The first occurrence of a drive wins, so earlier groups keep their
123
+ * position and metadata — e.g. the Vetra drive `ph vetra` starts stays first
124
+ * even when the project's `powerhouse.config.json` lists the same drive.
125
+ */
126
+ export declare function mergeDefaultDrives(...groups: PHConnectDefaultDrive[][]): PHConnectDefaultDrive[];
127
+ /**
128
+ * Rebase a local drive URL onto a public base: keeps the /d/<slug> path,
129
+ * swaps the loopback origin for the public base. Browser clients behind a
130
+ * reverse proxy can't reach http://localhost:<port>. Non-loopback URLs
131
+ * (e.g. a remote drive) are already public and pass through unchanged, as do
132
+ * unparseable ones.
133
+ */
134
+ export declare function rebaseDriveUrl(driveUrl: string, publicBase: string): string;
135
+ interface DriveProjectionInput {
136
+ /** Drive URLs the compound's reactor member created, in display order
137
+ * (e.g. vetra, preview, workflows). Null/undefined entries are skipped. */
138
+ createdDriveUrls: (string | null | undefined)[];
139
+ /** The project's configured `connect.drives.defaultDrives`. */
140
+ configuredDefaultDrives?: PHConnectDefaultDrive[];
141
+ /** `--drives-public-base`: advertise proxy-reachable URLs to the browser. */
142
+ publicBase?: string | null;
143
+ }
144
+ /**
145
+ * The compound's drives projection: created drives first (rebased onto the
146
+ * public base when given), then the project's configured drives, de-duplicated
147
+ * — and `preserve-all`, because compound-injected drive lists change per
148
+ * launch context and must never detach drives the user added by hand.
149
+ */
150
+ export declare function projectDrivesIntoConnect(input: DriveProjectionInput): Pick<PHConnectRuntimeConfig, "drives">;
151
+ //#endregion
152
+ //#region src/run-record-schema.d.ts
153
+ export declare const runRecordMemberSchema: z.ZodObject<{
154
+ host: z.ZodString;
155
+ runnerModule: z.ZodString;
156
+ kind: z.ZodEnum<{
157
+ compound: "compound";
158
+ reactor: "reactor";
159
+ }>;
160
+ verb: z.ZodString;
161
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
162
+ }, z.core.$strict>;
163
+ export declare const runRecordSchema: z.ZodObject<{
164
+ version: z.ZodLiteral<2>;
165
+ host: z.ZodString;
166
+ projectName: z.ZodString;
167
+ kind: z.ZodEnum<{
168
+ compound: "compound";
169
+ reactor: "reactor";
170
+ }>;
171
+ verb: z.ZodString;
172
+ pid: z.ZodNumber;
173
+ startedAt: z.ZodString;
174
+ outputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
175
+ members: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
176
+ host: z.ZodString;
177
+ runnerModule: z.ZodString;
178
+ kind: z.ZodEnum<{
179
+ compound: "compound";
180
+ reactor: "reactor";
181
+ }>;
182
+ verb: z.ZodString;
183
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
184
+ }, z.core.$strict>>>;
185
+ extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
186
+ }, z.core.$strict>;
187
+ type RunRecord = z.infer<typeof runRecordSchema>;
188
+ type RunRecordMember = z.infer<typeof runRecordMemberSchema>;
189
+ //#endregion
190
+ //#region src/resolve/declared.d.ts
191
+ /**
192
+ * Declared validation (pipeline step 3) of a host's tokens, before anything
193
+ * runs: operator shapes, `$env` `optional` placement, and every `$output`
194
+ * path against the producer's `outputsSchema`. No environment value is read
195
+ * and no producer needs to be running. Pure: producers are looked up through
196
+ * a callback the node side fills.
197
+ */
198
+ /** Which host's outputs a `$output` token names: `host` is the producer's
199
+ * FOLDER (`hosts/<host>/`); `member` picks one compound member when two
200
+ * share a host. */
201
+ interface OutputRef {
202
+ host: string;
203
+ member?: string;
204
+ }
205
+ interface DeclaredIssue {
206
+ /** Host path of the token (`runner.plugins[0].config.drive`). */
207
+ path: string;
208
+ message: string;
209
+ }
210
+ export declare function refKey(ref: OutputRef): string;
211
+ /** The distinct producers a host's `$output` tokens name, in document order. */
212
+ export declare function outputRefsOf(host: unknown): OutputRef[];
213
+ /** Every `$output` token with its host path and producer (for the plan and
214
+ * `--explain outputs`). */
215
+ export declare function outputSitesOf(host: unknown): {
216
+ path: string;
217
+ ref: OutputRef;
218
+ outputPath: OutputPath;
219
+ }[];
220
+ /** Every `$env` token with its host path (for `--explain outputs`). */
221
+ export declare function envSitesOf(host: unknown): {
222
+ path: string;
223
+ name: string;
224
+ optional: boolean;
225
+ }[];
226
+ /** Operator shapes and placement: malformed operands, `$item`/`$key`
227
+ * outside any `$map` or naming an unknown binding, and
228
+ * `{ $env: { name, optional: true } }` anywhere but the direct value of an
229
+ * object property (it omits that property when unset). */
230
+ export declare function checkTokenSites(host: unknown): DeclaredIssue[];
231
+ /** What a producer lookup yields: its runner's `outputsSchema` (any zod
232
+ * instance), or why there is none. */
233
+ type OutputsSchemaLookup = {
234
+ schema: unknown;
235
+ label: string;
236
+ } | {
237
+ error: string;
238
+ };
239
+ /** The schema at `path` inside a zod schema (walking objects, records,
240
+ * arrays, tuples, unions and wrappers), or why the path does not exist. */
241
+ export declare function schemaAtPath(schema: unknown, path: OutputPath): {
242
+ ok: true;
243
+ schema: unknown;
244
+ } | {
245
+ ok: false;
246
+ at: number;
247
+ reason: string;
248
+ };
249
+ /** Every `$output` token's producer exists and its path is valid against
250
+ * the producer's `outputsSchema`; every `$map`'s `over` is a collection
251
+ * there (a record under `into: "record"`), and every `$item` path exists
252
+ * in the element schema of the map it binds. */
253
+ export declare function checkOutputPaths(host: unknown, outputsSchemaOf: (ref: OutputRef) => OutputsSchemaLookup): DeclaredIssue[];
254
+ //#endregion
255
+ //#region src/resolve/plan.d.ts
256
+ /**
257
+ * The dependency plan (pipeline step 4): which compound member consumes
258
+ * which member's outputs, and the start order that follows. Producers start
259
+ * before consumers; `config.startOrder` is optional and, when given, must
260
+ * agree with the tokens. Cycles fail. Pure.
261
+ */
262
+ export declare class PlanError extends Error {
263
+ constructor(message: string);
264
+ }
265
+ interface PlanMember {
266
+ /** The member key (`children.<key>`). */
267
+ key: string;
268
+ /** The member's host folder (`children.<key>.host`). */
269
+ host: string;
270
+ /** The producers its tokens name, with the host path of one token each. */
271
+ refs: {
272
+ ref: OutputRef;
273
+ path: string;
274
+ }[];
275
+ }
276
+ interface PlanEdge {
277
+ consumer: string;
278
+ producer: string;
279
+ /** Host path in the consumer of the (first) token behind this edge. */
280
+ path: string;
281
+ }
282
+ interface CompoundPlan {
283
+ /** Member keys in start order. */
284
+ order: string[];
285
+ edges: PlanEdge[];
286
+ /** "tokens": derived from the dependencies; "startOrder": the declared
287
+ * order, checked against them. */
288
+ source: "tokens" | "startOrder";
289
+ }
290
+ /** The member a ref names: the unique member running `ref.host`, or the
291
+ * member `ref.member` when given (it must run `ref.host`). */
292
+ export declare function memberForRef(ref: OutputRef, members: readonly Pick<PlanMember, "key" | "host">[]): {
293
+ key: string;
294
+ } | {
295
+ error: string;
296
+ };
297
+ export declare function planCompound(members: readonly PlanMember[], startOrder?: readonly string[]): CompoundPlan;
298
+ //#endregion
299
+ //#region src/resolve/resolve.d.ts
300
+ /**
301
+ * The resolver (pipeline step 5): replaces every token in a declared host
302
+ * with its value. `$output` reads the producer's outputs through an
303
+ * `OutputSource` (live compound members, or a standalone run record: the
304
+ * node adapters in ./node.ts); `$env` reads the environment map of the
305
+ * resolving process; `$map` renders its `to` template once per element of
306
+ * its `over` (arrays in order, records key-sorted; `$item`/`$key` read the
307
+ * element being rendered); the `"${userData}"`/`"${projectRoot}"` string
308
+ * sugar is substituted on the way. An `$output`/`$item` that reads a field
309
+ * absent from the data but optional in the producer's schema (codegen's
310
+ * `OutputToken<T | undefined>`) omits its enclosing property, like an unset
311
+ * optional `$env`. Pure and browser-safe.
312
+ */
313
+ type OutputLookup = {
314
+ status: "available";
315
+ outputs: unknown;
316
+ /** The producer's `outputsSchema`, when known: an absent field it
317
+ * marks optional omits the consuming property instead of failing. */
318
+ schema?: unknown;
319
+ } |
320
+ /** `message` is the complete, user-facing reason (e.g. "connect needs
321
+ * outputs from host "switchboard", which is not running. …"). */
322
+ {
323
+ status: "unavailable";
324
+ message: string;
325
+ };
326
+ interface OutputSource {
327
+ lookup(ref: OutputRef): OutputLookup;
328
+ }
329
+ interface ResolveSources {
330
+ /** Where `$output` tokens read. Absent: any `$output` fails. */
331
+ outputs?: OutputSource;
332
+ /** The resolving process's environment (`$env`). */
333
+ env?: Readonly<Record<string, string | undefined>>;
334
+ /** `userData`/`projectRoot`: always resolvable `$env` names and string
335
+ * sugar. */
336
+ builtins?: BuiltinEnv;
337
+ /** The host file named in errors (`hosts/connect/host.js`). */
338
+ where?: string;
339
+ }
340
+ export declare class TokenResolutionError extends Error {
341
+ constructor(message: string);
342
+ }
343
+ /**
344
+ * The `$map` elements an issue path (from resolved validation of a resolved
345
+ * host) passes through, as text: `$map element "workflows"`. Undefined when
346
+ * the path crosses no `$map`-rendered array. Walk the SAME object
347
+ * `resolveHostOutputs` returned (provenance is by identity).
348
+ */
349
+ export declare function describeMapElements(host: unknown, path: readonly PropertyKey[]): string | undefined;
350
+ /** A compound's own member set, for `deferSelf`. */
351
+ interface SelfMembers {
352
+ /** The compound's members: key (`children.<key>`) and host folder. */
353
+ members: readonly {
354
+ key: string;
355
+ host: string;
356
+ }[];
357
+ }
358
+ /** A token in a compound's own fields that reads one of its members. */
359
+ interface DeferredToken {
360
+ /** Host path (`config.agents.assistant.url`). */
361
+ path: string;
362
+ /** The member keys whose outputs it needs. */
363
+ members: string[];
364
+ }
365
+ interface DeferredResolution<T> {
366
+ /** The host with every token resolved EXCEPT the deferred ones (still in
367
+ * place) and the `children` wrappers (member-level: each member resolves
368
+ * its own). */
369
+ host: T;
370
+ deferred: DeferredToken[];
371
+ /** The member keys any deferred token needs (start them first). */
372
+ needs: string[];
373
+ /** Resolve the deferred tokens once those members have started, from
374
+ * their live outputs (e.g. `compoundOutputSource`); returns the fully
375
+ * resolved host (children still untouched). */
376
+ finish(outputs: OutputSource): T;
377
+ }
378
+ interface ResolveOptions {
379
+ /** Resolving a COMPOUND's own fields: tokens that read one of its members
380
+ * are deferred until those members have started (see
381
+ * `DeferredResolution`); `children` is left for the members. */
382
+ deferSelf: SelfMembers;
383
+ }
384
+ /**
385
+ * Resolve every token in a declared host (or any JSON-shaped value): the
386
+ * result has the same shape with tokens replaced by values, optional unset
387
+ * `$env` properties omitted and the built-in string sugar substituted (`$$`
388
+ * escapes are kept; validateHost unwraps them). Throws `TokenResolutionError` naming the host path;
389
+ * an `$output` whose producer is not running fails with the source's
390
+ * message (no fallback, no waiting).
391
+ *
392
+ * With `{ deferSelf }` (a compound resolving its own fields), returns a
393
+ * `DeferredResolution` instead: everything but the self-references now,
394
+ * and `finish(outputs)` for the rest once the members it needs run.
395
+ */
396
+ export declare function resolveHostOutputs<T>(host: T, sources: ResolveSources): T;
397
+ export declare function resolveHostOutputs<T>(host: T, sources: ResolveSources, options: ResolveOptions): DeferredResolution<T>;
398
+ //#endregion
399
+ //#region src/resolve/removed-forms.d.ts
400
+ /**
401
+ * The cross-host forms removed in T3 (typed-host-configs 3.7), detected
402
+ * before schema validation so the error names the token form that replaces
403
+ * each one instead of a bare "Unrecognized key". clint's `agents.*.host` and
404
+ * proxy `routes.*.member` are checked by the clint runner schemas.
405
+ */
406
+ interface RemovedForm {
407
+ /** Host path of the removed value. */
408
+ path: string;
409
+ message: string;
410
+ }
411
+ /** Every removed form in a host file (reactor or compound), in document
412
+ * order. Compound wrappers are checked too. */
413
+ export declare function findRemovedForms(host: unknown): RemovedForm[];
414
+ //#endregion
415
+ //#region src/resolve/sources.d.ts
416
+ /**
417
+ * The compound output source: a member's `$output` tokens read the live
418
+ * `RunnerHandle.outputs` of the members started before it. `schemas` (member
419
+ * key → its runner's `outputsSchema`) lets an absent optional output field
420
+ * omit the consuming property. Pure (the run-record source for standalone
421
+ * hosts is node: ./node.ts).
422
+ */
423
+ export declare function compoundOutputSource(members: readonly {
424
+ key: string;
425
+ host: string;
426
+ }[], started: ReadonlyMap<string, unknown>, compound: string, schemas?: ReadonlyMap<string, unknown>): OutputSource;
427
+ //#endregion
428
+ //#region src/resolve/walk.d.ts
429
+ /**
430
+ * Token discovery over a declared (JSON-shaped) host: where every operator
431
+ * sits and in which syntactic position, which is what declared validation
432
+ * (`$env` optional placement), the dependency plan and `--explain outputs`
433
+ * read. Pure: no node imports.
434
+ */
435
+ /** Where a token sits: the direct value of an object property, an array
436
+ * element, the whole value, a `$concat` part, a `$map`'s `over`, or the
437
+ * whole `to` template of a `$map` (the top of the rendered element). */
438
+ type TokenPosition = "property" | "element" | "root" | "concat" | "over" | "template";
439
+ /** An enclosing `$map`, as seen from a token inside its `to` template. */
440
+ interface MapScope {
441
+ /** Host path of the `$map` token. */
442
+ path: OutputPath;
443
+ /** Its binding name (`$map.as`), if any. */
444
+ as?: string;
445
+ /** The `$map` token itself. */
446
+ token: Record<string, unknown>;
447
+ }
448
+ interface TokenSite {
449
+ /** Property keys and array indices from the host root to the token
450
+ * (`$map` operands appear as `…$map.over` / `…$map.to…`). */
451
+ path: OutputPath;
452
+ key: TokenKey;
453
+ /** The token object itself (`{ $output: … }`, …). */
454
+ token: Record<string, unknown>;
455
+ position: TokenPosition;
456
+ /** The `$map`s whose template holds this token, outermost first (the
457
+ * innermost binding is last). A map's own `over` is in its OUTER scope. */
458
+ scopes: readonly MapScope[];
459
+ }
460
+ /** `a.b[2].c` (or `<root>`). */
461
+ export declare function formatPath(path: readonly (string | number)[]): string;
462
+ /** Every token in `value`, in document order. `$concat` parts and `$map`
463
+ * operands (`over`, then the `to` template) are visited: they may hold tokens
464
+ * themselves. Each site carries the `$map` scopes it sits in. A `$$` escape
465
+ * hides its operand. */
466
+ export declare function collectTokenSites(value: unknown): TokenSite[];
467
+ /** A one-line human rendering of a token, for `--explain` and messages. */
468
+ export declare function describeToken(token: unknown): string;
469
+ /** A display copy of `value` with every token replaced by `«description»`
470
+ * (for printing declared hosts, e.g. `--explain drives`). */
471
+ export declare function renderTokens<T>(value: T): T;
472
+ /** A copy of `value` with every `$$` escape replaced by its operand (the
473
+ * literal it protects). Run after the no-token walk. */
474
+ export declare function unwrapEscapes<T>(value: T): T;
475
+ //#endregion
476
+ //#region src/expect-host.d.ts
477
+ /**
478
+ * What a host amounts to once its pipeline has run (typed-host-configs G2,
479
+ * 2.2): the reactor-client shape its backends select, the drives it serves
480
+ * or attaches, the producers whose outputs it consumes and, for a compound,
481
+ * the start order and each member's expectation. Pure and platform-neutral:
482
+ * the caller runs load → declared validation → resolve → resolved
483
+ * validation (and plugin contribution discovery) and hands over the
484
+ * results. The returned value is JSON-only, so it can be pinned in a test
485
+ * table or shipped to another process (a future reactor-monitor).
486
+ */
487
+ /** One backend, in placement-primary-first order. */
488
+ interface ExpectedBackend {
489
+ name: string;
490
+ kind: ReactorBackendKind;
491
+ storage?: ReactorStorageConfig["kind"];
492
+ /** The RESOLVED storage dir (`"${userData}"` sugar and `$env` applied). */
493
+ dataDir?: string;
494
+ /** Why a provisioned reactor (a browser tab, reactor-monitor) cannot be
495
+ * built from this backend (`backendToDescriptor`): e.g. postgres storage
496
+ * is server-side only, a remote backend needs `remote.url`. Absent when
497
+ * it can. A switchboard's own backend may legitimately carry one. */
498
+ provisionError?: string;
499
+ }
500
+ /** One drive of the merged plan: plugin contributions first, then the
501
+ * host's own declarations (the host wins a slug). Identity is the DECLARED
502
+ * slug: a `projectHash` drive reports the flag, not a hashed id, so the
503
+ * expectation does not depend on where the project lives. */
504
+ interface ExpectedDrive {
505
+ slug: string;
506
+ kind: "local" | "remote";
507
+ /** "host" for `reactor.drives`; the plugin name for a contribution. */
508
+ source: string;
509
+ /** A remote drive's resolved URL. */
510
+ url?: string;
511
+ id?: string;
512
+ projectHash?: boolean | "id";
513
+ }
514
+ /** One `$output` token in the declared host. */
515
+ interface ConsumedOutput {
516
+ /** Host path of the token (`reactor.backends.sb.remote.url`). */
517
+ at: string;
518
+ host: string;
519
+ member?: string;
520
+ path: OutputPath;
521
+ }
522
+ interface HostExpectation {
523
+ name: string;
524
+ kind: RunnerKind;
525
+ /** The verb this host runs at: `runner.defaultVerb ?? "run"` standalone;
526
+ * for a compound member, its own effective verb under the compound's. */
527
+ verb: string;
528
+ /** Reactor hosts with backends: `reactorClientMode`. */
529
+ clientMode?: ReactorClientMode;
530
+ /** Reactor hosts: local AND remote backends (Connect's routing client). */
531
+ multiReactor?: boolean;
532
+ backends?: ExpectedBackend[];
533
+ /** The resolved URLs of the remote backends, placement order. */
534
+ remotes?: string[];
535
+ drives?: ExpectedDrive[];
536
+ /** Producers its own tokens read (`host` or `host#member`), sorted. */
537
+ dependsOn: string[];
538
+ consumes: ConsumedOutput[];
539
+ /** `$env` names its own tokens read, sorted (values are not recorded). */
540
+ env: string[];
541
+ /** Compound: member keys in start order. */
542
+ startOrder?: string[];
543
+ /** Compound: each member's expectation. */
544
+ members?: Record<string, MemberExpectation>;
545
+ }
546
+ interface MemberExpectation extends Omit<HostExpectation, "startOrder" | "members"> {
547
+ /** The member's host folder (`children.<key>.host`). */
548
+ host: string;
549
+ /** Member keys this member consumes (it starts after them), sorted. */
550
+ after: string[];
551
+ }
552
+ /** A drive a plugin contributes, as plugin contribution discovery reports
553
+ * it (`resolvePluginContributions`). */
554
+ interface ContributedDriveInput {
555
+ declaration: Record<string, unknown>;
556
+ source: string;
557
+ }
558
+ interface ExpectHostInput {
559
+ kind: RunnerKind;
560
+ /** The host as declared (tokens in place); a compound member's draft
561
+ * (its host.js with the wrapper applied). */
562
+ declared: Record<string, unknown>;
563
+ /** The resolved (and parsed) host. Default: `declared`. */
564
+ resolved?: Record<string, unknown>;
565
+ /** Drives the host's plugins contribute at its verb. */
566
+ contributed?: readonly ContributedDriveInput[];
567
+ /** Compound: its members, any order (the plan orders them). */
568
+ members?: readonly MemberInput[];
569
+ /** Compound: the dependency plan (`planCompound`). */
570
+ plan?: CompoundPlan;
571
+ }
572
+ interface MemberInput extends Omit<ExpectHostInput, "members" | "plan"> {
573
+ key: string;
574
+ host: string;
575
+ }
576
+ /**
577
+ * The expectation for one host. A reactor host's comes from its resolved
578
+ * reactor block and contributed drives; a compound's lists its members in
579
+ * plan order, each with the verb it runs at under the compound's own verb
580
+ * and the members it starts after.
581
+ */
582
+ export declare function expectHost(input: ExpectHostInput): HostExpectation;
583
+ //#endregion
584
+ export type { CompoundPlan, ConnectReactorProjection, ConsumedOutput, ContributedDriveInput, DeclaredIssue, DeferredResolution, DeferredToken, DriveProjectionInput, ExpectHostInput, ExpectedBackend, ExpectedDrive, HostExpectation, MemberExpectation, MemberInput, OutputLookup, OutputRef, OutputSource, OutputsSchemaLookup, PlanEdge, PlanMember, ProjectedDescriptor, ProjectedStorage, ReactorClientMode, RemovedForm, ResolveOptions, ResolveSources, RunRecord, RunRecordMember, SelfMembers, SwitchboardReactorProjection, TokenPosition, TokenSite };
585
+ export {};
586
+ //# sourceMappingURL=projection.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.mts","names":[],"sources":["../src/reactor-config.ts","../src/backend-projection.ts","../src/connect-projection.ts","../src/run-record-schema.ts","../src/resolve/declared.ts","../src/resolve/plan.ts","../src/resolve/resolve.ts","../src/resolve/removed-forms.ts","../src/resolve/sources.ts","../src/resolve/walk.ts","../src/expect-host.ts"],"mappings":"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"}