@visulima/task-runner 1.0.0-alpha.3 → 1.0.0-alpha.5
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/CHANGELOG.md +58 -0
- package/README.md +193 -51
- package/dist/affected.d.ts +37 -3
- package/dist/cache.d.ts +8 -1
- package/dist/command-parser/expand-arguments.d.ts +11 -0
- package/dist/command-parser/expand-shortcut.d.ts +15 -0
- package/dist/command-parser/expand-wildcard.d.ts +13 -0
- package/dist/command-parser/index.d.ts +18 -0
- package/dist/command-parser/strip-quotes.d.ts +6 -0
- package/dist/concurrent-fallback.d.ts +16 -0
- package/dist/concurrent.d.ts +23 -0
- package/dist/detect-shell.d.ts +19 -0
- package/dist/flow-controllers/index.d.ts +7 -0
- package/dist/flow-controllers/input-handler.d.ts +44 -0
- package/dist/flow-controllers/log-timings.d.ts +18 -0
- package/dist/flow-controllers/restart-process.d.ts +21 -0
- package/dist/flow-controllers/teardown.d.ts +22 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +26 -12
- package/dist/native-binding.d.ts +44 -2
- package/dist/packem_shared/{Cache-IYpTYVUC.js → Cache-iAjRMV2d.js} +5 -5
- package/dist/packem_shared/{FingerprintManager-D6Y0erg-.js → FingerprintManager-Cu-ta9ee.js} +0 -1
- package/dist/packem_shared/{IncrementalFileHasher-Ds3J6dgb.js → IncrementalFileHasher-Cm_kJY5V.js} +1 -1
- package/dist/packem_shared/{TaskOrchestrator-BvYs3ONw.js → TaskOrchestrator-lLn-PH1m.js} +2 -5
- package/dist/packem_shared/TerminalBuffer-CnPyFgPB.js +266 -0
- package/dist/packem_shared/{filterAffectedTasks-I-18zPg6.js → buildForwardDependencyMap-0BJFMMPv.js} +61 -21
- package/dist/packem_shared/{computeTaskHash-BoCnnvIJ.js → computeTaskHash-B2SVZqgp.js} +1 -2
- package/dist/packem_shared/createInputHandler-DTfePcTG.js +37 -0
- package/dist/packem_shared/{defaultTaskRunner-CrW4v5Ye.js → defaultTaskRunner-BdFTifsh.js} +6 -7
- package/dist/packem_shared/detectScriptShell-CR-xXKA4.js +53 -0
- package/dist/packem_shared/enforceProjectConstraints-C5Jp_C3u.js +111 -0
- package/dist/packem_shared/expandArguments-0AwD2BIA.js +26 -0
- package/dist/packem_shared/expandShortcut-BVG05ee4.js +23 -0
- package/dist/packem_shared/expandWildcard-B0xN_knq.js +107 -0
- package/dist/packem_shared/{findCycle-DF4_BRdO.js → findCycle-DefgNYhg.js} +1 -1
- package/dist/packem_shared/formatTimingTable-3qtCM552.js +46 -0
- package/dist/packem_shared/isNativeAvailable-BpD28A6Z.js +44 -0
- package/dist/packem_shared/parseCommands-D-IgF8Zh.js +26 -0
- package/dist/packem_shared/{TaskScheduler-CJilHDta.js → parsePartition-C4-P5RjK.js} +44 -1
- package/dist/packem_shared/{projectGraphToDot-VdTjHcVp.js → projectGraphToDot-C8uYeaPo.js} +20 -3
- package/dist/packem_shared/runConcurrentFallback-CGHz_f-Q.js +371 -0
- package/dist/packem_shared/runConcurrently-qrkWyzXW.js +67 -0
- package/dist/packem_shared/runTeardown-BAezH79J.js +49 -0
- package/dist/packem_shared/stripQuotes-Cey-zwFf.js +9 -0
- package/dist/packem_shared/withRestart-BREjRJa4.js +49 -0
- package/dist/project-constraints.d.ts +9 -0
- package/dist/task-scheduler.d.ts +23 -0
- package/dist/terminal-buffer.d.ts +29 -0
- package/dist/types.d.ts +239 -1
- package/index.js +769 -0
- package/package.json +14 -13
- package/binding.js +0 -204
- package/dist/packem_shared/isNativeAvailable-BWhnZ4ES.js +0 -19
- package/dist/packem_shared/{RemoteCache-BDqrnDEi.js → RemoteCache-BFceSe4a.js} +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const withRestart = async (runFunction, commands, options, restartOptions) => {
|
|
2
|
+
const { delay, tries } = restartOptions;
|
|
3
|
+
if (tries === 0) {
|
|
4
|
+
return runFunction(commands, options);
|
|
5
|
+
}
|
|
6
|
+
const state = /* @__PURE__ */ new Map();
|
|
7
|
+
const allCloseEvents = [];
|
|
8
|
+
const userOnEvent = options.onEvent;
|
|
9
|
+
let pendingRestarts = [...commands];
|
|
10
|
+
let iteration = 0;
|
|
11
|
+
while (pendingRestarts.length > 0) {
|
|
12
|
+
const currentBatch = pendingRestarts;
|
|
13
|
+
pendingRestarts = [];
|
|
14
|
+
const result = await runFunction(currentBatch, {
|
|
15
|
+
...options,
|
|
16
|
+
onEvent: (event) => {
|
|
17
|
+
userOnEvent?.(event);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
for (const closeEvent of result.closeEvents) {
|
|
21
|
+
if (closeEvent.exitCode !== 0) {
|
|
22
|
+
const cmdState = state.get(closeEvent.index) ?? { attempts: 0, commandIndex: closeEvent.index };
|
|
23
|
+
cmdState.attempts++;
|
|
24
|
+
state.set(closeEvent.index, cmdState);
|
|
25
|
+
const shouldRestart = tries === -1 || cmdState.attempts <= tries;
|
|
26
|
+
if (shouldRestart) {
|
|
27
|
+
const delayMs = delay === "exponential" ? Math.min(2 ** (cmdState.attempts - 1) * 1e3, 3e4) : delay;
|
|
28
|
+
if (delayMs > 0) {
|
|
29
|
+
await sleep(delayMs);
|
|
30
|
+
}
|
|
31
|
+
pendingRestarts.push(currentBatch[closeEvent.index]);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
allCloseEvents.push(closeEvent);
|
|
36
|
+
}
|
|
37
|
+
iteration++;
|
|
38
|
+
if (iteration > 1e3) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const success = allCloseEvents.every((e) => e.exitCode === 0);
|
|
43
|
+
return { closeEvents: allCloseEvents, success };
|
|
44
|
+
};
|
|
45
|
+
const sleep = (ms) => new Promise((resolve) => {
|
|
46
|
+
setTimeout(resolve, ms);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export { withRestart };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConstraintsConfig, ConstraintViolation, ProjectGraph } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Enforces project dependency constraints on a project graph.
|
|
4
|
+
* @param projectGraph The workspace project graph to validate.
|
|
5
|
+
* @param constraints The constraint rules to enforce.
|
|
6
|
+
* @returns Array of violations found. Empty means all constraints pass.
|
|
7
|
+
*/
|
|
8
|
+
declare const enforceProjectConstraints: (projectGraph: ProjectGraph, constraints: ConstraintsConfig) => ConstraintViolation[];
|
|
9
|
+
export { enforceProjectConstraints };
|
package/dist/task-scheduler.d.ts
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import type { ProjectGraph, Task, TaskGraph } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Options for partitioning tasks across CI runners.
|
|
4
|
+
*/
|
|
5
|
+
export interface PartitionOptions {
|
|
6
|
+
/** 1-based partition index (e.g., 1 for the first partition) */
|
|
7
|
+
index: number;
|
|
8
|
+
/** Total number of partitions */
|
|
9
|
+
total: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parses a partition string like "1/4" into PartitionOptions.
|
|
13
|
+
* Also supports the VIS_PARTITION environment variable as fallback.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parsePartition: (value?: string) => PartitionOptions | undefined;
|
|
2
16
|
/**
|
|
3
17
|
* Manages the scheduling order of tasks based on dependencies,
|
|
4
18
|
* parallelism constraints, and estimated execution times.
|
|
5
19
|
*/
|
|
6
20
|
export declare class TaskScheduler {
|
|
7
21
|
#private;
|
|
22
|
+
/**
|
|
23
|
+
* Partitions a list of tasks for distributed CI execution.
|
|
24
|
+
* Tasks are sorted by ID for deterministic distribution, then split
|
|
25
|
+
* using ceiling division so partitions differ by at most one task.
|
|
26
|
+
* @param tasks The full list of tasks to partition
|
|
27
|
+
* @param partition The partition configuration (1-based index and total)
|
|
28
|
+
* @returns The subset of tasks assigned to this partition
|
|
29
|
+
*/
|
|
30
|
+
static partitionTasks(tasks: Task[], partition: PartitionOptions): Task[];
|
|
8
31
|
constructor(taskGraph: TaskGraph, projectGraph: ProjectGraph, maxParallel?: number);
|
|
9
32
|
/**
|
|
10
33
|
* Returns the next batch of tasks that are ready to execute.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal virtual terminal buffer that processes ANSI escape sequences
|
|
3
|
+
* for cursor movement and line erasure. This allows PTY output from
|
|
4
|
+
* interactive tools (inquirer, etc.) to render correctly by updating
|
|
5
|
+
* lines in place rather than always appending.
|
|
6
|
+
*
|
|
7
|
+
* Supported sequences:
|
|
8
|
+
* - \r carriage return (cursor to column 0)
|
|
9
|
+
* - \n line feed (new line)
|
|
10
|
+
* - \x1b[nA cursor up n lines
|
|
11
|
+
* - \x1b[nB cursor down n lines
|
|
12
|
+
* - \x1b[nC cursor forward n columns
|
|
13
|
+
* - \x1b[nD cursor back n columns
|
|
14
|
+
* - \x1b[nG cursor to column n
|
|
15
|
+
* - \x1b[r;cH cursor position
|
|
16
|
+
* - \x1b[K erase from cursor to end of line (0K, 1K, 2K)
|
|
17
|
+
* - \x1b[J erase from cursor to end of display (0J, 1J, 2J)
|
|
18
|
+
* - \x1b[...m SGR (colors/styles) — passed through into output
|
|
19
|
+
*/
|
|
20
|
+
export declare class TerminalBuffer {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(maxBytes?: number);
|
|
23
|
+
/**
|
|
24
|
+
* Process raw PTY output data.
|
|
25
|
+
*/
|
|
26
|
+
write(data: string): void;
|
|
27
|
+
/** Get the current buffer content as a string. */
|
|
28
|
+
toString(): string;
|
|
29
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -85,6 +85,15 @@ export type TaskResults = Map<string, TaskResult>;
|
|
|
85
85
|
export interface ProjectConfiguration {
|
|
86
86
|
/** Implicit dependencies on other projects */
|
|
87
87
|
implicitDependencies?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Project layer in the dependency hierarchy. Used by
|
|
90
|
+
* `enforceLayerRelationships` to ensure projects only depend on
|
|
91
|
+
* projects at the same or lower layer.
|
|
92
|
+
*
|
|
93
|
+
* Hierarchy (lowest → highest):
|
|
94
|
+
* `configuration < library < scaffolding < tool < automation < application`
|
|
95
|
+
*/
|
|
96
|
+
layer?: "application" | "automation" | "configuration" | "library" | "scaffolding" | "tool";
|
|
88
97
|
/** The project type */
|
|
89
98
|
projectType?: "library" | "application";
|
|
90
99
|
/** The root directory of the project, relative to workspace root */
|
|
@@ -160,6 +169,91 @@ export interface EnvironmentInput {
|
|
|
160
169
|
export interface ExternalDependencyInput {
|
|
161
170
|
externalDependencies: string[];
|
|
162
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Defines tag-based dependency rules.
|
|
174
|
+
* Each key is a tag name. The value is the list of tags that a dependency
|
|
175
|
+
* must have at least one of, when the source project has that tag.
|
|
176
|
+
*
|
|
177
|
+
* Example: `{ "frontend": ["shared", "frontend"] }` means a project tagged
|
|
178
|
+
* "frontend" can only depend on projects tagged "shared" or "frontend".
|
|
179
|
+
*/
|
|
180
|
+
export type TagRelationships = Record<string, string[]>;
|
|
181
|
+
/**
|
|
182
|
+
* Defines project-type-based dependency rules.
|
|
183
|
+
*/
|
|
184
|
+
export interface TypeBoundaries {
|
|
185
|
+
/**
|
|
186
|
+
* Custom rules mapping project types to allowed dependency types.
|
|
187
|
+
* Example: `{ "application": ["library"] }` means applications can only
|
|
188
|
+
* depend on libraries.
|
|
189
|
+
*/
|
|
190
|
+
allowedDependencyTypes?: Record<string, string[]>;
|
|
191
|
+
/**
|
|
192
|
+
* When true, no project may depend on an "application" type project.
|
|
193
|
+
* Applications are typically deployment targets, not libraries.
|
|
194
|
+
* @default true
|
|
195
|
+
*/
|
|
196
|
+
enforceApplicationBoundary?: boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Rules based on the dependency kind (dependencies vs devDependencies vs peerDependencies).
|
|
200
|
+
*/
|
|
201
|
+
export interface DependencyKindRules {
|
|
202
|
+
/**
|
|
203
|
+
* When true, a "library" project must not have workspace-internal devDependencies
|
|
204
|
+
* on other libraries that are also in its production dependencies.
|
|
205
|
+
* Prevents publishing libraries that silently rely on dev-only workspace packages.
|
|
206
|
+
* @default false
|
|
207
|
+
*/
|
|
208
|
+
noDevDependencyOnProductionDep?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* When true, production `dependencies` must not point to "application" type projects.
|
|
211
|
+
* devDependencies on applications are allowed (e.g., for testing).
|
|
212
|
+
* @default false
|
|
213
|
+
*/
|
|
214
|
+
noProductionDependencyOnApplication?: boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Configuration for project constraint enforcement.
|
|
218
|
+
*/
|
|
219
|
+
export interface ConstraintsConfig {
|
|
220
|
+
/** Rules based on the dependency kind (static vs devDependency vs peerDependency) */
|
|
221
|
+
dependencyKindRules?: DependencyKindRules;
|
|
222
|
+
/**
|
|
223
|
+
* When true, projects can only depend on projects at the same or
|
|
224
|
+
* lower layer in the hierarchy:
|
|
225
|
+
*
|
|
226
|
+
* configuration < library < scaffolding < tool < automation < application
|
|
227
|
+
*
|
|
228
|
+
* Projects without an explicit `layer` are unconstrained.
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
enforceLayerRelationships?: boolean;
|
|
232
|
+
/** Tag-based dependency rules */
|
|
233
|
+
tagRelationships?: TagRelationships;
|
|
234
|
+
/** Project-type-based dependency rules */
|
|
235
|
+
typeBoundaries?: TypeBoundaries;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A single constraint violation detected in the project graph.
|
|
239
|
+
*/
|
|
240
|
+
export interface ConstraintViolation {
|
|
241
|
+
/** The project being depended on */
|
|
242
|
+
dependencyProject: string;
|
|
243
|
+
/** Human-readable description of the violation */
|
|
244
|
+
message: string;
|
|
245
|
+
/** The type of rule that was violated */
|
|
246
|
+
rule: "dependency-kind" | "layer-relationship" | "tag-relationship" | "type-boundary";
|
|
247
|
+
/** The project that has the invalid dependency */
|
|
248
|
+
sourceProject: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Controls how far to traverse the dependency graph in a given direction.
|
|
252
|
+
* - "none": Don't traverse — only directly changed projects are included.
|
|
253
|
+
* - "direct": Include only immediate neighbors (one hop).
|
|
254
|
+
* - "deep": Include all transitive neighbors (full chain).
|
|
255
|
+
*/
|
|
256
|
+
export type AffectedScope = "deep" | "direct" | "none";
|
|
163
257
|
/**
|
|
164
258
|
* Workspace configuration containing all project configurations.
|
|
165
259
|
*/
|
|
@@ -167,6 +261,15 @@ export interface WorkspaceConfiguration {
|
|
|
167
261
|
/** All projects in the workspace, keyed by project name */
|
|
168
262
|
projects: Record<string, ProjectConfiguration>;
|
|
169
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* The kind of dependency relationship between projects.
|
|
266
|
+
* - "static": Production dependency (from `dependencies` in package.json)
|
|
267
|
+
* - "dynamic": Dynamically resolved dependency (e.g., lazy imports)
|
|
268
|
+
* - "implicit": Declared via `implicitDependencies` in project config
|
|
269
|
+
* - "devDependency": Development-only dependency (from `devDependencies`)
|
|
270
|
+
* - "peerDependency": Peer dependency (from `peerDependencies`)
|
|
271
|
+
*/
|
|
272
|
+
export type DependencyType = "devDependency" | "dynamic" | "implicit" | "peerDependency" | "static";
|
|
170
273
|
/**
|
|
171
274
|
* A dependency relationship in the project graph.
|
|
172
275
|
*/
|
|
@@ -176,7 +279,7 @@ export interface ProjectGraphDependency {
|
|
|
176
279
|
/** The target project */
|
|
177
280
|
target: string;
|
|
178
281
|
/** The type of dependency */
|
|
179
|
-
type:
|
|
282
|
+
type: DependencyType;
|
|
180
283
|
}
|
|
181
284
|
/**
|
|
182
285
|
* A node in the project graph.
|
|
@@ -370,6 +473,141 @@ export interface TaskRunnerContext {
|
|
|
370
473
|
/** The workspace root directory */
|
|
371
474
|
workspaceRoot: string;
|
|
372
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* Input for a concurrent command -- either a string or a config object.
|
|
478
|
+
*/
|
|
479
|
+
export type ConcurrentCommandInput = string | {
|
|
480
|
+
command: string;
|
|
481
|
+
cwd?: string;
|
|
482
|
+
env?: Record<string, string>;
|
|
483
|
+
name?: string;
|
|
484
|
+
/** Initial PTY dimensions (only used when stdin is "pty"). */
|
|
485
|
+
ptySize?: {
|
|
486
|
+
cols: number;
|
|
487
|
+
rows: number;
|
|
488
|
+
};
|
|
489
|
+
stdin?: "inherit" | "null" | "pipe" | "pty";
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Configuration for a single command to run concurrently.
|
|
493
|
+
*/
|
|
494
|
+
export interface ConcurrentCommandConfig {
|
|
495
|
+
/** The command string to execute (passed to shell). */
|
|
496
|
+
command: string;
|
|
497
|
+
/** Working directory for the command. */
|
|
498
|
+
cwd?: string;
|
|
499
|
+
/** Additional environment variables merged with process env. */
|
|
500
|
+
env?: Record<string, string>;
|
|
501
|
+
/** Human-readable name for this command (used in prefixes/logs). */
|
|
502
|
+
name?: string;
|
|
503
|
+
/**
|
|
504
|
+
* Initial PTY dimensions. Only used when stdin is "pty".
|
|
505
|
+
* Defaults to 80x24 if not specified.
|
|
506
|
+
*/
|
|
507
|
+
ptySize?: {
|
|
508
|
+
cols: number;
|
|
509
|
+
rows: number;
|
|
510
|
+
};
|
|
511
|
+
/** Whether to use shell execution (default: true). */
|
|
512
|
+
shell?: boolean;
|
|
513
|
+
/**
|
|
514
|
+
* Stdin mode for the child process.
|
|
515
|
+
* - "null" (default): stdin closed, child cannot read input
|
|
516
|
+
* - "pipe": stdin is piped, can be written to programmatically
|
|
517
|
+
* - "inherit": child inherits parent's stdin (for interactive commands like vite dev)
|
|
518
|
+
* - "pty": child runs inside a pseudo-terminal (isatty() returns true, enables interactive prompts)
|
|
519
|
+
*/
|
|
520
|
+
stdin?: "inherit" | "null" | "pipe" | "pty";
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Options controlling the concurrent runner behavior.
|
|
524
|
+
*/
|
|
525
|
+
export interface ConcurrentRunnerOptions {
|
|
526
|
+
/** Conditions under which to kill other processes: "success", "failure". */
|
|
527
|
+
killOthers?: ("failure" | "success")[];
|
|
528
|
+
/** Signal to send when killing processes (default: "SIGTERM"). */
|
|
529
|
+
killSignal?: string;
|
|
530
|
+
/** Milliseconds to wait after kill signal before sending SIGKILL (default: 5000). */
|
|
531
|
+
killTimeout?: number;
|
|
532
|
+
/** Maximum number of processes to run simultaneously. 0 = unlimited. */
|
|
533
|
+
maxProcesses?: number;
|
|
534
|
+
/** Callback for real-time process events. */
|
|
535
|
+
onEvent?: (event: ProcessEvent) => void;
|
|
536
|
+
/** Restart options for failed commands. */
|
|
537
|
+
restart?: {
|
|
538
|
+
/** Delay between restarts in ms. "exponential" for 2^attempt * 1000ms. */
|
|
539
|
+
delay?: number | "exponential";
|
|
540
|
+
/** Maximum restart attempts per command. 0 = no restarts. -1 = infinite. */
|
|
541
|
+
tries: number;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Custom shell path for command execution.
|
|
545
|
+
* Overrides the platform default (/bin/sh on Unix, cmd.exe on Windows).
|
|
546
|
+
* Automatically detected from npm's `script-shell` config if not set.
|
|
547
|
+
*/
|
|
548
|
+
shellPath?: string;
|
|
549
|
+
/** Success condition: "first", "last", "all", or "command-<name|index>". */
|
|
550
|
+
successCondition?: string;
|
|
551
|
+
/** Commands to run sequentially after all processes complete. */
|
|
552
|
+
teardown?: string[];
|
|
553
|
+
/** Working directory for teardown commands. */
|
|
554
|
+
teardownCwd?: string;
|
|
555
|
+
/** Print a timing summary table after completion. Default: false. */
|
|
556
|
+
timings?: boolean;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* An event emitted during concurrent execution.
|
|
560
|
+
*/
|
|
561
|
+
export interface ProcessEvent {
|
|
562
|
+
/** Command name (for close events). */
|
|
563
|
+
commandName?: string;
|
|
564
|
+
/** Duration in milliseconds (for close events). */
|
|
565
|
+
durationMs?: number;
|
|
566
|
+
/** Exit code (for close events). */
|
|
567
|
+
exitCode?: number;
|
|
568
|
+
/** Index of the command that produced this event. */
|
|
569
|
+
index: number;
|
|
570
|
+
/** Kill the child process/PTY. Only present on "started" events. */
|
|
571
|
+
kill?: (signal?: string) => void;
|
|
572
|
+
/** Whether the process was killed (for close events). */
|
|
573
|
+
killed?: boolean;
|
|
574
|
+
/** Event type: "stdout", "stderr", "close", "error", "started". */
|
|
575
|
+
kind: "close" | "error" | "started" | "stderr" | "stdout";
|
|
576
|
+
/** Error message (for error events). */
|
|
577
|
+
message?: string;
|
|
578
|
+
/** Resize the child's PTY. Only present on "started" events with stdin "pty". */
|
|
579
|
+
resize?: (cols: number, rows: number) => void;
|
|
580
|
+
/** Text content (for stdout/stderr events). */
|
|
581
|
+
text?: string;
|
|
582
|
+
/** Write data to the child's stdin (pipe) or PTY. Only present on "started" events. */
|
|
583
|
+
write?: (data: string) => void;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Result of a close event for a single command.
|
|
587
|
+
*/
|
|
588
|
+
export interface ConcurrentCloseEvent {
|
|
589
|
+
/** The command string that was executed. */
|
|
590
|
+
command: string;
|
|
591
|
+
/** Duration in milliseconds. */
|
|
592
|
+
durationMs: number;
|
|
593
|
+
/** Exit code. -1 if killed by signal. */
|
|
594
|
+
exitCode: number;
|
|
595
|
+
/** Index of the command. */
|
|
596
|
+
index: number;
|
|
597
|
+
/** Whether the process was forcefully killed. */
|
|
598
|
+
killed: boolean;
|
|
599
|
+
/** The command name (if provided). */
|
|
600
|
+
name?: string;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Overall result of a concurrent run.
|
|
604
|
+
*/
|
|
605
|
+
export interface ConcurrentRunResult {
|
|
606
|
+
/** Close events for all commands, in completion order. */
|
|
607
|
+
closeEvents: ConcurrentCloseEvent[];
|
|
608
|
+
/** Whether the run succeeded according to the success condition. */
|
|
609
|
+
success: boolean;
|
|
610
|
+
}
|
|
373
611
|
/**
|
|
374
612
|
* Interface for lifecycle event handlers.
|
|
375
613
|
*/
|