agent-web-os 0.1.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.
- package/dist/__sw__.js +421 -0
- package/dist/chunk-PR4QN5HX.js +43 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/chunk-QV36H6BY.js +5325 -0
- package/dist/chunk-QV36H6BY.js.map +1 -0
- package/dist/index.cjs +61970 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +250 -0
- package/dist/index.d.ts +250 -0
- package/dist/index.js +56165 -0
- package/dist/index.js.map +1 -0
- package/dist/index.web-UN7GB7PC.js +434 -0
- package/dist/index.web-UN7GB7PC.js.map +1 -0
- package/dist/npm-C6N7BGOG.js +14 -0
- package/dist/npm-C6N7BGOG.js.map +1 -0
- package/package.json +37 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as just_bash from 'just-bash';
|
|
2
|
+
import { InMemoryFs, FileContent, MkdirOptions, RmOptions, CpOptions } from 'just-bash';
|
|
3
|
+
import { CommandContext, ExecResult, Bash } from 'just-bash/browser';
|
|
4
|
+
export { Bash, CommandContext, ExecResult, defineCommand } from 'just-bash/browser';
|
|
5
|
+
|
|
6
|
+
type ObservableInMemoryFsWriteFileSyncOptions = Parameters<InMemoryFs["writeFileSync"]>[2];
|
|
7
|
+
type ObservableInMemoryFsWriteFileSyncMetadata = Parameters<InMemoryFs["writeFileSync"]>[3];
|
|
8
|
+
type ObservableInMemoryFsWriteFileLazy = Parameters<InMemoryFs["writeFileLazy"]>[1];
|
|
9
|
+
type ObservableInMemoryFsWriteFileLazyMetadata = Parameters<InMemoryFs["writeFileLazy"]>[2];
|
|
10
|
+
type ObservableInMemoryFsWriteOptions = Parameters<InMemoryFs["writeFile"]>[2];
|
|
11
|
+
type ObservableInMemoryFsEntryType = "file" | "directory" | "symlink";
|
|
12
|
+
type ObservableInMemoryFsChangeEventName = "add" | "addDir" | "change" | "unlink" | "unlinkDir";
|
|
13
|
+
type ObservableInMemoryFsChangeEvent = {
|
|
14
|
+
event: ObservableInMemoryFsChangeEventName;
|
|
15
|
+
path: string;
|
|
16
|
+
entryType: ObservableInMemoryFsEntryType;
|
|
17
|
+
previousPath?: string;
|
|
18
|
+
};
|
|
19
|
+
type ObservableInMemoryFsOptions = {
|
|
20
|
+
/** Whether to console.log change events (default: false) */
|
|
21
|
+
consoleLogChanges?: boolean;
|
|
22
|
+
/** Root path used to filter which changes are console-logged (default: "/") */
|
|
23
|
+
workspaceRoot?: string;
|
|
24
|
+
};
|
|
25
|
+
declare function assertObservableInMemoryFs(value: unknown): ObservableInMemoryFs;
|
|
26
|
+
type ObservableInMemoryFsListener = (event: ObservableInMemoryFsChangeEvent) => void;
|
|
27
|
+
declare class ObservableInMemoryFs extends InMemoryFs {
|
|
28
|
+
private listeners;
|
|
29
|
+
private lazyPaths;
|
|
30
|
+
private suppressSyncEventCount;
|
|
31
|
+
private suppressConsoleLogCount;
|
|
32
|
+
private suppressChangeEmissionCount;
|
|
33
|
+
private readonly consoleLogChanges;
|
|
34
|
+
private readonly isLoggableWorkspacePath;
|
|
35
|
+
constructor(options?: ObservableInMemoryFsOptions);
|
|
36
|
+
isPathLazy(filePath: string): boolean;
|
|
37
|
+
private clearLazyPath;
|
|
38
|
+
private clearLazyPathsUnder;
|
|
39
|
+
subscribe(listener: ObservableInMemoryFsListener): () => void;
|
|
40
|
+
private shouldEmitChanges;
|
|
41
|
+
suppressObservability<T>(operation: () => Promise<T>): Promise<T>;
|
|
42
|
+
private queueChangeEmission;
|
|
43
|
+
private areConsoleLogsSuppressed;
|
|
44
|
+
private runWithSuppressedConsoleLogs;
|
|
45
|
+
private shouldConsoleLogChangeEvent;
|
|
46
|
+
private emit;
|
|
47
|
+
private areSyncEventsSuppressed;
|
|
48
|
+
private runWithSuppressedSyncEvents;
|
|
49
|
+
writeFileSync(path: string, content: FileContent, options?: ObservableInMemoryFsWriteFileSyncOptions, metadata?: ObservableInMemoryFsWriteFileSyncMetadata): void;
|
|
50
|
+
writeFileLazy(path: string, lazy: ObservableInMemoryFsWriteFileLazy, metadata?: ObservableInMemoryFsWriteFileLazyMetadata): void;
|
|
51
|
+
private emitWriteEvent;
|
|
52
|
+
private emitMkdirEvent;
|
|
53
|
+
private emitRemovalEvent;
|
|
54
|
+
mkdirSync(path: string, options?: MkdirOptions): void;
|
|
55
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
56
|
+
stat(path: string): Promise<just_bash.FsStat>;
|
|
57
|
+
lstat(path: string): Promise<just_bash.FsStat>;
|
|
58
|
+
writeFile(path: string, content: FileContent, options?: ObservableInMemoryFsWriteOptions): Promise<void>;
|
|
59
|
+
appendFile(path: string, content: FileContent, options?: ObservableInMemoryFsWriteOptions): Promise<void>;
|
|
60
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
61
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
62
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
63
|
+
mv(src: string, dest: string): Promise<void>;
|
|
64
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
65
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
66
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
67
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type BinCommandRegistrar = (name: string, handler: (args: string[], ctx: CommandContext) => Promise<ExecResult>) => void;
|
|
71
|
+
type VitePreviewListener = (previewUrl: string | null) => void;
|
|
72
|
+
type BatchFileLoader = (paths: string[]) => Promise<Map<string, Uint8Array>>;
|
|
73
|
+
interface AlmostNodeSessionVfs {
|
|
74
|
+
existsSync(path: string): boolean;
|
|
75
|
+
statSync(path: string): {
|
|
76
|
+
isDirectory(): boolean;
|
|
77
|
+
isFile(): boolean;
|
|
78
|
+
};
|
|
79
|
+
readFileSync(path: string, encoding?: string): any;
|
|
80
|
+
writeFileSync(path: string, data: string | Uint8Array): void;
|
|
81
|
+
mkdirSync(path: string, options?: {
|
|
82
|
+
recursive?: boolean;
|
|
83
|
+
}): void;
|
|
84
|
+
readdirSync(path: string): string[];
|
|
85
|
+
unlinkSync(path: string): void;
|
|
86
|
+
rmdirSync(path: string): void;
|
|
87
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
88
|
+
}
|
|
89
|
+
declare global {
|
|
90
|
+
interface Window {
|
|
91
|
+
__esbuild?: unknown;
|
|
92
|
+
__esbuildInitPromise?: Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
declare class AlmostNodeSession {
|
|
96
|
+
private readonly fs;
|
|
97
|
+
private readonly _vfs;
|
|
98
|
+
get vfs(): AlmostNodeSessionVfs;
|
|
99
|
+
private readonly disposeObservableSubscription;
|
|
100
|
+
private initializePromise;
|
|
101
|
+
private initialized;
|
|
102
|
+
private pendingOperations;
|
|
103
|
+
private suppressObservableMirrorCount;
|
|
104
|
+
private registeredBinCommands;
|
|
105
|
+
private binCommandRegistrar?;
|
|
106
|
+
private batchFileLoader?;
|
|
107
|
+
private viteServer?;
|
|
108
|
+
private vitePort;
|
|
109
|
+
private vitePreviewUrl;
|
|
110
|
+
private vitePreviewListener?;
|
|
111
|
+
private parsedPackageJsonCache;
|
|
112
|
+
private transformedTextCache;
|
|
113
|
+
constructor(fs: ObservableInMemoryFs);
|
|
114
|
+
dispose(): void;
|
|
115
|
+
setBinCommandRegistrar(registrar: BinCommandRegistrar): void;
|
|
116
|
+
setBatchFileLoader(loader: BatchFileLoader): void;
|
|
117
|
+
setVitePreviewListener(listener: VitePreviewListener | undefined): void;
|
|
118
|
+
setViteHmrTarget(target: Window | null): void;
|
|
119
|
+
/**
|
|
120
|
+
* Resolve a bare module specifier (e.g. "@mui/material" or "react") to a
|
|
121
|
+
* `/node_modules/...` URL path that the ViteDevServer can serve.
|
|
122
|
+
*
|
|
123
|
+
* Resolution order mirrors Node/bundler conventions:
|
|
124
|
+
* 1. package.json "exports" (condition "import" → "default")
|
|
125
|
+
* 2. package.json "module"
|
|
126
|
+
* 3. package.json "main"
|
|
127
|
+
* 4. index.js / index.mjs fallback
|
|
128
|
+
*
|
|
129
|
+
* For deep imports like "@mui/material/Button", we resolve from the
|
|
130
|
+
* package directory directly.
|
|
131
|
+
*/
|
|
132
|
+
private resolveBarePkgEntryCache;
|
|
133
|
+
/**
|
|
134
|
+
* Packages whose imports are handled by the browser import map.
|
|
135
|
+
* These are NOT rewritten to /node_modules/... paths.
|
|
136
|
+
* Now empty: react/react-dom are served from node_modules via our
|
|
137
|
+
* CJS→ESM shim, which supports the actual installed version rather
|
|
138
|
+
* than the outdated esm.sh CDN pinned in almostnode's import map.
|
|
139
|
+
*/
|
|
140
|
+
private importMapPackages;
|
|
141
|
+
private parseCachedPackageJson;
|
|
142
|
+
private transformTextWithCache;
|
|
143
|
+
private resolveBarePkgEntry;
|
|
144
|
+
private _resolveBarePkgEntry;
|
|
145
|
+
private resolveExportsEntry;
|
|
146
|
+
/**
|
|
147
|
+
* Handle wildcard exports like "./*" → { "default": { "default": "./esm/* /index.js" } }
|
|
148
|
+
*/
|
|
149
|
+
private resolveWildcardExports;
|
|
150
|
+
/**
|
|
151
|
+
* Recursively resolve a condition value from an exports entry.
|
|
152
|
+
* Handles: string, { import, module, default, require }, and nested conditions.
|
|
153
|
+
* Skips "types" conditions since we need JS, not .d.ts files.
|
|
154
|
+
*
|
|
155
|
+
* Priority: browser > module > import > default > require
|
|
156
|
+
* "browser" and "module" are preferred because they point to true ESM bundles.
|
|
157
|
+
* "import" is deprioritised because some packages (e.g. @emotion/*) map it to
|
|
158
|
+
* a CJS-to-ESM wrapper (.cjs.mjs) that uses require()/exports which fails
|
|
159
|
+
* in a browser context.
|
|
160
|
+
*/
|
|
161
|
+
private resolveConditionValue;
|
|
162
|
+
/**
|
|
163
|
+
* Rewrite bare import specifiers in JavaScript source to /node_modules/... paths.
|
|
164
|
+
* When virtualPrefix is provided (e.g. "/__virtual__/5173"), prepends it to
|
|
165
|
+
* resolved paths so the browser stays within the service-worker-routed URL
|
|
166
|
+
* namespace and cascading relative imports keep going through the SW.
|
|
167
|
+
*/
|
|
168
|
+
rewriteBareImports(code: string, root: string, virtualPrefix?: string): string;
|
|
169
|
+
private serveExistingVirtualStaticFile;
|
|
170
|
+
private stopViteServer;
|
|
171
|
+
private resolveNpmBinPath;
|
|
172
|
+
private resolveAndRegisterBinCommands;
|
|
173
|
+
private trackOperation;
|
|
174
|
+
private flushPendingOperations;
|
|
175
|
+
private withSuppressedObservableMirroring;
|
|
176
|
+
private copyObservablePathIntoVirtualFs;
|
|
177
|
+
private getNodeModulesPackageRoot;
|
|
178
|
+
private hydrateObservablePackageIntoVirtualFs;
|
|
179
|
+
private hydrateObservablePathsIntoVirtualFs;
|
|
180
|
+
private hydrateObservableDependencyPackagesIntoVirtualFs;
|
|
181
|
+
private hydrateObservableProjectIntoVirtualFs;
|
|
182
|
+
applyVirtualWrite(targetPath: string, data: string | Uint8Array): Promise<void>;
|
|
183
|
+
applyVirtualMkdir(targetPath: string): Promise<void>;
|
|
184
|
+
applyVirtualRemove(targetPath: string, recursive: boolean): Promise<void>;
|
|
185
|
+
applyVirtualRename(previousPath: string, nextPath: string): Promise<void>;
|
|
186
|
+
private ensureInitialized;
|
|
187
|
+
private readPackageJson;
|
|
188
|
+
private runNpmScript;
|
|
189
|
+
executeNpm(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
190
|
+
executeNode(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
191
|
+
executeVite(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
192
|
+
}
|
|
193
|
+
declare function createAlmostNodeSession(fs: ObservableInMemoryFs): AlmostNodeSession;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Shared types for agent-web-os.
|
|
197
|
+
*/
|
|
198
|
+
interface ToolResult {
|
|
199
|
+
success: boolean;
|
|
200
|
+
error?: string;
|
|
201
|
+
[key: string]: any;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const DEFAULT_BASH_SHELL_ENV: {
|
|
205
|
+
readonly LANG: "C.UTF-8";
|
|
206
|
+
readonly LC_ALL: "C.UTF-8";
|
|
207
|
+
readonly PYTHONIOENCODING: "utf-8";
|
|
208
|
+
readonly PYTHONUTF8: "1";
|
|
209
|
+
};
|
|
210
|
+
type BrowserBashSession = {
|
|
211
|
+
fs: ObservableInMemoryFs;
|
|
212
|
+
bash: Bash;
|
|
213
|
+
almostNodeSession: AlmostNodeSession;
|
|
214
|
+
rootPath: string;
|
|
215
|
+
cwd: string;
|
|
216
|
+
dispose: () => void;
|
|
217
|
+
};
|
|
218
|
+
type BrowserBashSessionOptions = {
|
|
219
|
+
/** Root path in the virtual filesystem (default: "/workspace") */
|
|
220
|
+
rootPath?: string;
|
|
221
|
+
/** Shell environment variables */
|
|
222
|
+
env?: Record<string, string>;
|
|
223
|
+
/** Options for the ObservableInMemoryFs */
|
|
224
|
+
fsOptions?: ObservableInMemoryFsOptions;
|
|
225
|
+
};
|
|
226
|
+
type ExecuteBrowserBashOptions = {
|
|
227
|
+
/** Whether to truncate command output (default: true) */
|
|
228
|
+
truncateOutput?: boolean;
|
|
229
|
+
/** Abort signal for cancellation */
|
|
230
|
+
signal?: AbortSignal;
|
|
231
|
+
/** Command timeout in ms (default: DEFAULT_BASH_COMMAND_TIMEOUT_MS) */
|
|
232
|
+
commandTimeoutMs?: number;
|
|
233
|
+
/** Output truncation limit (default: DEFAULT_BASH_OUTPUT_LIMIT) */
|
|
234
|
+
outputLimit?: number;
|
|
235
|
+
};
|
|
236
|
+
/** Create a browser-based bash session with in-memory filesystem and almostnode */
|
|
237
|
+
declare function createBrowserBashSession(options?: BrowserBashSessionOptions): BrowserBashSession;
|
|
238
|
+
/** Execute a bash command and return a ToolResult */
|
|
239
|
+
declare function executeBrowserBash(session: BrowserBashSession, command: string, options?: ExecuteBrowserBashOptions): Promise<ToolResult>;
|
|
240
|
+
|
|
241
|
+
type ServerBridge = {
|
|
242
|
+
initServiceWorker(): Promise<void>;
|
|
243
|
+
registerServer(server: unknown, port: number): void;
|
|
244
|
+
unregisterServer(port: number): void;
|
|
245
|
+
getServerUrl(port: number): string;
|
|
246
|
+
};
|
|
247
|
+
declare const getServerBridge: () => ServerBridge;
|
|
248
|
+
declare const resetServerBridge: () => void;
|
|
249
|
+
|
|
250
|
+
export { AlmostNodeSession, type AlmostNodeSessionVfs, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createAlmostNodeSession, createBrowserBashSession, executeBrowserBash, getServerBridge, resetServerBridge };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as just_bash from 'just-bash';
|
|
2
|
+
import { InMemoryFs, FileContent, MkdirOptions, RmOptions, CpOptions } from 'just-bash';
|
|
3
|
+
import { CommandContext, ExecResult, Bash } from 'just-bash/browser';
|
|
4
|
+
export { Bash, CommandContext, ExecResult, defineCommand } from 'just-bash/browser';
|
|
5
|
+
|
|
6
|
+
type ObservableInMemoryFsWriteFileSyncOptions = Parameters<InMemoryFs["writeFileSync"]>[2];
|
|
7
|
+
type ObservableInMemoryFsWriteFileSyncMetadata = Parameters<InMemoryFs["writeFileSync"]>[3];
|
|
8
|
+
type ObservableInMemoryFsWriteFileLazy = Parameters<InMemoryFs["writeFileLazy"]>[1];
|
|
9
|
+
type ObservableInMemoryFsWriteFileLazyMetadata = Parameters<InMemoryFs["writeFileLazy"]>[2];
|
|
10
|
+
type ObservableInMemoryFsWriteOptions = Parameters<InMemoryFs["writeFile"]>[2];
|
|
11
|
+
type ObservableInMemoryFsEntryType = "file" | "directory" | "symlink";
|
|
12
|
+
type ObservableInMemoryFsChangeEventName = "add" | "addDir" | "change" | "unlink" | "unlinkDir";
|
|
13
|
+
type ObservableInMemoryFsChangeEvent = {
|
|
14
|
+
event: ObservableInMemoryFsChangeEventName;
|
|
15
|
+
path: string;
|
|
16
|
+
entryType: ObservableInMemoryFsEntryType;
|
|
17
|
+
previousPath?: string;
|
|
18
|
+
};
|
|
19
|
+
type ObservableInMemoryFsOptions = {
|
|
20
|
+
/** Whether to console.log change events (default: false) */
|
|
21
|
+
consoleLogChanges?: boolean;
|
|
22
|
+
/** Root path used to filter which changes are console-logged (default: "/") */
|
|
23
|
+
workspaceRoot?: string;
|
|
24
|
+
};
|
|
25
|
+
declare function assertObservableInMemoryFs(value: unknown): ObservableInMemoryFs;
|
|
26
|
+
type ObservableInMemoryFsListener = (event: ObservableInMemoryFsChangeEvent) => void;
|
|
27
|
+
declare class ObservableInMemoryFs extends InMemoryFs {
|
|
28
|
+
private listeners;
|
|
29
|
+
private lazyPaths;
|
|
30
|
+
private suppressSyncEventCount;
|
|
31
|
+
private suppressConsoleLogCount;
|
|
32
|
+
private suppressChangeEmissionCount;
|
|
33
|
+
private readonly consoleLogChanges;
|
|
34
|
+
private readonly isLoggableWorkspacePath;
|
|
35
|
+
constructor(options?: ObservableInMemoryFsOptions);
|
|
36
|
+
isPathLazy(filePath: string): boolean;
|
|
37
|
+
private clearLazyPath;
|
|
38
|
+
private clearLazyPathsUnder;
|
|
39
|
+
subscribe(listener: ObservableInMemoryFsListener): () => void;
|
|
40
|
+
private shouldEmitChanges;
|
|
41
|
+
suppressObservability<T>(operation: () => Promise<T>): Promise<T>;
|
|
42
|
+
private queueChangeEmission;
|
|
43
|
+
private areConsoleLogsSuppressed;
|
|
44
|
+
private runWithSuppressedConsoleLogs;
|
|
45
|
+
private shouldConsoleLogChangeEvent;
|
|
46
|
+
private emit;
|
|
47
|
+
private areSyncEventsSuppressed;
|
|
48
|
+
private runWithSuppressedSyncEvents;
|
|
49
|
+
writeFileSync(path: string, content: FileContent, options?: ObservableInMemoryFsWriteFileSyncOptions, metadata?: ObservableInMemoryFsWriteFileSyncMetadata): void;
|
|
50
|
+
writeFileLazy(path: string, lazy: ObservableInMemoryFsWriteFileLazy, metadata?: ObservableInMemoryFsWriteFileLazyMetadata): void;
|
|
51
|
+
private emitWriteEvent;
|
|
52
|
+
private emitMkdirEvent;
|
|
53
|
+
private emitRemovalEvent;
|
|
54
|
+
mkdirSync(path: string, options?: MkdirOptions): void;
|
|
55
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
56
|
+
stat(path: string): Promise<just_bash.FsStat>;
|
|
57
|
+
lstat(path: string): Promise<just_bash.FsStat>;
|
|
58
|
+
writeFile(path: string, content: FileContent, options?: ObservableInMemoryFsWriteOptions): Promise<void>;
|
|
59
|
+
appendFile(path: string, content: FileContent, options?: ObservableInMemoryFsWriteOptions): Promise<void>;
|
|
60
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
61
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
62
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
63
|
+
mv(src: string, dest: string): Promise<void>;
|
|
64
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
65
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
66
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
67
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type BinCommandRegistrar = (name: string, handler: (args: string[], ctx: CommandContext) => Promise<ExecResult>) => void;
|
|
71
|
+
type VitePreviewListener = (previewUrl: string | null) => void;
|
|
72
|
+
type BatchFileLoader = (paths: string[]) => Promise<Map<string, Uint8Array>>;
|
|
73
|
+
interface AlmostNodeSessionVfs {
|
|
74
|
+
existsSync(path: string): boolean;
|
|
75
|
+
statSync(path: string): {
|
|
76
|
+
isDirectory(): boolean;
|
|
77
|
+
isFile(): boolean;
|
|
78
|
+
};
|
|
79
|
+
readFileSync(path: string, encoding?: string): any;
|
|
80
|
+
writeFileSync(path: string, data: string | Uint8Array): void;
|
|
81
|
+
mkdirSync(path: string, options?: {
|
|
82
|
+
recursive?: boolean;
|
|
83
|
+
}): void;
|
|
84
|
+
readdirSync(path: string): string[];
|
|
85
|
+
unlinkSync(path: string): void;
|
|
86
|
+
rmdirSync(path: string): void;
|
|
87
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
88
|
+
}
|
|
89
|
+
declare global {
|
|
90
|
+
interface Window {
|
|
91
|
+
__esbuild?: unknown;
|
|
92
|
+
__esbuildInitPromise?: Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
declare class AlmostNodeSession {
|
|
96
|
+
private readonly fs;
|
|
97
|
+
private readonly _vfs;
|
|
98
|
+
get vfs(): AlmostNodeSessionVfs;
|
|
99
|
+
private readonly disposeObservableSubscription;
|
|
100
|
+
private initializePromise;
|
|
101
|
+
private initialized;
|
|
102
|
+
private pendingOperations;
|
|
103
|
+
private suppressObservableMirrorCount;
|
|
104
|
+
private registeredBinCommands;
|
|
105
|
+
private binCommandRegistrar?;
|
|
106
|
+
private batchFileLoader?;
|
|
107
|
+
private viteServer?;
|
|
108
|
+
private vitePort;
|
|
109
|
+
private vitePreviewUrl;
|
|
110
|
+
private vitePreviewListener?;
|
|
111
|
+
private parsedPackageJsonCache;
|
|
112
|
+
private transformedTextCache;
|
|
113
|
+
constructor(fs: ObservableInMemoryFs);
|
|
114
|
+
dispose(): void;
|
|
115
|
+
setBinCommandRegistrar(registrar: BinCommandRegistrar): void;
|
|
116
|
+
setBatchFileLoader(loader: BatchFileLoader): void;
|
|
117
|
+
setVitePreviewListener(listener: VitePreviewListener | undefined): void;
|
|
118
|
+
setViteHmrTarget(target: Window | null): void;
|
|
119
|
+
/**
|
|
120
|
+
* Resolve a bare module specifier (e.g. "@mui/material" or "react") to a
|
|
121
|
+
* `/node_modules/...` URL path that the ViteDevServer can serve.
|
|
122
|
+
*
|
|
123
|
+
* Resolution order mirrors Node/bundler conventions:
|
|
124
|
+
* 1. package.json "exports" (condition "import" → "default")
|
|
125
|
+
* 2. package.json "module"
|
|
126
|
+
* 3. package.json "main"
|
|
127
|
+
* 4. index.js / index.mjs fallback
|
|
128
|
+
*
|
|
129
|
+
* For deep imports like "@mui/material/Button", we resolve from the
|
|
130
|
+
* package directory directly.
|
|
131
|
+
*/
|
|
132
|
+
private resolveBarePkgEntryCache;
|
|
133
|
+
/**
|
|
134
|
+
* Packages whose imports are handled by the browser import map.
|
|
135
|
+
* These are NOT rewritten to /node_modules/... paths.
|
|
136
|
+
* Now empty: react/react-dom are served from node_modules via our
|
|
137
|
+
* CJS→ESM shim, which supports the actual installed version rather
|
|
138
|
+
* than the outdated esm.sh CDN pinned in almostnode's import map.
|
|
139
|
+
*/
|
|
140
|
+
private importMapPackages;
|
|
141
|
+
private parseCachedPackageJson;
|
|
142
|
+
private transformTextWithCache;
|
|
143
|
+
private resolveBarePkgEntry;
|
|
144
|
+
private _resolveBarePkgEntry;
|
|
145
|
+
private resolveExportsEntry;
|
|
146
|
+
/**
|
|
147
|
+
* Handle wildcard exports like "./*" → { "default": { "default": "./esm/* /index.js" } }
|
|
148
|
+
*/
|
|
149
|
+
private resolveWildcardExports;
|
|
150
|
+
/**
|
|
151
|
+
* Recursively resolve a condition value from an exports entry.
|
|
152
|
+
* Handles: string, { import, module, default, require }, and nested conditions.
|
|
153
|
+
* Skips "types" conditions since we need JS, not .d.ts files.
|
|
154
|
+
*
|
|
155
|
+
* Priority: browser > module > import > default > require
|
|
156
|
+
* "browser" and "module" are preferred because they point to true ESM bundles.
|
|
157
|
+
* "import" is deprioritised because some packages (e.g. @emotion/*) map it to
|
|
158
|
+
* a CJS-to-ESM wrapper (.cjs.mjs) that uses require()/exports which fails
|
|
159
|
+
* in a browser context.
|
|
160
|
+
*/
|
|
161
|
+
private resolveConditionValue;
|
|
162
|
+
/**
|
|
163
|
+
* Rewrite bare import specifiers in JavaScript source to /node_modules/... paths.
|
|
164
|
+
* When virtualPrefix is provided (e.g. "/__virtual__/5173"), prepends it to
|
|
165
|
+
* resolved paths so the browser stays within the service-worker-routed URL
|
|
166
|
+
* namespace and cascading relative imports keep going through the SW.
|
|
167
|
+
*/
|
|
168
|
+
rewriteBareImports(code: string, root: string, virtualPrefix?: string): string;
|
|
169
|
+
private serveExistingVirtualStaticFile;
|
|
170
|
+
private stopViteServer;
|
|
171
|
+
private resolveNpmBinPath;
|
|
172
|
+
private resolveAndRegisterBinCommands;
|
|
173
|
+
private trackOperation;
|
|
174
|
+
private flushPendingOperations;
|
|
175
|
+
private withSuppressedObservableMirroring;
|
|
176
|
+
private copyObservablePathIntoVirtualFs;
|
|
177
|
+
private getNodeModulesPackageRoot;
|
|
178
|
+
private hydrateObservablePackageIntoVirtualFs;
|
|
179
|
+
private hydrateObservablePathsIntoVirtualFs;
|
|
180
|
+
private hydrateObservableDependencyPackagesIntoVirtualFs;
|
|
181
|
+
private hydrateObservableProjectIntoVirtualFs;
|
|
182
|
+
applyVirtualWrite(targetPath: string, data: string | Uint8Array): Promise<void>;
|
|
183
|
+
applyVirtualMkdir(targetPath: string): Promise<void>;
|
|
184
|
+
applyVirtualRemove(targetPath: string, recursive: boolean): Promise<void>;
|
|
185
|
+
applyVirtualRename(previousPath: string, nextPath: string): Promise<void>;
|
|
186
|
+
private ensureInitialized;
|
|
187
|
+
private readPackageJson;
|
|
188
|
+
private runNpmScript;
|
|
189
|
+
executeNpm(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
190
|
+
executeNode(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
191
|
+
executeVite(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
192
|
+
}
|
|
193
|
+
declare function createAlmostNodeSession(fs: ObservableInMemoryFs): AlmostNodeSession;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Shared types for agent-web-os.
|
|
197
|
+
*/
|
|
198
|
+
interface ToolResult {
|
|
199
|
+
success: boolean;
|
|
200
|
+
error?: string;
|
|
201
|
+
[key: string]: any;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const DEFAULT_BASH_SHELL_ENV: {
|
|
205
|
+
readonly LANG: "C.UTF-8";
|
|
206
|
+
readonly LC_ALL: "C.UTF-8";
|
|
207
|
+
readonly PYTHONIOENCODING: "utf-8";
|
|
208
|
+
readonly PYTHONUTF8: "1";
|
|
209
|
+
};
|
|
210
|
+
type BrowserBashSession = {
|
|
211
|
+
fs: ObservableInMemoryFs;
|
|
212
|
+
bash: Bash;
|
|
213
|
+
almostNodeSession: AlmostNodeSession;
|
|
214
|
+
rootPath: string;
|
|
215
|
+
cwd: string;
|
|
216
|
+
dispose: () => void;
|
|
217
|
+
};
|
|
218
|
+
type BrowserBashSessionOptions = {
|
|
219
|
+
/** Root path in the virtual filesystem (default: "/workspace") */
|
|
220
|
+
rootPath?: string;
|
|
221
|
+
/** Shell environment variables */
|
|
222
|
+
env?: Record<string, string>;
|
|
223
|
+
/** Options for the ObservableInMemoryFs */
|
|
224
|
+
fsOptions?: ObservableInMemoryFsOptions;
|
|
225
|
+
};
|
|
226
|
+
type ExecuteBrowserBashOptions = {
|
|
227
|
+
/** Whether to truncate command output (default: true) */
|
|
228
|
+
truncateOutput?: boolean;
|
|
229
|
+
/** Abort signal for cancellation */
|
|
230
|
+
signal?: AbortSignal;
|
|
231
|
+
/** Command timeout in ms (default: DEFAULT_BASH_COMMAND_TIMEOUT_MS) */
|
|
232
|
+
commandTimeoutMs?: number;
|
|
233
|
+
/** Output truncation limit (default: DEFAULT_BASH_OUTPUT_LIMIT) */
|
|
234
|
+
outputLimit?: number;
|
|
235
|
+
};
|
|
236
|
+
/** Create a browser-based bash session with in-memory filesystem and almostnode */
|
|
237
|
+
declare function createBrowserBashSession(options?: BrowserBashSessionOptions): BrowserBashSession;
|
|
238
|
+
/** Execute a bash command and return a ToolResult */
|
|
239
|
+
declare function executeBrowserBash(session: BrowserBashSession, command: string, options?: ExecuteBrowserBashOptions): Promise<ToolResult>;
|
|
240
|
+
|
|
241
|
+
type ServerBridge = {
|
|
242
|
+
initServiceWorker(): Promise<void>;
|
|
243
|
+
registerServer(server: unknown, port: number): void;
|
|
244
|
+
unregisterServer(port: number): void;
|
|
245
|
+
getServerUrl(port: number): string;
|
|
246
|
+
};
|
|
247
|
+
declare const getServerBridge: () => ServerBridge;
|
|
248
|
+
declare const resetServerBridge: () => void;
|
|
249
|
+
|
|
250
|
+
export { AlmostNodeSession, type AlmostNodeSessionVfs, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createAlmostNodeSession, createBrowserBashSession, executeBrowserBash, getServerBridge, resetServerBridge };
|