super-dsh 0.1.6 → 0.1.10-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 +25 -3
- package/agent-agy/cordis.patch.yml +7 -4
- package/agent-agy/dist/agent.d.ts +12 -11
- package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
- package/agent-agy/dist/agy-auth-gateway.js +233 -0
- package/agent-agy/dist/agy-auth.d.ts +153 -0
- package/agent-agy/dist/agy-auth.js +179 -0
- package/agent-agy/dist/agy-cli-client.d.ts +39 -9
- package/agent-agy/dist/agy-cli-client.js +82 -18
- package/agent-agy/dist/agy-store.d.ts +8 -0
- package/agent-agy/dist/index.d.ts +46 -16
- package/agent-agy/dist/index.js +82 -56
- package/agent-agy/dist/models.d.ts +70 -0
- package/agent-agy/dist/models.js +102 -3
- package/agent-agy/package.json +7 -5
- package/agent-agy-sdk/cordis.patch.yml +58 -0
- package/agent-agy-sdk/dist/adapter.d.ts +15 -0
- package/agent-agy-sdk/dist/adapter.js +42 -0
- package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
- package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
- package/agent-agy-sdk/dist/agent.d.ts +138 -0
- package/agent-agy-sdk/dist/agent.js +494 -0
- package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
- package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
- package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
- package/agent-agy-sdk/dist/agy-sessions.js +107 -0
- package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
- package/agent-agy-sdk/dist/agy-store.js +83 -0
- package/agent-agy-sdk/dist/inbox.d.ts +26 -0
- package/agent-agy-sdk/dist/inbox.js +53 -0
- package/agent-agy-sdk/dist/index.d.ts +93 -0
- package/agent-agy-sdk/dist/index.js +476 -0
- package/agent-agy-sdk/dist/models.d.ts +41 -0
- package/agent-agy-sdk/dist/models.js +74 -0
- package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
- package/agent-agy-sdk/dist/sdk-venv.js +173 -0
- package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
- package/agent-agy-sdk/dist/world-plugin.js +82 -0
- package/agent-agy-sdk/package.json +64 -0
- package/agent-claude/dist/adapter.js +106 -31
- package/agent-claude/dist/agent.js +154 -17
- package/agent-claude/dist/claude-client.js +84 -43
- package/agent-claude/dist/claude-launch.js +101 -0
- package/agent-claude/dist/claude-native-config.js +169 -0
- package/agent-claude/dist/claude-provider-gateway.js +340 -0
- package/agent-claude/dist/claude-providers.js +391 -0
- package/agent-claude/dist/claude-route.js +152 -0
- package/agent-claude/dist/index.js +214 -37
- package/agent-claude/dist/models.js +14 -0
- package/agent-claude/dist/sdk-runtime.js +320 -0
- package/agent-claude/package.json +6 -4
- package/agent-codex/README.md +141 -36
- package/agent-codex/cordis.patch.yml +14 -10
- package/agent-codex/dist/adapter.js +64 -28
- package/agent-codex/dist/agent.js +255 -81
- package/agent-codex/dist/app-server-approvals.js +165 -0
- package/agent-codex/dist/app-server-client.js +723 -0
- package/agent-codex/dist/app-server-events.js +432 -0
- package/agent-codex/dist/app-server-protocol.js +95 -0
- package/agent-codex/dist/app-server-wire.js +299 -0
- package/agent-codex/dist/codex-launch.js +78 -0
- package/agent-codex/dist/codex-native-config.js +392 -0
- package/agent-codex/dist/codex-provider-gateway.js +402 -0
- package/agent-codex/dist/codex-providers.js +376 -0
- package/agent-codex/dist/codex-route.js +86 -0
- package/agent-codex/dist/index.js +256 -115
- package/agent-codex/dist/permission.js +75 -1
- package/agent-codex/package.json +1 -2
- package/agent-codex-sdk/README.md +79 -0
- package/agent-codex-sdk/cordis.patch.yml +81 -0
- package/agent-codex-sdk/dist/adapter.js +91 -0
- package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
- package/agent-codex-sdk/dist/agent.js +1085 -0
- package/agent-codex-sdk/dist/codex-native-config.js +392 -0
- package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
- package/agent-codex-sdk/dist/codex-providers.js +376 -0
- package/agent-codex-sdk/dist/codex-route.js +86 -0
- package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
- package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
- package/agent-codex-sdk/dist/codex-store.js +180 -0
- package/agent-codex-sdk/dist/inbox.js +53 -0
- package/agent-codex-sdk/dist/index.js +739 -0
- package/agent-codex-sdk/dist/permission.js +71 -0
- package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
- package/agent-codex-sdk/dist/session-map.js +167 -0
- package/agent-codex-sdk/dist/world-plugin.js +93 -0
- package/agent-codex-sdk/package.json +79 -0
- package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
- package/agent-omp/README.md +72 -55
- package/agent-omp/dist/agent.js +36 -11
- package/agent-omp/dist/index.js +92 -52
- package/agent-omp/dist/lazy-rpc.js +11 -4
- package/agent-omp/dist/omp-cli.js +114 -97
- package/agent-omp/dist/omp-store.js +12 -4
- package/agent-omp/dist/permission.js +70 -5
- package/agent-omp/dist/rpc-client.js +409 -0
- package/agent-omp/dist/world-plugin.js +36 -3
- package/agent-omp/package.json +2 -6
- package/agent-omp-sdk/README.md +103 -0
- package/agent-omp-sdk/cordis.patch.yml +108 -0
- package/agent-omp-sdk/dist/adapter.d.ts +21 -0
- package/agent-omp-sdk/dist/adapter.js +36 -0
- package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
- package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
- package/agent-omp-sdk/dist/agent.d.ts +64 -0
- package/agent-omp-sdk/dist/agent.js +1178 -0
- package/agent-omp-sdk/dist/discovery.d.ts +57 -0
- package/agent-omp-sdk/dist/discovery.js +116 -0
- package/agent-omp-sdk/dist/inbox.d.ts +28 -0
- package/agent-omp-sdk/dist/inbox.js +53 -0
- package/agent-omp-sdk/dist/index.d.ts +60 -0
- package/agent-omp-sdk/dist/index.js +632 -0
- package/agent-omp-sdk/dist/knobs.d.ts +34 -0
- package/agent-omp-sdk/dist/knobs.js +50 -0
- package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
- package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
- package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
- package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
- package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
- package/agent-omp-sdk/dist/mobile-boot.js +38 -0
- package/agent-omp-sdk/dist/models.d.ts +39 -0
- package/agent-omp-sdk/dist/models.js +299 -0
- package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
- package/agent-omp-sdk/dist/omp-cli.js +164 -0
- package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
- package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
- package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
- package/agent-omp-sdk/dist/omp-executable.js +30 -0
- package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
- package/agent-omp-sdk/dist/omp-store.js +526 -0
- package/agent-omp-sdk/dist/pairing.d.ts +7 -0
- package/agent-omp-sdk/dist/pairing.js +45 -0
- package/agent-omp-sdk/dist/permission.d.ts +138 -0
- package/agent-omp-sdk/dist/permission.js +161 -0
- package/agent-omp-sdk/dist/protocol.d.ts +189 -0
- package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
- package/agent-omp-sdk/dist/rpc-types.js +1 -0
- package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
- package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
- package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
- package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
- package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
- package/agent-omp-sdk/dist/sidecar-client.js +197 -0
- package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
- package/agent-omp-sdk/dist/store/adapter.js +47 -0
- package/agent-omp-sdk/dist/store/db.d.ts +70 -0
- package/agent-omp-sdk/dist/store/db.js +210 -0
- package/agent-omp-sdk/dist/store/index.d.ts +23 -0
- package/agent-omp-sdk/dist/store/index.js +59 -0
- package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
- package/agent-omp-sdk/dist/store/reconcile.js +51 -0
- package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
- package/agent-omp-sdk/dist/store/schema.js +40 -0
- package/agent-omp-sdk/dist/transport.d.ts +49 -0
- package/agent-omp-sdk/dist/transport.js +35 -0
- package/agent-omp-sdk/dist/world-home.d.ts +4 -0
- package/agent-omp-sdk/dist/world-home.js +23 -0
- package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
- package/agent-omp-sdk/dist/world-plugin.js +137 -0
- package/agent-omp-sdk/package.json +87 -0
- package/client/index.js +1883 -287
- package/cordis.patch.yml +80 -0
- package/package.json +23 -9
- package/superd-hub/dist/a2a-delivery.d.ts +189 -0
- package/superd-hub/dist/a2a-delivery.js +240 -0
- package/superd-hub/dist/a2a-host.d.ts +76 -0
- package/superd-hub/dist/a2a-host.js +145 -0
- package/superd-hub/dist/a2a-ingest.d.ts +31 -0
- package/superd-hub/dist/a2a-ingest.js +636 -0
- package/superd-hub/dist/a2a-log.d.ts +17 -0
- package/superd-hub/dist/a2a-log.js +42 -0
- package/superd-hub/dist/a2a-row.d.ts +65 -0
- package/superd-hub/dist/a2a-row.js +162 -0
- package/superd-hub/dist/a2a-service.d.ts +357 -0
- package/superd-hub/dist/a2a-service.js +980 -0
- package/superd-hub/dist/a2a-wire.d.ts +220 -0
- package/superd-hub/dist/a2a-wire.js +305 -0
- package/superd-hub/dist/agent-ids.d.ts +10 -0
- package/superd-hub/dist/agent-ids.js +68 -0
- package/superd-hub/dist/agent-roster.d.ts +29 -18
- package/superd-hub/dist/agent-roster.js +54 -15
- package/superd-hub/dist/agent-status.d.ts +119 -0
- package/superd-hub/dist/agent-status.js +386 -0
- package/superd-hub/dist/client/agent-settings.d.ts +210 -0
- package/superd-hub/dist/client/agent-settings.js +300 -0
- package/superd-hub/dist/client/mesh-api.d.ts +134 -0
- package/superd-hub/dist/client/mesh-api.js +219 -0
- package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
- package/superd-hub/dist/client/mesh-groups.js +66 -0
- package/superd-hub/dist/client/roster.d.ts +48 -0
- package/superd-hub/dist/client/roster.js +102 -0
- package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
- package/superd-hub/dist/client/runtime-settings-api.js +137 -0
- package/superd-hub/dist/client/switch.d.ts +165 -0
- package/superd-hub/dist/client/switch.js +295 -0
- package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
- package/superd-hub/dist/exec-pty-channel.js +162 -0
- package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
- package/superd-hub/dist/exec-pty-framing.js +81 -0
- package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
- package/superd-hub/dist/exec-pty-rpc.js +128 -0
- package/superd-hub/dist/exec-pty-session.d.ts +76 -0
- package/superd-hub/dist/exec-pty-session.js +234 -0
- package/superd-hub/dist/exec.d.ts +56 -0
- package/superd-hub/dist/exec.js +225 -0
- package/superd-hub/dist/gateway.d.ts +39 -2
- package/superd-hub/dist/gateway.js +62 -3
- package/superd-hub/dist/hub-tool.d.ts +174 -0
- package/superd-hub/dist/hub-tool.js +464 -0
- package/superd-hub/dist/index.d.ts +15 -1
- package/superd-hub/dist/index.js +16 -0
- package/superd-hub/dist/machines.d.ts +45 -0
- package/superd-hub/dist/machines.js +125 -0
- package/superd-hub/dist/mesh-federate.d.ts +138 -0
- package/superd-hub/dist/mesh-federate.js +223 -0
- package/superd-hub/dist/mesh-gateway.d.ts +67 -0
- package/superd-hub/dist/mesh-gateway.js +408 -0
- package/superd-hub/dist/mesh-link.d.ts +274 -0
- package/superd-hub/dist/mesh-link.js +441 -0
- package/superd-hub/dist/mesh-rpc.d.ts +123 -0
- package/superd-hub/dist/mesh-rpc.js +250 -0
- package/superd-hub/dist/mux-client.d.ts +71 -0
- package/superd-hub/dist/mux-client.js +281 -0
- package/superd-hub/dist/pack-version.d.ts +2 -0
- package/superd-hub/dist/pack-version.js +30 -0
- package/superd-hub/dist/roster.d.ts +6 -0
- package/superd-hub/dist/rpc.d.ts +18 -2
- package/superd-hub/dist/rpc.js +34 -4
- package/superd-hub/dist/spawn-world.js +3 -1
- package/superd-hub/dist/switch-core.d.ts +62 -25
- package/superd-hub/dist/switch-core.js +53 -30
- package/superd-hub/dist/system-head.d.ts +22 -12
- package/superd-hub/dist/system-head.js +100 -84
- package/superd-hub/dist/wire-endpoints.d.ts +264 -0
- package/superd-hub/dist/wire-endpoints.js +180 -0
- package/superd-hub/lib/client/index.js +1883 -287
- package/superd-hub/package.json +11 -2
- package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
- package/agent-agy/dist/agent-preset-projection.js +0 -33
- package/agent-claude/dist/agent-preset-projection.js +0 -30
- package/agent-codex/dist/agent-preset-projection.js +0 -37
- package/agent-codex/dist/app-home.js +0 -65
- package/agent-codex/dist/models.js +0 -152
- package/agent-codex/dist/spike.js +0 -46
- package/agent-hermes/dist/agent-preset-projection.js +0 -34
- package/agent-omp/dist/agent-preset-projection.js +0 -36
- package/agent-omp/dist/app-home.js +0 -86
- package/agent-omp/dist/sidecar-client.js +0 -195
- package/agent-pi/dist/agent-preset-projection.js +0 -29
- package/superd-hub/dist/client-shim.d.ts +0 -28
- package/superd-hub/dist/client-shim.js +0 -251
- package/superd-hub/dist/index-pass.d.ts +0 -22
- package/superd-hub/dist/index-pass.js +0 -47
- package/superd-hub/dist/labels.d.ts +0 -45
- package/superd-hub/dist/labels.js +0 -83
- /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
- /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
- /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
- /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
- /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sdk-runtime.ts — the lazy, durable SDK runtime the opt-in `omp-sdk` line runs on.
|
|
3
|
+
*
|
|
4
|
+
* 2026-10-03 user ruling (spec §2.4): this package declares NO SDK and NO `bun`
|
|
5
|
+
* dependency and ships NO postinstall/allow-scripts hook. Nothing is fetched at
|
|
6
|
+
* install time; the FIRST real prompt fetches the runtime into the world home,
|
|
7
|
+
* where it is durable across sessions, restarts and package upgrades. A second
|
|
8
|
+
* use reuses it (idempotent), and a FAILED fetch leaves a trace on disk instead
|
|
9
|
+
* of silently degrading into a confusing sidecar crash.
|
|
10
|
+
*
|
|
11
|
+
* Why the world home rather than the package root: the package root is the
|
|
12
|
+
* installed tarball — read-only in every real consumer install, and shared by
|
|
13
|
+
* every world. The world home is per-runtime, writable, and already the home of
|
|
14
|
+
* this adapter's own state.
|
|
15
|
+
*
|
|
16
|
+
* What lands where (bun resolves `node_modules` from the runtime dir, so the
|
|
17
|
+
* sidecar must live there):
|
|
18
|
+
*
|
|
19
|
+
* <worldHome>/sdk-runtime/
|
|
20
|
+
* bin/bun (a) the bun release, unzipped into place
|
|
21
|
+
* package.json / node_modules/ (b) installed with that bun
|
|
22
|
+
* sidecar/main.ts (c) copied from this package
|
|
23
|
+
* dist/protocol.js (c) copied from this package
|
|
24
|
+
* <worldHome>/sdk-runtime.json marker — written LAST, its presence is the contract
|
|
25
|
+
* <worldHome>/sdk-runtime.lock atomic (mkdir) bootstrap lock
|
|
26
|
+
* <worldHome>/sdk-runtime.error.log written ONLY by a failed fetch
|
|
27
|
+
*
|
|
28
|
+
* Every step is idempotent, so a half-built runtime heals in place: an existing
|
|
29
|
+
* `bin/bun` is not re-downloaded, and a missing marker simply re-runs the
|
|
30
|
+
* remaining steps.
|
|
31
|
+
*
|
|
32
|
+
* Measured cost (2026-10-03 probe, spec §1 + §3.3). bun release zip 36.6 MB,
|
|
33
|
+
* `bun add` ~2-5 s. A FULL install is 1133 MB / 114 packages, but the largest
|
|
34
|
+
* chunk of that is dead weight here: `@huggingface/transformers` +
|
|
35
|
+
* `onnxruntime-{node,web}` (~234 MB) come in through `optionalDependencies` and
|
|
36
|
+
* their native postinstall is blocked by `--ignore-scripts` anyway.
|
|
37
|
+
* `--omit=optional` alone is 535 MB but BREAKS the import — `@oh-my-pi/pi-natives`
|
|
38
|
+
* declares its platform binding in `optionalDependencies`, so bun drops
|
|
39
|
+
* `@oh-my-pi/pi-natives-<platform>` and the sidecar dies with `Failed to load
|
|
40
|
+
* pi_natives native addon for <platform>`. Re-adding that platform package
|
|
41
|
+
* explicitly is the fix: **899 MB / 84 packages, import passes**. Escape hatch:
|
|
42
|
+
* `OMP_SDK_KEEP_OPTIONAL=1` drops `--omit=optional` and reinstates the full
|
|
43
|
+
* 1133 MB tree.
|
|
44
|
+
*
|
|
45
|
+
* bun's install cache is another ~1.2 GB, so it is redirected to
|
|
46
|
+
* `<runtime>/.cache` and deleted once the install succeeds.
|
|
47
|
+
*
|
|
48
|
+
* The pin defaults to 18.5.0 because 18.4.9 is BROKEN for source-level import:
|
|
49
|
+
* its `src/sdk.ts` imports `./ratchet/prelude` extensionless, so bun resolves
|
|
50
|
+
* the template file `src/ratchet/prelude.js` instead of the real module and
|
|
51
|
+
* `bun -e 'await import("@oh-my-pi/pi-coding-agent")'` dies with
|
|
52
|
+
* `SyntaxError: Export named 'createRatchetPrelude' not found in module
|
|
53
|
+
* '.../src/ratchet/prelude.js'`. Upstream fixed it in 18.5.0 by renaming the
|
|
54
|
+
* real module to `./ratchet/prelude-definition`. The smoke step in
|
|
55
|
+
* {@link ensureSdkRuntime} pins that diagnosis down at fetch time; 18.2.11 is
|
|
56
|
+
* the last known-good fallback (`OMP_SDK_PACKAGE_VERSION=18.2.11`).
|
|
57
|
+
*
|
|
58
|
+
* Probe evidence: 18.5.0 slim = 84 packages / 899 MB / smoke ✅; 18.5.0 full =
|
|
59
|
+
* 114 packages / 1133 MB / smoke ✅; 18.4.9 = smoke ❌ (`createRatchetPrelude`);
|
|
60
|
+
* 18.2.11 = smoke ✅ (no `src/ratchet/` at all).
|
|
61
|
+
*/
|
|
62
|
+
import { execFile } from "node:child_process";
|
|
63
|
+
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
64
|
+
import { createWriteStream } from "node:fs";
|
|
65
|
+
import { rm } from "node:fs/promises";
|
|
66
|
+
import { Readable } from "node:stream";
|
|
67
|
+
import { pipeline } from "node:stream/promises";
|
|
68
|
+
import { promisify } from "node:util";
|
|
69
|
+
import { dirname, join } from "node:path";
|
|
70
|
+
import { fileURLToPath } from "node:url";
|
|
71
|
+
/** The coding-agent package the sidecar imports (same program as the `omp` binary). */
|
|
72
|
+
export const SDK_PACKAGE = "@oh-my-pi/pi-coding-agent";
|
|
73
|
+
/** Prefix of the per-platform native binding package (`-<platform>` is appended). */
|
|
74
|
+
export const SDK_NATIVES_PACKAGE_PREFIX = "@oh-my-pi/pi-natives";
|
|
75
|
+
/**
|
|
76
|
+
* Pin of {@link SDK_PACKAGE} (and of the native binding package). Defaults to
|
|
77
|
+
* the operator's local `omp --version` family (18.5.0) so both OMP faces run
|
|
78
|
+
* the same code; `OMP_SDK_PACKAGE_VERSION` overrides it. Do not go back to
|
|
79
|
+
* 18.4.9 — see the module doc (broken source-level import).
|
|
80
|
+
*/
|
|
81
|
+
export const SDK_PACKAGE_VERSION = process.env.OMP_SDK_PACKAGE_VERSION ?? "18.5.0";
|
|
82
|
+
/** The bun release the sidecar runs on; `OMP_SDK_BUN_VERSION` overrides it. */
|
|
83
|
+
export const SDK_BUN_VERSION = process.env.OMP_SDK_BUN_VERSION ?? "1.4.2";
|
|
84
|
+
/** The bun release platform archive this adapter fetches (worlds run on linux-x64). */
|
|
85
|
+
export const SDK_BUN_PLATFORM = "linux-x64";
|
|
86
|
+
/**
|
|
87
|
+
* Pure `process.platform`/`process.arch` → natives binding key.
|
|
88
|
+
* Throws for a tuple `@oh-my-pi/pi-natives` does not publish (fail loud rather
|
|
89
|
+
* than install a runtime whose addon cannot load).
|
|
90
|
+
*/
|
|
91
|
+
export function sdkNativesPlatform(platform = process.platform, arch = process.arch) {
|
|
92
|
+
switch (`${platform}-${arch}`) {
|
|
93
|
+
case "linux-x64":
|
|
94
|
+
case "linux-arm64":
|
|
95
|
+
case "darwin-x64":
|
|
96
|
+
case "darwin-arm64":
|
|
97
|
+
case "win32-x64":
|
|
98
|
+
case "win32-arm64":
|
|
99
|
+
return `${platform}-${arch}`;
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`omp-sdk: @oh-my-pi/pi-natives publishes no binding for ${platform}-${arch}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** The exact natives binding package name for a platform key. */
|
|
105
|
+
export function sdkNativesPackage(platform) {
|
|
106
|
+
return `${SDK_NATIVES_PACKAGE_PREFIX}-${platform}`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The install argv (pure, so the slim-install recipe is testable).
|
|
110
|
+
*
|
|
111
|
+
* `--omit=optional` drops the ~234 MB transformers/onnxruntime weight; the
|
|
112
|
+
* explicit natives package restores the one optional dependency the import
|
|
113
|
+
* actually needs. `keepOptional` (env `OMP_SDK_KEEP_OPTIONAL=1`) reinstates the
|
|
114
|
+
* full tree.
|
|
115
|
+
*/
|
|
116
|
+
export function sdkInstallArgv(packageVersion, platform, keepOptional = false) {
|
|
117
|
+
const args = ["add", "--exact", "--ignore-scripts"];
|
|
118
|
+
if (!keepOptional)
|
|
119
|
+
args.push("--omit=optional");
|
|
120
|
+
args.push(`${SDK_PACKAGE}@${packageVersion}`, `${sdkNativesPackage(platform)}@${packageVersion}`);
|
|
121
|
+
return args;
|
|
122
|
+
}
|
|
123
|
+
/** The exact GitHub release asset URL of a bun version's linux-x64 build. */
|
|
124
|
+
export function bunReleaseZipUrl(bunVersion) {
|
|
125
|
+
return `https://github.com/oven-sh/bun/releases/download/bun-v${bunVersion}/bun-${SDK_BUN_PLATFORM}.zip`;
|
|
126
|
+
}
|
|
127
|
+
export function sdkRuntimeLayout(worldHome) {
|
|
128
|
+
const dir = join(worldHome, "sdk-runtime");
|
|
129
|
+
return {
|
|
130
|
+
dir,
|
|
131
|
+
bun: join(dir, "bin", "bun"),
|
|
132
|
+
marker: join(worldHome, "sdk-runtime.json"),
|
|
133
|
+
lock: join(worldHome, "sdk-runtime.lock"),
|
|
134
|
+
errorLog: join(worldHome, "sdk-runtime.error.log"),
|
|
135
|
+
sidecarDir: join(dir, "sidecar"),
|
|
136
|
+
sidecarEntry: join(dir, "sidecar", "main.ts"),
|
|
137
|
+
protocolDir: join(dir, "dist"),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Destination of the compiled protocol module copied beside the sidecar. */
|
|
141
|
+
export function sdkRuntimeProtocolEntry(layout) {
|
|
142
|
+
return join(layout.protocolDir, "protocol.js");
|
|
143
|
+
}
|
|
144
|
+
/** Read the install marker; undefined when absent or unreadable. */
|
|
145
|
+
export function readSdkRuntimeRecord(worldHome) {
|
|
146
|
+
const { marker } = sdkRuntimeLayout(worldHome);
|
|
147
|
+
if (!existsSync(marker))
|
|
148
|
+
return undefined;
|
|
149
|
+
try {
|
|
150
|
+
const parsed = JSON.parse(readFileSync(marker, "utf8"));
|
|
151
|
+
return typeof parsed === "object" && parsed !== null ? parsed : undefined;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Fast path: the runtime is complete AND matches `identity` → its record.
|
|
159
|
+
*
|
|
160
|
+
* Returns undefined when the marker is absent/corrupt, when any identity field
|
|
161
|
+
* differs (the adapter or a pin changed), or when the recorded bun binary is
|
|
162
|
+
* gone — in every such case the caller must (re)fetch.
|
|
163
|
+
*/
|
|
164
|
+
export function sdkRuntimeReady(worldHome, identity) {
|
|
165
|
+
const record = readSdkRuntimeRecord(worldHome);
|
|
166
|
+
if (record === undefined)
|
|
167
|
+
return undefined;
|
|
168
|
+
if (record.pluginVersion !== identity.pluginVersion)
|
|
169
|
+
return undefined;
|
|
170
|
+
if (record.packageVersion !== identity.packageVersion)
|
|
171
|
+
return undefined;
|
|
172
|
+
if (record.bunVersion !== identity.bunVersion)
|
|
173
|
+
return undefined;
|
|
174
|
+
if (!existsSync(sdkRuntimeLayout(worldHome).bun))
|
|
175
|
+
return undefined;
|
|
176
|
+
return record;
|
|
177
|
+
}
|
|
178
|
+
/** A held lock older than this is treated as abandoned and reclaimed. */
|
|
179
|
+
const LOCK_STALE_MS = 30 * 60 * 1000;
|
|
180
|
+
/**
|
|
181
|
+
* The PRODUCTION {@link SdkRuntimeDeps}: everything the bootstrap touches
|
|
182
|
+
* outside its own filesystem work, wired to real OS primitives.
|
|
183
|
+
*
|
|
184
|
+
* Kept IN THE MODULE (not in `scripts/fetch-sdk-runtime.mjs`) so the manual
|
|
185
|
+
* pre-warm script and the first-prompt lazy fetch (sidecar `start()`) share ONE
|
|
186
|
+
* implementation: a second copy is exactly how the two paths would drift.
|
|
187
|
+
*
|
|
188
|
+
* `pluginDir` defaults to this package's root (the parent of the compiled
|
|
189
|
+
* `dist/`), from which the sidecar source and the compiled protocol module are
|
|
190
|
+
* copied into the runtime; the marker identity reads the package's own version.
|
|
191
|
+
*
|
|
192
|
+
* @param pluginDir - package root holding `sidecar/main.ts` + `dist/protocol.js`.
|
|
193
|
+
* @returns deps for {@link ensureSdkRuntime}.
|
|
194
|
+
*/
|
|
195
|
+
export function createSdkRuntimeDeps(pluginDir = pathDirname(fileURLToPath(import.meta.url), "..")) {
|
|
196
|
+
return {
|
|
197
|
+
download: downloadToFile,
|
|
198
|
+
run: runCommand,
|
|
199
|
+
copy: (from, to) => {
|
|
200
|
+
mkdirSync(pathDirname(to), { recursive: true });
|
|
201
|
+
copyFileSync(from, to);
|
|
202
|
+
},
|
|
203
|
+
pluginVersion: readPluginVersion(pluginDir),
|
|
204
|
+
pluginDir,
|
|
205
|
+
log: (line) => process.stderr.write(`[agent-omp-sdk] ${line}\n`),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/** The version of the adapter package at `pluginDir` (the marker identity half). */
|
|
209
|
+
export function readPluginVersion(pluginDir) {
|
|
210
|
+
const raw = readFileSync(join(pluginDir, "package.json"), "utf8");
|
|
211
|
+
const parsed = JSON.parse(raw);
|
|
212
|
+
if (typeof parsed.version !== "string" || parsed.version === "") {
|
|
213
|
+
throw new Error(`omp-sdk: ${join(pluginDir, "package.json")} carries no version`);
|
|
214
|
+
}
|
|
215
|
+
return parsed.version;
|
|
216
|
+
}
|
|
217
|
+
/** `dirname` without importing it twice under two names. */
|
|
218
|
+
function pathDirname(...parts) {
|
|
219
|
+
return dirname(join(...parts));
|
|
220
|
+
}
|
|
221
|
+
const execFileAsync = promisify(execFile);
|
|
222
|
+
/**
|
|
223
|
+
* Run a command to completion, inheriting the environment except for the
|
|
224
|
+
* explicit overrides ({@link SdkRuntimeRunOptions.env}); an `undefined`
|
|
225
|
+
* override REMOVES the key from the child (needed for the smoke import's
|
|
226
|
+
* redirected agent dir). Rejects on a non-zero exit.
|
|
227
|
+
*/
|
|
228
|
+
async function runCommand(cmd, args, opts) {
|
|
229
|
+
const env = { ...process.env };
|
|
230
|
+
if (opts?.env !== undefined) {
|
|
231
|
+
for (const [key, value] of Object.entries(opts.env)) {
|
|
232
|
+
if (value === undefined)
|
|
233
|
+
delete env[key];
|
|
234
|
+
else
|
|
235
|
+
env[key] = value;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
await execFileAsync(cmd, args, { cwd: opts?.cwd, env, maxBuffer: 64 * 1024 * 1024 });
|
|
239
|
+
}
|
|
240
|
+
/** Stream `url` to the file `dest` (curl-free — Node's own fetch). */
|
|
241
|
+
async function downloadToFile(url, dest) {
|
|
242
|
+
const response = await fetch(url);
|
|
243
|
+
if (!response.ok) {
|
|
244
|
+
throw new Error(`download failed: HTTP ${response.status} ${response.statusText} for ${url}`);
|
|
245
|
+
}
|
|
246
|
+
if (response.body === null)
|
|
247
|
+
throw new Error(`download failed: empty body for ${url}`);
|
|
248
|
+
mkdirSync(pathDirname(dest), { recursive: true });
|
|
249
|
+
try {
|
|
250
|
+
await pipeline(Readable.fromWeb(response.body), createWriteStream(dest));
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
await rm(dest, { force: true });
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Return the record for `<worldHome>`'s durable SDK runtime, fetching it first
|
|
259
|
+
* when it is absent, incomplete or does not match the running adapter.
|
|
260
|
+
*
|
|
261
|
+
* Idempotent: a complete, matching runtime short-circuits without touching the
|
|
262
|
+
* network. Concurrent callers: the bootstrap is guarded by a `mkdir` lock — a
|
|
263
|
+
* second caller that finds a FRESH lock throws a clear "fetch in progress"
|
|
264
|
+
* error (no waiting; the SDK transport is a per-process singleton, so the real
|
|
265
|
+
* race is another dsh process on the same world home), while an abandoned lock
|
|
266
|
+
* (older than {@link LOCK_STALE_MS}) is reclaimed so a crashed fetch cannot
|
|
267
|
+
* brick the line.
|
|
268
|
+
*
|
|
269
|
+
* Failures append to `<worldHome>/sdk-runtime.error.log` and throw a single
|
|
270
|
+
* actionable error — never a partial runtime behind a success marker.
|
|
271
|
+
*/
|
|
272
|
+
export async function ensureSdkRuntime(worldHome, deps) {
|
|
273
|
+
const layout = sdkRuntimeLayout(worldHome);
|
|
274
|
+
const identity = {
|
|
275
|
+
pluginVersion: deps.pluginVersion,
|
|
276
|
+
packageVersion: SDK_PACKAGE_VERSION,
|
|
277
|
+
bunVersion: SDK_BUN_VERSION,
|
|
278
|
+
};
|
|
279
|
+
const ready = sdkRuntimeReady(worldHome, identity);
|
|
280
|
+
if (ready !== undefined) {
|
|
281
|
+
deps.log(`omp-sdk: runtime ready (${SDK_PACKAGE}@${ready.packageVersion}, bun ${ready.bunVersion})`);
|
|
282
|
+
return ready;
|
|
283
|
+
}
|
|
284
|
+
mkdirSync(worldHome, { recursive: true });
|
|
285
|
+
acquireLock(layout, deps);
|
|
286
|
+
try {
|
|
287
|
+
// Re-check inside the lock: a peer may have completed the fetch in the
|
|
288
|
+
// window between our check and the lock, in which case we pay nothing.
|
|
289
|
+
const done = sdkRuntimeReady(worldHome, identity);
|
|
290
|
+
if (done !== undefined)
|
|
291
|
+
return done;
|
|
292
|
+
try {
|
|
293
|
+
return await buildRuntime(layout, deps, identity);
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
297
|
+
const stamp = new Date().toISOString();
|
|
298
|
+
try {
|
|
299
|
+
appendFileSync(layout.errorLog, `[${stamp}] omp-sdk runtime fetch failed: ${detail}\n`);
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
/* the trace is best-effort; the throw below is the contract */
|
|
303
|
+
}
|
|
304
|
+
throw new Error(`omp-sdk: could not fetch the SDK runtime ` +
|
|
305
|
+
`(${SDK_PACKAGE}@${SDK_PACKAGE_VERSION} + bun ${SDK_BUN_VERSION}) at ${layout.dir}: ${detail}. ` +
|
|
306
|
+
`Pre-warm it by hand with \`npm run fetch-sdk-runtime\`. Trace: ${layout.errorLog}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
rmSync(layout.lock, { recursive: true, force: true });
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** The idempotent build steps; the marker is written last, after the smoke check. */
|
|
314
|
+
async function buildRuntime(layout, deps, identity) {
|
|
315
|
+
mkdirSync(layout.dir, { recursive: true });
|
|
316
|
+
// (a) bun — skipped when a previous attempt already landed the binary.
|
|
317
|
+
if (!existsSync(layout.bun)) {
|
|
318
|
+
const zip = join(layout.dir, `bun-${SDK_BUN_PLATFORM}.zip`);
|
|
319
|
+
const staging = join(layout.dir, ".bun-unzip");
|
|
320
|
+
rmSync(staging, { recursive: true, force: true });
|
|
321
|
+
mkdirSync(staging, { recursive: true });
|
|
322
|
+
const url = bunReleaseZipUrl(SDK_BUN_VERSION);
|
|
323
|
+
deps.log(`omp-sdk: downloading bun ${SDK_BUN_VERSION} (${url})`);
|
|
324
|
+
await deps.download(url, zip);
|
|
325
|
+
await deps.run("unzip", ["-o", zip, "-d", staging], { cwd: layout.dir });
|
|
326
|
+
mkdirSync(join(layout.dir, "bin"), { recursive: true });
|
|
327
|
+
deps.copy(join(staging, `bun-${SDK_BUN_PLATFORM}`, "bun"), layout.bun);
|
|
328
|
+
rmSync(staging, { recursive: true, force: true });
|
|
329
|
+
rmSync(zip, { force: true });
|
|
330
|
+
if (!existsSync(layout.bun)) {
|
|
331
|
+
throw new Error(`bun archive produced no ${layout.bun} (unzip layout changed?)`);
|
|
332
|
+
}
|
|
333
|
+
deps.log(`omp-sdk: bun ${SDK_BUN_VERSION} ready at ${layout.bun}`);
|
|
334
|
+
}
|
|
335
|
+
// (b) the SDK package, installed WITH the fetched bun (cwd = the runtime dir),
|
|
336
|
+
// so `node_modules` lands where the sidecar will resolve it from. Slim
|
|
337
|
+
// install: --omit=optional plus the explicit platform binding (see module doc).
|
|
338
|
+
const manifest = join(layout.dir, "package.json");
|
|
339
|
+
if (!existsSync(manifest)) {
|
|
340
|
+
writeFileSync(manifest, JSON.stringify({ name: "omp-sdk-runtime", private: true, version: "0.0.0" }, null, 2) + "\n");
|
|
341
|
+
}
|
|
342
|
+
const platform = sdkNativesPlatform();
|
|
343
|
+
const argv = sdkInstallArgv(SDK_PACKAGE_VERSION, platform, process.env.OMP_SDK_KEEP_OPTIONAL === "1");
|
|
344
|
+
const cacheDir = join(layout.dir, ".cache");
|
|
345
|
+
deps.log(`omp-sdk: installing ${SDK_PACKAGE}@${SDK_PACKAGE_VERSION} (${platform})`);
|
|
346
|
+
await deps.run(layout.bun, argv, { cwd: layout.dir, env: { BUN_INSTALL_CACHE_DIR: cacheDir } });
|
|
347
|
+
// The bun install cache is install-only (~1.2 GB against a ~0.9 GB tree):
|
|
348
|
+
// keeping it would roughly double the disk footprint for nothing.
|
|
349
|
+
rmSync(cacheDir, { recursive: true, force: true });
|
|
350
|
+
// (c) sidecar + compiled protocol live beside node_modules.
|
|
351
|
+
mkdirSync(layout.sidecarDir, { recursive: true });
|
|
352
|
+
deps.copy(join(deps.pluginDir, "sidecar", "main.ts"), layout.sidecarEntry);
|
|
353
|
+
mkdirSync(layout.protocolDir, { recursive: true });
|
|
354
|
+
deps.copy(join(deps.pluginDir, "dist", "protocol.js"), sdkRuntimeProtocolEntry(layout));
|
|
355
|
+
// (c2) smoke: the pin must be importable from source level, or the sidecar
|
|
356
|
+
// would only die on its first import at the first prompt. 18.4.9 fails here
|
|
357
|
+
// (see the module doc) — fail loud now, naming the override. The agent dir is
|
|
358
|
+
// pointed INSIDE the runtime tree so the operator's native `~/.omp` is never
|
|
359
|
+
// touched by a check.
|
|
360
|
+
const smokeDir = join(layout.dir, ".smoke");
|
|
361
|
+
mkdirSync(smokeDir, { recursive: true });
|
|
362
|
+
deps.log(`omp-sdk: smoke-importing ${SDK_PACKAGE}@${SDK_PACKAGE_VERSION}`);
|
|
363
|
+
try {
|
|
364
|
+
await deps.run(layout.bun, ["-e", `await import(${JSON.stringify(SDK_PACKAGE)})`], {
|
|
365
|
+
cwd: layout.dir,
|
|
366
|
+
env: { PI_CODING_AGENT_DIR: smokeDir, OMP_HOME: smokeDir },
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
371
|
+
throw new Error(`smoke import of ${SDK_PACKAGE}@${SDK_PACKAGE_VERSION} failed ` +
|
|
372
|
+
`(override with OMP_SDK_PACKAGE_VERSION — e.g. 18.2.11 — and refetch): ${detail}`);
|
|
373
|
+
}
|
|
374
|
+
finally {
|
|
375
|
+
rmSync(smokeDir, { recursive: true, force: true });
|
|
376
|
+
}
|
|
377
|
+
// (d) marker LAST — a crash before this point leaves an incomplete runtime
|
|
378
|
+
// that the next call heals, never a false success.
|
|
379
|
+
const record = {
|
|
380
|
+
...identity,
|
|
381
|
+
bunPath: layout.bun,
|
|
382
|
+
installedAt: new Date().toISOString(),
|
|
383
|
+
};
|
|
384
|
+
writeFileSync(layout.marker, JSON.stringify(record, null, 2) + "\n");
|
|
385
|
+
rmSync(layout.errorLog, { force: true });
|
|
386
|
+
deps.log(`omp-sdk: runtime ready at ${layout.dir}`);
|
|
387
|
+
return record;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* mkdir-based mutex. Returns owning the lock; throws when a fresh lock is held
|
|
391
|
+
* by someone else; reclaims a lock older than {@link LOCK_STALE_MS}.
|
|
392
|
+
*/
|
|
393
|
+
function acquireLock(layout, deps) {
|
|
394
|
+
for (;;) {
|
|
395
|
+
try {
|
|
396
|
+
mkdirSync(layout.lock);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
if (error.code !== "EEXIST")
|
|
401
|
+
throw error;
|
|
402
|
+
}
|
|
403
|
+
let ageMs;
|
|
404
|
+
try {
|
|
405
|
+
ageMs = Date.now() - statSync(layout.lock).mtimeMs;
|
|
406
|
+
}
|
|
407
|
+
catch {
|
|
408
|
+
continue; // released between the mkdir attempt and the stat — retry now
|
|
409
|
+
}
|
|
410
|
+
if (ageMs > LOCK_STALE_MS) {
|
|
411
|
+
deps.log(`omp-sdk: reclaiming stale runtime lock (age ${Math.round(ageMs / 1000)}s)`);
|
|
412
|
+
rmSync(layout.lock, { recursive: true, force: true });
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
throw new Error(`omp-sdk: another SDK runtime fetch is already in progress (lock ${layout.lock}). ` +
|
|
416
|
+
`Retry once it finishes; if no fetch is running, remove that lock directory.`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-side client for the omp-sdk bun sidecar.
|
|
3
|
+
*
|
|
4
|
+
* The sidecar is NOT shipped as a runtime: this package declares no `bun` and
|
|
5
|
+
* no coding-agent dependency. `start()` is therefore the ONE place the lazy
|
|
6
|
+
* runtime bootstrap is awaited ({@link ensureSdkRuntime}) — it downloads bun +
|
|
7
|
+
* the pinned coding-agent package into `<worldHome>/sdk-runtime/` and copies
|
|
8
|
+
* this package's `sidecar/main.ts` + compiled `dist/protocol.js` there, then
|
|
9
|
+
* the child is spawned with `<runtime>/bin/bun run <runtime>/sidecar/main.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Because `start()` is only reached from the first real dispatch (via
|
|
12
|
+
* `LazyOmpRpc#ensure`), construction — and every passive path — stays at zero
|
|
13
|
+
* network, zero download and zero process.
|
|
14
|
+
*/
|
|
15
|
+
import { type ChildProcess } from "node:child_process";
|
|
16
|
+
import { type SdkRuntimeRecord } from "./sdk-runtime.js";
|
|
17
|
+
import { type EventFrame } from "./protocol.js";
|
|
18
|
+
/**
|
|
19
|
+
* Lazily produce the runtime for a world home and return its layout. Injected
|
|
20
|
+
* so tests can pin the spawn path with zero download and zero real bun.
|
|
21
|
+
*/
|
|
22
|
+
export type SidecarRuntimeFetch = (worldHome: string) => Promise<SdkRuntimeRecord>;
|
|
23
|
+
/**
|
|
24
|
+
* Spawn the sidecar process. Injected so tests can prove the spawn arguments
|
|
25
|
+
* without a real bun binary on the machine.
|
|
26
|
+
*/
|
|
27
|
+
export type SidecarSpawn = (command: string, args: string[], options: {
|
|
28
|
+
cwd: string;
|
|
29
|
+
env: Record<string, string>;
|
|
30
|
+
}) => ChildProcess;
|
|
31
|
+
export interface SidecarOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The DSH world home (`<dshHome>/agents/omp-sdk`). The durable runtime lands
|
|
34
|
+
* in `<worldHome>/sdk-runtime/` — never in this package (read-only in a real
|
|
35
|
+
* consumer install) and never in a prod home.
|
|
36
|
+
*/
|
|
37
|
+
worldHome: string;
|
|
38
|
+
/** Working directory for the sidecar process (default: the runtime dir). */
|
|
39
|
+
cwd?: string;
|
|
40
|
+
/** extra env for the sidecar process */
|
|
41
|
+
env?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* Override the runtime bootstrap (tests inject a fake so no bun is fetched
|
|
44
|
+
* and no network is touched). Defaults to {@link ensureSdkRuntime} with the
|
|
45
|
+
* package's real deps.
|
|
46
|
+
*/
|
|
47
|
+
runtimeFetch?: SidecarRuntimeFetch;
|
|
48
|
+
/**
|
|
49
|
+
* How long `start()` waits for the sidecar's `ready` frame (default 60 s).
|
|
50
|
+
* Overridable so a test can fail fast instead of holding a child for a
|
|
51
|
+
* minute.
|
|
52
|
+
*/
|
|
53
|
+
readyTimeoutMs?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Override the actual child-process spawn (tests drive the bootstrap with a
|
|
56
|
+
* fake process object, so no bun binary is ever required).
|
|
57
|
+
*/
|
|
58
|
+
spawnProcess?: SidecarSpawn;
|
|
59
|
+
}
|
|
60
|
+
export declare class OmpSdkSidecar {
|
|
61
|
+
#private;
|
|
62
|
+
private options;
|
|
63
|
+
private proc;
|
|
64
|
+
private nextId;
|
|
65
|
+
private pending;
|
|
66
|
+
private eventHandlers;
|
|
67
|
+
private readyPromise;
|
|
68
|
+
private buffer;
|
|
69
|
+
private startError;
|
|
70
|
+
constructor(options: SidecarOptions);
|
|
71
|
+
get started(): boolean;
|
|
72
|
+
onEvent(handler: (frame: EventFrame) => void): () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Fetch/reuse the durable runtime and spawn the sidecar on it.
|
|
75
|
+
*
|
|
76
|
+
* This is the FIRST and ONLY place the runtime bootstrap runs — the whole
|
|
77
|
+
* point of the opt-in SDK row is that nothing is downloaded until a real
|
|
78
|
+
* prompt materializes the transport.
|
|
79
|
+
*/
|
|
80
|
+
start(): Promise<{
|
|
81
|
+
protocol: number;
|
|
82
|
+
}>;
|
|
83
|
+
private consume;
|
|
84
|
+
call<T = any>(method: string, params?: unknown): Promise<T>;
|
|
85
|
+
notify(method: string, params?: unknown): void;
|
|
86
|
+
stop(): Promise<void>;
|
|
87
|
+
}
|