@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
@@ -3,9 +3,8 @@ export interface KeyedLock<in K> {
3
3
  readonly withLock: (key: K) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
4
4
  }
5
5
  /**
6
- * One mutex per key. `PartitionedSemaphore` is not this: its `permits` option
7
- * is one shared pool and the partition key only orders waiters, so
8
- * `make({ permits: 1 })` serializes every key behind a single global permit.
6
+ * Returns one mutex per key. `PartitionedSemaphore` doesn't provide this: its `permits` is one
7
+ * shared pool, so `make({ permits: 1 })` serializes every key.
9
8
  */
10
9
  export declare const keyedLockFor: <K>() => Effect.Effect<KeyedLock<K>>;
11
10
  //# sourceMappingURL=keyed-lock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyed-lock.d.ts","sourceRoot":"","sources":["../src/keyed-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAEhD,MAAM,WAAW,SAAS,CAAC,EAAE,CAAC,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,CACjB,GAAG,EAAE,CAAC,KACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC1E;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,OAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAcxD,CAAC"}
1
+ {"version":3,"file":"keyed-lock.d.ts","sourceRoot":"","sources":["../src/keyed-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAEhD,MAAM,WAAW,SAAS,CAAC,EAAE,CAAC,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,CACjB,GAAG,EAAE,CAAC,KACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC1E;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,OAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAcxD,CAAC"}
@@ -1,8 +1,7 @@
1
1
  import { Effect, Ref, Semaphore } from "effect";
2
2
  /**
3
- * One mutex per key. `PartitionedSemaphore` is not this: its `permits` option
4
- * is one shared pool and the partition key only orders waiters, so
5
- * `make({ permits: 1 })` serializes every key behind a single global permit.
3
+ * Returns one mutex per key. `PartitionedSemaphore` doesn't provide this: its `permits` is one
4
+ * shared pool, so `make({ permits: 1 })` serializes every key.
6
5
  */
7
6
  export const keyedLockFor = () => Effect.map(Ref.make(new Map()), (locks) => ({
8
7
  withLock: (key) => {
@@ -1 +1 @@
1
- {"version":3,"file":"keyed-lock.js","sourceRoot":"","sources":["../src/keyed-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS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GAAG,EAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAClE,QAAQ,EAAE,CAAC,GAAM,EAAE,EAAE;QACnB,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC;YAChE,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACvB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAU,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,CAAU,MAA8B,EAA0B,EAAE,CACzE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { WorkerName } from "@usine/core/worker";
2
+ import { Effect } from "effect";
3
+ /**
4
+ * Caches `list` per Worker for the life of one executor; concurrent callers share one listing.
5
+ * Failures are cached too, so an unreachable Worker is listed once and its checkouts stay until
6
+ * the next start.
7
+ */
8
+ export declare const listedOncePerWorker: <A, E>(list: (worker: WorkerName) => Effect.Effect<A, E>) => Effect.Effect<(worker: WorkerName) => Effect.Effect<A, E, never>, never, never>;
9
+ //# sourceMappingURL=leftovers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leftovers.d.ts","sourceRoot":"","sources":["../src/leftovers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAwD,CAAC,EAAE,CAAC,iBAC3E,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,4BAcjC,UAAU,8CAC1B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Cache, Effect } from "effect";
2
+ /**
3
+ * Caches `list` per Worker for the life of one executor; concurrent callers share one listing.
4
+ * Failures are cached too, so an unreachable Worker is listed once and its checkouts stay until
5
+ * the next start.
6
+ */
7
+ export const listedOncePerWorker = Effect.fn("Executor.listedOncePerWorker")(function* (list) {
8
+ const listed = yield* Cache.make({
9
+ capacity: Number.POSITIVE_INFINITY,
10
+ lookup: (worker) => list(worker).pipe(Effect.tapError((error) => Effect.logWarning("Could not list leftover checkouts; this Worker is not reconciled until the next start", { worker, message: String(error) }))),
11
+ });
12
+ return (worker) => Cache.get(listed, worker);
13
+ });
14
+ //# sourceMappingURL=leftovers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leftovers.js","sourceRoot":"","sources":["../src/leftovers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,8BAA8B,CAAC,CAAC,QAAQ,CAAC,EACpF,IAAiD;IAEjD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC,iBAAiB;QAClC,MAAM,EAAE,CAAC,MAAkB,EAAE,EAAE,CAC7B,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CACf,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,MAAM,CAAC,UAAU,CACf,uFAAuF,EACvF,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CACnC,CACF,CACF;KACJ,CAAC,CAAC;IACH,OAAO,CAAC,MAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Effect, FileSystem } from "effect";
2
+ import { CredentialProvider, ExecutorOperationError } from "../executor.ts";
3
+ /**
4
+ * Writes the Attempt's renewed credential to a private temporary directory outside the
5
+ * checkout, removed when the Attempt scope closes.
6
+ */
7
+ export declare const localCredentialsFor: Effect.Effect<(repository: string & import("effect/Brand").Brand<"RepositoryName">, attemptId: string & import("effect/Brand").Brand<"AttemptId">, permissions: "read" | "write", baseEnvironment: Record<string, string>) => Effect.Effect<{
8
+ refresh: () => Effect.Effect<void, import("../executor.ts").CredentialUnavailableError | import("effect/PlatformError").PlatformError, never>;
9
+ scrub: (text: string) => string;
10
+ environment: {
11
+ GH_CONFIG_DIR: string;
12
+ GH_PROMPT_DISABLED: string;
13
+ USINE_GITHUB_TOKEN_FILE: string;
14
+ GIT_CONFIG_COUNT: string;
15
+ GIT_CONFIG_KEY_0: string;
16
+ GIT_CONFIG_VALUE_0: string;
17
+ GIT_CONFIG_KEY_1: string;
18
+ GIT_CONFIG_VALUE_1: string;
19
+ };
20
+ }, import("../executor.ts").CredentialUnavailableError | ExecutorOperationError, import("effect/Scope").Scope>, never, CredentialProvider | FileSystem.FileSystem>;
21
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/local/credentials.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAY,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AAGnG;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;kKAsD9B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { Effect, FileSystem, Redacted } from "effect";
2
+ import { credentialEnvironment, GH_CONFIG, ghHostsConfig } from "../credential-environment.js";
3
+ import { CredentialProvider, ExecutorOperationError } from "../executor.js";
4
+ import { renewableCredential } from "../renewable-credential.js";
5
+ /**
6
+ * Writes the Attempt's renewed credential to a private temporary directory outside the
7
+ * checkout, removed when the Attempt scope closes.
8
+ */
9
+ export const localCredentialsFor = Effect.gen(function* () {
10
+ const provider = yield* CredentialProvider;
11
+ const fs = yield* FileSystem.FileSystem;
12
+ return Effect.fn("LocalExecutor.credentials")(function* (repository, attemptId, permissions, baseEnvironment) {
13
+ yield* Effect.annotateCurrentSpan({ repository, attemptId, permissions });
14
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "usine-credentials-" });
15
+ yield* fs.chmod(directory, 0o700);
16
+ yield* fs.writeFileString(`${directory}/config.yml`, GH_CONFIG, { mode: 0o600 });
17
+ const { refresh, scrub } = yield* renewableCredential(provider.issue, repository, attemptId, permissions, Effect.fn("LocalExecutor.writeCredential")(function* ({ value }) {
18
+ // Writes then renames so readers never see a partial token.
19
+ yield* fs.writeFileString(`${directory}/token.next`, Redacted.value(value), {
20
+ mode: 0o600,
21
+ });
22
+ yield* fs.rename(`${directory}/token.next`, `${directory}/token`);
23
+ yield* fs.writeFileString(`${directory}/hosts.next`, ghHostsConfig(Redacted.value(value)), {
24
+ mode: 0o600,
25
+ });
26
+ yield* fs.rename(`${directory}/hosts.next`, `${directory}/hosts.yml`);
27
+ }));
28
+ return {
29
+ refresh,
30
+ scrub,
31
+ environment: { ...baseEnvironment, ...credentialEnvironment(directory) },
32
+ };
33
+ }, (effect) => effect.pipe(Effect.catchTag("PlatformError", (cause) => Effect.fail(new ExecutorOperationError({
34
+ operation: "prepare",
35
+ message: "Can't write the attempt's credential files",
36
+ cause,
37
+ })))));
38
+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"effect";
3
+ /**
4
+ * Lists checkout paths under each local Worker's `attempts` directory, once per Worker per
5
+ * executor. Returns an empty set if the directory doesn't exist.
6
+ */
7
+ export declare const workerLeftoversFor: (workersRoot: string) => Effect.Effect<(worker: WorkerName) => Effect.Effect<ReadonlySet<string>, import("effect/PlatformError").PlatformError, never>, never, FileSystem.FileSystem | Path.Path>;
8
+ //# sourceMappingURL=leftovers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leftovers.d.ts","sourceRoot":"","sources":["../../src/local/leftovers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,mMAqB7B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Effect, FileSystem, Path } from "effect";
2
+ import { listedOncePerWorker } from "../leftovers.js";
3
+ /**
4
+ * Lists checkout paths under each local Worker's `attempts` directory, once per Worker per
5
+ * executor. Returns an empty set if the directory doesn't exist.
6
+ */
7
+ export const workerLeftoversFor = Effect.fn("LocalExecutor.workerLeftoversFor")(function* (workersRoot) {
8
+ const fileSystem = yield* FileSystem.FileSystem;
9
+ const path = yield* Path.Path;
10
+ return yield* listedOncePerWorker(Effect.fn("LocalExecutor.listWorkerLeftovers")(function* (worker) {
11
+ yield* Effect.annotateCurrentSpan({ worker, host: "local" });
12
+ const root = path.join(workersRoot, worker, "attempts");
13
+ const entries = (yield* fileSystem.exists(root)) ? yield* fileSystem.readDirectory(root) : [];
14
+ const checkouts = new Set(entries.map((entry) => path.join(root, entry)));
15
+ yield* Effect.logInfo("Listed local checkouts left for reconciliation", {
16
+ worker,
17
+ host: "local",
18
+ checkouts: checkouts.size,
19
+ });
20
+ return checkouts;
21
+ }));
22
+ });
23
+ //# sourceMappingURL=leftovers.js.map
@@ -0,0 +1 @@
1
+ {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AAE,SAAS,CAAC,IAAI;SAC1B,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,20 +1,26 @@
1
+ import { ClaudeLoginLock } from "@usine/agents/runtime";
1
2
  import { RepositoryName } from "@usine/core/repository";
2
3
  import { InstanceDirectory } from "@usine/core/instance";
4
+ import type { AttemptRuntime } from "@usine/durable/attempt-runtime";
3
5
  import { Effect, FileSystem, Layer, Path } from "effect";
4
6
  import { ChildProcessSpawner } from "effect/unstable/process";
5
- import { CredentialProvider, Executor, type RunHostCommand } from "../executor.ts";
6
- export type { RunHostCommand } from "../executor.ts";
7
- /** Storage and run-host settings for Attempts executed on the local machine. */
7
+ import { CredentialProvider, Executor } from "../executor.ts";
8
+ import { type HarnessProbe } from "../harness-preflight.ts";
9
+ export type { HarnessProbe } from "../harness-preflight.ts";
8
10
  export interface LocalExecutorOptions {
9
- /** Factory folder under which local Worker caches and Attempt checkouts are stored. */
11
+ /** The directory for local Worker caches and Attempt checkouts. */
10
12
  readonly instanceDirectory: InstanceDirectory;
11
- /** How to launch the one-shot run host; the composition root resolves it. */
12
- readonly runHost: RunHostCommand;
13
- /** Repository fetch URL override, for example a local mirror; defaults to the GitHub HTTPS clone URL. */
13
+ /** Returns the fetch URL for `repository`, for example a local mirror. Defaults to the GitHub HTTPS clone URL. */
14
14
  readonly repositoryUrl?: (repository: RepositoryName) => string;
15
- /** Grace for delivering a stop request, then for the run host to exit; each wait is bounded separately. Defaults to two seconds. */
15
+ /** The timeout for the parent task's cancellation, then separately for the Attempt to finish. Defaults to two seconds. */
16
16
  readonly interruptGrace?: Parameters<typeof Effect.timeoutOption>[1];
17
+ /** Defaults to the `@usine/agents/preflight` checks, which send no prompt. */
18
+ readonly harnessReadiness?: HarnessProbe;
17
19
  }
18
- /** Runs Attempts in isolated checkouts on the local machine. Requires Node; worker contracts are platform-free. */
19
- export declare const layer: (options: LocalExecutorOptions) => Layer.Layer<Executor, never, CredentialProvider | FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
20
+ /**
21
+ * The executor for the local machine. Each Attempt runs in its own checkout with its Pi parent
22
+ * as a durable task in this process (`AttemptRuntime`), so a live Attempt reattaches after an
23
+ * orchestrator restart. Requires Node.
24
+ */
25
+ export declare const layer: (options: LocalExecutorOptions) => Layer.Layer<Executor, never, AttemptRuntime | ClaudeLoginLock | CredentialProvider | FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
20
26
  //# sourceMappingURL=local.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/local/local.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,IAAI,EAML,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAEL,kBAAkB,EAClB,QAAQ,EAKR,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAaxB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,gFAAgF;AAChF,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,yGAAyG;IACzG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,MAAM,CAAC;IAChE,oIAAoI;IACpI,QAAQ,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACtE;AAoVD,mHAAmH;AACnH,eAAO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