@harness-mix/cli 0.1.3
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/CHANGELOG.md +19 -0
- package/LICENSE +202 -0
- package/NOTICE +14 -0
- package/README.md +262 -0
- package/Start-Codex.cmd +5 -0
- package/config/codex-desktop-compatibility.json +29 -0
- package/docs/chatgpt-web-sidebar.md +27 -0
- package/docs/cross-platform.md +73 -0
- package/docs/harness-management.md +44 -0
- package/docs/images/codex-desktop-home.png +0 -0
- package/docs/images/codex-desktop-session.png +0 -0
- package/docs/kiro-cursor-integration.md +3 -0
- package/docs/multi-agent-collaboration.md +89 -0
- package/docs/native-acp.md +122 -0
- package/docs/native-codex.md +95 -0
- package/docs/superpowers/specs/2026-09-13-native-hardening-design.md +326 -0
- package/licenses/codex-host-MIT.txt +21 -0
- package/output/native-build/desktop-controller.mjs +1466 -0
- package/output/native-build/harness-mix-appx.exe +0 -0
- package/output/native-build/harness-mix-secret.exe +0 -0
- package/output/native-build/harness-mix-shim.exe +0 -0
- package/output/native-build/renderer-extension.js +29380 -0
- package/package.json +168 -0
- package/scripts/acp-capabilities-probe.cjs +100 -0
- package/scripts/adapters-test.cjs +17 -0
- package/scripts/antigravity-adapter-test.cjs +529 -0
- package/scripts/architecture-test.cjs +62 -0
- package/scripts/build-native.cjs +56 -0
- package/scripts/catalog-test.cjs +25 -0
- package/scripts/cdp-eval.cjs +40 -0
- package/scripts/cdp-watch.cjs +36 -0
- package/scripts/check.cjs +23 -0
- package/scripts/codebuddy-migration-test.cjs +47 -0
- package/scripts/codex-adapter-test.cjs +83 -0
- package/scripts/collaboration-recovery-test.cjs +111 -0
- package/scripts/collaboration-test.cjs +108 -0
- package/scripts/collaboration-ui-smoke.cjs +57 -0
- package/scripts/concurrency-layers-test.cjs +181 -0
- package/scripts/contracts-test.cjs +105 -0
- package/scripts/core-concurrency-test.cjs +103 -0
- package/scripts/core-replay-test.cjs +179 -0
- package/scripts/core-runtime-test.cjs +104 -0
- package/scripts/core-services-test.cjs +50 -0
- package/scripts/determinism-test.cjs +36 -0
- package/scripts/diagnostics.cjs +63 -0
- package/scripts/docs-command-test.cjs +49 -0
- package/scripts/dsh-adapter-test.cjs +90 -0
- package/scripts/dsh-collaboration-acp-test.cjs +19 -0
- package/scripts/dsh-native.cjs +9 -0
- package/scripts/dsh-native.cmd +2 -0
- package/scripts/e2e-codex.cjs +82 -0
- package/scripts/e2e-collaboration.cjs +60 -0
- package/scripts/e2e-core-files.cjs +58 -0
- package/scripts/e2e-core-fork.cjs +49 -0
- package/scripts/e2e-core-resume.cjs +49 -0
- package/scripts/e2e-delegate.cjs +38 -0
- package/scripts/e2e-dsh.cjs +23 -0
- package/scripts/e2e-native-acp.cjs +42 -0
- package/scripts/e2e-native-commands.cjs +54 -0
- package/scripts/e2e-native-host.cjs +144 -0
- package/scripts/e2e-openclaw-image.cjs +59 -0
- package/scripts/e2e-openclaw.cjs +21 -0
- package/scripts/e2e-pi.cjs +23 -0
- package/scripts/e2e-shadow.cjs +52 -0
- package/scripts/fixture-capture.cjs +103 -0
- package/scripts/harness-health-check.cjs +72 -0
- package/scripts/kiro-cursor-adapters-test.cjs +82 -0
- package/scripts/launch-codex.cjs +5 -0
- package/scripts/native-acp-depth-test.cjs +189 -0
- package/scripts/native-compatibility-test.cjs +42 -0
- package/scripts/native-config-test.cjs +25 -0
- package/scripts/native-file-change-test.cjs +94 -0
- package/scripts/native-host.cjs +8 -0
- package/scripts/native-images-test.cjs +56 -0
- package/scripts/native-job-object-test.cjs +83 -0
- package/scripts/native-protocol-test.cjs +258 -0
- package/scripts/native-rollback-test.cjs +46 -0
- package/scripts/native-secret-test.cjs +57 -0
- package/scripts/native-shim-test.cjs +41 -0
- package/scripts/native-sidebar-test.cjs +88 -0
- package/scripts/native-ui-smoke.cjs +94 -0
- package/scripts/native-update-apply-test.cjs +215 -0
- package/scripts/native-updater-test.cjs +109 -0
- package/scripts/native-vendor-adapters-test.cjs +88 -0
- package/scripts/openclaw-acp-probe.cjs +39 -0
- package/scripts/openclaw-adapter-test.cjs +180 -0
- package/scripts/openclaw-models-probe.cjs +13 -0
- package/scripts/platform-test.cjs +62 -0
- package/scripts/projector-test.cjs +144 -0
- package/scripts/sequence-test.cjs +57 -0
- package/scripts/shadow-test.cjs +154 -0
- package/scripts/support/legacy-projection.cjs +95 -0
- package/scripts/support/legacy-transcript.cjs +48 -0
- package/scripts/support/parity-observer.cjs +27 -0
- package/scripts/support/shadow-comparator.cjs +62 -0
- package/scripts/support/shadow.cjs +114 -0
- package/scripts/switch-harness-test.cjs +145 -0
- package/scripts/thread-title-test.cjs +98 -0
- package/scripts/tool-concurrency-regression-test.cjs +119 -0
- package/scripts/transcript-test.cjs +24 -0
- package/scripts/turn-manager-test.cjs +91 -0
- package/scripts/workspace-test.cjs +86 -0
- package/src/assets/brand-harness-mix.png +0 -0
- package/src/assets/icons/antigravity-color.svg +1 -0
- package/src/assets/icons/claude-color.svg +1 -0
- package/src/assets/icons/codebuddy-color.svg +1 -0
- package/src/assets/icons/codex-color.svg +1 -0
- package/src/assets/icons/codex-harness.svg +1 -0
- package/src/assets/icons/cursor-cli-color.svg +1 -0
- package/src/assets/icons/cursor.svg +1 -0
- package/src/assets/icons/deepseek-color.svg +1 -0
- package/src/assets/icons/grok-color.svg +1 -0
- package/src/assets/icons/hermes-color.svg +1 -0
- package/src/assets/icons/kiro-cli-color.svg +11 -0
- package/src/assets/icons/model-astra.svg +1 -0
- package/src/assets/icons/model-claude.svg +1 -0
- package/src/assets/icons/model-deepseek.svg +1 -0
- package/src/assets/icons/model-gemini.svg +1 -0
- package/src/assets/icons/model-grok.svg +1 -0
- package/src/assets/icons/model-hunyuan.svg +1 -0
- package/src/assets/icons/model-kimi.svg +1 -0
- package/src/assets/icons/model-minimax.svg +1 -0
- package/src/assets/icons/model-openai.svg +1 -0
- package/src/assets/icons/model-qwen-color.svg +1 -0
- package/src/assets/icons/model-xiaomimimo.svg +1 -0
- package/src/assets/icons/model-zai.svg +1 -0
- package/src/assets/icons/omp-color.svg +1 -0
- package/src/assets/icons/openclaw-color.svg +1 -0
- package/src/assets/icons/opencode-color.svg +1 -0
- package/src/assets/icons/pi.svg +1 -0
- package/src/assets/icons/pinumber1_80899.svg +48 -0
- package/src/assets/icons/qoder-color.svg +1 -0
- package/src/assets/icons/trae-color.svg +1 -0
- package/src/assets/icons/workbuddy-color.svg +1 -0
- package/src/assets/icons/zcode-color.svg +1 -0
- package/src/main/adapters/acp-interactions.js +132 -0
- package/src/main/adapters/acp.js +191 -0
- package/src/main/adapters/antigravity.js +1368 -0
- package/src/main/adapters/claude.js +520 -0
- package/src/main/adapters/codebuddy-history.js +90 -0
- package/src/main/adapters/codebuddy.js +2 -0
- package/src/main/adapters/codex-app-server.js +119 -0
- package/src/main/adapters/codex.js +559 -0
- package/src/main/adapters/cursor.js +2 -0
- package/src/main/adapters/dsh-web-host.js +202 -0
- package/src/main/adapters/dsh.js +446 -0
- package/src/main/adapters/grok.js +277 -0
- package/src/main/adapters/hermes.js +24 -0
- package/src/main/adapters/index.js +32 -0
- package/src/main/adapters/kiro-history.js +43 -0
- package/src/main/adapters/kiro.js +2 -0
- package/src/main/adapters/native-acp-command.js +47 -0
- package/src/main/adapters/native-acp.js +435 -0
- package/src/main/adapters/omp.js +12 -0
- package/src/main/adapters/openclaw-gateway.js +211 -0
- package/src/main/adapters/openclaw.js +337 -0
- package/src/main/adapters/opencode-server.js +73 -0
- package/src/main/adapters/opencode.js +178 -0
- package/src/main/adapters/pi-family.js +342 -0
- package/src/main/adapters/pi-usage.js +24 -0
- package/src/main/adapters/pi.js +10 -0
- package/src/main/adapters/qoder.js +7 -0
- package/src/main/adapters/trae.js +7 -0
- package/src/main/adapters/workbuddy.js +2 -0
- package/src/main/adapters/zcode.js +7 -0
- package/src/main/harness-adapter/contract-test.js +53 -0
- package/src/main/harness-adapter/contract.js +34 -0
- package/src/main/harness-adapter/event-normalizer.js +252 -0
- package/src/main/harness-adapter/fixture-recorder.js +56 -0
- package/src/main/harness-adapter/index.js +6 -0
- package/src/main/harness-adapter/manifest.js +44 -0
- package/src/main/host/collaboration-mcp.cjs +35 -0
- package/src/main/host/collaboration-pi.mjs +17 -0
- package/src/main/host/collaboration-tools.js +16 -0
- package/src/main/host/collaboration-worktree.js +151 -0
- package/src/main/host/collaboration.js +264 -0
- package/src/main/host/core-session.js +81 -0
- package/src/main/host/handoff.js +46 -0
- package/src/main/host/history-import.js +55 -0
- package/src/main/host/jsonl.js +116 -0
- package/src/main/host/native-history.js +79 -0
- package/src/main/host/runtime.js +1050 -0
- package/src/main/host/session-history.js +63 -0
- package/src/main/host/store.js +75 -0
- package/src/main/native/compatibility.js +56 -0
- package/src/main/native/config.js +55 -0
- package/src/main/native/host.js +153 -0
- package/src/main/native/icons.js +105 -0
- package/src/main/native/input.js +43 -0
- package/src/main/native/launcher.js +188 -0
- package/src/main/native/platform.js +64 -0
- package/src/main/native/process-utils.js +57 -0
- package/src/main/native/protocol.js +836 -0
- package/src/main/native/redact.js +35 -0
- package/src/main/native/rs/Cargo.lock +15 -0
- package/src/main/native/rs/Cargo.toml +9 -0
- package/src/main/native/rs/crates/appx/Cargo.toml +13 -0
- package/src/main/native/rs/crates/appx/src/main.rs +309 -0
- package/src/main/native/rs/crates/secret/Cargo.toml +10 -0
- package/src/main/native/rs/crates/secret/src/main.rs +262 -0
- package/src/main/native/rs/crates/shim/Cargo.toml +10 -0
- package/src/main/native/rs/crates/shim/src/job.rs +83 -0
- package/src/main/native/rs/crates/shim/src/main.rs +257 -0
- package/src/main/native/secure-store.js +59 -0
- package/src/main/native/thread-list.js +38 -0
- package/src/main/native/update-state.js +110 -0
- package/src/main/native/updater.js +394 -0
- package/src/main/native/usage.js +105 -0
- package/src/main/protocol-core/capability-manager.js +16 -0
- package/src/main/protocol-core/event-router.js +32 -0
- package/src/main/protocol-core/file-change-projector.js +45 -0
- package/src/main/protocol-core/index.js +8 -0
- package/src/main/protocol-core/interaction-router.js +30 -0
- package/src/main/protocol-core/projector.js +238 -0
- package/src/main/protocol-core/protocol-core.js +132 -0
- package/src/main/protocol-core/sequence-validator.js +44 -0
- package/src/main/protocol-core/thread-manager.js +50 -0
- package/src/main/protocol-core/turn-manager.js +63 -0
- package/src/main/shared-contracts/capability.js +35 -0
- package/src/main/shared-contracts/event.js +55 -0
- package/src/main/shared-contracts/ids.js +12 -0
- package/src/main/shared-contracts/index.js +11 -0
- package/src/main/shared-contracts/interaction.js +37 -0
- package/src/main/shared-contracts/item.js +51 -0
- package/src/main/shared-contracts/native-ref.js +24 -0
- package/src/main/shared-contracts/thread.js +36 -0
- package/src/main/shared-contracts/turn.js +54 -0
- package/src/main/workspace/core-review.js +53 -0
- package/src/main/workspace/diff.js +27 -0
- package/src/main/workspace/file-changes.js +21 -0
- package/src/main/workspace/files.js +76 -0
- package/src/main/workspace/review-controller.js +102 -0
- package/src/main/workspace/review.js +88 -0
- package/src/native-ui/LICENSE +21 -0
- package/src/native-ui/README.md +16 -0
- package/src/native-ui/desktop-control/dist/cdp-client.d.ts +53 -0
- package/src/native-ui/desktop-control/dist/cdp-client.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/cdp-client.js +258 -0
- package/src/native-ui/desktop-control/dist/cdp-client.js.map +1 -0
- package/src/native-ui/desktop-control/dist/contract-audit.d.ts +73 -0
- package/src/native-ui/desktop-control/dist/contract-audit.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/contract-audit.js +152 -0
- package/src/native-ui/desktop-control/dist/contract-audit.js.map +1 -0
- package/src/native-ui/desktop-control/dist/controller-attachment-server.d.ts +10 -0
- package/src/native-ui/desktop-control/dist/controller-attachment-server.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/controller-attachment-server.js +77 -0
- package/src/native-ui/desktop-control/dist/controller-attachment-server.js.map +1 -0
- package/src/native-ui/desktop-control/dist/index.d.ts +21 -0
- package/src/native-ui/desktop-control/dist/index.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/index.js +14 -0
- package/src/native-ui/desktop-control/dist/index.js.map +1 -0
- package/src/native-ui/desktop-control/dist/main-process-title-policy.d.ts +24 -0
- package/src/native-ui/desktop-control/dist/main-process-title-policy.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/main-process-title-policy.js +284 -0
- package/src/native-ui/desktop-control/dist/main-process-title-policy.js.map +1 -0
- package/src/native-ui/desktop-control/dist/production-controller.d.ts +32 -0
- package/src/native-ui/desktop-control/dist/production-controller.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/production-controller.js +294 -0
- package/src/native-ui/desktop-control/dist/production-controller.js.map +1 -0
- package/src/native-ui/desktop-control/dist/release-main.d.ts +2 -0
- package/src/native-ui/desktop-control/dist/release-main.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/release-main.js +17 -0
- package/src/native-ui/desktop-control/dist/release-main.js.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-cdp-control-session.d.ts +49 -0
- package/src/native-ui/desktop-control/dist/renderer-cdp-control-session.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-cdp-control-session.js +214 -0
- package/src/native-ui/desktop-control/dist/renderer-cdp-control-session.js.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-control-session.d.ts +79 -0
- package/src/native-ui/desktop-control/dist/renderer-control-session.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-control-session.js +366 -0
- package/src/native-ui/desktop-control/dist/renderer-control-session.js.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-dom.d.ts +24 -0
- package/src/native-ui/desktop-control/dist/renderer-dom.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-dom.js +110 -0
- package/src/native-ui/desktop-control/dist/renderer-dom.js.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-policy.d.ts +20 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-policy.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-policy.js +173 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-policy.js.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-runtime.d.ts +38 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-runtime.d.ts.map +1 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-runtime.js +637 -0
- package/src/native-ui/desktop-control/dist/renderer-draft-prewarm-runtime.js.map +1 -0
- package/src/native-ui/desktop-control/dist/tsconfig.tsbuildinfo +1 -0
- package/src/native-ui/desktop-control/package.json +22 -0
- package/src/native-ui/desktop-control/scripts/build-release.mjs +94 -0
- package/src/native-ui/desktop-control/src/cdp-client.ts +347 -0
- package/src/native-ui/desktop-control/src/contract-audit.ts +291 -0
- package/src/native-ui/desktop-control/src/controller-attachment-server.ts +93 -0
- package/src/native-ui/desktop-control/src/index.ts +91 -0
- package/src/native-ui/desktop-control/src/main-process-title-policy.ts +372 -0
- package/src/native-ui/desktop-control/src/production-controller.ts +347 -0
- package/src/native-ui/desktop-control/src/release-main.ts +18 -0
- package/src/native-ui/desktop-control/src/renderer-cdp-control-session.ts +358 -0
- package/src/native-ui/desktop-control/src/renderer-control-session.ts +595 -0
- package/src/native-ui/desktop-control/src/renderer-dom.ts +144 -0
- package/src/native-ui/desktop-control/src/renderer-draft-prewarm-policy.ts +217 -0
- package/src/native-ui/desktop-control/src/renderer-draft-prewarm-runtime.ts +749 -0
- package/src/native-ui/desktop-control/test/cdp-client.test.ts +157 -0
- package/src/native-ui/desktop-control/test/contract-audit.test.ts +56 -0
- package/src/native-ui/desktop-control/test/controller-attachment-server.test.ts +98 -0
- package/src/native-ui/desktop-control/test/index.test.ts +11 -0
- package/src/native-ui/desktop-control/test/main-process-title-policy.test.ts +168 -0
- package/src/native-ui/desktop-control/test/production-controller.test.ts +392 -0
- package/src/native-ui/desktop-control/test/renderer-cdp-control-session.test.ts +205 -0
- package/src/native-ui/desktop-control/test/renderer-control-session.test.ts +451 -0
- package/src/native-ui/desktop-control/test/renderer-dom.test.ts +62 -0
- package/src/native-ui/desktop-control/test/renderer-draft-prewarm-policy.test.ts +1029 -0
- package/src/native-ui/desktop-control/tsconfig.json +12 -0
- package/src/native-ui/renderer-extension/dist/types/agent-group-preference.d.ts +39 -0
- package/src/native-ui/renderer-extension/dist/types/agent-group-preference.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/agent-selection-state.d.ts +85 -0
- package/src/native-ui/renderer-extension/dist/types/agent-selection-state.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/audit-entry.d.ts +2 -0
- package/src/native-ui/renderer-extension/dist/types/audit-entry.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/codex-locale-adapter.d.ts +23 -0
- package/src/native-ui/renderer-extension/dist/types/codex-locale-adapter.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/collaboration-icon.d.ts +2 -0
- package/src/native-ui/renderer-extension/dist/types/collaboration-icon.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/contract-audit.d.ts +37 -0
- package/src/native-ui/renderer-extension/dist/types/contract-audit.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/harness-mix-icons.d.ts +3 -0
- package/src/native-ui/renderer-extension/dist/types/harness-mix-icons.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/harness-mix-settings.d.ts +3 -0
- package/src/native-ui/renderer-extension/dist/types/harness-mix-settings.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/index.d.ts +51 -0
- package/src/native-ui/renderer-extension/dist/types/index.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/install-renderer-binding.d.ts +4 -0
- package/src/native-ui/renderer-extension/dist/types/install-renderer-binding.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/probe-entry.d.ts +2 -0
- package/src/native-ui/renderer-extension/dist/types/probe-entry.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/production-entry.d.ts +9 -0
- package/src/native-ui/renderer-extension/dist/types/production-entry.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-agent-icon.d.ts +4 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-agent-icon.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-agent-picker.d.ts +62 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-agent-picker.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-binding-probe.d.ts +70 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-binding-probe.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-codex-account-options.d.ts +34 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-codex-account-options.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-codex-account-state.d.ts +19 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-codex-account-state.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-collab-cards.d.ts +40 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-collab-cards.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-composer-dom.d.ts +82 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-composer-dom.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-credits-control.d.ts +21 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-credits-control.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-external-steering.d.ts +7 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-external-steering.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-fork-control.d.ts +34 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-fork-control.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-command-claim.d.ts +4 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-command-claim.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-command-control.d.ts +15 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-command-control.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-localization.d.ts +25 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-localization.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-mentions.d.ts +23 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-harness-mentions.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-model-client.d.ts +102 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-model-client.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-model-picker-positioning.d.ts +22 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-model-picker-positioning.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-model-picker.d.ts +54 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-model-picker.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-new-thread-preference.d.ts +18 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-new-thread-preference.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-permission-mode-picker.d.ts +42 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-permission-mode-picker.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-permission-mode-preference.d.ts +9 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-permission-mode-preference.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-request-sender.d.ts +9 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-request-sender.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-session-import-client.d.ts +12 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-session-import-client.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-settings-lifecycle.d.ts +18 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-settings-lifecycle.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-sidebar-agent-icons.d.ts +45 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-sidebar-agent-icons.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-transcript-dom.d.ts +23 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-transcript-dom.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-trigger-chip-style.d.ts +3 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-trigger-chip-style.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-usage-control.d.ts +72 -0
- package/src/native-ui/renderer-extension/dist/types/renderer-usage-control.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/accounts-list.d.ts +24 -0
- package/src/native-ui/renderer-extension/dist/types/settings/accounts-list.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/accounts-page.d.ts +18 -0
- package/src/native-ui/renderer-extension/dist/types/settings/accounts-page.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/accounts-usage.d.ts +27 -0
- package/src/native-ui/renderer-extension/dist/types/settings/accounts-usage.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/connections-page.d.ts +44 -0
- package/src/native-ui/renderer-extension/dist/types/settings/connections-page.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/core.d.ts +38 -0
- package/src/native-ui/renderer-extension/dist/types/settings/core.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/harness-accounts.d.ts +21 -0
- package/src/native-ui/renderer-extension/dist/types/settings/harness-accounts.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/icons.d.ts +6 -0
- package/src/native-ui/renderer-extension/dist/types/settings/icons.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/localization.d.ts +247 -0
- package/src/native-ui/renderer-extension/dist/types/settings/localization.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/pages.d.ts +23 -0
- package/src/native-ui/renderer-extension/dist/types/settings/pages.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/release-notes.d.ts +4 -0
- package/src/native-ui/renderer-extension/dist/types/settings/release-notes.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/session-import-list-controls.d.ts +12 -0
- package/src/native-ui/renderer-extension/dist/types/settings/session-import-list-controls.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/session-import-page.d.ts +8 -0
- package/src/native-ui/renderer-extension/dist/types/settings/session-import-page.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/shell.d.ts +24 -0
- package/src/native-ui/renderer-extension/dist/types/settings/shell.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/trigger.d.ts +45 -0
- package/src/native-ui/renderer-extension/dist/types/settings/trigger.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/settings/update-request.d.ts +6 -0
- package/src/native-ui/renderer-extension/dist/types/settings/update-request.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/dist/types/tsconfig.tsbuildinfo +1 -0
- package/src/native-ui/renderer-extension/dist/types/versioned-renderer-adapter.d.ts +143 -0
- package/src/native-ui/renderer-extension/dist/types/versioned-renderer-adapter.d.ts.map +1 -0
- package/src/native-ui/renderer-extension/package.json +22 -0
- package/src/native-ui/renderer-extension/src/agent-group-preference.ts +174 -0
- package/src/native-ui/renderer-extension/src/agent-selection-state.ts +627 -0
- package/src/native-ui/renderer-extension/src/assets/README.md +13 -0
- package/src/native-ui/renderer-extension/src/assets/antigravity-agent.svg +1 -0
- package/src/native-ui/renderer-extension/src/assets/codex-agent.png +0 -0
- package/src/native-ui/renderer-extension/src/assets/grok-agent.png +0 -0
- package/src/native-ui/renderer-extension/src/assets/kiro-agent.svg +11 -0
- package/src/native-ui/renderer-extension/src/assets/omp-agent.svg +14 -0
- package/src/native-ui/renderer-extension/src/assets/opencode-agent.png +0 -0
- package/src/native-ui/renderer-extension/src/assets.d.ts +26 -0
- package/src/native-ui/renderer-extension/src/audit-entry.ts +5 -0
- package/src/native-ui/renderer-extension/src/codex-locale-adapter.ts +321 -0
- package/src/native-ui/renderer-extension/src/collaboration-icon.ts +13 -0
- package/src/native-ui/renderer-extension/src/contract-audit.ts +102 -0
- package/src/native-ui/renderer-extension/src/harness-mix-icons.ts +31 -0
- package/src/native-ui/renderer-extension/src/harness-mix-settings.ts +88 -0
- package/src/native-ui/renderer-extension/src/index.ts +275 -0
- package/src/native-ui/renderer-extension/src/install-renderer-binding.ts +30 -0
- package/src/native-ui/renderer-extension/src/probe-entry.ts +4 -0
- package/src/native-ui/renderer-extension/src/production-entry.ts +23 -0
- package/src/native-ui/renderer-extension/src/renderer-agent-icon.ts +146 -0
- package/src/native-ui/renderer-extension/src/renderer-agent-picker.ts +814 -0
- package/src/native-ui/renderer-extension/src/renderer-binding-probe.ts +3002 -0
- package/src/native-ui/renderer-extension/src/renderer-codex-account-options.ts +281 -0
- package/src/native-ui/renderer-extension/src/renderer-codex-account-state.ts +53 -0
- package/src/native-ui/renderer-extension/src/renderer-collab-cards.ts +198 -0
- package/src/native-ui/renderer-extension/src/renderer-composer-dom.ts +782 -0
- package/src/native-ui/renderer-extension/src/renderer-credits-control.ts +520 -0
- package/src/native-ui/renderer-extension/src/renderer-external-steering.ts +339 -0
- package/src/native-ui/renderer-extension/src/renderer-fork-control.ts +273 -0
- package/src/native-ui/renderer-extension/src/renderer-harness-command-claim.ts +64 -0
- package/src/native-ui/renderer-extension/src/renderer-harness-command-control.ts +417 -0
- package/src/native-ui/renderer-extension/src/renderer-harness-localization.ts +144 -0
- package/src/native-ui/renderer-extension/src/renderer-harness-mentions.ts +306 -0
- package/src/native-ui/renderer-extension/src/renderer-model-client.ts +572 -0
- package/src/native-ui/renderer-extension/src/renderer-model-picker-positioning.ts +65 -0
- package/src/native-ui/renderer-extension/src/renderer-model-picker.ts +640 -0
- package/src/native-ui/renderer-extension/src/renderer-new-thread-preference.ts +177 -0
- package/src/native-ui/renderer-extension/src/renderer-permission-mode-picker.ts +413 -0
- package/src/native-ui/renderer-extension/src/renderer-permission-mode-preference.ts +49 -0
- package/src/native-ui/renderer-extension/src/renderer-request-sender.ts +43 -0
- package/src/native-ui/renderer-extension/src/renderer-session-import-client.ts +68 -0
- package/src/native-ui/renderer-extension/src/renderer-settings-lifecycle.ts +239 -0
- package/src/native-ui/renderer-extension/src/renderer-sidebar-agent-icons.ts +457 -0
- package/src/native-ui/renderer-extension/src/renderer-transcript-dom.ts +47 -0
- package/src/native-ui/renderer-extension/src/renderer-trigger-chip-style.ts +52 -0
- package/src/native-ui/renderer-extension/src/renderer-usage-control.ts +633 -0
- package/src/native-ui/renderer-extension/src/settings/accounts-list.ts +236 -0
- package/src/native-ui/renderer-extension/src/settings/accounts-page.ts +585 -0
- package/src/native-ui/renderer-extension/src/settings/accounts-usage.ts +221 -0
- package/src/native-ui/renderer-extension/src/settings/accounts.css +683 -0
- package/src/native-ui/renderer-extension/src/settings/connections-page.ts +1394 -0
- package/src/native-ui/renderer-extension/src/settings/core.ts +158 -0
- package/src/native-ui/renderer-extension/src/settings/harness-accounts.ts +195 -0
- package/src/native-ui/renderer-extension/src/settings/icons.ts +141 -0
- package/src/native-ui/renderer-extension/src/settings/localization.ts +800 -0
- package/src/native-ui/renderer-extension/src/settings/pages.ts +632 -0
- package/src/native-ui/renderer-extension/src/settings/release-notes.ts +222 -0
- package/src/native-ui/renderer-extension/src/settings/session-import-list-controls.ts +128 -0
- package/src/native-ui/renderer-extension/src/settings/session-import-page.ts +461 -0
- package/src/native-ui/renderer-extension/src/settings/shell.css +2238 -0
- package/src/native-ui/renderer-extension/src/settings/shell.ts +329 -0
- package/src/native-ui/renderer-extension/src/settings/trigger.ts +323 -0
- package/src/native-ui/renderer-extension/src/settings/update-request.ts +49 -0
- package/src/native-ui/renderer-extension/src/versioned-renderer-adapter.ts +1289 -0
- package/src/native-ui/renderer-extension/test/agent-selection-state.test.ts +611 -0
- package/src/native-ui/renderer-extension/test/codebuddy-migration.test.ts +22 -0
- package/src/native-ui/renderer-extension/test/codex-locale-adapter.test.ts +152 -0
- package/src/native-ui/renderer-extension/test/contract-audit.test.ts +71 -0
- package/src/native-ui/renderer-extension/test/harness-mix-icons.test.ts +58 -0
- package/src/native-ui/renderer-extension/test/index.test.ts +9 -0
- package/src/native-ui/renderer-extension/test/renderer-agent-icon.test.ts +98 -0
- package/src/native-ui/renderer-extension/test/renderer-agent-picker.test.ts +226 -0
- package/src/native-ui/renderer-extension/test/renderer-binding-probe-host-catalog.test.ts +728 -0
- package/src/native-ui/renderer-extension/test/renderer-binding-probe.test.ts +1290 -0
- package/src/native-ui/renderer-extension/test/renderer-codex-account-state.test.ts +65 -0
- package/src/native-ui/renderer-extension/test/renderer-collab-cards.test.ts +45 -0
- package/src/native-ui/renderer-extension/test/renderer-composer-permissions.test.ts +75 -0
- package/src/native-ui/renderer-extension/test/renderer-credits-control.test.ts +70 -0
- package/src/native-ui/renderer-extension/test/renderer-external-steering-rpc.test.ts +184 -0
- package/src/native-ui/renderer-extension/test/renderer-external-steering.test.ts +279 -0
- package/src/native-ui/renderer-extension/test/renderer-fork-control.test.ts +363 -0
- package/src/native-ui/renderer-extension/test/renderer-harness-command-claim.test.ts +167 -0
- package/src/native-ui/renderer-extension/test/renderer-harness-command-control.test.ts +54 -0
- package/src/native-ui/renderer-extension/test/renderer-model-client.test.ts +709 -0
- package/src/native-ui/renderer-extension/test/renderer-model-picker.test.ts +302 -0
- package/src/native-ui/renderer-extension/test/renderer-native-thread-ownership.test.ts +84 -0
- package/src/native-ui/renderer-extension/test/renderer-new-thread-preference.test.ts +81 -0
- package/src/native-ui/renderer-extension/test/renderer-permission-mode-picker.test.ts +269 -0
- package/src/native-ui/renderer-extension/test/renderer-permission-mode-preference.test.ts +48 -0
- package/src/native-ui/renderer-extension/test/renderer-settings-lifecycle.test.ts +156 -0
- package/src/native-ui/renderer-extension/test/renderer-sidebar-agent-icons.test.ts +575 -0
- package/src/native-ui/renderer-extension/test/renderer-unsupported-methods.test.ts +167 -0
- package/src/native-ui/renderer-extension/test/renderer-usage-control.test.ts +96 -0
- package/src/native-ui/renderer-extension/test/settings/accounts-usage.test.ts +208 -0
- package/src/native-ui/renderer-extension/test/settings/core.test.ts +145 -0
- package/src/native-ui/renderer-extension/test/settings/harness-settings.test.ts +92 -0
- package/src/native-ui/renderer-extension/test/settings/localization.test.ts +80 -0
- package/src/native-ui/renderer-extension/test/settings/pages.test.ts +2000 -0
- package/src/native-ui/renderer-extension/test/settings/release-notes.test.ts +163 -0
- package/src/native-ui/renderer-extension/test/settings/shell.test.ts +74 -0
- package/src/native-ui/renderer-extension/test/settings/trigger.test.ts +270 -0
- package/src/native-ui/renderer-extension/test/settings/update-request.test.ts +48 -0
- package/src/native-ui/renderer-extension/test/versioned-renderer-adapter.test.ts +695 -0
- package/src/native-ui/renderer-extension/tsconfig.json +15 -0
- package/src/native-ui/shared-contracts/dist/codex-accounts.d.ts +246 -0
- package/src/native-ui/shared-contracts/dist/codex-accounts.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/codex-accounts.js +99 -0
- package/src/native-ui/shared-contracts/dist/codex-accounts.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/deepseek-modern-sessions.d.ts +37 -0
- package/src/native-ui/shared-contracts/dist/deepseek-modern-sessions.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/deepseek-modern-sessions.js +36 -0
- package/src/native-ui/shared-contracts/dist/deepseek-modern-sessions.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/errors.d.ts +17 -0
- package/src/native-ui/shared-contracts/dist/errors.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/errors.js +14 -0
- package/src/native-ui/shared-contracts/dist/errors.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/external-thread-fork.d.ts +11 -0
- package/src/native-ui/shared-contracts/dist/external-thread-fork.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/external-thread-fork.js +14 -0
- package/src/native-ui/shared-contracts/dist/external-thread-fork.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-accounts.d.ts +78 -0
- package/src/native-ui/shared-contracts/dist/harness-accounts.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-accounts.js +27 -0
- package/src/native-ui/shared-contracts/dist/harness-accounts.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-commands.d.ts +46 -0
- package/src/native-ui/shared-contracts/dist/harness-commands.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-commands.js +61 -0
- package/src/native-ui/shared-contracts/dist/harness-commands.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-models.d.ts +300 -0
- package/src/native-ui/shared-contracts/dist/harness-models.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-models.js +318 -0
- package/src/native-ui/shared-contracts/dist/harness-models.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-permission-modes.d.ts +30 -0
- package/src/native-ui/shared-contracts/dist/harness-permission-modes.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-permission-modes.js +57 -0
- package/src/native-ui/shared-contracts/dist/harness-permission-modes.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-plugins.d.ts +56 -0
- package/src/native-ui/shared-contracts/dist/harness-plugins.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-plugins.js +75 -0
- package/src/native-ui/shared-contracts/dist/harness-plugins.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-route.d.ts +16 -0
- package/src/native-ui/shared-contracts/dist/harness-route.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-route.js +42 -0
- package/src/native-ui/shared-contracts/dist/harness-route.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-session-import.d.ts +54 -0
- package/src/native-ui/shared-contracts/dist/harness-session-import.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/harness-session-import.js +72 -0
- package/src/native-ui/shared-contracts/dist/harness-session-import.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/ids.d.ts +12 -0
- package/src/native-ui/shared-contracts/dist/ids.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/ids.js +10 -0
- package/src/native-ui/shared-contracts/dist/ids.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/index.d.ts +47 -0
- package/src/native-ui/shared-contracts/dist/index.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/index.js +29 -0
- package/src/native-ui/shared-contracts/dist/index.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/json-rpc.d.ts +84 -0
- package/src/native-ui/shared-contracts/dist/json-rpc.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/json-rpc.js +65 -0
- package/src/native-ui/shared-contracts/dist/json-rpc.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/json-value.d.ts +13 -0
- package/src/native-ui/shared-contracts/dist/json-value.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/json-value.js +60 -0
- package/src/native-ui/shared-contracts/dist/json-value.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/native-refs.d.ts +43 -0
- package/src/native-ui/shared-contracts/dist/native-refs.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/native-refs.js +35 -0
- package/src/native-ui/shared-contracts/dist/native-refs.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/reasoning-transcript.d.ts +7 -0
- package/src/native-ui/shared-contracts/dist/reasoning-transcript.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/reasoning-transcript.js +7 -0
- package/src/native-ui/shared-contracts/dist/reasoning-transcript.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/thread-delegate.d.ts +22 -0
- package/src/native-ui/shared-contracts/dist/thread-delegate.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/thread-delegate.js +30 -0
- package/src/native-ui/shared-contracts/dist/thread-delegate.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/thread-harness-switch.d.ts +16 -0
- package/src/native-ui/shared-contracts/dist/thread-harness-switch.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/thread-harness-switch.js +19 -0
- package/src/native-ui/shared-contracts/dist/thread-harness-switch.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/thread-usage.d.ts +106 -0
- package/src/native-ui/shared-contracts/dist/thread-usage.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/thread-usage.js +103 -0
- package/src/native-ui/shared-contracts/dist/thread-usage.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/tsconfig.tsbuildinfo +1 -0
- package/src/native-ui/shared-contracts/dist/updates.d.ts +128 -0
- package/src/native-ui/shared-contracts/dist/updates.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/updates.js +58 -0
- package/src/native-ui/shared-contracts/dist/updates.js.map +1 -0
- package/src/native-ui/shared-contracts/dist/version.d.ts +2 -0
- package/src/native-ui/shared-contracts/dist/version.d.ts.map +1 -0
- package/src/native-ui/shared-contracts/dist/version.js +2 -0
- package/src/native-ui/shared-contracts/dist/version.js.map +1 -0
- package/src/native-ui/shared-contracts/package.json +25 -0
- package/src/native-ui/shared-contracts/src/codex-accounts.ts +140 -0
- package/src/native-ui/shared-contracts/src/deepseek-modern-sessions.ts +67 -0
- package/src/native-ui/shared-contracts/src/errors.ts +25 -0
- package/src/native-ui/shared-contracts/src/external-thread-fork.ts +20 -0
- package/src/native-ui/shared-contracts/src/harness-accounts.ts +32 -0
- package/src/native-ui/shared-contracts/src/harness-commands.ts +81 -0
- package/src/native-ui/shared-contracts/src/harness-models.ts +406 -0
- package/src/native-ui/shared-contracts/src/harness-permission-modes.ts +73 -0
- package/src/native-ui/shared-contracts/src/harness-plugins.ts +96 -0
- package/src/native-ui/shared-contracts/src/harness-route.ts +47 -0
- package/src/native-ui/shared-contracts/src/harness-session-import.ts +90 -0
- package/src/native-ui/shared-contracts/src/ids.ts +20 -0
- package/src/native-ui/shared-contracts/src/index.ts +320 -0
- package/src/native-ui/shared-contracts/src/json-rpc.ts +80 -0
- package/src/native-ui/shared-contracts/src/json-value.ts +78 -0
- package/src/native-ui/shared-contracts/src/native-refs.ts +58 -0
- package/src/native-ui/shared-contracts/src/reasoning-transcript.ts +6 -0
- package/src/native-ui/shared-contracts/src/thread-delegate.ts +40 -0
- package/src/native-ui/shared-contracts/src/thread-harness-switch.ts +25 -0
- package/src/native-ui/shared-contracts/src/thread-usage.ts +126 -0
- package/src/native-ui/shared-contracts/src/updates.ts +78 -0
- package/src/native-ui/shared-contracts/src/version.ts +1 -0
- package/src/native-ui/shared-contracts/test/browser-bundle.test.ts +36 -0
- package/src/native-ui/shared-contracts/test/deepseek-modern-sessions.test.ts +120 -0
- package/src/native-ui/shared-contracts/test/errors.test.ts +72 -0
- package/src/native-ui/shared-contracts/test/harness-commands.test.ts +64 -0
- package/src/native-ui/shared-contracts/test/harness-models.test.ts +390 -0
- package/src/native-ui/shared-contracts/test/harness-permission-modes.test.ts +134 -0
- package/src/native-ui/shared-contracts/test/harness-plugins.test.ts +113 -0
- package/src/native-ui/shared-contracts/test/harness-session-import.test.ts +117 -0
- package/src/native-ui/shared-contracts/test/ids.test.ts +69 -0
- package/src/native-ui/shared-contracts/test/index.test.ts +80 -0
- package/src/native-ui/shared-contracts/test/json-rpc.test.ts +177 -0
- package/src/native-ui/shared-contracts/test/json-value.test.ts +62 -0
- package/src/native-ui/shared-contracts/test/native-refs.test.ts +95 -0
- package/src/native-ui/shared-contracts/test/thread-usage.test.ts +115 -0
- package/src/native-ui/shared-contracts/test/updates.test.ts +120 -0
- package/src/native-ui/shared-contracts/tsconfig.json +10 -0
- package/src/tsconfig.base.json +19 -0
|
@@ -0,0 +1,1368 @@
|
|
|
1
|
+
const { spawn, execFile } = require('node:child_process');
|
|
2
|
+
const { randomUUID, randomBytes } = require('node:crypto');
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const http = require('node:http');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const readline = require('node:readline');
|
|
8
|
+
const { recordNative } = require('../harness-adapter/fixture-recorder');
|
|
9
|
+
const { terminateTree } = require('../native/process-utils');
|
|
10
|
+
|
|
11
|
+
const manifest = {
|
|
12
|
+
id: 'antigravity',
|
|
13
|
+
name: 'Antigravity',
|
|
14
|
+
icon: 'antigravity-color.svg',
|
|
15
|
+
aliases: ['agy', 'antigravity'],
|
|
16
|
+
capabilities: {
|
|
17
|
+
collaborationTools: true,
|
|
18
|
+
streaming: true,
|
|
19
|
+
thinking: true,
|
|
20
|
+
tools: true,
|
|
21
|
+
approvals: true,
|
|
22
|
+
questions: true,
|
|
23
|
+
models: true,
|
|
24
|
+
thinkingLevels: true,
|
|
25
|
+
permissionModes: true,
|
|
26
|
+
resume: true,
|
|
27
|
+
fork: true,
|
|
28
|
+
forkFromMessage: true,
|
|
29
|
+
compaction: false,
|
|
30
|
+
usage: true,
|
|
31
|
+
contextUsage: true,
|
|
32
|
+
attachments: true,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const ANTIGRAVITY_PERMISSION_MODES = [
|
|
37
|
+
{ id: 'default', label: '默认', description: '按 Antigravity 预设规则拦截或执行' },
|
|
38
|
+
{ id: 'desktop', label: '桌面确认', description: '在 Harness Mix 桌面端弹出确认工具执行' },
|
|
39
|
+
{ id: 'skip', label: '自动放行', description: '自动放行工具执行(--dangerously-skip-permissions)', dangerous: true },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION =
|
|
43
|
+
'[System Instruction: When creating new files in the workspace, you MUST use the write_to_file tool. When modifying existing files, use the replace_file_content tool. CRITICAL: NEVER include ArtifactMetadata when calling write_to_file for workspace files (ArtifactMetadata is strictly reserved for artifacts in the brain directory, and providing it for workspace files causes a path validation rejection). Do NOT use terminal commands (such as Set-Content, Out-File, echo, or cat) to create or write code files. For clarification, ask_question is connected to the codexhost Desktop through a Hook. Use single-choice or text questions. The Hook returns the actual user response in its reason while blocking the native auto-skip behavior; do not retry merely because the native tool reports it was blocked.]\n\n';
|
|
44
|
+
|
|
45
|
+
const EFFORT_LABELS = {
|
|
46
|
+
low: 'Low',
|
|
47
|
+
medium: 'Medium',
|
|
48
|
+
high: 'High',
|
|
49
|
+
};
|
|
50
|
+
const EFFORT_SUFFIX_PATTERN = /^(?<base>.+)-(?<effort>low|medium|high)$/u;
|
|
51
|
+
const EFFORT_LABEL_SUFFIX_PATTERN = /\s*\((?:low|medium|high)\)$/iu;
|
|
52
|
+
const ANTIGRAVITY_RESULT_DRAIN_MS = 250;
|
|
53
|
+
const ANTIGRAVITY_RESULT_DRAIN_MAX_MS = 10_000;
|
|
54
|
+
|
|
55
|
+
function positiveDuration(value, fallback) {
|
|
56
|
+
const duration = Number(value);
|
|
57
|
+
return Number.isFinite(duration) && duration > 0 ? duration : fallback;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function resolveExecutable() {
|
|
61
|
+
if (process.env.HARNESS_MIX_ANTIGRAVITY_COMMAND) return process.env.HARNESS_MIX_ANTIGRAVITY_COMMAND;
|
|
62
|
+
if (process.env.CODEXHOST_ANTIGRAVITY_COMMAND) return process.env.CODEXHOST_ANTIGRAVITY_COMMAND;
|
|
63
|
+
if (process.platform === 'win32') {
|
|
64
|
+
const local = path.join(process.env.LOCALAPPDATA || '', 'agy', 'bin', 'agy.exe');
|
|
65
|
+
if (fs.existsSync(local)) return local;
|
|
66
|
+
}
|
|
67
|
+
return 'agy';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function parseModelsOutput(output) {
|
|
71
|
+
const grouped = new Map();
|
|
72
|
+
for (const rawLine of String(output || '').split(/\r?\n/)) {
|
|
73
|
+
const line = rawLine.trim();
|
|
74
|
+
if (!line || line.startsWith('Fetching')) continue;
|
|
75
|
+
const tabIdx = line.indexOf('\t');
|
|
76
|
+
if (tabIdx <= 0) continue;
|
|
77
|
+
const id = line.slice(0, tabIdx).trim();
|
|
78
|
+
const label = line.slice(tabIdx + 1).trim();
|
|
79
|
+
if (!id || !label) continue;
|
|
80
|
+
const match = EFFORT_SUFFIX_PATTERN.exec(id);
|
|
81
|
+
const baseId = match?.groups?.base || id;
|
|
82
|
+
const baseLabel = match ? label.replace(EFFORT_LABEL_SUFFIX_PATTERN, '').trim() || label : label;
|
|
83
|
+
const effort = match?.groups?.effort || null;
|
|
84
|
+
|
|
85
|
+
if (!grouped.has(baseId)) {
|
|
86
|
+
grouped.set(baseId, { id: baseId, name: baseLabel, efforts: [] });
|
|
87
|
+
}
|
|
88
|
+
const entry = grouped.get(baseId);
|
|
89
|
+
if (effort && !entry.efforts.some((e) => e.id === effort)) {
|
|
90
|
+
entry.efforts.push({ id: effort, label: EFFORT_LABELS[effort] || effort });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const models = [];
|
|
95
|
+
for (const entry of grouped.values()) {
|
|
96
|
+
let provider = 'google';
|
|
97
|
+
if (/claude/i.test(entry.id)) provider = 'anthropic';
|
|
98
|
+
else if (/gpt|openai/i.test(entry.id)) provider = 'openai';
|
|
99
|
+
|
|
100
|
+
const order = ['low', 'medium', 'high'];
|
|
101
|
+
entry.efforts.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
|
|
102
|
+
|
|
103
|
+
models.push({
|
|
104
|
+
id: entry.id,
|
|
105
|
+
name: entry.name,
|
|
106
|
+
provider,
|
|
107
|
+
efforts: entry.efforts,
|
|
108
|
+
defaultEffort: entry.efforts.at(-1)?.id || 'high',
|
|
109
|
+
contextWindow: /claude/i.test(entry.id) ? 200_000 : 1_048_576,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return models;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function resolveContextWindow(modelId) {
|
|
116
|
+
if (modelId && /claude/i.test(modelId)) return 200_000;
|
|
117
|
+
return 1_048_576;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function usedPercentFrom(remainingFraction) {
|
|
121
|
+
if (typeof remainingFraction !== 'number' || !Number.isFinite(remainingFraction)) return null;
|
|
122
|
+
const used = (1 - Math.min(1, Math.max(0, remainingFraction))) * 100;
|
|
123
|
+
return Math.round(used * 100) / 100;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function parseAntigravityUsageCommand(command, fetchedAt = new Date().toISOString()) {
|
|
127
|
+
if (!command || typeof command !== 'object' || command.name !== 'usage' || !command.data) return null;
|
|
128
|
+
const { groups } = command.data;
|
|
129
|
+
if (!Array.isArray(groups)) return null;
|
|
130
|
+
const buckets = [];
|
|
131
|
+
for (const group of groups) {
|
|
132
|
+
if (!group || !Array.isArray(group.buckets)) continue;
|
|
133
|
+
const groupName = typeof group.name === 'string' ? group.name.trim() : '';
|
|
134
|
+
for (const bucket of group.buckets) {
|
|
135
|
+
if (!bucket || typeof bucket !== 'object') continue;
|
|
136
|
+
const usagePercent = usedPercentFrom(bucket.remaining_fraction);
|
|
137
|
+
if (usagePercent === null) continue;
|
|
138
|
+
const window = typeof bucket.window === 'string' ? bucket.window.trim() : '';
|
|
139
|
+
const label = window === 'weekly' ? 'Weekly window' : window === '5h' ? '5-hour window' : (window || bucket.id);
|
|
140
|
+
const resetsAt = typeof bucket.reset_time === 'string' && bucket.reset_time.trim() ? bucket.reset_time.trim() : undefined;
|
|
141
|
+
buckets.push({
|
|
142
|
+
product: groupName ? `${groupName} · ${label}` : label,
|
|
143
|
+
usagePercent,
|
|
144
|
+
window,
|
|
145
|
+
...(resetsAt ? { resetsAt } : {}),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (!buckets.length) return null;
|
|
150
|
+
const leading = [...buckets].sort((a, b) => {
|
|
151
|
+
if (b.usagePercent !== a.usagePercent) return b.usagePercent - a.usagePercent;
|
|
152
|
+
return Number(b.window === '5h') - Number(a.window === '5h');
|
|
153
|
+
})[0];
|
|
154
|
+
const others = buckets.filter((b) => b !== leading);
|
|
155
|
+
return {
|
|
156
|
+
usedPercent: leading.usagePercent,
|
|
157
|
+
periodType: leading.window === '5h' ? 'five_hour' : 'weekly',
|
|
158
|
+
fetchedAt,
|
|
159
|
+
...(leading.resetsAt ? { resetsAt: leading.resetsAt } : {}),
|
|
160
|
+
...(others.length > 0
|
|
161
|
+
? { productUsage: others.map(({ product, usagePercent, resetsAt }) => ({ product, usagePercent, ...(resetsAt ? { resetsAt } : {}) })) }
|
|
162
|
+
: {}),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function fetchAntigravityQuota(executable = resolveExecutable()) {
|
|
167
|
+
return new Promise((resolve) => {
|
|
168
|
+
execFile(executable, ['--print=/usage', '--output-format', 'stream-json'], { windowsHide: true, timeout: 15000 }, (err, stdout) => {
|
|
169
|
+
if (err || !stdout) return resolve(null);
|
|
170
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
171
|
+
if (!line.trim()) continue;
|
|
172
|
+
try {
|
|
173
|
+
const event = JSON.parse(line);
|
|
174
|
+
if (event?.event === 'command_result') {
|
|
175
|
+
const snapshot = parseAntigravityUsageCommand(event.command);
|
|
176
|
+
if (snapshot) return resolve(snapshot);
|
|
177
|
+
}
|
|
178
|
+
} catch {}
|
|
179
|
+
}
|
|
180
|
+
resolve(null);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function parseUsage(usageObj, modelId, quota) {
|
|
186
|
+
if (!usageObj) return null;
|
|
187
|
+
const input = usageObj.input_tokens ?? usageObj.inputTokens;
|
|
188
|
+
const output = usageObj.output_tokens ?? usageObj.outputTokens;
|
|
189
|
+
const thinking = usageObj.thinking_tokens ?? usageObj.reasoningOutputTokens;
|
|
190
|
+
const cached = usageObj.cache_read_tokens ?? usageObj.cachedInputTokens;
|
|
191
|
+
const total = usageObj.total_tokens ?? usageObj.totalTokens;
|
|
192
|
+
const contextWindow = resolveContextWindow(modelId);
|
|
193
|
+
const contextUsed = usageObj.context_used_tokens ?? usageObj.estimated_tokens_used ?? input;
|
|
194
|
+
const tokens = typeof contextUsed === 'number' ? contextUsed : (typeof total === 'number' ? total : null);
|
|
195
|
+
const result = {
|
|
196
|
+
tokens,
|
|
197
|
+
contextWindow,
|
|
198
|
+
contextPercent: tokens != null && contextWindow ? Math.min(100, Math.round((100 * tokens / contextWindow) * 10) / 10) : null,
|
|
199
|
+
inputTokens: typeof input === 'number' ? input : null,
|
|
200
|
+
outputTokens: typeof output === 'number' ? output : null,
|
|
201
|
+
reasoningOutputTokens: typeof thinking === 'number' ? thinking : null,
|
|
202
|
+
cachedInputTokens: typeof cached === 'number' ? cached : null,
|
|
203
|
+
totalTokens: typeof total === 'number' ? total : (typeof input === 'number' && typeof output === 'number' ? input + output : null),
|
|
204
|
+
};
|
|
205
|
+
if (quota) {
|
|
206
|
+
if (quota.periodType === 'five_hour') {
|
|
207
|
+
result.planFiveHourUsedPercent = quota.usedPercent;
|
|
208
|
+
if (quota.resetsAt) {
|
|
209
|
+
const unix = Math.floor(Date.parse(quota.resetsAt) / 1000);
|
|
210
|
+
if (Number.isFinite(unix) && unix > 0) result.planFiveHourResetsAtUnix = unix;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const weekly = quota.productUsage?.find(p => /weekly/i.test(p.product)) || (quota.periodType === 'weekly' ? quota : null);
|
|
214
|
+
if (weekly) {
|
|
215
|
+
result.planSevenDayUsedPercent = weekly.usagePercent;
|
|
216
|
+
if (weekly.resetsAt) {
|
|
217
|
+
const unix = Math.floor(Date.parse(weekly.resetsAt) / 1000);
|
|
218
|
+
if (Number.isFinite(unix) && unix > 0) result.planSevenDayResetsAtUnix = unix;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function errorText(value) {
|
|
226
|
+
if (value == null) return '';
|
|
227
|
+
if (value instanceof Error) return value.message.trim();
|
|
228
|
+
if (typeof value === 'string') return value.trim();
|
|
229
|
+
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
230
|
+
if (Array.isArray(value)) return value.map(errorText).filter(Boolean).join('; ');
|
|
231
|
+
if (typeof value === 'object') {
|
|
232
|
+
const code = value.code ?? value.errorCode ?? value.status;
|
|
233
|
+
const nested = value.message ?? value.errorMessage ?? value.error_message ?? value.detail ?? value.description ?? value.reason ?? value.error;
|
|
234
|
+
const message = errorText(nested);
|
|
235
|
+
if (message) {
|
|
236
|
+
const codeText = code == null ? '' : String(code).trim();
|
|
237
|
+
return codeText && !message.startsWith(`${codeText}:`) ? `${codeText}: ${message}` : message;
|
|
238
|
+
}
|
|
239
|
+
try { return JSON.stringify(value); } catch { return ''; }
|
|
240
|
+
}
|
|
241
|
+
return String(value);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function formatAntigravityResultError(result) {
|
|
245
|
+
const detail = [result?.error, result?.errorMessage, result?.error_message, result?.message, result?.detail]
|
|
246
|
+
.map(errorText)
|
|
247
|
+
.find(Boolean);
|
|
248
|
+
if (detail) return `Antigravity 回合失败:${detail}`;
|
|
249
|
+
const status = errorText(result?.status);
|
|
250
|
+
return status ? `Antigravity 回合失败(${status})` : 'Antigravity 回合失败(未知错误)';
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function resultSucceeded(result) {
|
|
254
|
+
return errorText(result?.status).toUpperCase() === 'SUCCESS';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function modelSupportsEffort(model) {
|
|
258
|
+
const id = String(model?.id ?? '').trim();
|
|
259
|
+
if (Array.isArray(model?.efforts)) return model.efforts.length > 0;
|
|
260
|
+
// Claude models expose built-in thinking in agy and reject --effort.
|
|
261
|
+
return !/^claude(?:[-_.]|$)/i.test(id);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function formatPrompt(text) {
|
|
265
|
+
if (!text) return '';
|
|
266
|
+
if (text.startsWith('/') || text.includes('ArtifactMetadata')) return text;
|
|
267
|
+
return `${ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION}${text}`;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async function prepareImageAttachments(images, cwd) {
|
|
271
|
+
if (!Array.isArray(images) || !images.length) return { imageEntries: [], extraDirs: [] };
|
|
272
|
+
const imageEntries = [];
|
|
273
|
+
const extraDirs = [];
|
|
274
|
+
let targetDir = null;
|
|
275
|
+
const ensureTargetDir = async () => {
|
|
276
|
+
if (targetDir) return targetDir;
|
|
277
|
+
targetDir = path.join(cwd, '.gemini', 'attachments');
|
|
278
|
+
try {
|
|
279
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
280
|
+
} catch {
|
|
281
|
+
targetDir = path.join(os.tmpdir(), 'harness-mix-antigravity-attachments');
|
|
282
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
283
|
+
if (!extraDirs.includes(targetDir)) extraDirs.push(targetDir);
|
|
284
|
+
}
|
|
285
|
+
return targetDir;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
for (const img of images) {
|
|
289
|
+
if (!img) continue;
|
|
290
|
+
const ext = path.extname(img.name || '') || (img.mime === 'image/jpeg' ? '.jpg' : img.mime === 'image/gif' ? '.gif' : img.mime === 'image/webp' ? '.webp' : img.mime === 'image/svg+xml' ? '.svg' : '.png');
|
|
291
|
+
const safeBase = path.basename(img.name || 'image', ext).replace(/[^a-zA-Z0-9_\-\u4e00-\u9fa5]/g, '_') || 'image';
|
|
292
|
+
const fileName = `${Date.now()}-${randomUUID().slice(0, 6)}-${safeBase}${ext}`;
|
|
293
|
+
const sourcePath = typeof img.path === 'string' && img.path ? path.resolve(cwd, img.path) : null;
|
|
294
|
+
const hasData = typeof img.data === 'string' && img.data.length > 0;
|
|
295
|
+
if (!sourcePath && !hasData) throw new Error(`图片附件「${img.name || 'image'}」缺少本地文件或内容`);
|
|
296
|
+
|
|
297
|
+
// Desktop clipboard images live in %TEMP% and may disappear after this
|
|
298
|
+
// turn. Always materialize a durable copy before putting a path in the
|
|
299
|
+
// native prompt, even when the source still exists right now.
|
|
300
|
+
const durableDir = await ensureTargetDir();
|
|
301
|
+
const filePath = path.join(durableDir, fileName);
|
|
302
|
+
if (hasData) await fs.promises.writeFile(filePath, Buffer.from(img.data, 'base64'));
|
|
303
|
+
else await fs.promises.copyFile(sourcePath, filePath);
|
|
304
|
+
|
|
305
|
+
if (!fs.existsSync(filePath)) {
|
|
306
|
+
throw new Error(`图片附件「${img.name || 'image'}」保存失败`);
|
|
307
|
+
}
|
|
308
|
+
const normalizedPath = path.resolve(filePath).replace(/\\/g, '/');
|
|
309
|
+
imageEntries.push({ name: img.name || path.basename(filePath), path: normalizedPath });
|
|
310
|
+
}
|
|
311
|
+
return { imageEntries, extraDirs };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function restoreLegacyClipboardAttachments(thread) {
|
|
315
|
+
const tempRoot = path.resolve(os.tmpdir());
|
|
316
|
+
const restored = new Set();
|
|
317
|
+
const messages = Array.isArray(thread?.messages) ? thread.messages : [];
|
|
318
|
+
for (const message of messages) {
|
|
319
|
+
const attachments = Array.isArray(message?.attachments) ? message.attachments : [];
|
|
320
|
+
for (const attachment of attachments) {
|
|
321
|
+
if (attachment?.kind !== 'image' || typeof attachment.path !== 'string' || !attachment.path || typeof attachment.data !== 'string' || !attachment.data) continue;
|
|
322
|
+
const filePath = path.resolve(thread.cwd || process.cwd(), attachment.path);
|
|
323
|
+
const relative = path.relative(tempRoot, filePath);
|
|
324
|
+
if (!relative || path.isAbsolute(relative) || relative.includes(path.sep) || !/^codex-clipboard-[a-z0-9-]+\.(?:png|jpe?g|gif|webp)$/i.test(path.basename(filePath))) continue;
|
|
325
|
+
if (fs.existsSync(filePath) || restored.has(filePath)) continue;
|
|
326
|
+
try {
|
|
327
|
+
await fs.promises.writeFile(filePath, Buffer.from(attachment.data, 'base64'));
|
|
328
|
+
restored.add(filePath);
|
|
329
|
+
} catch { /* A missing legacy temp file must not prevent session recovery. */ }
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return restored.size;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function toolTitle(name) {
|
|
336
|
+
if (!name) return 'Antigravity 工具';
|
|
337
|
+
if (name === 'run_command') return 'exec_command';
|
|
338
|
+
if (name === 'write_to_file' || name === 'replace_file_content') return 'edit';
|
|
339
|
+
if (name === 'view_file') return 'view_file';
|
|
340
|
+
if (name === 'list_dir') return 'list_dir';
|
|
341
|
+
if (name === 'grep_search') return 'grep_search';
|
|
342
|
+
if (name === 'find_by_name') return 'find_by_name';
|
|
343
|
+
if (name === 'read_url_content') return 'web_fetch';
|
|
344
|
+
if (name === 'search_web') return 'search_web';
|
|
345
|
+
if (name === 'ask_question') return '提问';
|
|
346
|
+
if (name === 'generate_image') return '生成图片';
|
|
347
|
+
if (name === 'schedule') return '调度任务';
|
|
348
|
+
if (name === 'manage_task') return '后台任务';
|
|
349
|
+
if (name === 'invoke_subagent') return '子 Agent';
|
|
350
|
+
return name;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function mergePendingStep(pending, step) {
|
|
354
|
+
if (!pending) return step;
|
|
355
|
+
const toolName = step.tool_name ?? pending.tool_name;
|
|
356
|
+
const name = step.tool_info?.name ?? pending.tool_info?.name;
|
|
357
|
+
const parameters = step.tool_info?.parameters ?? pending.tool_info?.parameters;
|
|
358
|
+
const output = step.tool_info?.output ?? pending.tool_info?.output;
|
|
359
|
+
const error = step.tool_info?.error ?? pending.tool_info?.error;
|
|
360
|
+
return {
|
|
361
|
+
...pending,
|
|
362
|
+
...step,
|
|
363
|
+
...(toolName !== undefined ? { tool_name: toolName } : {}),
|
|
364
|
+
...(step.tool_info !== undefined || pending.tool_info !== undefined
|
|
365
|
+
? {
|
|
366
|
+
tool_info: {
|
|
367
|
+
...(name !== undefined ? { name } : {}),
|
|
368
|
+
...(parameters !== undefined ? { parameters } : {}),
|
|
369
|
+
...(output !== undefined ? { output } : {}),
|
|
370
|
+
...(error !== undefined ? { error } : {}),
|
|
371
|
+
},
|
|
372
|
+
}
|
|
373
|
+
: {}),
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function toolInput(step) {
|
|
378
|
+
const params = step.tool_info?.parameters;
|
|
379
|
+
if (!params) return undefined;
|
|
380
|
+
if (typeof params === 'string') return params;
|
|
381
|
+
if (params.CommandLine) return params.CommandLine;
|
|
382
|
+
if (params.TargetFile) return `${params.TargetFile}\n${params.Description || ''}`.trim();
|
|
383
|
+
if (params.AbsolutePath) return params.AbsolutePath;
|
|
384
|
+
if (params.DirectoryPath) return params.DirectoryPath;
|
|
385
|
+
if (params.Url) return params.Url;
|
|
386
|
+
if (params.query) return params.query;
|
|
387
|
+
if (Array.isArray(params.Subagents)) {
|
|
388
|
+
return params.Subagents.map((s) => `[${s.Role || s.TypeName || 'Agent'}] ${s.Prompt || ''}`.trim()).join('\n');
|
|
389
|
+
}
|
|
390
|
+
return JSON.stringify(params, null, 2);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function toolOutput(step) {
|
|
394
|
+
const info = step.tool_info;
|
|
395
|
+
if (!info) return undefined;
|
|
396
|
+
if (info.error) return typeof info.error === 'string' ? info.error : JSON.stringify(info.error, null, 2);
|
|
397
|
+
if (info.output != null) return typeof info.output === 'string' ? info.output : JSON.stringify(info.output, null, 2);
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function nativeConversationDbPath(sessionId, homedir = os.homedir()) {
|
|
402
|
+
return path.join(homedir, '.gemini', 'antigravity-cli', 'conversations', `${sessionId}.db`);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function nativeBrainDirPath(sessionId, homedir = os.homedir()) {
|
|
406
|
+
return path.join(homedir, '.gemini', 'antigravity-cli', 'brain', sessionId);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function cloneDatabase(sourceId, derivedId, retainedTurnsCountOrHomedir, homedirOption = os.homedir()) {
|
|
410
|
+
let retainedTurnsCount;
|
|
411
|
+
let homedir = homedirOption;
|
|
412
|
+
if (typeof retainedTurnsCountOrHomedir === 'string') {
|
|
413
|
+
homedir = retainedTurnsCountOrHomedir;
|
|
414
|
+
} else if (typeof retainedTurnsCountOrHomedir === 'number') {
|
|
415
|
+
retainedTurnsCount = retainedTurnsCountOrHomedir;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const sourceDb = nativeConversationDbPath(sourceId, homedir);
|
|
419
|
+
const targetDb = nativeConversationDbPath(derivedId, homedir);
|
|
420
|
+
try {
|
|
421
|
+
await fs.promises.mkdir(path.dirname(targetDb), { recursive: true });
|
|
422
|
+
await fs.promises.copyFile(sourceDb, targetDb);
|
|
423
|
+
} catch {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
let remainingStepCount = 0;
|
|
428
|
+
try {
|
|
429
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
430
|
+
const db = new DatabaseSync(targetDb);
|
|
431
|
+
try {
|
|
432
|
+
db.prepare('UPDATE trajectory_meta SET cascade_id = ?').run(derivedId);
|
|
433
|
+
if (typeof retainedTurnsCount === 'number' && Number.isInteger(retainedTurnsCount)) {
|
|
434
|
+
try {
|
|
435
|
+
if (retainedTurnsCount <= 0) {
|
|
436
|
+
db.prepare('DELETE FROM steps').run();
|
|
437
|
+
} else {
|
|
438
|
+
const rows = db.prepare('SELECT idx FROM steps WHERE step_type = 14 ORDER BY idx ASC').all();
|
|
439
|
+
const cutoff = rows[retainedTurnsCount];
|
|
440
|
+
if (cutoff && typeof cutoff.idx === 'number') {
|
|
441
|
+
db.prepare('DELETE FROM steps WHERE idx >= ?').run(cutoff.idx);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
} catch {}
|
|
445
|
+
try { db.prepare('DELETE FROM gen_metadata WHERE idx >= ?').run(retainedTurnsCount); } catch {}
|
|
446
|
+
try { db.prepare('DELETE FROM executor_metadata WHERE idx >= ?').run(retainedTurnsCount); } catch {}
|
|
447
|
+
try { db.prepare('DELETE FROM parent_references WHERE idx >= ?').run(retainedTurnsCount); } catch {}
|
|
448
|
+
try { db.prepare('DELETE FROM battle_mode_infos WHERE idx >= ?').run(retainedTurnsCount); } catch {}
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
const countRow = db.prepare('SELECT count(*) as c FROM steps').get();
|
|
452
|
+
if (countRow && typeof countRow.c === 'number') remainingStepCount = countRow.c;
|
|
453
|
+
} catch {}
|
|
454
|
+
} finally {
|
|
455
|
+
db.close();
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Register in conversation_summaries.db so `agy` trajectory lookup succeeds
|
|
459
|
+
try {
|
|
460
|
+
const summariesDbPath = path.join(homedir, '.gemini', 'antigravity-cli', 'conversation_summaries.db');
|
|
461
|
+
if (fs.existsSync(summariesDbPath)) {
|
|
462
|
+
const sumDb = new DatabaseSync(summariesDbPath);
|
|
463
|
+
try {
|
|
464
|
+
const row = sumDb.prepare('SELECT * FROM conversation_summaries WHERE conversation_id = ?').get(sourceId);
|
|
465
|
+
if (row) {
|
|
466
|
+
const cols = Object.keys(row);
|
|
467
|
+
const newRow = {
|
|
468
|
+
...row,
|
|
469
|
+
conversation_id: derivedId,
|
|
470
|
+
last_modified_time: new Date().toISOString(),
|
|
471
|
+
...(typeof retainedTurnsCount === 'number' ? { step_count: remainingStepCount } : {}),
|
|
472
|
+
};
|
|
473
|
+
const placeholders = cols.map(() => '?').join(', ');
|
|
474
|
+
const values = cols.map((col) => newRow[col]);
|
|
475
|
+
sumDb
|
|
476
|
+
.prepare(
|
|
477
|
+
`INSERT OR REPLACE INTO conversation_summaries (${cols.map((c) => `\`${c}\``).join(', ')}) VALUES (${placeholders})`
|
|
478
|
+
)
|
|
479
|
+
.run(...values);
|
|
480
|
+
}
|
|
481
|
+
} finally {
|
|
482
|
+
sumDb.close();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
} catch {}
|
|
486
|
+
} catch {}
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
async function cloneBrain(sourceId, derivedId, homedir = os.homedir()) {
|
|
491
|
+
const sourceBrain = nativeBrainDirPath(sourceId, homedir);
|
|
492
|
+
const targetBrain = nativeBrainDirPath(derivedId, homedir);
|
|
493
|
+
try {
|
|
494
|
+
await fs.promises.cp(sourceBrain, targetBrain, {
|
|
495
|
+
recursive: true,
|
|
496
|
+
filter: (src) => path.basename(src) !== '.system_generated',
|
|
497
|
+
});
|
|
498
|
+
return true;
|
|
499
|
+
} catch {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const ANTIGRAVITY_QUESTION_HOOK_CLIENT = `
|
|
505
|
+
const http = require("node:http");
|
|
506
|
+
const limit = 131072;
|
|
507
|
+
let input = "";
|
|
508
|
+
let finished = false;
|
|
509
|
+
let request;
|
|
510
|
+
function finish(value) {
|
|
511
|
+
if (finished) return;
|
|
512
|
+
finished = true;
|
|
513
|
+
process.stdout.write(JSON.stringify(value));
|
|
514
|
+
}
|
|
515
|
+
function unavailable() {
|
|
516
|
+
finish({
|
|
517
|
+
decision: "deny",
|
|
518
|
+
reason: "codexhost question bridge is unavailable. No user answer was received. Do not report that the user skipped or selected an option."
|
|
519
|
+
});
|
|
520
|
+
if (request) request.destroy();
|
|
521
|
+
}
|
|
522
|
+
process.stdin.setEncoding("utf8");
|
|
523
|
+
process.stdin.on("error", unavailable);
|
|
524
|
+
process.stdin.on("data", chunk => {
|
|
525
|
+
input += chunk;
|
|
526
|
+
if (Buffer.byteLength(input) > limit) {
|
|
527
|
+
input = "";
|
|
528
|
+
process.stdin.destroy();
|
|
529
|
+
unavailable();
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
process.stdin.on("end", () => {
|
|
533
|
+
if (finished) return;
|
|
534
|
+
try {
|
|
535
|
+
const target = new URL(process.env.CODEXHOST_AGY_QUESTION_URL);
|
|
536
|
+
if (target.protocol !== "http:" || target.hostname !== "127.0.0.1" ||
|
|
537
|
+
target.pathname !== "/question" || target.username || target.password) {
|
|
538
|
+
return unavailable();
|
|
539
|
+
}
|
|
540
|
+
const payload = JSON.parse(input);
|
|
541
|
+
const approval = process.env.CODEXHOST_AGY_QUESTION_APPROVALS === "1" &&
|
|
542
|
+
payload.toolCall && payload.toolCall.name !== "ask_question";
|
|
543
|
+
request = http.request(target, {
|
|
544
|
+
method: "POST",
|
|
545
|
+
headers: {
|
|
546
|
+
"content-type": "application/json",
|
|
547
|
+
"authorization": "Bearer " + process.env.CODEXHOST_AGY_QUESTION_TOKEN,
|
|
548
|
+
"content-length": Buffer.byteLength(input)
|
|
549
|
+
}
|
|
550
|
+
}, response => {
|
|
551
|
+
let body = "";
|
|
552
|
+
response.setEncoding("utf8");
|
|
553
|
+
response.on("error", unavailable);
|
|
554
|
+
response.on("aborted", unavailable);
|
|
555
|
+
response.on("data", chunk => {
|
|
556
|
+
body += chunk;
|
|
557
|
+
if (Buffer.byteLength(body) > limit) unavailable();
|
|
558
|
+
});
|
|
559
|
+
response.on("end", () => {
|
|
560
|
+
try {
|
|
561
|
+
const value = JSON.parse(body);
|
|
562
|
+
if (response.statusCode !== 200 ||
|
|
563
|
+
(value.decision !== "deny" && !(approval && value.decision === "allow")) ||
|
|
564
|
+
typeof value.reason !== "string") return unavailable();
|
|
565
|
+
finish(value);
|
|
566
|
+
} catch { unavailable(); }
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
request.setTimeout(Number(process.env.CODEXHOST_AGY_QUESTION_TIMEOUT_MS) + 5000, unavailable);
|
|
570
|
+
request.on("error", unavailable);
|
|
571
|
+
request.end(input);
|
|
572
|
+
} catch { unavailable(); }
|
|
573
|
+
});
|
|
574
|
+
`;
|
|
575
|
+
|
|
576
|
+
class QuestionBridge {
|
|
577
|
+
constructor({ approvals, emit, timeoutMs = 600000 }) {
|
|
578
|
+
this.approvals = approvals;
|
|
579
|
+
this.emit = emit;
|
|
580
|
+
this.timeoutMs = timeoutMs;
|
|
581
|
+
this.token = randomBytes(32).toString('hex');
|
|
582
|
+
this.pending = new Map();
|
|
583
|
+
this.directory = '';
|
|
584
|
+
this.server = null;
|
|
585
|
+
this.environment = {};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
static async create(options) {
|
|
589
|
+
const bridge = new QuestionBridge(options);
|
|
590
|
+
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'codexhost-agy-question-'));
|
|
591
|
+
bridge.directory = dir;
|
|
592
|
+
|
|
593
|
+
bridge.server = http.createServer((req, res) => bridge.#receive(req, res));
|
|
594
|
+
await new Promise((resolve, reject) => {
|
|
595
|
+
bridge.server.once('error', reject);
|
|
596
|
+
bridge.server.listen(0, '127.0.0.1', () => {
|
|
597
|
+
bridge.server.removeListener('error', reject);
|
|
598
|
+
resolve();
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
const address = bridge.server.address();
|
|
603
|
+
const port = address.port;
|
|
604
|
+
const clientPath = path.join(dir, 'question-hook.cjs');
|
|
605
|
+
await fs.promises.mkdir(path.join(dir, '.agents'), { recursive: true });
|
|
606
|
+
await fs.promises.writeFile(clientPath, ANTIGRAVITY_QUESTION_HOOK_CLIENT, 'utf8');
|
|
607
|
+
|
|
608
|
+
const hookCmd = process.platform === 'win32'
|
|
609
|
+
? '%CODEXHOST_AGY_QUESTION_NODE% %CODEXHOST_AGY_QUESTION_CLIENT%'
|
|
610
|
+
: `"${process.execPath}" "${clientPath}"`;
|
|
611
|
+
|
|
612
|
+
await fs.promises.writeFile(
|
|
613
|
+
path.join(dir, '.agents', 'hooks.json'),
|
|
614
|
+
JSON.stringify({
|
|
615
|
+
'codexhost-question-bridge': {
|
|
616
|
+
PreToolUse: [
|
|
617
|
+
{
|
|
618
|
+
matcher: options.approvals ? '.*' : '^ask_question$',
|
|
619
|
+
hooks: [
|
|
620
|
+
{
|
|
621
|
+
type: 'command',
|
|
622
|
+
command: hookCmd,
|
|
623
|
+
timeout: Math.ceil(options.timeoutMs / 1000) + 15,
|
|
624
|
+
},
|
|
625
|
+
],
|
|
626
|
+
},
|
|
627
|
+
],
|
|
628
|
+
},
|
|
629
|
+
}, null, 2),
|
|
630
|
+
'utf8',
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
bridge.environment = {
|
|
634
|
+
CODEXHOST_AGY_QUESTION_TOKEN: bridge.token,
|
|
635
|
+
CODEXHOST_AGY_QUESTION_URL: `http://127.0.0.1:${port}/question`,
|
|
636
|
+
CODEXHOST_AGY_QUESTION_TIMEOUT_MS: String(options.timeoutMs),
|
|
637
|
+
CODEXHOST_AGY_QUESTION_APPROVALS: options.approvals ? '1' : '0',
|
|
638
|
+
CODEXHOST_AGY_QUESTION_NODE: `"${process.execPath.replaceAll('\\', '/')}"`,
|
|
639
|
+
CODEXHOST_AGY_QUESTION_CLIENT: `"${clientPath.replaceAll('\\', '/')}"`,
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
if (options.collaboration) {
|
|
643
|
+
const pluginDir = path.join(dir, '.agents', 'plugins', 'harness-mix');
|
|
644
|
+
const plainPluginDir = path.join(dir, 'plugins', 'harness-mix');
|
|
645
|
+
await fs.promises.mkdir(pluginDir, { recursive: true });
|
|
646
|
+
await fs.promises.mkdir(plainPluginDir, { recursive: true });
|
|
647
|
+
const pluginManifest = JSON.stringify({ name: 'harness-mix-collaboration', description: 'Harness Mix Multi-agent Collaboration' }, null, 2);
|
|
648
|
+
const mcpConfig = JSON.stringify({
|
|
649
|
+
mcpServers: {
|
|
650
|
+
'harness-mix': {
|
|
651
|
+
command: options.collaboration.command,
|
|
652
|
+
args: options.collaboration.args,
|
|
653
|
+
env: options.collaboration.env,
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
}, null, 2);
|
|
657
|
+
await fs.promises.writeFile(path.join(pluginDir, 'plugin.json'), pluginManifest, 'utf8');
|
|
658
|
+
await fs.promises.writeFile(path.join(pluginDir, 'mcp_config.json'), mcpConfig, 'utf8');
|
|
659
|
+
await fs.promises.writeFile(path.join(plainPluginDir, 'plugin.json'), pluginManifest, 'utf8');
|
|
660
|
+
await fs.promises.writeFile(path.join(plainPluginDir, 'mcp_config.json'), mcpConfig, 'utf8');
|
|
661
|
+
await fs.promises.writeFile(path.join(dir, '.agents', 'mcp_config.json'), mcpConfig, 'utf8');
|
|
662
|
+
Object.assign(bridge.environment, options.collaboration.env || {});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return bridge;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
#receive(req, res) {
|
|
669
|
+
const auth = req.headers.authorization || '';
|
|
670
|
+
if (auth !== `Bearer ${this.token}` || req.method !== 'POST' || req.url !== '/question') {
|
|
671
|
+
res.writeHead(403, { 'content-type': 'application/json' });
|
|
672
|
+
res.end(JSON.stringify({ decision: 'deny', reason: 'Forbidden' }));
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
let body = '';
|
|
676
|
+
req.setEncoding('utf8');
|
|
677
|
+
req.on('data', (chunk) => { body += chunk; });
|
|
678
|
+
req.on('end', () => {
|
|
679
|
+
let payload;
|
|
680
|
+
try { payload = JSON.parse(body); }
|
|
681
|
+
catch {
|
|
682
|
+
res.writeHead(400, { 'content-type': 'application/json' });
|
|
683
|
+
res.end(JSON.stringify({ decision: 'deny', reason: 'Invalid JSON' }));
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
this.#handlePayload(payload, res);
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
#handlePayload(payload, res) {
|
|
691
|
+
const toolCall = payload.toolCall || {};
|
|
692
|
+
const toolName = toolCall.name;
|
|
693
|
+
const conversationId = payload.conversationId;
|
|
694
|
+
|
|
695
|
+
if (toolName === 'ask_question') {
|
|
696
|
+
const questions = toolCall.args?.questions || [];
|
|
697
|
+
const q = questions[0] || { question: 'Antigravity 提问' };
|
|
698
|
+
const requestId = `antigravity-q-${randomUUID()}`;
|
|
699
|
+
this.pending.set(requestId, { type: 'question', questions, response: res });
|
|
700
|
+
this.emit({
|
|
701
|
+
kind: 'approval',
|
|
702
|
+
requestId,
|
|
703
|
+
method: q.options?.length ? undefined : 'input',
|
|
704
|
+
title: 'Antigravity 提问',
|
|
705
|
+
message: q.question,
|
|
706
|
+
options: (q.options || []).map((opt) => ({ id: opt, label: opt })),
|
|
707
|
+
placeholder: '请输入或选择…',
|
|
708
|
+
nativeRef: { sessionId: conversationId },
|
|
709
|
+
});
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (this.approvals && toolName) {
|
|
714
|
+
const requestId = `antigravity-app-${randomUUID()}`;
|
|
715
|
+
this.pending.set(requestId, { type: 'approval', toolCall, response: res });
|
|
716
|
+
this.emit({
|
|
717
|
+
kind: 'approval',
|
|
718
|
+
requestId,
|
|
719
|
+
title: `Antigravity: ${toolName}`,
|
|
720
|
+
message: `请求执行工具 ${toolName}\n${JSON.stringify(toolCall.args || {}, null, 2)}`,
|
|
721
|
+
options: [
|
|
722
|
+
{ id: 'allow', label: '允许' },
|
|
723
|
+
{ id: 'deny', label: '拒绝', kind: 'reject' },
|
|
724
|
+
],
|
|
725
|
+
nativeRef: { sessionId: conversationId },
|
|
726
|
+
});
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
731
|
+
res.end(JSON.stringify({ decision: 'allow' }));
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
respond(requestId, response) {
|
|
735
|
+
const pending = this.pending.get(requestId);
|
|
736
|
+
if (!pending) return false;
|
|
737
|
+
this.pending.delete(requestId);
|
|
738
|
+
|
|
739
|
+
if (pending.type === 'question') {
|
|
740
|
+
const answer = response?.cancelled ? '' : String(response?.optionId ?? response?.value ?? '');
|
|
741
|
+
const result = response?.cancelled
|
|
742
|
+
? { status: 'cancelled', answers: {} }
|
|
743
|
+
: {
|
|
744
|
+
status: 'answered',
|
|
745
|
+
answers: (pending.questions || []).map((q) => ({
|
|
746
|
+
question: q.question,
|
|
747
|
+
answers: answer ? [answer] : [],
|
|
748
|
+
})),
|
|
749
|
+
};
|
|
750
|
+
const reason =
|
|
751
|
+
'codexhost handled this question through the Desktop. Native ask_question is blocked only to prevent automatic skipping. ' +
|
|
752
|
+
'The following JSON contains the actual user response, not a tool permission decision: ' +
|
|
753
|
+
JSON.stringify(result);
|
|
754
|
+
if (!pending.response.writableEnded) {
|
|
755
|
+
pending.response.writeHead(200, { 'content-type': 'application/json' });
|
|
756
|
+
pending.response.end(JSON.stringify({ decision: 'deny', reason }));
|
|
757
|
+
}
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (pending.type === 'approval') {
|
|
762
|
+
const allowed = !response?.cancelled && (response?.optionId === 'allow' || response?.confirmed !== false);
|
|
763
|
+
const decision = allowed ? 'allow' : 'deny';
|
|
764
|
+
const reason = allowed ? 'User approved this tool call once.' : 'User denied this tool call.';
|
|
765
|
+
if (!pending.response.writableEnded) {
|
|
766
|
+
pending.response.writeHead(200, { 'content-type': 'application/json' });
|
|
767
|
+
pending.response.end(JSON.stringify({ decision, reason }));
|
|
768
|
+
}
|
|
769
|
+
return true;
|
|
770
|
+
}
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
async dispose() {
|
|
775
|
+
for (const pending of this.pending.values()) {
|
|
776
|
+
if (!pending.response.writableEnded) {
|
|
777
|
+
pending.response.writeHead(200, { 'content-type': 'application/json' });
|
|
778
|
+
pending.response.end(JSON.stringify({ decision: 'deny', reason: 'Session closed' }));
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
this.pending.clear();
|
|
782
|
+
if (this.server) {
|
|
783
|
+
await new Promise((resolve) => this.server.close(resolve)).catch(() => {});
|
|
784
|
+
this.server = null;
|
|
785
|
+
}
|
|
786
|
+
if (this.directory) {
|
|
787
|
+
await fs.promises.rm(this.directory, { recursive: true, force: true }).catch(() => {});
|
|
788
|
+
this.directory = '';
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function create(emit, options = {}) {
|
|
794
|
+
let cachedQuota = null;
|
|
795
|
+
let quotaPromise = null;
|
|
796
|
+
const spawnProcess = options.spawnProcess || spawn;
|
|
797
|
+
const resultDrainMs = positiveDuration(
|
|
798
|
+
options.resultDrainMs ?? process.env.HARNESS_MIX_ANTIGRAVITY_RESULT_DRAIN_MS,
|
|
799
|
+
ANTIGRAVITY_RESULT_DRAIN_MS,
|
|
800
|
+
);
|
|
801
|
+
const resultDrainMaxMs = Math.max(
|
|
802
|
+
resultDrainMs,
|
|
803
|
+
positiveDuration(
|
|
804
|
+
options.resultDrainMaxMs ?? process.env.HARNESS_MIX_ANTIGRAVITY_RESULT_DRAIN_MAX_MS,
|
|
805
|
+
ANTIGRAVITY_RESULT_DRAIN_MAX_MS,
|
|
806
|
+
),
|
|
807
|
+
);
|
|
808
|
+
|
|
809
|
+
return {
|
|
810
|
+
manifest,
|
|
811
|
+
|
|
812
|
+
async inspect() {
|
|
813
|
+
const bin = resolveExecutable();
|
|
814
|
+
return new Promise((resolve) => {
|
|
815
|
+
execFile(bin, ['--version'], { windowsHide: true, timeout: 10000 }, (error, stdout) => {
|
|
816
|
+
if (error) {
|
|
817
|
+
resolve({ available: false, detail: '未找到 Antigravity CLI(agy)' });
|
|
818
|
+
} else {
|
|
819
|
+
if (!cachedQuota) fetchAntigravityQuota().then((q) => { if (q) cachedQuota = q; }).catch(() => {});
|
|
820
|
+
resolve({ available: true, detail: `agy ${String(stdout).trim()}` });
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
},
|
|
825
|
+
|
|
826
|
+
async open({ thread, emit: emitEvent, diagnostic, collaboration }) {
|
|
827
|
+
// Do not start a second agy process while a real turn may be starting.
|
|
828
|
+
// Quota is loaded only by the explicit account/usage refresh path below.
|
|
829
|
+
await restoreLegacyClipboardAttachments(thread);
|
|
830
|
+
const model = thread.options?.model ?? { id: 'gemini-3.8-flash', name: 'Gemini 3.8 Flash', provider: 'google' };
|
|
831
|
+
const thinkingLevel = thread.options?.thinking ?? 'high';
|
|
832
|
+
const permissionMode = thread.options?.permissionMode ?? 'default';
|
|
833
|
+
const session = {
|
|
834
|
+
nativeSessionId: thread.nativeSessionId || null,
|
|
835
|
+
cwd: thread.cwd,
|
|
836
|
+
model,
|
|
837
|
+
thinkingLevel,
|
|
838
|
+
permissionMode,
|
|
839
|
+
collaboration: collaboration || null,
|
|
840
|
+
collaborationEnabled: !!collaboration,
|
|
841
|
+
activeTurn: null,
|
|
842
|
+
bridge: null,
|
|
843
|
+
usage: undefined,
|
|
844
|
+
pendingApprovals: new Map(),
|
|
845
|
+
};
|
|
846
|
+
if (thread.restore && thread.nativeSessionId) {
|
|
847
|
+
emitEvent({ kind: 'session', nativeSessionId: thread.nativeSessionId, model });
|
|
848
|
+
}
|
|
849
|
+
return session;
|
|
850
|
+
},
|
|
851
|
+
|
|
852
|
+
async send(session, prompt, hooks, attachments) {
|
|
853
|
+
if (session.activeTurn) throw new Error('Antigravity 当前回合尚未结束');
|
|
854
|
+
|
|
855
|
+
const emitEvent = hooks?.emit || emit;
|
|
856
|
+
const bin = resolveExecutable();
|
|
857
|
+
const approvals = session.permissionMode === 'desktop' || session.permissionMode === 'desktop-approvals';
|
|
858
|
+
const bridge = await QuestionBridge.create({
|
|
859
|
+
approvals,
|
|
860
|
+
emit: emitEvent,
|
|
861
|
+
collaboration: session.collaboration,
|
|
862
|
+
});
|
|
863
|
+
session.bridge = bridge;
|
|
864
|
+
|
|
865
|
+
let effectivePrompt = prompt ?? '';
|
|
866
|
+
if (session.collaborationEnabled) {
|
|
867
|
+
effectivePrompt = `[多 Agent 协作系统已就绪。你作为主协调者,可调用已注入的 MCP 工具:delegate_to_agent(agent_type, task) 向其他已注册的 Harness(如 @pi、@claude-code、@codex、@deepseek-harness 等)委派子任务,使用 get_delegation_status(task_ids) 等待结果,使用 update_agent_plan(steps) 设定与更新分步计划。]\n\n${effectivePrompt}`;
|
|
868
|
+
}
|
|
869
|
+
const { imageEntries, extraDirs } = await prepareImageAttachments(attachments?.images, session.cwd);
|
|
870
|
+
if (imageEntries.length) {
|
|
871
|
+
const imageNotice = [
|
|
872
|
+
'[用户上传了图片附件]',
|
|
873
|
+
'[仅使用本轮列出的持久化副本路径;不要复用历史消息中的 codex-clipboard 临时路径。]',
|
|
874
|
+
...imageEntries.map(e => `- [${e.name}](file:///${e.path}): 请使用 view_file 工具查看并分析该图片。`),
|
|
875
|
+
].join('\n');
|
|
876
|
+
effectivePrompt = effectivePrompt.trim()
|
|
877
|
+
? `${imageNotice}\n\n${effectivePrompt}`
|
|
878
|
+
: `${imageNotice}\n\n请查看并分析上述图片附件。`;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
const logPath = path.join(os.tmpdir(), `harness-mix-antigravity-${randomUUID()}.log`);
|
|
882
|
+
const args = [
|
|
883
|
+
'--input-format', 'stream-json',
|
|
884
|
+
'--output-format', 'stream-json',
|
|
885
|
+
'--print-timeout', '30m',
|
|
886
|
+
];
|
|
887
|
+
if (session.nativeSessionId) {
|
|
888
|
+
args.push('--conversation', session.nativeSessionId);
|
|
889
|
+
}
|
|
890
|
+
if (session.model?.id) {
|
|
891
|
+
args.push('--model', session.model.id);
|
|
892
|
+
}
|
|
893
|
+
if (session.thinkingLevel && modelSupportsEffort(session.model)) {
|
|
894
|
+
args.push('--effort', session.thinkingLevel);
|
|
895
|
+
}
|
|
896
|
+
if (['skip', 'desktop', 'dangerously-skip-permissions', 'desktop-approvals'].includes(session.permissionMode)) {
|
|
897
|
+
args.push('--dangerously-skip-permissions');
|
|
898
|
+
}
|
|
899
|
+
args.push('--add-dir', session.cwd);
|
|
900
|
+
args.push('--add-dir', bridge.directory);
|
|
901
|
+
for (const dir of extraDirs) {
|
|
902
|
+
args.push('--add-dir', dir);
|
|
903
|
+
}
|
|
904
|
+
args.push('--log-file', logPath);
|
|
905
|
+
|
|
906
|
+
const child = spawnProcess(bin, args, {
|
|
907
|
+
cwd: session.cwd,
|
|
908
|
+
env: { ...process.env, ...bridge.environment },
|
|
909
|
+
windowsHide: true,
|
|
910
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
let turnResolve, turnReject;
|
|
914
|
+
const settled = new Promise((resolve, reject) => {
|
|
915
|
+
turnResolve = resolve;
|
|
916
|
+
turnReject = reject;
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
const turn = {
|
|
920
|
+
child,
|
|
921
|
+
resolve: turnResolve,
|
|
922
|
+
reject: turnReject,
|
|
923
|
+
logPath,
|
|
924
|
+
resultSeen: false,
|
|
925
|
+
result: null,
|
|
926
|
+
completed: false,
|
|
927
|
+
processClosing: false,
|
|
928
|
+
processClosed: false,
|
|
929
|
+
killTimer: null,
|
|
930
|
+
resultDrainTimer: null,
|
|
931
|
+
resultDrainMaxTimer: null,
|
|
932
|
+
pendingSteps: new Map(),
|
|
933
|
+
};
|
|
934
|
+
session.activeTurn = turn;
|
|
935
|
+
let sawTextSinceLastTool = false;
|
|
936
|
+
let stderrTail = '';
|
|
937
|
+
child.stderr?.setEncoding('utf8')?.on('data', (chunk) => {
|
|
938
|
+
stderrTail = (stderrTail + chunk).slice(-8000);
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
// agy 在 stream-json 模式下产出 result 后进程仍常驻(实测 25s+ 不自行退出),
|
|
942
|
+
// 不主动收尾会让 session.activeTurn 永远悬挂,下一回合 send 被“当前回合尚未结束”拒绝。
|
|
943
|
+
// 但某些工具(尤其 view_file 图片)会先产生没有 output 字段的 DONE,随后才
|
|
944
|
+
// 刷出最终 assistant_response。先结算 Turn 再结束 stdin 会把这段迟到文本丢给
|
|
945
|
+
// 已关闭的 Normalizer,所以空结果时必须先做一个有界 drain。
|
|
946
|
+
const clearResultDrainTimers = () => {
|
|
947
|
+
if (turn.resultDrainTimer) clearTimeout(turn.resultDrainTimer);
|
|
948
|
+
if (turn.resultDrainMaxTimer) clearTimeout(turn.resultDrainMaxTimer);
|
|
949
|
+
turn.resultDrainTimer = null;
|
|
950
|
+
turn.resultDrainMaxTimer = null;
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
const closeProcess = () => {
|
|
954
|
+
if (turn.processClosing || turn.processClosed) return;
|
|
955
|
+
turn.processClosing = true;
|
|
956
|
+
try { child.stdin.end(); } catch {}
|
|
957
|
+
turn.killTimer = setTimeout(() => { void terminateTree(child.pid); }, 10000);
|
|
958
|
+
turn.killTimer.unref?.();
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
const settleResult = () => {
|
|
962
|
+
if (turn.completed || !turn.result) return;
|
|
963
|
+
turn.completed = true;
|
|
964
|
+
clearResultDrainTimers();
|
|
965
|
+
if (session.activeTurn === turn) session.activeTurn = null;
|
|
966
|
+
const { res, nativeRef } = turn.result;
|
|
967
|
+
const completedRef = {
|
|
968
|
+
...nativeRef,
|
|
969
|
+
turnId: res.num_turns != null ? `turn:${res.num_turns}` : undefined,
|
|
970
|
+
checkpointId: res.num_turns != null ? String(res.num_turns) : undefined,
|
|
971
|
+
};
|
|
972
|
+
const successful = resultSucceeded(res);
|
|
973
|
+
const hasAssistantText = (typeof res.response === 'string'
|
|
974
|
+
? Boolean(res.response.trim())
|
|
975
|
+
: Boolean(res.response)) || sawTextSinceLastTool;
|
|
976
|
+
if (!successful) {
|
|
977
|
+
const message = formatAntigravityResultError(res);
|
|
978
|
+
emitEvent({ kind: 'error', message, nativeRef: completedRef });
|
|
979
|
+
turnReject?.(new Error(message));
|
|
980
|
+
closeProcess();
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
if (!hasAssistantText) {
|
|
984
|
+
const message = 'Antigravity 回合返回 SUCCESS,但没有 assistant 文本';
|
|
985
|
+
emitEvent({ kind: 'error', message, nativeRef: completedRef });
|
|
986
|
+
turnReject?.(new Error(message));
|
|
987
|
+
closeProcess();
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
emitEvent({
|
|
991
|
+
kind: 'completed',
|
|
992
|
+
finalAnswer: true,
|
|
993
|
+
stopReason: 'completed',
|
|
994
|
+
nativeRef: completedRef,
|
|
995
|
+
});
|
|
996
|
+
turnResolve?.();
|
|
997
|
+
closeProcess();
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
const scheduleResultDrain = () => {
|
|
1001
|
+
if (!turn.resultSeen || turn.completed || !turn.result) return;
|
|
1002
|
+
if (!resultSucceeded(turn.result.res)) {
|
|
1003
|
+
settleResult();
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
const hasAssistantText = (typeof turn.result.res.response === 'string'
|
|
1007
|
+
? Boolean(turn.result.res.response.trim())
|
|
1008
|
+
: Boolean(turn.result.res.response)) || sawTextSinceLastTool;
|
|
1009
|
+
if (hasAssistantText) {
|
|
1010
|
+
if (turn.resultDrainMaxTimer) clearTimeout(turn.resultDrainMaxTimer);
|
|
1011
|
+
turn.resultDrainMaxTimer = null;
|
|
1012
|
+
if (turn.resultDrainTimer) clearTimeout(turn.resultDrainTimer);
|
|
1013
|
+
turn.resultDrainTimer = setTimeout(settleResult, resultDrainMs);
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
// No text at result time is not proof that the native turn is finished.
|
|
1017
|
+
// Keep the Core turn active until a late assistant response arrives, but
|
|
1018
|
+
// always retain a hard ceiling for a genuinely tool-only/empty turn.
|
|
1019
|
+
if (!turn.resultDrainMaxTimer) {
|
|
1020
|
+
turn.resultDrainMaxTimer = setTimeout(settleResult, resultDrainMaxMs);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
const rl = readline.createInterface({ input: child.stdout });
|
|
1025
|
+
rl.on('line', (line) => {
|
|
1026
|
+
let event;
|
|
1027
|
+
try { event = JSON.parse(line.trim()); } catch { return; }
|
|
1028
|
+
recordNative(manifest.id, event);
|
|
1029
|
+
|
|
1030
|
+
const nativeRef = {
|
|
1031
|
+
sessionId: session.nativeSessionId || event.conversation_id || event.result?.conversation_id,
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
if (event.event === 'init') {
|
|
1035
|
+
session.nativeSessionId = event.conversation_id;
|
|
1036
|
+
emitEvent({ kind: 'session', nativeSessionId: event.conversation_id, model: session.model });
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
if (event.event === 'step_update') {
|
|
1041
|
+
const rawStep = event.step_update || {};
|
|
1042
|
+
const prevStep = turn.pendingSteps.get(rawStep.step_index);
|
|
1043
|
+
const s = mergePendingStep(prevStep, rawStep);
|
|
1044
|
+
if (s.step_index != null) turn.pendingSteps.set(s.step_index, s);
|
|
1045
|
+
const stepRef = { ...nativeRef, itemId: String(s.step_index) };
|
|
1046
|
+
|
|
1047
|
+
if (s.step_type === 'agent_response') {
|
|
1048
|
+
const text = s.text_delta || s.text || s.content || s.message;
|
|
1049
|
+
if (typeof text === 'string' && text) {
|
|
1050
|
+
sawTextSinceLastTool = true;
|
|
1051
|
+
emitEvent({ kind: 'text-delta', text, nativeRef: stepRef });
|
|
1052
|
+
scheduleResultDrain();
|
|
1053
|
+
}
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
if (s.step_type === 'thought' || s.step_type === 'thinking') {
|
|
1058
|
+
const thinkingText = s.text_delta || s.text || s.content;
|
|
1059
|
+
if (thinkingText) {
|
|
1060
|
+
emitEvent({ kind: 'thinking-delta', text: thinkingText, nativeRef: stepRef });
|
|
1061
|
+
}
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
if (s.step_type === 'subagent') {
|
|
1066
|
+
sawTextSinceLastTool = false;
|
|
1067
|
+
const info = s.subagent_info || {};
|
|
1068
|
+
const subagents = Array.isArray(info.subagents) ? info.subagents : [];
|
|
1069
|
+
const state = s.state === 'DONE' ? 'done' : (s.state === 'ERROR' ? 'error' : 'running');
|
|
1070
|
+
const details = subagents.map((sub) => `[${sub.role || sub.type_name || 'Subagent'}] ID: ${sub.conversation_id || ''}\n${sub.initial_prompt || ''}`.trim()).join('\n\n');
|
|
1071
|
+
emitEvent({
|
|
1072
|
+
kind: 'tool',
|
|
1073
|
+
toolCallId: String(s.step_index),
|
|
1074
|
+
title: '子 Agent',
|
|
1075
|
+
state,
|
|
1076
|
+
input: details || undefined,
|
|
1077
|
+
output: s.state === 'DONE' ? '子 Agent 启动完成' : undefined,
|
|
1078
|
+
nativeRef: stepRef,
|
|
1079
|
+
});
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if (s.step_type === 'tool') {
|
|
1084
|
+
sawTextSinceLastTool = false;
|
|
1085
|
+
const toolName = s.tool_name || s.tool_info?.name;
|
|
1086
|
+
const state = s.state === 'DONE' ? 'done' : (s.state === 'ERROR' ? 'error' : 'running');
|
|
1087
|
+
emitEvent({
|
|
1088
|
+
kind: 'tool',
|
|
1089
|
+
toolCallId: String(s.step_index),
|
|
1090
|
+
title: toolTitle(toolName),
|
|
1091
|
+
state,
|
|
1092
|
+
input: toolInput(s),
|
|
1093
|
+
output: toolOutput(s),
|
|
1094
|
+
nativeRef: stepRef,
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
// Native file mutations
|
|
1098
|
+
if (s.state === 'DONE' && (toolName === 'write_to_file' || toolName === 'replace_file_content')) {
|
|
1099
|
+
const params = s.tool_info?.parameters || {};
|
|
1100
|
+
// agy stream-json 工具事件只携带 TargetFile,不携带文件内容(实测 ACTIVE/DONE 均如此)。
|
|
1101
|
+
// 保持 complete: false(与 codex.js 同一约定):仅作实时提示,回合结算时由
|
|
1102
|
+
// 工作区快照(ReviewStore)用权威 before/after 覆盖,UI 才能显示真实增删统计。
|
|
1103
|
+
const target = typeof params.TargetFile === 'string' ? params.TargetFile : null;
|
|
1104
|
+
const relative = target ? path.relative(session.cwd, path.resolve(session.cwd, target)).replace(/\\/g, '/') : '';
|
|
1105
|
+
// 只投影工作区内的变更;脑目录等 --add-dir 目录不属于本轮文件审查
|
|
1106
|
+
if (relative && relative !== '..' && !relative.startsWith('../') && !path.isAbsolute(relative)) {
|
|
1107
|
+
emitEvent({
|
|
1108
|
+
kind: 'file-change',
|
|
1109
|
+
source: 'native',
|
|
1110
|
+
changes: [{
|
|
1111
|
+
path: target,
|
|
1112
|
+
changeType: toolName === 'write_to_file' ? (params.Overwrite ? 'modified' : 'added') : 'modified',
|
|
1113
|
+
complete: false,
|
|
1114
|
+
nativeRef: stepRef,
|
|
1115
|
+
}],
|
|
1116
|
+
nativeRef: stepRef,
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (s.usage) {
|
|
1123
|
+
const u = parseUsage(s.usage, session.model?.id, cachedQuota);
|
|
1124
|
+
if (u) {
|
|
1125
|
+
session.usage = u;
|
|
1126
|
+
emitEvent({ kind: 'usage', usage: u, nativeRef: stepRef });
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (event.event === 'result') {
|
|
1133
|
+
if (turn.resultSeen || turn.completed) return;
|
|
1134
|
+
const res = event.result || {};
|
|
1135
|
+
if (res.conversation_id && !session.nativeSessionId) {
|
|
1136
|
+
session.nativeSessionId = res.conversation_id;
|
|
1137
|
+
}
|
|
1138
|
+
if (res.usage) {
|
|
1139
|
+
const u = parseUsage(res.usage, session.model?.id, cachedQuota);
|
|
1140
|
+
if (u) {
|
|
1141
|
+
session.usage = u;
|
|
1142
|
+
emitEvent({ kind: 'usage', usage: u, nativeRef });
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (res.response && !sawTextSinceLastTool) {
|
|
1146
|
+
if (typeof res.response === 'string') {
|
|
1147
|
+
sawTextSinceLastTool = true;
|
|
1148
|
+
emitEvent({ kind: 'text-delta', text: res.response, nativeRef });
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
turn.resultSeen = true;
|
|
1152
|
+
turn.result = { res, nativeRef };
|
|
1153
|
+
scheduleResultDrain();
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
child.on('error', (err) => {
|
|
1158
|
+
if (turn.resultSeen) {
|
|
1159
|
+
settleResult();
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
if (turn.killTimer) clearTimeout(turn.killTimer);
|
|
1163
|
+
clearResultDrainTimers();
|
|
1164
|
+
turn.completed = true;
|
|
1165
|
+
if (session.activeTurn === turn) session.activeTurn = null;
|
|
1166
|
+
void fs.promises.unlink(logPath).catch(() => {});
|
|
1167
|
+
void bridge.dispose();
|
|
1168
|
+
if (session.bridge === bridge) session.bridge = null;
|
|
1169
|
+
emitEvent({ kind: 'error', message: `Antigravity 进程错误: ${err.message}` });
|
|
1170
|
+
turnReject?.(err);
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
child.on('close', (code) => {
|
|
1174
|
+
turn.processClosed = true;
|
|
1175
|
+
if (turn.killTimer) clearTimeout(turn.killTimer);
|
|
1176
|
+
clearResultDrainTimers();
|
|
1177
|
+
void fs.promises.unlink(logPath).catch(() => {});
|
|
1178
|
+
void bridge.dispose();
|
|
1179
|
+
if (session.bridge === bridge) session.bridge = null;
|
|
1180
|
+
if (turn.resultSeen) {
|
|
1181
|
+
// A real process close means stdout can no longer deliver a late
|
|
1182
|
+
// assistant event; settle the already received result now.
|
|
1183
|
+
settleResult();
|
|
1184
|
+
} else if (!turn.completed) {
|
|
1185
|
+
turn.completed = true;
|
|
1186
|
+
if (session.activeTurn === turn) session.activeTurn = null;
|
|
1187
|
+
const cleanErr = stderrTail.trim();
|
|
1188
|
+
const message = cleanErr
|
|
1189
|
+
? `Antigravity CLI 未返回 result(退出码 ${code ?? 'unknown'}):${cleanErr}`
|
|
1190
|
+
: `Antigravity CLI 未返回 result(退出码 ${code ?? 'unknown'})`;
|
|
1191
|
+
// 进程未产出 result 即退出(崩溃、认证失败或协议中断):明确失败,
|
|
1192
|
+
// 不能把 code 0 的空 stdout 伪装成成功回合。
|
|
1193
|
+
emitEvent({ kind: 'error', message });
|
|
1194
|
+
turnReject?.(new Error(message));
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
try {
|
|
1199
|
+
const fullPrompt = formatPrompt(effectivePrompt);
|
|
1200
|
+
if (child.stdin.writable) {
|
|
1201
|
+
child.stdin.write(JSON.stringify({ event: 'user', message: { content: fullPrompt } }) + '\n');
|
|
1202
|
+
}
|
|
1203
|
+
} catch (err) {
|
|
1204
|
+
const message = `Antigravity 输入失败:${err.message}`;
|
|
1205
|
+
turn.completed = true;
|
|
1206
|
+
if (session.activeTurn === turn) session.activeTurn = null;
|
|
1207
|
+
void bridge.dispose();
|
|
1208
|
+
if (session.bridge === bridge) session.bridge = null;
|
|
1209
|
+
void terminateTree(child.pid);
|
|
1210
|
+
emitEvent({ kind: 'error', message });
|
|
1211
|
+
turnReject?.(new Error(message));
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
return settled;
|
|
1215
|
+
},
|
|
1216
|
+
|
|
1217
|
+
async cancel(session) {
|
|
1218
|
+
if (session.activeTurn?.child) {
|
|
1219
|
+
void terminateTree(session.activeTurn.child.pid);
|
|
1220
|
+
}
|
|
1221
|
+
if (session.bridge) {
|
|
1222
|
+
await session.bridge.dispose().catch(() => {});
|
|
1223
|
+
session.bridge = null;
|
|
1224
|
+
}
|
|
1225
|
+
session.activeTurn?.resolve?.();
|
|
1226
|
+
session.activeTurn = null;
|
|
1227
|
+
},
|
|
1228
|
+
|
|
1229
|
+
async respond(session, requestId, response) {
|
|
1230
|
+
if (session.bridge) {
|
|
1231
|
+
session.bridge.respond(requestId, response);
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
|
|
1235
|
+
async listModels() {
|
|
1236
|
+
return null;
|
|
1237
|
+
},
|
|
1238
|
+
|
|
1239
|
+
async listModelsFor(_session) {
|
|
1240
|
+
const bin = resolveExecutable();
|
|
1241
|
+
return new Promise((resolve) => {
|
|
1242
|
+
execFile(bin, ['models'], { windowsHide: true, timeout: 20000 }, (error, stdout) => {
|
|
1243
|
+
if (error) return resolve([]);
|
|
1244
|
+
resolve(parseModelsOutput(stdout));
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
},
|
|
1248
|
+
|
|
1249
|
+
async setModel(session, model) {
|
|
1250
|
+
session.model = { id: model.id, name: model.name || model.id, provider: model.provider || 'google' };
|
|
1251
|
+
return session.model;
|
|
1252
|
+
},
|
|
1253
|
+
|
|
1254
|
+
async setThinkingLevel(session, level) {
|
|
1255
|
+
session.thinkingLevel = level;
|
|
1256
|
+
},
|
|
1257
|
+
|
|
1258
|
+
async setPermissionMode(session, mode) {
|
|
1259
|
+
session.permissionMode = mode;
|
|
1260
|
+
},
|
|
1261
|
+
|
|
1262
|
+
async getContextUsage(session) {
|
|
1263
|
+
return session.usage;
|
|
1264
|
+
},
|
|
1265
|
+
|
|
1266
|
+
async describe() {
|
|
1267
|
+
const bin = resolveExecutable();
|
|
1268
|
+
const stdout = await new Promise((resolve) => {
|
|
1269
|
+
execFile(bin, ['models'], { windowsHide: true, timeout: 20000 }, (error, out) => {
|
|
1270
|
+
if (error) return resolve('');
|
|
1271
|
+
resolve(out);
|
|
1272
|
+
});
|
|
1273
|
+
});
|
|
1274
|
+
const models = parseModelsOutput(stdout);
|
|
1275
|
+
return {
|
|
1276
|
+
models,
|
|
1277
|
+
thinkingLevels: [
|
|
1278
|
+
// default: true 是 adapter 的显式声明:该 Harness 的思考档位可在 UI 选择,
|
|
1279
|
+
// 且默认档与 open() 的回退值('high')一致——协议层据此下发可选集合。
|
|
1280
|
+
{ id: 'high', label: 'High', default: true },
|
|
1281
|
+
{ id: 'medium', label: 'Medium' },
|
|
1282
|
+
{ id: 'low', label: 'Low' },
|
|
1283
|
+
],
|
|
1284
|
+
permissionModes: ANTIGRAVITY_PERMISSION_MODES,
|
|
1285
|
+
};
|
|
1286
|
+
},
|
|
1287
|
+
|
|
1288
|
+
async describeFor(session) {
|
|
1289
|
+
const { models, thinkingLevels } = await this.describe();
|
|
1290
|
+
return {
|
|
1291
|
+
models,
|
|
1292
|
+
thinkingLevels,
|
|
1293
|
+
permissionModes: ANTIGRAVITY_PERMISSION_MODES,
|
|
1294
|
+
};
|
|
1295
|
+
},
|
|
1296
|
+
|
|
1297
|
+
async fork(source, { emit: emitEvent, diagnostic, message }) {
|
|
1298
|
+
const derivedId = randomUUID();
|
|
1299
|
+
const sourceId = source.nativeSessionId;
|
|
1300
|
+
const checkpointId = message?.coreTurn?.nativeTurnRef?.checkpointId;
|
|
1301
|
+
const retainedTurnsCount = checkpointId != null && !Number.isNaN(Number(checkpointId)) ? Number(checkpointId) : undefined;
|
|
1302
|
+
if (sourceId) {
|
|
1303
|
+
await cloneDatabase(sourceId, derivedId, retainedTurnsCount);
|
|
1304
|
+
await cloneBrain(sourceId, derivedId);
|
|
1305
|
+
}
|
|
1306
|
+
const model = source.model || { id: 'gemini-3.8-flash', name: 'Gemini 3.8 Flash', provider: 'google' };
|
|
1307
|
+
const session = {
|
|
1308
|
+
nativeSessionId: derivedId,
|
|
1309
|
+
cwd: source.cwd,
|
|
1310
|
+
model,
|
|
1311
|
+
thinkingLevel: source.options?.thinking || 'high',
|
|
1312
|
+
permissionMode: source.options?.permissionMode || 'default',
|
|
1313
|
+
activeTurn: null,
|
|
1314
|
+
bridge: null,
|
|
1315
|
+
usage: undefined,
|
|
1316
|
+
pendingApprovals: new Map(),
|
|
1317
|
+
};
|
|
1318
|
+
emitEvent({ kind: 'session', nativeSessionId: derivedId, model });
|
|
1319
|
+
return { session, nativeSessionId: derivedId };
|
|
1320
|
+
},
|
|
1321
|
+
|
|
1322
|
+
credits() {
|
|
1323
|
+
return cachedQuota;
|
|
1324
|
+
},
|
|
1325
|
+
|
|
1326
|
+
async refreshCredits() {
|
|
1327
|
+
if (!quotaPromise) quotaPromise = fetchAntigravityQuota();
|
|
1328
|
+
const request = quotaPromise;
|
|
1329
|
+
const quota = await request.finally(() => {
|
|
1330
|
+
if (quotaPromise === request) quotaPromise = null;
|
|
1331
|
+
});
|
|
1332
|
+
if (quota) cachedQuota = quota;
|
|
1333
|
+
return cachedQuota;
|
|
1334
|
+
},
|
|
1335
|
+
|
|
1336
|
+
async inspectAccount() {
|
|
1337
|
+
const quota = await this.refreshCredits();
|
|
1338
|
+
if (!quota) return null;
|
|
1339
|
+
return {
|
|
1340
|
+
label: 'Antigravity',
|
|
1341
|
+
plan: 'Google Gemini',
|
|
1342
|
+
credits: quota,
|
|
1343
|
+
};
|
|
1344
|
+
},
|
|
1345
|
+
|
|
1346
|
+
async close(session) {
|
|
1347
|
+
await this.cancel(session);
|
|
1348
|
+
},
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
module.exports = {
|
|
1353
|
+
manifest,
|
|
1354
|
+
create,
|
|
1355
|
+
parseModelsOutput,
|
|
1356
|
+
parseUsage,
|
|
1357
|
+
formatAntigravityResultError,
|
|
1358
|
+
modelSupportsEffort,
|
|
1359
|
+
formatPrompt,
|
|
1360
|
+
prepareImageAttachments,
|
|
1361
|
+
mergePendingStep,
|
|
1362
|
+
cloneDatabase,
|
|
1363
|
+
fetchAntigravityQuota,
|
|
1364
|
+
parseAntigravityUsageCommand,
|
|
1365
|
+
ANTIGRAVITY_PERMISSION_MODES,
|
|
1366
|
+
ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION,
|
|
1367
|
+
};
|
|
1368
|
+
|