@anhlp/alp-daemon 0.0.0-beta.2 → 0.0.1-beta.10

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 (104) hide show
  1. package/README.md +4 -0
  2. package/dist/THIRD-PARTY-NOTICES.txt +27 -2
  3. package/dist/alpd.js +39374 -17503
  4. package/dist/attachments.d.ts +187 -0
  5. package/dist/attachments.js +856 -0
  6. package/dist/build-manifest.json +41 -2
  7. package/dist/conversation.d.ts +119 -0
  8. package/dist/conversation.js +688 -0
  9. package/dist/disk.d.ts +67 -0
  10. package/dist/disk.js +152 -0
  11. package/dist/files.d.ts +156 -3
  12. package/dist/files.js +402 -59
  13. package/dist/git.d.ts +98 -0
  14. package/dist/git.js +1246 -0
  15. package/dist/gitignore.d.ts +5 -0
  16. package/dist/gitignore.js +26 -7
  17. package/dist/history.d.ts +24 -0
  18. package/dist/history.js +149 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +21 -1
  21. package/dist/lifecycle.d.ts +101 -0
  22. package/dist/lifecycle.js +239 -0
  23. package/dist/main.js +146 -21
  24. package/dist/model-catalog.d.ts +2 -0
  25. package/dist/model-catalog.js +44 -0
  26. package/dist/native-entry.d.ts +2 -0
  27. package/dist/native-entry.js +3 -0
  28. package/dist/native-register.d.ts +1 -0
  29. package/dist/native-register.js +13 -0
  30. package/dist/native-terminal.d.ts +45 -0
  31. package/dist/native-terminal.js +201 -0
  32. package/dist/operations.d.ts +20 -3
  33. package/dist/operations.js +62 -21
  34. package/dist/registry.d.ts +89 -0
  35. package/dist/registry.js +343 -0
  36. package/dist/scheduler.d.ts +96 -0
  37. package/dist/scheduler.js +298 -0
  38. package/dist/schedules.d.ts +70 -0
  39. package/dist/schedules.js +246 -0
  40. package/dist/server.d.ts +14 -2
  41. package/dist/server.js +903 -97
  42. package/dist/store.d.ts +72 -2
  43. package/dist/store.js +111 -4
  44. package/dist/terminal-native/README.md +201 -0
  45. package/dist/terminal-native/prebuilt/darwin-arm64/manifest.json +11 -0
  46. package/dist/terminal-native/prebuilt/darwin-arm64/terminal-owner +0 -0
  47. package/dist/terminal-native/prebuilt/darwin-x64/manifest.json +11 -0
  48. package/dist/terminal-native/prebuilt/darwin-x64/terminal-owner +0 -0
  49. package/dist/terminal-native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  50. package/dist/terminal-native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  51. package/dist/terminal-native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  52. package/dist/terminal-native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  53. package/dist/terminal-native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  54. package/dist/terminal-native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  55. package/dist/terminal-native/prebuilt/linux-x64-musl/manifest.json +10 -0
  56. package/dist/terminal-native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  57. package/dist/terminal-native/terminal-owner.c +389 -0
  58. package/dist/terminal-screen.d.ts +24 -0
  59. package/dist/terminal-screen.js +99 -0
  60. package/dist/terminals.d.ts +203 -0
  61. package/dist/terminals.js +570 -0
  62. package/dist/windows-terminal.d.ts +32 -0
  63. package/dist/windows-terminal.js +79 -0
  64. package/dist/worktrees.d.ts +65 -0
  65. package/dist/worktrees.js +318 -0
  66. package/native/README.md +201 -0
  67. package/native/prebuilt/darwin-arm64/manifest.json +11 -0
  68. package/native/prebuilt/darwin-arm64/terminal-owner +0 -0
  69. package/native/prebuilt/darwin-x64/manifest.json +11 -0
  70. package/native/prebuilt/darwin-x64/terminal-owner +0 -0
  71. package/native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  72. package/native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  73. package/native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  74. package/native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  75. package/native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  76. package/native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  77. package/native/prebuilt/linux-x64-musl/manifest.json +10 -0
  78. package/native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  79. package/native/terminal-owner.c +389 -0
  80. package/package.json +71 -8
  81. package/src/attachments.ts +908 -0
  82. package/src/conversation.ts +857 -0
  83. package/src/disk.ts +175 -0
  84. package/src/files.ts +535 -71
  85. package/src/git.ts +1220 -0
  86. package/src/gitignore.ts +25 -8
  87. package/src/history.ts +118 -0
  88. package/src/index.ts +7 -0
  89. package/src/lifecycle.ts +283 -0
  90. package/src/main.ts +154 -23
  91. package/src/model-catalog.ts +36 -0
  92. package/src/native-entry.ts +5 -0
  93. package/src/native-register.ts +21 -0
  94. package/src/native-terminal.ts +127 -0
  95. package/src/operations.ts +53 -22
  96. package/src/registry.ts +238 -0
  97. package/src/scheduler.ts +438 -0
  98. package/src/schedules.ts +297 -0
  99. package/src/server.ts +1019 -109
  100. package/src/store.ts +117 -4
  101. package/src/terminal-screen.ts +74 -0
  102. package/src/terminals.ts +653 -0
  103. package/src/windows-terminal.ts +74 -0
  104. package/src/worktrees.ts +382 -0
package/dist/git.d.ts ADDED
@@ -0,0 +1,98 @@
1
+ import type { Stats } from 'node:fs';
2
+ import type { GitCompare, GitDiffPage, GitFacts, GitStatus } from '@anhlp/alp-protocol';
3
+ /**
4
+ * `workspace.git.status` and `workspace.git.diff` (docs/protocol/alp-json-rpc-v1.md §12.5): the
5
+ * read-only Git state of a registry workspace, for Paseo's branch header and Changes panel.
6
+ *
7
+ * The workspace and its repository configuration are not trusted, so Git runs boxed in:
8
+ * - the Git found on the absolute PATH entries outside the workspace, by its real path
9
+ * (gitignore.ts resolveGit), spawned with an argument list, no shell, in the workspace's real
10
+ * path, its own process group killed at the call's deadline;
11
+ * - GIT_DIR and GIT_WORK_TREE set by alpd to the repository it checked (the workspace's `.git`,
12
+ * validated as the registry validates worktrees: core repositoryIdentity), every other GIT_*
13
+ * variable of alpd's dropped, no system or global configuration, no optional locks, no prompts,
14
+ * no lazy fetch, no replace objects, PATH without the workspace's entries;
15
+ * - configuration overrides so nothing the repository names runs: no fsmonitor, hooks to the null
16
+ * device, no pager, no colour, no external diff or textconv (flags too), every
17
+ * filter.<driver>.{clean,smudge,process} the repository's configuration names emptied and
18
+ * `required` false, no submodule recursion (`--ignore-submodules=dirty`: a gitlink's recorded
19
+ * commit only, never a Git run inside it), no network protocol, `diff.autoRefreshIndex` off (a
20
+ * porcelain `git diff` would otherwise rewrite the index even with GIT_OPTIONAL_LOCKS=0);
21
+ * - `--literal-pathspecs`: a path is never pathspec magic, and always after `--`; a base branch is
22
+ * a validated name resolved only as `refs/remotes/origin/<name>` then `refs/heads/<name>` with
23
+ * `rev-parse --verify --end-of-options`, never a revision expression;
24
+ * - every output read as a stream with a bound; at most GIT_READ.maxConcurrent Git processes at
25
+ * once in alpd.
26
+ * Content alpd shows is checked first: both sides of every file are scanned for a private key
27
+ * (files.ts PRIVATE_KEY), historical and deleted ones included; untracked files are read by alpd
28
+ * itself, confined as workspace.files.read confines a read. Errors carry fixed messages; the
29
+ * cause is logged, never answered.
30
+ *
31
+ * `workspace.git.facts` reads in the same box for an owner's host directory that need not be a
32
+ * registry workspace (a project-only, preflight or nested folder): its repository's root, branch,
33
+ * HEAD, origin and whether anything changed, never a file list or content.
34
+ */
35
+ export declare const GIT_READ: Readonly<{
36
+ /** One call (all of its Git processes, waiting for a turn included) gets this long. */
37
+ timeoutMs: 15000;
38
+ /** Git processes these reads run at once in alpd, and processes that may wait for one. */
39
+ maxConcurrent: 4;
40
+ maxQueued: 32;
41
+ maxErrorBytes: number;
42
+ /** Configuration, change list and untracked list output, at most. */
43
+ maxListBytes: number;
44
+ /** Ancestors retained per listing; exceeding the budget fails the read closed. */
45
+ maxAncestors: 16384;
46
+ /** One patch stream, at most (its files are at most a window's worth of content). */
47
+ maxPatchStreamBytes: number;
48
+ /** One side of a file scanned for a private key; a larger side is `too_large`. */
49
+ maxScanBytes: number;
50
+ /** Files whose content one window reads and diffs together, and their content's total. */
51
+ windowFiles: 64;
52
+ windowBytes: number;
53
+ /** Pathspec bytes on one command line. */
54
+ maxArgBytes: number;
55
+ /** Worktree files whose size and time enter a diff's snapshot. */
56
+ maxSnapshotStats: 5000;
57
+ }>;
58
+ /** A Git read that failed: answered as `1000 git_failed` with a fixed message; `cause` is logged only. */
59
+ export declare class GitReadFailed extends Error {
60
+ readonly cause: string;
61
+ constructor(cause: string);
62
+ }
63
+ /** Git processes these reads run now, for tests. */
64
+ export declare const gitReadsRunning: () => number;
65
+ /** A branch name as `git check-ref-format --branch` accepts one, never starting with '-' (no option, no revision syntax). */
66
+ export declare function validBranchName(name: unknown): name is string;
67
+ /**
68
+ * origin's URL as a client may see it: no user, password or token, no query or fragment; a local
69
+ * path, a `file:` URL or anything unrecognized is null.
70
+ */
71
+ export declare function scrubRemoteUrl(url: string | null): string | null;
72
+ export type GitReaderOptions = {
73
+ /** Resolves a workspaceId for status and diff; without it they are unavailable (facts needs none). */
74
+ registry?: {
75
+ resolve(workspaceId: string): Promise<string>;
76
+ };
77
+ /** Which git: a name looked up on PATH (outside the workspace), or an absolute path (tests). */
78
+ binary?: string;
79
+ timeoutMs?: number;
80
+ log?: (message: string, fields: Record<string, unknown>) => void;
81
+ /** Tests only: called after a window's contents were scanned and before Git writes their patch, where a racing writer could change a file. */
82
+ probe?: (step: 'scanned') => Promise<void> | void;
83
+ /** Tests only: how an untracked path's ancestor directories are inspected (default async lstat), to inject its failures. */
84
+ inspect?: (file: string) => Stats | Promise<Stats>;
85
+ };
86
+ type DiffParams = {
87
+ workspaceId: string;
88
+ compare: GitCompare;
89
+ path?: string;
90
+ cursor?: string;
91
+ };
92
+ export declare function createGitReader({ registry, binary, timeoutMs, log, probe, inspect }: GitReaderOptions): {
93
+ status: (workspaceId: unknown) => Promise<GitStatus>;
94
+ diff: (params: DiffParams) => Promise<GitDiffPage>;
95
+ facts: (directory: unknown) => Promise<GitFacts>;
96
+ };
97
+ export type GitReader = ReturnType<typeof createGitReader>;
98
+ export {};