@ariestools/cli-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/README.md +31 -0
- package/dist/node/ActorBuilderCatalog.d.ts +11 -0
- package/dist/node/ActorBuilderCatalog.d.ts.map +1 -0
- package/dist/node/ActorSupervisor.d.ts +55 -0
- package/dist/node/ActorSupervisor.d.ts.map +1 -0
- package/dist/node/CommandCatalog.d.ts +19 -0
- package/dist/node/CommandCatalog.d.ts.map +1 -0
- package/dist/node/ManagedActor.d.ts +20 -0
- package/dist/node/ManagedActor.d.ts.map +1 -0
- package/dist/node/ProcessApplication.d.ts +17 -0
- package/dist/node/ProcessApplication.d.ts.map +1 -0
- package/dist/node/ProcessHost.d.ts +37 -0
- package/dist/node/ProcessHost.d.ts.map +1 -0
- package/dist/node/RuntimeSession.d.ts +42 -0
- package/dist/node/RuntimeSession.d.ts.map +1 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +377 -0
- package/dist/node/index.mjs.map +7 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @ariestools/cli-kit
|
|
2
|
+
|
|
3
|
+
Reusable, instance-scoped actor lifecycle primitives for command-line applications.
|
|
4
|
+
|
|
5
|
+
This package is intentionally independent of XL1 and xyo-chain. Application packages supply structural actors that implement `ManagedActor`; the core only coordinates registration, startup, readiness, rollback, and shutdown.
|
|
6
|
+
|
|
7
|
+
The package also provides structural `ProcessHost` and `ProcessIO` boundaries for adapting an application's concrete process runtime without importing Node APIs into the core. Arguments, environment values, terminal width, output, prompts, interrupts, and exits are all supplied by the host. Use `exitProcess` at exit points that occur before the end of a command: production hosts may terminate immediately, while recording hosts receive a `ProcessExitError` that stops control flow deterministically. `RuntimeSession` owns one application-supplied stop operation and preserves fail-fast shutdown behavior while making repeated stop requests idempotent. It can also own one structural interrupt binding, coalesce repeated interrupts while the application listener settles, and dispose the binding at the correct manual or interrupt-driven shutdown boundary.
|
|
8
|
+
|
|
9
|
+
`runProcessApplication` owns the outermost application failure boundary. It absorbs standardized exit signals that have already been routed through a `ProcessHost`, hides unexpected error details outside development, and requests exit code one for unhandled failures. Concrete process adapters remain separate packages; Node applications can use `@ariestools/cli-kit-node`.
|
|
10
|
+
|
|
11
|
+
`createCommandCatalog` registers ordered command factories against a structural `CliApplicationContext`. The command type is supplied by the application, so parser-specific types and domain-specific configuration remain outside the core. A catalog is immutable and reusable; each application invocation materializes fresh command objects with its own context.
|
|
12
|
+
|
|
13
|
+
## Lifecycle guarantees
|
|
14
|
+
|
|
15
|
+
- Actors start sequentially in registration order.
|
|
16
|
+
- A failed startup rolls back every actor that already started, in reverse order.
|
|
17
|
+
- Readiness is observed in registration order with an optional supervisor-wide timeout.
|
|
18
|
+
- Shutdown runs in reverse startup order and is idempotent.
|
|
19
|
+
- Shutdown attempts every started actor before reporting aggregated failures.
|
|
20
|
+
- A runtime session invokes its stop delegate once and shares one stop promise.
|
|
21
|
+
- Runtime stop failures retain and rethrow the original value without wrapping.
|
|
22
|
+
- A runtime session accepts at most one interrupt binding while active.
|
|
23
|
+
- Repeated interrupts share one listener promise and retain the binding until that listener settles.
|
|
24
|
+
- Manual shutdown disposes its interrupt binding before cleanup begins.
|
|
25
|
+
- Process applications absorb host-routed exits and map unexpected failures to exit code one.
|
|
26
|
+
- Command catalogs preserve registration order and reject blank or duplicate ids.
|
|
27
|
+
- Command factories receive the exact per-application context and are invoked again for each materialization.
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
LGPL-3.0-only
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ActorBuilderDefinition<TContext, TActor> {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
build(context: TContext): Promise<TActor>;
|
|
4
|
+
}
|
|
5
|
+
export interface ActorBuilderCatalog<TContext, TActor> {
|
|
6
|
+
readonly names: readonly string[];
|
|
7
|
+
build(name: string, context: TContext): Promise<TActor>;
|
|
8
|
+
}
|
|
9
|
+
/** Creates an ordered, instance-scoped actor builder catalog. */
|
|
10
|
+
export declare function createActorBuilderCatalog<TContext, TActor>(definitions: readonly ActorBuilderDefinition<TContext, TActor>[]): ActorBuilderCatalog<TContext, TActor>;
|
|
11
|
+
//# sourceMappingURL=ActorBuilderCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActorBuilderCatalog.d.ts","sourceRoot":"","sources":["../../src/ActorBuilderCatalog.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB,CAAC,QAAQ,EAAE,MAAM;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAC1C;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ,EAAE,MAAM;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACxD;AAED,iEAAiE;AACjE,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EACxD,WAAW,EAAE,SAAS,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,GAC/D,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAmBvC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ManagedActor, ReadinessSignal, ReadyState } from './ManagedActor.ts';
|
|
2
|
+
export type ActorSupervisorState = 'failed' | 'idle' | 'started' | 'starting' | 'stopped' | 'stopping';
|
|
3
|
+
export declare class ActorRegistrationError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class ActorSupervisorStateError extends Error {
|
|
7
|
+
readonly state: ActorSupervisorState;
|
|
8
|
+
constructor(operation: string, state: ActorSupervisorState);
|
|
9
|
+
}
|
|
10
|
+
export declare class ActorStartupError extends Error {
|
|
11
|
+
readonly actorName: string;
|
|
12
|
+
readonly rollbackErrors: readonly Error[];
|
|
13
|
+
constructor(actorName: string, cause: unknown, rollbackErrors: readonly Error[]);
|
|
14
|
+
}
|
|
15
|
+
export declare class ActorReadinessError extends Error {
|
|
16
|
+
readonly actorName: string;
|
|
17
|
+
constructor(actorName: string, cause: unknown);
|
|
18
|
+
}
|
|
19
|
+
export declare class ActorReadinessTimeoutError extends Error {
|
|
20
|
+
readonly timeoutMs: number;
|
|
21
|
+
constructor(timeoutMs: number);
|
|
22
|
+
}
|
|
23
|
+
export declare class ActorShutdownError extends AggregateError {
|
|
24
|
+
constructor(errors: readonly Error[]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Instance-scoped coordinator for structural managed actors.
|
|
28
|
+
*
|
|
29
|
+
* Startup and readiness follow registration order. Rollback and ordinary shutdown
|
|
30
|
+
* follow reverse startup order. A supervisor is single-use after it has stopped or
|
|
31
|
+
* failed; construct a new instance for a new lifecycle.
|
|
32
|
+
*/
|
|
33
|
+
export declare class ActorSupervisor implements ReadinessSignal {
|
|
34
|
+
private readonly _actorNames;
|
|
35
|
+
private readonly _actors;
|
|
36
|
+
private _readyError?;
|
|
37
|
+
private _startPromise?;
|
|
38
|
+
private readonly _startedActors;
|
|
39
|
+
private _state;
|
|
40
|
+
private _stopPromise?;
|
|
41
|
+
constructor(actors?: readonly ManagedActor[]);
|
|
42
|
+
get actors(): readonly ManagedActor[];
|
|
43
|
+
get readyError(): Error | undefined;
|
|
44
|
+
get readyState(): ReadyState;
|
|
45
|
+
get state(): ActorSupervisorState;
|
|
46
|
+
isReady(): boolean;
|
|
47
|
+
register(actor: ManagedActor): void;
|
|
48
|
+
start(): Promise<void>;
|
|
49
|
+
stop(): Promise<void>;
|
|
50
|
+
whenReady(timeoutMs?: number): Promise<void>;
|
|
51
|
+
private startActors;
|
|
52
|
+
private stopActors;
|
|
53
|
+
private stopStartedActors;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ActorSupervisor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActorSupervisor.d.ts","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,CAAC,cAAc,CAAqB;IACpD,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,YAAY,CAAC,CAAe;gBAExB,MAAM,GAAE,SAAS,YAAY,EAAO;IAIhD,IAAI,MAAM,IAAI,SAAS,YAAY,EAAE,CAEpC;IAED,IAAI,UAAU,IAAI,KAAK,GAAG,SAAS,CAGlC;IAED,IAAI,UAAU,IAAI,UAAU,CAM3B;IAED,IAAI,KAAK,IAAI,oBAAoB,CAEhC;IAED,OAAO,IAAI,OAAO;IAIlB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAUnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKf,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YA0BpC,WAAW;YAiBX,UAAU;YAqBV,iBAAiB;CAchC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ProcessHost } from './ProcessHost.ts';
|
|
2
|
+
/** Process capability shared by every command created for one CLI app. */
|
|
3
|
+
export interface CliApplicationContext {
|
|
4
|
+
readonly host: ProcessHost;
|
|
5
|
+
}
|
|
6
|
+
/** Adapter-neutral factory for one parser-specific command object. */
|
|
7
|
+
export interface CommandDefinition<TContext extends CliApplicationContext, TCommand> {
|
|
8
|
+
readonly create: (context: TContext) => TCommand;
|
|
9
|
+
/** Internal registration identity; it does not define parser syntax or aliases. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
}
|
|
12
|
+
/** Ordered command factories materialized for one app context. */
|
|
13
|
+
export interface CommandCatalog<TContext extends CliApplicationContext, TCommand> {
|
|
14
|
+
readonly createCommands: (context: TContext) => readonly TCommand[];
|
|
15
|
+
readonly ids: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
/** Creates an immutable, adapter-neutral command catalog. */
|
|
18
|
+
export declare function createCommandCatalog<TContext extends CliApplicationContext, TCommand>(definitions: readonly CommandDefinition<TContext, TCommand>[]): CommandCatalog<TContext, TCommand>;
|
|
19
|
+
//# sourceMappingURL=CommandCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandCatalog.d.ts","sourceRoot":"","sources":["../../src/CommandCatalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,0EAA0E;AAC1E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAC3B;AAED,sEAAsE;AACtE,MAAM,WAAW,iBAAiB,CAAC,QAAQ,SAAS,qBAAqB,EAAE,QAAQ;IACjF,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,QAAQ,CAAA;IAChD,mFAAmF;IACnF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc,CAAC,QAAQ,SAAS,qBAAqB,EAAE,QAAQ;IAC9E,QAAQ,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,SAAS,QAAQ,EAAE,CAAA;IACnE,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,qBAAqB,EAAE,QAAQ,EACnF,WAAW,EAAE,SAAS,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAC5D,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAoBpC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Result convention used by managed actor lifecycle operations. */
|
|
2
|
+
export type ManagedActorLifecycleResult = boolean | void;
|
|
3
|
+
/** Observable readiness state for an actor or actor supervisor. */
|
|
4
|
+
export type ReadyState = 'failed' | 'pending' | 'ready';
|
|
5
|
+
/** Structural readiness contract; implementations do not need to inherit a kit class. */
|
|
6
|
+
export interface ReadinessSignal {
|
|
7
|
+
readonly readyError?: Error;
|
|
8
|
+
readonly readyState: ReadyState;
|
|
9
|
+
whenReady(timeoutMs?: number): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Structural lifecycle contract coordinated by {@link ActorSupervisor}.
|
|
13
|
+
* Returning `false` from `start` or `stop` reports a lifecycle failure.
|
|
14
|
+
*/
|
|
15
|
+
export interface ManagedActor extends ReadinessSignal {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
start(): ManagedActorLifecycleResult | Promise<ManagedActorLifecycleResult>;
|
|
18
|
+
stop(): ManagedActorLifecycleResult | Promise<ManagedActorLifecycleResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ManagedActor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManagedActor.d.ts","sourceRoot":"","sources":["../../src/ManagedActor.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,MAAM,2BAA2B,GAAG,OAAO,GAAG,IAAI,CAAA;AAExD,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AAEvD,yFAAyF;AACzF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,KAAK,IAAI,2BAA2B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAC3E,IAAI,IAAI,2BAA2B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;CAC3E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ProcessHost } from './ProcessHost.ts';
|
|
2
|
+
/** Application entry point executed against an explicit process boundary. */
|
|
3
|
+
export type ProcessApplication = (host: ProcessHost) => Promise<void>;
|
|
4
|
+
export interface RunProcessApplicationOptions {
|
|
5
|
+
readonly application: ProcessApplication;
|
|
6
|
+
readonly host: ProcessHost;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Runs one CLI app at the outermost process boundary.
|
|
10
|
+
*
|
|
11
|
+
* Immediate exits requested through `exitProcess` have already been
|
|
12
|
+
* routed to the host and are absorbed here. Unexpected failures retain the
|
|
13
|
+
* established CLI policy of logging details only in development before
|
|
14
|
+
* requesting exit code one.
|
|
15
|
+
*/
|
|
16
|
+
export declare function runProcessApplication({ application, host, }: RunProcessApplicationOptions): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=ProcessApplication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessApplication.d.ts","sourceRoot":"","sources":["../../src/ProcessApplication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAErE,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAA;IACxC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,WAAW,EACX,IAAI,GACL,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Process-facing input and output used by a command-line app. */
|
|
2
|
+
export interface ProcessIO {
|
|
3
|
+
/** Available terminal width when output is attached to a sized terminal. */
|
|
4
|
+
readonly columns?: number;
|
|
5
|
+
readonly isInteractive: boolean;
|
|
6
|
+
error(...values: readonly unknown[]): void;
|
|
7
|
+
log(...values: readonly unknown[]): void;
|
|
8
|
+
question(prompt: string): Promise<string>;
|
|
9
|
+
warn(...values: readonly unknown[]): void;
|
|
10
|
+
}
|
|
11
|
+
/** Control-flow signal used when a non-terminating host records an immediate exit. */
|
|
12
|
+
export declare class ProcessExitError extends Error {
|
|
13
|
+
readonly exitCode: number;
|
|
14
|
+
constructor(exitCode: number);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Structural process boundary for a command-line app.
|
|
18
|
+
*
|
|
19
|
+
* Production implementations may terminate from {@link exit}; recording hosts
|
|
20
|
+
* may return after retaining the requested status.
|
|
21
|
+
*/
|
|
22
|
+
export interface ProcessHost {
|
|
23
|
+
/** Full argument vector, including the executable and script entries. */
|
|
24
|
+
readonly argv: readonly string[];
|
|
25
|
+
/** Environment visible to this app invocation. */
|
|
26
|
+
readonly environment: Readonly<Record<string, string | undefined>>;
|
|
27
|
+
readonly io: ProcessIO;
|
|
28
|
+
readonly isDevelopment: boolean;
|
|
29
|
+
exit(code: number): void;
|
|
30
|
+
onInterrupt(listener: () => Promise<void> | void): () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Requests immediate process termination and prevents a recording host from
|
|
34
|
+
* accidentally continuing through code that follows the exit point.
|
|
35
|
+
*/
|
|
36
|
+
export declare function exitProcess(host: Pick<ProcessHost, 'exit'>, exitCode: number): never;
|
|
37
|
+
//# sourceMappingURL=ProcessHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessHost.d.ts","sourceRoot":"","sources":["../../src/ProcessHost.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAA;IAC1C,GAAG,CAAC,GAAG,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACzC,IAAI,CAAC,GAAG,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAA;CAC1C;AAED,sFAAsF;AACtF,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;gBAEb,QAAQ,EAAE,MAAM;CAK7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IAClE,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAA;IACtB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,IAAI,CAAA;CAC9D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAGpF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ProcessHost } from './ProcessHost.ts';
|
|
2
|
+
/** Lifecycle state of one active runtime session. */
|
|
3
|
+
export type RuntimeSessionState = 'active' | 'failed' | 'stopped' | 'stopping';
|
|
4
|
+
/** Application-owned cleanup invoked when a runtime session stops. */
|
|
5
|
+
export type RuntimeStopDelegate = () => Promise<void> | void;
|
|
6
|
+
/** Application-owned work invoked for the first process interrupt. */
|
|
7
|
+
export type RuntimeInterruptListener = () => Promise<void> | void;
|
|
8
|
+
/**
|
|
9
|
+
* Instance-scoped owner for one runtime cleanup operation.
|
|
10
|
+
*
|
|
11
|
+
* Every call to {@link stop} returns the same promise. A cleanup failure is
|
|
12
|
+
* retained and rethrown without wrapping so callers can preserve their
|
|
13
|
+
* existing fail-fast behavior.
|
|
14
|
+
*/
|
|
15
|
+
export declare class RuntimeSession {
|
|
16
|
+
private _exitCode?;
|
|
17
|
+
private _exitHost?;
|
|
18
|
+
private _exitPromise?;
|
|
19
|
+
private _hasInterruptBinding;
|
|
20
|
+
private _interruptDisposer?;
|
|
21
|
+
private _interruptPromise?;
|
|
22
|
+
private _isInterruptDisposed;
|
|
23
|
+
private _state;
|
|
24
|
+
private readonly _stopDelegate;
|
|
25
|
+
private _stopError?;
|
|
26
|
+
private _stopPromise?;
|
|
27
|
+
constructor(stopDelegate: RuntimeStopDelegate);
|
|
28
|
+
get state(): RuntimeSessionState;
|
|
29
|
+
get stopError(): unknown;
|
|
30
|
+
bindInterrupt(host: Pick<ProcessHost, 'onInterrupt'>, listener: RuntimeInterruptListener): void;
|
|
31
|
+
/**
|
|
32
|
+
* Coalesces competing process-exit requests for this session. Requests made
|
|
33
|
+
* in the same turn retain the highest exit code and every caller observes
|
|
34
|
+
* the same exactly-once exit operation.
|
|
35
|
+
*/
|
|
36
|
+
requestExit(host: Pick<ProcessHost, 'exit'>, exitCode: number): Promise<void>;
|
|
37
|
+
stop(): Promise<void>;
|
|
38
|
+
private disposeInterrupt;
|
|
39
|
+
private handleInterrupt;
|
|
40
|
+
private stopOnce;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=RuntimeSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeSession.d.ts","sourceRoot":"","sources":["../../src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BAAgB;IAQxB,OAAO,CAAC,eAAe;YAeT,QAAQ;CAUvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './ActorBuilderCatalog.ts';
|
|
2
|
+
export * from './ActorSupervisor.ts';
|
|
3
|
+
export * from './CommandCatalog.ts';
|
|
4
|
+
export * from './ManagedActor.ts';
|
|
5
|
+
export * from './ProcessApplication.ts';
|
|
6
|
+
export * from './ProcessHost.ts';
|
|
7
|
+
export * from './RuntimeSession.ts';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
// src/ActorBuilderCatalog.ts
|
|
2
|
+
function createActorBuilderCatalog(definitions) {
|
|
3
|
+
const definitionsByName = /* @__PURE__ */ new Map();
|
|
4
|
+
const names = [];
|
|
5
|
+
for (const definition of definitions) {
|
|
6
|
+
if (definitionsByName.has(definition.name)) {
|
|
7
|
+
throw new Error(`Actor builder "${definition.name}" is already registered`);
|
|
8
|
+
}
|
|
9
|
+
definitionsByName.set(definition.name, definition);
|
|
10
|
+
names.push(definition.name);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
names: Object.freeze(names),
|
|
14
|
+
async build(name, context) {
|
|
15
|
+
const definition = definitionsByName.get(name);
|
|
16
|
+
if (definition === void 0) throw new Error(`Unknown actor: ${name}`);
|
|
17
|
+
return await definition.build(context);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/ActorSupervisor.ts
|
|
23
|
+
var ActorRegistrationError = class extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ActorRegistrationError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var ActorSupervisorStateError = class extends Error {
|
|
30
|
+
state;
|
|
31
|
+
constructor(operation, state) {
|
|
32
|
+
super(`Cannot ${operation} while actor supervisor is ${state}`);
|
|
33
|
+
this.name = "ActorSupervisorStateError";
|
|
34
|
+
this.state = state;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var ActorStartupError = class extends Error {
|
|
38
|
+
actorName;
|
|
39
|
+
rollbackErrors;
|
|
40
|
+
constructor(actorName, cause, rollbackErrors) {
|
|
41
|
+
super(`Actor "${actorName}" failed to start`, { cause });
|
|
42
|
+
this.name = "ActorStartupError";
|
|
43
|
+
this.actorName = actorName;
|
|
44
|
+
this.rollbackErrors = rollbackErrors;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var ActorReadinessError = class extends Error {
|
|
48
|
+
actorName;
|
|
49
|
+
constructor(actorName, cause) {
|
|
50
|
+
super(`Actor "${actorName}" failed to become ready`, { cause });
|
|
51
|
+
this.name = "ActorReadinessError";
|
|
52
|
+
this.actorName = actorName;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var ActorReadinessTimeoutError = class extends Error {
|
|
56
|
+
timeoutMs;
|
|
57
|
+
constructor(timeoutMs) {
|
|
58
|
+
super(`Actors did not become ready within ${timeoutMs}ms`);
|
|
59
|
+
this.name = "ActorReadinessTimeoutError";
|
|
60
|
+
this.timeoutMs = timeoutMs;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var ActorShutdownError = class extends AggregateError {
|
|
64
|
+
constructor(errors) {
|
|
65
|
+
super(errors, `${errors.length} actor(s) failed to stop`);
|
|
66
|
+
this.name = "ActorShutdownError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function asError(error) {
|
|
70
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
71
|
+
}
|
|
72
|
+
function assertLifecycleSucceeded(actor, operation, result) {
|
|
73
|
+
if (result === false) {
|
|
74
|
+
throw new Error(`Actor "${actor.name}" ${operation}() reported failure`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function assertTimeout(timeoutMs) {
|
|
78
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
79
|
+
throw new RangeError("Readiness timeout must be a finite, non-negative number");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function waitWithTimeout(signal, timeoutMs) {
|
|
83
|
+
const timerHost = globalThis;
|
|
84
|
+
let timeoutHandle;
|
|
85
|
+
const expired = new Promise((_resolve, reject) => {
|
|
86
|
+
timeoutHandle = timerHost.setTimeout(() => reject(new ActorReadinessTimeoutError(timeoutMs)), timeoutMs);
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
await Promise.race([signal.whenReady(timeoutMs), expired]);
|
|
90
|
+
} finally {
|
|
91
|
+
timerHost.clearTimeout(timeoutHandle);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
var ActorSupervisor = class {
|
|
95
|
+
_actorNames = /* @__PURE__ */ new Set();
|
|
96
|
+
_actors = [];
|
|
97
|
+
_readyError;
|
|
98
|
+
_startPromise;
|
|
99
|
+
_startedActors = [];
|
|
100
|
+
_state = "idle";
|
|
101
|
+
_stopPromise;
|
|
102
|
+
constructor(actors = []) {
|
|
103
|
+
for (const actor of actors) this.register(actor);
|
|
104
|
+
}
|
|
105
|
+
get actors() {
|
|
106
|
+
return [...this._actors];
|
|
107
|
+
}
|
|
108
|
+
get readyError() {
|
|
109
|
+
if (this._readyError !== void 0) return this._readyError;
|
|
110
|
+
return this._actors.find((actor) => actor.readyState === "failed")?.readyError;
|
|
111
|
+
}
|
|
112
|
+
get readyState() {
|
|
113
|
+
if (this._readyError !== void 0 || this._state === "failed" || this._actors.some((actor) => actor.readyState === "failed")) {
|
|
114
|
+
return "failed";
|
|
115
|
+
}
|
|
116
|
+
if (this._state === "started" && this._actors.every((actor) => actor.readyState === "ready")) return "ready";
|
|
117
|
+
return "pending";
|
|
118
|
+
}
|
|
119
|
+
get state() {
|
|
120
|
+
return this._state;
|
|
121
|
+
}
|
|
122
|
+
isReady() {
|
|
123
|
+
return this.readyState === "ready";
|
|
124
|
+
}
|
|
125
|
+
register(actor) {
|
|
126
|
+
if (this._state !== "idle") throw new ActorSupervisorStateError("register an actor", this._state);
|
|
127
|
+
if (actor.name.trim().length === 0) throw new ActorRegistrationError("Actor name must not be empty");
|
|
128
|
+
if (this._actorNames.has(actor.name)) {
|
|
129
|
+
throw new ActorRegistrationError(`Actor "${actor.name}" is already registered`);
|
|
130
|
+
}
|
|
131
|
+
this._actorNames.add(actor.name);
|
|
132
|
+
this._actors.push(actor);
|
|
133
|
+
}
|
|
134
|
+
start() {
|
|
135
|
+
if (this._startPromise !== void 0) return this._startPromise;
|
|
136
|
+
if (this._state !== "idle") return Promise.reject(new ActorSupervisorStateError("start", this._state));
|
|
137
|
+
this._state = "starting";
|
|
138
|
+
this._startPromise = this.startActors();
|
|
139
|
+
return this._startPromise;
|
|
140
|
+
}
|
|
141
|
+
stop() {
|
|
142
|
+
this._stopPromise ??= this.stopActors();
|
|
143
|
+
return this._stopPromise;
|
|
144
|
+
}
|
|
145
|
+
async whenReady(timeoutMs) {
|
|
146
|
+
if (timeoutMs !== void 0) assertTimeout(timeoutMs);
|
|
147
|
+
if (this._state === "starting" && this._startPromise !== void 0) {
|
|
148
|
+
await this._startPromise;
|
|
149
|
+
}
|
|
150
|
+
if (this._state !== "started") throw new ActorSupervisorStateError("wait for readiness", this._state);
|
|
151
|
+
const startedAt = Date.now();
|
|
152
|
+
for (const actor of this._actors) {
|
|
153
|
+
try {
|
|
154
|
+
if (timeoutMs === void 0) {
|
|
155
|
+
await actor.whenReady();
|
|
156
|
+
} else {
|
|
157
|
+
const elapsed = Date.now() - startedAt;
|
|
158
|
+
const remainingTimeoutMs = timeoutMs - elapsed;
|
|
159
|
+
if (remainingTimeoutMs < 0) throw new ActorReadinessTimeoutError(timeoutMs);
|
|
160
|
+
await waitWithTimeout(actor, remainingTimeoutMs);
|
|
161
|
+
}
|
|
162
|
+
} catch (error) {
|
|
163
|
+
const readinessError = new ActorReadinessError(actor.name, error);
|
|
164
|
+
this._readyError = readinessError;
|
|
165
|
+
throw readinessError;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async startActors() {
|
|
170
|
+
for (const actor of this._actors) {
|
|
171
|
+
try {
|
|
172
|
+
const result = await actor.start();
|
|
173
|
+
assertLifecycleSucceeded(actor, "start", result);
|
|
174
|
+
this._startedActors.push(actor);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
const rollbackErrors = await this.stopStartedActors();
|
|
177
|
+
const startupError = new ActorStartupError(actor.name, error, rollbackErrors);
|
|
178
|
+
this._readyError = startupError;
|
|
179
|
+
this._state = "failed";
|
|
180
|
+
throw startupError;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
this._state = "started";
|
|
184
|
+
}
|
|
185
|
+
async stopActors() {
|
|
186
|
+
if (this._state === "starting" && this._startPromise !== void 0) {
|
|
187
|
+
try {
|
|
188
|
+
await this._startPromise;
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (this._state === "stopped") return;
|
|
193
|
+
if (this._state === "idle" || this._state === "failed" && this._startedActors.length === 0) {
|
|
194
|
+
this._state = "stopped";
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this._state = "stopping";
|
|
198
|
+
const errors = await this.stopStartedActors();
|
|
199
|
+
this._state = "stopped";
|
|
200
|
+
if (errors.length > 0) throw new ActorShutdownError(errors);
|
|
201
|
+
}
|
|
202
|
+
async stopStartedActors() {
|
|
203
|
+
const errors = [];
|
|
204
|
+
while (this._startedActors.length > 0) {
|
|
205
|
+
const actor = this._startedActors.pop();
|
|
206
|
+
if (actor === void 0) continue;
|
|
207
|
+
try {
|
|
208
|
+
const result = await actor.stop();
|
|
209
|
+
assertLifecycleSucceeded(actor, "stop", result);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
errors.push(new Error(`Actor "${actor.name}" failed to stop`, { cause: asError(error) }));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return errors;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/CommandCatalog.ts
|
|
219
|
+
function createCommandCatalog(definitions) {
|
|
220
|
+
const registeredIds = /* @__PURE__ */ new Set();
|
|
221
|
+
const retainedDefinitions = definitions.map((definition) => Object.freeze({
|
|
222
|
+
create: definition.create,
|
|
223
|
+
id: definition.id
|
|
224
|
+
}));
|
|
225
|
+
const ids = [];
|
|
226
|
+
for (const definition of retainedDefinitions) {
|
|
227
|
+
if (definition.id.trim().length === 0) throw new Error("Command id must not be empty");
|
|
228
|
+
if (registeredIds.has(definition.id)) throw new Error(`Command "${definition.id}" is already registered`);
|
|
229
|
+
registeredIds.add(definition.id);
|
|
230
|
+
ids.push(definition.id);
|
|
231
|
+
}
|
|
232
|
+
return Object.freeze({
|
|
233
|
+
ids: Object.freeze(ids),
|
|
234
|
+
createCommands: (context) => Object.freeze(retainedDefinitions.map((definition) => definition.create(context)))
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/ProcessHost.ts
|
|
239
|
+
var ProcessExitError = class extends Error {
|
|
240
|
+
exitCode;
|
|
241
|
+
constructor(exitCode) {
|
|
242
|
+
super(`Process requested exit with code ${exitCode}`);
|
|
243
|
+
this.name = "ProcessExitError";
|
|
244
|
+
this.exitCode = exitCode;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
function exitProcess(host, exitCode) {
|
|
248
|
+
host.exit(exitCode);
|
|
249
|
+
throw new ProcessExitError(exitCode);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/ProcessApplication.ts
|
|
253
|
+
async function runProcessApplication({
|
|
254
|
+
application,
|
|
255
|
+
host
|
|
256
|
+
}) {
|
|
257
|
+
try {
|
|
258
|
+
await application(host);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
if (error instanceof ProcessExitError) return;
|
|
261
|
+
if (host.isDevelopment) host.io.error("An error occurred during startup:", error);
|
|
262
|
+
host.exit(1);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/RuntimeSession.ts
|
|
267
|
+
var RuntimeSession = class {
|
|
268
|
+
_exitCode;
|
|
269
|
+
_exitHost;
|
|
270
|
+
_exitPromise;
|
|
271
|
+
_hasInterruptBinding = false;
|
|
272
|
+
_interruptDisposer;
|
|
273
|
+
_interruptPromise;
|
|
274
|
+
_isInterruptDisposed = false;
|
|
275
|
+
_state = "active";
|
|
276
|
+
_stopDelegate;
|
|
277
|
+
_stopError;
|
|
278
|
+
_stopPromise;
|
|
279
|
+
constructor(stopDelegate) {
|
|
280
|
+
this._stopDelegate = stopDelegate;
|
|
281
|
+
}
|
|
282
|
+
get state() {
|
|
283
|
+
return this._state;
|
|
284
|
+
}
|
|
285
|
+
get stopError() {
|
|
286
|
+
return this._stopError;
|
|
287
|
+
}
|
|
288
|
+
bindInterrupt(host, listener) {
|
|
289
|
+
if (this._hasInterruptBinding) throw new Error("An interrupt listener is already bound to this runtime session.");
|
|
290
|
+
if (this.state !== "active") throw new Error("An interrupt listener cannot be bound after runtime shutdown has started.");
|
|
291
|
+
this._hasInterruptBinding = true;
|
|
292
|
+
let isRegistrationComplete = false;
|
|
293
|
+
let isInterruptPending = false;
|
|
294
|
+
const handleInterrupt = () => {
|
|
295
|
+
if (!isRegistrationComplete) {
|
|
296
|
+
isInterruptPending = true;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
return this.handleInterrupt(listener);
|
|
300
|
+
};
|
|
301
|
+
this._interruptDisposer = host.onInterrupt(handleInterrupt);
|
|
302
|
+
isRegistrationComplete = true;
|
|
303
|
+
if (isInterruptPending) void this.handleInterrupt(listener);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Coalesces competing process-exit requests for this session. Requests made
|
|
307
|
+
* in the same turn retain the highest exit code and every caller observes
|
|
308
|
+
* the same exactly-once exit operation.
|
|
309
|
+
*/
|
|
310
|
+
requestExit(host, exitCode) {
|
|
311
|
+
this._exitCode = Math.max(this._exitCode ?? exitCode, exitCode);
|
|
312
|
+
this._exitHost ??= host;
|
|
313
|
+
this._exitPromise ??= Promise.try(async () => {
|
|
314
|
+
await Promise.resolve();
|
|
315
|
+
this._exitHost?.exit(this._exitCode ?? exitCode);
|
|
316
|
+
});
|
|
317
|
+
return this._exitPromise;
|
|
318
|
+
}
|
|
319
|
+
stop() {
|
|
320
|
+
if (this._interruptPromise === void 0) this.disposeInterrupt();
|
|
321
|
+
if (this._stopPromise === void 0) {
|
|
322
|
+
this._state = "stopping";
|
|
323
|
+
this._stopPromise = Promise.try(async () => {
|
|
324
|
+
await Promise.resolve();
|
|
325
|
+
await this.stopOnce();
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return this._stopPromise;
|
|
329
|
+
}
|
|
330
|
+
disposeInterrupt() {
|
|
331
|
+
if (!this._hasInterruptBinding || this._isInterruptDisposed) return;
|
|
332
|
+
this._isInterruptDisposed = true;
|
|
333
|
+
const dispose = this._interruptDisposer;
|
|
334
|
+
this._interruptDisposer = void 0;
|
|
335
|
+
dispose?.();
|
|
336
|
+
}
|
|
337
|
+
handleInterrupt(listener) {
|
|
338
|
+
if (this._interruptPromise === void 0) {
|
|
339
|
+
if (this._isInterruptDisposed) return Promise.resolve();
|
|
340
|
+
this._interruptPromise = Promise.try(async () => {
|
|
341
|
+
await Promise.resolve();
|
|
342
|
+
try {
|
|
343
|
+
await listener();
|
|
344
|
+
} finally {
|
|
345
|
+
this.disposeInterrupt();
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return this._interruptPromise;
|
|
350
|
+
}
|
|
351
|
+
async stopOnce() {
|
|
352
|
+
try {
|
|
353
|
+
await this._stopDelegate();
|
|
354
|
+
this._state = "stopped";
|
|
355
|
+
} catch (error) {
|
|
356
|
+
this._stopError = error;
|
|
357
|
+
this._state = "failed";
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
export {
|
|
363
|
+
ActorReadinessError,
|
|
364
|
+
ActorReadinessTimeoutError,
|
|
365
|
+
ActorRegistrationError,
|
|
366
|
+
ActorShutdownError,
|
|
367
|
+
ActorStartupError,
|
|
368
|
+
ActorSupervisor,
|
|
369
|
+
ActorSupervisorStateError,
|
|
370
|
+
ProcessExitError,
|
|
371
|
+
RuntimeSession,
|
|
372
|
+
createActorBuilderCatalog,
|
|
373
|
+
createCommandCatalog,
|
|
374
|
+
exitProcess,
|
|
375
|
+
runProcessApplication
|
|
376
|
+
};
|
|
377
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ActorBuilderCatalog.ts", "../../src/ActorSupervisor.ts", "../../src/CommandCatalog.ts", "../../src/ProcessHost.ts", "../../src/ProcessApplication.ts", "../../src/RuntimeSession.ts"],
|
|
4
|
+
"sourcesContent": ["export interface ActorBuilderDefinition<TContext, TActor> {\n readonly name: string\n build(context: TContext): Promise<TActor>\n}\n\nexport interface ActorBuilderCatalog<TContext, TActor> {\n readonly names: readonly string[]\n build(name: string, context: TContext): Promise<TActor>\n}\n\n/** Creates an ordered, instance-scoped actor builder catalog. */\nexport function createActorBuilderCatalog<TContext, TActor>(\n definitions: readonly ActorBuilderDefinition<TContext, TActor>[],\n): ActorBuilderCatalog<TContext, TActor> {\n const definitionsByName = new Map<string, ActorBuilderDefinition<TContext, TActor>>()\n const names: string[] = []\n for (const definition of definitions) {\n if (definitionsByName.has(definition.name)) {\n throw new Error(`Actor builder \"${definition.name}\" is already registered`)\n }\n definitionsByName.set(definition.name, definition)\n names.push(definition.name)\n }\n\n return {\n names: Object.freeze(names),\n async build(name: string, context: TContext): Promise<TActor> {\n const definition = definitionsByName.get(name)\n if (definition === undefined) throw new Error(`Unknown actor: ${name}`)\n return await definition.build(context)\n },\n }\n}\n", "import type {\n ManagedActor, ManagedActorLifecycleResult, ReadinessSignal, ReadyState,\n} from './ManagedActor.ts'\n\nexport type ActorSupervisorState = 'failed' | 'idle' | 'started' | 'starting' | 'stopped' | 'stopping'\n\nexport class ActorRegistrationError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'ActorRegistrationError'\n }\n}\n\nexport class ActorSupervisorStateError extends Error {\n readonly state: ActorSupervisorState\n\n constructor(operation: string, state: ActorSupervisorState) {\n super(`Cannot ${operation} while actor supervisor is ${state}`)\n this.name = 'ActorSupervisorStateError'\n this.state = state\n }\n}\n\nexport class ActorStartupError extends Error {\n readonly actorName: string\n readonly rollbackErrors: readonly Error[]\n\n constructor(actorName: string, cause: unknown, rollbackErrors: readonly Error[]) {\n super(`Actor \"${actorName}\" failed to start`, { cause })\n this.name = 'ActorStartupError'\n this.actorName = actorName\n this.rollbackErrors = rollbackErrors\n }\n}\n\nexport class ActorReadinessError extends Error {\n readonly actorName: string\n\n constructor(actorName: string, cause: unknown) {\n super(`Actor \"${actorName}\" failed to become ready`, { cause })\n this.name = 'ActorReadinessError'\n this.actorName = actorName\n }\n}\n\nexport class ActorReadinessTimeoutError extends Error {\n readonly timeoutMs: number\n\n constructor(timeoutMs: number) {\n super(`Actors did not become ready within ${timeoutMs}ms`)\n this.name = 'ActorReadinessTimeoutError'\n this.timeoutMs = timeoutMs\n }\n}\n\nexport class ActorShutdownError extends AggregateError {\n constructor(errors: readonly Error[]) {\n super(errors, `${errors.length} actor(s) failed to stop`)\n this.name = 'ActorShutdownError'\n }\n}\n\ninterface TimerHost {\n clearTimeout(handle: unknown): void\n setTimeout(callback: () => void, timeoutMs: number): unknown\n}\n\nfunction asError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error))\n}\n\nfunction assertLifecycleSucceeded(actor: ManagedActor, operation: 'start' | 'stop', result: ManagedActorLifecycleResult): void {\n if (result === false) {\n throw new Error(`Actor \"${actor.name}\" ${operation}() reported failure`)\n }\n}\n\nfunction assertTimeout(timeoutMs: number): void {\n if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {\n throw new RangeError('Readiness timeout must be a finite, non-negative number')\n }\n}\n\nasync function waitWithTimeout(signal: ReadinessSignal, timeoutMs: number): Promise<void> {\n const timerHost = globalThis as unknown as TimerHost\n let timeoutHandle: unknown\n const expired = new Promise<never>((_resolve, reject) => {\n timeoutHandle = timerHost.setTimeout(() => reject(new ActorReadinessTimeoutError(timeoutMs)), timeoutMs)\n })\n try {\n await Promise.race([signal.whenReady(timeoutMs), expired])\n } finally {\n timerHost.clearTimeout(timeoutHandle)\n }\n}\n\n/**\n * Instance-scoped coordinator for structural managed actors.\n *\n * Startup and readiness follow registration order. Rollback and ordinary shutdown\n * follow reverse startup order. A supervisor is single-use after it has stopped or\n * failed; construct a new instance for a new lifecycle.\n */\nexport class ActorSupervisor implements ReadinessSignal {\n private readonly _actorNames = new Set<string>()\n private readonly _actors: ManagedActor[] = []\n private _readyError?: Error\n private _startPromise?: Promise<void>\n private readonly _startedActors: ManagedActor[] = []\n private _state: ActorSupervisorState = 'idle'\n private _stopPromise?: Promise<void>\n\n constructor(actors: readonly ManagedActor[] = []) {\n for (const actor of actors) this.register(actor)\n }\n\n get actors(): readonly ManagedActor[] {\n return [...this._actors]\n }\n\n get readyError(): Error | undefined {\n if (this._readyError !== undefined) return this._readyError\n return this._actors.find(actor => actor.readyState === 'failed')?.readyError\n }\n\n get readyState(): ReadyState {\n if (this._readyError !== undefined || this._state === 'failed' || this._actors.some(actor => actor.readyState === 'failed')) {\n return 'failed'\n }\n if (this._state === 'started' && this._actors.every(actor => actor.readyState === 'ready')) return 'ready'\n return 'pending'\n }\n\n get state(): ActorSupervisorState {\n return this._state\n }\n\n isReady(): boolean {\n return this.readyState === 'ready'\n }\n\n register(actor: ManagedActor): void {\n if (this._state !== 'idle') throw new ActorSupervisorStateError('register an actor', this._state)\n if (actor.name.trim().length === 0) throw new ActorRegistrationError('Actor name must not be empty')\n if (this._actorNames.has(actor.name)) {\n throw new ActorRegistrationError(`Actor \"${actor.name}\" is already registered`)\n }\n this._actorNames.add(actor.name)\n this._actors.push(actor)\n }\n\n start(): Promise<void> {\n if (this._startPromise !== undefined) return this._startPromise\n if (this._state !== 'idle') return Promise.reject(new ActorSupervisorStateError('start', this._state))\n this._state = 'starting'\n this._startPromise = this.startActors()\n return this._startPromise\n }\n\n stop(): Promise<void> {\n this._stopPromise ??= this.stopActors()\n return this._stopPromise\n }\n\n async whenReady(timeoutMs?: number): Promise<void> {\n if (timeoutMs !== undefined) assertTimeout(timeoutMs)\n if (this._state === 'starting' && this._startPromise !== undefined) {\n await this._startPromise\n }\n if (this._state !== 'started') throw new ActorSupervisorStateError('wait for readiness', this._state)\n\n const startedAt = Date.now()\n for (const actor of this._actors) {\n try {\n if (timeoutMs === undefined) {\n await actor.whenReady()\n } else {\n const elapsed = Date.now() - startedAt\n const remainingTimeoutMs = timeoutMs - elapsed\n if (remainingTimeoutMs < 0) throw new ActorReadinessTimeoutError(timeoutMs)\n await waitWithTimeout(actor, remainingTimeoutMs)\n }\n } catch (error) {\n const readinessError = new ActorReadinessError(actor.name, error)\n this._readyError = readinessError\n throw readinessError\n }\n }\n }\n\n private async startActors(): Promise<void> {\n for (const actor of this._actors) {\n try {\n const result = await actor.start()\n assertLifecycleSucceeded(actor, 'start', result)\n this._startedActors.push(actor)\n } catch (error) {\n const rollbackErrors = await this.stopStartedActors()\n const startupError = new ActorStartupError(actor.name, error, rollbackErrors)\n this._readyError = startupError\n this._state = 'failed'\n throw startupError\n }\n }\n this._state = 'started'\n }\n\n private async stopActors(): Promise<void> {\n if (this._state === 'starting' && this._startPromise !== undefined) {\n try {\n await this._startPromise\n } catch {\n // Startup already rolled back every actor that reached started state.\n }\n }\n\n if (this._state === 'stopped') return\n if (this._state === 'idle' || (this._state === 'failed' && this._startedActors.length === 0)) {\n this._state = 'stopped'\n return\n }\n\n this._state = 'stopping'\n const errors = await this.stopStartedActors()\n this._state = 'stopped'\n if (errors.length > 0) throw new ActorShutdownError(errors)\n }\n\n private async stopStartedActors(): Promise<Error[]> {\n const errors: Error[] = []\n while (this._startedActors.length > 0) {\n const actor = this._startedActors.pop()\n if (actor === undefined) continue\n try {\n const result = await actor.stop()\n assertLifecycleSucceeded(actor, 'stop', result)\n } catch (error) {\n errors.push(new Error(`Actor \"${actor.name}\" failed to stop`, { cause: asError(error) }))\n }\n }\n return errors\n }\n}\n", "import type { ProcessHost } from './ProcessHost.ts'\n\n/** Process capability shared by every command created for one CLI app. */\nexport interface CliApplicationContext {\n readonly host: ProcessHost\n}\n\n/** Adapter-neutral factory for one parser-specific command object. */\nexport interface CommandDefinition<TContext extends CliApplicationContext, TCommand> {\n readonly create: (context: TContext) => TCommand\n /** Internal registration identity; it does not define parser syntax or aliases. */\n readonly id: string\n}\n\n/** Ordered command factories materialized for one app context. */\nexport interface CommandCatalog<TContext extends CliApplicationContext, TCommand> {\n readonly createCommands: (context: TContext) => readonly TCommand[]\n readonly ids: readonly string[]\n}\n\n/** Creates an immutable, adapter-neutral command catalog. */\nexport function createCommandCatalog<TContext extends CliApplicationContext, TCommand>(\n definitions: readonly CommandDefinition<TContext, TCommand>[],\n): CommandCatalog<TContext, TCommand> {\n const registeredIds = new Set<string>()\n const retainedDefinitions = definitions.map(definition => Object.freeze({\n create: definition.create,\n id: definition.id,\n }))\n const ids: string[] = []\n\n for (const definition of retainedDefinitions) {\n if (definition.id.trim().length === 0) throw new Error('Command id must not be empty')\n if (registeredIds.has(definition.id)) throw new Error(`Command \"${definition.id}\" is already registered`)\n registeredIds.add(definition.id)\n ids.push(definition.id)\n }\n\n return Object.freeze({\n ids: Object.freeze(ids),\n createCommands: (context: TContext): readonly TCommand[] =>\n Object.freeze(retainedDefinitions.map(definition => definition.create(context))),\n })\n}\n", "/** Process-facing input and output used by a command-line app. */\nexport interface ProcessIO {\n /** Available terminal width when output is attached to a sized terminal. */\n readonly columns?: number\n readonly isInteractive: boolean\n error(...values: readonly unknown[]): void\n log(...values: readonly unknown[]): void\n question(prompt: string): Promise<string>\n warn(...values: readonly unknown[]): void\n}\n\n/** Control-flow signal used when a non-terminating host records an immediate exit. */\nexport class ProcessExitError extends Error {\n readonly exitCode: number\n\n constructor(exitCode: number) {\n super(`Process requested exit with code ${exitCode}`)\n this.name = 'ProcessExitError'\n this.exitCode = exitCode\n }\n}\n\n/**\n * Structural process boundary for a command-line app.\n *\n * Production implementations may terminate from {@link exit}; recording hosts\n * may return after retaining the requested status.\n */\nexport interface ProcessHost {\n /** Full argument vector, including the executable and script entries. */\n readonly argv: readonly string[]\n /** Environment visible to this app invocation. */\n readonly environment: Readonly<Record<string, string | undefined>>\n readonly io: ProcessIO\n readonly isDevelopment: boolean\n exit(code: number): void\n onInterrupt(listener: () => Promise<void> | void): () => void\n}\n\n/**\n * Requests immediate process termination and prevents a recording host from\n * accidentally continuing through code that follows the exit point.\n */\nexport function exitProcess(host: Pick<ProcessHost, 'exit'>, exitCode: number): never {\n host.exit(exitCode)\n throw new ProcessExitError(exitCode)\n}\n", "import { ProcessExitError, type ProcessHost } from './ProcessHost.ts'\n\n/** Application entry point executed against an explicit process boundary. */\nexport type ProcessApplication = (host: ProcessHost) => Promise<void>\n\nexport interface RunProcessApplicationOptions {\n readonly application: ProcessApplication\n readonly host: ProcessHost\n}\n\n/**\n * Runs one CLI app at the outermost process boundary.\n *\n * Immediate exits requested through `exitProcess` have already been\n * routed to the host and are absorbed here. Unexpected failures retain the\n * established CLI policy of logging details only in development before\n * requesting exit code one.\n */\nexport async function runProcessApplication({\n application,\n host,\n}: RunProcessApplicationOptions): Promise<void> {\n try {\n await application(host)\n } catch (error) {\n if (error instanceof ProcessExitError) return\n if (host.isDevelopment) host.io.error('An error occurred during startup:', error)\n host.exit(1)\n }\n}\n", "import type { ProcessHost } from './ProcessHost.ts'\n\n/** Lifecycle state of one active runtime session. */\nexport type RuntimeSessionState = 'active' | 'failed' | 'stopped' | 'stopping'\n\n/** Application-owned cleanup invoked when a runtime session stops. */\nexport type RuntimeStopDelegate = () => Promise<void> | void\n\n/** Application-owned work invoked for the first process interrupt. */\nexport type RuntimeInterruptListener = () => Promise<void> | void\n\n/**\n * Instance-scoped owner for one runtime cleanup operation.\n *\n * Every call to {@link stop} returns the same promise. A cleanup failure is\n * retained and rethrown without wrapping so callers can preserve their\n * existing fail-fast behavior.\n */\nexport class RuntimeSession {\n private _exitCode?: number\n private _exitHost?: Pick<ProcessHost, 'exit'>\n private _exitPromise?: Promise<void>\n private _hasInterruptBinding = false\n private _interruptDisposer?: () => void\n private _interruptPromise?: Promise<void>\n private _isInterruptDisposed = false\n private _state: RuntimeSessionState = 'active'\n private readonly _stopDelegate: RuntimeStopDelegate\n private _stopError?: unknown\n private _stopPromise?: Promise<void>\n\n constructor(stopDelegate: RuntimeStopDelegate) {\n this._stopDelegate = stopDelegate\n }\n\n get state(): RuntimeSessionState {\n return this._state\n }\n\n get stopError(): unknown {\n return this._stopError\n }\n\n bindInterrupt(host: Pick<ProcessHost, 'onInterrupt'>, listener: RuntimeInterruptListener): void {\n if (this._hasInterruptBinding) throw new Error('An interrupt listener is already bound to this runtime session.')\n if (this.state !== 'active') throw new Error('An interrupt listener cannot be bound after runtime shutdown has started.')\n\n this._hasInterruptBinding = true\n let isRegistrationComplete = false\n let isInterruptPending = false\n const handleInterrupt = (): Promise<void> | void => {\n if (!isRegistrationComplete) {\n isInterruptPending = true\n return\n }\n return this.handleInterrupt(listener)\n }\n this._interruptDisposer = host.onInterrupt(handleInterrupt)\n isRegistrationComplete = true\n\n // A structural host may deliver an interrupt while registering the listener.\n // Defer that delivery until the returned disposer is retained so it can be\n // removed after the interrupt handler settles.\n if (isInterruptPending) void this.handleInterrupt(listener)\n }\n\n /**\n * Coalesces competing process-exit requests for this session. Requests made\n * in the same turn retain the highest exit code and every caller observes\n * the same exactly-once exit operation.\n */\n requestExit(host: Pick<ProcessHost, 'exit'>, exitCode: number): Promise<void> {\n this._exitCode = Math.max(this._exitCode ?? exitCode, exitCode)\n this._exitHost ??= host\n this._exitPromise ??= Promise.try(async () => {\n await Promise.resolve()\n this._exitHost?.exit(this._exitCode ?? exitCode)\n })\n return this._exitPromise\n }\n\n stop(): Promise<void> {\n // Manual shutdown owns listener disposal immediately. Interrupt-driven\n // shutdown retains the listener until its handler settles so repeated\n // interrupts are coalesced instead of reaching the host's default handler.\n if (this._interruptPromise === undefined) this.disposeInterrupt()\n if (this._stopPromise === undefined) {\n this._state = 'stopping'\n this._stopPromise = Promise.try(async () => {\n await Promise.resolve()\n await this.stopOnce()\n })\n }\n return this._stopPromise\n }\n\n private disposeInterrupt(): void {\n if (!this._hasInterruptBinding || this._isInterruptDisposed) return\n this._isInterruptDisposed = true\n const dispose = this._interruptDisposer\n this._interruptDisposer = undefined\n dispose?.()\n }\n\n private handleInterrupt(listener: RuntimeInterruptListener): Promise<void> {\n if (this._interruptPromise === undefined) {\n if (this._isInterruptDisposed) return Promise.resolve()\n this._interruptPromise = Promise.try(async () => {\n await Promise.resolve()\n try {\n await listener()\n } finally {\n this.disposeInterrupt()\n }\n })\n }\n return this._interruptPromise\n }\n\n private async stopOnce(): Promise<void> {\n try {\n await this._stopDelegate()\n this._state = 'stopped'\n } catch (error) {\n this._stopError = error\n this._state = 'failed'\n throw error\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAWO,SAAS,0BACd,aACuC;AACvC,QAAM,oBAAoB,oBAAI,IAAsD;AACpF,QAAM,QAAkB,CAAC;AACzB,aAAW,cAAc,aAAa;AACpC,QAAI,kBAAkB,IAAI,WAAW,IAAI,GAAG;AAC1C,YAAM,IAAI,MAAM,kBAAkB,WAAW,IAAI,yBAAyB;AAAA,IAC5E;AACA,sBAAkB,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json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ariestools/cli-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reusable actor lifecycle core for command-line applications",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ariestools",
|
|
7
|
+
"cli",
|
|
8
|
+
"typescript",
|
|
9
|
+
"esm"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://ariestools.ai",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/ariestools/cli-kit/issues",
|
|
14
|
+
"email": "support@ariestools.ai"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/ariestools/cli-kit.git",
|
|
19
|
+
"directory": "packages/cli-kit"
|
|
20
|
+
},
|
|
21
|
+
"license": "LGPL-3.0-only",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Arie Trouw",
|
|
24
|
+
"email": "support@ariestools.ai",
|
|
25
|
+
"url": "https://ariestools.ai"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/node/index.d.ts",
|
|
32
|
+
"default": "./dist/node/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
"./README.md": "./README.md"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"!**/*.bench.*",
|
|
40
|
+
"!**/*.spec.*",
|
|
41
|
+
"!**/*.test.*",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@ariestools/toolchain": "~8.7.21",
|
|
47
|
+
"@ariestools/tsconfig": "~8.7.21",
|
|
48
|
+
"eslint": "~10.7.0",
|
|
49
|
+
"typescript": "~6.0.3",
|
|
50
|
+
"vite": "~8.1.5",
|
|
51
|
+
"vitest": "~4.1.10",
|
|
52
|
+
"eslint-import-resolver-typescript": "~4.4.5"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=24"
|
|
56
|
+
},
|
|
57
|
+
"engineStrict": true,
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"test:ci": "vitest run"
|
|
64
|
+
}
|
|
65
|
+
}
|