@anhlp/alp-daemon 0.0.1-beta.4 → 0.0.1-beta.6

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 (82) hide show
  1. package/dist/THIRD-PARTY-NOTICES.txt +26 -1
  2. package/dist/alpd.js +10768 -2592
  3. package/dist/attachments.d.ts +25 -49
  4. package/dist/attachments.js +45 -8
  5. package/dist/build-manifest.json +14 -1
  6. package/dist/conversation.js +18 -2
  7. package/dist/disk.d.ts +67 -0
  8. package/dist/disk.js +152 -0
  9. package/dist/files.d.ts +141 -2
  10. package/dist/files.js +377 -68
  11. package/dist/git.d.ts +8 -2
  12. package/dist/git.js +111 -12
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +3 -0
  15. package/dist/main.js +57 -12
  16. package/dist/native-terminal.d.ts +45 -0
  17. package/dist/native-terminal.js +198 -0
  18. package/dist/operations.d.ts +12 -2
  19. package/dist/operations.js +22 -11
  20. package/dist/registry.js +1 -1
  21. package/dist/scheduler.js +8 -2
  22. package/dist/schedules.d.ts +2 -1
  23. package/dist/schedules.js +6 -4
  24. package/dist/server.d.ts +4 -2
  25. package/dist/server.js +171 -43
  26. package/dist/store.d.ts +3 -1
  27. package/dist/store.js +4 -3
  28. package/dist/terminal-native/README.md +201 -0
  29. package/dist/terminal-native/prebuilt/darwin-arm64/manifest.json +11 -0
  30. package/dist/terminal-native/prebuilt/darwin-arm64/terminal-owner +0 -0
  31. package/dist/terminal-native/prebuilt/darwin-x64/manifest.json +11 -0
  32. package/dist/terminal-native/prebuilt/darwin-x64/terminal-owner +0 -0
  33. package/dist/terminal-native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  34. package/dist/terminal-native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  35. package/dist/terminal-native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  36. package/dist/terminal-native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  37. package/dist/terminal-native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  38. package/dist/terminal-native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  39. package/dist/terminal-native/prebuilt/linux-x64-musl/manifest.json +10 -0
  40. package/dist/terminal-native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  41. package/dist/terminal-native/terminal-owner.c +389 -0
  42. package/dist/terminal-screen.d.ts +24 -0
  43. package/dist/terminal-screen.js +99 -0
  44. package/dist/terminals.d.ts +43 -7
  45. package/dist/terminals.js +222 -139
  46. package/dist/windows-terminal.d.ts +29 -0
  47. package/dist/windows-terminal.js +122 -0
  48. package/dist/worktrees.d.ts +25 -1
  49. package/dist/worktrees.js +74 -2
  50. package/native/README.md +201 -0
  51. package/native/prebuilt/darwin-arm64/manifest.json +11 -0
  52. package/native/prebuilt/darwin-arm64/terminal-owner +0 -0
  53. package/native/prebuilt/darwin-x64/manifest.json +11 -0
  54. package/native/prebuilt/darwin-x64/terminal-owner +0 -0
  55. package/native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  56. package/native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  57. package/native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  58. package/native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  59. package/native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  60. package/native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  61. package/native/prebuilt/linux-x64-musl/manifest.json +10 -0
  62. package/native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  63. package/native/terminal-owner.c +389 -0
  64. package/package.json +11 -7
  65. package/src/attachments.ts +46 -8
  66. package/src/conversation.ts +22 -2
  67. package/src/disk.ts +175 -0
  68. package/src/files.ts +505 -80
  69. package/src/git.ts +113 -18
  70. package/src/index.ts +1 -0
  71. package/src/main.ts +53 -13
  72. package/src/native-terminal.ts +122 -0
  73. package/src/operations.ts +28 -12
  74. package/src/registry.ts +1 -1
  75. package/src/scheduler.ts +13 -3
  76. package/src/schedules.ts +5 -2
  77. package/src/server.ts +164 -36
  78. package/src/store.ts +2 -1
  79. package/src/terminal-screen.ts +74 -0
  80. package/src/terminals.ts +205 -155
  81. package/src/windows-terminal.ts +123 -0
  82. package/src/worktrees.ts +97 -2
package/dist/files.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare const LIMITS: Readonly<{
27
27
  }>;
28
28
  export declare class FilesError extends Error {
29
29
  }
30
+ type Kind = 'file' | 'directory';
30
31
  /**
31
32
  * The files under `projectRoot` matching `query`, best first. `projectRoot` must be an absolute path
32
33
  * of a directory; anything else throws FilesError.
@@ -42,6 +43,63 @@ export declare function searchWorkspaceFiles(projectRoot: string, { query, limit
42
43
  }>;
43
44
  truncated?: true;
44
45
  }>;
46
+ /**
47
+ * Bounds of one workspace.files.find walk, deeper and larger than search's: as complete as
48
+ * `git ls-files` is for the Paseo bridge, which ranks the whole set itself. A snapshot of the
49
+ * names it found is kept `ttlMs` after its last page, at most `snapshots` of them in alpd.
50
+ */
51
+ export declare const FIND_LIMITS: Readonly<{
52
+ depth: 64;
53
+ scanned: 100000;
54
+ ms: 10000;
55
+ ttlMs: 60000;
56
+ snapshots: 16;
57
+ }>;
58
+ export type FoundEntry = {
59
+ path: string;
60
+ kind: Kind;
61
+ };
62
+ export type FindOptions = {
63
+ query?: string;
64
+ kinds?: readonly Kind[];
65
+ matchMode?: 'subsequence' | 'suffix';
66
+ now?: () => number;
67
+ git?: GitCheckOptions;
68
+ };
69
+ /** Whether `candidate` holds the characters of `query` in order (the Paseo bridge's last ranking tier). */
70
+ export declare function inOrder(query: string, candidate: string): boolean;
71
+ /**
72
+ * Every file and directory under `projectRoot` whose path, case-insensitively, holds `query`'s
73
+ * characters in order (`subsequence`, every name the Paseo bridge's ranking can match) or is it or
74
+ * ends with `/query` (`suffix`); every name for an empty query. In path order (code units).
75
+ *
76
+ * As `git ls-files --cached --others --exclude-standard` lists a repository: dot names included,
77
+ * .gitignore'd ones left out (Git's answer, failing closed as search does), and links whose real
78
+ * path is inside the root listed as their target's kind, never entered. Outside a repository,
79
+ * names starting with `.` and SKIPPED_FOLDERS are skipped. Blocked paths never appear. Bounded by
80
+ * FIND_LIMITS; `truncated` when a bound stopped the walk.
81
+ */
82
+ export declare function findWorkspaceEntries(projectRoot: string, { query, kinds, matchMode, now, git }?: FindOptions): Promise<{
83
+ entries: FoundEntry[];
84
+ truncated?: true;
85
+ }>;
86
+ /**
87
+ * workspace.files.find in pages: the first call (no cursor) walks and keeps the snapshot; each
88
+ * `nextCursor` names the snapshot and where the next page starts, for the connection (`owner`) that
89
+ * asked and the same params only. A snapshot is dropped after its last page, FIND_LIMITS.ttlMs
90
+ * after its last use, or when more than FIND_LIMITS.snapshots are kept (the oldest first).
91
+ */
92
+ export declare function createFindPages({ now, git }?: {
93
+ now?: () => number;
94
+ git?: GitCheckOptions;
95
+ }): (owner: unknown, projectRoot: string, { query, kinds, matchMode, limit, cursor }?: Omit<FindOptions, "now" | "git"> & {
96
+ limit?: number;
97
+ cursor?: string;
98
+ }) => Promise<{
99
+ entries: FoundEntry[];
100
+ nextCursor?: string;
101
+ truncated?: true;
102
+ }>;
45
103
  /**
46
104
  * A refusal of workspace.files.list or workspace.files.read: the JSON-RPC code and `data.reason`
47
105
  * alpd answers with. Messages are fixed or name only the client's own relative path, never a host
@@ -85,23 +143,35 @@ export type ListedEntry = {
85
143
  kind: 'file' | 'directory';
86
144
  size?: number;
87
145
  modifiedAt?: string;
146
+ target?: string;
88
147
  };
89
148
  /**
90
149
  * The entries of a directory under `projectRoot` (its root without `relative`): regular files and
91
150
  * directories only (links, sockets, devices are left out), never a blocked one (blockedFilePath)
92
151
  * and, unless `includeIgnored`, none .gitignore'd. Directories first, then by name. Each directory
93
152
  * on the way is checked (real directory, real path, same device and inode) before and after the
94
- * read. At most WORKSPACE_FILES.maxListEntries entries; then `truncated`.
153
+ * read. At most WORKSPACE_FILES.maxListEntries entries; then `truncated` and `nextCursor`, which
154
+ * `cursor` takes to answer the entries after them.
155
+ *
156
+ * With `internalLinks` (workspace.files.browse): a link whose real path is inside the root and not
157
+ * blocked is listed as what it leads to, with that path as `target`, and `relative` may go through
158
+ * such links (the answer's `target` then names the directory listed, and entries are under it).
159
+ * Both the link's path and its target must pass .gitignore. A link leading outside is left out,
160
+ * and refused (`outside`) as `relative`.
95
161
  */
96
- export declare function listWorkspaceDirectory(projectRoot: string, { path: relative, includeIgnored, now, probe, git }?: {
162
+ export declare function listWorkspaceDirectory(projectRoot: string, { path: relative, includeIgnored, cursor, internalLinks, now, probe, git }?: {
97
163
  path?: string;
98
164
  includeIgnored?: boolean;
165
+ cursor?: string;
166
+ internalLinks?: boolean;
99
167
  now?: () => number;
100
168
  probe?: FileProbe;
101
169
  git?: GitCheckOptions;
102
170
  }): Promise<{
103
171
  entries: ListedEntry[];
104
172
  truncated?: true;
173
+ nextCursor?: string;
174
+ target?: string;
105
175
  }>;
106
176
  /**
107
177
  * The content of a UTF-8 text file under `projectRoot`, read-only: refused when it is blocked
@@ -121,3 +191,72 @@ export declare function readWorkspaceFile(projectRoot: string, { path: relative,
121
191
  size: number;
122
192
  modifiedAt: string;
123
193
  }>;
194
+ /** Images a preview answers as such, by extension (the Paseo bridge's own list). */
195
+ export declare const PREVIEW_IMAGES: Readonly<Record<string, string>>;
196
+ export type FilePreview = {
197
+ path: string;
198
+ target?: string;
199
+ kind: 'text' | 'image' | 'binary';
200
+ mimeType: string;
201
+ size: number;
202
+ modifiedAt: string;
203
+ revision: string;
204
+ encoding: 'base64' | 'none';
205
+ content?: string;
206
+ offset?: number;
207
+ nextOffset?: number;
208
+ };
209
+ /**
210
+ * A preview of a file under `projectRoot`, as the Paseo bridge's Files panel showed one: `image`
211
+ * by extension (PREVIEW_IMAGES), else `text` when the whole file is (classify), else `binary`
212
+ * (metadata only, no content). Text and image bytes come as base64 in chunks of at most
213
+ * WORKSPACE_FILES.maxPreviewChunkBytes: the first from `offset` 0, each next one from the
214
+ * `nextOffset` before with the `revision` the first answered (a file that changed since is
215
+ * refused `changed`, so the chunks are of one file). At most `maxBytes` (and
216
+ * WORKSPACE_FILES.maxPreviewBytes), else `too_large`.
217
+ *
218
+ * Refused as workspace.files.read refuses: a blocked path, a .gitignore'd one (unless
219
+ * `includeIgnored`), missing or not a regular file, reached through a link, more than one name, a
220
+ * change while it is read; a text file holding a private key (and any chunk holding one) is
221
+ * refused `blocked_path`. With `internalLinks`, `relative` may go through links whose real path is
222
+ * inside the root (internalSegments): that real path, answered as `target`, is what is read, and
223
+ * both paths must pass .gitignore.
224
+ */
225
+ export declare function previewWorkspaceFile(projectRoot: string, { path: relative, includeIgnored, internalLinks, maxBytes, offset, revision, probe, git }: {
226
+ path: string;
227
+ includeIgnored?: boolean;
228
+ internalLinks?: boolean;
229
+ maxBytes?: number;
230
+ offset?: number;
231
+ revision?: string;
232
+ probe?: FileProbe;
233
+ git?: GitCheckOptions;
234
+ }): Promise<FilePreview>;
235
+ /** Bounds of host.directories.search: home's directories `depth` levels down, `scanned` looked at; a typed path's parent read up to `listed` entries. */
236
+ export declare const HOST_DIRECTORIES: Readonly<{
237
+ depth: 4;
238
+ scanned: 5000;
239
+ listed: 20000;
240
+ defaultLimit: 30;
241
+ maxLimit: 100;
242
+ }>;
243
+ /** How well a name matches a query, as the Paseo bridge ranks names: 0 equal, 1 starts with it, 2 holds it, 3 its letters in order, undefined none; case-insensitive. */
244
+ export declare function nameRank(candidate: string, query: string): number | undefined;
245
+ /**
246
+ * The daemon host's directories for the folder a user adds as a project, as the Paseo bridge
247
+ * suggested them: a `query` that is a path (absolute, or `~` and `~/…` under `home`) answers the
248
+ * directories of its parent whose name starts with what follows the last separator (dot names only
249
+ * when that starts with `.`), by name; any other word answers the directories under `home`, up to
250
+ * HOST_DIRECTORIES.depth levels and .scanned of them (no dot names, none of SKIPPED_FOLDERS), whose
251
+ * name matches it (nameRank), best, then nearest, first. Names only; a link is neither listed nor
252
+ * entered. Absolute paths: the caller is the host's owner (never remote).
253
+ */
254
+ export declare function searchHostDirectories(query: unknown, { limit, home }?: {
255
+ limit?: number;
256
+ home?: string;
257
+ }): Promise<{
258
+ entries: Array<{
259
+ path: string;
260
+ }>;
261
+ truncated?: true;
262
+ }>;