@deepseek-ai/dsh-experimental-webworker-runtime 0.1.6-alpha.1
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +75 -0
- package/README.zh.md +75 -0
- package/lib/client.js +854 -0
- package/lib/index.js +3506 -0
- package/lib/types/client/apply-injections.d.ts +15 -0
- package/lib/types/client/client.d.ts +102 -0
- package/lib/types/client/index.d.ts +66 -0
- package/lib/types/client/source-chooser.d.ts +8 -0
- package/lib/types/compile/transform.d.ts +39 -0
- package/lib/types/fixture-manifest.d.ts +26 -0
- package/lib/types/image-layout.d.ts +43 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/module-proxies.d.ts +25 -0
- package/lib/types/module-system/module-loader.d.ts +177 -0
- package/lib/types/module-system/posix-path.d.ts +98 -0
- package/lib/types/node/builtin_modules/implemented/abort-error.d.ts +11 -0
- package/lib/types/node/builtin_modules/implemented/async_hooks.d.ts +174 -0
- package/lib/types/node/builtin_modules/implemented/buffer.d.ts +28 -0
- package/lib/types/node/builtin_modules/implemented/child_process.d.ts +178 -0
- package/lib/types/node/builtin_modules/implemented/crypto.d.ts +53 -0
- package/lib/types/node/builtin_modules/implemented/events.d.ts +84 -0
- package/lib/types/node/builtin_modules/implemented/fs/promises.d.ts +39 -0
- package/lib/types/node/builtin_modules/implemented/fs-watch.d.ts +119 -0
- package/lib/types/node/builtin_modules/implemented/fs.d.ts +502 -0
- package/lib/types/node/builtin_modules/implemented/http.d.ts +113 -0
- package/lib/types/node/builtin_modules/implemented/module.d.ts +50 -0
- package/lib/types/node/builtin_modules/implemented/os.d.ts +115 -0
- package/lib/types/node/builtin_modules/implemented/path.d.ts +138 -0
- package/lib/types/node/builtin_modules/implemented/perf_hooks.d.ts +13 -0
- package/lib/types/node/builtin_modules/implemented/stream.d.ts +22 -0
- package/lib/types/node/builtin_modules/implemented/timers/promises.d.ts +36 -0
- package/lib/types/node/builtin_modules/implemented/tty.d.ts +18 -0
- package/lib/types/node/builtin_modules/implemented/url.d.ts +61 -0
- package/lib/types/node/builtin_modules/implemented/util/types.d.ts +12 -0
- package/lib/types/node/builtin_modules/implemented/util.d.ts +95 -0
- package/lib/types/node/builtin_modules/implemented/zlib.d.ts +65 -0
- package/lib/types/node/builtin_modules/mock/dns/promises.d.ts +10 -0
- package/lib/types/node/builtin_modules/mock/net.d.ts +61 -0
- package/lib/types/node/builtin_modules/mock/sqlite.d.ts +19 -0
- package/lib/types/node/builtin_modules/mock/vm.d.ts +25 -0
- package/lib/types/node/builtin_modules/mock/worker_threads.d.ts +34 -0
- package/lib/types/node/builtins.d.ts +13 -0
- package/lib/types/node/external_packages/koffi.d.ts +63 -0
- package/lib/types/node/external_packages/node-addon-system-flock.d.ts +19 -0
- package/lib/types/node/external_packages/node-pty.d.ts +13 -0
- package/lib/types/node/external_packages/pi-ai.d.ts +51 -0
- package/lib/types/node/external_packages/replaced-externals.d.ts +9 -0
- package/lib/types/node/external_packages/ripgrep.d.ts +16 -0
- package/lib/types/node/external_packages/sharp.d.ts +6 -0
- package/lib/types/node/external_packages/ws.d.ts +38 -0
- package/lib/types/node/globals/crypto.d.ts +3 -0
- package/lib/types/node/globals/process.d.ts +78 -0
- package/lib/types/node/globals/timers.d.ts +10 -0
- package/lib/types/node/notImplementedFail.d.ts +34 -0
- package/lib/types/node/process-table.d.ts +50 -0
- package/lib/types/polyfill/async-context/als-runtime.d.ts +45 -0
- package/lib/types/polyfill/async-context/async-context-hooks.d.ts +6 -0
- package/lib/types/shell/ast.d.ts +23 -0
- package/lib/types/shell/expand.d.ts +65 -0
- package/lib/types/shell/fs-access.d.ts +43 -0
- package/lib/types/shell/interpret.d.ts +54 -0
- package/lib/types/shell/process/child.d.ts +26 -0
- package/lib/types/shell/process/host.d.ts +58 -0
- package/lib/types/shell/process/landlock.d.ts +33 -0
- package/lib/types/shell/process/protocol.d.ts +74 -0
- package/lib/types/shell/process/virtual-executables.d.ts +49 -0
- package/lib/types/shell/programs/builtins.d.ts +9 -0
- package/lib/types/shell/programs/files.d.ts +11 -0
- package/lib/types/shell/programs/index.d.ts +14 -0
- package/lib/types/shell/programs/options.d.ts +40 -0
- package/lib/types/shell/programs/text.d.ts +9 -0
- package/lib/types/shell/types.d.ts +138 -0
- package/lib/types/storage/active.d.ts +18 -0
- package/lib/types/storage/image-gzip.d.ts +39 -0
- package/lib/types/storage/memory.d.ts +308 -0
- package/lib/types/storage/paths.d.ts +18 -0
- package/lib/types/storage/tar.d.ts +41 -0
- package/lib/types/storage/types.d.ts +279 -0
- package/lib/types/transport/frames.d.ts +108 -0
- package/lib/types/transport/synthetic-http.d.ts +50 -0
- package/lib/types/transport/tunnel.d.ts +132 -0
- package/lib/types/worker-host.d.ts +165 -0
- package/lib/types/worker.d.ts +2 -0
- package/lib/worker.js +21879 -0
- package/package.json +73 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Compiled script (unavailable). */
|
|
2
|
+
export declare const Script: typeof import('node:vm').Script;
|
|
3
|
+
/** Context creation (unavailable). */
|
|
4
|
+
export declare const createContext: typeof import('node:vm').createContext;
|
|
5
|
+
/** In-context evaluation (unavailable). */
|
|
6
|
+
export declare const runInContext: typeof import('node:vm').runInContext;
|
|
7
|
+
/** New-context evaluation (unavailable). */
|
|
8
|
+
export declare const runInNewContext: typeof import('node:vm').runInNewContext;
|
|
9
|
+
/** This-context evaluation (unavailable). */
|
|
10
|
+
export declare const runInThisContext: typeof import('node:vm').runInThisContext;
|
|
11
|
+
/** Context predicate (unavailable). */
|
|
12
|
+
export declare const isContext: typeof import('node:vm').isContext;
|
|
13
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
14
|
+
export declare const __esModule = true;
|
|
15
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
16
|
+
declare const _default: {
|
|
17
|
+
Script: typeof import("vm").Script;
|
|
18
|
+
createContext: typeof import("vm").createContext;
|
|
19
|
+
runInContext: typeof import("vm").runInContext;
|
|
20
|
+
runInNewContext: typeof import("vm").runInNewContext;
|
|
21
|
+
runInThisContext: typeof import("vm").runInThisContext;
|
|
22
|
+
isContext: typeof import("vm").isContext;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
//# sourceMappingURL=vm.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Worker-thread construction (unavailable). */
|
|
2
|
+
export declare const Worker: typeof import('node:worker_threads').Worker;
|
|
3
|
+
/** The host tree runs on the worker's main thread. */
|
|
4
|
+
export declare const isMainThread = true;
|
|
5
|
+
/** Thread id of the worker's main thread. */
|
|
6
|
+
export declare const threadId = 0;
|
|
7
|
+
/** No parent port exists, which Node reports as `null` outside a worker thread. */
|
|
8
|
+
export declare const parentPort: null;
|
|
9
|
+
/** No thread data was handed in. */
|
|
10
|
+
export declare const workerData: undefined;
|
|
11
|
+
/** Channel construction (unavailable). */
|
|
12
|
+
export declare const MessageChannel: typeof import('node:worker_threads').MessageChannel;
|
|
13
|
+
/** Port construction (unavailable). */
|
|
14
|
+
export declare const MessagePort: typeof import('node:worker_threads').MessagePort;
|
|
15
|
+
/** Object transfer marking (unavailable). */
|
|
16
|
+
export declare const markAsUntransferable: typeof import('node:worker_threads').markAsUntransferable;
|
|
17
|
+
/** Port receiving on a message channel (unavailable). */
|
|
18
|
+
export declare const receiveMessageOnPort: typeof import('node:worker_threads').receiveMessageOnPort;
|
|
19
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
20
|
+
export declare const __esModule = true;
|
|
21
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
22
|
+
declare const _default: {
|
|
23
|
+
Worker: typeof import("worker_threads").Worker;
|
|
24
|
+
isMainThread: true;
|
|
25
|
+
threadId: number;
|
|
26
|
+
parentPort: null;
|
|
27
|
+
workerData: undefined;
|
|
28
|
+
MessageChannel: typeof import("worker_threads").MessageChannel;
|
|
29
|
+
MessagePort: typeof import("worker_threads").MessagePort;
|
|
30
|
+
markAsUntransferable: typeof import("worker_threads").markAsUntransferable;
|
|
31
|
+
receiveMessageOnPort: typeof import("worker_threads").receiveMessageOnPort;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
34
|
+
//# sourceMappingURL=worker_threads.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StaticModuleFactory } from '../module-system/module-loader.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Prefixes whose every subpath resolves to one replacement module. The loader
|
|
4
|
+
* matches the longest prefix after its exact table misses, so pi-ai's
|
|
5
|
+
* `/providers/*` and `/api/*.lazy` entries need no enumeration.
|
|
6
|
+
*/
|
|
7
|
+
export declare const REPLACED_PREFIXES: Record<string, StaticModuleFactory>;
|
|
8
|
+
/**
|
|
9
|
+
* Build the specifier → factory table the worker module loader consults first.
|
|
10
|
+
* @returns every replaced specifier, including its `node:`-prefixed alias.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createNodeBuiltins(): Record<string, StaticModuleFactory>;
|
|
13
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Opaque type descriptor standing in for a koffi type handle. */
|
|
2
|
+
interface KoffiType {
|
|
3
|
+
readonly __dshKoffiType: string;
|
|
4
|
+
/** Byte size under the x64 ABI; struct layout guards compare against it. */
|
|
5
|
+
readonly size: number;
|
|
6
|
+
/** Byte alignment under the x64 ABI. */
|
|
7
|
+
readonly alignment: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Pointer type descriptor.
|
|
11
|
+
* @param target - pointee type name or descriptor.
|
|
12
|
+
* @returns the descriptor token.
|
|
13
|
+
*/
|
|
14
|
+
declare function pointer(target: unknown): KoffiType;
|
|
15
|
+
/**
|
|
16
|
+
* Struct type descriptor. The size and alignment are computed with the same
|
|
17
|
+
* padding rules koffi uses on x64, because the Windows ACL layer compares them
|
|
18
|
+
* against its own header probe at module scope.
|
|
19
|
+
* @param name - struct name, or the field record when the name is omitted.
|
|
20
|
+
* @param fields - field name → type record.
|
|
21
|
+
* @returns the descriptor token.
|
|
22
|
+
*/
|
|
23
|
+
declare function struct(name: unknown, fields?: Record<string, unknown>): KoffiType;
|
|
24
|
+
/**
|
|
25
|
+
* Array type descriptor.
|
|
26
|
+
* @param target - element type.
|
|
27
|
+
* @param length - element count.
|
|
28
|
+
* @returns the descriptor token.
|
|
29
|
+
*/
|
|
30
|
+
declare function array(target: unknown, length: number): KoffiType;
|
|
31
|
+
/**
|
|
32
|
+
* Opaque type descriptor.
|
|
33
|
+
* @param name - type name.
|
|
34
|
+
* @returns the descriptor token.
|
|
35
|
+
*/
|
|
36
|
+
declare function opaque(name?: string): KoffiType;
|
|
37
|
+
/** Primitive type table; members carry their x64 sizes. */
|
|
38
|
+
declare const types: Record<string, KoffiType>;
|
|
39
|
+
/** The koffi face its consumers read; every call refuses. */
|
|
40
|
+
declare const koffi: {
|
|
41
|
+
pointer: typeof pointer;
|
|
42
|
+
struct: typeof struct;
|
|
43
|
+
array: typeof array;
|
|
44
|
+
opaque: typeof opaque;
|
|
45
|
+
types: Record<string, KoffiType>;
|
|
46
|
+
alias: (name: string, target: unknown) => KoffiType;
|
|
47
|
+
sizeof: (target: unknown) => number;
|
|
48
|
+
alignof: (target: unknown) => number;
|
|
49
|
+
load: (...args: never[]) => never;
|
|
50
|
+
alloc: (...args: never[]) => never;
|
|
51
|
+
free: (...args: never[]) => never;
|
|
52
|
+
decode: (...args: never[]) => never;
|
|
53
|
+
encode: (...args: never[]) => never;
|
|
54
|
+
address: (...args: never[]) => never;
|
|
55
|
+
register: (...args: never[]) => never;
|
|
56
|
+
unregister: (...args: never[]) => never;
|
|
57
|
+
call: (...args: never[]) => never;
|
|
58
|
+
};
|
|
59
|
+
export { pointer, struct, array, opaque, types };
|
|
60
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
61
|
+
export declare const __esModule = true;
|
|
62
|
+
export default koffi;
|
|
63
|
+
//# sourceMappingURL=koffi.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-process worker replacement for `@deepseek-ai/node-addon-system/flock`.
|
|
3
|
+
* The JSONL backend's in-process write claim already excludes every writer,
|
|
4
|
+
* so its kernel-lock request succeeds without acquiring another resource.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Grant the single-process worker's exclusive-lock request immediately.
|
|
8
|
+
* @param _fd - file descriptor (unused).
|
|
9
|
+
* @returns an already-fulfilled promise.
|
|
10
|
+
*/
|
|
11
|
+
export declare function tryLockExclusive(_fd: number): Promise<void>;
|
|
12
|
+
/** CommonJS interop marker for the worker module loader. */
|
|
13
|
+
export declare const __esModule = true;
|
|
14
|
+
/** The native flock API used by the JSONL backend. */
|
|
15
|
+
declare const _default: {
|
|
16
|
+
tryLockExclusive: typeof tryLockExclusive;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=node-addon-system-flock.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Spawn a pseudo-terminal (unavailable). */
|
|
2
|
+
export declare const spawn: (...args: never[]) => never;
|
|
3
|
+
/** Open a pseudo-terminal pair (unavailable). */
|
|
4
|
+
export declare const open: (...args: never[]) => never;
|
|
5
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
6
|
+
export declare const __esModule = true;
|
|
7
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
8
|
+
declare const _default: {
|
|
9
|
+
spawn: (...args: never[]) => never;
|
|
10
|
+
open: (...args: never[]) => never;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=node-pty.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Provider factory (unavailable). */
|
|
2
|
+
export declare const createProvider: (...args: never[]) => never;
|
|
3
|
+
/** Model-list factory (unavailable). */
|
|
4
|
+
export declare const createModels: (...args: never[]) => never;
|
|
5
|
+
/** Thinking-level catalog (unavailable). */
|
|
6
|
+
export declare const getSupportedThinkingLevels: (...args: never[]) => never;
|
|
7
|
+
/** Context-overflow predicate (unavailable). */
|
|
8
|
+
export declare const isContextOverflow: (...args: never[]) => never;
|
|
9
|
+
/**
|
|
10
|
+
* Installed catalog providers, read while `llm-pi-ai` activates. Each carries the
|
|
11
|
+
* api-key auth marker the adapter filters on, and no models: the provider
|
|
12
|
+
* directory therefore matches the served deployment while every request path
|
|
13
|
+
* lands on a loud symbol above.
|
|
14
|
+
* @returns one entry per builtin provider.
|
|
15
|
+
*/
|
|
16
|
+
export declare function builtinProviders(): unknown[];
|
|
17
|
+
/**
|
|
18
|
+
* Provider route ids of the installed catalog. `llm-pi-ai` registers the whole
|
|
19
|
+
* catalog as configurable the moment it mounts and rejects an empty
|
|
20
|
+
* registration, so these are pi-ai's real ids rather than an empty list.
|
|
21
|
+
* @returns the builtin provider ids.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getBuiltinProviders(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Models of one installed catalog provider.
|
|
26
|
+
* @returns no models.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getBuiltinModels(): unknown[];
|
|
29
|
+
/** Anthropic messages API binding (unavailable). */
|
|
30
|
+
export declare const anthropicMessagesApi: (...args: never[]) => never;
|
|
31
|
+
/** OpenAI completions API binding (unavailable). */
|
|
32
|
+
export declare const openAICompletionsApi: (...args: never[]) => never;
|
|
33
|
+
/** OpenAI responses API binding (unavailable). */
|
|
34
|
+
export declare const openAIResponsesApi: (...args: never[]) => never;
|
|
35
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports. */
|
|
36
|
+
export declare const __esModule = true;
|
|
37
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
38
|
+
declare const _default: {
|
|
39
|
+
createProvider: (...args: never[]) => never;
|
|
40
|
+
createModels: (...args: never[]) => never;
|
|
41
|
+
getSupportedThinkingLevels: (...args: never[]) => never;
|
|
42
|
+
isContextOverflow: (...args: never[]) => never;
|
|
43
|
+
builtinProviders: typeof builtinProviders;
|
|
44
|
+
getBuiltinModels: typeof getBuiltinModels;
|
|
45
|
+
getBuiltinProviders: typeof getBuiltinProviders;
|
|
46
|
+
anthropicMessagesApi: (...args: never[]) => never;
|
|
47
|
+
openAICompletionsApi: (...args: never[]) => never;
|
|
48
|
+
openAIResponsesApi: (...args: never[]) => never;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
51
|
+
//# sourceMappingURL=pi-ai.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact package or subpath specifiers served from the worker bundle. Kept
|
|
3
|
+
* import-free for the runtime builtin table and the VFS image collector.
|
|
4
|
+
* Whole-package entries are omitted from the image; subpath entries leave
|
|
5
|
+
* their parent package available to other consumers.
|
|
6
|
+
*/
|
|
7
|
+
/** Package or subpath specifiers served from the worker bundle instead of the VFS. */
|
|
8
|
+
export declare const REPLACED_EXTERNAL_PACKAGES: readonly string[];
|
|
9
|
+
//# sourceMappingURL=replaced-externals.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@vscode/ripgrep` stub. The package's only export is the binary path, read at
|
|
3
|
+
* module scope by search plugins; the path stays a plain string so construction
|
|
4
|
+
* succeeds, and the loud failure comes from the child_process stub when something
|
|
5
|
+
* tries to run it.
|
|
6
|
+
*/
|
|
7
|
+
/** Path the search plugins would spawn; nothing can execute it in a browser. */
|
|
8
|
+
export declare const rgPath = "/dsh/bin/rg";
|
|
9
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
10
|
+
export declare const __esModule = true;
|
|
11
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
12
|
+
declare const _default: {
|
|
13
|
+
rgPath: string;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=ripgrep.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Image processing has no worker counterpart; the call refuses. */
|
|
2
|
+
declare const sharp: (...args: never[]) => never;
|
|
3
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
4
|
+
export declare const __esModule = true;
|
|
5
|
+
export default sharp;
|
|
6
|
+
//# sourceMappingURL=sharp.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Client socket (unavailable; the page side uses the tunnel, not WebSocket). */
|
|
2
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
3
|
+
export declare const __esModule = true;
|
|
4
|
+
/** Client socket (unavailable; the page side uses the tunnel, not WebSocket). */
|
|
5
|
+
export default class WebSocket {
|
|
6
|
+
/** Node's `CONNECTING` ready state, read by consumers that never connect. */
|
|
7
|
+
static readonly CONNECTING = 0;
|
|
8
|
+
/** Node's `OPEN` ready state. */
|
|
9
|
+
static readonly OPEN = 1;
|
|
10
|
+
/** Node's `CLOSING` ready state. */
|
|
11
|
+
static readonly CLOSING = 2;
|
|
12
|
+
/** Node's `CLOSED` ready state. */
|
|
13
|
+
static readonly CLOSED = 3;
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/** Server whose construction must succeed and whose methods are unreachable. */
|
|
17
|
+
export declare class WebSocketServer {
|
|
18
|
+
/** Connected clients: always empty, since no upgrade ever completes. */
|
|
19
|
+
readonly clients: Set<never>;
|
|
20
|
+
/** Upgrade handling (unreachable: no upgrade event is ever emitted). */
|
|
21
|
+
readonly handleUpgrade: (...args: never[]) => never;
|
|
22
|
+
/** Broadcast helper (unreachable). */
|
|
23
|
+
readonly emit: (...args: never[]) => never;
|
|
24
|
+
/**
|
|
25
|
+
* Register a listener; nothing is ever emitted.
|
|
26
|
+
* @returns this server.
|
|
27
|
+
*/
|
|
28
|
+
on(): this;
|
|
29
|
+
/**
|
|
30
|
+
* Close the server.
|
|
31
|
+
* @param callback - completion callback, invoked immediately.
|
|
32
|
+
*/
|
|
33
|
+
close(callback?: () => void): void;
|
|
34
|
+
}
|
|
35
|
+
/** Alias Node consumers sometimes import. */
|
|
36
|
+
export declare const Server: typeof WebSocketServer;
|
|
37
|
+
export { WebSocket };
|
|
38
|
+
//# sourceMappingURL=ws.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Construction inputs for {@link installProcessGlobal}. */
|
|
2
|
+
export interface ProcessShimOptions {
|
|
3
|
+
/** Virtual root reported by `cwd()`. */
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
/** Environment the tree reads; `DSH_HOME` belongs here. */
|
|
6
|
+
readonly env: Readonly<Record<string, string>>;
|
|
7
|
+
/** Argument vector reported to the tree. */
|
|
8
|
+
readonly argv?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/** The members this shim publishes. */
|
|
11
|
+
export interface ProcessShim {
|
|
12
|
+
readonly env: Record<string, string>;
|
|
13
|
+
readonly argv: string[];
|
|
14
|
+
readonly execArgv: string[];
|
|
15
|
+
/** Virtual host identity; spawning this path reports ENOENT because Node execution is unavailable. */
|
|
16
|
+
readonly execPath: string;
|
|
17
|
+
/** Node process identity used by dependencies for environment detection. */
|
|
18
|
+
readonly title: string;
|
|
19
|
+
/**
|
|
20
|
+
* Node 22 `process.getBuiltinModule`: the worker's module proxy for a
|
|
21
|
+
* builtin id (`fs`, `node:fs`), or undefined for anything else — it never
|
|
22
|
+
* resolves image modules.
|
|
23
|
+
* @param id - Builtin module id, with or without the `node:` prefix.
|
|
24
|
+
* @returns the proxied builtin, or undefined.
|
|
25
|
+
*/
|
|
26
|
+
getBuiltinModule(id: string): unknown;
|
|
27
|
+
readonly platform: string;
|
|
28
|
+
readonly arch: string;
|
|
29
|
+
readonly pid: number;
|
|
30
|
+
readonly version: string;
|
|
31
|
+
readonly versions: Record<string, string>;
|
|
32
|
+
cwd(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Signal one command started through the `node:child_process` shim. Signal
|
|
35
|
+
* `0` is the liveness probe the subprocess service polls a process tree
|
|
36
|
+
* with; a negative pid addresses the group, which here holds exactly the one
|
|
37
|
+
* command that leads it.
|
|
38
|
+
* @param pid - the target pid, negative for its group.
|
|
39
|
+
* @param signal - signal name, or `0` to probe without delivering one.
|
|
40
|
+
* @returns true once the signal is recorded.
|
|
41
|
+
* @throws Error with `code: 'ESRCH'` when no such command is running.
|
|
42
|
+
*/
|
|
43
|
+
kill(pid: number, signal?: NodeJS.Signals | 0): boolean;
|
|
44
|
+
nextTick(callback: (...args: unknown[]) => void, ...args: unknown[]): void;
|
|
45
|
+
readonly stdout: {
|
|
46
|
+
write(chunk: string): boolean;
|
|
47
|
+
};
|
|
48
|
+
readonly stderr: {
|
|
49
|
+
write(chunk: string): boolean;
|
|
50
|
+
};
|
|
51
|
+
on(): ProcessShim;
|
|
52
|
+
off(): ProcessShim;
|
|
53
|
+
once(): ProcessShim;
|
|
54
|
+
prependListener(): ProcessShim;
|
|
55
|
+
prependOnceListener(): ProcessShim;
|
|
56
|
+
removeListener(): ProcessShim;
|
|
57
|
+
removeAllListeners(): ProcessShim;
|
|
58
|
+
listeners(): unknown[];
|
|
59
|
+
listenerCount(): number;
|
|
60
|
+
setMaxListeners(): ProcessShim;
|
|
61
|
+
emit(): boolean;
|
|
62
|
+
readonly hrtime: {
|
|
63
|
+
bigint(): bigint;
|
|
64
|
+
};
|
|
65
|
+
uptime(): number;
|
|
66
|
+
exit(code?: number): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Publish `globalThis.process`.
|
|
70
|
+
*
|
|
71
|
+
* `versions.node` is `0.0.0` on purpose: it makes Cordis's
|
|
72
|
+
* `ModuleLoader.fromInternal()` return undefined instead of reaching for Node
|
|
73
|
+
* internals, which is what lets the worker install its own module seam.
|
|
74
|
+
* @param options - Root, environment, and argument vector.
|
|
75
|
+
* @returns The published object, for the module proxy table.
|
|
76
|
+
*/
|
|
77
|
+
export declare function installProcessGlobal(options: ProcessShimOptions): ProcessShim;
|
|
78
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Node `Timeout`/`Immediate` face the harness relies on. */
|
|
2
|
+
export interface TimerHandle {
|
|
3
|
+
ref(): TimerHandle;
|
|
4
|
+
unref(): TimerHandle;
|
|
5
|
+
hasRef(): boolean;
|
|
6
|
+
[Symbol.toPrimitive](): number;
|
|
7
|
+
}
|
|
8
|
+
/** Replace the worker's timer globals with the Node-shaped wrappers. */
|
|
9
|
+
export declare function installTimerGlobals(): void;
|
|
10
|
+
//# sourceMappingURL=timers.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural not-implemented stubs: a replaced module must expose every symbol
|
|
3
|
+
* its importers name (a missing CommonJS symbol degrades to `undefined` at call
|
|
4
|
+
* time instead of failing at link time), and every one of those symbols must
|
|
5
|
+
* report exactly what is unavailable when it is finally called.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Build a function that throws naming its module and symbol. The refusal is
|
|
9
|
+
* also written to the console before it propagates: callers routinely swallow
|
|
10
|
+
* these errors far from their cause, and the console line is what places the
|
|
11
|
+
* failure while debugging a worker session.
|
|
12
|
+
*
|
|
13
|
+
* `Face` is the Node declaration this stub stands in for, so the replaced module
|
|
14
|
+
* publishes the type its importers compile against. The value is one throwing
|
|
15
|
+
* function whatever that declaration says: a caller reaches the throw before any
|
|
16
|
+
* declared parameter, return value, or `new` result exists, so the assertion
|
|
17
|
+
* below cannot be observed as a lie. It is a function expression rather than an
|
|
18
|
+
* arrow because a stub standing in for a class must refuse under `new` too, and
|
|
19
|
+
* an arrow has no construct behavior to reach.
|
|
20
|
+
* @param module - module specifier being stubbed.
|
|
21
|
+
* @param symbol - exported symbol name.
|
|
22
|
+
* @returns the throwing stand-in, typed as the member it replaces.
|
|
23
|
+
*/
|
|
24
|
+
export declare function notImplementedFail<Face = (...args: never[]) => never>(module: string, symbol: string): Face;
|
|
25
|
+
/**
|
|
26
|
+
* Build the refusal error and write it to the console first, for stubs that
|
|
27
|
+
* cannot be a plain throwing function (constructors, methods on structural
|
|
28
|
+
* fakes).
|
|
29
|
+
* @param module - module specifier being stubbed.
|
|
30
|
+
* @param symbol - unavailable member, named as the importer sees it.
|
|
31
|
+
* @returns the error to throw.
|
|
32
|
+
*/
|
|
33
|
+
export declare function notAvailableError(module: string, symbol: string): Error;
|
|
34
|
+
//# sourceMappingURL=notImplementedFail.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker's process table. A browser worker cannot fork, so the
|
|
3
|
+
* `node:child_process` shim keeps its own table: one entry per running
|
|
4
|
+
* command, with the pid `process.kill` and the subprocess service's tree
|
|
5
|
+
* bookkeeping address it by.
|
|
6
|
+
*
|
|
7
|
+
* Kept apart from both consumers because they need it from opposite sides —
|
|
8
|
+
* the shim registers entries, the `process` global signals them.
|
|
9
|
+
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/node/process-table
|
|
10
|
+
*/
|
|
11
|
+
import type { RunningProcess } from '../shell/process/host.ts';
|
|
12
|
+
/** One running command, as the table tracks it. */
|
|
13
|
+
export interface WorkerProcessEntry {
|
|
14
|
+
/** Identifier handed out to the host tree; unique for the worker's lifetime. */
|
|
15
|
+
readonly pid: number;
|
|
16
|
+
/** The first signal delivered, which decides how the process reports its death. */
|
|
17
|
+
signal: NodeJS.Signals | undefined;
|
|
18
|
+
/** The started command, attached once it exists; signals reach it through this. */
|
|
19
|
+
process: RunningProcess | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reserve one pid before its command starts, so a handle can report it
|
|
23
|
+
* synchronously.
|
|
24
|
+
* @returns the new table entry, still without its process.
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerProcess(): WorkerProcessEntry;
|
|
27
|
+
/**
|
|
28
|
+
* Drop one entry once its command has settled.
|
|
29
|
+
* @param pid - the entry's pid.
|
|
30
|
+
*/
|
|
31
|
+
export declare function releaseProcess(pid: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a command with this pid is still running.
|
|
34
|
+
* @param pid - pid to look up; a negative value addresses the group, which here
|
|
35
|
+
* holds exactly the one process that leads it.
|
|
36
|
+
* @returns true while the entry is in the table.
|
|
37
|
+
*/
|
|
38
|
+
export declare function processAlive(pid: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Deliver a signal to one running command.
|
|
41
|
+
*
|
|
42
|
+
* `SIGKILL` stops the command whatever it is doing; every other signal asks it
|
|
43
|
+
* to stop at its next command boundary. That distinction is real only for a
|
|
44
|
+
* worker-backed process — see {@link RunningProcess.destroy}.
|
|
45
|
+
* @param pid - pid or negative process-group id.
|
|
46
|
+
* @param signal - the signal name to record and deliver.
|
|
47
|
+
* @returns true when an entry received it, false when no such process exists.
|
|
48
|
+
*/
|
|
49
|
+
export declare function signalProcess(pid: number, signal: NodeJS.Signals): boolean;
|
|
50
|
+
//# sourceMappingURL=process-table.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime the transformed modules call at every suspension point.
|
|
3
|
+
*
|
|
4
|
+
* `pause` snapshots every ambient store and hands back a token that **always
|
|
5
|
+
* fulfills** (a rejection travels inside it); `resume` restores that snapshot as
|
|
6
|
+
* the first thing the resumed frame does, then returns the value or rethrows the
|
|
7
|
+
* error, so both completion paths are causally exact. The state itself belongs to
|
|
8
|
+
* the `node:async_hooks` proxy — this module only moves it.
|
|
9
|
+
*
|
|
10
|
+
* The transform that inserts these calls lives in `transform.ts`.
|
|
11
|
+
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/polyfill/async-context/als-runtime
|
|
12
|
+
*/
|
|
13
|
+
/** Snapshot of every ambient store, opaque to this module. */
|
|
14
|
+
export type AlsSnapshot = unknown;
|
|
15
|
+
/** Result of a suspension: a rejection travels inside it, so the token always fulfills. */
|
|
16
|
+
export interface AlsToken {
|
|
17
|
+
readonly ok: boolean;
|
|
18
|
+
readonly value?: unknown;
|
|
19
|
+
readonly error?: unknown;
|
|
20
|
+
readonly snapshot: AlsSnapshot;
|
|
21
|
+
}
|
|
22
|
+
/** The state face the rewrite moves snapshots through; the shim owns the state itself. */
|
|
23
|
+
export interface AlsCausality {
|
|
24
|
+
/** Capture every instance's current store. */
|
|
25
|
+
snapshot(): AlsSnapshot;
|
|
26
|
+
/** Restore a captured snapshot. */
|
|
27
|
+
restore(snapshot: AlsSnapshot): void;
|
|
28
|
+
}
|
|
29
|
+
/** Runtime the rewritten modules call; built by {@link createAlsRuntime}. */
|
|
30
|
+
export interface AlsRuntime {
|
|
31
|
+
pause(value: unknown): Promise<AlsToken>;
|
|
32
|
+
resume(token: AlsToken): unknown;
|
|
33
|
+
snapshot(): AlsSnapshot;
|
|
34
|
+
afterYield(snapshot: AlsSnapshot, sent: unknown): unknown;
|
|
35
|
+
iterator(value: unknown): AsyncIterator<unknown>;
|
|
36
|
+
close(iterator: AsyncIterator<unknown>): Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build the runtime the rewritten code calls.
|
|
40
|
+
* @param causality - Snapshot face from the `node:async_hooks` proxy; omitted
|
|
41
|
+
* leaves the rewrite inert (it still hops a microtask, but moves no state).
|
|
42
|
+
* @returns Runtime object passed to every module wrapper.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createAlsRuntime(causality?: AlsCausality): AlsRuntime;
|
|
45
|
+
//# sourceMappingURL=als-runtime.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parsed command line, as this shell names it.
|
|
3
|
+
*
|
|
4
|
+
* `@yarnpkg/parsers` re-exports only part of its grammar's type map from the
|
|
5
|
+
* package root, and its `exports` field forbids reaching the grammar module
|
|
6
|
+
* directly, so the three missing members are derived from the ones it does
|
|
7
|
+
* publish. `CommandChain` is `Command` plus an optional pipeline link, which
|
|
8
|
+
* makes it usable wherever a command node is expected.
|
|
9
|
+
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/shell/ast
|
|
10
|
+
*/
|
|
11
|
+
import type { Argument, CommandChain } from '@yarnpkg/parsers';
|
|
12
|
+
export type { ArgumentSegment, ArithmeticExpression, CommandChain, CommandLine, ShellLine } from '@yarnpkg/parsers';
|
|
13
|
+
/** One command node: a program call, a subshell, a group, or bare assignments. */
|
|
14
|
+
export type Command = CommandChain;
|
|
15
|
+
/** An argument that becomes argv fields. */
|
|
16
|
+
export type ValueArgument = Extract<Argument, {
|
|
17
|
+
type: 'argument';
|
|
18
|
+
}>;
|
|
19
|
+
/** An argument that rewires a descriptor instead of becoming argv. */
|
|
20
|
+
export type RedirectArgument = Extract<Argument, {
|
|
21
|
+
type: 'redirection';
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Word expansion: one parsed argument becomes the zero or more fields a
|
|
3
|
+
* program receives in its argv. Covers the segment kinds the grammar produces
|
|
4
|
+
* — literal text, variables (with `:-` / `:+` forms), command substitution,
|
|
5
|
+
* arithmetic, and globs matched against the VFS.
|
|
6
|
+
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/shell/expand
|
|
7
|
+
*/
|
|
8
|
+
import type { ShellLine, ValueArgument } from './ast.ts';
|
|
9
|
+
import type { ShellFileSystem, ShellState } from './types.ts';
|
|
10
|
+
/**
|
|
11
|
+
* Whether one word is a glob the shell should match against the filesystem.
|
|
12
|
+
* Handed to `parseShell`, which decides between a `text` and a `glob` segment.
|
|
13
|
+
* @param word - the word exactly as it was written.
|
|
14
|
+
* @returns true when the word contains a wildcard.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isGlobPattern(word: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Read one variable the way `$name` does.
|
|
19
|
+
*
|
|
20
|
+
* Shell variables shadow the environment (an assignment without `export` is
|
|
21
|
+
* only visible to this shell), and the specials report what a shell without
|
|
22
|
+
* job control or positional parameters can honestly report.
|
|
23
|
+
* @param state - the shell state to read.
|
|
24
|
+
* @param name - variable name, or one of `?`, `$`, `#`, `@`, `*`, `0`.
|
|
25
|
+
* @returns the value, or undefined when the variable is unset.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readVariable(state: ShellState, name: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Expand one glob against the filesystem, one path segment at a time.
|
|
30
|
+
*
|
|
31
|
+
* Matches keep the pattern's own spelling: a relative pattern yields relative
|
|
32
|
+
* paths, so `ls *.ts` prints what the model typed.
|
|
33
|
+
* @param pattern - the glob as written.
|
|
34
|
+
* @param cwd - directory a relative pattern starts from.
|
|
35
|
+
* @param fs - the filesystem to match against.
|
|
36
|
+
* @returns sorted matches, or an empty array when nothing matches.
|
|
37
|
+
*/
|
|
38
|
+
export declare function expandGlob(pattern: string, cwd: string, fs: ShellFileSystem): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Everything expansion needs that the argument itself cannot supply: how to
|
|
41
|
+
* run a command substitution, and the state variables resolve against.
|
|
42
|
+
*/
|
|
43
|
+
export interface ExpansionContext {
|
|
44
|
+
state: ShellState;
|
|
45
|
+
/** The filesystem globs match against. */
|
|
46
|
+
fs: ShellFileSystem;
|
|
47
|
+
/**
|
|
48
|
+
* Run one nested command line and return its standard output.
|
|
49
|
+
* @param shell - the parsed line inside `$( … )`.
|
|
50
|
+
* @returns the captured output, with trailing newlines already stripped.
|
|
51
|
+
*/
|
|
52
|
+
substitute(shell: ShellLine): Promise<string>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Expand one argument into fields.
|
|
56
|
+
*
|
|
57
|
+
* Unquoted expansions split on whitespace the way a shell does, so
|
|
58
|
+
* `cat $FILES` with two names runs `cat` with two arguments while
|
|
59
|
+
* `cat "$FILES"` runs it with one.
|
|
60
|
+
* @param argument - the parsed argument.
|
|
61
|
+
* @param context - substitution hook and shell state.
|
|
62
|
+
* @returns the fields this argument contributes to argv.
|
|
63
|
+
*/
|
|
64
|
+
export declare function expandArgument(argument: ValueArgument, context: ExpansionContext): Promise<string[]>;
|
|
65
|
+
//# sourceMappingURL=expand.d.ts.map
|