@adhdev/daemon-core 0.9.82-rc.43 → 0.9.82-rc.430
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/dist/boot/daemon-lifecycle.d.ts +9 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +68 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +200 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +126 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +69 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
- package/dist/commands/chat-commands-read.d.ts +7 -0
- package/dist/commands/chat-commands-scope.d.ts +39 -0
- package/dist/commands/chat-commands-shared.d.ts +33 -0
- package/dist/commands/chat-commands-write.d.ts +14 -0
- package/dist/commands/chat-commands.d.ts +10 -23
- package/dist/commands/cli-manager.d.ts +15 -1
- package/dist/commands/handler.d.ts +125 -0
- package/dist/commands/high-family/index.d.ts +3 -0
- package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
- package/dist/commands/high-family/mesh-events.d.ts +2 -0
- package/dist/commands/high-family/mesh-status.d.ts +2 -0
- package/dist/commands/high-family/types.d.ts +60 -0
- package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
- package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
- package/dist/commands/low-family/diagnostics.d.ts +2 -0
- package/dist/commands/low-family/index.d.ts +3 -0
- package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
- package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
- package/dist/commands/low-family/notification.d.ts +2 -0
- package/dist/commands/low-family/refine-config.d.ts +2 -0
- package/dist/commands/low-family/session-host.d.ts +2 -0
- package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
- package/dist/commands/low-family/status-meta.d.ts +2 -0
- package/dist/commands/low-family/types.d.ts +33 -0
- package/dist/commands/med-family/cli-agent.d.ts +2 -0
- package/dist/commands/med-family/fast-forward.d.ts +2 -0
- package/dist/commands/med-family/ide.d.ts +10 -0
- package/dist/commands/med-family/index.d.ts +3 -0
- package/dist/commands/med-family/mesh-crud.d.ts +29 -0
- package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
- package/dist/commands/med-family/mesh-queue.d.ts +2 -0
- package/dist/commands/med-family/mesh-restart.d.ts +2 -0
- package/dist/commands/med-family/types.d.ts +142 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +276 -2
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +100 -1
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/repo-settings.d.ts +77 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +11 -1
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +57 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/git-worktree.d.ts +71 -1
- package/dist/git/index.d.ts +3 -1
- package/dist/index.d.ts +64 -14
- package/dist/index.js +49391 -19228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48574 -18570
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/logging/log-redactor.d.ts +24 -0
- package/dist/logging/log-tail-reader.d.ts +81 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +89 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +174 -0
- package/dist/mesh/mesh-clone-grace.d.ts +8 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-event-classify.d.ts +5 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +41 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
- package/dist/mesh/mesh-events-pending.d.ts +69 -0
- package/dist/mesh/mesh-events-stale.d.ts +61 -0
- package/dist/mesh/mesh-events-utils.d.ts +75 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-init.d.ts +86 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +189 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +113 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +65 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +450 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-inflight.d.ts +46 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +290 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +216 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +145 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +20 -0
- package/dist/providers/chat-message-normalization.d.ts +31 -1
- package/dist/providers/cli-provider-instance.d.ts +221 -3
- package/dist/providers/contracts.d.ts +139 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +63 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/constants.d.ts +12 -0
- package/dist/providers/native-history/dispatcher.d.ts +27 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +29 -0
- package/dist/providers/provider-instance.d.ts +23 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +91 -0
- package/dist/providers/spec/cli-adapter.d.ts +223 -0
- package/dist/providers/spec/evaluator.d.ts +45 -0
- package/dist/providers/spec/fsm-driver.d.ts +422 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +174 -0
- package/dist/providers/spec/native-history-executor.d.ts +41 -0
- package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/types.d.ts +222 -0
- package/dist/providers/status-monitor.d.ts +7 -7
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/providers/working-dir.d.ts +17 -0
- package/dist/repo-mesh-types.d.ts +501 -13
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +59 -2
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +26 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +63 -12
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +3 -1
- package/src/cli-adapter-types.ts +68 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1246 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
- package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
- package/src/cli-adapters/provider-cli-parse.ts +19 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.ts +121 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +204 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2327 -0
- package/src/commands/chat-commands-scope.ts +54 -0
- package/src/commands/chat-commands-shared.ts +114 -0
- package/src/commands/chat-commands-write.ts +891 -0
- package/src/commands/chat-commands.ts +19 -1841
- package/src/commands/cli-manager.ts +544 -26
- package/src/commands/handler.ts +841 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +678 -0
- package/src/commands/high-family/mesh-events.ts +80 -0
- package/src/commands/high-family/mesh-status.ts +710 -0
- package/src/commands/high-family/types.ts +76 -0
- package/src/commands/low-family/coordinator-prompt.ts +72 -0
- package/src/commands/low-family/daemon-lifecycle.ts +107 -0
- package/src/commands/low-family/diagnostics.ts +57 -0
- package/src/commands/low-family/index.ts +37 -0
- package/src/commands/low-family/mesh-ledger.ts +62 -0
- package/src/commands/low-family/mesh-node-logs.ts +87 -0
- package/src/commands/low-family/notification.ts +116 -0
- package/src/commands/low-family/refine-config.ts +106 -0
- package/src/commands/low-family/session-host.ts +274 -0
- package/src/commands/low-family/spec-providerdev.ts +217 -0
- package/src/commands/low-family/status-meta.ts +112 -0
- package/src/commands/low-family/types.ts +39 -0
- package/src/commands/med-family/cli-agent.ts +238 -0
- package/src/commands/med-family/fast-forward.ts +230 -0
- package/src/commands/med-family/ide.ts +163 -0
- package/src/commands/med-family/index.ts +37 -0
- package/src/commands/med-family/mesh-crud.ts +1066 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +167 -0
- package/src/commands/med-family/mesh-restart.ts +92 -0
- package/src/commands/med-family/types.ts +143 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router.ts +2711 -3254
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +495 -22
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/repo-settings.ts +111 -0
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +28 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +59 -15
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +767 -48
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +261 -4
- package/src/git/index.ts +17 -0
- package/src/index.ts +194 -12
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/command-log.ts +7 -5
- package/src/logging/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +341 -0
- package/src/logging/logger.ts +14 -7
- package/src/mesh/contracts.ts +338 -0
- package/src/mesh/coordinator-prompt.ts +381 -33
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +645 -0
- package/src/mesh/mesh-clone-grace.ts +68 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-event-classify.ts +51 -0
- package/src/mesh/mesh-event-forwarding.ts +1888 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +32 -0
- package/src/mesh/mesh-events-pending.ts +656 -0
- package/src/mesh/mesh-events-stale.ts +389 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +33 -1035
- package/src/mesh/mesh-fast-forward.ts +843 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-init.ts +260 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +656 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +449 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-queue-assignment.ts +1918 -0
- package/src/mesh/mesh-reconcile-loop.ts +1780 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1673 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-review-inbox.ts +307 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +1853 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-inflight.ts +70 -0
- package/src/mesh/mesh-task-stats.ts +161 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1243 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +450 -0
- package/src/providers/acp-provider-instance.ts +43 -10
- package/src/providers/approval-utils.d.ts +5 -0
- package/src/providers/approval-utils.ts +57 -5
- package/src/providers/chat-message-normalization.ts +92 -4
- package/src/providers/cli-provider-instance.ts +1933 -104
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +150 -6
- package/src/providers/extension-provider-instance.ts +12 -7
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +35 -12
- package/src/providers/manual-attendance.ts +85 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/constants.ts +19 -0
- package/src/providers/native-history/dispatcher.ts +339 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +71 -0
- package/src/providers/provider-instance.ts +19 -1
- package/src/providers/provider-loader.ts +668 -50
- package/src/providers/provider-schema.ts +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +235 -0
- package/src/providers/spec/cli-adapter.ts +1056 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1410 -0
- package/src/providers/spec/fsm-evaluator.ts +272 -0
- package/src/providers/spec/fsm-loader.ts +120 -0
- package/src/providers/spec/fsm-types.ts +273 -0
- package/src/providers/spec/native-history-executor.ts +1128 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +262 -0
- package/src/providers/status-monitor.d.ts +7 -7
- package/src/providers/status-monitor.ts +37 -22
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +64 -24
- package/src/providers/working-dir.ts +23 -0
- package/src/repo-mesh-types.ts +740 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +64 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +95 -26
- package/src/system/hash.ts +23 -0
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +5 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* antigravity-cli-transcript — Daemon-side built-in native history adapter for antigravity-cli.
|
|
3
|
+
*
|
|
4
|
+
* Antigravity CLI stores conversations in multiple complementary locations:
|
|
5
|
+
*
|
|
6
|
+
* 1. ~/.gemini/antigravity-cli/history.jsonl
|
|
7
|
+
* Lightweight index of user prompts, one row per turn:
|
|
8
|
+
* { conversationId: string, display: string, workspace: string, timestamp: number }
|
|
9
|
+
*
|
|
10
|
+
* 2. ~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/transcript*.jsonl
|
|
11
|
+
* Per-session full transcript, one row per agent step:
|
|
12
|
+
* { source: 'USER_EXPLICIT'|'MODEL', type: string, content: string, status: 'DONE'|..., created_at: number }
|
|
13
|
+
*
|
|
14
|
+
* 3. ~/.gemini/antigravity-cli/conversations/<uuid>.pb
|
|
15
|
+
* Protobuf binary — schema not publicly documented. Adapter extracts
|
|
16
|
+
* printable UTF-8 text runs as best-effort content (no proto library needed).
|
|
17
|
+
*
|
|
18
|
+
* This adapter provides:
|
|
19
|
+
* - Full coverage when a brain transcript exists (authoritative source).
|
|
20
|
+
* - Partial coverage (user prompts only) from history.jsonl as fallback.
|
|
21
|
+
* - Best-effort raw-string extraction from .pb files when no other source exists.
|
|
22
|
+
*
|
|
23
|
+
* watchPath (from provider.v1.json):
|
|
24
|
+
* ~/.gemini/antigravity-cli/history.jsonl
|
|
25
|
+
* ~/.gemini/antigravity-cli/brain/{uuid}/.system_generated/logs/transcript*.jsonl
|
|
26
|
+
* ~/.gemini/antigravity-cli/conversations/{uuid}.pb
|
|
27
|
+
*
|
|
28
|
+
* OSS code (AGPL-3.0). Must not import from packages/ (proprietary).
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import * as fs from 'fs';
|
|
32
|
+
import * as path from 'path';
|
|
33
|
+
import * as os from 'os';
|
|
34
|
+
|
|
35
|
+
// ─── Types ─────────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
export type NativeHistoryRole = 'user' | 'assistant' | 'system';
|
|
38
|
+
export type NativeHistoryKind = 'standard' | 'tool' | 'session_start';
|
|
39
|
+
|
|
40
|
+
export interface NativeHistoryMessage {
|
|
41
|
+
ts: string;
|
|
42
|
+
receivedAt: number;
|
|
43
|
+
role: NativeHistoryRole;
|
|
44
|
+
content: string;
|
|
45
|
+
kind: NativeHistoryKind;
|
|
46
|
+
senderName?: string;
|
|
47
|
+
agent: 'antigravity-cli';
|
|
48
|
+
historySessionId: string;
|
|
49
|
+
workspace?: string;
|
|
50
|
+
/** Stable per-message identity (v2 contract). */
|
|
51
|
+
providerUnitKey?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface NativeHistorySession {
|
|
55
|
+
messages: NativeHistoryMessage[];
|
|
56
|
+
providerSessionId: string;
|
|
57
|
+
source: 'provider-native';
|
|
58
|
+
sourcePath: string;
|
|
59
|
+
sourceMtimeMs: number;
|
|
60
|
+
/**
|
|
61
|
+
* 'full' — brain transcript was available and parsed.
|
|
62
|
+
* 'partial' — only history.jsonl user-prompts are available.
|
|
63
|
+
* 'best-effort' — .pb file bytes were used for raw text extraction.
|
|
64
|
+
*/
|
|
65
|
+
nativeHistoryCoverage: 'full' | 'partial' | 'best-effort';
|
|
66
|
+
workspace?: string;
|
|
67
|
+
partialReason?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface NativeHistorySessionMeta {
|
|
71
|
+
historySessionId: string;
|
|
72
|
+
sessionId: string;
|
|
73
|
+
sourcePath: string;
|
|
74
|
+
sourceMtimeMs: number;
|
|
75
|
+
messageCount: number;
|
|
76
|
+
firstMessageAt: number;
|
|
77
|
+
lastMessageAt: number;
|
|
78
|
+
sessionTitle?: string;
|
|
79
|
+
preview?: string;
|
|
80
|
+
workspace?: string;
|
|
81
|
+
agent: 'antigravity-cli';
|
|
82
|
+
source: 'provider-native';
|
|
83
|
+
nativeHistoryCoverage: 'full' | 'partial' | 'best-effort';
|
|
84
|
+
partialReason?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ─── Internal helpers ───────────────────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
function extractTimestampValue(value: unknown): number {
|
|
90
|
+
if (typeof value === 'number' && Number.isFinite(value) && value > 0) return value;
|
|
91
|
+
if (typeof value === 'string') {
|
|
92
|
+
const numeric = Number(value);
|
|
93
|
+
if (Number.isFinite(numeric) && numeric > 0) return numeric;
|
|
94
|
+
const parsed = Date.parse(value);
|
|
95
|
+
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
96
|
+
}
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function statMtimeMs(filePath: string): number {
|
|
101
|
+
try { return fs.statSync(filePath).mtimeMs; } catch { return 0; }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isUuidLike(value: string): boolean {
|
|
105
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function antigravityRoot(): string {
|
|
109
|
+
return path.join(os.homedir(), '.gemini', 'antigravity-cli');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function historyJsonlPath(): string {
|
|
113
|
+
return path.join(antigravityRoot(), 'history.jsonl');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function brainRoot(): string {
|
|
117
|
+
return path.join(antigravityRoot(), 'brain');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function conversationsRoot(): string {
|
|
121
|
+
return path.join(antigravityRoot(), 'conversations');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function resolvePathInside(root: string, ...segments: string[]): string | null {
|
|
125
|
+
const rootPath = path.resolve(root);
|
|
126
|
+
const targetPath = path.resolve(rootPath, ...segments);
|
|
127
|
+
if (targetPath !== rootPath && !targetPath.startsWith(rootPath + path.sep)) return null;
|
|
128
|
+
return targetPath;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Find the brain transcript file for a given session UUID.
|
|
133
|
+
* Prefers transcript_full.jsonl over transcript.jsonl when both exist.
|
|
134
|
+
*/
|
|
135
|
+
function findBrainTranscriptPath(sessionId: string): string | null {
|
|
136
|
+
if (!isUuidLike(sessionId)) return null;
|
|
137
|
+
const logsRoot = resolvePathInside(brainRoot(), sessionId, '.system_generated', 'logs');
|
|
138
|
+
if (!logsRoot || !fs.existsSync(logsRoot)) return null;
|
|
139
|
+
|
|
140
|
+
const candidates = (['transcript_full.jsonl', 'transcript.jsonl'] as const)
|
|
141
|
+
.map((file) => resolvePathInside(logsRoot, file))
|
|
142
|
+
.filter((p): p is string => p !== null && fs.existsSync(p));
|
|
143
|
+
|
|
144
|
+
if (candidates.length === 0) {
|
|
145
|
+
// Look for any transcript*.jsonl
|
|
146
|
+
let entries: fs.Dirent[] = [];
|
|
147
|
+
try { entries = fs.readdirSync(logsRoot, { withFileTypes: true }); } catch { return null; }
|
|
148
|
+
const transcriptFiles = entries
|
|
149
|
+
.filter((e) => e.isFile() && /^transcript.*\.jsonl$/.test(e.name))
|
|
150
|
+
.map((e) => path.join(logsRoot, e.name));
|
|
151
|
+
if (transcriptFiles.length === 0) return null;
|
|
152
|
+
transcriptFiles.sort((a, b) => statMtimeMs(b) - statMtimeMs(a));
|
|
153
|
+
return transcriptFiles[0];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
candidates.sort((a, b) => statMtimeMs(b) - statMtimeMs(a));
|
|
157
|
+
return candidates[0];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* List all session UUIDs that have a brain transcript directory.
|
|
162
|
+
*/
|
|
163
|
+
function listBrainSessions(): Array<{ sessionId: string; transcriptPath: string; sourceMtimeMs: number }> {
|
|
164
|
+
const root = brainRoot();
|
|
165
|
+
let entries: fs.Dirent[] = [];
|
|
166
|
+
try { entries = fs.readdirSync(root, { withFileTypes: true }); } catch { return []; }
|
|
167
|
+
|
|
168
|
+
const results: Array<{ sessionId: string; transcriptPath: string; sourceMtimeMs: number }> = [];
|
|
169
|
+
for (const entry of entries) {
|
|
170
|
+
if (!entry.isDirectory() || !isUuidLike(entry.name)) continue;
|
|
171
|
+
const transcriptPath = findBrainTranscriptPath(entry.name);
|
|
172
|
+
if (!transcriptPath) continue;
|
|
173
|
+
results.push({
|
|
174
|
+
sessionId: entry.name,
|
|
175
|
+
transcriptPath,
|
|
176
|
+
sourceMtimeMs: statMtimeMs(transcriptPath),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return results;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Strip USER_REQUEST XML wrapper from antigravity user prompts.
|
|
184
|
+
* Antigravity wraps structured user input in <USER_REQUEST>...</USER_REQUEST>.
|
|
185
|
+
*/
|
|
186
|
+
function extractUserRequestContent(content: string): string {
|
|
187
|
+
const raw = content.trim();
|
|
188
|
+
const match = raw.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/i);
|
|
189
|
+
if (match) return match[1].trim();
|
|
190
|
+
return raw
|
|
191
|
+
.replace(/<ADDITIONAL_METADATA>[\s\S]*?<\/ADDITIONAL_METADATA>/gi, '')
|
|
192
|
+
.replace(/<USER_SETTINGS_CHANGE>[\s\S]*?<\/USER_SETTINGS_CHANGE>/gi, '')
|
|
193
|
+
.replace(/<\/?USER_REQUEST>/gi, '')
|
|
194
|
+
.trim();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Determine the NativeHistoryKind from an antigravity transcript row type.
|
|
199
|
+
*/
|
|
200
|
+
function antigravityRowKind(rowType: string): NativeHistoryKind {
|
|
201
|
+
if (rowType === 'PLANNER_RESPONSE') return 'standard';
|
|
202
|
+
if (rowType && rowType !== 'USER_INPUT') return 'tool';
|
|
203
|
+
return 'standard';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ─── Brain transcript parser ─────────────────────────────────────────────────
|
|
207
|
+
|
|
208
|
+
interface TranscriptRow {
|
|
209
|
+
source?: string;
|
|
210
|
+
type?: string;
|
|
211
|
+
content?: string;
|
|
212
|
+
status?: string;
|
|
213
|
+
created_at?: unknown;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Parse a brain transcript JSONL file into NativeHistoryMessages.
|
|
218
|
+
* Only rows with status === 'DONE' are processed.
|
|
219
|
+
* USER_EXPLICIT / USER_INPUT rows → user role.
|
|
220
|
+
* MODEL rows → assistant role.
|
|
221
|
+
*/
|
|
222
|
+
function parseBrainTranscript(
|
|
223
|
+
filePath: string,
|
|
224
|
+
sessionId: string,
|
|
225
|
+
workspace?: string,
|
|
226
|
+
): NativeHistoryMessage[] | null {
|
|
227
|
+
let raw: string;
|
|
228
|
+
try { raw = fs.readFileSync(filePath, 'utf-8'); } catch { return null; }
|
|
229
|
+
|
|
230
|
+
const lines = raw.split('\n').filter(Boolean);
|
|
231
|
+
if (lines.length === 0) return null;
|
|
232
|
+
|
|
233
|
+
const records: NativeHistoryMessage[] = [];
|
|
234
|
+
const normalizedWorkspace = typeof workspace === 'string' ? workspace.trim() : '';
|
|
235
|
+
let fallbackTs = statMtimeMs(filePath) || Date.now();
|
|
236
|
+
|
|
237
|
+
for (const line of lines) {
|
|
238
|
+
let row: TranscriptRow | null = null;
|
|
239
|
+
try { row = JSON.parse(line) as TranscriptRow; } catch { continue; }
|
|
240
|
+
if (!row || typeof row !== 'object') continue;
|
|
241
|
+
if (row.status !== 'DONE') continue;
|
|
242
|
+
|
|
243
|
+
const rowSource = String(row.source ?? '').trim();
|
|
244
|
+
const rowType = String(row.type ?? '').trim();
|
|
245
|
+
const rawContent = typeof row.content === 'string' ? row.content : '';
|
|
246
|
+
const receivedAt = extractTimestampValue(row.created_at) || fallbackTs + records.length;
|
|
247
|
+
|
|
248
|
+
if (rowSource === 'USER_EXPLICIT' && rowType === 'USER_INPUT') {
|
|
249
|
+
const content = extractUserRequestContent(rawContent);
|
|
250
|
+
if (!content) continue;
|
|
251
|
+
const msg: NativeHistoryMessage = {
|
|
252
|
+
ts: new Date(receivedAt).toISOString(),
|
|
253
|
+
receivedAt,
|
|
254
|
+
role: 'user',
|
|
255
|
+
content,
|
|
256
|
+
kind: 'standard',
|
|
257
|
+
agent: 'antigravity-cli',
|
|
258
|
+
historySessionId: sessionId,
|
|
259
|
+
};
|
|
260
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
261
|
+
records.push(msg);
|
|
262
|
+
} else if (rowSource === 'MODEL') {
|
|
263
|
+
const content = rawContent.trim();
|
|
264
|
+
if (!content) continue;
|
|
265
|
+
const kind = antigravityRowKind(rowType);
|
|
266
|
+
const msg: NativeHistoryMessage = {
|
|
267
|
+
ts: new Date(receivedAt).toISOString(),
|
|
268
|
+
receivedAt,
|
|
269
|
+
role: 'assistant',
|
|
270
|
+
content,
|
|
271
|
+
kind,
|
|
272
|
+
agent: 'antigravity-cli',
|
|
273
|
+
historySessionId: sessionId,
|
|
274
|
+
};
|
|
275
|
+
if (kind === 'tool') msg.senderName = 'Tool';
|
|
276
|
+
if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
|
|
277
|
+
records.push(msg);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return records.length > 0 ? records : null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ─── History JSONL parser ────────────────────────────────────────────────────
|
|
285
|
+
|
|
286
|
+
interface HistoryRow {
|
|
287
|
+
conversationId: string;
|
|
288
|
+
display: string;
|
|
289
|
+
workspace: string;
|
|
290
|
+
receivedAt: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function readHistoryRows(): HistoryRow[] {
|
|
294
|
+
const sourcePath = historyJsonlPath();
|
|
295
|
+
let lines: string[] = [];
|
|
296
|
+
try { lines = fs.readFileSync(sourcePath, 'utf-8').split('\n').filter(Boolean); } catch { return []; }
|
|
297
|
+
|
|
298
|
+
const rows: HistoryRow[] = [];
|
|
299
|
+
for (const line of lines) {
|
|
300
|
+
let parsed: unknown = null;
|
|
301
|
+
try { parsed = JSON.parse(line); } catch { continue; }
|
|
302
|
+
if (!parsed || typeof parsed !== 'object') continue;
|
|
303
|
+
|
|
304
|
+
const row = parsed as Record<string, unknown>;
|
|
305
|
+
const conversationId = String(row.conversationId ?? '').trim();
|
|
306
|
+
const display = typeof row.display === 'string' ? row.display.trim() : '';
|
|
307
|
+
const workspace = typeof row.workspace === 'string' ? row.workspace.trim() : '';
|
|
308
|
+
const receivedAt = extractTimestampValue(row.timestamp);
|
|
309
|
+
|
|
310
|
+
if (!conversationId || !isUuidLike(conversationId) || !display || !receivedAt) continue;
|
|
311
|
+
rows.push({ conversationId, display, workspace, receivedAt });
|
|
312
|
+
}
|
|
313
|
+
return rows;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// ─── Protobuf best-effort text extraction ────────────────────────────────────
|
|
317
|
+
|
|
318
|
+
const MIN_PRINTABLE_RUN = 8;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Extract printable UTF-8 text runs from raw binary data (similar to the `strings` command).
|
|
322
|
+
* Runs of printable ASCII/UTF-8 characters of length >= MIN_PRINTABLE_RUN are collected.
|
|
323
|
+
* This is used as a best-effort fallback when the .pb schema is not available.
|
|
324
|
+
*/
|
|
325
|
+
function extractStringsFromBuffer(buf: Buffer): string[] {
|
|
326
|
+
const strings: string[] = [];
|
|
327
|
+
let current: number[] = [];
|
|
328
|
+
|
|
329
|
+
for (let i = 0; i < buf.length; i++) {
|
|
330
|
+
const byte = buf[i];
|
|
331
|
+
// Accept printable ASCII (32-126) and common whitespace (9=tab, 10=LF, 13=CR)
|
|
332
|
+
if ((byte >= 32 && byte <= 126) || byte === 9 || byte === 10 || byte === 13) {
|
|
333
|
+
current.push(byte);
|
|
334
|
+
} else {
|
|
335
|
+
if (current.length >= MIN_PRINTABLE_RUN) {
|
|
336
|
+
const str = Buffer.from(current).toString('utf-8').trim();
|
|
337
|
+
if (str) strings.push(str);
|
|
338
|
+
}
|
|
339
|
+
current = [];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Flush remaining
|
|
343
|
+
if (current.length >= MIN_PRINTABLE_RUN) {
|
|
344
|
+
const str = Buffer.from(current).toString('utf-8').trim();
|
|
345
|
+
if (str) strings.push(str);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return strings;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Read a .pb conversation file and extract best-effort text content.
|
|
353
|
+
* Returns a single NativeHistoryMessage with the extracted content,
|
|
354
|
+
* or null if nothing readable was found.
|
|
355
|
+
*/
|
|
356
|
+
function parsePbFile(
|
|
357
|
+
filePath: string,
|
|
358
|
+
sessionId: string,
|
|
359
|
+
): NativeHistoryMessage[] | null {
|
|
360
|
+
let buf: Buffer;
|
|
361
|
+
try { buf = fs.readFileSync(filePath); } catch { return null; }
|
|
362
|
+
if (buf.length === 0) return null;
|
|
363
|
+
|
|
364
|
+
const strings = extractStringsFromBuffer(buf);
|
|
365
|
+
// Filter out very short or likely-binary strings
|
|
366
|
+
const meaningful = strings.filter((s) => s.length >= MIN_PRINTABLE_RUN && /\w/.test(s));
|
|
367
|
+
if (meaningful.length === 0) return null;
|
|
368
|
+
|
|
369
|
+
const content = meaningful.join('\n');
|
|
370
|
+
const sourceMtimeMs = statMtimeMs(filePath);
|
|
371
|
+
|
|
372
|
+
return [
|
|
373
|
+
{
|
|
374
|
+
ts: new Date(sourceMtimeMs).toISOString(),
|
|
375
|
+
receivedAt: sourceMtimeMs,
|
|
376
|
+
role: 'assistant',
|
|
377
|
+
content,
|
|
378
|
+
kind: 'standard',
|
|
379
|
+
agent: 'antigravity-cli',
|
|
380
|
+
historySessionId: sessionId,
|
|
381
|
+
},
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// ─── Public API ─────────────────────────────────────────────────────────────
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Read a single Antigravity CLI session by its source file path.
|
|
389
|
+
*
|
|
390
|
+
* `sessionPath` is the absolute path to one of:
|
|
391
|
+
* - A brain transcript JSONL: ~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/transcript*.jsonl
|
|
392
|
+
* - The shared history.jsonl: ~/.gemini/antigravity-cli/history.jsonl
|
|
393
|
+
* - A conversation protobuf: ~/.gemini/antigravity-cli/conversations/<uuid>.pb
|
|
394
|
+
*
|
|
395
|
+
* The session UUID is inferred from the directory name (brain), filename (pb), or
|
|
396
|
+
* must be provided explicitly via `sessionId` for history.jsonl paths.
|
|
397
|
+
*
|
|
398
|
+
* Returns `null` when the file is missing, empty, or yields no parseable messages.
|
|
399
|
+
*/
|
|
400
|
+
export function readSession(
|
|
401
|
+
sessionPath: string,
|
|
402
|
+
sessionId?: string,
|
|
403
|
+
workspace?: string,
|
|
404
|
+
): NativeHistorySession | null {
|
|
405
|
+
if (!sessionPath || !path.isAbsolute(sessionPath)) return null;
|
|
406
|
+
if (!fs.existsSync(sessionPath)) return null;
|
|
407
|
+
|
|
408
|
+
const sourceMtimeMs = statMtimeMs(sessionPath);
|
|
409
|
+
|
|
410
|
+
// ── Case 1: brain transcript JSONL ──────────────────────────────────────
|
|
411
|
+
const brainRootPath = brainRoot();
|
|
412
|
+
if (sessionPath.startsWith(brainRootPath + path.sep) && sessionPath.endsWith('.jsonl')) {
|
|
413
|
+
// Extract UUID from the path: brain/<uuid>/.system_generated/...
|
|
414
|
+
const relative = sessionPath.slice(brainRootPath.length + 1);
|
|
415
|
+
const uuidFromPath = relative.split(path.sep)[0];
|
|
416
|
+
const resolvedSessionId = sessionId || (isUuidLike(uuidFromPath) ? uuidFromPath : '');
|
|
417
|
+
if (!resolvedSessionId) return null;
|
|
418
|
+
|
|
419
|
+
const messages = parseBrainTranscript(sessionPath, resolvedSessionId, workspace);
|
|
420
|
+
if (!messages || messages.length === 0) return null;
|
|
421
|
+
|
|
422
|
+
return {
|
|
423
|
+
messages,
|
|
424
|
+
providerSessionId: resolvedSessionId,
|
|
425
|
+
source: 'provider-native',
|
|
426
|
+
sourcePath: sessionPath,
|
|
427
|
+
sourceMtimeMs,
|
|
428
|
+
nativeHistoryCoverage: 'full',
|
|
429
|
+
workspace,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// ── Case 2: .pb conversation file ───────────────────────────────────────
|
|
434
|
+
if (sessionPath.endsWith('.pb')) {
|
|
435
|
+
const pbSessionId = sessionId || path.basename(sessionPath, '.pb');
|
|
436
|
+
if (!isUuidLike(pbSessionId)) return null;
|
|
437
|
+
|
|
438
|
+
const messages = parsePbFile(sessionPath, pbSessionId);
|
|
439
|
+
if (!messages || messages.length === 0) return null;
|
|
440
|
+
|
|
441
|
+
return {
|
|
442
|
+
messages,
|
|
443
|
+
providerSessionId: pbSessionId,
|
|
444
|
+
source: 'provider-native',
|
|
445
|
+
sourcePath: sessionPath,
|
|
446
|
+
sourceMtimeMs,
|
|
447
|
+
nativeHistoryCoverage: 'best-effort',
|
|
448
|
+
partialReason: 'antigravity_cli_pb_raw_text_extraction',
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// ── Case 3: history.jsonl (user prompts index) ──────────────────────────
|
|
453
|
+
if (path.basename(sessionPath) === 'history.jsonl') {
|
|
454
|
+
const resolvedSessionId = sessionId || '';
|
|
455
|
+
if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
|
|
456
|
+
|
|
457
|
+
const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
|
|
458
|
+
if (rows.length === 0) return null;
|
|
459
|
+
|
|
460
|
+
rows.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
461
|
+
const firstWorkspace = workspace || rows.find((r) => r.workspace)?.workspace || '';
|
|
462
|
+
|
|
463
|
+
const messages: NativeHistoryMessage[] = [];
|
|
464
|
+
if (firstWorkspace) {
|
|
465
|
+
messages.push({
|
|
466
|
+
ts: new Date(rows[0].receivedAt).toISOString(),
|
|
467
|
+
receivedAt: rows[0].receivedAt,
|
|
468
|
+
role: 'system',
|
|
469
|
+
content: firstWorkspace,
|
|
470
|
+
kind: 'session_start',
|
|
471
|
+
agent: 'antigravity-cli',
|
|
472
|
+
historySessionId: resolvedSessionId,
|
|
473
|
+
workspace: firstWorkspace,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
for (const row of rows) {
|
|
478
|
+
const msg: NativeHistoryMessage = {
|
|
479
|
+
ts: new Date(row.receivedAt).toISOString(),
|
|
480
|
+
receivedAt: row.receivedAt,
|
|
481
|
+
role: 'user',
|
|
482
|
+
content: row.display,
|
|
483
|
+
kind: 'standard',
|
|
484
|
+
agent: 'antigravity-cli',
|
|
485
|
+
historySessionId: resolvedSessionId,
|
|
486
|
+
};
|
|
487
|
+
if (row.workspace) msg.workspace = row.workspace;
|
|
488
|
+
messages.push(msg);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return {
|
|
492
|
+
messages,
|
|
493
|
+
providerSessionId: resolvedSessionId,
|
|
494
|
+
source: 'provider-native',
|
|
495
|
+
sourcePath: sessionPath,
|
|
496
|
+
sourceMtimeMs,
|
|
497
|
+
nativeHistoryCoverage: 'partial',
|
|
498
|
+
partialReason: 'antigravity_cli_history_jsonl_contains_user_prompts_only',
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* List all Antigravity CLI sessions found across all watchPath locations.
|
|
507
|
+
*
|
|
508
|
+
* Priority:
|
|
509
|
+
* 1. Brain transcript sessions (full coverage) — preferred source.
|
|
510
|
+
* 2. History JSONL entries without a brain transcript (partial coverage).
|
|
511
|
+
* 3. .pb conversation files without any other source (best-effort).
|
|
512
|
+
*
|
|
513
|
+
* Returns summary metadata sorted by most recently updated first.
|
|
514
|
+
*/
|
|
515
|
+
export async function listSessions(_watchPath: string): Promise<NativeHistorySessionMeta[]> {
|
|
516
|
+
const results: NativeHistorySessionMeta[] = [];
|
|
517
|
+
const seen = new Set<string>();
|
|
518
|
+
|
|
519
|
+
// ── Step 1: brain transcripts (full coverage) ──────────────────────────
|
|
520
|
+
const historyRows = readHistoryRows();
|
|
521
|
+
const workspaceBySession = new Map<string, string>();
|
|
522
|
+
for (const row of historyRows) {
|
|
523
|
+
if (row.workspace && !workspaceBySession.has(row.conversationId)) {
|
|
524
|
+
workspaceBySession.set(row.conversationId, row.workspace);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
for (const { sessionId, transcriptPath, sourceMtimeMs } of listBrainSessions()) {
|
|
529
|
+
const workspace = workspaceBySession.get(sessionId);
|
|
530
|
+
const messages = parseBrainTranscript(transcriptPath, sessionId, workspace);
|
|
531
|
+
if (!messages || messages.length === 0) continue;
|
|
532
|
+
|
|
533
|
+
const visible = messages.filter((m) => m.kind !== 'session_start');
|
|
534
|
+
if (visible.length === 0) continue;
|
|
535
|
+
|
|
536
|
+
const firstMsg = visible[0];
|
|
537
|
+
const lastMsg = visible[visible.length - 1];
|
|
538
|
+
|
|
539
|
+
results.push({
|
|
540
|
+
historySessionId: sessionId,
|
|
541
|
+
sessionId,
|
|
542
|
+
sourcePath: transcriptPath,
|
|
543
|
+
sourceMtimeMs,
|
|
544
|
+
messageCount: visible.length,
|
|
545
|
+
firstMessageAt: firstMsg.receivedAt || sourceMtimeMs,
|
|
546
|
+
lastMessageAt: lastMsg.receivedAt || sourceMtimeMs,
|
|
547
|
+
sessionTitle: lastMsg.content,
|
|
548
|
+
preview: lastMsg.content,
|
|
549
|
+
workspace,
|
|
550
|
+
agent: 'antigravity-cli',
|
|
551
|
+
source: 'provider-native',
|
|
552
|
+
nativeHistoryCoverage: 'full',
|
|
553
|
+
});
|
|
554
|
+
seen.add(sessionId);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// ── Step 2: history.jsonl entries without brain transcripts ────────────
|
|
558
|
+
const grouped = new Map<
|
|
559
|
+
string,
|
|
560
|
+
{
|
|
561
|
+
firstMessageAt: number;
|
|
562
|
+
lastMessageAt: number;
|
|
563
|
+
messageCount: number;
|
|
564
|
+
sessionTitle?: string;
|
|
565
|
+
preview?: string;
|
|
566
|
+
workspace?: string;
|
|
567
|
+
}
|
|
568
|
+
>();
|
|
569
|
+
for (const row of historyRows) {
|
|
570
|
+
const existing = grouped.get(row.conversationId) ?? {
|
|
571
|
+
firstMessageAt: row.receivedAt,
|
|
572
|
+
lastMessageAt: row.receivedAt,
|
|
573
|
+
messageCount: 0,
|
|
574
|
+
};
|
|
575
|
+
existing.messageCount += 1;
|
|
576
|
+
existing.firstMessageAt = Math.min(existing.firstMessageAt, row.receivedAt);
|
|
577
|
+
if (row.receivedAt >= existing.lastMessageAt) {
|
|
578
|
+
existing.lastMessageAt = row.receivedAt;
|
|
579
|
+
existing.sessionTitle = row.display;
|
|
580
|
+
existing.preview = row.display;
|
|
581
|
+
if (row.workspace) existing.workspace = row.workspace;
|
|
582
|
+
}
|
|
583
|
+
grouped.set(row.conversationId, existing);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const historySrc = historyJsonlPath();
|
|
587
|
+
const historyMtime = statMtimeMs(historySrc);
|
|
588
|
+
|
|
589
|
+
for (const [sessionId, info] of grouped.entries()) {
|
|
590
|
+
if (seen.has(sessionId)) continue;
|
|
591
|
+
results.push({
|
|
592
|
+
historySessionId: sessionId,
|
|
593
|
+
sessionId,
|
|
594
|
+
sourcePath: historySrc,
|
|
595
|
+
sourceMtimeMs: historyMtime,
|
|
596
|
+
messageCount: info.messageCount,
|
|
597
|
+
firstMessageAt: info.firstMessageAt,
|
|
598
|
+
lastMessageAt: info.lastMessageAt,
|
|
599
|
+
sessionTitle: info.sessionTitle,
|
|
600
|
+
preview: info.preview,
|
|
601
|
+
workspace: info.workspace,
|
|
602
|
+
agent: 'antigravity-cli',
|
|
603
|
+
source: 'provider-native',
|
|
604
|
+
nativeHistoryCoverage: 'partial',
|
|
605
|
+
partialReason: 'antigravity_cli_history_jsonl_contains_user_prompts_only',
|
|
606
|
+
});
|
|
607
|
+
seen.add(sessionId);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// ── Step 3: .pb files without any other source ─────────────────────────
|
|
611
|
+
const convRoot = conversationsRoot();
|
|
612
|
+
if (fs.existsSync(convRoot)) {
|
|
613
|
+
let entries: fs.Dirent[] = [];
|
|
614
|
+
try { entries = fs.readdirSync(convRoot, { withFileTypes: true }); } catch { /* ignore */ }
|
|
615
|
+
|
|
616
|
+
for (const entry of entries) {
|
|
617
|
+
if (!entry.isFile() || !/^[0-9a-f-]+\.pb$/i.test(entry.name)) continue;
|
|
618
|
+
const pbSessionId = entry.name.replace(/\.pb$/, '');
|
|
619
|
+
if (!isUuidLike(pbSessionId) || seen.has(pbSessionId)) continue;
|
|
620
|
+
|
|
621
|
+
const pbPath = path.join(convRoot, entry.name);
|
|
622
|
+
const pbMtime = statMtimeMs(pbPath);
|
|
623
|
+
|
|
624
|
+
results.push({
|
|
625
|
+
historySessionId: pbSessionId,
|
|
626
|
+
sessionId: pbSessionId,
|
|
627
|
+
sourcePath: pbPath,
|
|
628
|
+
sourceMtimeMs: pbMtime,
|
|
629
|
+
messageCount: 0,
|
|
630
|
+
firstMessageAt: pbMtime,
|
|
631
|
+
lastMessageAt: pbMtime,
|
|
632
|
+
agent: 'antigravity-cli',
|
|
633
|
+
source: 'provider-native',
|
|
634
|
+
nativeHistoryCoverage: 'best-effort',
|
|
635
|
+
partialReason: 'antigravity_cli_pb_raw_text_extraction',
|
|
636
|
+
});
|
|
637
|
+
seen.add(pbSessionId);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
results.sort((a, b) => (b.lastMessageAt || 0) - (a.lastMessageAt || 0));
|
|
642
|
+
return results;
|
|
643
|
+
}
|