better-dsh 0.3.0 → 0.3.1-b

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 (81) 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/omp-python/DILL-LICENSE +35 -0
  31. package/lib/omp-python/OMP-LICENSE +23 -0
  32. package/lib/omp-python/better_snapshot.py +391 -0
  33. package/lib/omp-python/better_support.py +425 -0
  34. package/lib/omp-python/dill-provenance.json +55 -0
  35. package/lib/omp-python/provenance.json +13 -0
  36. package/lib/omp-python/runner.py +2499 -0
  37. package/lib/omp-python/vendor/dill/__diff.py +234 -0
  38. package/lib/omp-python/vendor/dill/__info__.py +291 -0
  39. package/lib/omp-python/vendor/dill/__init__.py +119 -0
  40. package/lib/omp-python/vendor/dill/_dill.py +2265 -0
  41. package/lib/omp-python/vendor/dill/_objects.py +545 -0
  42. package/lib/omp-python/vendor/dill/_shims.py +193 -0
  43. package/lib/omp-python/vendor/dill/detect.py +287 -0
  44. package/lib/omp-python/vendor/dill/logger.py +285 -0
  45. package/lib/omp-python/vendor/dill/objtypes.py +24 -0
  46. package/lib/omp-python/vendor/dill/pointers.py +122 -0
  47. package/lib/omp-python/vendor/dill/session.py +612 -0
  48. package/lib/omp-python/vendor/dill/settings.py +25 -0
  49. package/lib/omp-python/vendor/dill/source.py +1025 -0
  50. package/lib/omp-python/vendor/dill/temp.py +252 -0
  51. package/lib/{puppeteer-core-CSk2PtSm.js → puppeteer-core-C-4NyOpY.js} +8 -8
  52. package/lib/remote/helper-bin/MANIFEST.json +35 -0
  53. package/lib/remote/helper-bin/aarch64-apple-darwin/BUILT-VER +1 -0
  54. package/lib/remote/helper-bin/aarch64-apple-darwin/superd-run +0 -0
  55. package/lib/remote/helper-bin/aarch64-unknown-linux-musl/BUILT-VER +1 -0
  56. package/lib/remote/helper-bin/aarch64-unknown-linux-musl/superd-run +0 -0
  57. package/lib/remote/helper-bin/x86_64-pc-windows-gnu/BUILT-VER +1 -0
  58. package/lib/remote/helper-bin/x86_64-pc-windows-gnu/superd-run.exe +0 -0
  59. package/lib/remote/helper-bin/x86_64-unknown-linux-musl/BUILT-VER +1 -0
  60. package/lib/remote/helper-bin/x86_64-unknown-linux-musl/superd-run +0 -0
  61. package/lib/remote/plugin.d.ts +487 -5
  62. package/lib/remote/plugin.js +2739 -213
  63. package/lib/url-schemes/index.js +11 -11
  64. package/lib/web-password.d.ts +1 -1
  65. package/lib/web-password.js +5 -1
  66. package/lib/welcome-notice.d.ts +5 -7
  67. package/lib/welcome-notice.js +9 -48
  68. package/lib/{wrap-T4I0nfPM.js → wrap-0VA0uFx8.js} +1 -1
  69. package/package.json +8 -25
  70. package/scripts/kernel-check.mjs +5 -0
  71. package/lib/LaunchOptions-B874eBu2.js +0 -4
  72. package/lib/bundle-delivery.d.ts +0 -20
  73. package/lib/bundle-delivery.js +0 -209
  74. package/lib/hmr.d.ts +0 -32
  75. package/lib/hmr.js +0 -49
  76. package/lib/kernel-bridge.py +0 -172
  77. package/lib/kernel-env-D8UOWeji.js +0 -195
  78. package/lib/webserver.d.ts +0 -10
  79. package/lib/webserver.js +0 -19
  80. package/scripts/kernel-provision.mjs +0 -35
  81. package/scripts/register-bundle.mjs +0 -80
package/lib/index.d.ts CHANGED
@@ -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
- /** Python interpreter with `ipykernel` installed. The bare sentinel `python3` (or absent) selects a managed venv under {@link Config.kernelEnvDir}. */
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;
@@ -388,8 +388,7 @@ interface Config$1 {
388
388
  /** Grace between a timeout/abort interrupt and the force-settle, in milliseconds. */
389
389
  interruptGraceMs?: number;
390
390
  /**
391
- * Confirm window between the control-channel interrupt and the SIGALRM
392
- * escalation, in milliseconds; must stay below {@link Config.interruptGraceMs}.
391
+ * Confirm window before repeating SIGINT, in milliseconds; must stay below {@link Config.interruptGraceMs}.
393
392
  * See the bridge's two-phase interrupt for why the escalation is deferred.
394
393
  */
395
394
  interruptConfirmMs?: number;
@@ -399,16 +398,10 @@ interface Config$1 {
399
398
  snapshotTimeoutMs?: number;
400
399
  /** Hard cap for serialized log-array, completion-value, and failure-message payloads. */
401
400
  maxOutputBytes?: number;
402
- /** Directory for per-session namespace snapshots (`state.dill` + `manifest.json`); none when absent. */
401
+ /** Per-session immutable checkpoints. Defaults to the official profile home; empty string disables, standalone callers opt in. */
403
402
  snapshotDir?: string;
404
- /** Serialized-size cap for a turn-end snapshot, in bytes; over-cap snapshots are skipped with a one-time model warning. */
403
+ /** Serialized graph cap in bytes; each over-cap attempt reports the last successful checkpoint. */
405
404
  snapshotSizeCapBytes?: number;
406
- /** Managed venv directory (used when `python` is absent/`python3`); defaults to `<package>/.venv-kernel`. */
407
- kernelEnvDir?: string;
408
- /** Preferred CPython version for a managed venv. */
409
- kernelPythonVersion?: string;
410
- /** Provision the managed venv (ipykernel + dill) on first use; default true. */
411
- kernelAutoInstall?: boolean;
412
405
  username?: string;
413
406
  }
414
407
  /**
@@ -428,8 +421,7 @@ declare class DashrRuntime extends ReplRuntime {
428
421
  /** One entry per session principal that has run code (lazy — never pre-seeded). */
429
422
  private readonly kernels;
430
423
  private disposed;
431
- /** Lazily-resolved (and, when managed, provisioned) kernel interpreter. */
432
- private kernelEnvPromise;
424
+ private readonly transactions;
433
425
  constructor(ctx: Context, config: Config$1);
434
426
  /**
435
427
  * The agentless-default kernel's pid, for lifecycle diagnostics; absent
@@ -446,7 +438,9 @@ declare class DashrRuntime extends ReplRuntime {
446
438
  * @param request - the program, its bindings, and the abort signal.
447
439
  * @returns the run's outcome per the seam contract.
448
440
  */
441
+ private transaction;
449
442
  run(request: CodeRunRequest): Promise<CodeRunResult>;
443
+ private runTransaction;
450
444
  /**
451
445
  * Read one user-namespace variable by name on the session's kernel. A
452
446
  * bare/empty name lists the namespace's user-variable names; a
@@ -459,6 +453,7 @@ declare class DashrRuntime extends ReplRuntime {
459
453
  * @param principal - the session key (absent → the shared default).
460
454
  */
461
455
  queryVar(name: string, principal?: string): Promise<ReplVarQuery>;
456
+ private queryTransaction;
462
457
  /**
463
458
  * Assign one lossless-JSON value into the user namespace under `name` on
464
459
  * the session's kernel. `name` must be a usable identifier (and not a
@@ -470,14 +465,13 @@ declare class DashrRuntime extends ReplRuntime {
470
465
  * @param principal - the session key (absent → the shared default).
471
466
  */
472
467
  setVar(name: string, value: unknown, principal?: string): Promise<void>;
468
+ private setTransaction;
473
469
  /** Map one cell outcome onto the seam's result shape under the output ledger. */
474
470
  private assembleResult;
475
471
  /** Reject malformed binding globals or typed-error declarations as contract misuse. */
476
472
  private validateBindings;
477
473
  /** Dispatch one kernel-side host request; unknown types and bad payloads become error replies. */
478
474
  private dispatchHostRequest;
479
- /** Resolve (and provision, when managed) the kernel interpreter once per runtime. */
480
- private resolveKernelPython;
481
475
  /**
482
476
  * Spawn-or-reuse the kernel for one key. The lazy map guarantees one
483
477
  * entry is created here and nowhere else, so a key that never runs never
@@ -486,40 +480,14 @@ declare class DashrRuntime extends ReplRuntime {
486
480
  * @param key - the run principal (or the agentless default).
487
481
  */
488
482
  private ensureKernel;
489
- /**
490
- * Restore a key's on-disk snapshot into a freshly booted kernel, when one
491
- * exists and its manifest is plausible. Called once per entry boot. The
492
- * kernel-side restore cell performs the authoritative environment checks
493
- * (python version, interpreter identity, skills); this method only gates on
494
- * the manifest the host can read cheaply, then records the turn so the
495
- * first-run notice and the revive chain can name it.
496
- */
483
+ /** Restore once before user admission; any degraded load retires that child. */
497
484
  private restoreEntry;
498
- /** Read the per-key manifest's host-relevant fields; absent when unreadable/missing. */
499
- private readSnapshotManifest;
500
- /**
501
- * Revive one session's kernel after death: respawn a fresh kernel, restore
502
- * the nearest replayable snapshot onto it (the normal restore path), and
503
- * return the death-observing run's explicit error naming the turn. When no
504
- * replayable snapshot exists the message falls back to M3-A's fresh-empty
505
- * contract. The run itself does NOT execute — an error that lies about a
506
- * NameError costs the model more than one dropped cell (blueprint §8.3).
507
- * @param key - the run principal.
508
- * @param dead - the entry that died (its `turn` is the last completed turn).
509
- */
485
+ private omissionNotice;
486
+ /** Restore a fresh child and report whether the observing call had started. */
510
487
  private reviveAfterDeath;
511
- /**
512
- * Write one key's turn-end snapshot, when a snapshot directory is
513
- * configured. A size-cap skip is reported (so the run can warn the model
514
- * once); other failures log without disturbing the run.
515
- */
488
+ /** Save completed mutations and expose partial/failed coverage within output limits. */
516
489
  private snapshotTurnEnd;
517
- /**
518
- * Dispose to quiescence: snapshot every live key's namespace when a
519
- * snapshot directory is configured (each under its own per-key
520
- * subdirectory), then shut the subprocesses down. Registered as the
521
- * plugin's `ctx.effect` disposer.
522
- */
490
+ /** Cancel active work, drain admitted transactions, and reap every owned child. */
523
491
  private teardown;
524
492
  /**
525
493
  * Tear one session's kernel down (session end via the `agent/disposed`
@@ -530,11 +498,9 @@ declare class DashrRuntime extends ReplRuntime {
530
498
  /**
531
499
  * Reset one session's kernel to a fresh, empty namespace: dispose the live
532
500
  * subprocess WITHOUT a turn-end snapshot and clear its on-disk snapshot, so
533
- * the next ensureKernel spawns empty (restore finds nothing to replay).
501
+ * the next ensureKernel spawns empty (restore finds no checkpoint).
534
502
  */
535
503
  private resetKey;
536
- /** Snapshot (when configured) then dispose one key's kernel; failures log, never throw into a listener. */
537
- private teardownKernel;
538
504
  }
539
505
  //#endregion
540
506
  //#region src/tool-call-id.d.ts
@@ -619,7 +585,7 @@ declare function resolveMaxParallelSubCalls(value: number | undefined): number;
619
585
  * `dashr/repl-dispatch-log` waterfall — dashr's OWN dispatch-log event,
620
586
  * self-registered via the cordis Events merge below. Decoupled from
621
587
  * upstream's `tools/ptc-dispatch-log` (PTC `run_code` sub-dispatches): `eval`
622
- * is a broader session-persistent REPL (IPython kernel) than upstream's
588
+ * is a broader session-persistent REPL (OMP Python child) than upstream's
623
589
  * `run_code` TS-worker tool, so its durable-log reshape extension point is
624
590
  * dashr-owned and version-independent — no coupling to upstream's
625
591
  * `CodeDispatchLog`/`PtcDispatchLog` rename or the PTC tool's event name.