@artenx/dshb 0.0.5 → 0.1.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/README.md +18 -0
- package/cordis.patch.yml +9 -9
- package/lib/auth/credentials.d.ts +30 -0
- package/lib/auth/credentials.js +121 -0
- package/lib/auth/credentials.js.map +1 -0
- package/lib/auth/decorate-webserver.d.ts +7 -0
- package/lib/auth/decorate-webserver.js +75 -0
- package/lib/auth/decorate-webserver.js.map +1 -0
- package/lib/auth/gate.d.ts +14 -0
- package/lib/auth/gate.js +45 -0
- package/lib/auth/gate.js.map +1 -0
- package/lib/auth/index.d.ts +8 -0
- package/lib/auth/index.js +51 -0
- package/lib/auth/index.js.map +1 -0
- package/lib/auth/login-page.d.ts +5 -0
- package/lib/auth/login-page.js +87 -0
- package/lib/auth/login-page.js.map +1 -0
- package/lib/auth/loopback-compat.d.ts +6 -0
- package/lib/auth/loopback-compat.js +94 -0
- package/lib/auth/loopback-compat.js.map +1 -0
- package/lib/auth/loopback.d.ts +7 -0
- package/lib/auth/loopback.js +24 -0
- package/lib/auth/loopback.js.map +1 -0
- package/lib/auth/ratelimit.d.ts +11 -0
- package/lib/auth/ratelimit.js +37 -0
- package/lib/auth/ratelimit.js.map +1 -0
- package/lib/auth/routes.d.ts +8 -0
- package/lib/auth/routes.js +224 -0
- package/lib/auth/routes.js.map +1 -0
- package/lib/auth/session.d.ts +11 -0
- package/lib/auth/session.js +52 -0
- package/lib/auth/session.js.map +1 -0
- package/lib/auth/startup.d.ts +15 -0
- package/lib/auth/startup.js +68 -0
- package/lib/auth/startup.js.map +1 -0
- package/lib/auth/webserver.d.ts +18 -0
- package/lib/auth/webserver.js +60 -0
- package/lib/auth/webserver.js.map +1 -0
- package/lib/client.js +2770 -0
- package/lib/client.js.map +1 -0
- package/lib/connection-sIX25pkS.d.ts +46 -0
- package/lib/core/audit.d.ts +16 -0
- package/lib/core/audit.js +38 -0
- package/lib/core/audit.js.map +1 -0
- package/lib/core/index.d.ts +8 -0
- package/lib/core/index.js +77 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/known-hosts.d.ts +23 -0
- package/lib/core/known-hosts.js +76 -0
- package/lib/core/known-hosts.js.map +1 -0
- package/lib/core/node-registry.d.ts +108 -0
- package/lib/core/node-registry.js +191 -0
- package/lib/core/node-registry.js.map +1 -0
- package/lib/core/routes.d.ts +9 -0
- package/lib/core/routes.js +404 -0
- package/lib/core/routes.js.map +1 -0
- package/lib/core/ssh-config.d.ts +23 -0
- package/lib/core/ssh-config.js +70 -0
- package/lib/core/ssh-config.js.map +1 -0
- package/lib/core/test.d.ts +43 -0
- package/lib/core/test.js +116 -0
- package/lib/core/test.js.map +1 -0
- package/lib/core/workspace-bindings.d.ts +28 -0
- package/lib/core/workspace-bindings.js +86 -0
- package/lib/core/workspace-bindings.js.map +1 -0
- package/lib/core/workspaces.d.ts +9 -0
- package/lib/core/workspaces.js +283 -0
- package/lib/core/workspaces.js.map +1 -0
- package/lib/exec-docker/daemon-runner.d.ts +21 -0
- package/lib/exec-docker/daemon-runner.js +326 -0
- package/lib/exec-docker/daemon-runner.js.map +1 -0
- package/lib/exec-docker/docker-backend.d.ts +48 -0
- package/lib/exec-docker/docker-backend.js +1 -0
- package/lib/exec-docker/docker-client.d.ts +46 -0
- package/lib/exec-docker/docker-client.js +302 -0
- package/lib/exec-docker/docker-client.js.map +1 -0
- package/lib/exec-docker/docker-routes.d.ts +6 -0
- package/lib/exec-docker/docker-routes.js +215 -0
- package/lib/exec-docker/docker-routes.js.map +1 -0
- package/lib/exec-docker/fs-provider.d.ts +50 -0
- package/lib/exec-docker/fs-provider.js +92 -0
- package/lib/exec-docker/fs-provider.js.map +1 -0
- package/lib/exec-docker/host-runner.d.ts +29 -0
- package/lib/exec-docker/host-runner.js +17 -0
- package/lib/exec-docker/host-runner.js.map +1 -0
- package/lib/exec-docker/index.d.ts +21 -0
- package/lib/exec-docker/index.js +137 -0
- package/lib/exec-docker/index.js.map +1 -0
- package/lib/exec-docker/process-provider.d.ts +20 -0
- package/lib/exec-docker/process-provider.js +75 -0
- package/lib/exec-docker/process-provider.js.map +1 -0
- package/lib/exec-docker/provision.d.ts +24 -0
- package/lib/exec-docker/provision.js +103 -0
- package/lib/exec-docker/provision.js.map +1 -0
- package/lib/exec-docker/remote-docker-cli.d.ts +52 -0
- package/lib/exec-docker/remote-docker-cli.js +155 -0
- package/lib/exec-docker/remote-docker-cli.js.map +1 -0
- package/lib/exec-docker/world.d.ts +37 -0
- package/lib/exec-docker/world.js +62 -0
- package/lib/exec-docker/world.js.map +1 -0
- package/lib/exec-ssh/connection-pool.d.ts +25 -0
- package/lib/exec-ssh/connection-pool.js +54 -0
- package/lib/exec-ssh/connection-pool.js.map +1 -0
- package/lib/exec-ssh/connection.d.ts +2 -0
- package/lib/exec-ssh/connection.js +125 -0
- package/lib/exec-ssh/connection.js.map +1 -0
- package/lib/exec-ssh/env-scrub.d.ts +7 -0
- package/lib/exec-ssh/env-scrub.js +40 -0
- package/lib/exec-ssh/env-scrub.js.map +1 -0
- package/lib/exec-ssh/executor.d.ts +46 -0
- package/lib/exec-ssh/executor.js +212 -0
- package/lib/exec-ssh/executor.js.map +1 -0
- package/lib/exec-ssh/fs-provider.d.ts +50 -0
- package/lib/exec-ssh/fs-provider.js +92 -0
- package/lib/exec-ssh/fs-provider.js.map +1 -0
- package/lib/exec-ssh/index.d.ts +16 -0
- package/lib/exec-ssh/index.js +30 -0
- package/lib/exec-ssh/index.js.map +1 -0
- package/lib/exec-ssh/process-provider.d.ts +20 -0
- package/lib/exec-ssh/process-provider.js +75 -0
- package/lib/exec-ssh/process-provider.js.map +1 -0
- package/lib/exec-ssh/runner.d.ts +13 -0
- package/lib/exec-ssh/runner.js +62 -0
- package/lib/exec-ssh/runner.js.map +1 -0
- package/lib/exec-ssh/world.d.ts +79 -0
- package/lib/exec-ssh/world.js +95 -0
- package/lib/exec-ssh/world.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/router/decorate-fs.d.ts +6 -0
- package/lib/router/decorate-fs.js +78 -0
- package/lib/router/decorate-fs.js.map +1 -0
- package/lib/router/decorate-shell.d.ts +6 -0
- package/lib/router/decorate-shell.js +35 -0
- package/lib/router/decorate-shell.js.map +1 -0
- package/lib/router/decorate-subprocess.d.ts +6 -0
- package/lib/router/decorate-subprocess.js +35 -0
- package/lib/router/decorate-subprocess.js.map +1 -0
- package/lib/router/index.d.ts +10 -0
- package/lib/router/index.js +21 -0
- package/lib/router/index.js.map +1 -0
- package/lib/router/resolve.d.ts +22 -0
- package/lib/router/resolve.js +45 -0
- package/lib/router/resolve.js.map +1 -0
- package/lib/router/router-fs.d.ts +25 -0
- package/lib/router/router-fs.js +64 -0
- package/lib/router/router-fs.js.map +1 -0
- package/lib/router/router-shell.d.ts +14 -0
- package/lib/router/router-shell.js +36 -0
- package/lib/router/router-shell.js.map +1 -0
- package/lib/router/router-subprocess.d.ts +13 -0
- package/lib/router/router-subprocess.js +33 -0
- package/lib/router/router-subprocess.js.map +1 -0
- package/lib/router/types.d.ts +2 -0
- package/lib/router/types.js +1 -0
- package/lib/types-C0TtEO7z.d.ts +67 -0
- package/lib/ui/decorate-picker.d.ts +6 -0
- package/lib/ui/decorate-picker.js +58 -0
- package/lib/ui/decorate-picker.js.map +1 -0
- package/lib/ui/index.d.ts +8 -0
- package/lib/ui/index.js +11 -0
- package/lib/ui/index.js.map +1 -0
- package/lib/ui/picker.d.ts +10 -0
- package/lib/ui/picker.js +58 -0
- package/lib/ui/picker.js.map +1 -0
- package/package.json +146 -13
- package/LICENSE +0 -21
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { a as NodeTestReport, t as ExecutionWorldProvider } from "../types-C0TtEO7z.js";
|
|
2
|
+
import { SshConnectionPool } from "./connection-pool.js";
|
|
3
|
+
import { SshExecutor } from "./executor.js";
|
|
4
|
+
import { SshFileSystem } from "./fs-provider.js";
|
|
5
|
+
import { SshShellExecutor, SshSubprocessRuntime } from "./process-provider.js";
|
|
6
|
+
//#region src/exec-ssh/world.d.ts
|
|
7
|
+
interface SshNodeConfig {
|
|
8
|
+
nodeId: string;
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
username: string;
|
|
12
|
+
auth: {
|
|
13
|
+
kind: 'password' | 'key' | 'agent';
|
|
14
|
+
keyPath?: string;
|
|
15
|
+
};
|
|
16
|
+
secrets: {
|
|
17
|
+
password?: string;
|
|
18
|
+
privateKey?: string;
|
|
19
|
+
passphrase?: string;
|
|
20
|
+
};
|
|
21
|
+
jump?: Array<{
|
|
22
|
+
host: string;
|
|
23
|
+
port?: number;
|
|
24
|
+
username?: string;
|
|
25
|
+
keyPath?: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
declare class SshExecutionWorld implements ExecutionWorldProvider {
|
|
29
|
+
readonly nodeId: string;
|
|
30
|
+
private readonly config;
|
|
31
|
+
readonly fs: SshFileSystem;
|
|
32
|
+
readonly subprocess: SshSubprocessRuntime;
|
|
33
|
+
readonly shell: SshShellExecutor;
|
|
34
|
+
readonly executor: SshExecutor;
|
|
35
|
+
constructor(nodeId: string, config: SshNodeConfig, pool: SshConnectionPool, audit?: (nodeId: string, op: string, target: string, result: string) => void);
|
|
36
|
+
ensureDir(remotePath: string): Promise<void>;
|
|
37
|
+
testConnection(): Promise<NodeTestReport>;
|
|
38
|
+
}
|
|
39
|
+
interface NodeRegistryLike {
|
|
40
|
+
get(id: string): {
|
|
41
|
+
id: string;
|
|
42
|
+
type: string;
|
|
43
|
+
ssh?: {
|
|
44
|
+
host: string;
|
|
45
|
+
port: number;
|
|
46
|
+
username: string;
|
|
47
|
+
auth: {
|
|
48
|
+
kind: 'password' | 'key' | 'agent';
|
|
49
|
+
keyPath?: string;
|
|
50
|
+
};
|
|
51
|
+
jump?: Array<{
|
|
52
|
+
host: string;
|
|
53
|
+
port?: number;
|
|
54
|
+
username?: string;
|
|
55
|
+
keyPath?: string;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
} | undefined;
|
|
59
|
+
getSecrets(id: string): Promise<{
|
|
60
|
+
password?: string;
|
|
61
|
+
privateKey?: string;
|
|
62
|
+
passphrase?: string;
|
|
63
|
+
} | undefined>;
|
|
64
|
+
}
|
|
65
|
+
declare class SshWorldRegistry {
|
|
66
|
+
private readonly pool;
|
|
67
|
+
private readonly nodeRegistry?;
|
|
68
|
+
private readonly audit?;
|
|
69
|
+
private readonly worlds;
|
|
70
|
+
constructor(pool: SshConnectionPool, nodeRegistry?: NodeRegistryLike | undefined, audit?: ((nodeId: string, op: string, target: string, result: string) => void) | undefined);
|
|
71
|
+
register(config: SshNodeConfig): SshExecutionWorld;
|
|
72
|
+
get(nodeId: string): SshExecutionWorld | undefined;
|
|
73
|
+
ensure(nodeId: string): Promise<SshExecutionWorld | undefined>;
|
|
74
|
+
remove(nodeId: string): void;
|
|
75
|
+
clear(): void;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { SshExecutionWorld, SshNodeConfig, SshWorldRegistry };
|
|
79
|
+
//# sourceMappingURL=world.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SshExecutor } from "./executor.js";
|
|
2
|
+
import { SshFileSystem } from "./fs-provider.js";
|
|
3
|
+
import { SshShellExecutor, SshSubprocessRuntime } from "./process-provider.js";
|
|
4
|
+
//#region src/exec-ssh/world.ts
|
|
5
|
+
var SshExecutionWorld = class {
|
|
6
|
+
nodeId;
|
|
7
|
+
config;
|
|
8
|
+
fs;
|
|
9
|
+
subprocess;
|
|
10
|
+
shell;
|
|
11
|
+
executor;
|
|
12
|
+
constructor(nodeId, config, pool, audit) {
|
|
13
|
+
this.nodeId = nodeId;
|
|
14
|
+
this.config = config;
|
|
15
|
+
const target = {
|
|
16
|
+
host: config.host,
|
|
17
|
+
port: config.port,
|
|
18
|
+
username: config.username,
|
|
19
|
+
auth: config.auth,
|
|
20
|
+
jump: config.jump
|
|
21
|
+
};
|
|
22
|
+
const connection = pool.acquire(target, config.secrets);
|
|
23
|
+
this.executor = new SshExecutor(connection, nodeId, audit ? (op, t, r) => audit(nodeId, op, t, r) : void 0);
|
|
24
|
+
this.fs = new SshFileSystem(this.executor);
|
|
25
|
+
this.subprocess = new SshSubprocessRuntime(this.executor);
|
|
26
|
+
this.shell = new SshShellExecutor(this.executor);
|
|
27
|
+
}
|
|
28
|
+
async ensureDir(remotePath) {
|
|
29
|
+
await this.executor.exec([
|
|
30
|
+
"mkdir",
|
|
31
|
+
"-p",
|
|
32
|
+
remotePath
|
|
33
|
+
], "/");
|
|
34
|
+
}
|
|
35
|
+
async testConnection() {
|
|
36
|
+
try {
|
|
37
|
+
return {
|
|
38
|
+
ok: (await this.executor.exec(["echo", "ok"], "/")).stdout.trim() === "ok",
|
|
39
|
+
reachable: true
|
|
40
|
+
};
|
|
41
|
+
} catch (err) {
|
|
42
|
+
return {
|
|
43
|
+
ok: false,
|
|
44
|
+
reachable: false,
|
|
45
|
+
error: err instanceof Error ? err.message : String(err)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var SshWorldRegistry = class {
|
|
51
|
+
pool;
|
|
52
|
+
nodeRegistry;
|
|
53
|
+
audit;
|
|
54
|
+
worlds = /* @__PURE__ */ new Map();
|
|
55
|
+
constructor(pool, nodeRegistry, audit) {
|
|
56
|
+
this.pool = pool;
|
|
57
|
+
this.nodeRegistry = nodeRegistry;
|
|
58
|
+
this.audit = audit;
|
|
59
|
+
}
|
|
60
|
+
register(config) {
|
|
61
|
+
const world = new SshExecutionWorld(config.nodeId, config, this.pool, this.audit);
|
|
62
|
+
this.worlds.set(config.nodeId, world);
|
|
63
|
+
return world;
|
|
64
|
+
}
|
|
65
|
+
get(nodeId) {
|
|
66
|
+
return this.worlds.get(nodeId);
|
|
67
|
+
}
|
|
68
|
+
async ensure(nodeId) {
|
|
69
|
+
const existing = this.worlds.get(nodeId);
|
|
70
|
+
if (existing) return existing;
|
|
71
|
+
if (!this.nodeRegistry) return void 0;
|
|
72
|
+
const node = this.nodeRegistry.get(nodeId);
|
|
73
|
+
if (!node || node.type !== "remote-ssh" && node.type !== "remote-docker" || !node.ssh) return void 0;
|
|
74
|
+
const secrets = await this.nodeRegistry.getSecrets(nodeId) ?? {};
|
|
75
|
+
return this.register({
|
|
76
|
+
nodeId,
|
|
77
|
+
host: node.ssh.host,
|
|
78
|
+
port: node.ssh.port,
|
|
79
|
+
username: node.ssh.username,
|
|
80
|
+
auth: node.ssh.auth,
|
|
81
|
+
secrets,
|
|
82
|
+
jump: node.ssh.jump
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
remove(nodeId) {
|
|
86
|
+
if (this.worlds.get(nodeId)) this.worlds.delete(nodeId);
|
|
87
|
+
}
|
|
88
|
+
clear() {
|
|
89
|
+
this.worlds.clear();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { SshExecutionWorld, SshWorldRegistry };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=world.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world.js","names":[],"sources":["../../src/exec-ssh/world.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport type { ExecutionWorldProvider, NodeTestReport } from '../router/types.js'\nimport { sharedWorldResolver } from '../router/resolve.js'\nimport { SshConnectionPool } from './connection-pool.js'\nimport { SshExecutor } from './executor.js'\nimport { SshFileSystem } from './fs-provider.js'\nimport { SshShellExecutor, SshSubprocessRuntime } from './process-provider.js'\n\nexport interface SshNodeConfig {\n nodeId: string\n host: string\n port: number\n username: string\n auth: { kind: 'password' | 'key' | 'agent'; keyPath?: string }\n secrets: { password?: string; privateKey?: string; passphrase?: string }\n jump?: Array<{ host: string; port?: number; username?: string; keyPath?: string }>\n}\n\nexport class SshExecutionWorld implements ExecutionWorldProvider {\n readonly fs: SshFileSystem\n readonly subprocess: SshSubprocessRuntime\n readonly shell: SshShellExecutor\n readonly executor: SshExecutor\n\n constructor(\n readonly nodeId: string,\n private readonly config: SshNodeConfig,\n pool: SshConnectionPool,\n audit?: (nodeId: string, op: string, target: string, result: string) => void,\n ) {\n const target = {\n host: config.host,\n port: config.port,\n username: config.username,\n auth: config.auth,\n jump: config.jump,\n }\n const connection = pool.acquire(target, config.secrets)\n this.executor = new SshExecutor(connection, nodeId, audit ? (op, t, r) => audit(nodeId, op, t, r) : undefined)\n this.fs = new SshFileSystem(this.executor)\n this.subprocess = new SshSubprocessRuntime(this.executor)\n this.shell = new SshShellExecutor(this.executor)\n }\n\n async ensureDir(remotePath: string): Promise<void> {\n await this.executor.exec(['mkdir', '-p', remotePath], '/')\n }\n\n async testConnection(): Promise<NodeTestReport> {\n try {\n const result = await this.executor.exec(['echo', 'ok'], '/')\n return { ok: result.stdout.trim() === 'ok', reachable: true }\n } catch (err) {\n return { ok: false, reachable: false, error: err instanceof Error ? err.message : String(err) }\n }\n }\n}\n\ninterface NodeRegistryLike {\n get(id: string): { id: string; type: string; ssh?: { host: string; port: number; username: string; auth: { kind: 'password' | 'key' | 'agent'; keyPath?: string }; jump?: Array<{ host: string; port?: number; username?: string; keyPath?: string }> } } | undefined\n getSecrets(id: string): Promise<{ password?: string; privateKey?: string; passphrase?: string } | undefined>\n}\n\nexport class SshWorldRegistry {\n private readonly worlds = new Map<string, SshExecutionWorld>()\n\n constructor(\n private readonly pool: SshConnectionPool,\n private readonly nodeRegistry?: NodeRegistryLike,\n private readonly audit?: (nodeId: string, op: string, target: string, result: string) => void,\n ) {}\n\n register(config: SshNodeConfig): SshExecutionWorld {\n const world = new SshExecutionWorld(config.nodeId, config, this.pool, this.audit)\n this.worlds.set(config.nodeId, world)\n return world\n }\n\n get(nodeId: string): SshExecutionWorld | undefined {\n return this.worlds.get(nodeId)\n }\n\n async ensure(nodeId: string): Promise<SshExecutionWorld | undefined> {\n const existing = this.worlds.get(nodeId)\n if (existing) return existing\n if (!this.nodeRegistry) return undefined\n const node = this.nodeRegistry.get(nodeId)\n if (!node || (node.type !== 'remote-ssh' && node.type !== 'remote-docker') || !node.ssh) return undefined\n const secrets = (await this.nodeRegistry.getSecrets(nodeId)) ?? {}\n return this.register({\n nodeId,\n host: node.ssh.host,\n port: node.ssh.port,\n username: node.ssh.username,\n auth: node.ssh.auth,\n secrets,\n jump: node.ssh.jump,\n })\n }\n\n remove(nodeId: string): void {\n const world = this.worlds.get(nodeId)\n if (world) {\n this.worlds.delete(nodeId)\n }\n }\n\n clear(): void {\n this.worlds.clear()\n }\n}\n"],"mappings":";;;;AAkBA,IAAa,oBAAb,MAAiE;CAOpD;CACQ;CAPnB;CACA;CACA;CACA;CAEA,YACE,QACA,QACA,MACA,OACA;EAJS,KAAA,SAAA;EACQ,KAAA,SAAA;EAIjB,MAAM,SAAS;GACb,MAAM,OAAO;GACb,MAAM,OAAO;GACb,UAAU,OAAO;GACjB,MAAM,OAAO;GACb,MAAM,OAAO;EACf;EACA,MAAM,aAAa,KAAK,QAAQ,QAAQ,OAAO,OAAO;EACtD,KAAK,WAAW,IAAI,YAAY,YAAY,QAAQ,SAAS,IAAI,GAAG,MAAM,MAAM,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAA,CAAS;EAC7G,KAAK,KAAK,IAAI,cAAc,KAAK,QAAQ;EACzC,KAAK,aAAa,IAAI,qBAAqB,KAAK,QAAQ;EACxD,KAAK,QAAQ,IAAI,iBAAiB,KAAK,QAAQ;CACjD;CAEA,MAAM,UAAU,YAAmC;EACjD,MAAM,KAAK,SAAS,KAAK;GAAC;GAAS;GAAM;EAAU,GAAG,GAAG;CAC3D;CAEA,MAAM,iBAA0C;EAC9C,IAAI;GAEF,OAAO;IAAE,KAAI,MADQ,KAAK,SAAS,KAAK,CAAC,QAAQ,IAAI,GAAG,GAAG,EAAA,CACvC,OAAO,KAAK,MAAM;IAAM,WAAW;GAAK;EAC9D,SAAS,KAAK;GACZ,OAAO;IAAE,IAAI;IAAO,WAAW;IAAO,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GAAE;EAChG;CACF;AACF;AAOA,IAAa,mBAAb,MAA8B;CAIT;CACA;CACA;CALnB,yBAA0B,IAAI,IAA+B;CAE7D,YACE,MACA,cACA,OACA;EAHiB,KAAA,OAAA;EACA,KAAA,eAAA;EACA,KAAA,QAAA;CAChB;CAEH,SAAS,QAA0C;EACjD,MAAM,QAAQ,IAAI,kBAAkB,OAAO,QAAQ,QAAQ,KAAK,MAAM,KAAK,KAAK;EAChF,KAAK,OAAO,IAAI,OAAO,QAAQ,KAAK;EACpC,OAAO;CACT;CAEA,IAAI,QAA+C;EACjD,OAAO,KAAK,OAAO,IAAI,MAAM;CAC/B;CAEA,MAAM,OAAO,QAAwD;EACnE,MAAM,WAAW,KAAK,OAAO,IAAI,MAAM;EACvC,IAAI,UAAU,OAAO;EACrB,IAAI,CAAC,KAAK,cAAc,OAAO,KAAA;EAC/B,MAAM,OAAO,KAAK,aAAa,IAAI,MAAM;EACzC,IAAI,CAAC,QAAS,KAAK,SAAS,gBAAgB,KAAK,SAAS,mBAAoB,CAAC,KAAK,KAAK,OAAO,KAAA;EAChG,MAAM,UAAW,MAAM,KAAK,aAAa,WAAW,MAAM,KAAM,CAAC;EACjE,OAAO,KAAK,SAAS;GACnB;GACA,MAAM,KAAK,IAAI;GACf,MAAM,KAAK,IAAI;GACf,UAAU,KAAK,IAAI;GACnB,MAAM,KAAK,IAAI;GACf;GACA,MAAM,KAAK,IAAI;EACjB,CAAC;CACH;CAEA,OAAO,QAAsB;EAE3B,IADc,KAAK,OAAO,IAAI,MACtB,GACN,KAAK,OAAO,OAAO,MAAM;CAE7B;CAEA,QAAc;EACZ,KAAK,OAAO,MAAM;CACpB;AACF"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { sharedWorldResolver } from "./resolve.js";
|
|
2
|
+
//#region src/router/decorate-fs.ts
|
|
3
|
+
function decorateFileSystem(fs) {
|
|
4
|
+
const resolver = sharedWorldResolver();
|
|
5
|
+
const origStat = fs.stat.bind(fs);
|
|
6
|
+
const origLstat = fs.lstat.bind(fs);
|
|
7
|
+
const origReadText = fs.readText.bind(fs);
|
|
8
|
+
const origStreamText = fs.streamText.bind(fs);
|
|
9
|
+
const origReadBytes = fs.readBytes.bind(fs);
|
|
10
|
+
const origListDir = fs.listDir.bind(fs);
|
|
11
|
+
const origWriteText = fs.writeText.bind(fs);
|
|
12
|
+
const origEditText = fs.editText.bind(fs);
|
|
13
|
+
function targetPath(target) {
|
|
14
|
+
return fs.processPath(target);
|
|
15
|
+
}
|
|
16
|
+
fs.stat = async (target, signal) => {
|
|
17
|
+
const ref = resolver.resolve(targetPath(target));
|
|
18
|
+
if (ref.kind === "local") return origStat(target, signal);
|
|
19
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
20
|
+
return ref.provider.fs.stat(ref.remotePath, signal);
|
|
21
|
+
};
|
|
22
|
+
fs.lstat = async (path, opts, signal) => {
|
|
23
|
+
const ref = resolver.resolve(path);
|
|
24
|
+
if (ref.kind === "local") return origLstat(path, opts, signal);
|
|
25
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
26
|
+
return ref.provider.fs.lstat(ref.remotePath, opts, signal);
|
|
27
|
+
};
|
|
28
|
+
fs.readText = async (target, signal) => {
|
|
29
|
+
const ref = resolver.resolve(targetPath(target));
|
|
30
|
+
if (ref.kind === "local") return origReadText(target, signal);
|
|
31
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
32
|
+
return ref.provider.fs.readText(ref.remotePath, signal);
|
|
33
|
+
};
|
|
34
|
+
fs.streamText = async (target, signal) => {
|
|
35
|
+
const ref = resolver.resolve(targetPath(target));
|
|
36
|
+
if (ref.kind === "local") return origStreamText(target, signal);
|
|
37
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
38
|
+
return ref.provider.fs.streamText(ref.remotePath, signal);
|
|
39
|
+
};
|
|
40
|
+
fs.readBytes = async (target, signal, maxBytes) => {
|
|
41
|
+
const ref = resolver.resolve(targetPath(target));
|
|
42
|
+
if (ref.kind === "local") return origReadBytes(target, signal, maxBytes);
|
|
43
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
44
|
+
return ref.provider.fs.readBytes(ref.remotePath, signal, maxBytes);
|
|
45
|
+
};
|
|
46
|
+
fs.listDir = async (target, signal) => {
|
|
47
|
+
const ref = resolver.resolve(targetPath(target));
|
|
48
|
+
if (ref.kind === "local") return origListDir(target, signal);
|
|
49
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
50
|
+
return ref.provider.fs.listDir(ref.remotePath, signal);
|
|
51
|
+
};
|
|
52
|
+
fs.writeText = async (target, content, expected, signal, sandboxPolicy) => {
|
|
53
|
+
const ref = resolver.resolve(targetPath(target));
|
|
54
|
+
if (ref.kind === "local") return origWriteText(target, content, expected, signal, sandboxPolicy);
|
|
55
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
56
|
+
return ref.provider.fs.writeText(ref.remotePath, content, expected, signal, sandboxPolicy);
|
|
57
|
+
};
|
|
58
|
+
fs.editText = async (target, edit, expected, signal, sandboxPolicy) => {
|
|
59
|
+
const ref = resolver.resolve(targetPath(target));
|
|
60
|
+
if (ref.kind === "local") return origEditText(target, edit, expected, signal, sandboxPolicy);
|
|
61
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
62
|
+
return ref.provider.fs.editText(ref.remotePath, edit, expected, signal, sandboxPolicy);
|
|
63
|
+
};
|
|
64
|
+
return () => {
|
|
65
|
+
fs.stat = origStat;
|
|
66
|
+
fs.lstat = origLstat;
|
|
67
|
+
fs.readText = origReadText;
|
|
68
|
+
fs.streamText = origStreamText;
|
|
69
|
+
fs.readBytes = origReadBytes;
|
|
70
|
+
fs.listDir = origListDir;
|
|
71
|
+
fs.writeText = origWriteText;
|
|
72
|
+
fs.editText = origEditText;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { decorateFileSystem };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=decorate-fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorate-fs.js","names":[],"sources":["../../src/router/decorate-fs.ts"],"sourcesContent":["import type { FileSystem } from '@deepseek-ai/dsh-fs'\nimport type { FsEditOutcome, FsEditRequest, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome, FsDirEntry, FsInfo, FsPathInfo } from '@deepseek-ai/dsh-fs'\nimport type { SandboxExecutionPolicy } from '@deepseek-ai/dsh-sandbox'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport function decorateFileSystem(fs: FileSystem): () => void {\n const resolver = sharedWorldResolver()\n\n const origStat = fs.stat.bind(fs)\n const origLstat = fs.lstat.bind(fs)\n const origReadText = fs.readText.bind(fs)\n const origStreamText = fs.streamText.bind(fs)\n const origReadBytes = fs.readBytes.bind(fs)\n const origListDir = fs.listDir.bind(fs)\n const origWriteText = fs.writeText.bind(fs)\n const origEditText = fs.editText.bind(fs)\n\n function targetPath(target: FsTarget): string {\n return fs.processPath(target)\n }\n\n fs.stat = async (target: FsTarget, signal?: AbortSignal): Promise<FsInfo | undefined> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origStat(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.stat(ref.remotePath, signal) as Promise<FsInfo | undefined>\n }\n\n fs.lstat = async (path: string, opts?: { cwd?: string }, signal?: AbortSignal): Promise<FsPathInfo | undefined> => {\n const ref = resolver.resolve(path)\n if (ref.kind === 'local') return origLstat(path, opts, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.lstat(ref.remotePath, opts, signal) as Promise<FsPathInfo | undefined>\n }\n\n fs.readText = async (target: FsTarget, signal?: AbortSignal): Promise<string> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origReadText(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.readText(ref.remotePath, signal)\n }\n\n fs.streamText = async (target: FsTarget, signal?: AbortSignal): Promise<AsyncIterable<string>> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origStreamText(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.streamText(ref.remotePath, signal)\n }\n\n fs.readBytes = async (target: FsTarget, signal: AbortSignal | undefined, maxBytes: number): Promise<Uint8Array> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origReadBytes(target, signal, maxBytes)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.readBytes(ref.remotePath, signal, maxBytes)\n }\n\n fs.listDir = async (target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origListDir(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.listDir(ref.remotePath, signal) as Promise<FsDirEntry[]>\n }\n\n fs.writeText = async (target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsWriteOutcome> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origWriteText(target, content, expected, signal, sandboxPolicy)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.writeText(ref.remotePath, content, expected, signal, sandboxPolicy) as Promise<FsWriteOutcome>\n }\n\n fs.editText = async (target: FsTarget, edit: FsEditRequest, expected?: { version: FsVersion }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome> => {\n const ref = resolver.resolve(targetPath(target))\n if (ref.kind === 'local') return origEditText(target, edit, expected, signal, sandboxPolicy)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.editText(ref.remotePath, edit, expected, signal, sandboxPolicy) as Promise<FsEditOutcome>\n }\n\n return () => {\n fs.stat = origStat\n fs.lstat = origLstat\n fs.readText = origReadText\n fs.streamText = origStreamText\n fs.readBytes = origReadBytes\n fs.listDir = origListDir\n fs.writeText = origWriteText\n fs.editText = origEditText\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sharedWorldResolver } from "./resolve.js";
|
|
2
|
+
//#region src/router/decorate-shell.ts
|
|
3
|
+
function decorateShell(shell) {
|
|
4
|
+
const resolver = sharedWorldResolver();
|
|
5
|
+
const origRun = shell.run.bind(shell);
|
|
6
|
+
const origStart = shell.start.bind(shell);
|
|
7
|
+
shell.run = async (spec) => {
|
|
8
|
+
const ref = resolver.resolve(spec.workdir ?? "");
|
|
9
|
+
if (ref.kind === "local") return origRun(spec);
|
|
10
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
11
|
+
await ref.provider.ensureDir(ref.remotePath).catch(() => {});
|
|
12
|
+
return ref.provider.shell.run({
|
|
13
|
+
...spec,
|
|
14
|
+
workdir: ref.remotePath
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
shell.start = (spec) => {
|
|
18
|
+
const ref = resolver.resolve(spec.workdir ?? "");
|
|
19
|
+
if (ref.kind === "local") return origStart(spec);
|
|
20
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
21
|
+
ref.provider.ensureDir(ref.remotePath).catch(() => {});
|
|
22
|
+
return ref.provider.shell.start({
|
|
23
|
+
...spec,
|
|
24
|
+
workdir: ref.remotePath
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
return () => {
|
|
28
|
+
shell.run = origRun;
|
|
29
|
+
shell.start = origStart;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { decorateShell };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=decorate-shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorate-shell.js","names":[],"sources":["../../src/router/decorate-shell.ts"],"sourcesContent":["import type { ShellExecutor } from '@deepseek-ai/dsh-shell'\nimport type { ShellExecRequest, ShellExecSpec, ShellProcess, ShellRunResult } from '@deepseek-ai/dsh-shell'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport function decorateShell(shell: ShellExecutor): () => void {\n const resolver = sharedWorldResolver()\n\n const origRun = shell.run.bind(shell)\n const origStart = shell.start.bind(shell)\n\n shell.run = async (spec: ShellExecSpec): Promise<ShellRunResult> => {\n const ref = resolver.resolve(spec.workdir ?? '')\n if (ref.kind === 'local') return origRun(spec)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n await ref.provider.ensureDir(ref.remotePath).catch(() => {})\n return ref.provider.shell.run({ ...spec, workdir: ref.remotePath })\n }\n\n shell.start = (spec: ShellExecSpec): ShellProcess => {\n const ref = resolver.resolve(spec.workdir ?? '')\n if (ref.kind === 'local') return origStart(spec)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n void ref.provider.ensureDir(ref.remotePath).catch(() => {})\n return ref.provider.shell.start({ ...spec, workdir: ref.remotePath })\n }\n\n return () => {\n shell.run = origRun\n shell.start = origStart\n }\n}\n"],"mappings":";;AAIA,SAAgB,cAAc,OAAkC;CAC9D,MAAM,WAAW,oBAAoB;CAErC,MAAM,UAAU,MAAM,IAAI,KAAK,KAAK;CACpC,MAAM,YAAY,MAAM,MAAM,KAAK,KAAK;CAExC,MAAM,MAAM,OAAO,SAAiD;EAClE,MAAM,MAAM,SAAS,QAAQ,KAAK,WAAW,EAAE;EAC/C,IAAI,IAAI,SAAS,SAAS,OAAO,QAAQ,IAAI;EAC7C,IAAI,IAAI,SAAS,YAAY,MAAM,IAAI,MAAM,QAAQ,IAAI,OAAO,qBAAqB;EACrF,MAAM,IAAI,SAAS,UAAU,IAAI,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;EAC3D,OAAO,IAAI,SAAS,MAAM,IAAI;GAAE,GAAG;GAAM,SAAS,IAAI;EAAW,CAAC;CACpE;CAEA,MAAM,SAAS,SAAsC;EACnD,MAAM,MAAM,SAAS,QAAQ,KAAK,WAAW,EAAE;EAC/C,IAAI,IAAI,SAAS,SAAS,OAAO,UAAU,IAAI;EAC/C,IAAI,IAAI,SAAS,YAAY,MAAM,IAAI,MAAM,QAAQ,IAAI,OAAO,qBAAqB;EACrF,IAAS,SAAS,UAAU,IAAI,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;EAC1D,OAAO,IAAI,SAAS,MAAM,MAAM;GAAE,GAAG;GAAM,SAAS,IAAI;EAAW,CAAC;CACtE;CAEA,aAAa;EACX,MAAM,MAAM;EACZ,MAAM,QAAQ;CAChB;AACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SubprocessRuntime } from "@deepseek-ai/dsh-subprocess";
|
|
2
|
+
//#region src/router/decorate-subprocess.d.ts
|
|
3
|
+
declare function decorateSubprocess(sp: SubprocessRuntime): () => void;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { decorateSubprocess };
|
|
6
|
+
//# sourceMappingURL=decorate-subprocess.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sharedWorldResolver } from "./resolve.js";
|
|
2
|
+
//#region src/router/decorate-subprocess.ts
|
|
3
|
+
function decorateSubprocess(sp) {
|
|
4
|
+
const resolver = sharedWorldResolver();
|
|
5
|
+
const origSpawn = sp.spawn.bind(sp);
|
|
6
|
+
const origSpawnTerminal = sp.spawnTerminal.bind(sp);
|
|
7
|
+
sp.spawn = (spec) => {
|
|
8
|
+
const ref = resolver.resolve(spec.cwd ?? "");
|
|
9
|
+
if (ref.kind === "local") return origSpawn(spec);
|
|
10
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
11
|
+
ref.provider.ensureDir(ref.remotePath).catch(() => {});
|
|
12
|
+
return ref.provider.subprocess.spawn({
|
|
13
|
+
...spec,
|
|
14
|
+
cwd: ref.remotePath
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
sp.spawnTerminal = async (spec) => {
|
|
18
|
+
const ref = resolver.resolve(spec.cwd ?? "");
|
|
19
|
+
if (ref.kind === "local") return origSpawnTerminal(spec);
|
|
20
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
21
|
+
await ref.provider.ensureDir(ref.remotePath).catch(() => {});
|
|
22
|
+
return ref.provider.subprocess.spawnTerminal({
|
|
23
|
+
...spec,
|
|
24
|
+
cwd: ref.remotePath
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
return () => {
|
|
28
|
+
sp.spawn = origSpawn;
|
|
29
|
+
sp.spawnTerminal = origSpawnTerminal;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { decorateSubprocess };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=decorate-subprocess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorate-subprocess.js","names":[],"sources":["../../src/router/decorate-subprocess.ts"],"sourcesContent":["import type { SubprocessRuntime } from '@deepseek-ai/dsh-subprocess'\nimport type { SubprocessHandle, SubprocessSpawnSpec, SubprocessTerminalHandle, SubprocessTerminalSpawnSpec } from '@deepseek-ai/dsh-subprocess'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport function decorateSubprocess(sp: SubprocessRuntime): () => void {\n const resolver = sharedWorldResolver()\n\n const origSpawn = sp.spawn.bind(sp)\n const origSpawnTerminal = sp.spawnTerminal.bind(sp)\n\n sp.spawn = (spec: SubprocessSpawnSpec): SubprocessHandle => {\n const ref = resolver.resolve(spec.cwd ?? '')\n if (ref.kind === 'local') return origSpawn(spec)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n void ref.provider.ensureDir(ref.remotePath).catch(() => {})\n return ref.provider.subprocess.spawn({ ...spec, cwd: ref.remotePath })\n }\n\n sp.spawnTerminal = async (spec: SubprocessTerminalSpawnSpec): Promise<SubprocessTerminalHandle> => {\n const ref = resolver.resolve(spec.cwd ?? '')\n if (ref.kind === 'local') return origSpawnTerminal(spec)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n await ref.provider.ensureDir(ref.remotePath).catch(() => {})\n return ref.provider.subprocess.spawnTerminal({ ...spec, cwd: ref.remotePath })\n }\n\n return () => {\n sp.spawn = origSpawn\n sp.spawnTerminal = origSpawnTerminal\n }\n}\n"],"mappings":";;AAIA,SAAgB,mBAAmB,IAAmC;CACpE,MAAM,WAAW,oBAAoB;CAErC,MAAM,YAAY,GAAG,MAAM,KAAK,EAAE;CAClC,MAAM,oBAAoB,GAAG,cAAc,KAAK,EAAE;CAElD,GAAG,SAAS,SAAgD;EAC1D,MAAM,MAAM,SAAS,QAAQ,KAAK,OAAO,EAAE;EAC3C,IAAI,IAAI,SAAS,SAAS,OAAO,UAAU,IAAI;EAC/C,IAAI,IAAI,SAAS,YAAY,MAAM,IAAI,MAAM,QAAQ,IAAI,OAAO,qBAAqB;EACrF,IAAS,SAAS,UAAU,IAAI,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;EAC1D,OAAO,IAAI,SAAS,WAAW,MAAM;GAAE,GAAG;GAAM,KAAK,IAAI;EAAW,CAAC;CACvE;CAEA,GAAG,gBAAgB,OAAO,SAAyE;EACjG,MAAM,MAAM,SAAS,QAAQ,KAAK,OAAO,EAAE;EAC3C,IAAI,IAAI,SAAS,SAAS,OAAO,kBAAkB,IAAI;EACvD,IAAI,IAAI,SAAS,YAAY,MAAM,IAAI,MAAM,QAAQ,IAAI,OAAO,qBAAqB;EACrF,MAAM,IAAI,SAAS,UAAU,IAAI,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;EAC3D,OAAO,IAAI,SAAS,WAAW,cAAc;GAAE,GAAG;GAAM,KAAK,IAAI;EAAW,CAAC;CAC/E;CAEA,aAAa;EACX,GAAG,QAAQ;EACX,GAAG,gBAAgB;CACrB;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { _ as WorkspaceBindings, a as NodeTestReport, t as ExecutionWorldProvider, v as WorldRef, y as WorldRegistry } from "../types-C0TtEO7z.js";
|
|
2
|
+
import { sharedWorldResolver } from "./resolve.js";
|
|
3
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
4
|
+
//#region src/router/index.d.ts
|
|
5
|
+
declare const name = "dshb-router";
|
|
6
|
+
declare const inject: string[];
|
|
7
|
+
declare function apply(ctx: Context): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { type ExecutionWorldProvider, type NodeTestReport, type WorkspaceBindings, type WorldRef, type WorldRegistry, apply, inject, name, sharedWorldResolver };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { sharedWorldResolver } from "./resolve.js";
|
|
2
|
+
import { decorateFileSystem } from "./decorate-fs.js";
|
|
3
|
+
import { decorateSubprocess } from "./decorate-subprocess.js";
|
|
4
|
+
import { decorateShell } from "./decorate-shell.js";
|
|
5
|
+
//#region src/router/index.ts
|
|
6
|
+
const name = "dshb-router";
|
|
7
|
+
const inject = [
|
|
8
|
+
"fs",
|
|
9
|
+
"subprocess",
|
|
10
|
+
"shell"
|
|
11
|
+
];
|
|
12
|
+
function apply(ctx) {
|
|
13
|
+
ctx.provide("dshbRouter", sharedWorldResolver());
|
|
14
|
+
decorateFileSystem(ctx.fs);
|
|
15
|
+
decorateSubprocess(ctx.subprocess);
|
|
16
|
+
decorateShell(ctx.shell);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { apply, inject, name, sharedWorldResolver };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/router/index.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport { decorateFileSystem } from './decorate-fs.js'\nimport { decorateSubprocess } from './decorate-subprocess.js'\nimport { decorateShell } from './decorate-shell.js'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport const name = 'dshb-router'\n\nexport const inject = ['fs', 'subprocess', 'shell']\n\nexport function apply(ctx: Context): void {\n ctx.provide('dshbRouter', sharedWorldResolver())\n decorateFileSystem(ctx.fs)\n decorateSubprocess(ctx.subprocess)\n decorateShell(ctx.shell)\n}\n\nexport { sharedWorldResolver } from './resolve.js'\nexport type { ExecutionWorldProvider, WorkspaceBindings, WorldRegistry, WorldRef, NodeTestReport } from './types.js'\n"],"mappings":";;;;;AAMA,MAAa,OAAO;AAEpB,MAAa,SAAS;CAAC;CAAM;CAAc;AAAO;AAElD,SAAgB,MAAM,KAAoB;CACxC,IAAI,QAAQ,cAAc,oBAAoB,CAAC;CAC/C,mBAAmB,IAAI,EAAE;CACzB,mBAAmB,IAAI,UAAU;CACjC,cAAc,IAAI,KAAK;AACzB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { _ as WorkspaceBindings, v as WorldRef, y as WorldRegistry } from "../types-C0TtEO7z.js";
|
|
2
|
+
//#region src/router/resolve.d.ts
|
|
3
|
+
interface BindingHit {
|
|
4
|
+
nodeId: string;
|
|
5
|
+
remotePath: string;
|
|
6
|
+
}
|
|
7
|
+
declare function resolveWorld(absPath: string, bindings?: WorkspaceBindings): {
|
|
8
|
+
kind: 'local';
|
|
9
|
+
} | ({
|
|
10
|
+
kind: 'remote';
|
|
11
|
+
} & BindingHit);
|
|
12
|
+
declare class WorldResolver {
|
|
13
|
+
private bindings?;
|
|
14
|
+
private registries;
|
|
15
|
+
setBindings(bindings: WorkspaceBindings): void;
|
|
16
|
+
setRegistry(registry: WorldRegistry): void;
|
|
17
|
+
resolve(absPath: string): WorldRef;
|
|
18
|
+
}
|
|
19
|
+
declare function sharedWorldResolver(): WorldResolver;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { BindingHit, WorldResolver, resolveWorld, sharedWorldResolver };
|
|
22
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/router/resolve.ts
|
|
2
|
+
function resolveWorld(absPath, bindings) {
|
|
3
|
+
if (!bindings) return { kind: "local" };
|
|
4
|
+
const hit = bindings.resolve(absPath);
|
|
5
|
+
if (!hit) return { kind: "local" };
|
|
6
|
+
return {
|
|
7
|
+
kind: "remote",
|
|
8
|
+
...hit
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
var WorldResolver = class {
|
|
12
|
+
bindings;
|
|
13
|
+
registries = [];
|
|
14
|
+
setBindings(bindings) {
|
|
15
|
+
this.bindings = bindings;
|
|
16
|
+
}
|
|
17
|
+
setRegistry(registry) {
|
|
18
|
+
this.registries.push(registry);
|
|
19
|
+
}
|
|
20
|
+
resolve(absPath) {
|
|
21
|
+
const r = resolveWorld(absPath, this.bindings);
|
|
22
|
+
if (r.kind === "local") return { kind: "local" };
|
|
23
|
+
for (const reg of this.registries) {
|
|
24
|
+
const provider = reg.get(r.nodeId);
|
|
25
|
+
if (provider) return {
|
|
26
|
+
kind: "remote",
|
|
27
|
+
provider,
|
|
28
|
+
remotePath: r.remotePath
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
kind: "unrouted",
|
|
33
|
+
nodeId: r.nodeId
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
let shared = null;
|
|
38
|
+
function sharedWorldResolver() {
|
|
39
|
+
if (!shared) shared = new WorldResolver();
|
|
40
|
+
return shared;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { WorldResolver, resolveWorld, sharedWorldResolver };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","names":[],"sources":["../../src/router/resolve.ts"],"sourcesContent":["import type { WorldRegistry, WorkspaceBindings, WorldRef } from './types.js'\n\nexport interface BindingHit {\n nodeId: string\n remotePath: string\n}\n\nexport function resolveWorld(absPath: string, bindings?: WorkspaceBindings): { kind: 'local' } | ({ kind: 'remote' } & BindingHit) {\n if (!bindings) return { kind: 'local' }\n const hit = bindings.resolve(absPath)\n if (!hit) return { kind: 'local' }\n return { kind: 'remote', ...hit }\n}\n\nexport class WorldResolver {\n private bindings?: WorkspaceBindings\n private registries: WorldRegistry[] = []\n\n setBindings(bindings: WorkspaceBindings): void {\n this.bindings = bindings\n }\n\n setRegistry(registry: WorldRegistry): void {\n this.registries.push(registry)\n }\n\n resolve(absPath: string): WorldRef {\n const r = resolveWorld(absPath, this.bindings)\n if (r.kind === 'local') return { kind: 'local' }\n for (const reg of this.registries) {\n const provider = reg.get(r.nodeId)\n if (provider) return { kind: 'remote', provider, remotePath: r.remotePath }\n }\n return { kind: 'unrouted', nodeId: r.nodeId }\n }\n}\n\nlet shared: WorldResolver | null = null\n\nexport function sharedWorldResolver(): WorldResolver {\n if (!shared) shared = new WorldResolver()\n return shared\n}\n"],"mappings":";AAOA,SAAgB,aAAa,SAAiB,UAAqF;CACjI,IAAI,CAAC,UAAU,OAAO,EAAE,MAAM,QAAQ;CACtC,MAAM,MAAM,SAAS,QAAQ,OAAO;CACpC,IAAI,CAAC,KAAK,OAAO,EAAE,MAAM,QAAQ;CACjC,OAAO;EAAE,MAAM;EAAU,GAAG;CAAI;AAClC;AAEA,IAAa,gBAAb,MAA2B;CACzB;CACA,aAAsC,CAAC;CAEvC,YAAY,UAAmC;EAC7C,KAAK,WAAW;CAClB;CAEA,YAAY,UAA+B;EACzC,KAAK,WAAW,KAAK,QAAQ;CAC/B;CAEA,QAAQ,SAA2B;EACjC,MAAM,IAAI,aAAa,SAAS,KAAK,QAAQ;EAC7C,IAAI,EAAE,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;EAC/C,KAAK,MAAM,OAAO,KAAK,YAAY;GACjC,MAAM,WAAW,IAAI,IAAI,EAAE,MAAM;GACjC,IAAI,UAAU,OAAO;IAAE,MAAM;IAAU;IAAU,YAAY,EAAE;GAAW;EAC5E;EACA,OAAO;GAAE,MAAM;GAAY,QAAQ,EAAE;EAAO;CAC9C;AACF;AAEA,IAAI,SAA+B;AAEnC,SAAgB,sBAAqC;CACnD,IAAI,CAAC,QAAQ,SAAS,IAAI,cAAc;CACxC,OAAO;AACT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import SandboxedFileSystem from "@deepseek-ai/dsh-fs-sandbox";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
import { FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome } from "@deepseek-ai/dsh-fs";
|
|
4
|
+
import { SandboxExecutionPolicy } from "@deepseek-ai/dsh-sandbox";
|
|
5
|
+
//#region src/router/router-fs.d.ts
|
|
6
|
+
declare class RouterFileSystem extends SandboxedFileSystem {
|
|
7
|
+
private readonly resolver;
|
|
8
|
+
constructor(ctx: Context, config: unknown);
|
|
9
|
+
private targetPath;
|
|
10
|
+
stat(target: FsTarget, signal?: AbortSignal): Promise<FsInfo | undefined>;
|
|
11
|
+
lstat(path: string, opts?: {
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}, signal?: AbortSignal): Promise<FsPathInfo | undefined>;
|
|
14
|
+
readText(target: FsTarget, signal?: AbortSignal): Promise<string>;
|
|
15
|
+
streamText(target: FsTarget, signal?: AbortSignal): Promise<AsyncIterable<string>>;
|
|
16
|
+
readBytes(target: FsTarget, signal: AbortSignal | undefined, maxBytes: number): Promise<Uint8Array>;
|
|
17
|
+
listDir(target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]>;
|
|
18
|
+
writeText(target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsWriteOutcome>;
|
|
19
|
+
editText(target: FsTarget, edit: FsEditRequest, expected?: {
|
|
20
|
+
version: FsVersion;
|
|
21
|
+
}, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RouterFileSystem as default };
|
|
25
|
+
//# sourceMappingURL=router-fs.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { sharedWorldResolver } from "./resolve.js";
|
|
2
|
+
import SandboxedFileSystem from "@deepseek-ai/dsh-fs-sandbox";
|
|
3
|
+
//#region src/router/router-fs.ts
|
|
4
|
+
var RouterFileSystem = class extends SandboxedFileSystem {
|
|
5
|
+
resolver = sharedWorldResolver();
|
|
6
|
+
constructor(ctx, config) {
|
|
7
|
+
super(ctx, config);
|
|
8
|
+
}
|
|
9
|
+
targetPath(target) {
|
|
10
|
+
return this.processPath(target);
|
|
11
|
+
}
|
|
12
|
+
async stat(target, signal) {
|
|
13
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
14
|
+
if (ref.kind === "local") return super.stat(target, signal);
|
|
15
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
16
|
+
return ref.provider.fs.stat(ref.remotePath, signal);
|
|
17
|
+
}
|
|
18
|
+
async lstat(path, opts, signal) {
|
|
19
|
+
const ref = this.resolver.resolve(path);
|
|
20
|
+
if (ref.kind === "local") return super.lstat(path, opts, signal);
|
|
21
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
22
|
+
return ref.provider.fs.lstat(ref.remotePath, opts, signal);
|
|
23
|
+
}
|
|
24
|
+
async readText(target, signal) {
|
|
25
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
26
|
+
if (ref.kind === "local") return super.readText(target, signal);
|
|
27
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
28
|
+
return ref.provider.fs.readText(ref.remotePath, signal);
|
|
29
|
+
}
|
|
30
|
+
async streamText(target, signal) {
|
|
31
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
32
|
+
if (ref.kind === "local") return super.streamText(target, signal);
|
|
33
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
34
|
+
return ref.provider.fs.streamText(ref.remotePath, signal);
|
|
35
|
+
}
|
|
36
|
+
async readBytes(target, signal, maxBytes) {
|
|
37
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
38
|
+
if (ref.kind === "local") return super.readBytes(target, signal, maxBytes);
|
|
39
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
40
|
+
return ref.provider.fs.readBytes(ref.remotePath, signal, maxBytes);
|
|
41
|
+
}
|
|
42
|
+
async listDir(target, signal) {
|
|
43
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
44
|
+
if (ref.kind === "local") return super.listDir(target, signal);
|
|
45
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
46
|
+
return ref.provider.fs.listDir(ref.remotePath, signal);
|
|
47
|
+
}
|
|
48
|
+
async writeText(target, content, expected, signal, sandboxPolicy) {
|
|
49
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
50
|
+
if (ref.kind === "local") return super.writeText(target, content, expected, signal, sandboxPolicy);
|
|
51
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
52
|
+
return ref.provider.fs.writeText(ref.remotePath, content, expected, signal, sandboxPolicy);
|
|
53
|
+
}
|
|
54
|
+
async editText(target, edit, expected, signal, sandboxPolicy) {
|
|
55
|
+
const ref = this.resolver.resolve(this.targetPath(target));
|
|
56
|
+
if (ref.kind === "local") return super.editText(target, edit, expected, signal, sandboxPolicy);
|
|
57
|
+
if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
|
|
58
|
+
return ref.provider.fs.editText(ref.remotePath, edit, expected, signal, sandboxPolicy);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { RouterFileSystem as default };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=router-fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-fs.js","names":[],"sources":["../../src/router/router-fs.ts"],"sourcesContent":["import SandboxedFileSystem from '@deepseek-ai/dsh-fs-sandbox'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { FsEditOutcome, FsEditRequest, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome, FsDirEntry, FsInfo, FsPathInfo } from '@deepseek-ai/dsh-fs'\nimport type { SandboxExecutionPolicy } from '@deepseek-ai/dsh-sandbox'\nimport type { FsDelegate } from './types.js'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport default class RouterFileSystem extends SandboxedFileSystem {\n private readonly resolver = sharedWorldResolver()\n\n constructor(ctx: Context, config: unknown) {\n super(ctx, config as never)\n }\n\n private targetPath(target: FsTarget): string {\n return this.processPath(target)\n }\n\n override async stat(target: FsTarget, signal?: AbortSignal): Promise<FsInfo | undefined> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.stat(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.stat(ref.remotePath, signal) as Promise<FsInfo | undefined>\n }\n\n override async lstat(path: string, opts?: { cwd?: string }, signal?: AbortSignal): Promise<FsPathInfo | undefined> {\n const ref = this.resolver.resolve(path)\n if (ref.kind === 'local') return super.lstat(path, opts, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.lstat(ref.remotePath, opts, signal) as Promise<FsPathInfo | undefined>\n }\n\n override async readText(target: FsTarget, signal?: AbortSignal): Promise<string> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.readText(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.readText(ref.remotePath, signal)\n }\n\n override async streamText(target: FsTarget, signal?: AbortSignal): Promise<AsyncIterable<string>> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.streamText(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.streamText(ref.remotePath, signal)\n }\n\n override async readBytes(target: FsTarget, signal: AbortSignal | undefined, maxBytes: number): Promise<Uint8Array> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.readBytes(target, signal, maxBytes)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.readBytes(ref.remotePath, signal, maxBytes)\n }\n\n override async listDir(target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.listDir(target, signal)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.listDir(ref.remotePath, signal) as Promise<FsDirEntry[]>\n }\n\n override async writeText(target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsWriteOutcome> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.writeText(target, content, expected, signal, sandboxPolicy)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.writeText(ref.remotePath, content, expected, signal, sandboxPolicy) as Promise<FsWriteOutcome>\n }\n\n override async editText(target: FsTarget, edit: FsEditRequest, expected?: { version: FsVersion }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome> {\n const ref = this.resolver.resolve(this.targetPath(target))\n if (ref.kind === 'local') return super.editText(target, edit, expected, signal, sandboxPolicy)\n if (ref.kind === 'unrouted') throw new Error(`node ${ref.nodeId} world not available`)\n return ref.provider.fs.editText(ref.remotePath, edit, expected, signal, sandboxPolicy) as Promise<FsEditOutcome>\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import SandboxBashExecutor from "@deepseek-ai/dsh-bash-sandbox";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
import { ShellExecRequest, ShellExecSpec, ShellProcess, ShellRunResult } from "@deepseek-ai/dsh-shell";
|
|
4
|
+
//#region src/router/router-shell.d.ts
|
|
5
|
+
declare class RouterShell extends SandboxBashExecutor {
|
|
6
|
+
private readonly resolver;
|
|
7
|
+
constructor(ctx: Context, config: unknown);
|
|
8
|
+
resolve(request: ShellExecRequest): ShellExecSpec;
|
|
9
|
+
run(spec: ShellExecSpec): Promise<ShellRunResult>;
|
|
10
|
+
start(spec: ShellExecSpec): ShellProcess;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { RouterShell as default };
|
|
14
|
+
//# sourceMappingURL=router-shell.d.ts.map
|