@hearsay-tools/squawk 0.18.0-dev.8335 → 0.18.0-dev.8337

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 (46) hide show
  1. package/dist/automations/tools.d.ts +8 -8
  2. package/dist/core/os-cgroup.d.ts +43 -0
  3. package/dist/core/os-cgroup.js +220 -0
  4. package/dist/core/os-cgroup.js.map +1 -0
  5. package/dist/core/os-win-job.d.ts +30 -0
  6. package/dist/core/os-win-job.js +80 -0
  7. package/dist/core/os-win-job.js.map +1 -0
  8. package/dist/core/session-containment.d.ts +78 -0
  9. package/dist/core/session-containment.js +247 -0
  10. package/dist/core/session-containment.js.map +1 -0
  11. package/dist/core/session-process.d.ts +10 -0
  12. package/dist/core/session-process.js +109 -22
  13. package/dist/core/session-process.js.map +1 -1
  14. package/dist/delegation/routes.d.ts +10 -10
  15. package/dist/delegation/transport.d.ts +14 -14
  16. package/dist/jobs/cli.js +6 -2
  17. package/dist/jobs/cli.js.map +1 -1
  18. package/dist/jobs/job.d.ts +6 -0
  19. package/dist/jobs/job.js +80 -2
  20. package/dist/jobs/job.js.map +1 -1
  21. package/dist/plugin/runtime.d.ts +1 -1
  22. package/dist/plugin/runtime.js +1 -1
  23. package/dist/plugin/runtime.js.map +1 -1
  24. package/dist/runners/opencode/opencode-http.d.ts +1 -0
  25. package/dist/runners/opencode/opencode-http.js +7 -0
  26. package/dist/runners/opencode/opencode-http.js.map +1 -1
  27. package/dist/runners/opencode/opencode-server-runner.js +3 -9
  28. package/dist/runners/opencode/opencode-server-runner.js.map +1 -1
  29. package/dist/runs/run-decode.d.ts +72 -72
  30. package/dist/server/live-routes.d.ts +6 -6
  31. package/dist/server/server.d.ts +1424 -1424
  32. package/dist/server/workspace-live-routes.d.ts +6 -6
  33. package/dist/worker-scope/cgroup.d.ts +2 -36
  34. package/dist/worker-scope/cgroup.js +5 -161
  35. package/dist/worker-scope/cgroup.js.map +1 -1
  36. package/dist/worker-scope/job.d.ts +1 -22
  37. package/dist/worker-scope/job.js +1 -56
  38. package/dist/worker-scope/job.js.map +1 -1
  39. package/dist/worker-scope/scope.d.ts +5 -1
  40. package/dist/worker-scope/worker-scopes.js +36 -18
  41. package/dist/worker-scope/worker-scopes.js.map +1 -1
  42. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  43. package/dist/workflows/run/wait-engine.d.ts +72 -72
  44. package/package.json +4 -4
  45. package/scripts/windows-worker-job.cs +67 -32
  46. package/scripts/windows-worker-job.ps1 +11 -4
@@ -237,6 +237,30 @@ export declare class WaitEngine {
237
237
  deadline: string;
238
238
  seconds: number;
239
239
  note?: string | undefined;
240
+ } | {
241
+ id: string;
242
+ source: "agent" | "cezar";
243
+ via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
244
+ registeredAt: string;
245
+ phase: "cancelled" | "delivered" | "open" | "resolved";
246
+ resolvedAt?: string | undefined;
247
+ deliveredAt?: string | undefined;
248
+ cancelledAt?: string | undefined;
249
+ turnId: string;
250
+ kind: "process";
251
+ deadline: string;
252
+ timeoutSeconds: number;
253
+ pid: number;
254
+ startToken?: string | undefined;
255
+ exitFile?: string | undefined;
256
+ note?: string | undefined;
257
+ result?: {
258
+ outcome: "deadline" | "error" | "exit_file" | "exited";
259
+ observedAt: string;
260
+ exitCode?: number | undefined;
261
+ exitFileNote?: "not-an-exit-code" | undefined;
262
+ diagnostic?: string | undefined;
263
+ } | undefined;
240
264
  } | {
241
265
  id: string;
242
266
  source: "agent" | "cezar";
@@ -298,30 +322,6 @@ export declare class WaitEngine {
298
322
  reason: "outcome" | "timeout";
299
323
  } | undefined;
300
324
  wakeInputId?: string | undefined;
301
- } | {
302
- id: string;
303
- source: "agent" | "cezar";
304
- via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
305
- registeredAt: string;
306
- phase: "cancelled" | "delivered" | "open" | "resolved";
307
- resolvedAt?: string | undefined;
308
- deliveredAt?: string | undefined;
309
- cancelledAt?: string | undefined;
310
- turnId: string;
311
- kind: "process";
312
- deadline: string;
313
- timeoutSeconds: number;
314
- pid: number;
315
- startToken?: string | undefined;
316
- exitFile?: string | undefined;
317
- note?: string | undefined;
318
- result?: {
319
- outcome: "deadline" | "error" | "exit_file" | "exited";
320
- observedAt: string;
321
- exitCode?: number | undefined;
322
- exitFileNote?: "not-an-exit-code" | undefined;
323
- diagnostic?: string | undefined;
324
- } | undefined;
325
325
  } | {
326
326
  id: string;
327
327
  source: "agent" | "cezar";
@@ -449,6 +449,30 @@ export declare class WaitEngine {
449
449
  deadline: string;
450
450
  seconds: number;
451
451
  note?: string | undefined;
452
+ } | {
453
+ id: string;
454
+ source: "agent" | "cezar";
455
+ via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
456
+ registeredAt: string;
457
+ phase: "cancelled" | "delivered" | "open" | "resolved";
458
+ resolvedAt?: string | undefined;
459
+ deliveredAt?: string | undefined;
460
+ cancelledAt?: string | undefined;
461
+ turnId: string;
462
+ kind: "process";
463
+ deadline: string;
464
+ timeoutSeconds: number;
465
+ pid: number;
466
+ startToken?: string | undefined;
467
+ exitFile?: string | undefined;
468
+ note?: string | undefined;
469
+ result?: {
470
+ outcome: "deadline" | "error" | "exit_file" | "exited";
471
+ observedAt: string;
472
+ exitCode?: number | undefined;
473
+ exitFileNote?: "not-an-exit-code" | undefined;
474
+ diagnostic?: string | undefined;
475
+ } | undefined;
452
476
  } | {
453
477
  id: string;
454
478
  source: "agent" | "cezar";
@@ -510,30 +534,6 @@ export declare class WaitEngine {
510
534
  reason: "outcome" | "timeout";
511
535
  } | undefined;
512
536
  wakeInputId?: string | undefined;
513
- } | {
514
- id: string;
515
- source: "agent" | "cezar";
516
- via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
517
- registeredAt: string;
518
- phase: "cancelled" | "delivered" | "open" | "resolved";
519
- resolvedAt?: string | undefined;
520
- deliveredAt?: string | undefined;
521
- cancelledAt?: string | undefined;
522
- turnId: string;
523
- kind: "process";
524
- deadline: string;
525
- timeoutSeconds: number;
526
- pid: number;
527
- startToken?: string | undefined;
528
- exitFile?: string | undefined;
529
- note?: string | undefined;
530
- result?: {
531
- outcome: "deadline" | "error" | "exit_file" | "exited";
532
- observedAt: string;
533
- exitCode?: number | undefined;
534
- exitFileNote?: "not-an-exit-code" | undefined;
535
- diagnostic?: string | undefined;
536
- } | undefined;
537
537
  } | {
538
538
  id: string;
539
539
  source: "agent" | "cezar";
@@ -660,6 +660,30 @@ export declare class WaitEngine {
660
660
  deadline: string;
661
661
  seconds: number;
662
662
  note?: string | undefined;
663
+ } | {
664
+ id: string;
665
+ source: "agent" | "cezar";
666
+ via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
667
+ registeredAt: string;
668
+ phase: "cancelled" | "delivered" | "open" | "resolved";
669
+ resolvedAt?: string | undefined;
670
+ deliveredAt?: string | undefined;
671
+ cancelledAt?: string | undefined;
672
+ turnId: string;
673
+ kind: "process";
674
+ deadline: string;
675
+ timeoutSeconds: number;
676
+ pid: number;
677
+ startToken?: string | undefined;
678
+ exitFile?: string | undefined;
679
+ note?: string | undefined;
680
+ result?: {
681
+ outcome: "deadline" | "error" | "exit_file" | "exited";
682
+ observedAt: string;
683
+ exitCode?: number | undefined;
684
+ exitFileNote?: "not-an-exit-code" | undefined;
685
+ diagnostic?: string | undefined;
686
+ } | undefined;
663
687
  } | {
664
688
  id: string;
665
689
  source: "agent" | "cezar";
@@ -721,30 +745,6 @@ export declare class WaitEngine {
721
745
  reason: "outcome" | "timeout";
722
746
  } | undefined;
723
747
  wakeInputId?: string | undefined;
724
- } | {
725
- id: string;
726
- source: "agent" | "cezar";
727
- via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
728
- registeredAt: string;
729
- phase: "cancelled" | "delivered" | "open" | "resolved";
730
- resolvedAt?: string | undefined;
731
- deliveredAt?: string | undefined;
732
- cancelledAt?: string | undefined;
733
- turnId: string;
734
- kind: "process";
735
- deadline: string;
736
- timeoutSeconds: number;
737
- pid: number;
738
- startToken?: string | undefined;
739
- exitFile?: string | undefined;
740
- note?: string | undefined;
741
- result?: {
742
- outcome: "deadline" | "error" | "exit_file" | "exited";
743
- observedAt: string;
744
- exitCode?: number | undefined;
745
- exitFileNote?: "not-an-exit-code" | undefined;
746
- diagnostic?: string | undefined;
747
- } | undefined;
748
748
  } | {
749
749
  id: string;
750
750
  source: "agent" | "cezar";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hearsay-tools/squawk",
3
- "version": "0.18.0-dev.8335",
3
+ "version": "0.18.0-dev.8337",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -68,8 +68,8 @@
68
68
  "devDependencies": {
69
69
  "@babel/parser": "^8.0.8",
70
70
  "@babel/types": "^8.0.8",
71
- "@open-mercato/cezar-api-client": "0.18.0-dev.8335",
72
- "@open-mercato/cezar-contract": "0.18.0-dev.8335",
71
+ "@open-mercato/cezar-api-client": "0.18.0-dev.8337",
72
+ "@open-mercato/cezar-contract": "0.18.0-dev.8337",
73
73
  "@types/node": "^24.19.1",
74
74
  "@types/ws": "^8.18.1",
75
75
  "esbuild": "^0.28.1",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "de0af9262f5bc743b57595bed46a8eead1477eeb"
89
+ "gitHead": "5925a526c8894c023f59c8aae934e825d5214050"
90
90
  }
@@ -1,9 +1,10 @@
1
- // Windows worker scope (ADR 0032): one named Job Object per worker. A keeper holds the only lasting
2
- // handle, with KILL_ON_JOB_CLOSE and no breakaway, so the job and every process in it end when the
3
- // keeper ends, which it does when its controller closes its stdin. Each command starts inside the
4
- // job at creation (PROC_THREAD_ATTRIBUTE_JOB_LIST), never assigned after it ran. Loaded by the
5
- // adjacent PowerShell entry point; shipped with the CLI.
1
+ // Windows worker scope (ADR 0032) and session containment (hearsay-tools/squawk#1345).
2
+ // Worker jobs use KILL_ON_JOB_CLOSE and disallow breakaway. Session jobs allow breakaway
3
+ // (so `hsq job start` breaks out of the session while staying inside any parent worker job)
4
+ // and omit KILL_ON_JOB_CLOSE so normal session exit closes the keeper without killing detached
5
+ // survivors. Loaded by the adjacent PowerShell entry point; shipped with the CLI.
6
6
  using System;
7
+ using System.Collections.Generic;
7
8
  using System.ComponentModel;
8
9
  using System.Runtime.InteropServices;
9
10
  using System.Text;
@@ -11,11 +12,12 @@ using System.Threading;
11
12
 
12
13
  public static class SquawkWorkerJob {
13
14
  const uint JobAssignProcess = 0x1, JobQuery = 0x4, JobTerminate = 0x8;
14
- const uint KillOnJobClose = 0x2000;
15
+ const uint BreakawayOk = 0x0800, KillOnJobClose = 0x2000;
15
16
  const int ExtendedLimitInformation = 9, BasicAccountingInformation = 1;
16
17
  const uint ExtendedStartupInfoPresent = 0x80000, UseStdHandles = 0x100;
18
+ const uint CreateNewProcessGroup = 0x00000200, DetachedProcess = 0x00000008, CreateBreakawayFromJob = 0x01000000;
17
19
  static readonly IntPtr JobListAttribute = (IntPtr)0x2000D;
18
- const int NotFound = 2;
20
+ const int NotFound = 2, AccessDenied = 5;
19
21
 
20
22
  [StructLayout(LayoutKind.Sequential)] struct BasicLimit {
21
23
  public long PerProcessUserTimeLimit, PerJobUserTimeLimit; public uint LimitFlags;
@@ -56,52 +58,85 @@ public static class SquawkWorkerJob {
56
58
 
57
59
  static Win32Exception Last(string what) { return new Win32Exception(Marshal.GetLastWin32Error(), what); }
58
60
 
59
- // A job whose last handle closes kills every process in it; no process may break away.
60
- static IntPtr CreateJob(string name) {
61
+ static IntPtr CreateJob(string name, uint limitFlags) {
61
62
  IntPtr job = CreateJobObjectW(IntPtr.Zero, name);
62
63
  if (job == IntPtr.Zero) throw Last("CreateJobObject");
63
64
  if (name != null && Marshal.GetLastWin32Error() == 183) { CloseHandle(job); throw new InvalidOperationException("worker job already exists: " + name); }
64
- var limit = new ExtendedLimit(); limit.Basic.LimitFlags = KillOnJobClose;
65
+ var limit = new ExtendedLimit(); limit.Basic.LimitFlags = limitFlags;
65
66
  if (!SetInformationJobObject(job, ExtendedLimitInformation, ref limit, Marshal.SizeOf(typeof(ExtendedLimit)))) { CloseHandle(job); throw Last("SetInformationJobObject"); }
66
67
  return job;
67
68
  }
68
69
 
69
- /** Creates the worker's job, reports `ready`, and holds it until stdin ends. */
70
+ /** Creates the worker's job (KILL_ON_JOB_CLOSE, no breakaway), reports `ready`, and holds it until stdin ends. */
70
71
  public static void Keep(string name) {
71
- IntPtr job = CreateJob(name);
72
+ IntPtr job = CreateJob(name, KillOnJobClose);
72
73
  Console.Out.WriteLine("ready"); Console.Out.Flush();
73
74
  try { Console.In.ReadToEnd(); } finally { CloseHandle(job); }
74
75
  }
75
76
 
76
- /** Starts `argv` inside the named job with this process's standard handles and returns its exit
77
- * code. The job is opened, never created: a keeper that is not there yet is waited for, and a
78
- * command whose job never appears does not run. */
79
- public static int Run(string name, string[] argv, int waitMs) {
80
- IntPtr job = IntPtr.Zero;
77
+ /** Creates a session job (BREAKAWAY_OK, no KILL_ON_JOB_CLOSE), reports `ready`, and holds it until stdin ends. */
78
+ public static void KeepSession(string name) {
79
+ IntPtr job = CreateJob(name, BreakawayOk);
80
+ Console.Out.WriteLine("ready"); Console.Out.Flush();
81
+ try { Console.In.ReadToEnd(); } finally { CloseHandle(job); }
82
+ }
83
+
84
+ /** Starts `argv` inside one or more comma-separated named jobs with this process's standard
85
+ * handles and returns its exit code. Each job is opened, never created: a keeper that is not
86
+ * there yet is waited for, and a command whose job never appears does not run. */
87
+ public static int Run(string names, string[] argv, int waitMs) {
88
+ string[] parts = names.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
89
+ var handles = new List<IntPtr>(parts.Length);
81
90
  var deadline = DateTime.UtcNow.AddMilliseconds(waitMs);
82
- while ((job = OpenJobObjectW(JobAssignProcess | JobQuery, false, name)) == IntPtr.Zero) {
83
- if (Marshal.GetLastWin32Error() != NotFound || DateTime.UtcNow >= deadline) throw Last("OpenJobObject " + name);
84
- Thread.Sleep(20);
91
+ try {
92
+ foreach (string name in parts) {
93
+ IntPtr job;
94
+ while ((job = OpenJobObjectW(JobAssignProcess | JobQuery, false, name)) == IntPtr.Zero) {
95
+ if (Marshal.GetLastWin32Error() != NotFound || DateTime.UtcNow >= deadline) throw Last("OpenJobObject " + name);
96
+ Thread.Sleep(20);
97
+ }
98
+ handles.Add(job);
99
+ }
100
+ ProcessInformation info = StartIn(handles.ToArray(), argv);
101
+ foreach (IntPtr job in handles) CloseHandle(job);
102
+ handles.Clear();
103
+ try {
104
+ WaitForSingleObject(info.Process, 0xFFFFFFFF);
105
+ uint code; GetExitCodeProcess(info.Process, out code);
106
+ return (int)code;
107
+ } finally { CloseHandle(info.Process); }
108
+ } finally {
109
+ foreach (IntPtr job in handles) CloseHandle(job);
85
110
  }
111
+ }
112
+
113
+ /** Starts `argv` detached with CREATE_BREAKAWAY_FROM_JOB and prints its PID. If the immediate
114
+ * job disallows breakaway (e.g. a worker check step outside a session job), falls back without
115
+ * the breakaway flag so the process stays inside the worker job. */
116
+ public static int Breakaway(string[] argv) {
117
+ var startup = new StartupInfoEx();
118
+ startup.Info.Size = Marshal.SizeOf(typeof(StartupInfoEx));
119
+ uint flags = CreateNewProcessGroup | DetachedProcess;
86
120
  ProcessInformation info;
87
- try { info = StartIn(job, argv); } finally { CloseHandle(job); }
88
- try {
89
- WaitForSingleObject(info.Process, 0xFFFFFFFF);
90
- uint code; GetExitCodeProcess(info.Process, out code);
91
- return (int)code;
92
- } finally { CloseHandle(info.Process); }
121
+ if (!CreateProcessW(null, new StringBuilder(CommandLine(argv)), IntPtr.Zero, IntPtr.Zero, false, flags | CreateBreakawayFromJob, IntPtr.Zero, null, ref startup, out info)) {
122
+ if (Marshal.GetLastWin32Error() != AccessDenied) throw Last("CreateProcess breakaway");
123
+ if (!CreateProcessW(null, new StringBuilder(CommandLine(argv)), IntPtr.Zero, IntPtr.Zero, false, flags, IntPtr.Zero, null, ref startup, out info)) throw Last("CreateProcess");
124
+ }
125
+ CloseHandle(info.Thread);
126
+ CloseHandle(info.Process);
127
+ return info.ProcessId;
93
128
  }
94
129
 
95
- static ProcessInformation StartIn(IntPtr job, string[] argv) {
130
+ static ProcessInformation StartIn(IntPtr[] jobHandles, string[] argv) {
96
131
  IntPtr size = IntPtr.Zero;
97
132
  InitializeProcThreadAttributeList(IntPtr.Zero, 1, 0, ref size);
98
133
  IntPtr list = Marshal.AllocHGlobal(size);
99
- IntPtr jobs = Marshal.AllocHGlobal(IntPtr.Size);
134
+ IntPtr jobs = Marshal.AllocHGlobal(IntPtr.Size * jobHandles.Length);
100
135
  try {
101
136
  if (!InitializeProcThreadAttributeList(list, 1, 0, ref size)) throw Last("InitializeProcThreadAttributeList");
102
137
  try {
103
- Marshal.WriteIntPtr(jobs, job);
104
- if (!UpdateProcThreadAttribute(list, 0, JobListAttribute, jobs, (IntPtr)IntPtr.Size, IntPtr.Zero, IntPtr.Zero)) throw Last("UpdateProcThreadAttribute");
138
+ for (int i = 0; i < jobHandles.Length; i++) Marshal.WriteIntPtr(jobs, i * IntPtr.Size, jobHandles[i]);
139
+ if (!UpdateProcThreadAttribute(list, 0, JobListAttribute, jobs, (IntPtr)(IntPtr.Size * jobHandles.Length), IntPtr.Zero, IntPtr.Zero)) throw Last("UpdateProcThreadAttribute");
105
140
  var startup = new StartupInfoEx(); startup.Info.Size = Marshal.SizeOf(typeof(StartupInfoEx));
106
141
  startup.Info.Flags = (int)UseStdHandles;
107
142
  startup.Info.StdInput = GetStdHandle(-10); startup.Info.StdOutput = GetStdHandle(-11); startup.Info.StdError = GetStdHandle(-12);
@@ -141,9 +176,9 @@ public static class SquawkWorkerJob {
141
176
 
142
177
  /** Whether this host lets this user create a job, start a process inside it at creation, and end it. */
143
178
  public static string Probe() {
144
- IntPtr job = CreateJob(null);
179
+ IntPtr job = CreateJob(null, KillOnJobClose);
145
180
  try {
146
- var info = StartIn(job, new[] { Environment.GetEnvironmentVariable("ComSpec") ?? "cmd.exe", "/d", "/c", "exit 0" });
181
+ var info = StartIn(new[] { job }, new[] { Environment.GetEnvironmentVariable("ComSpec") ?? "cmd.exe", "/d", "/c", "exit 0" });
147
182
  WaitForSingleObject(info.Process, 10000); CloseHandle(info.Process);
148
183
  if (!TerminateJobObject(job, 1)) throw Last("TerminateJobObject");
149
184
  return "ok";
@@ -1,7 +1,8 @@
1
- # Windows worker scope (ADR 0032). Usage: [-Assembly <dll>] <mode> ...; modes: keep <job>,
2
- # run <job> <argv file>, terminate <job> <ms>, query <job>, probe (prints `ok <dll>`). Only .NET
3
- # calls, no cmdlets: `run` inherits the agent's environment (its own TEMP, a PowerShell 7
4
- # PSModulePath), so it loads the DLL the controller's probe compiled, by the path it is given; only
1
+ # Windows worker scope (ADR 0032) and session containment (hearsay-tools/squawk#1345).
2
+ # Usage: [-Assembly <dll>] <mode> ...; modes: keep <job>, keep-session <job>, run <job[,job]> <argv file>,
3
+ # breakaway <argv file>, terminate <job> <ms>, query <job>, probe (prints `ok <dll>`). Only .NET
4
+ # calls, no cmdlets: `run` and `breakaway` inherit the agent's environment (its own TEMP, a PowerShell 7
5
+ # PSModulePath), so they load the DLL the controller's probe compiled, by the path given; only
5
6
  # the probe, with a clean environment, compiles.
6
7
  $ErrorActionPreference = 'Stop'
7
8
  $assembly = $null
@@ -21,12 +22,18 @@ if (-not [IO.File]::Exists($assembly)) {
21
22
  [void][Reflection.Assembly]::LoadFrom($assembly)
22
23
  switch ($args[0]) {
23
24
  'keep' { [SquawkWorkerJob]::Keep($args[1]) }
25
+ 'keep-session' { [SquawkWorkerJob]::KeepSession($args[1]) }
24
26
  'run' {
25
27
  # The argv travels in a private file, NUL-separated, so its length is the command's own.
26
28
  $argv = [IO.File]::ReadAllText($args[2], [Text.Encoding]::UTF8).Split([char]0)
27
29
  [IO.File]::Delete($args[2])
28
30
  [Environment]::Exit([SquawkWorkerJob]::Run($args[1], $argv, 30000))
29
31
  }
32
+ 'breakaway' {
33
+ $argv = [IO.File]::ReadAllText($args[1], [Text.Encoding]::UTF8).Split([char]0)
34
+ [IO.File]::Delete($args[1])
35
+ [Console]::Out.WriteLine([SquawkWorkerJob]::Breakaway($argv))
36
+ }
30
37
  'terminate' { [SquawkWorkerJob]::Terminate($args[1], [int]$args[2]) }
31
38
  'query' { [SquawkWorkerJob]::Query($args[1]) }
32
39
  'probe' { "$([SquawkWorkerJob]::Probe()) $assembly" }