@powerhousedao/host-core 6.3.0-dev.3 → 6.3.0-dev.4
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-CDrU3CLt.mjs → compound-DKi56SSx.mjs} +2 -1
- package/dist/{compound-CDrU3CLt.mjs.map → compound-DKi56SSx.mjs.map} +1 -1
- package/dist/index.d.mts +60 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +98 -2
- package/dist/index.mjs.map +1 -1
- package/dist/runners/compound.mjs +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { $ as HOST_NAME_PATTERN, $t as Token, A as kindShapeIssues, At as profil
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { SwitchboardDrive, driveAddressMessage, switchboardOfDrive } from "@powerhousedao/shared/host-tokens";
|
|
4
4
|
import { ORIGIN_PLACEHOLDER, SWITCHBOARD_PROXY_PATHS, isHtmlNavigation, isOriginPlaceholderUrl, isSwitchboardProxyPath, resolveOriginPlaceholders, toOriginPlaceholder, withOriginPlaceholders } from "@powerhousedao/shared/connect/origin-placeholder";
|
|
5
|
+
import net from "node:net";
|
|
5
6
|
import { PHConnectCollection, PHConnectDefaultDrive, PHConnectRuntimeConfig, PHConnectRuntimeDefaultDrive } from "@powerhousedao/shared/clis";
|
|
6
7
|
//#region src/host-loader.d.ts
|
|
7
8
|
export declare class HostLoadError extends Error {
|
|
@@ -128,7 +129,8 @@ export declare function isRunnerArgsSchema(value: unknown): value is RunnerArgsS
|
|
|
128
129
|
interface SplitRunArgv {
|
|
129
130
|
host?: string;
|
|
130
131
|
verb?: string;
|
|
131
|
-
/** `ph run`'s own arguments (`--debug`, `--explain <topic>`,
|
|
132
|
+
/** `ph run`'s own arguments (`--debug`, `--stop`, `--explain <topic>`,
|
|
133
|
+
* help). */
|
|
132
134
|
own: string[];
|
|
133
135
|
/** Everything else, in order: the runner's. */
|
|
134
136
|
argv: string[];
|
|
@@ -249,6 +251,62 @@ export declare function isPidAlive(pid: number): boolean;
|
|
|
249
251
|
*/
|
|
250
252
|
export declare function probeRun(projectDir: string, hostName: string, projectName: string, env?: Env$1): RunProbe;
|
|
251
253
|
//#endregion
|
|
254
|
+
//#region src/stop-channel.d.ts
|
|
255
|
+
/**
|
|
256
|
+
* Windows has no SIGTERM: `process.kill(pid, "SIGTERM")` ends the process at
|
|
257
|
+
* once, so no handler runs and a stack's stores are left as a crash leaves
|
|
258
|
+
* them. A started host therefore listens on a pipe named after its pid, and
|
|
259
|
+
* a connection to it is delivered as the SIGTERM it stands for. Elsewhere
|
|
260
|
+
* the signal itself does this, and there is no channel.
|
|
261
|
+
*/
|
|
262
|
+
export declare function stopChannelPath(pid: number, platform?: NodeJS.Platform): string | undefined;
|
|
263
|
+
/** Calls `onStop` for each connection to `channel`. The server holds no
|
|
264
|
+
* process open, and one that cannot listen leaves the host running without
|
|
265
|
+
* a channel rather than not running. */
|
|
266
|
+
export declare function listenForStop(channel: string, onStop: () => void): net.Server;
|
|
267
|
+
/** What a host's process calls once before it starts anything: from then on
|
|
268
|
+
* {@link requestStop} reaches its SIGTERM handlers on every platform. */
|
|
269
|
+
export declare function installStopChannel(): void;
|
|
270
|
+
/** Connects to a stop channel; true once the listener took the request. */
|
|
271
|
+
export declare function askToStop(channel: string, timeoutMs?: number): Promise<boolean>;
|
|
272
|
+
/**
|
|
273
|
+
* Asks the process to stop as SIGTERM would. False when it could not be
|
|
274
|
+
* asked: on Windows a process without a stop channel (started by an older
|
|
275
|
+
* version, or not a host), which only a kill ends.
|
|
276
|
+
*/
|
|
277
|
+
export declare function requestStop(pid: number, platform?: NodeJS.Platform): Promise<boolean>;
|
|
278
|
+
type StopRunResult =
|
|
279
|
+
/** No live instance of this host for this project. */
|
|
280
|
+
{
|
|
281
|
+
status: "none";
|
|
282
|
+
} | {
|
|
283
|
+
status: "foreign";
|
|
284
|
+
pid: number;
|
|
285
|
+
projectName: string;
|
|
286
|
+
} | {
|
|
287
|
+
status: "stopped";
|
|
288
|
+
pid: number;
|
|
289
|
+
} |
|
|
290
|
+
/** It runs, and has no stop channel. */
|
|
291
|
+
{
|
|
292
|
+
status: "unreachable";
|
|
293
|
+
pid: number;
|
|
294
|
+
} |
|
|
295
|
+
/** Asked, and still running after `timeoutMs`. */
|
|
296
|
+
{
|
|
297
|
+
status: "timeout";
|
|
298
|
+
pid: number;
|
|
299
|
+
};
|
|
300
|
+
interface StopRunOptions {
|
|
301
|
+
/** How long the host may take to stop (default {@link STOP_RUN_TIMEOUT_MS}). */
|
|
302
|
+
timeoutMs?: number;
|
|
303
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
304
|
+
}
|
|
305
|
+
export declare const STOP_RUN_TIMEOUT_MS = 60000;
|
|
306
|
+
/** Asks the project's running `hostName` to stop and waits until its process
|
|
307
|
+
* is gone. It never kills: a host that does not answer keeps running. */
|
|
308
|
+
export declare function stopRun(projectDir: string, hostName: string, options?: StopRunOptions): Promise<StopRunResult>;
|
|
309
|
+
//#endregion
|
|
252
310
|
//#region src/spawn-host.d.ts
|
|
253
311
|
interface SpawnHostOptions {
|
|
254
312
|
projectRoot: string;
|
|
@@ -1392,6 +1450,6 @@ interface MemberInput extends Omit<ExpectHostInput, "members" | "plan"> {
|
|
|
1392
1450
|
*/
|
|
1393
1451
|
export declare function expectHost(input: ExpectHostInput): HostExpectation;
|
|
1394
1452
|
//#endregion
|
|
1395
|
-
export { type ArrayMapToken, type BootCheckContext, type BootIssue, type BuiltinEnv, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, type CheckDeferred, type CheckHostOptions, type CheckHostResult, type CheckStage, type ChildWrapper, type CompoundArgvMember, type CompoundHost, type CompoundHostInput, type CompoundPlan, type CompoundWiring, type ConcatToken, type ConnectPluginSlices, type ConnectReactorProjection, type ConnectRouterSettings, type ConnectStorageKind, type ConsumedOutput, type ContributedDrive, type ContributedDriveInput, type ContributionSource, type Contributions, type DeadConfigWarning, type DeclaredHostOptions, type DeclaredIssue, type DeferredResolution, type DeferredToken, type DriveDeclaration, type DrivePlanEntry, type DriveProjectionInput, type DriveSeederClient, type EnvToken, type ExpectHostInput, type ExpectedBackend, type ExpectedDrive, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, type HostDefinition, type HostExit, type HostExpectation, type HostExport, type HostImports, type HostIssue, type HostOutputsDescription, type HostPlugin, type HostPluginModule, type HostSchemaIssue, type HostSchemaIssues, type HostSchemaLike, type HostSchemas, type HostsFolderStatus, type ItemToken, type KeyToken, type LoadedHost, type MapToken, type MemberDraft, type MemberExpectation, type MemberInput, type MergedContribution, type NormalizedPluginEntry, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, type Observe, type OutputLookup, type OutputPath, type OutputRef, type OutputSource, type OutputToken, type OutputsSchemaLookup, type OwnedConfigSlice, type PHHost, type PHHostOutputs, type PlacedConnectDrives, type PlacementKeyIssue, type PlanEdge, type PlanMember, type PluginContributionsPlan, type PluginEntry, type PluginEntryData, type ProducerInfo, type ProducerMap, type Profile, type ProjectedDescriptor, type ProjectedStorage, type Provide, type ReactorBackend, type ReactorBackendKind, type ReactorClientMode, type ReactorConfig, type ReactorHost, type ReactorHostInput, type ReactorPackageConfig, type ReactorProtocol, type ReactorRemoteConfig, type ReactorStorageConfig, type RecordMapToken, type RefFn, type RemovedForm, type ResolveOptions, type ResolveSources, type ResolvedDrive, type ResolvedPlugin, type RunCompoundOptions, type RunCompoundResult, type RunProbe, type RunRecord, type RunRecordMember, type RunnerArgsSchema, type RunnerArgvTarget, type RunnerBase, type RunnerContext, RunnerError, type RunnerHandle, type RunnerHandleData, type RunnerIssue, type RunnerKind, type RunnerModule, type RunnerVerb, STORE_VERBS, SWITCHBOARD_PROXY_PATHS, type SchemaIssue, type SeedResult, type SelfMembers, type ServedRemoteBackend, type SpawnHostOptions, type SpawnHostPhase, type SpawnedHost, type SplitRunArgv, type StartedHandle, type SwitchboardDrive, type SwitchboardReactorLayer, TOKEN_ESCAPE_KEY, TOKEN_KEYS, type Template, type Token, type TokenFor, type TokenKey, type TokenMode, type TokenPosition, type TokenSite, type TokenableSchema, type Transform, type ValidateHostOptions, applyChildWrapper, checkOutputPaths, checkTokenSites, childWrapperSchema, childrenSchema, compoundHostSchema, compoundWiringSchema, concatTokenSchema, connectReactorIssues, declaredGenericCompoundHostSchema, declaredHostSchemas, defineHostSchemas, driveAddressMessage, emitHostJsonSchema, emittedHostSchemas, envSitesOf, envTokenSchema, envTokenable, findToken, forbidRef, genericCompoundHostSchema, getVerb, hostNameSchema, hostSchemaIssues, isHtmlNavigation, isOriginPlaceholderUrl, isSchemaLike, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, kindShapeIssues, knownVerbIssues, listVerbs, makeHostSchemas, mapTokenSchema, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, placementKeyIssues, profileSchema, reactorBackendKindSchema, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, ref, refKey, refineConnectReactor, refineStartOrder, resolveOriginPlaceholders, resolveRunnerModule, runCompound, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, schemaAtPath, switchboardOfDrive, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, validateDeclaredHost, validateHost, withOriginPlaceholders };
|
|
1453
|
+
export { type ArrayMapToken, type BootCheckContext, type BootIssue, type BuiltinEnv, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, type CheckDeferred, type CheckHostOptions, type CheckHostResult, type CheckStage, type ChildWrapper, type CompoundArgvMember, type CompoundHost, type CompoundHostInput, type CompoundPlan, type CompoundWiring, type ConcatToken, type ConnectPluginSlices, type ConnectReactorProjection, type ConnectRouterSettings, type ConnectStorageKind, type ConsumedOutput, type ContributedDrive, type ContributedDriveInput, type ContributionSource, type Contributions, type DeadConfigWarning, type DeclaredHostOptions, type DeclaredIssue, type DeferredResolution, type DeferredToken, type DriveDeclaration, type DrivePlanEntry, type DriveProjectionInput, type DriveSeederClient, type EnvToken, type ExpectHostInput, type ExpectedBackend, type ExpectedDrive, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, type HostDefinition, type HostExit, type HostExpectation, type HostExport, type HostImports, type HostIssue, type HostOutputsDescription, type HostPlugin, type HostPluginModule, type HostSchemaIssue, type HostSchemaIssues, type HostSchemaLike, type HostSchemas, type HostsFolderStatus, type ItemToken, type KeyToken, type LoadedHost, type MapToken, type MemberDraft, type MemberExpectation, type MemberInput, type MergedContribution, type NormalizedPluginEntry, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, type Observe, type OutputLookup, type OutputPath, type OutputRef, type OutputSource, type OutputToken, type OutputsSchemaLookup, type OwnedConfigSlice, type PHHost, type PHHostOutputs, type PlacedConnectDrives, type PlacementKeyIssue, type PlanEdge, type PlanMember, type PluginContributionsPlan, type PluginEntry, type PluginEntryData, type ProducerInfo, type ProducerMap, type Profile, type ProjectedDescriptor, type ProjectedStorage, type Provide, type ReactorBackend, type ReactorBackendKind, type ReactorClientMode, type ReactorConfig, type ReactorHost, type ReactorHostInput, type ReactorPackageConfig, type ReactorProtocol, type ReactorRemoteConfig, type ReactorStorageConfig, type RecordMapToken, type RefFn, type RemovedForm, type ResolveOptions, type ResolveSources, type ResolvedDrive, type ResolvedPlugin, type RunCompoundOptions, type RunCompoundResult, type RunProbe, type RunRecord, type RunRecordMember, type RunnerArgsSchema, type RunnerArgvTarget, type RunnerBase, type RunnerContext, RunnerError, type RunnerHandle, type RunnerHandleData, type RunnerIssue, type RunnerKind, type RunnerModule, type RunnerVerb, STORE_VERBS, SWITCHBOARD_PROXY_PATHS, type SchemaIssue, type SeedResult, type SelfMembers, type ServedRemoteBackend, type SpawnHostOptions, type SpawnHostPhase, type SpawnedHost, type SplitRunArgv, type StartedHandle, type StopRunOptions, type StopRunResult, type SwitchboardDrive, type SwitchboardReactorLayer, TOKEN_ESCAPE_KEY, TOKEN_KEYS, type Template, type Token, type TokenFor, type TokenKey, type TokenMode, type TokenPosition, type TokenSite, type TokenableSchema, type Transform, type ValidateHostOptions, applyChildWrapper, checkOutputPaths, checkTokenSites, childWrapperSchema, childrenSchema, compoundHostSchema, compoundWiringSchema, concatTokenSchema, connectReactorIssues, declaredGenericCompoundHostSchema, declaredHostSchemas, defineHostSchemas, driveAddressMessage, emitHostJsonSchema, emittedHostSchemas, envSitesOf, envTokenSchema, envTokenable, findToken, forbidRef, genericCompoundHostSchema, getVerb, hostNameSchema, hostSchemaIssues, isHtmlNavigation, isOriginPlaceholderUrl, isSchemaLike, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, kindShapeIssues, knownVerbIssues, listVerbs, makeHostSchemas, mapTokenSchema, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, placementKeyIssues, profileSchema, reactorBackendKindSchema, reactorBackendSchema, reactorHostSchema, reactorProtocolSchema, reactorSchema, ref, refKey, refineConnectReactor, refineStartOrder, resolveOriginPlaceholders, resolveRunnerModule, runCompound, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, schemaAtPath, switchboardOfDrive, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, validateDeclaredHost, validateHost, withOriginPlaceholders };
|
|
1396
1454
|
export {};
|
|
1397
1455
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/host-loader.ts","../src/runner-args.ts","../src/run-record-schema.ts","../src/run-record.ts","../src/spawn-host.ts","../src/host-issues.ts","../src/env-substitution.ts","../src/resolve/resolve.ts","../src/check-host.ts","../src/host-export-schema.ts","../src/host-export.ts","../src/placeholders.ts","../src/host-types.ts","../src/plugins.ts","../src/plugins-resolve.ts","../src/drive-schema.ts","../src/drives.ts","../src/backend-projection.ts","../src/reactor-config.ts","../src/connect-projection.ts","../src/resolve/plan.ts","../src/resolve/removed-forms.ts","../src/resolve/sources.ts","../src/resolve/walk.ts","../src/resolve/node.ts","../src/expect-host.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/host-loader.ts","../src/runner-args.ts","../src/run-record-schema.ts","../src/run-record.ts","../src/stop-channel.ts","../src/spawn-host.ts","../src/host-issues.ts","../src/env-substitution.ts","../src/resolve/resolve.ts","../src/check-host.ts","../src/host-export-schema.ts","../src/host-export.ts","../src/placeholders.ts","../src/host-types.ts","../src/plugins.ts","../src/plugins-resolve.ts","../src/drive-schema.ts","../src/drives.ts","../src/backend-projection.ts","../src/reactor-config.ts","../src/connect-projection.ts","../src/resolve/plan.ts","../src/resolve/removed-forms.ts","../src/resolve/sources.ts","../src/resolve/walk.ts","../src/resolve/node.ts","../src/expect-host.ts"],"mappings":";;;;;;;qBAiCa,sBAAsB;EACjC,YAAY,iBAAiB;;KAMnB;EACN;;EACA;EAAe;;EACf;EAAiB;EAAa;;;;;wBAKpB,iBAAiB,sBAAsB;;qBAwB1C;;;;wBAsGG,cAAc;;UA8Bb;;EAEf;;EAEA;;;;;;;;wBASc,gBAAgB,mBAAmB,eAAe;;;wBAoClD,gBAAgB,mBAAmB;;;wBAMnC,gBAAgB,mBAAmB;;;;;wBAoBnC,oBACd,kBACA;;;wBA0Cc,mBACd,gBACA;UA8Be;EACf;EACA;EACA;EACA,MAAM;;wBA2Bc,SACpB,qBACA,mBACC,QAAQ;;;UAqEM;;EAEf;EACA;;EAEA,eAAe;;;;EAIf;EACA;;;wBAMc,oBAAoB;;;;wBAoBpB,mBAAmB;EACjC;EACA;EACA,eAAe;EACf;;;;;;;;;;;;;;;wBAiDoB,oBACpB,qBACA,mBACC,QAAQ;;;;;;;;;;;UC3hBM;;EAEf;;EAEA;;;;EAIA,gBAAgB,SAAS;;;EAGzB,UAAU,SAAS;;wBAYL,mBAAmB,iBAAiB,SAAS;UAY5C;EACf;EACA;;;EAGA;;EAEA;;;;;;;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;;;qBAiBV;KAER,MAAM,SAAS;;;;;;;;;;;wBA0BJ,sBACd,qBACA;EACE;EACA,WAAW;EACX;EACA,MAAM;IAEP;;;wBA4Ea,kBACd,qBACA,MAAK,SAAS,sCACb,KAAK;;;;;;;;;;;;;;UC/KS;EACf;EACA,MAAM;EACN,UAAU;;EAEV;;;;;EAKA;;;;;;UAOe;EACf;EACA;;EAEA;;EAEA;EACA;EACA;;;UAIe;;EAEf;EACA;EACA;EACA,MAAM;;UAGS;EACf;EACA,MAAM;;;EAGN;;EAEA,aAAa;;EAEb;EACA,WAAW;;EAEX;EACA,SAAS;;EAET;EACA,UAAU;;EAEV;;EAEA;;EAEA,UAAU,eAAe;;UAGV,0BAA0B,KACzC;;EAIA;;EAEA;;;;UAKe;EACf,aAAa;EACb;;UAGe;EACf,MAAM;;;EAGN,UAAU;;EAEV,WAAW;;EAEX,uBAAuB;;EAEvB,mBAAmB;;EAEnB,OAAO;;UAGQ,oBAAoB,KAAK;EACxC;EACA;;;;;;;;wBAgKc,WAAW,OAAO,kBAAkB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as knownVerbIssues, $t as reactorSchema, A as splitCompoundArgv, An as entryActiveForVerb, At as HOST_NAME_MAX_LENGTH, B as loadHost, Bn as runObserveHookSequential, Bt as defineHostSchemas, C as readProjectName, Cn as tokenable, Ct as collectTokenSites, D as runRecordSchema, Dn as resolveHostPlugins, Dt as renderTokens, E as runRecordMemberSchema, En as findDeadConnectConfig, Et as isPlainObject, F as describeHostOutputs, Fn as pluginEntryObjectSchema, Ft as compoundHostSchema, G as CONNECT_RUNNER, Gt as makeHostSchemas, H as readOutputsFileHash, Hn as runTransformHook, Ht as emittedHostSchemas, I as findNonStaticValue, In as pluginEntrySchema, It as compoundWiringSchema, J as STORE_VERBS, Jt as profileSchema, K as ONE_SHOT_VERBS, Kt as originOrUrlSchema, L as lintHostImportGraph, Ln as registerHostType, Lt as connectReactorIssues, M as HostLoadError, Mn as mergeContributions, Mt as HOST_NAME_PATTERN, N as OUTPUTS_FILE, Nn as normalizePluginEntries, Nt as childWrapperSchema, O as checkRunnerArgv, On as resolvePluginContributions, Ot as unwrapEscapes, P as computeOutputsHash, Pn as normalizePluginEntry, Pt as childrenSchema, Q as kindShapeIssues, Qt as reactorProtocolSchema, R as lintHostImports, Rn as resolveOrder, Rt as declaredGenericCompoundHostSchema, S as probeRun, Sn as tokenSchema, St as schemaAtPath, T as writeRunRecord, Tn as defaultConnectComposition, Tt as formatPath, U as scanHostImports, Ut as genericCompoundHostSchema, V as probeHostsFolder, Vn as runProvideHook, Vt as emitHostJsonSchema, W as stripComments, Wt as hostNameSchema, X as hostSchemaIssues, Xt as reactorBackendSchema, Y as getVerb, Yt as reactorBackendKindSchema, Z as isSchemaLike, Zt as reactorHostSchema, _ as resolveUserDataPlaceholders, _n as keyTokenSchema, _t as checkTokenSites, an as driveDeclarationSchema, at as describeMapElements, b as isPidAlive, bn as ref, bt as outputSitesOf, c as toStartedHandle, cn as TOKEN_ESCAPE_KEY, ct as unsetEnvMessage, d as loadProducers, dn as envTokenSchema, dt as planCompound, en as refineConnectReactor, et as listVerbs, f as processResolveEnv, fn as envTokenable, ft as BUILTIN_ENV_NAMES, g as defaultUserDataDir, gn as itemTokenSchema, gt as checkOutputPaths, h as runnerOutputsSchema, hn as isToken, ht as findRemovedForms, i as runCompound, in as buildDriveDeclarationSchema, it as TokenResolutionError, j as splitRunArgv, jn as hostTypeSatisfies, jt as HOST_NAME_MESSAGE, k as isRunnerArgsSchema, kn as PluginError, kt as CONNECT_PRIMARY_MESSAGE, l as compoundOutputSource, ln as TOKEN_KEYS, lt as PlanError, m as runRecordOutputSource, mn as forbidRef, mt as substituteBuiltinEnv, n as memberVerbOf, nn as runnerBaseSchema, nt as validateDeclaredHost, o as takesCspRegistrySync, on as drivesSchema, ot as emptyMaps, p as producerOutputsSchemas, pn as findToken, pt as isBuiltinEnvName, q as RunnerError, qt as placementKeyIssues, r as prepareMember, rn as runnerKindSchema, rt as validateHost, s as runnerHandleSchema, sn as projectDriveIdWith, st as resolveHostOutputs, t as compoundStartVerb, tn as refineStartOrder, tt as resolveRunnerModule, u as OUTPUT_DATA_DIRS_ENV, un as concatTokenSchema, ut as memberForRef, v as applyChildWrapper, vn as mapTokenSchema, vt as envSitesOf, w as readRunRecord, wn as CONNECT_PLUGIN_OWNED_SLICES, wt as describeToken, x as listRunRecords, xn as tokenKeyOf, xt as refKey, y as clearRunRecord, yn as outputTokenSchema, yt as outputRefsOf, z as lintOutputsFile, zn as runObserveHook, zt as declaredHostSchemas } from "./compound-
|
|
1
|
+
import { $ as knownVerbIssues, $t as reactorSchema, A as splitCompoundArgv, An as entryActiveForVerb, At as HOST_NAME_MAX_LENGTH, B as loadHost, Bn as runObserveHookSequential, Bt as defineHostSchemas, C as readProjectName, Cn as tokenable, Ct as collectTokenSites, D as runRecordSchema, Dn as resolveHostPlugins, Dt as renderTokens, E as runRecordMemberSchema, En as findDeadConnectConfig, Et as isPlainObject, F as describeHostOutputs, Fn as pluginEntryObjectSchema, Ft as compoundHostSchema, G as CONNECT_RUNNER, Gt as makeHostSchemas, H as readOutputsFileHash, Hn as runTransformHook, Ht as emittedHostSchemas, I as findNonStaticValue, In as pluginEntrySchema, It as compoundWiringSchema, J as STORE_VERBS, Jt as profileSchema, K as ONE_SHOT_VERBS, Kt as originOrUrlSchema, L as lintHostImportGraph, Ln as registerHostType, Lt as connectReactorIssues, M as HostLoadError, Mn as mergeContributions, Mt as HOST_NAME_PATTERN, N as OUTPUTS_FILE, Nn as normalizePluginEntries, Nt as childWrapperSchema, O as checkRunnerArgv, On as resolvePluginContributions, Ot as unwrapEscapes, P as computeOutputsHash, Pn as normalizePluginEntry, Pt as childrenSchema, Q as kindShapeIssues, Qt as reactorProtocolSchema, R as lintHostImports, Rn as resolveOrder, Rt as declaredGenericCompoundHostSchema, S as probeRun, Sn as tokenSchema, St as schemaAtPath, T as writeRunRecord, Tn as defaultConnectComposition, Tt as formatPath, U as scanHostImports, Ut as genericCompoundHostSchema, V as probeHostsFolder, Vn as runProvideHook, Vt as emitHostJsonSchema, W as stripComments, Wt as hostNameSchema, X as hostSchemaIssues, Xt as reactorBackendSchema, Y as getVerb, Yt as reactorBackendKindSchema, Z as isSchemaLike, Zt as reactorHostSchema, _ as resolveUserDataPlaceholders, _n as keyTokenSchema, _t as checkTokenSites, an as driveDeclarationSchema, at as describeMapElements, b as isPidAlive, bn as ref, bt as outputSitesOf, c as toStartedHandle, cn as TOKEN_ESCAPE_KEY, ct as unsetEnvMessage, d as loadProducers, dn as envTokenSchema, dt as planCompound, en as refineConnectReactor, et as listVerbs, f as processResolveEnv, fn as envTokenable, ft as BUILTIN_ENV_NAMES, g as defaultUserDataDir, gn as itemTokenSchema, gt as checkOutputPaths, h as runnerOutputsSchema, hn as isToken, ht as findRemovedForms, i as runCompound, in as buildDriveDeclarationSchema, it as TokenResolutionError, j as splitRunArgv, jn as hostTypeSatisfies, jt as HOST_NAME_MESSAGE, k as isRunnerArgsSchema, kn as PluginError, kt as CONNECT_PRIMARY_MESSAGE, l as compoundOutputSource, ln as TOKEN_KEYS, lt as PlanError, m as runRecordOutputSource, mn as forbidRef, mt as substituteBuiltinEnv, n as memberVerbOf, nn as runnerBaseSchema, nt as validateDeclaredHost, o as takesCspRegistrySync, on as drivesSchema, ot as emptyMaps, p as producerOutputsSchemas, pn as findToken, pt as isBuiltinEnvName, q as RunnerError, qt as placementKeyIssues, r as prepareMember, rn as runnerKindSchema, rt as validateHost, s as runnerHandleSchema, sn as projectDriveIdWith, st as resolveHostOutputs, t as compoundStartVerb, tn as refineStartOrder, tt as resolveRunnerModule, u as OUTPUT_DATA_DIRS_ENV, un as concatTokenSchema, ut as memberForRef, v as applyChildWrapper, vn as mapTokenSchema, vt as envSitesOf, w as readRunRecord, wn as CONNECT_PLUGIN_OWNED_SLICES, wt as describeToken, x as listRunRecords, xn as tokenKeyOf, xt as refKey, y as clearRunRecord, yn as outputTokenSchema, yt as outputRefsOf, z as lintOutputsFile, zn as runObserveHook, zt as declaredHostSchemas } from "./compound-DKi56SSx.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import crypto from "node:crypto";
|
|
4
4
|
import fs from "node:fs";
|
|
@@ -8,8 +8,104 @@ import { z } from "zod";
|
|
|
8
8
|
import { driveAddressMessage, switchboardOfDrive, switchboardOfDrive as switchboardOfDrive$1 } from "@powerhousedao/shared/host-tokens";
|
|
9
9
|
import { ORIGIN_PLACEHOLDER, SWITCHBOARD_PROXY_PATHS, isHtmlNavigation, isOriginPlaceholderUrl, isSwitchboardProxyPath, resolveOriginPlaceholders, toOriginPlaceholder, withOriginPlaceholders } from "@powerhousedao/shared/connect/origin-placeholder";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
|
+
import net from "node:net";
|
|
11
12
|
import { DEFAULT_CONNECT_STUDIO_PORT, DEFAULT_SWITCHBOARD_PORT } from "@powerhousedao/shared/clis/constants";
|
|
12
13
|
import { DRIVE_ICON_MAX_BYTES, resolveImageRef } from "@powerhousedao/shared/connect/image-ref";
|
|
14
|
+
//#region src/stop-channel.ts
|
|
15
|
+
/**
|
|
16
|
+
* Windows has no SIGTERM: `process.kill(pid, "SIGTERM")` ends the process at
|
|
17
|
+
* once, so no handler runs and a stack's stores are left as a crash leaves
|
|
18
|
+
* them. A started host therefore listens on a pipe named after its pid, and
|
|
19
|
+
* a connection to it is delivered as the SIGTERM it stands for. Elsewhere
|
|
20
|
+
* the signal itself does this, and there is no channel.
|
|
21
|
+
*/
|
|
22
|
+
function stopChannelPath(pid, platform = process.platform) {
|
|
23
|
+
return platform === "win32" ? `\\\\.\\pipe\\ph-stop-${pid}` : void 0;
|
|
24
|
+
}
|
|
25
|
+
/** Calls `onStop` for each connection to `channel`. The server holds no
|
|
26
|
+
* process open, and one that cannot listen leaves the host running without
|
|
27
|
+
* a channel rather than not running. */
|
|
28
|
+
function listenForStop(channel, onStop) {
|
|
29
|
+
const server = net.createServer((socket) => {
|
|
30
|
+
socket.on("error", () => void 0);
|
|
31
|
+
socket.end();
|
|
32
|
+
onStop();
|
|
33
|
+
});
|
|
34
|
+
server.on("error", () => void 0);
|
|
35
|
+
server.listen(channel);
|
|
36
|
+
server.unref();
|
|
37
|
+
return server;
|
|
38
|
+
}
|
|
39
|
+
let installed = false;
|
|
40
|
+
/** What a host's process calls once before it starts anything: from then on
|
|
41
|
+
* {@link requestStop} reaches its SIGTERM handlers on every platform. */
|
|
42
|
+
function installStopChannel() {
|
|
43
|
+
const channel = stopChannelPath(process.pid);
|
|
44
|
+
if (!channel || installed) return;
|
|
45
|
+
installed = true;
|
|
46
|
+
listenForStop(channel, () => {
|
|
47
|
+
if (!process.emit("SIGTERM", "SIGTERM")) process.exit(143);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const ASK_TIMEOUT_MS = 2e3;
|
|
51
|
+
/** Connects to a stop channel; true once the listener took the request. */
|
|
52
|
+
function askToStop(channel, timeoutMs = ASK_TIMEOUT_MS) {
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
let connected = false;
|
|
55
|
+
const socket = net.connect(channel);
|
|
56
|
+
socket.setTimeout(timeoutMs, () => socket.destroy());
|
|
57
|
+
socket.once("connect", () => connected = true);
|
|
58
|
+
socket.on("error", () => void 0);
|
|
59
|
+
socket.once("close", () => resolve(connected));
|
|
60
|
+
socket.resume();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Asks the process to stop as SIGTERM would. False when it could not be
|
|
65
|
+
* asked: on Windows a process without a stop channel (started by an older
|
|
66
|
+
* version, or not a host), which only a kill ends.
|
|
67
|
+
*/
|
|
68
|
+
async function requestStop(pid, platform = process.platform) {
|
|
69
|
+
const channel = stopChannelPath(pid, platform);
|
|
70
|
+
if (channel) return askToStop(channel);
|
|
71
|
+
try {
|
|
72
|
+
process.kill(pid, "SIGTERM");
|
|
73
|
+
} catch {}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
const STOP_RUN_TIMEOUT_MS = 6e4;
|
|
77
|
+
/** Asks the project's running `hostName` to stop and waits until its process
|
|
78
|
+
* is gone. It never kills: a host that does not answer keeps running. */
|
|
79
|
+
async function stopRun(projectDir, hostName, options = {}) {
|
|
80
|
+
const env = options.env ?? process.env;
|
|
81
|
+
const projectName = readProjectName(projectDir);
|
|
82
|
+
const probe = probeRun(projectDir, hostName, projectName, env);
|
|
83
|
+
if (probe.status === "none" || probe.status === "stale") return { status: "none" };
|
|
84
|
+
const { pid } = probe.record;
|
|
85
|
+
if (probe.status === "foreign") return {
|
|
86
|
+
status: "foreign",
|
|
87
|
+
pid,
|
|
88
|
+
projectName: probe.record.projectName
|
|
89
|
+
};
|
|
90
|
+
if (!await requestStop(pid)) return {
|
|
91
|
+
status: "unreachable",
|
|
92
|
+
pid
|
|
93
|
+
};
|
|
94
|
+
const deadline = Date.now() + (options.timeoutMs ?? 6e4);
|
|
95
|
+
while (isPidAlive(pid)) {
|
|
96
|
+
if (Date.now() >= deadline) return {
|
|
97
|
+
status: "timeout",
|
|
98
|
+
pid
|
|
99
|
+
};
|
|
100
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
101
|
+
}
|
|
102
|
+
if (readRunRecord(projectDir, hostName, env)?.pid === pid) clearRunRecord(projectDir, hostName, env);
|
|
103
|
+
return {
|
|
104
|
+
status: "stopped",
|
|
105
|
+
pid
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
13
109
|
//#region src/spawn-host.ts
|
|
14
110
|
/** The tail line before which a timed-out or aborted run's output is its own. */
|
|
15
111
|
const SPAWN_STOPPING_NOTE = "spawnHost: stopping it";
|
|
@@ -1175,6 +1271,6 @@ function expectHost(input) {
|
|
|
1175
1271
|
return expectation;
|
|
1176
1272
|
}
|
|
1177
1273
|
//#endregion
|
|
1178
|
-
export { BUILTIN_ENV_NAMES, CONNECT_PLUGIN_OWNED_SLICES, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, HostLoadError, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, OUTPUTS_FILE, OUTPUT_DATA_DIRS_ENV, PlanError, PluginError, RunnerError, SPAWN_STOPPING_NOTE, STORE_VERBS, SWITCHBOARD_PROXY_PATHS, SpawnHostError, TOKEN_ESCAPE_KEY, TOKEN_KEYS, TokenResolutionError, applyChildWrapper, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, browserBackend, buildDriveDeclarationSchema, checkHost, checkOutputPaths, checkRunnerArgv, checkTokenSites, childWrapperSchema, childrenSchema, clearRunRecord, collectTokenSites, compoundHostSchema, compoundOutputSource, compoundWiringSchema, computeOutputsHash, concatTokenSchema, connectReactorIssues, declaredGenericCompoundHostSchema, declaredHostSchemas, defaultConnectComposition, defaultUserDataDir, defineHostSchemas, describeHostOutputs, describeMapElements, describeToken, driveAddressMessage, driveDeclarationSchema, drivesSchema, emitHostJsonSchema, emittedHostSchemas, emptyMaps, entryActiveForVerb, envSitesOf, envTokenSchema, envTokenable, expectHost, explainDrivePlan, exportHost, findDeadConnectConfig, findNonStaticValue, findRemovedForms, findToken, forbidRef, formatPath, genericCompoundHostSchema, getVerb, hostExportSchema, hostNameSchema, hostSchemaIssues, hostTypeSatisfies, isBuiltinEnvName, isHtmlNavigation, isOriginPlaceholderUrl, isPidAlive, isRunnerArgsSchema, isSchemaLike, isStructuralMultiReactor, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, kindShapeIssues, knownVerbIssues, lintHostImportGraph, lintHostImports, lintOutputsFile, listRunRecords, listVerbs, loadHost, loadProducers, makeHostSchemas, mapTokenSchema, memberForRef, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, placeConnectDrives, placementKeyIssues, planCompound, pluginEntryObjectSchema, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, processResolveEnv, producerOutputsSchemas, profileSchema, projectDriveId, projectDriveIdWith, projectDrivesIntoConnect, projectReactorToConnect, protocolConflicts, protocolEnv, protocolEnvAgrees, reactorBackendKindSchema, reactorBackendSchema, reactorBlockToSwitchboardConfig, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readOutputsFileHash, readProjectName, readRunRecord, rebaseDriveUrl, ref, refKey, refineConnectReactor, refineStartOrder, registerHostType, remoteBackendUrls, remoteBackends, renderTokens, resolveDriveDeclaration, resolveHostOutputs, resolveHostPlugins, resolveOrder, resolveOriginPlaceholders, resolvePluginContributions, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runRecordMemberSchema, runRecordOutputSource, runRecordSchema, runTransformHook, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, runnerOutputsSchema, scanHostImports, schemaAtPath, seedDrives, spawnHost, splitCompoundArgv, splitRunArgv, stripComments, substituteBuiltinEnv, switchboardOfDrive, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, unservedConnectStorage, unwrapEscapes, validateDeclaredHost, validateHost, withOriginPlaceholders, writeRunRecord };
|
|
1274
|
+
export { BUILTIN_ENV_NAMES, CONNECT_PLUGIN_OWNED_SLICES, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, HostLoadError, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, OUTPUTS_FILE, OUTPUT_DATA_DIRS_ENV, PlanError, PluginError, RunnerError, SPAWN_STOPPING_NOTE, STOP_RUN_TIMEOUT_MS, STORE_VERBS, SWITCHBOARD_PROXY_PATHS, SpawnHostError, TOKEN_ESCAPE_KEY, TOKEN_KEYS, TokenResolutionError, applyChildWrapper, askToStop, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, browserBackend, buildDriveDeclarationSchema, checkHost, checkOutputPaths, checkRunnerArgv, checkTokenSites, childWrapperSchema, childrenSchema, clearRunRecord, collectTokenSites, compoundHostSchema, compoundOutputSource, compoundWiringSchema, computeOutputsHash, concatTokenSchema, connectReactorIssues, declaredGenericCompoundHostSchema, declaredHostSchemas, defaultConnectComposition, defaultUserDataDir, defineHostSchemas, describeHostOutputs, describeMapElements, describeToken, driveAddressMessage, driveDeclarationSchema, drivesSchema, emitHostJsonSchema, emittedHostSchemas, emptyMaps, entryActiveForVerb, envSitesOf, envTokenSchema, envTokenable, expectHost, explainDrivePlan, exportHost, findDeadConnectConfig, findNonStaticValue, findRemovedForms, findToken, forbidRef, formatPath, genericCompoundHostSchema, getVerb, hostExportSchema, hostNameSchema, hostSchemaIssues, hostTypeSatisfies, installStopChannel, isBuiltinEnvName, isHtmlNavigation, isOriginPlaceholderUrl, isPidAlive, isRunnerArgsSchema, isSchemaLike, isStructuralMultiReactor, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, kindShapeIssues, knownVerbIssues, lintHostImportGraph, lintHostImports, lintOutputsFile, listRunRecords, listVerbs, listenForStop, loadHost, loadProducers, makeHostSchemas, mapTokenSchema, memberForRef, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, placeConnectDrives, placementKeyIssues, planCompound, pluginEntryObjectSchema, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, processResolveEnv, producerOutputsSchemas, profileSchema, projectDriveId, projectDriveIdWith, projectDrivesIntoConnect, projectReactorToConnect, protocolConflicts, protocolEnv, protocolEnvAgrees, reactorBackendKindSchema, reactorBackendSchema, reactorBlockToSwitchboardConfig, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readOutputsFileHash, readProjectName, readRunRecord, rebaseDriveUrl, ref, refKey, refineConnectReactor, refineStartOrder, registerHostType, remoteBackendUrls, remoteBackends, renderTokens, requestStop, resolveDriveDeclaration, resolveHostOutputs, resolveHostPlugins, resolveOrder, resolveOriginPlaceholders, resolvePluginContributions, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runRecordMemberSchema, runRecordOutputSource, runRecordSchema, runTransformHook, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, runnerOutputsSchema, scanHostImports, schemaAtPath, seedDrives, spawnHost, splitCompoundArgv, splitRunArgv, stopChannelPath, stopRun, stripComments, substituteBuiltinEnv, switchboardOfDrive, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, unservedConnectStorage, unwrapEscapes, validateDeclaredHost, validateHost, withOriginPlaceholders, writeRunRecord };
|
|
1179
1275
|
|
|
1180
1276
|
//# sourceMappingURL=index.mjs.map
|