@tangle-network/agent-app 0.43.49 → 0.43.51

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.
@@ -1,114 +0,0 @@
1
- import { K as FileMention } from './parts-IB-Kbb7z.js';
2
-
3
- /**
4
- * `createSandboxFileIndexRoute` — server side of `@`-file-mentions
5
- * (companion to sandbox-ui#184's composer mention primitive). Serves a flat,
6
- * ignore-filtered listing of the workspace sandbox so `useFileMentions`
7
- * (`/web-react`) can filter it client-side without a round trip per
8
- * keystroke.
9
- *
10
- * Same seam style as `createUploadRoute`: `authorize({ request })` resolves a
11
- * structural `{ tree(path, opts) }` handle (the shape of the sandbox SDK's
12
- * `box.fs.tree`) — no SDK import here. `authorize` also carries the
13
- * cold-box signal: a sandbox that isn't running yet answers `{ status:
14
- * 'warming' }` directly, never provisions-and-waits inside this route.
15
- *
16
- * A box can also be running with its workspace root not yet materialised, which
17
- * `authorize` cannot see; the route recognises that one signal off `fs.tree`
18
- * and answers `warming` too, so every consumer gets the retry-and-wait state
19
- * instead of a 500. Every other `tree()` failure propagates.
20
- */
21
-
22
- /** One entry from a structural `tree()` scan. Mirrors the sandbox SDK's
23
- * `FileTreeFile` (`path`, `size`, `mtime`) — `mtime` is unused here so it's
24
- * omitted from the structural match. */
25
- interface SandboxTreeFile {
26
- path: string;
27
- size: number;
28
- }
29
- /** Structural match of the sandbox SDK's `box.fs.tree` result shape
30
- * (`FileTreeResult`). `stats.truncated` is the only stat this route reads;
31
- * the rest ride through unread on the real SDK type. */
32
- interface SandboxTreeResult {
33
- root: string;
34
- files: SandboxTreeFile[];
35
- stats: {
36
- truncated: boolean;
37
- };
38
- }
39
- /** Structural match of the sandbox SDK's `box.fs` tree surface. */
40
- interface SandboxFileTreeSource {
41
- tree(path: string, options?: {
42
- maxDepth?: number;
43
- }): Promise<SandboxTreeResult>;
44
- }
45
- interface FileIndexReadyResponse {
46
- status: 'ready';
47
- /** Workspace-relative entries. Same shape as `FileMention` (`./wire`) so a
48
- * client can hand a response entry straight to `fileMentionsToParts` /
49
- * `buildMentionPromptBlock` without remapping. */
50
- files: FileMention[];
51
- /** True when either the underlying scan truncated (SDK-side cap) or this
52
- * route's own `maxEntries` cap trimmed the filtered list. The client
53
- * should show "showing first N files" rather than imply completeness. */
54
- truncated: boolean;
55
- generatedAt: string;
56
- }
57
- /** Cold-box answer: no provisioning happened, no files were scanned. The
58
- * client shows a warming state and retries — this route never blocks on a
59
- * box coming up. Two situations produce it: `authorize` reporting a box that
60
- * is not running, and a running box whose workspace root does not exist yet
61
- * (see `isMissingRootError`). */
62
- interface FileIndexWarmingResponse {
63
- status: 'warming';
64
- }
65
- type FileIndexResponse = FileIndexReadyResponse | FileIndexWarmingResponse;
66
- /** Short-TTL cache seam so repeat popover opens in the same session don't
67
- * re-scan the workspace. Host-provided (e.g. a KV binding); `key` is
68
- * whatever `authorize` returns as `cacheKey` — this route treats it opaquely. */
69
- interface FileIndexCache {
70
- get(key: string): Promise<FileIndexReadyResponse | null> | FileIndexReadyResponse | null;
71
- put(key: string, value: FileIndexReadyResponse, options?: {
72
- ttlSeconds?: number;
73
- }): Promise<void> | void;
74
- }
75
- type FileIndexAuthorization = {
76
- status: 'ready';
77
- /** Structural sandbox `fs` handle, usually `ensureWorkspaceSandbox(...)` → `box.fs`. */
78
- fs: SandboxFileTreeSource;
79
- /** Workspace root to index (e.g. `/home/agent`). */
80
- root: string;
81
- /** Extra ignore segments for this request, merged with the route's
82
- * defaults + `CreateSandboxFileIndexRouteOptions.ignore`. */
83
- ignore?: string[];
84
- /** Opaque cache key for the optional cache seam. Omit to skip caching
85
- * for this request (e.g. a workspace the host chooses not to cache). */
86
- cacheKey?: string;
87
- } | {
88
- status: 'warming';
89
- } | {
90
- status: 'denied';
91
- response: Response;
92
- };
93
- interface CreateSandboxFileIndexRouteOptions {
94
- /** Authenticate the caller, resolve the sandbox `fs` handle, and signal a
95
- * cold box — never provisions or waits. */
96
- authorize(args: {
97
- request: Request;
98
- }): Promise<FileIndexAuthorization>;
99
- /** Extra ignore segments beyond the route's defaults (node_modules, .git,
100
- * dotfiles/dot-dirs, common build dirs). Matched as exact path-segment
101
- * names, same rule as the defaults. */
102
- ignore?: string[];
103
- /** Passed to `fs.tree` as `options.maxDepth`. Default 12. */
104
- maxDepth?: number;
105
- /** Hard cap on entries returned after filtering. Default 5000. */
106
- maxEntries?: number;
107
- /** Optional host-provided cache seam. */
108
- cache?: FileIndexCache;
109
- /** Cache TTL in seconds when `cache` is set. Default 20. */
110
- cacheTtlSeconds?: number;
111
- }
112
- declare function createSandboxFileIndexRoute(options: CreateSandboxFileIndexRouteOptions): (request: Request) => Promise<Response>;
113
-
114
- export { type CreateSandboxFileIndexRouteOptions as C, type FileIndexAuthorization as F, type SandboxFileTreeSource as S, type FileIndexCache as a, type FileIndexReadyResponse as b, type FileIndexResponse as c, type FileIndexWarmingResponse as d, type SandboxTreeFile as e, type SandboxTreeResult as f, createSandboxFileIndexRoute as g };