@lotagate/cli 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/agent/agent-history.d.ts +3 -0
- package/dist/application/agent/agent-history.js +81 -0
- package/dist/application/agent/agent-input-context.d.ts +9 -0
- package/dist/application/agent/agent-input-context.js +12 -0
- package/dist/application/agent/agent-limit.d.ts +3 -0
- package/dist/application/agent/agent-limit.js +12 -0
- package/dist/application/agent/agent-run-tracker.d.ts +30 -0
- package/dist/application/agent/agent-run-tracker.js +68 -0
- package/dist/application/agent/agent-session-store.d.ts +19 -0
- package/dist/application/agent/agent-session-store.js +74 -0
- package/dist/application/agent/capability-profile.d.ts +37 -0
- package/dist/application/agent/capability-profile.js +13 -0
- package/dist/application/agent/cli-agent-execution-service.d.ts +81 -0
- package/dist/application/agent/cli-agent-execution-service.js +279 -0
- package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
- package/dist/application/agent/context-compaction-persistence.js +27 -0
- package/dist/application/agent/context-compaction.d.ts +20 -0
- package/dist/application/agent/context-compaction.js +114 -0
- package/dist/application/agent/prompt-data-safety.d.ts +14 -0
- package/dist/application/agent/prompt-data-safety.js +38 -0
- package/dist/application/agent/safe-system-prompt.d.ts +3 -0
- package/dist/application/agent/safe-system-prompt.js +19 -0
- package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
- package/dist/application/agent/scoped-tool-executor.js +32 -0
- package/dist/application/agent/system-prompt-builder.d.ts +14 -0
- package/dist/application/agent/system-prompt-builder.js +199 -0
- package/dist/application/agent/tool-catalog.d.ts +14 -0
- package/dist/application/agent/tool-catalog.js +30 -0
- package/dist/application/agent/tool-display.d.ts +6 -0
- package/dist/application/agent/tool-display.js +59 -0
- package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
- package/dist/application/agent/tool-hook-lifecycle.js +85 -0
- package/dist/application/auth/authentication-service.d.ts +20 -0
- package/dist/application/auth/authentication-service.js +44 -0
- package/dist/application/chat/chat-service.d.ts +12 -0
- package/dist/application/chat/chat-service.js +19 -0
- package/dist/application/chat/pending-attachment-store.d.ts +12 -0
- package/dist/application/chat/pending-attachment-store.js +28 -0
- package/dist/application/commands/application-command-executor.d.ts +20 -0
- package/dist/application/commands/application-command-executor.js +66 -0
- package/dist/application/commands/cli-args.d.ts +6 -0
- package/dist/application/commands/cli-args.js +43 -0
- package/dist/application/commands/cli-command-services.d.ts +16 -0
- package/dist/application/commands/cli-command-services.js +405 -0
- package/dist/application/commands/command-catalog.d.ts +6 -0
- package/dist/application/commands/command-catalog.js +159 -0
- package/dist/application/commands/command-contract.d.ts +58 -0
- package/dist/application/commands/command-contract.js +1 -0
- package/dist/application/commands/command-hints.d.ts +9 -0
- package/dist/application/commands/command-hints.js +17 -0
- package/dist/application/commands/command-output.d.ts +4 -0
- package/dist/application/commands/command-output.js +1 -0
- package/dist/application/commands/command-parser.d.ts +10 -0
- package/dist/application/commands/command-parser.js +155 -0
- package/dist/application/commands/command-presentation.d.ts +7 -0
- package/dist/application/commands/command-presentation.js +131 -0
- package/dist/application/commands/command-registry.d.ts +11 -0
- package/dist/application/commands/command-registry.js +64 -0
- package/dist/application/commands/command-runtime.d.ts +2 -0
- package/dist/application/commands/command-runtime.js +3 -0
- package/dist/application/commands/goal-command-handlers.d.ts +3 -0
- package/dist/application/commands/goal-command-handlers.js +120 -0
- package/dist/application/commands/media-command-handlers.d.ts +9 -0
- package/dist/application/commands/media-command-handlers.js +307 -0
- package/dist/application/commands/media-command-output.d.ts +11 -0
- package/dist/application/commands/media-command-output.js +8 -0
- package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
- package/dist/application/commands/runtime-command-handlers.js +177 -0
- package/dist/application/commands/stream-output.d.ts +4 -0
- package/dist/application/commands/stream-output.js +10 -0
- package/dist/application/commands/utility-commands.d.ts +6 -0
- package/dist/application/commands/utility-commands.js +81 -0
- package/dist/application/config/execution-config.d.ts +4 -0
- package/dist/application/config/execution-config.js +6 -0
- package/dist/application/extensions/extension-list-contract.d.ts +13 -0
- package/dist/application/extensions/extension-list-contract.js +1 -0
- package/dist/application/extensions/extension-list-formatters.d.ts +31 -0
- package/dist/application/extensions/extension-list-formatters.js +98 -0
- package/dist/application/extensions/extension-list-output.d.ts +3 -0
- package/dist/application/extensions/extension-list-output.js +7 -0
- package/dist/application/extensions/plugin-contribution-registry.d.ts +15 -0
- package/dist/application/extensions/plugin-contribution-registry.js +80 -0
- package/dist/application/extensions/skill-scope-store.d.ts +23 -0
- package/dist/application/extensions/skill-scope-store.js +33 -0
- package/dist/application/formatting/compact-number.d.ts +2 -0
- package/dist/application/formatting/compact-number.js +18 -0
- package/dist/application/formatting/compact-table.d.ts +22 -0
- package/dist/application/formatting/compact-table.js +49 -0
- package/dist/application/media/video-operation-poller.d.ts +5 -0
- package/dist/application/media/video-operation-poller.js +42 -0
- package/dist/application/model/cached-model-catalog.d.ts +13 -0
- package/dist/application/model/cached-model-catalog.js +31 -0
- package/dist/application/model/initial-model-selection.d.ts +10 -0
- package/dist/application/model/initial-model-selection.js +11 -0
- package/dist/application/model/model-catalog-service.d.ts +6 -0
- package/dist/application/model/model-catalog-service.js +13 -0
- package/dist/application/model/model-context-window.d.ts +3 -0
- package/dist/application/model/model-context-window.js +23 -0
- package/dist/application/orchestration/cli-subagent-service.d.ts +70 -0
- package/dist/application/orchestration/cli-subagent-service.js +328 -0
- package/dist/application/orchestration/cli-turn-event-projector.d.ts +12 -0
- package/dist/application/orchestration/cli-turn-event-projector.js +81 -0
- package/dist/application/orchestration/cli-turn-events.d.ts +76 -0
- package/dist/application/orchestration/cli-turn-events.js +39 -0
- package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
- package/dist/application/orchestration/cli-turn-persistence.js +14 -0
- package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
- package/dist/application/orchestration/goal-evaluator.js +88 -0
- package/dist/application/orchestration/goal-input.d.ts +3 -0
- package/dist/application/orchestration/goal-input.js +19 -0
- package/dist/application/orchestration/goal-output.d.ts +2 -0
- package/dist/application/orchestration/goal-output.js +11 -0
- package/dist/application/orchestration/goal-runner.d.ts +22 -0
- package/dist/application/orchestration/goal-runner.js +153 -0
- package/dist/application/orchestration/goal-usage.d.ts +9 -0
- package/dist/application/orchestration/goal-usage.js +19 -0
- package/dist/application/orchestration/headless-agent-turn.d.ts +32 -0
- package/dist/application/orchestration/headless-agent-turn.js +82 -0
- package/dist/application/orchestration/plan-generator.d.ts +7 -0
- package/dist/application/orchestration/plan-generator.js +34 -0
- package/dist/application/orchestration/subagent-coordinator.d.ts +33 -0
- package/dist/application/orchestration/subagent-coordinator.js +28 -0
- package/dist/application/orchestration/subagent-handoff.d.ts +2 -0
- package/dist/application/orchestration/subagent-handoff.js +68 -0
- package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
- package/dist/application/orchestration/subagent-tool-executor.js +93 -0
- package/dist/application/orchestration/task-assessment.d.ts +4 -0
- package/dist/application/orchestration/task-assessment.js +35 -0
- package/dist/application/orchestration/task-graph.d.ts +13 -0
- package/dist/application/orchestration/task-graph.js +56 -0
- package/dist/application/orchestration/task-scheduler.d.ts +18 -0
- package/dist/application/orchestration/task-scheduler.js +88 -0
- package/dist/application/project/project-trust-service.d.ts +13 -0
- package/dist/application/project/project-trust-service.js +74 -0
- package/dist/application/protocol/browser-host-tool-executor.d.ts +41 -0
- package/dist/application/protocol/browser-host-tool-executor.js +88 -0
- package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
- package/dist/application/protocol/desktop-agent-command.js +663 -0
- package/dist/application/protocol/desktop-attachment-store.d.ts +16 -0
- package/dist/application/protocol/desktop-attachment-store.js +82 -0
- package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
- package/dist/application/protocol/desktop-command-catalog.js +19 -0
- package/dist/application/protocol/desktop-command-contract.d.ts +22 -0
- package/dist/application/protocol/desktop-command-contract.js +3 -0
- package/dist/application/protocol/desktop-command-executor.d.ts +16 -0
- package/dist/application/protocol/desktop-command-executor.js +47 -0
- package/dist/application/protocol/desktop-command-output.d.ts +15 -0
- package/dist/application/protocol/desktop-command-output.js +24 -0
- package/dist/application/protocol/desktop-execution-policy.d.ts +17 -0
- package/dist/application/protocol/desktop-execution-policy.js +49 -0
- package/dist/application/protocol/desktop-host-tool-executor.d.ts +57 -0
- package/dist/application/protocol/desktop-host-tool-executor.js +53 -0
- package/dist/application/protocol/desktop-orchestration-events.d.ts +5 -0
- package/dist/application/protocol/desktop-orchestration-events.js +37 -0
- package/dist/application/protocol/json-line-writer.d.ts +9 -0
- package/dist/application/protocol/json-line-writer.js +19 -0
- package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
- package/dist/application/protocol/jsonl-agent-command.js +97 -0
- package/dist/application/protocol/jsonl-protocol.d.ts +52 -0
- package/dist/application/protocol/jsonl-protocol.js +170 -0
- package/dist/application/security/desktop-tool-scope-policy.d.ts +3 -0
- package/dist/application/security/desktop-tool-scope-policy.js +52 -0
- package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
- package/dist/application/security/tool-action-risk-analyzer.js +64 -0
- package/dist/application/security/tool-approval-service.d.ts +35 -0
- package/dist/application/security/tool-approval-service.js +97 -0
- package/dist/application/security/tool-risk-classifier.d.ts +11 -0
- package/dist/application/security/tool-risk-classifier.js +65 -0
- package/dist/application/security/workspace-permission-policy.d.ts +10 -0
- package/dist/application/security/workspace-permission-policy.js +50 -0
- package/dist/application/session/project-session-access.d.ts +8 -0
- package/dist/application/session/project-session-access.js +19 -0
- package/dist/application/session/session-compaction-service.d.ts +10 -0
- package/dist/application/session/session-compaction-service.js +43 -0
- package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
- package/dist/application/session/session-turn-lifecycle.js +31 -0
- package/dist/application/workspace/workspace-file-index.d.ts +15 -0
- package/dist/application/workspace/workspace-file-index.js +60 -0
- package/dist/application/workspace/workspace-file-reference-resolver.d.ts +14 -0
- package/dist/application/workspace/workspace-file-reference-resolver.js +123 -0
- package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
- package/dist/application/workspace/workspace-instruction-loader.js +55 -0
- package/dist/bootstrap/composition-root.d.ts +6 -0
- package/dist/bootstrap/composition-root.js +4 -0
- package/dist/bootstrap/global-cli-options.d.ts +6 -0
- package/dist/bootstrap/global-cli-options.js +29 -0
- package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
- package/dist/bootstrap/native-devtools-stub.js +10 -0
- package/dist/bootstrap/native-entry.d.ts +1 -0
- package/dist/bootstrap/native-entry.js +6 -0
- package/dist/bootstrap/native-tiktoken.d.ts +4 -0
- package/dist/bootstrap/native-tiktoken.js +5 -0
- package/dist/bootstrap/runtime-factory.d.ts +35 -0
- package/dist/bootstrap/runtime-factory.js +44 -0
- package/dist/bootstrap/shutdown-manager.d.ts +10 -0
- package/dist/bootstrap/shutdown-manager.js +14 -0
- package/dist/bootstrap/startup-sequence.d.ts +5 -0
- package/dist/bootstrap/startup-sequence.js +10 -0
- package/dist/domain/auth/auth-profile.d.ts +14 -0
- package/dist/domain/auth/auth-profile.js +39 -0
- package/dist/domain/config/config-schema.d.ts +17 -0
- package/dist/domain/config/config-schema.js +105 -0
- package/dist/domain/errors/cli-command-hint.d.ts +5 -0
- package/dist/domain/errors/cli-command-hint.js +1 -0
- package/dist/domain/errors/cli-error.d.ts +35 -0
- package/dist/domain/errors/cli-error.js +129 -0
- package/dist/domain/errors/error-codes.d.ts +46 -0
- package/dist/domain/errors/error-codes.js +45 -0
- package/dist/domain/extensions/extension-scope.d.ts +3 -0
- package/dist/domain/extensions/extension-scope.js +23 -0
- package/dist/domain/extensions/extension-state.d.ts +5 -0
- package/dist/domain/extensions/extension-state.js +11 -0
- package/dist/domain/extensions/hook-manifest.d.ts +10 -0
- package/dist/domain/extensions/hook-manifest.js +23 -0
- package/dist/domain/extensions/mcp-config.d.ts +18 -0
- package/dist/domain/extensions/mcp-config.js +111 -0
- package/dist/domain/extensions/plugin-manifest.d.ts +11 -0
- package/dist/domain/extensions/plugin-manifest.js +43 -0
- package/dist/domain/extensions/skill-manifest.d.ts +10 -0
- package/dist/domain/extensions/skill-manifest.js +51 -0
- package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
- package/dist/domain/filesystem/file-change-diff.js +60 -0
- package/dist/domain/media/gateway-media-contract.d.ts +23 -0
- package/dist/domain/media/gateway-media-contract.js +163 -0
- package/dist/domain/media/media-contract.d.ts +28 -0
- package/dist/domain/media/media-contract.js +1 -0
- package/dist/domain/media/media-execution-policy.d.ts +9 -0
- package/dist/domain/media/media-execution-policy.js +31 -0
- package/dist/domain/orchestration/goal.d.ts +58 -0
- package/dist/domain/orchestration/goal.js +113 -0
- package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
- package/dist/domain/orchestration/subagent-identity.js +8 -0
- package/dist/domain/orchestration/subagent.d.ts +33 -0
- package/dist/domain/orchestration/subagent.js +1 -0
- package/dist/domain/orchestration/task.d.ts +31 -0
- package/dist/domain/orchestration/task.js +1 -0
- package/dist/domain/project/project-identity.d.ts +6 -0
- package/dist/domain/project/project-identity.js +4 -0
- package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
- package/dist/domain/runtime/assistant-delta-normalizer.js +19 -0
- package/dist/domain/runtime/resource-limits.d.ts +60 -0
- package/dist/domain/runtime/resource-limits.js +60 -0
- package/dist/domain/session/attachment.d.ts +13 -0
- package/dist/domain/session/attachment.js +1 -0
- package/dist/domain/session/session-schema.d.ts +6 -0
- package/dist/domain/session/session-schema.js +28 -0
- package/dist/domain/session/session.d.ts +27 -0
- package/dist/domain/session/session.js +1 -0
- package/dist/domain/settings/settings-document.d.ts +8 -0
- package/dist/domain/settings/settings-document.js +36 -0
- package/dist/domain/validation/record-schema.d.ts +4 -0
- package/dist/domain/validation/record-schema.js +9 -0
- package/dist/domain/workspace/workspace-settings.d.ts +12 -0
- package/dist/domain/workspace/workspace-settings.js +44 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
- package/dist/infrastructure/agent-sdk/agent-instance-factory.js +31 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +447 -0
- package/dist/infrastructure/cache/cache-policy.d.ts +7 -0
- package/dist/infrastructure/cache/cache-policy.js +18 -0
- package/dist/infrastructure/cache/file-cache-store.d.ts +17 -0
- package/dist/infrastructure/cache/file-cache-store.js +121 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +98 -0
- package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
- package/dist/infrastructure/clipboard/clipboard-policy.js +19 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +94 -0
- package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
- package/dist/infrastructure/clipboard/image-normalizer.js +78 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +66 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +70 -0
- package/dist/infrastructure/config/config-loader.d.ts +19 -0
- package/dist/infrastructure/config/config-loader.js +76 -0
- package/dist/infrastructure/config/environment-values.d.ts +2 -0
- package/dist/infrastructure/config/environment-values.js +7 -0
- package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/composite-credential-store.js +32 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
- package/dist/infrastructure/credentials/encrypted-file-credential-store.js +181 -0
- package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
- package/dist/infrastructure/credentials/environment-credential-store.js +37 -0
- package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
- package/dist/infrastructure/credentials/secret-input.js +44 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
- package/dist/infrastructure/extensions/composite-mcp-config-store.js +10 -0
- package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
- package/dist/infrastructure/extensions/extension-directory-reader.js +15 -0
- package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
- package/dist/infrastructure/extensions/extension-source-resolver.js +126 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
- package/dist/infrastructure/extensions/file-mcp-config-store.js +66 -0
- package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
- package/dist/infrastructure/extensions/hook-runtime.js +66 -0
- package/dist/infrastructure/extensions/mcp-runtime.d.ts +12 -0
- package/dist/infrastructure/extensions/mcp-runtime.js +52 -0
- package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
- package/dist/infrastructure/extensions/plugin-discovery.js +52 -0
- package/dist/infrastructure/extensions/plugin-manager.d.ts +26 -0
- package/dist/infrastructure/extensions/plugin-manager.js +139 -0
- package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
- package/dist/infrastructure/extensions/skill-discovery.js +29 -0
- package/dist/infrastructure/extensions/skill-installer.d.ts +8 -0
- package/dist/infrastructure/extensions/skill-installer.js +88 -0
- package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
- package/dist/infrastructure/extensions/skill-manager.js +67 -0
- package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
- package/dist/infrastructure/extensions/skill-roots.js +25 -0
- package/dist/infrastructure/extensions/skill-tool-executor.d.ts +18 -0
- package/dist/infrastructure/extensions/skill-tool-executor.js +53 -0
- package/dist/infrastructure/filesystem/atomic-file-store.d.ts +12 -0
- package/dist/infrastructure/filesystem/atomic-file-store.js +106 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
- package/dist/infrastructure/filesystem/bounded-file-reader.js +24 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
- package/dist/infrastructure/filesystem/bounded-json-reader.js +7 -0
- package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
- package/dist/infrastructure/filesystem/fs-errors.js +6 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
- package/dist/infrastructure/filesystem/gateway-media-input-reader.js +49 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +21 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +176 -0
- package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
- package/dist/infrastructure/filesystem/path-resolver.js +119 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +152 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +20 -0
- package/dist/infrastructure/logging/daily-rotating-file-writer.js +75 -0
- package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
- package/dist/infrastructure/logging/log-redactor.js +26 -0
- package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
- package/dist/infrastructure/logging/logging-policy.js +6 -0
- package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
- package/dist/infrastructure/logging/structured-logger.js +40 -0
- package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
- package/dist/infrastructure/network/safe-media-downloader.js +239 -0
- package/dist/infrastructure/platform/host-platform.d.ts +14 -0
- package/dist/infrastructure/platform/host-platform.js +23 -0
- package/dist/infrastructure/platform/host-process.d.ts +17 -0
- package/dist/infrastructure/platform/host-process.js +116 -0
- package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
- package/dist/infrastructure/platform/platform-paths.js +33 -0
- package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
- package/dist/infrastructure/project/file-project-trust-store.js +59 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
- package/dist/infrastructure/sdk/chat-completion-adapter.js +115 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
- package/dist/infrastructure/sdk/lotagate-client-factory.js +8 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
- package/dist/infrastructure/sdk/model-catalog-adapter.js +28 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +20 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.js +97 -0
- package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
- package/dist/infrastructure/sessions/file-goal-store.js +160 -0
- package/dist/infrastructure/sessions/file-session-store.d.ts +48 -0
- package/dist/infrastructure/sessions/file-session-store.js +525 -0
- package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
- package/dist/infrastructure/sessions/project-session-paths.js +41 -0
- package/dist/infrastructure/sessions/session-index.d.ts +16 -0
- package/dist/infrastructure/sessions/session-index.js +84 -0
- package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
- package/dist/infrastructure/sessions/session-journal.js +137 -0
- package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
- package/dist/infrastructure/sessions/subagent-journal-store.js +30 -0
- package/dist/infrastructure/shell/shell-tool-executor.d.ts +17 -0
- package/dist/infrastructure/shell/shell-tool-executor.js +115 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
- package/dist/infrastructure/tokens/tiktoken-token-estimator.js +48 -0
- package/dist/infrastructure/workspace/workspace-settings-store.d.ts +9 -0
- package/dist/infrastructure/workspace/workspace-settings-store.js +75 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +66 -0
- package/dist/ports/cache-store.d.ts +10 -0
- package/dist/ports/cache-store.js +1 -0
- package/dist/ports/chat-model.d.ts +30 -0
- package/dist/ports/chat-model.js +1 -0
- package/dist/ports/clipboard-adapter.d.ts +7 -0
- package/dist/ports/clipboard-adapter.js +1 -0
- package/dist/ports/clipboard-text-adapter.d.ts +3 -0
- package/dist/ports/clipboard-text-adapter.js +1 -0
- package/dist/ports/credential-store.d.ts +7 -0
- package/dist/ports/credential-store.js +1 -0
- package/dist/ports/goal-store.d.ts +12 -0
- package/dist/ports/goal-store.js +1 -0
- package/dist/ports/logger.d.ts +8 -0
- package/dist/ports/logger.js +1 -0
- package/dist/ports/media-gateway-client.d.ts +54 -0
- package/dist/ports/media-gateway-client.js +1 -0
- package/dist/ports/model-diagnostics.d.ts +17 -0
- package/dist/ports/model-diagnostics.js +1 -0
- package/dist/ports/project-trust-store.d.ts +12 -0
- package/dist/ports/project-trust-store.js +1 -0
- package/dist/ports/session-store.d.ts +58 -0
- package/dist/ports/session-store.js +1 -0
- package/dist/ports/subagent-lifecycle.d.ts +31 -0
- package/dist/ports/subagent-lifecycle.js +1 -0
- package/dist/ports/tool-activity.d.ts +13 -0
- package/dist/ports/tool-activity.js +1 -0
- package/dist/presentation/themes/theme.d.ts +19 -0
- package/dist/presentation/themes/theme.js +8 -0
- package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
- package/dist/presentation/tui/agent-initialization-renderer.js +37 -0
- package/dist/presentation/tui/context-display.d.ts +21 -0
- package/dist/presentation/tui/context-display.js +33 -0
- package/dist/presentation/tui/formatters.d.ts +6 -0
- package/dist/presentation/tui/formatters.js +60 -0
- package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
- package/dist/presentation/tui/ink/choice-window.js +5 -0
- package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
- package/dist/presentation/tui/ink/components/activity-entry.js +16 -0
- package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
- package/dist/presentation/tui/ink/components/activity-status.js +21 -0
- package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
- package/dist/presentation/tui/ink/components/choice-modal.js +29 -0
- package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
- package/dist/presentation/tui/ink/components/composer.js +271 -0
- package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
- package/dist/presentation/tui/ink/components/file-diff.js +34 -0
- package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
- package/dist/presentation/tui/ink/components/modal.js +110 -0
- package/dist/presentation/tui/ink/components/shimmer-text.d.ts +6 -0
- package/dist/presentation/tui/ink/components/shimmer-text.js +9 -0
- package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
- package/dist/presentation/tui/ink/components/subagent-activity.js +61 -0
- package/dist/presentation/tui/ink/components/transcript.d.ts +39 -0
- package/dist/presentation/tui/ink/components/transcript.js +121 -0
- package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
- package/dist/presentation/tui/ink/components/welcome-panel.js +20 -0
- package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
- package/dist/presentation/tui/ink/lotagate-tui.js +136 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
- package/dist/presentation/tui/ink/markdown-inline-renderer.js +20 -0
- package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
- package/dist/presentation/tui/ink/markdown-inline.js +91 -0
- package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
- package/dist/presentation/tui/ink/markdown-message.js +66 -0
- package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
- package/dist/presentation/tui/ink/markdown-table.js +77 -0
- package/dist/presentation/tui/ink/tui-bridge.d.ts +195 -0
- package/dist/presentation/tui/ink/tui-bridge.js +289 -0
- package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
- package/dist/presentation/tui/terminal-capabilities.js +7 -0
- package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
- package/dist/presentation/tui/terminal-mouse.js +19 -0
- package/dist/presentation/tui/terminal-screen.d.ts +10 -0
- package/dist/presentation/tui/terminal-screen.js +23 -0
- package/dist/presentation/tui/tui-agent-event-runner.d.ts +24 -0
- package/dist/presentation/tui/tui-agent-event-runner.js +69 -0
- package/dist/presentation/tui/tui-application-contract.d.ts +10 -0
- package/dist/presentation/tui/tui-application-contract.js +8 -0
- package/dist/presentation/tui/tui-application.d.ts +62 -0
- package/dist/presentation/tui/tui-application.js +675 -0
- package/dist/presentation/tui/tui-attachment-input.d.ts +2 -0
- package/dist/presentation/tui/tui-attachment-input.js +5 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
- package/dist/presentation/tui/tui-clipboard-paste-handlers.js +25 -0
- package/dist/presentation/tui/tui-command-context.d.ts +3 -0
- package/dist/presentation/tui/tui-command-context.js +1 -0
- package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
- package/dist/presentation/tui/tui-command-executor.js +214 -0
- package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
- package/dist/presentation/tui/tui-command-host-factory.js +23 -0
- package/dist/presentation/tui/tui-context-compaction.d.ts +5 -0
- package/dist/presentation/tui/tui-context-compaction.js +22 -0
- package/dist/presentation/tui/tui-context-service.d.ts +34 -0
- package/dist/presentation/tui/tui-context-service.js +126 -0
- package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
- package/dist/presentation/tui/tui-file-suggestions.js +8 -0
- package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
- package/dist/presentation/tui/tui-goal-controller.js +52 -0
- package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
- package/dist/presentation/tui/tui-initial-model.js +28 -0
- package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
- package/dist/presentation/tui/tui-lifecycle-actions.js +45 -0
- package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
- package/dist/presentation/tui/tui-manual-compaction.js +31 -0
- package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
- package/dist/presentation/tui/tui-media-model-selection.js +38 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
- package/dist/presentation/tui/tui-prompt-dispatcher.js +38 -0
- package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
- package/dist/presentation/tui/tui-skill-controller.js +13 -0
- package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
- package/dist/presentation/tui/tui-tool-approval.js +73 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +8 -7
- package/scripts/install-native.mjs +11 -11
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentEvent } from '@lotagate/agent-sdk';
|
|
2
|
+
import { type CliTurnEvent } from './cli-turn-events.js';
|
|
3
|
+
/** Converts external agent events into a small, CLI-owned lifecycle projection. */
|
|
4
|
+
export declare class CliTurnEventProjector {
|
|
5
|
+
private readonly openSegments;
|
|
6
|
+
observe(event: AgentEvent): readonly CliTurnEvent[];
|
|
7
|
+
private delta;
|
|
8
|
+
private closeOpenSegment;
|
|
9
|
+
private approval;
|
|
10
|
+
private started;
|
|
11
|
+
private completed;
|
|
12
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { actionDisplayName, actionId, actionKind } from './cli-turn-events.js';
|
|
2
|
+
/** Converts external agent events into a small, CLI-owned lifecycle projection. */
|
|
3
|
+
export class CliTurnEventProjector {
|
|
4
|
+
openSegments = new Map();
|
|
5
|
+
observe(event) {
|
|
6
|
+
switch (event.type) {
|
|
7
|
+
case 'session.started':
|
|
8
|
+
this.openSegments.delete(event.runId);
|
|
9
|
+
return [{ type: 'turn.started', runId: event.runId, timestamp: event.timestamp }];
|
|
10
|
+
case 'model.delta': return event.content.length === 0 ? [] : [this.delta(event)];
|
|
11
|
+
case 'tool.approval.requested': return [...this.closeOpenSegment(event.request.context.runId, 'progress', event.timestamp), this.approval(event)];
|
|
12
|
+
case 'tool.called': return [...this.closeOpenSegment(event.runId, 'progress', event.timestamp), this.started(event)];
|
|
13
|
+
case 'tool.completed': return [this.completed(event)];
|
|
14
|
+
case 'context.compacted': return [{ type: 'context.compacted', runId: event.runId, timestamp: event.timestamp }];
|
|
15
|
+
case 'session.completed': {
|
|
16
|
+
const boundary = this.closeOpenSegment(event.runId, 'final', event.timestamp);
|
|
17
|
+
if (boundary.length > 0)
|
|
18
|
+
return [...boundary, { type: 'turn.completed', runId: event.runId, timestamp: event.timestamp }];
|
|
19
|
+
if (event.content.length === 0)
|
|
20
|
+
return [{ type: 'turn.completed', runId: event.runId, timestamp: event.timestamp }];
|
|
21
|
+
const segmentId = `${event.runId}:final`;
|
|
22
|
+
return [
|
|
23
|
+
{ type: 'assistant.delta', runId: event.runId, segmentId, iteration: 0, content: event.content, timestamp: event.timestamp },
|
|
24
|
+
{ type: 'assistant.segment.completed', runId: event.runId, segmentId, iteration: 0, phase: 'final', timestamp: event.timestamp },
|
|
25
|
+
{ type: 'turn.completed', runId: event.runId, timestamp: event.timestamp },
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
case 'session.failed': return [...this.closeOpenSegment(event.runId, 'progress', event.timestamp), { type: 'turn.failed', runId: event.runId, error: event.error, timestamp: event.timestamp }];
|
|
29
|
+
default: return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
delta(event) {
|
|
33
|
+
const segmentId = `${event.runId}:${event.iteration}`;
|
|
34
|
+
this.openSegments.set(event.runId, { segmentId, iteration: event.iteration });
|
|
35
|
+
return { type: 'assistant.delta', runId: event.runId, segmentId, iteration: event.iteration, content: event.content, timestamp: event.timestamp };
|
|
36
|
+
}
|
|
37
|
+
closeOpenSegment(runId, phase, timestamp) {
|
|
38
|
+
const open = this.openSegments.get(runId);
|
|
39
|
+
if (open === undefined)
|
|
40
|
+
return [];
|
|
41
|
+
this.openSegments.delete(runId);
|
|
42
|
+
return [{ type: 'assistant.segment.completed', runId, segmentId: open.segmentId, iteration: open.iteration, phase, timestamp }];
|
|
43
|
+
}
|
|
44
|
+
approval(event) {
|
|
45
|
+
const request = event.request;
|
|
46
|
+
return {
|
|
47
|
+
type: 'action.approval_requested',
|
|
48
|
+
actionId: actionId(request.context.runId, request.toolName),
|
|
49
|
+
runId: request.context.runId,
|
|
50
|
+
toolName: request.toolName,
|
|
51
|
+
displayName: actionDisplayName(request.toolName),
|
|
52
|
+
kind: actionKind(request.toolName, request.toolInfo?.source),
|
|
53
|
+
timestamp: event.timestamp,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
started(event) {
|
|
57
|
+
return {
|
|
58
|
+
type: 'action.started',
|
|
59
|
+
actionId: actionId(event.runId, event.toolName),
|
|
60
|
+
runId: event.runId,
|
|
61
|
+
toolName: event.toolName,
|
|
62
|
+
displayName: actionDisplayName(event.toolName),
|
|
63
|
+
kind: actionKind(event.toolName, event.source),
|
|
64
|
+
...(event.source === undefined ? {} : { source: event.source }),
|
|
65
|
+
timestamp: event.timestamp,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
completed(event) {
|
|
69
|
+
return {
|
|
70
|
+
type: 'action.completed',
|
|
71
|
+
actionId: actionId(event.runId, event.toolName),
|
|
72
|
+
runId: event.runId,
|
|
73
|
+
toolName: event.toolName,
|
|
74
|
+
displayName: actionDisplayName(event.toolName),
|
|
75
|
+
kind: actionKind(event.toolName, event.source),
|
|
76
|
+
status: event.isError ? 'failed' : 'completed',
|
|
77
|
+
isError: event.isError,
|
|
78
|
+
timestamp: event.timestamp,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { AgentEvent } from '@lotagate/agent-sdk';
|
|
2
|
+
export type CliActionKind = 'filesystem' | 'shell' | 'mcp' | 'skill' | 'subagent' | 'other';
|
|
3
|
+
export type CliActionStatus = 'waiting_approval' | 'running' | 'completed' | 'failed';
|
|
4
|
+
export type AssistantSegmentPhase = 'progress' | 'final';
|
|
5
|
+
export type CliTurnEvent = {
|
|
6
|
+
type: 'turn.started';
|
|
7
|
+
runId: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'assistant.delta';
|
|
11
|
+
runId: string;
|
|
12
|
+
segmentId: string;
|
|
13
|
+
iteration: number;
|
|
14
|
+
content: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'assistant.segment.completed';
|
|
18
|
+
runId: string;
|
|
19
|
+
segmentId: string;
|
|
20
|
+
iteration: number;
|
|
21
|
+
phase: AssistantSegmentPhase;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'action.approval_requested';
|
|
25
|
+
actionId: string;
|
|
26
|
+
runId: string;
|
|
27
|
+
toolName: string;
|
|
28
|
+
displayName: string;
|
|
29
|
+
kind: CliActionKind;
|
|
30
|
+
timestamp: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'action.started';
|
|
33
|
+
actionId: string;
|
|
34
|
+
runId: string;
|
|
35
|
+
toolName: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
kind: CliActionKind;
|
|
38
|
+
source?: string;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'action.completed';
|
|
42
|
+
actionId: string;
|
|
43
|
+
runId: string;
|
|
44
|
+
toolName: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
kind: CliActionKind;
|
|
47
|
+
status: Extract<CliActionStatus, 'completed' | 'failed'>;
|
|
48
|
+
isError: boolean;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'context.compacted';
|
|
52
|
+
runId: string;
|
|
53
|
+
timestamp: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'turn.completed';
|
|
56
|
+
runId: string;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'turn.failed';
|
|
60
|
+
runId: string;
|
|
61
|
+
error: Error;
|
|
62
|
+
timestamp: string;
|
|
63
|
+
};
|
|
64
|
+
export declare function actionId(runId: string, toolName: string): string;
|
|
65
|
+
export declare function actionKind(toolName: string, source?: string): CliActionKind;
|
|
66
|
+
export declare function actionDisplayName(toolName: string): string;
|
|
67
|
+
export declare function isDurableTurnEvent(event: CliTurnEvent): boolean;
|
|
68
|
+
export declare function toSafeTurnEventData(event: CliTurnEvent): Record<string, unknown>;
|
|
69
|
+
/** Produces the only error text permitted in durable turn state or model-facing history. */
|
|
70
|
+
export declare function safeTurnFailureMessage(error: unknown): string;
|
|
71
|
+
export type ActionEvent = Extract<CliTurnEvent, {
|
|
72
|
+
type: 'action.started' | 'action.completed' | 'action.approval_requested';
|
|
73
|
+
}>;
|
|
74
|
+
export type ProjectableAgentEvent = Extract<AgentEvent, {
|
|
75
|
+
type: 'session.started' | 'model.delta' | 'tool.approval.requested' | 'tool.called' | 'tool.completed' | 'context.compacted' | 'session.completed' | 'session.failed';
|
|
76
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { formatToolActivityName } from '../agent/tool-display.js';
|
|
2
|
+
export function actionId(runId, toolName) {
|
|
3
|
+
return `${runId}:${toolName}`;
|
|
4
|
+
}
|
|
5
|
+
export function actionKind(toolName, source) {
|
|
6
|
+
if (toolName === 'agent.spawn')
|
|
7
|
+
return 'subagent';
|
|
8
|
+
if (toolName.startsWith('mcp__') || source === 'mcp')
|
|
9
|
+
return 'mcp';
|
|
10
|
+
if (toolName.startsWith('filesystem.') || source === 'filesystem')
|
|
11
|
+
return 'filesystem';
|
|
12
|
+
if (toolName.startsWith('shell.') || source === 'shell')
|
|
13
|
+
return 'shell';
|
|
14
|
+
if (toolName.startsWith('skill.') || source === 'skill')
|
|
15
|
+
return 'skill';
|
|
16
|
+
return 'other';
|
|
17
|
+
}
|
|
18
|
+
export function actionDisplayName(toolName) {
|
|
19
|
+
return formatToolActivityName(toolName);
|
|
20
|
+
}
|
|
21
|
+
export function isDurableTurnEvent(event) {
|
|
22
|
+
return event.type === 'action.started' || event.type === 'action.completed' || event.type === 'assistant.segment.completed';
|
|
23
|
+
}
|
|
24
|
+
export function toSafeTurnEventData(event) {
|
|
25
|
+
switch (event.type) {
|
|
26
|
+
case 'assistant.segment.completed': return { segmentId: event.segmentId, iteration: event.iteration, phase: event.phase };
|
|
27
|
+
case 'action.started': return { actionId: event.actionId, toolName: event.toolName, displayName: event.displayName, kind: event.kind, source: event.source, status: 'running' };
|
|
28
|
+
case 'action.completed': return { actionId: event.actionId, toolName: event.toolName, displayName: event.displayName, kind: event.kind, status: event.status, isError: event.isError };
|
|
29
|
+
case 'context.compacted': return { runId: event.runId };
|
|
30
|
+
case 'turn.completed': return { runId: event.runId };
|
|
31
|
+
case 'turn.failed': return { runId: event.runId, message: safeTurnFailureMessage(event.error) };
|
|
32
|
+
default: return {};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Produces the only error text permitted in durable turn state or model-facing history. */
|
|
36
|
+
export function safeTurnFailureMessage(error) {
|
|
37
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
38
|
+
return message.replace(/(api[-_ ]?key|authorization|bearer|token)\s*[:=]\s*[^\s,;]+/giu, '$1=[REDACTED]').slice(0, 1024);
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SessionStore } from '../../ports/session-store.js';
|
|
2
|
+
import { type CliTurnEvent } from './cli-turn-events.js';
|
|
3
|
+
/** Persists only sanitized, durable lifecycle metadata; deltas and raw payloads stay ephemeral. */
|
|
4
|
+
export declare function persistCliTurnEvent(store: SessionStore, sessionId: string, event: CliTurnEvent, options?: {
|
|
5
|
+
turnId?: string;
|
|
6
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isDurableTurnEvent, toSafeTurnEventData } from './cli-turn-events.js';
|
|
2
|
+
/** Persists only sanitized, durable lifecycle metadata; deltas and raw payloads stay ephemeral. */
|
|
3
|
+
export async function persistCliTurnEvent(store, sessionId, event, options = {}) {
|
|
4
|
+
if (!isDurableTurnEvent(event))
|
|
5
|
+
return;
|
|
6
|
+
await store.appendEvent({
|
|
7
|
+
type: `agent.${event.type}`,
|
|
8
|
+
timestamp: event.timestamp,
|
|
9
|
+
sessionId,
|
|
10
|
+
...(options.turnId === undefined ? {} : { turnId: options.turnId }),
|
|
11
|
+
...('runId' in event ? { runId: event.runId } : {}),
|
|
12
|
+
data: toSafeTurnEventData(event),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { LotaGate } from '@lotagate/sdk';
|
|
2
|
+
import type { GoalEvaluation } from '../../domain/orchestration/goal.js';
|
|
3
|
+
import type { ModelUsageReport } from '../../ports/model-diagnostics.js';
|
|
4
|
+
export interface GoalVerificationContext {
|
|
5
|
+
toolCalls: number;
|
|
6
|
+
toolFailures: number;
|
|
7
|
+
toolNames: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface GoalEvaluationInput {
|
|
10
|
+
objective: string;
|
|
11
|
+
response: string;
|
|
12
|
+
turn: number;
|
|
13
|
+
model: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
verification?: GoalVerificationContext;
|
|
16
|
+
onUsage?: (report: ModelUsageReport) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function evaluateGoal(client: LotaGate, input: GoalEvaluationInput): Promise<GoalEvaluation>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { RESOURCE_LIMITS } from '../../domain/runtime/resource-limits.js';
|
|
2
|
+
import { estimateTurnUsage } from '../../infrastructure/tokens/tiktoken-token-estimator.js';
|
|
3
|
+
export async function evaluateGoal(client, input) {
|
|
4
|
+
const evaluatorPrompt = [
|
|
5
|
+
`<objective>\n${bounded(input.objective, RESOURCE_LIMITS.goalObjectiveBytes)}\n</objective>`,
|
|
6
|
+
`<latest-turn>\n${bounded(input.response, RESOURCE_LIMITS.goalEvidenceBytes)}\n</latest-turn>`,
|
|
7
|
+
`<verification>\n${formatVerification(input.verification)}\n</verification>`,
|
|
8
|
+
`<turn>${input.turn}</turn>`,
|
|
9
|
+
].join('\n');
|
|
10
|
+
try {
|
|
11
|
+
const response = await client.chat.completions.create({
|
|
12
|
+
model: input.model,
|
|
13
|
+
messages: [
|
|
14
|
+
{ role: 'system', content: 'Evaluate whether the user goal is complete. Return JSON only with decision (continue|complete|blocked), reason, and evidence (array of strings). Mark complete only when every requirement has concrete evidence from the latest work and verification context. A model claim alone is not evidence. Do not invent evidence and do not use tools.' },
|
|
15
|
+
{ role: 'user', content: evaluatorPrompt },
|
|
16
|
+
],
|
|
17
|
+
stream: false,
|
|
18
|
+
max_tokens: 512,
|
|
19
|
+
temperature: 0,
|
|
20
|
+
}, input.signal === undefined ? undefined : { signal: input.signal });
|
|
21
|
+
const content = response.choices[0]?.message.content;
|
|
22
|
+
const usage = mapUsage(response.usage);
|
|
23
|
+
const estimated = usage === undefined ? estimateTurnUsage({ model: input.model, prompt: evaluatorPrompt, response: textContent(content) }) : usage;
|
|
24
|
+
if (estimated !== undefined)
|
|
25
|
+
input.onUsage?.({ usage: estimated, modelCalls: 1 });
|
|
26
|
+
const parsed = parseEvaluation(content);
|
|
27
|
+
if (parsed === undefined)
|
|
28
|
+
throw new Error('Goal evaluator returned an invalid decision.');
|
|
29
|
+
return { ...requireConcreteCompletionEvidence(parsed, input.verification), timestamp: new Date().toISOString(), evaluatorModel: input.model };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new Error(`Goal evaluator failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function requireConcreteCompletionEvidence(evaluation, verification) {
|
|
36
|
+
if (evaluation.decision !== 'complete')
|
|
37
|
+
return evaluation;
|
|
38
|
+
if (verification === undefined || verification.toolCalls === 0 || verification.toolFailures > 0) {
|
|
39
|
+
return {
|
|
40
|
+
decision: 'continue',
|
|
41
|
+
reason: 'Completion requires successful tool-backed verification; continue inspecting and validating the workspace.',
|
|
42
|
+
evidence: verification?.toolFailures === 0 ? verification.toolNames : [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return evaluation;
|
|
46
|
+
}
|
|
47
|
+
function parseEvaluation(content) {
|
|
48
|
+
const text = textContent(content);
|
|
49
|
+
const match = text.match(/\{[\s\S]*\}/u);
|
|
50
|
+
if (match === null)
|
|
51
|
+
return undefined;
|
|
52
|
+
try {
|
|
53
|
+
const value = JSON.parse(match[0]);
|
|
54
|
+
const decision = value['decision'];
|
|
55
|
+
const reason = value['reason'];
|
|
56
|
+
const evidence = value['evidence'];
|
|
57
|
+
if (decision !== 'continue' && decision !== 'complete' && decision !== 'blocked')
|
|
58
|
+
return undefined;
|
|
59
|
+
if (typeof reason !== 'string' || !Array.isArray(evidence) || evidence.some((item) => typeof item !== 'string'))
|
|
60
|
+
return undefined;
|
|
61
|
+
return { decision, reason: bounded(reason, RESOURCE_LIMITS.goalReasonBytes), evidence: evidence.slice(0, RESOURCE_LIMITS.goalEvidenceItems).map((item) => bounded(item, RESOURCE_LIMITS.goalEvidenceBytes)) };
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function mapUsage(usage) {
|
|
68
|
+
if (usage === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
return {
|
|
71
|
+
...(typeof usage.prompt_tokens === 'number' ? { promptTokens: usage.prompt_tokens } : {}),
|
|
72
|
+
...(typeof usage.completion_tokens === 'number' ? { completionTokens: usage.completion_tokens } : {}),
|
|
73
|
+
...(typeof usage.total_tokens === 'number' ? { totalTokens: usage.total_tokens } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function formatVerification(value) {
|
|
77
|
+
if (value === undefined)
|
|
78
|
+
return 'No tool verification metadata was available; do not mark complete from a claim alone.';
|
|
79
|
+
return `tool_calls=${value.toolCalls}; tool_failures=${value.toolFailures}; tools=${value.toolNames.slice(0, 32).join(', ') || 'none'}`;
|
|
80
|
+
}
|
|
81
|
+
function textContent(content) {
|
|
82
|
+
if (typeof content === 'string')
|
|
83
|
+
return content;
|
|
84
|
+
if (!Array.isArray(content))
|
|
85
|
+
return '';
|
|
86
|
+
return content.map((part) => typeof part === 'object' && part !== null && 'text' in part && typeof part.text === 'string' ? part.text : '').join('');
|
|
87
|
+
}
|
|
88
|
+
function bounded(value, maximum) { return value.length <= maximum ? value : `${value.slice(0, maximum - 3)}...`; }
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CreateGoalInput } from '../../domain/orchestration/goal.js';
|
|
2
|
+
export declare function parseGoalInput(objective: string, flags: ReadonlyMap<string, string | boolean>): CreateGoalInput;
|
|
3
|
+
export declare function parseGoalLimits(flags: ReadonlyMap<string, string | boolean>): Omit<CreateGoalInput, 'objective'>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getPositiveIntegerFlag } from '../commands/cli-args.js';
|
|
2
|
+
import { RESOURCE_LIMITS } from '../../domain/runtime/resource-limits.js';
|
|
3
|
+
export function parseGoalInput(objective, flags) {
|
|
4
|
+
return { objective, maxTurns: RESOURCE_LIMITS.goalDefaultMaxTurns, maxDurationMs: RESOURCE_LIMITS.goalDefaultMaxDurationMs, ...parseGoalLimits(flags) };
|
|
5
|
+
}
|
|
6
|
+
export function parseGoalLimits(flags) {
|
|
7
|
+
const tokenBudget = readPositive(flags, 'token-budget');
|
|
8
|
+
const maxTurns = readPositive(flags, 'max-turns');
|
|
9
|
+
const maxDurationMs = readPositive(flags, 'max-duration-ms');
|
|
10
|
+
return { ...(tokenBudget === undefined ? {} : { tokenBudget }), ...(maxTurns === undefined ? {} : { maxTurns }), ...(maxDurationMs === undefined ? {} : { maxDurationMs }) };
|
|
11
|
+
}
|
|
12
|
+
function readPositive(flags, name) {
|
|
13
|
+
const maximum = name === 'max-duration-ms'
|
|
14
|
+
? RESOURCE_LIMITS.goalMaximumMaxDurationMs
|
|
15
|
+
: name === 'max-turns'
|
|
16
|
+
? RESOURCE_LIMITS.goalMaximumMaxTurns
|
|
17
|
+
: RESOURCE_LIMITS.goalMaximumTokenBudget;
|
|
18
|
+
return getPositiveIntegerFlag(flags, name, maximum);
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function formatGoalStatus(state) {
|
|
2
|
+
return [
|
|
3
|
+
`Goal ${state.status}`, `Objective: ${state.objective}`, `Turns: ${state.turns}`, `Evaluator runs: ${state.evaluatorRuns}`,
|
|
4
|
+
`Tokens: ${state.usage.totalTokens} (input ${state.usage.inputTokens}, output ${state.usage.outputTokens}${state.usage.estimated ? ', estimated' : ''})`,
|
|
5
|
+
...(state.tokenBudget === undefined ? [] : [`Token budget: ${state.tokenBudget}`]),
|
|
6
|
+
...(state.maxTurns === undefined ? [] : [`Max turns: ${state.maxTurns}`]),
|
|
7
|
+
...(state.maxDurationMs === undefined ? [] : [`Max duration: ${state.maxDurationMs} ms`]),
|
|
8
|
+
...(state.lastError === undefined ? [] : [`Last error: ${state.lastError}`]),
|
|
9
|
+
...(state.lastEvaluation === undefined ? [] : [`Last evaluation: ${state.lastEvaluation.decision} — ${state.lastEvaluation.reason}`]),
|
|
10
|
+
].join('\n');
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LotaGate } from '@lotagate/sdk';
|
|
2
|
+
import type { AgentRunSnapshot } from '../agent/agent-run-tracker.js';
|
|
3
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
4
|
+
import type { GoalState } from '../../domain/orchestration/goal.js';
|
|
5
|
+
import { GoalUsageAccumulator } from './goal-usage.js';
|
|
6
|
+
export interface GoalRunnerOptions {
|
|
7
|
+
runtime: CliRuntime;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
objective: string;
|
|
10
|
+
model: string;
|
|
11
|
+
client: LotaGate;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
initialPrompt?: string;
|
|
14
|
+
runTurn: (prompt: string, callbacks: GoalTurnCallbacks, signal: AbortSignal) => Promise<string>;
|
|
15
|
+
onMessage?: (message: string) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface GoalTurnCallbacks {
|
|
18
|
+
onUsage: (report: Parameters<GoalUsageAccumulator['add']>[0]) => void;
|
|
19
|
+
onSnapshot: (snapshot: AgentRunSnapshot) => void;
|
|
20
|
+
onError: (error: unknown) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function runGoalLoop(options: GoalRunnerOptions): Promise<GoalState | undefined>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { RESOURCE_LIMITS } from '../../domain/runtime/resource-limits.js';
|
|
2
|
+
import { evaluateGoal } from './goal-evaluator.js';
|
|
3
|
+
import { GoalUsageAccumulator } from './goal-usage.js';
|
|
4
|
+
import { CliError } from '../../domain/errors/cli-error.js';
|
|
5
|
+
export async function runGoalLoop(options) {
|
|
6
|
+
let prompt = options.initialPrompt ?? options.objective;
|
|
7
|
+
let turnsThisRun = 0;
|
|
8
|
+
let evaluatorRunsThisRun = 0;
|
|
9
|
+
options.onMessage?.(`Goal started: ${options.objective}`);
|
|
10
|
+
while (true) {
|
|
11
|
+
const state = await options.runtime.goalStore.get(options.sessionId);
|
|
12
|
+
if (state === undefined || state.status !== 'active')
|
|
13
|
+
break;
|
|
14
|
+
const limit = executionLimit(state, turnsThisRun, evaluatorRunsThisRun);
|
|
15
|
+
if (limit !== undefined) {
|
|
16
|
+
await pauseForLimit(options, limit);
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
await options.runtime.goalStore.recordTurn(options.sessionId);
|
|
20
|
+
turnsThisRun += 1;
|
|
21
|
+
const turnUsage = new GoalUsageAccumulator();
|
|
22
|
+
let verification;
|
|
23
|
+
let turnError;
|
|
24
|
+
let response = '';
|
|
25
|
+
const turn = deadlineSignal(state, options.signal);
|
|
26
|
+
try {
|
|
27
|
+
response = await options.runTurn(prompt, {
|
|
28
|
+
onUsage: (report) => turnUsage.add(report),
|
|
29
|
+
onSnapshot: (snapshot) => { verification = { toolCalls: snapshot.toolCalls, toolFailures: snapshot.toolFailures, toolNames: snapshot.toolNames }; },
|
|
30
|
+
onError: (error) => { turnError = error; },
|
|
31
|
+
}, turn.signal);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
turnError = error;
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
turn.dispose();
|
|
38
|
+
}
|
|
39
|
+
await persistUsage(options, turnUsage);
|
|
40
|
+
if (isGoalDeadline(turn.signal, options.signal)) {
|
|
41
|
+
await pauseForLimit(options, { kind: 'duration', reason: 'Goal execution duration limit reached.' });
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (turnError !== undefined || response.trim().length === 0) {
|
|
45
|
+
await pauseAfterFailure(options, turnError ?? new Error('The agent turn did not return a final response.'));
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
const afterTurn = await options.runtime.goalStore.get(options.sessionId);
|
|
49
|
+
if (afterTurn?.tokenBudget !== undefined && afterTurn.usage.totalTokens >= afterTurn.tokenBudget) {
|
|
50
|
+
await pauseForLimit(options, { kind: 'tokens', reason: 'Goal token budget reached after the agent turn.' });
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
const evaluationUsage = new GoalUsageAccumulator();
|
|
54
|
+
const evaluationDeadline = deadlineSignal(afterTurn ?? state, options.signal);
|
|
55
|
+
try {
|
|
56
|
+
const evaluation = await evaluateGoal(options.client, {
|
|
57
|
+
objective: options.objective,
|
|
58
|
+
response,
|
|
59
|
+
turn: afterTurn?.turns ?? state.turns + 1,
|
|
60
|
+
model: options.model,
|
|
61
|
+
signal: evaluationDeadline.signal,
|
|
62
|
+
...(verification === undefined ? {} : { verification }),
|
|
63
|
+
onUsage: (report) => evaluationUsage.add(report),
|
|
64
|
+
});
|
|
65
|
+
if (isGoalDeadline(evaluationDeadline.signal, options.signal)) {
|
|
66
|
+
await pauseForLimit(options, { kind: 'duration', reason: 'Goal execution duration limit reached during evaluation.' });
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
evaluatorRunsThisRun += 1;
|
|
70
|
+
await persistUsage(options, evaluationUsage);
|
|
71
|
+
const afterEvaluation = await options.runtime.goalStore.get(options.sessionId);
|
|
72
|
+
const updated = afterEvaluation?.tokenBudget !== undefined && afterEvaluation.usage.totalTokens >= afterEvaluation.tokenBudget
|
|
73
|
+
? await pauseForLimit(options, { kind: 'tokens', reason: 'Goal token budget reached during evaluation.' })
|
|
74
|
+
: await options.runtime.goalStore.recordEvaluation(options.sessionId, evaluation);
|
|
75
|
+
if (updated?.status !== 'active')
|
|
76
|
+
break;
|
|
77
|
+
prompt = nextPrompt(options.objective, evaluation.reason, evaluation.evidence);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (isGoalDeadline(evaluationDeadline.signal, options.signal)) {
|
|
81
|
+
await persistUsage(options, evaluationUsage);
|
|
82
|
+
await pauseForLimit(options, { kind: 'duration', reason: 'Goal execution duration limit reached during evaluation.' });
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
await persistUsage(options, evaluationUsage);
|
|
86
|
+
await pauseAfterFailure(options, error);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
evaluationDeadline.dispose();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const final = await options.runtime.goalStore.get(options.sessionId);
|
|
94
|
+
options.onMessage?.(final === undefined ? 'Goal ended.' : `Goal ${final.status}. Turns: ${final.turns}. Tokens: ${final.usage.totalTokens}${final.usage.estimated ? ' (estimated)' : ''}.`);
|
|
95
|
+
return final;
|
|
96
|
+
}
|
|
97
|
+
function deadlineSignal(state, parent) {
|
|
98
|
+
const controller = new AbortController();
|
|
99
|
+
const abort = () => controller.abort(parent?.reason);
|
|
100
|
+
if (parent?.aborted)
|
|
101
|
+
abort();
|
|
102
|
+
else
|
|
103
|
+
parent?.addEventListener('abort', abort, { once: true });
|
|
104
|
+
const remaining = Math.max(1, (state.maxDurationMs ?? RESOURCE_LIMITS.goalDefaultMaxDurationMs) - (Date.now() - Date.parse(state.startedAt)));
|
|
105
|
+
const timer = setTimeout(() => controller.abort(new Error('Goal execution duration limit reached.')), remaining);
|
|
106
|
+
return { signal: controller.signal, dispose: () => { clearTimeout(timer); parent?.removeEventListener('abort', abort); } };
|
|
107
|
+
}
|
|
108
|
+
function executionLimit(state, turnsThisRun, evaluatorRunsThisRun) {
|
|
109
|
+
const maxTurns = state.maxTurns ?? RESOURCE_LIMITS.goalDefaultMaxTurns;
|
|
110
|
+
if (turnsThisRun >= maxTurns)
|
|
111
|
+
return { kind: 'turns', reason: 'Goal safety turn guard reached for this run.' };
|
|
112
|
+
if (evaluatorRunsThisRun >= RESOURCE_LIMITS.goalDefaultMaxEvaluatorRuns)
|
|
113
|
+
return { kind: 'evaluator', reason: 'Goal safety evaluator guard reached for this run.' };
|
|
114
|
+
if (state.tokenBudget !== undefined && state.usage.totalTokens >= state.tokenBudget)
|
|
115
|
+
return { kind: 'tokens', reason: 'Goal token budget reached.' };
|
|
116
|
+
const started = Date.parse(state.startedAt);
|
|
117
|
+
const elapsed = Number.isFinite(started) ? Date.now() - started : Number.MAX_SAFE_INTEGER;
|
|
118
|
+
if (elapsed >= (state.maxDurationMs ?? RESOURCE_LIMITS.goalDefaultMaxDurationMs))
|
|
119
|
+
return { kind: 'duration', reason: 'Goal execution duration limit reached.' };
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
async function persistUsage(options, usage) {
|
|
123
|
+
const delta = usage.delta();
|
|
124
|
+
if ((delta.modelCalls ?? 0) === 0)
|
|
125
|
+
return;
|
|
126
|
+
const state = await options.runtime.goalStore.get(options.sessionId);
|
|
127
|
+
if (state?.status === 'active')
|
|
128
|
+
await options.runtime.goalStore.recordUsage(options.sessionId, delta);
|
|
129
|
+
}
|
|
130
|
+
async function pauseAfterFailure(options, error) {
|
|
131
|
+
const reason = sanitizeFailureReason(error);
|
|
132
|
+
const state = await options.runtime.goalStore.get(options.sessionId);
|
|
133
|
+
if (state?.status === 'active')
|
|
134
|
+
await options.runtime.goalStore.pause(options.sessionId, `Goal paused: ${reason}`);
|
|
135
|
+
}
|
|
136
|
+
async function pauseForLimit(options, limit) {
|
|
137
|
+
const state = await options.runtime.goalStore.get(options.sessionId);
|
|
138
|
+
if (state?.status !== 'active')
|
|
139
|
+
return state;
|
|
140
|
+
const paused = await options.runtime.goalStore.pause(options.sessionId, `Goal paused by safety limit: ${limit.reason}`);
|
|
141
|
+
options.onMessage?.(`Goal paused safely: ${limit.reason}\nResume the goal to continue from the persisted state.`);
|
|
142
|
+
return paused;
|
|
143
|
+
}
|
|
144
|
+
function isGoalDeadline(signal, parent) {
|
|
145
|
+
return signal.aborted && signal !== parent && signal.reason instanceof Error && /Goal execution duration limit reached/iu.test(signal.reason.message);
|
|
146
|
+
}
|
|
147
|
+
function sanitizeFailureReason(error) {
|
|
148
|
+
const raw = error instanceof CliError ? error.userMessage : error instanceof Error ? error.message : String(error);
|
|
149
|
+
return raw.replace(/(api[-_ ]?key|authorization|bearer|token)\s*[:=]\s*[^\s,;]+/giu, '$1=[REDACTED]').slice(0, RESOURCE_LIMITS.goalReasonBytes);
|
|
150
|
+
}
|
|
151
|
+
function nextPrompt(objective, reason, evidence) {
|
|
152
|
+
return `<active-goal>\n${objective}\n</active-goal>\n<last-evaluation>\n${reason}\n${evidence.join('\n')}\n</last-evaluation>\nContinue the work and verify the remaining requirements.`;
|
|
153
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChatUsage } from '../../ports/chat-model.js';
|
|
2
|
+
import type { ModelUsageReport } from '../../ports/model-diagnostics.js';
|
|
3
|
+
import type { GoalUsage, GoalUsageDelta } from '../../domain/orchestration/goal.js';
|
|
4
|
+
export declare class GoalUsageAccumulator {
|
|
5
|
+
private current;
|
|
6
|
+
add(report: ModelUsageReport | ChatUsage): void;
|
|
7
|
+
snapshot(): GoalUsage;
|
|
8
|
+
delta(): GoalUsageDelta;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class GoalUsageAccumulator {
|
|
2
|
+
current = { inputTokens: 0, outputTokens: 0, totalTokens: 0, modelCalls: 0, estimated: false };
|
|
3
|
+
add(report) {
|
|
4
|
+
const usage = 'usage' in report ? report.usage : report;
|
|
5
|
+
const modelCalls = 'usage' in report ? report.modelCalls ?? 1 : 1;
|
|
6
|
+
const inputTokens = usage.promptTokens ?? 0;
|
|
7
|
+
const outputTokens = usage.completionTokens ?? 0;
|
|
8
|
+
const totalTokens = Math.max(usage.totalTokens ?? 0, inputTokens + outputTokens);
|
|
9
|
+
this.current = {
|
|
10
|
+
inputTokens: this.current.inputTokens + inputTokens,
|
|
11
|
+
outputTokens: this.current.outputTokens + outputTokens,
|
|
12
|
+
totalTokens: this.current.totalTokens + totalTokens,
|
|
13
|
+
modelCalls: this.current.modelCalls + modelCalls,
|
|
14
|
+
estimated: this.current.estimated || usage.estimated === true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
snapshot() { return { ...this.current }; }
|
|
18
|
+
delta() { return { ...this.current }; }
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LotaGate } from '@lotagate/sdk';
|
|
2
|
+
import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
|
|
3
|
+
import type { AgentGoalSummary } from '../agent/capability-profile.js';
|
|
4
|
+
import type { SessionStore as AgentSessionStore } from '@lotagate/agent-sdk';
|
|
5
|
+
import type { ModelUsageReport } from '../../ports/model-diagnostics.js';
|
|
6
|
+
import type { AgentRunSnapshot } from '../agent/agent-run-tracker.js';
|
|
7
|
+
import type { SessionEvent, TranscriptEntry } from '../../domain/session/session.js';
|
|
8
|
+
type HydratableAgentSessionStore = AgentSessionStore & {
|
|
9
|
+
hydrate(sessionId: string, systemPrompt: string, transcript: readonly TranscriptEntry[], events: readonly SessionEvent[], currentInput: string): void;
|
|
10
|
+
delete(sessionId: string): void;
|
|
11
|
+
};
|
|
12
|
+
export interface HeadlessAgentTurnOptions {
|
|
13
|
+
runtime: CliRuntime;
|
|
14
|
+
cwd: string;
|
|
15
|
+
model: string;
|
|
16
|
+
client: LotaGate;
|
|
17
|
+
prompt: string;
|
|
18
|
+
output?: {
|
|
19
|
+
write(chunk: string): unknown;
|
|
20
|
+
};
|
|
21
|
+
json?: boolean;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
turnId?: string;
|
|
25
|
+
goal?: AgentGoalSummary;
|
|
26
|
+
agentSessionStore?: HydratableAgentSessionStore;
|
|
27
|
+
onUsage?: (report: ModelUsageReport) => void;
|
|
28
|
+
onSubagentUsage?: (report: ModelUsageReport) => void;
|
|
29
|
+
onSnapshot?: (snapshot: AgentRunSnapshot) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare function runHeadlessAgentTurn(options: HeadlessAgentTurnOptions): Promise<string>;
|
|
32
|
+
export {};
|