@powerhousedao/host-core 6.2.3-dev.70 → 6.2.3-dev.72
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-B6RZMA0Y.mjs +2804 -0
- package/dist/compound-B6RZMA0Y.mjs.map +1 -0
- package/dist/compound-PhoVeqe1.d.mts +2401 -0
- package/dist/compound-PhoVeqe1.d.mts.map +1 -0
- package/dist/env-substitution-C_fVirPh.d.mts +17 -0
- package/dist/env-substitution-C_fVirPh.d.mts.map +1 -0
- package/dist/env-substitution-Dj3pdsut.mjs +330 -0
- package/dist/env-substitution-Dj3pdsut.mjs.map +1 -0
- package/dist/host-schemas-mqOYNGot.d.mts +2153 -0
- package/dist/host-schemas-mqOYNGot.d.mts.map +1 -0
- package/dist/index.d.mts +908 -691
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +335 -109
- package/dist/index.mjs.map +1 -1
- package/dist/plugins-XL6WsvTL.d.mts +182 -0
- package/dist/plugins-XL6WsvTL.d.mts.map +1 -0
- package/dist/plugins.d.mts +2 -120
- package/dist/plugins.mjs.map +1 -1
- package/dist/projection.d.mts +586 -0
- package/dist/projection.d.mts.map +1 -0
- package/dist/projection.mjs +1505 -0
- package/dist/projection.mjs.map +1 -0
- package/dist/runners/compound.d.mts +157 -12
- package/dist/runners/compound.d.mts.map +1 -1
- package/dist/runners/compound.mjs +5 -13
- package/dist/runners/compound.mjs.map +1 -1
- package/dist/schema.d.mts +105 -0
- package/dist/schema.d.mts.map +1 -0
- package/dist/schema.mjs +35 -0
- package/dist/schema.mjs.map +1 -0
- package/package.json +16 -4
- package/dist/compound-C8P0kvPJ.d.mts +0 -157
- package/dist/compound-C8P0kvPJ.d.mts.map +0 -1
- package/dist/host-schemas-CtPNRr5v.mjs +0 -720
- package/dist/host-schemas-CtPNRr5v.mjs.map +0 -1
- package/dist/plugins.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compound.mjs","names":[],"sources":["../../src/runners/compound.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"compound.mjs","names":[],"sources":["../../src/runners/compound.ts"],"sourcesContent":["import {\n declaredGenericCompoundHostSchema,\n genericCompoundHostSchema,\n type HostDefinition,\n} from \"../host-schemas.js\";\nimport { runCompound, type RunCompoundResult } from \"../compound.js\";\nimport { readProjectName } from \"../run-record.js\";\nimport type { RunnerContext } from \"../runner-resolver.js\";\n\n/**\n * The GENERIC compound runner module (phase 3): supervises the members a\n * compound host declares via the runCompound engine. Verb semantics: `run`\n * starts members at `runner.defaultVerb ?? \"run\"`; `dev`/`build`/`serve`\n * start members at that same verb — an explicit `ph run <host> <verb>` beats\n * defaultVerb structurally. A member whose runner lacks the forwarded verb\n * fails the compound loudly with that member's verb list (never skipped).\n *\n * Vetra does NOT run through this yet (phase-1 scope decision: its drive\n * provisioning arrives as plugin contributions); the first real consumer is\n * the desktop-shaped host (switchboard `run` + connect `serve`).\n */\n\nexport const kind = \"compound\";\n\nexport const hostSchema = genericCompoundHostSchema;\nexport const declaredHostSchema = declaredGenericCompoundHostSchema;\n\nasync function startAt(\n host: HostDefinition,\n ctx: RunnerContext,\n memberVerb: string,\n): Promise<RunCompoundResult> {\n return runCompound(\n host,\n { ...ctx, verb: memberVerb },\n { projectName: readProjectName(ctx.projectRoot) },\n );\n}\n\nexport async function run(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<RunCompoundResult> {\n const defaultVerb = host.runner.defaultVerb ?? \"run\";\n return startAt(host, ctx, defaultVerb);\n}\n\nexport async function dev(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<RunCompoundResult> {\n return startAt(host, ctx, \"dev\");\n}\n\nexport async function build(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<RunCompoundResult> {\n return startAt(host, ctx, \"build\");\n}\n\nexport async function serve(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<RunCompoundResult> {\n return startAt(host, ctx, \"serve\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAa,OAAO;AAEpB,MAAa,aAAa;AAC1B,MAAa,qBAAqB;AAElC,eAAe,QACb,MACA,KACA,YAC4B;CAC5B,OAAO,YACL,MACA;EAAE,GAAG;EAAK,MAAM;CAAW,GAC3B,EAAE,aAAa,gBAAgB,IAAI,WAAW,EAAE,CAClD;AACF;AAEA,eAAsB,IACpB,MACA,KAC4B;CAE5B,OAAO,QAAQ,MAAM,KADD,KAAK,OAAO,eAAe,KACV;AACvC;AAEA,eAAsB,IACpB,MACA,KAC4B;CAC5B,OAAO,QAAQ,MAAM,KAAK,KAAK;AACjC;AAEA,eAAsB,MACpB,MACA,KAC4B;CAC5B,OAAO,QAAQ,MAAM,KAAK,OAAO;AACnC;AAEA,eAAsB,MACpB,MACA,KAC4B;CAC5B,OAAO,QAAQ,MAAM,KAAK,OAAO;AACnC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { $ as TokenFor, A as profileSchema, B as ConcatToken, C as declaredGenericCompoundHostSchema, D as emittedHostSchemas, E as emitHostJsonSchema, F as reactorSchema, G as OutputPath, H as ItemToken, I as refineStartOrder, J as RefFn, K as OutputToken, L as runnerBaseSchema, M as reactorBackendSchema, N as reactorHostSchema, O as genericCompoundHostSchema, P as reactorProtocolSchema, Q as Token, R as runnerKindSchema, S as compoundWiringSchema, T as defineHostSchemas, U as KeyToken, V as EnvToken, W as MapToken, X as TOKEN_KEYS, Y as TOKEN_ESCAPE_KEY, Z as Template, _ as RunnerBase, a as HostDefinition, at as envTokenable, b as childrenSchema, c as ReactorBackend, ct as isToken, d as ReactorHost, dt as mapTokenSchema, et as TokenKey, f as ReactorHostInput, ft as outputTokenSchema, g as ReactorStorageConfig, gt as tokenable, h as ReactorRemoteConfig, ht as tokenSchema, i as CompoundWiring, it as envTokenSchema, j as reactorBackendKindSchema, k as makeHostSchemas, l as ReactorBackendKind, lt as itemTokenSchema, m as ReactorProtocol, mt as tokenKeyOf, n as CompoundHost, nt as TokenableSchema, o as HostSchemas, ot as findToken, p as ReactorPackageConfig, pt as ref, q as RecordMapToken, r as CompoundHostInput, rt as concatTokenSchema, s as Profile, st as forbidRef, t as ChildWrapper, tt as TokenMode, u as ReactorConfig, ut as keyTokenSchema, v as RunnerKind, w as declaredHostSchemas, x as compoundHostSchema, y as childWrapperSchema, z as ArrayMapToken } from "./host-schemas-mqOYNGot.mjs";
|
|
2
|
+
import { D as PHHostOutputs, E as PHHost, O as PluginEntry, c as PluginEntryData, v as pluginEntryObjectSchema, y as pluginEntrySchema } from "./plugins-XL6WsvTL.mjs";
|
|
3
|
+
import { n as substituteBuiltinEnv, t as BuiltinEnv } from "./env-substitution-C_fVirPh.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/drive-schema.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The schema half of drives.ts, zod only so `./schema` stays neutral.
|
|
8
|
+
* - slug: the SEEDING KEY (idempotence); id optional (stable identity).
|
|
9
|
+
* - preferredEditor: stored at header.meta.preferredEditor; Connect config's
|
|
10
|
+
* `app` is the legacy alias.
|
|
11
|
+
* - remote.url: a drive served elsewhere; local fields are ignored for it.
|
|
12
|
+
* Token-able (`$output` on a producer's `drives.<slug>.url`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildDriveDeclarationSchema(urlField: (schema: z.ZodString) => TokenableSchema<z.ZodString>): z.ZodObject<{
|
|
15
|
+
slug: z.ZodString;
|
|
16
|
+
id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
18
|
+
name: z.ZodOptional<z.ZodString>;
|
|
19
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
20
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
21
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
private: "private";
|
|
23
|
+
public: "public";
|
|
24
|
+
shared: "shared";
|
|
25
|
+
}>>;
|
|
26
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
url: TokenableSchema<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
export declare const driveDeclarationSchema: z.ZodObject<{
|
|
32
|
+
slug: z.ZodString;
|
|
33
|
+
id: z.ZodOptional<z.ZodString>;
|
|
34
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
35
|
+
name: z.ZodOptional<z.ZodString>;
|
|
36
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
37
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
38
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
39
|
+
private: "private";
|
|
40
|
+
public: "public";
|
|
41
|
+
shared: "shared";
|
|
42
|
+
}>>;
|
|
43
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
url: TokenableSchema<z.ZodString>;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
type DriveDeclaration = z.infer<typeof driveDeclarationSchema>;
|
|
49
|
+
export declare const drivesSchema: z.ZodArray<z.ZodObject<{
|
|
50
|
+
slug: z.ZodString;
|
|
51
|
+
id: z.ZodOptional<z.ZodString>;
|
|
52
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
53
|
+
name: z.ZodOptional<z.ZodString>;
|
|
54
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
55
|
+
preferredEditor: z.ZodOptional<z.ZodString>;
|
|
56
|
+
sharingType: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
private: "private";
|
|
58
|
+
public: "public";
|
|
59
|
+
shared: "shared";
|
|
60
|
+
}>>;
|
|
61
|
+
availableOffline: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
remote: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
url: TokenableSchema<z.ZodString>;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
/** The project-hashed drive id (`${slug}-${sha256(projectRoot)[0..8]}`) with
|
|
67
|
+
* the hash function injected, so neutral consumers (a browser monitor) can
|
|
68
|
+
* pass `crypto.subtle`-derived or precomputed hex. drives.ts binds it to
|
|
69
|
+
* node:crypto as `projectDriveId`. */
|
|
70
|
+
export declare function projectDriveIdWith(sha256Hex: (input: string) => string, projectRoot: string, slug: string): string;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/runner-handle.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* What a server verb returns to its supervisor (typed-host-configs 3.1/3.6):
|
|
75
|
+
* `RunnerHandle<O>`. Consumers read a started host only through `outputs`
|
|
76
|
+
* (and `$output` tokens over them). A verb that returns nothing (one-shot,
|
|
77
|
+
* or self-sustaining) is an empty handle.
|
|
78
|
+
*/
|
|
79
|
+
interface RunnerHandle<O = Record<string, unknown>> {
|
|
80
|
+
outputs: O;
|
|
81
|
+
/** Resolves when the member is serving. */
|
|
82
|
+
ready: Promise<void>;
|
|
83
|
+
/** Reverse-order compound teardown (and standalone signal handling). */
|
|
84
|
+
shutdown(): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
/** The data half of a handle, validated by the compound. `ready`/`shutdown`
|
|
87
|
+
* are functions and promises, so they are checked as TS fields, not here. */
|
|
88
|
+
export declare const runnerHandleSchema: z.ZodObject<{
|
|
89
|
+
outputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
}, z.core.$loose>;
|
|
91
|
+
type RunnerHandleData = z.infer<typeof runnerHandleSchema>;
|
|
92
|
+
/** A verb's return value, normalized: validated data plus the live fields
|
|
93
|
+
* when present. */
|
|
94
|
+
interface StartedHandle extends RunnerHandleData {
|
|
95
|
+
outputs: Record<string, unknown>;
|
|
96
|
+
ready?: PromiseLike<unknown>;
|
|
97
|
+
shutdown?: () => unknown;
|
|
98
|
+
}
|
|
99
|
+
/** Normalize what a verb returned. `undefined` (a self-sustaining bridge)
|
|
100
|
+
* is an empty handle; anything else must match runnerHandleSchema. */
|
|
101
|
+
export declare function toStartedHandle(value: unknown, where: string): StartedHandle;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { type ArrayMapToken, type BuiltinEnv, type ChildWrapper, type CompoundHost, type CompoundHostInput, type CompoundWiring, type ConcatToken, type DriveDeclaration, type EnvToken, type HostDefinition, type HostSchemas, type ItemToken, type KeyToken, type MapToken, type OutputPath, type OutputToken, type PHHost, type PHHostOutputs, type PluginEntry, type PluginEntryData, type Profile, type ReactorBackend, type ReactorBackendKind, type ReactorConfig, type ReactorHost, type ReactorHostInput, type ReactorPackageConfig, type ReactorProtocol, type ReactorRemoteConfig, type ReactorStorageConfig, type RecordMapToken, type RefFn, type RunnerBase, type RunnerHandle, type RunnerHandleData, type RunnerKind, type StartedHandle, TOKEN_ESCAPE_KEY, TOKEN_KEYS, type Template, type Token, type TokenFor, type TokenKey, type TokenMode, type TokenableSchema, childWrapperSchema, childrenSchema, compoundHostSchema, compoundWiringSchema, concatTokenSchema, declaredGenericCompoundHostSchema, declaredHostSchemas, defineHostSchemas, emitHostJsonSchema, emittedHostSchemas, envTokenSchema, envTokenable, findToken, forbidRef, genericCompoundHostSchema, isToken, itemTokenSchema, keyTokenSchema, makeHostSchemas, mapTokenSchema, outputTokenSchema, pluginEntryObjectSchema, pluginEntrySchema, profileSchema, reactorBackendKindSchema, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, ref, refineStartOrder, runnerBaseSchema, runnerKindSchema, substituteBuiltinEnv, tokenKeyOf, tokenSchema, tokenable };
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=schema.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../src/drive-schema.ts","../src/runner-handle.ts"],"mappings":";;;;;;;;;;;;;wBAWgB,4BACd,WAAW,QAAQ,EAAE,cAAc,gBAAgB,EAAE,aAAU,EAAA;;;;;;;;;;;;;;;;GAkBhE,EAAA,KAAA;qBAEY,wBAAsB,EAAA;;;;;;;;;;;;;;;;GAAyC,EAAA,KAAA;KAEhE,mBAAmB,EAAE,aAAa;qBAEjC,cAAY,EAAA,SAAA,EAAA;;;;;;;;;;;;;;;;GAAkC,EAAA,KAAA;;;;;wBAM3C,mBACd,YAAY,0BACZ,qBACA;;;;;;;;;UCrCe,aAAa,IAAI;EAChC,SAAS;;EAET,OAAO;;EAEP,YAAY;;;;qBAKD,oBAAkB,EAAA;;GAE7B,EAAA,KAAA;KAEU,mBAAmB,EAAE,aAAa;;;UAI7B,sBAAsB;EACrC,SAAS;EACT,QAAQ;EACR;;;;wBAiBc,gBAAgB,gBAAgB,gBAAgB"}
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { A as envTokenable, B as tokenSchema, C as driveDeclarationSchema, D as TOKEN_KEYS, E as TOKEN_ESCAPE_KEY, F as keyTokenSchema, I as mapTokenSchema, L as outputTokenSchema, M as forbidRef, N as isToken, O as concatTokenSchema, P as itemTokenSchema, R as ref, S as buildDriveDeclarationSchema, T as projectDriveIdWith, V as tokenable, _ as reactorProtocolSchema, a as compoundWiringSchema, b as runnerBaseSchema, c as defineHostSchemas, d as genericCompoundHostSchema, f as makeHostSchemas, g as reactorHostSchema, h as reactorBackendSchema, i as compoundHostSchema, j as findToken, k as envTokenSchema, l as emitHostJsonSchema, m as reactorBackendKindSchema, n as childWrapperSchema, o as declaredGenericCompoundHostSchema, p as profileSchema, r as childrenSchema, s as declaredHostSchemas, t as substituteBuiltinEnv, u as emittedHostSchemas, v as reactorSchema, w as drivesSchema, x as runnerKindSchema, y as refineStartOrder, z as tokenKeyOf } from "./env-substitution-Dj3pdsut.mjs";
|
|
2
|
+
import { pluginEntryObjectSchema, pluginEntrySchema } from "./plugins.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/runner-handle.ts
|
|
5
|
+
/** The data half of a handle, validated by the compound. `ready`/`shutdown`
|
|
6
|
+
* are functions and promises, so they are checked as TS fields, not here. */
|
|
7
|
+
const runnerHandleSchema = z.looseObject({ outputs: z.record(z.string(), z.unknown()).optional() });
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null;
|
|
10
|
+
}
|
|
11
|
+
function isPromiseLike(value) {
|
|
12
|
+
return isRecord(value) && typeof value.then === "function";
|
|
13
|
+
}
|
|
14
|
+
function isCallable(value) {
|
|
15
|
+
return typeof value === "function";
|
|
16
|
+
}
|
|
17
|
+
/** Normalize what a verb returned. `undefined` (a self-sustaining bridge)
|
|
18
|
+
* is an empty handle; anything else must match runnerHandleSchema. */
|
|
19
|
+
function toStartedHandle(value, where) {
|
|
20
|
+
if (value === void 0 || value === null) return { outputs: {} };
|
|
21
|
+
const parsed = runnerHandleSchema.safeParse(value);
|
|
22
|
+
if (!parsed.success) throw new Error(`${where} returned an invalid runner handle:\n${z.prettifyError(parsed.error)}`);
|
|
23
|
+
const live = isRecord(value) ? value : {};
|
|
24
|
+
const shutdown = live.shutdown;
|
|
25
|
+
return {
|
|
26
|
+
...parsed.data,
|
|
27
|
+
outputs: parsed.data.outputs ?? {},
|
|
28
|
+
...isPromiseLike(live.ready) ? { ready: live.ready } : {},
|
|
29
|
+
...isCallable(shutdown) ? { shutdown: () => shutdown.call(value) } : {}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TOKEN_ESCAPE_KEY, TOKEN_KEYS, buildDriveDeclarationSchema, childWrapperSchema, childrenSchema, compoundHostSchema, compoundWiringSchema, concatTokenSchema, declaredGenericCompoundHostSchema, declaredHostSchemas, defineHostSchemas, driveDeclarationSchema, drivesSchema, emitHostJsonSchema, emittedHostSchemas, envTokenSchema, envTokenable, findToken, forbidRef, genericCompoundHostSchema, isToken, itemTokenSchema, keyTokenSchema, makeHostSchemas, mapTokenSchema, outputTokenSchema, pluginEntryObjectSchema, pluginEntrySchema, profileSchema, projectDriveIdWith, reactorBackendKindSchema, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, ref, refineStartOrder, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, substituteBuiltinEnv, toStartedHandle, tokenKeyOf, tokenSchema, tokenable };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../src/runner-handle.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * What a server verb returns to its supervisor (typed-host-configs 3.1/3.6):\n * `RunnerHandle<O>`. Consumers read a started host only through `outputs`\n * (and `$output` tokens over them). A verb that returns nothing (one-shot,\n * or self-sustaining) is an empty handle.\n */\nexport interface RunnerHandle<O = Record<string, unknown>> {\n outputs: O;\n /** Resolves when the member is serving. */\n ready: Promise<void>;\n /** Reverse-order compound teardown (and standalone signal handling). */\n shutdown(): Promise<void>;\n}\n\n/** The data half of a handle, validated by the compound. `ready`/`shutdown`\n * are functions and promises, so they are checked as TS fields, not here. */\nexport const runnerHandleSchema = z.looseObject({\n outputs: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport type RunnerHandleData = z.infer<typeof runnerHandleSchema>;\n\n/** A verb's return value, normalized: validated data plus the live fields\n * when present. */\nexport interface StartedHandle extends RunnerHandleData {\n outputs: Record<string, unknown>;\n ready?: PromiseLike<unknown>;\n shutdown?: () => unknown;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return isRecord(value) && typeof value.then === \"function\";\n}\n\nfunction isCallable(value: unknown): value is (this: unknown) => unknown {\n return typeof value === \"function\";\n}\n\n/** Normalize what a verb returned. `undefined` (a self-sustaining bridge)\n * is an empty handle; anything else must match runnerHandleSchema. */\nexport function toStartedHandle(value: unknown, where: string): StartedHandle {\n if (value === undefined || value === null) return { outputs: {} };\n const parsed = runnerHandleSchema.safeParse(value);\n if (!parsed.success) {\n throw new Error(\n `${where} returned an invalid runner handle:\\n${z.prettifyError(parsed.error)}`,\n );\n }\n const live = isRecord(value) ? value : {};\n const shutdown = live.shutdown;\n return {\n ...parsed.data,\n outputs: parsed.data.outputs ?? {},\n ...(isPromiseLike(live.ready) ? { ready: live.ready } : {}),\n ...(isCallable(shutdown) ? { shutdown: () => shutdown.call(value) } : {}),\n };\n}\n"],"mappings":";;;;;;AAkBA,MAAa,qBAAqB,EAAE,YAAY,EAC9C,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,EACtD,CAAC;AAYD,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAEA,SAAS,cAAc,OAA+C;CACpE,OAAO,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS;AAClD;AAEA,SAAS,WAAW,OAAqD;CACvE,OAAO,OAAO,UAAU;AAC1B;;;AAIA,SAAgB,gBAAgB,OAAgB,OAA8B;CAC5E,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,EAAE,SAAS,CAAC,EAAE;CAChE,MAAM,SAAS,mBAAmB,UAAU,KAAK;CACjD,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,MACR,GAAG,MAAM,uCAAuC,EAAE,cAAc,OAAO,KAAK,GAC9E;CAEF,MAAM,OAAO,SAAS,KAAK,IAAI,QAAQ,CAAC;CACxC,MAAM,WAAW,KAAK;CACtB,OAAO;EACL,GAAG,OAAO;EACV,SAAS,OAAO,KAAK,WAAW,CAAC;EACjC,GAAI,cAAc,KAAK,KAAK,IAAI,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;EACzD,GAAI,WAAW,QAAQ,IAAI,EAAE,gBAAgB,SAAS,KAAK,KAAK,EAAE,IAAI,CAAC;CACzE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/host-core",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.72",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,21 +34,33 @@
|
|
|
34
34
|
"types": "./dist/plugins.d.mts",
|
|
35
35
|
"import": "./dist/plugins.mjs",
|
|
36
36
|
"default": "./dist/plugins.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./schema": {
|
|
39
|
+
"source": "./src/schema.ts",
|
|
40
|
+
"types": "./dist/schema.d.mts",
|
|
41
|
+
"import": "./dist/schema.mjs",
|
|
42
|
+
"default": "./dist/schema.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./projection": {
|
|
45
|
+
"source": "./src/projection.ts",
|
|
46
|
+
"types": "./dist/projection.d.mts",
|
|
47
|
+
"import": "./dist/projection.mjs",
|
|
48
|
+
"default": "./dist/projection.mjs"
|
|
37
49
|
}
|
|
38
50
|
},
|
|
39
51
|
"dependencies": {
|
|
40
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
52
|
+
"@powerhousedao/shared": "6.2.3-dev.72",
|
|
41
53
|
"zod": "^4.5.4"
|
|
42
54
|
},
|
|
43
55
|
"devDependencies": {
|
|
44
56
|
"tsdown": "0.23.0",
|
|
45
57
|
"vitest": "5.0.3",
|
|
46
|
-
"@powerhousedao/reactor-monitor": "6.2.3-dev.
|
|
58
|
+
"@powerhousedao/reactor-monitor": "6.2.3-dev.72"
|
|
47
59
|
},
|
|
48
60
|
"scripts": {
|
|
49
61
|
"tsc": "tsc",
|
|
50
62
|
"lint": "cd ../.. && oxlint packages/host-core",
|
|
51
|
-
"build": "tsdown",
|
|
63
|
+
"build": "tsdown && node scripts/assert-neutral.mjs",
|
|
52
64
|
"test": "vitest --run",
|
|
53
65
|
"emit-schemas": "tsx scripts/emit-schemas.ts"
|
|
54
66
|
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
//#region src/host-loader.d.ts
|
|
2
|
-
declare class HostLoadError extends Error {
|
|
3
|
-
constructor(message: string, hint?: string);
|
|
4
|
-
}
|
|
5
|
-
type HostsFolderStatus = {
|
|
6
|
-
kind: "absent";
|
|
7
|
-
} | {
|
|
8
|
-
kind: "empty";
|
|
9
|
-
dir: string;
|
|
10
|
-
} | {
|
|
11
|
-
kind: "present";
|
|
12
|
-
dir: string;
|
|
13
|
-
hosts: string[];
|
|
14
|
-
};
|
|
15
|
-
/** A `hosts/` folder with no `<name>/host.js` inside is "empty" — the guard
|
|
16
|
-
* state: callers warn loudly and fall back to legacy rather than activating
|
|
17
|
-
* the new architecture off a stray `mkdir hosts`. */
|
|
18
|
-
declare function probeHostsFolder(projectRoot: string): HostsFolderStatus;
|
|
19
|
-
/** Rejects every import except the project's powerhouse.config.json and
|
|
20
|
-
* SIBLING host files (R1: derived compositions), plus any dynamic
|
|
21
|
-
* `import(...)` or `require(...)`. Source-level enforcement: the JSON round
|
|
22
|
-
* trip below is the hard gate; this one produces the better error. Returns
|
|
23
|
-
* the sibling host names the file imports, for cycle detection. */
|
|
24
|
-
declare function lintHostImports(source: string, file: string): string[];
|
|
25
|
-
/** Returns the path of the first value that would not survive a JSON round
|
|
26
|
-
* trip, or undefined when the object is fully static. */
|
|
27
|
-
declare function findNonStaticValue(value: unknown, trail?: string): string | undefined;
|
|
28
|
-
interface HostDefinition {
|
|
29
|
-
name: string;
|
|
30
|
-
runner: {
|
|
31
|
-
module: string;
|
|
32
|
-
} & Record<string, unknown>;
|
|
33
|
-
config?: Record<string, unknown>;
|
|
34
|
-
profile?: Record<string, unknown>;
|
|
35
|
-
reactor?: Record<string, unknown>;
|
|
36
|
-
children?: Record<string, unknown>;
|
|
37
|
-
}
|
|
38
|
-
interface LoadedHost {
|
|
39
|
-
name: string;
|
|
40
|
-
dir: string;
|
|
41
|
-
file: string;
|
|
42
|
-
host: HostDefinition;
|
|
43
|
-
}
|
|
44
|
-
declare function loadHost(projectRoot: string, hostName: string): Promise<LoadedHost>;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/runner-resolver.d.ts
|
|
47
|
-
/**
|
|
48
|
-
* Resolves a host's `runner.module` specifier from the PROJECT's dependency
|
|
49
|
-
* tree (not ph-cli's), imports it, and checks the runner-module contract:
|
|
50
|
-
* `{ run, hostSchema, kind, ...optionalVerbs }`. Phase-0 home is ph-cli; the
|
|
51
|
-
* uniform-runners plan moves this into @powerhousedao/host-core with the
|
|
52
|
-
* generic compound (phase 1).
|
|
53
|
-
*/
|
|
54
|
-
declare class RunnerError extends Error {
|
|
55
|
-
constructor(message: string, hint?: string);
|
|
56
|
-
}
|
|
57
|
-
interface RunnerContext {
|
|
58
|
-
projectRoot: string;
|
|
59
|
-
verb: string;
|
|
60
|
-
env: Record<string, string | undefined>;
|
|
61
|
-
}
|
|
62
|
-
type RunnerVerb = (host: HostDefinition, ctx: RunnerContext) => Promise<unknown>;
|
|
63
|
-
/** zod-shaped structurally, so this module needs no zod dependency. */
|
|
64
|
-
interface HostSchemaLike {
|
|
65
|
-
safeParse(host: unknown): {
|
|
66
|
-
success: boolean;
|
|
67
|
-
error?: {
|
|
68
|
-
issues?: {
|
|
69
|
-
path: (string | number)[];
|
|
70
|
-
message: string;
|
|
71
|
-
}[];
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
interface RunnerModule {
|
|
76
|
-
run: RunnerVerb;
|
|
77
|
-
hostSchema: HostSchemaLike;
|
|
78
|
-
kind: string;
|
|
79
|
-
[key: string]: unknown;
|
|
80
|
-
}
|
|
81
|
-
declare function resolveRunnerModule(projectRoot: string, specifier: string): Promise<RunnerModule>;
|
|
82
|
-
declare function listVerbs(runner: RunnerModule): string[];
|
|
83
|
-
declare function getVerb(runner: RunnerModule, specifier: string, verb: string): RunnerVerb;
|
|
84
|
-
declare function validateHost(runner: RunnerModule, specifier: string, host: HostDefinition, file: string): void;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/compound.d.ts
|
|
87
|
-
/**
|
|
88
|
-
* The generic compound runner: supervises the members a compound host
|
|
89
|
-
* declares, each started via its OWN declared runner at the compound's member
|
|
90
|
-
* verb. It projects a reactor member's created drives into a connect member's
|
|
91
|
-
* config, writes a .ph/run/<host>.json record, holds a per-project lock, and
|
|
92
|
-
* tears members down in reverse order on shutdown.
|
|
93
|
-
*
|
|
94
|
-
* Phase-1 model is ATTACHED and in-process: member runner verbs start their
|
|
95
|
-
* servers (which hold the event loop) and return a handle of facts; the
|
|
96
|
-
* compound stays alive as long as they do. Detached supervision is phase 5.
|
|
97
|
-
*/
|
|
98
|
-
/** Facts a member runner verb returns so the compound can project and tear
|
|
99
|
-
* down. All optional: a void-returning verb is treated as "started, no facts,
|
|
100
|
-
* self-sustaining" (the phase-0 bridges). */
|
|
101
|
-
interface RunnerHandle {
|
|
102
|
-
/** Port the member bound. */
|
|
103
|
-
port?: number;
|
|
104
|
-
/** Drive URLs a reactor member created, in display order — projected into a
|
|
105
|
-
* connect member's defaultDrives. */
|
|
106
|
-
driveUrls?: (string | null | undefined)[];
|
|
107
|
-
/** Named endpoints (graphql, mcp, …) for the run record / diagnostics. */
|
|
108
|
-
endpoints?: Record<string, string>;
|
|
109
|
-
/** Resolves when the member is serving; the compound awaits it before the
|
|
110
|
-
* next member when ordering requires readiness. */
|
|
111
|
-
ready?: Promise<void>;
|
|
112
|
-
/** Reverse-order teardown. */
|
|
113
|
-
shutdown?: () => void | Promise<void>;
|
|
114
|
-
}
|
|
115
|
-
interface CompoundMember {
|
|
116
|
-
host: string;
|
|
117
|
-
plugins?: string[];
|
|
118
|
-
runner?: {
|
|
119
|
-
port?: number;
|
|
120
|
-
} & Record<string, unknown>;
|
|
121
|
-
config?: Record<string, unknown>;
|
|
122
|
-
reactor?: Record<string, unknown>;
|
|
123
|
-
}
|
|
124
|
-
interface CompoundWiring {
|
|
125
|
-
/** Project the reactor member's created drives into the connect member. */
|
|
126
|
-
projectDrivesIntoConnect?: boolean;
|
|
127
|
-
/** --drives-public-base equivalent. */
|
|
128
|
-
drivesPublicBase?: string | null;
|
|
129
|
-
/** Member start order; defaults to declaration order. */
|
|
130
|
-
startOrder?: string[];
|
|
131
|
-
/** Write .ph/run/<host>.json (default true). */
|
|
132
|
-
runtimeRecord?: boolean;
|
|
133
|
-
/** Patch the baked CSP for the runtime registry on a served connect member
|
|
134
|
-
* (forwarded to the connect runner as a runner option). */
|
|
135
|
-
cspRegistrySync?: boolean;
|
|
136
|
-
}
|
|
137
|
-
interface StartedMember {
|
|
138
|
-
name: string;
|
|
139
|
-
handle: RunnerHandle;
|
|
140
|
-
}
|
|
141
|
-
interface RunCompoundOptions {
|
|
142
|
-
/** Project identity for the lock (defaults read from package.json by the CLI). */
|
|
143
|
-
projectName: string;
|
|
144
|
-
/** Extra record fields (e.g. mcpUrl). */
|
|
145
|
-
recordExtra?: Record<string, unknown>;
|
|
146
|
-
/** Registers signal handlers for teardown (default true; tests pass false). */
|
|
147
|
-
installSignalHandlers?: boolean;
|
|
148
|
-
}
|
|
149
|
-
interface RunCompoundResult {
|
|
150
|
-
started: StartedMember[];
|
|
151
|
-
shutdown: () => Promise<void>;
|
|
152
|
-
}
|
|
153
|
-
declare function runCompound(host: HostDefinition, ctx: RunnerContext, options: RunCompoundOptions): Promise<RunCompoundResult>;
|
|
154
|
-
//#endregion
|
|
155
|
-
export { probeHostsFolder as C, loadHost as S, HostLoadError as _, RunnerHandle as a, findNonStaticValue as b, RunnerContext as c, RunnerVerb as d, getVerb as f, HostDefinition as g, validateHost as h, RunCompoundResult as i, RunnerError as l, resolveRunnerModule as m, CompoundWiring as n, runCompound as o, listVerbs as p, RunCompoundOptions as r, HostSchemaLike as s, CompoundMember as t, RunnerModule as u, HostsFolderStatus as v, lintHostImports as x, LoadedHost as y };
|
|
156
|
-
export {};
|
|
157
|
-
//# sourceMappingURL=compound-C8P0kvPJ.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compound-C8P0kvPJ.d.mts","names":[],"sources":["../src/host-loader.ts","../src/runner-resolver.ts","../src/compound.ts"],"mappings":";cAuBa,sBAAsB;EACjC,YAAY,iBAAiB;;KAMnB;EACN;;EACA;EAAe;;EACf;EAAiB;EAAa;;;;;iBAKpB,iBAAiB,sBAAsB;;;;;;iBA2BvC,gBAAgB,gBAAgB;;;iBA4DhC,mBACd,gBACA;UA4Be;EACf;EACA;IAAU;MAAmB;EAC7B,SAAS;EACT,UAAU;EACV,UAAU;EACV,WAAW;;UAGI;EACf;EACA;EACA;EACA,MAAM;;iBA2Bc,SACpB,qBACA,mBACC,QAAQ;;;;;;;;;;cCzLE,oBAAoB;EAC/B,YAAY,iBAAiB;;UAMd;EACf;EACA;EACA,KAAK;;KAGK,cACV,MAAM,gBACN,KAAK,kBACF;;UAGY;EACf,UAAU;IACR;IACA;MAAU;QAAW;QAA2B;;;;;UAInC;EACf,KAAK;EACL,YAAY;EACZ;GACC;;iBAMmB,oBACpB,qBACA,oBACC,QAAQ;iBAsCK,UAAU,QAAQ;iBAUlB,QACd,QAAQ,cACR,mBACA,eACC;iBAYa,aACd,QAAQ,cACR,mBACA,MAAM,gBACN;;;;;;;;;;;;;;;;;UCrFe;;EAEf;;;EAGA;;EAEA,YAAY;;;EAGZ,QAAQ;;EAER,wBAAwB;;UAGT;EACf;EACA;EACA;IAAW;MAAkB;EAC7B,SAAS;EACT,UAAU;;UAGK;;EAEf;;EAEA;;EAEA;;EAEA;;;EAGA;;UAGQ;EACR;EACA,QAAQ;;UAmEO;;EAEf;;EAEA,cAAc;;EAEd;;UAGe;EACf,SAAS;EACT,gBAAgB;;iBAGI,YACpB,MAAM,gBACN,KAAK,eACL,SAAS,qBACR,QAAQ"}
|