@richhardry/codor 0.10.0
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/LICENSE +21 -0
- package/README.md +293 -0
- package/bin/codor.mjs +7 -0
- package/node_modules/@codor/adapter-antigravity/dist/adapter.d.ts +41 -0
- package/node_modules/@codor/adapter-antigravity/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-antigravity/dist/adapter.js +275 -0
- package/node_modules/@codor/adapter-antigravity/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-antigravity/dist/index.d.ts +2 -0
- package/node_modules/@codor/adapter-antigravity/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-antigravity/dist/index.js +2 -0
- package/node_modules/@codor/adapter-antigravity/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-antigravity/package.json +18 -0
- package/node_modules/@codor/adapter-claude-code/dist/adapter.d.ts +94 -0
- package/node_modules/@codor/adapter-claude-code/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/adapter.js +785 -0
- package/node_modules/@codor/adapter-claude-code/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/index.d.ts +8 -0
- package/node_modules/@codor/adapter-claude-code/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/index.js +5 -0
- package/node_modules/@codor/adapter-claude-code/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/limits-probe.d.ts +18 -0
- package/node_modules/@codor/adapter-claude-code/dist/limits-probe.d.ts.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/limits-probe.js +67 -0
- package/node_modules/@codor/adapter-claude-code/dist/limits-probe.js.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/peek.d.ts +3 -0
- package/node_modules/@codor/adapter-claude-code/dist/peek.d.ts.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/peek.js +128 -0
- package/node_modules/@codor/adapter-claude-code/dist/peek.js.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/query.d.ts +9 -0
- package/node_modules/@codor/adapter-claude-code/dist/query.d.ts.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/query.js +7 -0
- package/node_modules/@codor/adapter-claude-code/dist/query.js.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/translate.d.ts +40 -0
- package/node_modules/@codor/adapter-claude-code/dist/translate.d.ts.map +1 -0
- package/node_modules/@codor/adapter-claude-code/dist/translate.js +505 -0
- package/node_modules/@codor/adapter-claude-code/dist/translate.js.map +1 -0
- package/node_modules/@codor/adapter-claude-code/package.json +18 -0
- package/node_modules/@codor/adapter-codex/dist/adapter.d.ts +105 -0
- package/node_modules/@codor/adapter-codex/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/adapter.js +625 -0
- package/node_modules/@codor/adapter-codex/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/app-server-transport.d.ts +39 -0
- package/node_modules/@codor/adapter-codex/dist/app-server-transport.d.ts.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/app-server-transport.js +186 -0
- package/node_modules/@codor/adapter-codex/dist/app-server-transport.js.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/index.d.ts +8 -0
- package/node_modules/@codor/adapter-codex/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/index.js +5 -0
- package/node_modules/@codor/adapter-codex/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/limits-probe.d.ts +18 -0
- package/node_modules/@codor/adapter-codex/dist/limits-probe.d.ts.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/limits-probe.js +87 -0
- package/node_modules/@codor/adapter-codex/dist/limits-probe.js.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/peek.d.ts +3 -0
- package/node_modules/@codor/adapter-codex/dist/peek.d.ts.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/peek.js +98 -0
- package/node_modules/@codor/adapter-codex/dist/peek.js.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/translate.d.ts +17 -0
- package/node_modules/@codor/adapter-codex/dist/translate.d.ts.map +1 -0
- package/node_modules/@codor/adapter-codex/dist/translate.js +286 -0
- package/node_modules/@codor/adapter-codex/dist/translate.js.map +1 -0
- package/node_modules/@codor/adapter-codex/package.json +17 -0
- package/node_modules/@codor/adapter-copilot/dist/adapter.d.ts +40 -0
- package/node_modules/@codor/adapter-copilot/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-copilot/dist/adapter.js +190 -0
- package/node_modules/@codor/adapter-copilot/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-copilot/dist/index.d.ts +4 -0
- package/node_modules/@codor/adapter-copilot/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-copilot/dist/index.js +3 -0
- package/node_modules/@codor/adapter-copilot/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-copilot/dist/translate.d.ts +11 -0
- package/node_modules/@codor/adapter-copilot/dist/translate.d.ts.map +1 -0
- package/node_modules/@codor/adapter-copilot/dist/translate.js +184 -0
- package/node_modules/@codor/adapter-copilot/dist/translate.js.map +1 -0
- package/node_modules/@codor/adapter-copilot/package.json +18 -0
- package/node_modules/@codor/adapter-cursor/dist/adapter.d.ts +32 -0
- package/node_modules/@codor/adapter-cursor/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-cursor/dist/adapter.js +179 -0
- package/node_modules/@codor/adapter-cursor/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-cursor/dist/index.d.ts +9 -0
- package/node_modules/@codor/adapter-cursor/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-cursor/dist/index.js +8 -0
- package/node_modules/@codor/adapter-cursor/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-cursor/dist/translate.d.ts +15 -0
- package/node_modules/@codor/adapter-cursor/dist/translate.d.ts.map +1 -0
- package/node_modules/@codor/adapter-cursor/dist/translate.js +164 -0
- package/node_modules/@codor/adapter-cursor/dist/translate.js.map +1 -0
- package/node_modules/@codor/adapter-cursor/package.json +17 -0
- package/node_modules/@codor/adapter-gemini/dist/adapter.d.ts +36 -0
- package/node_modules/@codor/adapter-gemini/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-gemini/dist/adapter.js +245 -0
- package/node_modules/@codor/adapter-gemini/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-gemini/dist/index.d.ts +4 -0
- package/node_modules/@codor/adapter-gemini/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-gemini/dist/index.js +3 -0
- package/node_modules/@codor/adapter-gemini/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-gemini/dist/translate.d.ts +12 -0
- package/node_modules/@codor/adapter-gemini/dist/translate.d.ts.map +1 -0
- package/node_modules/@codor/adapter-gemini/dist/translate.js +123 -0
- package/node_modules/@codor/adapter-gemini/dist/translate.js.map +1 -0
- package/node_modules/@codor/adapter-gemini/package.json +18 -0
- package/node_modules/@codor/adapter-opencode/dist/adapter.d.ts +42 -0
- package/node_modules/@codor/adapter-opencode/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/adapter-opencode/dist/adapter.js +240 -0
- package/node_modules/@codor/adapter-opencode/dist/adapter.js.map +1 -0
- package/node_modules/@codor/adapter-opencode/dist/index.d.ts +4 -0
- package/node_modules/@codor/adapter-opencode/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/adapter-opencode/dist/index.js +3 -0
- package/node_modules/@codor/adapter-opencode/dist/index.js.map +1 -0
- package/node_modules/@codor/adapter-opencode/dist/translate.d.ts +12 -0
- package/node_modules/@codor/adapter-opencode/dist/translate.d.ts.map +1 -0
- package/node_modules/@codor/adapter-opencode/dist/translate.js +144 -0
- package/node_modules/@codor/adapter-opencode/dist/translate.js.map +1 -0
- package/node_modules/@codor/adapter-opencode/package.json +18 -0
- package/node_modules/@codor/cli/dist/artifact.d.ts +33 -0
- package/node_modules/@codor/cli/dist/artifact.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/artifact.js +183 -0
- package/node_modules/@codor/cli/dist/artifact.js.map +1 -0
- package/node_modules/@codor/cli/dist/attach.d.ts +25 -0
- package/node_modules/@codor/cli/dist/attach.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/attach.js +133 -0
- package/node_modules/@codor/cli/dist/attach.js.map +1 -0
- package/node_modules/@codor/cli/dist/connection.d.ts +21 -0
- package/node_modules/@codor/cli/dist/connection.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/connection.js +130 -0
- package/node_modules/@codor/cli/dist/connection.js.map +1 -0
- package/node_modules/@codor/cli/dist/detect.d.ts +14 -0
- package/node_modules/@codor/cli/dist/detect.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/detect.js +99 -0
- package/node_modules/@codor/cli/dist/detect.js.map +1 -0
- package/node_modules/@codor/cli/dist/index.d.ts +17 -0
- package/node_modules/@codor/cli/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/index.js +24 -0
- package/node_modules/@codor/cli/dist/index.js.map +1 -0
- package/node_modules/@codor/cli/dist/mirror.d.ts +4 -0
- package/node_modules/@codor/cli/dist/mirror.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/mirror.js +93 -0
- package/node_modules/@codor/cli/dist/mirror.js.map +1 -0
- package/node_modules/@codor/cli/dist/program.d.ts +17 -0
- package/node_modules/@codor/cli/dist/program.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/program.js +1068 -0
- package/node_modules/@codor/cli/dist/program.js.map +1 -0
- package/node_modules/@codor/cli/dist/runtime-install.d.ts +61 -0
- package/node_modules/@codor/cli/dist/runtime-install.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/runtime-install.js +122 -0
- package/node_modules/@codor/cli/dist/runtime-install.js.map +1 -0
- package/node_modules/@codor/cli/dist/runtime-paths.d.ts +24 -0
- package/node_modules/@codor/cli/dist/runtime-paths.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/runtime-paths.js +69 -0
- package/node_modules/@codor/cli/dist/runtime-paths.js.map +1 -0
- package/node_modules/@codor/cli/dist/setup-flow.d.ts +69 -0
- package/node_modules/@codor/cli/dist/setup-flow.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/setup-flow.js +110 -0
- package/node_modules/@codor/cli/dist/setup-flow.js.map +1 -0
- package/node_modules/@codor/cli/dist/setup-session.d.ts +105 -0
- package/node_modules/@codor/cli/dist/setup-session.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/setup-session.js +346 -0
- package/node_modules/@codor/cli/dist/setup-session.js.map +1 -0
- package/node_modules/@codor/cli/dist/setup-ui.d.ts +93 -0
- package/node_modules/@codor/cli/dist/setup-ui.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/setup-ui.js +249 -0
- package/node_modules/@codor/cli/dist/setup-ui.js.map +1 -0
- package/node_modules/@codor/cli/dist/setup.d.ts +108 -0
- package/node_modules/@codor/cli/dist/setup.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/setup.js +878 -0
- package/node_modules/@codor/cli/dist/setup.js.map +1 -0
- package/node_modules/@codor/cli/dist/terminal-keys.d.ts +26 -0
- package/node_modules/@codor/cli/dist/terminal-keys.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/terminal-keys.js +70 -0
- package/node_modules/@codor/cli/dist/terminal-keys.js.map +1 -0
- package/node_modules/@codor/cli/dist/terminal-qr.d.ts +2 -0
- package/node_modules/@codor/cli/dist/terminal-qr.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/terminal-qr.js +30 -0
- package/node_modules/@codor/cli/dist/terminal-qr.js.map +1 -0
- package/node_modules/@codor/cli/dist/up.d.ts +52 -0
- package/node_modules/@codor/cli/dist/up.d.ts.map +1 -0
- package/node_modules/@codor/cli/dist/up.js +178 -0
- package/node_modules/@codor/cli/dist/up.js.map +1 -0
- package/node_modules/@codor/cli/package.json +24 -0
- package/node_modules/@codor/cli/packaging/systemd/codor.service +21 -0
- package/node_modules/@codor/cli/runtime/web/assets/LandingPage-BOmG5kSw.js +31 -0
- package/node_modules/@codor/cli/runtime/web/assets/LedgerPage-CecuTS8-.js +1 -0
- package/node_modules/@codor/cli/runtime/web/assets/NoChannels-CYiBXGQd.js +11 -0
- package/node_modules/@codor/cli/runtime/web/assets/PairingCodeInput-Cr6XDWx-.js +1 -0
- package/node_modules/@codor/cli/runtime/web/assets/PairingPage-CQBWNA2L.js +6 -0
- package/node_modules/@codor/cli/runtime/web/assets/SettingsPage-DGLbSXE7.js +16 -0
- package/node_modules/@codor/cli/runtime/web/assets/StartupUnavailable-DdQBHip_.js +1 -0
- package/node_modules/@codor/cli/runtime/web/assets/arrow-left-BOpjMuRi.js +6 -0
- package/node_modules/@codor/cli/runtime/web/assets/browser-BWQYNOsD.js +6 -0
- package/node_modules/@codor/cli/runtime/web/assets/graph-toBZHlC0.js +1 -0
- package/node_modules/@codor/cli/runtime/web/assets/index-Cxi54Xim.js +408 -0
- package/node_modules/@codor/cli/runtime/web/assets/index-DjwJakJC.css +1 -0
- package/node_modules/@codor/cli/runtime/web/assets/qr-DpynCwP9.js +8 -0
- package/node_modules/@codor/cli/runtime/web/assets/react-C8w-UNLI.js +32 -0
- package/node_modules/@codor/cli/runtime/web/assets/sodium-DtsvMzX9.js +1 -0
- package/node_modules/@codor/cli/runtime/web/codor-192.png +0 -0
- package/node_modules/@codor/cli/runtime/web/codor-512.png +0 -0
- package/node_modules/@codor/cli/runtime/web/codor-apple-touch-180.png +0 -0
- package/node_modules/@codor/cli/runtime/web/codor-favicon.svg +86 -0
- package/node_modules/@codor/cli/runtime/web/codor-mark.svg +86 -0
- package/node_modules/@codor/cli/runtime/web/codor-maskable-512.png +0 -0
- package/node_modules/@codor/cli/runtime/web/codor-og.png +0 -0
- package/node_modules/@codor/cli/runtime/web/fonts/BitcountPropSingle-latin.woff2 +0 -0
- package/node_modules/@codor/cli/runtime/web/fonts/Geist-Variable.woff2 +0 -0
- package/node_modules/@codor/cli/runtime/web/fonts/GeistMono-Variable.woff2 +0 -0
- package/node_modules/@codor/cli/runtime/web/fonts/OFL.txt +93 -0
- package/node_modules/@codor/cli/runtime/web/index.html +53 -0
- package/node_modules/@codor/cli/runtime/web/manifest.webmanifest +1 -0
- package/node_modules/@codor/cli/runtime/web/sw.js +2 -0
- package/node_modules/@codor/protocol/dist/adapter.d.ts +118 -0
- package/node_modules/@codor/protocol/dist/adapter.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/adapter.js +15 -0
- package/node_modules/@codor/protocol/dist/adapter.js.map +1 -0
- package/node_modules/@codor/protocol/dist/body.d.ts +14 -0
- package/node_modules/@codor/protocol/dist/body.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/body.js +50 -0
- package/node_modules/@codor/protocol/dist/body.js.map +1 -0
- package/node_modules/@codor/protocol/dist/changelog.d.ts +30 -0
- package/node_modules/@codor/protocol/dist/changelog.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/changelog.js +19 -0
- package/node_modules/@codor/protocol/dist/changelog.js.map +1 -0
- package/node_modules/@codor/protocol/dist/default-recipient.d.ts +8 -0
- package/node_modules/@codor/protocol/dist/default-recipient.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/default-recipient.js +19 -0
- package/node_modules/@codor/protocol/dist/default-recipient.js.map +1 -0
- package/node_modules/@codor/protocol/dist/delivery.d.ts +42 -0
- package/node_modules/@codor/protocol/dist/delivery.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/delivery.js +44 -0
- package/node_modules/@codor/protocol/dist/delivery.js.map +1 -0
- package/node_modules/@codor/protocol/dist/events.d.ts +284 -0
- package/node_modules/@codor/protocol/dist/events.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/events.js +150 -0
- package/node_modules/@codor/protocol/dist/events.js.map +1 -0
- package/node_modules/@codor/protocol/dist/ids.d.ts +19 -0
- package/node_modules/@codor/protocol/dist/ids.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/ids.js +27 -0
- package/node_modules/@codor/protocol/dist/ids.js.map +1 -0
- package/node_modules/@codor/protocol/dist/index.d.ts +14 -0
- package/node_modules/@codor/protocol/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/index.js +14 -0
- package/node_modules/@codor/protocol/dist/index.js.map +1 -0
- package/node_modules/@codor/protocol/dist/interaction.d.ts +45 -0
- package/node_modules/@codor/protocol/dist/interaction.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/interaction.js +33 -0
- package/node_modules/@codor/protocol/dist/interaction.js.map +1 -0
- package/node_modules/@codor/protocol/dist/member.d.ts +146 -0
- package/node_modules/@codor/protocol/dist/member.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/member.js +169 -0
- package/node_modules/@codor/protocol/dist/member.js.map +1 -0
- package/node_modules/@codor/protocol/dist/message.d.ts +166 -0
- package/node_modules/@codor/protocol/dist/message.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/message.js +95 -0
- package/node_modules/@codor/protocol/dist/message.js.map +1 -0
- package/node_modules/@codor/protocol/dist/observability.d.ts +80 -0
- package/node_modules/@codor/protocol/dist/observability.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/observability.js +41 -0
- package/node_modules/@codor/protocol/dist/observability.js.map +1 -0
- package/node_modules/@codor/protocol/dist/room.d.ts +430 -0
- package/node_modules/@codor/protocol/dist/room.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/room.js +142 -0
- package/node_modules/@codor/protocol/dist/room.js.map +1 -0
- package/node_modules/@codor/protocol/dist/ws.d.ts +1348 -0
- package/node_modules/@codor/protocol/dist/ws.d.ts.map +1 -0
- package/node_modules/@codor/protocol/dist/ws.js +282 -0
- package/node_modules/@codor/protocol/dist/ws.js.map +1 -0
- package/node_modules/@codor/protocol/package.json +17 -0
- package/node_modules/@codor/switchboard/dist/adapter-registry.d.ts +14 -0
- package/node_modules/@codor/switchboard/dist/adapter-registry.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/adapter-registry.js +175 -0
- package/node_modules/@codor/switchboard/dist/adapter-registry.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/authorization.d.ts +13 -0
- package/node_modules/@codor/switchboard/dist/authorization.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/authorization.js +96 -0
- package/node_modules/@codor/switchboard/dist/authorization.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/blobs.d.ts +17 -0
- package/node_modules/@codor/switchboard/dist/blobs.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/blobs.js +54 -0
- package/node_modules/@codor/switchboard/dist/blobs.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/collaboration.d.ts +115 -0
- package/node_modules/@codor/switchboard/dist/collaboration.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/collaboration.js +123 -0
- package/node_modules/@codor/switchboard/dist/collaboration.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/continuation.d.ts +33 -0
- package/node_modules/@codor/switchboard/dist/continuation.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/continuation.js +177 -0
- package/node_modules/@codor/switchboard/dist/continuation.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/browser-sessions.d.ts +22 -0
- package/node_modules/@codor/switchboard/dist/crypto/browser-sessions.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/browser-sessions.js +92 -0
- package/node_modules/@codor/switchboard/dist/crypto/browser-sessions.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/challenge.d.ts +37 -0
- package/node_modules/@codor/switchboard/dist/crypto/challenge.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/challenge.js +132 -0
- package/node_modules/@codor/switchboard/dist/crypto/challenge.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/keys.d.ts +41 -0
- package/node_modules/@codor/switchboard/dist/crypto/keys.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/keys.js +145 -0
- package/node_modules/@codor/switchboard/dist/crypto/keys.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/pairing.d.ts +53 -0
- package/node_modules/@codor/switchboard/dist/crypto/pairing.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/pairing.js +182 -0
- package/node_modules/@codor/switchboard/dist/crypto/pairing.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/roomkeys.d.ts +30 -0
- package/node_modules/@codor/switchboard/dist/crypto/roomkeys.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/crypto/roomkeys.js +101 -0
- package/node_modules/@codor/switchboard/dist/crypto/roomkeys.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/daemon.d.ts +545 -0
- package/node_modules/@codor/switchboard/dist/daemon.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/daemon.js +3907 -0
- package/node_modules/@codor/switchboard/dist/daemon.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/fake-adapter.d.ts +103 -0
- package/node_modules/@codor/switchboard/dist/fake-adapter.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/fake-adapter.js +228 -0
- package/node_modules/@codor/switchboard/dist/fake-adapter.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/index.d.ts +44 -0
- package/node_modules/@codor/switchboard/dist/index.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/index.js +24 -0
- package/node_modules/@codor/switchboard/dist/index.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/ledger/resolve.d.ts +12 -0
- package/node_modules/@codor/switchboard/dist/ledger/resolve.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/ledger/resolve.js +17 -0
- package/node_modules/@codor/switchboard/dist/ledger/resolve.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/ledger/vault.d.ts +47 -0
- package/node_modules/@codor/switchboard/dist/ledger/vault.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/ledger/vault.js +175 -0
- package/node_modules/@codor/switchboard/dist/ledger/vault.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/ledger/watch.d.ts +73 -0
- package/node_modules/@codor/switchboard/dist/ledger/watch.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/ledger/watch.js +232 -0
- package/node_modules/@codor/switchboard/dist/ledger/watch.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/local-dirs.d.ts +14 -0
- package/node_modules/@codor/switchboard/dist/local-dirs.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/local-dirs.js +40 -0
- package/node_modules/@codor/switchboard/dist/local-dirs.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/local-socket.d.ts +3 -0
- package/node_modules/@codor/switchboard/dist/local-socket.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/local-socket.js +16 -0
- package/node_modules/@codor/switchboard/dist/local-socket.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/pricing.d.ts +32 -0
- package/node_modules/@codor/switchboard/dist/pricing.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/pricing.js +64 -0
- package/node_modules/@codor/switchboard/dist/pricing.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/process-liveness.d.ts +2 -0
- package/node_modules/@codor/switchboard/dist/process-liveness.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/process-liveness.js +9 -0
- package/node_modules/@codor/switchboard/dist/process-liveness.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/push/producer.d.ts +54 -0
- package/node_modules/@codor/switchboard/dist/push/producer.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/push/producer.js +168 -0
- package/node_modules/@codor/switchboard/dist/push/producer.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/push/subscriptions.d.ts +29 -0
- package/node_modules/@codor/switchboard/dist/push/subscriptions.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/push/subscriptions.js +83 -0
- package/node_modules/@codor/switchboard/dist/push/subscriptions.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/redact.d.ts +11 -0
- package/node_modules/@codor/switchboard/dist/redact.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/redact.js +65 -0
- package/node_modules/@codor/switchboard/dist/redact.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/residency.d.ts +110 -0
- package/node_modules/@codor/switchboard/dist/residency.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/residency.js +587 -0
- package/node_modules/@codor/switchboard/dist/residency.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/router.d.ts +120 -0
- package/node_modules/@codor/switchboard/dist/router.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/router.js +198 -0
- package/node_modules/@codor/switchboard/dist/router.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/server.d.ts +50 -0
- package/node_modules/@codor/switchboard/dist/server.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/server.js +1425 -0
- package/node_modules/@codor/switchboard/dist/server.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/store.d.ts +534 -0
- package/node_modules/@codor/switchboard/dist/store.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/store.js +2625 -0
- package/node_modules/@codor/switchboard/dist/store.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/transport/hyperswarm.d.ts +59 -0
- package/node_modules/@codor/switchboard/dist/transport/hyperswarm.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/transport/hyperswarm.js +183 -0
- package/node_modules/@codor/switchboard/dist/transport/hyperswarm.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/transport/peer.d.ts +87 -0
- package/node_modules/@codor/switchboard/dist/transport/peer.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/transport/peer.js +316 -0
- package/node_modules/@codor/switchboard/dist/transport/peer.js.map +1 -0
- package/node_modules/@codor/switchboard/dist/working-directory.d.ts +2 -0
- package/node_modules/@codor/switchboard/dist/working-directory.d.ts.map +1 -0
- package/node_modules/@codor/switchboard/dist/working-directory.js +26 -0
- package/node_modules/@codor/switchboard/dist/working-directory.js.map +1 -0
- package/node_modules/@codor/switchboard/package.json +33 -0
- package/package.json +58 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync, } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
export const PUBLIC_PACKAGE_NAME = '@richhardry/codor';
|
|
5
|
+
export const ENTRY_PACKAGE = '@codor/cli';
|
|
6
|
+
const WORKSPACE_DIRS = ['packages', 'packages/adapters', 'packages/bridges'];
|
|
7
|
+
const WORKSPACE_PROTOCOL = 'workspace:';
|
|
8
|
+
function readManifest(path) {
|
|
9
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
10
|
+
}
|
|
11
|
+
export function readWorkspace(repoRoot) {
|
|
12
|
+
const found = new Map();
|
|
13
|
+
for (const group of WORKSPACE_DIRS) {
|
|
14
|
+
const groupDir = join(repoRoot, group);
|
|
15
|
+
if (!existsSync(groupDir))
|
|
16
|
+
continue;
|
|
17
|
+
for (const entry of readdirSync(groupDir, { withFileTypes: true })) {
|
|
18
|
+
if (!entry.isDirectory())
|
|
19
|
+
continue;
|
|
20
|
+
const dir = join(groupDir, entry.name);
|
|
21
|
+
const manifestPath = join(dir, 'package.json');
|
|
22
|
+
if (!existsSync(manifestPath))
|
|
23
|
+
continue;
|
|
24
|
+
const manifest = readManifest(manifestPath);
|
|
25
|
+
if (typeof manifest.name !== 'string')
|
|
26
|
+
continue;
|
|
27
|
+
found.set(manifest.name, { name: manifest.name, dir, manifest });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return found;
|
|
31
|
+
}
|
|
32
|
+
export function discoverClosure(workspace, entry = ENTRY_PACKAGE) {
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
const walk = (name) => {
|
|
35
|
+
if (seen.has(name))
|
|
36
|
+
return;
|
|
37
|
+
const pkg = workspace.get(name);
|
|
38
|
+
if (pkg === undefined)
|
|
39
|
+
throw new Error(`closure walk reached unknown workspace package ${name}`);
|
|
40
|
+
seen.add(name);
|
|
41
|
+
for (const dependency of Object.keys(pkg.manifest.dependencies ?? {})) {
|
|
42
|
+
if (workspace.has(dependency))
|
|
43
|
+
walk(dependency);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
walk(entry);
|
|
47
|
+
return [...seen].sort();
|
|
48
|
+
}
|
|
49
|
+
export function hoistThirdPartyDependencies(workspace, closure) {
|
|
50
|
+
const hoisted = {};
|
|
51
|
+
const origin = {};
|
|
52
|
+
for (const name of closure) {
|
|
53
|
+
const pkg = workspace.get(name);
|
|
54
|
+
if (pkg === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
for (const [dependency, range] of Object.entries(pkg.manifest.dependencies ?? {})) {
|
|
57
|
+
if (workspace.has(dependency))
|
|
58
|
+
continue;
|
|
59
|
+
const existing = hoisted[dependency];
|
|
60
|
+
if (existing !== undefined && existing !== range) {
|
|
61
|
+
throw new Error(`conflicting ranges for ${dependency}: ${origin[dependency]} wants ${existing}, ${name} wants ${range}`);
|
|
62
|
+
}
|
|
63
|
+
hoisted[dependency] = range;
|
|
64
|
+
origin[dependency] = name;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return Object.fromEntries(Object.entries(hoisted).sort(([a], [b]) => a.localeCompare(b)));
|
|
68
|
+
}
|
|
69
|
+
export function stageManifest(manifest, versions) {
|
|
70
|
+
const staged = { ...manifest };
|
|
71
|
+
delete staged.devDependencies;
|
|
72
|
+
delete staged.scripts;
|
|
73
|
+
delete staged.private;
|
|
74
|
+
if (staged.dependencies !== undefined) {
|
|
75
|
+
staged.dependencies = Object.fromEntries(Object.entries(staged.dependencies).map(([name, range]) => {
|
|
76
|
+
if (!range.startsWith(WORKSPACE_PROTOCOL))
|
|
77
|
+
return [name, range];
|
|
78
|
+
const version = versions.get(name);
|
|
79
|
+
if (version === undefined) {
|
|
80
|
+
throw new Error(`cannot resolve ${name} to an exact version while staging`);
|
|
81
|
+
}
|
|
82
|
+
return [name, version];
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
return staged;
|
|
86
|
+
}
|
|
87
|
+
// harn:assume public-cli-delegation-reports-concise-failures ref=public-wrapper-delegation
|
|
88
|
+
export function renderWrapperExecutable() {
|
|
89
|
+
return `#!/usr/bin/env node
|
|
90
|
+
import { runCli } from '${ENTRY_PACKAGE}';
|
|
91
|
+
|
|
92
|
+
await runCli().catch((error) => {
|
|
93
|
+
process.stderr.write(\`\${error instanceof Error ? error.message : String(error)}\\n\`);
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
});
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
function assertNoSymlinks(root) {
|
|
99
|
+
const visit = (path) => {
|
|
100
|
+
for (const entry of readdirSync(path, { withFileTypes: true })) {
|
|
101
|
+
const child = join(path, entry.name);
|
|
102
|
+
if (lstatSync(child).isSymbolicLink()) {
|
|
103
|
+
throw new Error(`artifact staging refuses symlink ${child}`);
|
|
104
|
+
}
|
|
105
|
+
if (entry.isDirectory())
|
|
106
|
+
visit(child);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
visit(root);
|
|
110
|
+
}
|
|
111
|
+
// harn:assume public-package-bundles-complete-codor-runtime ref=artifact-runtime-builder
|
|
112
|
+
export function buildArtifact(options) {
|
|
113
|
+
const repoRoot = resolve(options.repoRoot);
|
|
114
|
+
const outDir = resolve(options.outDir);
|
|
115
|
+
const publicName = options.publicName ?? PUBLIC_PACKAGE_NAME;
|
|
116
|
+
const workspace = readWorkspace(repoRoot);
|
|
117
|
+
const closure = discoverClosure(workspace);
|
|
118
|
+
const versions = new Map(closure.map((name) => {
|
|
119
|
+
const version = workspace.get(name)?.manifest.version;
|
|
120
|
+
if (typeof version !== 'string')
|
|
121
|
+
throw new Error(`workspace package ${name} has no version to bundle`);
|
|
122
|
+
return [name, version];
|
|
123
|
+
}));
|
|
124
|
+
const entry = workspace.get(ENTRY_PACKAGE);
|
|
125
|
+
if (entry === undefined)
|
|
126
|
+
throw new Error(`${ENTRY_PACKAGE} is not a workspace package`);
|
|
127
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
128
|
+
mkdirSync(outDir, { recursive: true });
|
|
129
|
+
for (const name of closure) {
|
|
130
|
+
const pkg = workspace.get(name);
|
|
131
|
+
const dist = join(pkg.dir, 'dist');
|
|
132
|
+
if (!existsSync(dist)) {
|
|
133
|
+
throw new Error(`${name} has no dist; build the workspace before staging the artifact`);
|
|
134
|
+
}
|
|
135
|
+
const stagedDir = join(outDir, 'node_modules', name);
|
|
136
|
+
mkdirSync(stagedDir, { recursive: true });
|
|
137
|
+
cpSync(dist, join(stagedDir, 'dist'), { recursive: true });
|
|
138
|
+
rmSync(join(stagedDir, 'dist', 'test-utils'), { recursive: true, force: true });
|
|
139
|
+
rmSync(join(stagedDir, 'dist', 'fixtures'), { recursive: true, force: true });
|
|
140
|
+
writeFileSync(join(stagedDir, 'package.json'), `${JSON.stringify(stageManifest(pkg.manifest, versions), undefined, 2)}\n`, 'utf8');
|
|
141
|
+
}
|
|
142
|
+
const stagedCli = join(outDir, 'node_modules', ENTRY_PACKAGE);
|
|
143
|
+
const webDist = join(repoRoot, 'packages', 'web-next', 'dist');
|
|
144
|
+
if (!existsSync(webDist))
|
|
145
|
+
throw new Error('@codor/web-next has no dist; build it before staging the artifact');
|
|
146
|
+
cpSync(webDist, join(stagedCli, 'runtime', 'web'), { recursive: true });
|
|
147
|
+
const templateTarget = join(stagedCli, 'packaging', 'systemd', 'codor.service');
|
|
148
|
+
mkdirSync(dirname(templateTarget), { recursive: true });
|
|
149
|
+
cpSync(join(repoRoot, 'packaging', 'systemd', 'codor.service'), templateTarget);
|
|
150
|
+
const binPath = join(outDir, 'bin', 'codor.mjs');
|
|
151
|
+
mkdirSync(dirname(binPath), { recursive: true });
|
|
152
|
+
writeFileSync(binPath, renderWrapperExecutable(), { encoding: 'utf8', mode: 0o755 });
|
|
153
|
+
for (const doc of ['README.md', 'LICENSE'])
|
|
154
|
+
cpSync(join(repoRoot, doc), join(outDir, doc));
|
|
155
|
+
const manifest = {
|
|
156
|
+
name: publicName,
|
|
157
|
+
version: versions.get(ENTRY_PACKAGE),
|
|
158
|
+
description: 'Codor - one channel for every coding agent.',
|
|
159
|
+
license: 'MIT',
|
|
160
|
+
type: 'module',
|
|
161
|
+
bin: { codor: './bin/codor.mjs' },
|
|
162
|
+
files: ['bin', 'README.md', 'LICENSE'],
|
|
163
|
+
engines: { node: '>=22.12.0' },
|
|
164
|
+
publishConfig: { access: 'public' },
|
|
165
|
+
dependencies: {
|
|
166
|
+
...Object.fromEntries(closure.map((name) => [name, versions.get(name) ?? ''])),
|
|
167
|
+
...hoistThirdPartyDependencies(workspace, closure),
|
|
168
|
+
},
|
|
169
|
+
bundleDependencies: [...closure],
|
|
170
|
+
};
|
|
171
|
+
writeFileSync(join(outDir, 'package.json'), `${JSON.stringify(manifest, undefined, 2)}\n`, 'utf8');
|
|
172
|
+
assertNoSymlinks(outDir);
|
|
173
|
+
return { outDir, closure, manifest };
|
|
174
|
+
}
|
|
175
|
+
// harn:end public-package-bundles-complete-codor-runtime
|
|
176
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
|
|
177
|
+
const repoRoot = fileURLToPath(new URL('../../../', import.meta.url));
|
|
178
|
+
const outDir = process.argv[2] ?? join(repoRoot, 'artifact', 'codor');
|
|
179
|
+
const result = buildArtifact({ repoRoot, outDir });
|
|
180
|
+
process.stdout.write(`staged ${result.manifest.name ?? ''}@${result.manifest.version ?? ''} -> ${result.outDir}\n`);
|
|
181
|
+
process.stdout.write(`bundled ${String(result.closure.length)}: ${result.closure.join(', ')}\n`);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -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AM,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IACpH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ChildProcess, type SpawnOptions } from 'node:child_process';
|
|
2
|
+
import type { AttachLease, Member } from '@codor/protocol';
|
|
3
|
+
import type { ProtocolClient } from './connection.js';
|
|
4
|
+
export interface InteractiveCommand {
|
|
5
|
+
command: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
}
|
|
8
|
+
export type InteractiveCommandResolver = (member: Member, env: NodeJS.ProcessEnv) => InteractiveCommand;
|
|
9
|
+
export type InteractiveSpawner = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
10
|
+
export declare const nativeResumeCommand: InteractiveCommandResolver;
|
|
11
|
+
export declare function superviseInteractiveAttach(input: {
|
|
12
|
+
client: ProtocolClient;
|
|
13
|
+
room: string;
|
|
14
|
+
member: Member;
|
|
15
|
+
lease: AttachLease;
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
commandResolver?: InteractiveCommandResolver;
|
|
18
|
+
spawnChild?: InteractiveSpawner;
|
|
19
|
+
heartbeatMs?: number;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
status: 'completed' | 'uncertain';
|
|
22
|
+
code: number | null;
|
|
23
|
+
signal: NodeJS.Signals | null;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=attach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../src/attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,MAAM,0BAA0B,GAAG,CACvC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,KACnB,kBAAkB,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,YAAY,KAClB,YAAY,CAAC;AAGlB,eAAO,MAAM,mBAAmB,EAAE,0BAiCjC,CAAC;AA6BF,wBAAsB,0BAA0B,CAAC,KAAK,EAAE;IACtD,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,0BAA0B,CAAC;IAC7C,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC,CAuErG"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
// harn:assume attach-custody-lease-tracks-child-pid ref=interactive-child-supervision
|
|
3
|
+
export const nativeResumeCommand = (member, env) => {
|
|
4
|
+
if (!member.session_ref)
|
|
5
|
+
throw new Error(`member @${member.handle} has no resumable session`);
|
|
6
|
+
if (member.harness === 'claude-code') {
|
|
7
|
+
return {
|
|
8
|
+
command: env.CODOR_CLAUDE_COMMAND ?? 'claude',
|
|
9
|
+
args: ['--resume', member.session_ref],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (member.harness === 'codex') {
|
|
13
|
+
return {
|
|
14
|
+
command: env.CODOR_CODEX_COMMAND ?? 'codex',
|
|
15
|
+
args: ['resume', member.session_ref],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (member.harness === 'gemini') {
|
|
19
|
+
return {
|
|
20
|
+
command: env.CODOR_GEMINI_COMMAND ?? 'gemini',
|
|
21
|
+
args: ['--resume', member.session_ref],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (member.harness === 'opencode') {
|
|
25
|
+
return {
|
|
26
|
+
command: env.CODOR_OPENCODE_COMMAND ?? 'opencode',
|
|
27
|
+
args: ['--session', member.session_ref],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (member.harness === 'copilot') {
|
|
31
|
+
return {
|
|
32
|
+
command: env.CODOR_COPILOT_COMMAND ?? 'copilot',
|
|
33
|
+
args: ['--resume', member.session_ref],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`adapter '${member.harness ?? 'unknown'}' has no interactive resume command`);
|
|
37
|
+
};
|
|
38
|
+
async function nextAttachFrame(client, memberId, statuses) {
|
|
39
|
+
for (;;) {
|
|
40
|
+
const frame = await client.next(30_000);
|
|
41
|
+
if (frame.type === 'error')
|
|
42
|
+
throw new Error(frame.message);
|
|
43
|
+
if (frame.type === 'attach_lease' &&
|
|
44
|
+
frame.member.id === memberId &&
|
|
45
|
+
statuses.has(frame.status)) {
|
|
46
|
+
return frame;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function signalProcessGroup(child, signal) {
|
|
51
|
+
if (child.pid === undefined)
|
|
52
|
+
return;
|
|
53
|
+
try {
|
|
54
|
+
process.kill(-child.pid, signal);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
child.kill(signal);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function superviseInteractiveAttach(input) {
|
|
61
|
+
const resolveCommand = input.commandResolver ?? nativeResumeCommand;
|
|
62
|
+
const spawnChild = input.spawnChild ?? spawn;
|
|
63
|
+
const resume = resolveCommand(input.member, input.env ?? process.env);
|
|
64
|
+
const child = spawnChild(resume.command, resume.args, {
|
|
65
|
+
cwd: input.member.cwd ?? process.cwd(),
|
|
66
|
+
stdio: 'inherit',
|
|
67
|
+
detached: true,
|
|
68
|
+
});
|
|
69
|
+
const spawned = new Promise((resolve, reject) => {
|
|
70
|
+
child.once('spawn', resolve);
|
|
71
|
+
child.once('error', reject);
|
|
72
|
+
});
|
|
73
|
+
const closed = new Promise((resolve) => {
|
|
74
|
+
child.once('close', (code, signal) => resolve({ code, signal }));
|
|
75
|
+
});
|
|
76
|
+
let heartbeat;
|
|
77
|
+
const forwardInterrupt = () => signalProcessGroup(child, 'SIGINT');
|
|
78
|
+
const forwardTerminate = () => signalProcessGroup(child, 'SIGTERM');
|
|
79
|
+
let exit = { code: null, signal: null };
|
|
80
|
+
let failure;
|
|
81
|
+
try {
|
|
82
|
+
await spawned;
|
|
83
|
+
if (child.pid === undefined)
|
|
84
|
+
throw new Error('interactive child started without a pid');
|
|
85
|
+
input.client.send({
|
|
86
|
+
type: 'act',
|
|
87
|
+
room: input.room,
|
|
88
|
+
act: {
|
|
89
|
+
act: 'attach_child',
|
|
90
|
+
lease_id: input.lease.id,
|
|
91
|
+
child_pid: child.pid,
|
|
92
|
+
process_group_id: child.pid,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
await nextAttachFrame(input.client, input.member.id, new Set(['child_recorded']));
|
|
96
|
+
process.on('SIGINT', forwardInterrupt);
|
|
97
|
+
process.on('SIGTERM', forwardTerminate);
|
|
98
|
+
heartbeat = setInterval(() => {
|
|
99
|
+
try {
|
|
100
|
+
input.client.send({
|
|
101
|
+
type: 'act',
|
|
102
|
+
room: input.room,
|
|
103
|
+
act: { act: 'attach_heartbeat', lease_id: input.lease.id },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Lease expiry is the daemon's fail-closed recovery path.
|
|
108
|
+
}
|
|
109
|
+
}, input.heartbeatMs ?? 1_000);
|
|
110
|
+
heartbeat.unref();
|
|
111
|
+
exit = await closed;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
failure = error;
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
if (heartbeat)
|
|
118
|
+
clearInterval(heartbeat);
|
|
119
|
+
process.off('SIGINT', forwardInterrupt);
|
|
120
|
+
process.off('SIGTERM', forwardTerminate);
|
|
121
|
+
input.client.send({
|
|
122
|
+
type: 'act',
|
|
123
|
+
room: input.room,
|
|
124
|
+
act: { act: 'attach_complete', lease_id: input.lease.id },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const completed = await nextAttachFrame(input.client, input.member.id, new Set(['completed', 'uncertain']));
|
|
128
|
+
if (failure)
|
|
129
|
+
throw failure;
|
|
130
|
+
return { status: completed.status, ...exit };
|
|
131
|
+
}
|
|
132
|
+
// harn:end attach-custody-lease-tracks-child-pid
|
|
133
|
+
//# sourceMappingURL=attach.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach.js","sourceRoot":"","sources":["../src/attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAwC,MAAM,oBAAoB,CAAC;AAsBjF,sFAAsF;AACtF,MAAM,CAAC,MAAM,mBAAmB,GAA+B,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;IAC7E,IAAI,CAAC,MAAM,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,WAAW,MAAM,CAAC,MAAM,2BAA2B,C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CAAC,MAAM,CAAC,EAAE,EACf,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CACpC,CAAC;IACF,IAAI,OAAO;QAAE,MAAM,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAmC,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5E,CAAC;AACD,iDAAiD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ClientFrame, type ServerFrame } from '@codor/protocol';
|
|
2
|
+
export interface ProtocolClientOptions {
|
|
3
|
+
dataDir: string;
|
|
4
|
+
socketPath?: string;
|
|
5
|
+
remoteUrl?: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class ProtocolClient {
|
|
10
|
+
private readonly socket;
|
|
11
|
+
private readonly frames;
|
|
12
|
+
private readonly waiters;
|
|
13
|
+
private cursor;
|
|
14
|
+
private closedError;
|
|
15
|
+
private constructor();
|
|
16
|
+
static connect(options: ProtocolClientOptions): Promise<ProtocolClient>;
|
|
17
|
+
send(frame: ClientFrame): void;
|
|
18
|
+
next(timeoutMs?: number): Promise<ServerFrame>;
|
|
19
|
+
close(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAwBD,qBAAa,cAAc;IAML,OAAO,CAAC,QAAQ,CAAC,MAAM;IAL3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAoB;IAEvC,OAAO;WAmBM,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAwC7E,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAIxB,IAAI,CAAC,SAAS,SAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;IAkB7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { connect as netConnect } from 'node:net';
|
|
2
|
+
import { ClientFrameSchema, ServerFrameSchema, } from '@codor/protocol';
|
|
3
|
+
import { isPipePath, localSocketPath } from '@codor/switchboard';
|
|
4
|
+
import WebSocket from 'ws';
|
|
5
|
+
function transportUrl(options) {
|
|
6
|
+
if (options.remoteUrl === undefined) {
|
|
7
|
+
const socketPath = options.socketPath ?? localSocketPath(options.dataDir);
|
|
8
|
+
// harn:assume member-env-selects-narrow-cli-identity ref=explicit-token-unix-transport
|
|
9
|
+
const query = options.token === undefined ? '' : `?token=${encodeURIComponent(options.token)}`;
|
|
10
|
+
const prefix = isPipePath(socketPath) ? 'ws+unix:///' : 'ws+unix://';
|
|
11
|
+
return `${prefix}${socketPath}:/ws${query}`;
|
|
12
|
+
// harn:end member-env-selects-narrow-cli-identity
|
|
13
|
+
}
|
|
14
|
+
if (!options.token)
|
|
15
|
+
throw new Error('--token or CODOR_TOKEN is required with --url');
|
|
16
|
+
const url = new URL(options.remoteUrl);
|
|
17
|
+
if (url.protocol === 'http:')
|
|
18
|
+
url.protocol = 'ws:';
|
|
19
|
+
else if (url.protocol === 'https:')
|
|
20
|
+
url.protocol = 'wss:';
|
|
21
|
+
if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {
|
|
22
|
+
throw new Error('--url must use http(s) or ws(s)');
|
|
23
|
+
}
|
|
24
|
+
if (url.pathname === '/' || url.pathname === '')
|
|
25
|
+
url.pathname = '/ws';
|
|
26
|
+
url.searchParams.set('token', options.token);
|
|
27
|
+
return url.toString();
|
|
28
|
+
}
|
|
29
|
+
// harn:assume unix-socket-same-protocol ref=cli-protocol-transport
|
|
30
|
+
export class ProtocolClient {
|
|
31
|
+
socket;
|
|
32
|
+
frames = [];
|
|
33
|
+
waiters = new Set();
|
|
34
|
+
cursor = 0;
|
|
35
|
+
closedError;
|
|
36
|
+
constructor(socket) {
|
|
37
|
+
this.socket = socket;
|
|
38
|
+
socket.on('message', (raw) => {
|
|
39
|
+
const frame = ServerFrameSchema.parse(JSON.parse(raw.toString()));
|
|
40
|
+
this.frames.push(frame);
|
|
41
|
+
for (const wake of this.waiters)
|
|
42
|
+
wake();
|
|
43
|
+
this.waiters.clear();
|
|
44
|
+
});
|
|
45
|
+
socket.on('error', (error) => {
|
|
46
|
+
this.closedError = error;
|
|
47
|
+
for (const wake of this.waiters)
|
|
48
|
+
wake();
|
|
49
|
+
this.waiters.clear();
|
|
50
|
+
});
|
|
51
|
+
socket.on('close', (code, reason) => {
|
|
52
|
+
this.closedError ??= new Error(`connection closed (${code} ${reason.toString()})`);
|
|
53
|
+
for (const wake of this.waiters)
|
|
54
|
+
wake();
|
|
55
|
+
this.waiters.clear();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
static async connect(options) {
|
|
59
|
+
// harn:assume windows-named-pipe-shares-local-websocket-protocol ref=windows-pipe-client-transport
|
|
60
|
+
const localPath = options.remoteUrl === undefined
|
|
61
|
+
? options.socketPath ?? localSocketPath(options.dataDir)
|
|
62
|
+
: undefined;
|
|
63
|
+
const wsOptions = {};
|
|
64
|
+
if (localPath !== undefined && isPipePath(localPath)) {
|
|
65
|
+
wsOptions.createConnection = (connectOptions) => {
|
|
66
|
+
const normalized = {
|
|
67
|
+
...connectOptions,
|
|
68
|
+
};
|
|
69
|
+
for (const key of ['socketPath', 'path']) {
|
|
70
|
+
const value = normalized[key];
|
|
71
|
+
if (typeof value === 'string' && value.startsWith('/\\\\.\\pipe\\')) {
|
|
72
|
+
normalized[key] = value.slice(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return netConnect(normalized);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const socket = new WebSocket(transportUrl(options), wsOptions);
|
|
79
|
+
// harn:end windows-named-pipe-shares-local-websocket-protocol
|
|
80
|
+
const timeoutMs = options.timeoutMs ?? 5_000;
|
|
81
|
+
await new Promise((resolve, reject) => {
|
|
82
|
+
const timer = setTimeout(() => {
|
|
83
|
+
socket.terminate();
|
|
84
|
+
reject(new Error('connection timed out'));
|
|
85
|
+
}, timeoutMs);
|
|
86
|
+
socket.once('open', () => {
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
resolve();
|
|
89
|
+
});
|
|
90
|
+
socket.once('error', (error) => {
|
|
91
|
+
clearTimeout(timer);
|
|
92
|
+
reject(error);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
return new ProtocolClient(socket);
|
|
96
|
+
}
|
|
97
|
+
send(frame) {
|
|
98
|
+
this.socket.send(JSON.stringify(ClientFrameSchema.parse(frame)));
|
|
99
|
+
}
|
|
100
|
+
async next(timeoutMs = 5_000) {
|
|
101
|
+
if (this.cursor < this.frames.length)
|
|
102
|
+
return this.frames[this.cursor++];
|
|
103
|
+
if (this.closedError)
|
|
104
|
+
throw this.closedError;
|
|
105
|
+
await new Promise((resolve, reject) => {
|
|
106
|
+
const wake = () => {
|
|
107
|
+
clearTimeout(timer);
|
|
108
|
+
resolve();
|
|
109
|
+
};
|
|
110
|
+
const timer = setTimeout(() => {
|
|
111
|
+
this.waiters.delete(wake);
|
|
112
|
+
reject(new Error('timed out waiting for server frame'));
|
|
113
|
+
}, timeoutMs);
|
|
114
|
+
this.waiters.add(wake);
|
|
115
|
+
});
|
|
116
|
+
if (this.cursor < this.frames.length)
|
|
117
|
+
return this.frames[this.cursor++];
|
|
118
|
+
throw this.closedError ?? new Error('connection closed');
|
|
119
|
+
}
|
|
120
|
+
async close() {
|
|
121
|
+
if (this.socket.readyState === WebSocket.CLOSED)
|
|
122
|
+
return;
|
|
123
|
+
await new Promise((resolve) => {
|
|
124
|
+
this.socket.once('close', () => resolve());
|
|
125
|
+
this.socket.close();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// harn:end unix-socket-same-protocol
|
|
130
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,SAAS,MAAM,IAAI,CAAC;AAU3B,SAAS,YAAY,CAAC,OAA8B;IAClD,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1E,uFAAuF;QACvF,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/F,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;QACrE,OAAO,GAAG,MAAM,GAAG,UAAU,OAAO,KAAK,EAAE,CAAC;QAC5C,kDAAk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,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AACD,qCAAqC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface DetectedSession {
|
|
2
|
+
harness: 'claude-code' | 'codex';
|
|
3
|
+
session_ref: string;
|
|
4
|
+
cwd: string;
|
|
5
|
+
transcript_path: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function findCodexSessionFile(sessionRef: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
8
|
+
export declare function detectSession(options?: {
|
|
9
|
+
harness?: string;
|
|
10
|
+
session?: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
}): DetectedSession;
|
|
14
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;CACzB;AA4BD,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACpB,GAAG,eAAe,CAoEvB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { basename, join } from 'node:path';
|
|
4
|
+
const CODEX_FILE = /^rollout-.*-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/;
|
|
5
|
+
const CLAUDE_FILE = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/;
|
|
6
|
+
function filesBelow(root) {
|
|
7
|
+
const files = [];
|
|
8
|
+
const walk = (dir) => {
|
|
9
|
+
let entries;
|
|
10
|
+
try {
|
|
11
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
const path = join(dir, entry.name);
|
|
18
|
+
if (entry.isDirectory())
|
|
19
|
+
walk(path);
|
|
20
|
+
else if (entry.isFile())
|
|
21
|
+
files.push(path);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
walk(root);
|
|
25
|
+
return files;
|
|
26
|
+
}
|
|
27
|
+
export function findCodexSessionFile(sessionRef, env = process.env) {
|
|
28
|
+
const root = join(env.CODEX_HOME ?? join(env.HOME ?? homedir(), '.codex'), 'sessions');
|
|
29
|
+
return filesBelow(root).find((path) => CODEX_FILE.exec(basename(path))?.[1] === sessionRef);
|
|
30
|
+
}
|
|
31
|
+
export function detectSession(options = {}) {
|
|
32
|
+
const env = options.env ?? process.env;
|
|
33
|
+
const cwd = options.cwd ?? process.cwd();
|
|
34
|
+
const explicitHarness = options.harness === 'claude' ? 'claude-code' : options.harness;
|
|
35
|
+
const envClaude = env.CLAUDE_SESSION_ID;
|
|
36
|
+
const envCodex = env.CODEX_THREAD_ID ?? env.CODEX_SESSION_ID;
|
|
37
|
+
if (options.session) {
|
|
38
|
+
const harness = explicitHarness ?? (envClaude === options.session ? 'claude-code' : 'codex');
|
|
39
|
+
if (harness !== 'claude-code' && harness !== 'codex') {
|
|
40
|
+
throw new Error(`unsupported harness '${harness}'`);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
harness,
|
|
44
|
+
session_ref: options.session,
|
|
45
|
+
cwd,
|
|
46
|
+
transcript_path: harness === 'codex' ? (findCodexSessionFile(options.session, env) ?? '') : '',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!explicitHarness && envClaude) {
|
|
50
|
+
return { harness: 'claude-code', session_ref: envClaude, cwd, transcript_path: '' };
|
|
51
|
+
}
|
|
52
|
+
if (!explicitHarness && envCodex) {
|
|
53
|
+
return {
|
|
54
|
+
harness: 'codex',
|
|
55
|
+
session_ref: envCodex,
|
|
56
|
+
cwd,
|
|
57
|
+
transcript_path: findCodexSessionFile(envCodex, env) ?? '',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const home = env.HOME ?? homedir();
|
|
61
|
+
const candidates = [];
|
|
62
|
+
if (explicitHarness === undefined || explicitHarness === 'claude-code') {
|
|
63
|
+
const root = join(env.CLAUDE_CONFIG_DIR ?? join(home, '.claude'), 'projects');
|
|
64
|
+
for (const path of filesBelow(root)) {
|
|
65
|
+
const match = CLAUDE_FILE.exec(basename(path));
|
|
66
|
+
if (!match)
|
|
67
|
+
continue;
|
|
68
|
+
candidates.push({
|
|
69
|
+
harness: 'claude-code',
|
|
70
|
+
session_ref: match[1],
|
|
71
|
+
cwd,
|
|
72
|
+
transcript_path: path,
|
|
73
|
+
mtimeMs: statSync(path).mtimeMs,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (explicitHarness === undefined || explicitHarness === 'codex') {
|
|
78
|
+
const root = join(env.CODEX_HOME ?? join(home, '.codex'), 'sessions');
|
|
79
|
+
for (const path of filesBelow(root)) {
|
|
80
|
+
const match = CODEX_FILE.exec(basename(path));
|
|
81
|
+
if (!match)
|
|
82
|
+
continue;
|
|
83
|
+
candidates.push({
|
|
84
|
+
harness: 'codex',
|
|
85
|
+
session_ref: match[1],
|
|
86
|
+
cwd,
|
|
87
|
+
transcript_path: path,
|
|
88
|
+
mtimeMs: statSync(path).mtimeMs,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const latest = candidates.sort((a, b) => b.mtimeMs - a.mtimeMs)[0];
|
|
93
|
+
if (!latest) {
|
|
94
|
+
throw new Error('could not autodetect a live Claude Code or Codex session; pass --harness and --session');
|
|
95
|
+
}
|
|
96
|
+
const { mtimeMs: _mtimeMs, ...detected } = latest;
|
|
97
|
+
return detected;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=detect.js.map
|