agent-web-os 0.1.18 → 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 +41 -50
- 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 +41 -50
- 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
|
@@ -56279,6 +56279,17 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
56279
56279
|
stdoutAny.columns = this._terminalColumns;
|
|
56280
56280
|
stdoutAny.rows = this._terminalRows;
|
|
56281
56281
|
stdoutAny.getWindowSize = () => [this._terminalColumns, this._terminalRows];
|
|
56282
|
+
let rawModeRequested = false;
|
|
56283
|
+
if (process4.stdin) {
|
|
56284
|
+
const originalSetRawMode = process4.stdin.setRawMode;
|
|
56285
|
+
process4.stdin.setRawMode = (mode) => {
|
|
56286
|
+
rawModeRequested = rawModeRequested || mode;
|
|
56287
|
+
if (typeof originalSetRawMode === "function") {
|
|
56288
|
+
return originalSetRawMode.call(process4.stdin, mode);
|
|
56289
|
+
}
|
|
56290
|
+
return process4.stdin;
|
|
56291
|
+
};
|
|
56292
|
+
}
|
|
56282
56293
|
this._stdinHandler = process4.stdin ? (data2) => {
|
|
56283
56294
|
process4.stdin.emit("data", data2);
|
|
56284
56295
|
} : null;
|
|
@@ -56346,7 +56357,11 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
56346
56357
|
runtime.runFile(invocation.scriptPath);
|
|
56347
56358
|
}
|
|
56348
56359
|
syncExecution = false;
|
|
56349
|
-
|
|
56360
|
+
await new Promise((resolve5) => {
|
|
56361
|
+
setTimeout(resolve5, 0);
|
|
56362
|
+
});
|
|
56363
|
+
const hasStdinListeners = process4.stdin && (process4.stdin.listenerCount("data") > 0 || process4.stdin.listenerCount("keypress") > 0);
|
|
56364
|
+
const isInteractive = hasStdinListeners || rawModeRequested;
|
|
56350
56365
|
const asyncExitCode = isInteractive ? await exitPromise : await Promise.race([
|
|
56351
56366
|
exitPromise,
|
|
56352
56367
|
new Promise((resolve5) => {
|
|
@@ -56725,7 +56740,13 @@ function globToRegex(pattern) {
|
|
|
56725
56740
|
function escapeRegex(s10) {
|
|
56726
56741
|
return s10.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
56727
56742
|
}
|
|
56728
|
-
function
|
|
56743
|
+
async function loadIgnoreFile(fs, filePath) {
|
|
56744
|
+
let content;
|
|
56745
|
+
try {
|
|
56746
|
+
content = await fs.readFile(filePath);
|
|
56747
|
+
} catch {
|
|
56748
|
+
return [];
|
|
56749
|
+
}
|
|
56729
56750
|
const matchers = [];
|
|
56730
56751
|
for (const raw of content.split("\n")) {
|
|
56731
56752
|
const line = raw.trim();
|
|
@@ -56743,19 +56764,8 @@ function parseIgnorePatterns(content) {
|
|
|
56743
56764
|
}
|
|
56744
56765
|
return matchers;
|
|
56745
56766
|
}
|
|
56746
|
-
async function loadIgnoreFile(fs, filePath) {
|
|
56747
|
-
try {
|
|
56748
|
-
const content = await fs.readFile(filePath);
|
|
56749
|
-
return parseIgnorePatterns(content);
|
|
56750
|
-
} catch {
|
|
56751
|
-
return [];
|
|
56752
|
-
}
|
|
56753
|
-
}
|
|
56754
56767
|
function resolvePath(base, rel) {
|
|
56755
|
-
|
|
56756
|
-
return normalizePath2(`${base}/${rel}`);
|
|
56757
|
-
}
|
|
56758
|
-
function normalizePath2(p) {
|
|
56768
|
+
const p = rel.startsWith("/") ? rel : `${base}/${rel}`;
|
|
56759
56769
|
const parts = p.split("/").filter(Boolean);
|
|
56760
56770
|
const result = [];
|
|
56761
56771
|
for (const part of parts) {
|
|
@@ -56820,13 +56830,6 @@ async function executeFd(args, ctx) {
|
|
|
56820
56830
|
}
|
|
56821
56831
|
const excludeMatchers = opts.excludes.map((p) => globToRegex(p));
|
|
56822
56832
|
const ignoreMatchers = [];
|
|
56823
|
-
if (!opts.noIgnore) {
|
|
56824
|
-
for (const root2 of searchRoots) {
|
|
56825
|
-
const gitignorePath = `${root2}/.gitignore`;
|
|
56826
|
-
const loaded = await loadIgnoreFile(fs, gitignorePath);
|
|
56827
|
-
ignoreMatchers.push(...loaded);
|
|
56828
|
-
}
|
|
56829
|
-
}
|
|
56830
56833
|
for (const ignoreFile of opts.ignoreFiles) {
|
|
56831
56834
|
const absPath = resolvePath(cwd, ignoreFile);
|
|
56832
56835
|
const loaded = await loadIgnoreFile(fs, absPath);
|
|
@@ -56906,9 +56909,7 @@ async function executeFd(args, ctx) {
|
|
|
56906
56909
|
if (!opts.noIgnore) {
|
|
56907
56910
|
const rootGitignore = `${root2}/.gitignore`;
|
|
56908
56911
|
const loaded = await loadIgnoreFile(fs, rootGitignore);
|
|
56909
|
-
|
|
56910
|
-
ignoreMatchers.push(...loaded);
|
|
56911
|
-
}
|
|
56912
|
+
ignoreMatchers.push(...loaded);
|
|
56912
56913
|
}
|
|
56913
56914
|
await walk(root2, root2, 1);
|
|
56914
56915
|
}
|
|
@@ -56982,17 +56983,24 @@ function createBrowserBashSession(options2 = {}) {
|
|
|
56982
56983
|
return {
|
|
56983
56984
|
fs,
|
|
56984
56985
|
bash,
|
|
56985
|
-
almostNodeSession,
|
|
56986
56986
|
rootPath,
|
|
56987
56987
|
cwd: rootPath,
|
|
56988
|
+
setStdoutWriter: (writer) => almostNodeSession.setStdoutWriter(writer),
|
|
56989
|
+
writeStdin: (data2) => almostNodeSession.writeStdin(data2),
|
|
56990
|
+
setTerminalSize: (columns, rows) => almostNodeSession.setTerminalSize(columns, rows),
|
|
56988
56991
|
dispose: () => {
|
|
56989
56992
|
almostNodeSession.dispose();
|
|
56990
56993
|
}
|
|
56991
56994
|
};
|
|
56992
56995
|
}
|
|
56993
|
-
async function
|
|
56994
|
-
const
|
|
56995
|
-
|
|
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;
|
|
56996
57004
|
const timeoutController = new AbortController();
|
|
56997
57005
|
const combinedController = new AbortController();
|
|
56998
57006
|
const abort = (reason) => {
|
|
@@ -57010,10 +57018,10 @@ async function execBashWithTimeout(session, command, options2 = {}) {
|
|
|
57010
57018
|
timeoutController.abort(new Error(`Command timed out after ${timeoutMs}ms`));
|
|
57011
57019
|
}, timeoutMs);
|
|
57012
57020
|
try {
|
|
57013
|
-
const result = await session.bash.exec(
|
|
57021
|
+
const result = await session.bash.exec(trimmedCommand, {
|
|
57014
57022
|
cwd: session.cwd,
|
|
57015
57023
|
env: {
|
|
57016
|
-
...
|
|
57024
|
+
...DEFAULT_BASH_SHELL_ENV,
|
|
57017
57025
|
PWD: session.cwd
|
|
57018
57026
|
},
|
|
57019
57027
|
signal: combinedController.signal
|
|
@@ -57022,23 +57030,6 @@ async function execBashWithTimeout(session, command, options2 = {}) {
|
|
|
57022
57030
|
if (nextCwd) {
|
|
57023
57031
|
session.cwd = normalizeBashPath(nextCwd);
|
|
57024
57032
|
}
|
|
57025
|
-
return result;
|
|
57026
|
-
} finally {
|
|
57027
|
-
globalThis.clearTimeout(timeoutId);
|
|
57028
|
-
}
|
|
57029
|
-
}
|
|
57030
|
-
async function executeBrowserBash(session, command, options2 = {}) {
|
|
57031
|
-
const trimmedCommand = command.trim();
|
|
57032
|
-
if (!trimmedCommand) {
|
|
57033
|
-
return { success: false, error: "Command is required", stderr: "Command is required", exit_code: 1, command: trimmedCommand, backend: "just-bash" };
|
|
57034
|
-
}
|
|
57035
|
-
const startedAt = Date.now();
|
|
57036
|
-
const outputLimit = options2.outputLimit ?? DEFAULT_BASH_OUTPUT_LIMIT;
|
|
57037
|
-
try {
|
|
57038
|
-
const result = await execBashWithTimeout(session, trimmedCommand, {
|
|
57039
|
-
timeoutMs: options2.commandTimeoutMs,
|
|
57040
|
-
signal: options2.signal
|
|
57041
|
-
});
|
|
57042
57033
|
const stdout = options2.truncateOutput === false ? result.stdout : truncateBashOutput(result.stdout, outputLimit);
|
|
57043
57034
|
const stderr = options2.truncateOutput === false ? result.stderr : truncateBashOutput(result.stderr, outputLimit);
|
|
57044
57035
|
const error = result.exitCode === 0 ? void 0 : stderr || void 0;
|
|
@@ -57056,22 +57047,22 @@ async function executeBrowserBash(session, command, options2 = {}) {
|
|
|
57056
57047
|
} catch (error) {
|
|
57057
57048
|
const message = error instanceof Error ? error.message : String(error);
|
|
57058
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);
|
|
57059
57052
|
}
|
|
57060
57053
|
}
|
|
57061
57054
|
|
|
57062
57055
|
// src/index.ts
|
|
57063
|
-
var AGENT_WEB_OS_VERSION = "0.
|
|
57056
|
+
var AGENT_WEB_OS_VERSION = "0.2.0";
|
|
57064
57057
|
console.log(`[agent-web-os] v${AGENT_WEB_OS_VERSION}`);
|
|
57065
57058
|
var getServerBridge2 = getServerBridge;
|
|
57066
57059
|
var resetServerBridge2 = resetServerBridge;
|
|
57067
57060
|
export {
|
|
57068
57061
|
AGENT_WEB_OS_VERSION,
|
|
57069
|
-
AlmostNodeSession,
|
|
57070
57062
|
Ju as Bash,
|
|
57071
57063
|
DEFAULT_BASH_SHELL_ENV,
|
|
57072
57064
|
ObservableInMemoryFs,
|
|
57073
57065
|
assertObservableInMemoryFs,
|
|
57074
|
-
createAlmostNodeSession,
|
|
57075
57066
|
createBrowserBashSession,
|
|
57076
57067
|
Dx as defineCommand,
|
|
57077
57068
|
executeBrowserBash,
|