@lotagate/cli 0.1.23 → 0.1.25
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/README.md +70 -3
- package/SECURITY.md +2 -0
- package/dist/application/agent/agent-history.d.ts +3 -0
- package/dist/application/agent/agent-history.js +5 -0
- package/dist/application/agent/agent-input-context.d.ts +12 -0
- package/dist/application/agent/agent-input-context.js +5 -0
- package/dist/application/agent/agent-limit.d.ts +3 -0
- package/dist/application/agent/agent-limit.js +1 -0
- package/dist/application/agent/agent-run-tracker.d.ts +30 -0
- package/dist/application/agent/agent-run-tracker.js +1 -0
- package/dist/application/agent/agent-runtime-context.d.ts +22 -0
- package/dist/application/agent/agent-runtime-context.js +1 -0
- package/dist/application/agent/agent-session-store.d.ts +19 -0
- package/dist/application/agent/agent-session-store.js +6 -0
- package/dist/application/agent/capability-profile.d.ts +55 -0
- package/dist/application/agent/capability-profile.js +1 -0
- package/dist/application/agent/cli-agent-execution-service.d.ts +110 -0
- package/dist/application/agent/cli-agent-execution-service.js +1 -0
- package/dist/application/agent/cli-agent-run-request.d.ts +12 -0
- package/dist/application/agent/cli-agent-run-request.js +0 -0
- package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
- package/dist/application/agent/context-compaction-persistence.js +1 -0
- package/dist/application/agent/context-compaction.d.ts +21 -0
- package/dist/application/agent/context-compaction.js +7 -0
- package/dist/application/agent/interactive-agent-guidance.d.ts +5 -0
- package/dist/application/agent/interactive-agent-guidance.js +2 -0
- package/dist/application/agent/prompt-data-safety.d.ts +14 -0
- package/dist/application/agent/prompt-data-safety.js +4 -0
- package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
- package/dist/application/agent/scoped-tool-executor.js +1 -0
- package/dist/application/agent/tool-catalog.d.ts +14 -0
- package/dist/application/agent/tool-catalog.js +1 -0
- package/dist/application/agent/tool-display.d.ts +7 -0
- package/dist/application/agent/tool-display.js +1 -0
- package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
- package/dist/application/agent/tool-hook-lifecycle.js +1 -0
- package/dist/application/auth/authentication-service.d.ts +20 -0
- package/dist/application/auth/authentication-service.js +1 -0
- package/dist/application/chat/chat-service.d.ts +12 -0
- package/dist/application/chat/chat-service.js +1 -0
- package/dist/application/chat/pending-attachment-store.d.ts +12 -0
- package/dist/application/chat/pending-attachment-store.js +1 -0
- package/dist/application/commands/application-command-executor.d.ts +23 -0
- package/dist/application/commands/application-command-executor.js +3 -0
- package/dist/application/commands/cli-args.d.ts +6 -0
- package/dist/application/commands/cli-args.js +1 -0
- package/dist/application/commands/cli-command-services.d.ts +17 -0
- package/dist/application/commands/cli-command-services.js +33 -0
- package/dist/application/commands/command-cancellation.d.ts +6 -0
- package/dist/application/commands/command-cancellation.js +1 -0
- package/dist/application/commands/command-catalog.d.ts +6 -0
- package/dist/application/commands/command-catalog.js +1 -0
- package/dist/application/commands/command-contract.d.ts +60 -0
- package/dist/application/commands/command-contract.js +0 -0
- package/dist/application/commands/command-hints.d.ts +9 -0
- package/dist/application/commands/command-hints.js +1 -0
- package/dist/application/commands/command-output.d.ts +4 -0
- package/dist/application/commands/command-output.js +0 -0
- package/dist/application/commands/command-parser.d.ts +10 -0
- package/dist/application/commands/command-parser.js +1 -0
- package/dist/application/commands/command-presentation.d.ts +7 -0
- package/dist/application/commands/command-presentation.js +3 -0
- package/dist/application/commands/command-registry.d.ts +11 -0
- package/dist/application/commands/command-registry.js +1 -0
- package/dist/application/commands/command-runtime.d.ts +2 -0
- package/dist/application/commands/command-runtime.js +1 -0
- package/dist/application/commands/goal-command-handlers.d.ts +3 -0
- package/dist/application/commands/goal-command-handlers.js +7 -0
- package/dist/application/commands/media-command-handlers.d.ts +9 -0
- package/dist/application/commands/media-command-handlers.js +8 -0
- package/dist/application/commands/media-command-output.d.ts +11 -0
- package/dist/application/commands/media-command-output.js +1 -0
- package/dist/application/commands/memory-command-handler.d.ts +29 -0
- package/dist/application/commands/memory-command-handler.js +12 -0
- package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
- package/dist/application/commands/runtime-command-handlers.js +14 -0
- package/dist/application/commands/stream-output.d.ts +4 -0
- package/dist/application/commands/stream-output.js +1 -0
- package/dist/application/commands/utility-commands.d.ts +6 -0
- package/dist/application/commands/utility-commands.js +10 -0
- package/dist/application/config/execution-config.d.ts +4 -0
- package/dist/application/config/execution-config.js +1 -0
- package/dist/application/extensions/extension-list-contract.d.ts +18 -0
- package/dist/application/extensions/extension-list-contract.js +0 -0
- package/dist/application/extensions/extension-list-formatters.d.ts +38 -0
- package/dist/application/extensions/extension-list-formatters.js +1 -0
- package/dist/application/extensions/extension-list-output.d.ts +3 -0
- package/dist/application/extensions/extension-list-output.js +3 -0
- package/dist/application/extensions/plugin-contribution-registry.d.ts +31 -0
- package/dist/application/extensions/plugin-contribution-registry.js +1 -0
- package/dist/application/extensions/plugin-detail-contract.d.ts +25 -0
- package/dist/application/extensions/plugin-detail-contract.js +0 -0
- package/dist/application/extensions/plugin-detail-service.d.ts +3 -0
- package/dist/application/extensions/plugin-detail-service.js +1 -0
- package/dist/application/extensions/skill-scope-store.d.ts +23 -0
- package/dist/application/extensions/skill-scope-store.js +1 -0
- package/dist/application/formatting/compact-number.d.ts +2 -0
- package/dist/application/formatting/compact-number.js +1 -0
- package/dist/application/formatting/compact-table.d.ts +22 -0
- package/dist/application/formatting/compact-table.js +2 -0
- package/dist/application/intent/completion-gate.d.ts +6 -0
- package/dist/application/intent/completion-gate.js +1 -0
- package/dist/application/intent/evidence-ledger.d.ts +21 -0
- package/dist/application/intent/evidence-ledger.js +1 -0
- package/dist/application/intent/evidence-recording-tool-executor.d.ts +16 -0
- package/dist/application/intent/evidence-recording-tool-executor.js +1 -0
- package/dist/application/intent/intent-compiler.d.ts +11 -0
- package/dist/application/intent/intent-compiler.js +2 -0
- package/dist/application/intent/intent-execution-gate.d.ts +11 -0
- package/dist/application/intent/intent-execution-gate.js +1 -0
- package/dist/application/intent/intent-host-context.d.ts +6 -0
- package/dist/application/intent/intent-host-context.js +1 -0
- package/dist/application/intent/intent-run-controller.d.ts +56 -0
- package/dist/application/intent/intent-run-controller.js +3 -0
- package/dist/application/intent/project-policy.d.ts +16 -0
- package/dist/application/intent/project-policy.js +1 -0
- package/dist/application/media/video-operation-poller.d.ts +5 -0
- package/dist/application/media/video-operation-poller.js +1 -0
- package/dist/application/memory/memory-capture-policy.d.ts +10 -0
- package/dist/application/memory/memory-capture-policy.js +1 -0
- package/dist/application/memory/memory-consolidation-service.d.ts +12 -0
- package/dist/application/memory/memory-consolidation-service.js +1 -0
- package/dist/application/memory/memory-context-assembler.d.ts +24 -0
- package/dist/application/memory/memory-context-assembler.js +1 -0
- package/dist/application/memory/memory-extractor.d.ts +21 -0
- package/dist/application/memory/memory-extractor.js +2 -0
- package/dist/application/memory/memory-service.d.ts +34 -0
- package/dist/application/memory/memory-service.js +1 -0
- package/dist/application/model/cached-model-catalog.d.ts +13 -0
- package/dist/application/model/cached-model-catalog.js +1 -0
- package/dist/application/model/initial-model-selection.d.ts +10 -0
- package/dist/application/model/initial-model-selection.js +1 -0
- package/dist/application/model/model-catalog-service.d.ts +6 -0
- package/dist/application/model/model-catalog-service.js +1 -0
- package/dist/application/model/model-context-window.d.ts +3 -0
- package/dist/application/model/model-context-window.js +1 -0
- package/dist/application/model/model-response-retry.d.ts +9 -0
- package/dist/application/model/model-response-retry.js +1 -0
- package/dist/application/orchestration/abortable-wait.d.ts +2 -0
- package/dist/application/orchestration/abortable-wait.js +1 -0
- package/dist/application/orchestration/cli-subagent-service.d.ts +73 -0
- package/dist/application/orchestration/cli-subagent-service.js +13 -0
- package/dist/application/orchestration/cli-turn-event-projector.d.ts +15 -0
- package/dist/application/orchestration/cli-turn-event-projector.js +1 -0
- package/dist/application/orchestration/cli-turn-events.d.ts +83 -0
- package/dist/application/orchestration/cli-turn-events.js +1 -0
- package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
- package/dist/application/orchestration/cli-turn-persistence.js +1 -0
- package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
- package/dist/application/orchestration/goal-evaluator.js +3 -0
- package/dist/application/orchestration/goal-input.d.ts +3 -0
- package/dist/application/orchestration/goal-input.js +1 -0
- package/dist/application/orchestration/goal-output.d.ts +2 -0
- package/dist/application/orchestration/goal-output.js +2 -0
- package/dist/application/orchestration/goal-runner.d.ts +22 -0
- package/dist/application/orchestration/goal-runner.js +10 -0
- package/dist/application/orchestration/goal-usage.d.ts +9 -0
- package/dist/application/orchestration/goal-usage.js +1 -0
- package/dist/application/orchestration/headless-agent-turn.d.ts +35 -0
- package/dist/application/orchestration/headless-agent-turn.js +4 -0
- package/dist/application/orchestration/subagent-coordinator.d.ts +41 -0
- package/dist/application/orchestration/subagent-coordinator.js +1 -0
- package/dist/application/orchestration/subagent-handoff.d.ts +3 -0
- package/dist/application/orchestration/subagent-handoff.js +3 -0
- package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
- package/dist/application/orchestration/subagent-tool-executor.js +1 -0
- package/dist/application/orchestration/task-graph.d.ts +13 -0
- package/dist/application/orchestration/task-graph.js +1 -0
- package/dist/application/orchestration/task-scheduler.d.ts +18 -0
- package/dist/application/orchestration/task-scheduler.js +1 -0
- package/dist/application/project/project-trust-service.d.ts +13 -0
- package/dist/application/project/project-trust-service.js +1 -0
- package/dist/application/project-intelligence/project-intelligence-service.d.ts +14 -0
- package/dist/application/project-intelligence/project-intelligence-service.js +1 -0
- package/dist/application/protocol/browser-host-tool-executor.d.ts +41 -0
- package/dist/application/protocol/browser-host-tool-executor.js +2 -0
- package/dist/application/protocol/computer-host-tool-executor.d.ts +42 -0
- package/dist/application/protocol/computer-host-tool-executor.js +2 -0
- package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
- package/dist/application/protocol/desktop-agent-command.js +3 -0
- package/dist/application/protocol/desktop-agent-request-parser.d.ts +186 -0
- package/dist/application/protocol/desktop-agent-request-parser.js +1 -0
- package/dist/application/protocol/desktop-approval-broker.d.ts +16 -0
- package/dist/application/protocol/desktop-approval-broker.js +1 -0
- package/dist/application/protocol/desktop-attachment-store.d.ts +16 -0
- package/dist/application/protocol/desktop-attachment-store.js +1 -0
- package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
- package/dist/application/protocol/desktop-command-catalog.js +1 -0
- package/dist/application/protocol/desktop-command-contract.d.ts +26 -0
- package/dist/application/protocol/desktop-command-contract.js +1 -0
- package/dist/application/protocol/desktop-command-executor.d.ts +17 -0
- package/dist/application/protocol/desktop-command-executor.js +1 -0
- package/dist/application/protocol/desktop-command-output.d.ts +15 -0
- package/dist/application/protocol/desktop-command-output.js +1 -0
- package/dist/application/protocol/desktop-execution-policy.d.ts +17 -0
- package/dist/application/protocol/desktop-execution-policy.js +1 -0
- package/dist/application/protocol/desktop-extension-request-handler.d.ts +14 -0
- package/dist/application/protocol/desktop-extension-request-handler.js +1 -0
- package/dist/application/protocol/desktop-extension-service.d.ts +44 -0
- package/dist/application/protocol/desktop-extension-service.js +3 -0
- package/dist/application/protocol/desktop-host-tool-executor.d.ts +63 -0
- package/dist/application/protocol/desktop-host-tool-executor.js +2 -0
- package/dist/application/protocol/desktop-intent-event-writer.d.ts +20 -0
- package/dist/application/protocol/desktop-intent-event-writer.js +1 -0
- package/dist/application/protocol/desktop-mcp-events.d.ts +10 -0
- package/dist/application/protocol/desktop-mcp-events.js +1 -0
- package/dist/application/protocol/desktop-orchestration-events.d.ts +2 -0
- package/dist/application/protocol/desktop-orchestration-events.js +2 -0
- package/dist/application/protocol/desktop-protocol-helpers.d.ts +13 -0
- package/dist/application/protocol/desktop-protocol-helpers.js +1 -0
- package/dist/application/protocol/document-host-tool-definitions.d.ts +4 -0
- package/dist/application/protocol/document-host-tool-definitions.js +1 -0
- package/dist/application/protocol/document-host-tool-executor.d.ts +49 -0
- package/dist/application/protocol/document-host-tool-executor.js +2 -0
- package/dist/application/protocol/json-line-writer.d.ts +9 -0
- package/dist/application/protocol/json-line-writer.js +2 -0
- package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
- package/dist/application/protocol/jsonl-agent-command.js +3 -0
- package/dist/application/protocol/jsonl-protocol.d.ts +82 -0
- package/dist/application/protocol/jsonl-protocol.js +2 -0
- package/dist/application/protocol/tool-image-content.d.ts +4 -0
- package/dist/application/protocol/tool-image-content.js +1 -0
- package/dist/application/security/delegated-worker-policy.d.ts +3 -0
- package/dist/application/security/delegated-worker-policy.js +1 -0
- package/dist/application/security/desktop-tool-scope-policy.d.ts +4 -0
- package/dist/application/security/desktop-tool-scope-policy.js +1 -0
- package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
- package/dist/application/security/tool-action-risk-analyzer.js +1 -0
- package/dist/application/security/tool-approval-service.d.ts +37 -0
- package/dist/application/security/tool-approval-service.js +1 -0
- package/dist/application/security/tool-risk-classifier.d.ts +18 -0
- package/dist/application/security/tool-risk-classifier.js +1 -0
- package/dist/application/security/workspace-permission-policy.d.ts +10 -0
- package/dist/application/security/workspace-permission-policy.js +1 -0
- package/dist/application/session/project-session-access.d.ts +8 -0
- package/dist/application/session/project-session-access.js +1 -0
- package/dist/application/session/session-compaction-service.d.ts +10 -0
- package/dist/application/session/session-compaction-service.js +1 -0
- package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
- package/dist/application/session/session-turn-lifecycle.js +1 -0
- package/dist/application/workspace/session-execution-workspace.d.ts +59 -0
- package/dist/application/workspace/session-execution-workspace.js +3 -0
- package/dist/application/workspace/workspace-file-index.d.ts +15 -0
- package/dist/application/workspace/workspace-file-index.js +1 -0
- package/dist/application/workspace/workspace-file-reference-resolver.d.ts +20 -0
- package/dist/application/workspace/workspace-file-reference-resolver.js +17 -0
- package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
- package/dist/application/workspace/workspace-instruction-loader.js +1 -0
- package/dist/bootstrap/composition-root.d.ts +6 -0
- package/dist/bootstrap/composition-root.js +1 -0
- package/dist/bootstrap/global-cli-options.d.ts +6 -0
- package/dist/bootstrap/global-cli-options.js +1 -0
- package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
- package/dist/bootstrap/native-devtools-stub.js +1 -0
- package/dist/bootstrap/native-entry.d.ts +1 -0
- package/dist/bootstrap/native-entry.js +2 -0
- package/dist/bootstrap/native-tiktoken.d.ts +4 -0
- package/dist/bootstrap/native-tiktoken.js +1 -0
- package/dist/bootstrap/runtime-factory.d.ts +41 -0
- package/dist/bootstrap/runtime-factory.js +1 -0
- package/dist/bootstrap/shutdown-manager.d.ts +11 -0
- package/dist/bootstrap/shutdown-manager.js +1 -0
- package/dist/bootstrap/startup-sequence.d.ts +5 -0
- package/dist/bootstrap/startup-sequence.js +1 -0
- package/dist/domain/auth/auth-profile.d.ts +14 -0
- package/dist/domain/auth/auth-profile.js +1 -0
- package/dist/domain/config/config-schema.d.ts +24 -0
- package/dist/domain/config/config-schema.js +1 -0
- package/dist/domain/errors/cli-command-hint.d.ts +5 -0
- package/dist/domain/errors/cli-command-hint.js +0 -0
- package/dist/domain/errors/cli-error.d.ts +35 -0
- package/dist/domain/errors/cli-error.js +1 -0
- package/dist/domain/errors/error-codes.d.ts +51 -0
- package/dist/domain/errors/error-codes.js +1 -0
- package/dist/domain/extensions/extension-scope.d.ts +3 -0
- package/dist/domain/extensions/extension-scope.js +1 -0
- package/dist/domain/extensions/extension-state.d.ts +5 -0
- package/dist/domain/extensions/extension-state.js +1 -0
- package/dist/domain/extensions/hook-manifest.d.ts +13 -0
- package/dist/domain/extensions/hook-manifest.js +1 -0
- package/dist/domain/extensions/host-tool-plugin-ids.d.ts +9 -0
- package/dist/domain/extensions/host-tool-plugin-ids.js +1 -0
- package/dist/domain/extensions/mcp-config.d.ts +35 -0
- package/dist/domain/extensions/mcp-config.js +1 -0
- package/dist/domain/extensions/plugin-agent-manifest.d.ts +8 -0
- package/dist/domain/extensions/plugin-agent-manifest.js +1 -0
- package/dist/domain/extensions/plugin-manifest.d.ts +23 -0
- package/dist/domain/extensions/plugin-manifest.js +1 -0
- package/dist/domain/extensions/skill-manifest.d.ts +10 -0
- package/dist/domain/extensions/skill-manifest.js +3 -0
- package/dist/domain/extensions/yaml-subset.d.ts +9 -0
- package/dist/domain/extensions/yaml-subset.js +2 -0
- package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
- package/dist/domain/filesystem/file-change-diff.js +3 -0
- package/dist/domain/intent/intent-contract.d.ts +41 -0
- package/dist/domain/intent/intent-contract.js +1 -0
- package/dist/domain/media/gateway-media-contract.d.ts +23 -0
- package/dist/domain/media/gateway-media-contract.js +1 -0
- package/dist/domain/media/media-contract.d.ts +28 -0
- package/dist/domain/media/media-contract.js +0 -0
- package/dist/domain/media/media-execution-policy.d.ts +9 -0
- package/dist/domain/media/media-execution-policy.js +1 -0
- package/dist/domain/memory/memory-kinds.d.ts +15 -0
- package/dist/domain/memory/memory-kinds.js +1 -0
- package/dist/domain/memory/memory-retrieval-policy.d.ts +3 -0
- package/dist/domain/memory/memory-retrieval-policy.js +1 -0
- package/dist/domain/memory/memory-search.d.ts +33 -0
- package/dist/domain/memory/memory-search.js +2 -0
- package/dist/domain/memory/memory.d.ts +48 -0
- package/dist/domain/memory/memory.js +1 -0
- package/dist/domain/orchestration/goal.d.ts +58 -0
- package/dist/domain/orchestration/goal.js +1 -0
- package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
- package/dist/domain/orchestration/subagent-identity.js +1 -0
- package/dist/domain/orchestration/subagent.d.ts +33 -0
- package/dist/domain/orchestration/subagent.js +0 -0
- package/dist/domain/orchestration/work-plan.d.ts +77 -0
- package/dist/domain/orchestration/work-plan.js +1 -0
- package/dist/domain/project/project-identity.d.ts +6 -0
- package/dist/domain/project/project-identity.js +1 -0
- package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
- package/dist/domain/runtime/assistant-delta-normalizer.js +1 -0
- package/dist/domain/runtime/resource-limits.d.ts +75 -0
- package/dist/domain/runtime/resource-limits.js +1 -0
- package/dist/domain/session/attachment.d.ts +13 -0
- package/dist/domain/session/attachment.js +0 -0
- package/dist/domain/session/session-schema.d.ts +6 -0
- package/dist/domain/session/session-schema.js +1 -0
- package/dist/domain/session/session.d.ts +27 -0
- package/dist/domain/session/session.js +0 -0
- package/dist/domain/settings/settings-document.d.ts +8 -0
- package/dist/domain/settings/settings-document.js +1 -0
- package/dist/domain/validation/record-schema.d.ts +4 -0
- package/dist/domain/validation/record-schema.js +1 -0
- package/dist/domain/workspace/workspace-settings.d.ts +12 -0
- package/dist/domain/workspace/workspace-settings.js +1 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.js +1 -0
- package/dist/infrastructure/agent-sdk/model-tool-name-mapper.d.ts +13 -0
- package/dist/infrastructure/agent-sdk/model-tool-name-mapper.js +1 -0
- package/dist/infrastructure/agent-sdk/tool-calling-completion-client.d.ts +4 -0
- package/dist/infrastructure/agent-sdk/tool-calling-completion-client.js +1 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +1 -0
- package/dist/infrastructure/cache/cache-policy.d.ts +7 -0
- package/dist/infrastructure/cache/cache-policy.js +1 -0
- package/dist/infrastructure/cache/file-cache-store.d.ts +17 -0
- package/dist/infrastructure/cache/file-cache-store.js +2 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +1 -0
- package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
- package/dist/infrastructure/clipboard/clipboard-policy.js +1 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +1 -0
- package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
- package/dist/infrastructure/clipboard/image-normalizer.js +1 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +1 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +1 -0
- package/dist/infrastructure/config/config-loader.d.ts +19 -0
- package/dist/infrastructure/config/config-loader.js +2 -0
- package/dist/infrastructure/config/environment-values.d.ts +2 -0
- package/dist/infrastructure/config/environment-values.js +1 -0
- package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/composite-credential-store.js +1 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.js +3 -0
- package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/environment-credential-store.js +1 -0
- package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
- package/dist/infrastructure/credentials/secret-input.js +3 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.js +1 -0
- package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
- package/dist/infrastructure/extensions/extension-directory-reader.js +1 -0
- package/dist/infrastructure/extensions/extension-integrity.d.ts +7 -0
- package/dist/infrastructure/extensions/extension-integrity.js +1 -0
- package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
- package/dist/infrastructure/extensions/extension-source-resolver.js +1 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.js +2 -0
- package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
- package/dist/infrastructure/extensions/hook-runtime.js +1 -0
- package/dist/infrastructure/extensions/mcp-runtime.d.ts +51 -0
- package/dist/infrastructure/extensions/mcp-runtime.js +1 -0
- package/dist/infrastructure/extensions/plugin-agent-discovery.d.ts +4 -0
- package/dist/infrastructure/extensions/plugin-agent-discovery.js +1 -0
- package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
- package/dist/infrastructure/extensions/plugin-discovery.js +1 -0
- package/dist/infrastructure/extensions/plugin-manager.d.ts +23 -0
- package/dist/infrastructure/extensions/plugin-manager.js +2 -0
- package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
- package/dist/infrastructure/extensions/skill-discovery.js +1 -0
- package/dist/infrastructure/extensions/skill-installer.d.ts +9 -0
- package/dist/infrastructure/extensions/skill-installer.js +1 -0
- package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
- package/dist/infrastructure/extensions/skill-manager.js +2 -0
- package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
- package/dist/infrastructure/extensions/skill-roots.js +1 -0
- package/dist/infrastructure/extensions/skill-tool-executor.d.ts +18 -0
- package/dist/infrastructure/extensions/skill-tool-executor.js +2 -0
- package/dist/infrastructure/filesystem/atomic-file-store.d.ts +17 -0
- package/dist/infrastructure/filesystem/atomic-file-store.js +1 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.js +1 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.js +1 -0
- package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
- package/dist/infrastructure/filesystem/fs-errors.js +1 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.js +1 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +22 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +3 -0
- package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
- package/dist/infrastructure/filesystem/path-resolver.js +1 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +1 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +26 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.js +2 -0
- package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
- package/dist/infrastructure/logging/log-redactor.js +1 -0
- package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
- package/dist/infrastructure/logging/logging-policy.js +1 -0
- package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
- package/dist/infrastructure/logging/structured-logger.js +4 -0
- package/dist/infrastructure/memory/file-memory-store.d.ts +37 -0
- package/dist/infrastructure/memory/file-memory-store.js +11 -0
- package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
- package/dist/infrastructure/network/safe-media-downloader.js +1 -0
- package/dist/infrastructure/platform/host-platform.d.ts +14 -0
- package/dist/infrastructure/platform/host-platform.js +1 -0
- package/dist/infrastructure/platform/host-process.d.ts +29 -0
- package/dist/infrastructure/platform/host-process.js +1 -0
- package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
- package/dist/infrastructure/platform/platform-paths.js +1 -0
- package/dist/infrastructure/platform/process-termination.d.ts +4 -0
- package/dist/infrastructure/platform/process-termination.js +1 -0
- package/dist/infrastructure/platform/read-only-executable.d.ts +3 -0
- package/dist/infrastructure/platform/read-only-executable.js +1 -0
- package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
- package/dist/infrastructure/project/file-project-trust-store.js +2 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.js +1 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.js +1 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.js +1 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +20 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.js +1 -0
- package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
- package/dist/infrastructure/sessions/file-goal-store.js +1 -0
- package/dist/infrastructure/sessions/file-session-store.d.ts +47 -0
- package/dist/infrastructure/sessions/file-session-store.js +4 -0
- package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
- package/dist/infrastructure/sessions/project-session-paths.js +1 -0
- package/dist/infrastructure/sessions/session-index.d.ts +16 -0
- package/dist/infrastructure/sessions/session-index.js +3 -0
- package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
- package/dist/infrastructure/sessions/session-journal.js +6 -0
- package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
- package/dist/infrastructure/sessions/subagent-journal-store.js +2 -0
- package/dist/infrastructure/shell/shell-tool-executor.d.ts +17 -0
- package/dist/infrastructure/shell/shell-tool-executor.js +2 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.js +1 -0
- package/dist/infrastructure/workspace/workspace-settings-store.d.ts +9 -0
- package/dist/infrastructure/workspace/workspace-settings-store.js +4 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +3 -0
- package/dist/ports/cache-store.d.ts +10 -0
- package/dist/ports/cache-store.js +0 -0
- package/dist/ports/chat-model.d.ts +30 -0
- package/dist/ports/chat-model.js +0 -0
- package/dist/ports/clipboard-adapter.d.ts +7 -0
- package/dist/ports/clipboard-adapter.js +0 -0
- package/dist/ports/clipboard-text-adapter.d.ts +3 -0
- package/dist/ports/clipboard-text-adapter.js +0 -0
- package/dist/ports/credential-store.d.ts +7 -0
- package/dist/ports/credential-store.js +0 -0
- package/dist/ports/goal-store.d.ts +12 -0
- package/dist/ports/goal-store.js +0 -0
- package/dist/ports/logger.d.ts +8 -0
- package/dist/ports/logger.js +0 -0
- package/dist/ports/media-gateway-client.d.ts +54 -0
- package/dist/ports/media-gateway-client.js +0 -0
- package/dist/ports/memory-store.d.ts +26 -0
- package/dist/ports/memory-store.js +0 -0
- package/dist/ports/model-completion-client.d.ts +8 -0
- package/dist/ports/model-completion-client.js +0 -0
- package/dist/ports/model-diagnostics.d.ts +17 -0
- package/dist/ports/model-diagnostics.js +0 -0
- package/dist/ports/project-trust-store.d.ts +12 -0
- package/dist/ports/project-trust-store.js +0 -0
- package/dist/ports/session-store.d.ts +58 -0
- package/dist/ports/session-store.js +0 -0
- package/dist/ports/subagent-lifecycle.d.ts +31 -0
- package/dist/ports/subagent-lifecycle.js +0 -0
- package/dist/ports/tool-activity.d.ts +13 -0
- package/dist/ports/tool-activity.js +0 -0
- package/dist/presentation/themes/theme.d.ts +19 -0
- package/dist/presentation/themes/theme.js +1 -0
- package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
- package/dist/presentation/tui/agent-initialization-renderer.js +1 -0
- package/dist/presentation/tui/context-display.d.ts +21 -0
- package/dist/presentation/tui/context-display.js +2 -0
- package/dist/presentation/tui/formatters.d.ts +6 -0
- package/dist/presentation/tui/formatters.js +1 -0
- package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
- package/dist/presentation/tui/ink/choice-window.js +1 -0
- package/dist/presentation/tui/ink/components/activity-animation.d.ts +3 -0
- package/dist/presentation/tui/ink/components/activity-animation.js +1 -0
- package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
- package/dist/presentation/tui/ink/components/activity-entry.js +1 -0
- package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
- package/dist/presentation/tui/ink/components/activity-status.js +1 -0
- package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
- package/dist/presentation/tui/ink/components/choice-modal.js +1 -0
- package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
- package/dist/presentation/tui/ink/components/composer.js +8 -0
- package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
- package/dist/presentation/tui/ink/components/file-diff.js +1 -0
- package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
- package/dist/presentation/tui/ink/components/modal.js +2 -0
- package/dist/presentation/tui/ink/components/shimmer-text.d.ts +8 -0
- package/dist/presentation/tui/ink/components/shimmer-text.js +1 -0
- package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
- package/dist/presentation/tui/ink/components/subagent-activity.js +1 -0
- package/dist/presentation/tui/ink/components/transcript.d.ts +39 -0
- package/dist/presentation/tui/ink/components/transcript.js +5 -0
- package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
- package/dist/presentation/tui/ink/components/welcome-panel.js +1 -0
- package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
- package/dist/presentation/tui/ink/lotagate-tui.js +2 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.js +1 -0
- package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
- package/dist/presentation/tui/ink/markdown-inline.js +1 -0
- package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
- package/dist/presentation/tui/ink/markdown-message.js +2 -0
- package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
- package/dist/presentation/tui/ink/markdown-table.js +1 -0
- package/dist/presentation/tui/ink/tui-bridge.d.ts +193 -0
- package/dist/presentation/tui/ink/tui-bridge.js +1 -0
- package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
- package/dist/presentation/tui/terminal-capabilities.js +1 -0
- package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
- package/dist/presentation/tui/terminal-mouse.js +1 -0
- package/dist/presentation/tui/terminal-screen.d.ts +10 -0
- package/dist/presentation/tui/terminal-screen.js +1 -0
- package/dist/presentation/tui/tui-agent-event-runner.d.ts +29 -0
- package/dist/presentation/tui/tui-agent-event-runner.js +1 -0
- package/dist/presentation/tui/tui-application-contract.d.ts +10 -0
- package/dist/presentation/tui/tui-application-contract.js +1 -0
- package/dist/presentation/tui/tui-application.d.ts +64 -0
- package/dist/presentation/tui/tui-application.js +3 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.js +1 -0
- package/dist/presentation/tui/tui-command-context.d.ts +3 -0
- package/dist/presentation/tui/tui-command-context.js +0 -0
- package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
- package/dist/presentation/tui/tui-command-executor.js +4 -0
- package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
- package/dist/presentation/tui/tui-command-host-factory.js +1 -0
- package/dist/presentation/tui/tui-context-compaction.d.ts +5 -0
- package/dist/presentation/tui/tui-context-compaction.js +1 -0
- package/dist/presentation/tui/tui-context-service.d.ts +34 -0
- package/dist/presentation/tui/tui-context-service.js +2 -0
- package/dist/presentation/tui/tui-extension-loader.d.ts +21 -0
- package/dist/presentation/tui/tui-extension-loader.js +1 -0
- package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
- package/dist/presentation/tui/tui-file-suggestions.js +1 -0
- package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
- package/dist/presentation/tui/tui-goal-controller.js +1 -0
- package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
- package/dist/presentation/tui/tui-initial-model.js +1 -0
- package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
- package/dist/presentation/tui/tui-lifecycle-actions.js +1 -0
- package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
- package/dist/presentation/tui/tui-manual-compaction.js +1 -0
- package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
- package/dist/presentation/tui/tui-media-model-selection.js +1 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.js +1 -0
- package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
- package/dist/presentation/tui/tui-skill-controller.js +3 -0
- package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
- package/dist/presentation/tui/tui-tool-approval.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +12 -10
- package/skills/architecture-review/SKILL.md +41 -14
- package/skills/code-review/SKILL.md +41 -12
- package/skills/debugging/SKILL.md +49 -12
- package/skills/documentation/SKILL.md +43 -9
- package/skills/feature-implementation/SKILL.md +58 -19
- package/skills/api-contract-review/SKILL.md +0 -17
- package/skills/database-review/SKILL.md +0 -17
- package/skills/dependency-review/SKILL.md +0 -16
- package/skills/frontend-review/SKILL.md +0 -18
- package/skills/incident-response/SKILL.md +0 -18
- package/skills/performance-review/SKILL.md +0 -17
- package/skills/refactor/SKILL.md +0 -23
- package/skills/release-readiness/SKILL.md +0 -16
- package/skills/security-review/SKILL.md +0 -16
- package/skills/test-plan/SKILL.md +0 -22
- package/skills/verify/SKILL.md +0 -13
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { Attachment } from '../../../domain/session/attachment.js';
|
|
2
|
+
import type { ChatUsage } from '../../../ports/chat-model.js';
|
|
3
|
+
import type { FileChangeDiff } from '../../../domain/filesystem/file-change-diff.js';
|
|
4
|
+
import type { ExtensionScope } from '../../../domain/extensions/extension-scope.js';
|
|
5
|
+
import type { SubagentMode, SubagentStatus } from '../../../domain/orchestration/subagent.js';
|
|
6
|
+
import type { SubagentHandoff } from '../../../domain/orchestration/subagent.js';
|
|
7
|
+
import type { SubagentLastAction, SubagentLifecycleEvent } from '../../../ports/subagent-lifecycle.js';
|
|
8
|
+
import type { CliActionKind } from '../../../application/orchestration/cli-turn-events.js';
|
|
9
|
+
export type TuiMessageKind = 'user' | 'assistant' | 'command' | 'notice' | 'error' | 'diff' | 'activity' | 'subagent';
|
|
10
|
+
export type TuiActivityState = 'pending' | 'running' | 'completed' | 'failed';
|
|
11
|
+
export interface TuiMessage {
|
|
12
|
+
id: string;
|
|
13
|
+
kind: TuiMessageKind;
|
|
14
|
+
content: string;
|
|
15
|
+
attachments?: readonly Attachment[];
|
|
16
|
+
fileChange?: FileChangeDiff;
|
|
17
|
+
activity?: {
|
|
18
|
+
label: string;
|
|
19
|
+
state: TuiActivityState;
|
|
20
|
+
startedAt: number;
|
|
21
|
+
elapsedMs?: number;
|
|
22
|
+
toolName?: string;
|
|
23
|
+
kind?: CliActionKind;
|
|
24
|
+
};
|
|
25
|
+
subagent?: TuiSubagent;
|
|
26
|
+
}
|
|
27
|
+
export interface TuiSubagent {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly displayName: string;
|
|
30
|
+
readonly task: string;
|
|
31
|
+
readonly mode: SubagentMode;
|
|
32
|
+
readonly model: string;
|
|
33
|
+
readonly status: SubagentStatus;
|
|
34
|
+
readonly background: boolean;
|
|
35
|
+
readonly createdAt: number;
|
|
36
|
+
readonly updatedAt: number;
|
|
37
|
+
readonly durationMs?: number;
|
|
38
|
+
readonly summary?: string;
|
|
39
|
+
readonly lastAction?: SubagentLastAction;
|
|
40
|
+
readonly handoff?: SubagentHandoff;
|
|
41
|
+
}
|
|
42
|
+
export interface TuiWelcome {
|
|
43
|
+
version: string;
|
|
44
|
+
cwd: string;
|
|
45
|
+
model: string | null;
|
|
46
|
+
profile: string | null;
|
|
47
|
+
trusted: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface TuiContextUsage {
|
|
50
|
+
usedTokens: number;
|
|
51
|
+
contextWindow?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface TuiChoice {
|
|
54
|
+
value: string;
|
|
55
|
+
label: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
kind?: 'file' | 'directory';
|
|
58
|
+
}
|
|
59
|
+
export type TuiModal = {
|
|
60
|
+
kind: 'trust';
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'approval';
|
|
63
|
+
toolName: string;
|
|
64
|
+
detail?: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'subagent';
|
|
67
|
+
subagent: TuiSubagent;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'choice';
|
|
70
|
+
title: string;
|
|
71
|
+
choices: readonly TuiChoice[];
|
|
72
|
+
currentValue?: string;
|
|
73
|
+
detail?: string;
|
|
74
|
+
} | {
|
|
75
|
+
kind: 'secret';
|
|
76
|
+
label: string;
|
|
77
|
+
};
|
|
78
|
+
export interface TuiViewState {
|
|
79
|
+
ready: boolean;
|
|
80
|
+
runActive: boolean;
|
|
81
|
+
welcome?: TuiWelcome | undefined;
|
|
82
|
+
messages: readonly TuiMessage[];
|
|
83
|
+
subagents: readonly TuiSubagent[];
|
|
84
|
+
status?: string | undefined;
|
|
85
|
+
footerNotice?: string | undefined;
|
|
86
|
+
activityStartedAt?: number | undefined;
|
|
87
|
+
elapsedMs?: number | undefined;
|
|
88
|
+
usage?: ChatUsage | undefined;
|
|
89
|
+
contextUsage?: TuiContextUsage | undefined;
|
|
90
|
+
pendingAttachments: readonly Attachment[];
|
|
91
|
+
fileSuggestions: readonly TuiChoice[];
|
|
92
|
+
modal?: TuiModal | undefined;
|
|
93
|
+
clearBlockedUntil?: number | undefined;
|
|
94
|
+
actionDetails: boolean;
|
|
95
|
+
}
|
|
96
|
+
type Listener = () => void;
|
|
97
|
+
export declare class InkTuiBridge {
|
|
98
|
+
private readonly listeners;
|
|
99
|
+
private readonly initializationNotices;
|
|
100
|
+
private state;
|
|
101
|
+
private resolveModal;
|
|
102
|
+
private readonly exitResolvers;
|
|
103
|
+
private submitHandler;
|
|
104
|
+
private imagePasteHandler;
|
|
105
|
+
private textPasteHandler;
|
|
106
|
+
private clearAttachmentsHandler;
|
|
107
|
+
private interruptHandler;
|
|
108
|
+
private cancelHandler;
|
|
109
|
+
private sequence;
|
|
110
|
+
private noticeTimer;
|
|
111
|
+
private assistantRevealTimer;
|
|
112
|
+
private pendingAssistant;
|
|
113
|
+
private assistantSegmentPending;
|
|
114
|
+
private readonly pendingActivityTimers;
|
|
115
|
+
snapshot(): TuiViewState;
|
|
116
|
+
subscribe(listener: Listener): () => void;
|
|
117
|
+
setSubmitHandler(handler: (value: string) => Promise<void>): void;
|
|
118
|
+
setImagePasteHandler(handler: () => Promise<void>): void;
|
|
119
|
+
setTextPasteHandler(handler: () => Promise<string | undefined>): void;
|
|
120
|
+
setClearAttachmentsHandler(handler: () => void): void;
|
|
121
|
+
setInterruptHandler(handler: () => void): void;
|
|
122
|
+
setCancelHandler(handler: () => void): void;
|
|
123
|
+
submit(value: string): Promise<void>;
|
|
124
|
+
pasteImage(): Promise<void>;
|
|
125
|
+
pasteText(): Promise<string | undefined>;
|
|
126
|
+
interrupt(): void;
|
|
127
|
+
cancel(): void;
|
|
128
|
+
clearAttachments(): void;
|
|
129
|
+
setReady(): void;
|
|
130
|
+
setRunActive(runActive: boolean): void;
|
|
131
|
+
setWelcome(welcome: TuiWelcome): void;
|
|
132
|
+
setPendingAttachments(attachments: readonly Attachment[]): void;
|
|
133
|
+
setContextUsage(contextUsage: TuiContextUsage | undefined): void;
|
|
134
|
+
setFileSuggestions(fileSuggestions: readonly TuiChoice[]): void;
|
|
135
|
+
toggleActionDetails(): boolean;
|
|
136
|
+
clearTranscript(): void;
|
|
137
|
+
private exitCode;
|
|
138
|
+
requestExit(code?: number): void;
|
|
139
|
+
waitForExit(): Promise<number>;
|
|
140
|
+
userPrompt(content: string, attachments?: readonly Attachment[]): void;
|
|
141
|
+
command(content: string): void;
|
|
142
|
+
commandOutput(content: string): void;
|
|
143
|
+
transcriptNotice(content: string, notify?: boolean): void;
|
|
144
|
+
initializationNotice(key: string, content: string): void;
|
|
145
|
+
fileChange(change: FileChangeDiff): void;
|
|
146
|
+
notice(content: string): void;
|
|
147
|
+
dispose(): void;
|
|
148
|
+
error(content: string): void;
|
|
149
|
+
subagentLifecycle(event: SubagentLifecycleEvent): void;
|
|
150
|
+
startToolActivity(key: string, label: string, metadata?: {
|
|
151
|
+
toolName?: string;
|
|
152
|
+
kind?: CliActionKind;
|
|
153
|
+
}): {
|
|
154
|
+
complete: (isError: boolean) => void;
|
|
155
|
+
};
|
|
156
|
+
toolActivityStarted(key: string, label: string, metadata?: {
|
|
157
|
+
toolName?: string;
|
|
158
|
+
kind?: CliActionKind;
|
|
159
|
+
}): void;
|
|
160
|
+
toolActivityCompleted(key: string, isError: boolean): void;
|
|
161
|
+
status(label: string): void;
|
|
162
|
+
activity(label: string, elapsedMs: number, usage?: ChatUsage): void;
|
|
163
|
+
clearActivity(): void;
|
|
164
|
+
complete(elapsedMs: number, usage?: ChatUsage): void;
|
|
165
|
+
failed(): void;
|
|
166
|
+
cancelled(): void;
|
|
167
|
+
beginAssistant(): void;
|
|
168
|
+
/** Starts a new assistant segment after a host-owned action or approval boundary. */
|
|
169
|
+
assistantActionBoundary(): void;
|
|
170
|
+
assistantDelta(content: string): void;
|
|
171
|
+
replaceAssistant(content: string): void;
|
|
172
|
+
finishAssistant(): void;
|
|
173
|
+
confirmTrust(): Promise<boolean>;
|
|
174
|
+
confirmTool(toolName: string, detail?: string): Promise<boolean>;
|
|
175
|
+
openSubagentDetails(id: string): void;
|
|
176
|
+
closeSubagentDetails(): void;
|
|
177
|
+
selectModel(title: string, choices: readonly TuiChoice[], currentValue?: string): Promise<string | undefined>;
|
|
178
|
+
selectScope(title: string): Promise<ExtensionScope | undefined>;
|
|
179
|
+
requestSecret(label: string): Promise<string | undefined>;
|
|
180
|
+
resolveActiveModal(value: boolean | string | undefined): void;
|
|
181
|
+
private request;
|
|
182
|
+
private selectChoice;
|
|
183
|
+
private append;
|
|
184
|
+
private appendAssistant;
|
|
185
|
+
private message;
|
|
186
|
+
private updateActivity;
|
|
187
|
+
private completeToolActivity;
|
|
188
|
+
private clearPendingActivityTimer;
|
|
189
|
+
private update;
|
|
190
|
+
private flushAssistant;
|
|
191
|
+
private revealAssistant;
|
|
192
|
+
}
|
|
193
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{RESOURCE_LIMITS as c}from"../../../domain/runtime/resource-limits.js";class A{listeners=new Set;initializationNotices=new Map;state={ready:!1,runActive:!1,messages:[],subagents:[],pendingAttachments:[],fileSuggestions:[],actionDetails:!1};resolveModal;exitResolvers=new Set;submitHandler;imagePasteHandler;textPasteHandler;clearAttachmentsHandler;interruptHandler;cancelHandler;sequence=0;noticeTimer;assistantRevealTimer;pendingAssistant;assistantSegmentPending=!1;pendingActivityTimers=new Map;snapshot(){return this.state}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}setSubmitHandler(t){this.submitHandler=t}setImagePasteHandler(t){this.imagePasteHandler=t}setTextPasteHandler(t){this.textPasteHandler=t}setClearAttachmentsHandler(t){this.clearAttachmentsHandler=t}setInterruptHandler(t){this.interruptHandler=t}setCancelHandler(t){this.cancelHandler=t}async submit(t){await this.submitHandler?.(t)}async pasteImage(){await this.imagePasteHandler?.()}async pasteText(){return this.textPasteHandler?.()}interrupt(){this.interruptHandler?.()}cancel(){this.cancelHandler?.(),this.resolveActiveModal(void 0),this.update({clearBlockedUntil:Date.now()+1500})}clearAttachments(){this.clearAttachmentsHandler?.()}setReady(){this.update({ready:!0})}setRunActive(t){this.update({runActive:t})}setWelcome(t){this.update({welcome:t})}setPendingAttachments(t){this.update({pendingAttachments:t})}setContextUsage(t){this.update({contextUsage:t})}setFileSuggestions(t){this.update({fileSuggestions:t})}toggleActionDetails(){const t=!this.state.actionDetails;return this.update({actionDetails:t}),t}clearTranscript(){this.initializationNotices.clear(),this.assistantRevealTimer!==void 0&&clearTimeout(this.assistantRevealTimer),this.assistantRevealTimer=void 0,this.pendingAssistant=void 0,this.update({messages:[],subagents:[]})}exitCode;requestExit(t=0){this.exitCode??=t;for(const e of this.exitResolvers)e(this.exitCode);this.exitResolvers.clear()}waitForExit(){return this.exitCode===void 0?new Promise(t=>{this.exitResolvers.add(t)}):Promise.resolve(this.exitCode)}userPrompt(t,e=[]){this.append("user",t,e)}command(t){this.append("command",t)}commandOutput(t){this.append("notice",t)}transcriptNotice(t,e=!0){this.append("notice",t,void 0,void 0,void 0,void 0,e)}initializationNotice(t,e){this.initializationNotices.get(t)!==e&&(this.initializationNotices.set(t,e),this.transcriptNotice(e))}fileChange(t){this.append("diff",t.path,void 0,t)}notice(t){this.noticeTimer!==void 0&&clearTimeout(this.noticeTimer),this.update({footerNotice:t}),this.noticeTimer=setTimeout(()=>{this.noticeTimer=void 0,this.update({footerNotice:void 0})},4e3)}dispose(){this.noticeTimer!==void 0&&clearTimeout(this.noticeTimer),this.assistantRevealTimer!==void 0&&clearTimeout(this.assistantRevealTimer);for(const t of this.pendingActivityTimers.values())clearImmediate(t);this.pendingActivityTimers.clear(),this.noticeTimer=void 0,this.assistantRevealTimer=void 0,this.resolveActiveModal(void 0),this.initializationNotices.clear(),this.listeners.clear()}error(t){this.append("error",t)}subagentLifecycle(t){const e=this.state.modal?.kind==="subagent",i=this.state.subagents.find(n=>n.id===t.id),s={id:t.id,displayName:t.displayName,task:t.task,mode:t.mode,model:t.model,status:t.status,background:t.background,createdAt:i?.createdAt??t.timestamp,updatedAt:t.timestamp,...t.durationMs===void 0?{}:{durationMs:t.durationMs},...t.summary===void 0?{}:{summary:t.summary},...t.lastAction===void 0?i?.lastAction===void 0?{}:{lastAction:i.lastAction}:{lastAction:t.lastAction},...t.handoff===void 0?i?.handoff===void 0?{}:{handoff:i.handoff}:{handoff:t.handoff}},a=i===void 0?[...this.state.subagents,s]:this.state.subagents.map(n=>n.id===t.id?s:n);this.update({subagents:a},!e),t.type==="created"&&!this.state.messages.some(n=>n.kind==="subagent"&&n.subagent?.id===t.id)&&this.append("subagent",t.id,void 0,void 0,void 0,s,!e),(t.type==="completed"||t.type==="failed"||t.type==="cancelled")&&t.summary!==void 0&&this.transcriptNotice(`Agent ${t.displayName} ${t.status} \xB7 ${t.summary}`,!e)}startToolActivity(t,e,i){const s=this.state.messages.find(n=>n.kind==="activity"&&(n.activity?.state==="pending"||n.activity?.state==="running")&&n.content===t);let a=s?.id;if(s===void 0){const n=this.message("activity",t,void 0,void 0,{label:e,state:"running",startedAt:Date.now(),...i});a=n.id,this.update({messages:[...this.state.messages,n]})}else this.clearPendingActivityTimer(t),this.updateActivity(s.id,e,"running",i);return{complete:n=>this.completeToolActivity(a,n)}}toolActivityStarted(t,e,i){const s=this.state.messages.find(d=>d.kind==="activity"&&d.content===t&&(d.activity?.state==="pending"||d.activity?.state==="running"));if(s!==void 0){this.updateActivity(s.id,e,s.activity?.state==="pending"?"pending":"running",i);return}const a=this.message("activity",t,void 0,void 0,{label:e,state:"pending",startedAt:Date.now(),...i});this.update({messages:[...this.state.messages,a]});const n=setImmediate(()=>{this.pendingActivityTimers.delete(t);const d=this.state.messages.find(u=>u.kind==="activity"&&u.content===t&&u.activity?.state==="pending");d!==void 0&&this.updateActivity(d.id,e,"running",i)});this.pendingActivityTimers.set(t,n)}toolActivityCompleted(t,e){this.clearPendingActivityTimer(t);const i=this.state.messages.find(s=>s.kind==="activity"&&s.content===t&&(s.activity?.state==="pending"||s.activity?.state==="running"));i!==void 0&&this.completeToolActivity(i.id,e)}status(t){this.update({status:t,activityStartedAt:Date.now(),elapsedMs:void 0,usage:void 0})}activity(t,e,i){this.update({status:t,...this.state.activityStartedAt===void 0?{activityStartedAt:Date.now()-e}:{},elapsedMs:e,...i===void 0?{}:{usage:i}})}clearActivity(){this.update({status:void 0,activityStartedAt:void 0,elapsedMs:void 0,usage:void 0})}complete(t,e){this.update({status:"Done",elapsedMs:t,...e===void 0?{}:{usage:e}})}failed(){this.update({status:"Failed",elapsedMs:void 0,usage:void 0})}cancelled(){this.update({status:"Cancelled",elapsedMs:void 0,usage:void 0})}beginAssistant(){this.flushAssistant(),this.assistantSegmentPending=!1,this.appendAssistant("")}assistantActionBoundary(){this.flushAssistant(),this.assistantSegmentPending=!0}assistantDelta(t){if(this.assistantSegmentPending){this.assistantSegmentPending=!1,this.appendAssistant(t);return}const e=this.state.messages.at(-1);if(e?.kind!=="assistant"){this.flushAssistant(),this.appendAssistant(t);return}const i=this.pendingAssistant;this.pendingAssistant={id:e.id,content:`${i?.id===e.id?i.content:e.content}${t}`},this.revealAssistant()}replaceAssistant(t){this.assistantRevealTimer!==void 0&&clearTimeout(this.assistantRevealTimer),this.assistantRevealTimer=void 0,this.pendingAssistant=void 0,this.assistantSegmentPending=!1;let e=-1;for(let s=this.state.messages.length-1;s>=0;s-=1)if(this.state.messages[s]?.kind==="user"){e=s;break}const i=this.state.messages.filter((s,a)=>a<=e||s.kind!=="assistant");this.update({messages:o([...i,this.message("assistant",t)])})}finishAssistant(){this.revealAssistant(),this.assistantSegmentPending=!1}confirmTrust(){return this.request({kind:"trust"}).then(t=>t===!0)}confirmTool(t,e){return this.request({kind:"approval",toolName:t,...e===void 0?{}:{detail:e}}).then(i=>i==="allow"||i===!0)}openSubagentDetails(t){if(this.state.modal!==void 0)return;const e=this.state.subagents.find(i=>i.id===t);e!==void 0&&this.update({modal:{kind:"subagent",subagent:e}})}closeSubagentDetails(){this.state.modal?.kind==="subagent"&&this.update({modal:void 0})}selectModel(t,e,i){return this.selectChoice(t,e,i)}selectScope(t){return this.selectChoice(t,[{value:"user",label:"User",description:"Available across your projects"},{value:"project",label:"Project",description:"Stored in the trusted project"}]).then(e=>e==="user"||e==="project"?e:void 0)}requestSecret(t){return this.request({kind:"secret",label:t}).then(e=>typeof e=="string"?e:void 0)}resolveActiveModal(t){const e=this.resolveModal;e!==void 0&&(this.resolveModal=void 0,this.update({modal:void 0}),e?.(t))}request(t){if(this.resolveModal!==void 0)throw new Error("A TUI decision is already active.");return this.update({modal:t}),new Promise(e=>{this.resolveModal=e})}selectChoice(t,e,i){return this.request({kind:"choice",title:t,choices:e,...i===void 0?{}:{currentValue:i}}).then(s=>typeof s=="string"?s:void 0)}append(t,e,i,s,a,n,d=!0){this.update({messages:o([...this.state.messages,this.message(t,e,i,s,a,n)])},d)}appendAssistant(t){const e=this.message("assistant","");this.update({messages:o([...this.state.messages,e])}),this.pendingAssistant={id:e.id,content:t},this.revealAssistant()}message(t,e,i,s,a,n){return{id:`tui-${++this.sequence}`,kind:t,content:e,...i===void 0||i.length===0?{}:{attachments:i},...s===void 0?{}:{fileChange:s},...a===void 0?{}:{activity:a},...n===void 0?{}:{subagent:n}}}updateActivity(t,e,i,s){const a=this.state.messages.map(n=>n.id===t&&n.activity!==void 0?{...n,content:n.content,activity:{...n.activity,label:e,state:i,...s}}:n);this.update({messages:a})}completeToolActivity(t,e){const i=this.state.messages.find(s=>s.id===t&&s.activity!==void 0);i?.activity===void 0||i.activity.state!=="pending"&&i.activity.state!=="running"||this.update({messages:this.state.messages.map(s=>s.id===t&&s.activity!==void 0?{...s,activity:{...s.activity,state:e?"failed":"completed",elapsedMs:Date.now()-s.activity.startedAt}}:s)})}clearPendingActivityTimer(t){const e=this.pendingActivityTimers.get(t);e!==void 0&&(clearImmediate(e),this.pendingActivityTimers.delete(t))}update(t,e=!0){if(this.state={...this.state,...t},!!e)for(const i of this.listeners)i()}flushAssistant(){this.assistantRevealTimer!==void 0&&(clearTimeout(this.assistantRevealTimer),this.assistantRevealTimer=void 0);const t=this.pendingAssistant;if(t===void 0)return;this.pendingAssistant=void 0;const e=this.state.messages.findIndex(a=>a.id===t.id);if(e<0)return;const i=[...this.state.messages],s=i[e];s===void 0||s.kind!=="assistant"||(i[e]={...s,content:t.content},this.update({messages:i}))}revealAssistant(){const t=this.pendingAssistant;if(t===void 0)return;const e=this.state.messages.findIndex(l=>l.id===t.id);if(e<0){this.pendingAssistant=void 0;return}const i=this.state.messages[e];if(i===void 0||i.kind!=="assistant"){this.pendingAssistant=void 0;return}const s=Array.from(t.content),a=Array.from(i.content),n=a.length===0,d=Math.min(s.length,a.length+(n?p:m)),u=d>=s.length,h=[...this.state.messages];if(h[e]={...i,content:s.slice(0,d).join("")},this.update({messages:h}),u){this.pendingAssistant=void 0,this.assistantRevealTimer!==void 0&&(clearTimeout(this.assistantRevealTimer),this.assistantRevealTimer=void 0);return}this.assistantRevealTimer===void 0&&(this.assistantRevealTimer=setTimeout(()=>{this.assistantRevealTimer=void 0,this.revealAssistant()},f))}}const f=16,p=64,m=8;function o(r){if(r.length<=c.tuiTranscriptMessages)return r;const t=r.filter(s=>s.activity?.state==="pending"||s.activity?.state==="running"||s.subagent?.status==="queued"||s.subagent?.status==="running"),e=r.slice(-c.tuiTranscriptMessages);return[...t,...e.filter(s=>!t.some(a=>a.id===s.id))].slice(-c.tuiTranscriptMessages)}export{A as InkTuiBridge};
|
|
@@ -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 @@
|
|
|
1
|
+
function t(s,e,n=process.env){const c=s.isTTY===!0&&e.isTTY===!0,i=c&&n.NO_COLOR===void 0&&n.TERM!=="dumb",o=n.LOTAGATE_ASCII!=="1",r=typeof e.columns=="number"&&e.columns>0?e.columns:80;return{isInteractive:c,colorEnabled:i,unicodeEnabled:o,width:r}}export{t as detectTerminalCapabilities};
|
|
@@ -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 @@
|
|
|
1
|
+
const o="\x1B",u=/^\[<(\d+);(\d+);(\d+)([mM])$/u;function s(e){const n=u.exec(r(e));if(n===null)return;const t=Number(n[1]);if((t&64)!==0)return(t&1)===0?"up":"down"}function c(e){return/^\[<[0-9;]+[mM]$/u.test(r(e))}function r(e){return e.startsWith("\x1B")?e.slice(1):e}export{c as isMouseSequence,s as parseMouseWheel};
|
|
@@ -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 @@
|
|
|
1
|
+
const E="\x1B[2J\x1B[H",n="\x1B[?1049h",r="\x1B[?1049l",t="\x1B[?1000h\x1B[?1006h",c="\x1B[?1006l\x1B[?1000l";function i(e){e.write(E)}function S(e){e.write(n),i(e),e.write(t)}function _(e){e.write(c),e.write(r)}export{i as clearTerminalScreen,S as enterInteractiveScreen,_ as exitInteractiveScreen};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import type { CliAgentRunRequest } from '../../application/agent/cli-agent-run-request.js';
|
|
8
|
+
export interface TuiAgentEventRunnerOptions {
|
|
9
|
+
prepared: PreparedCliAgent;
|
|
10
|
+
input: string;
|
|
11
|
+
userInput?: string;
|
|
12
|
+
workspaceContext?: string;
|
|
13
|
+
inputContent?: CliAgentRunRequest['inputContent'];
|
|
14
|
+
model: string;
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
turnId?: string;
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
agentSessionStore: CliAgentSessionStore;
|
|
19
|
+
tracker: AgentRunTracker;
|
|
20
|
+
runtime: CliRuntime;
|
|
21
|
+
renderer: InkTuiBridge;
|
|
22
|
+
startedAt: number;
|
|
23
|
+
getUsage: () => ChatUsage | undefined;
|
|
24
|
+
appendAssistantDelta: (content: string) => void;
|
|
25
|
+
replaceAssistantResponse: (content: string) => void;
|
|
26
|
+
hasResponse: () => boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Owns the CLI projection of the Agent SDK event stream for interactive runs. */
|
|
29
|
+
export declare function runTuiAgentEvents(options: TuiAgentEventRunnerOptions): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CliTurnEventProjector as i}from"../../application/orchestration/cli-turn-event-projector.js";import{persistCliTurnEvent as d}from"../../application/orchestration/cli-turn-persistence.js";import{persistContextCompaction as s}from"../../application/agent/context-compaction-persistence.js";import{renderAgentInitialization as c}from"./agent-initialization-renderer.js";import{throwIfAborted as l}from"./tui-lifecycle-actions.js";import{agentLimitNotice as f,classifyAgentLimit as m}from"../../application/agent/agent-limit.js";async function w(e){const a=new i;if(c(e.renderer,await e.prepared.agent.initialize()),e.sessionId!==void 0){const r=await e.runtime.sessionStore.readHistory(e.sessionId);e.agentSessionStore.hydrate(e.sessionId,r.transcript,r.events,e.input)}for await(const r of e.prepared.run({input:e.input,...e.userInput===void 0?{}:{userInput:e.userInput},...e.workspaceContext===void 0?{}:{workspaceContext:e.workspaceContext},...e.inputContent===void 0?{}:{inputContent:e.inputContent},model:e.model,...e.sessionId===void 0?{}:{sessionId:e.sessionId},signal:e.signal})){l(e.signal),e.tracker.observe(r);for(const t of a.observe(r)){if(e.sessionId!==void 0)try{await d(e.runtime.sessionStore,e.sessionId,t,{...e.turnId===void 0?{}:{turnId:e.turnId}})}catch(n){e.runtime.logger.warn("Unable to persist agent lifecycle event.",{eventType:t.type,reason:n instanceof Error?n.message:String(n)})}t.type==="assistant.delta"&&e.appendAssistantDelta(t.content),t.type==="assistant.replaced"&&e.replaceAssistantResponse(t.content),t.type==="assistant.segment.completed"&&(e.renderer.assistantActionBoundary(),t.phase==="final"&&e.renderer.complete(Date.now()-e.startedAt,e.getUsage())),t.type==="action.approval_requested"&&(e.renderer.assistantActionBoundary(),e.renderer.status("Waiting for approval")),t.type==="action.started"&&(e.renderer.assistantActionBoundary(),e.runtime.logger.info("Agent tool called.",{toolName:t.toolName,actionId:t.actionId}),t.toolName!=="agent.spawn"&&e.renderer.toolActivityStarted(t.actionId,t.displayName,{toolName:t.toolName,kind:t.kind})),t.type==="action.completed"&&(e.runtime.logger.info("Agent tool completed.",{toolName:t.toolName,actionId:t.actionId,isError:t.isError}),e.renderer.toolActivityCompleted(t.actionId,t.isError))}if(r.type==="context.compacted"&&(e.sessionId!==void 0&&await s(e.runtime,e.prepared,e.sessionId,r.metrics,e.turnId),e.renderer.transcriptNotice("Context compacted automatically."),e.renderer.activity("Thinking",Date.now()-e.startedAt,e.getUsage())),r.type==="session.failed"){const t=m(r.error);if(t===void 0)throw r.error;e.tracker.markStuck(),e.sessionId!==void 0&&e.agentSessionStore.delete(e.sessionId);const n=f(t);e.hasResponse()?e.renderer.notice(n):e.appendAssistantDelta(n);return}r.type==="session.completed"&&!e.hasResponse()&&e.appendAssistantDelta(r.content)}}export{w as runTuiAgentEvents};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { TerminalOutput } from './terminal-capabilities.js';
|
|
3
|
+
export interface TuiApplicationOptions {
|
|
4
|
+
input?: Readable & {
|
|
5
|
+
isTTY?: boolean;
|
|
6
|
+
};
|
|
7
|
+
output?: TerminalOutput;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function formatResumeCommand(sessionId: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatCommandInvocation as r}from"../../application/commands/command-presentation.js";import{COMMAND_REGISTRY as n}from"../../application/commands/command-runtime.js";function m(o){const e=n.get("session.resume.direct");if(e===void 0)throw new Error("Missing session resume command contract.");return r(e,"direct",[o],new Map([["interactive",!0]]))}export{m as formatResumeCommand};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
2
|
+
import type { TuiCommandContext } from './tui-command-context.js';
|
|
3
|
+
import type { ScopedSkill } from '../../infrastructure/extensions/skill-manager.js';
|
|
4
|
+
import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
|
|
5
|
+
import type { ExtensionScope } from '../../domain/extensions/extension-scope.js';
|
|
6
|
+
import type { TuiContextSnapshot } from './context-display.js';
|
|
7
|
+
import type { GoalTurnCallbacks } from '../../application/orchestration/goal-runner.js';
|
|
8
|
+
import type { CreateGoalInput } from '../../domain/orchestration/goal.js';
|
|
9
|
+
import { type TuiApplicationOptions } from './tui-application-contract.js';
|
|
10
|
+
export declare class TuiApplication {
|
|
11
|
+
private readonly runtime;
|
|
12
|
+
private readonly cwd;
|
|
13
|
+
private readonly options;
|
|
14
|
+
private readonly input;
|
|
15
|
+
private readonly output;
|
|
16
|
+
private readonly renderer;
|
|
17
|
+
private readonly pendingAttachments;
|
|
18
|
+
private session;
|
|
19
|
+
private hookRuntime;
|
|
20
|
+
private hooks;
|
|
21
|
+
private skillRootScopes;
|
|
22
|
+
private enabledPluginNames;
|
|
23
|
+
private pluginMcpConfig;
|
|
24
|
+
private activeAbortController;
|
|
25
|
+
private activePromptRun;
|
|
26
|
+
private activeForegroundRun;
|
|
27
|
+
private exitArmedUntil;
|
|
28
|
+
private lastInterruptAt;
|
|
29
|
+
private printResumeCommandOnExit;
|
|
30
|
+
private activeModel;
|
|
31
|
+
private activeProfile;
|
|
32
|
+
private readonly approvals;
|
|
33
|
+
private readonly contextService;
|
|
34
|
+
private readonly agentSessionStore;
|
|
35
|
+
private subagentJobs;
|
|
36
|
+
private readonly executionWorkspaces;
|
|
37
|
+
private executionWorkspace;
|
|
38
|
+
constructor(runtime: CliRuntime, cwd: string, options?: TuiApplicationOptions);
|
|
39
|
+
run(): Promise<number>;
|
|
40
|
+
private processPrompt;
|
|
41
|
+
private attachClipboardImage;
|
|
42
|
+
runPrompt(prompt: string, initialSkill?: SkillManifest, goalCallbacks?: GoalTurnCallbacks): Promise<string>;
|
|
43
|
+
runGoal(objective: string, context: TuiCommandContext, limits?: Omit<CreateGoalInput, 'objective'>): Promise<void>;
|
|
44
|
+
resumeGoal(context: TuiCommandContext): Promise<void>;
|
|
45
|
+
private sendPrompt;
|
|
46
|
+
private executePrompt;
|
|
47
|
+
private commandContext;
|
|
48
|
+
getActiveModel(): string | null;
|
|
49
|
+
getActiveProfile(): string | null;
|
|
50
|
+
refreshExtensions(): Promise<void>;
|
|
51
|
+
refreshWelcome(overrides?: {
|
|
52
|
+
model?: string | null;
|
|
53
|
+
profile?: string | null;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
getContextSnapshot(): Promise<TuiContextSnapshot>;
|
|
56
|
+
private refreshContextUsage;
|
|
57
|
+
runSkill(name: string, args: readonly string[], context: TuiCommandContext, availableSkills?: readonly ScopedSkill[], scope?: ExtensionScope): Promise<void>;
|
|
58
|
+
private reloadExtensions;
|
|
59
|
+
compactSession(): Promise<void>;
|
|
60
|
+
resumeSession(sessionId: string): Promise<void>;
|
|
61
|
+
private handleInterrupt;
|
|
62
|
+
private awaitActiveForegroundRun;
|
|
63
|
+
private runHookEvent;
|
|
64
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createElement as J}from"react";import{render as z}from"ink";import{AuthenticationService as q}from"../../application/auth/authentication-service.js";import{createLotaGateClient as V}from"../../infrastructure/sdk/lotagate-client-factory.js";import{detectTerminalCapabilities as Y}from"./terminal-capabilities.js";import{enterInteractiveScreen as K,exitInteractiveScreen as Q}from"./terminal-screen.js";import{buildUserMessage as X,createImageAttachment as Z,normalizeImage as ee}from"../../infrastructure/clipboard/image-normalizer.js";import{PendingAttachmentStore as te}from"../../application/chat/pending-attachment-store.js";import{CLI_VERSION as x}from"../../version.js";import{asCliError as ie,CliError as se}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as I}from"../../domain/errors/error-codes.js";import{InkTuiBridge as ne}from"./ink/tui-bridge.js";import{LotaGateTui as re}from"./ink/lotagate-tui.js";import{estimateTurnUsage as oe}from"../../infrastructure/tokens/tiktoken-token-estimator.js";import{WorkspaceFileIndex as ae}from"../../application/workspace/workspace-file-index.js";import{ProjectSessionAccess as de}from"../../application/session/project-session-access.js";import{createTuiCommandHost as ce}from"./tui-command-host-factory.js";import{workspaceFileSuggestions as le}from"./tui-file-suggestions.js";import{AUTH_LOGIN_HINT as ue,MODEL_SELECT_HINT as he,formatCliErrorMessage as me,formatCommandHint as R}from"../../application/commands/command-hints.js";import{AgentRunTracker as pe}from"../../application/agent/agent-run-tracker.js";import{prepareCliAgent as fe,warmMcpRuntime as M}from"../../application/agent/cli-agent-execution-service.js";import{TuiToolApprovalCoordinator as ge}from"./tui-tool-approval.js";import{TuiContextService as we}from"./tui-context-service.js";import{createTuiClipboardPasteHandlers as ve}from"./tui-clipboard-paste-handlers.js";import{dispatchTuiPrompt as Se}from"./tui-prompt-dispatcher.js";import{CliAgentSessionStore as Ce,retainLatestCompaction as U}from"../../application/agent/agent-session-store.js";import{createTuiContextManagement as xe}from"./tui-context-compaction.js";import{compactManualTuiSession as be}from"./tui-manual-compaction.js";import{resolveInitialModel as j}from"./tui-initial-model.js";import{cancelTuiResponse as Ae,handleTuiInterrupt as Pe,isAbortError as W,runTuiHookEvent as ke,throwIfAborted as k}from"./tui-lifecycle-actions.js";import{loadExecutionConfig as F}from"../../application/config/execution-config.js";import{resumeTuiGoal as ye,runTuiGoal as Te}from"./tui-goal-controller.js";import{runTuiSkill as Ee}from"./tui-skill-controller.js";import{SubagentJobRegistry as L}from"../../application/orchestration/cli-subagent-service.js";import{formatResumeCommand as Ie}from"./tui-application-contract.js";import{runTuiAgentEvents as Re}from"./tui-agent-event-runner.js";import{createTurnId as Me,recordTurnCompletion as Ue,recordTurnFailure as je,recordTurnStart as We}from"../../application/session/session-turn-lifecycle.js";import{SessionExecutionWorkspaceService as Fe}from"../../application/workspace/session-execution-workspace.js";import{loadTuiExtensions as Le}from"./tui-extension-loader.js";class At{runtime;cwd;options;input;output;renderer;pendingAttachments=new te;session;hookRuntime;hooks=[];skillRootScopes=[];enabledPluginNames=[];pluginMcpConfig={};activeAbortController;activePromptRun;activeForegroundRun;exitArmedUntil=0;lastInterruptAt=0;printResumeCommandOnExit=!1;activeModel=null;activeProfile=null;approvals;contextService;agentSessionStore=new Ce;subagentJobs=new L;executionWorkspaces;executionWorkspace;constructor(n,t,i={}){this.runtime=n,this.cwd=t,this.options=i,this.input=i.input??process.stdin,this.output=i.output??process.stdout,this.renderer=new ne,this.executionWorkspaces=this.runtime.executionWorkspaces??new Fe(this.runtime.paths.globalConfigDir,this.runtime.platform),this.contextService=new we(this.runtime,this.cwd),this.approvals=new ge({renderer:this.renderer,runtime:this.runtime,getSessionId:()=>this.session?.id,getActiveSignal:()=>this.activeAbortController?.signal}),this.renderer.setInterruptHandler(()=>this.handleInterrupt()),this.renderer.setCancelHandler(()=>Ae(this.activeAbortController,this.renderer));const r=ve({platform:this.runtime.platform,notify:s=>this.renderer.notice(s),attachImage:s=>this.attachClipboardImage(s,!1)});this.renderer.setImagePasteHandler(r.image),this.renderer.setTextPasteHandler(r.text),this.renderer.setClearAttachmentsHandler(()=>{this.pendingAttachments.clear(),this.renderer.setPendingAttachments([])})}async run(){if(!Y(this.input,this.output).isInteractive)return this.output.write('Interactive TUI requires a terminal. Use `lotagate chat "prompt"` for non-interactive streaming.\n'),2;K(this.output);const t=z(J(re,{bridge:this.renderer}),{stdin:this.input,stdout:this.output,exitOnCtrlC:!1}),i=()=>this.handleInterrupt();process.on("SIGINT",i);let r="completed";try{const s=await this.runtime.projectTrust.inspect(this.cwd);let d=await this.runtime.projectTrust.isTrusted(s),o=await this.runtime.configLoader.load(this.cwd,{includeProject:d}),g=await j(this.runtime,o.config),l={...o,config:{...o.config,model:g}};if(this.activeModel=l.config.model,this.activeProfile=l.config.profile,this.renderer.setWelcome({version:x,cwd:s.canonicalPath,model:l.config.model,profile:l.config.profile,trusted:d}),this.renderer.setFileSuggestions([]),d||(d=await this.renderer.confirmTrust(),d?(await this.runtime.projectTrust.grant(s),o=await this.runtime.configLoader.load(this.cwd),g=await j(this.runtime,o.config),l={...o,config:{...o.config,model:g}},this.activeModel=l.config.model,this.activeProfile=l.config.profile,this.renderer.setWelcome({version:x,cwd:s.canonicalPath,model:this.activeModel,profile:this.activeProfile,trusted:!0}),this.renderer.notice("Project trusted.")):this.renderer.notice("Project remains untrusted; local tools and extensions stay disabled.")),d&&await this.runtime.workspaceSettings.ensureInitialized(s.canonicalPath),await this.reloadExtensions(d,l.config.approvalMode,s.canonicalPath),this.options.sessionId!==void 0){const a=await this.runtime.sessionStore.get(this.options.sessionId);if(a===void 0)throw new Error(`Session not found: ${this.options.sessionId}`);if(a.projectFingerprint!==s.fingerprint)throw new Error("Session belongs to another project.");this.session=a,this.renderer.status(`Resuming session ${a.id}`);for(const w of U(await this.runtime.sessionStore.readTranscript(a.id)))w.type==="user"?this.renderer.userPrompt(w.content):w.type==="assistant"&&(this.renderer.beginAssistant(),this.renderer.assistantDelta(w.content),this.renderer.finishAssistant())}else this.session=await this.runtime.sessionStore.create({projectFingerprint:s.fingerprint,cwd:s.canonicalPath,model:l.config.model,profile:l.config.profile,status:"active"});return this.executionWorkspace=await this.executionWorkspaces.prepare({sessionId:this.session.id,projectRoot:s.canonicalPath}),await this.refreshContextUsage(),await this.runHookEvent("session.start",this.session.id),M(this.runtime,this.cwd).catch(a=>this.runtime.logger.warn("MCP session warm-up failed.",{reason:a instanceof Error?a.message:String(a)})),this.renderer.setSubmitHandler(async a=>{await this.processPrompt(a)&&this.renderer.requestExit()}),this.renderer.clearActivity(),this.renderer.setReady(),new ae(s.canonicalPath).listEntries().then(a=>this.renderer.setFileSuggestions(le(a))).catch(a=>this.runtime.logger.debug("Unable to load workspace file suggestions.",{reason:a instanceof Error?a.message:String(a)})),await this.renderer.waitForExit()}catch(s){throw r=W(s)?"cancelled":"failed",s}finally{this.activeAbortController?.abort(new Error("Interactive session is closing.")),this.renderer.resolveActiveModal(void 0),await this.awaitActiveForegroundRun();try{await this.subagentJobs.close()}catch(s){this.runtime.logger.warn("Unable to close subagent jobs during TUI shutdown.",{reason:s instanceof Error?s.message:String(s)})}if(this.session!==void 0){try{await this.runHookEvent("session.end",this.session.id)}catch(s){this.runtime.logger.warn("Session end hook failed during TUI shutdown.",{sessionId:this.session.id,reason:s instanceof Error?s.message:String(s)})}try{await this.runtime.sessionStore.updateStatus(this.session.id,r)}catch(s){this.runtime.logger.warn("Unable to update TUI session status during shutdown.",{sessionId:this.session.id,reason:s instanceof Error?s.message:String(s)})}try{await this.executionWorkspaces.markReady(this.session.id)}catch(s){this.runtime.logger.warn("Unable to release TUI execution workspace.",{sessionId:this.session.id,reason:s instanceof Error?s.message:String(s)})}}process.off("SIGINT",i),this.renderer.dispose(),t.unmount(),Q(this.output),this.printResumeCommandOnExit&&this.session!==void 0&&this.output.write(`
|
|
2
|
+
${Ie(this.session.id)}
|
|
3
|
+
`)}}async processPrompt(n){if(this.activeForegroundRun!==void 0)return this.renderer.notice("An operation is already running. Stop it before starting another one."),!1;const t=Se(n,{renderer:this.renderer,logger:this.runtime.logger,commandHost:ce({runtime:this.runtime,cwd:this.cwd,renderer:this.renderer,pendingAttachments:this.pendingAttachments,getHooks:()=>this.hooks,getSession:()=>this.session,getActiveAbortController:()=>this.activeAbortController,setActiveAbortController:i=>{this.activeAbortController=i},attachClipboardImage:i=>this.attachClipboardImage(i),runPrompt:(i,r)=>this.sendPrompt(i,this.pendingAttachments.list(),r),runGoal:(i,r,s)=>this.runGoal(i,r,s),resumeGoal:i=>this.resumeGoal(i),runSkill:(i,r,s,d,o)=>this.runSkill(i,r,s,d,o),refreshExtensions:()=>this.refreshExtensions(),compactSession:()=>this.compactSession(),refreshWelcome:i=>this.refreshWelcome(i),getContextSnapshot:()=>this.getContextSnapshot(),resumeSession:i=>this.resumeSession(i)}),pendingAttachments:this.pendingAttachments,commandContext:()=>this.commandContext(),sendPrompt:(i,r)=>this.sendPrompt(i,r),resetActiveAbortController:()=>{this.activePromptRun===void 0&&(this.activeAbortController=void 0)}});this.activeForegroundRun=t;try{return await t}finally{this.activeForegroundRun===t&&(this.activeForegroundRun=void 0)}}async attachClipboardImage(n,t=!0){if(n===void 0){t&&this.renderer.notice("Clipboard does not contain an image.");return}const i=ee(n.bytes,n.mimeType);this.pendingAttachments.assertCanAdd(i.bytes.byteLength);const r=this.pendingAttachments.nextId(),s=Z(i,"clipboard",r),d=this.session===void 0?s:await this.runtime.sessionStore.saveAttachment(this.session.id,s,i.bytes);this.pendingAttachments.add({attachment:d,bytes:i.bytes}),this.renderer.setPendingAttachments(this.pendingAttachments.list().map(({attachment:o})=>o)),t&&this.renderer.notice(`Attached ${s.name} \xB7 ${s.mimeType} \xB7 ${s.sizeBytes} bytes`)}async runPrompt(n,t,i){return this.sendPrompt(n,this.pendingAttachments.list(),t,i)}async runGoal(n,t,i={}){if(this.activePromptRun!==void 0){t.write("Stop the active response before starting a goal.");return}await Te({runtime:this.runtime,cwd:this.cwd,sessionId:this.session?.id,model:this.activeModel??this.session?.model??null,profile:this.activeProfile??this.session?.profile??null,runPrompt:(r,s)=>this.runPrompt(r,void 0,s),write:r=>t.write(r)},n,i)}async resumeGoal(n){if(this.activePromptRun!==void 0){n.write("Stop the active response before resuming a goal.");return}await ye({runtime:this.runtime,cwd:this.cwd,sessionId:this.session?.id,model:this.activeModel??this.session?.model??null,profile:this.activeProfile??this.session?.profile??null,runPrompt:(t,i)=>this.runPrompt(t,void 0,i),write:t=>n.write(t)})}async sendPrompt(n,t=[],i,r){if(this.activePromptRun!==void 0)return this.renderer.notice("A response is already running. Stop it before sending another prompt."),"";const s=this.executePrompt(n,t,i,r);this.activePromptRun=s,this.renderer.setRunActive(!0);try{return await s}finally{this.activePromptRun===s&&(this.activePromptRun=void 0),this.renderer.setRunActive(!1)}}async executePrompt(n,t=[],i,r){const s=await F(this.runtime,this.cwd),d=this.activeModel??s.config.model;if(d===null)return this.renderer.error(`No model is selected. ${R(he,"tui")}`),"";const o=this.activeProfile??s.config.profile??q.defaultProfileName(),g=await this.runtime.credentialStore.get(o);if(g===void 0)return this.renderer.error(`No API key is configured. ${R(ue,"tui")}`),"";const l=await this.runtime.projectTrust.inspect(this.cwd);this.session!==void 0&&(this.executionWorkspace=await this.executionWorkspaces.prepare({sessionId:this.session.id,projectRoot:l.canonicalPath})),await this.runHookEvent("prompt.before",this.session?.id??"tui"),this.renderer.userPrompt(n,t.map(({attachment:e})=>e));const a=Me();this.session!==void 0&&await We(this.runtime.sessionStore,this.session.id,a,n,t.map(({attachment:e})=>e.id));const w=Date.now();let S,b=!1;this.renderer.status("Thinking");const v=new AbortController;this.activeAbortController=v;const y=V(g.profile,g.apiKey),H=await this.runtime.projectTrust.isTrusted(l),c=this.session===void 0?void 0:await this.runtime.goalStore.get(this.session.id),h=new pe,N={start:e=>this.renderer.startToolActivity(e.key,e.label)},D={onSubagentLifecycle:e=>{e.sessionId===this.session?.id&&this.renderer.subagentLifecycle(e)}},O=await this.contextService.getModelContextWindow(d,o),G=e=>{h.observeModel(e),e.usage!==void 0&&(b=!0,r?.onUsage({usage:e.usage,modelCalls:1})),this.runtime.logger.debug("Model turn completed.",{model:e.model,stream:e.stream,contentLength:e.contentLength,toolCallCount:e.toolCallCount,toolNames:e.toolNames,finishReason:e.finishReason})},C=await fe({runtime:this.runtime,projectRoot:l.canonicalPath,executionCwd:this.executionWorkspace.executionCwd,model:d,reasoningEffort:s.config.effort,client:y,profile:H?"interactive-trusted":"interactive-untrusted",approvalMode:s.config.approvalMode,subagentJobs:this.subagentJobs,...i===void 0?{}:{initialSkill:i},onWrite:e=>this.renderer.fileChange(e),prompt:e=>this.approvals.ask(e),rememberApproval:e=>this.approvals.remember(l.canonicalPath,e),onApprovalPersistenceFailure:(e,f)=>this.approvals.rememberFailure(f),audit:e=>this.approvals.audit(e),onModelComplete:G,onSubagentModelComplete:e=>{e.usage!==void 0&&r?.onUsage({usage:e.usage,modelCalls:1})},contextManagement:xe(y,d,O,e=>this.runtime.logger.warn("Context summarization failed; using fallback summary.",{reason:e instanceof Error?e.message:String(e)})),agentSessionStore:this.agentSessionStore,toolActivity:N,onIntentLifecycle:e=>{e.type==="intent.compiled"?this.renderer.status("Understanding the task"):e.type==="intent.verification.required"?this.renderer.status("Verifying the result"):e.type==="intent.blocked"&&this.renderer.status("Verification is incomplete")},subagentLifecycle:D,...c===void 0?{}:{goal:{objective:c.objective,status:c.status,turns:c.turns,evaluatorRuns:c.evaluatorRuns,tokensUsed:c.usage.totalTokens,...c.tokenBudget===void 0?{}:{tokenBudget:c.tokenBudget},...c.maxTurns===void 0?{}:{maxTurns:c.maxTurns},...c.maxDurationMs===void 0?{}:{maxDurationMs:c.maxDurationMs},...c.lastError===void 0?{}:{lastError:c.lastError},...c.lastEvaluation===void 0?{}:{lastEvaluation:c.lastEvaluation.reason}}}}),p=[];let A=!1;const _=e=>{k(v.signal),p.push(e),this.renderer.assistantDelta(e)},$=e=>{k(v.signal),p.splice(0,p.length,e),this.renderer.replaceAssistant(e)};try{k(v.signal);const e=await C.buildInput(n),f=e.input,u=t.length===0?void 0:X(f,t),T=u?.content===null?void 0:u?.content;if(await Re({prepared:C,input:f,userInput:e.userInput,...e.workspaceContext===void 0?{}:{workspaceContext:e.workspaceContext},...T===void 0?{}:{inputContent:T},model:d,...this.session===void 0?{}:{sessionId:this.session.id},turnId:a,signal:v.signal,agentSessionStore:this.agentSessionStore,tracker:h,runtime:this.runtime,renderer:this.renderer,startedAt:w,getUsage:()=>S,appendAssistantDelta:_,replaceAssistantResponse:$,hasResponse:()=>p.length>0}),p.join("").trim().length===0){const m=h.snapshot();m.toolCalls>0&&h.markStuck();const B=m.toolCalls>0?I.MODEL_EMPTY_FINAL:I.MODEL_PROTOCOL_EMPTY_RESPONSE,E=m.toolCalls>0?"The model completed its tool work without a final text response.":"The model returned neither text nor a tool call.";throw new se(B,E,{category:"model",userMessage:`${E} Check the selected model and gateway tool-calling support, then try again.`,retryable:!0,details:{modelTurns:m.modelTurns,toolCalls:m.toolCalls,toolCompletions:m.toolCompletions,toolFailures:m.toolFailures,toolNames:m.toolNames,finishReason:m.lastFinishReason}})}this.session!==void 0&&(await this.executionWorkspaces.apply(this.session.id),A=!0),r?.onSnapshot(h.snapshot())}catch(e){const f=v.signal.aborted||W(e);if(this.session!==void 0&&!A)try{const u=await this.executionWorkspaces.apply(this.session.id);A=!0,u.appliedPaths.length>0&&this.runtime.logger.info("Applied session workspace changes after turn failure.",{sessionId:this.session.id,turnId:a,appliedPaths:u.appliedPaths})}catch(u){this.runtime.logger.error("Failed to apply session workspace changes after turn failure.",{sessionId:this.session.id,turnId:a,reason:u instanceof Error?u.message:String(u)})}if(this.session!==void 0&&this.agentSessionStore.delete(this.session.id),f?h.markCancelled():h.snapshot().state!=="stuck"&&h.markFailed(),this.session!==void 0&&await je(this.runtime.sessionStore,this.session.id,a,e,f),this.renderer.finishAssistant(),f)this.renderer.notice("Interrupted.");else{const u=ie(e);this.renderer.failed(),this.runtime.logger.error("Agent run failed.",{code:u.code,category:u.category,...u.details??{}}),this.renderer.error(me(u,"tui"))}return r?.onError(e),r?.onSnapshot(h.snapshot()),""}finally{if(this.activeAbortController===v&&(this.activeAbortController=void 0),C!==void 0)try{await C.close()}catch(e){this.runtime.logger.warn("Agent cleanup failed after a completed turn.",{reason:e instanceof Error?e.message:String(e)})}if(this.session!==void 0)try{await this.executionWorkspaces.markReady(this.session.id)}catch(e){this.runtime.logger.warn("Unable to release TUI execution workspace after turn.",{sessionId:this.session.id,reason:e instanceof Error?e.message:String(e)})}}this.renderer.finishAssistant();try{this.session!==void 0&&await Ue(this.runtime.sessionStore,this.session.id,a,p.join(""))}catch(e){this.runtime.logger.warn("Unable to persist the completed turn.",{reason:e instanceof Error?e.message:String(e)}),this.renderer.notice("Response completed, but the session state could not be saved.")}try{await this.runHookEvent("response.after",this.session?.id??"tui")}catch(e){this.runtime.logger.warn("Response hook failed after a completed turn.",{reason:e instanceof Error?e.message:String(e)}),this.renderer.notice("Response completed, but the response hook failed.")}this.pendingAttachments.clear(),this.renderer.setPendingAttachments([]),!b&&S!==void 0&&r?.onUsage({usage:S,modelCalls:1});const P=S?.totalTokens===void 0?oe({model:d,prompt:n,response:p.join("")}):S;return!b&&S===void 0&&P!==void 0&&r?.onUsage({usage:P,modelCalls:1}),this.renderer.complete(Date.now()-w,P),await this.refreshContextUsage(),p.join("")}commandContext(){return{write:n=>this.renderer.commandOutput(n)}}getActiveModel(){return this.activeModel}getActiveProfile(){return this.activeProfile}async refreshExtensions(){const n=await this.runtime.projectTrust.inspect(this.cwd),t=await this.runtime.projectTrust.isTrusted(n),i=await this.runtime.configLoader.load(this.cwd,{includeProject:t});await this.reloadExtensions(t,i.config.approvalMode,n.canonicalPath),await this.refreshContextUsage()}async refreshWelcome(n={}){const t=await this.runtime.projectTrust.inspect(this.cwd),i=await this.runtime.projectTrust.isTrusted(t),r=await this.runtime.configLoader.load(this.cwd,{includeProject:i});this.activeModel=n.model===void 0?this.activeModel??r.config.model:n.model,this.activeProfile=n.profile===void 0?this.activeProfile??r.config.profile:n.profile,this.renderer.setWelcome({version:x,cwd:t.canonicalPath,model:this.activeModel,profile:this.activeProfile,trusted:i}),await this.refreshContextUsage()}async getContextSnapshot(){const n=this.activeModel??this.session?.model??null,t=this.session===void 0?void 0:await this.runtime.goalStore.get(this.session.id),i=await this.contextService.buildForProject({...this.session===void 0?{}:{sessionId:this.session.id},model:n,profileName:this.activeProfile??this.session?.profile??null,pluginNames:this.enabledPluginNames,pluginMcpConfig:this.pluginMcpConfig,pendingAttachments:this.pendingAttachments.size,skillRootScopes:this.skillRootScopes,agentSessionStore:this.agentSessionStore,...t===void 0?{}:{goal:{objective:t.objective,status:t.status,turns:t.turns,evaluatorRuns:t.evaluatorRuns,tokensUsed:t.usage.totalTokens,...t.tokenBudget===void 0?{}:{tokenBudget:t.tokenBudget},...t.maxTurns===void 0?{}:{maxTurns:t.maxTurns},...t.maxDurationMs===void 0?{}:{maxDurationMs:t.maxDurationMs},...t.lastError===void 0?{}:{lastError:t.lastError},...t.lastEvaluation===void 0?{}:{lastEvaluation:t.lastEvaluation.reason}}}});return this.renderer.setContextUsage({usedTokens:i.usedTokens,...i.contextWindow===void 0?{}:{contextWindow:i.contextWindow}}),i}async refreshContextUsage(){try{await this.getContextSnapshot()}catch(n){this.runtime.logger.debug("Unable to refresh context usage.",{reason:n instanceof Error?n.message:String(n)})}}async runSkill(n,t,i,r,s){await Ee({globalConfigDir:this.runtime.paths.globalConfigDir,skillRootScopes:this.skillRootScopes,runPrompt:(d,o)=>this.sendPrompt(d,this.pendingAttachments.list(),o)},n,t,i,s,r)}async reloadExtensions(n,t,i){const r=await Le({runtime:this.runtime,cwd:this.cwd,trusted:n,approvalMode:t,workspaceRoot:i,approvals:this.approvals});this.hookRuntime=r.hookRuntime,this.skillRootScopes=r.skillRootScopes,this.enabledPluginNames=r.enabledPluginNames,this.pluginMcpConfig=r.pluginMcpConfig,this.hooks=r.hooks}async compactSession(){await be({runtime:this.runtime,cwd:this.cwd,session:this.session,activeModel:this.activeModel,activeProfile:this.activeProfile,activeResponse:this.activeAbortController!==void 0,renderer:this.renderer,contextService:this.contextService,agentSessionStore:this.agentSessionStore,refreshContextUsage:()=>this.refreshContextUsage()})}async resumeSession(n){if(this.activePromptRun!==void 0)throw new Error("Stop the active response before resuming another session.");const t=await this.runtime.projectTrust.inspect(this.cwd),i=await new de(this.runtime.sessionStore).require(n,t.fingerprint);if(i.id===this.session?.id){this.renderer.notice(`Already using session: ${i.id}`);return}const r=await this.runtime.sessionStore.readTranscript(i.id),s=this.session;s!==void 0&&(await this.subagentJobs.close(),this.subagentJobs=new L,await this.runHookEvent("session.end",s.id),await this.runtime.sessionStore.updateStatus(s.id,"completed")),this.session=await this.runtime.sessionStore.updateStatus(i.id,"active"),this.executionWorkspace=await this.executionWorkspaces.prepare({sessionId:i.id,projectRoot:t.canonicalPath});const d=await F(this.runtime,this.cwd);this.activeModel=i.model??d.config.model,this.activeProfile=i.profile??d.config.profile,this.renderer.setWelcome({version:x,cwd:t.canonicalPath,model:this.activeModel,profile:this.activeProfile,trusted:await this.runtime.projectTrust.isTrusted(t)}),this.renderer.clearTranscript();for(const o of U(r))o.type==="user"?this.renderer.userPrompt(o.content):o.type==="assistant"&&(this.renderer.beginAssistant(),this.renderer.assistantDelta(o.content),this.renderer.finishAssistant());await this.refreshContextUsage(),await this.runHookEvent("session.start",i.id),M(this.runtime,this.cwd).catch(o=>this.runtime.logger.warn("MCP session warm-up failed.",{reason:o instanceof Error?o.message:String(o)})),this.renderer.notice(`Resumed session: ${i.id}`)}handleInterrupt(){const n=Pe({lastInterruptAt:this.lastInterruptAt,exitArmedUntil:this.exitArmedUntil,printResumeCommandOnExit:this.printResumeCommandOnExit},this.activeAbortController,this.renderer);this.lastInterruptAt=n.lastInterruptAt,this.exitArmedUntil=n.exitArmedUntil,this.printResumeCommandOnExit=n.printResumeCommandOnExit}async awaitActiveForegroundRun(){const n=this.activeForegroundRun;if(n!==void 0)try{await n}catch(t){this.runtime.logger.warn("Foreground TUI operation failed during shutdown.",{reason:t instanceof Error?t.message:String(t)})}}async runHookEvent(n,t){await ke(this.hookRuntime,this.hooks,n,this.executionWorkspace?.executionCwd??this.cwd,t)}}export{At as TuiApplication};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ClipboardImage } from '../../ports/clipboard-adapter.js';
|
|
2
|
+
import type { HostPlatformContext } from '../../infrastructure/platform/host-platform.js';
|
|
3
|
+
export interface TuiClipboardPasteHandlers {
|
|
4
|
+
image: () => Promise<void>;
|
|
5
|
+
text: () => Promise<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
export declare function createTuiClipboardPasteHandlers(options: {
|
|
8
|
+
platform: HostPlatformContext;
|
|
9
|
+
notify: (message: string) => void;
|
|
10
|
+
attachImage: (image: ClipboardImage | undefined) => Promise<void>;
|
|
11
|
+
}): TuiClipboardPasteHandlers;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{asCliError as t}from"../../domain/errors/cli-error.js";import{createClipboardAdapter as i}from"../../infrastructure/clipboard/clipboard-adapter-factory.js";import{createClipboardTextAdapter as m}from"../../infrastructure/clipboard/clipboard-text-adapter-factory.js";import{formatCliErrorMessage as e}from"../../application/commands/command-hints.js";function l(r){return{image:async()=>{try{await r.attachImage(await i(r.platform).readImage())}catch(a){r.notify(e(t(a),"tui"))}},text:async()=>{try{return await m(r.platform).readText()}catch(a){r.notify(e(t(a),"tui"));return}}}}export{l as createTuiClipboardPasteHandlers};
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CommandInvocation } from '../../application/commands/command-contract.js';
|
|
2
|
+
import { type TuiContextSnapshot } from './context-display.js';
|
|
3
|
+
import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
|
|
4
|
+
import type { ScopedSkill } from '../../infrastructure/extensions/skill-manager.js';
|
|
5
|
+
import type { ExtensionScope } from '../../domain/extensions/extension-scope.js';
|
|
6
|
+
import type { SessionMetadata } from '../../domain/session/session.js';
|
|
7
|
+
import type { HookDefinition } from '../../domain/extensions/hook-manifest.js';
|
|
8
|
+
import type { PendingAttachmentStore } from '../../application/chat/pending-attachment-store.js';
|
|
9
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
10
|
+
import type { InkTuiBridge } from './ink/tui-bridge.js';
|
|
11
|
+
import type { CreateGoalInput } from '../../domain/orchestration/goal.js';
|
|
12
|
+
import type { TuiCommandContext } from './tui-command-context.js';
|
|
13
|
+
export interface TuiCommandHost {
|
|
14
|
+
runtime: CliRuntime;
|
|
15
|
+
cwd: string;
|
|
16
|
+
renderer: InkTuiBridge;
|
|
17
|
+
pendingAttachments: PendingAttachmentStore;
|
|
18
|
+
hooks: readonly HookDefinition[];
|
|
19
|
+
session: SessionMetadata | undefined;
|
|
20
|
+
activeAbortController: AbortController | undefined;
|
|
21
|
+
attachClipboardImage(image: {
|
|
22
|
+
bytes: Uint8Array;
|
|
23
|
+
mimeType: string;
|
|
24
|
+
} | undefined): Promise<void>;
|
|
25
|
+
runPrompt(prompt: string, initialSkill?: SkillManifest): Promise<string>;
|
|
26
|
+
runGoal(objective: string, context: TuiCommandContext, limits?: Omit<CreateGoalInput, 'objective'>): Promise<void>;
|
|
27
|
+
resumeGoal(context: TuiCommandContext): Promise<void>;
|
|
28
|
+
runSkill(name: string, args: readonly string[], context: TuiCommandContext, availableSkills?: readonly ScopedSkill[], scope?: ExtensionScope): Promise<void>;
|
|
29
|
+
refreshExtensions(): Promise<void>;
|
|
30
|
+
compactSession(): Promise<void>;
|
|
31
|
+
refreshWelcome(overrides?: {
|
|
32
|
+
model?: string | null;
|
|
33
|
+
profile?: string | null;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
getContextSnapshot(): Promise<TuiContextSnapshot>;
|
|
36
|
+
resumeSession(sessionId: string): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare function executeTuiCommand(invocation: CommandInvocation, host: TuiCommandHost, context: TuiCommandContext): Promise<boolean>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{AuthenticationService as u}from"../../application/auth/authentication-service.js";import{executeApplicationCommand as c}from"../../application/commands/application-command-executor.js";import{runEffortCommand as f,runModelCommand as m}from"../../application/commands/cli-command-services.js";import{REASONING_EFFORTS as p}from"../../domain/config/config-schema.js";import{loadModelCatalog as d}from"../../application/model/model-catalog-service.js";import{formatContextSnapshot as w}from"./context-display.js";import{createClipboardAdapter as g}from"../../infrastructure/clipboard/clipboard-adapter-factory.js";import{formatCompactTable as y}from"../../application/formatting/compact-table.js";import{formatGoalStatus as A}from"../../application/orchestration/goal-output.js";import{parseGoalLimits as b}from"../../application/orchestration/goal-input.js";import{prepareTuiMediaInvocation as S}from"./tui-media-model-selection.js";async function K(e,i,a){switch(e.action.executor){case"tui-exit":return!0;case"tui-clear":return i.renderer.clearTranscript(),!1;case"tui-stop":return G(i,a),!1;case"tui-details":return a.write(`Action details: ${i.renderer.toggleActionDetails()?"on":"off"}`),!1;case"tui-context":return await L(i,a),!1;case"tui-auth-login":return await T(i,e,a),!1;case"tui-model-select":return await E(i,a),!1;case"tui-effort-select":return await W(i,a),!1;case"tui-skill-run":return await $(i,e,a),!1;case"tui-session-resume":return await i.resumeSession(l(e,0,"session id")),!1;case"tui-session-compact":return await i.compactSession(),!1;case"tui-session-rename":return await k(i,e,a),!1;case"tui-goal":return await I(i,e,a),!1;case"tui-attachments":return await P(i,e,a),!1;case"tui-prompt":return await i.runPrompt(e.positionals.join(" ")),!1;case"tui-agent-info":return a.write("The JSONL agent protocol owns stdin/stdout and must be run directly: lotagate agent stdio."),!1;default:{const t=await S(e,{loadModels:()=>d(i.runtime,i.cwd),selectModel:(r,n)=>i.renderer.selectModel(r,n)});return t===void 0?(a.write("Model selection cancelled."),!1):(await C(t,i,a),await N(i,t),!1)}}}async function C(e,i,a){const t=new AbortController;i.activeAbortController=t;try{await c(e,M(i,a,t.signal))}finally{i.activeAbortController===t&&(i.activeAbortController=void 0)}}function M(e,i,a){return{runtime:e.runtime,cwd:e.cwd,output:{write:t=>i.write(t.endsWith(`
|
|
2
|
+
`)?t.slice(0,-1):t)},selectScope:t=>e.renderer.selectScope(t),activity:{start:(t,r)=>e.renderer.startToolActivity(t,r)},signal:a}}async function N(e,i){i.action.id==="model.use"&&await e.refreshWelcome({model:i.positionals[0]??null}),(i.action.id==="trust.grant"||i.action.id==="trust.revoke")&&(await e.refreshExtensions(),await e.refreshWelcome()),i.action.id.startsWith("plugin.")&&i.action.id!=="plugin.list"&&i.action.id!=="plugin.list.default"&&await e.refreshExtensions()}function G(e,i){e.activeAbortController===void 0?i.write("No response is currently running."):(e.activeAbortController.abort(),i.write("Stopping the active response."))}async function L(e,i){i.write(e.session===void 0?"No active session.":w(await e.getContextSnapshot()))}async function T(e,i,a){const t=await e.runtime.configLoader.load(e.cwd,{includeProject:!1}),r=String(i.options.get("profile")??t.config.profile??u.defaultProfileName()),n=String(i.options.get("base-url")??t.config.baseUrl),o=await e.renderer.requestSecret("LotaGate API key");if(o===void 0){a.write("Login cancelled.");return}const s=await e.runtime.auth.login({profileName:r,baseUrl:n,apiKey:o});await e.runtime.configLoader.setGlobal("profile",s.name),await e.refreshWelcome({profile:s.name}),a.write(`Logged in profile: ${s.name}`)}async function E(e,i){const a=await e.runtime.configLoader.load(e.cwd),t=await d(e.runtime,e.cwd);if(t.data.length===0){i.write("No models are available.");return}const r=await e.renderer.selectModel("Select a model",t.data.map(n=>({value:n.id,label:typeof n.display_name=="string"?n.display_name:n.id})),a.config.model??void 0);if(r===void 0){i.write("Model selection cancelled.");return}await m(["use",r],e.runtime,e.cwd,{write:n=>i.write(n.endsWith(`
|
|
3
|
+
`)?n.slice(0,-1):n)}),await e.refreshWelcome({model:r})}async function W(e,i){const a=await e.runtime.configLoader.load(e.cwd),t=await e.renderer.selectModel("Select reasoning effort",p.map(r=>({value:r,label:r})),a.config.effort);if(t===void 0){i.write("Effort selection cancelled.");return}await f(["use",t],e.runtime,e.cwd,{write:r=>i.write(r.endsWith(`
|
|
4
|
+
`)?r.slice(0,-1):r)})}async function $(e,i,a){const t=l(i,0,"skill name");await e.runSkill(t,i.positionals.slice(1),a,void 0,j(i))}async function k(e,i,a){if(e.session===void 0){a.write("No active session.");return}const t=i.positionals.join(" ").trim();e.session=await e.runtime.sessionStore.rename(e.session.id,t),a.write(`Renamed session: ${e.session.name}`)}async function I(e,i,a){if(i.action.id==="goal.start.tui"){await e.runGoal(i.positionals.join(" "),a,b(i.options));return}if(e.session===void 0){a.write("No active session.");return}if(i.action.id==="goal.status.tui"){const t=await e.runtime.goalStore.get(e.session.id);a.write(t===void 0?"No active goal.":A(t));return}if(i.action.id==="goal.pause.tui"){e.activeAbortController?.abort();const t=await e.runtime.goalStore.get(e.session.id);t?.status==="active"&&await e.runtime.goalStore.pause(e.session.id),a.write(t?.status==="paused"?"Goal already paused.":"Goal paused.");return}if(i.action.id==="goal.resume.tui"){await e.resumeGoal(a);return}e.activeAbortController?.abort(),await e.runtime.goalStore.clear(e.session.id),a.write("Goal cleared.")}async function P(e,i,a){const t=i.action.id;if(t==="attachments.paste"){const r=await g(e.runtime.platform).readImage();await e.attachClipboardImage(r),a.write(r===void 0?"Clipboard does not contain an image.":"Attachment added from clipboard.");return}if(t==="attachments.remove"){const r=l(i,0,"attachment id");e.pendingAttachments.remove(r)?(e.renderer.setPendingAttachments(e.pendingAttachments.list().map(({attachment:n})=>n)),a.write(`Removed attachment: ${r}`)):a.write(`Attachment not found: ${r}`);return}a.write(y(e.pendingAttachments.list().map(({attachment:r})=>({name:r.name,status:r.mimeType,detail:`${r.sizeBytes} bytes`})),{empty:"No pending attachments."}))}function l(e,i,a){const t=e.positionals[i];if(t===void 0)throw new Error(`Missing ${a}.`);return t}function j(e){const i=e.options.get("scope");return i==="user"||i==="project"?i:void 0}export{K as executeTuiCommand};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
2
|
+
import type { PendingAttachmentStore } from '../../application/chat/pending-attachment-store.js';
|
|
3
|
+
import type { HookDefinition } from '../../domain/extensions/hook-manifest.js';
|
|
4
|
+
import type { SessionMetadata } from '../../domain/session/session.js';
|
|
5
|
+
import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
|
|
6
|
+
import type { ScopedSkill } from '../../infrastructure/extensions/skill-manager.js';
|
|
7
|
+
import type { ExtensionScope } from '../../domain/extensions/extension-scope.js';
|
|
8
|
+
import type { CreateGoalInput } from '../../domain/orchestration/goal.js';
|
|
9
|
+
import type { InkTuiBridge } from './ink/tui-bridge.js';
|
|
10
|
+
import type { TuiCommandContext } from './tui-command-context.js';
|
|
11
|
+
import type { TuiCommandHost } from './tui-command-executor.js';
|
|
12
|
+
import type { TuiContextSnapshot } from './context-display.js';
|
|
13
|
+
export interface TuiCommandHostBindings {
|
|
14
|
+
runtime: CliRuntime;
|
|
15
|
+
cwd: string;
|
|
16
|
+
renderer: InkTuiBridge;
|
|
17
|
+
pendingAttachments: PendingAttachmentStore;
|
|
18
|
+
getHooks(): readonly HookDefinition[];
|
|
19
|
+
getSession(): SessionMetadata | undefined;
|
|
20
|
+
getActiveAbortController(): AbortController | undefined;
|
|
21
|
+
setActiveAbortController(controller: AbortController | undefined): void;
|
|
22
|
+
attachClipboardImage(image: {
|
|
23
|
+
bytes: Uint8Array;
|
|
24
|
+
mimeType: string;
|
|
25
|
+
} | undefined): Promise<void>;
|
|
26
|
+
runPrompt(prompt: string, initialSkill?: SkillManifest): Promise<string>;
|
|
27
|
+
runGoal(objective: string, context: TuiCommandContext, limits?: Omit<CreateGoalInput, 'objective'>): Promise<void>;
|
|
28
|
+
resumeGoal(context: TuiCommandContext): Promise<void>;
|
|
29
|
+
runSkill(name: string, args: readonly string[], context: TuiCommandContext, availableSkills?: readonly ScopedSkill[], scope?: ExtensionScope): Promise<void>;
|
|
30
|
+
refreshExtensions(): Promise<void>;
|
|
31
|
+
compactSession(): Promise<void>;
|
|
32
|
+
refreshWelcome(overrides?: {
|
|
33
|
+
model?: string | null;
|
|
34
|
+
profile?: string | null;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
getContextSnapshot(): Promise<TuiContextSnapshot>;
|
|
37
|
+
resumeSession(sessionId: string): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** Adapts TUI-owned mutable state without exposing the application instance as an unsafe structural cast. */
|
|
40
|
+
export declare function createTuiCommandHost(bindings: TuiCommandHostBindings): TuiCommandHost;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(e){return{runtime:e.runtime,cwd:e.cwd,renderer:e.renderer,pendingAttachments:e.pendingAttachments,get hooks(){return e.getHooks()},get session(){return e.getSession()},get activeAbortController(){return e.getActiveAbortController()},set activeAbortController(t){e.setActiveAbortController(t)},attachClipboardImage:e.attachClipboardImage,runPrompt:e.runPrompt,runGoal:e.runGoal,resumeGoal:e.resumeGoal,runSkill:e.runSkill,refreshExtensions:e.refreshExtensions,compactSession:e.compactSession,refreshWelcome:e.refreshWelcome,getContextSnapshot:e.getContextSnapshot,resumeSession:e.resumeSession}}export{r as createTuiCommandHost};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SessionStore as AgentSessionStore } from '@lotagate/agent-sdk';
|
|
2
|
+
import type { LotaGate } from '@lotagate/sdk';
|
|
3
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
4
|
+
export declare function createTuiContextManagement(client: LotaGate, model: string, contextWindow: number | undefined, onSummaryFailure: (error: unknown) => void): import("@lotagate/agent-sdk").ContextManagementOptions;
|
|
5
|
+
export declare function compactTuiSession(runtime: CliRuntime, agentSessions: AgentSessionStore, sessionId: string, client: LotaGate, model: string, contextWindow?: number, onSummaryFailure?: (error: unknown) => void): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContextManagement as u,redactCompactionSummary as p}from"../../application/agent/context-compaction.js";import{retainLatestCompaction as f,toAgentMessage as g}from"../../application/agent/agent-session-store.js";import{buildAgentHistory as d}from"../../application/agent/agent-history.js";import{compactSessionMessages as y}from"../../application/session/session-compaction-service.js";function x(e,a,t,s){return u({client:e,model:a,...t===void 0?{}:{contextWindow:t},onSummaryFailure:s})}async function A(e,a,t,s,n,i,m){const o=await a.get(t),c=o?.messages??await l(e,t),r=await y(c,s,n,i,m);return r.summary===void 0?!1:(o!==void 0&&await a.update(t,{messages:r.messages,status:"completed"}),await e.sessionStore.compact(t,p(r.summary)),!0)}async function l(e,a){const t=await e.sessionStore.readHistory(a);return f(d(t.transcript,t.events)).map(g)}export{A as compactTuiSession,x as createTuiContextManagement};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
2
|
+
import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
|
|
3
|
+
import { type CliMcpConfig } from '../../domain/extensions/mcp-config.js';
|
|
4
|
+
import type { SkillRootScope } from '../../infrastructure/extensions/skill-roots.js';
|
|
5
|
+
import type { TuiContextSnapshot } from './context-display.js';
|
|
6
|
+
import type { SessionStore as AgentSessionStore } from '@lotagate/agent-sdk';
|
|
7
|
+
import type { AgentGoalSummary } from '../../application/agent/capability-profile.js';
|
|
8
|
+
export interface TuiContextServiceInput {
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
model: string | null;
|
|
11
|
+
profileName?: string | null;
|
|
12
|
+
trusted: boolean;
|
|
13
|
+
skills: readonly (SkillManifest & {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
})[];
|
|
16
|
+
pluginNames: readonly string[];
|
|
17
|
+
pluginMcpConfig?: CliMcpConfig;
|
|
18
|
+
pendingAttachments: number;
|
|
19
|
+
skillRootScopes?: readonly SkillRootScope[];
|
|
20
|
+
agentSessionStore?: AgentSessionStore;
|
|
21
|
+
goal?: AgentGoalSummary;
|
|
22
|
+
}
|
|
23
|
+
/** Builds the human-readable context model from durable session data and CLI-owned metadata. */
|
|
24
|
+
export declare class TuiContextService {
|
|
25
|
+
private readonly runtime;
|
|
26
|
+
private readonly cwd;
|
|
27
|
+
private contextWindow;
|
|
28
|
+
private contextWindowModel;
|
|
29
|
+
constructor(runtime: CliRuntime, cwd: string);
|
|
30
|
+
buildForProject(input: Omit<TuiContextServiceInput, 'trusted' | 'skills'>): Promise<TuiContextSnapshot>;
|
|
31
|
+
build(input: TuiContextServiceInput): Promise<TuiContextSnapshot>;
|
|
32
|
+
getModelContextWindow(model: string | null, profileName?: string | null): Promise<number | undefined>;
|
|
33
|
+
private resolveContextWindow;
|
|
34
|
+
}
|