@ahpd/server 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +88 -81
  2. package/dist/config.d.ts +72 -0
  3. package/dist/config.js +75 -0
  4. package/dist/daemon.d.ts +31 -0
  5. package/dist/daemon.js +162 -0
  6. package/dist/main.d.ts +2 -0
  7. package/dist/main.js +335 -0
  8. package/dist/pty.d.ts +12 -0
  9. package/dist/pty.js +56 -0
  10. package/package.json +15 -25
  11. package/dist/automations.d.ts +0 -4
  12. package/dist/automations.d.ts.map +0 -1
  13. package/dist/automations.js +0 -191
  14. package/dist/automations.js.map +0 -1
  15. package/dist/catalog.d.ts +0 -48
  16. package/dist/catalog.d.ts.map +0 -1
  17. package/dist/catalog.js +0 -51
  18. package/dist/catalog.js.map +0 -1
  19. package/dist/changes.d.ts +0 -4
  20. package/dist/changes.d.ts.map +0 -1
  21. package/dist/changes.js +0 -601
  22. package/dist/changes.js.map +0 -1
  23. package/dist/cron.d.ts +0 -43
  24. package/dist/cron.d.ts.map +0 -1
  25. package/dist/cron.js +0 -211
  26. package/dist/cron.js.map +0 -1
  27. package/dist/git.d.ts +0 -16
  28. package/dist/git.d.ts.map +0 -1
  29. package/dist/git.js +0 -126
  30. package/dist/git.js.map +0 -1
  31. package/dist/host.d.ts +0 -24
  32. package/dist/host.d.ts.map +0 -1
  33. package/dist/host.js +0 -5850
  34. package/dist/host.js.map +0 -1
  35. package/dist/index.d.ts +0 -36
  36. package/dist/index.d.ts.map +0 -1
  37. package/dist/index.js +0 -34
  38. package/dist/index.js.map +0 -1
  39. package/dist/listen.d.ts +0 -3
  40. package/dist/listen.d.ts.map +0 -1
  41. package/dist/listen.js +0 -183
  42. package/dist/listen.js.map +0 -1
  43. package/dist/paging.d.ts +0 -38
  44. package/dist/paging.d.ts.map +0 -1
  45. package/dist/paging.js +0 -53
  46. package/dist/paging.js.map +0 -1
  47. package/dist/paths.d.ts +0 -15
  48. package/dist/paths.d.ts.map +0 -1
  49. package/dist/paths.js +0 -19
  50. package/dist/paths.js.map +0 -1
  51. package/dist/resources.d.ts +0 -122
  52. package/dist/resources.d.ts.map +0 -1
  53. package/dist/resources.js +0 -494
  54. package/dist/resources.js.map +0 -1
  55. package/dist/rpc.d.ts +0 -63
  56. package/dist/rpc.d.ts.map +0 -1
  57. package/dist/rpc.js +0 -208
  58. package/dist/rpc.js.map +0 -1
  59. package/dist/scheduled.d.ts +0 -48
  60. package/dist/scheduled.d.ts.map +0 -1
  61. package/dist/scheduled.js +0 -325
  62. package/dist/scheduled.js.map +0 -1
  63. package/dist/terminals.d.ts +0 -29
  64. package/dist/terminals.d.ts.map +0 -1
  65. package/dist/terminals.js +0 -346
  66. package/dist/terminals.js.map +0 -1
  67. package/dist/tools.d.ts +0 -18
  68. package/dist/tools.d.ts.map +0 -1
  69. package/dist/tools.js +0 -65
  70. package/dist/tools.js.map +0 -1
  71. package/dist/types/agent.d.ts +0 -245
  72. package/dist/types/agent.d.ts.map +0 -1
  73. package/dist/types/agent.js +0 -3
  74. package/dist/types/agent.js.map +0 -1
  75. package/dist/types/automations.d.ts +0 -164
  76. package/dist/types/automations.d.ts.map +0 -1
  77. package/dist/types/automations.js +0 -3
  78. package/dist/types/automations.js.map +0 -1
  79. package/dist/types/catalog.d.ts +0 -30
  80. package/dist/types/catalog.d.ts.map +0 -1
  81. package/dist/types/catalog.js +0 -3
  82. package/dist/types/catalog.js.map +0 -1
  83. package/dist/types/changes.d.ts +0 -272
  84. package/dist/types/changes.d.ts.map +0 -1
  85. package/dist/types/changes.js +0 -3
  86. package/dist/types/changes.js.map +0 -1
  87. package/dist/types/common.d.ts +0 -9
  88. package/dist/types/common.d.ts.map +0 -1
  89. package/dist/types/common.js +0 -3
  90. package/dist/types/common.js.map +0 -1
  91. package/dist/types/host.d.ts +0 -372
  92. package/dist/types/host.d.ts.map +0 -1
  93. package/dist/types/host.js +0 -3
  94. package/dist/types/host.js.map +0 -1
  95. package/dist/types/index.d.ts +0 -20
  96. package/dist/types/index.d.ts.map +0 -1
  97. package/dist/types/index.js +0 -8
  98. package/dist/types/index.js.map +0 -1
  99. package/dist/types/listen.d.ts +0 -48
  100. package/dist/types/listen.d.ts.map +0 -1
  101. package/dist/types/listen.js +0 -3
  102. package/dist/types/listen.js.map +0 -1
  103. package/dist/types/paging.d.ts +0 -10
  104. package/dist/types/paging.d.ts.map +0 -1
  105. package/dist/types/paging.js +0 -3
  106. package/dist/types/paging.js.map +0 -1
  107. package/dist/types/probe.d.ts +0 -46
  108. package/dist/types/probe.d.ts.map +0 -1
  109. package/dist/types/probe.js +0 -3
  110. package/dist/types/probe.js.map +0 -1
  111. package/dist/types/resources.d.ts +0 -83
  112. package/dist/types/resources.d.ts.map +0 -1
  113. package/dist/types/resources.js +0 -3
  114. package/dist/types/resources.js.map +0 -1
  115. package/dist/types/rpc.d.ts +0 -65
  116. package/dist/types/rpc.d.ts.map +0 -1
  117. package/dist/types/rpc.js +0 -3
  118. package/dist/types/rpc.js.map +0 -1
  119. package/dist/types/session.d.ts +0 -395
  120. package/dist/types/session.d.ts.map +0 -1
  121. package/dist/types/session.js +0 -3
  122. package/dist/types/session.js.map +0 -1
  123. package/dist/types/terminals.d.ts +0 -131
  124. package/dist/types/terminals.d.ts.map +0 -1
  125. package/dist/types/terminals.js +0 -3
  126. package/dist/types/terminals.js.map +0 -1
  127. package/dist/types/wire.d.ts +0 -62
  128. package/dist/types/wire.d.ts.map +0 -1
  129. package/dist/types/wire.js +0 -13
  130. package/dist/types/wire.js.map +0 -1
  131. package/dist/types/worktrees.d.ts +0 -86
  132. package/dist/types/worktrees.d.ts.map +0 -1
  133. package/dist/types/worktrees.js +0 -3
  134. package/dist/types/worktrees.js.map +0 -1
  135. package/dist/worktrees.d.ts +0 -27
  136. package/dist/worktrees.d.ts.map +0 -1
  137. package/dist/worktrees.js +0 -152
  138. package/dist/worktrees.js.map +0 -1
  139. package/src/automations.ts +0 -204
  140. package/src/catalog.ts +0 -53
  141. package/src/changes.ts +0 -629
  142. package/src/cron.ts +0 -251
  143. package/src/git.ts +0 -132
  144. package/src/host.ts +0 -5947
  145. package/src/index.ts +0 -40
  146. package/src/listen.ts +0 -240
  147. package/src/paging.ts +0 -56
  148. package/src/paths.ts +0 -19
  149. package/src/resources.ts +0 -513
  150. package/src/rpc.ts +0 -222
  151. package/src/scheduled.ts +0 -369
  152. package/src/terminals.ts +0 -353
  153. package/src/tools.ts +0 -64
  154. package/src/types/agent.ts +0 -255
  155. package/src/types/automations.ts +0 -164
  156. package/src/types/catalog.ts +0 -26
  157. package/src/types/changes.ts +0 -266
  158. package/src/types/common.ts +0 -9
  159. package/src/types/host.ts +0 -386
  160. package/src/types/index.ts +0 -27
  161. package/src/types/listen.ts +0 -53
  162. package/src/types/paging.ts +0 -11
  163. package/src/types/probe.ts +0 -42
  164. package/src/types/resources.ts +0 -107
  165. package/src/types/rpc.ts +0 -68
  166. package/src/types/session.ts +0 -415
  167. package/src/types/terminals.ts +0 -133
  168. package/src/types/wire.ts +0 -69
  169. package/src/types/worktrees.ts +0 -91
  170. package/src/worktrees.ts +0 -162
package/dist/resources.js DELETED
@@ -1,494 +0,0 @@
1
- import { watch as watchPath } from 'node:fs';
2
- import { copyFile, cp, mkdir as makeDir, readdir, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
3
- import { dirname, isAbsolute, join, relative, sep } from 'node:path';
4
- import { RpcError } from './rpc.js';
5
- import { within } from './paths.js';
6
- /**
7
- * The host's filesystem, as far as a client is allowed to see it.
8
- *
9
- * Every path is checked against the directories the host was told to serve
10
- * before anything is opened. A host that answered for any path is one that
11
- * anybody who can reach the port can read `~/.ssh/id_ed25519` through - and
12
- * this daemon is meant to be reachable, with a token, from another machine.
13
- *
14
- * `node:fs/promises` and `node:path` are used here because all three
15
- * supported runtimes provide them.
16
- */
17
- /** `-32008`, which the protocol has for a resource that is not there. */
18
- const NOT_FOUND = -32008;
19
- /** `-32009`, for one this client may not see. */
20
- const REFUSED = -32009;
21
- /** `-32010`, for a `createOnly` write onto something already there. */
22
- const ALREADY = -32010;
23
- /** `-32011`, for a write whose `ifMatch` no longer matches. */
24
- const CONFLICT = -32011;
25
- /** `file:///a/b` and `/a/b` both mean the same path here. */
26
- export const pathOf = (uri) => {
27
- const bare = uri.startsWith('file://') ? uri.slice('file://'.length) : uri;
28
- return decodeURIComponent(bare);
29
- };
30
- /** A path, back as the URI a client sends and receives. */
31
- export const uriOf = (path) => `file://${path}`;
32
- /** Whether `path` is `root` or is under it. */
33
- /**
34
- * Why this store cannot answer for a URI, in the terms of what it is.
35
- *
36
- * This one serves a filesystem, so anything that is not a `file:` URI is not
37
- * a path it got wrong - it is a URI somebody else was meant to answer. A
38
- * client publishes its own under `<scheme>://<clientId>/`, and a request for
39
- * one whose client has hung up arrives here having been routed nowhere. Told
40
- * as what it is, because `virtual://ahpc-6ec6cf49/hello.txt is not an
41
- * absolute path` sends whoever reads it looking at their path.
42
- */
43
- const why = (uri) => {
44
- const scheme = /^([a-zA-Z][\w+.-]*):/.exec(uri)?.[1];
45
- if (scheme !== undefined && scheme !== 'file') {
46
- return `${uri} is not this host's to read: nothing here serves ${scheme}:,`
47
- + ' and no connected client publishes it';
48
- }
49
- return `${uri} is not an absolute path`;
50
- };
51
- /**
52
- * The real path, if the client may see it.
53
- *
54
- * Resolved *before* the check, not after: `served/link` pointing at `/etc`
55
- * passes a textual test and opens something else entirely. A path that does
56
- * not exist yet is checked as written, since there is nothing to resolve.
57
- */
58
- export async function allowed(uri, roots) {
59
- const asked = pathOf(uri);
60
- if (!isAbsolute(asked)) {
61
- throw new RpcError(REFUSED, why(uri));
62
- }
63
- let real = asked;
64
- try {
65
- real = await realpath(asked);
66
- }
67
- catch { /* not there yet; the written path is what will be created */ }
68
- const roots_ = await Promise.all(roots.map((root) => realpath(root).catch(() => root)));
69
- if (!roots_.some((root) => within(root, real))) {
70
- throw new RpcError(REFUSED, `This host does not serve ${asked}. It serves ${roots.join(', ')}.`);
71
- }
72
- return real;
73
- }
74
- /**
75
- * The path to write, if the client may write it.
76
- *
77
- * Not `allowed`, and the difference is the whole security of the write half.
78
- * `allowed` resolves the path itself and falls back to the written text when
79
- * there is nothing there yet - which is right for reading, where a file that
80
- * does not exist has nothing to hand back either way. For a write it is a
81
- * hole: `served/link` pointing at `/etc` resolves to nothing for
82
- * `served/link/passwd`, so the textual test passes and the file is created
83
- * in `/etc`.
84
- *
85
- * So the *parent* is resolved, and the check is on that. A directory that is
86
- * not there yet is walked up until one is, because `mkdir -p` may be creating
87
- * several at once and none of them can escape a real ancestor.
88
- */
89
- export async function writable(uri, roots) {
90
- const asked = pathOf(uri);
91
- if (!isAbsolute(asked))
92
- throw new RpcError(REFUSED, why(uri));
93
- /** The nearest ancestor that exists, and how far up it was. */
94
- let up = dirname(asked);
95
- const climbed = [];
96
- for (;;) {
97
- const real = await realpath(up).catch(() => undefined);
98
- if (real !== undefined) {
99
- const roots_ = await Promise.all(roots.map((root) => realpath(root).catch(() => root)));
100
- if (!roots_.some((root) => within(root, real))) {
101
- throw new RpcError(REFUSED, `This host does not serve ${asked}. It serves ${roots.join(', ')}.`);
102
- }
103
- // Rebuilt from the resolved ancestor down, so what is opened is what was
104
- // checked rather than the text that was sent.
105
- return join(real, ...climbed.reverse(), asked.slice(asked.lastIndexOf(sep) + 1));
106
- }
107
- const next = dirname(up);
108
- // `/` resolving to nothing means the filesystem is gone, not that the
109
- // client found a way out.
110
- if (next === up)
111
- throw new RpcError(REFUSED, `This host does not serve ${asked}.`);
112
- climbed.push(up.slice(up.lastIndexOf(sep) + 1));
113
- up = next;
114
- }
115
- }
116
- /** The validator `resourceWrite`'s `ifMatch` compares against. */
117
- const tagOf = (size, mtimeMs) => `W/"${size.toString(16)}-${Math.trunc(mtimeMs).toString(16)}"`;
118
- /** One directory's entries, names only. */
119
- export async function list(uri, roots) {
120
- const path = await allowed(uri, roots);
121
- const found = await readdir(path, { withFileTypes: true }).catch(() => {
122
- throw new RpcError(NOT_FOUND, `No directory at ${uri}`);
123
- });
124
- return found
125
- .map((entry) => ({ name: entry.name, type: entry.isDirectory() ? 'directory' : 'file' }))
126
- // Directories first, then by name: a listing sorted by the order the
127
- // filesystem happens to return is a listing nobody can scan.
128
- .sort((a, b) => (a.type === b.type ? a.name.localeCompare(b.name) : a.type === 'directory' ? -1 : 1));
129
- }
130
- /**
131
- * What a path is, without opening it.
132
- *
133
- * `followSymlinks` decides which of the two questions is being asked - what
134
- * the link points at, or what the link is - and they have different answers
135
- * for size and type.
136
- */
137
- export async function resolve(uri, roots, followSymlinks = true) {
138
- const path = await allowed(uri, roots);
139
- const asked = followSymlinks ? path : pathOf(uri);
140
- const found = await stat(asked, { bigint: false }).catch(() => {
141
- throw new RpcError(NOT_FOUND, `Nothing at ${uri}`);
142
- });
143
- return {
144
- uri: uriOf(followSymlinks ? path : asked),
145
- type: found.isDirectory() ? 'directory' : found.isSymbolicLink() ? 'symlink' : 'file',
146
- ...(found.isDirectory() ? {} : { size: found.size }),
147
- mtime: found.mtime.toISOString(),
148
- ctime: found.birthtime.toISOString(),
149
- // Only for a file. A directory has no bytes to have been changed under
150
- // somebody, which is the only thing this is compared for.
151
- ...(found.isDirectory() ? {} : { etag: tagOf(found.size, found.mtimeMs) }),
152
- };
153
- }
154
- /** Text by extension, and bytes for anything this does not recognise. */
155
- const TEXTUAL = new Set([
156
- 'ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json', 'md', 'txt', 'css', 'html',
157
- 'yml', 'yaml', 'toml', 'sh', 'c', 'h', 'cc', 'cpp', 'hpp', 'py', 'rb', 'go',
158
- 'rs', 'java', 'sql', 'xml', 'svg', 'ini', 'conf', 'env', 'gitignore',
159
- ]);
160
- /**
161
- * One file's bytes, as text where that is meaningful.
162
- *
163
- * The encoding is *reported* rather than assumed by the caller: a client that
164
- * asked for utf-8 and got a PNG would render the replacement character four
165
- * hundred thousand times, so anything not recognisably textual comes back
166
- * base64 whatever was asked for - which the protocol allows for exactly this.
167
- */
168
- export async function read(uri, roots, wanted) {
169
- const path = await allowed(uri, roots);
170
- const bytes = await readFile(path).catch(() => {
171
- throw new RpcError(NOT_FOUND, `No file at ${uri}`);
172
- });
173
- const dot = path.lastIndexOf('.');
174
- const extension = dot === -1 ? '' : path.slice(dot + 1).toLowerCase();
175
- const textual = TEXTUAL.has(extension) || path.slice(path.lastIndexOf(sep) + 1).startsWith('.');
176
- if (wanted === 'base64' || !textual) {
177
- return { data: bytes.toString('base64'), encoding: 'base64' };
178
- }
179
- return { data: bytes.toString('utf8'), encoding: 'utf-8', contentType: 'text/plain' };
180
- }
181
- /**
182
- * Paths under `base` that start with what was typed.
183
- *
184
- * The typed text is a path fragment, so its last segment is the prefix and
185
- * everything before it is the directory to look in - which is what makes
186
- * `@src/ho` complete to `@src/host.ts` rather than looking for a file called
187
- * `src/ho`.
188
- */
189
- export async function complete(typed, base, roots, limit = 50) {
190
- const cut = typed.lastIndexOf('/');
191
- const inside = cut === -1 ? '' : typed.slice(0, cut + 1);
192
- const prefix = cut === -1 ? typed : typed.slice(cut + 1);
193
- const where = join(base, inside);
194
- const found = await list(uriOf(where), roots).catch(() => []);
195
- return found
196
- .filter((entry) => entry.name.toLowerCase().startsWith(prefix.toLowerCase()))
197
- // A directory keeps its slash, so the next keystroke goes into it rather
198
- // than starting again.
199
- .map((entry) => `${inside}${entry.name}${entry.type === 'directory' ? '/' : ''}`)
200
- .slice(0, limit);
201
- }
202
- /**
203
- * Write, create or splice one file.
204
- *
205
- * The three modes differ in where `position` is rooted, which the protocol is
206
- * explicit about and which is easy to get subtly wrong: `truncate` and
207
- * `insert` count from the start of the file and `append` counts *backwards
208
- * from EOF*, so `append` with `position: 0` is a POSIX append and with
209
- * `position: 5` splices five bytes before the end.
210
- *
211
- * Everything is done on a buffer and written once. A file is not a stream
212
- * here - the protocol has no chunked write - so reading it, splicing, and
213
- * putting it back is both the simplest form and the only one that can honour
214
- * `insert` at all.
215
- */
216
- export async function write(uri, roots, content) {
217
- const path = await writable(uri, roots);
218
- const incoming = Buffer.from(content.data, content.encoding === 'base64' ? 'base64' : 'utf8');
219
- const found = await stat(path).catch(() => undefined);
220
- if (found?.isDirectory())
221
- throw new RpcError(REFUSED, `${uri} is a directory`);
222
- if (content.createOnly === true && found !== undefined) {
223
- throw new RpcError(ALREADY, `${uri} already exists`);
224
- }
225
- if (content.ifMatch !== undefined) {
226
- // A file that is gone cannot match, and one that is there must. Both are
227
- // the same failure from the client's side: what it read is not what is
228
- // there now.
229
- const now = found === undefined ? undefined : tagOf(found.size, found.mtimeMs);
230
- if (now !== content.ifMatch) {
231
- throw new RpcError(CONFLICT, `${uri} has changed since ${content.ifMatch}`);
232
- }
233
- }
234
- const mode = content.mode ?? 'truncate';
235
- const at = content.position ?? 0;
236
- // Only read the existing bytes where a mode actually keeps some. A truncate
237
- // from zero - the ordinary save - reads nothing.
238
- const held = mode === 'truncate' && at === 0
239
- ? Buffer.alloc(0)
240
- : await readFile(path).catch(() => Buffer.alloc(0));
241
- let out;
242
- if (mode === 'append') {
243
- // Backwards from EOF, and clamped: a position past the start of the file
244
- // is a client asking to insert before the beginning.
245
- const cut = Math.max(0, held.length - Math.max(0, at));
246
- out = Buffer.concat([held.subarray(0, cut), incoming, held.subarray(cut)]);
247
- }
248
- else if (mode === 'insert') {
249
- const cut = Math.min(Math.max(0, at), held.length);
250
- out = Buffer.concat([held.subarray(0, cut), incoming, held.subarray(cut)]);
251
- }
252
- else {
253
- // Truncate: everything from `position` on is replaced, so what survives is
254
- // the head. A short file padded out to `position` would be inventing
255
- // bytes, so the head is however much of it there is.
256
- const cut = Math.min(Math.max(0, at), held.length);
257
- out = Buffer.concat([held.subarray(0, cut), incoming]);
258
- }
259
- await writeFile(path, out).catch((error) => {
260
- // A missing parent is the protocol's `NotFound`, said about the directory
261
- // rather than about the file the client asked to create.
262
- if (error.code === 'ENOENT')
263
- throw new RpcError(NOT_FOUND, `No directory for ${uri}`);
264
- throw new RpcError(REFUSED, `Could not write ${uri}: ${error.message}`);
265
- });
266
- }
267
- /**
268
- * Remove one.
269
- *
270
- * A directory needs `recursive`, and a directory without it is refused rather
271
- * than emptied: the protocol has the flag so that deleting a tree is
272
- * something a client asked for in as many words.
273
- */
274
- export async function remove(uri, roots, recursive = false) {
275
- const path = await writable(uri, roots);
276
- const found = await stat(path).catch(() => {
277
- throw new RpcError(NOT_FOUND, `Nothing at ${uri}`);
278
- });
279
- if (found.isDirectory() && !recursive) {
280
- throw new RpcError(REFUSED, `${uri} is a directory. Pass recursive to remove it.`);
281
- }
282
- await rm(path, { recursive, force: false }).catch((error) => {
283
- throw new RpcError(REFUSED, `Could not remove ${uri}: ${error.message}`);
284
- });
285
- }
286
- /** Make a directory, and the parents it needs. */
287
- export async function mkdir(uri, roots) {
288
- const path = await writable(uri, roots);
289
- await makeDir(path, { recursive: true }).catch((error) => {
290
- // `recursive` already tolerates an existing directory, so this is a *file*
291
- // in the way - which is a different thing to say.
292
- if (error.code === 'EEXIST' || error.code === 'ENOTDIR') {
293
- throw new RpcError(ALREADY, `${uri} is already a file`);
294
- }
295
- throw new RpcError(REFUSED, `Could not create ${uri}: ${error.message}`);
296
- });
297
- }
298
- /**
299
- * Both ends of a two-path operation, checked.
300
- *
301
- * The source has to exist and the destination has to be somewhere this host
302
- * serves - so they are different questions and neither implies the other. A
303
- * move out of the served set is the interesting one to refuse: it would carry
304
- * a file somewhere the host can no longer see, which is a deletion nobody
305
- * asked for.
306
- */
307
- async function pair(source, destination, roots, failIfExists) {
308
- const from = await allowed(source, roots);
309
- const to = await writable(destination, roots);
310
- await stat(from).catch(() => {
311
- throw new RpcError(NOT_FOUND, `Nothing at ${source}`);
312
- });
313
- if (failIfExists && await stat(to).then(() => true, () => false)) {
314
- throw new RpcError(ALREADY, `${destination} already exists`);
315
- }
316
- return { from, to };
317
- }
318
- /** Rename, within the served directories on both ends. */
319
- export async function move(source, destination, roots, failIfExists = false) {
320
- const { from, to } = await pair(source, destination, roots, failIfExists);
321
- await rename(from, to).catch((error) => {
322
- throw new RpcError(REFUSED, `Could not move ${source}: ${error.message}`);
323
- });
324
- }
325
- /** Copy, within the served directories on both ends. */
326
- export async function copy(source, destination, roots, failIfExists = false) {
327
- const { from, to } = await pair(source, destination, roots, failIfExists);
328
- const found = await stat(from);
329
- // A directory copy is a tree walk and a file copy is one syscall. `cp` does
330
- // both, but only `copyFile` reports the ordinary case honestly.
331
- const run = found.isDirectory()
332
- ? cp(from, to, { recursive: true, force: !failIfExists, errorOnExist: failIfExists })
333
- : copyFile(from, to);
334
- await run.catch((error) => {
335
- throw new RpcError(REFUSED, `Could not copy ${source}: ${error.message}`);
336
- });
337
- }
338
- /**
339
- * One glob, as a regular expression.
340
- *
341
- * Enough of the syntax to read what the protocol's own example sends -
342
- * `**\/.git/**`, `**\/node_modules/**` - and no more. `**` crosses
343
- * separators and `*` does not, which is the distinction the whole notation
344
- * exists for; everything else is escaped, so a pattern with a dot in it means
345
- * a dot.
346
- */
347
- const globbed = (pattern) => {
348
- let out = '';
349
- for (let i = 0; i < pattern.length; i++) {
350
- const c = pattern[i];
351
- if (c === '*') {
352
- if (pattern[i + 1] === '*') {
353
- i += 1;
354
- // `**/` also matches nothing at all, so `**\/.git/**` finds `.git/config`
355
- // at the root and not only in a subdirectory.
356
- if (pattern[i + 1] === '/') {
357
- i += 1;
358
- out += '(?:.*/)?';
359
- }
360
- else
361
- out += '.*';
362
- }
363
- else
364
- out += '[^/]*';
365
- }
366
- else if (c === '?')
367
- out += '[^/]';
368
- else
369
- out += c.replace(/[.+^${}()|[\]\\]/g, '\\$&');
370
- }
371
- return new RegExp(`^${out}$`);
372
- };
373
- /** How long to gather events before saying anything. */
374
- const COALESCE = 50;
375
- /**
376
- * How far before a watch started a file may have been created and still count
377
- * as new.
378
- *
379
- * `Date.now()` and the filesystem's own clock are not the same clock: a file
380
- * written immediately after a watch begins stats with a `birthtime` a
381
- * millisecond or two *before* the moment the watch recorded. Without an
382
- * allowance the first file created under a fresh watch is reported as an edit.
383
- */
384
- const SKEW = 50;
385
- /**
386
- * Tell me when that changes.
387
- *
388
- * `node:fs.watch`, and the two things about it worth stating. It reports one
389
- * event per file, so a save that rewrites four files is four events and a
390
- * `git checkout` is hundreds - hence the window: events are gathered and sent
391
- * as one batch, which is what the protocol asks a server to do and what keeps
392
- * a client from redrawing per file.
393
- *
394
- * And its event names are not the protocol's, nor even the same across
395
- * runtimes: creating a file is `rename` on Node and `change` on Deno, which is
396
- * the sort of thing only running it on both ever tells you. So the name is
397
- * ignored and the file is *looked at*. Gone is `deleted`. There and created
398
- * since this watch started is `added`. Anything else is `updated`.
399
- *
400
- * `birthtime` rather than an inventory of the tree, because the tree may be a
401
- * hundred thousand files and the question is only ever asked about the handful
402
- * that moved. A path already reported as `added` is `updated` from then on, so
403
- * a file created and then written twice is one appearance and two edits rather
404
- * than three appearances.
405
- */
406
- export async function watch(uri, roots, options, onChange) {
407
- const path = await allowed(uri, roots);
408
- await stat(path).catch(() => {
409
- throw new RpcError(NOT_FOUND, `Nothing at ${uri}`);
410
- });
411
- const excludes = (options.excludes ?? []).map(globbed);
412
- const includes = (options.includes ?? []).map(globbed);
413
- /** Whether a path relative to the root is one the caller asked about. */
414
- const wanted = (relative_) => {
415
- if (excludes.some((one) => one.test(relative_)))
416
- return false;
417
- return includes.length === 0 || includes.some((one) => one.test(relative_));
418
- };
419
- /** Paths that have moved since the last batch went out. */
420
- const pending = new Set();
421
- /** Paths already reported as having appeared, so they are edits from then on. */
422
- const announced = new Set();
423
- const since = Date.now() - SKEW;
424
- let timer;
425
- let closed = false;
426
- const flush = () => {
427
- timer = undefined;
428
- const held = [...pending];
429
- pending.clear();
430
- void (async () => {
431
- const items = [];
432
- for (const full of held) {
433
- const found = await stat(full).catch(() => undefined);
434
- if (found === undefined) {
435
- announced.delete(full);
436
- items.push({ uri: uriOf(full), type: 'deleted' });
437
- continue;
438
- }
439
- const fresh = found.birthtimeMs >= since && !announced.has(full);
440
- if (fresh)
441
- announced.add(full);
442
- items.push({ uri: uriOf(full), type: fresh ? 'added' : 'updated' });
443
- }
444
- // "An empty `changes.items` list MUST NOT be dispatched" - and the whole
445
- // batch can be empty once every event in it was filtered out.
446
- if (items.length > 0 && !closed)
447
- onChange(items);
448
- })().catch(() => { });
449
- };
450
- const held = watchPath(path, { recursive: options.recursive === true }, (kind, name) => {
451
- // A watcher can fire with no filename - the platform knows something moved
452
- // and not what. Nothing useful can be said about that, and saying the
453
- // directory changed would send a client to re-read the wrong thing.
454
- if (name === null || name === undefined)
455
- return;
456
- const relative_ = String(name).split(sep).join('/');
457
- if (!wanted(relative_))
458
- return;
459
- // `kind` is deliberately unread: see above.
460
- void kind;
461
- pending.add(join(path, String(name)));
462
- if (timer === undefined)
463
- timer = setTimeout(flush, COALESCE);
464
- });
465
- // Never the reason a daemon stays up: a watch is something a client asked
466
- // for, and the process should still exit when everything else is done.
467
- held.unref?.();
468
- held.on('error', () => { });
469
- return {
470
- close() {
471
- closed = true;
472
- if (timer !== undefined)
473
- clearTimeout(timer);
474
- held.close();
475
- },
476
- };
477
- }
478
- /**
479
- * The filesystem this process is on, as a host's `ResourceStore`.
480
- *
481
- * Kept out of `createHost` so the protocol imports no runtime: this file is
482
- * the one that touches `node:fs`, and a host that never opens a file never
483
- * loads it.
484
- *
485
- * ```ts
486
- * createHost({ path, agents, resources: fileResources() });
487
- * ```
488
- */
489
- export const fileResources = () => ({
490
- list, read, resolve, complete,
491
- write, remove, mkdir, move, copy,
492
- watch,
493
- });
494
- //# sourceMappingURL=resources.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,IAAI,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,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M,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI;IAChC,KAAK;CACN,CAAC,CAAC"}
package/dist/rpc.d.ts DELETED
@@ -1,63 +0,0 @@
1
- /**
2
- * JSON-RPC 2.0 framing.
3
- *
4
- * Decodes incoming frames, dispatches them to a handler and encodes the
5
- * replies. It holds no socket: `Wire` is the only thing it writes through, and
6
- * `listen.ts` connects that to whichever runtime's WebSocket is in use.
7
- *
8
- * A message with no `id` is a notification and receives no reply, whatever the
9
- * handler returns.
10
- */
11
- import type { Handler, Peer, Wire } from './types/rpc.js';
12
- export declare const PARSE_ERROR = -32700;
13
- export declare const INVALID_REQUEST = -32600;
14
- export declare const METHOD_NOT_FOUND = -32601;
15
- export declare const INTERNAL_ERROR = -32603;
16
- /**
17
- * An error carrying a JSON-RPC code, and whatever the client needs to act.
18
- *
19
- * The fields are declared and assigned rather than written as constructor
20
- * parameter properties, which are the one piece of TypeScript in this
21
- * codebase that *emits* code: a runtime that only strips types cannot run
22
- * them, and running this source unbuilt is worth more than the two lines.
23
- */
24
- export declare class RpcError extends Error {
25
- /** The JSON-RPC error code. */
26
- readonly code: number;
27
- /** Structured detail for the client, where there is any. */
28
- readonly data?: unknown;
29
- constructor(code: number, message: string, data?: unknown);
30
- }
31
- /** How long a question to a client waits before it is given up on. */
32
- export declare const ANSWER_TIMEOUT = 30000;
33
- /**
34
- * A question this host asked that never came back.
35
- *
36
- * Its own type rather than an `RpcError`: nothing arrived, so there is no code
37
- * a client chose and no data it sent. A timeout read as an error the client
38
- * returned is an answer attributed to somebody who never gave one.
39
- */
40
- export declare class RpcTimeout extends Error {
41
- /** The method that went unanswered. */
42
- readonly method: string;
43
- constructor(method: string, ms: number);
44
- }
45
- /** A question still in flight when the connection went away. */
46
- export declare class RpcClosed extends Error {
47
- /** The method that was in flight. */
48
- readonly method: string;
49
- constructor(method: string);
50
- }
51
- /** Ask and answer over one wire. */
52
- export declare function createPeer(wire: Wire): Peer;
53
- /**
54
- * One frame in, and whatever it deserves back.
55
- *
56
- * AHP is JSON-RPC with one deviation worth knowing: a *notification* is a
57
- * message with no `id`, and the client sends two of them - `unsubscribe` and
58
- * `dispatchAction`. Answering a notification is a protocol error, so the
59
- * absence of an id is what decides whether a reply is written, never the
60
- * handler's return value.
61
- */
62
- export declare function receive(raw: string, peer: Peer, handle: Handler): void;
63
- //# sourceMappingURL=rpc.d.ts.map
package/dist/rpc.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAW,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACnE,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC;;;;;;;GAOG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAM1D;AAED,sEAAsE;AACtE,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC;;;;;;GAMG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAKvC;AAED,gEAAgE;AAChE,qBAAa,SAAU,SAAQ,KAAK;IAClC,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAK3B;AAED,oCAAoC;AACpC,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA8E3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CA2DtE"}