better-dsh 0.3.0 → 0.3.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.
Files changed (73) hide show
  1. package/README.md +49 -178
  2. package/cordis.patch.yml +4 -35
  3. package/docs/adr/0015-independent-bundles-agent-remote.md +40 -0
  4. package/docs/remote-tools.md +56 -0
  5. package/docs/specs/omp-python-repl-port/runtime-guide.md +33 -0
  6. package/docs/specs/omp-python-repl-port/spec.md +61 -0
  7. package/docs/specs/remote-tool-enhancement/spec.md +203 -0
  8. package/dsh-docs/baseline.md +13 -0
  9. package/dsh-docs/subsystems/invariants.md +3 -0
  10. package/dsh-docs/subsystems/invariants.zh.md +3 -0
  11. package/eval-description.md +7 -3
  12. package/lib/{LaunchOptions-kGXcZOe0.js → LaunchOptions-5eg7E0ye.js} +1 -1
  13. package/lib/LaunchOptions-DxQQ0s-A.js +4 -0
  14. package/lib/{bidi-BalpKaJc.js → bidi-CwabFH07.js} +1 -1
  15. package/lib/client/index.js +30 -6
  16. package/lib/failover/index.js +1 -1
  17. package/lib/fs-aware/sandbox-plugin.js +3 -3
  18. package/lib/{index-browser-CysrjMyM.js → index-browser-B-9jm12n.js} +4 -4
  19. package/lib/index.d.ts +17 -41
  20. package/lib/index.js +473 -1678
  21. package/lib/kernel-env-BOF0fNHn.js +91 -0
  22. package/lib/kernel-env.d.ts +4 -58
  23. package/lib/kernel-env.js +2 -2
  24. package/lib/{lsp-server-registry-BXvUTBY7.js → lsp-server-registry-BcdkHROD.js} +1 -1
  25. package/lib/{lsp-server-registry-CH9WNFFt.js → lsp-server-registry-D4VLs1Sm.js} +1 -1
  26. package/lib/{main-CupOhMp5.js → main-BeCgUd20.js} +8 -6
  27. package/lib/{main-BQeFrBM1.js → main-Dv_UQqG2.js} +1 -1
  28. package/lib/mobile/plugin.d.ts +1 -1
  29. package/lib/omp-python/DILL-LICENSE +35 -0
  30. package/lib/omp-python/OMP-LICENSE +23 -0
  31. package/lib/omp-python/better_snapshot.py +391 -0
  32. package/lib/omp-python/better_support.py +425 -0
  33. package/lib/omp-python/dill-provenance.json +55 -0
  34. package/lib/omp-python/provenance.json +13 -0
  35. package/lib/omp-python/runner.py +2499 -0
  36. package/lib/omp-python/vendor/dill/__diff.py +234 -0
  37. package/lib/omp-python/vendor/dill/__info__.py +291 -0
  38. package/lib/omp-python/vendor/dill/__init__.py +119 -0
  39. package/lib/omp-python/vendor/dill/_dill.py +2265 -0
  40. package/lib/omp-python/vendor/dill/_objects.py +545 -0
  41. package/lib/omp-python/vendor/dill/_shims.py +193 -0
  42. package/lib/omp-python/vendor/dill/detect.py +287 -0
  43. package/lib/omp-python/vendor/dill/logger.py +285 -0
  44. package/lib/omp-python/vendor/dill/objtypes.py +24 -0
  45. package/lib/omp-python/vendor/dill/pointers.py +122 -0
  46. package/lib/omp-python/vendor/dill/session.py +612 -0
  47. package/lib/omp-python/vendor/dill/settings.py +25 -0
  48. package/lib/omp-python/vendor/dill/source.py +1025 -0
  49. package/lib/omp-python/vendor/dill/temp.py +252 -0
  50. package/lib/{puppeteer-core-CSk2PtSm.js → puppeteer-core-Dnd7eqel.js} +9 -9
  51. package/lib/remote/plugin.d.ts +459 -5
  52. package/lib/remote/plugin.js +2389 -210
  53. package/lib/url-schemes/index.d.ts +11 -11
  54. package/lib/url-schemes/index.js +12 -12
  55. package/lib/web-password.d.ts +8 -8
  56. package/lib/web-password.js +5 -1
  57. package/lib/{web-trust-Dej_RI2B.d.ts → web-trust-CwZrTBcl.d.ts} +11 -11
  58. package/lib/web-trust.d.ts +1 -2
  59. package/lib/welcome-notice.d.ts +5 -7
  60. package/lib/welcome-notice.js +9 -48
  61. package/lib/{wrap-T4I0nfPM.js → wrap-0VA0uFx8.js} +1 -1
  62. package/package.json +6 -23
  63. package/scripts/kernel-provision.mjs +4 -34
  64. package/lib/LaunchOptions-B874eBu2.js +0 -4
  65. package/lib/bundle-delivery.d.ts +0 -20
  66. package/lib/bundle-delivery.js +0 -209
  67. package/lib/hmr.d.ts +0 -32
  68. package/lib/hmr.js +0 -49
  69. package/lib/kernel-bridge.py +0 -172
  70. package/lib/kernel-env-D8UOWeji.js +0 -195
  71. package/lib/webserver.d.ts +0 -10
  72. package/lib/webserver.js +0 -19
  73. package/scripts/register-bundle.mjs +0 -80
package/lib/webserver.js DELETED
@@ -1,19 +0,0 @@
1
- import { Service } from "@deepseek-ai/cordis";
2
- import { WebServer } from "@deepseek-ai/dsh-host-webserver";
3
-
4
- //#region src/webserver.ts
5
- var BetterWebServer = class extends WebServer {
6
- static inject = ["loader"];
7
- async [Service.init]() {
8
- const welcome = [...this.ctx.loader.entries()].find((entry) => entry.options.id === "dashr-welcome-notice");
9
- if (welcome !== void 0 && !welcome.disabled) {
10
- if (welcome.fiber === void 0) await welcome.init();
11
- await welcome.fiber?.await();
12
- }
13
- this.ctx.fiber.assertActive();
14
- await super[Service.init]();
15
- }
16
- };
17
-
18
- //#endregion
19
- export { BetterWebServer as default };
@@ -1,80 +0,0 @@
1
- // Separate-process entry for the SAME native package operations used by dsh plugin.
2
- // No shell interpolation, package scripts, upstream edits, or companion registry lookup.
3
- import { createRequire } from 'node:module'
4
- import { createHash } from 'node:crypto'
5
- import { readFile, realpath } from 'node:fs/promises'
6
- import { dirname, join, relative, resolve, isAbsolute, sep } from 'node:path'
7
- import { pathToFileURL } from 'node:url'
8
- let input = ''
9
- for await (const bytes of process.stdin) input += bytes
10
- const {profile,archive,expected} = JSON.parse(input)
11
- const require = createRequire(profile.installAnchor)
12
- const {runProfilePnpm} = await import(pathToFileURL(require.resolve('@deepseek-ai/dsh-plugin-manager/operations')).href)
13
- const {withFileLock} = await import(pathToFileURL(require.resolve('@deepseek-ai/dsh-atomic-write')).href)
14
- const abort = new AbortController()
15
- process.once('SIGTERM', () => abort.abort())
16
- const json = async path => JSON.parse(await readFile(path, 'utf8'))
17
- const hash = bytes => createHash('sha256').update(bytes).digest('hex')
18
- async function contained(root, path) {
19
- if (typeof path !== 'string' || isAbsolute(path)) throw new Error('Pack delivery path must be relative')
20
- const base = await realpath(root), file = await realpath(resolve(base, path)), rel = relative(base, file)
21
- if (rel === '..' || rel.startsWith('..' + sep) || isAbsolute(rel)) throw new Error('Pack delivery path escapes its owner')
22
- return file
23
- }
24
- const skipped = disposition => ({ exitCode: 0, disposition })
25
- // Complete each native acquisition/release before observing cancellation;
26
- // exiting during its async lock-file write can strand incomplete lock metadata.
27
- async function withCancellableProfileLock(operation) {
28
- const path = join(profile.dir, 'package.json'), deadline = Date.now() + 120000
29
- for (;;) {
30
- abort.signal.throwIfAborted()
31
- let acquired = false
32
- try {
33
- return await withFileLock(path, async () => {
34
- acquired = true
35
- abort.signal.throwIfAborted()
36
- return operation()
37
- }, { waitMs: Math.min(250, Math.max(0, deadline - Date.now())) })
38
- } catch (error) {
39
- abort.signal.throwIfAborted()
40
- if (acquired || Date.now() >= deadline
41
- || error.message !== `atomic-write: timed out waiting for the writer lock at ${path}.lock`) throw error
42
- }
43
- }
44
- }
45
- const result = await withCancellableProfileLock(async () => {
46
- abort.signal.throwIfAborted()
47
- const current = await json(join(profile.dir, 'package.json'))
48
- if (typeof expected.ownerSpec !== 'string' || current.dependencies?.[expected.owner] !== expected.ownerSpec) return skipped('owner-changed')
49
- const ownerDir = join(profile.dir, 'node_modules', expected.owner)
50
- let owner, descriptorPath, descriptor
51
- try {
52
- owner = await json(join(ownerDir, 'package.json'))
53
- if (owner.dependencies?.[expected.companion.name] !== expected.companion.version || owner.superd?.delivery === undefined) return skipped('owner-changed')
54
- descriptorPath = await contained(ownerDir, owner.superd.delivery)
55
- descriptor = await json(descriptorPath)
56
- } catch (error) {
57
- if (error.code === 'ENOENT') return skipped('owner-changed')
58
- throw error
59
- }
60
- const item = descriptor.companions?.find(item => item.name === expected.companion.name)
61
- if (item?.version !== expected.companion.version || item.sha256 !== expected.companion.sha256
62
- || hash(await readFile(await contained(dirname(descriptorPath), item.tarball))) !== expected.companion.sha256) return skipped('owner-changed')
63
- const prior = current.dependencies?.[item.name]
64
- if (prior !== expected.priorSpec) return skipped(prior === undefined && expected.priorSpec !== undefined ? 'companion-removed' : 'companion-changed')
65
- if (hash(await readFile(archive)) !== item.sha256) throw new Error('Cached companion SHA256 mismatch')
66
- abort.signal.throwIfAborted()
67
- // Same public operation and writer lock used by the native Plugin Manager;
68
- // intent is checked after acquisition, before a queued install can undo removal.
69
- const operation = await runProfilePnpm({profile:profile.name,dir:profile.dir,installAnchor:profile.installAnchor,cwd:profile.dir,home:profile.home}, ['add','file:'+archive,'--ignore-scripts'], {
70
- ...profile.packageManager, execution:'service', signal:abort.signal, outputBytes:16384,
71
- lookupTimeoutMs:120000, idleTimeoutMs:120000,
72
- })
73
- if (operation.exitCode === 0) {
74
- const installed = await json(join(profile.dir, 'node_modules', item.name, 'package.json'))
75
- const after = await json(join(profile.dir, 'package.json'))
76
- if (installed.name !== item.name || installed.version !== item.version || after.dependencies?.[item.name] !== 'file:' + archive) throw new Error('Native companion registration did not install the exact local artifact')
77
- }
78
- return { exitCode: operation.exitCode, logPath: operation.logPath, disposition: 'installed' }
79
- })
80
- process.stdout.write(JSON.stringify(result)+'\n')