@stringsync/splates 0.0.45 → 0.0.47

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 (254) hide show
  1. package/README.md +121 -9
  2. package/artifact.d.ts +3 -30
  3. package/budget.d.ts +3 -0
  4. package/coordinator.d.ts +3 -0
  5. package/creds.d.ts +3 -123
  6. package/flags.d.ts +37 -0
  7. package/index.js +826 -26419
  8. package/lane.d.ts +3 -55
  9. package/main.d.ts +6 -0
  10. package/package.json +3 -42
  11. package/projects.d.ts +3 -136
  12. package/queue.d.ts +3 -0
  13. package/setup.d.ts +16 -98
  14. package/slots.d.ts +3 -135
  15. package/splates.d.ts +1 -19
  16. package/todo.d.ts +3 -146
  17. package/{splates-tunnel.d.ts → tunnel.d.ts} +1 -1
  18. package/{splates-worker.d.ts → worker.d.ts} +1 -1
  19. package/acp-extensions.d.ts +0 -82
  20. package/add.d.ts +0 -53
  21. package/adherence.d.ts +0 -49
  22. package/age.d.ts +0 -2
  23. package/agent-connection.d.ts +0 -171
  24. package/agent-errors.d.ts +0 -2
  25. package/agent-process.d.ts +0 -65
  26. package/agent-stream.d.ts +0 -91
  27. package/agents.d.ts +0 -15
  28. package/artifact-room.d.ts +0 -47
  29. package/artifact-viewers.d.ts +0 -6
  30. package/artifacts.d.ts +0 -161
  31. package/asked.d.ts +0 -146
  32. package/asked.js +0 -7
  33. package/assumed.d.ts +0 -34
  34. package/attach.d.ts +0 -30
  35. package/attachments.d.ts +0 -43
  36. package/baselines.d.ts +0 -55
  37. package/claim.d.ts +0 -17
  38. package/cloudflare-api.d.ts +0 -25
  39. package/cloudflare-error.d.ts +0 -5
  40. package/cloudflared-tunnel-provider.d.ts +0 -27
  41. package/codex-limits.d.ts +0 -19
  42. package/compaction.d.ts +0 -17
  43. package/config-source.d.ts +0 -13
  44. package/config.d.ts +0 -98
  45. package/config.js +0 -7
  46. package/conversation-archive.d.ts +0 -6
  47. package/conversation-background.d.ts +0 -21
  48. package/conversation-choice.d.ts +0 -4
  49. package/conversation-files.d.ts +0 -51
  50. package/conversation-given.d.ts +0 -8
  51. package/conversation-host.d.ts +0 -102
  52. package/conversation-listing.d.ts +0 -15
  53. package/conversation-log.d.ts +0 -301
  54. package/conversation-messages.d.ts +0 -18
  55. package/conversation-name.d.ts +0 -28
  56. package/conversation-options.d.ts +0 -73
  57. package/conversation-reference.d.ts +0 -2
  58. package/conversation-state.d.ts +0 -472
  59. package/conversation-turns.d.ts +0 -115
  60. package/conversation.d.ts +0 -209
  61. package/conversations.d.ts +0 -140
  62. package/coordinator-state.d.ts +0 -28
  63. package/darwin-temperature.d.ts +0 -7
  64. package/decided.d.ts +0 -18
  65. package/demo.d.ts +0 -29
  66. package/dev/api.d.ts +0 -209
  67. package/dev/assets.d.ts +0 -24
  68. package/dev/conversation-address.d.ts +0 -47
  69. package/dev/conversation-feed.d.ts +0 -166
  70. package/dev/live-stream.d.ts +0 -29
  71. package/dev/worker.d.ts +0 -33
  72. package/dev-access.d.ts +0 -61
  73. package/dev-artifacts.d.ts +0 -22
  74. package/dev-budgets.d.ts +0 -18
  75. package/dev-conversation-events.d.ts +0 -39
  76. package/dev-conversation-routes.d.ts +0 -90
  77. package/dev-creds.d.ts +0 -17
  78. package/dev-dictation-connection.d.ts +0 -18
  79. package/dev-dictation.d.ts +0 -17
  80. package/dev-http.d.ts +0 -76
  81. package/dev-open.d.ts +0 -15
  82. package/dev-options.d.ts +0 -133
  83. package/dev-outcomes.d.ts +0 -21
  84. package/dev-pages.d.ts +0 -16
  85. package/dev-picker.d.ts +0 -57
  86. package/dev-port-socket.d.ts +0 -26
  87. package/dev-ports.d.ts +0 -11
  88. package/dev-project-watch.d.ts +0 -44
  89. package/dev-project.d.ts +0 -168
  90. package/dev-push.d.ts +0 -59
  91. package/dev-restart.d.ts +0 -141
  92. package/dev-servers.d.ts +0 -30
  93. package/dev-setup-native.d.ts +0 -23
  94. package/dev-setup-opencode.d.ts +0 -29
  95. package/dev-setup.d.ts +0 -16
  96. package/dev-shell.d.ts +0 -70
  97. package/dev-slot.d.ts +0 -28
  98. package/dev-sockets.d.ts +0 -13
  99. package/dev-task-ports.d.ts +0 -73
  100. package/dev-tasks.d.ts +0 -20
  101. package/dev-terminal-connection.d.ts +0 -19
  102. package/dev-terminal.d.ts +0 -42
  103. package/dev-todos.d.ts +0 -35
  104. package/dev-transcriber.d.ts +0 -15
  105. package/dev-tunnel.d.ts +0 -38
  106. package/dev-versions.d.ts +0 -53
  107. package/dev-workers.d.ts +0 -55
  108. package/dev.d.ts +0 -24
  109. package/diff.d.ts +0 -29
  110. package/dispatched.d.ts +0 -16
  111. package/editors.d.ts +0 -22
  112. package/escalate.d.ts +0 -27
  113. package/events.d.ts +0 -311
  114. package/everywhere.d.ts +0 -41
  115. package/exhibit.d.ts +0 -21
  116. package/exit.d.ts +0 -54
  117. package/fact-todos.d.ts +0 -18
  118. package/fake-agent.d.ts +0 -107
  119. package/fake-agent.js +0 -284
  120. package/finding-facts.d.ts +0 -38
  121. package/findings.d.ts +0 -84
  122. package/fold.d.ts +0 -43
  123. package/follow.d.ts +0 -41
  124. package/format.d.ts +0 -68
  125. package/git.d.ts +0 -112
  126. package/handed-out.d.ts +0 -79
  127. package/handoff.d.ts +0 -23
  128. package/heavy-run.d.ts +0 -12
  129. package/heavy.d.ts +0 -28
  130. package/heavy.js +0 -16
  131. package/held.d.ts +0 -22
  132. package/index-0tfvy823.js +0 -272
  133. package/index-43pq33n4.js +0 -157
  134. package/index-4776671w.js +0 -698
  135. package/index-d4hjrzaq.js +0 -464
  136. package/index-gcfq7awr.js +0 -740
  137. package/index-k73tsw5g.js +0 -101
  138. package/index-kaa44k7q.js +0 -59
  139. package/index-vcv9m93e.js +0 -1265
  140. package/index-xmfmy729.js +0 -249
  141. package/init.d.ts +0 -28
  142. package/journal.d.ts +0 -57
  143. package/landed.d.ts +0 -14
  144. package/lane-todos.d.ts +0 -44
  145. package/lanes-from-tags.d.ts +0 -17
  146. package/lanes.d.ts +0 -96
  147. package/legacy-names.d.ts +0 -70
  148. package/legacy-ps.d.ts +0 -31
  149. package/limits.d.ts +0 -32
  150. package/list.d.ts +0 -18
  151. package/load-config.d.ts +0 -44
  152. package/log.d.ts +0 -14
  153. package/machine.d.ts +0 -42
  154. package/merge.d.ts +0 -35
  155. package/migrate-config.d.ts +0 -31
  156. package/models.d.ts +0 -24
  157. package/needs.d.ts +0 -115
  158. package/notices.d.ts +0 -39
  159. package/offered.d.ts +0 -39
  160. package/opencode-usage.d.ts +0 -37
  161. package/outcomes.d.ts +0 -114
  162. package/path.d.ts +0 -13
  163. package/plan.d.ts +0 -236
  164. package/port-forward.d.ts +0 -22
  165. package/port-pipe.d.ts +0 -36
  166. package/ports-list.d.ts +0 -19
  167. package/probe-runtime.d.ts +0 -5
  168. package/probe-runtime.js +0 -13
  169. package/project-reaches.d.ts +0 -23
  170. package/prompts.d.ts +0 -128
  171. package/pty.d.ts +0 -39
  172. package/pulse.d.ts +0 -8
  173. package/recommend.d.ts +0 -31
  174. package/release.d.ts +0 -41
  175. package/remote-process.d.ts +0 -26
  176. package/remote-pty.d.ts +0 -29
  177. package/remote-worker.d.ts +0 -77
  178. package/remove.d.ts +0 -31
  179. package/repository.d.ts +0 -91
  180. package/retry.d.ts +0 -34
  181. package/roster.d.ts +0 -63
  182. package/saved-ports-host.d.ts +0 -25
  183. package/saved-tunnel.d.ts +0 -44
  184. package/server-worker-socket.d.ts +0 -21
  185. package/setup-areas.d.ts +0 -7
  186. package/setup-opencode-model-error.d.ts +0 -3
  187. package/setup-opencode-models.d.ts +0 -54
  188. package/setup-opencode-recipe.d.ts +0 -26
  189. package/setup-opencode.d.ts +0 -46
  190. package/shared-browser.d.ts +0 -50
  191. package/shell.d.ts +0 -17
  192. package/show.d.ts +0 -106
  193. package/skill-checks.d.ts +0 -73
  194. package/skill-checks.js +0 -10
  195. package/skills.d.ts +0 -16
  196. package/slot-tunnel.d.ts +0 -27
  197. package/snapshot.d.ts +0 -75
  198. package/splates-artifact.d.ts +0 -3
  199. package/splates-creds.d.ts +0 -3
  200. package/splates-dev.d.ts +0 -22
  201. package/splates-flags.d.ts +0 -34
  202. package/splates-lane.d.ts +0 -3
  203. package/splates-projects.d.ts +0 -3
  204. package/splates-setup.d.ts +0 -17
  205. package/splates-slots.d.ts +0 -3
  206. package/splates-todo.d.ts +0 -3
  207. package/stats.d.ts +0 -186
  208. package/supervise.d.ts +0 -50
  209. package/system-changes.d.ts +0 -67
  210. package/system.d.ts +0 -28
  211. package/systems.d.ts +0 -119
  212. package/systems.js +0 -21
  213. package/table.d.ts +0 -5
  214. package/task-log.d.ts +0 -35
  215. package/task-ports.d.ts +0 -25
  216. package/tell.d.ts +0 -47
  217. package/todo-edit.d.ts +0 -60
  218. package/todo-file.d.ts +0 -6
  219. package/todo-lanes.d.ts +0 -82
  220. package/todo-list.d.ts +0 -26
  221. package/todo-take.d.ts +0 -27
  222. package/todos.d.ts +0 -157
  223. package/tool-calls.d.ts +0 -18
  224. package/tunnel-provider.d.ts +0 -37
  225. package/tunnel-provider.js +0 -0
  226. package/tunnel-remove.d.ts +0 -28
  227. package/tunnel-setup.d.ts +0 -104
  228. package/unix-worker-listener.d.ts +0 -23
  229. package/unix-worker-socket.d.ts +0 -30
  230. package/update.d.ts +0 -29
  231. package/update.js +0 -10
  232. package/vocabulary.d.ts +0 -9
  233. package/wait.d.ts +0 -36
  234. package/watch.d.ts +0 -46
  235. package/watched.d.ts +0 -43
  236. package/websocket-worker-socket.d.ts +0 -18
  237. package/worker-call-host.d.ts +0 -51
  238. package/worker-channel.d.ts +0 -83
  239. package/worker-connection.d.ts +0 -24
  240. package/worker-daemon.d.ts +0 -64
  241. package/worker-git.d.ts +0 -18
  242. package/worker-list.d.ts +0 -49
  243. package/worker-machine.d.ts +0 -34
  244. package/worker-port-host.d.ts +0 -21
  245. package/worker-process-host.d.ts +0 -29
  246. package/worker-protocol.d.ts +0 -104
  247. package/worker-pty-host.d.ts +0 -34
  248. package/worker-registry.d.ts +0 -68
  249. package/worker-replay.d.ts +0 -25
  250. package/worker-run.d.ts +0 -20
  251. package/worker-session.d.ts +0 -189
  252. package/worker-socket.d.ts +0 -15
  253. package/worktree-service.d.ts +0 -113
  254. package/worktree.d.ts +0 -232
@@ -1,83 +0,0 @@
1
- import type { Resource } from "webappwiz/disposable";
2
- import { type Eventful } from "webappwiz/events";
3
- import type { Json } from "./worker-protocol.js";
4
- /** What a `WorkerChannel` hears from the other end, each with its seq. */
5
- export interface WorkerChannelEvents extends Record<string, unknown> {
6
- data: {
7
- bytes: Uint8Array;
8
- seq: number;
9
- };
10
- message: {
11
- body: Json;
12
- seq: number;
13
- };
14
- /** Both ends have closed it, whichever closed first. */
15
- close: undefined;
16
- }
17
- /** What a channel needs of the session it runs over. */
18
- export interface WorkerChannelLink {
19
- /** Sends a frame in the channel's next seq, and says whether there is room for more. */
20
- send(channel: number, frame: {
21
- type: "message";
22
- body: Json;
23
- } | {
24
- type: "data";
25
- bytes: Uint8Array;
26
- } | {
27
- type: "close";
28
- }): boolean;
29
- ack(channel: number, seq: number): void;
30
- /** Both ends have said close, so the session can forget the channel. */
31
- done(channel: number): void;
32
- }
33
- /**
34
- * One stream between a coordinator and a worker, such as an agent's stdio or
35
- * a PTY: bytes as `data`, and JSON as `message` for what is not bytes (a
36
- * resize, an exit code). Its frames survive a reconnect. Disposing it closes
37
- * it at both ends, and each hears `close` once both have.
38
- */
39
- export declare class WorkerChannel implements Eventful<WorkerChannelEvents>, Resource {
40
- readonly id: number;
41
- readonly kind: string;
42
- readonly params: Json;
43
- private readonly link;
44
- private readonly dispatcher;
45
- readonly events: import("webappwiz/events").Events<WorkerChannelEvents>;
46
- private sentClose;
47
- private heardClose;
48
- constructor(id: number, kind: string, params: Json, link: WorkerChannelLink);
49
- get closed(): boolean;
50
- /**
51
- * Returns `false` once the session holds as many unacked bytes as it is
52
- * allowed: stop reading whatever feeds this until the session's `drain`.
53
- */
54
- write(bytes: Uint8Array): boolean;
55
- /** As `write`, for JSON. */
56
- send(body: Json): boolean;
57
- /** Says this end holds everything up to `seq`, for a session that acks by hand. */
58
- ack(seq: number): void;
59
- dispose(): void;
60
- /**
61
- * Ends it here without a word to the other end, which no longer knows it,
62
- * as a coordinator started again does not; this end hears `close`.
63
- */
64
- drop(): void;
65
- /**
66
- * Hands the channel what the other end sent; the session calls it. Says
67
- * whether anyone heard it, since a frame nobody heard is the session's to ack.
68
- */
69
- receive(frame: {
70
- type: "message";
71
- body: Json;
72
- seq: number;
73
- } | {
74
- type: "data";
75
- bytes: Uint8Array;
76
- seq: number;
77
- } | {
78
- type: "close";
79
- seq: number;
80
- }): boolean;
81
- private finishIfDone;
82
- private assertOpen;
83
- }
@@ -1,24 +0,0 @@
1
- import { Disposer, type Resource } from "webappwiz/disposable";
2
- import type { Duration } from "webappwiz/time";
3
- import type { Negotiated } from "./worker-protocol.js";
4
- import type { WorkerSocket } from "./worker-socket.js";
5
- /**
6
- * One socket's worth of a `WorkerSession`: what goes when the socket does,
7
- * while the session's channels and unacked frames stay for the next one.
8
- */
9
- export declare class WorkerConnection implements Resource {
10
- readonly socket: WorkerSocket;
11
- heard: Duration;
12
- readonly resources: Disposer;
13
- /** Settles with the handshake, or with why the socket went first. */
14
- readonly settled: {
15
- promise: Promise<Negotiated>;
16
- resolve: (value?: PromiseLike<Negotiated> | Negotiated | undefined) => void;
17
- reject: (reason?: any) => void;
18
- };
19
- /** Past the handshake, so channel frames flow. */
20
- live: boolean;
21
- ackFlush: Resource | undefined;
22
- constructor(socket: WorkerSocket, heard: Duration);
23
- dispose(): void;
24
- }
@@ -1,64 +0,0 @@
1
- import type { AsyncResource } from "webappwiz/disposable";
2
- import type { Logger } from "webappwiz/log";
3
- import type { Fs, Ps } from "webappwiz/system";
4
- import { type Clock, Duration, type Timer } from "webappwiz/time";
5
- import { WorkerSession, type WorkerSessionOptions } from "./worker-session.js";
6
- import type { WorkerSocket } from "./worker-socket.js";
7
- /** How a worker reaches its coordinator, dialed afresh after each drop. */
8
- export interface WorkerDialer {
9
- /** Where it dials, for the log. */
10
- readonly where: string;
11
- dial(): Promise<WorkerSocket>;
12
- }
13
- /** The channels a worker serves, which it says it can in its hello. */
14
- export declare const WORKER_CAPABILITIES: string[];
15
- /** Who a `WorkerDaemon` is and what it runs on. */
16
- export interface WorkerDaemonOptions {
17
- /** Stays the same across restarts, so the coordinator resumes its session. */
18
- id: string;
19
- slots: number;
20
- ps: Ps;
21
- fs: Fs;
22
- log: Logger;
23
- /** The shortest and longest wait between dials. */
24
- backoff?: {
25
- min: Duration;
26
- max: Duration;
27
- };
28
- /** Paces the session, as `WorkerSession` takes it. */
29
- session?: Omit<WorkerSessionOptions, "timer" | "clock" | "capabilities">;
30
- timer?: Timer;
31
- clock?: Clock;
32
- }
33
- /**
34
- * `splates worker run`: a worker that dials out to its coordinator and keeps
35
- * dialing, waiting longer after each failure, and runs what it is asked to
36
- * on this machine: processes, PTYs, calls, and connections to the ports its
37
- * tasks serve. What it runs outlives a
38
- * dropped link, since the session replays what the coordinator missed.
39
- */
40
- export declare class WorkerDaemon implements AsyncResource {
41
- private readonly dialer;
42
- private readonly opts;
43
- readonly session: WorkerSession;
44
- private readonly hosts;
45
- private readonly timer;
46
- private readonly backoff;
47
- private readonly machine;
48
- private waiting;
49
- private stopped;
50
- constructor(dialer: WorkerDialer, opts: WorkerDaemonOptions);
51
- /**
52
- * Dials and serves until disposed, or until the coordinator refuses this
53
- * worker, resolving with why it stopped.
54
- */
55
- run(): Promise<{
56
- refused: string;
57
- } | {
58
- stopped: true;
59
- }>;
60
- /** Stops dialing and everything this worker runs, and hangs up. */
61
- disposeAsync(): Promise<void>;
62
- private serve;
63
- private sleep;
64
- }
package/worker-git.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { GitResult } from "./git.js";
2
- import type { WatchGit } from "./watch.js";
3
- import type { WorkerMachine } from "./worker-machine.js";
4
- /**
5
- * The git `Watch` runs around an agent's commands, run on the worker the
6
- * agent works on, since its worktree is there.
7
- */
8
- export declare class WorkerGit implements WatchGit {
9
- /** The main worktree, where trunk lives. */
10
- readonly root: string;
11
- private readonly machine;
12
- constructor(
13
- /** The main worktree, where trunk lives. */
14
- root: string, machine: WorkerMachine);
15
- run(cwd: string, ...args: string[]): Promise<GitResult>;
16
- /** As `Git.interruptedOps`, read on the worker: a worktree's half-finished merges and rebases. */
17
- interruptedOps(worktree: string): Promise<string[]>;
18
- }
package/worker-list.d.ts DELETED
@@ -1,49 +0,0 @@
1
- import type { Logger } from "webappwiz/log";
2
- import type { Ps } from "webappwiz/system";
3
- import { type WallClock } from "webappwiz/time";
4
- import type { WorkerKind } from "./remote-worker.js";
5
- import type { WorkerRegistry } from "./worker-registry.js";
6
- /** One worker as `GET /api/workers` and `splates worker list` give it. */
7
- export interface WorkerListing {
8
- id: string;
9
- /** `provisioned` is for workers splates makes itself, which do not exist yet. */
10
- kind: WorkerKind | "provisioned";
11
- platform: string | null;
12
- build: string | null;
13
- /** What its link settled on; null before any handshake. */
14
- protocol: string | null;
15
- slots: {
16
- used: number;
17
- total: number | null;
18
- };
19
- /** `connected` while the link is up, else `away`. */
20
- health: "connected" | "away";
21
- /** When anything last came from it, epoch milliseconds; null before the first. */
22
- lastHeard: number | null;
23
- /** The tasks placed on it; none until tasks are placed on workers. */
24
- tasks: string[];
25
- dollarsPerHour: number;
26
- }
27
- /** What `GET /api/workers` answers. */
28
- export interface WorkerListings {
29
- workers: WorkerListing[];
30
- refused: {
31
- id: string;
32
- protocol: string;
33
- reason: string;
34
- }[];
35
- }
36
- /** The workers a registry keeps and the ones it turned away. */
37
- export declare function workerList(registry: WorkerRegistry): WorkerListings;
38
- /** What `splates worker list` is run with. */
39
- export interface ListWorkersOptions {
40
- /** The `splates server` to ask; empty for the one this agent runs under. */
41
- dev: string;
42
- json: boolean;
43
- log: Logger;
44
- ps: Ps;
45
- send?: typeof fetch;
46
- wall?: WallClock;
47
- }
48
- /** `splates worker list`: asks the running `splates server` which workers it has. */
49
- export declare function listWorkers(opts: ListWorkersOptions): Promise<void>;
@@ -1,34 +0,0 @@
1
- import type { Fs, ListeningEntry, ProcessEntry, Ps } from "webappwiz/system";
2
- import { type GitResult } from "./git.js";
3
- /** A file's size, and its bytes from where the caller last read up to. */
4
- export interface WorkerRead {
5
- size: number;
6
- bytes: Uint8Array;
7
- }
8
- /**
9
- * What the coordinator asks of the machine a task runs on: git in its
10
- * worktree around each tool call (`Watch`), a background command's output
11
- * (`ConversationBackground`), the process table (`heldBy`), and the ports
12
- * its processes listen on (`TaskPorts`).
13
- */
14
- export interface WorkerMachine {
15
- git(cwd: string, args: string[]): Promise<GitResult>;
16
- processes(): Promise<ProcessEntry[]>;
17
- listening(): Promise<ListeningEntry[]>;
18
- /** `path` from byte `from` on; a missing file reads as empty. */
19
- read(path: string, from: number): Promise<WorkerRead>;
20
- /** Whether anything is at `path`, a file or a directory. */
21
- exists(path: string): Promise<boolean>;
22
- }
23
- /** The machine this process runs on, as a worker answers for it. */
24
- export declare class LocalWorkerMachine implements WorkerMachine {
25
- private readonly ps;
26
- private readonly fs;
27
- private readonly runner;
28
- constructor(ps: Ps, fs: Fs);
29
- git(cwd: string, args: string[]): Promise<GitResult>;
30
- processes(): Promise<ProcessEntry[]>;
31
- listening(): Promise<ListeningEntry[]>;
32
- exists(path: string): Promise<boolean>;
33
- read(path: string, from: number): Promise<WorkerRead>;
34
- }
@@ -1,21 +0,0 @@
1
- import type { Resource } from "webappwiz/disposable";
2
- import { z } from "zod";
3
- import type { WorkerChannel } from "./worker-channel.js";
4
- import type { WorkerSession } from "./worker-session.js";
5
- /** What a coordinator opens a `port` channel with. */
6
- export declare const PortParams: z.ZodObject<{
7
- port: z.ZodNumber;
8
- }, z.core.$strip>;
9
- /**
10
- * One TCP connection a `port` channel opened to a port on the worker's
11
- * loopback, such as a task's dev server: its bytes both ways as the
12
- * channel's, `connected` once it is open, or `failed` with why before the
13
- * channel closes. Closing the channel ends the connection.
14
- */
15
- export declare class WorkerPortHost implements Resource {
16
- private readonly channel;
17
- private readonly pipe;
18
- constructor(channel: WorkerChannel, session: WorkerSession);
19
- dispose(): void;
20
- private connect;
21
- }
@@ -1,29 +0,0 @@
1
- import type { Resource } from "webappwiz/disposable";
2
- import type { Ps } from "webappwiz/system";
3
- import { z } from "zod";
4
- import type { WorkerChannel } from "./worker-channel.js";
5
- import type { WorkerSession } from "./worker-session.js";
6
- /** What a coordinator opens a `process` channel with. */
7
- export declare const ProcessParams: z.ZodObject<{
8
- argv: z.ZodArray<z.ZodString>;
9
- cwd: z.ZodString;
10
- env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
11
- }, z.core.$strip>;
12
- /**
13
- * One process a `process` channel started on the worker, such as an agent:
14
- * its stdout as the channel's bytes, its stdin from them, and its pid,
15
- * stderr and exit code as messages. Its stdout is read only while the
16
- * session has room, so a coordinator away for long stalls the process
17
- * rather than losing what it says. Closing the channel kills it.
18
- */
19
- export declare class WorkerProcessHost implements Resource {
20
- private readonly channel;
21
- private readonly session;
22
- private readonly child;
23
- private readonly stdin;
24
- constructor(channel: WorkerChannel, session: WorkerSession, ps: Ps);
25
- dispose(): void;
26
- private told;
27
- private run;
28
- private pump;
29
- }
@@ -1,104 +0,0 @@
1
- /**
2
- * Turns frames into what a `WorkerSocket` carries and back, and settles which
3
- * version two ends speak. A `WorkerSession` uses it for every frame; reach for
4
- * it directly only to speak the protocol without one.
5
- */
6
- export declare class WorkerProtocol {
7
- private constructor();
8
- /** The version this end speaks, sent in every hello and welcome. */
9
- static readonly version = "1.0";
10
- static readonly headerBytes = 8;
11
- static encode(frame: Frame): string | Uint8Array;
12
- /** Throws on anything that is not a frame, which ends the connection. */
13
- static decode(encoded: string | Uint8Array): Frame;
14
- /**
15
- * Settles on the lower minor and the capabilities both ends have; another
16
- * major cannot be read, so it is refused with a reason the coordinator
17
- * shows when it drains that worker.
18
- */
19
- static negotiate(ours: {
20
- protocol: string;
21
- capabilities: string[];
22
- }, theirs: {
23
- protocol: string;
24
- capabilities: string[];
25
- }): Negotiated;
26
- }
27
- /** A JSON value, as control frames carry them. */
28
- export type Json = string | number | boolean | null | Json[] | {
29
- [key: string]: Json;
30
- };
31
- /** Each channel's last seq one end holds, as `[channel, seq]` pairs. */
32
- export type Held = [channel: number, seq: number][];
33
- /**
34
- * Every frame on the link between a coordinator and a worker. Those naming a
35
- * `channel` carry its seq and are kept until acked, so they survive a
36
- * reconnect; the rest belong to one connection and are never replayed.
37
- */
38
- export type Frame = {
39
- type: "hello";
40
- protocol: string;
41
- capabilities: string[];
42
- id: string;
43
- info: {
44
- [key: string]: Json;
45
- };
46
- /** The worker session's id, new each time a worker starts. */
47
- session: string;
48
- held: Held;
49
- } | {
50
- type: "welcome";
51
- protocol: string;
52
- capabilities: string[];
53
- /** The coordinator session's id, new each time a coordinator starts. */
54
- session: string;
55
- held: Held;
56
- } | {
57
- type: "refuse";
58
- reason: string;
59
- } | {
60
- type: "open";
61
- channel: number;
62
- seq: number;
63
- kind: string;
64
- params: Json;
65
- } | {
66
- type: "message";
67
- channel: number;
68
- seq: number;
69
- body: Json;
70
- } | {
71
- type: "data";
72
- channel: number;
73
- seq: number;
74
- bytes: Uint8Array;
75
- } | {
76
- type: "close";
77
- channel: number;
78
- seq: number;
79
- } | {
80
- type: "ack";
81
- acks: Held;
82
- } | {
83
- type: "ping";
84
- n: number;
85
- } | {
86
- type: "pong";
87
- n: number;
88
- };
89
- /** A frame that belongs to a channel, so it has a seq and is replayed. */
90
- export type ChannelFrame = Extract<Frame, {
91
- channel: number;
92
- }>;
93
- /** What one end makes of the other's version, from its hello or welcome. */
94
- export type Negotiated = {
95
- ok: true;
96
- protocol: string;
97
- capabilities: string[];
98
- }
99
- /** `refused` when the other end turned this one away, rather than the link going. */
100
- | {
101
- ok: false;
102
- reason: string;
103
- refused: boolean;
104
- };
@@ -1,34 +0,0 @@
1
- import type { Resource } from "webappwiz/disposable";
2
- import type { Ps } from "webappwiz/system";
3
- import { z } from "zod";
4
- import type { WorkerChannel } from "./worker-channel.js";
5
- /** What a coordinator opens a `pty` channel with. */
6
- export declare const PtyParams: z.ZodObject<{
7
- argv: z.ZodArray<z.ZodString>;
8
- cwd: z.ZodString;
9
- cols: z.ZodNumber;
10
- rows: z.ZodNumber;
11
- env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
12
- }, z.core.$strip>;
13
- /** How much of what the shell last wrote is kept, to redraw a terminal that comes back. */
14
- export declare const SCREEN_BYTES: number;
15
- /**
16
- * One shell a `pty` channel started on the worker, for a page's terminal:
17
- * the terminal's bytes both ways, a resize as a message, and its pid and
18
- * exit code as messages back. It keeps the last `SCREEN_BYTES` the shell
19
- * wrote, and says its pid and writes them again when asked to `describe`
20
- * itself, for a terminal taken back after a coordinator restart, or a page
21
- * come back to it. Closing the channel hangs it up.
22
- */
23
- export declare class WorkerPtyHost implements Resource {
24
- readonly channel: WorkerChannel;
25
- private readonly pty;
26
- /** What the shell last wrote, oldest first, `SCREEN_BYTES` at most in all. */
27
- private readonly screen;
28
- private screenBytes;
29
- constructor(channel: WorkerChannel, ps: Ps);
30
- /** Says the pid again, then writes the screen kept, to redraw a terminal that came back. */
31
- private describe;
32
- private keep;
33
- dispose(): void;
34
- }
@@ -1,68 +0,0 @@
1
- import type { Resource } from "webappwiz/disposable";
2
- import { type Eventful } from "webappwiz/events";
3
- import type { Logger } from "webappwiz/log";
4
- import { type Clock, Duration, type Timer, type WallClock } from "webappwiz/time";
5
- import { RemoteWorker, type WorkerKind } from "./remote-worker.js";
6
- import { type WorkerSessionOptions } from "./worker-session.js";
7
- import type { WorkerSocket } from "./worker-socket.js";
8
- /** A worker turned away, and why, so the coordinator can drain it. */
9
- export interface RefusedWorker {
10
- id: string;
11
- protocol: string;
12
- reason: string;
13
- }
14
- /** What a `WorkerRegistry` hears. */
15
- export interface WorkerRegistryEvents extends Record<string, unknown> {
16
- /** A worker connected, for the first time or again. */
17
- joined: RemoteWorker;
18
- refused: RefusedWorker;
19
- }
20
- /** How a `WorkerRegistry` paces the sessions it keeps. */
21
- export interface WorkerRegistryOptions {
22
- /** How long a new connection has to say hello. */
23
- helloWithin?: Duration;
24
- session?: Omit<WorkerSessionOptions, "timer" | "clock" | "wall" | "capabilities">;
25
- timer?: Timer;
26
- clock?: Clock;
27
- wall?: WallClock;
28
- }
29
- /**
30
- * The coordinator's roster of workers, in memory for now: it takes each
31
- * connection, on whatever transport, reads its hello, and resumes the session
32
- * of a worker it knows by its id, so what it was running carries on.
33
- */
34
- export declare class WorkerRegistry implements Eventful<WorkerRegistryEvents>, Resource {
35
- private readonly log;
36
- private readonly opts;
37
- private readonly dispatcher;
38
- readonly events: import("webappwiz/events").Events<WorkerRegistryEvents>;
39
- private readonly byId;
40
- private readonly refusals;
41
- private readonly timer;
42
- private readonly clock;
43
- private readonly wall;
44
- constructor(log: Logger, opts?: WorkerRegistryOptions);
45
- get workers(): RemoteWorker[];
46
- /** Workers turned away for another major, by id, last word first. */
47
- get refused(): RefusedWorker[];
48
- worker(id: string): RemoteWorker | undefined;
49
- /**
50
- * The worker known by `id`, made now if it has yet to join, so work can be
51
- * given it before it does: its session keeps what it is sent until then.
52
- * `kind` is how it will connect.
53
- */
54
- expect(id: string, kind?: WorkerKind): RemoteWorker;
55
- /**
56
- * Takes a worker's new connection, hanging up on one that says nothing in
57
- * time. `kind` is how it reached us: `local` over this machine's socket.
58
- */
59
- accept(socket: WorkerSocket, kind?: WorkerKind): Promise<void>;
60
- /**
61
- * Hangs up on every worker for a restart, keeping what each runs for
62
- * the next run to take back, once each holds everything it was sent, or
63
- * `ACK_WAIT` is up.
64
- */
65
- detach(): Promise<void>;
66
- private session;
67
- dispose(): void;
68
- }
@@ -1,25 +0,0 @@
1
- import type { ChannelFrame, Held } from "./worker-protocol.js";
2
- /**
3
- * The channel frames one end has sent and the other has yet to ack, kept to
4
- * send again on a reconnect. Its bound is in bytes: past it, `keep` still
5
- * keeps the frame, so nothing is lost, but says the writer should stop.
6
- */
7
- export declare class WorkerReplay {
8
- readonly limit: number;
9
- private readonly channels;
10
- private nextOrder;
11
- private _bytes;
12
- constructor(limit: number);
13
- get bytes(): number;
14
- get full(): boolean;
15
- /** Keeps a frame until acked, and says whether there is room for more. */
16
- keep(frame: ChannelFrame, encoded: string | Uint8Array): boolean;
17
- /** Lets go of every frame, for an other end that will never ack them. */
18
- clear(): void;
19
- /** Lets go of `channel`'s frames, once both ends have closed it: nothing will ask for them. */
20
- drop(channel: number): void;
21
- /** Drops every frame of each channel up to the seq the other end holds. */
22
- ack(acks: Held): void;
23
- /** Every frame still kept, in the order it was first sent. */
24
- unacked(): (string | Uint8Array)[];
25
- }
package/worker-run.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { Logger } from "webappwiz/log";
2
- import type { Fs, Ps } from "webappwiz/system";
3
- /** Where the local worker finds the coordinator on this machine. */
4
- export declare function workerSocketPath(ps: Ps): string;
5
- /** What `splates worker run` is run with. */
6
- export interface WorkerRunOptions {
7
- /** Empty for this machine's coordinator, a URL for another's, or `unix:<path>`. */
8
- coordinator: string;
9
- slots: number;
10
- id: string;
11
- log: Logger;
12
- ps: Ps;
13
- fs: Fs;
14
- }
15
- /**
16
- * `splates worker run`: a worker that serves its coordinator until a SIGINT
17
- * or SIGTERM, or until the coordinator refuses it for speaking another
18
- * protocol, which is a refusal to update one or the other.
19
- */
20
- export declare function workerRun(opts: WorkerRunOptions): Promise<void>;