@neuralnomads/codenomad-dev 0.18.0-dev-20260716-40cee071 → 0.18.0-dev-20260718-8f6aa44b

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.
Files changed (80) hide show
  1. package/dist/auth/manager.js +1 -1
  2. package/dist/filesystem/__tests__/search-cache.test.js +5 -5
  3. package/dist/filesystem/search-cache.js +1 -1
  4. package/dist/index.js +25 -0
  5. package/dist/index.test.js +40 -10
  6. package/dist/opencode-update/service.js +150 -0
  7. package/dist/opencode-update/service.test.js +107 -0
  8. package/dist/server/__tests__/remote-proxy.test.js +64 -56
  9. package/dist/server/http-server.js +7 -1
  10. package/dist/server/remote-proxy.js +68 -98
  11. package/dist/server/routes/opencode-update.js +37 -0
  12. package/dist/server/routes/opencode-update.test.js +34 -0
  13. package/dist/server/routes/remote-servers.js +1 -1
  14. package/dist/server/routes/workspaces.test.js +38 -0
  15. package/dist/server/tls.js +2 -2
  16. package/dist/settings/binaries.test.js +2 -7
  17. package/dist/shutdown.js +67 -59
  18. package/dist/shutdown.test.js +115 -78
  19. package/dist/ui/remote-ui.js +2 -2
  20. package/dist/usage/providers/api-key.js +3 -3
  21. package/dist/usage/providers/google.js +1 -1
  22. package/dist/usage/providers/special.js +3 -3
  23. package/dist/usage/service.js +1 -1
  24. package/dist/usage/service.test.js +1 -1
  25. package/dist/usage/shared.js +4 -4
  26. package/dist/usage/shared.test.js +1 -1
  27. package/dist/workspaces/__tests__/spawn.test.js +2 -2
  28. package/dist/workspaces/__tests__/workspace-identity.test.js +94 -286
  29. package/dist/workspaces/binary-path.test.js +10 -0
  30. package/dist/workspaces/instance-client.js +4 -3
  31. package/dist/workspaces/launch-cleanup.test.js +21 -25
  32. package/dist/workspaces/manager.js +300 -351
  33. package/dist/workspaces/manager.test.js +209 -237
  34. package/dist/workspaces/process-identity.darwin.test.js +88 -0
  35. package/dist/workspaces/process-identity.js +172 -149
  36. package/dist/workspaces/process-identity.test.js +86 -140
  37. package/dist/workspaces/runtime.js +261 -373
  38. package/dist/workspaces/runtime.test.js +222 -547
  39. package/package.json +1 -1
  40. package/public/assets/{FilesTab-BjztpSdj.js → FilesTab-B0-DlSCT.js} +2 -2
  41. package/public/assets/{GitChangesTab-B9XraSoR.js → GitChangesTab-CxjbNBVr.js} +2 -2
  42. package/public/assets/{SplitFilePanel-Cu_5-Z-E.js → SplitFilePanel-CLQb-6uX.js} +1 -1
  43. package/public/assets/{StatusTab-D_IE79r-.js → StatusTab-CBGAuhmp.js} +1 -1
  44. package/public/assets/{align-justify-BKS9gyRk.js → align-justify-s5mnjsP0.js} +1 -1
  45. package/public/assets/{bundle-full-CXGXXlzR.js → bundle-full-lwIMY5om.js} +1 -1
  46. package/public/assets/{diff-viewer-CSNOYoEB.js → diff-viewer-CDtmFe6e.js} +1 -1
  47. package/public/assets/index-6ABz_Izb.js +1 -0
  48. package/public/assets/index-BPdjM9ZI.css +1 -0
  49. package/public/assets/index-BQK8um1r.js +1 -0
  50. package/public/assets/index-BkUAI4ZY.js +1 -0
  51. package/public/assets/index-D8bkUvEd.js +2 -0
  52. package/public/assets/index-DY_sbCt9.js +1 -0
  53. package/public/assets/index-DhmUOdAI.js +1 -0
  54. package/public/assets/{index-sLe9hEfQ.js → index-DupnEKCQ.js} +1 -1
  55. package/public/assets/index-HhZzWWha.js +1 -0
  56. package/public/assets/{index-DVc4ls8c.js → index-lBAEWdAF.js} +1 -1
  57. package/public/assets/index-nVII4VJz.js +1 -0
  58. package/public/assets/index-p1Sble5V.js +1 -0
  59. package/public/assets/{loading-CDmt9OJU.js → loading-h8DvUqqc.js} +1 -1
  60. package/public/assets/main-BxUSjoWA.js +68 -0
  61. package/public/assets/{markdown-1ZLSxCFT.js → markdown-Djug_spc.js} +3 -3
  62. package/public/assets/{monaco-viewer-D6JgH76W.js → monaco-viewer-lkUcsK65.js} +2 -2
  63. package/public/assets/{tool-call-CyXb63LH.js → tool-call-C4YH896w.js} +3 -3
  64. package/public/assets/{unified-picker-DCCdSVwI.js → unified-picker-DwNZOVlY.js} +1 -1
  65. package/public/assets/{wrap-text-pNMdTIq3.js → wrap-text-BLVYxvcj.js} +1 -1
  66. package/public/index.html +4 -4
  67. package/public/loading.html +4 -4
  68. package/public/sw.js +1 -1
  69. package/dist/workspaces/launch-cleanup.js +0 -132
  70. package/public/assets/index-B3YjNCh4.js +0 -1
  71. package/public/assets/index-B3ZD2_SU.js +0 -1
  72. package/public/assets/index-Bh2ofaQo.js +0 -1
  73. package/public/assets/index-CM0c9xRZ.js +0 -1
  74. package/public/assets/index-CdDxouJl.js +0 -2
  75. package/public/assets/index-D06Y2cFq.js +0 -1
  76. package/public/assets/index-PmE51vPh.js +0 -1
  77. package/public/assets/index-Qj63IiSj.css +0 -1
  78. package/public/assets/index-VY_zwmsG.js +0 -1
  79. package/public/assets/index-qiiH7egV.js +0 -1
  80. package/public/assets/main-CTN6Wwz1.js +0 -68
@@ -3,8 +3,7 @@ import { randomBytes } from "crypto";
3
3
  import { existsSync, statSync } from "fs";
4
4
  import path from "path";
5
5
  import { buildSpawnSpec } from "./spawn";
6
- import { descendantsOf, probePosixProcesses, probeWindowsProcesses, probeWslProcesses, sameProcess, signalPosixProcesses, signalOwnedPosixProcessGroup, signalWindowsProcesses, signalWslProcesses, startedNoLaterThan, } from "./process-identity";
7
- import { LAUNCH_CLEANUP_TOKEN_ENV, probeLaunchCleanupToken, signalLaunchCleanupToken, } from "./launch-cleanup";
6
+ import { descendantsOf, LAUNCH_CLEANUP_TOKEN_ENV, probeLaunchCleanupToken, probePosixProcesses, probeWindowsProcesses, probeWslProcesses, sameProcess, signalPosixProcesses, signalOwnedPosixProcessGroup, signalLaunchCleanupToken, signalWindowsProcesses, signalWslProcesses, startedNoLaterThan, } from "./process-identity";
8
7
  const SENSITIVE_ENV_KEY = /(PASSWORD|TOKEN|SECRET)/i;
9
8
  const WSL_PID_MARKER = "__CODENOMAD_WSL_PID__:";
10
9
  function redactEnvironment(env) {
@@ -38,13 +37,6 @@ export class WorkspaceWindowsTreeCleanupIncompleteError extends Error {
38
37
  this.name = "WorkspaceWindowsTreeCleanupIncompleteError";
39
38
  }
40
39
  }
41
- export class WorkspaceRuntimeLaunchCancelledError extends Error {
42
- constructor(workspaceId) {
43
- super(`Workspace ${workspaceId} runtime launch was cancelled`);
44
- this.code = "WORKSPACE_RUNTIME_LAUNCH_CANCELLED";
45
- this.name = "WorkspaceRuntimeLaunchCancelledError";
46
- }
47
- }
48
40
  export class WorkspaceRuntimeIdentityCaptureError extends Error {
49
41
  constructor(workspaceId, detail) {
50
42
  super(`Workspace ${workspaceId} process identity capture failed: ${detail}`);
@@ -67,6 +59,7 @@ export class WorkspaceRuntime {
67
59
  this.stopCommandTimeoutMs = Math.max(1, options.stopCommandTimeoutMs ?? 1000);
68
60
  }
69
61
  async launch(options) {
62
+ options.signal?.throwIfAborted();
70
63
  this.validateFolder(options.folder);
71
64
  const logLevel = typeof options.logLevel === "string" ? options.logLevel.toUpperCase() : "DEBUG";
72
65
  const args = ["serve", "--port", "0", "--print-logs", "--log-level", logLevel];
@@ -76,10 +69,6 @@ export class WorkspaceRuntime {
76
69
  const exitPromise = new Promise((resolveExit) => {
77
70
  exitResolve = resolveExit;
78
71
  });
79
- let cancellationResolve = null;
80
- const cancellationPromise = new Promise((resolveCancellation) => {
81
- cancellationResolve = resolveCancellation;
82
- });
83
72
  // Store recent output for debugging - keep last 50 lines from each stream
84
73
  const MAX_OUTPUT_LINES = 50;
85
74
  const recentStdout = [];
@@ -157,7 +146,7 @@ export class WorkspaceRuntime {
157
146
  const launchSnapshot = child.pid
158
147
  ? this.platform === "win32"
159
148
  ? probeWindowsProcesses(this.spawnCommand, this.stopCommandTimeoutMs)
160
- : probePosixProcesses(this.spawnCommand, this.stopCommandTimeoutMs, this.platform)
149
+ : probePosixProcesses(this.spawnCommand, this.stopCommandTimeoutMs, this.platform, this.platform === "linux" ? undefined : { pids: [child.pid], groupId: child.pid })
161
150
  : { ok: false, error: "spawned child did not expose a PID" };
162
151
  const launchLeader = launchSnapshot.ok && child.pid ? launchSnapshot.processes.get(child.pid) : undefined;
163
152
  if (!launchLeader) {
@@ -170,13 +159,26 @@ export class WorkspaceRuntime {
170
159
  }
171
160
  managed.targets.leader = launchLeader;
172
161
  managed.targets.groupId = launchLeader.groupId;
173
- managed.targets.members.set(launchLeader.pid, launchLeader);
162
+ managed.targets.groupOwnershipRetained = this.platform !== "linux" && this.platform !== "win32" &&
163
+ launchLeader.groupId === launchLeader.pid;
164
+ for (const identity of launchSnapshot.ok ? launchSnapshot.processes.values() : [launchLeader]) {
165
+ if (identity.groupId === launchLeader.groupId)
166
+ managed.targets.members.set(identity.pid, identity);
167
+ }
174
168
  }
175
169
  let stdoutBuffer = "";
176
170
  let stderrBuffer = "";
177
171
  let portFound = false;
178
172
  let pendingPort = null;
179
173
  let launchSettled = false;
174
+ const cancelLaunch = () => {
175
+ if (launchSettled)
176
+ return;
177
+ launchSettled = true;
178
+ stopWarningTimer();
179
+ reject(options.signal?.reason ?? new Error(`Workspace ${options.workspaceId} runtime launch was cancelled`));
180
+ };
181
+ managed.cancelLaunch = cancelLaunch;
180
182
  let warningTimer = null;
181
183
  const startWarningTimer = () => {
182
184
  warningTimer = setInterval(() => {
@@ -190,18 +192,9 @@ export class WorkspaceRuntime {
190
192
  }
191
193
  };
192
194
  startWarningTimer();
193
- managed.cancelWaits = () => {
194
- const error = new WorkspaceRuntimeLaunchCancelledError(options.workspaceId);
195
- if (!launchSettled) {
196
- launchSettled = true;
197
- stopWarningTimer();
198
- reject(error);
199
- }
200
- if (cancellationResolve) {
201
- cancellationResolve(error);
202
- cancellationResolve = null;
203
- }
204
- };
195
+ options.signal?.addEventListener("abort", cancelLaunch, { once: true });
196
+ if (options.signal?.aborted)
197
+ cancelLaunch();
205
198
  const cleanupStreams = () => {
206
199
  stopWarningTimer();
207
200
  child.stdout?.removeAllListeners();
@@ -212,11 +205,11 @@ export class WorkspaceRuntime {
212
205
  if (finalized)
213
206
  return;
214
207
  finalized = true;
208
+ const cleanupRequired = !managed.requestedStop;
215
209
  this.logger.info({ workspaceId: options.workspaceId, code, signal }, "OpenCode process exited");
216
- if (!managed.requestedStop && this.processes.get(options.workspaceId) === managed) {
217
- this.processes.delete(options.workspaceId);
218
- }
219
210
  cleanupStreams();
211
+ options.signal?.removeEventListener("abort", cancelLaunch);
212
+ managed.cancelLaunch = undefined;
220
213
  child.removeListener("error", handleError);
221
214
  child.removeListener("exit", handleExit);
222
215
  const exitInfo = {
@@ -240,14 +233,19 @@ export class WorkspaceRuntime {
240
233
  else {
241
234
  options.onExit?.(exitInfo);
242
235
  }
236
+ if (cleanupRequired && this.processes.get(options.workspaceId) === managed) {
237
+ void this.stop(options.workspaceId).catch((error) => {
238
+ this.logger.warn({ workspaceId: options.workspaceId, err: error }, "Unexpected workspace exit cleanup remains pending");
239
+ });
240
+ }
243
241
  };
244
242
  managed.finalizeExit = handleExit;
245
243
  const handleError = (error) => {
244
+ const cleanupRequired = !managed.requestedStop;
246
245
  cleanupStreams();
246
+ options.signal?.removeEventListener("abort", cancelLaunch);
247
+ managed.cancelLaunch = undefined;
247
248
  child.removeListener("exit", handleExit);
248
- if (!managed.requestedStop && this.processes.get(options.workspaceId) === managed) {
249
- this.processes.delete(options.workspaceId);
250
- }
251
249
  this.logger.error({ workspaceId: options.workspaceId, err: error }, "Workspace runtime error");
252
250
  if (exitResolve) {
253
251
  exitResolve({ workspaceId: options.workspaceId, code: null, signal: null, requested: managed.requestedStop });
@@ -257,6 +255,11 @@ export class WorkspaceRuntime {
257
255
  launchSettled = true;
258
256
  reject(error);
259
257
  }
258
+ if (cleanupRequired && this.processes.get(options.workspaceId) === managed) {
259
+ void this.stop(options.workspaceId).catch((stopError) => {
260
+ this.logger.warn({ workspaceId: options.workspaceId, err: stopError }, "Workspace error cleanup remains pending");
261
+ });
262
+ }
260
263
  };
261
264
  child.removeListener("error", handleEarlyError);
262
265
  child.on("error", handleError);
@@ -270,9 +273,11 @@ export class WorkspaceRuntime {
270
273
  portFound = true;
271
274
  launchSettled = true;
272
275
  stopWarningTimer();
276
+ options.signal?.removeEventListener("abort", cancelLaunch);
277
+ managed.cancelLaunch = undefined;
273
278
  child.removeListener("error", handleError);
274
279
  this.logger.info({ workspaceId: options.workspaceId, port: pendingPort }, "Workspace runtime allocated port");
275
- resolve({ pid: child.pid, port: pendingPort, exitPromise, cancellationPromise, getLastOutput });
280
+ resolve({ pid: child.pid, port: pendingPort, exitPromise, getLastOutput });
276
281
  };
277
282
  const failWslIdentityCapture = (detail) => {
278
283
  if (launchSettled)
@@ -360,16 +365,17 @@ export class WorkspaceRuntime {
360
365
  });
361
366
  }
362
367
  beginFailedLaunchCleanup(workspaceId, managed) {
363
- const child = managed.child;
364
368
  managed.identityCaptureFailed = true;
365
369
  void this.stop(workspaceId).catch((error) => {
366
370
  this.logger.warn({ workspaceId, err: error }, "Unpublished workspace cleanup remains pending");
367
371
  });
368
- try {
369
- child.kill("SIGTERM");
370
- }
371
- catch (error) {
372
- this.logger.debug({ workspaceId, err: error }, "Failed initial live-child cleanup signal");
372
+ if (managed.child.exitCode === null && managed.child.signalCode === null) {
373
+ try {
374
+ managed.child.kill("SIGTERM");
375
+ }
376
+ catch (error) {
377
+ this.logger.debug({ workspaceId, err: error }, "Failed initial live-child cleanup signal");
378
+ }
373
379
  }
374
380
  }
375
381
  stop(workspaceId) {
@@ -381,412 +387,294 @@ export class WorkspaceRuntime {
381
387
  }
382
388
  const stopPromise = this.stopManagedProcess(workspaceId, managed);
383
389
  managed.stopPromise = stopPromise;
384
- void stopPromise.then(() => {
385
- if (managed.stopPromise === stopPromise)
386
- managed.stopPromise = undefined;
387
- }, () => {
390
+ void stopPromise.finally(() => {
388
391
  if (managed.stopPromise === stopPromise)
389
392
  managed.stopPromise = undefined;
390
- });
393
+ }).catch(() => undefined);
391
394
  return stopPromise;
392
395
  }
393
396
  stopManagedProcess(workspaceId, managed) {
394
397
  managed.requestedStop = true;
395
- managed.cancelWaits?.();
396
- managed.cancelWaits = undefined;
397
- const child = managed.child;
398
+ managed.cancelLaunch?.();
399
+ managed.cancelLaunch = undefined;
398
400
  this.logger.info({ workspaceId }, "Stopping OpenCode process");
399
- if (managed.processKind === "windows-wrapper") {
401
+ if (managed.processKind === "windows-wrapper")
400
402
  return this.stopOwnedWindowsProcess(workspaceId, managed);
401
- }
403
+ const { child } = managed;
402
404
  const pid = child.pid;
403
405
  const failures = [];
404
406
  const wrapperExited = () => child.exitCode !== null || child.signalCode !== null;
405
- const rememberGroupMembers = (snapshot, targets) => {
406
- if (!snapshot.ok || !pid)
407
- return { snapshot, leaderMatches: false, aliveMembers: [] };
408
- const currentLeader = snapshot.processes.get(pid);
409
- const leaderMatches = sameProcess(targets.leader, currentLeader);
410
- const currentGroupLeader = targets.groupId ? snapshot.processes.get(targets.groupId) : undefined;
411
- const groupWasReused = Boolean(currentGroupLeader && !sameProcess(targets.leader, currentGroupLeader));
412
- if (targets.groupId) {
413
- for (const process of snapshot.processes.values()) {
414
- const launchBootMatches = !targets.leader?.bootId || process.bootId === targets.leader.bootId;
415
- const withinProvenLinuxDispatch = this.platform === "linux" && Boolean(targets.dispatchCutoff && launchBootMatches && startedNoLaterThan(process, targets.dispatchCutoff));
416
- if (process.groupId === targets.groupId && (leaderMatches || (!groupWasReused && withinProvenLinuxDispatch))) {
417
- targets.members.set(process.pid, process);
418
- }
419
- }
420
- }
407
+ const hasWslIdentity = () => Boolean(managed.wsl?.linuxPid && managed.wsl.linuxPgid && managed.wsl.leaderStartTime && managed.wsl.bootId);
408
+ const trackedTarget = () => managed.wsl && hasWslIdentity() ? managed.wsl : managed.targets;
409
+ const trackedLeader = () => {
410
+ if (!managed.wsl || !hasWslIdentity())
411
+ return managed.targets?.leader;
421
412
  return {
422
- snapshot,
423
- leaderMatches,
424
- aliveMembers: Array.from(targets.members.values()).filter((identity) => sameProcess(identity, snapshot.processes.get(identity.pid))),
413
+ pid: managed.wsl.linuxPid,
414
+ parentPid: 0,
415
+ groupId: managed.wsl.linuxPgid,
416
+ startTime: managed.wsl.leaderStartTime,
417
+ bootId: managed.wsl.bootId,
418
+ startOrder: managed.wsl.leaderStartTime,
425
419
  };
426
420
  };
427
- const refreshHostTargets = () => {
428
- const targets = managed.targets ?? { members: new Map() };
429
- managed.targets = targets;
430
- const snapshot = this.platform === "win32"
431
- ? probeWindowsProcesses(this.spawnCommand, this.stopCommandTimeoutMs)
432
- : probePosixProcesses(this.spawnCommand, this.stopCommandTimeoutMs, this.platform);
421
+ const refreshTargets = () => {
422
+ const target = trackedTarget();
423
+ const leader = trackedLeader();
424
+ const groupId = managed.wsl && hasWslIdentity() ? managed.wsl.linuxPgid : target.groupId;
425
+ const portableGroupId = this.platform !== "linux" && this.platform !== "win32" &&
426
+ target.groupOwnershipRetained && !target.groupGoneConfirmed ? groupId : undefined;
427
+ const snapshot = managed.wsl && hasWslIdentity()
428
+ ? probeWslProcesses(this.spawnCommand, managed.wsl.distro, this.stopCommandTimeoutMs)
429
+ : this.platform === "win32"
430
+ ? probeWindowsProcesses(this.spawnCommand, this.stopCommandTimeoutMs)
431
+ : probePosixProcesses(this.spawnCommand, this.stopCommandTimeoutMs, this.platform, this.platform === "linux"
432
+ ? undefined
433
+ : { pids: [leader?.pid, ...target.members.keys()].filter((value) => Boolean(value)), groupId: portableGroupId });
433
434
  if (!snapshot.ok) {
434
- failures.push(`${this.platform === "win32" ? "Windows" : "POSIX"} identity discovery failed: ${snapshot.error}`);
435
- return { snapshot, leaderMatches: false, aliveMembers: [] };
435
+ const platformName = managed.wsl && hasWslIdentity() ? "WSL" : this.platform === "win32" ? "Windows" : "POSIX";
436
+ failures.push(`${platformName} identity discovery failed: ${snapshot.error}`);
437
+ return { snapshot, aliveMembers: [] };
436
438
  }
437
- const refreshed = rememberGroupMembers(snapshot, targets);
438
- if (this.platform === "win32" && refreshed.leaderMatches && targets.leader) {
439
- for (const descendant of descendantsOf(snapshot.processes, targets.leader.pid)) {
440
- targets.members.set(descendant.pid, descendant);
441
- }
442
- refreshed.aliveMembers = Array.from(targets.members.values()).filter((identity) => sameProcess(identity, snapshot.processes.get(identity.pid)));
439
+ const leaderMatches = sameProcess(leader, leader ? snapshot.processes.get(leader.pid) : undefined);
440
+ const groupLeader = groupId ? snapshot.processes.get(groupId) : undefined;
441
+ const groupWasReused = Boolean(groupLeader && !sameProcess(leader, groupLeader));
442
+ const retainedAnchorMatches = Boolean(portableGroupId && Array.from(target.members.values()).some((identity) => sameProcess(identity, snapshot.processes.get(identity.pid))));
443
+ if (portableGroupId && groupWasReused) {
444
+ target.groupGoneConfirmed = true;
445
+ target.groupOwnershipUncertain = false;
443
446
  }
444
- return refreshed;
445
- };
446
- const refreshWslTargets = () => {
447
- const wsl = managed.wsl;
448
- const snapshot = probeWslProcesses(this.spawnCommand, wsl.distro, this.stopCommandTimeoutMs);
449
- if (!snapshot.ok) {
450
- failures.push(`WSL identity discovery failed: ${snapshot.error}`);
451
- return { snapshot, leaderMatches: false, aliveMembers: [] };
452
- }
453
- if (!wsl.linuxPid || !wsl.leaderStartTime) {
454
- return { snapshot, leaderMatches: false, aliveMembers: [] };
447
+ for (const process of snapshot.processes.values()) {
448
+ const sameBoot = !leader?.bootId || process.bootId === leader.bootId;
449
+ const withinDispatch = (this.platform === "linux" || Boolean(managed.wsl)) && Boolean(target.dispatchCutoff && sameBoot && startedNoLaterThan(process, target.dispatchCutoff));
450
+ const withinRetainedPortableGroup = Boolean(portableGroupId && !groupWasReused && retainedAnchorMatches);
451
+ if (groupId && process.groupId === groupId && (leaderMatches || withinRetainedPortableGroup || (!groupWasReused && withinDispatch))) {
452
+ target.members.set(process.pid, process);
453
+ }
455
454
  }
456
- const leaderIdentity = {
457
- pid: wsl.linuxPid,
458
- parentPid: 0,
459
- groupId: wsl.linuxPgid ?? wsl.linuxPid,
460
- startTime: wsl.leaderStartTime,
461
- ...(wsl.bootId ? { bootId: wsl.bootId } : {}),
462
- startOrder: wsl.leaderStartTime,
463
- };
464
- const currentLeader = snapshot.processes.get(wsl.linuxPid);
465
- const leaderMatches = sameProcess(leaderIdentity, currentLeader);
466
- const currentGroupLeader = wsl.linuxPgid ? snapshot.processes.get(wsl.linuxPgid) : undefined;
467
- const groupWasReused = Boolean(currentGroupLeader && !sameProcess(leaderIdentity, currentGroupLeader));
468
- if (wsl.linuxPgid) {
469
- for (const process of snapshot.processes.values()) {
470
- const withinProvenDispatch = Boolean(wsl.dispatchCutoff && process.bootId === wsl.bootId && startedNoLaterThan(process, wsl.dispatchCutoff));
471
- if (process.groupId === wsl.linuxPgid && (leaderMatches || (!groupWasReused && withinProvenDispatch))) {
472
- wsl.members.set(process.pid, process);
473
- }
455
+ if (portableGroupId && !groupWasReused) {
456
+ const groupPresent = Array.from(snapshot.processes.values()).some((process) => process.groupId === portableGroupId);
457
+ if (!groupPresent) {
458
+ target.groupGoneConfirmed = true;
459
+ target.groupOwnershipUncertain = false;
460
+ }
461
+ else if (!leaderMatches && !retainedAnchorMatches) {
462
+ target.groupOwnershipUncertain = true;
474
463
  }
475
464
  }
476
- return {
477
- snapshot,
478
- leaderMatches,
479
- aliveMembers: Array.from(wsl.members.values()).filter((identity) => sameProcess(identity, snapshot.processes.get(identity.pid))),
480
- };
465
+ if (this.platform === "win32" && !managed.wsl && leaderMatches && leader) {
466
+ for (const descendant of descendantsOf(snapshot.processes, leader.pid))
467
+ target.members.set(descendant.pid, descendant);
468
+ }
469
+ const aliveMembers = Array.from(target.members.values()).filter((identity) => sameProcess(identity, snapshot.processes.get(identity.pid)));
470
+ return { snapshot, aliveMembers };
481
471
  };
482
- const hasWslIdentity = () => Boolean(managed.wsl?.linuxPid && managed.wsl.linuxPgid && managed.wsl.leaderStartTime && managed.wsl.bootId);
483
- const canUseTokenCleanup = () => this.platform === "linux" || Boolean(managed.wsl);
484
- const tokenTarget = () => managed.wsl ?? managed.targets;
472
+ const usesTokenCleanup = () => this.platform === "linux" || Boolean(managed.wsl);
485
473
  const refreshTokenTargets = () => {
486
- if (!canUseTokenCleanup())
487
- return undefined;
474
+ if (!usesTokenCleanup())
475
+ return;
488
476
  const snapshot = probeLaunchCleanupToken(this.spawnCommand, managed.cleanupToken, this.stopCommandTimeoutMs, managed.wsl?.distro);
489
- if (!snapshot.ok) {
477
+ if (!snapshot.ok)
490
478
  failures.push(`${managed.wsl ? "WSL" : "Linux"} launch-token discovery failed: ${snapshot.error}`);
491
- return snapshot;
492
- }
493
- const target = tokenTarget();
494
- for (const identity of snapshot.processes.values())
495
- target.members.set(identity.pid, identity);
479
+ else
480
+ for (const identity of snapshot.processes.values())
481
+ trackedTarget().members.set(identity.pid, identity);
496
482
  return snapshot;
497
483
  };
498
- const recordSignalResult = (result, target, platformName, signal) => {
499
- if (!result.ok) {
500
- for (const identity of result.observed ?? [])
501
- target.members.set(identity.pid, identity);
502
- failures.push(`${platformName} guarded ${signal} failed: ${result.error}`);
503
- return;
504
- }
505
- if (result.matched && !result.signalSent)
506
- failures.push(`${platformName} guarded ${signal} matched but sent no signal`);
507
- for (const identity of result.signaled)
484
+ const recordSignalResult = (result, target, name, signal) => {
485
+ const identities = result.ok ? result.signaled : (result.observed ?? []);
486
+ for (const identity of identities)
508
487
  target.members.set(identity.pid, identity);
509
- if (result.cutoff)
510
- target.dispatchCutoff = result.cutoff;
488
+ if (!result.ok)
489
+ failures.push(`${name} guarded ${signal} failed: ${result.error}`);
490
+ else {
491
+ if (result.matched && !result.signalSent)
492
+ failures.push(`${name} guarded ${signal} matched but sent no signal`);
493
+ if (result.cutoff)
494
+ target.dispatchCutoff = result.cutoff;
495
+ }
511
496
  };
512
497
  const sendStopSignal = (signal) => {
513
- if (!pid) {
498
+ if (!pid)
514
499
  failures.push(`${signal} was not sent because the process PID is unavailable`);
515
- }
516
- let ownedPosixHandled = false;
500
+ if (pid && wrapperExited() && this.platform !== "linux" && this.platform !== "win32")
501
+ refreshTargets();
502
+ let signaledOwnedGroup = false;
517
503
  if (pid && managed.identityCaptureFailed && this.platform !== "linux" && this.platform !== "win32" && !wrapperExited()) {
518
- const cleanup = signalOwnedPosixProcessGroup(this.spawnCommand, pid, signal, this.stopCommandTimeoutMs);
519
- recordSignalResult(cleanup, managed.targets, "owned POSIX group", signal);
520
- if (cleanup.ok && cleanup.matched) {
521
- const leader = cleanup.signaled.find((identity) => identity.pid === pid);
522
- if (leader) {
523
- managed.targets.leader = leader;
524
- managed.targets.groupId = pid;
525
- }
526
- }
527
- refreshHostTargets();
528
- ownedPosixHandled = true;
504
+ const result = signalOwnedPosixProcessGroup(this.spawnCommand, pid, signal, this.stopCommandTimeoutMs);
505
+ recordSignalResult(result, managed.targets, "owned POSIX group", signal);
506
+ const leader = result.ok && result.matched ? result.signaled.find((identity) => identity.pid === pid) : undefined;
507
+ if (leader)
508
+ Object.assign(managed.targets, { leader, groupId: pid });
509
+ refreshTargets();
510
+ signaledOwnedGroup = true;
529
511
  }
530
- if (pid && managed.wsl && hasWslIdentity()) {
531
- const wsl = managed.wsl;
532
- const leader = {
533
- pid: wsl.linuxPid,
534
- parentPid: 0,
535
- groupId: wsl.linuxPgid,
536
- startTime: wsl.leaderStartTime,
537
- bootId: wsl.bootId,
538
- startOrder: wsl.leaderStartTime,
539
- };
540
- const result = signalWslProcesses(this.spawnCommand, wsl.distro, {
541
- leader,
542
- groupId: wsl.linuxPgid,
543
- members: Array.from(wsl.members.values()),
544
- signal,
545
- }, this.stopCommandTimeoutMs);
546
- recordSignalResult(result, wsl, "WSL", signal);
547
- refreshWslTargets();
548
- }
549
- else if (pid && !ownedPosixHandled) {
550
- const targets = managed.targets;
512
+ if (pid && !signaledOwnedGroup) {
513
+ const target = trackedTarget();
514
+ const groupId = managed.wsl && hasWslIdentity() ? managed.wsl.linuxPgid : target.groupId;
551
515
  const request = {
552
- leader: targets.leader,
553
- groupId: targets.groupId,
554
- members: Array.from(targets.members.values()),
555
- signal,
516
+ leader: trackedLeader(), groupId, members: [...target.members.values()], signal,
517
+ allowLeaderlessGroup: this.platform !== "linux" && this.platform !== "win32" &&
518
+ Boolean(target.groupOwnershipRetained && !target.groupGoneConfirmed && wrapperExited()),
519
+ cleanupToken: this.platform !== "linux" && this.platform !== "win32" ? managed.cleanupToken : undefined,
556
520
  };
557
- if (this.platform === "win32") {
558
- recordSignalResult(signalWindowsProcesses(this.spawnCommand, request, this.stopCommandTimeoutMs), targets, "Windows", signal);
559
- }
560
- else {
561
- recordSignalResult(signalPosixProcesses(this.spawnCommand, request, this.stopCommandTimeoutMs, this.platform), targets, "POSIX", signal);
562
- }
563
- refreshHostTargets();
521
+ const result = managed.wsl && hasWslIdentity()
522
+ ? signalWslProcesses(this.spawnCommand, managed.wsl.distro, request, this.stopCommandTimeoutMs)
523
+ : this.platform === "win32"
524
+ ? signalWindowsProcesses(this.spawnCommand, request, this.stopCommandTimeoutMs)
525
+ : signalPosixProcesses(this.spawnCommand, request, this.stopCommandTimeoutMs, this.platform);
526
+ recordSignalResult(result, target, managed.wsl && hasWslIdentity() ? "WSL" : this.platform === "win32" ? "Windows" : "POSIX", signal);
527
+ refreshTargets();
564
528
  }
565
- if (canUseTokenCleanup()) {
566
- const tokenResult = signalLaunchCleanupToken(this.spawnCommand, managed.cleanupToken, signal, this.stopCommandTimeoutMs, managed.wsl?.distro);
567
- if (!tokenResult.ok) {
568
- failures.push(`${managed.wsl ? "WSL" : "Linux"} launch-token ${signal} failed: ${tokenResult.error}`);
569
- }
529
+ if (usesTokenCleanup()) {
530
+ const result = signalLaunchCleanupToken(this.spawnCommand, managed.cleanupToken, signal, this.stopCommandTimeoutMs, managed.wsl?.distro);
531
+ const name = managed.wsl ? "WSL" : "Linux";
532
+ if (!result.ok)
533
+ failures.push(`${name} launch-token ${signal} failed: ${result.error}`);
570
534
  else {
571
- if (tokenResult.targets.length > 0 && !tokenResult.signalSent) {
572
- failures.push(`${managed.wsl ? "WSL" : "Linux"} launch-token ${signal} matched but sent no signal`);
573
- }
574
- const target = tokenTarget();
575
- for (const identity of tokenResult.targets)
576
- target.members.set(identity.pid, identity);
535
+ if (result.targets.length > 0 && !result.signalSent)
536
+ failures.push(`${name} launch-token ${signal} matched but sent no signal`);
537
+ for (const identity of result.targets)
538
+ trackedTarget().members.set(identity.pid, identity);
577
539
  }
578
540
  refreshTokenTargets();
579
541
  }
580
542
  };
581
- const probeTargetLiveness = () => {
582
- const refreshed = pid
583
- ? managed.wsl && hasWslIdentity() ? refreshWslTargets() : refreshHostTargets()
584
- : undefined;
543
+ const probeLiveness = () => {
544
+ const refreshed = pid ? refreshTargets() : undefined;
585
545
  const tokenSnapshot = refreshTokenTargets();
586
546
  if (tokenSnapshot && !tokenSnapshot.ok) {
587
547
  return { state: "unknown", detail: `${managed.wsl ? "WSL Linux" : "Linux"} launch-token cleanup could not be confirmed` };
588
548
  }
589
549
  if (refreshed && !refreshed.snapshot.ok && (managed.targets?.leader || !tokenSnapshot?.ok)) {
590
- const platformName = managed.wsl ? "WSL Linux" : this.platform === "win32" ? "Windows" : "POSIX";
591
- return { state: "unknown", detail: `${platformName} target identity could not be confirmed` };
550
+ const name = managed.wsl ? "WSL Linux" : this.platform === "win32" ? "Windows" : "POSIX";
551
+ return { state: "unknown", detail: `${name} target identity could not be confirmed` };
592
552
  }
593
- const trackedCount = managed.wsl ? managed.wsl.members.size : (managed.targets?.members.size ?? 0);
594
553
  if (managed.identityCaptureFailed && this.platform === "win32" && !managed.wsl) {
595
554
  return { state: "unknown", detail: "Windows cleanup cannot prove exact launch ownership without a Job Object" };
596
555
  }
597
556
  if (managed.identityCaptureFailed && managed.wsl && !managed.targets?.leader && !wrapperExited()) {
598
557
  return { state: "unknown", detail: "the unidentified Windows WSL wrapper is still alive" };
599
558
  }
600
- if (trackedCount === 0) {
601
- if (tokenSnapshot?.ok && tokenSnapshot.processes.size === 0) {
559
+ if (trackedTarget().groupOwnershipUncertain) {
560
+ return { state: "unknown", detail: "the retained POSIX process group no longer has a verified identity anchor" };
561
+ }
562
+ if (trackedTarget().members.size === 0) {
563
+ if (tokenSnapshot?.ok && tokenSnapshot.processes.size === 0)
602
564
  return { state: "gone", detail: "no process carries the unpublished launch token" };
603
- }
604
565
  return { state: "unknown", detail: pid ? "the original process identity was not captured" : "the target PID is unavailable" };
605
566
  }
606
567
  if ((refreshed?.aliveMembers.length ?? 0) === 0 && (!tokenSnapshot?.ok || tokenSnapshot.processes.size === 0)) {
607
568
  return { state: "gone", detail: "all tracked original process identities are gone" };
608
569
  }
609
- const targetName = managed.wsl && hasWslIdentity() ? "WSL Linux process group" : this.platform === "win32" ? "Windows process tree" : "POSIX process group";
610
- return { state: "alive", detail: `the tracked original ${targetName} is still alive` };
570
+ const name = managed.wsl && hasWslIdentity() ? "WSL Linux process group" : this.platform === "win32" ? "Windows process tree" : "POSIX process group";
571
+ return { state: "alive", detail: `the tracked original ${name} is still alive` };
611
572
  };
612
- return new Promise((resolve, reject) => {
613
- let escalationTimer = null;
614
- let deadlineTimer = null;
615
- let settled = false;
616
- const cleanup = () => {
617
- child.removeListener("exit", onExit);
618
- child.removeListener("error", onError);
619
- if (escalationTimer) {
620
- this.cancelTimeout(escalationTimer);
621
- escalationTimer = null;
622
- }
623
- if (deadlineTimer) {
624
- this.cancelTimeout(deadlineTimer);
625
- deadlineTimer = null;
626
- }
627
- };
628
- const confirmTargetGone = () => {
629
- if (settled)
630
- return;
631
- settled = true;
632
- cleanup();
633
- if (this.processes.get(workspaceId) === managed) {
634
- this.processes.delete(workspaceId);
635
- }
636
- managed.finalizeExit?.(child.exitCode, child.signalCode);
637
- resolve();
638
- };
639
- const checkForConfirmedStop = () => {
640
- const liveness = probeTargetLiveness();
641
- if (liveness.state === "gone") {
642
- confirmTargetGone();
643
- }
644
- return liveness;
645
- };
646
- const onExit = () => {
647
- checkForConfirmedStop();
648
- };
649
- const onError = (error) => {
650
- failures.push(`child process error while stopping: ${error.message}`);
651
- };
652
- child.once("exit", onExit);
653
- child.on("error", onError);
654
- escalationTimer = this.scheduleTimeout(() => {
655
- escalationTimer = null;
656
- if (settled)
657
- return;
658
- const liveness = checkForConfirmedStop();
659
- if (settled)
660
- return;
573
+ const stopped = () => probeLiveness().state === "gone" ? true : undefined;
574
+ const totalTimeoutMs = this.gracefulStopTimeoutMs + this.forcedStopTimeoutMs;
575
+ return this.runBoundedStop(workspaceId, managed, {
576
+ start: () => {
577
+ this.logger.debug({ workspaceId, pid, detached: this.platform !== "win32" }, "Sending SIGTERM to workspace process (tree/group)");
578
+ sendStopSignal("SIGTERM");
579
+ return stopped();
580
+ },
581
+ exit: stopped,
582
+ error: (error) => { failures.push(`child process error while stopping: ${error.message}`); },
583
+ escalate: () => {
584
+ const liveness = probeLiveness();
585
+ if (liveness.state === "gone")
586
+ return true;
661
587
  this.logger.warn({ workspaceId, pid }, "Process did not stop after SIGTERM, escalating");
662
588
  sendStopSignal("SIGKILL");
663
- if (liveness.state === "unknown") {
664
- this.logger.debug({ workspaceId, pid }, "Escalating because target liveness could not be confirmed");
665
- }
666
- }, this.gracefulStopTimeoutMs);
667
- const totalTimeoutMs = this.gracefulStopTimeoutMs + this.forcedStopTimeoutMs;
668
- deadlineTimer = this.scheduleTimeout(() => {
669
- deadlineTimer = null;
670
- if (settled)
671
- return;
672
- const liveness = checkForConfirmedStop();
673
- if (settled)
674
- return;
675
- settled = true;
676
- cleanup();
677
- const wrapperDetail = wrapperExited() ? "the wrapper exited but " : "";
678
- reject(new WorkspaceStopTimeoutError(workspaceId, pid, totalTimeoutMs, `${wrapperDetail}${liveness.detail}`, failures));
679
- }, totalTimeoutMs);
680
- this.logger.debug({ workspaceId, pid, detached: this.platform !== "win32" }, "Sending SIGTERM to workspace process (tree/group)");
681
- sendStopSignal("SIGTERM");
682
- checkForConfirmedStop();
589
+ },
590
+ deadline: () => {
591
+ const liveness = probeLiveness();
592
+ if (liveness.state === "gone")
593
+ return true;
594
+ const prefix = wrapperExited() ? "the wrapper exited but " : "";
595
+ return new WorkspaceStopTimeoutError(workspaceId, pid, totalTimeoutMs, `${prefix}${liveness.detail}`, failures);
596
+ },
683
597
  });
684
598
  }
685
599
  stopOwnedWindowsProcess(workspaceId, managed) {
686
- const child = managed.child;
600
+ const { child } = managed;
687
601
  const pid = child.pid;
688
- const failures = (managed.windowsTreeCleanupFailures ?? (managed.windowsTreeCleanupFailures = []));
602
+ const failures = (managed.windowsTreeCleanupFailures ??= []);
603
+ const outcome = () => managed.windowsTreeCleanupConfirmed
604
+ ? true
605
+ : new WorkspaceWindowsTreeCleanupIncompleteError(workspaceId, pid, failures);
606
+ const stopChild = (force) => {
607
+ if (child.exitCode !== null || child.signalCode !== null)
608
+ return;
609
+ if (!pid) {
610
+ failures.push(`${force ? "forced" : "graceful"} stop was not sent because the process PID is unavailable`);
611
+ return;
612
+ }
613
+ const args = ["/PID", String(pid), "/T", ...(force ? ["/F"] : [])];
614
+ try {
615
+ const result = this.spawnCommand("taskkill.exe", args, { encoding: "utf8", timeout: this.stopCommandTimeoutMs });
616
+ if (result.status === 0)
617
+ managed.windowsTreeCleanupConfirmed = true;
618
+ else {
619
+ const detail = result.error?.message || String(result.stderr ?? result.stdout ?? "").trim() || `exit code ${result.status}`;
620
+ failures.push(`taskkill ${force ? "/T /F" : "/T"} failed: ${detail}`);
621
+ }
622
+ }
623
+ catch (error) {
624
+ failures.push(`taskkill ${force ? "/T /F" : "/T"} failed: ${error instanceof Error ? error.message : String(error)}`);
625
+ }
626
+ };
627
+ const totalTimeoutMs = this.gracefulStopTimeoutMs + this.forcedStopTimeoutMs;
628
+ return this.runBoundedStop(workspaceId, managed, {
629
+ start: () => {
630
+ if (child.exitCode !== null || child.signalCode !== null)
631
+ return outcome();
632
+ this.logger.debug({ workspaceId, pid }, "Stopping owned Windows workspace wrapper tree");
633
+ stopChild(false);
634
+ },
635
+ exit: outcome,
636
+ error: (error) => {
637
+ failures.push(`child process error while stopping: ${error.message}`);
638
+ return error;
639
+ },
640
+ escalate: () => {
641
+ this.logger.warn({ workspaceId, pid }, "Owned Windows process did not stop after the graceful attempt, escalating");
642
+ stopChild(true);
643
+ },
644
+ deadline: () => new WorkspaceStopTimeoutError(workspaceId, pid, totalTimeoutMs, child.exitCode !== null || child.signalCode !== null
645
+ ? "taskkill did not confirm tree cleanup before the owned Windows wrapper exited"
646
+ : "the owned Windows wrapper did not emit exit or error after tree termination", failures),
647
+ });
648
+ }
649
+ runBoundedStop(workspaceId, managed, actions) {
650
+ const { child } = managed;
689
651
  return new Promise((resolve, reject) => {
690
- let escalationTimer = null;
691
- let deadlineTimer = null;
692
652
  let settled = false;
693
- const cleanup = () => {
694
- child.removeListener("exit", onExit);
695
- child.removeListener("error", onError);
696
- if (escalationTimer)
697
- this.cancelTimeout(escalationTimer);
698
- if (deadlineTimer)
699
- this.cancelTimeout(deadlineTimer);
700
- };
701
- const finish = () => {
702
- if (settled)
653
+ const timers = [];
654
+ const finish = (outcome) => {
655
+ if (settled || !outcome)
703
656
  return;
704
657
  settled = true;
705
- cleanup();
706
- if (this.processes.get(workspaceId) === managed)
707
- this.processes.delete(workspaceId);
708
- managed.finalizeExit?.(child.exitCode, child.signalCode);
709
- resolve();
710
- };
711
- const rejectIncompleteCleanup = () => {
712
- if (settled)
713
- return;
714
- settled = true;
715
- cleanup();
716
- reject(new WorkspaceWindowsTreeCleanupIncompleteError(workspaceId, pid, failures));
717
- };
718
- const onExit = () => {
719
- if (managed.windowsTreeCleanupConfirmed) {
720
- finish();
721
- }
658
+ child.removeListener("exit", onExit);
659
+ child.removeListener("error", onError);
660
+ for (const timer of timers)
661
+ this.cancelTimeout(timer);
662
+ if (outcome instanceof Error)
663
+ reject(outcome);
722
664
  else {
723
- rejectIncompleteCleanup();
724
- }
725
- };
726
- const onError = (error) => {
727
- if (settled)
728
- return;
729
- settled = true;
730
- cleanup();
731
- failures.push(`child process error while stopping: ${error.message}`);
732
- reject(error);
733
- };
734
- const stopChild = (force) => {
735
- if (child.exitCode !== null || child.signalCode !== null)
736
- return;
737
- if (!pid) {
738
- failures.push(`${force ? "forced" : "graceful"} stop was not sent because the process PID is unavailable`);
739
- return;
740
- }
741
- const args = ["/PID", String(pid), "/T", ...(force ? ["/F"] : [])];
742
- try {
743
- const result = this.spawnCommand("taskkill.exe", args, {
744
- encoding: "utf8",
745
- timeout: this.stopCommandTimeoutMs,
746
- });
747
- if (result.status === 0) {
748
- managed.windowsTreeCleanupConfirmed = true;
749
- }
750
- else {
751
- const detail = result.error?.message || String(result.stderr ?? result.stdout ?? "").trim() || `exit code ${result.status}`;
752
- failures.push(`taskkill ${force ? "/T /F" : "/T"} failed: ${detail}`);
753
- }
754
- }
755
- catch (error) {
756
- failures.push(`taskkill ${force ? "/T /F" : "/T"} failed: ${error instanceof Error ? error.message : String(error)}`);
665
+ if (this.processes.get(workspaceId) === managed)
666
+ this.processes.delete(workspaceId);
667
+ managed.finalizeExit?.(child.exitCode, child.signalCode);
668
+ resolve();
757
669
  }
758
670
  };
671
+ const onExit = () => finish(actions.exit());
672
+ const onError = (error) => finish(actions.error(error));
759
673
  child.once("exit", onExit);
760
- child.once("error", onError);
761
- if (child.exitCode !== null || child.signalCode !== null) {
762
- if (managed.windowsTreeCleanupConfirmed) {
763
- finish();
764
- }
765
- else {
766
- rejectIncompleteCleanup();
767
- }
768
- return;
769
- }
770
- escalationTimer = this.scheduleTimeout(() => {
771
- escalationTimer = null;
772
- if (settled)
773
- return;
774
- this.logger.warn({ workspaceId, pid }, "Owned Windows process did not stop after the graceful attempt, escalating");
775
- stopChild(true);
776
- }, this.gracefulStopTimeoutMs);
777
- const totalTimeoutMs = this.gracefulStopTimeoutMs + this.forcedStopTimeoutMs;
778
- deadlineTimer = this.scheduleTimeout(() => {
779
- deadlineTimer = null;
780
- if (settled)
781
- return;
782
- settled = true;
783
- cleanup();
784
- reject(new WorkspaceStopTimeoutError(workspaceId, pid, totalTimeoutMs, child.exitCode !== null || child.signalCode !== null
785
- ? "taskkill did not confirm tree cleanup before the owned Windows wrapper exited"
786
- : "the owned Windows wrapper did not emit exit or error after tree termination", failures));
787
- }, totalTimeoutMs);
788
- this.logger.debug({ workspaceId, pid }, "Stopping owned Windows workspace wrapper tree");
789
- stopChild(false);
674
+ child.on("error", onError);
675
+ timers.push(this.scheduleTimeout(() => finish(actions.escalate()), this.gracefulStopTimeoutMs));
676
+ timers.push(this.scheduleTimeout(() => finish(actions.deadline()), this.gracefulStopTimeoutMs + this.forcedStopTimeoutMs));
677
+ finish(actions.start());
790
678
  });
791
679
  }
792
680
  emitLog(workspaceId, level, message) {