@wringer/core 0.1.0 → 0.1.2

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 (258) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +71 -2
  3. package/dist/answer-supervisor-connection.d.ts +8 -0
  4. package/dist/app-machine.d.ts +76 -0
  5. package/dist/append-run-event.d.ts +16 -0
  6. package/dist/bind-drivers.d.ts +9 -0
  7. package/dist/build-commands.d.ts +5 -0
  8. package/dist/build-envelope-json-schema.d.ts +1 -0
  9. package/dist/build-envelope.d.ts +16 -0
  10. package/dist/build-launch-guard.d.ts +1 -0
  11. package/dist/build-manifest-write.d.ts +6 -0
  12. package/dist/build-promised-object-reads.d.ts +7 -0
  13. package/dist/build-report.d.ts +10 -0
  14. package/dist/build-run-handle.d.ts +2 -0
  15. package/dist/build-run-view.d.ts +29 -0
  16. package/dist/build-service-key.d.ts +1 -0
  17. package/dist/build-shut-down-steps.d.ts +14 -0
  18. package/dist/build-skip-worktree-marks.d.ts +7 -0
  19. package/dist/build-spawn-error.d.ts +2 -0
  20. package/dist/build-state-paths.d.ts +21 -0
  21. package/dist/build-submodule-adds.d.ts +7 -0
  22. package/dist/builtins/build-doctor-command.d.ts +2 -0
  23. package/dist/builtins/build-exec-command.d.ts +2 -0
  24. package/dist/builtins/build-lifecycle-commands.d.ts +3 -0
  25. package/dist/builtins/build-state-commands.d.ts +2 -0
  26. package/dist/builtins/build-use-pointers.d.ts +9 -0
  27. package/dist/builtins/build-verdict-commands.d.ts +2 -0
  28. package/dist/builtins/call-run-supervisor.d.ts +5 -0
  29. package/dist/builtins/pick-doctor-outcome.d.ts +13 -0
  30. package/dist/builtins/pick-start-action.d.ts +10 -0
  31. package/dist/builtins/pick-stop-plan.d.ts +14 -0
  32. package/dist/builtins/start-run.d.ts +22 -0
  33. package/dist/builtins/stop-data-schema.d.ts +6 -0
  34. package/dist/builtins/stop-run.d.ts +3 -0
  35. package/dist/call-supervisor.d.ts +10 -0
  36. package/dist/cap-data.d.ts +17 -0
  37. package/dist/collect-driver-configs.d.ts +7 -0
  38. package/dist/create-directory.d.ts +1 -0
  39. package/dist/create-evidence-writer.d.ts +13 -0
  40. package/dist/create-file-state.d.ts +36 -0
  41. package/dist/create-log-writer.d.ts +5 -0
  42. package/dist/create-node-repo-host.d.ts +2 -0
  43. package/dist/create-node-state-file-system.d.ts +10 -0
  44. package/dist/create-repo-state.d.ts +2 -0
  45. package/dist/create-socket-folder.d.ts +1 -0
  46. package/dist/create-wringer.d.ts +17 -0
  47. package/dist/decide-guard.d.ts +12 -0
  48. package/dist/define-driver.d.ts +13 -0
  49. package/dist/dispatch.d.ts +10 -0
  50. package/dist/envelope.d.ts +63 -0
  51. package/dist/error-codes.d.ts +25 -0
  52. package/dist/find-cancel-failure.d.ts +2 -0
  53. package/dist/find-colliding-service-key.d.ts +5 -0
  54. package/dist/find-own-value.d.ts +1 -0
  55. package/dist/find-remote-stop-failure.d.ts +2 -0
  56. package/dist/find-verdict-refusal.d.ts +3 -0
  57. package/dist/follow-process.d.ts +10 -0
  58. package/dist/get-lock-value.d.ts +2 -0
  59. package/dist/get-target.d.ts +2 -0
  60. package/dist/host.d.ts +19 -0
  61. package/dist/index.d.ts +60 -0
  62. package/dist/is-error-code.d.ts +1 -0
  63. package/dist/keep-cancelled-call.d.ts +1 -0
  64. package/dist/kill-process-group.d.ts +1 -0
  65. package/dist/launch-line-schema.d.ts +3 -0
  66. package/dist/listen-supervisor-socket.d.ts +8 -0
  67. package/dist/local.d.ts +2 -0
  68. package/dist/make-fence.d.ts +8 -0
  69. package/dist/make-fenced-exec.d.ts +10 -0
  70. package/dist/make-process-supervisor-port.d.ts +7 -0
  71. package/dist/open-drive.d.ts +23 -0
  72. package/dist/open-runless-drive.d.ts +17 -0
  73. package/dist/parse-launch-line.d.ts +2 -0
  74. package/dist/parse-patch-id.d.ts +2 -0
  75. package/dist/parse-report-block.d.ts +9 -0
  76. package/dist/parse-run-log.d.ts +2 -0
  77. package/dist/pick-access-refusal.d.ts +12 -0
  78. package/dist/pick-command-needs.d.ts +15 -0
  79. package/dist/pick-command-plan.d.ts +23 -0
  80. package/dist/pick-context-target.d.ts +7 -0
  81. package/dist/pick-drive-kind.d.ts +8 -0
  82. package/dist/pick-envelope-context.d.ts +1 -0
  83. package/dist/pick-envelope-payload.d.ts +12 -0
  84. package/dist/pick-envelope-run.d.ts +6 -0
  85. package/dist/pick-envelope-target.d.ts +4 -0
  86. package/dist/pick-late-failure-write.d.ts +13 -0
  87. package/dist/pick-log-refusal.d.ts +4 -0
  88. package/dist/pick-merge-base-failure.d.ts +2 -0
  89. package/dist/pick-merge-base-steps.d.ts +13 -0
  90. package/dist/pick-pending-cleanups.d.ts +10 -0
  91. package/dist/pick-submodule-refusal.d.ts +2 -0
  92. package/dist/pick-supervisor-operation.d.ts +16 -0
  93. package/dist/prepare-args.d.ts +3 -0
  94. package/dist/probe-process.d.ts +1 -0
  95. package/dist/quote-shell-word.d.ts +1 -0
  96. package/dist/race-deadline.d.ts +1 -0
  97. package/dist/read-changed-paths.d.ts +7 -0
  98. package/dist/read-default-base.d.ts +2 -0
  99. package/dist/read-fingerprint.d.ts +13 -0
  100. package/dist/read-head-sha.d.ts +2 -0
  101. package/dist/read-launch-host.d.ts +26 -0
  102. package/dist/read-pid-namespace.d.ts +1 -0
  103. package/dist/read-stream-line-batches.d.ts +2 -0
  104. package/dist/read-stream-lines.d.ts +2 -0
  105. package/dist/read-text.d.ts +1 -0
  106. package/dist/read-verdicts.d.ts +5 -0
  107. package/dist/remove-directory.d.ts +1 -0
  108. package/dist/remove-file.d.ts +1 -0
  109. package/dist/render-report-markdown.d.ts +4 -0
  110. package/dist/report-schema.d.ts +51 -0
  111. package/dist/run-events.d.ts +129 -0
  112. package/dist/run-git.d.ts +9 -0
  113. package/dist/run-process.d.ts +19 -0
  114. package/dist/run-supervisor-process.d.ts +2 -0
  115. package/dist/run-supervisor.d.ts +16 -0
  116. package/dist/settle-dispatch-answer.d.ts +9 -0
  117. package/dist/settle-envelope.d.ts +16 -0
  118. package/dist/ssh.d.ts +12 -0
  119. package/dist/start-launch.d.ts +20 -0
  120. package/dist/start-services.d.ts +16 -0
  121. package/dist/supervisor-machine.d.ts +78 -0
  122. package/dist/supervisor-protocol.d.ts +43 -0
  123. package/dist/to-wringer-error.d.ts +2 -0
  124. package/dist/types.d.ts +353 -0
  125. package/dist/wait-for-cancelled-calls.d.ts +2 -0
  126. package/dist/wringer-error.d.ts +12 -0
  127. package/dist/write-envelope-log.d.ts +11 -0
  128. package/dist/write-late-failure.d.ts +11 -0
  129. package/dist/write-new-file.d.ts +1 -0
  130. package/envelope.schema.json +175 -0
  131. package/package.json +21 -5
  132. package/src/answer-supervisor-connection.ts +117 -0
  133. package/src/app-machine.ts +174 -0
  134. package/src/append-run-event.ts +131 -0
  135. package/src/bind-drivers.ts +33 -0
  136. package/src/build-commands.ts +104 -0
  137. package/src/build-envelope-json-schema.ts +34 -0
  138. package/src/build-envelope.ts +40 -0
  139. package/src/build-launch-guard.ts +5 -0
  140. package/src/build-manifest-write.ts +26 -0
  141. package/src/build-promised-object-reads.ts +48 -0
  142. package/src/build-report.ts +55 -0
  143. package/src/build-run-handle.ts +13 -0
  144. package/src/build-run-view.ts +120 -0
  145. package/src/build-service-key.ts +4 -0
  146. package/src/build-shut-down-steps.ts +54 -0
  147. package/src/build-skip-worktree-marks.ts +36 -0
  148. package/src/build-spawn-error.ts +12 -0
  149. package/src/build-state-paths.ts +53 -0
  150. package/src/build-submodule-adds.ts +64 -0
  151. package/src/builtins/build-doctor-command.ts +163 -0
  152. package/src/builtins/build-exec-command.ts +41 -0
  153. package/src/builtins/build-lifecycle-commands.ts +115 -0
  154. package/src/builtins/build-state-commands.ts +152 -0
  155. package/src/builtins/build-use-pointers.ts +26 -0
  156. package/src/builtins/build-verdict-commands.ts +266 -0
  157. package/src/builtins/call-run-supervisor.ts +40 -0
  158. package/src/builtins/pick-doctor-outcome.ts +32 -0
  159. package/src/builtins/pick-start-action.ts +35 -0
  160. package/src/builtins/pick-stop-plan.ts +32 -0
  161. package/src/builtins/start-run.ts +281 -0
  162. package/src/builtins/stop-data-schema.ts +8 -0
  163. package/src/builtins/stop-run.ts +49 -0
  164. package/src/call-supervisor.ts +109 -0
  165. package/src/cap-data.ts +43 -0
  166. package/src/collect-driver-configs.ts +36 -0
  167. package/src/create-directory.ts +6 -0
  168. package/src/create-evidence-writer.ts +82 -0
  169. package/src/create-file-state.ts +193 -0
  170. package/src/create-log-writer.ts +38 -0
  171. package/src/create-node-repo-host.ts +20 -0
  172. package/src/create-node-state-file-system.ts +52 -0
  173. package/src/create-repo-state.ts +15 -0
  174. package/src/create-socket-folder.ts +24 -0
  175. package/src/create-wringer.ts +169 -0
  176. package/src/decide-guard.ts +47 -0
  177. package/src/define-driver.ts +165 -0
  178. package/src/dispatch.ts +589 -0
  179. package/src/envelope.ts +57 -0
  180. package/src/error-codes.ts +39 -0
  181. package/src/find-cancel-failure.ts +7 -0
  182. package/src/find-colliding-service-key.ts +16 -0
  183. package/src/find-own-value.ts +8 -0
  184. package/src/find-remote-stop-failure.ts +19 -0
  185. package/src/find-verdict-refusal.ts +26 -0
  186. package/src/follow-process.ts +147 -0
  187. package/src/get-lock-value.ts +17 -0
  188. package/src/get-target.ts +15 -0
  189. package/src/host.ts +26 -0
  190. package/src/index.ts +75 -0
  191. package/src/is-error-code.ts +3 -0
  192. package/src/keep-cancelled-call.ts +21 -0
  193. package/src/kill-process-group.ts +13 -0
  194. package/src/launch-line-schema.ts +6 -0
  195. package/src/listen-supervisor-socket.ts +75 -0
  196. package/src/local.ts +20 -0
  197. package/src/make-fence.ts +27 -0
  198. package/src/make-fenced-exec.ts +52 -0
  199. package/src/make-process-supervisor-port.ts +65 -0
  200. package/src/open-drive.ts +151 -0
  201. package/src/open-runless-drive.ts +71 -0
  202. package/src/parse-launch-line.ts +19 -0
  203. package/src/parse-patch-id.ts +8 -0
  204. package/src/parse-report-block.ts +39 -0
  205. package/src/parse-run-log.ts +34 -0
  206. package/src/pick-access-refusal.ts +32 -0
  207. package/src/pick-command-needs.ts +29 -0
  208. package/src/pick-command-plan.ts +51 -0
  209. package/src/pick-context-target.ts +22 -0
  210. package/src/pick-drive-kind.ts +23 -0
  211. package/src/pick-envelope-context.ts +10 -0
  212. package/src/pick-envelope-payload.ts +28 -0
  213. package/src/pick-envelope-run.ts +25 -0
  214. package/src/pick-envelope-target.ts +10 -0
  215. package/src/pick-late-failure-write.ts +44 -0
  216. package/src/pick-log-refusal.ts +18 -0
  217. package/src/pick-merge-base-failure.ts +15 -0
  218. package/src/pick-merge-base-steps.ts +37 -0
  219. package/src/pick-pending-cleanups.ts +23 -0
  220. package/src/pick-submodule-refusal.ts +46 -0
  221. package/src/pick-supervisor-operation.ts +52 -0
  222. package/src/prepare-args.ts +22 -0
  223. package/src/probe-process.ts +16 -0
  224. package/src/quote-shell-word.ts +9 -0
  225. package/src/race-deadline.ts +23 -0
  226. package/src/read-changed-paths.ts +39 -0
  227. package/src/read-default-base.ts +21 -0
  228. package/src/read-fingerprint.ts +271 -0
  229. package/src/read-head-sha.ts +23 -0
  230. package/src/read-launch-host.ts +64 -0
  231. package/src/read-pid-namespace.ts +18 -0
  232. package/src/read-stream-line-batches.ts +28 -0
  233. package/src/read-stream-lines.ts +11 -0
  234. package/src/read-text.ts +5 -0
  235. package/src/read-verdicts.ts +57 -0
  236. package/src/remove-directory.ts +6 -0
  237. package/src/remove-file.ts +6 -0
  238. package/src/render-report-markdown.ts +53 -0
  239. package/src/report-schema.ts +37 -0
  240. package/src/run-events.ts +71 -0
  241. package/src/run-git.ts +49 -0
  242. package/src/run-process.ts +168 -0
  243. package/src/run-supervisor-process.ts +51 -0
  244. package/src/run-supervisor.ts +327 -0
  245. package/src/settle-dispatch-answer.ts +26 -0
  246. package/src/settle-envelope.ts +34 -0
  247. package/src/ssh.ts +211 -0
  248. package/src/start-launch.ts +327 -0
  249. package/src/start-services.ts +108 -0
  250. package/src/supervisor-machine.ts +169 -0
  251. package/src/supervisor-protocol.ts +42 -0
  252. package/src/to-wringer-error.ts +20 -0
  253. package/src/types.ts +476 -0
  254. package/src/wait-for-cancelled-calls.ts +37 -0
  255. package/src/wringer-error.ts +25 -0
  256. package/src/write-envelope-log.ts +72 -0
  257. package/src/write-late-failure.ts +40 -0
  258. package/src/write-new-file.ts +17 -0
@@ -0,0 +1,26 @@
1
+ import type { SupervisorSocket, SupervisorSocketOptions } from './listen-supervisor-socket.ts';
2
+ import type { ProcessRequest, ProcessResult } from './run-process.ts';
3
+ export interface AppSpawnOptions {
4
+ readonly cwd: string;
5
+ readonly env: Readonly<Record<string, string | undefined>>;
6
+ }
7
+ export interface AppProcess {
8
+ readonly pid: number;
9
+ readonly stdout: ReadableStream<Uint8Array>;
10
+ readonly stderr: ReadableStream<Uint8Array>;
11
+ readonly exited: Promise<number>;
12
+ }
13
+ export interface LaunchHost {
14
+ readonly guard: readonly string[];
15
+ readonly cwd: string;
16
+ readonly env: Readonly<Record<string, string | undefined>>;
17
+ readonly spawnApp: (argv: readonly string[], options: AppSpawnOptions) => AppProcess;
18
+ readonly appendLog: (path: string, text: string) => Promise<void>;
19
+ readonly createDirectory: (path: string) => Promise<void>;
20
+ readonly createSocketFolder: (preferredSocket: string) => Promise<string>;
21
+ readonly removeDirectory: (path: string) => Promise<void>;
22
+ readonly listenSupervisorSocket: (options: SupervisorSocketOptions) => Promise<SupervisorSocket>;
23
+ readonly killProcessGroup: (pid: number, signal?: NodeJS.Signals) => void;
24
+ readonly runProcess: (request: ProcessRequest) => Promise<ProcessResult>;
25
+ }
26
+ export declare function readLaunchHost(): LaunchHost;
@@ -0,0 +1 @@
1
+ export declare function readPIDNamespace(): string;
@@ -0,0 +1,2 @@
1
+ export declare const streamLineCapChars: number;
2
+ export declare function readStreamLineBatches(stream: ReadableStream<Uint8Array>): AsyncGenerator<readonly string[], void, undefined>;
@@ -0,0 +1,2 @@
1
+ export { streamLineCapChars } from './read-stream-line-batches.ts';
2
+ export declare function readStreamLines(stream: ReadableStream<Uint8Array>): AsyncGenerator<string, void, undefined>;
@@ -0,0 +1 @@
1
+ export declare function readText(path: string): Promise<string>;
@@ -0,0 +1,5 @@
1
+ import type { StatePort } from './create-file-state.ts';
2
+ import type { Verdict } from './report-schema.ts';
3
+ import type { RepoHost } from './types.ts';
4
+ export declare const doneCommand = "done";
5
+ export declare function readVerdicts(state: StatePort, host: Pick<RepoHost, 'readText'>, root: string): Promise<ReadonlyMap<string, Verdict>>;
@@ -0,0 +1 @@
1
+ export declare function removeDirectory(path: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function removeFile(path: string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { Report } from './report-schema.ts';
2
+ export declare const reportBlockOpen = "<!-- wringer-report v1";
3
+ export declare const reportBlockClose = "-->";
4
+ export declare function renderReportMarkdown(report: Report): string;
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ export declare const verdictSchema: z.ZodObject<{
3
+ feature: z.ZodString;
4
+ fingerprint: z.ZodString;
5
+ run: z.ZodString;
6
+ at: z.ZodISODateTime;
7
+ evidence: z.ZodArray<z.ZodObject<{
8
+ kind: z.ZodString;
9
+ path: z.ZodString;
10
+ sha256: z.ZodString;
11
+ url: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strict>>;
13
+ }, z.core.$strict>;
14
+ export type Verdict = z.infer<typeof verdictSchema>;
15
+ declare const featureStatusSchema: z.ZodEnum<{
16
+ missing: "missing";
17
+ stale: "stale";
18
+ unchanged: "unchanged";
19
+ verified: "verified";
20
+ }>;
21
+ export type FeatureStatus = z.infer<typeof featureStatusSchema>;
22
+ export declare const reportSchema: z.ZodObject<{
23
+ version: z.ZodLiteral<1>;
24
+ base: z.ZodString;
25
+ fingerprint: z.ZodString;
26
+ complete: z.ZodBoolean;
27
+ features: z.ZodArray<z.ZodObject<{
28
+ name: z.ZodString;
29
+ changed: z.ZodBoolean;
30
+ status: z.ZodEnum<{
31
+ missing: "missing";
32
+ stale: "stale";
33
+ unchanged: "unchanged";
34
+ verified: "verified";
35
+ }>;
36
+ verdict: z.ZodNullable<z.ZodObject<{
37
+ feature: z.ZodString;
38
+ fingerprint: z.ZodString;
39
+ run: z.ZodString;
40
+ at: z.ZodISODateTime;
41
+ evidence: z.ZodArray<z.ZodObject<{
42
+ kind: z.ZodString;
43
+ path: z.ZodString;
44
+ sha256: z.ZodString;
45
+ url: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strict>>;
47
+ }, z.core.$strict>>;
48
+ }, z.core.$strict>>;
49
+ }, z.core.$strict>;
50
+ export type Report = z.infer<typeof reportSchema>;
51
+ export {};
@@ -0,0 +1,129 @@
1
+ import { z } from 'zod';
2
+ export declare const runIDSchema: z.ZodString;
3
+ export type RunID = z.infer<typeof runIDSchema>;
4
+ export declare const modeSchema: z.ZodEnum<{
5
+ attach: "attach";
6
+ launch: "launch";
7
+ }>;
8
+ export type Mode = z.infer<typeof modeSchema>;
9
+ export declare const endpointsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
10
+ export type Endpoints = z.infer<typeof endpointsSchema>;
11
+ export declare const checkResultSchema: z.ZodObject<{
12
+ name: z.ZodString;
13
+ status: z.ZodEnum<{
14
+ failed: "failed";
15
+ passed: "passed";
16
+ }>;
17
+ durationMs: z.ZodNumber;
18
+ code: z.ZodNullable<z.ZodString>;
19
+ message: z.ZodNullable<z.ZodString>;
20
+ }, z.core.$strict>;
21
+ export type CheckResult = z.infer<typeof checkResultSchema>;
22
+ export declare const lateFailureEventSchema: z.ZodObject<{
23
+ type: z.ZodLiteral<"late-failure">;
24
+ at: z.ZodISODateTime;
25
+ command: z.ZodString;
26
+ code: z.ZodString;
27
+ message: z.ZodString;
28
+ }, z.core.$strict>;
29
+ export type LateFailureEvent = z.infer<typeof lateFailureEventSchema>;
30
+ export declare const runEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
31
+ type: z.ZodLiteral<"run-started">;
32
+ at: z.ZodISODateTime;
33
+ target: z.ZodString;
34
+ mode: z.ZodEnum<{
35
+ attach: "attach";
36
+ launch: "launch";
37
+ }>;
38
+ fingerprint: z.ZodString;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ type: z.ZodLiteral<"supervisor-ready">;
41
+ at: z.ZodISODateTime;
42
+ pid: z.ZodNumber;
43
+ socket: z.ZodString;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ type: z.ZodLiteral<"launch-ready">;
46
+ at: z.ZodISODateTime;
47
+ endpoints: z.ZodRecord<z.ZodString, z.ZodString>;
48
+ }, z.core.$strict>, z.ZodObject<{
49
+ type: z.ZodLiteral<"service-ready">;
50
+ at: z.ZodISODateTime;
51
+ service: z.ZodString;
52
+ }, z.core.$strict>, z.ZodObject<{
53
+ type: z.ZodLiteral<"run-ready">;
54
+ at: z.ZodISODateTime;
55
+ }, z.core.$strict>, z.ZodObject<{
56
+ type: z.ZodEnum<{
57
+ "doctor-failed": "doctor-failed";
58
+ "doctor-passed": "doctor-passed";
59
+ }>;
60
+ at: z.ZodISODateTime;
61
+ results: z.ZodArray<z.ZodObject<{
62
+ name: z.ZodString;
63
+ status: z.ZodEnum<{
64
+ failed: "failed";
65
+ passed: "passed";
66
+ }>;
67
+ durationMs: z.ZodNumber;
68
+ code: z.ZodNullable<z.ZodString>;
69
+ message: z.ZodNullable<z.ZodString>;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>, z.ZodObject<{
72
+ type: z.ZodLiteral<"envelope">;
73
+ at: z.ZodISODateTime;
74
+ drive: z.ZodBoolean;
75
+ envelope: z.ZodObject<{
76
+ wringer: z.ZodLiteral<1>;
77
+ ok: z.ZodBoolean;
78
+ command: z.ZodString;
79
+ target: z.ZodNullable<z.ZodString>;
80
+ instance: z.ZodNullable<z.ZodString>;
81
+ feature: z.ZodNullable<z.ZodString>;
82
+ sha: z.ZodNullable<z.ZodString>;
83
+ durationMs: z.ZodNumber;
84
+ data: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
85
+ evidence: z.ZodArray<z.ZodObject<{
86
+ kind: z.ZodString;
87
+ path: z.ZodString;
88
+ sha256: z.ZodString;
89
+ }, z.core.$strict>>;
90
+ cursors: z.ZodRecord<z.ZodString, z.ZodNumber>;
91
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
92
+ truncatedPath: z.ZodOptional<z.ZodString>;
93
+ error: z.ZodNullable<z.ZodObject<{
94
+ code: z.ZodEnum<{
95
+ "check-failed": "check-failed";
96
+ "doctor-required": "doctor-required";
97
+ environment: "environment";
98
+ internal: "internal";
99
+ "not-running": "not-running";
100
+ "read-only": "read-only";
101
+ "target-not-allowed": "target-not-allowed";
102
+ timeout: "timeout";
103
+ usage: "usage";
104
+ }>;
105
+ message: z.ZodString;
106
+ hint: z.ZodNullable<z.ZodString>;
107
+ }, z.core.$strict>>;
108
+ }, z.core.$strict>;
109
+ }, z.core.$strict>, z.ZodObject<{
110
+ type: z.ZodLiteral<"internal-error">;
111
+ at: z.ZodISODateTime;
112
+ command: z.ZodString;
113
+ stack: z.ZodString;
114
+ }, z.core.$strict>, z.ZodObject<{
115
+ type: z.ZodLiteral<"late-failure">;
116
+ at: z.ZodISODateTime;
117
+ command: z.ZodString;
118
+ code: z.ZodString;
119
+ message: z.ZodString;
120
+ }, z.core.$strict>, z.ZodObject<{
121
+ type: z.ZodLiteral<"crashed">;
122
+ at: z.ZodISODateTime;
123
+ reason: z.ZodString;
124
+ }, z.core.$strict>, z.ZodObject<{
125
+ type: z.ZodLiteral<"run-ended">;
126
+ at: z.ZodISODateTime;
127
+ }, z.core.$strict>], "type">;
128
+ export type RunEvent = z.infer<typeof runEventSchema>;
129
+ export type RunEventType = RunEvent['type'];
@@ -0,0 +1,9 @@
1
+ import type { ProcessResult } from './run-process.ts';
2
+ export interface GitRequest {
3
+ readonly cwd: string;
4
+ readonly args: readonly string[];
5
+ readonly env?: Readonly<Record<string, string>> | undefined;
6
+ readonly stdin?: string | Uint8Array | undefined;
7
+ }
8
+ export declare function runGit(request: GitRequest): Promise<ProcessResult>;
9
+ export declare function runGitBytes(request: GitRequest): Promise<Uint8Array>;
@@ -0,0 +1,19 @@
1
+ export interface ProcessRequest {
2
+ readonly argv: readonly string[];
3
+ readonly cwd?: string | undefined;
4
+ readonly env?: Readonly<Record<string, string | undefined>> | undefined;
5
+ readonly stdin?: string | Uint8Array | undefined;
6
+ readonly signal?: AbortSignal | undefined;
7
+ }
8
+ export interface ProcessResult {
9
+ readonly exitCode: number;
10
+ readonly stdout: string;
11
+ readonly stderr: string;
12
+ }
13
+ export declare function runProcess(request: ProcessRequest): Promise<ProcessResult>;
14
+ export interface ProcessBytesResult {
15
+ readonly exitCode: number;
16
+ readonly stdout: Uint8Array;
17
+ readonly stderr: string;
18
+ }
19
+ export declare function runProcessBytes(request: ProcessRequest): Promise<ProcessBytesResult>;
@@ -0,0 +1,2 @@
1
+ import type { Wringer } from './types.ts';
2
+ export declare function runSupervisorProcess(wringer: Wringer, argv: readonly string[]): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import type { StatePort } from './create-file-state.ts';
2
+ import type { LaunchHost } from './read-launch-host.ts';
3
+ import type { Wringer } from './types.ts';
4
+ export interface SupervisorOptions {
5
+ readonly wringer: Wringer;
6
+ readonly launchHost: LaunchHost;
7
+ readonly state: StatePort;
8
+ readonly runID: string;
9
+ readonly target: string;
10
+ readonly readyTimeoutMs: number;
11
+ readonly stopWaitMs: number;
12
+ readonly now: () => Date;
13
+ readonly reportError: (message: string) => void;
14
+ readonly signal?: AbortSignal | undefined;
15
+ }
16
+ export declare function runSupervisor(options: SupervisorOptions): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import type { EnvelopeInput } from './build-envelope.ts';
2
+ import type { Envelope } from './envelope.ts';
3
+ import type { ExitCode } from './error-codes.ts';
4
+ import type { WringerError } from './wringer-error.ts';
5
+ export interface DispatchAnswer {
6
+ readonly envelope: Envelope;
7
+ readonly exitCode: ExitCode;
8
+ }
9
+ export declare function settleDispatchAnswer(input: EnvelopeInput, logFailure: WringerError | null): DispatchAnswer;
@@ -0,0 +1,16 @@
1
+ import type { EnvelopeInput } from './build-envelope.ts';
2
+ import type { CappedData } from './cap-data.ts';
3
+ import type { Evidence } from './envelope.ts';
4
+ import type { EnvelopePayload } from './pick-envelope-payload.ts';
5
+ export interface EnvelopeFacts {
6
+ readonly command: string;
7
+ readonly target: string | null;
8
+ readonly instance: string | null;
9
+ readonly feature: string | null;
10
+ readonly sha: string | null;
11
+ readonly durationMs: number;
12
+ readonly driveEvidence: readonly Evidence[];
13
+ readonly payload: EnvelopePayload;
14
+ readonly capped: CappedData;
15
+ }
16
+ export declare function settleEnvelope(facts: EnvelopeFacts): EnvelopeInput;
package/dist/ssh.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Host } from './host.ts';
2
+ export interface PrefixLayer {
3
+ readonly argv: readonly string[];
4
+ readonly shell: boolean;
5
+ }
6
+ export interface SSHOptions {
7
+ readonly destination: string;
8
+ readonly readOnlyUser?: string;
9
+ readonly prefix?: readonly PrefixLayer[];
10
+ readonly binary?: string;
11
+ }
12
+ export declare function ssh(options: SSHOptions): Host;
@@ -0,0 +1,20 @@
1
+ import type { LaunchHost } from './read-launch-host.ts';
2
+ import type { Endpoints } from './run-events.ts';
3
+ import type { LaunchPlan } from './types.ts';
4
+ export interface LaunchRequest {
5
+ readonly host: LaunchHost;
6
+ readonly plan: LaunchPlan;
7
+ readonly logPath: string;
8
+ readonly readyTimeoutMs: number;
9
+ readonly signal: AbortSignal;
10
+ readonly onCrash: (reason: string) => void;
11
+ readonly onStopFailed: (reason: string) => void;
12
+ readonly stopGraceMs: number;
13
+ }
14
+ export interface Launch {
15
+ readonly endpoints: Endpoints;
16
+ readonly stop: () => Promise<void>;
17
+ }
18
+ export declare const appStopGraceMs = 5000;
19
+ export declare function startLaunch(request: LaunchRequest): Promise<Launch>;
20
+ export declare const appStopLimitMs: number;
@@ -0,0 +1,16 @@
1
+ import type { Endpoints } from './run-events.ts';
2
+ import type { RunHandle, ServiceInstance, TargetDefinition, Wringer } from './types.ts';
3
+ export interface ServicesRequest {
4
+ readonly wringer: Wringer;
5
+ readonly targetName: string;
6
+ readonly target: TargetDefinition;
7
+ readonly endpoints: Endpoints;
8
+ readonly run: RunHandle;
9
+ readonly hint: string;
10
+ readonly signal: AbortSignal;
11
+ readonly commandSignal: AbortSignal;
12
+ readonly startupCommandSignal: AbortSignal;
13
+ readonly started: Map<string, ServiceInstance>;
14
+ readonly onReady: (key: string) => Promise<void>;
15
+ }
16
+ export declare function startServices(request: ServicesRequest): Promise<void>;
@@ -0,0 +1,78 @@
1
+ import type { WringerError } from './wringer-error.ts';
2
+ export interface ShutDownPlan {
3
+ readonly crashReason: string | null;
4
+ readonly gaveUpOnStartup: boolean;
5
+ }
6
+ interface SupervisorMachineInput {
7
+ readonly stopWaitMs: number;
8
+ readonly startUp: () => Promise<void>;
9
+ readonly abortStartup: () => void;
10
+ readonly shutDown: (plan: ShutDownPlan) => Promise<WringerError | null>;
11
+ readonly cleanUpLate: () => Promise<void>;
12
+ }
13
+ interface SupervisorContext extends SupervisorMachineInput {
14
+ readonly crashReason: string | null;
15
+ readonly gaveUpOnStartup: boolean;
16
+ readonly startupSettled: boolean;
17
+ readonly failure: WringerError | null;
18
+ }
19
+ type SupervisorEvent = {
20
+ readonly type: 'stop';
21
+ readonly reason: string | null;
22
+ } | {
23
+ readonly type: 'startup.done';
24
+ } | {
25
+ readonly type: 'startup.failed';
26
+ readonly reason: string;
27
+ };
28
+ interface RunInput<Input, Output> {
29
+ readonly run: (input: Input) => Promise<Output>;
30
+ readonly input: Input;
31
+ }
32
+ export declare const supervisorMachine: import("xstate").StateMachine<SupervisorContext, SupervisorEvent, {
33
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<null, RunInput<null, void>, import("xstate").EventObject> | import("xstate").PromiseActorLogic<WringerError | null, RunInput<ShutDownPlan, WringerError | null>, import("xstate").EventObject>> | undefined;
34
+ }, {
35
+ src: "cleanUpLate";
36
+ logic: import("xstate").PromiseActorLogic<null, RunInput<null, void>, import("xstate").EventObject>;
37
+ id: string | undefined;
38
+ } | {
39
+ src: "shutDown";
40
+ logic: import("xstate").PromiseActorLogic<WringerError | null, RunInput<ShutDownPlan, WringerError | null>, import("xstate").EventObject>;
41
+ id: string | undefined;
42
+ } | {
43
+ src: "startUp";
44
+ logic: import("xstate").PromiseActorLogic<null, RunInput<null, void>, import("xstate").EventObject>;
45
+ id: string | undefined;
46
+ }, {
47
+ type: "abortStartup";
48
+ params: unknown;
49
+ } | {
50
+ type: "giveUpOnStartup";
51
+ params: import("xstate").NonReducibleUnknown;
52
+ } | {
53
+ type: "keepStartupFailure";
54
+ params: import("xstate").NonReducibleUnknown;
55
+ } | {
56
+ type: "keepStopReason";
57
+ params: import("xstate").NonReducibleUnknown;
58
+ } | {
59
+ type: "settleStartup";
60
+ params: import("xstate").NonReducibleUnknown;
61
+ }, {
62
+ type: "gaveUpOnStartup";
63
+ params: unknown;
64
+ } | {
65
+ type: "startupSettled";
66
+ params: unknown;
67
+ }, "stopWait", "cleaningUpLate" | "closed" | "ended" | "running" | "shuttingDown" | "starting" | "waitingForStartup", string, SupervisorMachineInput, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, {
68
+ states: {
69
+ readonly starting: {};
70
+ readonly running: {};
71
+ readonly waitingForStartup: {};
72
+ readonly shuttingDown: {};
73
+ readonly closed: {};
74
+ readonly cleaningUpLate: {};
75
+ readonly ended: {};
76
+ };
77
+ }, import("xstate").MetaObject>;
78
+ export {};
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ export declare const supervisorRequestSchema: z.ZodObject<{
3
+ service: z.ZodString;
4
+ method: z.ZodString;
5
+ args: z.ZodUnknown;
6
+ deadlineAt: z.ZodOptional<z.ZodNumber>;
7
+ }, z.core.$strict>;
8
+ export type SupervisorRequest = z.infer<typeof supervisorRequestSchema>;
9
+ export declare const supervisorResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
10
+ ok: z.ZodLiteral<true>;
11
+ result: z.ZodUnknown;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ ok: z.ZodLiteral<false>;
14
+ error: z.ZodObject<{
15
+ code: z.ZodEnum<{
16
+ "check-failed": "check-failed";
17
+ "doctor-required": "doctor-required";
18
+ environment: "environment";
19
+ internal: "internal";
20
+ "not-running": "not-running";
21
+ "read-only": "read-only";
22
+ "target-not-allowed": "target-not-allowed";
23
+ timeout: "timeout";
24
+ usage: "usage";
25
+ }>;
26
+ message: z.ZodString;
27
+ hint: z.ZodNullable<z.ZodString>;
28
+ }, z.core.$strict>;
29
+ }, z.core.$strict>], "ok">;
30
+ export type SupervisorResponse = z.infer<typeof supervisorResponseSchema>;
31
+ export declare const supervisorServiceName = "supervisor";
32
+ export declare const supervisorCommandName = "__wringer-supervisor";
33
+ export declare const supervisorArgsSchema: z.ZodPipe<z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>, z.ZodTransform<{
34
+ runID: string;
35
+ target: string;
36
+ root: string;
37
+ }, [string, string, string]>>;
38
+ export interface SupervisorArgvInput {
39
+ readonly runID: string;
40
+ readonly target: string;
41
+ readonly root: string;
42
+ }
43
+ export declare function buildSupervisorArgv(args: SupervisorArgvInput): readonly string[];
@@ -0,0 +1,2 @@
1
+ import { WringerError } from './wringer-error.ts';
2
+ export declare function toWringerError(error: unknown): WringerError;