dshb-router 0.0.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/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { t as Context } from "./index-CLOUBKxU.js";
2
+ import { ExecutionWorldProvider, NodeTestReport, WorkspaceBindings, WorldRef, WorldRegistry } from "./types.js";
3
+ import { sharedWorldResolver } from "./resolve.js";
4
+ //#region src/index.d.ts
5
+ declare const name = "dshb-router";
6
+ declare function apply(ctx: Context): void;
7
+ //#endregion
8
+ export { type ExecutionWorldProvider, type NodeTestReport, type WorkspaceBindings, type WorldRef, type WorldRegistry, apply, name, sharedWorldResolver };
9
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { sharedWorldResolver } from "./resolve.js";
2
+ //#region src/index.ts
3
+ const name = "dshb-router";
4
+ function apply(ctx) {
5
+ ctx.provide("dshbRouter", sharedWorldResolver());
6
+ }
7
+ //#endregion
8
+ export { apply, name, sharedWorldResolver };
9
+
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport const name = 'dshb-router'\n\nexport function apply(ctx: Context): void {\n ctx.provide('dshbRouter', sharedWorldResolver())\n}\n\nexport { sharedWorldResolver } from './resolve.js'\nexport type { ExecutionWorldProvider, WorkspaceBindings, WorldRegistry, WorldRef, NodeTestReport } from './types.js'\n"],"mappings":";;AAGA,MAAa,OAAO;AAEpB,SAAgB,MAAM,KAAoB;CACxC,IAAI,QAAQ,cAAc,oBAAoB,CAAC;AACjD"}
@@ -0,0 +1,22 @@
1
+ import { WorkspaceBindings, WorldRef, WorldRegistry } from "./types.js";
2
+ //#region src/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
package/lib/resolve.js ADDED
@@ -0,0 +1,45 @@
1
+ //#region src/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/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 { t as Context } from "./index-CLOUBKxU.js";
2
+ import SandboxedFileSystem from "@deepseek-ai/dsh-fs-sandbox";
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-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-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-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 { t as Context } from "./index-CLOUBKxU.js";
2
+ import SandboxBashExecutor from "@deepseek-ai/dsh-bash-sandbox";
3
+ import { ShellExecRequest, ShellExecSpec, ShellProcess, ShellRunResult } from "@deepseek-ai/dsh-shell";
4
+ //#region src/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
@@ -0,0 +1,36 @@
1
+ import { sharedWorldResolver } from "./resolve.js";
2
+ import SandboxBashExecutor from "@deepseek-ai/dsh-bash-sandbox";
3
+ //#region src/router-shell.ts
4
+ var RouterShell = class extends SandboxBashExecutor {
5
+ resolver = sharedWorldResolver();
6
+ constructor(ctx, config) {
7
+ super(ctx, config);
8
+ }
9
+ resolve(request) {
10
+ return super.resolve(request);
11
+ }
12
+ async run(spec) {
13
+ const ref = this.resolver.resolve(spec.workdir ?? "");
14
+ if (ref.kind === "local") return super.run(spec);
15
+ if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
16
+ await ref.provider.ensureDir(ref.remotePath).catch(() => {});
17
+ return ref.provider.shell.run({
18
+ ...spec,
19
+ workdir: ref.remotePath
20
+ });
21
+ }
22
+ start(spec) {
23
+ const ref = this.resolver.resolve(spec.workdir ?? "");
24
+ if (ref.kind === "local") return super.start(spec);
25
+ if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
26
+ ref.provider.ensureDir(ref.remotePath).catch(() => {});
27
+ return ref.provider.shell.start({
28
+ ...spec,
29
+ workdir: ref.remotePath
30
+ });
31
+ }
32
+ };
33
+ //#endregion
34
+ export { RouterShell as default };
35
+
36
+ //# sourceMappingURL=router-shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-shell.js","names":[],"sources":["../src/router-shell.ts"],"sourcesContent":["import SandboxBashExecutor from '@deepseek-ai/dsh-bash-sandbox'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ShellExecRequest, ShellExecSpec, ShellProcess, ShellRunResult } from '@deepseek-ai/dsh-shell'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport default class RouterShell extends SandboxBashExecutor {\n private readonly resolver = sharedWorldResolver()\n\n constructor(ctx: Context, config: unknown) {\n super(ctx, config as never)\n }\n\n override resolve(request: ShellExecRequest): ShellExecSpec {\n return super.resolve(request)\n }\n\n override async run(spec: ShellExecSpec): Promise<ShellRunResult> {\n const ref = this.resolver.resolve(spec.workdir ?? '')\n if (ref.kind === 'local') return super.run(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 override start(spec: ShellExecSpec): ShellProcess {\n const ref = this.resolver.resolve(spec.workdir ?? '')\n if (ref.kind === 'local') return super.start(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"],"mappings":";;;AAKA,IAAqB,cAArB,cAAyC,oBAAoB;CAC3D,WAA4B,oBAAoB;CAEhD,YAAY,KAAc,QAAiB;EACzC,MAAM,KAAK,MAAe;CAC5B;CAEA,QAAiB,SAA0C;EACzD,OAAO,MAAM,QAAQ,OAAO;CAC9B;CAEA,MAAe,IAAI,MAA8C;EAC/D,MAAM,MAAM,KAAK,SAAS,QAAQ,KAAK,WAAW,EAAE;EACpD,IAAI,IAAI,SAAS,SAAS,OAAO,MAAM,IAAI,IAAI;EAC/C,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,MAAe,MAAmC;EAChD,MAAM,MAAM,KAAK,SAAS,QAAQ,KAAK,WAAW,EAAE;EACpD,IAAI,IAAI,SAAS,SAAS,OAAO,MAAM,MAAM,IAAI;EACjD,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;AACF"}
@@ -0,0 +1,13 @@
1
+ import { t as Context } from "./index-CLOUBKxU.js";
2
+ import LocalSubprocessRuntime from "@deepseek-ai/dsh-subprocess-local";
3
+ import { SubprocessHandle, SubprocessSpawnSpec, SubprocessTerminalHandle, SubprocessTerminalSpawnSpec } from "@deepseek-ai/dsh-subprocess";
4
+ //#region src/router-subprocess.d.ts
5
+ declare class RouterSubprocess extends LocalSubprocessRuntime {
6
+ private readonly resolver;
7
+ constructor(ctx: Context);
8
+ spawn(spec: SubprocessSpawnSpec): SubprocessHandle;
9
+ spawnTerminal(spec: SubprocessTerminalSpawnSpec): Promise<SubprocessTerminalHandle>;
10
+ }
11
+ //#endregion
12
+ export { RouterSubprocess as default };
13
+ //# sourceMappingURL=router-subprocess.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { sharedWorldResolver } from "./resolve.js";
2
+ import LocalSubprocessRuntime from "@deepseek-ai/dsh-subprocess-local";
3
+ //#region src/router-subprocess.ts
4
+ var RouterSubprocess = class extends LocalSubprocessRuntime {
5
+ resolver = sharedWorldResolver();
6
+ constructor(ctx) {
7
+ super(ctx);
8
+ }
9
+ spawn(spec) {
10
+ const ref = this.resolver.resolve(spec.cwd ?? "");
11
+ if (ref.kind === "local") return super.spawn(spec);
12
+ if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
13
+ ref.provider.ensureDir(ref.remotePath).catch(() => {});
14
+ return ref.provider.subprocess.spawn({
15
+ ...spec,
16
+ cwd: ref.remotePath
17
+ });
18
+ }
19
+ async spawnTerminal(spec) {
20
+ const ref = this.resolver.resolve(spec.cwd ?? "");
21
+ if (ref.kind === "local") return super.spawnTerminal(spec);
22
+ if (ref.kind === "unrouted") throw new Error(`node ${ref.nodeId} world not available`);
23
+ await ref.provider.ensureDir(ref.remotePath).catch(() => {});
24
+ return ref.provider.subprocess.spawnTerminal({
25
+ ...spec,
26
+ cwd: ref.remotePath
27
+ });
28
+ }
29
+ };
30
+ //#endregion
31
+ export { RouterSubprocess as default };
32
+
33
+ //# sourceMappingURL=router-subprocess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-subprocess.js","names":[],"sources":["../src/router-subprocess.ts"],"sourcesContent":["import LocalSubprocessRuntime from '@deepseek-ai/dsh-subprocess-local'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { SubprocessHandle, SubprocessSpawnSpec, SubprocessTerminalHandle, SubprocessTerminalSpawnSpec } from '@deepseek-ai/dsh-subprocess'\nimport { sharedWorldResolver } from './resolve.js'\n\nexport default class RouterSubprocess extends LocalSubprocessRuntime {\n private readonly resolver = sharedWorldResolver()\n\n constructor(ctx: Context) {\n super(ctx)\n }\n\n override spawn(spec: SubprocessSpawnSpec): SubprocessHandle {\n const ref = this.resolver.resolve(spec.cwd ?? '')\n if (ref.kind === 'local') return super.spawn(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 override async spawnTerminal(spec: SubprocessTerminalSpawnSpec): Promise<SubprocessTerminalHandle> {\n const ref = this.resolver.resolve(spec.cwd ?? '')\n if (ref.kind === 'local') return super.spawnTerminal(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"],"mappings":";;;AAKA,IAAqB,mBAArB,cAA8C,uBAAuB;CACnE,WAA4B,oBAAoB;CAEhD,YAAY,KAAc;EACxB,MAAM,GAAG;CACX;CAEA,MAAe,MAA6C;EAC1D,MAAM,MAAM,KAAK,SAAS,QAAQ,KAAK,OAAO,EAAE;EAChD,IAAI,IAAI,SAAS,SAAS,OAAO,MAAM,MAAM,IAAI;EACjD,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,MAAe,cAAc,MAAsE;EACjG,MAAM,MAAM,KAAK,SAAS,QAAQ,KAAK,OAAO,EAAE;EAChD,IAAI,IAAI,SAAS,SAAS,OAAO,MAAM,cAAc,IAAI;EACzD,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;AACF"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { FileSystem } from "@deepseek-ai/dsh-fs";
2
+ import { SubprocessHandle, SubprocessRuntime, SubprocessSpawnSpec, SubprocessTerminalHandle, SubprocessTerminalSpawnSpec } from "@deepseek-ai/dsh-subprocess";
3
+ import { ShellExecRequest, ShellExecSpec, ShellProcess, ShellRunResult } from "@deepseek-ai/dsh-shell";
4
+ //#region src/types.d.ts
5
+ interface NodeTestReport {
6
+ ok: boolean;
7
+ reachable?: boolean;
8
+ error?: string;
9
+ }
10
+ interface FsDelegate {
11
+ resolve(path: string, opts?: {
12
+ cwd?: string;
13
+ }): Promise<FsTargetLike>;
14
+ processPath(target: FsTargetLike): string;
15
+ fileUrl(target: FsTargetLike): string;
16
+ contains(parent: FsTargetLike, child: FsTargetLike): boolean;
17
+ stat(target: FsTargetLike, signal?: AbortSignal): Promise<unknown>;
18
+ lstat(path: string, opts?: {
19
+ cwd?: string;
20
+ }, signal?: AbortSignal): Promise<unknown>;
21
+ readText(target: FsTargetLike, signal?: AbortSignal): Promise<string>;
22
+ streamText(target: FsTargetLike, signal?: AbortSignal): Promise<AsyncIterable<string>>;
23
+ readBytes(target: FsTargetLike, signal: AbortSignal | undefined, maxBytes: number): Promise<Uint8Array>;
24
+ listDir(target: FsTargetLike, signal?: AbortSignal): Promise<unknown[]>;
25
+ writeText(target: FsTargetLike, content: string, expected?: unknown, signal?: AbortSignal, policy?: unknown): Promise<unknown>;
26
+ editText(target: FsTargetLike, edit: unknown, expected?: unknown, signal?: AbortSignal, policy?: unknown): Promise<unknown>;
27
+ }
28
+ type FsTargetLike = string;
29
+ interface SubprocessDelegate {
30
+ spawn(spec: SubprocessSpawnSpec): SubprocessHandle;
31
+ spawnTerminal(spec: SubprocessTerminalSpawnSpec): Promise<SubprocessTerminalHandle>;
32
+ }
33
+ interface ShellDelegate {
34
+ resolve(request: ShellExecRequest): ShellExecSpec;
35
+ run(spec: ShellExecSpec): Promise<ShellRunResult>;
36
+ start(spec: ShellExecSpec): ShellProcess;
37
+ }
38
+ interface ExecutionWorldProvider {
39
+ readonly nodeId: string;
40
+ readonly fs: FsDelegate;
41
+ readonly subprocess: SubprocessDelegate;
42
+ readonly shell: ShellDelegate;
43
+ ensureDir(remotePath: string): Promise<void>;
44
+ testConnection(): Promise<NodeTestReport>;
45
+ }
46
+ interface WorkspaceBindings {
47
+ resolve(mirrorPath: string): {
48
+ nodeId: string;
49
+ remotePath: string;
50
+ } | undefined;
51
+ }
52
+ interface WorldRegistry {
53
+ get(nodeId: string): ExecutionWorldProvider | undefined;
54
+ }
55
+ type WorldRef = {
56
+ kind: 'local';
57
+ } | {
58
+ kind: 'remote';
59
+ provider: ExecutionWorldProvider;
60
+ remotePath: string;
61
+ } | {
62
+ kind: 'unrouted';
63
+ nodeId: string;
64
+ };
65
+ //#endregion
66
+ export { ExecutionWorldProvider, type FileSystem, FsDelegate, FsTargetLike, NodeTestReport, ShellDelegate, type ShellExecRequest, type ShellExecSpec, type ShellProcess, type ShellRunResult, SubprocessDelegate, type SubprocessHandle, type SubprocessRuntime, type SubprocessSpawnSpec, type SubprocessTerminalHandle, type SubprocessTerminalSpawnSpec, WorkspaceBindings, WorldRef, WorldRegistry };
67
+ //# sourceMappingURL=types.d.ts.map
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "dshb-router",
3
+ "version": "0.0.1",
4
+ "description": "DSHB 执行世界路由器(ctx.fs / ctx.subprocess / ctx.shell 按镜像路径分流)",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./fs": "./lib/router-fs.js",
10
+ "./subprocess": "./lib/router-subprocess.js",
11
+ "./shell": "./lib/router-shell.js",
12
+ "./resolve": "./lib/resolve.js",
13
+ "./types": "./lib/types.js",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "lib",
18
+ "cordis.patch.yml"
19
+ ],
20
+ "dsh": {
21
+ "bundle": {
22
+ "patch": "./cordis.patch.yml"
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "@deepseek-ai/dsh-fs": "^0.1.1-rc.2",
27
+ "@deepseek-ai/dsh-fs-sandbox": "^0.1.1-rc.2",
28
+ "@deepseek-ai/dsh-subprocess": "^0.1.1-rc.2",
29
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.1-rc.2",
30
+ "@deepseek-ai/dsh-shell": "^0.1.1-rc.2",
31
+ "@deepseek-ai/dsh-bash-sandbox": "^0.1.1-rc.2",
32
+ "@deepseek-ai/dsh-sandbox": "^0.1.1-rc.2"
33
+ },
34
+ "devDependencies": {
35
+ "@deepseek-ai/cordis": "^4.0.2"
36
+ },
37
+ "types": "lib/index.d.ts",
38
+ "scripts": {
39
+ "build": "tsdown",
40
+ "typecheck": "tsc --noEmit"
41
+ }
42
+ }