@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 @@
|
|
|
1
|
+
class f{client;constructor(r){this.client=r}async generateImage(r,t){return(await this.client.images.generations.create(a(r),t)).data.map(n=>({...typeof n.b64_json=="string"?{base64:n.b64_json}:{},...typeof n.url=="string"?{url:n.url}:{},...typeof n.revised_prompt=="string"?{revisedPrompt:n.revised_prompt}:{}}))}async editImage(r,t){const s={...a(r),image:r.images,...r.mask===void 0?{}:{mask:r.mask},...r.inputFidelity===void 0?{}:{input_fidelity:r.inputFidelity}};return(await this.client.images.edits.create(s,t)).data.map(o=>({...typeof o.b64_json=="string"?{base64:o.b64_json}:{},...typeof o.url=="string"?{url:o.url}:{},...typeof o.revised_prompt=="string"?{revisedPrompt:o.revised_prompt}:{}}))}async createSpeech(r,t){const s=await this.client.audio.speech.create({model:r.model,input:r.input,voice:r.voice,...r.instructions===void 0?{}:{instructions:r.instructions},...r.responseFormat===void 0?{}:{response_format:r.responseFormat},...r.speed===void 0?{}:{speed:r.speed}},t);return d(s)}async transcribe(r,t){return(await this.client.audio.transcriptions.create(m(r),t)).text}async translate(r,t){return(await this.client.audio.translations.create(c(r),t)).text}async createVideo(r,t){const s={model:r.model,instances:[{prompt:r.prompt}],...r.parameters===void 0?{}:{parameters:r.parameters}};return i(await this.client.video.generations.create(s,t))}async getVideoOperation(r,t){return i(await this.client.video.operations.retrieve(r,t))}async downloadVideo(r,t){return d(await this.client.video.operations.download(r,t))}}function a(e){return{model:e.model,prompt:e.prompt,...e.n===void 0?{}:{n:e.n},...e.size===void 0?{}:{size:e.size},...e.quality===void 0?{}:{quality:e.quality},...e.background===void 0?{}:{background:e.background},...e.outputFormat===void 0?{}:{output_format:e.outputFormat},...e.outputCompression===void 0?{}:{output_compression:e.outputCompression},...e.moderation===void 0?{}:{moderation:e.moderation},...e.user===void 0?{}:{user:e.user}}}function m(e){const r={model:e.model,file:e.file,filename:e.filename};return e.prompt!==void 0&&(r.prompt=e.prompt),e.temperature!==void 0&&(r.temperature=e.temperature),e.responseFormat!==void 0&&(r.response_format=e.responseFormat),e.language!==void 0&&(r.language=e.language),e.timestampGranularities!==void 0&&(r.timestamp_granularities=[...e.timestampGranularities]),e.include!==void 0&&(r.include=[...e.include]),r}function c(e){const r={model:e.model,file:e.file,filename:e.filename};return e.prompt!==void 0&&(r.prompt=e.prompt),e.temperature!==void 0&&(r.temperature=e.temperature),e.responseFormat!==void 0&&(r.response_format=e.responseFormat),r}function d(e){const r=e.headers.get("content-type")?.split(";",1)[0]?.trim();return{bytes:new Uint8Array(e.data),...r===void 0||r.length===0?{}:{contentType:r}}}function i(e){return{id:e.name,done:e.done===!0,...typeof e.error?.message=="string"?{errorMessage:e.error.message}:{}}}export{f as SdkMediaGatewayClient};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CreateGoalInput, type GoalEvaluation, type GoalState, type GoalUsageDelta } from '../../domain/orchestration/goal.js';
|
|
2
|
+
import type { GoalStore } from '../../ports/goal-store.js';
|
|
3
|
+
import type { SessionStore } from '../../ports/session-store.js';
|
|
4
|
+
export declare class FileGoalStore implements GoalStore {
|
|
5
|
+
private readonly sessions;
|
|
6
|
+
constructor(sessions: SessionStore);
|
|
7
|
+
get(sessionId: string): Promise<GoalState | undefined>;
|
|
8
|
+
create(sessionId: string, input: CreateGoalInput): Promise<GoalState>;
|
|
9
|
+
replace(sessionId: string, input: CreateGoalInput): Promise<GoalState>;
|
|
10
|
+
pause(sessionId: string, reason?: string): Promise<GoalState>;
|
|
11
|
+
resume(sessionId: string): Promise<GoalState>;
|
|
12
|
+
recordTurn(sessionId: string): Promise<GoalState>;
|
|
13
|
+
recordUsage(sessionId: string, delta: GoalUsageDelta): Promise<GoalState>;
|
|
14
|
+
recordEvaluation(sessionId: string, evaluation: GoalEvaluation): Promise<GoalState>;
|
|
15
|
+
clear(sessionId: string, reason?: string): Promise<void>;
|
|
16
|
+
private requireActiveUnlocked;
|
|
17
|
+
private getOrThrowUnlocked;
|
|
18
|
+
private invalidState;
|
|
19
|
+
private appendState;
|
|
20
|
+
private append;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import v from"node:crypto";import{CliError as l}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as p}from"../../domain/errors/error-codes.js";import{RESOURCE_LIMITS as i}from"../../domain/runtime/resource-limits.js";import{addGoalUsage as w,EMPTY_GOAL_USAGE as m,isGoalEvaluation as h,isGoalEventType as y,isGoalState as E,validateGoalInput as g}from"../../domain/orchestration/goal.js";class T{sessions;constructor(t){this.sessions=t}async get(t){return c(await this.sessions.readEvents(t))}async create(t,e){return this.sessions.withLock(t,async()=>{const s=g(e),n=c(await this.sessions.readEvents(t));return n?.status==="active"||n?.status==="paused"?this.appendState(n,s,"goal.replaced"):this.appendState(void 0,s,"goal.created",t)})}async replace(t,e){return this.sessions.withLock(t,async()=>this.appendState(void 0,g(e),"goal.replaced",t))}async pause(t,e="Paused by user."){return this.sessions.withLock(t,async()=>{const n={...await this.requireActiveUnlocked(t),status:"paused",updatedAt:r(),lastError:o(e,i.goalReasonBytes)};return await this.append(n,"goal.paused",{reason:n.lastError},!0),n})}async resume(t){return this.sessions.withLock(t,async()=>{const e=await this.getOrThrowUnlocked(t);if(e.status!=="paused")throw this.invalidState(`Goal cannot be resumed from ${e.status}.`);const s=r(),n=f({...e,status:"active",startedAt:s,updatedAt:s});return await this.append(n,"goal.resumed",{},!0),n})}async recordTurn(t){return this.sessions.withLock(t,async()=>{const e=await this.requireActiveUnlocked(t),s={...e,turns:e.turns+1,updatedAt:r()};return await this.append(s,"goal.turn.started",{},!0),s})}async recordUsage(t,e){return this.sessions.withLock(t,async()=>{const s=await this.requireActiveUnlocked(t),n={...s,usage:w(s.usage,e),updatedAt:r()};return await this.append(n,"goal.usage_recorded",{},!0),n})}async recordEvaluation(t,e){return this.sessions.withLock(t,async()=>{const s=await this.requireActiveUnlocked(t);if(!h(e))throw this.invalidState("Goal evaluation is invalid.");const n=k(e.decision),u=S(e),d=f({...s,status:n,evaluatorRuns:s.evaluatorRuns+1,updatedAt:r(),lastEvaluation:u});return await this.append(d,n==="active"?"goal.evaluated":`goal.${n}`,{evaluation:u},!0),d})}async clear(t,e="Cleared by user."){await this.sessions.withLock(t,async()=>{const s=c(await this.sessions.readEvents(t));s!==void 0&&await this.append(s,"goal.cleared",{reason:o(e,i.goalReasonBytes)},!0)})}async requireActiveUnlocked(t){const e=await this.getOrThrowUnlocked(t);if(e.status!=="active")throw this.invalidState(`Goal is not active: ${e.status}.`);return e}async getOrThrowUnlocked(t){const e=c(await this.sessions.readEvents(t));if(e===void 0)throw new l(p.GOAL_NOT_FOUND,`Goal not found for session: ${t}`,{category:"goal",userMessage:"No goal is configured for this session."});return e}invalidState(t){return new l(p.GOAL_INVALID_STATE,t,{category:"goal",userMessage:t})}async appendState(t,e,s,n){const u=t?.sessionId??n;if(u===void 0)throw this.invalidState("A session id is required to create a goal.");const d=A(u,e);return await this.append(d,s,{},!0),d}async append(t,e,s,n){await this.sessions.appendEvent({type:e,timestamp:r(),sessionId:t.sessionId,data:{goal:G(t),...s}},{locked:n})}}function A(a,t){const e=r();return{id:v.randomUUID(),sessionId:a,objective:t.objective,status:"active",createdAt:e,updatedAt:e,startedAt:e,turns:0,evaluatorRuns:0,usage:{...m},...t.tokenBudget===void 0?{}:{tokenBudget:t.tokenBudget},...t.maxTurns===void 0?{}:{maxTurns:t.maxTurns},...t.maxDurationMs===void 0?{}:{maxDurationMs:t.maxDurationMs}}}function c(a){let t;for(const e of a){if(!y(e.type))continue;if(e.type==="goal.cleared"){t=void 0;continue}const s=e.data?.goal;E(s)&&(t=s,e.type==="goal.evaluated"&&e.data?.evaluation!==void 0&&h(e.data.evaluation)&&(t={...t,lastEvaluation:e.data.evaluation}))}return t}function k(a){return a==="complete"?"completed":a==="blocked"?"blocked":a==="budget_limited"?"budget_limited":a==="usage_limited"?"usage_limited":"active"}function S(a){return{decision:a.decision,reason:o(a.reason,i.goalReasonBytes),evidence:a.evidence.slice(0,i.goalEvidenceItems).map(t=>o(t,i.goalEvidenceBytes)),timestamp:a.timestamp,...a.evaluatorModel===void 0?{}:{evaluatorModel:o(a.evaluatorModel,256)}}}function G(a){return{...a,objective:o(a.objective,i.goalObjectiveBytes)}}function o(a,t){return a.length<=t?a:`${a.slice(0,t-3)}...`}function r(){return new Date().toISOString()}function f(a){return delete a.lastError,a}export{T as FileGoalStore};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SessionEvent, SessionMetadata, TranscriptEntry } from '../../domain/session/session.js';
|
|
2
|
+
import type { Attachment } from '../../domain/session/attachment.js';
|
|
3
|
+
import type { SessionStore, SessionBundle, SessionHistory, SessionJournalAppend, SessionRepairResult } from '../../ports/session-store.js';
|
|
4
|
+
import type { PlatformPaths } from '../platform/platform-paths.js';
|
|
5
|
+
export declare class FileSessionStore implements SessionStore {
|
|
6
|
+
private readonly paths;
|
|
7
|
+
constructor(paths: PlatformPaths);
|
|
8
|
+
create(input: Omit<SessionMetadata, 'id' | 'createdAt' | 'updatedAt'>): Promise<SessionMetadata>;
|
|
9
|
+
get(sessionId: string): Promise<SessionMetadata | undefined>;
|
|
10
|
+
list(projectFingerprint?: string): Promise<readonly SessionMetadata[]>;
|
|
11
|
+
updateStatus(sessionId: string, status: SessionMetadata['status']): Promise<SessionMetadata>;
|
|
12
|
+
rename(sessionId: string, name: string): Promise<SessionMetadata>;
|
|
13
|
+
appendEvent(event: SessionEvent, options?: {
|
|
14
|
+
locked?: boolean;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
appendTranscript(sessionId: string, entry: TranscriptEntry): Promise<void>;
|
|
17
|
+
appendJournal(sessionId: string, records: readonly SessionJournalAppend[]): Promise<void>;
|
|
18
|
+
readEvents(sessionId: string): Promise<readonly SessionEvent[]>;
|
|
19
|
+
readTranscript(sessionId: string): Promise<readonly TranscriptEntry[]>;
|
|
20
|
+
readHistory(sessionId: string): Promise<SessionHistory>;
|
|
21
|
+
delete(sessionId: string): Promise<boolean>;
|
|
22
|
+
fork(sessionId: string, overrides?: Partial<Pick<SessionMetadata, 'model' | 'profile'>>): Promise<SessionMetadata>;
|
|
23
|
+
compact(sessionId: string, summary: string, options?: {
|
|
24
|
+
turnId?: string;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export(sessionId: string): Promise<SessionBundle>;
|
|
27
|
+
import(bundle: SessionBundle, projectFingerprint: string, cwd: string): Promise<SessionMetadata>;
|
|
28
|
+
saveAttachment(sessionId: string, attachment: Attachment, bytes: Uint8Array): Promise<Attachment>;
|
|
29
|
+
private persistAttachment;
|
|
30
|
+
readAttachment(sessionId: string, attachmentId: string): Promise<Uint8Array | undefined>;
|
|
31
|
+
recoverStaleLock(sessionId: string): Promise<boolean>;
|
|
32
|
+
repair(sessionId: string): Promise<SessionRepairResult>;
|
|
33
|
+
withLock<T>(sessionId: string, action: () => Promise<T>): Promise<T>;
|
|
34
|
+
private require;
|
|
35
|
+
private requirePaths;
|
|
36
|
+
private locate;
|
|
37
|
+
private locateByScan;
|
|
38
|
+
private projectKeys;
|
|
39
|
+
private readOrRebuildIndex;
|
|
40
|
+
private indexMatchesJournals;
|
|
41
|
+
private projectJournalIds;
|
|
42
|
+
private rebuildProjectIndex;
|
|
43
|
+
private readSnapshot;
|
|
44
|
+
private appendJournalLocked;
|
|
45
|
+
private readAttachmentMetadata;
|
|
46
|
+
private corrupt;
|
|
47
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import R from"node:crypto";import o from"node:fs/promises";import m from"node:path";import{CliError as h}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as d}from"../../domain/errors/error-codes.js";import{isRecord as F,isSessionEvent as _,isSessionMetadata as q,isTranscriptEntry as z}from"../../domain/session/session-schema.js";import{isGoalEventType as C,isPersistedGoalEventData as J}from"../../domain/orchestration/goal.js";import{isAlreadyExists as $,isFileNotFound as p}from"../filesystem/fs-errors.js";import{acquireAdvisoryFileLock as G,atomicWriteFile as x,isAdvisoryLockContention as U,releaseAdvisoryFileLock as K}from"../filesystem/atomic-file-store.js";import{isSafeProjectKey as O,resolveProjectSessionPaths as H,resolveProjectSessionPathsForKey as j}from"./project-session-paths.js";import{appendJournalRecord as y,appendJournalRecords as V,eventRecord as L,journalEvents as E,journalTranscript as P,latestMetadata as D,metadataRecord as T,readJournal as w,repairJournal as W,transcriptRecord as B}from"./session-journal.js";import{indexProjectSession as g,readProjectSessionIndex as Z,readSessionLocator as Q,removeIndexedSession as X}from"./session-index.js";import{RESOURCE_LIMITS as l}from"../../domain/runtime/resource-limits.js";import{readJsonFileBounded as I}from"../filesystem/bounded-json-reader.js";const b=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,v=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Y=300*1e3;class vt{paths;constructor(t){this.paths=t}async create(t){const a=new Date().toISOString(),e={...t,id:R.randomUUID(),createdAt:a,updatedAt:a},r=H(this.paths,e.cwd,e.id);return await o.mkdir(r.attachmentsDirectory,{recursive:!0}),await y(r.journalFile,T(e)),await g(this.paths,e,r.projectKey),e}async get(t){const a=await this.locate(t);if(a!==void 0)try{const e=D(await w(a.journalFile));if(e===void 0)throw new Error("Session metadata is missing.");return e}catch(e){throw this.corrupt(t,e)}}async list(t){const a=[];for(const e of await this.projectKeys()){const r=j(this.paths,e,"00000000-0000-4000-8000-000000000000"),n=await this.readOrRebuildIndex(r.projectIndexFile,e);for(const i of Object.values(n))(t===void 0||i.projectFingerprint===t)&&a.push(i)}return a.sort((e,r)=>r.updatedAt.localeCompare(e.updatedAt))}async updateStatus(t,a){return this.withLock(t,async()=>{const r={...await this.require(t),status:a,updatedAt:new Date().toISOString()},n=await this.requirePaths(t);return await y(n.journalFile,T(r)),await g(this.paths,r,n.projectKey),r})}async rename(t,a){const e=a.trim().replace(/\s+/gu," ");if(e.length===0||e.length>120||/[\r\n]/u.test(e)||e.includes("\0"))throw new h(d.INVALID_ARGUMENT,"Session name is invalid.",{category:"session",userMessage:"Session name must be between 1 and 120 printable characters."});return this.withLock(t,async()=>{const n={...await this.require(t),name:e,updatedAt:new Date().toISOString()},i=await this.requirePaths(t);return await y(i.journalFile,T(n)),await g(this.paths,n,i.projectKey),n})}async appendEvent(t,a={}){const e=[{kind:"event",event:t}];a.locked===!0?await this.appendJournalLocked(t.sessionId,e):await this.appendJournal(t.sessionId,e)}async appendTranscript(t,a){await this.appendJournal(t,[{kind:"transcript",entry:a}])}async appendJournal(t,a){a.length!==0&&await this.withLock(t,()=>this.appendJournalLocked(t,a))}async readEvents(t){const a=await this.requirePaths(t);return await this.require(t),E(await w(a.journalFile))}async readTranscript(t){const a=await this.requirePaths(t);return await this.require(t),P(await w(a.journalFile))}async readHistory(t){return this.withLock(t,async()=>{const a=await this.requirePaths(t);await this.require(t);const e=await w(a.journalFile);return{events:E(e),transcript:P(e)}})}async delete(t){const a=await this.get(t);return a===void 0?!1:(await this.withLock(t,async()=>{const e=await this.requirePaths(t);await o.rm(e.journalFile,{force:!0}),await o.rm(e.sessionDirectory,{recursive:!0,force:!0}),await X(this.paths,a,e.projectKey)}),!0)}async fork(t,a={}){const e=await this.readSnapshot(t),r=e.metadata,n=await this.create({projectFingerprint:r.projectFingerprint,cwd:r.cwd,model:a.model??r.model,profile:a.profile??r.profile,status:"active"});try{return await this.withLock(n.id,async()=>{const i=await this.requirePaths(n.id);for(const c of e.events){const f=tt(c.data);await y(i.journalFile,L({...c,sessionId:n.id,...f===void 0?{}:{data:f}}))}for(const c of e.transcript)await y(i.journalFile,B(c));for(const[c,f]of e.attachments)f.attachment!==void 0&&await this.persistAttachment(n.id,{...f.attachment,id:c},f.bytes)}),n}catch(i){try{await this.delete(n.id)}catch(c){throw new AggregateError([i,c],"Session fork failed and cleanup was incomplete.")}throw i}}async compact(t,a,e={}){const r=a.trim();if(r.length===0)throw new h(d.SESSION_CORRUPTED,"Compaction summary cannot be empty.",{category:"session",userMessage:"Compaction summary cannot be empty."});const n=new Date().toISOString();await this.appendJournal(t,[{kind:"transcript",entry:{type:"system",timestamp:n,content:`[Compacted context]
|
|
2
|
+
${r}`,...e.turnId===void 0?{}:{turnId:e.turnId}}},{kind:"event",event:{type:"context.compacted",timestamp:n,sessionId:t,...e.turnId===void 0?{}:{turnId:e.turnId},data:{summary:r}}}])}async export(t){const a=await this.readSnapshot(t),e=[];for(const r of a.transcript)for(const n of r.attachmentIds??[]){if(e.some(f=>f.attachment.id===n))continue;const i=a.attachments.get(n);if(i===void 0)continue;const c=i.attachment??{id:n,name:n,mimeType:"application/octet-stream",sizeBytes:i.bytes.byteLength,source:"file"};e.push({attachment:c,dataBase64:Buffer.from(i.bytes).toString("base64")})}return{metadata:a.metadata,events:a.events,transcript:a.transcript,attachments:e}}async import(t,a,e){rt(t);const r=await this.create({projectFingerprint:a,cwd:e,model:t.metadata.model,profile:t.metadata.profile,status:"active"});try{for(const n of t.events){const i=et(n.data);await this.appendEvent({...n,sessionId:r.id,...i===void 0?{}:{data:i}})}for(const n of t.transcript)await this.appendTranscript(r.id,n);for(const n of t.attachments)await this.saveAttachment(r.id,n.attachment,Buffer.from(n.dataBase64,"base64"));return r}catch(n){try{await this.delete(r.id)}catch(i){throw new AggregateError([n,i],"Session import failed and cleanup was incomplete.")}throw n}}async saveAttachment(t,a,e){if(!v.test(a.id))throw new h(d.ATTACHMENT_INVALID_IMAGE,"Attachment id is invalid.",{category:"attachment",userMessage:"Attachment name is invalid."});if(a.sizeBytes<0||a.sizeBytes>l.maxAttachmentBytes)throw new h(d.ATTACHMENT_TOO_LARGE,"Attachment exceeds the allowed size.",{category:"attachment",userMessage:"Attachment exceeds the allowed size."});if(e.byteLength!==a.sizeBytes)throw new h(d.ATTACHMENT_INVALID_IMAGE,"Attachment size does not match metadata.",{category:"attachment",userMessage:"Attachment size does not match its metadata."});return this.withLock(t,()=>this.persistAttachment(t,a,e))}async persistAttachment(t,a,e){const r=await this.requirePaths(t);await this.require(t),await o.mkdir(r.attachmentsDirectory,{recursive:!0});const n=m.join(r.attachmentsDirectory,`${a.id}.bin`);return await o.writeFile(n,e,{flag:"wx",mode:384}).catch(async i=>{if(!$(i))throw i;await o.writeFile(n,e,{mode:384})}),await x(m.join(r.attachmentsDirectory,`${a.id}.json`),`${JSON.stringify(a,null,2)}
|
|
3
|
+
`),{...a,storagePath:m.posix.join("attachments",`${a.id}.bin`)}}async readAttachment(t,a){const e=await this.requirePaths(t);if(await this.require(t),!v.test(a))return;const r=m.join(e.attachmentsDirectory,`${a}.bin`);try{if((await o.stat(r)).size>l.maxAttachmentBytes)throw new h(d.ATTACHMENT_TOO_LARGE,"Stored attachment exceeds the allowed size.",{category:"attachment",userMessage:"Stored attachment exceeds the allowed size."});return await o.readFile(r)}catch(n){if(p(n))return;throw n}}async recoverStaleLock(t){const a=await this.locate(t);if(a===void 0)return!1;let e;try{e=await o.stat(a.lockFile)}catch(n){if(p(n))return!1;throw n}if(Date.now()-e.mtimeMs<Y)return!1;let r={};try{r=await I(a.lockFile,4*1024)}catch{}return typeof r.pid=="number"&&at(r.pid)?!1:(await o.rm(a.lockFile,{force:!0}),!0)}async repair(t){const a=await this.requirePaths(t);return{eventsRemoved:await this.withLock(t,()=>W(a.journalFile)),transcriptRemoved:0}}async withLock(t,a){const e=await this.requirePaths(t);await o.mkdir(e.sessionDirectory,{recursive:!0});let r;try{r=await G(e.lockFile)}catch(n){const i=await U(n,e.lockFile);if(i&&await this.recoverStaleLock(t))return this.withLock(t,a);throw i?new h(d.SESSION_LOCKED,`Session is locked: ${t}`,{category:"session",userMessage:"The session is being used by another process. Try again later.",retryable:!0}):n}try{return await a()}finally{await K(r,e.lockFile)}}async require(t){const a=await this.get(t);if(a===void 0)throw new h(d.SESSION_NOT_FOUND,`Session not found: ${t}`,{category:"session",userMessage:`Session not found: ${t}.`});return a}async requirePaths(t){const a=await this.locate(t);if(a===void 0)throw new h(d.SESSION_NOT_FOUND,`Session not found: ${t}`,{category:"session",userMessage:`Session not found: ${t}.`});return a}async locate(t){if(!b.test(t))return;const e=(await Q(this.paths)).sessions[t];if(typeof e=="string"&&O(e)){const r=j(this.paths,e,t);if(await N(r.journalFile))return r}return this.locateByScan(t)}async locateByScan(t){for(const a of await this.projectKeys()){const e=j(this.paths,a,t);if(await N(e.journalFile))return e}}async projectKeys(){try{return(await o.readdir(this.paths.projectsDir,{withFileTypes:!0})).filter(t=>t.isDirectory()&&O(t.name)).map(t=>t.name)}catch(t){if(p(t))return[];throw t}}async readOrRebuildIndex(t,a){try{const e=(await Z(t,a)).sessions;return await this.indexMatchesJournals(a,e)?e:this.rebuildProjectIndex(a)}catch{return this.rebuildProjectIndex(a)}}async indexMatchesJournals(t,a){const e=await this.projectJournalIds(t),r=Object.keys(a);return e.length===r.length&&e.every(n=>a[n]!==void 0)}async projectJournalIds(t){const a=m.join(this.paths.projectsDir,t);try{return(await o.readdir(a,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(".jsonl")).map(e=>e.name.slice(0,-6)).filter(e=>b.test(e))}catch(e){if(p(e))return[];throw e}}async rebuildProjectIndex(t){const a={},e=m.join(this.paths.projectsDir,t);for(const n of await o.readdir(e,{withFileTypes:!0}))if(!(!n.isFile()||!n.name.endsWith(".jsonl")))try{const i=D(await w(m.join(e,n.name)));i!==void 0&&(a[i.id]=i)}catch{}const r=m.join(e,"index.json");await o.mkdir(e,{recursive:!0}),await x(r,`${JSON.stringify({projectKey:t,sessions:a},null,2)}
|
|
4
|
+
`);for(const n of Object.values(a))await g(this.paths,n,t);return a}async readSnapshot(t){return this.withLock(t,async()=>{const a=await this.require(t),e=await this.requirePaths(t),r=await w(e.journalFile),n=E(r),i=P(r),c=new Map;for(const f of i)for(const S of f.attachmentIds??[]){if(c.has(S))continue;const k=await this.readAttachment(t,S);k!==void 0&&c.set(S,{bytes:k,attachment:await this.readAttachmentMetadata(e,S)})}return{metadata:a,events:n,transcript:i,attachments:c}})}async appendJournalLocked(t,a){const e=await this.requirePaths(t);await this.require(t);const r=a.map(n=>{if(n.kind==="event"&&n.event.sessionId!==t)throw new h(d.SESSION_CORRUPTED,"Cannot append an event to a different session.",{category:"session",userMessage:"Session event data is invalid."});return n.kind==="event"?L(n.event):B(n.entry)});await V(e.journalFile,r)}async readAttachmentMetadata(t,a){try{return st(await I(m.join(t.attachmentsDirectory,`${a}.json`),l.configFileBytes))}catch(e){if(p(e))return;throw e}}corrupt(t,a){return new h(d.SESSION_CORRUPTED,`Session metadata is corrupted: ${t}`,{category:"session",userMessage:"Session is corrupted and its metadata cannot be read.",cause:a})}}function tt(s){return M(s)}function et(s){return M(s)}function M(s){if(s===void 0||typeof s.goal!="object"||s.goal===null)return s;const t=s.goal;return t.status!=="active"?s:{...s,goal:{...t,status:"paused",updatedAt:new Date().toISOString()},reason:"Explicit resume is required after fork or import."}}async function N(s){try{return await o.access(s),!0}catch(t){if(p(t))return!1;throw t}}function at(s){if(s===process.pid)return!0;try{return process.kill(s,0),!0}catch{return!1}}function rt(s){if(!q(s.metadata)||!Array.isArray(s.events)||!Array.isArray(s.transcript)||!Array.isArray(s.attachments))throw u("Session export file is invalid.");if(s.events.length>l.sessionEvents||s.transcript.length>l.sessionTranscriptEntries||s.attachments.length>l.sessionAttachments)throw u("Session export exceeds the supported entry limits.");for(const e of s.events){if(!_(e))throw u("Session export contains an invalid event.");if(C(e.type)&&!J(e.data))throw u("Session export contains an invalid goal event.");if(A(e.type)>256||A(e.timestamp)>128||A(e.sessionId)>128)throw u("Session event metadata is too large.")}const t=new Set;let a=0;for(const e of s.transcript){if(!z(e)||A(e.content)>l.sessionTextBytes)throw u("Session export contains an invalid transcript entry.");if(e.attachmentIds!==void 0&&(!Array.isArray(e.attachmentIds)||e.attachmentIds.some(r=>typeof r!="string"||!v.test(r))))throw u("Session transcript contains invalid attachment references.")}for(const e of s.attachments){if(!nt(e))throw u("Session export contains an invalid attachment.");const r=e.attachment;if(typeof r.id!="string"||!v.test(r.id)||t.has(r.id)||typeof r.name!="string"||typeof r.mimeType!="string"||typeof r.sizeBytes!="number"||!Number.isSafeInteger(r.sizeBytes)||r.sizeBytes<0||r.sizeBytes>l.maxAttachmentBytes||r.source!=="clipboard"&&r.source!=="file")throw u("Session export contains invalid attachment metadata.");const n=Buffer.from(e.dataBase64,"base64");if(n.toString("base64")!==e.dataBase64||n.byteLength!==r.sizeBytes)throw u("Session export contains an invalid attachment payload.");if(a+=n.byteLength,a>l.sessionAttachmentTotalBytes)throw u("Session export exceeds the total attachment limit.");t.add(r.id)}}function nt(s){if(!F(s)||!F(s.attachment)||typeof s.dataBase64!="string")return!1;const t=s.attachment;return typeof t.id=="string"&&typeof t.name=="string"&&typeof t.mimeType=="string"&&typeof t.sizeBytes=="number"&&Number.isSafeInteger(t.sizeBytes)&&(t.source==="clipboard"||t.source==="file")}function A(s){return Buffer.byteLength(s,"utf8")}function u(s){return new h(d.SESSION_CORRUPTED,s,{category:"session",userMessage:s})}function st(s){if(typeof s!="object"||s===null)throw new Error("Invalid attachment metadata.");const t=s;if(typeof t.id!="string"||typeof t.name!="string"||typeof t.mimeType!="string"||typeof t.sizeBytes!="number"||t.source!=="clipboard"&&t.source!=="file")throw new Error("Invalid attachment metadata.");return s}export{vt as FileSessionStore};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlatformPaths } from '../platform/platform-paths.js';
|
|
2
|
+
import { type HostPlatformContext } from '../platform/host-platform.js';
|
|
3
|
+
export interface ProjectSessionPaths {
|
|
4
|
+
projectKey: string;
|
|
5
|
+
projectDirectory: string;
|
|
6
|
+
projectIndexFile: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
journalFile: string;
|
|
9
|
+
sessionDirectory: string;
|
|
10
|
+
attachmentsDirectory: string;
|
|
11
|
+
subagentsDirectory: string;
|
|
12
|
+
lockFile: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function isSafeProjectKey(value: string): boolean;
|
|
15
|
+
export declare function createProjectKey(cwd: string, platform?: HostPlatformContext): string;
|
|
16
|
+
export declare function resolveProjectSessionPaths(paths: PlatformPaths, cwd: string, sessionId: string): ProjectSessionPaths;
|
|
17
|
+
export declare function resolveProjectSessionPathsForKey(paths: PlatformPaths, projectKey: string, sessionId: string): ProjectSessionPaths;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"node:crypto";import r from"node:path";import{detectHostPlatform as i}from"../platform/host-platform.js";function a(o){return/^[A-Za-z0-9._-]+--[0-9a-f]{12}$/u.test(o)}function l(o,n=i()){const e=r.resolve(o),t=n.isWindows?e.toLowerCase():e,c=s.createHash("sha256").update(t,"utf8").digest("hex").slice(0,12);return`${e.replaceAll("\\","-").replaceAll("/","-").replaceAll(":","-").replace(/[^A-Za-z0-9._-]+/gu,"-").replace(/-+/gu,"-").replace(/^-|-$/gu,"").slice(0,120)||"project"}--${c}`}function h(o,n,e){const t=l(n,o.platform);return p(o,t,e)}function p(o,n,e){if(!a(n))throw new Error("Invalid project session key.");const t=r.join(o.projectsDir,n),c=r.join(t,e);return{projectKey:n,projectDirectory:t,projectIndexFile:r.join(t,"index.json"),sessionId:e,journalFile:r.join(t,`${e}.jsonl`),sessionDirectory:c,attachmentsDirectory:r.join(c,"attachments"),subagentsDirectory:r.join(c,"subagents"),lockFile:r.join(c,"lock")}}export{l as createProjectKey,a as isSafeProjectKey,h as resolveProjectSessionPaths,p as resolveProjectSessionPathsForKey};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionMetadata } from '../../domain/session/session.js';
|
|
2
|
+
import type { PlatformPaths } from '../platform/platform-paths.js';
|
|
3
|
+
interface ProjectSessionIndex {
|
|
4
|
+
projectKey: string;
|
|
5
|
+
sessions: Record<string, SessionMetadata>;
|
|
6
|
+
}
|
|
7
|
+
interface SessionLocatorIndex {
|
|
8
|
+
sessions: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare function readProjectSessionIndex(filePath: string, projectKey: string): Promise<ProjectSessionIndex>;
|
|
11
|
+
export declare function writeProjectSessionIndex(filePath: string, projectKey: string, sessions: Readonly<Record<string, SessionMetadata>>): Promise<void>;
|
|
12
|
+
export declare function readSessionLocator(paths: PlatformPaths): Promise<SessionLocatorIndex>;
|
|
13
|
+
export declare function writeSessionLocator(paths: PlatformPaths, sessions: Readonly<Record<string, string>>): Promise<void>;
|
|
14
|
+
export declare function indexProjectSession(paths: PlatformPaths, metadata: SessionMetadata, projectKey: string): Promise<void>;
|
|
15
|
+
export declare function removeIndexedSession(paths: PlatformPaths, metadata: SessionMetadata, projectKey: string): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import c from"node:path";import{atomicWriteFile as f,withFileLock as a}from"../filesystem/atomic-file-store.js";import{isFileNotFound as l}from"../filesystem/fs-errors.js";import{resolveProjectSessionPathsForKey as p}from"./project-session-paths.js";import{readJsonFileBounded as j}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as w}from"../../domain/runtime/resource-limits.js";async function x(o,s){try{return m(await j(o,w.configFileBytes),s)}catch(t){if(l(t))return{projectKey:s,sessions:{}};throw t}}async function y(o,s,t){await f(o,`${JSON.stringify({projectKey:s,sessions:t},null,2)}
|
|
2
|
+
`)}async function I(o){const s=c.join(o.projectsDir,"locator.json");try{return g(await j(s,w.configFileBytes))}catch(t){if(l(t))return{sessions:{}};throw t}}function m(o,s){if(!e(o)||o.projectKey!==s||!e(o.sessions))throw new Error("Invalid project session index.");for(const t of Object.values(o.sessions))if(!u(t))throw new Error("Invalid project session metadata.");return{projectKey:s,sessions:o.sessions}}function g(o){if(!e(o)||!e(o.sessions)||Object.values(o.sessions).some(s=>typeof s!="string"))throw new Error("Invalid session locator index.");return{sessions:o.sessions}}function u(o){return e(o)?typeof o.id=="string"&&typeof o.projectFingerprint=="string"&&typeof o.cwd=="string"&&(typeof o.model=="string"||o.model===null)&&(typeof o.profile=="string"||o.profile===null)&&(o.status==="active"||o.status==="completed"||o.status==="failed"||o.status==="cancelled")&&typeof o.createdAt=="string"&&typeof o.updatedAt=="string":!1}function e(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}async function F(o,s){await f(c.join(o.projectsDir,"locator.json"),`${JSON.stringify({sessions:s},null,2)}
|
|
3
|
+
`)}async function A(o,s,t){const n=p(o,t,s.id);await a(n.projectIndexFile,async()=>{const i=await x(n.projectIndexFile,t);await y(n.projectIndexFile,t,{...i.sessions,[s.id]:s})});const d=c.join(o.projectsDir,"locator.json");await a(d,async()=>{const i=await I(o);await F(o,{...i.sessions,[s.id]:t})})}async function D(o,s,t){const n=p(o,t,s.id);await a(n.projectIndexFile,async()=>{const r={...(await x(n.projectIndexFile,t)).sessions};delete r[s.id],await y(n.projectIndexFile,t,r)});const d=c.join(o.projectsDir,"locator.json");await a(d,async()=>{const r={...(await I(o)).sessions};delete r[s.id],await F(o,r)})}export{A as indexProjectSession,x as readProjectSessionIndex,I as readSessionLocator,D as removeIndexedSession,y as writeProjectSessionIndex,F as writeSessionLocator};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SessionEvent, SessionMetadata, TranscriptEntry } from '../../domain/session/session.js';
|
|
2
|
+
export type SessionJournalRecord = {
|
|
3
|
+
recordType: 'metadata';
|
|
4
|
+
metadata: SessionMetadata;
|
|
5
|
+
} | {
|
|
6
|
+
recordType: 'event';
|
|
7
|
+
event: SessionEvent;
|
|
8
|
+
} | {
|
|
9
|
+
recordType: 'transcript';
|
|
10
|
+
entry: TranscriptEntry;
|
|
11
|
+
};
|
|
12
|
+
export declare function metadataRecord(metadata: SessionMetadata): SessionJournalRecord;
|
|
13
|
+
export declare function eventRecord(event: SessionEvent): SessionJournalRecord;
|
|
14
|
+
export declare function transcriptRecord(entry: TranscriptEntry): SessionJournalRecord;
|
|
15
|
+
export declare function appendJournalRecord(filePath: string, record: SessionJournalRecord): Promise<void>;
|
|
16
|
+
/** Appends one crash-consistent physical JSONL record for an ordered logical batch. */
|
|
17
|
+
export declare function appendJournalRecords(filePath: string, records: readonly SessionJournalRecord[]): Promise<void>;
|
|
18
|
+
export declare function readJournal(filePath: string): Promise<readonly SessionJournalRecord[]>;
|
|
19
|
+
export declare function latestMetadata(records: readonly SessionJournalRecord[]): SessionMetadata | undefined;
|
|
20
|
+
export declare function journalEvents(records: readonly SessionJournalRecord[]): readonly SessionEvent[];
|
|
21
|
+
export declare function journalTranscript(records: readonly SessionJournalRecord[]): readonly TranscriptEntry[];
|
|
22
|
+
export declare function repairJournal(filePath: string): Promise<number>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import a from"node:fs/promises";import T from"node:path";import{isFileNotFound as s}from"../filesystem/fs-errors.js";import{atomicWriteFile as g}from"../filesystem/atomic-file-store.js";import{isRecord as u,isSessionEvent as x,isSessionMetadata as J,isTranscriptEntry as v}from"../../domain/session/session-schema.js";import{RESOURCE_LIMITS as p}from"../../domain/runtime/resource-limits.js";function L(e){return{recordType:"metadata",metadata:e}}function M(e){return{recordType:"event",event:e}}function N(e){return{recordType:"transcript",entry:e}}async function O(e,r){await f(e,r)}async function A(e,r){r.length!==0&&await f(e,r.length===1?r[0]:{recordType:"batch",records:r})}async function f(e,r){await a.mkdir(T.dirname(e),{recursive:!0});const t=`${JSON.stringify(r)}
|
|
2
|
+
`;await E(e,Buffer.byteLength(t,"utf8")),await a.appendFile(e,t,{encoding:"utf8",mode:384})}async function U(e){let r;try{await z(e),r=await a.readFile(e,"utf8")}catch(t){if(s(t))return[];throw t}try{return l(r)}catch(t){if(!R(r))throw t;return await new Promise(o=>setImmediate(o)),l(await a.readFile(e,"utf8"))}}function l(e){return e.split(/\r?\n/u).filter(Boolean).flatMap(r=>m(JSON.parse(r)))}function R(e){const r=e.replace(/\r\n/gu,`
|
|
3
|
+
`);return r.length>0&&!r.endsWith(`
|
|
4
|
+
`)}async function z(e){if((await a.stat(e)).size>p.sessionJournalBytes)throw new Error("Session journal exceeds the supported size limit. Repair or export the session before resuming it.")}async function E(e,r){let t=0;try{t=(await a.stat(e)).size}catch(o){if(!s(o))throw o}if(t+r>p.sessionJournalBytes)throw new Error("Session journal exceeds the supported size limit. Compact or export the session before adding more data.")}function W(e){return e.filter(r=>r.recordType==="metadata").at(-1)?.metadata}function $(e){return e.filter(r=>r.recordType==="event").map(r=>r.event)}function k(e){return e.filter(r=>r.recordType==="transcript").map(r=>r.entry)}async function _(e){const r=await a.stat(e).catch(n=>{if(!s(n))throw n});if(r===void 0)return 0;if(r.size>p.sessionJournalBytes)throw new Error("Session journal exceeds the supported size limit. Repair cannot process an oversized journal.");let t;try{t=await a.readFile(e,"utf8")}catch(n){if(s(n))return 0;throw n}const o=t.split(/\r?\n/u),c=[];let d=0;for(let n=0;n<o.length;n+=1){const i=o[n]?.trim();if(!(i===void 0||i.length===0))try{m(JSON.parse(i)),c.push(i)}catch(w){if(!o.slice(n+1).every(h=>h.trim().length===0))throw w;d+=1}}return d>0&&await g(e,c.length===0?"":`${c.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`),d}function m(e){if(u(e)&&e.recordType==="batch"){const r=e.records;if(!Array.isArray(r)||r.length===0)throw new Error("Invalid session journal batch.");return r.map(y)}return[y(e)]}function y(e){if(!u(e))throw new Error("Invalid session journal record.");const r=e;if(r.recordType==="metadata"&&J(r.metadata))return{recordType:"metadata",metadata:r.metadata};if(r.recordType==="event"&&x(r.event))return{recordType:"event",event:r.event};if(r.recordType==="transcript"&&v(r.entry))return{recordType:"transcript",entry:r.entry};throw new Error("Unsupported or malformed session journal record.")}export{O as appendJournalRecord,A as appendJournalRecords,M as eventRecord,$ as journalEvents,k as journalTranscript,W as latestMetadata,L as metadataRecord,U as readJournal,_ as repairJournal,N as transcriptRecord};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PlatformPaths } from '../platform/platform-paths.js';
|
|
2
|
+
import type { SubagentResult } from '../../domain/orchestration/subagent.js';
|
|
3
|
+
export type SubagentJournalRecord = {
|
|
4
|
+
recordType: 'created';
|
|
5
|
+
id: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
task: string;
|
|
8
|
+
mode: 'research' | 'worker';
|
|
9
|
+
model: string;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
} | {
|
|
12
|
+
recordType: 'started';
|
|
13
|
+
id: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
mode: 'research' | 'worker';
|
|
16
|
+
model: string;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
} | {
|
|
19
|
+
recordType: 'completed' | 'completed_with_warning' | 'failed' | 'cancelled';
|
|
20
|
+
result: SubagentResult;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
};
|
|
23
|
+
/** Persists bounded child-agent lifecycle records beside the parent session. */
|
|
24
|
+
export declare class SubagentJournalStore {
|
|
25
|
+
private readonly paths;
|
|
26
|
+
constructor(paths: PlatformPaths);
|
|
27
|
+
append(parentSessionId: string, cwd: string, record: SubagentJournalRecord): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import s from"node:fs/promises";import a from"node:path";import{resolveProjectSessionPaths as u}from"./project-session-paths.js";class m{paths;constructor(e){this.paths=e}async append(e,r,o){c(e);const n=u(this.paths,r,e),i=a.join(n.subagentsDirectory,`${f(o)}.jsonl`);await s.mkdir(n.subagentsDirectory,{recursive:!0,mode:448}),await d(i,o)}}function c(t){if(!/^[A-Za-z0-9._-]{1,128}$/u.test(t))throw new Error("Invalid parent session id for subagent journal.")}async function d(t,e){const r=`${JSON.stringify(e)}
|
|
2
|
+
`;if(Buffer.byteLength(r,"utf8")>32*1024)throw new Error("Subagent journal record exceeds the configured limit.");await s.appendFile(t,r,{encoding:"utf8",mode:384})}function f(t){return t.recordType==="created"||t.recordType==="started"?t.id:t.result.id}export{m as SubagentJournalStore};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@lotagate/sdk';
|
|
2
|
+
import type { ToolExecutionContext, ToolExecutor, ToolInfo, ToolResult } from '@lotagate/agent-sdk';
|
|
3
|
+
import type { ToolActivityObserver } from '../../ports/tool-activity.js';
|
|
4
|
+
import { type HostPlatformContext } from '../platform/host-platform.js';
|
|
5
|
+
/** Exposes the same shell capability definitions to runtime and context accounting. */
|
|
6
|
+
export declare function shellToolDefinitions(): readonly ToolDefinition[];
|
|
7
|
+
export declare class ShellToolExecutor implements ToolExecutor {
|
|
8
|
+
private readonly options;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
onActivity?: ToolActivityObserver;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
platform?: HostPlatformContext;
|
|
13
|
+
});
|
|
14
|
+
listTools(): readonly ToolDefinition[];
|
|
15
|
+
getToolInfo(toolName: string): ToolInfo | undefined;
|
|
16
|
+
execute(toolName: string, input: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{resolveReadOnlyExecutable as g,readOnlyArguments as y}from"../platform/read-only-executable.js";import{resolveWorkspacePath as u}from"../filesystem/path-resolver.js";import{isReadOnlyShellRequest as w}from"../../application/security/tool-risk-classifier.js";import{detectHostPlatform as x}from"../platform/host-platform.js";import{normalizePowerShellScriptInput as E,execPlatformCommand as b}from"../platform/host-process.js";import{formatShellCommandForDisplay as S}from"../../application/agent/tool-display.js";const P=[{type:"function",function:{name:"shell.exec",description:"Execute one program with structured arguments inside the trusted workspace. Shell interpretation is disabled. On Windows, prefer powershell.exe with script for operating-system work; use direct command and args for node, npm, npx, pnpm, yarn, git, rg, and other project executables. Keep the executable in command and pass arguments separately in args (for example, git status --short means command git and args [status, --short]).",parameters:{type:"object",properties:{command:{type:"string",description:"Executable name or path."},args:{type:"array",items:{type:"string"},description:"Structured process arguments."},script:{type:"string",description:"Optional complete PowerShell script. Use only with powershell.exe or pwsh.exe; passed as one -Command argument."},cwd:{type:"string",description:"Optional workspace-relative working directory."},timeoutMs:{type:"number",description:"Timeout between 100 and 120000 milliseconds."}},required:["command"],additionalProperties:!1}}}],O="Process completed successfully with no output.";function T(){return P}class I{options;constructor(t={}){this.options=t}listTools(){return T()}getToolInfo(t){return t==="shell.exec"?{toolName:t,source:"shell",executorId:"local-shell"}:void 0}async execute(t,a,o){if(t!=="shell.exec")return{content:`Unknown shell tool: ${t}`,isError:!0};if(typeof a.command!="string"||a.command.trim().length===0)return{content:"shell.exec requires a command.",isError:!0};const n=this.options.platform??x();let r;try{r=E(a,n)}catch(s){return{content:s instanceof Error?s.message:"Invalid shell.exec PowerShell script.",isError:!0}}const e=r.args===void 0?[]:r.args;if(!Array.isArray(e)||e.some(s=>typeof s!="string"))return{content:"shell.exec args must be an array of strings.",isError:!0};const i=await w(r.command,e,o,u,r.cwd);if(this.options.readOnly&&!i)return{content:"This subagent is limited to read-only shell commands inside the trusted workspace.",isError:!0};const p=typeof r.timeoutMs=="number"?Math.min(Math.max(r.timeoutMs,100),12e4):3e4,l=await u(r.cwd??".",o),m=i?await g(r.command,o.workspaceRoot??l):void 0;if(i&&m===void 0)return{content:"Read-only executable is no longer available.",isError:!0};const h=S(r.command,e),f=this.options.onActivity?.start({key:`${o.runId}:shell.exec`,toolName:"shell.exec",source:"shell",label:h});return k(m??r.command,i?y(r.command,e):e,l,p,o,n).then(s=>(f?.complete(s.isError===!0),s))}}async function k(c,t,a,o,n,r){try{const e=await b(c,t,r,{cwd:a,timeoutMs:o,maxBufferBytes:n.maxResultBytes,rejectOnNonZero:!1,...n.signal===void 0?{}:{signal:n.signal}}),i=`${e.stdout}${e.stderr}${e.exitCode===0?"":`
|
|
2
|
+
Process exited with code ${String(e.exitCode)}.`}`;return{content:d(i||O),isError:e.exitCode!==0}}catch(e){return{content:d(e instanceof Error?e.message:"Process execution failed."),isError:!0}}}function d(c){return c.replace(/Bearer\s+[^\s]+/gi,"Bearer [REDACTED]").replace(/sk-[A-Za-z0-9_-]{8,}/g,"[REDACTED]")}export{I as ShellToolExecutor,T as shellToolDefinitions};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatUsage } from '../../ports/chat-model.js';
|
|
2
|
+
export interface TokenEstimateInput {
|
|
3
|
+
model: string;
|
|
4
|
+
prompt: string;
|
|
5
|
+
response: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TextTokenEstimateInput {
|
|
8
|
+
model: string;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Estimates turn usage when an upstream provider does not include usage in the
|
|
13
|
+
* streaming protocol. The result is deliberately marked as estimated because
|
|
14
|
+
* providers may use a tokenizer different from the OpenAI tokenizer family.
|
|
15
|
+
*/
|
|
16
|
+
export declare function estimateTurnUsage(input: TokenEstimateInput): ChatUsage | undefined;
|
|
17
|
+
/** Estimates one text payload with the same tokenizer used for turn fallback accounting. */
|
|
18
|
+
export declare function estimateTextTokens(input: TextTokenEstimateInput): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{encoding_for_model as c,get_encoding as s}from"tiktoken";const d="o200k_base";function f(e){try{const t=r(e.model);try{const n=t.encode(e.prompt).length,o=t.encode(e.response).length;return{promptTokens:n,completionTokens:o,totalTokens:n+o,estimated:!0}}finally{t.free()}}catch{return}}function l(e){try{const t=r(e.model);try{return t.encode(e.text).length}finally{t.free()}}catch{return Math.ceil(Buffer.byteLength(e.text,"utf8")/4)}}function r(e){try{return c(e)}catch{return s(d)}}export{l as estimateTextTokens,f as estimateTurnUsage};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type WorkspaceSettings } from '../../domain/workspace/workspace-settings.js';
|
|
2
|
+
export declare class WorkspaceSettingsStore {
|
|
3
|
+
ensureInitialized(cwd: string): Promise<void>;
|
|
4
|
+
load(cwd: string): Promise<WorkspaceSettings>;
|
|
5
|
+
/** Persist a user-approved rule in the ignored local project policy. */
|
|
6
|
+
rememberAllow(cwd: string, rule: string): Promise<void>;
|
|
7
|
+
private readOptional;
|
|
8
|
+
private createIfMissing;
|
|
9
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import o from"node:fs/promises";import p from"node:path";import{DEFAULT_WORKSPACE_SETTINGS as a}from"../../domain/workspace/workspace-settings.js";import{permissionsFromSettings as f,validateSettingsDocument as g}from"../../domain/settings/settings-document.js";import{resolveProjectConfigPaths as l}from"../platform/platform-paths.js";import{atomicWriteFile as d,withFileLock as u}from"../filesystem/atomic-file-store.js";import{isAlreadyExists as w,isFileNotFound as h}from"../filesystem/fs-errors.js";import{readJsonFileBounded as y}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as S}from"../../domain/runtime/resource-limits.js";class A{async ensureInitialized(t){const i=l(t);await o.mkdir(i.directory,{recursive:!0}),await Promise.all([i.skillsDir,i.pluginsDir,i.hooksDir].map(s=>o.mkdir(s,{recursive:!0}))),await this.createIfMissing(i.settings,a),await this.createIfMissing(i.localSettings,a),await this.createIfMissing(p.join(i.directory,".gitignore"),`settings.local.json
|
|
2
|
+
`)}async load(t){const i=l(t),[s,r]=await Promise.all([this.readOptional(i.settings),this.readOptional(i.localSettings)]);return{schemaVersion:1,permissions:k(s?.permissions,r?.permissions)}}async rememberAllow(t,i){const s=i.trim();if(s.length===0)return;const r=l(t);await o.mkdir(r.directory,{recursive:!0}),await u(r.localSettings,async()=>{const n=await this.readOptional(r.localSettings)??a;if(n.permissions.allow.includes(s))return;const m={schemaVersion:1,permissions:{...n.permissions,allow:[...n.permissions.allow,s]}};await d(r.localSettings,`${JSON.stringify(m,null,2)}
|
|
3
|
+
`)})}async readOptional(t){try{const i=g(await y(t,S.workspaceSettingsBytes));return{schemaVersion:1,permissions:f(i)}}catch(i){if(h(i))return;throw i}}async createIfMissing(t,i){try{await o.writeFile(t,typeof i=="string"?i:`${JSON.stringify(i,null,2)}
|
|
4
|
+
`,{encoding:"utf8",mode:384,flag:"wx"})}catch(s){if(!w(s))throw s}}}function k(e,t){return{allow:c(e?.allow,t?.allow),ask:c(e?.ask,t?.ask),deny:c(e?.deny,t?.deny)}}function c(...e){return[...new Set(e.flatMap(t=>t??[]))]}export{A as WorkspaceSettingsStore};
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{asCliError as x}from"./domain/errors/cli-error.js";import{createCompositionRoot as g}from"./bootstrap/composition-root.js";import{resolveStartupContext as C}from"./bootstrap/startup-sequence.js";import{parseGlobalCliOptions as y}from"./bootstrap/global-cli-options.js";import{TuiApplication as w}from"./presentation/tui/tui-application.js";import{formatCliErrorMessage as I}from"./application/commands/command-hints.js";import{COMMAND_REGISTRY as O}from"./application/commands/command-runtime.js";import{parseCommandInvocation as E}from"./application/commands/command-parser.js";import{executeApplicationCommand as v,executeInformationalCommand as R}from"./application/commands/application-command-executor.js";import{CLI_VERSION as W}from"./version.js";async function _(o,e={}){const h=e.stdin??process.stdin,n=e.stdout??process.stdout,a=e.stderr??process.stderr;let r;try{const d=y(o),t=T(d.commandTokens);if(t.length===0){r=g({stderr:a});const m=r.logger;m.info("Interactive session started.");const f=await new w(r,C(o).cwd,{output:n}).run();return m.info("Interactive session completed.",{exitCode:f}),f}const i=C(o).cwd,s=E(t,"direct",O),u=R(s,n);if(u!==void 0)return u;const c=g({stderr:a});r=c;const l=c.logger;l.info("CLI command started.",{command:s.action.id,cwd:i});const p=await v(s,{runtime:c,cwd:i,output:n,stdin:h,writableOutput:n,resumeInteractive:async m=>new w(c,i,{output:n,sessionId:m}).run()});return l.info("CLI command completed.",{command:s.action.id,exitCode:p}),p}catch(d){const t=x(d);return r?.logger.error("CLI command failed.",{code:t.code,category:t.category}),S(o)?n.write(`${JSON.stringify({error:t.toJSON()})}
|
|
2
|
+
`):r!==void 0?r.logger.error(I(t,"direct"),{code:t.code,category:t.category}):a.write(`[error] ${I(t,"direct")}
|
|
3
|
+
`),t.exitCode}finally{await r?.shutdown.shutdown()}}function S(o){return o.some(e=>e==="--json"||e.startsWith("--json="))}function T(o){return o.length===1&&(o[0]==="--help"||o[0]==="-h")?["help"]:o.length===1&&o[0]==="--version"?["version"]:o}export{W as CLI_VERSION,_ as main};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CacheWriteOptions {
|
|
2
|
+
ttlMs: number;
|
|
3
|
+
}
|
|
4
|
+
export interface CacheStore {
|
|
5
|
+
get<T>(namespace: string, key: string): Promise<T | undefined>;
|
|
6
|
+
set<T>(namespace: string, key: string, value: T, options: CacheWriteOptions): Promise<void>;
|
|
7
|
+
delete(namespace: string, key: string): Promise<void>;
|
|
8
|
+
clear(namespace?: string): Promise<void>;
|
|
9
|
+
prune(): Promise<void>;
|
|
10
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AttachmentPayload } from '../domain/session/attachment.js';
|
|
2
|
+
export interface ChatModelRequest {
|
|
3
|
+
model: string;
|
|
4
|
+
prompt: string;
|
|
5
|
+
reasoningEffort?: string;
|
|
6
|
+
attachments?: readonly AttachmentPayload[];
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
export interface ChatUsage {
|
|
10
|
+
promptTokens?: number;
|
|
11
|
+
completionTokens?: number;
|
|
12
|
+
totalTokens?: number;
|
|
13
|
+
/** True when the CLI derived usage locally rather than receiving it from the provider. */
|
|
14
|
+
estimated?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type ChatModelEvent = {
|
|
17
|
+
type: 'activity';
|
|
18
|
+
state: 'connecting' | 'thinking' | 'writing' | 'completed';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'delta';
|
|
21
|
+
content: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'usage';
|
|
24
|
+
usage: ChatUsage;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'completed';
|
|
27
|
+
};
|
|
28
|
+
export interface ChatModelPort {
|
|
29
|
+
stream(request: ChatModelRequest): AsyncIterable<ChatModelEvent>;
|
|
30
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AuthProfile, StoredCredential } from '../domain/auth/auth-profile.js';
|
|
2
|
+
export interface CredentialStore {
|
|
3
|
+
list(): Promise<readonly AuthProfile[]>;
|
|
4
|
+
get(profileName: string): Promise<StoredCredential | undefined>;
|
|
5
|
+
set(credential: StoredCredential): Promise<void>;
|
|
6
|
+
delete(profileName: string): Promise<boolean>;
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CreateGoalInput, GoalEvaluation, GoalState, GoalUsageDelta } from '../domain/orchestration/goal.js';
|
|
2
|
+
export interface GoalStore {
|
|
3
|
+
get(sessionId: string): Promise<GoalState | undefined>;
|
|
4
|
+
create(sessionId: string, input: CreateGoalInput): Promise<GoalState>;
|
|
5
|
+
replace(sessionId: string, input: CreateGoalInput): Promise<GoalState>;
|
|
6
|
+
pause(sessionId: string, reason?: string): Promise<GoalState>;
|
|
7
|
+
resume(sessionId: string): Promise<GoalState>;
|
|
8
|
+
recordTurn(sessionId: string): Promise<GoalState>;
|
|
9
|
+
recordUsage(sessionId: string, delta: GoalUsageDelta): Promise<GoalState>;
|
|
10
|
+
recordEvaluation(sessionId: string, evaluation: GoalEvaluation): Promise<GoalState>;
|
|
11
|
+
clear(sessionId: string, reason?: string): Promise<void>;
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
2
|
+
export interface Logger {
|
|
3
|
+
error(message: string, details?: Record<string, unknown>): void;
|
|
4
|
+
warn(message: string, details?: Record<string, unknown>): void;
|
|
5
|
+
info(message: string, details?: Record<string, unknown>): void;
|
|
6
|
+
debug(message: string, details?: Record<string, unknown>): void;
|
|
7
|
+
trace(message: string, details?: Record<string, unknown>): void;
|
|
8
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GeneratedImage, MediaBinary, VideoOperation } from '../domain/media/media-contract.js';
|
|
2
|
+
export interface MediaRequestOptions {
|
|
3
|
+
readonly signal?: AbortSignal | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface ImageGenerationInput {
|
|
6
|
+
readonly model: string;
|
|
7
|
+
readonly prompt: string;
|
|
8
|
+
readonly n?: number | undefined;
|
|
9
|
+
readonly size?: string | undefined;
|
|
10
|
+
readonly quality?: 'low' | 'medium' | 'high' | 'auto' | undefined;
|
|
11
|
+
readonly background?: 'transparent' | 'opaque' | 'auto' | undefined;
|
|
12
|
+
readonly outputFormat?: 'png' | 'jpeg' | 'webp' | undefined;
|
|
13
|
+
readonly outputCompression?: number | undefined;
|
|
14
|
+
readonly moderation?: string | undefined;
|
|
15
|
+
readonly user?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface ImageEditInput extends ImageGenerationInput {
|
|
18
|
+
readonly images: Uint8Array[];
|
|
19
|
+
readonly mask?: Uint8Array | undefined;
|
|
20
|
+
readonly inputFidelity?: 'low' | 'high' | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface SpeechInput {
|
|
23
|
+
readonly model: string;
|
|
24
|
+
readonly input: string;
|
|
25
|
+
readonly voice: string;
|
|
26
|
+
readonly instructions?: string | undefined;
|
|
27
|
+
readonly responseFormat?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm' | undefined;
|
|
28
|
+
readonly speed?: number | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface AudioUploadInput {
|
|
31
|
+
readonly model: string;
|
|
32
|
+
readonly file: Uint8Array;
|
|
33
|
+
readonly filename: string;
|
|
34
|
+
readonly prompt?: string | undefined;
|
|
35
|
+
readonly responseFormat?: string | undefined;
|
|
36
|
+
readonly temperature?: number | undefined;
|
|
37
|
+
readonly language?: string | undefined;
|
|
38
|
+
readonly timestampGranularities?: readonly ('word' | 'segment')[] | undefined;
|
|
39
|
+
readonly include?: readonly string[] | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface MediaGatewayClient {
|
|
42
|
+
generateImage(input: ImageGenerationInput, options?: MediaRequestOptions): Promise<readonly GeneratedImage[]>;
|
|
43
|
+
editImage(input: ImageEditInput, options?: MediaRequestOptions): Promise<readonly GeneratedImage[]>;
|
|
44
|
+
createSpeech(input: SpeechInput, options?: MediaRequestOptions): Promise<MediaBinary>;
|
|
45
|
+
transcribe(input: AudioUploadInput, options?: MediaRequestOptions): Promise<string>;
|
|
46
|
+
translate(input: AudioUploadInput, options?: MediaRequestOptions): Promise<string>;
|
|
47
|
+
createVideo(input: {
|
|
48
|
+
model: string;
|
|
49
|
+
prompt: string;
|
|
50
|
+
parameters?: Record<string, unknown>;
|
|
51
|
+
}, options?: MediaRequestOptions): Promise<VideoOperation>;
|
|
52
|
+
getVideoOperation(id: string, options?: MediaRequestOptions): Promise<VideoOperation>;
|
|
53
|
+
downloadVideo(id: string, options?: MediaRequestOptions): Promise<MediaBinary>;
|
|
54
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MemoryBundle, MemoryDraft, MemoryRecord, MemoryState } from '../domain/memory/memory.js';
|
|
2
|
+
import type { MemoryKind } from '../domain/memory/memory-kinds.js';
|
|
3
|
+
import type { MemorySearchHit, MemorySearchQuery, MemorySemanticHit } from '../domain/memory/memory-search.js';
|
|
4
|
+
export interface MemoryListOptions {
|
|
5
|
+
readonly kind?: MemoryKind;
|
|
6
|
+
readonly state?: MemoryState;
|
|
7
|
+
}
|
|
8
|
+
export interface MemoryStore {
|
|
9
|
+
list(cwd: string, options?: MemoryListOptions): Promise<readonly MemoryRecord[]>;
|
|
10
|
+
search(cwd: string, query: MemorySearchQuery): Promise<readonly MemorySearchHit[]>;
|
|
11
|
+
ensureSemanticIndex(cwd: string, model: string, embed: (texts: readonly string[], signal?: AbortSignal) => Promise<readonly number[][]>, signal?: AbortSignal): Promise<void>;
|
|
12
|
+
semanticSearch(cwd: string, model: string, vector: readonly number[], maximum: number): Promise<readonly MemorySemanticHit[]>;
|
|
13
|
+
get(cwd: string, id: string): Promise<MemoryRecord | undefined>;
|
|
14
|
+
consolidate(cwd: string, draft: MemoryDraft): Promise<{
|
|
15
|
+
record: MemoryRecord;
|
|
16
|
+
action: 'insert' | 'merge' | 'supersede' | 'ignore';
|
|
17
|
+
}>;
|
|
18
|
+
forget(cwd: string, id: string): Promise<boolean>;
|
|
19
|
+
clear(cwd: string): Promise<number>;
|
|
20
|
+
markRetrieved(cwd: string, ids: readonly string[]): Promise<void>;
|
|
21
|
+
export(cwd: string): Promise<MemoryBundle>;
|
|
22
|
+
import(cwd: string, bundle: MemoryBundle): Promise<{
|
|
23
|
+
imported: number;
|
|
24
|
+
skipped: number;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChatCompletionRequest, ChatCompletionResponse, RequestOptions } from '@lotagate/sdk';
|
|
2
|
+
export interface ModelCompletionClient {
|
|
3
|
+
readonly chat: {
|
|
4
|
+
readonly completions: {
|
|
5
|
+
create(request: ChatCompletionRequest, options?: RequestOptions): Promise<ChatCompletionResponse>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChatUsage } from './chat-model.js';
|
|
2
|
+
export interface ModelCallSummary {
|
|
3
|
+
model: string;
|
|
4
|
+
stream: boolean;
|
|
5
|
+
contentLength: number;
|
|
6
|
+
toolCallCount: number;
|
|
7
|
+
toolNames: readonly string[];
|
|
8
|
+
finishReason?: string | null;
|
|
9
|
+
usage?: ChatUsage;
|
|
10
|
+
}
|
|
11
|
+
export interface ModelUsageReport {
|
|
12
|
+
usage: ChatUsage;
|
|
13
|
+
modelCalls?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ModelCallObserver {
|
|
16
|
+
onComplete?: (summary: ModelCallSummary) => void;
|
|
17
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TrustedProject {
|
|
2
|
+
fingerprint: string;
|
|
3
|
+
canonicalPath: string;
|
|
4
|
+
grantedAt: string;
|
|
5
|
+
grantedBy: 'user';
|
|
6
|
+
}
|
|
7
|
+
export interface ProjectTrustStore {
|
|
8
|
+
list(): Promise<readonly TrustedProject[]>;
|
|
9
|
+
get(fingerprint: string): Promise<TrustedProject | undefined>;
|
|
10
|
+
grant(project: TrustedProject): Promise<void>;
|
|
11
|
+
revoke(fingerprint: string): Promise<boolean>;
|
|
12
|
+
}
|
|
File without changes
|