@anhlp/alp-daemon 0.0.1-beta.3 → 0.0.1-beta.4
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.
- package/README.md +4 -0
- package/dist/alpd.js +10350 -3346
- package/dist/attachments.d.ts +211 -0
- package/dist/attachments.js +819 -0
- package/dist/build-manifest.json +21 -1
- package/dist/conversation.d.ts +119 -0
- package/dist/conversation.js +672 -0
- package/dist/files.d.ts +13 -0
- package/dist/files.js +15 -0
- package/dist/git.d.ts +87 -0
- package/dist/git.js +1093 -0
- package/dist/gitignore.d.ts +5 -0
- package/dist/gitignore.js +7 -1
- package/dist/history.d.ts +24 -0
- package/dist/history.js +149 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +18 -1
- package/dist/lifecycle.d.ts +101 -0
- package/dist/lifecycle.js +239 -0
- package/dist/main.js +9 -3
- package/dist/registry.d.ts +89 -0
- package/dist/registry.js +343 -0
- package/dist/scheduler.d.ts +96 -0
- package/dist/scheduler.js +290 -0
- package/dist/schedules.d.ts +69 -0
- package/dist/schedules.js +244 -0
- package/dist/server.d.ts +11 -1
- package/dist/server.js +698 -76
- package/dist/store.d.ts +69 -1
- package/dist/store.js +109 -3
- package/dist/terminals.d.ts +157 -0
- package/dist/terminals.js +487 -0
- package/dist/worktrees.d.ts +41 -0
- package/dist/worktrees.js +246 -0
- package/package.json +64 -5
- package/src/attachments.ts +870 -0
- package/src/conversation.ts +837 -0
- package/src/files.ts +23 -2
- package/src/git.ts +1045 -0
- package/src/gitignore.ts +10 -0
- package/src/history.ts +118 -0
- package/src/index.ts +6 -0
- package/src/lifecycle.ts +283 -0
- package/src/main.ts +9 -3
- package/src/registry.ts +238 -0
- package/src/scheduler.ts +422 -0
- package/src/schedules.ts +294 -0
- package/src/server.ts +810 -86
- package/src/store.ts +115 -3
- package/src/terminals.ts +591 -0
- package/src/worktrees.ts +287 -0
package/src/files.ts
CHANGED
|
@@ -327,8 +327,29 @@ async function readConfined(file: string, maxBytes: number, probe?: FileProbe):
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
/**
|
|
331
|
+
* The bytes of the file at `segments` under the real root `root`, confined as readWorkspaceFile
|
|
332
|
+
* confines a read (every directory on the way a real directory reached by name and the same after
|
|
333
|
+
* the read; the file a regular file with one name, opened without following a link, the same by
|
|
334
|
+
* handle and by name), or `too_large` past `maxBytes`. Throws FileAccessError `linked` or
|
|
335
|
+
* `not_found` (its message names only `relative`). No block list or .gitignore check: the caller
|
|
336
|
+
* decides what may be read (workspace.git.diff, docs/protocol/alp-json-rpc-v1.md §12.5).
|
|
337
|
+
*/
|
|
338
|
+
export async function readConfinedFile(root: string, segments: readonly string[], relative: string, maxBytes: number): Promise<Buffer | 'too_large'> {
|
|
339
|
+
const chain = await directoryChain(root, segments.slice(0, -1), relative);
|
|
340
|
+
let read: { bytes: Buffer } | undefined;
|
|
341
|
+
try {
|
|
342
|
+
read = await readConfined(path.join(root, ...segments), maxBytes);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if ((error as { linked?: boolean }).linked) throw linked(relative);
|
|
345
|
+
throw notFound(relative);
|
|
346
|
+
}
|
|
347
|
+
await sameChain(chain, relative);
|
|
348
|
+
return read === undefined ? 'too_large' : read.bytes;
|
|
349
|
+
}
|
|
350
|
+
|
|
330
351
|
/** Paseo's isLikelyBinary (file-explorer/service.ts at b63a325): a NUL byte, or over 30% control characters. */
|
|
331
|
-
function likelyBinary(buffer: Buffer): boolean {
|
|
352
|
+
export function likelyBinary(buffer: Buffer): boolean {
|
|
332
353
|
if (!buffer.length) return false;
|
|
333
354
|
let suspicious = 0;
|
|
334
355
|
for (const byte of buffer) {
|
|
@@ -340,7 +361,7 @@ function likelyBinary(buffer: Buffer): boolean {
|
|
|
340
361
|
|
|
341
362
|
// The BOM is kept: the content is the file's bytes, decoded.
|
|
342
363
|
/** PEM, OpenSSH and PuTTY private-key headers: a file holding one is refused whatever its name. */
|
|
343
|
-
const PRIVATE_KEY = /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY(?: BLOCK)?-----|PuTTY-User-Key-File-\d+:/;
|
|
364
|
+
export const PRIVATE_KEY = /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY(?: BLOCK)?-----|PuTTY-User-Key-File-\d+:/;
|
|
344
365
|
|
|
345
366
|
const UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
346
367
|
|