@lotagate/cli 0.1.21 → 0.1.22
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/application/agent/agent-history.d.ts +3 -0
- package/dist/application/agent/agent-history.js +81 -0
- package/dist/application/agent/agent-input-context.d.ts +9 -0
- package/dist/application/agent/agent-input-context.js +12 -0
- package/dist/application/agent/agent-limit.d.ts +3 -0
- package/dist/application/agent/agent-limit.js +12 -0
- package/dist/application/agent/agent-run-tracker.d.ts +30 -0
- package/dist/application/agent/agent-run-tracker.js +68 -0
- package/dist/application/agent/agent-session-store.d.ts +19 -0
- package/dist/application/agent/agent-session-store.js +74 -0
- package/dist/application/agent/capability-profile.d.ts +37 -0
- package/dist/application/agent/capability-profile.js +13 -0
- package/dist/application/agent/cli-agent-execution-service.d.ts +81 -0
- package/dist/application/agent/cli-agent-execution-service.js +279 -0
- package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
- package/dist/application/agent/context-compaction-persistence.js +27 -0
- package/dist/application/agent/context-compaction.d.ts +20 -0
- package/dist/application/agent/context-compaction.js +114 -0
- package/dist/application/agent/prompt-data-safety.d.ts +14 -0
- package/dist/application/agent/prompt-data-safety.js +38 -0
- package/dist/application/agent/safe-system-prompt.d.ts +3 -0
- package/dist/application/agent/safe-system-prompt.js +19 -0
- package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
- package/dist/application/agent/scoped-tool-executor.js +32 -0
- package/dist/application/agent/system-prompt-builder.d.ts +14 -0
- package/dist/application/agent/system-prompt-builder.js +199 -0
- package/dist/application/agent/tool-catalog.d.ts +14 -0
- package/dist/application/agent/tool-catalog.js +30 -0
- package/dist/application/agent/tool-display.d.ts +6 -0
- package/dist/application/agent/tool-display.js +59 -0
- package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
- package/dist/application/agent/tool-hook-lifecycle.js +85 -0
- package/dist/application/auth/authentication-service.d.ts +20 -0
- package/dist/application/auth/authentication-service.js +44 -0
- package/dist/application/chat/chat-service.d.ts +12 -0
- package/dist/application/chat/chat-service.js +19 -0
- package/dist/application/chat/pending-attachment-store.d.ts +12 -0
- package/dist/application/chat/pending-attachment-store.js +28 -0
- package/dist/application/commands/application-command-executor.d.ts +20 -0
- package/dist/application/commands/application-command-executor.js +66 -0
- package/dist/application/commands/cli-args.d.ts +6 -0
- package/dist/application/commands/cli-args.js +43 -0
- package/dist/application/commands/cli-command-services.d.ts +16 -0
- package/dist/application/commands/cli-command-services.js +405 -0
- package/dist/application/commands/command-catalog.d.ts +6 -0
- package/dist/application/commands/command-catalog.js +159 -0
- package/dist/application/commands/command-contract.d.ts +58 -0
- package/dist/application/commands/command-contract.js +1 -0
- package/dist/application/commands/command-hints.d.ts +9 -0
- package/dist/application/commands/command-hints.js +17 -0
- package/dist/application/commands/command-output.d.ts +4 -0
- package/dist/application/commands/command-output.js +1 -0
- package/dist/application/commands/command-parser.d.ts +10 -0
- package/dist/application/commands/command-parser.js +155 -0
- package/dist/application/commands/command-presentation.d.ts +7 -0
- package/dist/application/commands/command-presentation.js +131 -0
- package/dist/application/commands/command-registry.d.ts +11 -0
- package/dist/application/commands/command-registry.js +64 -0
- package/dist/application/commands/command-runtime.d.ts +2 -0
- package/dist/application/commands/command-runtime.js +3 -0
- package/dist/application/commands/goal-command-handlers.d.ts +3 -0
- package/dist/application/commands/goal-command-handlers.js +120 -0
- package/dist/application/commands/media-command-handlers.d.ts +9 -0
- package/dist/application/commands/media-command-handlers.js +307 -0
- package/dist/application/commands/media-command-output.d.ts +11 -0
- package/dist/application/commands/media-command-output.js +8 -0
- package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
- package/dist/application/commands/runtime-command-handlers.js +177 -0
- package/dist/application/commands/stream-output.d.ts +4 -0
- package/dist/application/commands/stream-output.js +10 -0
- package/dist/application/commands/utility-commands.d.ts +6 -0
- package/dist/application/commands/utility-commands.js +81 -0
- package/dist/application/config/execution-config.d.ts +4 -0
- package/dist/application/config/execution-config.js +6 -0
- package/dist/application/extensions/extension-list-contract.d.ts +13 -0
- package/dist/application/extensions/extension-list-contract.js +1 -0
- package/dist/application/extensions/extension-list-formatters.d.ts +31 -0
- package/dist/application/extensions/extension-list-formatters.js +98 -0
- package/dist/application/extensions/extension-list-output.d.ts +3 -0
- package/dist/application/extensions/extension-list-output.js +7 -0
- package/dist/application/extensions/plugin-contribution-registry.d.ts +15 -0
- package/dist/application/extensions/plugin-contribution-registry.js +80 -0
- package/dist/application/extensions/skill-scope-store.d.ts +23 -0
- package/dist/application/extensions/skill-scope-store.js +33 -0
- package/dist/application/formatting/compact-number.d.ts +2 -0
- package/dist/application/formatting/compact-number.js +18 -0
- package/dist/application/formatting/compact-table.d.ts +22 -0
- package/dist/application/formatting/compact-table.js +49 -0
- package/dist/application/media/video-operation-poller.d.ts +5 -0
- package/dist/application/media/video-operation-poller.js +42 -0
- package/dist/application/model/cached-model-catalog.d.ts +13 -0
- package/dist/application/model/cached-model-catalog.js +31 -0
- package/dist/application/model/initial-model-selection.d.ts +10 -0
- package/dist/application/model/initial-model-selection.js +11 -0
- package/dist/application/model/model-catalog-service.d.ts +6 -0
- package/dist/application/model/model-catalog-service.js +13 -0
- package/dist/application/model/model-context-window.d.ts +3 -0
- package/dist/application/model/model-context-window.js +23 -0
- package/dist/application/orchestration/cli-subagent-service.d.ts +70 -0
- package/dist/application/orchestration/cli-subagent-service.js +328 -0
- package/dist/application/orchestration/cli-turn-event-projector.d.ts +12 -0
- package/dist/application/orchestration/cli-turn-event-projector.js +81 -0
- package/dist/application/orchestration/cli-turn-events.d.ts +76 -0
- package/dist/application/orchestration/cli-turn-events.js +39 -0
- package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
- package/dist/application/orchestration/cli-turn-persistence.js +14 -0
- package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
- package/dist/application/orchestration/goal-evaluator.js +88 -0
- package/dist/application/orchestration/goal-input.d.ts +3 -0
- package/dist/application/orchestration/goal-input.js +19 -0
- package/dist/application/orchestration/goal-output.d.ts +2 -0
- package/dist/application/orchestration/goal-output.js +11 -0
- package/dist/application/orchestration/goal-runner.d.ts +22 -0
- package/dist/application/orchestration/goal-runner.js +153 -0
- package/dist/application/orchestration/goal-usage.d.ts +9 -0
- package/dist/application/orchestration/goal-usage.js +19 -0
- package/dist/application/orchestration/headless-agent-turn.d.ts +32 -0
- package/dist/application/orchestration/headless-agent-turn.js +82 -0
- package/dist/application/orchestration/plan-generator.d.ts +7 -0
- package/dist/application/orchestration/plan-generator.js +34 -0
- package/dist/application/orchestration/subagent-coordinator.d.ts +33 -0
- package/dist/application/orchestration/subagent-coordinator.js +28 -0
- package/dist/application/orchestration/subagent-handoff.d.ts +2 -0
- package/dist/application/orchestration/subagent-handoff.js +68 -0
- package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
- package/dist/application/orchestration/subagent-tool-executor.js +93 -0
- package/dist/application/orchestration/task-assessment.d.ts +4 -0
- package/dist/application/orchestration/task-assessment.js +35 -0
- package/dist/application/orchestration/task-graph.d.ts +13 -0
- package/dist/application/orchestration/task-graph.js +56 -0
- package/dist/application/orchestration/task-scheduler.d.ts +18 -0
- package/dist/application/orchestration/task-scheduler.js +88 -0
- package/dist/application/project/project-trust-service.d.ts +13 -0
- package/dist/application/project/project-trust-service.js +74 -0
- package/dist/application/protocol/browser-host-tool-executor.d.ts +41 -0
- package/dist/application/protocol/browser-host-tool-executor.js +88 -0
- package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
- package/dist/application/protocol/desktop-agent-command.js +663 -0
- package/dist/application/protocol/desktop-attachment-store.d.ts +16 -0
- package/dist/application/protocol/desktop-attachment-store.js +82 -0
- package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
- package/dist/application/protocol/desktop-command-catalog.js +19 -0
- package/dist/application/protocol/desktop-command-contract.d.ts +22 -0
- package/dist/application/protocol/desktop-command-contract.js +3 -0
- package/dist/application/protocol/desktop-command-executor.d.ts +16 -0
- package/dist/application/protocol/desktop-command-executor.js +47 -0
- package/dist/application/protocol/desktop-command-output.d.ts +15 -0
- package/dist/application/protocol/desktop-command-output.js +24 -0
- package/dist/application/protocol/desktop-execution-policy.d.ts +17 -0
- package/dist/application/protocol/desktop-execution-policy.js +49 -0
- package/dist/application/protocol/desktop-host-tool-executor.d.ts +57 -0
- package/dist/application/protocol/desktop-host-tool-executor.js +53 -0
- package/dist/application/protocol/desktop-orchestration-events.d.ts +5 -0
- package/dist/application/protocol/desktop-orchestration-events.js +37 -0
- package/dist/application/protocol/json-line-writer.d.ts +9 -0
- package/dist/application/protocol/json-line-writer.js +19 -0
- package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
- package/dist/application/protocol/jsonl-agent-command.js +97 -0
- package/dist/application/protocol/jsonl-protocol.d.ts +52 -0
- package/dist/application/protocol/jsonl-protocol.js +170 -0
- package/dist/application/security/desktop-tool-scope-policy.d.ts +3 -0
- package/dist/application/security/desktop-tool-scope-policy.js +52 -0
- package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
- package/dist/application/security/tool-action-risk-analyzer.js +64 -0
- package/dist/application/security/tool-approval-service.d.ts +35 -0
- package/dist/application/security/tool-approval-service.js +97 -0
- package/dist/application/security/tool-risk-classifier.d.ts +11 -0
- package/dist/application/security/tool-risk-classifier.js +65 -0
- package/dist/application/security/workspace-permission-policy.d.ts +10 -0
- package/dist/application/security/workspace-permission-policy.js +50 -0
- package/dist/application/session/project-session-access.d.ts +8 -0
- package/dist/application/session/project-session-access.js +19 -0
- package/dist/application/session/session-compaction-service.d.ts +10 -0
- package/dist/application/session/session-compaction-service.js +43 -0
- package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
- package/dist/application/session/session-turn-lifecycle.js +31 -0
- package/dist/application/workspace/workspace-file-index.d.ts +15 -0
- package/dist/application/workspace/workspace-file-index.js +60 -0
- package/dist/application/workspace/workspace-file-reference-resolver.d.ts +14 -0
- package/dist/application/workspace/workspace-file-reference-resolver.js +123 -0
- package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
- package/dist/application/workspace/workspace-instruction-loader.js +55 -0
- package/dist/bootstrap/composition-root.d.ts +6 -0
- package/dist/bootstrap/composition-root.js +4 -0
- package/dist/bootstrap/global-cli-options.d.ts +6 -0
- package/dist/bootstrap/global-cli-options.js +29 -0
- package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
- package/dist/bootstrap/native-devtools-stub.js +10 -0
- package/dist/bootstrap/native-entry.d.ts +1 -0
- package/dist/bootstrap/native-entry.js +6 -0
- package/dist/bootstrap/native-tiktoken.d.ts +4 -0
- package/dist/bootstrap/native-tiktoken.js +5 -0
- package/dist/bootstrap/runtime-factory.d.ts +35 -0
- package/dist/bootstrap/runtime-factory.js +44 -0
- package/dist/bootstrap/shutdown-manager.d.ts +10 -0
- package/dist/bootstrap/shutdown-manager.js +14 -0
- package/dist/bootstrap/startup-sequence.d.ts +5 -0
- package/dist/bootstrap/startup-sequence.js +10 -0
- package/dist/domain/auth/auth-profile.d.ts +14 -0
- package/dist/domain/auth/auth-profile.js +39 -0
- package/dist/domain/config/config-schema.d.ts +17 -0
- package/dist/domain/config/config-schema.js +105 -0
- package/dist/domain/errors/cli-command-hint.d.ts +5 -0
- package/dist/domain/errors/cli-command-hint.js +1 -0
- package/dist/domain/errors/cli-error.d.ts +35 -0
- package/dist/domain/errors/cli-error.js +129 -0
- package/dist/domain/errors/error-codes.d.ts +46 -0
- package/dist/domain/errors/error-codes.js +45 -0
- package/dist/domain/extensions/extension-scope.d.ts +3 -0
- package/dist/domain/extensions/extension-scope.js +23 -0
- package/dist/domain/extensions/extension-state.d.ts +5 -0
- package/dist/domain/extensions/extension-state.js +11 -0
- package/dist/domain/extensions/hook-manifest.d.ts +10 -0
- package/dist/domain/extensions/hook-manifest.js +23 -0
- package/dist/domain/extensions/mcp-config.d.ts +18 -0
- package/dist/domain/extensions/mcp-config.js +111 -0
- package/dist/domain/extensions/plugin-manifest.d.ts +11 -0
- package/dist/domain/extensions/plugin-manifest.js +43 -0
- package/dist/domain/extensions/skill-manifest.d.ts +10 -0
- package/dist/domain/extensions/skill-manifest.js +51 -0
- package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
- package/dist/domain/filesystem/file-change-diff.js +60 -0
- package/dist/domain/media/gateway-media-contract.d.ts +23 -0
- package/dist/domain/media/gateway-media-contract.js +163 -0
- package/dist/domain/media/media-contract.d.ts +28 -0
- package/dist/domain/media/media-contract.js +1 -0
- package/dist/domain/media/media-execution-policy.d.ts +9 -0
- package/dist/domain/media/media-execution-policy.js +31 -0
- package/dist/domain/orchestration/goal.d.ts +58 -0
- package/dist/domain/orchestration/goal.js +113 -0
- package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
- package/dist/domain/orchestration/subagent-identity.js +8 -0
- package/dist/domain/orchestration/subagent.d.ts +33 -0
- package/dist/domain/orchestration/subagent.js +1 -0
- package/dist/domain/orchestration/task.d.ts +31 -0
- package/dist/domain/orchestration/task.js +1 -0
- package/dist/domain/project/project-identity.d.ts +6 -0
- package/dist/domain/project/project-identity.js +4 -0
- package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
- package/dist/domain/runtime/assistant-delta-normalizer.js +19 -0
- package/dist/domain/runtime/resource-limits.d.ts +60 -0
- package/dist/domain/runtime/resource-limits.js +60 -0
- package/dist/domain/session/attachment.d.ts +13 -0
- package/dist/domain/session/attachment.js +1 -0
- package/dist/domain/session/session-schema.d.ts +6 -0
- package/dist/domain/session/session-schema.js +28 -0
- package/dist/domain/session/session.d.ts +27 -0
- package/dist/domain/session/session.js +1 -0
- package/dist/domain/settings/settings-document.d.ts +8 -0
- package/dist/domain/settings/settings-document.js +36 -0
- package/dist/domain/validation/record-schema.d.ts +4 -0
- package/dist/domain/validation/record-schema.js +9 -0
- package/dist/domain/workspace/workspace-settings.d.ts +12 -0
- package/dist/domain/workspace/workspace-settings.js +44 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.js +31 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +447 -0
- package/dist/infrastructure/cache/cache-policy.d.ts +7 -0
- package/dist/infrastructure/cache/cache-policy.js +18 -0
- package/dist/infrastructure/cache/file-cache-store.d.ts +17 -0
- package/dist/infrastructure/cache/file-cache-store.js +121 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +98 -0
- package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
- package/dist/infrastructure/clipboard/clipboard-policy.js +19 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +94 -0
- package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
- package/dist/infrastructure/clipboard/image-normalizer.js +78 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +66 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +70 -0
- package/dist/infrastructure/config/config-loader.d.ts +19 -0
- package/dist/infrastructure/config/config-loader.js +76 -0
- package/dist/infrastructure/config/environment-values.d.ts +2 -0
- package/dist/infrastructure/config/environment-values.js +7 -0
- package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/composite-credential-store.js +32 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.js +181 -0
- package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/environment-credential-store.js +37 -0
- package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
- package/dist/infrastructure/credentials/secret-input.js +44 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.js +10 -0
- package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
- package/dist/infrastructure/extensions/extension-directory-reader.js +15 -0
- package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
- package/dist/infrastructure/extensions/extension-source-resolver.js +126 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.js +66 -0
- package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
- package/dist/infrastructure/extensions/hook-runtime.js +66 -0
- package/dist/infrastructure/extensions/mcp-runtime.d.ts +12 -0
- package/dist/infrastructure/extensions/mcp-runtime.js +52 -0
- package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
- package/dist/infrastructure/extensions/plugin-discovery.js +52 -0
- package/dist/infrastructure/extensions/plugin-manager.d.ts +26 -0
- package/dist/infrastructure/extensions/plugin-manager.js +139 -0
- package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
- package/dist/infrastructure/extensions/skill-discovery.js +29 -0
- package/dist/infrastructure/extensions/skill-installer.d.ts +8 -0
- package/dist/infrastructure/extensions/skill-installer.js +88 -0
- package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
- package/dist/infrastructure/extensions/skill-manager.js +67 -0
- package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
- package/dist/infrastructure/extensions/skill-roots.js +25 -0
- package/dist/infrastructure/extensions/skill-tool-executor.d.ts +18 -0
- package/dist/infrastructure/extensions/skill-tool-executor.js +53 -0
- package/dist/infrastructure/filesystem/atomic-file-store.d.ts +12 -0
- package/dist/infrastructure/filesystem/atomic-file-store.js +106 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.js +24 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.js +7 -0
- package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
- package/dist/infrastructure/filesystem/fs-errors.js +6 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.js +49 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +21 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +176 -0
- package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
- package/dist/infrastructure/filesystem/path-resolver.js +119 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +152 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +20 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.js +75 -0
- package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
- package/dist/infrastructure/logging/log-redactor.js +26 -0
- package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
- package/dist/infrastructure/logging/logging-policy.js +6 -0
- package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
- package/dist/infrastructure/logging/structured-logger.js +40 -0
- package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
- package/dist/infrastructure/network/safe-media-downloader.js +239 -0
- package/dist/infrastructure/platform/host-platform.d.ts +14 -0
- package/dist/infrastructure/platform/host-platform.js +23 -0
- package/dist/infrastructure/platform/host-process.d.ts +17 -0
- package/dist/infrastructure/platform/host-process.js +116 -0
- package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
- package/dist/infrastructure/platform/platform-paths.js +33 -0
- package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
- package/dist/infrastructure/project/file-project-trust-store.js +59 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.js +115 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.js +8 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.js +28 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +20 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.js +97 -0
- package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
- package/dist/infrastructure/sessions/file-goal-store.js +160 -0
- package/dist/infrastructure/sessions/file-session-store.d.ts +48 -0
- package/dist/infrastructure/sessions/file-session-store.js +525 -0
- package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
- package/dist/infrastructure/sessions/project-session-paths.js +41 -0
- package/dist/infrastructure/sessions/session-index.d.ts +16 -0
- package/dist/infrastructure/sessions/session-index.js +84 -0
- package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
- package/dist/infrastructure/sessions/session-journal.js +137 -0
- package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
- package/dist/infrastructure/sessions/subagent-journal-store.js +30 -0
- package/dist/infrastructure/shell/shell-tool-executor.d.ts +17 -0
- package/dist/infrastructure/shell/shell-tool-executor.js +115 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.js +48 -0
- package/dist/infrastructure/workspace/workspace-settings-store.d.ts +9 -0
- package/dist/infrastructure/workspace/workspace-settings-store.js +75 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +66 -0
- package/dist/ports/cache-store.d.ts +10 -0
- package/dist/ports/cache-store.js +1 -0
- package/dist/ports/chat-model.d.ts +30 -0
- package/dist/ports/chat-model.js +1 -0
- package/dist/ports/clipboard-adapter.d.ts +7 -0
- package/dist/ports/clipboard-adapter.js +1 -0
- package/dist/ports/clipboard-text-adapter.d.ts +3 -0
- package/dist/ports/clipboard-text-adapter.js +1 -0
- package/dist/ports/credential-store.d.ts +7 -0
- package/dist/ports/credential-store.js +1 -0
- package/dist/ports/goal-store.d.ts +12 -0
- package/dist/ports/goal-store.js +1 -0
- package/dist/ports/logger.d.ts +8 -0
- package/dist/ports/logger.js +1 -0
- package/dist/ports/media-gateway-client.d.ts +54 -0
- package/dist/ports/media-gateway-client.js +1 -0
- package/dist/ports/model-diagnostics.d.ts +17 -0
- package/dist/ports/model-diagnostics.js +1 -0
- package/dist/ports/project-trust-store.d.ts +12 -0
- package/dist/ports/project-trust-store.js +1 -0
- package/dist/ports/session-store.d.ts +58 -0
- package/dist/ports/session-store.js +1 -0
- package/dist/ports/subagent-lifecycle.d.ts +31 -0
- package/dist/ports/subagent-lifecycle.js +1 -0
- package/dist/ports/tool-activity.d.ts +13 -0
- package/dist/ports/tool-activity.js +1 -0
- package/dist/presentation/themes/theme.d.ts +19 -0
- package/dist/presentation/themes/theme.js +8 -0
- package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
- package/dist/presentation/tui/agent-initialization-renderer.js +37 -0
- package/dist/presentation/tui/context-display.d.ts +21 -0
- package/dist/presentation/tui/context-display.js +33 -0
- package/dist/presentation/tui/formatters.d.ts +6 -0
- package/dist/presentation/tui/formatters.js +60 -0
- package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
- package/dist/presentation/tui/ink/choice-window.js +5 -0
- package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
- package/dist/presentation/tui/ink/components/activity-entry.js +16 -0
- package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
- package/dist/presentation/tui/ink/components/activity-status.js +21 -0
- package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
- package/dist/presentation/tui/ink/components/choice-modal.js +29 -0
- package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
- package/dist/presentation/tui/ink/components/composer.js +271 -0
- package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
- package/dist/presentation/tui/ink/components/file-diff.js +34 -0
- package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
- package/dist/presentation/tui/ink/components/modal.js +110 -0
- package/dist/presentation/tui/ink/components/shimmer-text.d.ts +6 -0
- package/dist/presentation/tui/ink/components/shimmer-text.js +9 -0
- package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
- package/dist/presentation/tui/ink/components/subagent-activity.js +61 -0
- package/dist/presentation/tui/ink/components/transcript.d.ts +39 -0
- package/dist/presentation/tui/ink/components/transcript.js +121 -0
- package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
- package/dist/presentation/tui/ink/components/welcome-panel.js +20 -0
- package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
- package/dist/presentation/tui/ink/lotagate-tui.js +136 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.js +20 -0
- package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
- package/dist/presentation/tui/ink/markdown-inline.js +91 -0
- package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
- package/dist/presentation/tui/ink/markdown-message.js +66 -0
- package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
- package/dist/presentation/tui/ink/markdown-table.js +77 -0
- package/dist/presentation/tui/ink/tui-bridge.d.ts +195 -0
- package/dist/presentation/tui/ink/tui-bridge.js +289 -0
- package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
- package/dist/presentation/tui/terminal-capabilities.js +7 -0
- package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
- package/dist/presentation/tui/terminal-mouse.js +19 -0
- package/dist/presentation/tui/terminal-screen.d.ts +10 -0
- package/dist/presentation/tui/terminal-screen.js +23 -0
- package/dist/presentation/tui/tui-agent-event-runner.d.ts +24 -0
- package/dist/presentation/tui/tui-agent-event-runner.js +69 -0
- package/dist/presentation/tui/tui-application-contract.d.ts +10 -0
- package/dist/presentation/tui/tui-application-contract.js +8 -0
- package/dist/presentation/tui/tui-application.d.ts +62 -0
- package/dist/presentation/tui/tui-application.js +675 -0
- package/dist/presentation/tui/tui-attachment-input.d.ts +2 -0
- package/dist/presentation/tui/tui-attachment-input.js +5 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.js +25 -0
- package/dist/presentation/tui/tui-command-context.d.ts +3 -0
- package/dist/presentation/tui/tui-command-context.js +1 -0
- package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
- package/dist/presentation/tui/tui-command-executor.js +214 -0
- package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
- package/dist/presentation/tui/tui-command-host-factory.js +23 -0
- package/dist/presentation/tui/tui-context-compaction.d.ts +5 -0
- package/dist/presentation/tui/tui-context-compaction.js +22 -0
- package/dist/presentation/tui/tui-context-service.d.ts +34 -0
- package/dist/presentation/tui/tui-context-service.js +126 -0
- package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
- package/dist/presentation/tui/tui-file-suggestions.js +8 -0
- package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
- package/dist/presentation/tui/tui-goal-controller.js +52 -0
- package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
- package/dist/presentation/tui/tui-initial-model.js +28 -0
- package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
- package/dist/presentation/tui/tui-lifecycle-actions.js +45 -0
- package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
- package/dist/presentation/tui/tui-manual-compaction.js +31 -0
- package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
- package/dist/presentation/tui/tui-media-model-selection.js +38 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.js +38 -0
- package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
- package/dist/presentation/tui/tui-skill-controller.js +13 -0
- package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
- package/dist/presentation/tui/tui-tool-approval.js +73 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +8 -7
- package/scripts/install-native.mjs +11 -11
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { Attachment } from '../../../domain/session/attachment.js';
|
|
2
|
+
import type { ExecutionPlan } from '../../../domain/orchestration/task.js';
|
|
3
|
+
import type { ChatUsage } from '../../../ports/chat-model.js';
|
|
4
|
+
import type { FileChangeDiff } from '../../../domain/filesystem/file-change-diff.js';
|
|
5
|
+
import type { ExtensionScope } from '../../../domain/extensions/extension-scope.js';
|
|
6
|
+
import type { SubagentMode, SubagentStatus } from '../../../domain/orchestration/subagent.js';
|
|
7
|
+
import type { SubagentHandoff } from '../../../domain/orchestration/subagent.js';
|
|
8
|
+
import type { SubagentLastAction, SubagentLifecycleEvent } from '../../../ports/subagent-lifecycle.js';
|
|
9
|
+
import type { CliActionKind } from '../../../application/orchestration/cli-turn-events.js';
|
|
10
|
+
export type TuiMessageKind = 'user' | 'assistant' | 'command' | 'notice' | 'error' | 'diff' | 'activity' | 'subagent';
|
|
11
|
+
export type TuiActivityState = 'pending' | 'running' | 'completed' | 'failed';
|
|
12
|
+
export interface TuiMessage {
|
|
13
|
+
id: string;
|
|
14
|
+
kind: TuiMessageKind;
|
|
15
|
+
content: string;
|
|
16
|
+
attachments?: readonly Attachment[];
|
|
17
|
+
fileChange?: FileChangeDiff;
|
|
18
|
+
activity?: {
|
|
19
|
+
label: string;
|
|
20
|
+
state: TuiActivityState;
|
|
21
|
+
startedAt: number;
|
|
22
|
+
elapsedMs?: number;
|
|
23
|
+
toolName?: string;
|
|
24
|
+
kind?: CliActionKind;
|
|
25
|
+
};
|
|
26
|
+
subagent?: TuiSubagent;
|
|
27
|
+
}
|
|
28
|
+
export interface TuiSubagent {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly displayName: string;
|
|
31
|
+
readonly task: string;
|
|
32
|
+
readonly mode: SubagentMode;
|
|
33
|
+
readonly model: string;
|
|
34
|
+
readonly status: SubagentStatus;
|
|
35
|
+
readonly background: boolean;
|
|
36
|
+
readonly createdAt: number;
|
|
37
|
+
readonly updatedAt: number;
|
|
38
|
+
readonly durationMs?: number;
|
|
39
|
+
readonly summary?: string;
|
|
40
|
+
readonly lastAction?: SubagentLastAction;
|
|
41
|
+
readonly handoff?: SubagentHandoff;
|
|
42
|
+
}
|
|
43
|
+
export interface TuiWelcome {
|
|
44
|
+
version: string;
|
|
45
|
+
cwd: string;
|
|
46
|
+
model: string | null;
|
|
47
|
+
profile: string | null;
|
|
48
|
+
trusted: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface TuiContextUsage {
|
|
51
|
+
usedTokens: number;
|
|
52
|
+
contextWindow?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface TuiChoice {
|
|
55
|
+
value: string;
|
|
56
|
+
label: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
kind?: 'file' | 'directory';
|
|
59
|
+
}
|
|
60
|
+
export type TuiModal = {
|
|
61
|
+
kind: 'trust';
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'plan';
|
|
64
|
+
plan: ExecutionPlan;
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'approval';
|
|
67
|
+
toolName: string;
|
|
68
|
+
detail?: string;
|
|
69
|
+
} | {
|
|
70
|
+
kind: 'subagent';
|
|
71
|
+
subagent: TuiSubagent;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'choice';
|
|
74
|
+
title: string;
|
|
75
|
+
choices: readonly TuiChoice[];
|
|
76
|
+
currentValue?: string;
|
|
77
|
+
detail?: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'secret';
|
|
80
|
+
label: string;
|
|
81
|
+
};
|
|
82
|
+
export interface TuiViewState {
|
|
83
|
+
ready: boolean;
|
|
84
|
+
runActive: boolean;
|
|
85
|
+
welcome?: TuiWelcome | undefined;
|
|
86
|
+
messages: readonly TuiMessage[];
|
|
87
|
+
subagents: readonly TuiSubagent[];
|
|
88
|
+
status?: string | undefined;
|
|
89
|
+
footerNotice?: string | undefined;
|
|
90
|
+
activityStartedAt?: number | undefined;
|
|
91
|
+
elapsedMs?: number | undefined;
|
|
92
|
+
usage?: ChatUsage | undefined;
|
|
93
|
+
contextUsage?: TuiContextUsage | undefined;
|
|
94
|
+
pendingAttachments: readonly Attachment[];
|
|
95
|
+
fileSuggestions: readonly TuiChoice[];
|
|
96
|
+
modal?: TuiModal | undefined;
|
|
97
|
+
clearBlockedUntil?: number | undefined;
|
|
98
|
+
actionDetails: boolean;
|
|
99
|
+
}
|
|
100
|
+
type Listener = () => void;
|
|
101
|
+
export declare class InkTuiBridge {
|
|
102
|
+
private readonly listeners;
|
|
103
|
+
private readonly initializationNotices;
|
|
104
|
+
private state;
|
|
105
|
+
private resolveModal;
|
|
106
|
+
private readonly exitResolvers;
|
|
107
|
+
private submitHandler;
|
|
108
|
+
private imagePasteHandler;
|
|
109
|
+
private textPasteHandler;
|
|
110
|
+
private clearAttachmentsHandler;
|
|
111
|
+
private interruptHandler;
|
|
112
|
+
private cancelHandler;
|
|
113
|
+
private sequence;
|
|
114
|
+
private noticeTimer;
|
|
115
|
+
private assistantFlushTimer;
|
|
116
|
+
private pendingAssistant;
|
|
117
|
+
private assistantSegmentPending;
|
|
118
|
+
private readonly pendingActivityTimers;
|
|
119
|
+
snapshot(): TuiViewState;
|
|
120
|
+
subscribe(listener: Listener): () => void;
|
|
121
|
+
setSubmitHandler(handler: (value: string) => Promise<void>): void;
|
|
122
|
+
setImagePasteHandler(handler: () => Promise<void>): void;
|
|
123
|
+
setTextPasteHandler(handler: () => Promise<string | undefined>): void;
|
|
124
|
+
setClearAttachmentsHandler(handler: () => void): void;
|
|
125
|
+
setInterruptHandler(handler: () => void): void;
|
|
126
|
+
setCancelHandler(handler: () => void): void;
|
|
127
|
+
submit(value: string): Promise<void>;
|
|
128
|
+
pasteImage(): Promise<void>;
|
|
129
|
+
pasteText(): Promise<string | undefined>;
|
|
130
|
+
interrupt(): void;
|
|
131
|
+
cancel(): void;
|
|
132
|
+
clearAttachments(): void;
|
|
133
|
+
setReady(): void;
|
|
134
|
+
setRunActive(runActive: boolean): void;
|
|
135
|
+
setWelcome(welcome: TuiWelcome): void;
|
|
136
|
+
setPendingAttachments(attachments: readonly Attachment[]): void;
|
|
137
|
+
setContextUsage(contextUsage: TuiContextUsage | undefined): void;
|
|
138
|
+
setFileSuggestions(fileSuggestions: readonly TuiChoice[]): void;
|
|
139
|
+
toggleActionDetails(): boolean;
|
|
140
|
+
clearTranscript(): void;
|
|
141
|
+
private exitCode;
|
|
142
|
+
requestExit(code?: number): void;
|
|
143
|
+
waitForExit(): Promise<number>;
|
|
144
|
+
userPrompt(content: string, attachments?: readonly Attachment[]): void;
|
|
145
|
+
command(content: string): void;
|
|
146
|
+
commandOutput(content: string): void;
|
|
147
|
+
transcriptNotice(content: string, notify?: boolean): void;
|
|
148
|
+
initializationNotice(key: string, content: string): void;
|
|
149
|
+
fileChange(change: FileChangeDiff): void;
|
|
150
|
+
notice(content: string): void;
|
|
151
|
+
dispose(): void;
|
|
152
|
+
error(content: string): void;
|
|
153
|
+
subagentLifecycle(event: SubagentLifecycleEvent): void;
|
|
154
|
+
startToolActivity(key: string, label: string, metadata?: {
|
|
155
|
+
toolName?: string;
|
|
156
|
+
kind?: CliActionKind;
|
|
157
|
+
}): {
|
|
158
|
+
complete: (isError: boolean) => void;
|
|
159
|
+
};
|
|
160
|
+
toolActivityStarted(key: string, label: string, metadata?: {
|
|
161
|
+
toolName?: string;
|
|
162
|
+
kind?: CliActionKind;
|
|
163
|
+
}): void;
|
|
164
|
+
toolActivityCompleted(key: string, isError: boolean): void;
|
|
165
|
+
status(label: string): void;
|
|
166
|
+
activity(label: string, elapsedMs: number, usage?: ChatUsage): void;
|
|
167
|
+
clearActivity(): void;
|
|
168
|
+
complete(elapsedMs: number, usage?: ChatUsage): void;
|
|
169
|
+
failed(): void;
|
|
170
|
+
cancelled(): void;
|
|
171
|
+
beginAssistant(): void;
|
|
172
|
+
/** Starts a new assistant segment after a host-owned action or approval boundary. */
|
|
173
|
+
assistantActionBoundary(): void;
|
|
174
|
+
assistantDelta(content: string): void;
|
|
175
|
+
finishAssistant(): void;
|
|
176
|
+
confirmTrust(): Promise<boolean>;
|
|
177
|
+
confirmPlan(plan: ExecutionPlan): Promise<boolean>;
|
|
178
|
+
confirmTool(toolName: string, detail?: string): Promise<boolean>;
|
|
179
|
+
openSubagentDetails(id: string): void;
|
|
180
|
+
closeSubagentDetails(): void;
|
|
181
|
+
selectModel(title: string, choices: readonly TuiChoice[], currentValue?: string): Promise<string | undefined>;
|
|
182
|
+
selectScope(title: string): Promise<ExtensionScope | undefined>;
|
|
183
|
+
requestSecret(label: string): Promise<string | undefined>;
|
|
184
|
+
resolveActiveModal(value: boolean | string | undefined): void;
|
|
185
|
+
private request;
|
|
186
|
+
private selectChoice;
|
|
187
|
+
private append;
|
|
188
|
+
private message;
|
|
189
|
+
private updateActivity;
|
|
190
|
+
private completeToolActivity;
|
|
191
|
+
private clearPendingActivityTimer;
|
|
192
|
+
private update;
|
|
193
|
+
private flushAssistant;
|
|
194
|
+
}
|
|
195
|
+
export {};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { RESOURCE_LIMITS } from '../../../domain/runtime/resource-limits.js';
|
|
2
|
+
export class InkTuiBridge {
|
|
3
|
+
listeners = new Set();
|
|
4
|
+
initializationNotices = new Map();
|
|
5
|
+
state = { ready: false, runActive: false, messages: [], subagents: [], pendingAttachments: [], fileSuggestions: [], actionDetails: false };
|
|
6
|
+
resolveModal;
|
|
7
|
+
exitResolvers = new Set();
|
|
8
|
+
submitHandler;
|
|
9
|
+
imagePasteHandler;
|
|
10
|
+
textPasteHandler;
|
|
11
|
+
clearAttachmentsHandler;
|
|
12
|
+
interruptHandler;
|
|
13
|
+
cancelHandler;
|
|
14
|
+
sequence = 0;
|
|
15
|
+
noticeTimer;
|
|
16
|
+
assistantFlushTimer;
|
|
17
|
+
pendingAssistant;
|
|
18
|
+
assistantSegmentPending = false;
|
|
19
|
+
pendingActivityTimers = new Map();
|
|
20
|
+
snapshot() { return this.state; }
|
|
21
|
+
subscribe(listener) { this.listeners.add(listener); return () => this.listeners.delete(listener); }
|
|
22
|
+
setSubmitHandler(handler) { this.submitHandler = handler; }
|
|
23
|
+
setImagePasteHandler(handler) { this.imagePasteHandler = handler; }
|
|
24
|
+
setTextPasteHandler(handler) { this.textPasteHandler = handler; }
|
|
25
|
+
setClearAttachmentsHandler(handler) { this.clearAttachmentsHandler = handler; }
|
|
26
|
+
setInterruptHandler(handler) { this.interruptHandler = handler; }
|
|
27
|
+
setCancelHandler(handler) { this.cancelHandler = handler; }
|
|
28
|
+
async submit(value) { await this.submitHandler?.(value); }
|
|
29
|
+
async pasteImage() { await this.imagePasteHandler?.(); }
|
|
30
|
+
async pasteText() { return this.textPasteHandler?.(); }
|
|
31
|
+
interrupt() { this.interruptHandler?.(); }
|
|
32
|
+
cancel() {
|
|
33
|
+
this.cancelHandler?.();
|
|
34
|
+
this.resolveActiveModal(undefined);
|
|
35
|
+
this.update({ clearBlockedUntil: Date.now() + 1500 });
|
|
36
|
+
}
|
|
37
|
+
clearAttachments() { this.clearAttachmentsHandler?.(); }
|
|
38
|
+
setReady() { this.update({ ready: true }); }
|
|
39
|
+
setRunActive(runActive) { this.update({ runActive }); }
|
|
40
|
+
setWelcome(welcome) { this.update({ welcome }); }
|
|
41
|
+
setPendingAttachments(attachments) { this.update({ pendingAttachments: attachments }); }
|
|
42
|
+
setContextUsage(contextUsage) { this.update({ contextUsage }); }
|
|
43
|
+
setFileSuggestions(fileSuggestions) { this.update({ fileSuggestions }); }
|
|
44
|
+
toggleActionDetails() { const actionDetails = !this.state.actionDetails; this.update({ actionDetails }); return actionDetails; }
|
|
45
|
+
clearTranscript() { this.initializationNotices.clear(); this.update({ messages: [], subagents: [] }); }
|
|
46
|
+
exitCode;
|
|
47
|
+
requestExit(code = 0) { this.exitCode ??= code; for (const resolve of this.exitResolvers)
|
|
48
|
+
resolve(this.exitCode); this.exitResolvers.clear(); }
|
|
49
|
+
waitForExit() { return this.exitCode === undefined ? new Promise((resolve) => { this.exitResolvers.add(resolve); }) : Promise.resolve(this.exitCode); }
|
|
50
|
+
userPrompt(content, attachments = []) { this.append('user', content, attachments); }
|
|
51
|
+
command(content) { this.append('command', content); }
|
|
52
|
+
commandOutput(content) { this.append('notice', content); }
|
|
53
|
+
transcriptNotice(content, notify = true) { this.append('notice', content, undefined, undefined, undefined, undefined, notify); }
|
|
54
|
+
initializationNotice(key, content) {
|
|
55
|
+
if (this.initializationNotices.get(key) === content)
|
|
56
|
+
return;
|
|
57
|
+
this.initializationNotices.set(key, content);
|
|
58
|
+
this.transcriptNotice(content);
|
|
59
|
+
}
|
|
60
|
+
fileChange(change) { this.append('diff', change.path, undefined, change); }
|
|
61
|
+
notice(content) {
|
|
62
|
+
if (this.noticeTimer !== undefined)
|
|
63
|
+
clearTimeout(this.noticeTimer);
|
|
64
|
+
this.update({ footerNotice: content });
|
|
65
|
+
this.noticeTimer = setTimeout(() => {
|
|
66
|
+
this.noticeTimer = undefined;
|
|
67
|
+
this.update({ footerNotice: undefined });
|
|
68
|
+
}, 4000);
|
|
69
|
+
}
|
|
70
|
+
dispose() {
|
|
71
|
+
if (this.noticeTimer !== undefined)
|
|
72
|
+
clearTimeout(this.noticeTimer);
|
|
73
|
+
if (this.assistantFlushTimer !== undefined)
|
|
74
|
+
clearImmediate(this.assistantFlushTimer);
|
|
75
|
+
for (const timer of this.pendingActivityTimers.values())
|
|
76
|
+
clearImmediate(timer);
|
|
77
|
+
this.pendingActivityTimers.clear();
|
|
78
|
+
this.noticeTimer = undefined;
|
|
79
|
+
this.assistantFlushTimer = undefined;
|
|
80
|
+
this.resolveActiveModal(undefined);
|
|
81
|
+
this.initializationNotices.clear();
|
|
82
|
+
this.listeners.clear();
|
|
83
|
+
}
|
|
84
|
+
error(content) { this.append('error', content); }
|
|
85
|
+
subagentLifecycle(event) {
|
|
86
|
+
const deferRender = this.state.modal?.kind === 'subagent';
|
|
87
|
+
const existing = this.state.subagents.find((subagent) => subagent.id === event.id);
|
|
88
|
+
const subagent = {
|
|
89
|
+
id: event.id,
|
|
90
|
+
displayName: event.displayName,
|
|
91
|
+
task: event.task,
|
|
92
|
+
mode: event.mode,
|
|
93
|
+
model: event.model,
|
|
94
|
+
status: event.status,
|
|
95
|
+
background: event.background,
|
|
96
|
+
createdAt: existing?.createdAt ?? event.timestamp,
|
|
97
|
+
updatedAt: event.timestamp,
|
|
98
|
+
...(event.durationMs === undefined ? {} : { durationMs: event.durationMs }),
|
|
99
|
+
...(event.summary === undefined ? {} : { summary: event.summary }),
|
|
100
|
+
...(event.lastAction === undefined ? (existing?.lastAction === undefined ? {} : { lastAction: existing.lastAction }) : { lastAction: event.lastAction }),
|
|
101
|
+
...(event.handoff === undefined ? (existing?.handoff === undefined ? {} : { handoff: existing.handoff }) : { handoff: event.handoff }),
|
|
102
|
+
};
|
|
103
|
+
const subagents = existing === undefined
|
|
104
|
+
? [...this.state.subagents, subagent]
|
|
105
|
+
: this.state.subagents.map((candidate) => candidate.id === event.id ? subagent : candidate);
|
|
106
|
+
this.update({ subagents }, !deferRender);
|
|
107
|
+
if (event.type === 'created' && !this.state.messages.some((message) => message.kind === 'subagent' && message.subagent?.id === event.id)) {
|
|
108
|
+
this.append('subagent', event.id, undefined, undefined, undefined, subagent, !deferRender);
|
|
109
|
+
}
|
|
110
|
+
if ((event.type === 'completed' || event.type === 'failed' || event.type === 'cancelled') && event.summary !== undefined) {
|
|
111
|
+
this.transcriptNotice(`Agent ${event.displayName} ${event.status} · ${event.summary}`, !deferRender);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
startToolActivity(key, label, metadata) {
|
|
115
|
+
const existing = this.state.messages.find((message) => message.kind === 'activity' && (message.activity?.state === 'pending' || message.activity?.state === 'running') && message.content === key);
|
|
116
|
+
let id = existing?.id;
|
|
117
|
+
if (existing === undefined) {
|
|
118
|
+
const created = this.message('activity', key, undefined, undefined, { label, state: 'running', startedAt: Date.now(), ...metadata });
|
|
119
|
+
id = created.id;
|
|
120
|
+
this.update({ messages: [...this.state.messages, created] });
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.clearPendingActivityTimer(key);
|
|
124
|
+
this.updateActivity(existing.id, label, 'running', metadata);
|
|
125
|
+
}
|
|
126
|
+
return { complete: (isError) => this.completeToolActivity(id, isError) };
|
|
127
|
+
}
|
|
128
|
+
toolActivityStarted(key, label, metadata) {
|
|
129
|
+
const existing = this.state.messages.find((message) => message.kind === 'activity' && message.content === key && (message.activity?.state === 'pending' || message.activity?.state === 'running'));
|
|
130
|
+
if (existing !== undefined) {
|
|
131
|
+
this.updateActivity(existing.id, label, existing.activity?.state === 'pending' ? 'pending' : 'running', metadata);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const created = this.message('activity', key, undefined, undefined, { label, state: 'pending', startedAt: Date.now(), ...metadata });
|
|
135
|
+
this.update({ messages: [...this.state.messages, created] });
|
|
136
|
+
const timer = setImmediate(() => {
|
|
137
|
+
this.pendingActivityTimers.delete(key);
|
|
138
|
+
const pending = this.state.messages.find((message) => message.kind === 'activity' && message.content === key && message.activity?.state === 'pending');
|
|
139
|
+
if (pending !== undefined)
|
|
140
|
+
this.updateActivity(pending.id, label, 'running', metadata);
|
|
141
|
+
});
|
|
142
|
+
this.pendingActivityTimers.set(key, timer);
|
|
143
|
+
}
|
|
144
|
+
toolActivityCompleted(key, isError) {
|
|
145
|
+
this.clearPendingActivityTimer(key);
|
|
146
|
+
const message = this.state.messages.find((candidate) => candidate.kind === 'activity' && candidate.content === key && (candidate.activity?.state === 'pending' || candidate.activity?.state === 'running'));
|
|
147
|
+
if (message !== undefined)
|
|
148
|
+
this.completeToolActivity(message.id, isError);
|
|
149
|
+
}
|
|
150
|
+
status(label) { this.update({ status: label, activityStartedAt: Date.now(), elapsedMs: undefined, usage: undefined }); }
|
|
151
|
+
activity(label, elapsedMs, usage) { this.update({ status: label, ...(this.state.activityStartedAt === undefined ? { activityStartedAt: Date.now() - elapsedMs } : {}), elapsedMs, ...(usage === undefined ? {} : { usage }) }); }
|
|
152
|
+
clearActivity() { this.update({ status: undefined, activityStartedAt: undefined, elapsedMs: undefined, usage: undefined }); }
|
|
153
|
+
complete(elapsedMs, usage) { this.update({ status: 'Done', elapsedMs, ...(usage === undefined ? {} : { usage }) }); }
|
|
154
|
+
failed() { this.update({ status: 'Failed', elapsedMs: undefined, usage: undefined }); }
|
|
155
|
+
cancelled() { this.update({ status: 'Cancelled', elapsedMs: undefined, usage: undefined }); }
|
|
156
|
+
beginAssistant() { this.flushAssistant(); this.assistantSegmentPending = false; this.append('assistant', ''); }
|
|
157
|
+
/** Starts a new assistant segment after a host-owned action or approval boundary. */
|
|
158
|
+
assistantActionBoundary() { this.flushAssistant(); this.assistantSegmentPending = true; }
|
|
159
|
+
assistantDelta(content) {
|
|
160
|
+
if (this.assistantSegmentPending) {
|
|
161
|
+
this.assistantSegmentPending = false;
|
|
162
|
+
this.append('assistant', content);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const last = this.state.messages.at(-1);
|
|
166
|
+
if (last?.kind !== 'assistant') {
|
|
167
|
+
this.flushAssistant();
|
|
168
|
+
this.append('assistant', content);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const pending = this.pendingAssistant;
|
|
172
|
+
this.pendingAssistant = { id: last.id, content: `${pending?.id === last.id ? pending.content : last.content}${content}` };
|
|
173
|
+
if (this.assistantFlushTimer === undefined)
|
|
174
|
+
this.assistantFlushTimer = setImmediate(() => { this.assistantFlushTimer = undefined; this.flushAssistant(); });
|
|
175
|
+
}
|
|
176
|
+
finishAssistant() { this.flushAssistant(); this.assistantSegmentPending = false; }
|
|
177
|
+
confirmTrust() { return this.request({ kind: 'trust' }).then((value) => value === true); }
|
|
178
|
+
confirmPlan(plan) { return this.request({ kind: 'plan', plan }).then((value) => value === true); }
|
|
179
|
+
confirmTool(toolName, detail) {
|
|
180
|
+
return this.request({ kind: 'approval', toolName, ...(detail === undefined ? {} : { detail }) }).then((value) => value === 'allow' || value === true);
|
|
181
|
+
}
|
|
182
|
+
openSubagentDetails(id) {
|
|
183
|
+
if (this.state.modal !== undefined)
|
|
184
|
+
return;
|
|
185
|
+
const subagent = this.state.subagents.find((candidate) => candidate.id === id);
|
|
186
|
+
if (subagent !== undefined)
|
|
187
|
+
this.update({ modal: { kind: 'subagent', subagent } });
|
|
188
|
+
}
|
|
189
|
+
closeSubagentDetails() {
|
|
190
|
+
if (this.state.modal?.kind === 'subagent')
|
|
191
|
+
this.update({ modal: undefined });
|
|
192
|
+
}
|
|
193
|
+
selectModel(title, choices, currentValue) {
|
|
194
|
+
return this.selectChoice(title, choices, currentValue);
|
|
195
|
+
}
|
|
196
|
+
selectScope(title) {
|
|
197
|
+
return this.selectChoice(title, [
|
|
198
|
+
{ value: 'user', label: 'User', description: 'Available across your projects' },
|
|
199
|
+
{ value: 'project', label: 'Project', description: 'Stored in the trusted project' },
|
|
200
|
+
]).then((value) => value === 'user' || value === 'project' ? value : undefined);
|
|
201
|
+
}
|
|
202
|
+
requestSecret(label) { return this.request({ kind: 'secret', label }).then((value) => typeof value === 'string' ? value : undefined); }
|
|
203
|
+
resolveActiveModal(value) {
|
|
204
|
+
const resolve = this.resolveModal;
|
|
205
|
+
if (resolve === undefined)
|
|
206
|
+
return;
|
|
207
|
+
this.resolveModal = undefined;
|
|
208
|
+
this.update({ modal: undefined });
|
|
209
|
+
resolve?.(value);
|
|
210
|
+
}
|
|
211
|
+
request(modal) {
|
|
212
|
+
if (this.resolveModal !== undefined)
|
|
213
|
+
throw new Error('A TUI decision is already active.');
|
|
214
|
+
this.update({ modal });
|
|
215
|
+
return new Promise((resolve) => { this.resolveModal = resolve; });
|
|
216
|
+
}
|
|
217
|
+
selectChoice(title, choices, currentValue) {
|
|
218
|
+
return this.request({ kind: 'choice', title, choices, ...(currentValue === undefined ? {} : { currentValue }) }).then((value) => typeof value === 'string' ? value : undefined);
|
|
219
|
+
}
|
|
220
|
+
append(kind, content, attachments, fileChange, activity, subagent, notify = true) {
|
|
221
|
+
this.update({ messages: retainTranscriptMessages([...this.state.messages, this.message(kind, content, attachments, fileChange, activity, subagent)]) }, notify);
|
|
222
|
+
}
|
|
223
|
+
message(kind, content, attachments, fileChange, activity, subagent) {
|
|
224
|
+
return {
|
|
225
|
+
id: `tui-${++this.sequence}`,
|
|
226
|
+
kind,
|
|
227
|
+
content,
|
|
228
|
+
...(attachments === undefined || attachments.length === 0 ? {} : { attachments }),
|
|
229
|
+
...(fileChange === undefined ? {} : { fileChange }),
|
|
230
|
+
...(activity === undefined ? {} : { activity }),
|
|
231
|
+
...(subagent === undefined ? {} : { subagent }),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
updateActivity(id, label, state, metadata) {
|
|
235
|
+
const messages = this.state.messages.map((message) => message.id === id && message.activity !== undefined
|
|
236
|
+
? { ...message, content: message.content, activity: { ...message.activity, label, state, ...metadata } }
|
|
237
|
+
: message);
|
|
238
|
+
this.update({ messages });
|
|
239
|
+
}
|
|
240
|
+
completeToolActivity(id, isError) {
|
|
241
|
+
const message = this.state.messages.find((candidate) => candidate.id === id && candidate.activity !== undefined);
|
|
242
|
+
if (message?.activity === undefined || (message.activity.state !== 'pending' && message.activity.state !== 'running'))
|
|
243
|
+
return;
|
|
244
|
+
this.update({ messages: this.state.messages.map((candidate) => candidate.id === id && candidate.activity !== undefined
|
|
245
|
+
? { ...candidate, activity: { ...candidate.activity, state: isError ? 'failed' : 'completed', elapsedMs: Date.now() - candidate.activity.startedAt } }
|
|
246
|
+
: candidate) });
|
|
247
|
+
}
|
|
248
|
+
clearPendingActivityTimer(key) {
|
|
249
|
+
const timer = this.pendingActivityTimers.get(key);
|
|
250
|
+
if (timer === undefined)
|
|
251
|
+
return;
|
|
252
|
+
clearImmediate(timer);
|
|
253
|
+
this.pendingActivityTimers.delete(key);
|
|
254
|
+
}
|
|
255
|
+
update(patch, notify = true) {
|
|
256
|
+
this.state = { ...this.state, ...patch };
|
|
257
|
+
if (!notify)
|
|
258
|
+
return;
|
|
259
|
+
for (const listener of this.listeners)
|
|
260
|
+
listener();
|
|
261
|
+
}
|
|
262
|
+
flushAssistant() {
|
|
263
|
+
if (this.assistantFlushTimer !== undefined) {
|
|
264
|
+
clearImmediate(this.assistantFlushTimer);
|
|
265
|
+
this.assistantFlushTimer = undefined;
|
|
266
|
+
}
|
|
267
|
+
const pending = this.pendingAssistant;
|
|
268
|
+
if (pending === undefined)
|
|
269
|
+
return;
|
|
270
|
+
this.pendingAssistant = undefined;
|
|
271
|
+
const index = this.state.messages.findIndex((message) => message.id === pending.id);
|
|
272
|
+
if (index < 0)
|
|
273
|
+
return;
|
|
274
|
+
const messages = [...this.state.messages];
|
|
275
|
+
const current = messages[index];
|
|
276
|
+
if (current === undefined || current.kind !== 'assistant')
|
|
277
|
+
return;
|
|
278
|
+
messages[index] = { ...current, content: pending.content };
|
|
279
|
+
this.update({ messages });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function retainTranscriptMessages(messages) {
|
|
283
|
+
if (messages.length <= RESOURCE_LIMITS.tuiTranscriptMessages)
|
|
284
|
+
return messages;
|
|
285
|
+
const active = messages.filter((message) => message.activity?.state === 'pending' || message.activity?.state === 'running' || message.subagent?.status === 'queued' || message.subagent?.status === 'running');
|
|
286
|
+
const recent = messages.slice(-RESOURCE_LIMITS.tuiTranscriptMessages);
|
|
287
|
+
const retained = [...active, ...recent.filter((message) => !active.some((candidate) => candidate.id === message.id))];
|
|
288
|
+
return retained.slice(-RESOURCE_LIMITS.tuiTranscriptMessages);
|
|
289
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
export interface TerminalOutput extends Writable {
|
|
3
|
+
isTTY?: boolean;
|
|
4
|
+
columns?: number;
|
|
5
|
+
rows?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TerminalCapabilities {
|
|
8
|
+
isInteractive: boolean;
|
|
9
|
+
colorEnabled: boolean;
|
|
10
|
+
unicodeEnabled: boolean;
|
|
11
|
+
width: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function detectTerminalCapabilities(input: Readable & {
|
|
14
|
+
isTTY?: boolean;
|
|
15
|
+
}, output: TerminalOutput, env?: Readonly<Record<string, string | undefined>>): TerminalCapabilities;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function detectTerminalCapabilities(input, output, env = process.env) {
|
|
2
|
+
const isInteractive = input.isTTY === true && output.isTTY === true;
|
|
3
|
+
const colorEnabled = isInteractive && env['NO_COLOR'] === undefined && env['TERM'] !== 'dumb';
|
|
4
|
+
const unicodeEnabled = env['LOTAGATE_ASCII'] !== '1';
|
|
5
|
+
const width = typeof output.columns === 'number' && output.columns > 0 ? output.columns : 80;
|
|
6
|
+
return { isInteractive, colorEnabled, unicodeEnabled, width };
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type MouseWheelDirection = 'up' | 'down';
|
|
2
|
+
/** Returns the wheel direction for an SGR mouse event, if the event is a wheel event. */
|
|
3
|
+
export declare function parseMouseWheel(input: string): MouseWheelDirection | undefined;
|
|
4
|
+
/** Identifies mouse escape sequences so they cannot be inserted into the prompt draft. */
|
|
5
|
+
export declare function isMouseSequence(input: string): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const ESC = String.fromCharCode(27);
|
|
2
|
+
const SGR_MOUSE_SEQUENCE = /^\[<(\d+);(\d+);(\d+)([mM])$/u;
|
|
3
|
+
/** Returns the wheel direction for an SGR mouse event, if the event is a wheel event. */
|
|
4
|
+
export function parseMouseWheel(input) {
|
|
5
|
+
const match = SGR_MOUSE_SEQUENCE.exec(stripEscape(input));
|
|
6
|
+
if (match === null)
|
|
7
|
+
return undefined;
|
|
8
|
+
const button = Number(match[1]);
|
|
9
|
+
if ((button & 64) === 0)
|
|
10
|
+
return undefined;
|
|
11
|
+
return (button & 1) === 0 ? 'up' : 'down';
|
|
12
|
+
}
|
|
13
|
+
/** Identifies mouse escape sequences so they cannot be inserted into the prompt draft. */
|
|
14
|
+
export function isMouseSequence(input) {
|
|
15
|
+
return /^\[<[0-9;]+[mM]$/u.test(stripEscape(input));
|
|
16
|
+
}
|
|
17
|
+
function stripEscape(input) {
|
|
18
|
+
return input.startsWith(ESC) ? input.slice(1) : input;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TerminalOutput } from './terminal-capabilities.js';
|
|
2
|
+
/** Starts the interactive application at the top of a clean terminal screen. */
|
|
3
|
+
export declare function clearTerminalScreen(output: TerminalOutput): void;
|
|
4
|
+
/**
|
|
5
|
+
* Isolates the interactive application from the invoking shell's scrollback.
|
|
6
|
+
* The terminal restores the original screen after the TUI has unmounted.
|
|
7
|
+
*/
|
|
8
|
+
export declare function enterInteractiveScreen(output: TerminalOutput): void;
|
|
9
|
+
/** Restores the shell screen that was active before the interactive TUI. */
|
|
10
|
+
export declare function exitInteractiveScreen(output: TerminalOutput): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const CLEAR_SCREEN_AND_HOME = '\u001B[2J\u001B[H';
|
|
2
|
+
const ENTER_ALTERNATE_SCREEN = '\u001B[?1049h';
|
|
3
|
+
const EXIT_ALTERNATE_SCREEN = '\u001B[?1049l';
|
|
4
|
+
const ENABLE_SGR_MOUSE = '\u001B[?1000h\u001B[?1006h';
|
|
5
|
+
const DISABLE_SGR_MOUSE = '\u001B[?1006l\u001B[?1000l';
|
|
6
|
+
/** Starts the interactive application at the top of a clean terminal screen. */
|
|
7
|
+
export function clearTerminalScreen(output) {
|
|
8
|
+
output.write(CLEAR_SCREEN_AND_HOME);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Isolates the interactive application from the invoking shell's scrollback.
|
|
12
|
+
* The terminal restores the original screen after the TUI has unmounted.
|
|
13
|
+
*/
|
|
14
|
+
export function enterInteractiveScreen(output) {
|
|
15
|
+
output.write(ENTER_ALTERNATE_SCREEN);
|
|
16
|
+
clearTerminalScreen(output);
|
|
17
|
+
output.write(ENABLE_SGR_MOUSE);
|
|
18
|
+
}
|
|
19
|
+
/** Restores the shell screen that was active before the interactive TUI. */
|
|
20
|
+
export function exitInteractiveScreen(output) {
|
|
21
|
+
output.write(DISABLE_SGR_MOUSE);
|
|
22
|
+
output.write(EXIT_ALTERNATE_SCREEN);
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PreparedCliAgent } from '../../application/agent/cli-agent-execution-service.js';
|
|
2
|
+
import type { AgentRunTracker } from '../../application/agent/agent-run-tracker.js';
|
|
3
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
4
|
+
import type { ChatUsage } from '../../ports/chat-model.js';
|
|
5
|
+
import type { InkTuiBridge } from './ink/tui-bridge.js';
|
|
6
|
+
import type { CliAgentSessionStore } from '../../application/agent/agent-session-store.js';
|
|
7
|
+
export interface TuiAgentEventRunnerOptions {
|
|
8
|
+
prepared: PreparedCliAgent;
|
|
9
|
+
input: string;
|
|
10
|
+
model: string;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
turnId?: string;
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
agentSessionStore: CliAgentSessionStore;
|
|
15
|
+
tracker: AgentRunTracker;
|
|
16
|
+
runtime: CliRuntime;
|
|
17
|
+
renderer: InkTuiBridge;
|
|
18
|
+
startedAt: number;
|
|
19
|
+
getUsage: () => ChatUsage | undefined;
|
|
20
|
+
appendAssistantDelta: (content: string) => void;
|
|
21
|
+
hasResponse: () => boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Owns the CLI projection of the Agent SDK event stream for interactive runs. */
|
|
24
|
+
export declare function runTuiAgentEvents(options: TuiAgentEventRunnerOptions): Promise<void>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CliTurnEventProjector } from '../../application/orchestration/cli-turn-event-projector.js';
|
|
2
|
+
import { persistCliTurnEvent } from '../../application/orchestration/cli-turn-persistence.js';
|
|
3
|
+
import { persistContextCompaction } from '../../application/agent/context-compaction-persistence.js';
|
|
4
|
+
import { renderAgentInitialization } from './agent-initialization-renderer.js';
|
|
5
|
+
import { throwIfAborted } from './tui-lifecycle-actions.js';
|
|
6
|
+
import { agentLimitNotice, classifyAgentLimit } from '../../application/agent/agent-limit.js';
|
|
7
|
+
/** Owns the CLI projection of the Agent SDK event stream for interactive runs. */
|
|
8
|
+
export async function runTuiAgentEvents(options) {
|
|
9
|
+
const projector = new CliTurnEventProjector();
|
|
10
|
+
renderAgentInitialization(options.renderer, await options.prepared.agent.initialize());
|
|
11
|
+
if (options.sessionId !== undefined) {
|
|
12
|
+
const history = await options.runtime.sessionStore.readHistory(options.sessionId);
|
|
13
|
+
options.agentSessionStore.hydrate(options.sessionId, options.prepared.system, history.transcript, history.events, options.input);
|
|
14
|
+
}
|
|
15
|
+
for await (const event of options.prepared.run({ input: options.input, model: options.model, ...(options.sessionId === undefined ? {} : { sessionId: options.sessionId }), signal: options.signal })) {
|
|
16
|
+
throwIfAborted(options.signal);
|
|
17
|
+
options.tracker.observe(event);
|
|
18
|
+
for (const item of projector.observe(event)) {
|
|
19
|
+
if (options.sessionId !== undefined) {
|
|
20
|
+
try {
|
|
21
|
+
await persistCliTurnEvent(options.runtime.sessionStore, options.sessionId, item, { ...(options.turnId === undefined ? {} : { turnId: options.turnId }) });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
options.runtime.logger.warn('Unable to persist agent lifecycle event.', { eventType: item.type, reason: error instanceof Error ? error.message : String(error) });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (item.type === 'assistant.delta')
|
|
28
|
+
options.appendAssistantDelta(item.content);
|
|
29
|
+
if (item.type === 'assistant.segment.completed')
|
|
30
|
+
options.renderer.assistantActionBoundary();
|
|
31
|
+
if (item.type === 'action.approval_requested') {
|
|
32
|
+
options.renderer.assistantActionBoundary();
|
|
33
|
+
options.renderer.status('Waiting for approval');
|
|
34
|
+
}
|
|
35
|
+
if (item.type === 'action.started') {
|
|
36
|
+
options.renderer.assistantActionBoundary();
|
|
37
|
+
options.runtime.logger.info('Agent tool called.', { toolName: item.toolName, actionId: item.actionId });
|
|
38
|
+
if (item.toolName !== 'agent.spawn')
|
|
39
|
+
options.renderer.toolActivityStarted(item.actionId, item.displayName, { toolName: item.toolName, kind: item.kind });
|
|
40
|
+
}
|
|
41
|
+
if (item.type === 'action.completed') {
|
|
42
|
+
options.runtime.logger.info('Agent tool completed.', { toolName: item.toolName, actionId: item.actionId, isError: item.isError });
|
|
43
|
+
options.renderer.toolActivityCompleted(item.actionId, item.isError);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (event.type === 'context.compacted') {
|
|
47
|
+
if (options.sessionId !== undefined)
|
|
48
|
+
await persistContextCompaction(options.runtime, options.prepared, options.sessionId, event.metrics, options.turnId);
|
|
49
|
+
options.renderer.transcriptNotice('Context compacted automatically.');
|
|
50
|
+
options.renderer.activity('Thinking', Date.now() - options.startedAt, options.getUsage());
|
|
51
|
+
}
|
|
52
|
+
if (event.type === 'session.failed') {
|
|
53
|
+
const limitReason = classifyAgentLimit(event.error);
|
|
54
|
+
if (limitReason === undefined)
|
|
55
|
+
throw event.error;
|
|
56
|
+
options.tracker.markStuck();
|
|
57
|
+
if (options.sessionId !== undefined)
|
|
58
|
+
options.agentSessionStore.delete(options.sessionId);
|
|
59
|
+
const notice = agentLimitNotice(limitReason);
|
|
60
|
+
if (options.hasResponse())
|
|
61
|
+
options.renderer.notice(notice);
|
|
62
|
+
else
|
|
63
|
+
options.appendAssistantDelta(notice);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (event.type === 'session.completed' && !options.hasResponse())
|
|
67
|
+
options.appendAssistantDelta(event.content);
|
|
68
|
+
}
|
|
69
|
+
}
|