better-dsh 0.3.1 → 0.3.2-e
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 +6 -5
- package/cordis.patch.yml +14 -9
- package/docs/20_specs/kernel-provisioning/spec.md +2 -0
- package/docs/remote-tools.md +36 -14
- package/docs/specs/kernel-provisioning/spec.md +12 -40
- package/docs/specs/omp-python-repl-port/runtime-guide.md +3 -1
- package/docs/specs/omp-python-repl-port/spec.md +7 -0
- package/docs/specs/remote-pty-label/spec.md +2 -0
- package/docs/specs/remote-tool-enhancement/spec.md +2 -0
- package/lib/BrowserWebSocketTransport.js +4 -0
- package/lib/{BrowserWebSocketTransport-wm99h94r.js → BrowserWebSocketTransport2.js} +1 -1
- package/lib/LaunchOptions.js +4 -0
- package/lib/{LaunchOptions-5eg7E0ye.js → LaunchOptions2.js} +1 -1
- package/lib/{NodeWebSocketTransport-D9ysYGLM.js → NodeWebSocketTransport.js} +2 -2
- package/lib/NodeWebSocketTransport2.js +4 -0
- package/lib/{bidi-CwabFH07.js → bidi.js} +4 -4
- package/lib/client/index.js +59 -6
- package/lib/compaction/index.d.ts +1 -1
- package/lib/compaction/index.js +1 -1
- package/lib/failover/index.d.ts +1 -1
- package/lib/failover/index.js +1 -1
- package/lib/fs-aware/sandbox-plugin.js +1 -1
- package/lib/{index-browser-B-9jm12n.js → index-browser.js} +6 -6
- package/lib/index.d.ts +2 -12
- package/lib/index.js +58 -62
- package/lib/kernel-env.d.ts +5 -15
- package/lib/kernel-env.js +2 -2
- package/lib/kernel-env2.js +76 -0
- package/lib/{lsp-server-registry-BcdkHROD.js → lsp-server-registry2.js} +1 -1
- package/lib/{main-BeCgUd20.js → main.js} +1 -1
- package/lib/{main-Dv_UQqG2.js → main2.js} +1 -1
- package/lib/mobile/plugin.d.ts +2 -2
- package/lib/mobile/plugin.js +2 -2
- package/lib/{puppeteer-core-Dnd7eqel.js → puppeteer-core.js} +9 -9
- package/lib/py-sdk.js +1 -1
- package/lib/remote/helper-bin/MANIFEST.json +35 -0
- package/lib/remote/helper-bin/aarch64-apple-darwin/BUILT-VER +1 -0
- package/lib/remote/helper-bin/aarch64-apple-darwin/superd-run +0 -0
- package/lib/remote/helper-bin/aarch64-unknown-linux-musl/BUILT-VER +1 -0
- package/lib/remote/helper-bin/aarch64-unknown-linux-musl/superd-run +0 -0
- package/lib/remote/helper-bin/x86_64-pc-windows-gnu/BUILT-VER +1 -0
- package/lib/remote/helper-bin/x86_64-pc-windows-gnu/superd-run.exe +0 -0
- package/lib/remote/helper-bin/x86_64-unknown-linux-musl/BUILT-VER +1 -0
- package/lib/remote/helper-bin/x86_64-unknown-linux-musl/superd-run +0 -0
- package/lib/remote/hub-pty-pump.mjs +97 -0
- package/lib/remote/plugin.d.ts +523 -199
- package/lib/remote/plugin.js +2527 -765
- package/lib/url-schemes/index.d.ts +11 -11
- package/lib/url-schemes/index.js +12 -12
- package/lib/{wasm_bg-CNXhHjVg.js → wasm_bg.js} +1 -1
- package/lib/web-password.d.ts +7 -7
- package/lib/web-password.js +1 -1
- package/lib/web-trust.d.ts +2 -1
- package/lib/web-trust.js +2 -2
- package/lib/{web-trust-CwZrTBcl.d.ts → web-trust2.d.ts} +11 -11
- package/lib/{web-trust-D6gJpUMf.js → web-trust2.js} +20 -8
- package/lib/welcome-notice.d.ts +3 -3
- package/lib/welcome-notice.js +1 -1
- package/package.json +4 -4
- package/scripts/kernel-check.mjs +5 -0
- package/lib/BrowserWebSocketTransport-D1aFReu_.js +0 -4
- package/lib/LaunchOptions-DxQQ0s-A.js +0 -4
- package/lib/NodeWebSocketTransport-BRLjmu2R.js +0 -4
- package/lib/kernel-env-BOF0fNHn.js +0 -91
- package/scripts/kernel-provision.mjs +0 -5
- /package/lib/{chunk-DQxbwPpZ.js → chunk.js} +0 -0
- /package/lib/{index-DTDXUe6m.d.ts → index2.d.ts} +0 -0
- /package/lib/{lib-C8_jXvwA.js → lib.js} +0 -0
- /package/lib/{lsp-server-registry-D4VLs1Sm.js → lsp-server-registry.js} +0 -0
- /package/lib/{native-capture-BEByDXYM.js → native-capture.js} +0 -0
- /package/lib/{py-sdk-D7klhpWb.js → py-sdk2.js} +0 -0
- /package/lib/{util-BHL_dfV_.js → util.js} +0 -0
- /package/lib/{web-tree-sitter-CPrPD4J2.js → web-tree-sitter.js} +0 -0
- /package/lib/{wrap-0VA0uFx8.js → wrap.js} +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Schema } from "./
|
|
1
|
+
import { t as Schema } from "./index2.js";
|
|
2
2
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
3
|
import { ToolDefinition, ToolExecutionInput, ToolRunContext, ToolRuntime } from "@deepseek-ai/dsh-tools";
|
|
4
4
|
import { ContentBlock, HarnessError } from "@deepseek-ai/dsh-llm";
|
|
@@ -379,7 +379,7 @@ interface ReplRuntimeSurface {
|
|
|
379
379
|
//#region src/runtime.d.ts
|
|
380
380
|
/** Plugin config: every tunable, changeable from `cordis.yml` (no hardcoded tunables). */
|
|
381
381
|
interface Config$1 {
|
|
382
|
-
/**
|
|
382
|
+
/** Existing interpreter path/name; absent discovers active/project environments then PATH. */
|
|
383
383
|
python?: string;
|
|
384
384
|
/** Budget for kernel spawn → ready, in milliseconds. */
|
|
385
385
|
startupTimeoutMs?: number;
|
|
@@ -402,12 +402,6 @@ interface Config$1 {
|
|
|
402
402
|
snapshotDir?: string;
|
|
403
403
|
/** Serialized graph cap in bytes; each over-cap attempt reports the last successful checkpoint. */
|
|
404
404
|
snapshotSizeCapBytes?: number;
|
|
405
|
-
/** Managed venv directory (used when `python` is absent/`python3`); defaults to `<package>/.venv-kernel`. */
|
|
406
|
-
kernelEnvDir?: string;
|
|
407
|
-
/** Preferred CPython version for a managed venv. */
|
|
408
|
-
kernelPythonVersion?: string;
|
|
409
|
-
/** Provision a stdlib-only managed venv on first use; default true. */
|
|
410
|
-
kernelAutoInstall?: boolean;
|
|
411
405
|
username?: string;
|
|
412
406
|
}
|
|
413
407
|
/**
|
|
@@ -428,8 +422,6 @@ declare class DashrRuntime extends ReplRuntime {
|
|
|
428
422
|
private readonly kernels;
|
|
429
423
|
private disposed;
|
|
430
424
|
private readonly transactions;
|
|
431
|
-
/** Lazily-resolved (and, when managed, provisioned) kernel interpreter. */
|
|
432
|
-
private kernelEnvPromise;
|
|
433
425
|
constructor(ctx: Context, config: Config$1);
|
|
434
426
|
/**
|
|
435
427
|
* The agentless-default kernel's pid, for lifecycle diagnostics; absent
|
|
@@ -480,8 +472,6 @@ declare class DashrRuntime extends ReplRuntime {
|
|
|
480
472
|
private validateBindings;
|
|
481
473
|
/** Dispatch one kernel-side host request; unknown types and bad payloads become error replies. */
|
|
482
474
|
private dispatchHostRequest;
|
|
483
|
-
/** Resolve (and provision, when managed) the kernel interpreter once per runtime. */
|
|
484
|
-
private resolveKernelPython;
|
|
485
475
|
/**
|
|
486
476
|
* Spawn-or-reuse the kernel for one key. The lazy map guarantees one
|
|
487
477
|
* entry is created here and nowhere else, so a key that never runs never
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Schema } from "./lib
|
|
2
|
-
import { a as RESERVED_ERROR_MEMBERS, i as RESERVED_BINDING_GLOBALS, n as DUNDER_MEMBER, o as ReplRuntime, r as PORTABLE_RESERVED_WORDS, t as isFlatBindableName } from "./py-
|
|
3
|
-
import {
|
|
4
|
-
import { t as captureAllTools } from "./native-capture
|
|
1
|
+
import { t as Schema } from "./lib.js";
|
|
2
|
+
import { a as RESERVED_ERROR_MEMBERS, i as RESERVED_BINDING_GLOBALS, n as DUNDER_MEMBER, o as ReplRuntime, r as PORTABLE_RESERVED_WORDS, t as isFlatBindableName } from "./py-sdk2.js";
|
|
3
|
+
import { n as resolveKernelEnv } from "./kernel-env2.js";
|
|
4
|
+
import { t as captureAllTools } from "./native-capture.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { Context } from "@deepseek-ai/cordis";
|
|
7
7
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -378,6 +378,7 @@ var IpyKernelBridge = class {
|
|
|
378
378
|
],
|
|
379
379
|
env: {
|
|
380
380
|
...process.env,
|
|
381
|
+
...this.options.env,
|
|
381
382
|
PYTHONUNBUFFERED: "1",
|
|
382
383
|
PYTHONIOENCODING: "utf-8",
|
|
383
384
|
PYTHONDONTWRITEBYTECODE: "1",
|
|
@@ -746,7 +747,7 @@ function keyDirectoryName(principal) {
|
|
|
746
747
|
*/
|
|
747
748
|
var DashrRuntime = class extends ReplRuntime {
|
|
748
749
|
static Config = Schema.object({
|
|
749
|
-
python: Schema.string()
|
|
750
|
+
python: Schema.string(),
|
|
750
751
|
startupTimeoutMs: Schema.number().default(3e4),
|
|
751
752
|
runTimeoutMs: Schema.number().default(12e4),
|
|
752
753
|
interruptGraceMs: Schema.number().default(2e3),
|
|
@@ -756,9 +757,6 @@ var DashrRuntime = class extends ReplRuntime {
|
|
|
756
757
|
maxOutputBytes: Schema.number().default(67108864),
|
|
757
758
|
snapshotDir: Schema.string(),
|
|
758
759
|
snapshotSizeCapBytes: Schema.number().default(268435456),
|
|
759
|
-
kernelEnvDir: Schema.string(),
|
|
760
|
-
kernelPythonVersion: Schema.string(),
|
|
761
|
-
kernelAutoInstall: Schema.boolean().default(true),
|
|
762
760
|
username: Schema.string().default("dashr")
|
|
763
761
|
});
|
|
764
762
|
language = "python";
|
|
@@ -769,8 +767,6 @@ var DashrRuntime = class extends ReplRuntime {
|
|
|
769
767
|
kernels = /* @__PURE__ */ new Map();
|
|
770
768
|
disposed = false;
|
|
771
769
|
transactions = /* @__PURE__ */ new Map();
|
|
772
|
-
/** Lazily-resolved (and, when managed, provisioned) kernel interpreter. */
|
|
773
|
-
kernelEnvPromise;
|
|
774
770
|
constructor(ctx, config) {
|
|
775
771
|
super(ctx);
|
|
776
772
|
const profile = ctx.get("profileContext");
|
|
@@ -1060,23 +1056,6 @@ var DashrRuntime = class extends ReplRuntime {
|
|
|
1060
1056
|
result: value
|
|
1061
1057
|
};
|
|
1062
1058
|
}
|
|
1063
|
-
/** Resolve (and provision, when managed) the kernel interpreter once per runtime. */
|
|
1064
|
-
resolveKernelPython() {
|
|
1065
|
-
this.kernelEnvPromise ??= resolveKernelEnv({
|
|
1066
|
-
python: this.config.python,
|
|
1067
|
-
venvDir: this.config.kernelEnvDir,
|
|
1068
|
-
pythonVersion: this.config.kernelPythonVersion,
|
|
1069
|
-
autoInstall: this.config.kernelAutoInstall,
|
|
1070
|
-
log: (level, message) => {
|
|
1071
|
-
if (level === "warn") this.logger.warn(message);
|
|
1072
|
-
else this.logger.info(message);
|
|
1073
|
-
}
|
|
1074
|
-
}).catch((error) => {
|
|
1075
|
-
this.kernelEnvPromise = void 0;
|
|
1076
|
-
throw error;
|
|
1077
|
-
});
|
|
1078
|
-
return this.kernelEnvPromise;
|
|
1079
|
-
}
|
|
1080
1059
|
/**
|
|
1081
1060
|
* Spawn-or-reuse the kernel for one key. The lazy map guarantees one
|
|
1082
1061
|
* entry is created here and nowhere else, so a key that never runs never
|
|
@@ -1088,11 +1067,16 @@ var DashrRuntime = class extends ReplRuntime {
|
|
|
1088
1067
|
let entry = this.kernels.get(key);
|
|
1089
1068
|
if (!entry) {
|
|
1090
1069
|
const kernelCwd = cwd && existsSync(cwd) ? cwd : void 0;
|
|
1070
|
+
const environment = await resolveKernelEnv({
|
|
1071
|
+
python: this.config.python,
|
|
1072
|
+
cwd: kernelCwd
|
|
1073
|
+
});
|
|
1091
1074
|
entry = {
|
|
1092
1075
|
key,
|
|
1093
1076
|
cwd: kernelCwd,
|
|
1094
1077
|
bridge: new IpyKernelBridge({
|
|
1095
|
-
python:
|
|
1078
|
+
python: environment.python,
|
|
1079
|
+
env: environment.env,
|
|
1096
1080
|
...kernelCwd ? { cwd: kernelCwd } : {},
|
|
1097
1081
|
startupTimeoutMs: this.config.startupTimeoutMs,
|
|
1098
1082
|
disposeTimeoutMs: this.config.disposeTimeoutMs,
|
|
@@ -1425,8 +1409,7 @@ const agentExecutor = async (rawArgs, exec, deps) => {
|
|
|
1425
1409
|
if (!exec.agent) return { error: "agent() requires a calling agent (this run has no agent to delegate from)" };
|
|
1426
1410
|
const subagents = deps.requireSubagents?.();
|
|
1427
1411
|
if (!subagents) return { error: "agent() is unavailable: no ctx.subagents service is mounted in this composition" };
|
|
1428
|
-
const
|
|
1429
|
-
label: description,
|
|
1412
|
+
const request = {
|
|
1430
1413
|
prompt: [{
|
|
1431
1414
|
type: "text",
|
|
1432
1415
|
text: prompt
|
|
@@ -1435,30 +1418,60 @@ const agentExecutor = async (rawArgs, exec, deps) => {
|
|
|
1435
1418
|
maxDepth: NATIVE_MAX_DEPTH
|
|
1436
1419
|
};
|
|
1437
1420
|
const runInBackground = a["run_in_background"] ?? true;
|
|
1421
|
+
const legacyRequest = {
|
|
1422
|
+
label: description,
|
|
1423
|
+
...request,
|
|
1424
|
+
signal: exec.signal
|
|
1425
|
+
};
|
|
1426
|
+
if (subagents.startActivation === void 0) try {
|
|
1427
|
+
if (runInBackground) {
|
|
1428
|
+
if (subagents.startContinuable === void 0) return { error: "agent() is unavailable: this DSH host exposes neither managed activations nor the legacy continuable seam" };
|
|
1429
|
+
return {
|
|
1430
|
+
kind: "continuable",
|
|
1431
|
+
subagentId: (await subagents.startContinuable({
|
|
1432
|
+
provider,
|
|
1433
|
+
request: legacyRequest
|
|
1434
|
+
})).childId
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
if (subagents.start === void 0) return { error: "agent() is unavailable: this DSH host exposes neither managed activations nor the legacy one-shot seam" };
|
|
1438
|
+
const run = await subagents.start(provider, legacyRequest);
|
|
1439
|
+
try {
|
|
1440
|
+
const result = await run.result;
|
|
1441
|
+
if (result.stopReason !== "completed") return { error: `agent() ${stopReasonError(result.stopReason)}` };
|
|
1442
|
+
return {
|
|
1443
|
+
kind: "foreground",
|
|
1444
|
+
subagentId: run.id,
|
|
1445
|
+
output: result.output
|
|
1446
|
+
};
|
|
1447
|
+
} finally {
|
|
1448
|
+
await run.dispose();
|
|
1449
|
+
}
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
return { error: `agent() failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
1452
|
+
}
|
|
1438
1453
|
try {
|
|
1454
|
+
const activation = await subagents.startActivation({
|
|
1455
|
+
provider,
|
|
1456
|
+
label: description,
|
|
1457
|
+
request,
|
|
1458
|
+
signal: exec.signal,
|
|
1459
|
+
delivery: runInBackground ? "parent" : "caller"
|
|
1460
|
+
});
|
|
1439
1461
|
if (runInBackground) return {
|
|
1440
1462
|
kind: "continuable",
|
|
1441
|
-
subagentId:
|
|
1442
|
-
provider,
|
|
1443
|
-
label: description,
|
|
1444
|
-
request: delegation,
|
|
1445
|
-
signal: exec.signal
|
|
1446
|
-
})).childId
|
|
1463
|
+
subagentId: activation.childId
|
|
1447
1464
|
};
|
|
1448
|
-
const run = await subagents.start(provider, {
|
|
1449
|
-
...delegation,
|
|
1450
|
-
signal: exec.signal
|
|
1451
|
-
});
|
|
1452
1465
|
try {
|
|
1453
|
-
const result = await
|
|
1466
|
+
const result = await activation.result;
|
|
1454
1467
|
if (result.stopReason !== "completed") return { error: `agent() ${stopReasonError(result.stopReason)}` };
|
|
1455
1468
|
return {
|
|
1456
1469
|
kind: "foreground",
|
|
1457
|
-
|
|
1470
|
+
subagentId: activation.childId,
|
|
1458
1471
|
output: result.output
|
|
1459
1472
|
};
|
|
1460
1473
|
} finally {
|
|
1461
|
-
await
|
|
1474
|
+
await activation.dispose();
|
|
1462
1475
|
}
|
|
1463
1476
|
} catch (error) {
|
|
1464
1477
|
return { error: `agent() failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -1666,7 +1679,7 @@ function createAgentBridgeTools(deps) {
|
|
|
1666
1679
|
type: "string",
|
|
1667
1680
|
enum: ["foreground"]
|
|
1668
1681
|
},
|
|
1669
|
-
|
|
1682
|
+
subagentId: { type: "string" },
|
|
1670
1683
|
output: { type: "json" }
|
|
1671
1684
|
},
|
|
1672
1685
|
additionalProperties: false
|
|
@@ -2496,10 +2509,7 @@ const RUNTIME_CONFIG_KEYS = [
|
|
|
2496
2509
|
"maxOutputBytes",
|
|
2497
2510
|
"snapshotDir",
|
|
2498
2511
|
"snapshotSizeCapBytes",
|
|
2499
|
-
"username"
|
|
2500
|
-
"kernelEnvDir",
|
|
2501
|
-
"kernelPythonVersion",
|
|
2502
|
-
"kernelAutoInstall"
|
|
2512
|
+
"username"
|
|
2503
2513
|
];
|
|
2504
2514
|
/** The runtime slice of the merged config — the keys `DashrRuntime` owns. */
|
|
2505
2515
|
function pickRuntimeConfig(config) {
|
|
@@ -2511,20 +2521,6 @@ function apply(ctx, config) {
|
|
|
2511
2521
|
ctx.plugin(DashrRuntime, pickRuntimeConfig(config));
|
|
2512
2522
|
const logger = ctx.logger("dashr-repl");
|
|
2513
2523
|
const maxParallel = resolveMaxParallelSubCalls(config.maxParallelSubCalls);
|
|
2514
|
-
{
|
|
2515
|
-
const kernelConfig = pickRuntimeConfig(config);
|
|
2516
|
-
resolveKernelEnv({
|
|
2517
|
-
python: kernelConfig.python,
|
|
2518
|
-
venvDir: kernelConfig.kernelEnvDir,
|
|
2519
|
-
pythonVersion: kernelConfig.kernelPythonVersion,
|
|
2520
|
-
autoInstall: kernelConfig.kernelAutoInstall ?? true,
|
|
2521
|
-
log: (level, message) => {
|
|
2522
|
-
logger[level](message);
|
|
2523
|
-
}
|
|
2524
|
-
}).catch((error) => {
|
|
2525
|
-
logger.error(`dashr-repl: spin-up kernel check failed (non-blocking): ${error instanceof Error ? error.message : String(error)}`);
|
|
2526
|
-
});
|
|
2527
|
-
}
|
|
2528
2524
|
ctx.inject(["replRuntime"], (runtimeCtx) => {
|
|
2529
2525
|
const requireRuntime = () => {
|
|
2530
2526
|
const runtime = runtimeCtx.get("replRuntime");
|
package/lib/kernel-env.d.ts
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
//#region src/kernel-env.d.ts
|
|
2
2
|
declare const PACKAGE_ROOT: string;
|
|
3
|
-
declare const AUTO_PYTHON_SENTINEL = "python3";
|
|
4
|
-
declare const DEFAULT_KERNEL_PYTHON_VERSION = "3.11";
|
|
5
|
-
declare const DILL_VERSION = "0.4.1";
|
|
6
3
|
interface KernelEnv {
|
|
7
4
|
python: string;
|
|
8
|
-
|
|
9
|
-
venvDir: string | undefined;
|
|
10
|
-
/** Snapshot implementation is packaged rather than installed into Python. */
|
|
11
|
-
dill: boolean;
|
|
5
|
+
env: NodeJS.ProcessEnv;
|
|
12
6
|
version: string;
|
|
13
7
|
}
|
|
14
8
|
interface ResolveKernelEnvOptions {
|
|
9
|
+
/** An explicit path or executable name bypasses automatic discovery. */
|
|
15
10
|
python?: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
autoInstall?: boolean;
|
|
19
|
-
log?: (level: 'info' | 'warn', message: string) => void;
|
|
11
|
+
/** Session workspace, used for existing project environments and relative paths. */
|
|
12
|
+
cwd?: string;
|
|
20
13
|
}
|
|
21
|
-
declare function uvToolEnv(venvDir: string): NodeJS.ProcessEnv;
|
|
22
|
-
declare function uvVenvArgs(dir: string, version: string): string[];
|
|
23
|
-
declare function venvFallbackArgs(dir: string): string[];
|
|
24
14
|
declare function resolveKernelEnv(options?: ResolveKernelEnvOptions): Promise<KernelEnv>;
|
|
25
15
|
//#endregion
|
|
26
|
-
export {
|
|
16
|
+
export { KernelEnv, PACKAGE_ROOT, ResolveKernelEnvOptions, resolveKernelEnv };
|
package/lib/kernel-env.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as resolveKernelEnv, t as PACKAGE_ROOT } from "./kernel-env2.js";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { PACKAGE_ROOT, resolveKernelEnv };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
|
|
8
|
+
//#region src/kernel-env.ts
|
|
9
|
+
const exec = promisify(execFile);
|
|
10
|
+
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
function venvPython(dir) {
|
|
12
|
+
return join(dir, process.platform === "win32" ? "Scripts/python.exe" : "bin/python");
|
|
13
|
+
}
|
|
14
|
+
function activate(dir) {
|
|
15
|
+
const bin = dirname(venvPython(dir));
|
|
16
|
+
return {
|
|
17
|
+
...process.env,
|
|
18
|
+
VIRTUAL_ENV: dir,
|
|
19
|
+
PATH: [bin, process.env.PATH].filter(Boolean).join(delimiter)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function explicitPath(python, cwd) {
|
|
23
|
+
const expanded = python === "~" ? homedir() : python.startsWith("~/") ? join(homedir(), python.slice(2)) : python;
|
|
24
|
+
return isAbsolute(expanded) || /[/\\]/.test(expanded) ? resolve(cwd, expanded) : expanded;
|
|
25
|
+
}
|
|
26
|
+
async function probe(python, env, cwd) {
|
|
27
|
+
const { stdout } = await exec(python, ["-c", "import ast, asyncio, json, sys; assert sys.version_info >= (3, 9), \"Packaged dill checkpoints require Python >=3.9\"; print(json.dumps({\"python\": sys.executable, \"version\": sys.version.split()[0]}))"], {
|
|
28
|
+
timeout: 15e3,
|
|
29
|
+
cwd,
|
|
30
|
+
env: {
|
|
31
|
+
...env,
|
|
32
|
+
PYTHONDONTWRITEBYTECODE: "1"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const result = JSON.parse(stdout.trim());
|
|
36
|
+
if (!isAbsolute(result.python) || !result.version) throw new Error("Interpreter did not report an absolute executable and version");
|
|
37
|
+
return {
|
|
38
|
+
...result,
|
|
39
|
+
env
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function resolveKernelEnv(options = {}) {
|
|
43
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
44
|
+
if (options.python) {
|
|
45
|
+
const python = explicitPath(options.python, cwd);
|
|
46
|
+
const venv$1 = dirname(dirname(python));
|
|
47
|
+
const env = isAbsolute(python) && existsSync(join(venv$1, "pyvenv.cfg")) ? activate(venv$1) : { ...process.env };
|
|
48
|
+
try {
|
|
49
|
+
return await probe(python, env, cwd);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error(`Could not use configured Python ${JSON.stringify(options.python)}: ${error instanceof Error ? error.message : String(error)}. Configure python with a working Python >=3.9 interpreter.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const active = process.env.VIRTUAL_ENV || process.env.CONDA_PREFIX;
|
|
55
|
+
const project = [join(cwd, ".venv"), join(cwd, "venv")].find(existsSync);
|
|
56
|
+
const venv = active || project;
|
|
57
|
+
const candidates = [];
|
|
58
|
+
if (venv && existsSync(venvPython(venv))) candidates.push({
|
|
59
|
+
python: venvPython(venv),
|
|
60
|
+
env: activate(venv)
|
|
61
|
+
});
|
|
62
|
+
for (const python of ["python3", "python"]) candidates.push({
|
|
63
|
+
python,
|
|
64
|
+
env: { ...process.env }
|
|
65
|
+
});
|
|
66
|
+
const failures = [];
|
|
67
|
+
for (const candidate of candidates) try {
|
|
68
|
+
return await probe(candidate.python, candidate.env, cwd);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
failures.push(`${candidate.python}: ${error instanceof Error ? error.message : String(error)}`);
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`No working Python interpreter found. Tried: ${failures.join("; ")}. Install Python >=3.9 on PATH (python3 or python), or configure python with an existing interpreter. Better does not install Python automatically.`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { resolveKernelEnv as n, PACKAGE_ROOT as t };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as primaryServerForFile, c as serversForFile, i as installServer, n as findWorkspaceRoot, o as resolveCommandPath, r as installHintFor, s as serverByName, t as clearCommandProbeCache } from "./lsp-server-registry
|
|
1
|
+
import { a as primaryServerForFile, c as serversForFile, i as installServer, n as findWorkspaceRoot, o as resolveCommandPath, r as installHintFor, s as serverByName, t as clearCommandProbeCache } from "./lsp-server-registry.js";
|
|
2
2
|
|
|
3
3
|
export { clearCommandProbeCache, findWorkspaceRoot, installHintFor, installServer, primaryServerForFile, resolveCommandPath, serverByName, serversForFile };
|
|
@@ -5,11 +5,11 @@ import childProcess, { execFile, execSync, spawn, spawnSync } from "node:child_p
|
|
|
5
5
|
import * as http from "node:http";
|
|
6
6
|
import readline from "node:readline";
|
|
7
7
|
import { URL as URL$1, urlToHttpOptions } from "node:url";
|
|
8
|
+
import os from "node:os";
|
|
8
9
|
import { debuglog, promisify } from "node:util";
|
|
9
10
|
import { mkdir, readdir, symlink, unlink } from "node:fs/promises";
|
|
10
11
|
import { pipeline } from "node:stream/promises";
|
|
11
12
|
import { Writable } from "node:stream";
|
|
12
|
-
import os from "node:os";
|
|
13
13
|
import { EventEmitter } from "node:events";
|
|
14
14
|
import * as https from "node:https";
|
|
15
15
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as Browser, a as TimeoutError, b as ChromeReleaseChannel, c as computeSystemExecutablePath, d as InstalledBrowser, f as detectBrowserPlatform, g as resolveDefaultUserDataDir, h as resolveBuildId, i as Process, l as launch, m as getVersionComparator, n as uninstall, o as WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, p as createProfile, r as CDP_WEBSOCKET_ENDPOINT_REGEX, s as computeExecutablePath, t as getInstalledBrowsers, u as Cache, v as BrowserPlatform, y as BrowserTag } from "./main
|
|
1
|
+
import { _ as Browser, a as TimeoutError, b as ChromeReleaseChannel, c as computeSystemExecutablePath, d as InstalledBrowser, f as detectBrowserPlatform, g as resolveDefaultUserDataDir, h as resolveBuildId, i as Process, l as launch, m as getVersionComparator, n as uninstall, o as WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, p as createProfile, r as CDP_WEBSOCKET_ENDPOINT_REGEX, s as computeExecutablePath, t as getInstalledBrowsers, u as Cache, v as BrowserPlatform, y as BrowserTag } from "./main.js";
|
|
2
2
|
|
|
3
3
|
export { Browser, BrowserPlatform, BrowserTag, CDP_WEBSOCKET_ENDPOINT_REGEX, Cache, ChromeReleaseChannel, InstalledBrowser, Process, TimeoutError, WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, computeExecutablePath, computeSystemExecutablePath, createProfile, detectBrowserPlatform, getInstalledBrowsers, getVersionComparator, launch, resolveBuildId, resolveDefaultUserDataDir, uninstall };
|
package/lib/mobile/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Schema } from "../
|
|
2
|
-
import { r as MobileConfig } from "../web-
|
|
1
|
+
import { t as Schema } from "../index2.js";
|
|
2
|
+
import { r as MobileConfig } from "../web-trust2.js";
|
|
3
3
|
import { Context } from "@deepseek-ai/cordis";
|
|
4
4
|
|
|
5
5
|
//#region src/mobile/plugin.d.ts
|
package/lib/mobile/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Schema } from "../lib
|
|
2
|
-
import { r as buildMobileScript } from "../web-
|
|
1
|
+
import { t as Schema } from "../lib.js";
|
|
2
|
+
import { r as buildMobileScript } from "../web-trust2.js";
|
|
3
3
|
import { Context } from "@deepseek-ai/cordis";
|
|
4
4
|
|
|
5
5
|
//#region src/mobile/plugin.ts
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { _ as Browser$1, a as TimeoutError$1, c as computeSystemExecutablePath, f as detectBrowserPlatform, h as resolveBuildId, l as launch$1, n as uninstall, o as WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, p as createProfile, r as CDP_WEBSOCKET_ENDPOINT_REGEX, s as computeExecutablePath, t as getInstalledBrowsers } from "./main
|
|
2
|
-
import { C as unitToPixels, Ct as getCapturedLogs, E as paperFormats, F as bufferCount, J as fromEvent, K as firstValueFrom, M as assert, Q as map, S as timeout, St as debug, T as withSourcePuppeteerURLIfNone, Tt as environment, W as filter, Z as lastValueFrom, _ as isNumber, _t as PuppeteerError, a as UTILITY_WORLD_NAME, at as race, b as isString, bt as TouchError, c as evaluationString, d as fromEmitterEvent, dt as takeUntil, f as getReadableAsTypedArray, ft as tap, g as isDate, gt as ProtocolError, h as getSourceUrlComment, ht as ConnectionClosedError, i as SOURCE_URL_REGEX, l as filterAsync, m as getSourcePuppeteerURLIfAvailable, mt as timer, n as NETWORK_IDLE_TIME, o as debugCatchError, p as getReadableFromProtocolStream, q as from, r as PuppeteerURL, s as debugError, t as DEFAULT_VIEWPORT, u as fromAbortSignal, v as isPlainObject, vt as TargetCloseError, w as validateDialogType, wt as setLogCapture, x as parsePDFOptions, xt as UnsupportedOperation, y as isRegExp, yt as TimeoutError, z as concatMap } from "./util
|
|
3
|
-
import { $ as pageBindingInitString, $n as Deferred, $t as scriptInjector, A as NetworkManager, An as guarded, At as DEFAULT_INTERCEPT_RESOLUTION_PRIORITY, B as MAIN_WORLD, Bn as AsyncDisposableStack, Bt as throwIfDetached, C as WebMCPToolCall, Cn as NodeLocator, Ct as WebWorkerEvent, D as CdpTouchscreen, Dn as DeviceRequestPrompt, Dt as normalizeHeaderValue, E as CdpTouchHandle, En as TimeoutSettings, Et as WaitTask, F as CdpFrame, Fn as Browser, Ft as headersArray, G as CdpJSHandle, Gn as asyncDisposeSymbol, Gt as XPathQueryHandler, H as FrameManagerEvent, Hn as DisposableStack, Ht as bindIsolatedHandle, I as referrerPolicyToProtocol, In as WEB_PERMISSION_TO_PROTOCOL_PERMISSION, It as Dialog, J as addPageBinding, Jn as CallbackRegistry, Jt as PQueryHandler, K as releaseObject, Kn as disposeSymbol, Kt as TextQueryHandler, L as LifecycleWatcher, Ln as CDPSession, Lt as Accessibility, M as CdpHTTPResponse, Mt as InterceptResolutionAction, N as CdpHTTPRequest, Nt as STATUS_TEXTS, O as _keyDefinitions, On as BrowserContext, Ot as SecurityDetails, P as FrameTree, Pn as Mutex, Pt as handleError, Q as createEvaluationError, Qn as rewriteError, Qt as ScriptInjector, R as IsolatedWorld, Rn as CDPSessionEvent, Rt as Frame, S as WebMCPTool, Sn as MappedLocator, St as WebWorker, T as CdpMouse, Tn as RaceLocator, Tt as TaskManager, U as ExecutionContext, Un as DisposableStackPolyfill, Ut as JSHandle, V as PUPPETEER_WORLD, Vn as AsyncDisposableStackPolyfill, Vt as ElementHandle, W as CdpElementHandle, Wn as SuppressedError, Wt as getQueryHandlerAndSelector, X as createClientError, Xn as isErrnoException, Xt as CustomQueryHandlerRegistry, Y as convertConsoleMessageLevel, Yn as createProtocolErrorMessage, Yt as PierceQueryHandler, Z as createConsoleMessage, Zn as isErrorLike, Zt as customQueryHandlers, _ as CdpBrowserContext, _n as DelegatedLocator, _t as Mouse, a as KnownDevices, at as CdpPreloadScript, b as convertSameSiteFromPuppeteerToCdp, bn as Locator, bt as createIncrementalIdGenerator, c as _connectToCdpBrowser, cn as Tracing, ct as isTargetClosedError, d as CdpTarget, dn as CSSCoverage, dt as ConsoleMessage, en as ARIAQueryHandler, et as valueFromJSHandle, f as DevToolsTarget, fn as Coverage, ft as CdpBluetoothEmulation, g as WorkerTarget, gn as supportedMetrics, gt as Keyboard, h as PageTarget, hn as setDefaultScreenshotOptions, ht as TargetType, i as assertSupportedUrlRestrictions, it as CdpDeviceRequestPromptManager, j as NetworkEventManager, jt as HTTPRequest, k as FrameManager, kt as HTTPResponse, l as CdpBrowser, ln as EmulatedState, lt as CdpCDPSession, m as OtherTarget, mn as Page, mt as Target, n as TaskQueue, nn as LazyArg, nt as valueFromRemoteObjectReference, o as PredefinedNetworkConditions, on as AsyncIterableUtil, ot as CdpDialog, p as InitializationStatus, pn as JSCoverage, pt as Binding, q as CDP_BINDING_PREFIX, qn as Callback, qt as parsePSelectors, r as Puppeteer, rn as transposeIterableHandle, rt as CdpDeviceRequestPrompt, s as ExtensionTransport, sn as FileChooser, st as Connection, t as PUPPETEER_REVISIONS, tn as QueryHandler, tt as valueFromPrimitiveRemoteObject, u as TargetManager, un as EmulationManager, ut as NetworkManagerEvent, v as CdpPage, vn as FilteredLocator, vt as MouseButton, w as CdpKeyboard, wn as RETRY_DELAY, wt as Realm, x as WebMCP, xn as LocatorEvent, xt as Extension, y as convertCookiesPartitionKeyFromPuppeteerToCdp, yn as FunctionLocator, yt as Touchscreen, z as CdpWebWorker, zn as EventEmitter, zt as FrameEvent } from "./index-browser
|
|
4
|
-
import { t as BrowserWebSocketTransport } from "./
|
|
5
|
-
import { t as convertPuppeteerChannelToBrowsersChannel } from "./
|
|
6
|
-
import { t as NodeWebSocketTransport } from "./NodeWebSocketTransport
|
|
1
|
+
import { _ as Browser$1, a as TimeoutError$1, c as computeSystemExecutablePath, f as detectBrowserPlatform, h as resolveBuildId, l as launch$1, n as uninstall, o as WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, p as createProfile, r as CDP_WEBSOCKET_ENDPOINT_REGEX, s as computeExecutablePath, t as getInstalledBrowsers } from "./main.js";
|
|
2
|
+
import { C as unitToPixels, Ct as getCapturedLogs, E as paperFormats, F as bufferCount, J as fromEvent, K as firstValueFrom, M as assert, Q as map, S as timeout, St as debug, T as withSourcePuppeteerURLIfNone, Tt as environment, W as filter, Z as lastValueFrom, _ as isNumber, _t as PuppeteerError, a as UTILITY_WORLD_NAME, at as race, b as isString, bt as TouchError, c as evaluationString, d as fromEmitterEvent, dt as takeUntil, f as getReadableAsTypedArray, ft as tap, g as isDate, gt as ProtocolError, h as getSourceUrlComment, ht as ConnectionClosedError, i as SOURCE_URL_REGEX, l as filterAsync, m as getSourcePuppeteerURLIfAvailable, mt as timer, n as NETWORK_IDLE_TIME, o as debugCatchError, p as getReadableFromProtocolStream, q as from, r as PuppeteerURL, s as debugError, t as DEFAULT_VIEWPORT, u as fromAbortSignal, v as isPlainObject, vt as TargetCloseError, w as validateDialogType, wt as setLogCapture, x as parsePDFOptions, xt as UnsupportedOperation, y as isRegExp, yt as TimeoutError, z as concatMap } from "./util.js";
|
|
3
|
+
import { $ as pageBindingInitString, $n as Deferred, $t as scriptInjector, A as NetworkManager, An as guarded, At as DEFAULT_INTERCEPT_RESOLUTION_PRIORITY, B as MAIN_WORLD, Bn as AsyncDisposableStack, Bt as throwIfDetached, C as WebMCPToolCall, Cn as NodeLocator, Ct as WebWorkerEvent, D as CdpTouchscreen, Dn as DeviceRequestPrompt, Dt as normalizeHeaderValue, E as CdpTouchHandle, En as TimeoutSettings, Et as WaitTask, F as CdpFrame, Fn as Browser, Ft as headersArray, G as CdpJSHandle, Gn as asyncDisposeSymbol, Gt as XPathQueryHandler, H as FrameManagerEvent, Hn as DisposableStack, Ht as bindIsolatedHandle, I as referrerPolicyToProtocol, In as WEB_PERMISSION_TO_PROTOCOL_PERMISSION, It as Dialog, J as addPageBinding, Jn as CallbackRegistry, Jt as PQueryHandler, K as releaseObject, Kn as disposeSymbol, Kt as TextQueryHandler, L as LifecycleWatcher, Ln as CDPSession, Lt as Accessibility, M as CdpHTTPResponse, Mt as InterceptResolutionAction, N as CdpHTTPRequest, Nt as STATUS_TEXTS, O as _keyDefinitions, On as BrowserContext, Ot as SecurityDetails, P as FrameTree, Pn as Mutex, Pt as handleError, Q as createEvaluationError, Qn as rewriteError, Qt as ScriptInjector, R as IsolatedWorld, Rn as CDPSessionEvent, Rt as Frame, S as WebMCPTool, Sn as MappedLocator, St as WebWorker, T as CdpMouse, Tn as RaceLocator, Tt as TaskManager, U as ExecutionContext, Un as DisposableStackPolyfill, Ut as JSHandle, V as PUPPETEER_WORLD, Vn as AsyncDisposableStackPolyfill, Vt as ElementHandle, W as CdpElementHandle, Wn as SuppressedError, Wt as getQueryHandlerAndSelector, X as createClientError, Xn as isErrnoException, Xt as CustomQueryHandlerRegistry, Y as convertConsoleMessageLevel, Yn as createProtocolErrorMessage, Yt as PierceQueryHandler, Z as createConsoleMessage, Zn as isErrorLike, Zt as customQueryHandlers, _ as CdpBrowserContext, _n as DelegatedLocator, _t as Mouse, a as KnownDevices, at as CdpPreloadScript, b as convertSameSiteFromPuppeteerToCdp, bn as Locator, bt as createIncrementalIdGenerator, c as _connectToCdpBrowser, cn as Tracing, ct as isTargetClosedError, d as CdpTarget, dn as CSSCoverage, dt as ConsoleMessage, en as ARIAQueryHandler, et as valueFromJSHandle, f as DevToolsTarget, fn as Coverage, ft as CdpBluetoothEmulation, g as WorkerTarget, gn as supportedMetrics, gt as Keyboard, h as PageTarget, hn as setDefaultScreenshotOptions, ht as TargetType, i as assertSupportedUrlRestrictions, it as CdpDeviceRequestPromptManager, j as NetworkEventManager, jt as HTTPRequest, k as FrameManager, kt as HTTPResponse, l as CdpBrowser, ln as EmulatedState, lt as CdpCDPSession, m as OtherTarget, mn as Page, mt as Target, n as TaskQueue, nn as LazyArg, nt as valueFromRemoteObjectReference, o as PredefinedNetworkConditions, on as AsyncIterableUtil, ot as CdpDialog, p as InitializationStatus, pn as JSCoverage, pt as Binding, q as CDP_BINDING_PREFIX, qn as Callback, qt as parsePSelectors, r as Puppeteer, rn as transposeIterableHandle, rt as CdpDeviceRequestPrompt, s as ExtensionTransport, sn as FileChooser, st as Connection, t as PUPPETEER_REVISIONS, tn as QueryHandler, tt as valueFromPrimitiveRemoteObject, u as TargetManager, un as EmulationManager, ut as NetworkManagerEvent, v as CdpPage, vn as FilteredLocator, vt as MouseButton, w as CdpKeyboard, wn as RETRY_DELAY, wt as Realm, x as WebMCP, xn as LocatorEvent, xt as Extension, y as convertCookiesPartitionKeyFromPuppeteerToCdp, yn as FunctionLocator, yt as Touchscreen, z as CdpWebWorker, zn as EventEmitter, zt as FrameEvent } from "./index-browser.js";
|
|
4
|
+
import { t as BrowserWebSocketTransport } from "./BrowserWebSocketTransport2.js";
|
|
5
|
+
import { t as convertPuppeteerChannelToBrowsersChannel } from "./LaunchOptions2.js";
|
|
6
|
+
import { t as NodeWebSocketTransport } from "./NodeWebSocketTransport.js";
|
|
7
7
|
import fs, { existsSync } from "node:fs";
|
|
8
8
|
import path, { dirname, join } from "node:path";
|
|
9
9
|
import { spawn, spawnSync } from "node:child_process";
|
|
10
|
+
import os, { tmpdir } from "node:os";
|
|
10
11
|
import { debuglog } from "node:util";
|
|
11
12
|
import { mkdtemp, rename, unlink } from "node:fs/promises";
|
|
12
13
|
import { PassThrough } from "node:stream";
|
|
13
|
-
import os, { tmpdir } from "node:os";
|
|
14
14
|
|
|
15
15
|
//#region node_modules/puppeteer-core/lib/puppeteer/node-env-setup.js
|
|
16
16
|
environment.value = {
|
|
@@ -240,7 +240,7 @@ var BrowserLauncher = class {
|
|
|
240
240
|
const bidiOnly = process.env["PUPPETEER_WEBDRIVER_BIDI_ONLY"] === "true";
|
|
241
241
|
const BiDi = await import(
|
|
242
242
|
/* webpackIgnore: true */
|
|
243
|
-
"./bidi
|
|
243
|
+
"./bidi.js"
|
|
244
244
|
);
|
|
245
245
|
const bidiConnection = await BiDi.connectBidiOverCdp(cdpConnection);
|
|
246
246
|
return await BiDi.BidiBrowser.create({
|
|
@@ -262,7 +262,7 @@ var BrowserLauncher = class {
|
|
|
262
262
|
const transport = await NodeWebSocketTransport.create(browserWSEndpoint);
|
|
263
263
|
const BiDi = await import(
|
|
264
264
|
/* webpackIgnore: true */
|
|
265
|
-
"./bidi
|
|
265
|
+
"./bidi.js"
|
|
266
266
|
);
|
|
267
267
|
const bidiConnection = new BiDi.BidiConnection(browserWSEndpoint, transport, opts.idGenerator, opts.slowMo, opts.protocolTimeout);
|
|
268
268
|
return await BiDi.BidiBrowser.create({
|
package/lib/py-sdk.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"name": "superd-run",
|
|
4
|
+
"ver": "0.3.1-d.b596",
|
|
5
|
+
"protocol": 1,
|
|
6
|
+
"targets": {
|
|
7
|
+
"aarch64-apple-darwin": {
|
|
8
|
+
"file": "superd-run",
|
|
9
|
+
"bytes": 337808,
|
|
10
|
+
"sha256": "a8fd11a5e6a2cb146deb599414434a299ebf78c53cfc1d3e5f42617ee11c1706"
|
|
11
|
+
},
|
|
12
|
+
"aarch64-unknown-linux-musl": {
|
|
13
|
+
"file": "superd-run",
|
|
14
|
+
"bytes": 397592,
|
|
15
|
+
"sha256": "3a8660fa099f1e71de6e08313ee2aaace00503f74365475ee46e2d2a89228397"
|
|
16
|
+
},
|
|
17
|
+
"x86_64-pc-windows-gnu": {
|
|
18
|
+
"file": "superd-run.exe",
|
|
19
|
+
"bytes": 337408,
|
|
20
|
+
"sha256": "1372450238c5bda702b4529f4148aa79e80a255c3c125d1a6229afd4693e9d90"
|
|
21
|
+
},
|
|
22
|
+
"x86_64-unknown-linux-musl": {
|
|
23
|
+
"file": "superd-run",
|
|
24
|
+
"bytes": 447152,
|
|
25
|
+
"sha256": "05b428657942abf22a0ad609433d5cab6b6182fe389851345459a0274b5a6533"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"sources": {
|
|
29
|
+
"Cargo.toml": "129ab8360e9da872f9dfd6e713d81fe1389735a74d781f3d9c15e110f92d2757",
|
|
30
|
+
"build.rs": "c4fb356956b1ec700e99bdeca07d657a7d3b2a4026582db136411676da3d125e",
|
|
31
|
+
"src/main.rs": "47f1648ea1abc30583839edab219a9062c83d57be981c0505ab6bf79c6fbff54",
|
|
32
|
+
"src/unix.rs": "56c5f523b7b1a9efd50ef24ccdabc024bc065dd2f904fdbecdf0ca49fe7f3393",
|
|
33
|
+
"src/windows.rs": "6c1537424b1adc05ed17c7cf8bf376fb5711602b9da1697d596155bf21d541da"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.3.1-d.b596
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.3.1-d.b596
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.3.1-d.b596
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.3.1-d.b596
|
|
Binary file
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Hub PTY pump — the DUMB child of the canonical PTY session over a Hub
|
|
3
|
+
// machine (0.3.2-c). The session (better-dsh/src/remote/pty-session.ts)
|
|
4
|
+
// spawns `script -qfec 'stty -echo; … exec node <this file>' /dev/null`, so
|
|
5
|
+
// this process's stdin/stdout ride a host-side PTY; we forward those bytes
|
|
6
|
+
// over one WebSocket to the peer hub's dumb PTY executor
|
|
7
|
+
// (/api/superd/exec/pty: one WS = one `script -qfec bash /dev/null`, text
|
|
8
|
+
// frames = stream bytes, {"op":…} JSON frames = transport control, WS close
|
|
9
|
+
// = peer group-kill). All session intelligence (nonce framing, init
|
|
10
|
+
// handshake, env E-frames, two-stage interrupt, idle TTL) is in-band bytes
|
|
11
|
+
// produced by the SESSION — this pump never parses the stream, only the
|
|
12
|
+
// peer's control frames.
|
|
13
|
+
//
|
|
14
|
+
// Connection facts arrive via environment (never argv — credentials must not
|
|
15
|
+
// show up in `ps`):
|
|
16
|
+
// SUPERD_HUB_PTY_URL wss://…/api/superd/exec/pty (peer executor)
|
|
17
|
+
// SUPERD_HUB_PTY_COOKIE pairing cookie for the upgrade request
|
|
18
|
+
// SUPERD_HUB_PTY_WS ABSOLUTE path to a usable `ws` module (resolved by
|
|
19
|
+
// the caller before spawning; no resolution gamble
|
|
20
|
+
// here — a missing module is a creation-time error)
|
|
21
|
+
//
|
|
22
|
+
// Verbatim-asset discipline (helper-bin precedent): this file is copied
|
|
23
|
+
// byte-for-byte into lib/remote/ and the Super closure; no build step
|
|
24
|
+
// transforms it. Crash-proof by construction (mesh-gateway lesson): the
|
|
25
|
+
// 'error' listener is registered before anything can reject, and post-close
|
|
26
|
+
// sends are swallowed — the session's death path owns the teardown.
|
|
27
|
+
const PUMP_ENV_PREFIX = 'SUPERD_HUB_PTY_'
|
|
28
|
+
const [url, cookie, wsPath] = ['URL', 'COOKIE', 'WS'].map((k) => process.env[`SUPERD_HUB_PTY_${k}`])
|
|
29
|
+
|
|
30
|
+
// cookie may be legitimately empty (an unauthenticated test lane sends no header);
|
|
31
|
+
// the endpoint URL and the ws module path are the hard requirements.
|
|
32
|
+
if (url === undefined || url === '' || wsPath === undefined || wsPath === '') {
|
|
33
|
+
process.stderr.write(`hub-pty-pump: missing environment (${PUMP_ENV_PREFIX}URL/WS)\n`)
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let WebSocket
|
|
38
|
+
try {
|
|
39
|
+
const require = (await import('node:module')).createRequire(import.meta.url)
|
|
40
|
+
const mod = require(wsPath)
|
|
41
|
+
WebSocket = typeof mod === 'function' ? mod : mod.default
|
|
42
|
+
} catch (err) {
|
|
43
|
+
process.stderr.write(`hub-pty-pump: cannot load ws module at ${wsPath} — ${err instanceof Error ? err.message : String(err)}\n`)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
if (typeof WebSocket !== 'function') {
|
|
47
|
+
process.stderr.write('hub-pty-pump: the ws module did not yield a WebSocket constructor\n')
|
|
48
|
+
process.exit(1)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const socket = new WebSocket(url, { headers: cookie ? { cookie } : {} })
|
|
52
|
+
let opened = false
|
|
53
|
+
let forward = true
|
|
54
|
+
|
|
55
|
+
socket.on('error', (err) => {
|
|
56
|
+
// Always-on listener: an ECONNREFUSED or a rejected 401 upgrade must be a
|
|
57
|
+
// reported death, never an uncaught exception.
|
|
58
|
+
process.stderr.write(`hub-pty-pump: ${opened ? 'socket error' : 'connect failed'} — ${err instanceof Error ? err.message : String(err)}\n`)
|
|
59
|
+
})
|
|
60
|
+
socket.on('open', () => { opened = true; pumpStdin() })
|
|
61
|
+
socket.on('message', (data) => {
|
|
62
|
+
if (!forward) return
|
|
63
|
+
const text = typeof data === 'string' ? data : Array.isArray(data) ? Buffer.concat(data).toString('utf8') : Buffer.from(data).toString('utf8')
|
|
64
|
+
// Transport control frames (peer: {"op":"exit"} / {"op":"spawn-error"}) are
|
|
65
|
+
// addressed to THIS pump, not to the shell stream — the exit frame is
|
|
66
|
+
// followed by a socket close, which settles us below.
|
|
67
|
+
if (text.startsWith('{"op":')) {
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(text)
|
|
70
|
+
if (typeof parsed.op === 'string') {
|
|
71
|
+
if (parsed.op === 'spawn-error' && typeof parsed.error === 'string') process.stderr.write(`hub-pty-pump: peer could not spawn the terminal — ${parsed.error}\n`)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
} catch { /* not JSON after all: fall through and forward */ }
|
|
75
|
+
}
|
|
76
|
+
process.stdout.write(text)
|
|
77
|
+
})
|
|
78
|
+
socket.on('close', () => {
|
|
79
|
+
forward = false
|
|
80
|
+
// Before open this is a failed connection (diag already on stderr); after
|
|
81
|
+
// open it is the peer session ending — either way the child exiting is the
|
|
82
|
+
// session's dead signal.
|
|
83
|
+
process.exit(opened ? 0 : 1)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
function pumpStdin() {
|
|
87
|
+
process.stdin.setEncoding('utf8')
|
|
88
|
+
process.stdin.on('data', (chunk) => {
|
|
89
|
+
if (!opened) return
|
|
90
|
+
try { socket.send(chunk) } catch { /* closing: the close handler exits us */ }
|
|
91
|
+
})
|
|
92
|
+
// The session's kill path tears down the process group; a plain stdin end
|
|
93
|
+
// (no kill) still means nobody will type more — close politely so the peer
|
|
94
|
+
// reaps its side.
|
|
95
|
+
process.stdin.on('end', () => { try { socket.close() } catch { /* already closing */ } })
|
|
96
|
+
process.stdin.on('error', () => { /* EPIPE on teardown: the close path owns the exit */ })
|
|
97
|
+
}
|