@usine/executor 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +115 -37
  2. package/dist/child-command.d.ts +4 -7
  3. package/dist/child-command.d.ts.map +1 -1
  4. package/dist/child-command.js +6 -12
  5. package/dist/child-command.js.map +1 -1
  6. package/dist/claude-login-lock.d.ts +8 -0
  7. package/dist/claude-login-lock.d.ts.map +1 -0
  8. package/dist/claude-login-lock.js +9 -0
  9. package/dist/claude-login-lock.js.map +1 -0
  10. package/dist/credential-environment.d.ts +20 -0
  11. package/dist/credential-environment.d.ts.map +1 -0
  12. package/dist/credential-environment.js +20 -0
  13. package/dist/credential-environment.js.map +1 -0
  14. package/dist/durable-session.d.ts +63 -0
  15. package/dist/durable-session.d.ts.map +1 -0
  16. package/dist/durable-session.js +491 -0
  17. package/dist/durable-session.js.map +1 -0
  18. package/dist/exe-dev/commands.d.ts +23 -13
  19. package/dist/exe-dev/commands.d.ts.map +1 -1
  20. package/dist/exe-dev/commands.js +11 -57
  21. package/dist/exe-dev/commands.js.map +1 -1
  22. package/dist/exe-dev/exe-dev.d.ts +9 -3
  23. package/dist/exe-dev/exe-dev.d.ts.map +1 -1
  24. package/dist/exe-dev/exe-dev.js +53 -128
  25. package/dist/exe-dev/exe-dev.js.map +1 -1
  26. package/dist/exe-dev/grants.d.ts.map +1 -1
  27. package/dist/exe-dev/grants.js +35 -15
  28. package/dist/exe-dev/grants.js.map +1 -1
  29. package/dist/exe-dev/model.d.ts +15 -19
  30. package/dist/exe-dev/model.d.ts.map +1 -1
  31. package/dist/exe-dev/model.js +9 -12
  32. package/dist/exe-dev/model.js.map +1 -1
  33. package/dist/exe-dev/preflight.d.ts +8 -4
  34. package/dist/exe-dev/preflight.d.ts.map +1 -1
  35. package/dist/exe-dev/preflight.js +23 -33
  36. package/dist/exe-dev/preflight.js.map +1 -1
  37. package/dist/executor.d.ts +140 -41
  38. package/dist/executor.d.ts.map +1 -1
  39. package/dist/executor.js +90 -19
  40. package/dist/executor.js.map +1 -1
  41. package/dist/guard.d.ts +57 -7
  42. package/dist/guard.d.ts.map +1 -1
  43. package/dist/guard.js +273 -59
  44. package/dist/guard.js.map +1 -1
  45. package/dist/harness-preflight.d.ts +25 -4
  46. package/dist/harness-preflight.d.ts.map +1 -1
  47. package/dist/harness-preflight.js +25 -29
  48. package/dist/harness-preflight.js.map +1 -1
  49. package/dist/keyed-lock.d.ts +2 -3
  50. package/dist/keyed-lock.d.ts.map +1 -1
  51. package/dist/keyed-lock.js +2 -3
  52. package/dist/keyed-lock.js.map +1 -1
  53. package/dist/leftovers.d.ts +9 -0
  54. package/dist/leftovers.d.ts.map +1 -0
  55. package/dist/leftovers.js +14 -0
  56. package/dist/leftovers.js.map +1 -0
  57. package/dist/local/credentials.d.ts +21 -0
  58. package/dist/local/credentials.d.ts.map +1 -0
  59. package/dist/local/credentials.js +39 -0
  60. package/dist/local/credentials.js.map +1 -0
  61. package/dist/local/leftovers.d.ts +8 -0
  62. package/dist/local/leftovers.d.ts.map +1 -0
  63. package/dist/local/leftovers.js +23 -0
  64. package/dist/local/leftovers.js.map +1 -0
  65. package/dist/local/local.d.ts +16 -10
  66. package/dist/local/local.d.ts.map +1 -1
  67. package/dist/local/local.js +163 -129
  68. package/dist/local/local.js.map +1 -1
  69. package/dist/memory-preflight.d.ts +25 -0
  70. package/dist/memory-preflight.d.ts.map +1 -0
  71. package/dist/memory-preflight.js +83 -0
  72. package/dist/memory-preflight.js.map +1 -0
  73. package/dist/pre-push-hook.d.ts +20 -0
  74. package/dist/pre-push-hook.d.ts.map +1 -0
  75. package/dist/pre-push-hook.js +33 -0
  76. package/dist/pre-push-hook.js.map +1 -0
  77. package/dist/prepared-attempt.d.ts +33 -3
  78. package/dist/prepared-attempt.d.ts.map +1 -1
  79. package/dist/prepared-attempt.js +109 -31
  80. package/dist/prepared-attempt.js.map +1 -1
  81. package/dist/provision.d.ts +77 -14
  82. package/dist/provision.d.ts.map +1 -1
  83. package/dist/provision.js +357 -55
  84. package/dist/provision.js.map +1 -1
  85. package/dist/remote/commands.d.ts +51 -0
  86. package/dist/remote/commands.d.ts.map +1 -0
  87. package/dist/remote/commands.js +94 -0
  88. package/dist/remote/commands.js.map +1 -0
  89. package/dist/remote/leftovers.d.ts +14 -0
  90. package/dist/remote/leftovers.d.ts.map +1 -0
  91. package/dist/remote/leftovers.js +22 -0
  92. package/dist/remote/leftovers.js.map +1 -0
  93. package/dist/remote/liveness.d.ts +33 -0
  94. package/dist/remote/liveness.d.ts.map +1 -0
  95. package/dist/remote/liveness.js +194 -0
  96. package/dist/remote/liveness.js.map +1 -0
  97. package/dist/remote/machine.d.ts +64 -0
  98. package/dist/remote/machine.d.ts.map +1 -0
  99. package/dist/remote/machine.js +2 -0
  100. package/dist/remote/machine.js.map +1 -0
  101. package/dist/remote/remote.d.ts +24 -0
  102. package/dist/remote/remote.d.ts.map +1 -0
  103. package/dist/remote/remote.js +308 -0
  104. package/dist/remote/remote.js.map +1 -0
  105. package/dist/remote/sweep.d.ts +15 -0
  106. package/dist/remote/sweep.d.ts.map +1 -0
  107. package/dist/remote/sweep.js +116 -0
  108. package/dist/remote/sweep.js.map +1 -0
  109. package/dist/renewable-credential.d.ts +17 -0
  110. package/dist/renewable-credential.d.ts.map +1 -0
  111. package/dist/renewable-credential.js +58 -0
  112. package/dist/renewable-credential.js.map +1 -0
  113. package/dist/salvage.d.ts +30 -0
  114. package/dist/salvage.d.ts.map +1 -0
  115. package/dist/salvage.js +104 -0
  116. package/dist/salvage.js.map +1 -0
  117. package/dist/ssh/credentials.d.ts +40 -0
  118. package/dist/ssh/credentials.d.ts.map +1 -0
  119. package/dist/ssh/credentials.js +83 -0
  120. package/dist/ssh/credentials.js.map +1 -0
  121. package/dist/ssh/gateway/admin.d.ts +45 -0
  122. package/dist/ssh/gateway/admin.d.ts.map +1 -0
  123. package/dist/ssh/gateway/admin.js +129 -0
  124. package/dist/ssh/gateway/admin.js.map +1 -0
  125. package/dist/ssh/gateway/attachments.d.ts +22 -0
  126. package/dist/ssh/gateway/attachments.d.ts.map +1 -0
  127. package/dist/ssh/gateway/attachments.js +154 -0
  128. package/dist/ssh/gateway/attachments.js.map +1 -0
  129. package/dist/ssh/gateway/environment.d.ts +52 -0
  130. package/dist/ssh/gateway/environment.d.ts.map +1 -0
  131. package/dist/ssh/gateway/environment.js +78 -0
  132. package/dist/ssh/gateway/environment.js.map +1 -0
  133. package/dist/ssh/gateway/forward.d.ts +74 -0
  134. package/dist/ssh/gateway/forward.d.ts.map +1 -0
  135. package/dist/ssh/gateway/forward.js +247 -0
  136. package/dist/ssh/gateway/forward.js.map +1 -0
  137. package/dist/ssh/gateway/preflight.d.ts +28 -0
  138. package/dist/ssh/gateway/preflight.d.ts.map +1 -0
  139. package/dist/ssh/gateway/preflight.js +234 -0
  140. package/dist/ssh/gateway/preflight.js.map +1 -0
  141. package/dist/ssh/model.d.ts +65 -0
  142. package/dist/ssh/model.d.ts.map +1 -0
  143. package/dist/ssh/model.js +2 -0
  144. package/dist/ssh/model.js.map +1 -0
  145. package/dist/ssh/preflight.d.ts +16 -0
  146. package/dist/ssh/preflight.d.ts.map +1 -0
  147. package/dist/ssh/preflight.js +47 -0
  148. package/dist/ssh/preflight.js.map +1 -0
  149. package/dist/ssh/ssh.d.ts +20 -0
  150. package/dist/ssh/ssh.d.ts.map +1 -0
  151. package/dist/ssh/ssh.js +78 -0
  152. package/dist/ssh/ssh.js.map +1 -0
  153. package/dist/ssh/workers.d.ts +53 -0
  154. package/dist/ssh/workers.d.ts.map +1 -0
  155. package/dist/ssh/workers.js +173 -0
  156. package/dist/ssh/workers.js.map +1 -0
  157. package/package.json +12 -4
  158. package/dist/exe-dev/channel.d.ts +0 -12
  159. package/dist/exe-dev/channel.d.ts.map +0 -1
  160. package/dist/exe-dev/channel.js +0 -42
  161. package/dist/exe-dev/channel.js.map +0 -1
  162. package/dist/exe-dev/shell.d.ts +0 -12
  163. package/dist/exe-dev/shell.d.ts.map +0 -1
  164. package/dist/exe-dev/shell.js +0 -31
  165. package/dist/exe-dev/shell.js.map +0 -1
  166. package/dist/exe-dev/sweep.d.ts +0 -10
  167. package/dist/exe-dev/sweep.d.ts.map +0 -1
  168. package/dist/exe-dev/sweep.js +0 -117
  169. package/dist/exe-dev/sweep.js.map +0 -1
  170. package/dist/invalid-frame.d.ts +0 -17
  171. package/dist/invalid-frame.d.ts.map +0 -1
  172. package/dist/invalid-frame.js +0 -111
  173. package/dist/invalid-frame.js.map +0 -1
  174. package/dist/run-host-session.d.ts +0 -27
  175. package/dist/run-host-session.d.ts.map +0 -1
  176. package/dist/run-host-session.js +0 -303
  177. package/dist/run-host-session.js.map +0 -1
@@ -1,27 +0,0 @@
1
- import * as AttemptChannel from "@usine/core/attempt/channel";
2
- import { AttemptFailure } from "@usine/core/attempt/failure";
3
- import { AttemptId } from "@usine/core/attempt";
4
- import { StepResult } from "@usine/core/step/result";
5
- import { Cause, Effect, Queue, Scope, type PlatformError } from "effect";
6
- import type { ChildProcessHandle } from "effect/unstable/process/ChildProcessSpawner";
7
- import { ExecutorError, type AttemptWorkspace } from "./executor.ts";
8
- interface SpawnedRunHost {
9
- readonly handle: ChildProcessHandle;
10
- readonly host: string;
11
- /** Redacts the Attempt credential from run-host output before it is persisted. */
12
- readonly scrub: (text: string) => string;
13
- }
14
- export type RunHostInput = Queue.Queue<Uint8Array, Cause.Done>;
15
- export interface RunHostSessionOptions {
16
- readonly interruptGrace: Parameters<typeof Effect.timeoutOption>[1];
17
- }
18
- type SpawnRunHost = (input: RunHostInput) => Effect.Effect<SpawnedRunHost, AttemptFailure | PlatformError.PlatformError, Scope.Scope>;
19
- export interface RunHostSession {
20
- readonly intervene: (attemptId: AttemptId, intervention: AttemptChannel.Intervention) => Effect.Effect<void, AttemptFailure>;
21
- readonly cancel: (attemptId: AttemptId) => Effect.Effect<void, ExecutorError>;
22
- readonly launch: (prepared: AttemptWorkspace, io: AttemptChannel.Sink, spawn: SpawnRunHost) => Effect.Effect<StepResult, AttemptFailure>;
23
- }
24
- /** The run-host byte-channel session every process-backed Executor shares. */
25
- export declare const runHostSessionFor: (options: RunHostSessionOptions) => Effect.Effect<RunHostSession>;
26
- export {};
27
- //# sourceMappingURL=run-host-session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-host-session.d.ts","sourceRoot":"","sources":["../src/run-host-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAgB,cAAc,EAAgB,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,KAAK,EAEL,MAAM,EAGN,KAAK,EAKL,KAAK,EAEL,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,aAAa,EAA0B,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG7F,UAAU,cAAc;IACtB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAED,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACrE;AAED,KAAK,YAAY,GAAG,CAClB,KAAK,EAAE,YAAY,KAChB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AAE9F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,CAClB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,cAAc,CAAC,YAAY,KACtC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC9E,QAAQ,CAAC,MAAM,EAAE,CACf,QAAQ,EAAE,gBAAgB,EAC1B,EAAE,EAAE,cAAc,CAAC,IAAI,EACvB,KAAK,EAAE,YAAY,KAChB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;CAChD;AA0CD,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,MAAM,CAAC,MAAM,CAAC,cAAc,CAqY5F,CAAC"}
@@ -1,303 +0,0 @@
1
- import * as AttemptChannel from "@usine/core/attempt/channel";
2
- import { AgentFailure, AttemptFailure, InfraFailure } from "@usine/core/attempt/failure";
3
- import { AttemptId } from "@usine/core/attempt";
4
- import { StepResult } from "@usine/core/step/result";
5
- import { Cause, DateTime, Effect, Fiber, Option, Queue, Ref, Result, Schema, Semaphore, Scope, Stream, } from "effect";
6
- import { ExecutorError, ExecutorOperationError } from "./executor.js";
7
- import { invalidFrameDiagnostic, invalidFrameMessage } from "./invalid-frame.js";
8
- const STDERR_TAIL_BYTES = 4_096;
9
- /** Sending SIGKILL is its own bounded step, unrelated to the interrupt grace. */
10
- const KILL_TIMEOUT = "5 seconds";
11
- const inputFrameToJson = Schema.encodeSync(AttemptChannel.InputFrameFromJson);
12
- /** Rejects a frame with any unknown key; the protocol is strict by contract. */
13
- const decodeOutboundEnvelope = (line) => Schema.decodeUnknownEffect(AttemptChannel.OutboundEnvelopeFromJson)(line, {
14
- onExcessProperty: "error",
15
- });
16
- const isExecutorError = Schema.is(ExecutorError);
17
- const encoder = new TextEncoder();
18
- const frame = (input) => encoder.encode(`${inputFrameToJson(input)}\n`);
19
- const infrastructureFailure = (message, cause) => new InfraFailure({ message, cause });
20
- const violationFailure = (violation) => infrastructureFailure(violation.message, new Error(violation.detail));
21
- const cancelError = (attemptId, cause) => new ExecutorOperationError({
22
- operation: "cancel",
23
- message: `Could not cancel Attempt ${attemptId}`,
24
- cause,
25
- });
26
- /** The run-host byte-channel session every process-backed Executor shares. */
27
- export const runHostSessionFor = Effect.fn("RunHostSession.for")(function* (options) {
28
- const activeAttempts = yield* Ref.make(new Map());
29
- const hardKill = Effect.fn("RunHostSession.hardKill")(function* (attemptId, active, reason) {
30
- yield* Effect.logWarning("Hard-killing the run host", {
31
- attemptId,
32
- worker: active.worker,
33
- host: active.host,
34
- reason,
35
- });
36
- // The kill failure is logged, never propagated, so it cannot mask the
37
- // failure that forced the hard kill.
38
- yield* active.handle.kill({ killSignal: "SIGKILL" }).pipe(Effect.timeout(KILL_TIMEOUT), Effect.tapError((error) => Effect.logError("Run-host hard kill failed", {
39
- attemptId,
40
- worker: active.worker,
41
- host: active.host,
42
- reason,
43
- message: String(error),
44
- })), Effect.ignore);
45
- yield* Effect.logWarning("Run-host hard-kill signal sent", {
46
- attemptId,
47
- worker: active.worker,
48
- host: active.host,
49
- reason,
50
- });
51
- });
52
- const cancelActive = Effect.fn("RunHostSession.cancelActive")(function* (attemptId, active) {
53
- return yield* Effect.uninterruptible(Effect.gen(function* () {
54
- yield* Effect.annotateCurrentSpan({
55
- attemptId,
56
- worker: active.worker,
57
- host: active.host,
58
- });
59
- const first = yield* Ref.modify(active.cancelStarted, (started) => [!started, true]);
60
- if (!first) {
61
- yield* Effect.logDebug("Attempt cancellation was already started", {
62
- attemptId,
63
- worker: active.worker,
64
- host: active.host,
65
- });
66
- return;
67
- }
68
- yield* Effect.logInfo("Sending the interrupt envelope", {
69
- attemptId,
70
- worker: active.worker,
71
- host: active.host,
72
- });
73
- const delivered = yield* active.writeLock
74
- .withPermits(1)(Effect.gen(function* () {
75
- const sequence = yield* Ref.get(active.sequence);
76
- const envelope = new AttemptChannel.InboundEnvelope({
77
- version: AttemptChannel.PROTOCOL_VERSION,
78
- attemptId,
79
- sequence: AttemptChannel.Sequence.make(sequence),
80
- sentAt: yield* DateTime.now,
81
- // Cancellation stops the whole Attempt, so it addresses the parent.
82
- target: new AttemptChannel.ParentTarget(),
83
- operator: "engine",
84
- payload: new AttemptChannel.Cancel(),
85
- });
86
- yield* active.io.append("inbound", envelope);
87
- yield* Ref.update(active.sequence, (value) => value + 1);
88
- return yield* Queue.offer(active.input, frame(envelope));
89
- }))
90
- .pipe(
91
- // The transcript store sits outside the process adapter and may be
92
- // parked; the bound keeps the uninterruptible cancellation handshake
93
- // moving on to the hard kill.
94
- Effect.timeoutOption(options.interruptGrace), Effect.result);
95
- if (Result.isFailure(delivered)) {
96
- yield* Effect.logWarning("Interrupt could not be delivered", {
97
- attemptId,
98
- worker: active.worker,
99
- host: active.host,
100
- message: String(delivered.failure),
101
- });
102
- yield* hardKill(attemptId, active, "delivery-failed");
103
- return yield* delivered.failure;
104
- }
105
- if (Option.isNone(delivered.success)) {
106
- const cause = new Error("interrupt delivery exceeded the cancellation grace");
107
- yield* Effect.logWarning("Interrupt delivery timed out", {
108
- attemptId,
109
- worker: active.worker,
110
- host: active.host,
111
- });
112
- yield* hardKill(attemptId, active, "delivery-failed");
113
- return yield* cancelError(attemptId, cause);
114
- }
115
- const completed = yield* active.handle.exitCode.pipe(Effect.timeoutOption(options.interruptGrace));
116
- if (Option.isNone(completed)) {
117
- yield* Effect.logWarning("Interrupt grace expired", {
118
- attemptId,
119
- worker: active.worker,
120
- host: active.host,
121
- });
122
- yield* hardKill(attemptId, active, "grace-expired");
123
- }
124
- else {
125
- yield* Effect.logInfo("Run host stopped within the interrupt grace", {
126
- attemptId,
127
- worker: active.worker,
128
- host: active.host,
129
- });
130
- }
131
- }));
132
- });
133
- const cancel = Effect.fn("RunHostSession.cancel")(function* (attemptId) {
134
- const active = (yield* Ref.get(activeAttempts)).get(attemptId);
135
- if (active === undefined) {
136
- yield* Effect.logDebug("Attempt cancellation was a no-op", { attemptId });
137
- return;
138
- }
139
- yield* cancelActive(attemptId, active).pipe(Effect.mapError((cause) => isExecutorError(cause) ? cause : cancelError(attemptId, cause)));
140
- });
141
- const launch = Effect.fn("RunHostSession.launch")(function* (prepared, io, spawn) {
142
- const attemptId = prepared.spec.attemptId;
143
- yield* Effect.annotateCurrentSpan({ attemptId, worker: prepared.worker });
144
- const execute = Effect.scoped(Effect.gen(function* () {
145
- const input = yield* Queue.make();
146
- const { handle, host, scrub } = yield* spawn(input);
147
- yield* Effect.annotateCurrentSpan({ host });
148
- const active = {
149
- scope: yield* Effect.scope,
150
- writeLock: yield* Semaphore.make(1),
151
- cancelStarted: yield* Ref.make(false),
152
- handle,
153
- host,
154
- input,
155
- io,
156
- sequence: yield* Ref.make(1),
157
- worker: prepared.worker,
158
- };
159
- yield* Queue.offer(input, frame(new AttemptChannel.Start({
160
- version: AttemptChannel.PROTOCOL_VERSION,
161
- spec: prepared.spec,
162
- })));
163
- // Publish the live channel only after its mandatory Start frame is queued.
164
- yield* Ref.update(activeAttempts, (current) => {
165
- const next = new Map(current);
166
- next.set(attemptId, active);
167
- return next;
168
- });
169
- const stderr = yield* Ref.make("");
170
- const stderrFiber = yield* handle.stderr.pipe(Stream.decodeText(), Stream.runForEach((chunk) => Ref.update(stderr, (current) => `${current}${chunk}`.slice(-STDERR_TAIL_BYTES))), Effect.forkChild);
171
- const terminal = yield* Ref.make(Option.none());
172
- const progress = yield* Ref.make(AttemptChannel.initialProgress);
173
- yield* handle.stdout.pipe(Stream.decodeText(), Stream.splitLines, Stream.runForEach((rawLine) => Effect.gen(function* () {
174
- // Frames include raw tool inputs and outputs; scrub the credential
175
- // from the line before it is decoded or persisted.
176
- const line = scrub(rawLine);
177
- const decoded = yield* decodeOutboundEnvelope(line).pipe(Effect.result);
178
- if (Result.isFailure(decoded)) {
179
- const diagnostic = invalidFrameDiagnostic(line, decoded.failure);
180
- if (diagnostic.source === "effect-log") {
181
- yield* Effect.logWarning("Dropped a run-host diagnostic from protocol output", {
182
- attemptId,
183
- ...diagnostic,
184
- });
185
- return;
186
- }
187
- yield* Effect.logError("Run host emitted an invalid frame", {
188
- attemptId,
189
- ...diagnostic,
190
- });
191
- return yield* infrastructureFailure(invalidFrameMessage(diagnostic), decoded.failure);
192
- }
193
- const envelope = decoded.success;
194
- const admitted = AttemptChannel.admit(yield* Ref.get(progress), attemptId, envelope);
195
- if (Result.isFailure(admitted))
196
- return yield* violationFailure(admitted.failure);
197
- yield* Ref.set(progress, admitted.success);
198
- yield* io.append("outbound", envelope);
199
- const payload = envelope.payload;
200
- if (payload._tag === "Final" ||
201
- payload._tag === "Failed" ||
202
- payload._tag === "Interrupted") {
203
- yield* Effect.logInfo("Run host reached its terminal envelope", {
204
- attemptId,
205
- terminal: payload._tag,
206
- sequence: envelope.sequence,
207
- });
208
- yield* Ref.set(terminal, Option.some(payload));
209
- yield* Queue.end(input);
210
- }
211
- })), Effect.mapError((error) => Schema.is(AttemptFailure)(error)
212
- ? error
213
- : infrastructureFailure("The run-host channel failed", error)));
214
- const exitCode = yield* handle.exitCode.pipe(Effect.mapError((cause) => infrastructureFailure("Could not read the run-host exit code", cause)));
215
- yield* Fiber.join(stderrFiber).pipe(Effect.tapError((error) => Effect.logWarning("Could not finish reading run-host stderr", {
216
- attemptId,
217
- message: String(error),
218
- })), Effect.ignore);
219
- yield* Effect.logInfo("Run host exited", {
220
- attemptId,
221
- exitCode: String(exitCode),
222
- });
223
- const ended = yield* Ref.get(terminal);
224
- const errorOutput = scrub((yield* Ref.get(stderr)).trim());
225
- if (Option.isNone(ended)) {
226
- return yield* infrastructureFailure("The run-host channel closed without a final envelope", new Error(`run host exited with code ${String(exitCode)}: ${errorOutput}`));
227
- }
228
- if (ended.value._tag === "Failed")
229
- return yield* ended.value.failure;
230
- if (ended.value._tag === "Interrupted") {
231
- return yield* new AgentFailure({
232
- message: "The run host confirmed the interrupt and stopped",
233
- });
234
- }
235
- if (Number(exitCode) !== 0) {
236
- return yield* infrastructureFailure(`The run host exited with code ${String(exitCode)} after its final envelope`, new Error(errorOutput));
237
- }
238
- return ended.value.result;
239
- }).pipe(Effect.onError((cause) =>
240
- // A ceiling reported by the transcript sink needs the same bounded
241
- // shutdown as external cancellation, before process scope cleanup.
242
- Cause.hasInterrupts(cause) ||
243
- Cause.findErrorOption(cause).pipe(Option.exists((error) => error._tag === "RunawayFailure"))
244
- ? cancel(attemptId).pipe(Effect.tapError((error) => Effect.logWarning("Run-host shutdown failed", {
245
- attemptId,
246
- message: String(error),
247
- })), Effect.ignore)
248
- : Effect.void)));
249
- return yield* execute.pipe(Effect.ensuring(Ref.update(activeAttempts, (current) => {
250
- const next = new Map(current);
251
- next.delete(attemptId);
252
- return next;
253
- })), Effect.mapError((error) => Schema.is(AttemptFailure)(error)
254
- ? error
255
- : infrastructureFailure("The executor failed while running the run host", error)));
256
- });
257
- const intervene = Effect.fn("RunHostSession.intervene")(function* (attemptId, intervention) {
258
- yield* Effect.annotateCurrentSpan({
259
- attemptId,
260
- target: intervention.target._tag,
261
- action: intervention.action._tag,
262
- });
263
- const active = (yield* Ref.get(activeAttempts)).get(attemptId);
264
- const unavailable = new AgentFailure({
265
- message: "This Attempt no longer has a live channel",
266
- });
267
- if (active === undefined)
268
- return yield* unavailable;
269
- yield* active.writeLock
270
- .withPermits(1)(Effect.gen(function* () {
271
- if (yield* Ref.get(active.cancelStarted))
272
- return yield* unavailable;
273
- const envelope = new AttemptChannel.InboundEnvelope({
274
- version: AttemptChannel.PROTOCOL_VERSION,
275
- attemptId,
276
- sequence: AttemptChannel.Sequence.make(yield* Ref.get(active.sequence)),
277
- sentAt: yield* DateTime.now,
278
- operator: intervention.operator,
279
- target: intervention.target,
280
- payload: intervention.action,
281
- });
282
- yield* active.io.append("inbound", envelope);
283
- yield* Ref.update(active.sequence, (value) => value + 1);
284
- if (!(yield* Queue.offer(active.input, frame(envelope))))
285
- return yield* unavailable;
286
- yield* Effect.logInfo("Operator input queued on the live Attempt channel", {
287
- attemptId,
288
- sequence: envelope.sequence,
289
- action: intervention.action._tag,
290
- });
291
- }))
292
- .pipe(Effect.tapError((error) => Effect.logWarning("Operator input delivery failed", {
293
- attemptId,
294
- action: intervention.action._tag,
295
- errorTag: error._tag,
296
- })),
297
- // Delivery belongs to the Attempt. A disconnected HTTP caller must not
298
- // strand a persisted input before its sequence and queue are advanced.
299
- Effect.forkIn(active.scope), Effect.flatMap(Fiber.join));
300
- });
301
- return { cancel, launch, intervene };
302
- });
303
- //# sourceMappingURL=run-host-session.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-host-session.js","sourceRoot":"","sources":["../src/run-host-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,GAAG,EACH,MAAM,EACN,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,GAEP,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAyB,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA4CjF,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,iFAAiF;AACjF,MAAM,YAAY,GAAG,WAAW,CAAC;AACjC,MAAM,gBAAgB,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