agent-web-os 0.1.19 → 0.2.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/README.md +35 -48
- package/README.zh-CN.md +35 -48
- package/dist/index.cjs +25 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -147
- package/dist/index.d.ts +6 -147
- package/dist/index.js +25 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as just_bash from 'just-bash';
|
|
2
2
|
import { InMemoryFs, FileContent, MkdirOptions, RmOptions, CpOptions } from 'just-bash';
|
|
3
|
-
import {
|
|
3
|
+
import { Bash, CustomCommand, CommandContext, ExecResult } from 'just-bash/browser';
|
|
4
4
|
export { Bash, CommandContext, CustomCommand, ExecResult, defineCommand } from 'just-bash/browser';
|
|
5
5
|
|
|
6
6
|
type ObservableInMemoryFsWriteFileSyncOptions = Parameters<InMemoryFs["writeFileSync"]>[2];
|
|
@@ -67,149 +67,6 @@ declare class ObservableInMemoryFs extends InMemoryFs {
|
|
|
67
67
|
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
68
68
|
}
|
|
69
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 stdoutWriter?;
|
|
108
|
-
private _stdinHandler;
|
|
109
|
-
private _terminalColumns;
|
|
110
|
-
private _terminalRows;
|
|
111
|
-
private viteServer?;
|
|
112
|
-
private vitePort;
|
|
113
|
-
private vitePreviewUrl;
|
|
114
|
-
private vitePreviewListener?;
|
|
115
|
-
private parsedPackageJsonCache;
|
|
116
|
-
private transformedTextCache;
|
|
117
|
-
constructor(fs: ObservableInMemoryFs);
|
|
118
|
-
dispose(): void;
|
|
119
|
-
setBinCommandRegistrar(registrar: BinCommandRegistrar): void;
|
|
120
|
-
setBatchFileLoader(loader: BatchFileLoader): void;
|
|
121
|
-
setStdoutWriter(writer: ((data: string) => void) | undefined): void;
|
|
122
|
-
/** Send data to the stdin of the currently running interactive process. */
|
|
123
|
-
writeStdin(data: string): void;
|
|
124
|
-
/** Update terminal dimensions (used for process.stdout.columns/rows). */
|
|
125
|
-
setTerminalSize(columns: number, rows: number): void;
|
|
126
|
-
setVitePreviewListener(listener: VitePreviewListener | undefined): void;
|
|
127
|
-
setViteHmrTarget(target: Window | null): void;
|
|
128
|
-
/**
|
|
129
|
-
* Resolve a bare module specifier (e.g. "@mui/material" or "react") to a
|
|
130
|
-
* `/node_modules/...` URL path that the ViteDevServer can serve.
|
|
131
|
-
*
|
|
132
|
-
* Resolution order mirrors Node/bundler conventions:
|
|
133
|
-
* 1. package.json "exports" (condition "import" → "default")
|
|
134
|
-
* 2. package.json "module"
|
|
135
|
-
* 3. package.json "main"
|
|
136
|
-
* 4. index.js / index.mjs fallback
|
|
137
|
-
*
|
|
138
|
-
* For deep imports like "@mui/material/Button", we resolve from the
|
|
139
|
-
* package directory directly.
|
|
140
|
-
*/
|
|
141
|
-
private resolveBarePkgEntryCache;
|
|
142
|
-
private parseCachedPackageJson;
|
|
143
|
-
private transformTextWithCache;
|
|
144
|
-
private resolveBarePkgEntry;
|
|
145
|
-
private _resolveBarePkgEntry;
|
|
146
|
-
private resolveExportsEntry;
|
|
147
|
-
/**
|
|
148
|
-
* Handle wildcard exports like "./*" → { "default": { "default": "./esm/* /index.js" } }
|
|
149
|
-
*/
|
|
150
|
-
private resolveWildcardExports;
|
|
151
|
-
/**
|
|
152
|
-
* Recursively resolve a condition value from an exports entry.
|
|
153
|
-
* Handles: string, { import, module, default, require }, and nested conditions.
|
|
154
|
-
* Skips "types" conditions since we need JS, not .d.ts files.
|
|
155
|
-
*
|
|
156
|
-
* Priority: browser > module > import > default > require
|
|
157
|
-
* "browser" and "module" are preferred because they point to true ESM bundles.
|
|
158
|
-
* "import" is deprioritised because some packages (e.g. @emotion/*) map it to
|
|
159
|
-
* a CJS-to-ESM wrapper (.cjs.mjs) that uses require()/exports which fails
|
|
160
|
-
* in a browser context.
|
|
161
|
-
*/
|
|
162
|
-
private resolveConditionValue;
|
|
163
|
-
/**
|
|
164
|
-
* Rewrite bare import specifiers in JavaScript source to /node_modules/... paths.
|
|
165
|
-
* When virtualPrefix is provided (e.g. "/__virtual__/5173"), prepends it to
|
|
166
|
-
* resolved paths so the browser stays within the service-worker-routed URL
|
|
167
|
-
* namespace and cascading relative imports keep going through the SW.
|
|
168
|
-
*/
|
|
169
|
-
rewriteBareImports(code: string, root: string, virtualPrefix?: string): string;
|
|
170
|
-
private serveExistingVirtualStaticFile;
|
|
171
|
-
private stopViteServer;
|
|
172
|
-
private resolveBinFromPackageJson;
|
|
173
|
-
private resolveNpmBinPath;
|
|
174
|
-
private resolveGlobalBinPath;
|
|
175
|
-
/**
|
|
176
|
-
* Replace lru-cache CJS entry points with a browser-safe implementation.
|
|
177
|
-
*
|
|
178
|
-
* lru-cache v11's minified CJS uses `require("node:diagnostics_channel")`
|
|
179
|
-
* and private class fields (`static #t`) which can fail inside the browser
|
|
180
|
-
* WASM runtime's `eval()` context, leaving `exports.LRUCache` undefined
|
|
181
|
-
* ("TypeError: LRUCache is not a constructor").
|
|
182
|
-
*
|
|
183
|
-
* The fix: overwrite the CJS entry with a clean Map-based LRU cache that
|
|
184
|
-
* covers the full API surface used by lru-cache consumers (hosted-git-info,
|
|
185
|
-
* path-scurry, glob, etc.) without any diagnostics_channel dependency or
|
|
186
|
-
* private class fields.
|
|
187
|
-
*/
|
|
188
|
-
private patchLruCacheInNodeModules;
|
|
189
|
-
private registerGlobalBinCommands;
|
|
190
|
-
private resolveAndRegisterBinCommands;
|
|
191
|
-
private trackOperation;
|
|
192
|
-
private flushPendingOperations;
|
|
193
|
-
private withSuppressedObservableMirroring;
|
|
194
|
-
private copyObservablePathIntoVirtualFs;
|
|
195
|
-
private getNodeModulesPackageRoot;
|
|
196
|
-
private hydrateObservablePackageIntoVirtualFs;
|
|
197
|
-
private hydrateObservablePathsIntoVirtualFs;
|
|
198
|
-
private hydrateObservableDependencyPackagesIntoVirtualFs;
|
|
199
|
-
private hydrateObservableProjectIntoVirtualFs;
|
|
200
|
-
applyVirtualWrite(targetPath: string, data: string | Uint8Array): Promise<void>;
|
|
201
|
-
applyVirtualMkdir(targetPath: string): Promise<void>;
|
|
202
|
-
applyVirtualRemove(targetPath: string, recursive: boolean): Promise<void>;
|
|
203
|
-
applyVirtualRename(previousPath: string, nextPath: string): Promise<void>;
|
|
204
|
-
private ensureInitialized;
|
|
205
|
-
private readPackageJson;
|
|
206
|
-
private runNpmScript;
|
|
207
|
-
executeNpm(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
208
|
-
executeNode(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
209
|
-
executeVite(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
210
|
-
}
|
|
211
|
-
declare function createAlmostNodeSession(fs: ObservableInMemoryFs): AlmostNodeSession;
|
|
212
|
-
|
|
213
70
|
/**
|
|
214
71
|
* Shared types for agent-web-os.
|
|
215
72
|
*/
|
|
@@ -229,9 +86,11 @@ declare const DEFAULT_BASH_SHELL_ENV: {
|
|
|
229
86
|
type BrowserBashSession = {
|
|
230
87
|
fs: ObservableInMemoryFs;
|
|
231
88
|
bash: Bash;
|
|
232
|
-
almostNodeSession: AlmostNodeSession;
|
|
233
89
|
rootPath: string;
|
|
234
90
|
cwd: string;
|
|
91
|
+
setStdoutWriter: (writer: ((data: string) => void) | undefined) => void;
|
|
92
|
+
writeStdin: (data: string) => void;
|
|
93
|
+
setTerminalSize: (columns: number, rows: number) => void;
|
|
235
94
|
dispose: () => void;
|
|
236
95
|
};
|
|
237
96
|
type BrowserBashSessionOptions = {
|
|
@@ -285,7 +144,7 @@ declare function executeBrowserBash(session: BrowserBashSession, command: string
|
|
|
285
144
|
|
|
286
145
|
declare function executeFd(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
287
146
|
|
|
288
|
-
declare const AGENT_WEB_OS_VERSION = "0.
|
|
147
|
+
declare const AGENT_WEB_OS_VERSION = "0.2.0";
|
|
289
148
|
|
|
290
149
|
type ServerBridge = {
|
|
291
150
|
initServiceWorker(): Promise<void>;
|
|
@@ -296,4 +155,4 @@ type ServerBridge = {
|
|
|
296
155
|
declare const getServerBridge: () => ServerBridge;
|
|
297
156
|
declare const resetServerBridge: () => void;
|
|
298
157
|
|
|
299
|
-
export { AGENT_WEB_OS_VERSION,
|
|
158
|
+
export { AGENT_WEB_OS_VERSION, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createBrowserBashSession, executeBrowserBash, executeFd, getServerBridge, resetServerBridge };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as just_bash from 'just-bash';
|
|
2
2
|
import { InMemoryFs, FileContent, MkdirOptions, RmOptions, CpOptions } from 'just-bash';
|
|
3
|
-
import {
|
|
3
|
+
import { Bash, CustomCommand, CommandContext, ExecResult } from 'just-bash/browser';
|
|
4
4
|
export { Bash, CommandContext, CustomCommand, ExecResult, defineCommand } from 'just-bash/browser';
|
|
5
5
|
|
|
6
6
|
type ObservableInMemoryFsWriteFileSyncOptions = Parameters<InMemoryFs["writeFileSync"]>[2];
|
|
@@ -67,149 +67,6 @@ declare class ObservableInMemoryFs extends InMemoryFs {
|
|
|
67
67
|
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
68
68
|
}
|
|
69
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 stdoutWriter?;
|
|
108
|
-
private _stdinHandler;
|
|
109
|
-
private _terminalColumns;
|
|
110
|
-
private _terminalRows;
|
|
111
|
-
private viteServer?;
|
|
112
|
-
private vitePort;
|
|
113
|
-
private vitePreviewUrl;
|
|
114
|
-
private vitePreviewListener?;
|
|
115
|
-
private parsedPackageJsonCache;
|
|
116
|
-
private transformedTextCache;
|
|
117
|
-
constructor(fs: ObservableInMemoryFs);
|
|
118
|
-
dispose(): void;
|
|
119
|
-
setBinCommandRegistrar(registrar: BinCommandRegistrar): void;
|
|
120
|
-
setBatchFileLoader(loader: BatchFileLoader): void;
|
|
121
|
-
setStdoutWriter(writer: ((data: string) => void) | undefined): void;
|
|
122
|
-
/** Send data to the stdin of the currently running interactive process. */
|
|
123
|
-
writeStdin(data: string): void;
|
|
124
|
-
/** Update terminal dimensions (used for process.stdout.columns/rows). */
|
|
125
|
-
setTerminalSize(columns: number, rows: number): void;
|
|
126
|
-
setVitePreviewListener(listener: VitePreviewListener | undefined): void;
|
|
127
|
-
setViteHmrTarget(target: Window | null): void;
|
|
128
|
-
/**
|
|
129
|
-
* Resolve a bare module specifier (e.g. "@mui/material" or "react") to a
|
|
130
|
-
* `/node_modules/...` URL path that the ViteDevServer can serve.
|
|
131
|
-
*
|
|
132
|
-
* Resolution order mirrors Node/bundler conventions:
|
|
133
|
-
* 1. package.json "exports" (condition "import" → "default")
|
|
134
|
-
* 2. package.json "module"
|
|
135
|
-
* 3. package.json "main"
|
|
136
|
-
* 4. index.js / index.mjs fallback
|
|
137
|
-
*
|
|
138
|
-
* For deep imports like "@mui/material/Button", we resolve from the
|
|
139
|
-
* package directory directly.
|
|
140
|
-
*/
|
|
141
|
-
private resolveBarePkgEntryCache;
|
|
142
|
-
private parseCachedPackageJson;
|
|
143
|
-
private transformTextWithCache;
|
|
144
|
-
private resolveBarePkgEntry;
|
|
145
|
-
private _resolveBarePkgEntry;
|
|
146
|
-
private resolveExportsEntry;
|
|
147
|
-
/**
|
|
148
|
-
* Handle wildcard exports like "./*" → { "default": { "default": "./esm/* /index.js" } }
|
|
149
|
-
*/
|
|
150
|
-
private resolveWildcardExports;
|
|
151
|
-
/**
|
|
152
|
-
* Recursively resolve a condition value from an exports entry.
|
|
153
|
-
* Handles: string, { import, module, default, require }, and nested conditions.
|
|
154
|
-
* Skips "types" conditions since we need JS, not .d.ts files.
|
|
155
|
-
*
|
|
156
|
-
* Priority: browser > module > import > default > require
|
|
157
|
-
* "browser" and "module" are preferred because they point to true ESM bundles.
|
|
158
|
-
* "import" is deprioritised because some packages (e.g. @emotion/*) map it to
|
|
159
|
-
* a CJS-to-ESM wrapper (.cjs.mjs) that uses require()/exports which fails
|
|
160
|
-
* in a browser context.
|
|
161
|
-
*/
|
|
162
|
-
private resolveConditionValue;
|
|
163
|
-
/**
|
|
164
|
-
* Rewrite bare import specifiers in JavaScript source to /node_modules/... paths.
|
|
165
|
-
* When virtualPrefix is provided (e.g. "/__virtual__/5173"), prepends it to
|
|
166
|
-
* resolved paths so the browser stays within the service-worker-routed URL
|
|
167
|
-
* namespace and cascading relative imports keep going through the SW.
|
|
168
|
-
*/
|
|
169
|
-
rewriteBareImports(code: string, root: string, virtualPrefix?: string): string;
|
|
170
|
-
private serveExistingVirtualStaticFile;
|
|
171
|
-
private stopViteServer;
|
|
172
|
-
private resolveBinFromPackageJson;
|
|
173
|
-
private resolveNpmBinPath;
|
|
174
|
-
private resolveGlobalBinPath;
|
|
175
|
-
/**
|
|
176
|
-
* Replace lru-cache CJS entry points with a browser-safe implementation.
|
|
177
|
-
*
|
|
178
|
-
* lru-cache v11's minified CJS uses `require("node:diagnostics_channel")`
|
|
179
|
-
* and private class fields (`static #t`) which can fail inside the browser
|
|
180
|
-
* WASM runtime's `eval()` context, leaving `exports.LRUCache` undefined
|
|
181
|
-
* ("TypeError: LRUCache is not a constructor").
|
|
182
|
-
*
|
|
183
|
-
* The fix: overwrite the CJS entry with a clean Map-based LRU cache that
|
|
184
|
-
* covers the full API surface used by lru-cache consumers (hosted-git-info,
|
|
185
|
-
* path-scurry, glob, etc.) without any diagnostics_channel dependency or
|
|
186
|
-
* private class fields.
|
|
187
|
-
*/
|
|
188
|
-
private patchLruCacheInNodeModules;
|
|
189
|
-
private registerGlobalBinCommands;
|
|
190
|
-
private resolveAndRegisterBinCommands;
|
|
191
|
-
private trackOperation;
|
|
192
|
-
private flushPendingOperations;
|
|
193
|
-
private withSuppressedObservableMirroring;
|
|
194
|
-
private copyObservablePathIntoVirtualFs;
|
|
195
|
-
private getNodeModulesPackageRoot;
|
|
196
|
-
private hydrateObservablePackageIntoVirtualFs;
|
|
197
|
-
private hydrateObservablePathsIntoVirtualFs;
|
|
198
|
-
private hydrateObservableDependencyPackagesIntoVirtualFs;
|
|
199
|
-
private hydrateObservableProjectIntoVirtualFs;
|
|
200
|
-
applyVirtualWrite(targetPath: string, data: string | Uint8Array): Promise<void>;
|
|
201
|
-
applyVirtualMkdir(targetPath: string): Promise<void>;
|
|
202
|
-
applyVirtualRemove(targetPath: string, recursive: boolean): Promise<void>;
|
|
203
|
-
applyVirtualRename(previousPath: string, nextPath: string): Promise<void>;
|
|
204
|
-
private ensureInitialized;
|
|
205
|
-
private readPackageJson;
|
|
206
|
-
private runNpmScript;
|
|
207
|
-
executeNpm(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
208
|
-
executeNode(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
209
|
-
executeVite(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
210
|
-
}
|
|
211
|
-
declare function createAlmostNodeSession(fs: ObservableInMemoryFs): AlmostNodeSession;
|
|
212
|
-
|
|
213
70
|
/**
|
|
214
71
|
* Shared types for agent-web-os.
|
|
215
72
|
*/
|
|
@@ -229,9 +86,11 @@ declare const DEFAULT_BASH_SHELL_ENV: {
|
|
|
229
86
|
type BrowserBashSession = {
|
|
230
87
|
fs: ObservableInMemoryFs;
|
|
231
88
|
bash: Bash;
|
|
232
|
-
almostNodeSession: AlmostNodeSession;
|
|
233
89
|
rootPath: string;
|
|
234
90
|
cwd: string;
|
|
91
|
+
setStdoutWriter: (writer: ((data: string) => void) | undefined) => void;
|
|
92
|
+
writeStdin: (data: string) => void;
|
|
93
|
+
setTerminalSize: (columns: number, rows: number) => void;
|
|
235
94
|
dispose: () => void;
|
|
236
95
|
};
|
|
237
96
|
type BrowserBashSessionOptions = {
|
|
@@ -285,7 +144,7 @@ declare function executeBrowserBash(session: BrowserBashSession, command: string
|
|
|
285
144
|
|
|
286
145
|
declare function executeFd(args: string[], ctx: CommandContext): Promise<ExecResult>;
|
|
287
146
|
|
|
288
|
-
declare const AGENT_WEB_OS_VERSION = "0.
|
|
147
|
+
declare const AGENT_WEB_OS_VERSION = "0.2.0";
|
|
289
148
|
|
|
290
149
|
type ServerBridge = {
|
|
291
150
|
initServiceWorker(): Promise<void>;
|
|
@@ -296,4 +155,4 @@ type ServerBridge = {
|
|
|
296
155
|
declare const getServerBridge: () => ServerBridge;
|
|
297
156
|
declare const resetServerBridge: () => void;
|
|
298
157
|
|
|
299
|
-
export { AGENT_WEB_OS_VERSION,
|
|
158
|
+
export { AGENT_WEB_OS_VERSION, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createBrowserBashSession, executeBrowserBash, executeFd, getServerBridge, resetServerBridge };
|
package/dist/index.js
CHANGED
|
@@ -56740,7 +56740,13 @@ function globToRegex(pattern) {
|
|
|
56740
56740
|
function escapeRegex(s10) {
|
|
56741
56741
|
return s10.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
56742
56742
|
}
|
|
56743
|
-
function
|
|
56743
|
+
async function loadIgnoreFile(fs, filePath) {
|
|
56744
|
+
let content;
|
|
56745
|
+
try {
|
|
56746
|
+
content = await fs.readFile(filePath);
|
|
56747
|
+
} catch {
|
|
56748
|
+
return [];
|
|
56749
|
+
}
|
|
56744
56750
|
const matchers = [];
|
|
56745
56751
|
for (const raw of content.split("\n")) {
|
|
56746
56752
|
const line = raw.trim();
|
|
@@ -56758,19 +56764,8 @@ function parseIgnorePatterns(content) {
|
|
|
56758
56764
|
}
|
|
56759
56765
|
return matchers;
|
|
56760
56766
|
}
|
|
56761
|
-
async function loadIgnoreFile(fs, filePath) {
|
|
56762
|
-
try {
|
|
56763
|
-
const content = await fs.readFile(filePath);
|
|
56764
|
-
return parseIgnorePatterns(content);
|
|
56765
|
-
} catch {
|
|
56766
|
-
return [];
|
|
56767
|
-
}
|
|
56768
|
-
}
|
|
56769
56767
|
function resolvePath(base, rel) {
|
|
56770
|
-
|
|
56771
|
-
return normalizePath2(`${base}/${rel}`);
|
|
56772
|
-
}
|
|
56773
|
-
function normalizePath2(p) {
|
|
56768
|
+
const p = rel.startsWith("/") ? rel : `${base}/${rel}`;
|
|
56774
56769
|
const parts = p.split("/").filter(Boolean);
|
|
56775
56770
|
const result = [];
|
|
56776
56771
|
for (const part of parts) {
|
|
@@ -56835,13 +56830,6 @@ async function executeFd(args, ctx) {
|
|
|
56835
56830
|
}
|
|
56836
56831
|
const excludeMatchers = opts.excludes.map((p) => globToRegex(p));
|
|
56837
56832
|
const ignoreMatchers = [];
|
|
56838
|
-
if (!opts.noIgnore) {
|
|
56839
|
-
for (const root2 of searchRoots) {
|
|
56840
|
-
const gitignorePath = `${root2}/.gitignore`;
|
|
56841
|
-
const loaded = await loadIgnoreFile(fs, gitignorePath);
|
|
56842
|
-
ignoreMatchers.push(...loaded);
|
|
56843
|
-
}
|
|
56844
|
-
}
|
|
56845
56833
|
for (const ignoreFile of opts.ignoreFiles) {
|
|
56846
56834
|
const absPath = resolvePath(cwd, ignoreFile);
|
|
56847
56835
|
const loaded = await loadIgnoreFile(fs, absPath);
|
|
@@ -56921,9 +56909,7 @@ async function executeFd(args, ctx) {
|
|
|
56921
56909
|
if (!opts.noIgnore) {
|
|
56922
56910
|
const rootGitignore = `${root2}/.gitignore`;
|
|
56923
56911
|
const loaded = await loadIgnoreFile(fs, rootGitignore);
|
|
56924
|
-
|
|
56925
|
-
ignoreMatchers.push(...loaded);
|
|
56926
|
-
}
|
|
56912
|
+
ignoreMatchers.push(...loaded);
|
|
56927
56913
|
}
|
|
56928
56914
|
await walk(root2, root2, 1);
|
|
56929
56915
|
}
|
|
@@ -56997,17 +56983,24 @@ function createBrowserBashSession(options2 = {}) {
|
|
|
56997
56983
|
return {
|
|
56998
56984
|
fs,
|
|
56999
56985
|
bash,
|
|
57000
|
-
almostNodeSession,
|
|
57001
56986
|
rootPath,
|
|
57002
56987
|
cwd: rootPath,
|
|
56988
|
+
setStdoutWriter: (writer) => almostNodeSession.setStdoutWriter(writer),
|
|
56989
|
+
writeStdin: (data2) => almostNodeSession.writeStdin(data2),
|
|
56990
|
+
setTerminalSize: (columns, rows) => almostNodeSession.setTerminalSize(columns, rows),
|
|
57003
56991
|
dispose: () => {
|
|
57004
56992
|
almostNodeSession.dispose();
|
|
57005
56993
|
}
|
|
57006
56994
|
};
|
|
57007
56995
|
}
|
|
57008
|
-
async function
|
|
57009
|
-
const
|
|
57010
|
-
|
|
56996
|
+
async function executeBrowserBash(session, command, options2 = {}) {
|
|
56997
|
+
const trimmedCommand = command.trim();
|
|
56998
|
+
if (!trimmedCommand) {
|
|
56999
|
+
return { success: false, error: "Command is required", stderr: "Command is required", exit_code: 1, command: trimmedCommand, backend: "just-bash" };
|
|
57000
|
+
}
|
|
57001
|
+
const startedAt = Date.now();
|
|
57002
|
+
const outputLimit = options2.outputLimit ?? DEFAULT_BASH_OUTPUT_LIMIT;
|
|
57003
|
+
const timeoutMs = options2.commandTimeoutMs ?? DEFAULT_BASH_COMMAND_TIMEOUT_MS;
|
|
57011
57004
|
const timeoutController = new AbortController();
|
|
57012
57005
|
const combinedController = new AbortController();
|
|
57013
57006
|
const abort = (reason) => {
|
|
@@ -57025,10 +57018,10 @@ async function execBashWithTimeout(session, command, options2 = {}) {
|
|
|
57025
57018
|
timeoutController.abort(new Error(`Command timed out after ${timeoutMs}ms`));
|
|
57026
57019
|
}, timeoutMs);
|
|
57027
57020
|
try {
|
|
57028
|
-
const result = await session.bash.exec(
|
|
57021
|
+
const result = await session.bash.exec(trimmedCommand, {
|
|
57029
57022
|
cwd: session.cwd,
|
|
57030
57023
|
env: {
|
|
57031
|
-
...
|
|
57024
|
+
...DEFAULT_BASH_SHELL_ENV,
|
|
57032
57025
|
PWD: session.cwd
|
|
57033
57026
|
},
|
|
57034
57027
|
signal: combinedController.signal
|
|
@@ -57037,23 +57030,6 @@ async function execBashWithTimeout(session, command, options2 = {}) {
|
|
|
57037
57030
|
if (nextCwd) {
|
|
57038
57031
|
session.cwd = normalizeBashPath(nextCwd);
|
|
57039
57032
|
}
|
|
57040
|
-
return result;
|
|
57041
|
-
} finally {
|
|
57042
|
-
globalThis.clearTimeout(timeoutId);
|
|
57043
|
-
}
|
|
57044
|
-
}
|
|
57045
|
-
async function executeBrowserBash(session, command, options2 = {}) {
|
|
57046
|
-
const trimmedCommand = command.trim();
|
|
57047
|
-
if (!trimmedCommand) {
|
|
57048
|
-
return { success: false, error: "Command is required", stderr: "Command is required", exit_code: 1, command: trimmedCommand, backend: "just-bash" };
|
|
57049
|
-
}
|
|
57050
|
-
const startedAt = Date.now();
|
|
57051
|
-
const outputLimit = options2.outputLimit ?? DEFAULT_BASH_OUTPUT_LIMIT;
|
|
57052
|
-
try {
|
|
57053
|
-
const result = await execBashWithTimeout(session, trimmedCommand, {
|
|
57054
|
-
timeoutMs: options2.commandTimeoutMs,
|
|
57055
|
-
signal: options2.signal
|
|
57056
|
-
});
|
|
57057
57033
|
const stdout = options2.truncateOutput === false ? result.stdout : truncateBashOutput(result.stdout, outputLimit);
|
|
57058
57034
|
const stderr = options2.truncateOutput === false ? result.stderr : truncateBashOutput(result.stderr, outputLimit);
|
|
57059
57035
|
const error = result.exitCode === 0 ? void 0 : stderr || void 0;
|
|
@@ -57071,22 +57047,22 @@ async function executeBrowserBash(session, command, options2 = {}) {
|
|
|
57071
57047
|
} catch (error) {
|
|
57072
57048
|
const message = error instanceof Error ? error.message : String(error);
|
|
57073
57049
|
return { success: false, command: trimmedCommand, error: message, stderr: message, exit_code: 1, duration_ms: Date.now() - startedAt, backend: "just-bash" };
|
|
57050
|
+
} finally {
|
|
57051
|
+
globalThis.clearTimeout(timeoutId);
|
|
57074
57052
|
}
|
|
57075
57053
|
}
|
|
57076
57054
|
|
|
57077
57055
|
// src/index.ts
|
|
57078
|
-
var AGENT_WEB_OS_VERSION = "0.
|
|
57056
|
+
var AGENT_WEB_OS_VERSION = "0.2.0";
|
|
57079
57057
|
console.log(`[agent-web-os] v${AGENT_WEB_OS_VERSION}`);
|
|
57080
57058
|
var getServerBridge2 = getServerBridge;
|
|
57081
57059
|
var resetServerBridge2 = resetServerBridge;
|
|
57082
57060
|
export {
|
|
57083
57061
|
AGENT_WEB_OS_VERSION,
|
|
57084
|
-
AlmostNodeSession,
|
|
57085
57062
|
Ju as Bash,
|
|
57086
57063
|
DEFAULT_BASH_SHELL_ENV,
|
|
57087
57064
|
ObservableInMemoryFs,
|
|
57088
57065
|
assertObservableInMemoryFs,
|
|
57089
|
-
createAlmostNodeSession,
|
|
57090
57066
|
createBrowserBashSession,
|
|
57091
57067
|
Dx as defineCommand,
|
|
57092
57068
|
executeBrowserBash,
|