better-dsh 0.3.0 → 0.3.1-a

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.
Files changed (76) hide show
  1. package/README.md +49 -177
  2. package/cordis.patch.yml +5 -36
  3. package/docs/20_specs/kernel-provisioning/spec.md +2 -0
  4. package/docs/adr/0015-independent-bundles-agent-remote.md +40 -0
  5. package/docs/remote-tools.md +56 -0
  6. package/docs/specs/kernel-provisioning/spec.md +12 -40
  7. package/docs/specs/omp-python-repl-port/runtime-guide.md +35 -0
  8. package/docs/specs/omp-python-repl-port/spec.md +68 -0
  9. package/docs/specs/remote-tool-enhancement/spec.md +203 -0
  10. package/dsh-docs/baseline.md +13 -0
  11. package/dsh-docs/subsystems/invariants.md +3 -0
  12. package/dsh-docs/subsystems/invariants.zh.md +3 -0
  13. package/eval-description.md +7 -3
  14. package/lib/LaunchOptions-0Mr6meJc.js +4 -0
  15. package/lib/{LaunchOptions-kGXcZOe0.js → LaunchOptions-iE9M-STS.js} +1 -1
  16. package/lib/{bidi-BalpKaJc.js → bidi-CaQeBZHY.js} +1 -1
  17. package/lib/client/index.js +30 -6
  18. package/lib/failover/index.js +1 -1
  19. package/lib/fs-aware/sandbox-plugin.js +3 -3
  20. package/lib/{index-browser-CysrjMyM.js → index-browser-CJzxT9Vi.js} +4 -4
  21. package/lib/index.d.ts +16 -50
  22. package/lib/index.js +482 -1720
  23. package/lib/kernel-env-x_WkG6Fr.js +76 -0
  24. package/lib/kernel-env.d.ts +5 -69
  25. package/lib/kernel-env.js +2 -2
  26. package/lib/{lsp-server-registry-BXvUTBY7.js → lsp-server-registry-BcdkHROD.js} +1 -1
  27. package/lib/{lsp-server-registry-CH9WNFFt.js → lsp-server-registry-D4VLs1Sm.js} +1 -1
  28. package/lib/{main-BQeFrBM1.js → main-taSMz1KX.js} +1 -1
  29. package/lib/{main-CupOhMp5.js → main-uqGqYYnA.js} +7 -5
  30. package/lib/mobile/plugin.d.ts +1 -1
  31. package/lib/omp-python/DILL-LICENSE +35 -0
  32. package/lib/omp-python/OMP-LICENSE +23 -0
  33. package/lib/omp-python/better_snapshot.py +391 -0
  34. package/lib/omp-python/better_support.py +425 -0
  35. package/lib/omp-python/dill-provenance.json +55 -0
  36. package/lib/omp-python/provenance.json +13 -0
  37. package/lib/omp-python/runner.py +2499 -0
  38. package/lib/omp-python/vendor/dill/__diff.py +234 -0
  39. package/lib/omp-python/vendor/dill/__info__.py +291 -0
  40. package/lib/omp-python/vendor/dill/__init__.py +119 -0
  41. package/lib/omp-python/vendor/dill/_dill.py +2265 -0
  42. package/lib/omp-python/vendor/dill/_objects.py +545 -0
  43. package/lib/omp-python/vendor/dill/_shims.py +193 -0
  44. package/lib/omp-python/vendor/dill/detect.py +287 -0
  45. package/lib/omp-python/vendor/dill/logger.py +285 -0
  46. package/lib/omp-python/vendor/dill/objtypes.py +24 -0
  47. package/lib/omp-python/vendor/dill/pointers.py +122 -0
  48. package/lib/omp-python/vendor/dill/session.py +612 -0
  49. package/lib/omp-python/vendor/dill/settings.py +25 -0
  50. package/lib/omp-python/vendor/dill/source.py +1025 -0
  51. package/lib/omp-python/vendor/dill/temp.py +252 -0
  52. package/lib/{puppeteer-core-CSk2PtSm.js → puppeteer-core-C-4NyOpY.js} +8 -8
  53. package/lib/remote/plugin.d.ts +459 -5
  54. package/lib/remote/plugin.js +2389 -210
  55. package/lib/url-schemes/index.d.ts +11 -11
  56. package/lib/url-schemes/index.js +11 -11
  57. package/lib/web-password.d.ts +8 -8
  58. package/lib/web-password.js +5 -1
  59. package/lib/{web-trust-Dej_RI2B.d.ts → web-trust-C_Y6o8Z2.d.ts} +11 -11
  60. package/lib/web-trust.d.ts +1 -2
  61. package/lib/welcome-notice.d.ts +5 -7
  62. package/lib/welcome-notice.js +9 -48
  63. package/lib/{wrap-T4I0nfPM.js → wrap-0VA0uFx8.js} +1 -1
  64. package/package.json +7 -24
  65. package/scripts/kernel-check.mjs +5 -0
  66. package/lib/LaunchOptions-B874eBu2.js +0 -4
  67. package/lib/bundle-delivery.d.ts +0 -20
  68. package/lib/bundle-delivery.js +0 -209
  69. package/lib/hmr.d.ts +0 -32
  70. package/lib/hmr.js +0 -49
  71. package/lib/kernel-bridge.py +0 -172
  72. package/lib/kernel-env-D8UOWeji.js +0 -195
  73. package/lib/webserver.d.ts +0 -10
  74. package/lib/webserver.js +0 -19
  75. package/scripts/kernel-provision.mjs +0 -35
  76. package/scripts/register-bundle.mjs +0 -80
@@ -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,80 +1,16 @@
1
1
  //#region src/kernel-env.d.ts
2
- /**
3
- * Kernel environment resolution and provisioning.
4
- *
5
- * The runtime OWNS the interpreter it spawns: it never trusts a bare
6
- * `python3` on the PATH, because that interpreter may lack `ipykernel`
7
- * (hard failure — the kernel cannot start) or `dill` (snapshot capability —
8
- * silently degrading to no snapshots). Instead it resolves one of two
9
- * environments:
10
- *
11
- * - **Explicit** — `config.python` names a real interpreter (a path, or any
12
- * name other than the bare-`python3` sentinel the default/patch produce).
13
- * It is probed, and a missing `ipykernel` is a loud error while a missing
14
- * `dill` is a loud warning (snapshots disabled).
15
- * - **Managed** — no explicit interpreter: the runtime provisions a venv
16
- * UNDER THE PACKAGE (`<packageRoot>/.venv-kernel`, or `config.kernelEnvDir`)
17
- * with `ipykernel` + `dill`, installing it on first use when
18
- * `config.kernelAutoInstall` is on. The venv lives beside the package, NOT
19
- * in `/tmp` (the pre-v0.1.9 dangling-symlink failure mode), so it survives
20
- * the host's tmp reaper and the process restart.
21
- *
22
- * Provisioning uses `uv` when available (fast, can fetch the pinned CPython
23
- * version), falling back to `python3 -m venv` + `ensurepip`. It is idempotent:
24
- * a complete venv is reused untouched; a partial one is repaired.
25
- * @module dashr/kernel-env
26
- */
27
- /** The installed package root (where `lib/` and `src/` live): the default home of the managed venv. */
28
2
  declare const PACKAGE_ROOT: string;
29
- /** The config value meaning "no explicit interpreter — auto-manage a venv". */
30
- declare const AUTO_PYTHON_SENTINEL = "python3";
31
- /** Preferred CPython version for a managed venv. */
32
- declare const DEFAULT_KERNEL_PYTHON_VERSION = "3.11";
33
- /** Pinned, tested `ipykernel` version (2026-09-02 tested value; upgrade = explicit change + regression). */
34
- declare const IPYKERNEL_VERSION = "7.3.0";
35
- /** Pinned, tested `dill` version. */
36
- declare const DILL_VERSION = "0.4.1";
37
3
  interface KernelEnv {
38
- /** Absolute path to the interpreter to spawn (`-m ipykernel_launcher`). */
39
4
  python: string;
40
- /** True when this runtime provisioned a venv (vs an explicit interpreter). */
41
- managed: boolean;
42
- /** The managed venv root, when {@link managed}. */
43
- venvDir: string | undefined;
44
- /** True when `dill` is importable — snapshot capability is available. */
45
- dill: boolean;
46
- /** True when `ipykernel` is importable (a hard requirement). */
47
- ipykernel: boolean;
48
- /** The interpreter's reported version, e.g. `3.11.15`. */
5
+ env: NodeJS.ProcessEnv;
49
6
  version: string;
50
7
  }
51
8
  interface ResolveKernelEnvOptions {
52
- /** `config.python`; the bare sentinel (or absent) selects a managed venv. */
9
+ /** An explicit path or executable name bypasses automatic discovery. */
53
10
  python?: string;
54
- /** Managed venv directory; defaults to `<packageRoot>/.venv-kernel`. */
55
- venvDir?: string;
56
- /** Preferred CPython version for the managed venv. */
57
- pythonVersion?: string;
58
- /** Provision the managed venv when missing/incomplete (default true). */
59
- autoInstall?: boolean;
60
- /** Logger callback (info on provisioning, warn on degraded snapshot). */
61
- log?: (level: 'info' | 'warn', message: string) => void;
11
+ /** Session workspace, used for existing project environments and relative paths. */
12
+ cwd?: string;
62
13
  }
63
- /** Tool-cache env for uv: caches live NEXT TO the venv (plugin territory), so a read-only home can never block provisioning. */
64
- declare function uvToolEnv(venvDir: string): NodeJS.ProcessEnv;
65
- /** uv venv arguments (pure; unit-tested). */
66
- declare function uvVenvArgs(venvDir: string, pythonVersion: string): string[];
67
- /** python3 -m venv fallback arguments (pure; cache-free by construction). */
68
- declare function venvFallbackArgs(venvDir: string): string[];
69
- /** uv pip install arguments with pinned versions (pure; unit-tested). */
70
- declare function uvInstallArgs(python: string): string[];
71
- /** pip install arguments with pinned versions for the venv interpreter (pure). */
72
- declare function pipInstallArgs(): string[];
73
- /**
74
- * Resolve the kernel interpreter, provisioning a managed venv when no
75
- * explicit interpreter is configured. Throws when the resolved interpreter
76
- * cannot run `ipykernel`; a missing `dill` only disables snapshots (warned).
77
- */
78
14
  declare function resolveKernelEnv(options?: ResolveKernelEnvOptions): Promise<KernelEnv>;
79
15
  //#endregion
80
- export { AUTO_PYTHON_SENTINEL, DEFAULT_KERNEL_PYTHON_VERSION, DILL_VERSION, IPYKERNEL_VERSION, KernelEnv, PACKAGE_ROOT, ResolveKernelEnvOptions, pipInstallArgs, resolveKernelEnv, uvInstallArgs, uvToolEnv, uvVenvArgs, venvFallbackArgs };
16
+ export { KernelEnv, PACKAGE_ROOT, ResolveKernelEnvOptions, resolveKernelEnv };
package/lib/kernel-env.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as PACKAGE_ROOT, c as uvInstallArgs, d as venvFallbackArgs, i as IPYKERNEL_VERSION, l as uvToolEnv, n as DEFAULT_KERNEL_PYTHON_VERSION, o as pipInstallArgs, r as DILL_VERSION, s as resolveKernelEnv, t as AUTO_PYTHON_SENTINEL, u as uvVenvArgs } from "./kernel-env-D8UOWeji.js";
1
+ import { n as resolveKernelEnv, t as PACKAGE_ROOT } from "./kernel-env-x_WkG6Fr.js";
2
2
 
3
- export { AUTO_PYTHON_SENTINEL, DEFAULT_KERNEL_PYTHON_VERSION, DILL_VERSION, IPYKERNEL_VERSION, PACKAGE_ROOT, pipInstallArgs, resolveKernelEnv, uvInstallArgs, uvToolEnv, uvVenvArgs, venvFallbackArgs };
3
+ export { PACKAGE_ROOT, resolveKernelEnv };
@@ -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-CH9WNFFt.js";
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-D4VLs1Sm.js";
2
2
 
3
3
  export { clearCommandProbeCache, findWorkspaceRoot, installHintFor, installServer, primaryServerForFile, resolveCommandPath, serverByName, serversForFile };
@@ -1,5 +1,5 @@
1
- import * as path$1 from "node:path";
2
1
  import { accessSync, constants, existsSync, readdirSync } from "node:fs";
2
+ import * as path$1 from "node:path";
3
3
 
4
4
  //#region src/devices/lsp/defaults.json
5
5
  var defaults_default = {
@@ -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-CupOhMp5.js";
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-uqGqYYnA.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 };
@@ -1,14 +1,16 @@
1
1
  import { createHash } from "node:crypto";
2
- import childProcess, { execFile, execSync, spawn, spawnSync } from "node:child_process";
3
- import { mkdir, readdir, unlink } from "node:fs/promises";
2
+ import fs, { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
4
3
  import path from "node:path";
4
+ import childProcess, { execFile, execSync, spawn, spawnSync } from "node:child_process";
5
+ import * as http from "node:http";
6
+ import readline from "node:readline";
5
7
  import { URL as URL$1, urlToHttpOptions } from "node:url";
6
- import fs, { accessSync, constants, existsSync, readFileSync } from "node:fs";
7
8
  import os from "node:os";
8
- import readline from "node:readline";
9
9
  import { debuglog, promisify } from "node:util";
10
+ import { mkdir, readdir, symlink, unlink } from "node:fs/promises";
11
+ import { pipeline } from "node:stream/promises";
12
+ import { Writable } from "node:stream";
10
13
  import { EventEmitter } from "node:events";
11
- import * as http from "node:http";
12
14
  import * as https from "node:https";
13
15
 
14
16
  //#region node_modules/@puppeteer/browsers/lib/browser-data/types.js
@@ -1,5 +1,5 @@
1
1
  import { t as Schema } from "../index-DTDXUe6m.js";
2
- import { r as MobileConfig } from "../web-trust-Dej_RI2B.js";
2
+ import { r as MobileConfig } from "../web-trust-C_Y6o8Z2.js";
3
3
  import { Context } from "@deepseek-ai/cordis";
4
4
 
5
5
  //#region src/mobile/plugin.d.ts
@@ -0,0 +1,35 @@
1
+ Copyright (c) 2004-2016 California Institute of Technology.
2
+ Copyright (c) 2016-2026 The Uncertainty Quantification Foundation.
3
+ All rights reserved.
4
+
5
+ This software is available subject to the conditions and terms laid
6
+ out below. By downloading and using this software you are agreeing
7
+ to the following conditions.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions
11
+ are met:
12
+
13
+ - Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ - Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in the
18
+ documentation and/or other materials provided with the distribution.
19
+
20
+ - Neither the names of the copyright holders nor the names of any of
21
+ the contributors may be used to endorse or promote products derived
22
+ from this software without specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
31
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mario Zechner
4
+ Copyright (c) 2025-2026 Can Bölük
5
+ Copyright (c) 2026 Stencil Labs, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.