@hearsay-tools/squawk 0.18.0-dev.6821 → 0.18.0-dev.6842

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 (96) hide show
  1. package/dist/contract/delegation.d.ts +2 -0
  2. package/dist/contract/index.js +1 -1
  3. package/dist/delegation/routes.d.ts +74 -74
  4. package/dist/delegation/transport.d.ts +14 -14
  5. package/dist/preview/dev-server.js +10 -5
  6. package/dist/preview/dev-server.js.map +1 -1
  7. package/dist/server/live-routes.d.ts +6 -6
  8. package/dist/server/server.d.ts +66 -66
  9. package/dist/server/workspace-live-routes.d.ts +6 -6
  10. package/dist/worker-scope/job.d.ts +28 -0
  11. package/dist/worker-scope/job.js +65 -0
  12. package/dist/worker-scope/job.js.map +1 -0
  13. package/dist/worker-scope/scope.d.ts +3 -1
  14. package/dist/worker-scope/scope.js +3 -1
  15. package/dist/worker-scope/scope.js.map +1 -1
  16. package/dist/worker-scope/worker-scopes.d.ts +13 -1
  17. package/dist/worker-scope/worker-scopes.js +71 -11
  18. package/dist/worker-scope/worker-scopes.js.map +1 -1
  19. package/dist/workflows/grouped-command.js +14 -4
  20. package/dist/workflows/grouped-command.js.map +1 -1
  21. package/dist/workflows/run/compose.js +7 -2
  22. package/dist/workflows/run/compose.js.map +1 -1
  23. package/dist/workflows/run/continuation-session.js +3 -1
  24. package/dist/workflows/run/continuation-session.js.map +1 -1
  25. package/dist/workflows/run/input-delivery.d.ts +6 -0
  26. package/dist/workflows/run/input-delivery.js +15 -2
  27. package/dist/workflows/run/input-delivery.js.map +1 -1
  28. package/dist/workflows/run/input-receipts.d.ts +4 -3
  29. package/dist/workflows/run/input-receipts.js +5 -4
  30. package/dist/workflows/run/input-receipts.js.map +1 -1
  31. package/dist/workflows/run/liveness-timers.d.ts +1 -1
  32. package/dist/workflows/run/liveness-timers.js +1 -1
  33. package/dist/workflows/run/liveness-timers.js.map +1 -1
  34. package/dist/workflows/run/run-settlement.js +2 -1
  35. package/dist/workflows/run/run-settlement.js.map +1 -1
  36. package/dist/workflows/run/session-events.d.ts +8 -4
  37. package/dist/workflows/run/session-events.js +8 -6
  38. package/dist/workflows/run/session-events.js.map +1 -1
  39. package/dist/workflows/run/step-session.js +3 -1
  40. package/dist/workflows/run/step-session.js.map +1 -1
  41. package/dist/workflows/run/turn-nudges.d.ts +29 -0
  42. package/dist/workflows/run/turn-nudges.js +64 -2
  43. package/dist/workflows/run/turn-nudges.js.map +1 -1
  44. package/dist/workflows/run/turn-settler.d.ts +5 -1
  45. package/dist/workflows/run/turn-settler.js +15 -8
  46. package/dist/workflows/run/turn-settler.js.map +1 -1
  47. package/dist/workflows/run-states.js +1 -0
  48. package/dist/workflows/run-states.js.map +1 -1
  49. package/dist/workflows/turn-end.d.ts +1 -0
  50. package/dist/workflows/turn-end.js +1 -0
  51. package/dist/workflows/turn-end.js.map +1 -1
  52. package/package.json +4 -4
  53. package/scripts/windows-worker-job.cs +186 -0
  54. package/scripts/windows-worker-job.ps1 +34 -0
  55. package/web/dist/assets/{activity-motion-AuQA350-.js → activity-motion-awuRigEi.js} +1 -1
  56. package/web/dist/assets/{activity-route-BNZ9bOOZ.js → activity-route-rhYVhpXu.js} +1 -1
  57. package/web/dist/assets/{agent-accounts-D2uZHuiM.js → agent-accounts-D3q1WLxk.js} +1 -1
  58. package/web/dist/assets/attention-CdwMIvQG.js +1 -0
  59. package/web/dist/assets/{cez-idle-MToU9Wv_.js → cez-idle-BqmM5iRr.js} +1 -1
  60. package/web/dist/assets/{commit-diff-panel-DBW7us79.js → commit-diff-panel-CZAQ_wMQ.js} +1 -1
  61. package/web/dist/assets/{diff-C3Cms5Ep.js → diff-BDJ4xGSd.js} +2 -2
  62. package/web/dist/assets/{diff-view-D5zTYOKV.js → diff-view-Bn7tV6S7.js} +1 -1
  63. package/web/dist/assets/{file-preview-FhzIdXZ3.js → file-preview-1f8vPVsK.js} +1 -1
  64. package/web/dist/assets/{git-toolbar-MFjkjDDG.js → git-toolbar-BbY7l1x9.js} +1 -1
  65. package/web/dist/assets/{github-CYmdc5Dh.js → github-CTdrVztq.js} +1 -1
  66. package/web/dist/assets/{global-activity-route-C41ofuHV.js → global-activity-route-xvY0P60v.js} +1 -1
  67. package/web/dist/assets/{index-e1OpsDKN.js → index-MgNz22Tg.js} +4 -4
  68. package/web/dist/assets/{live-protocol-B8boP96Z.js → live-protocol-BmbbwF5R.js} +1 -1
  69. package/web/dist/assets/{preview-pane-connected-Ds209_UZ.js → preview-pane-connected-D6TfZFTU.js} +1 -1
  70. package/web/dist/assets/{project-router-F1inY-EB.js → project-router-BqAKGSaS.js} +1 -1
  71. package/web/dist/assets/{project-scope-context-0Z0nsheq.js → project-scope-context-B0yKt2yI.js} +1 -1
  72. package/web/dist/assets/{prompt-template-menu-uUjg9v98.js → prompt-template-menu-DpCrLDWG.js} +1 -1
  73. package/web/dist/assets/{queries-7W9tOZsg.js → queries-DoYRza8s.js} +1 -1
  74. package/web/dist/assets/{reference-chip-BqRpnpaI.js → reference-chip-Dd_YU2KX.js} +1 -1
  75. package/web/dist/assets/{repo-git-BZcRanYE.js → repo-git-BrkR6pTH.js} +1 -1
  76. package/web/dist/assets/{report-reader-BLlV3dPF.js → report-reader-BeZdoVhf.js} +1 -1
  77. package/web/dist/assets/{reports-C--EXqf1.js → reports-D93WfzdD.js} +1 -1
  78. package/web/dist/assets/{run-header-CJg8dyfz.js → run-header-FB4j_Fjm.js} +1 -1
  79. package/web/dist/assets/{skills-CHWVejdV.js → skills-BV3eF6mC.js} +1 -1
  80. package/web/dist/assets/{tab-link-XI9xWLwR.js → tab-link-CGzPcVvS.js} +1 -1
  81. package/web/dist/assets/{task-changes-DFm_EHnj.js → task-changes-f9ldtHuA.js} +1 -1
  82. package/web/dist/assets/{task-commits-BX-GVdXG.js → task-commits-CLjEhkFM.js} +1 -1
  83. package/web/dist/assets/{task-files-Dsn11PYu.js → task-files-BEKlg0dR.js} +1 -1
  84. package/web/dist/assets/{task-github-item-3N6jEijR.js → task-github-item-CbdPCKot.js} +1 -1
  85. package/web/dist/assets/{task-thread-VNPhkI8i.js → task-thread-BPSL3OMS.js} +1 -1
  86. package/web/dist/assets/{thread-state-D1XLo7ab.js → thread-state-ZdBez7Ij.js} +1 -1
  87. package/web/dist/assets/{use-desktop-DdcA0Atl.js → use-desktop-BwkqVHep.js} +1 -1
  88. package/web/dist/assets/{use-hand-to-agent-state-2tzEmCDo.js → use-hand-to-agent-state-BOD9cT6o.js} +1 -1
  89. package/web/dist/assets/{useInfiniteQuery-BmmIZbVY.js → useInfiniteQuery-DYAQvmMU.js} +1 -1
  90. package/web/dist/assets/useQuery-CnVG8NoC.js +1 -0
  91. package/web/dist/assets/{workflows-CqqdPBFr.js → workflows-Driy32Xn.js} +1 -1
  92. package/web/dist/assets/{ws-BvDSfSVH.js → ws-BXpZYApG.js} +1 -1
  93. package/web/dist/index.html +14 -14
  94. package/web/dist/live-worker.js +1 -1
  95. package/web/dist/assets/attention-B7icDSLh.js +0 -1
  96. package/web/dist/assets/useQuery-CBKC2lBX.js +0 -1
@@ -2988,6 +2988,12 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
2988
2988
  output: {
2989
2989
  generation: string;
2990
2990
  results: ({
2991
+ projectId: string;
2992
+ runId: string;
2993
+ type: "error" | "reset";
2994
+ status: 400 | 404 | 409 | 413 | 503;
2995
+ error: string;
2996
+ } | {
2991
2997
  projectId: string;
2992
2998
  runId: string;
2993
2999
  type: "batch";
@@ -3001,12 +3007,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
3001
3007
  cursor: string;
3002
3008
  afterSeq: number;
3003
3009
  hasMore: boolean;
3004
- } | {
3005
- projectId: string;
3006
- runId: string;
3007
- type: "error" | "reset";
3008
- status: 400 | 404 | 409 | 413 | 503;
3009
- error: string;
3010
3010
  })[];
3011
3011
  };
3012
3012
  outputFormat: "json";
@@ -4794,6 +4794,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
4794
4794
  } & {
4795
4795
  "/repo/commit/:sha": {
4796
4796
  $get: {
4797
+ output: string;
4798
+ outputFormat: "text";
4799
+ status: import("hono/utils/http-status").ContentfulStatusCode;
4800
+ input: {
4801
+ query: {
4802
+ structured?: string | undefined;
4803
+ };
4804
+ } & {
4805
+ param: {
4806
+ sha: string;
4807
+ };
4808
+ };
4809
+ } | {
4797
4810
  output: {
4798
4811
  error: string;
4799
4812
  code?: "invalid_input" | undefined;
@@ -4857,19 +4870,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
4857
4870
  sha: string;
4858
4871
  };
4859
4872
  };
4860
- } | {
4861
- output: string;
4862
- outputFormat: "text";
4863
- status: import("hono/utils/http-status").ContentfulStatusCode;
4864
- input: {
4865
- query: {
4866
- structured?: string | undefined;
4867
- };
4868
- } & {
4869
- param: {
4870
- sha: string;
4871
- };
4872
- };
4873
4873
  };
4874
4874
  };
4875
4875
  } & {
@@ -8547,7 +8547,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
8547
8547
  revision?: number | undefined;
8548
8548
  } | undefined;
8549
8549
  scope?: {
8550
- backend: "cgroup" | "groups";
8550
+ backend: "cgroup" | "groups" | "job";
8551
8551
  guarantee: "contained" | "scoped";
8552
8552
  } | undefined;
8553
8553
  }[];
@@ -18246,20 +18246,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18246
18246
  } & {
18247
18247
  "/runs/:id/handoff": {
18248
18248
  $get: {
18249
- output: {
18250
- error: string;
18251
- };
18252
- outputFormat: "json";
18253
- status: 404;
18249
+ output: string;
18250
+ outputFormat: "text";
18251
+ status: 200;
18254
18252
  input: {
18255
18253
  param: {
18256
18254
  id: string;
18257
18255
  };
18258
18256
  };
18259
18257
  } | {
18260
- output: string;
18261
- outputFormat: "text";
18262
- status: 200;
18258
+ output: {
18259
+ error: string;
18260
+ };
18261
+ outputFormat: "json";
18262
+ status: 404;
18263
18263
  input: {
18264
18264
  param: {
18265
18265
  id: string;
@@ -18297,20 +18297,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
18297
18297
  } & {
18298
18298
  "/runs/:id/diff": {
18299
18299
  $get: {
18300
- output: {
18301
- error: string;
18302
- };
18303
- outputFormat: "json";
18304
- status: 404 | 409;
18300
+ output: string;
18301
+ outputFormat: "text";
18302
+ status: import("hono/utils/http-status").ContentfulStatusCode;
18305
18303
  input: {
18306
18304
  param: {
18307
18305
  id: string;
18308
18306
  };
18309
18307
  };
18310
18308
  } | {
18311
- output: string;
18312
- outputFormat: "text";
18313
- status: import("hono/utils/http-status").ContentfulStatusCode;
18309
+ output: {
18310
+ error: string;
18311
+ };
18312
+ outputFormat: "json";
18313
+ status: 404 | 409;
18314
18314
  input: {
18315
18315
  param: {
18316
18316
  id: string;
@@ -20603,6 +20603,19 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
20603
20603
  } & {
20604
20604
  "/repo/commit/:sha": {
20605
20605
  $get: {
20606
+ output: string;
20607
+ outputFormat: "text";
20608
+ status: import("hono/utils/http-status").ContentfulStatusCode;
20609
+ input: {
20610
+ query: {
20611
+ structured?: string | undefined;
20612
+ };
20613
+ } & {
20614
+ param: {
20615
+ sha: string;
20616
+ };
20617
+ };
20618
+ } | {
20606
20619
  output: {
20607
20620
  error: string;
20608
20621
  code?: "invalid_input" | undefined;
@@ -20666,19 +20679,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
20666
20679
  sha: string;
20667
20680
  };
20668
20681
  };
20669
- } | {
20670
- output: string;
20671
- outputFormat: "text";
20672
- status: import("hono/utils/http-status").ContentfulStatusCode;
20673
- input: {
20674
- query: {
20675
- structured?: string | undefined;
20676
- };
20677
- } & {
20678
- param: {
20679
- sha: string;
20680
- };
20681
- };
20682
20682
  };
20683
20683
  };
20684
20684
  } & {
@@ -24356,7 +24356,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
24356
24356
  revision?: number | undefined;
24357
24357
  } | undefined;
24358
24358
  scope?: {
24359
- backend: "cgroup" | "groups";
24359
+ backend: "cgroup" | "groups" | "job";
24360
24360
  guarantee: "contained" | "scoped";
24361
24361
  } | undefined;
24362
24362
  }[];
@@ -34055,20 +34055,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34055
34055
  } & {
34056
34056
  "/runs/:id/handoff": {
34057
34057
  $get: {
34058
- output: {
34059
- error: string;
34060
- };
34061
- outputFormat: "json";
34062
- status: 404;
34058
+ output: string;
34059
+ outputFormat: "text";
34060
+ status: 200;
34063
34061
  input: {
34064
34062
  param: {
34065
34063
  id: string;
34066
34064
  };
34067
34065
  };
34068
34066
  } | {
34069
- output: string;
34070
- outputFormat: "text";
34071
- status: 200;
34067
+ output: {
34068
+ error: string;
34069
+ };
34070
+ outputFormat: "json";
34071
+ status: 404;
34072
34072
  input: {
34073
34073
  param: {
34074
34074
  id: string;
@@ -34106,20 +34106,20 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
34106
34106
  } & {
34107
34107
  "/runs/:id/diff": {
34108
34108
  $get: {
34109
- output: {
34110
- error: string;
34111
- };
34112
- outputFormat: "json";
34113
- status: 404 | 409;
34109
+ output: string;
34110
+ outputFormat: "text";
34111
+ status: import("hono/utils/http-status").ContentfulStatusCode;
34114
34112
  input: {
34115
34113
  param: {
34116
34114
  id: string;
34117
34115
  };
34118
34116
  };
34119
34117
  } | {
34120
- output: string;
34121
- outputFormat: "text";
34122
- status: import("hono/utils/http-status").ContentfulStatusCode;
34118
+ output: {
34119
+ error: string;
34120
+ };
34121
+ outputFormat: "json";
34122
+ status: 404 | 409;
34123
34123
  input: {
34124
34124
  param: {
34125
34125
  id: string;
@@ -7,12 +7,6 @@ export declare function createWorkspaceLiveRoutes(live: Parameters<typeof create
7
7
  output: {
8
8
  generation: string;
9
9
  results: ({
10
- projectId: string;
11
- runId: string;
12
- type: "error" | "reset";
13
- status: 400 | 404 | 409 | 413 | 503;
14
- error: string;
15
- } | {
16
10
  projectId: string;
17
11
  runId: string;
18
12
  type: "batch";
@@ -26,6 +20,12 @@ export declare function createWorkspaceLiveRoutes(live: Parameters<typeof create
26
20
  cursor: string;
27
21
  afterSeq: number;
28
22
  hasMore: boolean;
23
+ } | {
24
+ projectId: string;
25
+ runId: string;
26
+ type: "error" | "reset";
27
+ status: 400 | 404 | 409 | 413 | 503;
28
+ error: string;
29
29
  })[];
30
30
  };
31
31
  outputFormat: "json";
@@ -0,0 +1,28 @@
1
+ /** The Windows `job` backend: one named Job Object per worker (ADR 0032). A keeper process holds
2
+ * the job's only lasting handle with KILL_ON_JOB_CLOSE; the controller holds the keeper's stdin, so
3
+ * the worker's processes end with the controller (product decision 4). Each command starts inside
4
+ * the job at creation through `scripts/windows-worker-job.ps1 run`. */
5
+ import { type ChildProcess } from 'node:child_process';
6
+ /** The job's name in this session's namespace. */
7
+ export declare function workerJobName(workerId: string): string;
8
+ /** What the backend runs; tests replace it. */
9
+ export type JobHelper = {
10
+ /** Start the keeper that creates and holds `job`; it ends when its stdin closes. */
11
+ keep: (job: string) => ChildProcess;
12
+ /** A synchronous helper operation's stdout. */
13
+ call: (args: string[], timeoutMs: number) => string;
14
+ };
15
+ export declare const realJobHelper: JobHelper;
16
+ /** The argv that runs `file args` inside `job`. The command's own argv travels in a private file the
17
+ * helper reads and deletes, so the wrapper's command line stays short whatever the prompt. */
18
+ export declare function jobCommand(job: string, file: string, args: readonly string[]): [string, string[]];
19
+ /** Whether this host lets this user create a job and start a process inside it at creation. */
20
+ export declare function probeJobs(helper?: JobHelper): {
21
+ ok: true;
22
+ } | {
23
+ reason: string;
24
+ };
25
+ /** End every process in `job` and wait up to `waitMs`: true when none is left or the job is gone. */
26
+ export declare function terminateJob(job: string, waitMs: number, helper?: JobHelper): boolean;
27
+ /** Whether `job` holds no process (a job that is gone holds none). */
28
+ export declare function jobEmpty(job: string, helper?: JobHelper): boolean;
@@ -0,0 +1,65 @@
1
+ /** The Windows `job` backend: one named Job Object per worker (ADR 0032). A keeper process holds
2
+ * the job's only lasting handle with KILL_ON_JOB_CLOSE; the controller holds the keeper's stdin, so
3
+ * the worker's processes end with the controller (product decision 4). Each command starts inside
4
+ * the job at creation through `scripts/windows-worker-job.ps1 run`. */
5
+ import { execFileSync, spawn } from 'node:child_process';
6
+ import { randomUUID } from 'node:crypto';
7
+ import { writeFileSync } from 'node:fs';
8
+ import { tmpdir } from 'node:os';
9
+ import { join } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+ import { POWERSHELL, powershellEnv } from '../core/process-stat.js';
12
+ const script = fileURLToPath(new URL('../../scripts/windows-worker-job.ps1', import.meta.url));
13
+ /** The helper DLL the probe compiled, passed by path to every later call: a worker's environment
14
+ * has its own temp directory, where the cache is not. */
15
+ let compiled;
16
+ const powershellArgs = () => ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', script, ...(compiled ? ['-Assembly', compiled] : [])];
17
+ /** The job's name in this session's namespace. */
18
+ export function workerJobName(workerId) {
19
+ return `Local\\squawk-worker-${workerId}`;
20
+ }
21
+ export const realJobHelper = {
22
+ keep: job => {
23
+ const keeper = spawn(POWERSHELL, [...powershellArgs(), 'keep', job], { env: powershellEnv(), stdio: ['pipe', 'ignore', 'ignore'], windowsHide: true });
24
+ keeper.on('error', () => undefined);
25
+ keeper.unref();
26
+ // The pipe must not hold the controller's event loop open; its end is the job's end.
27
+ keeper.stdin?.unref?.();
28
+ return keeper;
29
+ },
30
+ call: (args, timeoutMs) => execFileSync(POWERSHELL, [...powershellArgs(), ...args], {
31
+ env: powershellEnv(), encoding: 'utf8', windowsHide: true, timeout: timeoutMs, maxBuffer: 64 * 1024,
32
+ }).trim(),
33
+ };
34
+ /** The argv that runs `file args` inside `job`. The command's own argv travels in a private file the
35
+ * helper reads and deletes, so the wrapper's command line stays short whatever the prompt. */
36
+ export function jobCommand(job, file, args) {
37
+ const argvFile = join(tmpdir(), `squawk-worker-argv-${randomUUID()}`);
38
+ writeFileSync(argvFile, [file, ...args].join('\0'), { encoding: 'utf8', mode: 0o600, flag: 'wx' });
39
+ return [POWERSHELL, [...powershellArgs(), 'run', job, argvFile]];
40
+ }
41
+ /** Whether this host lets this user create a job and start a process inside it at creation. */
42
+ export function probeJobs(helper = realJobHelper) {
43
+ try {
44
+ const [state, ...dll] = helper.call(['probe'], 60_000).split(' ');
45
+ if (state !== 'ok')
46
+ return { reason: 'the job probe did not confirm' };
47
+ if (dll.length)
48
+ compiled = dll.join(' ');
49
+ return { ok: true };
50
+ }
51
+ catch (error) {
52
+ return { reason: `cannot run a process inside a job (${error.message.split('\n')[0]})` };
53
+ }
54
+ }
55
+ /** End every process in `job` and wait up to `waitMs`: true when none is left or the job is gone. */
56
+ export function terminateJob(job, waitMs, helper = realJobHelper) {
57
+ const state = helper.call(['terminate', job, String(waitMs)], waitMs + 60_000);
58
+ return state === 'empty' || state === 'absent';
59
+ }
60
+ /** Whether `job` holds no process (a job that is gone holds none). */
61
+ export function jobEmpty(job, helper = realJobHelper) {
62
+ const state = helper.call(['query', job], 60_000);
63
+ return state === 'absent' || state === '0';
64
+ }
65
+ //# sourceMappingURL=job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../../src/worker-scope/job.ts"],"names":[],"mappings":"AAAA;;;uEAGuE;AACvE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEpE,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,GAAG,CA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AC,GAAW,EAAE,MAAc,EAAE,MAAM,GAAc,aAAa;IACzF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC/E,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,QAAQ,CAAC;AACjD,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,MAAM,GAAc,aAAa;IACrE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,GAAG,CAAC;AAC7C,CAAC"}
@@ -2,8 +2,9 @@
2
2
  * worker, and the record that names them. ADR 0032. */
3
3
  import { z } from 'zod';
4
4
  /** How a host contains a worker. `cgroup`: a private Linux cgroup, which every descendant inherits.
5
+ * `job`: a Windows Job Object, which every descendant joins at creation and cannot leave.
5
6
  * `groups`: the worker's own POSIX process groups, which a detached descendant can leave. */
6
- export type ScopeBackend = 'cgroup' | 'groups';
7
+ export type ScopeBackend = 'cgroup' | 'job' | 'groups';
7
8
  /** `contained`: stopping the scope ends every descendant. `scoped`: it ends the recorded groups
8
9
  * only; a descendant that left them survives. */
9
10
  export type ScopeGuarantee = 'contained' | 'scoped';
@@ -22,6 +23,7 @@ export declare const scopeRecordSchema: z.ZodObject<{
22
23
  startToken: z.ZodOptional<z.ZodString>;
23
24
  pgid: z.ZodOptional<z.ZodNumber>;
24
25
  }, z.core.$strict>>;
26
+ jobs: z.ZodDefault<z.ZodArray<z.ZodString>>;
25
27
  }, z.core.$strict>;
26
28
  export type ScopeRecord = z.infer<typeof scopeRecordSchema>;
27
29
  /** What a spawn site needs: the argv that runs a command inside the scope, and a report of the
@@ -1,7 +1,7 @@
1
1
  /** What a worker scope is: the set of OS containers that hold every process Squawk starts for one
2
2
  * worker, and the record that names them. ADR 0032. */
3
3
  import { z } from 'zod';
4
- export const GUARANTEE = { cgroup: 'contained', groups: 'scoped' };
4
+ export const GUARANTEE = { cgroup: 'contained', job: 'contained', groups: 'scoped' };
5
5
  /** Recorded groups kept per worker. A dead group is dropped before a new one is added. */
6
6
  export const SCOPE_GROUP_CAP = 64;
7
7
  /** Recorded cgroups kept per worker: one per controller cgroup it was spawned from. */
@@ -14,5 +14,7 @@ export const scopeRecordSchema = z.object({
14
14
  workerId: z.string().uuid(),
15
15
  cgroups: z.array(z.string().startsWith('/sys/fs/cgroup/').max(4096)).max(SCOPE_CGROUP_CAP),
16
16
  groups: z.array(recordedGroupSchema).max(SCOPE_GROUP_CAP),
17
+ /** Windows Job Object names; a record written before the `job` backend has none. */
18
+ jobs: z.array(z.string().regex(/^Local\\squawk-worker-[0-9a-f-]{36}$/)).max(1).default([]),
17
19
  }).strict();
18
20
  //# sourceMappingURL=scope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/worker-scope/scope.ts"],"names":[],"mappings":"AAAA;uDACuD;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,MAAM,CAAC,MAAM,SAAS,GAAmD,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAEnH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,uFAAuF;AACvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,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AAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAE3D;kFACkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC1F,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC;IACzD,oFAAoF;IACpF,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC3F,CAAC,CAAC,MAAM,EAAE,CAAC"}
@@ -1,9 +1,12 @@
1
1
  import type { RunRecord } from '../contract/index.js';
2
2
  import type { WorkerProcessRecord } from '../delegation/process-liveness.ts';
3
+ import { type JobHelper } from './job.ts';
3
4
  import { type ScopeBackend, type ScopeGuarantee, type ScopeRecord, type SpawnScope } from './scope.ts';
4
5
  export type HostScope = {
5
6
  backend: 'cgroup';
6
7
  base: string;
8
+ } | {
9
+ backend: 'job';
7
10
  } | {
8
11
  backend: 'groups';
9
12
  reason: string;
@@ -34,7 +37,10 @@ export type ScopeStop = {
34
37
  export declare class WorkerScopes {
35
38
  private readonly store;
36
39
  private readonly hostOf;
37
- constructor(store: ScopeStore, hostOf?: () => HostScope);
40
+ private readonly jobs;
41
+ /** This controller's job keepers, by worker: each holds its worker's job open while it runs. */
42
+ private readonly keepers;
43
+ constructor(store: ScopeStore, hostOf?: () => HostScope, jobs?: JobHelper);
38
44
  describe(): {
39
45
  backend: ScopeBackend;
40
46
  guarantee: ScopeGuarantee;
@@ -55,6 +61,12 @@ export declare class WorkerScopes {
55
61
  stop(workerId: string, timeoutMs: number): Promise<ScopeStop>;
56
62
  /** One kill-and-wait over the record as read now; `late` when the record gained entries meanwhile. */
57
63
  private stopRound;
64
+ /** Starts the keeper that creates and holds the worker's job, unless one of this controller runs.
65
+ * A command's `run` helper waits for the job to appear, so this need not wait for the keeper. */
66
+ private keeper;
67
+ /** Ends this controller's keeper for the worker, and waits (until `deadline`) for it to exit: its
68
+ * job closes with it once no process holds the job. */
69
+ private release;
58
70
  private read;
59
71
  /** The record's groups and the current execution's recorded processes, without duplicates. A
60
72
  * worker created before scopes has its session groups only in its execution record. */
@@ -5,18 +5,27 @@
5
5
  import { logPrefix } from '../home/display.js';
6
6
  import { cgroupCommand, cgroupPopulated, ensureCgroup, killCgroup, probeCgroups, removeCgroup, workerCgroupPath } from './cgroup.js';
7
7
  import { groupEntry, groupsStillStopping, killGroups, liveGroups } from './groups.js';
8
+ import { jobCommand, jobEmpty, probeJobs, realJobHelper, terminateJob, workerJobName } from './job.js';
8
9
  import { GUARANTEE, SCOPE_CGROUP_CAP, SCOPE_GROUP_CAP } from './scope.js';
9
10
  let host;
10
11
  /** This controller's backend: `cgroup` where a real probe proves delegation, else `groups`. */
11
12
  export function hostScope() {
12
13
  if (host)
13
14
  return host;
14
- const probe = process.platform === 'linux' ? probeCgroups() : { reason: `${process.platform} has no cgroups` };
15
- host = 'base' in probe ? { backend: 'cgroup', base: probe.base } : { backend: 'groups', reason: probe.reason };
15
+ host = detectHost();
16
16
  console.info(`${logPrefix()} worker scope: ${host.backend === 'cgroup' ? `cgroup (contained) under ${host.base}`
17
- : `process groups (scoped: a detached descendant can outlive destroy) — ${host.reason}`}`);
17
+ : host.backend === 'job' ? 'Windows Job Object (contained)'
18
+ : `process groups (scoped: a detached descendant can outlive destroy) — ${host.reason}`}`);
18
19
  return host;
19
20
  }
21
+ function detectHost() {
22
+ if (process.platform === 'win32') {
23
+ const probe = probeJobs();
24
+ return 'ok' in probe ? { backend: 'job' } : { backend: 'groups', reason: probe.reason };
25
+ }
26
+ const probe = process.platform === 'linux' ? probeCgroups() : { reason: `${process.platform} has no cgroups` };
27
+ return 'base' in probe ? { backend: 'cgroup', base: probe.base } : { backend: 'groups', reason: probe.reason };
28
+ }
20
29
  /** Tests pin the backend; `undefined` re-probes on next use. */
21
30
  export function setHostScope(value) { host = value; }
22
31
  export class WorkerScopeUnreadable extends Error {
@@ -28,9 +37,13 @@ const STOP_POLL_MS = 10;
28
37
  export class WorkerScopes {
29
38
  store;
30
39
  hostOf;
31
- constructor(store, hostOf = hostScope) {
40
+ jobs;
41
+ /** This controller's job keepers, by worker: each holds its worker's job open while it runs. */
42
+ keepers = new Map();
43
+ constructor(store, hostOf = hostScope, jobs = realJobHelper) {
32
44
  this.store = store;
33
45
  this.hostOf = hostOf;
46
+ this.jobs = jobs;
34
47
  }
35
48
  describe() {
36
49
  const { backend } = this.hostOf();
@@ -48,6 +61,12 @@ export class WorkerScopes {
48
61
  // Refused before anything runs: a full group record never has to end a started process.
49
62
  if (host.backend === 'groups' && liveGroups(this.read(workerId).groups).length >= SCOPE_GROUP_CAP)
50
63
  throw capacityError(workerId);
64
+ if (host.backend === 'job') {
65
+ const job = workerJobName(workerId);
66
+ this.update(workerId, record => record.jobs.includes(job) ? record : { ...record, jobs: [job] });
67
+ this.keeper(workerId, job);
68
+ return jobCommand(job, file, args);
69
+ }
51
70
  if (host.backend !== 'cgroup')
52
71
  return [file, [...args]];
53
72
  const path = workerCgroupPath(host.base, workerId);
@@ -88,7 +107,8 @@ export class WorkerScopes {
88
107
  catch {
89
108
  return false;
90
109
  }
91
- return !record.cgroups.some(path => cgroupPopulated(path)) && !liveGroups(this.groups(workerId, record)).length;
110
+ return record.jobs.every(job => jobEmpty(job, this.jobs)) && !record.cgroups.some(path => cgroupPopulated(path)) &&
111
+ !liveGroups(this.groups(workerId, record)).length;
92
112
  }
93
113
  /** After `kill`: whether nothing the worker owned still runs. A cgroup drops a task when it exits,
94
114
  * zombie or not; a group counts while its recorded leader runs (see `groupsStillStopping`). */
@@ -100,11 +120,14 @@ export class WorkerScopes {
100
120
  catch {
101
121
  return false;
102
122
  }
103
- return !record.cgroups.some(path => cgroupPopulated(path)) && !groupsStillStopping(this.groups(workerId, record)).length;
123
+ return record.jobs.every(job => jobEmpty(job, this.jobs)) && !record.cgroups.some(path => cgroupPopulated(path)) &&
124
+ !groupsStillStopping(this.groups(workerId, record)).length;
104
125
  }
105
126
  /** SIGKILL everything the worker owns, now, without waiting. */
106
127
  kill(workerId) {
107
128
  const record = this.read(workerId);
129
+ for (const job of record.jobs)
130
+ terminateJob(job, 0, this.jobs);
108
131
  for (const path of record.cgroups)
109
132
  killCgroup(path);
110
133
  killGroups(this.groups(workerId, record));
@@ -132,6 +155,13 @@ export class WorkerScopes {
132
155
  return { stopped: false, error: error.message };
133
156
  }
134
157
  killGroups(this.groups(workerId, record));
158
+ const jobs = [];
159
+ for (const job of record.jobs) {
160
+ if (terminateJob(job, Math.max(0, deadline - Date.now()), this.jobs))
161
+ await this.release(workerId, deadline);
162
+ else
163
+ jobs.push(job);
164
+ }
135
165
  const cgroups = [];
136
166
  for (const path of record.cgroups)
137
167
  if (!await removeCgroup(path, deadline))
@@ -144,23 +174,53 @@ export class WorkerScopes {
144
174
  // Merged into the record as it is now: an entry written while this stop waited is kept, and only
145
175
  // what this stop ended leaves it. Groups only the execution record names stay there.
146
176
  const removed = new Set(record.cgroups.filter(path => !cgroups.includes(path)));
177
+ const closed = new Set(record.jobs.filter(job => !jobs.includes(job)));
147
178
  const ended = new Set(record.groups.filter(group => !groups.some(left => key(left) === key(group))).map(key));
148
179
  let late = false;
149
180
  this.update(workerId, current => {
150
- late = current.cgroups.some(path => !record.cgroups.includes(path)) || current.groups.some(group => !record.groups.some(known => key(known) === key(group)));
151
- return { ...current, cgroups: current.cgroups.filter(path => !removed.has(path)), groups: current.groups.filter(group => !ended.has(key(group))) };
181
+ late = current.cgroups.some(path => !record.cgroups.includes(path)) || current.jobs.some(job => !record.jobs.includes(job)) ||
182
+ current.groups.some(group => !record.groups.some(known => key(known) === key(group)));
183
+ return { ...current, cgroups: current.cgroups.filter(path => !removed.has(path)), jobs: current.jobs.filter(job => !closed.has(job)),
184
+ groups: current.groups.filter(group => !ended.has(key(group))) };
152
185
  });
153
186
  if (late)
154
187
  return 'late';
155
- if (!cgroups.length && !groups.length)
188
+ if (!jobs.length && !cgroups.length && !groups.length)
156
189
  return { stopped: true };
157
- return { stopped: false, error: `worker processes did not stop within ${Math.round(timeoutMs / 1000)}s: ${[...cgroups.map(path => `cgroup ${path}`), ...groups.map(group => `process group ${group.pgid}`)].join(', ')}` };
190
+ return { stopped: false, error: `worker processes did not stop within ${Math.round(timeoutMs / 1000)}s: ${[...jobs.map(job => `job ${job}`), ...cgroups.map(path => `cgroup ${path}`), ...groups.map(group => `process group ${group.pgid}`)].join(', ')}` };
191
+ }
192
+ /** Starts the keeper that creates and holds the worker's job, unless one of this controller runs.
193
+ * A command's `run` helper waits for the job to appear, so this need not wait for the keeper. */
194
+ keeper(workerId, job) {
195
+ const running = this.keepers.get(workerId);
196
+ if (running && running.exitCode === null && running.signalCode === null)
197
+ return;
198
+ const keeper = this.jobs.keep(job);
199
+ this.keepers.set(workerId, keeper);
200
+ keeper.once('exit', () => { if (this.keepers.get(workerId) === keeper)
201
+ this.keepers.delete(workerId); });
202
+ }
203
+ /** Ends this controller's keeper for the worker, and waits (until `deadline`) for it to exit: its
204
+ * job closes with it once no process holds the job. */
205
+ async release(workerId, deadline) {
206
+ const keeper = this.keepers.get(workerId);
207
+ this.keepers.delete(workerId);
208
+ if (!keeper)
209
+ return;
210
+ const exited = new Promise(resolve => {
211
+ if (keeper.exitCode !== null || keeper.signalCode !== null)
212
+ resolve();
213
+ else
214
+ keeper.once('exit', () => resolve());
215
+ });
216
+ keeper.stdin?.end();
217
+ await Promise.race([exited, new Promise(resolve => setTimeout(resolve, Math.max(0, deadline - Date.now())).unref?.())]);
158
218
  }
159
219
  read(workerId) {
160
220
  const record = this.store.readWorkerScope(workerId);
161
221
  if (record === 'unknown')
162
222
  throw new WorkerScopeUnreadable();
163
- return record === 'absent' ? { workerId, cgroups: [], groups: [] } : record;
223
+ return record === 'absent' ? { workerId, cgroups: [], groups: [], jobs: [] } : record;
164
224
  }
165
225
  /** The record's groups and the current execution's recorded processes, without duplicates. A
166
226
  * worker created before scopes has its session groups only in its execution record. */