@aria-cli/cli 1.0.54 → 1.0.55
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/bin/aria.mjs +671 -802
- package/dist/.tsbuildinfo +1 -0
- package/dist/attached-local-control-client.js +826 -0
- package/dist/attached-local-control-client.js.map +1 -0
- package/dist/bootstrap-local-control-client.js +2 -0
- package/dist/bootstrap-local-control-client.js.map +1 -0
- package/dist/capability-aware-method-proxy.js +42 -0
- package/dist/capability-aware-method-proxy.js.map +1 -0
- package/dist/cli-context.js +160 -0
- package/dist/cli-context.js.map +1 -0
- package/dist/commands/arions.js +174 -0
- package/dist/commands/arions.js.map +1 -0
- package/dist/commands/auth.js +123 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/daemon.js +367 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/definitions.js +176 -0
- package/dist/commands/definitions.js.map +1 -0
- package/dist/commands/index.js +80 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/login-handler.js +1108 -0
- package/dist/commands/login-handler.js.map +1 -0
- package/dist/commands/logout-handler.js +92 -0
- package/dist/commands/logout-handler.js.map +1 -0
- package/dist/commands/memory-handlers.js +89 -0
- package/dist/commands/memory-handlers.js.map +1 -0
- package/dist/commands/pairing.js +60 -0
- package/dist/commands/pairing.js.map +1 -0
- package/dist/commands/runtime-cutover-reset-command.js +12 -0
- package/dist/commands/runtime-cutover-reset-command.js.map +1 -0
- package/dist/commands/runtime-cutover-reset.js +265 -0
- package/dist/commands/runtime-cutover-reset.js.map +1 -0
- package/dist/commands/terminal-setup.js +84 -0
- package/dist/commands/terminal-setup.js.map +1 -0
- package/dist/config/aria-config.js +238 -0
- package/dist/config/aria-config.js.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.js +97 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config.js +142 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon-info.js +10 -0
- package/dist/daemon-info.js.map +1 -0
- package/dist/ensure-daemon.js +128 -0
- package/dist/ensure-daemon.js.map +1 -0
- package/dist/entrypoints/command-mode.js +5 -0
- package/dist/entrypoints/command-mode.js.map +1 -0
- package/dist/entrypoints/daemon.js +50 -0
- package/dist/entrypoints/daemon.js.map +1 -0
- package/dist/entrypoints/headless-stdio.js +25 -0
- package/dist/entrypoints/headless-stdio.js.map +1 -0
- package/dist/entrypoints/interactive.d.ts.map +1 -0
- package/dist/entrypoints/interactive.js +80 -0
- package/dist/entrypoints/interactive.js.map +1 -0
- package/dist/event-loop-watchdog.js +73 -0
- package/dist/event-loop-watchdog.js.map +1 -0
- package/dist/headless/auth-orchestrator.js +508 -0
- package/dist/headless/auth-orchestrator.js.map +1 -0
- package/dist/headless/auth-service.js +43 -0
- package/dist/headless/auth-service.js.map +1 -0
- package/dist/headless/bootstrap-fast-path.js +112 -0
- package/dist/headless/bootstrap-fast-path.js.map +1 -0
- package/dist/headless/call-command.js +143 -0
- package/dist/headless/call-command.js.map +1 -0
- package/dist/headless/daemon-service.js +318 -0
- package/dist/headless/daemon-service.js.map +1 -0
- package/dist/headless/hook-actions.js +235 -0
- package/dist/headless/hook-actions.js.map +1 -0
- package/dist/headless/hook-service.js +42 -0
- package/dist/headless/hook-service.js.map +1 -0
- package/dist/headless/kernel-services.js +216 -0
- package/dist/headless/kernel-services.js.map +1 -0
- package/dist/headless/kernel.js +785 -0
- package/dist/headless/kernel.js.map +1 -0
- package/dist/headless/operations/arion.js +119 -0
- package/dist/headless/operations/arion.js.map +1 -0
- package/dist/headless/operations/auth.js +45 -0
- package/dist/headless/operations/auth.js.map +1 -0
- package/dist/headless/operations/client.js +31 -0
- package/dist/headless/operations/client.js.map +1 -0
- package/dist/headless/operations/config.js +69 -0
- package/dist/headless/operations/config.js.map +1 -0
- package/dist/headless/operations/daemon.js +47 -0
- package/dist/headless/operations/daemon.js.map +1 -0
- package/dist/headless/operations/hook.js +56 -0
- package/dist/headless/operations/hook.js.map +1 -0
- package/dist/headless/operations/index.js +11 -0
- package/dist/headless/operations/index.js.map +1 -0
- package/dist/headless/operations/memory.js +102 -0
- package/dist/headless/operations/memory.js.map +1 -0
- package/dist/headless/operations/message.js +279 -0
- package/dist/headless/operations/message.js.map +1 -0
- package/dist/headless/operations/model.js +100 -0
- package/dist/headless/operations/model.js.map +1 -0
- package/dist/headless/operations/peer.js +56 -0
- package/dist/headless/operations/peer.js.map +1 -0
- package/dist/headless/operations/run.js +24 -0
- package/dist/headless/operations/run.js.map +1 -0
- package/dist/headless/operations/session.js +90 -0
- package/dist/headless/operations/session.js.map +1 -0
- package/dist/headless/operations/system.js +19 -0
- package/dist/headless/operations/system.js.map +1 -0
- package/dist/headless/operations/utils.js +35 -0
- package/dist/headless/operations/utils.js.map +1 -0
- package/dist/headless/run-orchestrator.js +703 -0
- package/dist/headless/run-orchestrator.js.map +1 -0
- package/dist/headless/stdio-server.js +439 -0
- package/dist/headless/stdio-server.js.map +1 -0
- package/dist/history/SessionHistory.js +8 -0
- package/dist/history/SessionHistory.js.map +1 -0
- package/dist/history/SessionHistoryClient.js +186 -0
- package/dist/history/SessionHistoryClient.js.map +1 -0
- package/dist/history/conversation-message.js +112 -0
- package/dist/history/conversation-message.js.map +1 -0
- package/dist/history/index.js +8 -0
- package/dist/history/index.js.map +1 -0
- package/dist/history/jsonl-replay.js +154 -0
- package/dist/history/jsonl-replay.js.map +1 -0
- package/dist/history/repair-tool-pairing.js +84 -0
- package/dist/history/repair-tool-pairing.js.map +1 -0
- package/dist/history/stall-phase-bridge.js +11 -0
- package/dist/history/stall-phase-bridge.js.map +1 -0
- package/dist/history/turn-accumulator.js +427 -0
- package/dist/history/turn-accumulator.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/ink-repl.d.ts.map +1 -0
- package/dist/ink-repl.js +4183 -0
- package/dist/ink-repl.js.map +1 -0
- package/dist/local-control-bootstrap.js +26 -0
- package/dist/local-control-bootstrap.js.map +1 -0
- package/dist/local-control-client.js +2 -0
- package/dist/local-control-client.js.map +1 -0
- package/dist/local-control-error-reporting.js +34 -0
- package/dist/local-control-error-reporting.js.map +1 -0
- package/dist/local-control-http-client.js +362 -0
- package/dist/local-control-http-client.js.map +1 -0
- package/dist/local-control-lazy-wrapper.js +363 -0
- package/dist/local-control-lazy-wrapper.js.map +1 -0
- package/dist/local-control-manager.js +146 -0
- package/dist/local-control-manager.js.map +1 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +62 -0
- package/dist/main.js.map +1 -0
- package/dist/network-security.js +62 -0
- package/dist/network-security.js.map +1 -0
- package/dist/networking-server.js +38 -0
- package/dist/networking-server.js.map +1 -0
- package/dist/peer-identity.js +23 -0
- package/dist/peer-identity.js.map +1 -0
- package/dist/polling-subscription.js +34 -0
- package/dist/polling-subscription.js.map +1 -0
- package/dist/relaunch.d.ts +63 -0
- package/dist/relaunch.d.ts.map +1 -0
- package/dist/relaunch.js +617 -0
- package/dist/relaunch.js.map +1 -0
- package/dist/release-notes.js +35 -0
- package/dist/release-notes.js.map +1 -0
- package/dist/repl-cleanup.js +47 -0
- package/dist/repl-cleanup.js.map +1 -0
- package/dist/runtime/configure-bun-sqlite.js +3 -0
- package/dist/runtime/configure-bun-sqlite.js.map +1 -0
- package/dist/runtime/crash-handlers.js +111 -0
- package/dist/runtime/crash-handlers.js.map +1 -0
- package/dist/runtime/interactive-invocation.js +39 -0
- package/dist/runtime/interactive-invocation.js.map +1 -0
- package/dist/runtime/internal-mode.js +14 -0
- package/dist/runtime/internal-mode.js.map +1 -0
- package/dist/runtime/launch-spec.js +64 -0
- package/dist/runtime/launch-spec.js.map +1 -0
- package/dist/runtime/owner-lease.js +44 -0
- package/dist/runtime/owner-lease.js.map +1 -0
- package/dist/runtime/public-mode.js +20 -0
- package/dist/runtime/public-mode.js.map +1 -0
- package/dist/runtime/run-internal-mode.d.ts.map +1 -0
- package/dist/runtime/run-internal-mode.js +18 -0
- package/dist/runtime/run-internal-mode.js.map +1 -0
- package/dist/runtime/runtime-kind.js +32 -0
- package/dist/runtime/runtime-kind.js.map +1 -0
- package/dist/runtime/spawn-aria.js +38 -0
- package/dist/runtime/spawn-aria.js.map +1 -0
- package/dist/selectable-client.js +2 -0
- package/dist/selectable-client.js.map +1 -0
- package/dist/selectable-peer.js +2 -0
- package/dist/selectable-peer.js.map +1 -0
- package/dist/session.js +203 -0
- package/dist/session.js.map +1 -0
- package/dist/slash-commands.js +80 -0
- package/dist/slash-commands.js.map +1 -0
- package/dist/sounds.js +210 -0
- package/dist/sounds.js.map +1 -0
- package/dist/ui/App.js +526 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/components/AnthropicMethodPicker.js +6 -0
- package/dist/ui/components/AnthropicMethodPicker.js.map +1 -0
- package/dist/ui/components/ArionPrompt.js +15 -0
- package/dist/ui/components/ArionPrompt.js.map +1 -0
- package/dist/ui/components/AutocompleteDropdown.js +23 -0
- package/dist/ui/components/AutocompleteDropdown.js.map +1 -0
- package/dist/ui/components/AutonomySelector.js +55 -0
- package/dist/ui/components/AutonomySelector.js.map +1 -0
- package/dist/ui/components/Banner.js +98 -0
- package/dist/ui/components/Banner.js.map +1 -0
- package/dist/ui/components/ConversationHistory.js +175 -0
- package/dist/ui/components/ConversationHistory.js.map +1 -0
- package/dist/ui/components/CopilotDeviceLoginFlow.js +88 -0
- package/dist/ui/components/CopilotDeviceLoginFlow.js.map +1 -0
- package/dist/ui/components/CopilotSourcePicker.js +50 -0
- package/dist/ui/components/CopilotSourcePicker.js.map +1 -0
- package/dist/ui/components/Cost.js +10 -0
- package/dist/ui/components/Cost.js.map +1 -0
- package/dist/ui/components/CustomSelect/option-map.js +30 -0
- package/dist/ui/components/CustomSelect/option-map.js.map +1 -0
- package/dist/ui/components/CustomSelect/select-option.js +13 -0
- package/dist/ui/components/CustomSelect/select-option.js.map +1 -0
- package/dist/ui/components/CustomSelect/select.js +42 -0
- package/dist/ui/components/CustomSelect/select.js.map +1 -0
- package/dist/ui/components/CustomSelect/use-select-state.js +179 -0
- package/dist/ui/components/CustomSelect/use-select-state.js.map +1 -0
- package/dist/ui/components/CustomSelect/use-select.js +15 -0
- package/dist/ui/components/CustomSelect/use-select.js.map +1 -0
- package/dist/ui/components/ErrorDisplay.js +35 -0
- package/dist/ui/components/ErrorDisplay.js.map +1 -0
- package/dist/ui/components/FallbackToolUseRejectedMessage.js +7 -0
- package/dist/ui/components/FallbackToolUseRejectedMessage.js.map +1 -0
- package/dist/ui/components/FileEditToolUpdatedMessage.js +57 -0
- package/dist/ui/components/FileEditToolUpdatedMessage.js.map +1 -0
- package/dist/ui/components/HandoffMarker.js +18 -0
- package/dist/ui/components/HandoffMarker.js.map +1 -0
- package/dist/ui/components/HighlightedCode.js +21 -0
- package/dist/ui/components/HighlightedCode.js.map +1 -0
- package/dist/ui/components/InputArea.js +187 -0
- package/dist/ui/components/InputArea.js.map +1 -0
- package/dist/ui/components/Message.js +25 -0
- package/dist/ui/components/Message.js.map +1 -0
- package/dist/ui/components/OAuthLoginFlow.js +113 -0
- package/dist/ui/components/OAuthLoginFlow.js.map +1 -0
- package/dist/ui/components/OutputTruncation.js +35 -0
- package/dist/ui/components/OutputTruncation.js.map +1 -0
- package/dist/ui/components/PermissionPrompt.js +79 -0
- package/dist/ui/components/PermissionPrompt.js.map +1 -0
- package/dist/ui/components/PipelineTimingPanel.js +15 -0
- package/dist/ui/components/PipelineTimingPanel.js.map +1 -0
- package/dist/ui/components/ProviderMethodPicker.js +61 -0
- package/dist/ui/components/ProviderMethodPicker.js.map +1 -0
- package/dist/ui/components/ProviderPicker.js +63 -0
- package/dist/ui/components/ProviderPicker.js.map +1 -0
- package/dist/ui/components/RenderItemView.js +71 -0
- package/dist/ui/components/RenderItemView.js.map +1 -0
- package/dist/ui/components/Spinner.js +46 -0
- package/dist/ui/components/Spinner.js.map +1 -0
- package/dist/ui/components/StatusBar.js +95 -0
- package/dist/ui/components/StatusBar.js.map +1 -0
- package/dist/ui/components/StreamingIndicator.js +55 -0
- package/dist/ui/components/StreamingIndicator.js.map +1 -0
- package/dist/ui/components/StructuredDiff.js +168 -0
- package/dist/ui/components/StructuredDiff.js.map +1 -0
- package/dist/ui/components/TextInputOverlay.js +43 -0
- package/dist/ui/components/TextInputOverlay.js.map +1 -0
- package/dist/ui/components/ThinkingBlock.js +82 -0
- package/dist/ui/components/ThinkingBlock.js.map +1 -0
- package/dist/ui/components/ToolCost.js +17 -0
- package/dist/ui/components/ToolCost.js.map +1 -0
- package/dist/ui/components/ToolExecution.js +61 -0
- package/dist/ui/components/ToolExecution.js.map +1 -0
- package/dist/ui/components/ToolHeader.js +51 -0
- package/dist/ui/components/ToolHeader.js.map +1 -0
- package/dist/ui/components/ToolRenderLayoutContext.js +14 -0
- package/dist/ui/components/ToolRenderLayoutContext.js.map +1 -0
- package/dist/ui/components/ToolResultWrapper.js +6 -0
- package/dist/ui/components/ToolResultWrapper.js.map +1 -0
- package/dist/ui/components/ToolUseLoader.js +35 -0
- package/dist/ui/components/ToolUseLoader.js.map +1 -0
- package/dist/ui/components/TraceWaterfall.js +91 -0
- package/dist/ui/components/TraceWaterfall.js.map +1 -0
- package/dist/ui/components/index.js +33 -0
- package/dist/ui/components/index.js.map +1 -0
- package/dist/ui/components/messages/AssistantTextMessage.js +25 -0
- package/dist/ui/components/messages/AssistantTextMessage.js.map +1 -0
- package/dist/ui/components/messages/UserImageMessage.js +12 -0
- package/dist/ui/components/messages/UserImageMessage.js.map +1 -0
- package/dist/ui/components/messages/UserTextMessage.js +12 -0
- package/dist/ui/components/messages/UserTextMessage.js.map +1 -0
- package/dist/ui/components/overlays/ArionSelector.js +68 -0
- package/dist/ui/components/overlays/ArionSelector.js.map +1 -0
- package/dist/ui/components/overlays/ClientSelector.js +62 -0
- package/dist/ui/components/overlays/ClientSelector.js.map +1 -0
- package/dist/ui/components/overlays/CommandPalette.js +67 -0
- package/dist/ui/components/overlays/CommandPalette.js.map +1 -0
- package/dist/ui/components/overlays/DaemonControl.js +87 -0
- package/dist/ui/components/overlays/DaemonControl.js.map +1 -0
- package/dist/ui/components/overlays/InviteShareOverlay.js +15 -0
- package/dist/ui/components/overlays/InviteShareOverlay.js.map +1 -0
- package/dist/ui/components/overlays/JoinInviteOverlay.js +32 -0
- package/dist/ui/components/overlays/JoinInviteOverlay.js.map +1 -0
- package/dist/ui/components/overlays/MemoryBrowser.js +100 -0
- package/dist/ui/components/overlays/MemoryBrowser.js.map +1 -0
- package/dist/ui/components/overlays/MessageSelector.js +123 -0
- package/dist/ui/components/overlays/MessageSelector.js.map +1 -0
- package/dist/ui/components/overlays/ModelSelector.js +211 -0
- package/dist/ui/components/overlays/ModelSelector.js.map +1 -0
- package/dist/ui/components/overlays/PairRequestOverlay.js +42 -0
- package/dist/ui/components/overlays/PairRequestOverlay.js.map +1 -0
- package/dist/ui/components/overlays/PeerSelector.js +84 -0
- package/dist/ui/components/overlays/PeerSelector.js.map +1 -0
- package/dist/ui/components/overlays/SessionSelector.js +102 -0
- package/dist/ui/components/overlays/SessionSelector.js.map +1 -0
- package/dist/ui/components/overlays/SoundSelector.js +86 -0
- package/dist/ui/components/overlays/SoundSelector.js.map +1 -0
- package/dist/ui/components/overlays/ThemeSelector.js +139 -0
- package/dist/ui/components/overlays/ThemeSelector.js.map +1 -0
- package/dist/ui/components/overlays/index.js +15 -0
- package/dist/ui/components/overlays/index.js.map +1 -0
- package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.js +53 -0
- package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.js.map +1 -0
- package/dist/ui/components/permissions/FallbackPermissionRequest.js +56 -0
- package/dist/ui/components/permissions/FallbackPermissionRequest.js.map +1 -0
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +76 -0
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js.map +1 -0
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js +18 -0
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js.map +1 -0
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +64 -0
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js.map +1 -0
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +26 -0
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js.map +1 -0
- package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +141 -0
- package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js.map +1 -0
- package/dist/ui/components/permissions/PermissionRequest.js +70 -0
- package/dist/ui/components/permissions/PermissionRequest.js.map +1 -0
- package/dist/ui/components/permissions/PermissionRequestTitle.js +41 -0
- package/dist/ui/components/permissions/PermissionRequestTitle.js.map +1 -0
- package/dist/ui/components/permissions/hooks.js +10 -0
- package/dist/ui/components/permissions/hooks.js.map +1 -0
- package/dist/ui/components/permissions/toolUseOptions.js +68 -0
- package/dist/ui/components/permissions/toolUseOptions.js.map +1 -0
- package/dist/ui/components/permissions/utils.js +10 -0
- package/dist/ui/components/permissions/utils.js.map +1 -0
- package/dist/ui/components/text-input/Cursor.js +326 -0
- package/dist/ui/components/text-input/Cursor.js.map +1 -0
- package/dist/ui/components/text-input/TextInput.js +231 -0
- package/dist/ui/components/text-input/TextInput.js.map +1 -0
- package/dist/ui/components/text-input/imagePaste.js +28 -0
- package/dist/ui/components/text-input/imagePaste.js.map +1 -0
- package/dist/ui/components/text-input/index.js +6 -0
- package/dist/ui/components/text-input/index.js.map +1 -0
- package/dist/ui/components/text-input/useDoublePress.js +30 -0
- package/dist/ui/components/text-input/useDoublePress.js.map +1 -0
- package/dist/ui/components/text-input/useTextInput.js +245 -0
- package/dist/ui/components/text-input/useTextInput.js.map +1 -0
- package/dist/ui/components/tool-types.js +9 -0
- package/dist/ui/components/tool-types.js.map +1 -0
- package/dist/ui/constants/figures.js +4 -0
- package/dist/ui/constants/figures.js.map +1 -0
- package/dist/ui/constants/index.js +3 -0
- package/dist/ui/constants/index.js.map +1 -0
- package/dist/ui/display-mode.js +93 -0
- package/dist/ui/display-mode.js.map +1 -0
- package/dist/ui/display-policy.js +19 -0
- package/dist/ui/display-policy.js.map +1 -0
- package/dist/ui/hooks/index.js +6 -0
- package/dist/ui/hooks/index.js.map +1 -0
- package/dist/ui/hooks/useCommandAutocomplete.js +93 -0
- package/dist/ui/hooks/useCommandAutocomplete.js.map +1 -0
- package/dist/ui/hooks/useDoublePress.js +37 -0
- package/dist/ui/hooks/useDoublePress.js.map +1 -0
- package/dist/ui/hooks/useIndicatorState.js +55 -0
- package/dist/ui/hooks/useIndicatorState.js.map +1 -0
- package/dist/ui/hooks/useInterval.js +23 -0
- package/dist/ui/hooks/useInterval.js.map +1 -0
- package/dist/ui/hooks/useKeyboardShortcuts.js +127 -0
- package/dist/ui/hooks/useKeyboardShortcuts.js.map +1 -0
- package/dist/ui/hooks/useTerminalSize.js +55 -0
- package/dist/ui/hooks/useTerminalSize.js.map +1 -0
- package/dist/ui/hooks/useUnifiedMessages.js +117 -0
- package/dist/ui/hooks/useUnifiedMessages.js.map +1 -0
- package/dist/ui/indicator-state.js +44 -0
- package/dist/ui/indicator-state.js.map +1 -0
- package/dist/ui/markdown/highlight.js +44 -0
- package/dist/ui/markdown/highlight.js.map +1 -0
- package/dist/ui/markdown/index.js +1460 -0
- package/dist/ui/markdown/index.js.map +1 -0
- package/dist/ui/markdown/tokenizer.js +24 -0
- package/dist/ui/markdown/tokenizer.js.map +1 -0
- package/dist/ui/render-item.js +5 -0
- package/dist/ui/render-item.js.map +1 -0
- package/dist/ui/screens/REPL.js +119 -0
- package/dist/ui/screens/REPL.js.map +1 -0
- package/dist/ui/screens/approval-lifecycle.js +38 -0
- package/dist/ui/screens/approval-lifecycle.js.map +1 -0
- package/dist/ui/status-line.js +72 -0
- package/dist/ui/status-line.js.map +1 -0
- package/dist/ui/theme/index.js +51 -0
- package/dist/ui/theme/index.js.map +1 -0
- package/dist/ui/theme/themes/claude-dark-daltonized.js +51 -0
- package/dist/ui/theme/themes/claude-dark-daltonized.js.map +1 -0
- package/dist/ui/theme/themes/claude-dark.js +50 -0
- package/dist/ui/theme/themes/claude-dark.js.map +1 -0
- package/dist/ui/theme/themes/claude-light-daltonized.js +51 -0
- package/dist/ui/theme/themes/claude-light-daltonized.js.map +1 -0
- package/dist/ui/theme/themes/claude-light.js +50 -0
- package/dist/ui/theme/themes/claude-light.js.map +1 -0
- package/dist/ui/theme/themes/dark-accessible.js +18 -0
- package/dist/ui/theme/themes/dark-accessible.js.map +1 -0
- package/dist/ui/theme/themes/dark.js +49 -0
- package/dist/ui/theme/themes/dark.js.map +1 -0
- package/dist/ui/theme/themes/light-accessible.js +18 -0
- package/dist/ui/theme/themes/light-accessible.js.map +1 -0
- package/dist/ui/theme/themes/light.js +49 -0
- package/dist/ui/theme/themes/light.js.map +1 -0
- package/dist/ui/theme/types.js +3 -0
- package/dist/ui/theme/types.js.map +1 -0
- package/dist/ui/theme.js +142 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/ui/to-render-items.js +145 -0
- package/dist/ui/to-render-items.js.map +1 -0
- package/dist/ui/tools/AgentTool/index.js +30 -0
- package/dist/ui/tools/AgentTool/index.js.map +1 -0
- package/dist/ui/tools/ArchitectTool/index.js +31 -0
- package/dist/ui/tools/ArchitectTool/index.js.map +1 -0
- package/dist/ui/tools/AskUserTool/index.js +46 -0
- package/dist/ui/tools/AskUserTool/index.js.map +1 -0
- package/dist/ui/tools/BashTool/BashToolResultMessage.js +11 -0
- package/dist/ui/tools/BashTool/BashToolResultMessage.js.map +1 -0
- package/dist/ui/tools/BashTool/OutputLine.js +21 -0
- package/dist/ui/tools/BashTool/OutputLine.js.map +1 -0
- package/dist/ui/tools/BashTool/index.js +91 -0
- package/dist/ui/tools/BashTool/index.js.map +1 -0
- package/dist/ui/tools/BrowseTool/index.js +43 -0
- package/dist/ui/tools/BrowseTool/index.js.map +1 -0
- package/dist/ui/tools/BrowserTool/index.js +47 -0
- package/dist/ui/tools/BrowserTool/index.js.map +1 -0
- package/dist/ui/tools/CbmTool/index.js +188 -0
- package/dist/ui/tools/CbmTool/index.js.map +1 -0
- package/dist/ui/tools/CheckDelegationTool/index.js +46 -0
- package/dist/ui/tools/CheckDelegationTool/index.js.map +1 -0
- package/dist/ui/tools/CheckMessagesTool/index.js +85 -0
- package/dist/ui/tools/CheckMessagesTool/index.js.map +1 -0
- package/dist/ui/tools/CreateQuipTool/index.js +30 -0
- package/dist/ui/tools/CreateQuipTool/index.js.map +1 -0
- package/dist/ui/tools/CreateSkillTool/index.js +22 -0
- package/dist/ui/tools/CreateSkillTool/index.js.map +1 -0
- package/dist/ui/tools/CreateToolTool/index.js +31 -0
- package/dist/ui/tools/CreateToolTool/index.js.map +1 -0
- package/dist/ui/tools/DelegateRemoteTool/index.js +42 -0
- package/dist/ui/tools/DelegateRemoteTool/index.js.map +1 -0
- package/dist/ui/tools/DeployTool/index.js +47 -0
- package/dist/ui/tools/DeployTool/index.js.map +1 -0
- package/dist/ui/tools/FffTool/index.js +103 -0
- package/dist/ui/tools/FffTool/index.js.map +1 -0
- package/dist/ui/tools/FileEditTool/index.js +67 -0
- package/dist/ui/tools/FileEditTool/index.js.map +1 -0
- package/dist/ui/tools/FileReadTool/index.js +68 -0
- package/dist/ui/tools/FileReadTool/index.js.map +1 -0
- package/dist/ui/tools/FileWriteTool/index.js +61 -0
- package/dist/ui/tools/FileWriteTool/index.js.map +1 -0
- package/dist/ui/tools/ForkTool/index.js +47 -0
- package/dist/ui/tools/ForkTool/index.js.map +1 -0
- package/dist/ui/tools/FrgTool/index.js +96 -0
- package/dist/ui/tools/FrgTool/index.js.map +1 -0
- package/dist/ui/tools/GetThreadTool/index.js +39 -0
- package/dist/ui/tools/GetThreadTool/index.js.map +1 -0
- package/dist/ui/tools/GlobTool/index.js +50 -0
- package/dist/ui/tools/GlobTool/index.js.map +1 -0
- package/dist/ui/tools/GrepTool/index.js +84 -0
- package/dist/ui/tools/GrepTool/index.js.map +1 -0
- package/dist/ui/tools/HatchArionTool/index.js +36 -0
- package/dist/ui/tools/HatchArionTool/index.js.map +1 -0
- package/dist/ui/tools/LearnSkillTool/index.js +22 -0
- package/dist/ui/tools/LearnSkillTool/index.js.map +1 -0
- package/dist/ui/tools/LearnTool/index.js +43 -0
- package/dist/ui/tools/LearnTool/index.js.map +1 -0
- package/dist/ui/tools/LearnToolTool/index.js +22 -0
- package/dist/ui/tools/LearnToolTool/index.js.map +1 -0
- package/dist/ui/tools/ListClientsTool/index.js +39 -0
- package/dist/ui/tools/ListClientsTool/index.js.map +1 -0
- package/dist/ui/tools/LspTool/index.js +261 -0
- package/dist/ui/tools/LspTool/index.js.map +1 -0
- package/dist/ui/tools/MCPTool/index.js +33 -0
- package/dist/ui/tools/MCPTool/index.js.map +1 -0
- package/dist/ui/tools/ManageNetworkTool/index.js +53 -0
- package/dist/ui/tools/ManageNetworkTool/index.js.map +1 -0
- package/dist/ui/tools/MemoryReadTool/index.js +64 -0
- package/dist/ui/tools/MemoryReadTool/index.js.map +1 -0
- package/dist/ui/tools/MemoryWriteTool/index.js +20 -0
- package/dist/ui/tools/MemoryWriteTool/index.js.map +1 -0
- package/dist/ui/tools/NotebookEditTool/index.js +33 -0
- package/dist/ui/tools/NotebookEditTool/index.js.map +1 -0
- package/dist/ui/tools/NotebookReadTool/index.js +25 -0
- package/dist/ui/tools/NotebookReadTool/index.js.map +1 -0
- package/dist/ui/tools/OutlookReadTool/index.js +66 -0
- package/dist/ui/tools/OutlookReadTool/index.js.map +1 -0
- package/dist/ui/tools/OutlookReplyTool/index.js +49 -0
- package/dist/ui/tools/OutlookReplyTool/index.js.map +1 -0
- package/dist/ui/tools/OutlookSendTool/index.js +49 -0
- package/dist/ui/tools/OutlookSendTool/index.js.map +1 -0
- package/dist/ui/tools/PauseDelegationTool/index.js +35 -0
- package/dist/ui/tools/PauseDelegationTool/index.js.map +1 -0
- package/dist/ui/tools/ProbeTool/index.js +121 -0
- package/dist/ui/tools/ProbeTool/index.js.map +1 -0
- package/dist/ui/tools/ProcessTool/index.js +66 -0
- package/dist/ui/tools/ProcessTool/index.js.map +1 -0
- package/dist/ui/tools/QuestListTool/index.js +46 -0
- package/dist/ui/tools/QuestListTool/index.js.map +1 -0
- package/dist/ui/tools/QuestReportTool/index.js +49 -0
- package/dist/ui/tools/QuestReportTool/index.js.map +1 -0
- package/dist/ui/tools/QuestUpdateTool/index.js +87 -0
- package/dist/ui/tools/QuestUpdateTool/index.js.map +1 -0
- package/dist/ui/tools/QuipCommentTool/index.js +69 -0
- package/dist/ui/tools/QuipCommentTool/index.js.map +1 -0
- package/dist/ui/tools/QuipReadTool/index.js +71 -0
- package/dist/ui/tools/QuipReadTool/index.js.map +1 -0
- package/dist/ui/tools/RestArionTool/index.js +32 -0
- package/dist/ui/tools/RestArionTool/index.js.map +1 -0
- package/dist/ui/tools/RestartTool/index.js +35 -0
- package/dist/ui/tools/RestartTool/index.js.map +1 -0
- package/dist/ui/tools/ResumeDelegationTool/index.js +35 -0
- package/dist/ui/tools/ResumeDelegationTool/index.js.map +1 -0
- package/dist/ui/tools/RetireArionTool/index.js +32 -0
- package/dist/ui/tools/RetireArionTool/index.js.map +1 -0
- package/dist/ui/tools/RgTool/index.js +73 -0
- package/dist/ui/tools/RgTool/index.js.map +1 -0
- package/dist/ui/tools/SearchKnowledgeTool/index.js +43 -0
- package/dist/ui/tools/SearchKnowledgeTool/index.js.map +1 -0
- package/dist/ui/tools/SearchMessagesTool/index.js +43 -0
- package/dist/ui/tools/SearchMessagesTool/index.js.map +1 -0
- package/dist/ui/tools/SelfDiagnoseTool/index.js +61 -0
- package/dist/ui/tools/SelfDiagnoseTool/index.js.map +1 -0
- package/dist/ui/tools/SendMessageTool/index.js +45 -0
- package/dist/ui/tools/SendMessageTool/index.js.map +1 -0
- package/dist/ui/tools/SerenaTool/index.js +124 -0
- package/dist/ui/tools/SerenaTool/index.js.map +1 -0
- package/dist/ui/tools/SessionHistoryTool/index.js +52 -0
- package/dist/ui/tools/SessionHistoryTool/index.js.map +1 -0
- package/dist/ui/tools/SgTool/index.js +80 -0
- package/dist/ui/tools/SgTool/index.js.map +1 -0
- package/dist/ui/tools/SlackReactTool/index.js +41 -0
- package/dist/ui/tools/SlackReactTool/index.js.map +1 -0
- package/dist/ui/tools/SlackReadTool/index.js +48 -0
- package/dist/ui/tools/SlackReadTool/index.js.map +1 -0
- package/dist/ui/tools/SlackSendTool/index.js +45 -0
- package/dist/ui/tools/SlackSendTool/index.js.map +1 -0
- package/dist/ui/tools/SpawnWorkerTool/index.js +33 -0
- package/dist/ui/tools/SpawnWorkerTool/index.js.map +1 -0
- package/dist/ui/tools/StickerRequestTool/index.js +19 -0
- package/dist/ui/tools/StickerRequestTool/index.js.map +1 -0
- package/dist/ui/tools/ThinkTool/index.js +17 -0
- package/dist/ui/tools/ThinkTool/index.js.map +1 -0
- package/dist/ui/tools/UgTool/index.js +108 -0
- package/dist/ui/tools/UgTool/index.js.map +1 -0
- package/dist/ui/tools/UseSkillTool/index.js +22 -0
- package/dist/ui/tools/UseSkillTool/index.js.map +1 -0
- package/dist/ui/tools/WakeArionTool/index.js +32 -0
- package/dist/ui/tools/WakeArionTool/index.js.map +1 -0
- package/dist/ui/tools/WebFetchTool/index.js +56 -0
- package/dist/ui/tools/WebFetchTool/index.js.map +1 -0
- package/dist/ui/tools/WebSearchTool/index.js +44 -0
- package/dist/ui/tools/WebSearchTool/index.js.map +1 -0
- package/dist/ui/tools/lsTool/index.js +58 -0
- package/dist/ui/tools/lsTool/index.js.map +1 -0
- package/dist/ui/tools/registry.js +197 -0
- package/dist/ui/tools/registry.js.map +1 -0
- package/dist/ui/tools/tool-renderer.js +11 -0
- package/dist/ui/tools/tool-renderer.js.map +1 -0
- package/dist/ui/tools/truncation.js +35 -0
- package/dist/ui/tools/truncation.js.map +1 -0
- package/dist/ui/types/anthropic.js +4 -0
- package/dist/ui/types/anthropic.js.map +1 -0
- package/dist/ui/types/index.js +2 -0
- package/dist/ui/types/index.js.map +1 -0
- package/dist/ui/types/message.js +3 -0
- package/dist/ui/types/message.js.map +1 -0
- package/dist/ui/types/tool.js +4 -0
- package/dist/ui/types/tool.js.map +1 -0
- package/dist/ui/utils/array.js +4 -0
- package/dist/ui/utils/array.js.map +1 -0
- package/dist/ui/utils/cursor.js +131 -0
- package/dist/ui/utils/cursor.js.map +1 -0
- package/dist/ui/utils/diff.js +120 -0
- package/dist/ui/utils/diff.js.map +1 -0
- package/dist/ui/utils/format.js +42 -0
- package/dist/ui/utils/format.js.map +1 -0
- package/dist/ui/utils/fuzzy.js +59 -0
- package/dist/ui/utils/fuzzy.js.map +1 -0
- package/dist/ui/utils/index.js +11 -0
- package/dist/ui/utils/index.js.map +1 -0
- package/dist/ui/utils/keys.js +8 -0
- package/dist/ui/utils/keys.js.map +1 -0
- package/dist/ui/utils/patch.js +17 -0
- package/dist/ui/utils/patch.js.map +1 -0
- package/dist/ui/utils/risk.js +114 -0
- package/dist/ui/utils/risk.js.map +1 -0
- package/dist/ui/utils/terminal-image.js +70 -0
- package/dist/ui/utils/terminal-image.js.map +1 -0
- package/dist/ui/utils/validation.js +48 -0
- package/dist/ui/utils/validation.js.map +1 -0
- package/dist/ui/verb-pairs.js +248 -0
- package/dist/ui/verb-pairs.js.map +1 -0
- package/dist/ui.js +131 -0
- package/dist/ui.js.map +1 -0
- package/package.json +73 -14
- package/src/entrypoints/command-mode.ts +5 -0
- package/src/entrypoints/daemon.ts +54 -0
- package/src/entrypoints/headless-stdio.ts +27 -0
- package/src/entrypoints/interactive.ts +112 -0
- package/src/main.ts +72 -0
- package/src/runtime/configure-bun-sqlite.ts +3 -0
- package/src/runtime/crash-handlers.ts +128 -0
- package/src/runtime/interactive-invocation.test.ts +42 -0
- package/src/runtime/interactive-invocation.ts +51 -0
- package/src/runtime/internal-mode.test.ts +19 -0
- package/src/runtime/internal-mode.ts +24 -0
- package/src/runtime/launch-spec.test.ts +26 -0
- package/src/runtime/launch-spec.ts +84 -0
- package/src/runtime/owner-lease.ts +52 -0
- package/src/runtime/public-mode.test.ts +18 -0
- package/src/runtime/public-mode.ts +19 -0
- package/src/runtime/run-internal-mode.ts +19 -0
- package/src/runtime/runtime-kind.test.ts +23 -0
- package/src/runtime/runtime-kind.ts +41 -0
- package/src/runtime/spawn-aria.ts +62 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC-backed session history client for the REPL.
|
|
3
|
+
*
|
|
4
|
+
* Bulk writes (appendMessages, replaceMessages, markCompleted) are dispatched
|
|
5
|
+
* to the daemon over the existing LocalControl IPC socket — fire-and-forget,
|
|
6
|
+
* never blocking the event loop. Small writes (completeRun, claimSession,
|
|
7
|
+
* etc.) run locally with a short busy_timeout (100ms via lowContentionMode).
|
|
8
|
+
* Reads are served locally from the same WAL connection (instant).
|
|
9
|
+
*
|
|
10
|
+
* The daemon owns the canonical single-writer connection and serializes all
|
|
11
|
+
* IPC writes. On IPC failure, writes fall back to the local connection.
|
|
12
|
+
*/
|
|
13
|
+
import { log } from "@aria-cli/types";
|
|
14
|
+
import { clearStallPhase, setStallPhase } from "../event-loop-watchdog.js";
|
|
15
|
+
/**
|
|
16
|
+
* Fire-and-forget IPC write. Logs on failure, never throws.
|
|
17
|
+
* Falls back to a local sync write if provided.
|
|
18
|
+
*/
|
|
19
|
+
/** Errors that are expected during normal teardown and should not be logged. */
|
|
20
|
+
function isTeardownError(err) {
|
|
21
|
+
if (!(err instanceof Error))
|
|
22
|
+
return false;
|
|
23
|
+
const msg = err.message;
|
|
24
|
+
return msg.includes("has been released") || msg.includes("aborted");
|
|
25
|
+
}
|
|
26
|
+
function fireAndForget(label, ipcCall, fallback) {
|
|
27
|
+
if (!ipcCall) {
|
|
28
|
+
fallback?.();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
ipcCall.catch((err) => {
|
|
32
|
+
// Silently fall back during normal teardown (client released / aborted).
|
|
33
|
+
if (!isTeardownError(err)) {
|
|
34
|
+
log.warn(`[SessionHistoryClient] ${label} IPC failed:`, err?.message ?? err);
|
|
35
|
+
}
|
|
36
|
+
if (fallback) {
|
|
37
|
+
try {
|
|
38
|
+
fallback();
|
|
39
|
+
}
|
|
40
|
+
catch (localErr) {
|
|
41
|
+
log.warn(`[SessionHistoryClient] ${label} local fallback also failed:`, localErr?.message ?? localErr);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export class SessionHistoryClient {
|
|
47
|
+
readDb;
|
|
48
|
+
ipc;
|
|
49
|
+
constructor(
|
|
50
|
+
/** Local SessionHistory for reads + local fallback writes. */
|
|
51
|
+
readDb,
|
|
52
|
+
/** IPC handle to the daemon's localControl API. */
|
|
53
|
+
ipc) {
|
|
54
|
+
this.readDb = readDb;
|
|
55
|
+
this.ipc = ipc;
|
|
56
|
+
// The daemon owns the main writer. This local connection only does tiny
|
|
57
|
+
// writes (createSession, claimSession) so reduce busy_timeout from 5s to
|
|
58
|
+
// 100ms to avoid blocking the event loop.
|
|
59
|
+
readDb.enableLowContentionMode();
|
|
60
|
+
}
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Reads — local, instant, zero contention. Proxy every read method so the
|
|
63
|
+
// client is a full drop-in replacement for SessionHistory.
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
withPhase(label, fn) {
|
|
66
|
+
setStallPhase(label);
|
|
67
|
+
try {
|
|
68
|
+
return fn();
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
clearStallPhase();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
listSessions(...args) {
|
|
75
|
+
return this.withPhase("session-history:listSessions", () => this.readDb.listSessions(...args));
|
|
76
|
+
}
|
|
77
|
+
loadSessionMessages(...args) {
|
|
78
|
+
return this.withPhase("session-history:loadSessionMessages", () => this.readDb.loadSessionMessages(...args));
|
|
79
|
+
}
|
|
80
|
+
loadSession(...args) {
|
|
81
|
+
return this.withPhase("session-history:loadSession", () => this.readDb.loadSession(...args));
|
|
82
|
+
}
|
|
83
|
+
searchSessionsFts(...args) {
|
|
84
|
+
return this.withPhase("session-history:searchSessionsFts", () => this.readDb.searchSessionsFts(...args));
|
|
85
|
+
}
|
|
86
|
+
searchSessionSummaries(...args) {
|
|
87
|
+
return this.withPhase("session-history:searchSessionSummaries", () => this.readDb.searchSessionSummaries(...args));
|
|
88
|
+
}
|
|
89
|
+
findSessionByPrefix(...args) {
|
|
90
|
+
return this.readDb.findSessionByPrefix(...args);
|
|
91
|
+
}
|
|
92
|
+
getSessionRuntimeState(...args) {
|
|
93
|
+
return this.readDb.getSessionRuntimeState(...args);
|
|
94
|
+
}
|
|
95
|
+
getInteraction(...args) {
|
|
96
|
+
return this.readDb.getInteraction(...args);
|
|
97
|
+
}
|
|
98
|
+
getIncompleteSessions(...args) {
|
|
99
|
+
return this.readDb.getIncompleteSessions(...args);
|
|
100
|
+
}
|
|
101
|
+
getInputHistory(...args) {
|
|
102
|
+
return this.withPhase("session-history:getInputHistory", () => this.readDb.getInputHistory(...args));
|
|
103
|
+
}
|
|
104
|
+
addInputHistory(...args) {
|
|
105
|
+
return this.withPhase("session-history:addInputHistory", () => this.readDb.addInputHistory(...args));
|
|
106
|
+
}
|
|
107
|
+
getSessionCount(...args) {
|
|
108
|
+
return this.readDb.getSessionCount(...args);
|
|
109
|
+
}
|
|
110
|
+
markStaleSessionsCompleted(...args) {
|
|
111
|
+
return this.withPhase("session-history:markStaleSessionsCompleted", () => this.readDb.markStaleSessionsCompleted(...args));
|
|
112
|
+
}
|
|
113
|
+
getSession(...args) {
|
|
114
|
+
return this.readDb.getSession(...args);
|
|
115
|
+
}
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// createSession — local write so it's immediately readable
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
createSession(...args) {
|
|
120
|
+
return this.readDb.createSession(...args);
|
|
121
|
+
}
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
// Writes — fire-and-forget via IPC to daemon
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
persistMessagesNonBlocking(sessionId, msgs) {
|
|
126
|
+
if (msgs.length === 0)
|
|
127
|
+
return;
|
|
128
|
+
// Mark session as incremental BEFORE the IPC call so that the orchestrator's
|
|
129
|
+
// deferred replaceConversationMessages sees it and short-circuits (no-op).
|
|
130
|
+
this.readDb.markSessionIncremental(sessionId);
|
|
131
|
+
fireAndForget("appendSessionMessages", this.ipc.appendSessionMessages?.(sessionId, msgs), () => this.readDb.addConversationMessages(sessionId, msgs));
|
|
132
|
+
}
|
|
133
|
+
/** Batched sync write — used by addConversationMessages callers. Routes to IPC. */
|
|
134
|
+
addConversationMessages(sessionId, msgs) {
|
|
135
|
+
this.persistMessagesNonBlocking(sessionId, msgs);
|
|
136
|
+
}
|
|
137
|
+
/** Single message write — routes to batched path. */
|
|
138
|
+
addConversationMessage(sessionId, msg) {
|
|
139
|
+
this.persistMessagesNonBlocking(sessionId, [msg]);
|
|
140
|
+
}
|
|
141
|
+
markCompleted(sessionId) {
|
|
142
|
+
fireAndForget("markSessionCompleted", this.ipc.markSessionCompleted?.(sessionId), () => this.readDb.markCompleted(sessionId));
|
|
143
|
+
}
|
|
144
|
+
replaceConversationMessages(sessionId, msgs) {
|
|
145
|
+
fireAndForget("replaceSessionMessages", this.ipc.replaceSessionMessages?.(sessionId, msgs), () => this.readDb.replaceConversationMessages(sessionId, msgs));
|
|
146
|
+
}
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// Small writes — local only (fast single-row ops, not worth IPC overhead).
|
|
149
|
+
// With lowContentionMode (100ms busy_timeout), these never block the event
|
|
150
|
+
// loop meaningfully. The daemon sees them through WAL visibility.
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
completeRun(...args) {
|
|
153
|
+
return this.readDb.completeRun(...args);
|
|
154
|
+
}
|
|
155
|
+
claimSessionForMutation(...args) {
|
|
156
|
+
return this.readDb.claimSessionForMutation(...args);
|
|
157
|
+
}
|
|
158
|
+
releaseSessionClaim(...args) {
|
|
159
|
+
return this.readDb.releaseSessionClaim(...args);
|
|
160
|
+
}
|
|
161
|
+
recordPausedRun(...args) {
|
|
162
|
+
return this.readDb.recordPausedRun(...args);
|
|
163
|
+
}
|
|
164
|
+
deleteSession(...args) {
|
|
165
|
+
return this.readDb.deleteSession(...args);
|
|
166
|
+
}
|
|
167
|
+
forkSession(...args) {
|
|
168
|
+
return this.readDb.forkSession(...args);
|
|
169
|
+
}
|
|
170
|
+
cancelInteraction(...args) {
|
|
171
|
+
return this.readDb.cancelInteraction(...args);
|
|
172
|
+
}
|
|
173
|
+
setSessionTitle(...args) {
|
|
174
|
+
return this.readDb.setSessionTitle(...args);
|
|
175
|
+
}
|
|
176
|
+
recordInteractionResponse(...args) {
|
|
177
|
+
return this.readDb.recordInteractionResponse(...args);
|
|
178
|
+
}
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
// Passthrough
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
close() {
|
|
183
|
+
this.readDb.close();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=SessionHistoryClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionHistoryClient.js","sourceRoot":"","sources":["../../src/history/SessionHistoryClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAS3E;;;GAGG;AACH,gFAAgF;AAChF,SAAS,eAAe,CAAC,GAAY;IACnC,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO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specific UI bridge.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all core types and functions from @aria-cli/aria,
|
|
5
|
+
* and provides the UI-specific bridge function for rendering.
|
|
6
|
+
*/
|
|
7
|
+
// Re-export everything from the aria package
|
|
8
|
+
export * from "@aria-cli/aria/history/conversation-message.js";
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// UI Bridge - converts ConversationMessage[] to HistoryMessage[] for rendering
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/**
|
|
13
|
+
* Convert ConversationMessage[] to the legacy HistoryMessage[] format
|
|
14
|
+
* used by the existing CLI UI components.
|
|
15
|
+
*
|
|
16
|
+
* This bridges the new unified message format to the old rendering pipeline.
|
|
17
|
+
*/
|
|
18
|
+
export function conversationMessageToHistoryMessages(messages) {
|
|
19
|
+
const items = [];
|
|
20
|
+
for (const msg of messages) {
|
|
21
|
+
for (const block of msg.content) {
|
|
22
|
+
switch (block.type) {
|
|
23
|
+
case "thinking":
|
|
24
|
+
items.push({
|
|
25
|
+
id: `thinking-${crypto.randomUUID()}`,
|
|
26
|
+
role: "thinking_history",
|
|
27
|
+
content: block.content,
|
|
28
|
+
wordCount: block.wordCount,
|
|
29
|
+
durationSeconds: block.durationMs != null ? block.durationMs / 1000 : undefined,
|
|
30
|
+
verb: block.verb,
|
|
31
|
+
arionName: msg.arion?.name,
|
|
32
|
+
arionEmoji: msg.arion?.emoji,
|
|
33
|
+
arionColor: msg.arion?.color,
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case "tool_use":
|
|
37
|
+
items.push({
|
|
38
|
+
id: `tool-${crypto.randomUUID()}`,
|
|
39
|
+
role: "tool_history",
|
|
40
|
+
tool: {
|
|
41
|
+
id: block.id,
|
|
42
|
+
name: block.name,
|
|
43
|
+
args: block.arguments,
|
|
44
|
+
status: "pending",
|
|
45
|
+
startTime: undefined,
|
|
46
|
+
endTime: undefined,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
case "tool_result": {
|
|
51
|
+
// Find matching tool_history across ALL messages and update its result/status
|
|
52
|
+
let toolItem;
|
|
53
|
+
for (let idx = items.length - 1; idx >= 0; idx--) {
|
|
54
|
+
const item = items[idx];
|
|
55
|
+
if (item.role === "tool_history" &&
|
|
56
|
+
item.tool.id === block.toolUseId) {
|
|
57
|
+
toolItem = item;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (toolItem) {
|
|
62
|
+
toolItem.tool.status = block.status === "error" ? "error" : "complete";
|
|
63
|
+
if (block.status === "error") {
|
|
64
|
+
toolItem.tool.error = block.content;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
toolItem.tool.result = block.content;
|
|
68
|
+
}
|
|
69
|
+
if (block.resultData !== undefined) {
|
|
70
|
+
toolItem.tool.resultData = block.resultData;
|
|
71
|
+
}
|
|
72
|
+
if (block.durationMs !== undefined) {
|
|
73
|
+
toolItem.tool.durationMs = block.durationMs;
|
|
74
|
+
}
|
|
75
|
+
if (block.usage !== undefined) {
|
|
76
|
+
toolItem.tool.usage = block.usage;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case "handoff":
|
|
82
|
+
items.push({
|
|
83
|
+
id: `handoff-${crypto.randomUUID()}`,
|
|
84
|
+
role: "handoff_history",
|
|
85
|
+
target: block.target,
|
|
86
|
+
direction: block.direction,
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
case "error":
|
|
90
|
+
items.push({
|
|
91
|
+
id: `error-${crypto.randomUUID()}`,
|
|
92
|
+
role: "error",
|
|
93
|
+
content: block.content,
|
|
94
|
+
suggestion: block.suggestion,
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
97
|
+
case "text":
|
|
98
|
+
items.push({
|
|
99
|
+
id: `msg-${crypto.randomUUID()}`,
|
|
100
|
+
role: msg.role,
|
|
101
|
+
content: block.text,
|
|
102
|
+
arion: msg.arion
|
|
103
|
+
? { name: msg.arion.name, emoji: msg.arion.emoji, color: msg.arion.color }
|
|
104
|
+
: undefined,
|
|
105
|
+
});
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return items;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=conversation-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-message.js","sourceRoot":"","sources":["../../src/history/conversation-message.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,6CAA6C;AAC7C,cAAc,gDAAgD,CAAC;AAY/D,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,QAA+B;IAE/B,MAAM,KAAK,GAAqB,EAAE,CAAC;IAEnC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnB,KAAK,UAAU;oBACb,KAAK,CAAC,IAAI,CAAC;wBACT,EAAE,EAAE,YAAY,MAAM,CAAC,UAAU,EAAE,EAAE;wBACrC,IAAI,EAAE,kBAAkB;wBACxB,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;wBAC1B,eAAe,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS;wBAC/E,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI;wBAC1B,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK;wBAC5B,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK;qBAC7B,CAAC,CAAC;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AAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE;4BAC1E,CAAC,CAAC,SAAS;qBACd,CAAC,CAAC;oBACH,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// packages/cli/src/history/index.ts
|
|
2
|
+
export { SessionHistory } from "./SessionHistory.js";
|
|
3
|
+
export { SessionHistoryClient } from "./SessionHistoryClient.js";
|
|
4
|
+
export { repairToolCallPairing } from "./repair-tool-pairing.js";
|
|
5
|
+
export { ContentBlockSchema, ArionRefSchema, ConversationMessageSchema, createUserMessage, createSystemMessage, createErrorMessage, createIncomingMessagePair, toModelMessages, fromModelMessages, fromV1Columns, conversationMessageToHistoryMessages, extractTextContent, extractToolCalls, extractThinking, extractToolCallId, } from "./conversation-message.js";
|
|
6
|
+
export { TurnAccumulator } from "./turn-accumulator.js";
|
|
7
|
+
export { replaySessionFromJsonl, findJsonlForSession, mergeWithJsonlRecovery, } from "./jsonl-replay.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAejE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,oCAAoC,EACpC,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSONL Replay — reconstructs ConversationMessage[] from a JSONL event log.
|
|
3
|
+
*
|
|
4
|
+
* The JsonlEventLogger writes every RunEvent to disk as newline-delimited JSON.
|
|
5
|
+
* This module reads those logs back and feeds them through a TurnAccumulator
|
|
6
|
+
* to reconstruct the conversation messages for crash recovery and session resume.
|
|
7
|
+
*
|
|
8
|
+
* Each JSONL line has the shape: { ts: string, event: RunEvent }
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
11
|
+
import { TurnAccumulator } from "./turn-accumulator.js";
|
|
12
|
+
import { createUserMessage } from "./conversation-message.js";
|
|
13
|
+
/**
|
|
14
|
+
* Replay a JSONL event log file and reconstruct ConversationMessage[].
|
|
15
|
+
*
|
|
16
|
+
* Feeds each RunEvent through a fresh TurnAccumulator. On turn boundaries
|
|
17
|
+
* (turn_complete events), the accumulator flushes and messages are collected.
|
|
18
|
+
* Any remaining pending content is flushed at the end (handles mid-turn crashes).
|
|
19
|
+
*
|
|
20
|
+
* Returns user + assistant + tool messages. User messages are captured via
|
|
21
|
+
* synthetic `user_message` events logged before each LLM call.
|
|
22
|
+
*/
|
|
23
|
+
export function replaySessionFromJsonl(jsonlPath) {
|
|
24
|
+
if (!existsSync(jsonlPath))
|
|
25
|
+
return [];
|
|
26
|
+
const raw = readFileSync(jsonlPath, "utf-8");
|
|
27
|
+
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
28
|
+
const accumulator = new TurnAccumulator();
|
|
29
|
+
const allMessages = [];
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
let entry;
|
|
32
|
+
try {
|
|
33
|
+
entry = JSON.parse(line);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Malformed line (truncated on crash) — skip
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!entry.event || typeof entry.event.type !== "string")
|
|
40
|
+
continue;
|
|
41
|
+
// User messages are logged as synthetic events — not RunEvents.
|
|
42
|
+
// Convert them directly to ConversationMessage without the accumulator.
|
|
43
|
+
if (entry.event.type === "user_message") {
|
|
44
|
+
// Flush any pending assistant content before the user message
|
|
45
|
+
if (accumulator.hasPendingContent()) {
|
|
46
|
+
allMessages.push(...accumulator.flush());
|
|
47
|
+
}
|
|
48
|
+
const content = entry.event.content ?? "";
|
|
49
|
+
const id = entry.event.id;
|
|
50
|
+
const userMsg = createUserMessage(content);
|
|
51
|
+
if (id)
|
|
52
|
+
userMsg.id = id;
|
|
53
|
+
allMessages.push(userMsg);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// Feed the RunEvent through the accumulator
|
|
57
|
+
const signal = accumulator.ingest(entry.event);
|
|
58
|
+
if (signal === "flush") {
|
|
59
|
+
const turnMessages = accumulator.flush();
|
|
60
|
+
allMessages.push(...turnMessages);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Flush any remaining pending content (mid-turn crash recovery)
|
|
64
|
+
if (accumulator.hasPendingContent()) {
|
|
65
|
+
const partial = accumulator.flush();
|
|
66
|
+
allMessages.push(...partial);
|
|
67
|
+
}
|
|
68
|
+
return allMessages;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Find the JSONL log file for a session within an Arion's log directory.
|
|
72
|
+
* Returns the file path if found, null otherwise.
|
|
73
|
+
*
|
|
74
|
+
* JSONL files are named {sessionId}.jsonl under the Arion's logs/ directory.
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Extract a content fingerprint from a ConversationMessage for identity-based dedup.
|
|
78
|
+
*
|
|
79
|
+
* Uses API-assigned identifiers (tool_use IDs, tool_result references) when available —
|
|
80
|
+
* these are stable across replays. Falls back to role+content text for messages without
|
|
81
|
+
* tool blocks (user text, assistant text), since their UUIDs are regenerated on replay.
|
|
82
|
+
*/
|
|
83
|
+
function extractContentFingerprint(msg) {
|
|
84
|
+
for (const block of msg.content) {
|
|
85
|
+
if (block.type === "tool_use" && block.id) {
|
|
86
|
+
return `tool_use:${block.id}`;
|
|
87
|
+
}
|
|
88
|
+
if (block.type === "tool_result" && block.toolUseId) {
|
|
89
|
+
return `tool_result:${block.toolUseId}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Text-only messages: fingerprint by role + text content (stable across replays)
|
|
93
|
+
const text = msg.content
|
|
94
|
+
.filter((b) => b.type === "text")
|
|
95
|
+
.map((b) => b.text)
|
|
96
|
+
.join("");
|
|
97
|
+
return `${msg.role}:${text}`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Merge SQLite messages with JSONL-replayed messages for crash recovery.
|
|
101
|
+
*
|
|
102
|
+
* Strategy: SQLite is the primary store; JSONL fills gaps from crash recovery.
|
|
103
|
+
* Uses content-based identity (tool_use IDs, tool_result references) to detect
|
|
104
|
+
* which JSONL messages are truly missing from SQLite, avoiding the position-based
|
|
105
|
+
* counting that breaks when JSONL accumulates events across multiple session runs
|
|
106
|
+
* with different message coalescing boundaries.
|
|
107
|
+
*
|
|
108
|
+
* Returns { messages, backfillMessages } where backfillMessages are the
|
|
109
|
+
* messages JSONL had that SQLite was missing (for SQLite index backfill).
|
|
110
|
+
*/
|
|
111
|
+
export function mergeWithJsonlRecovery(sqliteMessages, jsonlPath) {
|
|
112
|
+
if (!jsonlPath) {
|
|
113
|
+
return { messages: sqliteMessages, backfillMessages: [] };
|
|
114
|
+
}
|
|
115
|
+
let jsonlMessages;
|
|
116
|
+
try {
|
|
117
|
+
jsonlMessages = replaySessionFromJsonl(jsonlPath);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return { messages: sqliteMessages, backfillMessages: [] };
|
|
121
|
+
}
|
|
122
|
+
if (jsonlMessages.length === 0) {
|
|
123
|
+
return { messages: sqliteMessages, backfillMessages: [] };
|
|
124
|
+
}
|
|
125
|
+
// If SQLite already has at least as many messages, it's complete.
|
|
126
|
+
if (sqliteMessages.length >= jsonlMessages.length) {
|
|
127
|
+
return { messages: sqliteMessages, backfillMessages: [] };
|
|
128
|
+
}
|
|
129
|
+
// JSONL has more messages than SQLite — crash recovery needed.
|
|
130
|
+
// Use content-based identity to find which JSONL messages are truly missing.
|
|
131
|
+
// Tool_use IDs and tool_result references are API-assigned and stable across replays.
|
|
132
|
+
const sqliteFingerprints = new Set(sqliteMessages.map(extractContentFingerprint));
|
|
133
|
+
const backfillMessages = [];
|
|
134
|
+
for (const msg of jsonlMessages) {
|
|
135
|
+
const fp = extractContentFingerprint(msg);
|
|
136
|
+
if (!sqliteFingerprints.has(fp)) {
|
|
137
|
+
backfillMessages.push(msg);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Combine: SQLite messages (primary, in persisted order) + truly new JSONL messages
|
|
141
|
+
const messages = [...sqliteMessages, ...backfillMessages];
|
|
142
|
+
return { messages, backfillMessages };
|
|
143
|
+
}
|
|
144
|
+
export function findJsonlForSession(ariaDir, arionName, sessionId) {
|
|
145
|
+
const perArionPath = `${ariaDir}/arions/${arionName}/logs/${sessionId}.jsonl`;
|
|
146
|
+
if (existsSync(perArionPath))
|
|
147
|
+
return perArionPath;
|
|
148
|
+
// Fallback: check legacy global path
|
|
149
|
+
const globalPath = `${ariaDir}/logs/${sessionId}.jsonl`;
|
|
150
|
+
if (existsSync(globalPath))
|
|
151
|
+
return globalPath;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=jsonl-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl-replay.js","sourceRoot":"","sources":["../../src/history/jsonl-replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC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CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,MAAM,QAAQ,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAE1D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,SAAiB,EACjB,SAAiB;IAEjB,MAAM,YAAY,GAAG,GAAG,OAAO,WAAW,SAAS,SAAS,SAAS,QAAQ,CAAC;IAC9E,IAAI,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,YAAY,CAAC;IAElD,qCAAqC;IACrC,MAAM,UAAU,GAAG,GAAG,OAAO,SAAS,SAAS,QAAQ,CAAC;IACxD,IAAI,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IAE9C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function hasMeaningfulAssistantContent(content) {
|
|
2
|
+
return typeof content !== "string" || content.trim().length > 0;
|
|
3
|
+
}
|
|
4
|
+
function stripToolCalls(msg) {
|
|
5
|
+
const { toolCalls, ...rest } = msg;
|
|
6
|
+
return rest;
|
|
7
|
+
}
|
|
8
|
+
function hasToolResultLater(messages, startIdx, toolCallId) {
|
|
9
|
+
for (let i = startIdx; i < messages.length; i++) {
|
|
10
|
+
const msg = messages[i];
|
|
11
|
+
if (msg.role === "tool" && msg.toolCallId === toolCallId) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Repair tool call/result pairing in a message sequence.
|
|
19
|
+
*
|
|
20
|
+
* Ensures:
|
|
21
|
+
* 1. Every tool result has a matching tool call (removes orphans)
|
|
22
|
+
* 2. Every tool call has a matching result (adds synthetic "interrupted" result)
|
|
23
|
+
* 3. Synthetic results are placed AFTER real results for the same assistant (R2-C3)
|
|
24
|
+
* 4. Tool messages without toolCallId are removed (R2 F-10)
|
|
25
|
+
* 5. thoughtSignature is preserved on tool calls (Gemini requirement)
|
|
26
|
+
*
|
|
27
|
+
* Inspired by Codex's normalize_history() and OpenClaw's repairToolUseResultPairing().
|
|
28
|
+
*/
|
|
29
|
+
export function repairToolCallPairing(messages) {
|
|
30
|
+
const result = [];
|
|
31
|
+
for (let i = 0; i < messages.length; i++) {
|
|
32
|
+
const msg = messages[i];
|
|
33
|
+
if (msg.role === "assistant" && msg.toolCalls?.length) {
|
|
34
|
+
const toolCallIds = new Set(msg.toolCalls.map((tc) => tc.id));
|
|
35
|
+
const immediateResultIds = new Set();
|
|
36
|
+
const immediateToolResults = [];
|
|
37
|
+
let cursor = i + 1;
|
|
38
|
+
while (cursor < messages.length && messages[cursor].role === "tool") {
|
|
39
|
+
const toolMsg = messages[cursor];
|
|
40
|
+
if (toolMsg.toolCallId &&
|
|
41
|
+
toolCallIds.has(toolMsg.toolCallId) &&
|
|
42
|
+
!immediateResultIds.has(toolMsg.toolCallId)) {
|
|
43
|
+
immediateResultIds.add(toolMsg.toolCallId);
|
|
44
|
+
immediateToolResults.push(toolMsg);
|
|
45
|
+
}
|
|
46
|
+
cursor++;
|
|
47
|
+
}
|
|
48
|
+
const keptToolCalls = msg.toolCalls.filter((tc) => {
|
|
49
|
+
if (immediateResultIds.has(tc.id)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return !hasToolResultLater(messages, cursor, tc.id);
|
|
53
|
+
});
|
|
54
|
+
const syntheticCalls = keptToolCalls.filter((tc) => !immediateResultIds.has(tc.id));
|
|
55
|
+
if (keptToolCalls.length === msg.toolCalls.length) {
|
|
56
|
+
result.push(msg);
|
|
57
|
+
}
|
|
58
|
+
else if (keptToolCalls.length > 0) {
|
|
59
|
+
result.push({ ...msg, toolCalls: keptToolCalls });
|
|
60
|
+
}
|
|
61
|
+
else if (hasMeaningfulAssistantContent(msg.content)) {
|
|
62
|
+
result.push(stripToolCalls(msg));
|
|
63
|
+
}
|
|
64
|
+
result.push(...immediateToolResults);
|
|
65
|
+
for (const tc of syntheticCalls) {
|
|
66
|
+
result.push({
|
|
67
|
+
role: "tool",
|
|
68
|
+
content: `[Tool execution interrupted — no result for ${tc.name}]`,
|
|
69
|
+
toolCallId: tc.id,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
i = cursor - 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Tool messages are only valid when consumed as part of the immediate
|
|
76
|
+
// assistant -> tool_result boundary handled above.
|
|
77
|
+
if (msg.role === "tool") {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
result.push(msg);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=repair-tool-pairing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-tool-pairing.js","sourceRoot":"","sources":["../../src/history/repair-tool-pairing.ts"],"names":[],"mappings":"AAEA,SAAS,6BAA6B,CAAC,OAA2B;IAChE,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,cAAc,CAAC,GAAY;IAClC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IACnC,OAAO,IAAe,CAAC;AACzB,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAmB,EAAE,QAAgB,EAAE,UAAkB;IACnF,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;QAC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CAAC;YAED,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;YACf,SAAS;QACX,CAAC;QAED,sEAAsE;QACtE,mDAAmD;QACnD,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge between SessionHistory's injectable stall-phase callbacks and
|
|
3
|
+
* the CLI's event-loop watchdog.
|
|
4
|
+
*/
|
|
5
|
+
import { setStallPhase, clearStallPhase, getStallPhase } from "../event-loop-watchdog.js";
|
|
6
|
+
export const cliStallPhase = {
|
|
7
|
+
get: getStallPhase,
|
|
8
|
+
set: setStallPhase,
|
|
9
|
+
clear: clearStallPhase,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=stall-phase-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stall-phase-bridge.js","sourceRoot":"","sources":["../../src/history/stall-phase-bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1F,MAAM,CAAC,MAAM,aAAa,GAAqD;IAC7E,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE,eAAe;CACvB,CAAC"}
|