@powerhousedao/host-core 6.2.3-dev.58 → 6.2.3-dev.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{compound-9--OujO-.d.mts → compound-C8P0kvPJ.d.mts} +7 -5
- package/dist/compound-C8P0kvPJ.d.mts.map +1 -0
- package/dist/{host-schemas-C_MLcYX6.mjs → host-schemas-CL_wFpY7.mjs} +193 -20
- package/dist/host-schemas-CL_wFpY7.mjs.map +1 -0
- package/dist/index.d.mts +316 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +55 -2
- package/dist/index.mjs.map +1 -1
- package/dist/plugins.d.mts +127 -0
- package/dist/plugins.d.mts.map +1 -0
- package/dist/plugins.mjs +174 -0
- package/dist/plugins.mjs.map +1 -0
- package/dist/runners/compound.d.mts +47 -3
- package/dist/runners/compound.d.mts.map +1 -1
- package/dist/runners/compound.mjs +1 -1
- package/package.json +9 -3
- package/dist/compound-9--OujO-.d.mts.map +0 -1
- package/dist/host-schemas-C_MLcYX6.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as probeHostsFolder, S as loadHost, _ as HostLoadError, a as RunnerHandle, b as findNonStaticValue, c as RunnerContext, d as RunnerVerb, f as getVerb, g as HostDefinition, h as validateHost, i as RunCompoundResult, l as RunnerError, m as resolveRunnerModule, n as CompoundWiring, o as runCompound, p as listVerbs, r as RunCompoundOptions, s as HostSchemaLike, t as CompoundMember, u as RunnerModule, v as HostsFolderStatus, x as lintHostImports, y as LoadedHost } from "./compound-
|
|
1
|
+
import { C as probeHostsFolder, S as loadHost, _ as HostLoadError, a as RunnerHandle, b as findNonStaticValue, c as RunnerContext, d as RunnerVerb, f as getVerb, g as HostDefinition, h as validateHost, i as RunCompoundResult, l as RunnerError, m as resolveRunnerModule, n as CompoundWiring, o as runCompound, p as listVerbs, r as RunCompoundOptions, s as HostSchemaLike, t as CompoundMember, u as RunnerModule, v as HostsFolderStatus, x as lintHostImports, y as LoadedHost } from "./compound-C8P0kvPJ.mjs";
|
|
2
|
+
import { ContributionSource, Contributions, HostPlugin, HostPluginModule, MergedContribution, NormalizedPluginEntry, Observe, PluginEntry, PluginError, Provide, ResolvedPlugin, Transform, entryActiveForVerb, hostTypeSatisfies, mergeContributions, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, registerHostType, resolveOrder, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook } from "./plugins.mjs";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { PHConnectDefaultDrive, PHConnectRuntimeConfig } from "@powerhousedao/shared/clis";
|
|
4
5
|
//#region src/connect-projection.d.ts
|
|
@@ -305,6 +306,13 @@ export declare const reactorBackendSchema: z.ZodObject<{
|
|
|
305
306
|
host: z.ZodOptional<z.ZodString>;
|
|
306
307
|
url: z.ZodOptional<z.ZodString>;
|
|
307
308
|
}, z.core.$strict>>;
|
|
309
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
310
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
311
|
+
dbPoolSize: z.ZodOptional<z.ZodNumber>;
|
|
312
|
+
}, z.core.$strict>>;
|
|
313
|
+
executors: z.ZodOptional<z.ZodObject<{
|
|
314
|
+
numWorkers: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>>;
|
|
315
|
+
}, z.core.$strict>>;
|
|
308
316
|
}, z.core.$strict>;
|
|
309
317
|
export declare const reactorSchema: z.ZodObject<{
|
|
310
318
|
backends: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -335,12 +343,18 @@ export declare const reactorSchema: z.ZodObject<{
|
|
|
335
343
|
host: z.ZodOptional<z.ZodString>;
|
|
336
344
|
url: z.ZodOptional<z.ZodString>;
|
|
337
345
|
}, z.core.$strict>>;
|
|
346
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
347
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
348
|
+
dbPoolSize: z.ZodOptional<z.ZodNumber>;
|
|
349
|
+
}, z.core.$strict>>;
|
|
350
|
+
executors: z.ZodOptional<z.ZodObject<{
|
|
351
|
+
numWorkers: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>>;
|
|
352
|
+
}, z.core.$strict>>;
|
|
338
353
|
}, z.core.$strict>>>;
|
|
339
354
|
placement: z.ZodOptional<z.ZodObject<{
|
|
340
355
|
primary: z.ZodOptional<z.ZodString>;
|
|
341
356
|
default: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
342
357
|
}, z.core.$strict>>;
|
|
343
|
-
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
344
358
|
protocol: z.ZodOptional<z.ZodObject<{
|
|
345
359
|
featureFlags: z.ZodOptional<z.ZodObject<{
|
|
346
360
|
documentDecisions: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -357,6 +371,40 @@ export declare const reactorSchema: z.ZodObject<{
|
|
|
357
371
|
refuse: "refuse";
|
|
358
372
|
}>>;
|
|
359
373
|
}, z.core.$strict>>;
|
|
374
|
+
/** DEPRECATED (dies in R2): workflows become a listed plugin — presence is
|
|
375
|
+
* activation. Kept parsing until the switchboard rewire lands. */
|
|
376
|
+
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
377
|
+
renown: z.ZodOptional<z.ZodObject<{
|
|
378
|
+
url: z.ZodOptional<z.ZodString>;
|
|
379
|
+
networkId: z.ZodOptional<z.ZodString>;
|
|
380
|
+
chainId: z.ZodOptional<z.ZodNumber>;
|
|
381
|
+
}, z.core.$strict>>;
|
|
382
|
+
packages: z.ZodOptional<z.ZodObject<{
|
|
383
|
+
registryUrl: z.ZodOptional<z.ZodString>;
|
|
384
|
+
}, z.core.$strict>>;
|
|
385
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
386
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
387
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
388
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
389
|
+
renown: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
390
|
+
}, z.core.$strict>>;
|
|
391
|
+
drives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
392
|
+
slug: z.ZodString;
|
|
393
|
+
id: z.ZodOptional<z.ZodString>;
|
|
394
|
+
projectHash: z.ZodOptional<z.ZodBoolean>;
|
|
395
|
+
name: z.ZodOptional<z.ZodString>;
|
|
396
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
397
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
398
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
399
|
+
private: "private";
|
|
400
|
+
public: "public";
|
|
401
|
+
shared: "shared";
|
|
402
|
+
}>>;
|
|
403
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
404
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
405
|
+
url: z.ZodString;
|
|
406
|
+
}, z.core.$strict>>;
|
|
407
|
+
}, z.core.$strict>>>;
|
|
360
408
|
}, z.core.$strict>;
|
|
361
409
|
/** Common runner options every host.runner carries; runner modules extend it
|
|
362
410
|
* loosely with their own process options. */
|
|
@@ -364,12 +412,22 @@ export declare const runnerBaseSchema: z.ZodObject<{
|
|
|
364
412
|
module: z.ZodString;
|
|
365
413
|
defaultVerb: z.ZodOptional<z.ZodString>;
|
|
366
414
|
port: z.ZodOptional<z.ZodNumber>;
|
|
415
|
+
/** Bind address; each runner documents its default (0.0.0.0 for servers,
|
|
416
|
+
* localhost for vite dev, 127.0.0.1 for serve). */
|
|
417
|
+
host: z.ZodOptional<z.ZodString>;
|
|
418
|
+
/** THE COMPOSITION: the plugin entries this host boots with. Presence is
|
|
419
|
+
* activation; see plugins.ts for entry semantics. */
|
|
420
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
421
|
+
module: z.ZodString;
|
|
422
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
423
|
+
verbs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
424
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
425
|
+
}, z.core.$strict>]>>>;
|
|
367
426
|
}, z.core.$loose>;
|
|
368
427
|
/** A compound's children map (mutually exclusive with `reactor` — the XOR is
|
|
369
428
|
* structural, enforced by the loader; schemas validate each side's shape). */
|
|
370
429
|
export declare const childrenSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
371
430
|
host: z.ZodString;
|
|
372
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
373
431
|
runner: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
374
432
|
config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
375
433
|
reactor: z.ZodOptional<z.ZodObject<{
|
|
@@ -401,12 +459,18 @@ export declare const childrenSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
|
401
459
|
host: z.ZodOptional<z.ZodString>;
|
|
402
460
|
url: z.ZodOptional<z.ZodString>;
|
|
403
461
|
}, z.core.$strict>>;
|
|
462
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
463
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
464
|
+
dbPoolSize: z.ZodOptional<z.ZodNumber>;
|
|
465
|
+
}, z.core.$strict>>;
|
|
466
|
+
executors: z.ZodOptional<z.ZodObject<{
|
|
467
|
+
numWorkers: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>>;
|
|
468
|
+
}, z.core.$strict>>;
|
|
404
469
|
}, z.core.$strict>>>;
|
|
405
470
|
placement: z.ZodOptional<z.ZodObject<{
|
|
406
471
|
primary: z.ZodOptional<z.ZodString>;
|
|
407
472
|
default: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
408
473
|
}, z.core.$strict>>;
|
|
409
|
-
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
410
474
|
protocol: z.ZodOptional<z.ZodObject<{
|
|
411
475
|
featureFlags: z.ZodOptional<z.ZodObject<{
|
|
412
476
|
documentDecisions: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -423,6 +487,40 @@ export declare const childrenSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
|
423
487
|
refuse: "refuse";
|
|
424
488
|
}>>;
|
|
425
489
|
}, z.core.$strict>>;
|
|
490
|
+
/** DEPRECATED (dies in R2): workflows become a listed plugin — presence is
|
|
491
|
+
* activation. Kept parsing until the switchboard rewire lands. */
|
|
492
|
+
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
493
|
+
renown: z.ZodOptional<z.ZodObject<{
|
|
494
|
+
url: z.ZodOptional<z.ZodString>;
|
|
495
|
+
networkId: z.ZodOptional<z.ZodString>;
|
|
496
|
+
chainId: z.ZodOptional<z.ZodNumber>;
|
|
497
|
+
}, z.core.$strict>>;
|
|
498
|
+
packages: z.ZodOptional<z.ZodObject<{
|
|
499
|
+
registryUrl: z.ZodOptional<z.ZodString>;
|
|
500
|
+
}, z.core.$strict>>;
|
|
501
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
502
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
503
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
504
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
505
|
+
renown: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
506
|
+
}, z.core.$strict>>;
|
|
507
|
+
drives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
508
|
+
slug: z.ZodString;
|
|
509
|
+
id: z.ZodOptional<z.ZodString>;
|
|
510
|
+
projectHash: z.ZodOptional<z.ZodBoolean>;
|
|
511
|
+
name: z.ZodOptional<z.ZodString>;
|
|
512
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
513
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
514
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
515
|
+
private: "private";
|
|
516
|
+
public: "public";
|
|
517
|
+
shared: "shared";
|
|
518
|
+
}>>;
|
|
519
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
520
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
521
|
+
url: z.ZodString;
|
|
522
|
+
}, z.core.$strict>>;
|
|
523
|
+
}, z.core.$strict>>>;
|
|
426
524
|
}, z.core.$strict>>;
|
|
427
525
|
}, z.core.$strict>>;
|
|
428
526
|
/** Composed generic host shapes — the basis for the emitted editor schemas
|
|
@@ -434,6 +532,17 @@ export declare const reactorHostSchema: z.ZodObject<{
|
|
|
434
532
|
module: z.ZodString;
|
|
435
533
|
defaultVerb: z.ZodOptional<z.ZodString>;
|
|
436
534
|
port: z.ZodOptional<z.ZodNumber>;
|
|
535
|
+
/** Bind address; each runner documents its default (0.0.0.0 for servers,
|
|
536
|
+
* localhost for vite dev, 127.0.0.1 for serve). */
|
|
537
|
+
host: z.ZodOptional<z.ZodString>;
|
|
538
|
+
/** THE COMPOSITION: the plugin entries this host boots with. Presence is
|
|
539
|
+
* activation; see plugins.ts for entry semantics. */
|
|
540
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
541
|
+
module: z.ZodString;
|
|
542
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
543
|
+
verbs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
544
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
545
|
+
}, z.core.$strict>]>>>;
|
|
437
546
|
}, z.core.$loose>;
|
|
438
547
|
config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
439
548
|
profile: z.ZodOptional<z.ZodObject<{
|
|
@@ -471,12 +580,18 @@ export declare const reactorHostSchema: z.ZodObject<{
|
|
|
471
580
|
host: z.ZodOptional<z.ZodString>;
|
|
472
581
|
url: z.ZodOptional<z.ZodString>;
|
|
473
582
|
}, z.core.$strict>>;
|
|
583
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
584
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
585
|
+
dbPoolSize: z.ZodOptional<z.ZodNumber>;
|
|
586
|
+
}, z.core.$strict>>;
|
|
587
|
+
executors: z.ZodOptional<z.ZodObject<{
|
|
588
|
+
numWorkers: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>>;
|
|
589
|
+
}, z.core.$strict>>;
|
|
474
590
|
}, z.core.$strict>>>;
|
|
475
591
|
placement: z.ZodOptional<z.ZodObject<{
|
|
476
592
|
primary: z.ZodOptional<z.ZodString>;
|
|
477
593
|
default: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
478
594
|
}, z.core.$strict>>;
|
|
479
|
-
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
480
595
|
protocol: z.ZodOptional<z.ZodObject<{
|
|
481
596
|
featureFlags: z.ZodOptional<z.ZodObject<{
|
|
482
597
|
documentDecisions: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -493,6 +608,40 @@ export declare const reactorHostSchema: z.ZodObject<{
|
|
|
493
608
|
refuse: "refuse";
|
|
494
609
|
}>>;
|
|
495
610
|
}, z.core.$strict>>;
|
|
611
|
+
/** DEPRECATED (dies in R2): workflows become a listed plugin — presence is
|
|
612
|
+
* activation. Kept parsing until the switchboard rewire lands. */
|
|
613
|
+
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
614
|
+
renown: z.ZodOptional<z.ZodObject<{
|
|
615
|
+
url: z.ZodOptional<z.ZodString>;
|
|
616
|
+
networkId: z.ZodOptional<z.ZodString>;
|
|
617
|
+
chainId: z.ZodOptional<z.ZodNumber>;
|
|
618
|
+
}, z.core.$strict>>;
|
|
619
|
+
packages: z.ZodOptional<z.ZodObject<{
|
|
620
|
+
registryUrl: z.ZodOptional<z.ZodString>;
|
|
621
|
+
}, z.core.$strict>>;
|
|
622
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
623
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
624
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
625
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
626
|
+
renown: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
627
|
+
}, z.core.$strict>>;
|
|
628
|
+
drives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
629
|
+
slug: z.ZodString;
|
|
630
|
+
id: z.ZodOptional<z.ZodString>;
|
|
631
|
+
projectHash: z.ZodOptional<z.ZodBoolean>;
|
|
632
|
+
name: z.ZodOptional<z.ZodString>;
|
|
633
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
634
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
635
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
636
|
+
private: "private";
|
|
637
|
+
public: "public";
|
|
638
|
+
shared: "shared";
|
|
639
|
+
}>>;
|
|
640
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
641
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
642
|
+
url: z.ZodString;
|
|
643
|
+
}, z.core.$strict>>;
|
|
644
|
+
}, z.core.$strict>>>;
|
|
496
645
|
}, z.core.$strict>>;
|
|
497
646
|
}, z.core.$loose>;
|
|
498
647
|
export declare const compoundHostSchema: z.ZodObject<{
|
|
@@ -501,10 +650,20 @@ export declare const compoundHostSchema: z.ZodObject<{
|
|
|
501
650
|
module: z.ZodString;
|
|
502
651
|
defaultVerb: z.ZodOptional<z.ZodString>;
|
|
503
652
|
port: z.ZodOptional<z.ZodNumber>;
|
|
653
|
+
/** Bind address; each runner documents its default (0.0.0.0 for servers,
|
|
654
|
+
* localhost for vite dev, 127.0.0.1 for serve). */
|
|
655
|
+
host: z.ZodOptional<z.ZodString>;
|
|
656
|
+
/** THE COMPOSITION: the plugin entries this host boots with. Presence is
|
|
657
|
+
* activation; see plugins.ts for entry semantics. */
|
|
658
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
659
|
+
module: z.ZodString;
|
|
660
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
661
|
+
verbs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
662
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
663
|
+
}, z.core.$strict>]>>>;
|
|
504
664
|
}, z.core.$loose>;
|
|
505
665
|
children: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
506
666
|
host: z.ZodString;
|
|
507
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
508
667
|
runner: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
509
668
|
config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
510
669
|
reactor: z.ZodOptional<z.ZodObject<{
|
|
@@ -536,12 +695,18 @@ export declare const compoundHostSchema: z.ZodObject<{
|
|
|
536
695
|
host: z.ZodOptional<z.ZodString>;
|
|
537
696
|
url: z.ZodOptional<z.ZodString>;
|
|
538
697
|
}, z.core.$strict>>;
|
|
698
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
699
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
700
|
+
dbPoolSize: z.ZodOptional<z.ZodNumber>;
|
|
701
|
+
}, z.core.$strict>>;
|
|
702
|
+
executors: z.ZodOptional<z.ZodObject<{
|
|
703
|
+
numWorkers: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>>;
|
|
704
|
+
}, z.core.$strict>>;
|
|
539
705
|
}, z.core.$strict>>>;
|
|
540
706
|
placement: z.ZodOptional<z.ZodObject<{
|
|
541
707
|
primary: z.ZodOptional<z.ZodString>;
|
|
542
708
|
default: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
543
709
|
}, z.core.$strict>>;
|
|
544
|
-
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
545
710
|
protocol: z.ZodOptional<z.ZodObject<{
|
|
546
711
|
featureFlags: z.ZodOptional<z.ZodObject<{
|
|
547
712
|
documentDecisions: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -558,6 +723,40 @@ export declare const compoundHostSchema: z.ZodObject<{
|
|
|
558
723
|
refuse: "refuse";
|
|
559
724
|
}>>;
|
|
560
725
|
}, z.core.$strict>>;
|
|
726
|
+
/** DEPRECATED (dies in R2): workflows become a listed plugin — presence is
|
|
727
|
+
* activation. Kept parsing until the switchboard rewire lands. */
|
|
728
|
+
workflows: z.ZodOptional<z.ZodBoolean>;
|
|
729
|
+
renown: z.ZodOptional<z.ZodObject<{
|
|
730
|
+
url: z.ZodOptional<z.ZodString>;
|
|
731
|
+
networkId: z.ZodOptional<z.ZodString>;
|
|
732
|
+
chainId: z.ZodOptional<z.ZodNumber>;
|
|
733
|
+
}, z.core.$strict>>;
|
|
734
|
+
packages: z.ZodOptional<z.ZodObject<{
|
|
735
|
+
registryUrl: z.ZodOptional<z.ZodString>;
|
|
736
|
+
}, z.core.$strict>>;
|
|
737
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
738
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
739
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
740
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
741
|
+
renown: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
742
|
+
}, z.core.$strict>>;
|
|
743
|
+
drives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
744
|
+
slug: z.ZodString;
|
|
745
|
+
id: z.ZodOptional<z.ZodString>;
|
|
746
|
+
projectHash: z.ZodOptional<z.ZodBoolean>;
|
|
747
|
+
name: z.ZodOptional<z.ZodString>;
|
|
748
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
749
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
750
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
751
|
+
private: "private";
|
|
752
|
+
public: "public";
|
|
753
|
+
shared: "shared";
|
|
754
|
+
}>>;
|
|
755
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
756
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
757
|
+
url: z.ZodString;
|
|
758
|
+
}, z.core.$strict>>;
|
|
759
|
+
}, z.core.$strict>>>;
|
|
561
760
|
}, z.core.$strict>>;
|
|
562
761
|
}, z.core.$strict>>;
|
|
563
762
|
config: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
@@ -573,6 +772,115 @@ export declare const compoundHostSchema: z.ZodObject<{
|
|
|
573
772
|
* them, per the runtime-config-schema pattern. */
|
|
574
773
|
export declare function emittedHostSchemas(): Record<string, unknown>;
|
|
575
774
|
//#endregion
|
|
576
|
-
|
|
775
|
+
//#region src/plugins-resolve.d.ts
|
|
776
|
+
/**
|
|
777
|
+
* Resolve host.js plugin entries into live plugins for one host boot:
|
|
778
|
+
* verb-filter → module resolution from the project tree (default condition,
|
|
779
|
+
* like runners) → factory/object contract → config validation → appliesTo.
|
|
780
|
+
*/
|
|
781
|
+
export declare function resolveHostPlugins<THooks = Record<string, unknown>>(projectRoot: string, hostType: string, verb: string, entries: readonly PluginEntry[], where: string): Promise<ResolvedPlugin<THooks>[]>;
|
|
782
|
+
//#endregion
|
|
783
|
+
//#region src/drives.d.ts
|
|
784
|
+
/**
|
|
785
|
+
* R1 — core drive declarations. A reactor without drives is not a running
|
|
786
|
+
* reactor, so declaring + seeding them is HOST RUNTIME work (not a plugin):
|
|
787
|
+
* onReactorReady → idempotent slug-keyed seeding → onDrivesReady. Plugins
|
|
788
|
+
* CONTRIBUTE declarations into the same merged list (Contributions.drives);
|
|
789
|
+
* `--explain drives` prints the merged set with provenance.
|
|
790
|
+
*
|
|
791
|
+
* Field semantics (union of the three existing creation sites — vetra,
|
|
792
|
+
* preview, workflows — plus Connect's PHConnectDefaultDrive):
|
|
793
|
+
* - slug: the SEEDING KEY (idempotence); id optional (stable identity),
|
|
794
|
+
* projectHash derives both from the project path (generateProjectDriveId
|
|
795
|
+
* semantics: `${slug}-${sha256(projectPath).slice(0, 8)}`).
|
|
796
|
+
* - preferredEditor: binds the drive to its drive app — stored at
|
|
797
|
+
* header.meta.preferredEditor; Connect config's `app` is the legacy alias.
|
|
798
|
+
* - remote.url: an attachment to a drive served elsewhere (Connect default
|
|
799
|
+
* drives, switchboard remoteDrives); local fields are ignored for remotes.
|
|
800
|
+
*/
|
|
801
|
+
export declare const driveDeclarationSchema: z.ZodObject<{
|
|
802
|
+
slug: z.ZodString;
|
|
803
|
+
id: z.ZodOptional<z.ZodString>;
|
|
804
|
+
/** Derive id (and the served slug) from the project path, like
|
|
805
|
+
* generateProjectDriveId — same ids classic `ph vetra` produces. */
|
|
806
|
+
projectHash: z.ZodOptional<z.ZodBoolean>;
|
|
807
|
+
name: z.ZodOptional<z.ZodString>;
|
|
808
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
809
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
810
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
811
|
+
private: "private";
|
|
812
|
+
public: "public";
|
|
813
|
+
shared: "shared";
|
|
814
|
+
}>>;
|
|
815
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
816
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
817
|
+
url: z.ZodString;
|
|
818
|
+
}, z.core.$strict>>;
|
|
819
|
+
}, z.core.$strict>;
|
|
820
|
+
type DriveDeclaration = z.infer<typeof driveDeclarationSchema>;
|
|
821
|
+
export declare const drivesSchema: z.ZodArray<z.ZodObject<{
|
|
822
|
+
slug: z.ZodString;
|
|
823
|
+
id: z.ZodOptional<z.ZodString>;
|
|
824
|
+
/** Derive id (and the served slug) from the project path, like
|
|
825
|
+
* generateProjectDriveId — same ids classic `ph vetra` produces. */
|
|
826
|
+
projectHash: z.ZodOptional<z.ZodBoolean>;
|
|
827
|
+
name: z.ZodOptional<z.ZodString>;
|
|
828
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
829
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
830
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
831
|
+
private: "private";
|
|
832
|
+
public: "public";
|
|
833
|
+
shared: "shared";
|
|
834
|
+
}>>;
|
|
835
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
836
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
837
|
+
url: z.ZodString;
|
|
838
|
+
}, z.core.$strict>>;
|
|
839
|
+
}, z.core.$strict>>;
|
|
840
|
+
export declare function projectDriveId(projectRoot: string, slug: string): string;
|
|
841
|
+
interface ResolvedDrive {
|
|
842
|
+
kind: "local" | "remote";
|
|
843
|
+
id: string;
|
|
844
|
+
slug: string;
|
|
845
|
+
name: string;
|
|
846
|
+
icon?: string;
|
|
847
|
+
preferredEditor?: string;
|
|
848
|
+
sharingType: "public" | "private" | "shared";
|
|
849
|
+
availableOffline: boolean;
|
|
850
|
+
remoteUrl?: string;
|
|
851
|
+
}
|
|
852
|
+
export declare function resolveDriveDeclaration(projectRoot: string, decl: DriveDeclaration): ResolvedDrive;
|
|
853
|
+
/** The minimal client surface the seeder needs — runners adapt their reactor
|
|
854
|
+
* clients (IReactorClient, addDefaultDrive-style helpers) onto it. */
|
|
855
|
+
interface DriveSeederClient {
|
|
856
|
+
/** Return the existing drive's id for a slug, or undefined. */
|
|
857
|
+
findDriveBySlug(slug: string): Promise<string | undefined>;
|
|
858
|
+
/** Create a local drive; preferredEditor lands on header.meta. */
|
|
859
|
+
createDrive(drive: ResolvedDrive): Promise<void>;
|
|
860
|
+
/** Attach a remote drive by URL (idempotent on the client side). */
|
|
861
|
+
attachRemoteDrive(url: string): Promise<void>;
|
|
862
|
+
}
|
|
863
|
+
interface SeedResult {
|
|
864
|
+
created: string[];
|
|
865
|
+
existing: string[];
|
|
866
|
+
attached: string[];
|
|
867
|
+
}
|
|
868
|
+
/** Idempotent, slug-keyed: an existing slug is left untouched (never
|
|
869
|
+
* recreated, never mutated — preserveStrategy refinements live here later). */
|
|
870
|
+
export declare function seedDrives(client: DriveSeederClient, drives: readonly ResolvedDrive[]): Promise<SeedResult>;
|
|
871
|
+
interface DrivePlanEntry {
|
|
872
|
+
drive: ResolvedDrive;
|
|
873
|
+
/** "host" for host.js declarations; a plugin name for contributions. */
|
|
874
|
+
source: string;
|
|
875
|
+
}
|
|
876
|
+
/** Merge host-declared drives with plugin contributions, slug-keyed — the
|
|
877
|
+
* host file wins on conflicts (it is the most explicit source). */
|
|
878
|
+
export declare function mergeDrivePlan(projectRoot: string, hostDeclared: readonly DriveDeclaration[], contributed: readonly {
|
|
879
|
+
declaration: DriveDeclaration;
|
|
880
|
+
source: string;
|
|
881
|
+
}[]): DrivePlanEntry[];
|
|
882
|
+
export declare function explainDrivePlan(plan: readonly DrivePlanEntry[]): string;
|
|
883
|
+
//#endregion
|
|
884
|
+
export { type CompoundMember, type CompoundWiring, type ConnectReactorProjection, type ContributionSource, type Contributions, type DriveDeclaration, type DrivePlanEntry, type DriveProjectionInput, type DriveSeederClient, type HostDefinition, HostLoadError, type HostPlugin, type HostPluginModule, type HostSchemaLike, type HostsFolderStatus, type LoadedHost, type MergedContribution, type NormalizedPluginEntry, type Observe, type PluginEntry, PluginError, type ProjectedDescriptor, type Provide, type ReactorBackend, type ReactorConfig, type ReactorProtocol, type ResolvedDrive, type ResolvedPlugin, type RunCompoundOptions, type RunCompoundResult, type RunProbe, type RunRecord, type RunRecordMember, type RunnerContext, RunnerError, type RunnerHandle, type RunnerModule, type RunnerVerb, type SeedResult, type SwitchboardReactorProjection, type Transform, entryActiveForVerb, findNonStaticValue, getVerb, hostTypeSatisfies, lintHostImports, listVerbs, loadHost, mergeContributions, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, probeHostsFolder, registerHostType, resolveOrder, resolveRunnerModule, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook, validateHost };
|
|
577
885
|
export {};
|
|
578
886
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/connect-projection.ts","../src/run-record.ts","../src/placeholders.ts","../src/reactor-config.ts","../src/backend-projection.ts","../src/host-schemas.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/connect-projection.ts","../src/run-record.ts","../src/placeholders.ts","../src/reactor-config.ts","../src/backend-projection.ts","../src/host-schemas.ts","../src/plugins-resolve.ts","../src/drives.ts"],"mappings":";;;;;;;;;;;;wBA+BgB,sBACX,QAAQ,4BACV;;;;;;;;wBAqBa,eAAe,kBAAkB;UAahC;;;EAGf;;EAEA,0BAA0B;;EAE1B;;;;;;;;wBASc,yBACd,OAAO,uBACN,KAAK;;;;;;;;;;UC3ES;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA,SAAS,eAAe;;EAExB,QAAQ;;KAGE;EACN;;EACA;EAAiB,QAAQ;;EACzB;EAAgB,QAAQ;;EACxB;EAAmB,QAAQ;;wBAMjB,cACd,oBACA,mBACC;wBAUa,eAAe,oBAAoB,QAAQ;wBAM3C,eAAe,oBAAoB;wBAQnC,WAAW;;;;;;;;;;wBAmBX,SACd,oBACA,kBACA,sBACC;;;;;;;;;;wBC5Ea,mBACd,qBACA,MAAK;;;wBASS,4BAA4B,GAAG,OAAO,GAAG,mBAAmB;;;;;;;;;;;KCXhE;UAEK;EACf;EACA;EACA;;UAGe;EACf;EACA;;EAEA;;UAGe;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAW1B,EAAA,KAAA;;;;qBAKY,mBAAiB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM5B,EAAA,KAAA;qBAEW,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM7B,EAAA,KAAA;;;;wBAOc,sBAAsB;;;;;;;;wBClIhB,mBAAmB,SAAS,yBAChD,qBACA,kBACA,cACA,kBAAkB,eAClB,gBACC,QAAQ,eAAe;;;;;;;;;;;;;;;;;;;;qBClBb,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;GAYjC,EAAA,KAAA;KAEU,mBAAmB,EAAE,aAAa;qBAEjC,cAAY,EAAA,SAAA,EAAA;;;;;;;;;;;;;;;;;;GAAkC,EAAA,KAAA;wBAE3C,eAAe,qBAAqB;UASnC;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGc,wBACd,qBACA,MAAM,mBACL;;;UAkCc;;EAEf,gBAAgB,eAAe;;EAE/B,YAAY,OAAO,gBAAgB;;EAEnC,kBAAkB,cAAc;;UAGjB;EACf;EACA;EACA;;;;wBAKoB,WACpB,QAAQ,mBACR,iBAAiB,kBAChB,QAAQ;UAqBM;EACf,OAAO;;EAEP;;;;wBAKc,eACd,qBACA,uBAAuB,oBACvB;EAAwB,aAAa;EAAkB;MACtD;wBAaa,iBAAiB,eAAe"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as HostLoadError, C as readRunRecord, D as listVerbs, E as getVerb, F as mergeDefaultDrives, I as projectDrivesIntoConnect, L as rebaseDriveUrl, M as lintHostImports, N as loadHost, O as resolveRunnerModule, P as probeHostsFolder, S as probeRun, T as RunnerError, _ as runCompound, a as reactorBackendSchema, b as clearRunRecord, c as reactorSchema, d as drivesSchema, f as explainDrivePlan, g as seedDrives, h as resolveDriveDeclaration, i as profileSchema, j as findNonStaticValue, k as validateHost, l as runnerBaseSchema, m as projectDriveId, n as compoundHostSchema, o as reactorHostSchema, p as mergeDrivePlan, r as emittedHostSchemas, s as reactorProtocolSchema, t as childrenSchema, u as driveDeclarationSchema, v as defaultUserDataDir, w as writeRunRecord, x as isPidAlive, y as resolveUserDataPlaceholders } from "./host-schemas-CL_wFpY7.mjs";
|
|
2
|
+
import { PluginError, entryActiveForVerb, hostTypeSatisfies, mergeContributions, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, registerHostType, resolveOrder, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook } from "./plugins.mjs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { z } from "zod";
|
|
2
7
|
//#region src/backend-projection.ts
|
|
3
8
|
function projectStorage(name, storage) {
|
|
4
9
|
switch (storage.kind) {
|
|
@@ -137,6 +142,54 @@ function assertProtocolConsistency(protocol, env, hostFile = "the host file") {
|
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
144
|
//#endregion
|
|
140
|
-
|
|
145
|
+
//#region src/plugins-resolve.ts
|
|
146
|
+
/**
|
|
147
|
+
* NODE-ONLY plugin resolution (split from plugins.ts so the pure runner core
|
|
148
|
+
* stays browser-safe for ConnectCore — R3). Resolves host.js entries from the
|
|
149
|
+
* PROJECT dependency tree, exactly like runner modules.
|
|
150
|
+
*/
|
|
151
|
+
function isHostPluginShape(value) {
|
|
152
|
+
return value !== null && typeof value === "object" && typeof value.name === "string";
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Resolve host.js plugin entries into live plugins for one host boot:
|
|
156
|
+
* verb-filter → module resolution from the project tree (default condition,
|
|
157
|
+
* like runners) → factory/object contract → config validation → appliesTo.
|
|
158
|
+
*/
|
|
159
|
+
async function resolveHostPlugins(projectRoot, hostType, verb, entries, where) {
|
|
160
|
+
const normalized = normalizePluginEntries(entries, where);
|
|
161
|
+
const projectRequire = createRequire(pathToFileURL(path.join(projectRoot, "package.json")).href);
|
|
162
|
+
const resolved = [];
|
|
163
|
+
for (const entry of normalized) {
|
|
164
|
+
if (!entryActiveForVerb(entry, verb)) continue;
|
|
165
|
+
let file;
|
|
166
|
+
try {
|
|
167
|
+
file = projectRequire.resolve(entry.module);
|
|
168
|
+
} catch {
|
|
169
|
+
throw new PluginError(`${where}: cannot resolve plugin "${entry.module}" from ${projectRoot}.`, "Plugins resolve from the project dependency tree, exactly like runner modules.");
|
|
170
|
+
}
|
|
171
|
+
const exported = (await import(pathToFileURL(file).href)).default;
|
|
172
|
+
let plugin;
|
|
173
|
+
if (typeof exported === "function") plugin = exported(entry.config);
|
|
174
|
+
else if (isHostPluginShape(exported)) {
|
|
175
|
+
if (Object.keys(entry.config).length > 0 && !exported.configSchema) throw new PluginError(`${where}: plugin "${entry.module}" takes no config, but the entry passes one.`);
|
|
176
|
+
plugin = exported;
|
|
177
|
+
} else throw new PluginError(`${where}: "${entry.module}" does not default-export a plugin object or factory.`, "Export `{ name, hooks?, contributions? }` or `(config) => plugin`.");
|
|
178
|
+
if (plugin.configSchema) {
|
|
179
|
+
const parsed = plugin.configSchema.safeParse(entry.config);
|
|
180
|
+
if (!parsed.success) throw new PluginError(`${where}: config for plugin "${plugin.name}" is invalid:\n` + z.prettifyError(parsed.error));
|
|
181
|
+
}
|
|
182
|
+
const appliesTo = plugin.appliesTo ?? "reactor";
|
|
183
|
+
if (!hostTypeSatisfies(hostType, appliesTo)) throw new PluginError(`${where}: plugin "${plugin.name}" applies to "${appliesTo}" hosts, but this host is "${hostType}".`);
|
|
184
|
+
resolved.push({
|
|
185
|
+
entry,
|
|
186
|
+
plugin,
|
|
187
|
+
provenance: "dependency"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return resolved;
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
export { HostLoadError, PluginError, RunnerError, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, childrenSchema, clearRunRecord, compoundHostSchema, defaultUserDataDir, driveDeclarationSchema, drivesSchema, emittedHostSchemas, entryActiveForVerb, explainDrivePlan, findNonStaticValue, getVerb, hostTypeSatisfies, isPidAlive, isStructuralMultiReactor, lintHostImports, listVerbs, loadHost, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, profileSchema, projectDriveId, projectDrivesIntoConnect, projectReactorToConnect, projectReactorToSwitchboard, protocolEnv, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, readRunRecord, rebaseDriveUrl, registerHostType, remoteBackendUrls, resolveDriveDeclaration, resolveHostPlugins, resolveOrder, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook, runnerBaseSchema, seedDrives, validateHost, writeRunRecord };
|
|
141
194
|
|
|
142
195
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/backend-projection.ts","../src/reactor-config.ts"],"sourcesContent":["import type {\n ReactorBackend,\n ReactorConfig,\n ReactorProtocol,\n} from \"./reactor-config.js\";\n\n/**\n * Phase 4 (track R): project named host backends onto reactor-monitor's\n * `ReactorDescriptor` shape — the input `provision()` takes. Pure and\n * dependency-free; a type-assignability test pins the output to the real\n * `ReactorDescriptor` so an upstream field rename fails this package's tests\n * instead of silently drifting (D2.b: aligned locally, upstreaming not\n * blocked on).\n */\n\n/** The browser-provisionable storage union — reactor-monitor's\n * `ReactorStorageConfig` shape. `postgres` is the SERVER extension (D2.b): a\n * switchboard backend's storage, never a provisioned browser reactor's. */\nexport type ProjectedStorage =\n | { kind: \"idb\" }\n | { kind: \"memory\" }\n | { kind: \"path\"; dataDir: string };\n\nexport interface ProjectedDescriptor {\n kind: \"in-process\" | \"worker\" | \"remote\";\n name: string;\n storage?: ProjectedStorage;\n packages?: { cdnUrl?: string; specs?: string[]; dynamic?: boolean };\n featureFlags?: {\n documentDecisions?: boolean;\n authEnforcement?: boolean;\n authGroups?: boolean;\n authConditions?: boolean;\n };\n remote?: { url: string };\n}\n\nfunction projectStorage(\n name: string,\n storage: NonNullable<ReactorBackend[\"storage\"]>,\n): ProjectedStorage {\n switch (storage.kind) {\n case \"idb\":\n return { kind: \"idb\" };\n case \"memory\":\n return { kind: \"memory\" };\n case \"path\": {\n if (!storage.dataDir) {\n throw new Error(\n `Backend \"${name}\": storage kind \"path\" requires dataDir.`,\n );\n }\n return { kind: \"path\", dataDir: storage.dataDir };\n }\n case \"postgres\":\n throw new Error(\n `Backend \"${name}\": storage kind \"postgres\" is server-side only — ` +\n `a provisioned (in-process/worker) reactor cannot use it. Point a ` +\n `\"remote\" backend at the switchboard that owns that database instead.`,\n );\n }\n}\n\n/** One backend → one descriptor. The protocol's featureFlags ride every\n * descriptor (they are fleet consensus, not per-backend). A remote backend\n * must carry remote.url — provision() requires it. */\nexport function backendToDescriptor(\n name: string,\n backend: ReactorBackend,\n protocol?: ReactorProtocol,\n): ProjectedDescriptor {\n const descriptor: ProjectedDescriptor = {\n kind: backend.kind ?? \"in-process\",\n name,\n };\n if (descriptor.kind === \"remote\") {\n const url = backend.remote?.url;\n if (!url) {\n throw new Error(\n `Backend \"${name}\" is kind \"remote\" but has no remote.url — ` +\n `a remote descriptor attaches to an already-running reactor by URL.`,\n );\n }\n descriptor.remote = { url };\n // remote attaches; it builds nothing, so local-build fields do not apply\n return descriptor;\n }\n if (backend.storage) {\n descriptor.storage = projectStorage(name, backend.storage);\n }\n if (backend.packages) descriptor.packages = backend.packages;\n if (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;\n return descriptor;\n}\n\n/** All named backends, in placement-primary-first order (the order a\n * createReactorClients step would provision them). */\nexport function backendsToDescriptors(\n reactor: ReactorConfig | undefined,\n): ProjectedDescriptor[] {\n const backends = reactor?.backends;\n if (!backends) return [];\n const names = Object.keys(backends);\n const primary = reactor.placement?.primary;\n const ordered =\n primary && names.includes(primary)\n ? [primary, ...names.filter((n) => n !== primary)]\n : names;\n return ordered.map((name) =>\n backendToDescriptor(name, backends[name], reactor.protocol),\n );\n}\n\nconst LOCAL_KINDS = new Set([\"in-process\", \"worker\", undefined]);\n\n/**\n * Structural multi-reactor (phase 4): true when the block names BOTH a local\n * backend (in-process/worker — the tab's own reactor) and a remote one. This\n * is the shape Connect's routing client serves; a lone remote backend is an\n * attach-only host (assistant/agent shape), not a routed tab.\n */\nexport function isStructuralMultiReactor(\n reactor: ReactorConfig | undefined,\n): boolean {\n const backends = reactor?.backends;\n if (!backends) return false;\n const kinds = Object.values(backends).map((b) => b.kind);\n return (\n kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === \"remote\")\n );\n}\n\n/** The remote backends' urls, placement order — what the routing client dials. */\nexport function remoteBackendUrls(\n reactor: ReactorConfig | undefined,\n): string[] {\n return backendsToDescriptors(reactor)\n .filter((d) => d.kind === \"remote\")\n .map((d) => d.remote?.url)\n .filter((u): u is string => typeof u === \"string\");\n}\n","/**\n * The shared `reactor` host-config block and its projections onto today's\n * Switchboard env / Connect runtime config. Phase 2 of uniform-runners: makes\n * the reactor block live through the bridge runners, BEFORE track R replaces\n * the projection with reactor-monitor's provision(). The headline is\n * single-sourced `reactor.protocol` — both projections read the same block, so\n * client and server cannot diverge, and a contradicting pre-set env fails boot.\n */\n\nexport type ReactorBackendKind = \"in-process\" | \"worker\" | \"remote\";\n\nexport interface ReactorStorageConfig {\n kind: \"idb\" | \"memory\" | \"path\" | \"postgres\";\n dataDir?: string;\n url?: string;\n}\n\nexport interface ReactorPackageConfig {\n cdnUrl?: string;\n specs?: string[];\n /** on-demand model resolution (was DYNAMIC_MODEL_LOADING). */\n dynamic?: boolean;\n}\n\nexport interface ReactorRemoteConfig {\n host?: string;\n url?: string;\n}\n\nexport interface ReactorBackend {\n kind?: ReactorBackendKind;\n storage?: ReactorStorageConfig;\n readModel?: { url?: string };\n packages?: ReactorPackageConfig;\n remote?: ReactorRemoteConfig;\n}\n\n/** Replay/admission rules every sync peer must share. */\nexport interface ReactorProtocol {\n featureFlags?: {\n documentDecisions?: boolean;\n authEnforcement?: boolean;\n authGroups?: boolean;\n authConditions?: boolean;\n };\n createSignaturePolicy?: \"legacy\" | \"v2-required\";\n unsupportedStoredDocuments?: \"refuse\" | \"read-only\";\n}\n\nexport interface ReactorConfig {\n backends?: Record<string, ReactorBackend>;\n placement?: {\n primary?: string;\n default?: Record<string, unknown>;\n };\n workflows?: boolean;\n protocol?: ReactorProtocol;\n}\n\n/** The single primary backend for phase-2 projection (multi-backend routing is\n * track R). Prefers placement.primary, else \"main\"/\"local\", else the first. */\nexport function primaryBackend(\n reactor: ReactorConfig | undefined,\n): ReactorBackend | undefined {\n const backends = reactor?.backends;\n if (!backends) return undefined;\n const names = Object.keys(backends);\n if (names.length === 0) return undefined;\n const pick =\n reactor.placement?.primary ??\n (names.includes(\"main\")\n ? \"main\"\n : names.includes(\"local\")\n ? \"local\"\n : names[0]);\n return backends[pick];\n}\n\nconst FLAG_ENV: Record<\n keyof NonNullable<ReactorProtocol[\"featureFlags\"]>,\n string\n> = {\n documentDecisions: \"REACTOR_DOCUMENT_DECISIONS\",\n authEnforcement: \"REACTOR_AUTH_ENFORCEMENT\",\n authGroups: \"REACTOR_AUTH_GROUPS\",\n authConditions: \"REACTOR_AUTH_CONDITIONS\",\n};\n\n/** The env vars a protocol block maps onto, with their string values. Only\n * keys the block actually sets appear. */\nexport function protocolEnv(\n protocol: ReactorProtocol | undefined,\n): Record<string, string> {\n const env: Record<string, string> = {};\n if (!protocol) return env;\n for (const [key, varName] of Object.entries(FLAG_ENV)) {\n const value = protocol.featureFlags?.[key as keyof typeof FLAG_ENV];\n if (value !== undefined) env[varName] = value ? \"true\" : \"false\";\n }\n if (protocol.createSignaturePolicy !== undefined) {\n env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;\n }\n if (protocol.unsupportedStoredDocuments !== undefined) {\n env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS =\n protocol.unsupportedStoredDocuments;\n }\n return env;\n}\n\nexport interface SwitchboardReactorProjection {\n /** Env the switchboard server reads at boot. Only keys the block sets. */\n env: Record<string, string>;\n /** Options passed to startSwitchboard (DB path). */\n options: { dbPath?: string };\n}\n\n/** Project the reactor block onto the switchboard's env + options. */\nexport function projectReactorToSwitchboard(\n reactor: ReactorConfig | undefined,\n): SwitchboardReactorProjection {\n const env = protocolEnv(reactor?.protocol);\n const backend = primaryBackend(reactor);\n const options: { dbPath?: string } = {};\n\n if (backend?.storage) {\n const s = backend.storage;\n const dbUrl = s.kind === \"postgres\" ? s.url : s.dataDir;\n if (dbUrl) env.PH_REACTOR_DATABASE_URL = dbUrl;\n }\n if (backend?.readModel?.url) options.dbPath = backend.readModel.url;\n if (backend?.packages?.dynamic) env.DYNAMIC_MODEL_LOADING = \"true\";\n if (reactor?.workflows !== undefined) {\n env.PH_WORKFLOWS_ENABLED = reactor.workflows ? \"1\" : \"0\";\n }\n return { env, options };\n}\n\nexport interface ConnectReactorProjection {\n /** Patch merged into the connect runtime config (connect.*). */\n connect: {\n reactor?: ReactorProtocol;\n instance?: { reactorWorker?: boolean };\n app?: { workflowsEnabled?: boolean };\n };\n}\n\n/** Project the reactor block onto the Connect runtime config: protocol →\n * connect.reactor (same shape), backend kind → instance.reactorWorker,\n * workflows → app.workflowsEnabled. */\nexport function projectReactorToConnect(\n reactor: ReactorConfig | undefined,\n): ConnectReactorProjection {\n const connect: ConnectReactorProjection[\"connect\"] = {};\n if (reactor?.protocol) connect.reactor = reactor.protocol;\n const backend = primaryBackend(reactor);\n if (backend?.kind !== undefined) {\n connect.instance = { reactorWorker: backend.kind === \"worker\" };\n }\n if (reactor?.workflows !== undefined) {\n connect.app = { workflowsEnabled: reactor.workflows };\n }\n return { connect };\n}\n\n/**\n * The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS\n * the host's protocol block, fail loudly naming the var, the host value, and\n * the env value. An env var that merely matches, or is unset, is fine (phase-2\n * transition keeps an operator's explicit env as an escape hatch unless it\n * disagrees with the protocol — see the WBS precedence note).\n */\nexport function assertProtocolConsistency(\n protocol: ReactorProtocol | undefined,\n env: Record<string, string | undefined>,\n hostFile = \"the host file\",\n): void {\n if (!protocol) return;\n const expected = protocolEnv(protocol);\n for (const [varName, hostValue] of Object.entries(expected)) {\n const envValue = env[varName];\n if (envValue !== undefined && envValue !== hostValue) {\n throw new Error(\n `reactor.protocol conflict: ${varName} is \"${envValue}\" in the environment ` +\n `but \"${hostValue}\" in ${hostFile}. These are fleet-consensus settings — ` +\n `a mismatch would diverge replay. Remove the env override or align the host.`,\n );\n }\n }\n}\n"],"mappings":";;AAqCA,SAAS,eACP,MACA,SACkB;CAClB,QAAQ,QAAQ,MAAhB;EACE,KAAK,OACH,OAAO,EAAE,MAAM,MAAM;EACvB,KAAK,UACH,OAAO,EAAE,MAAM,SAAS;EAC1B,KAAK;GACH,IAAI,CAAC,QAAQ,SACX,MAAM,IAAI,MACR,YAAY,KAAK,yCACnB;GAEF,OAAO;IAAE,MAAM;IAAQ,SAAS,QAAQ;GAAQ;EAElD,KAAK,YACH,MAAM,IAAI,MACR,YAAY,KAAK,uLAGnB;CACJ;AACF;;;;AAKA,SAAgB,oBACd,MACA,SACA,UACqB;CACrB,MAAM,aAAkC;EACtC,MAAM,QAAQ,QAAQ;EACtB;CACF;CACA,IAAI,WAAW,SAAS,UAAU;EAChC,MAAM,MAAM,QAAQ,QAAQ;EAC5B,IAAI,CAAC,KACH,MAAM,IAAI,MACR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A,GACpB,QAAQ,WAAW,EAAE,eAAe,QAAQ,SAAS,SAAS;CAEhE,IAAI,SAAS,cAAc,KAAA,GACzB,QAAQ,MAAM,EAAE,kBAAkB,QAAQ,UAAU;CAEtD,OAAO,EAAE,QAAQ;AACnB;;;;;;;;AASA,SAAgB,0BACd,UACA,KACA,WAAW,iBACL;CACN,IAAI,CAAC,UAAU;CACf,MAAM,WAAW,YAAY,QAAQ;CACrC,KAAK,MAAM,CAAC,SAAS,cAAc,OAAO,QAAQ,QAAQ,GAAG;EAC3D,MAAM,WAAW,IAAI;EACrB,IAAI,aAAa,KAAA,KAAa,aAAa,WACzC,MAAM,IAAI,MACR,8BAA8B,QAAQ,OAAO,SAAS,4BAC5C,UAAU,OAAO,SAAS,mHAEtC;CAEJ;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["factory"],"sources":["../src/backend-projection.ts","../src/reactor-config.ts","../src/plugins-resolve.ts"],"sourcesContent":["import type {\n ReactorBackend,\n ReactorConfig,\n ReactorProtocol,\n} from \"./reactor-config.js\";\n\n/**\n * Phase 4 (track R): project named host backends onto reactor-monitor's\n * `ReactorDescriptor` shape — the input `provision()` takes. Pure and\n * dependency-free; a type-assignability test pins the output to the real\n * `ReactorDescriptor` so an upstream field rename fails this package's tests\n * instead of silently drifting (D2.b: aligned locally, upstreaming not\n * blocked on).\n */\n\n/** The browser-provisionable storage union — reactor-monitor's\n * `ReactorStorageConfig` shape. `postgres` is the SERVER extension (D2.b): a\n * switchboard backend's storage, never a provisioned browser reactor's. */\nexport type ProjectedStorage =\n | { kind: \"idb\" }\n | { kind: \"memory\" }\n | { kind: \"path\"; dataDir: string };\n\nexport interface ProjectedDescriptor {\n kind: \"in-process\" | \"worker\" | \"remote\";\n name: string;\n storage?: ProjectedStorage;\n packages?: { cdnUrl?: string; specs?: string[]; dynamic?: boolean };\n featureFlags?: {\n documentDecisions?: boolean;\n authEnforcement?: boolean;\n authGroups?: boolean;\n authConditions?: boolean;\n };\n remote?: { url: string };\n}\n\nfunction projectStorage(\n name: string,\n storage: NonNullable<ReactorBackend[\"storage\"]>,\n): ProjectedStorage {\n switch (storage.kind) {\n case \"idb\":\n return { kind: \"idb\" };\n case \"memory\":\n return { kind: \"memory\" };\n case \"path\": {\n if (!storage.dataDir) {\n throw new Error(\n `Backend \"${name}\": storage kind \"path\" requires dataDir.`,\n );\n }\n return { kind: \"path\", dataDir: storage.dataDir };\n }\n case \"postgres\":\n throw new Error(\n `Backend \"${name}\": storage kind \"postgres\" is server-side only — ` +\n `a provisioned (in-process/worker) reactor cannot use it. Point a ` +\n `\"remote\" backend at the switchboard that owns that database instead.`,\n );\n }\n}\n\n/** One backend → one descriptor. The protocol's featureFlags ride every\n * descriptor (they are fleet consensus, not per-backend). A remote backend\n * must carry remote.url — provision() requires it. */\nexport function backendToDescriptor(\n name: string,\n backend: ReactorBackend,\n protocol?: ReactorProtocol,\n): ProjectedDescriptor {\n const descriptor: ProjectedDescriptor = {\n kind: backend.kind ?? \"in-process\",\n name,\n };\n if (descriptor.kind === \"remote\") {\n const url = backend.remote?.url;\n if (!url) {\n throw new Error(\n `Backend \"${name}\" is kind \"remote\" but has no remote.url — ` +\n `a remote descriptor attaches to an already-running reactor by URL.`,\n );\n }\n descriptor.remote = { url };\n // remote attaches; it builds nothing, so local-build fields do not apply\n return descriptor;\n }\n if (backend.storage) {\n descriptor.storage = projectStorage(name, backend.storage);\n }\n if (backend.packages) descriptor.packages = backend.packages;\n if (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;\n return descriptor;\n}\n\n/** All named backends, in placement-primary-first order (the order a\n * createReactorClients step would provision them). */\nexport function backendsToDescriptors(\n reactor: ReactorConfig | undefined,\n): ProjectedDescriptor[] {\n const backends = reactor?.backends;\n if (!backends) return [];\n const names = Object.keys(backends);\n const primary = reactor.placement?.primary;\n const ordered =\n primary && names.includes(primary)\n ? [primary, ...names.filter((n) => n !== primary)]\n : names;\n return ordered.map((name) =>\n backendToDescriptor(name, backends[name], reactor.protocol),\n );\n}\n\nconst LOCAL_KINDS = new Set([\"in-process\", \"worker\", undefined]);\n\n/**\n * Structural multi-reactor (phase 4): true when the block names BOTH a local\n * backend (in-process/worker — the tab's own reactor) and a remote one. This\n * is the shape Connect's routing client serves; a lone remote backend is an\n * attach-only host (assistant/agent shape), not a routed tab.\n */\nexport function isStructuralMultiReactor(\n reactor: ReactorConfig | undefined,\n): boolean {\n const backends = reactor?.backends;\n if (!backends) return false;\n const kinds = Object.values(backends).map((b) => b.kind);\n return (\n kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === \"remote\")\n );\n}\n\n/** The remote backends' urls, placement order — what the routing client dials. */\nexport function remoteBackendUrls(\n reactor: ReactorConfig | undefined,\n): string[] {\n return backendsToDescriptors(reactor)\n .filter((d) => d.kind === \"remote\")\n .map((d) => d.remote?.url)\n .filter((u): u is string => typeof u === \"string\");\n}\n","/**\n * The shared `reactor` host-config block and its projections onto today's\n * Switchboard env / Connect runtime config. Phase 2 of uniform-runners: makes\n * the reactor block live through the bridge runners, BEFORE track R replaces\n * the projection with reactor-monitor's provision(). The headline is\n * single-sourced `reactor.protocol` — both projections read the same block, so\n * client and server cannot diverge, and a contradicting pre-set env fails boot.\n */\n\nexport type ReactorBackendKind = \"in-process\" | \"worker\" | \"remote\";\n\nexport interface ReactorStorageConfig {\n kind: \"idb\" | \"memory\" | \"path\" | \"postgres\";\n dataDir?: string;\n url?: string;\n}\n\nexport interface ReactorPackageConfig {\n cdnUrl?: string;\n specs?: string[];\n /** on-demand model resolution (was DYNAMIC_MODEL_LOADING). */\n dynamic?: boolean;\n}\n\nexport interface ReactorRemoteConfig {\n host?: string;\n url?: string;\n}\n\nexport interface ReactorBackend {\n kind?: ReactorBackendKind;\n storage?: ReactorStorageConfig;\n readModel?: { url?: string };\n packages?: ReactorPackageConfig;\n remote?: ReactorRemoteConfig;\n}\n\n/** Replay/admission rules every sync peer must share. */\nexport interface ReactorProtocol {\n featureFlags?: {\n documentDecisions?: boolean;\n authEnforcement?: boolean;\n authGroups?: boolean;\n authConditions?: boolean;\n };\n createSignaturePolicy?: \"legacy\" | \"v2-required\";\n unsupportedStoredDocuments?: \"refuse\" | \"read-only\";\n}\n\nexport interface ReactorConfig {\n backends?: Record<string, ReactorBackend>;\n placement?: {\n primary?: string;\n default?: Record<string, unknown>;\n };\n workflows?: boolean;\n protocol?: ReactorProtocol;\n}\n\n/** The single primary backend for phase-2 projection (multi-backend routing is\n * track R). Prefers placement.primary, else \"main\"/\"local\", else the first. */\nexport function primaryBackend(\n reactor: ReactorConfig | undefined,\n): ReactorBackend | undefined {\n const backends = reactor?.backends;\n if (!backends) return undefined;\n const names = Object.keys(backends);\n if (names.length === 0) return undefined;\n const pick =\n reactor.placement?.primary ??\n (names.includes(\"main\")\n ? \"main\"\n : names.includes(\"local\")\n ? \"local\"\n : names[0]);\n return backends[pick];\n}\n\nconst FLAG_ENV: Record<\n keyof NonNullable<ReactorProtocol[\"featureFlags\"]>,\n string\n> = {\n documentDecisions: \"REACTOR_DOCUMENT_DECISIONS\",\n authEnforcement: \"REACTOR_AUTH_ENFORCEMENT\",\n authGroups: \"REACTOR_AUTH_GROUPS\",\n authConditions: \"REACTOR_AUTH_CONDITIONS\",\n};\n\n/** The env vars a protocol block maps onto, with their string values. Only\n * keys the block actually sets appear. */\nexport function protocolEnv(\n protocol: ReactorProtocol | undefined,\n): Record<string, string> {\n const env: Record<string, string> = {};\n if (!protocol) return env;\n for (const [key, varName] of Object.entries(FLAG_ENV)) {\n const value = protocol.featureFlags?.[key as keyof typeof FLAG_ENV];\n if (value !== undefined) env[varName] = value ? \"true\" : \"false\";\n }\n if (protocol.createSignaturePolicy !== undefined) {\n env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;\n }\n if (protocol.unsupportedStoredDocuments !== undefined) {\n env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS =\n protocol.unsupportedStoredDocuments;\n }\n return env;\n}\n\nexport interface SwitchboardReactorProjection {\n /** Env the switchboard server reads at boot. Only keys the block sets. */\n env: Record<string, string>;\n /** Options passed to startSwitchboard (DB path). */\n options: { dbPath?: string };\n}\n\n/** Project the reactor block onto the switchboard's env + options. */\nexport function projectReactorToSwitchboard(\n reactor: ReactorConfig | undefined,\n): SwitchboardReactorProjection {\n const env = protocolEnv(reactor?.protocol);\n const backend = primaryBackend(reactor);\n const options: { dbPath?: string } = {};\n\n if (backend?.storage) {\n const s = backend.storage;\n const dbUrl = s.kind === \"postgres\" ? s.url : s.dataDir;\n if (dbUrl) env.PH_REACTOR_DATABASE_URL = dbUrl;\n }\n if (backend?.readModel?.url) options.dbPath = backend.readModel.url;\n if (backend?.packages?.dynamic) env.DYNAMIC_MODEL_LOADING = \"true\";\n if (reactor?.workflows !== undefined) {\n env.PH_WORKFLOWS_ENABLED = reactor.workflows ? \"1\" : \"0\";\n }\n return { env, options };\n}\n\nexport interface ConnectReactorProjection {\n /** Patch merged into the connect runtime config (connect.*). */\n connect: {\n reactor?: ReactorProtocol;\n instance?: { reactorWorker?: boolean };\n app?: { workflowsEnabled?: boolean };\n };\n}\n\n/** Project the reactor block onto the Connect runtime config: protocol →\n * connect.reactor (same shape), backend kind → instance.reactorWorker,\n * workflows → app.workflowsEnabled. */\nexport function projectReactorToConnect(\n reactor: ReactorConfig | undefined,\n): ConnectReactorProjection {\n const connect: ConnectReactorProjection[\"connect\"] = {};\n if (reactor?.protocol) connect.reactor = reactor.protocol;\n const backend = primaryBackend(reactor);\n if (backend?.kind !== undefined) {\n connect.instance = { reactorWorker: backend.kind === \"worker\" };\n }\n if (reactor?.workflows !== undefined) {\n connect.app = { workflowsEnabled: reactor.workflows };\n }\n return { connect };\n}\n\n/**\n * The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS\n * the host's protocol block, fail loudly naming the var, the host value, and\n * the env value. An env var that merely matches, or is unset, is fine (phase-2\n * transition keeps an operator's explicit env as an escape hatch unless it\n * disagrees with the protocol — see the WBS precedence note).\n */\nexport function assertProtocolConsistency(\n protocol: ReactorProtocol | undefined,\n env: Record<string, string | undefined>,\n hostFile = \"the host file\",\n): void {\n if (!protocol) return;\n const expected = protocolEnv(protocol);\n for (const [varName, hostValue] of Object.entries(expected)) {\n const envValue = env[varName];\n if (envValue !== undefined && envValue !== hostValue) {\n throw new Error(\n `reactor.protocol conflict: ${varName} is \"${envValue}\" in the environment ` +\n `but \"${hostValue}\" in ${hostFile}. These are fleet-consensus settings — ` +\n `a mismatch would diverge replay. Remove the env override or align the host.`,\n );\n }\n }\n}\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { z } from \"zod\";\nimport {\n entryActiveForVerb,\n hostTypeSatisfies,\n normalizePluginEntries,\n PluginError,\n type HostPlugin,\n type PluginEntry,\n type ResolvedPlugin,\n} from \"./plugins.js\";\n\n/**\n * NODE-ONLY plugin resolution (split from plugins.ts so the pure runner core\n * stays browser-safe for ConnectCore — R3). Resolves host.js entries from the\n * PROJECT dependency tree, exactly like runner modules.\n */\n\nfunction isHostPluginShape(value: unknown): value is HostPlugin {\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof (value as HostPlugin).name === \"string\"\n );\n}\n\n/**\n * Resolve host.js plugin entries into live plugins for one host boot:\n * verb-filter → module resolution from the project tree (default condition,\n * like runners) → factory/object contract → config validation → appliesTo.\n */\nexport async function resolveHostPlugins<THooks = Record<string, unknown>>(\n projectRoot: string,\n hostType: string,\n verb: string,\n entries: readonly PluginEntry[],\n where: string,\n): Promise<ResolvedPlugin<THooks>[]> {\n const normalized = normalizePluginEntries(entries, where);\n const projectRequire = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n\n const resolved: ResolvedPlugin<THooks>[] = [];\n for (const entry of normalized) {\n if (!entryActiveForVerb(entry, verb)) continue;\n\n let file: string;\n try {\n file = projectRequire.resolve(entry.module);\n } catch {\n throw new PluginError(\n `${where}: cannot resolve plugin \"${entry.module}\" from ${projectRoot}.`,\n \"Plugins resolve from the project dependency tree, exactly like runner modules.\",\n );\n }\n const module = (await import(pathToFileURL(file).href)) as {\n default?: unknown;\n };\n const exported = module.default;\n\n let plugin: HostPlugin<THooks>;\n if (typeof exported === \"function\") {\n const factory = exported as (config: unknown) => HostPlugin<THooks>;\n plugin = factory(entry.config);\n } else if (isHostPluginShape(exported)) {\n if (Object.keys(entry.config).length > 0 && !exported.configSchema) {\n throw new PluginError(\n `${where}: plugin \"${entry.module}\" takes no config, but the entry passes one.`,\n );\n }\n plugin = exported as HostPlugin<THooks>;\n } else {\n throw new PluginError(\n `${where}: \"${entry.module}\" does not default-export a plugin object or factory.`,\n \"Export `{ name, hooks?, contributions? }` or `(config) => plugin`.\",\n );\n }\n\n if (plugin.configSchema) {\n const parsed = plugin.configSchema.safeParse(entry.config);\n if (!parsed.success) {\n throw new PluginError(\n `${where}: config for plugin \"${plugin.name}\" is invalid:\\n` +\n z.prettifyError(parsed.error),\n );\n }\n }\n\n const appliesTo = plugin.appliesTo ?? \"reactor\";\n if (!hostTypeSatisfies(hostType, appliesTo)) {\n throw new PluginError(\n `${where}: plugin \"${plugin.name}\" applies to \"${appliesTo}\" hosts, but this host is \"${hostType}\".`,\n );\n }\n\n resolved.push({ entry, plugin, provenance: \"dependency\" });\n }\n return resolved;\n}\n"],"mappings":";;;;;;;AAqCA,SAAS,eACP,MACA,SACkB;CAClB,QAAQ,QAAQ,MAAhB;EACE,KAAK,OACH,OAAO,EAAE,MAAM,MAAM;EACvB,KAAK,UACH,OAAO,EAAE,MAAM,SAAS;EAC1B,KAAK;GACH,IAAI,CAAC,QAAQ,SACX,MAAM,IAAI,MACR,YAAY,KAAK,yCACnB;GAEF,OAAO;IAAE,MAAM;IAAQ,SAAS,QAAQ;GAAQ;EAElD,KAAK,YACH,MAAM,IAAI,MACR,YAAY,KAAK,uLAGnB;CACJ;AACF;;;;AAKA,SAAgB,oBACd,MACA,SACA,UACqB;CACrB,MAAM,aAAkC;EACtC,MAAM,QAAQ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