@stringsync/splates 0.0.0-stage → 0.0.45

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 (251) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +308 -2
  3. package/acp-extensions.d.ts +82 -0
  4. package/add.d.ts +53 -0
  5. package/adherence.d.ts +49 -0
  6. package/age.d.ts +2 -0
  7. package/agent-connection.d.ts +171 -0
  8. package/agent-errors.d.ts +2 -0
  9. package/agent-process.d.ts +65 -0
  10. package/agent-stream.d.ts +91 -0
  11. package/agents.d.ts +15 -0
  12. package/artifact-room.d.ts +47 -0
  13. package/artifact-viewers.d.ts +6 -0
  14. package/artifact.d.ts +30 -0
  15. package/artifacts.d.ts +161 -0
  16. package/asked.d.ts +146 -0
  17. package/asked.js +7 -0
  18. package/assumed.d.ts +34 -0
  19. package/attach.d.ts +30 -0
  20. package/attachments.d.ts +43 -0
  21. package/baselines.d.ts +55 -0
  22. package/claim.d.ts +17 -0
  23. package/cloudflare-api.d.ts +25 -0
  24. package/cloudflare-error.d.ts +5 -0
  25. package/cloudflared-tunnel-provider.d.ts +27 -0
  26. package/codex-limits.d.ts +19 -0
  27. package/compaction.d.ts +17 -0
  28. package/config-source.d.ts +13 -0
  29. package/config.d.ts +98 -0
  30. package/config.js +7 -0
  31. package/conversation-archive.d.ts +6 -0
  32. package/conversation-background.d.ts +21 -0
  33. package/conversation-choice.d.ts +4 -0
  34. package/conversation-files.d.ts +51 -0
  35. package/conversation-given.d.ts +8 -0
  36. package/conversation-host.d.ts +102 -0
  37. package/conversation-listing.d.ts +15 -0
  38. package/conversation-log.d.ts +301 -0
  39. package/conversation-messages.d.ts +18 -0
  40. package/conversation-name.d.ts +28 -0
  41. package/conversation-options.d.ts +73 -0
  42. package/conversation-reference.d.ts +2 -0
  43. package/conversation-state.d.ts +472 -0
  44. package/conversation-turns.d.ts +115 -0
  45. package/conversation.d.ts +209 -0
  46. package/conversations.d.ts +140 -0
  47. package/coordinator-state.d.ts +28 -0
  48. package/creds.d.ts +123 -0
  49. package/darwin-temperature.d.ts +7 -0
  50. package/decided.d.ts +18 -0
  51. package/demo.d.ts +29 -0
  52. package/dev/api.d.ts +209 -0
  53. package/dev/assets.d.ts +24 -0
  54. package/dev/conversation-address.d.ts +47 -0
  55. package/dev/conversation-feed.d.ts +166 -0
  56. package/dev/live-stream.d.ts +29 -0
  57. package/dev/worker.d.ts +33 -0
  58. package/dev-access.d.ts +61 -0
  59. package/dev-artifacts.d.ts +22 -0
  60. package/dev-budgets.d.ts +18 -0
  61. package/dev-conversation-events.d.ts +39 -0
  62. package/dev-conversation-routes.d.ts +90 -0
  63. package/dev-creds.d.ts +17 -0
  64. package/dev-dictation-connection.d.ts +18 -0
  65. package/dev-dictation.d.ts +17 -0
  66. package/dev-http.d.ts +76 -0
  67. package/dev-open.d.ts +15 -0
  68. package/dev-options.d.ts +133 -0
  69. package/dev-outcomes.d.ts +21 -0
  70. package/dev-pages.d.ts +16 -0
  71. package/dev-picker.d.ts +57 -0
  72. package/dev-port-socket.d.ts +26 -0
  73. package/dev-ports.d.ts +11 -0
  74. package/dev-project-watch.d.ts +44 -0
  75. package/dev-project.d.ts +168 -0
  76. package/dev-push.d.ts +59 -0
  77. package/dev-restart.d.ts +141 -0
  78. package/dev-servers.d.ts +30 -0
  79. package/dev-setup-native.d.ts +23 -0
  80. package/dev-setup-opencode.d.ts +29 -0
  81. package/dev-setup.d.ts +16 -0
  82. package/dev-shell.d.ts +70 -0
  83. package/dev-slot.d.ts +28 -0
  84. package/dev-sockets.d.ts +13 -0
  85. package/dev-task-ports.d.ts +73 -0
  86. package/dev-tasks.d.ts +20 -0
  87. package/dev-terminal-connection.d.ts +19 -0
  88. package/dev-terminal.d.ts +42 -0
  89. package/dev-todos.d.ts +35 -0
  90. package/dev-transcriber.d.ts +15 -0
  91. package/dev-tunnel.d.ts +38 -0
  92. package/dev-versions.d.ts +53 -0
  93. package/dev-workers.d.ts +55 -0
  94. package/dev.d.ts +24 -0
  95. package/diff.d.ts +29 -0
  96. package/dispatched.d.ts +16 -0
  97. package/editors.d.ts +22 -0
  98. package/escalate.d.ts +27 -0
  99. package/events.d.ts +311 -0
  100. package/everywhere.d.ts +41 -0
  101. package/exhibit.d.ts +21 -0
  102. package/exit.d.ts +54 -0
  103. package/fact-todos.d.ts +18 -0
  104. package/fake-agent.d.ts +107 -0
  105. package/fake-agent.js +284 -0
  106. package/finding-facts.d.ts +38 -0
  107. package/findings.d.ts +84 -0
  108. package/fold.d.ts +43 -0
  109. package/follow.d.ts +41 -0
  110. package/format.d.ts +68 -0
  111. package/git.d.ts +112 -0
  112. package/handed-out.d.ts +79 -0
  113. package/handoff.d.ts +23 -0
  114. package/heavy-run.d.ts +12 -0
  115. package/heavy.d.ts +28 -0
  116. package/heavy.js +16 -0
  117. package/held.d.ts +22 -0
  118. package/index-0tfvy823.js +272 -0
  119. package/index-43pq33n4.js +157 -0
  120. package/index-4776671w.js +698 -0
  121. package/index-d4hjrzaq.js +464 -0
  122. package/index-gcfq7awr.js +740 -0
  123. package/index-k73tsw5g.js +101 -0
  124. package/index-kaa44k7q.js +59 -0
  125. package/index-vcv9m93e.js +1265 -0
  126. package/index-xmfmy729.js +249 -0
  127. package/index.d.ts +2 -0
  128. package/index.js +26928 -0
  129. package/init.d.ts +28 -0
  130. package/journal.d.ts +57 -0
  131. package/landed.d.ts +14 -0
  132. package/lane-todos.d.ts +44 -0
  133. package/lane.d.ts +55 -0
  134. package/lanes-from-tags.d.ts +17 -0
  135. package/lanes.d.ts +96 -0
  136. package/legacy-names.d.ts +70 -0
  137. package/legacy-ps.d.ts +31 -0
  138. package/limits.d.ts +32 -0
  139. package/list.d.ts +18 -0
  140. package/load-config.d.ts +44 -0
  141. package/log.d.ts +14 -0
  142. package/machine.d.ts +42 -0
  143. package/merge.d.ts +35 -0
  144. package/migrate-config.d.ts +31 -0
  145. package/models.d.ts +24 -0
  146. package/needs.d.ts +115 -0
  147. package/notices.d.ts +39 -0
  148. package/offered.d.ts +39 -0
  149. package/opencode-usage.d.ts +37 -0
  150. package/outcomes.d.ts +114 -0
  151. package/package.json +74 -5
  152. package/path.d.ts +13 -0
  153. package/plan.d.ts +236 -0
  154. package/port-forward.d.ts +22 -0
  155. package/port-pipe.d.ts +36 -0
  156. package/ports-list.d.ts +19 -0
  157. package/probe-runtime.d.ts +5 -0
  158. package/probe-runtime.js +13 -0
  159. package/project-reaches.d.ts +23 -0
  160. package/projects.d.ts +136 -0
  161. package/prompts.d.ts +128 -0
  162. package/pty.d.ts +39 -0
  163. package/pulse.d.ts +8 -0
  164. package/recommend.d.ts +31 -0
  165. package/release.d.ts +41 -0
  166. package/remote-process.d.ts +26 -0
  167. package/remote-pty.d.ts +29 -0
  168. package/remote-worker.d.ts +77 -0
  169. package/remove.d.ts +31 -0
  170. package/repository.d.ts +91 -0
  171. package/retry.d.ts +34 -0
  172. package/roster.d.ts +63 -0
  173. package/saved-ports-host.d.ts +25 -0
  174. package/saved-tunnel.d.ts +44 -0
  175. package/server-worker-socket.d.ts +21 -0
  176. package/setup-areas.d.ts +7 -0
  177. package/setup-opencode-model-error.d.ts +3 -0
  178. package/setup-opencode-models.d.ts +54 -0
  179. package/setup-opencode-recipe.d.ts +26 -0
  180. package/setup-opencode.d.ts +46 -0
  181. package/setup.d.ts +102 -0
  182. package/shared-browser.d.ts +50 -0
  183. package/shell.d.ts +17 -0
  184. package/show.d.ts +106 -0
  185. package/skill-checks.d.ts +73 -0
  186. package/skill-checks.js +10 -0
  187. package/skills.d.ts +16 -0
  188. package/slot-tunnel.d.ts +27 -0
  189. package/slots.d.ts +135 -0
  190. package/snapshot.d.ts +75 -0
  191. package/splates-artifact.d.ts +3 -0
  192. package/splates-creds.d.ts +3 -0
  193. package/splates-dev.d.ts +22 -0
  194. package/splates-flags.d.ts +34 -0
  195. package/splates-lane.d.ts +3 -0
  196. package/splates-projects.d.ts +3 -0
  197. package/splates-setup.d.ts +17 -0
  198. package/splates-slots.d.ts +3 -0
  199. package/splates-todo.d.ts +3 -0
  200. package/splates-tunnel.d.ts +3 -0
  201. package/splates-worker.d.ts +3 -0
  202. package/splates.d.ts +28 -0
  203. package/stats.d.ts +186 -0
  204. package/supervise.d.ts +50 -0
  205. package/system-changes.d.ts +67 -0
  206. package/system.d.ts +28 -0
  207. package/systems.d.ts +119 -0
  208. package/systems.js +21 -0
  209. package/table.d.ts +5 -0
  210. package/task-log.d.ts +35 -0
  211. package/task-ports.d.ts +25 -0
  212. package/tell.d.ts +47 -0
  213. package/todo-edit.d.ts +60 -0
  214. package/todo-file.d.ts +6 -0
  215. package/todo-lanes.d.ts +82 -0
  216. package/todo-list.d.ts +26 -0
  217. package/todo-take.d.ts +27 -0
  218. package/todo.d.ts +146 -0
  219. package/todos.d.ts +157 -0
  220. package/tool-calls.d.ts +18 -0
  221. package/tunnel-provider.d.ts +37 -0
  222. package/tunnel-provider.js +0 -0
  223. package/tunnel-remove.d.ts +28 -0
  224. package/tunnel-setup.d.ts +104 -0
  225. package/unix-worker-listener.d.ts +23 -0
  226. package/unix-worker-socket.d.ts +30 -0
  227. package/update.d.ts +29 -0
  228. package/update.js +10 -0
  229. package/vocabulary.d.ts +9 -0
  230. package/wait.d.ts +36 -0
  231. package/watch.d.ts +46 -0
  232. package/watched.d.ts +43 -0
  233. package/websocket-worker-socket.d.ts +18 -0
  234. package/worker-call-host.d.ts +51 -0
  235. package/worker-channel.d.ts +83 -0
  236. package/worker-connection.d.ts +24 -0
  237. package/worker-daemon.d.ts +64 -0
  238. package/worker-git.d.ts +18 -0
  239. package/worker-list.d.ts +49 -0
  240. package/worker-machine.d.ts +34 -0
  241. package/worker-port-host.d.ts +21 -0
  242. package/worker-process-host.d.ts +29 -0
  243. package/worker-protocol.d.ts +104 -0
  244. package/worker-pty-host.d.ts +34 -0
  245. package/worker-registry.d.ts +68 -0
  246. package/worker-replay.d.ts +25 -0
  247. package/worker-run.d.ts +20 -0
  248. package/worker-session.d.ts +189 -0
  249. package/worker-socket.d.ts +15 -0
  250. package/worktree-service.d.ts +113 -0
  251. package/worktree.d.ts +232 -0
@@ -0,0 +1,168 @@
1
+ import type { Deps } from "webappwiz/cmd";
2
+ import type { Transcriber } from "webappwiz/dictate";
3
+ import type { AsyncResource } from "webappwiz/disposable";
4
+ import type { Logger } from "webappwiz/log";
5
+ import type { Fs, Ps } from "webappwiz/system";
6
+ import type { ConversationState, Conversations } from "./conversations.js";
7
+ import type { SecretStores } from "./creds.js";
8
+ import type { Assets } from "./dev/assets.js";
9
+ import type { TranscriberFor } from "./dev-transcriber.js";
10
+ import type { Everywhere } from "./everywhere.js";
11
+ import type { Format } from "./format.js";
12
+ import type { LaneRecord } from "./lanes.js";
13
+ import { type Needing } from "./needs.js";
14
+ import type { Projects } from "./projects.js";
15
+ import type { Behind, Release } from "./release.js";
16
+ import type { Repository } from "./repository.js";
17
+ import type { Details } from "./show.js";
18
+ import type { Slot } from "./slots.js";
19
+ import type { PortOwners } from "./task-ports.js";
20
+ /**
21
+ * Everything one project's page talks to: its records, its stream of
22
+ * changes and its conversations, kept from the first request for it until
23
+ * the server stops.
24
+ */
25
+ export declare function serveProject(project: Project, context: DevContext): Promise<Served>;
26
+ /** What `dev` serves a project with: its own records, read and written. */
27
+ export type Project = Pick<Repository, "service" | "journal" | "todos" | "format" | "splatesDir" | "git" | "creds" | "slots"> & {
28
+ fs: Fs;
29
+ ps: Ps;
30
+ log: Logger;
31
+ };
32
+ /**
33
+ * What `dev` runs with: the machine's, not any project's, since it serves
34
+ * every registered project wherever it was started.
35
+ */
36
+ export type DevMachine = Deps & {
37
+ fs: Fs;
38
+ /** Where each project's creds are kept; the system's stores by default. */
39
+ secrets?: SecretStores;
40
+ /** How setup's checks reach the network; the global fetch by default. */
41
+ fetch?: typeof fetch;
42
+ /** The built page. */
43
+ assets: Assets;
44
+ /** Every splates project on this machine. */
45
+ projects: Projects;
46
+ /**
47
+ * Projects opened already, served as they are rather than opened again:
48
+ * a test's own, with its fakes.
49
+ */
50
+ opened?: Project[];
51
+ };
52
+ /** What the server as a whole tells each project it serves. */
53
+ export interface DevContext {
54
+ /** Where the agents' own `splates` reaches this server, once it listens. */
55
+ readonly url: string | null;
56
+ /** A newer splates on npm, once a check has found one; every page says so. */
57
+ readonly release: Release | null;
58
+ /** Commits to splates's own source since this run started, once seen. */
59
+ readonly behind: Behind | null;
60
+ /** Whether building the page failed, so it serves the one built before. */
61
+ readonly unbuilt: boolean;
62
+ /** The slot `splates server --slot` serves under, or null. */
63
+ readonly slot: Slot | null;
64
+ /** The conversations `project`'s page may hold, or null when they are off. */
65
+ conversationsFor(project: Project): Conversations | null;
66
+ /** Every served project's conversations, where a caller of one may be. */
67
+ readonly everywhere: Everywhere;
68
+ /** What `project`'s dictations transcribe with. */
69
+ readonly transcriberFor: TranscriberFor;
70
+ }
71
+ /** A route's work once its project is known. */
72
+ export type Handler = (request: Request) => Promise<Response>;
73
+ /** One project as the server holds it: what each of its routes does. */
74
+ export interface Served extends AsyncResource {
75
+ root: string;
76
+ format: Format;
77
+ conversations: Conversations | null;
78
+ /** Reads the repo again soon, telling its pages if anything moved. */
79
+ refresh: () => void;
80
+ snapshot: Handler;
81
+ /** How many of its agents wait on the person. */
82
+ waiting: () => Promise<number>;
83
+ /** What each of its agents needs, and the lanes that name an orchestrator. */
84
+ needing: () => Promise<{
85
+ rows: Needing[];
86
+ lanes: LaneRecord[];
87
+ }>;
88
+ /** Every lane there has been, to name an orchestrator after. */
89
+ lanes: () => Promise<LaneRecord[]>;
90
+ /** Its tasks' worktrees and agents, whose processes' ports are the tasks'. */
91
+ portOwners: () => Promise<PortOwners>;
92
+ events: Handler;
93
+ file: Handler;
94
+ open: Handler;
95
+ paths: Handler;
96
+ systems: Handler;
97
+ systemChanges: Handler;
98
+ diff: Handler;
99
+ retryTask: Handler;
100
+ removeTask: Handler;
101
+ addTodo: Handler;
102
+ updateTodo: Handler;
103
+ moveTodo: Handler;
104
+ linkTodo: Handler;
105
+ arrangeTodo: Handler;
106
+ assignTodo: Handler;
107
+ joinLane: Handler;
108
+ addLane: Handler;
109
+ updateLane: Handler;
110
+ dropLane: Handler;
111
+ removeTodo: Handler;
112
+ restoreTodo: Handler;
113
+ listCreds: Handler;
114
+ saveCred: Handler;
115
+ removeCred: Handler;
116
+ dismissCred: Handler;
117
+ listBudgets: Handler;
118
+ setBudget: Handler;
119
+ raiseBudget: Handler;
120
+ endRaise: Handler;
121
+ pauseBudget: Handler;
122
+ resumeBudget: Handler;
123
+ listConversations: Handler;
124
+ refreshLimits: Handler;
125
+ startConversation: Handler;
126
+ listSessions: Handler;
127
+ bringSession: Handler;
128
+ /**
129
+ * Asks every live conversation here to bring its SPLATES.md up to date,
130
+ * answering with what settles as each answers.
131
+ */
132
+ checkpoint: (only?: string[]) => Promise<Promise<void>[]>;
133
+ moveConversation: Handler;
134
+ promptConversation: Handler;
135
+ tellConversation: Handler;
136
+ addArtifact: Handler;
137
+ removeArtifact: Handler;
138
+ deleteArtifactVersion: Handler;
139
+ terminateConversation: Handler;
140
+ conversationAttachment: Handler;
141
+ conversationArtifact: Handler;
142
+ answerConversation: Handler;
143
+ cancelConversation: Handler;
144
+ pauseConversation: Handler;
145
+ stopBackground: Handler;
146
+ backgroundOutput: Handler;
147
+ unqueueConversation: Handler;
148
+ sendQueuedNow: Handler;
149
+ chooseSetting: Handler;
150
+ renameConversation: Handler;
151
+ markUnread: Handler;
152
+ pinConversation: Handler;
153
+ reparentConversation: Handler;
154
+ archiveConversation: Handler;
155
+ conversationEvents: Handler;
156
+ terminalTree: (request: Request) => Promise<string>;
157
+ /**
158
+ * What a dictation transcribes with, read afresh for each take; null,
159
+ * after asking for the key on the Creds page, without one.
160
+ */
161
+ transcriber: () => Promise<Transcriber | null>;
162
+ }
163
+ /**
164
+ * How many agents wait on the person, as the page's own waiting line counts
165
+ * them, but for an external agent whose reply the page copied: only the page
166
+ * knows that.
167
+ */
168
+ export declare function waitingOn(tasks: Details[], conversations: ConversationState[]): number;
package/dev-push.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ import type { Logger } from "webappwiz/log";
2
+ import { type Pusher, type VapidKeys } from "webappwiz/push";
3
+ import type { Fs, Ps } from "webappwiz/system";
4
+ import { Duration } from "webappwiz/time";
5
+ import type { Handler, Served } from "./dev-project.js";
6
+ import type { Projects } from "./projects.js";
7
+ /** How often the server looks for something worth pushing, while a device listens. */
8
+ export declare const PUSH_EVERY: Duration;
9
+ /** What `Pushes` reads each served project through. */
10
+ export interface PushesDeps {
11
+ fs: Fs;
12
+ ps: Ps;
13
+ log: Logger;
14
+ projects: Projects;
15
+ /** By root, every project the server has opened. */
16
+ served: Map<string, Promise<Served>>;
17
+ /** What sends a push, signed with the keys kept; the Web Push services by default. */
18
+ pusher?: (keys: VapidKeys) => Pusher;
19
+ /** How often to look; `PUSH_EVERY` by default. */
20
+ every?: Duration;
21
+ }
22
+ /**
23
+ * Tells each device that subscribed, through its browser's push service,
24
+ * what the page's own notifications would: an agent that came to wait,
25
+ * finished its turn or went quiet, in any project the server has open. The
26
+ * page cannot tell it itself once a phone freezes it, soon after the app
27
+ * leaves the front. The keys it signs with and the devices it pushes to are
28
+ * kept in one file for every project on the machine, so a restart keeps them.
29
+ */
30
+ export declare class Pushes {
31
+ private readonly deps;
32
+ private readonly file;
33
+ private readonly keys;
34
+ private devices;
35
+ private readonly pusher;
36
+ /** By device and project, what the last look saw. */
37
+ private readonly notices;
38
+ private readonly tick;
39
+ private looking;
40
+ static start(deps: PushesDeps): Promise<Pushes>;
41
+ private constructor();
42
+ /** The public key a page subscribes with. */
43
+ readonly key: Handler;
44
+ /** Keeps a device's subscription and what it wants, replacing what it said before. */
45
+ readonly subscribe: Handler;
46
+ /** Forgets the device whose subscription `endpoint` names. */
47
+ readonly unsubscribe: Handler;
48
+ /**
49
+ * Compares every open project's rows with the last look, for each device,
50
+ * and pushes each notice it wants. A look still going when the next is due
51
+ * lets it pass.
52
+ */
53
+ look(): Promise<void>;
54
+ dispose(): void;
55
+ private lookOnce;
56
+ private push;
57
+ private forget;
58
+ private keep;
59
+ }
@@ -0,0 +1,141 @@
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 Project, type Served } from "./dev-project.js";
5
+ import type { ServerChoice } from "./dev-servers.js";
6
+ import type { Terminals } from "./dev-terminal.js";
7
+ import type { Versions } from "./dev-versions.js";
8
+ import type { Projects } from "./projects.js";
9
+ import type { WorkerMachine } from "./worker-machine.js";
10
+ /** The projects `splates server` serves, as its restarts reach them. */
11
+ export interface ServedProjects {
12
+ /** Each project opened so far, by root. */
13
+ readonly served: Map<string, Promise<Served>>;
14
+ /** The project at `root`, opened on first asking. */
15
+ servedAt(root: string): Promise<Served>;
16
+ /** The project `slug` names, or the focused one for none. */
17
+ projectNamed(slug: string): Promise<Served>;
18
+ }
19
+ /** What `Restarts` works with: the machine, and what `splates server` holds. */
20
+ export interface RestartsHome {
21
+ fs: Fs;
22
+ ps: Ps;
23
+ log: Logger;
24
+ /** The registry of splates projects. */
25
+ projects: Projects;
26
+ served: ServedProjects;
27
+ terminals: Terminals;
28
+ /** Where agents and shells run, whose process table says what a restart would kill. */
29
+ machine: Pick<WorkerMachine, "processes">;
30
+ /** Stops the whole server, before a restart ends the process. */
31
+ server: AsyncResource;
32
+ /** Hands every agent and shell on a worker to the next run, which takes them back; called before the server stops. */
33
+ handOver(): Promise<void>;
34
+ }
35
+ /** What `Restarts` takes from `dev`'s options. */
36
+ export interface RestartsOptions {
37
+ exit: ((code: number) => void) | null;
38
+ open: (root: string) => Promise<Project>;
39
+ /** Every `splates server` on this machine the page can switch to. */
40
+ servers: () => Promise<ServerChoice[]>;
41
+ }
42
+ /**
43
+ * How `splates server` restarts: the checkpoint a restart waits on, the restart
44
+ * itself, and how this run began. Its handlers are properties, so `dev` hands them to its routes
45
+ * as they are.
46
+ */
47
+ export declare class Restarts {
48
+ private readonly home;
49
+ private readonly versions;
50
+ private readonly opts;
51
+ /**
52
+ * The restart to follow the checkpoint under way, once every agent has
53
+ * answered, and whether the next run resumes them, or whether it shuts
54
+ * down instead, for the next start to resume them; null for none.
55
+ */
56
+ private restarting;
57
+ /**
58
+ * How this run began, when a checkpoint's restart started it: its agents
59
+ * `resuming`, told to carry on, until each has.
60
+ */
61
+ private restarted;
62
+ /**
63
+ * Whether `reopenStopped` has read how this run began, before which a
64
+ * checkpoint left in the logs may yet be one to resume.
65
+ */
66
+ private began;
67
+ /** This run of `splates server`, so a page can tell it has restarted. */
68
+ private readonly run;
69
+ /**
70
+ * Written by a checkpoint's restart, beside the registry, with the other
71
+ * projects whose agents it stopped, so the next run opens them at once
72
+ * and resumes them.
73
+ */
74
+ private readonly reopen;
75
+ private readonly peeked;
76
+ constructor(home: RestartsHome, versions: Versions, opts: RestartsOptions);
77
+ /**
78
+ * Opens the projects a restart stopped agents in, and once they are
79
+ * served, tells each agent done with the checkpoint to carry on.
80
+ */
81
+ reopenStopped(): Promise<void>;
82
+ readonly listProjects: () => Promise<Response>;
83
+ /**
84
+ * Asks every live conversation in each project `projects` names, by slug,
85
+ * for a checkpoint, then restarts, or shuts down when `after` says to,
86
+ * once all of them have answered, stopping other projects' agents as they
87
+ * are; the next run tells each to carry on.
88
+ */
89
+ readonly checkpointProjects: (request: Request) => Promise<Response>;
90
+ /**
91
+ * Restarts `splates server` now, or with `shutdown` exits for good, without a
92
+ * checkpoint: an agent at work stops mid-turn, and a command it would
93
+ * kill dies with it. The next run starts as if started afresh.
94
+ */
95
+ readonly powerNow: (request: Request) => Promise<Response>;
96
+ /**
97
+ * Restarts `splates server` now, refused while an agent is at work that a
98
+ * restart would stop (one on a worker carries on through it), or a
99
+ * command it would kill runs: a job in front in a shell, or one an idle
100
+ * agent left running.
101
+ */
102
+ readonly restartIdle: () => Promise<Response>;
103
+ readonly forgetProject: (request: Request) => Promise<Response>;
104
+ /** Each project opened so far, but those that failed to open. */
105
+ private opened;
106
+ /**
107
+ * What a restart would kill: each command an idle agent left running,
108
+ * unless the agent runs on a worker, which keeps its commands as it keeps
109
+ * it; the page's shells run there too, and stay. An agent at work that a
110
+ * restart would stop holds one off on its own.
111
+ */
112
+ private holding;
113
+ private checkpointable;
114
+ private live;
115
+ private conversationsIn;
116
+ private waitingIn;
117
+ /**
118
+ * Restarts `splates server` once each checkpoint `asked` has been answered,
119
+ * unless dismissed meanwhile, or with `shutdown`, exits for good, the
120
+ * next start reopening and resuming as a restart would. Without
121
+ * `reopens`, the next run starts as if started afresh, as for a restart
122
+ * with every agent idle.
123
+ */
124
+ private restartAfter;
125
+ /**
126
+ * Forgets each checkpoint ended with no run under way to restart or
127
+ * resume it: left by a run that stopped without saying to resume, as when
128
+ * killed mid-checkpoint, or in a project opened after the resume. Kept,
129
+ * it would hold Power on a checkpoint nothing ever ends.
130
+ */
131
+ private forgetStale;
132
+ /** Each conversation a checkpoint has asked, in every project. */
133
+ private checkpointed;
134
+ /**
135
+ * Tells each agent done with the checkpoint to carry on, which ends its
136
+ * checkpoint once said, and forgets the checkpoint of those it missed.
137
+ * One whose agent fails to come back has its checkpoint forgotten too,
138
+ * left failed for the person to open.
139
+ */
140
+ private carryOn;
141
+ }
@@ -0,0 +1,30 @@
1
+ import type { Logger } from "webappwiz/log";
2
+ import type { Fs, Ps } from "webappwiz/system";
3
+ import { type SecretStores } from "./creds.js";
4
+ import { type Slot } from "./slots.js";
5
+ /**
6
+ * A `splates server` on this machine the page can switch to: the machine's own,
7
+ * reached at the host `splates tunnel setup` made, or a slot's.
8
+ */
9
+ export interface ServerChoice {
10
+ /** The slot it serves under; null for the machine's own. */
11
+ slot: Slot | null;
12
+ /** Its page, as in https://fox.example.com. */
13
+ url: string;
14
+ /** The checkout that holds the slot; null for the machine's own. */
15
+ tree: string | null;
16
+ /** Whether it is the one serving this page. */
17
+ here: boolean;
18
+ }
19
+ /**
20
+ * Every `splates server` this machine has a host for: its own, then each slot a
21
+ * checkout that still exists holds, in the pool's order, whether or not it
22
+ * runs. Read from the machine's home, which a slot's server is told of, since
23
+ * its own `SPLATES_HOME` is the slot's.
24
+ */
25
+ export declare function devServers({ fs, ps, log, secrets, }: {
26
+ fs: Fs;
27
+ ps: Ps;
28
+ log: Logger;
29
+ secrets?: SecretStores;
30
+ }): Promise<ServerChoice[]>;
@@ -0,0 +1,23 @@
1
+ import type { Ps } from "webappwiz/system";
2
+ import type { Connection } from "./dev-sockets.js";
3
+ /** Releases the single native setup slot when its command ends. */
4
+ export interface NativeSetupOwner {
5
+ finished(): void;
6
+ }
7
+ /** A single ephemeral native command. Input/output are never persisted or logged. */
8
+ export declare class NativeSetupConnection implements Connection {
9
+ private readonly ps;
10
+ private readonly argv;
11
+ private readonly cwd;
12
+ private readonly owner;
13
+ private child;
14
+ private socket;
15
+ private timer;
16
+ private disposed;
17
+ constructor(ps: Ps, argv: string[], cwd: string, owner: NativeSetupOwner);
18
+ open(socket: Bun.ServerWebSocket<Connection>): void;
19
+ message(_socket: Bun.ServerWebSocket<Connection>, message: string | Buffer<ArrayBuffer>): void;
20
+ closed(): void;
21
+ private finish;
22
+ dispose(): void;
23
+ }
@@ -0,0 +1,29 @@
1
+ import type { Ps } from "webappwiz/system";
2
+ import { type HostGate } from "./dev-http.js";
3
+ import type { Connection } from "./dev-sockets.js";
4
+ import { type OpenCodeSetup } from "./setup-opencode.js";
5
+ /** Local/Access-protected setup operations, with no conversation or worker log. */
6
+ export declare class OpenCodeSetupRoutes {
7
+ readonly setup: OpenCodeSetup;
8
+ private readonly ps;
9
+ private readonly gate;
10
+ private readonly roster;
11
+ private terminal;
12
+ constructor(setup: OpenCodeSetup, ps: Ps, gate: HostGate, roster?: SetupRoster);
13
+ readonly read: () => Promise<Response>;
14
+ readonly check: () => Promise<Response>;
15
+ readonly cancel: () => Promise<Response>;
16
+ readonly models: () => Promise<Response>;
17
+ readonly refreshModels: () => Promise<Response>;
18
+ readonly previewModels: (request: Request) => Promise<Response>;
19
+ readonly applyModels: (request: Request) => Promise<Response>;
20
+ readiness(cwd: string, verify: boolean): Promise<Response>;
21
+ readonly disable: () => Promise<Response>;
22
+ private modelOperation;
23
+ readonly open: (request: Request, server: Bun.Server<Connection>) => Promise<Response | undefined>;
24
+ finished(): void;
25
+ disposeAsync(): Promise<void>;
26
+ }
27
+ export interface SetupRoster {
28
+ refresh(): Promise<void>;
29
+ }
package/dev-setup.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type { Setup } from "./setup.js";
2
+ /**
3
+ * How the page reads this machine's setup and skips its steps. Not any
4
+ * project's: every page on the server shares one machine. Each handler is a
5
+ * property, so `dev` hands them straight to its routes.
6
+ */
7
+ export declare class SetupRoutes {
8
+ #private;
9
+ constructor(setup: Setup);
10
+ /** Every step checked, by area, and the one to do next. */
11
+ readonly read: () => Promise<Response>;
12
+ /** Marks setup seen, so the page stops nudging towards it. */
13
+ readonly see: () => Promise<Response>;
14
+ /** Skips the step `/api/setup/:step/skipped` names, or asks for it again. */
15
+ readonly skip: (request: Request) => Promise<Response>;
16
+ }
package/dev-shell.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ import type { AsyncResource } from "webappwiz/disposable";
2
+ import type { ProcessEntry } from "webappwiz/system";
3
+ import { Duration, type Timer } from "webappwiz/time";
4
+ import type { ProcessHandle } from "./agent-process.js";
5
+ import type { Connection } from "./dev-sockets.js";
6
+ import type { RemotePty } from "./remote-pty.js";
7
+ import type { RemotePtyOptions } from "./remote-worker.js";
8
+ /** Bigger than any screen, and small enough that a typo cannot hurt. */
9
+ export declare const MAX_SIZE = 1000;
10
+ /**
11
+ * How long a keyed shell stays once its page's socket goes, for the page to
12
+ * come back to it: through a reload, or a restart of `splates server`.
13
+ */
14
+ export declare const TERMINAL_GRACE: Duration;
15
+ /** The shells a terminal opens, as a worker runs them. */
16
+ export type TerminalShell = RemotePty;
17
+ /** What a terminal needs of the worker it runs on. */
18
+ export interface ShellHost {
19
+ pty(options: RemotePtyOptions): TerminalShell;
20
+ /** Takes back a shell the worker kept through a restart; see `RemoteWorker.resumePty`. */
21
+ resumePty(handle: ProcessHandle): TerminalShell;
22
+ processes(): Promise<ProcessEntry[]>;
23
+ }
24
+ /** A shell handed to the next run of `splates server`, as `coordinator.json` keeps it. */
25
+ export interface KeptShell {
26
+ key: string;
27
+ handle: ProcessHandle;
28
+ }
29
+ /**
30
+ * One shell the server runs for a page's terminal, by its key: the page's
31
+ * socket shows it, and may go and come back, through a reload or a restart
32
+ * of `splates server`, the worker redrawing the screen for the one that comes
33
+ * back. One with no key ends with its socket; one with a key stays
34
+ * `TERMINAL_GRACE` after it, or until the page says it is closing it.
35
+ */
36
+ export declare class Shell implements AsyncResource {
37
+ readonly key: string | null;
38
+ readonly pty: TerminalShell;
39
+ /** The worker the shell runs on, where its job in front is read from. */
40
+ private readonly worker;
41
+ private readonly timer;
42
+ /** Hears that the shell is gone: exited, closed, or let go. */
43
+ private readonly gone;
44
+ private socket;
45
+ private grace;
46
+ private ended;
47
+ constructor(key: string | null, pty: TerminalShell,
48
+ /** The worker the shell runs on, where its job in front is read from. */
49
+ worker: ShellHost, timer: Timer,
50
+ /** Hears that the shell is gone: exited, closed, or let go. */
51
+ gone: (shell: Shell) => void);
52
+ /** What the next run takes the shell back by, once it has a key. */
53
+ get kept(): KeptShell | null;
54
+ /**
55
+ * Shows the shell on `socket`, in place of any before it: one come back
56
+ * to a shell has the worker redraw its screen first.
57
+ */
58
+ attach(socket: Bun.ServerWebSocket<Connection>, back: boolean): void;
59
+ /** Keeps the shell `TERMINAL_GRACE` for a page to come back to it. */
60
+ wait(): void;
61
+ /** The page's `socket` went: keyed, the shell waits for it to come back. */
62
+ detach(socket: Bun.ServerWebSocket<Connection>): void;
63
+ message(socket: Bun.ServerWebSocket<Connection>, message: string | Buffer<ArrayBuffer>): void;
64
+ /** Tells the page what the shell runs in front, or null at its prompt. */
65
+ private front;
66
+ /** Lets go of the shell for the next run to take back, without ending it. */
67
+ release(): void;
68
+ /** Hangs up, as closing a terminal window does. */
69
+ disposeAsync(): Promise<void>;
70
+ }
package/dev-slot.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { type Logger } from "webappwiz/log";
2
+ import { type Slot, Slots } from "./slots.js";
3
+ import type { SplatesDeps } from "./splates.js";
4
+ /** How `splates server --slot` starts its server: with what added. */
5
+ export interface SlotStart {
6
+ slot: Slot;
7
+ /** The public host it answers on, as in fox.example.com. */
8
+ host: string;
9
+ /** The slot's home, its `SPLATES_HOME`, and the word it serves under. */
10
+ env: Record<string, string>;
11
+ }
12
+ /**
13
+ * Readies the slot this checkout holds, claimed now when it holds none: its
14
+ * tunnel, made on the slot's first claim, and its home, `~/.splates/slots/<word>`,
15
+ * which keeps its own projects, roster and tunnel apart from the machine's, so
16
+ * it never drives the agents of the `splates server` serving your projects. Its
17
+ * home starts out with a throwaway project of its own, made on the first
18
+ * start, so its page has one to show.
19
+ */
20
+ export declare function devSlot(ctx: SplatesDeps): Promise<SlotStart>;
21
+ /**
22
+ * Stops the server this tree's slot last ran, if it still runs, as one does
23
+ * when its wrapper was killed or it was started again: it holds a port, and
24
+ * its cloudflared still serves the slot's host from it, so the new server
25
+ * would answer beside old code. Only this tree ever holds the word, so the
26
+ * server is this task's own to stop.
27
+ */
28
+ export declare function stopLeftover(slots: Slots, slot: Slot, log: Pick<Logger, "info">): Promise<void>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * What one WebSocket the server upgraded does, handed over as the socket's
3
+ * data on the upgrade, since Bun takes one handler for every socket: a
4
+ * terminal's shell, a dictation's transcription.
5
+ */
6
+ export interface Connection {
7
+ open(socket: Bun.ServerWebSocket<Connection>): void;
8
+ message(socket: Bun.ServerWebSocket<Connection>, message: string | Buffer<ArrayBuffer>): void;
9
+ /** The socket closed, from either end. */
10
+ closed(socket: Bun.ServerWebSocket<Connection>): void;
11
+ }
12
+ /** The server's one handler, which leaves each socket to its own connection. */
13
+ export declare const CONNECTIONS: Bun.WebSocketHandler<Connection>;
@@ -0,0 +1,73 @@
1
+ import type { Resource } from "webappwiz/disposable";
2
+ import type { Logger } from "webappwiz/log";
3
+ import { type Clock } from "webappwiz/time";
4
+ import { type Access } from "./dev-access.js";
5
+ import type { Served } from "./dev-project.js";
6
+ import type { Connection } from "./dev-sockets.js";
7
+ import type { RemoteWorker } from "./remote-worker.js";
8
+ import { type PortOwners, type TaskPort } from "./task-ports.js";
9
+ /** One task port, with where to open it. */
10
+ export interface PortLink extends TaskPort {
11
+ /** On the coordinator's machine. */
12
+ local: string;
13
+ /** Through the saved base host, behind Access; null with none saved. */
14
+ remote: string | null;
15
+ }
16
+ /**
17
+ * The ports each task's processes listen on, found on the worker that runs
18
+ * them, as VS Code finds the ports to forward: each one forwarded to a
19
+ * loopback port here, down the worker's socket, and, under a saved base
20
+ * host, served at `<task>-<port>.<base>` to whoever Cloudflare Access lets
21
+ * in, and never without it. DNS and TLS for the base are the operator's.
22
+ */
23
+ export declare class DevTaskPorts implements Resource, Claimer {
24
+ private readonly deps;
25
+ private readonly forwards;
26
+ private looked;
27
+ private readonly clock;
28
+ constructor(deps: {
29
+ /** The worker the tasks' agents run on. */
30
+ worker: RemoteWorker;
31
+ /** Each served project's worktrees and agents. */
32
+ owners: () => Promise<PortOwners>;
33
+ /** `<task>-<port>.<base>` is a task port's; null for none. */
34
+ base: string | null;
35
+ /** What lets a request reach a task port, which none does without. */
36
+ access: Access | null;
37
+ log: Logger;
38
+ clock?: Clock;
39
+ });
40
+ /** Each port a task serves now, forwarded, with its links. */
41
+ links(): Promise<PortLink[]>;
42
+ /** `GET /api/ports`: `links`, as JSON. */
43
+ readonly list: () => Promise<Response>;
44
+ /**
45
+ * Answers `request` when its host is a task port's, proxying it to the
46
+ * task's server; null for any other host, which the page's routes answer.
47
+ */
48
+ claim(request: Request, server: Bun.Server<Connection>): Promise<Response | undefined> | null;
49
+ dispose(): void;
50
+ private proxy;
51
+ /** The ports tasks serve: as last seen while fresh, unless `again`. */
52
+ private look;
53
+ private read;
54
+ /**
55
+ * The forward to `port` on the worker, made on first use. A local
56
+ * worker's port is open here already, so its forward takes any port; a
57
+ * remote one's keeps its number when it is free.
58
+ */
59
+ private forward;
60
+ private link;
61
+ }
62
+ /** Every served project's worktrees and agents, those that failed to open left out. */
63
+ export declare function portOwnersOf(served: Map<string, Promise<Served>>): Promise<PortOwners>;
64
+ /** What answers a task port's request before the page's routes do. */
65
+ export interface Claimer {
66
+ /** Its answer to `request`, or null to leave it to the route. */
67
+ claim(request: Request, server: Bun.Server<Connection>): Promise<Response | undefined> | null;
68
+ }
69
+ /**
70
+ * `routes`, each handler asking `claimer` first: Bun matches a route by its
71
+ * path alone, so a task port's `/` would otherwise reach the page's.
72
+ */
73
+ export declare function claimedFirst<Routes extends Record<string, unknown>>(routes: Routes, claimer: Claimer): Routes;