@lotagate/cli 0.1.22 → 0.1.23
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/package.json +7 -7
- package/scripts/install-native.mjs +11 -11
- package/dist/application/agent/agent-history.d.ts +0 -3
- package/dist/application/agent/agent-history.js +0 -81
- package/dist/application/agent/agent-input-context.d.ts +0 -9
- package/dist/application/agent/agent-input-context.js +0 -12
- package/dist/application/agent/agent-limit.d.ts +0 -3
- package/dist/application/agent/agent-limit.js +0 -12
- package/dist/application/agent/agent-run-tracker.d.ts +0 -30
- package/dist/application/agent/agent-run-tracker.js +0 -68
- package/dist/application/agent/agent-session-store.d.ts +0 -19
- package/dist/application/agent/agent-session-store.js +0 -74
- package/dist/application/agent/capability-profile.d.ts +0 -37
- package/dist/application/agent/capability-profile.js +0 -13
- package/dist/application/agent/cli-agent-execution-service.d.ts +0 -81
- package/dist/application/agent/cli-agent-execution-service.js +0 -279
- package/dist/application/agent/context-compaction-persistence.d.ts +0 -8
- package/dist/application/agent/context-compaction-persistence.js +0 -27
- package/dist/application/agent/context-compaction.d.ts +0 -20
- package/dist/application/agent/context-compaction.js +0 -114
- package/dist/application/agent/prompt-data-safety.d.ts +0 -14
- package/dist/application/agent/prompt-data-safety.js +0 -38
- package/dist/application/agent/safe-system-prompt.d.ts +0 -3
- package/dist/application/agent/safe-system-prompt.js +0 -19
- package/dist/application/agent/scoped-tool-executor.d.ts +0 -13
- package/dist/application/agent/scoped-tool-executor.js +0 -32
- package/dist/application/agent/system-prompt-builder.d.ts +0 -14
- package/dist/application/agent/system-prompt-builder.js +0 -199
- package/dist/application/agent/tool-catalog.d.ts +0 -14
- package/dist/application/agent/tool-catalog.js +0 -30
- package/dist/application/agent/tool-display.d.ts +0 -6
- package/dist/application/agent/tool-display.js +0 -59
- package/dist/application/agent/tool-hook-lifecycle.d.ts +0 -19
- package/dist/application/agent/tool-hook-lifecycle.js +0 -85
- package/dist/application/auth/authentication-service.d.ts +0 -20
- package/dist/application/auth/authentication-service.js +0 -44
- package/dist/application/chat/chat-service.d.ts +0 -12
- package/dist/application/chat/chat-service.js +0 -19
- package/dist/application/chat/pending-attachment-store.d.ts +0 -12
- package/dist/application/chat/pending-attachment-store.js +0 -28
- package/dist/application/commands/application-command-executor.d.ts +0 -20
- package/dist/application/commands/application-command-executor.js +0 -66
- package/dist/application/commands/cli-args.d.ts +0 -6
- package/dist/application/commands/cli-args.js +0 -43
- package/dist/application/commands/cli-command-services.d.ts +0 -16
- package/dist/application/commands/cli-command-services.js +0 -405
- package/dist/application/commands/command-catalog.d.ts +0 -6
- package/dist/application/commands/command-catalog.js +0 -159
- package/dist/application/commands/command-contract.d.ts +0 -58
- package/dist/application/commands/command-contract.js +0 -1
- package/dist/application/commands/command-hints.d.ts +0 -9
- package/dist/application/commands/command-hints.js +0 -17
- package/dist/application/commands/command-output.d.ts +0 -4
- package/dist/application/commands/command-output.js +0 -1
- package/dist/application/commands/command-parser.d.ts +0 -10
- package/dist/application/commands/command-parser.js +0 -155
- package/dist/application/commands/command-presentation.d.ts +0 -7
- package/dist/application/commands/command-presentation.js +0 -131
- package/dist/application/commands/command-registry.d.ts +0 -11
- package/dist/application/commands/command-registry.js +0 -64
- package/dist/application/commands/command-runtime.d.ts +0 -2
- package/dist/application/commands/command-runtime.js +0 -3
- package/dist/application/commands/goal-command-handlers.d.ts +0 -3
- package/dist/application/commands/goal-command-handlers.js +0 -120
- package/dist/application/commands/media-command-handlers.d.ts +0 -9
- package/dist/application/commands/media-command-handlers.js +0 -307
- package/dist/application/commands/media-command-output.d.ts +0 -11
- package/dist/application/commands/media-command-output.js +0 -8
- package/dist/application/commands/runtime-command-handlers.d.ts +0 -7
- package/dist/application/commands/runtime-command-handlers.js +0 -177
- package/dist/application/commands/stream-output.d.ts +0 -4
- package/dist/application/commands/stream-output.js +0 -10
- package/dist/application/commands/utility-commands.d.ts +0 -6
- package/dist/application/commands/utility-commands.js +0 -81
- package/dist/application/config/execution-config.d.ts +0 -4
- package/dist/application/config/execution-config.js +0 -6
- package/dist/application/extensions/extension-list-contract.d.ts +0 -13
- package/dist/application/extensions/extension-list-contract.js +0 -1
- package/dist/application/extensions/extension-list-formatters.d.ts +0 -31
- package/dist/application/extensions/extension-list-formatters.js +0 -98
- package/dist/application/extensions/extension-list-output.d.ts +0 -3
- package/dist/application/extensions/extension-list-output.js +0 -7
- package/dist/application/extensions/plugin-contribution-registry.d.ts +0 -15
- package/dist/application/extensions/plugin-contribution-registry.js +0 -80
- package/dist/application/extensions/skill-scope-store.d.ts +0 -23
- package/dist/application/extensions/skill-scope-store.js +0 -33
- package/dist/application/formatting/compact-number.d.ts +0 -2
- package/dist/application/formatting/compact-number.js +0 -18
- package/dist/application/formatting/compact-table.d.ts +0 -22
- package/dist/application/formatting/compact-table.js +0 -49
- package/dist/application/media/video-operation-poller.d.ts +0 -5
- package/dist/application/media/video-operation-poller.js +0 -42
- package/dist/application/model/cached-model-catalog.d.ts +0 -13
- package/dist/application/model/cached-model-catalog.js +0 -31
- package/dist/application/model/initial-model-selection.d.ts +0 -10
- package/dist/application/model/initial-model-selection.js +0 -11
- package/dist/application/model/model-catalog-service.d.ts +0 -6
- package/dist/application/model/model-catalog-service.js +0 -13
- package/dist/application/model/model-context-window.d.ts +0 -3
- package/dist/application/model/model-context-window.js +0 -23
- package/dist/application/orchestration/cli-subagent-service.d.ts +0 -70
- package/dist/application/orchestration/cli-subagent-service.js +0 -328
- package/dist/application/orchestration/cli-turn-event-projector.d.ts +0 -12
- package/dist/application/orchestration/cli-turn-event-projector.js +0 -81
- package/dist/application/orchestration/cli-turn-events.d.ts +0 -76
- package/dist/application/orchestration/cli-turn-events.js +0 -39
- package/dist/application/orchestration/cli-turn-persistence.d.ts +0 -6
- package/dist/application/orchestration/cli-turn-persistence.js +0 -14
- package/dist/application/orchestration/goal-evaluator.d.ts +0 -18
- package/dist/application/orchestration/goal-evaluator.js +0 -88
- package/dist/application/orchestration/goal-input.d.ts +0 -3
- package/dist/application/orchestration/goal-input.js +0 -19
- package/dist/application/orchestration/goal-output.d.ts +0 -2
- package/dist/application/orchestration/goal-output.js +0 -11
- package/dist/application/orchestration/goal-runner.d.ts +0 -22
- package/dist/application/orchestration/goal-runner.js +0 -153
- package/dist/application/orchestration/goal-usage.d.ts +0 -9
- package/dist/application/orchestration/goal-usage.js +0 -19
- package/dist/application/orchestration/headless-agent-turn.d.ts +0 -32
- package/dist/application/orchestration/headless-agent-turn.js +0 -82
- package/dist/application/orchestration/plan-generator.d.ts +0 -7
- package/dist/application/orchestration/plan-generator.js +0 -34
- package/dist/application/orchestration/subagent-coordinator.d.ts +0 -33
- package/dist/application/orchestration/subagent-coordinator.js +0 -28
- package/dist/application/orchestration/subagent-handoff.d.ts +0 -2
- package/dist/application/orchestration/subagent-handoff.js +0 -68
- package/dist/application/orchestration/subagent-tool-executor.d.ts +0 -12
- package/dist/application/orchestration/subagent-tool-executor.js +0 -93
- package/dist/application/orchestration/task-assessment.d.ts +0 -4
- package/dist/application/orchestration/task-assessment.js +0 -35
- package/dist/application/orchestration/task-graph.d.ts +0 -13
- package/dist/application/orchestration/task-graph.js +0 -56
- package/dist/application/orchestration/task-scheduler.d.ts +0 -18
- package/dist/application/orchestration/task-scheduler.js +0 -88
- package/dist/application/project/project-trust-service.d.ts +0 -13
- package/dist/application/project/project-trust-service.js +0 -74
- package/dist/application/protocol/browser-host-tool-executor.d.ts +0 -41
- package/dist/application/protocol/browser-host-tool-executor.js +0 -88
- package/dist/application/protocol/desktop-agent-command.d.ts +0 -9
- package/dist/application/protocol/desktop-agent-command.js +0 -663
- package/dist/application/protocol/desktop-attachment-store.d.ts +0 -16
- package/dist/application/protocol/desktop-attachment-store.js +0 -82
- package/dist/application/protocol/desktop-command-catalog.d.ts +0 -2
- package/dist/application/protocol/desktop-command-catalog.js +0 -19
- package/dist/application/protocol/desktop-command-contract.d.ts +0 -22
- package/dist/application/protocol/desktop-command-contract.js +0 -3
- package/dist/application/protocol/desktop-command-executor.d.ts +0 -16
- package/dist/application/protocol/desktop-command-executor.js +0 -47
- package/dist/application/protocol/desktop-command-output.d.ts +0 -15
- package/dist/application/protocol/desktop-command-output.js +0 -24
- package/dist/application/protocol/desktop-execution-policy.d.ts +0 -17
- package/dist/application/protocol/desktop-execution-policy.js +0 -49
- package/dist/application/protocol/desktop-host-tool-executor.d.ts +0 -57
- package/dist/application/protocol/desktop-host-tool-executor.js +0 -53
- package/dist/application/protocol/desktop-orchestration-events.d.ts +0 -5
- package/dist/application/protocol/desktop-orchestration-events.js +0 -37
- package/dist/application/protocol/json-line-writer.d.ts +0 -9
- package/dist/application/protocol/json-line-writer.js +0 -19
- package/dist/application/protocol/jsonl-agent-command.d.ts +0 -3
- package/dist/application/protocol/jsonl-agent-command.js +0 -97
- package/dist/application/protocol/jsonl-protocol.d.ts +0 -52
- package/dist/application/protocol/jsonl-protocol.js +0 -170
- package/dist/application/security/desktop-tool-scope-policy.d.ts +0 -3
- package/dist/application/security/desktop-tool-scope-policy.js +0 -52
- package/dist/application/security/tool-action-risk-analyzer.d.ts +0 -13
- package/dist/application/security/tool-action-risk-analyzer.js +0 -64
- package/dist/application/security/tool-approval-service.d.ts +0 -35
- package/dist/application/security/tool-approval-service.js +0 -97
- package/dist/application/security/tool-risk-classifier.d.ts +0 -11
- package/dist/application/security/tool-risk-classifier.js +0 -65
- package/dist/application/security/workspace-permission-policy.d.ts +0 -10
- package/dist/application/security/workspace-permission-policy.js +0 -50
- package/dist/application/session/project-session-access.d.ts +0 -8
- package/dist/application/session/project-session-access.js +0 -19
- package/dist/application/session/session-compaction-service.d.ts +0 -10
- package/dist/application/session/session-compaction-service.js +0 -43
- package/dist/application/session/session-turn-lifecycle.d.ts +0 -5
- package/dist/application/session/session-turn-lifecycle.js +0 -31
- package/dist/application/workspace/workspace-file-index.d.ts +0 -15
- package/dist/application/workspace/workspace-file-index.js +0 -60
- package/dist/application/workspace/workspace-file-reference-resolver.d.ts +0 -14
- package/dist/application/workspace/workspace-file-reference-resolver.js +0 -123
- package/dist/application/workspace/workspace-instruction-loader.d.ts +0 -8
- package/dist/application/workspace/workspace-instruction-loader.js +0 -55
- package/dist/bootstrap/composition-root.d.ts +0 -6
- package/dist/bootstrap/composition-root.js +0 -4
- package/dist/bootstrap/global-cli-options.d.ts +0 -6
- package/dist/bootstrap/global-cli-options.js +0 -29
- package/dist/bootstrap/native-devtools-stub.d.ts +0 -10
- package/dist/bootstrap/native-devtools-stub.js +0 -10
- package/dist/bootstrap/native-entry.d.ts +0 -1
- package/dist/bootstrap/native-entry.js +0 -6
- package/dist/bootstrap/native-tiktoken.d.ts +0 -4
- package/dist/bootstrap/native-tiktoken.js +0 -5
- package/dist/bootstrap/runtime-factory.d.ts +0 -35
- package/dist/bootstrap/runtime-factory.js +0 -44
- package/dist/bootstrap/shutdown-manager.d.ts +0 -10
- package/dist/bootstrap/shutdown-manager.js +0 -14
- package/dist/bootstrap/startup-sequence.d.ts +0 -5
- package/dist/bootstrap/startup-sequence.js +0 -10
- package/dist/domain/auth/auth-profile.d.ts +0 -14
- package/dist/domain/auth/auth-profile.js +0 -39
- package/dist/domain/config/config-schema.d.ts +0 -17
- package/dist/domain/config/config-schema.js +0 -105
- package/dist/domain/errors/cli-command-hint.d.ts +0 -5
- package/dist/domain/errors/cli-command-hint.js +0 -1
- package/dist/domain/errors/cli-error.d.ts +0 -35
- package/dist/domain/errors/cli-error.js +0 -129
- package/dist/domain/errors/error-codes.d.ts +0 -46
- package/dist/domain/errors/error-codes.js +0 -45
- package/dist/domain/extensions/extension-scope.d.ts +0 -3
- package/dist/domain/extensions/extension-scope.js +0 -23
- package/dist/domain/extensions/extension-state.d.ts +0 -5
- package/dist/domain/extensions/extension-state.js +0 -11
- package/dist/domain/extensions/hook-manifest.d.ts +0 -10
- package/dist/domain/extensions/hook-manifest.js +0 -23
- package/dist/domain/extensions/mcp-config.d.ts +0 -18
- package/dist/domain/extensions/mcp-config.js +0 -111
- package/dist/domain/extensions/plugin-manifest.d.ts +0 -11
- package/dist/domain/extensions/plugin-manifest.js +0 -43
- package/dist/domain/extensions/skill-manifest.d.ts +0 -10
- package/dist/domain/extensions/skill-manifest.js +0 -51
- package/dist/domain/filesystem/file-change-diff.d.ts +0 -21
- package/dist/domain/filesystem/file-change-diff.js +0 -60
- package/dist/domain/media/gateway-media-contract.d.ts +0 -23
- package/dist/domain/media/gateway-media-contract.js +0 -163
- package/dist/domain/media/media-contract.d.ts +0 -28
- package/dist/domain/media/media-contract.js +0 -1
- package/dist/domain/media/media-execution-policy.d.ts +0 -9
- package/dist/domain/media/media-execution-policy.js +0 -31
- package/dist/domain/orchestration/goal.d.ts +0 -58
- package/dist/domain/orchestration/goal.js +0 -113
- package/dist/domain/orchestration/subagent-identity.d.ts +0 -2
- package/dist/domain/orchestration/subagent-identity.js +0 -8
- package/dist/domain/orchestration/subagent.d.ts +0 -33
- package/dist/domain/orchestration/subagent.js +0 -1
- package/dist/domain/orchestration/task.d.ts +0 -31
- package/dist/domain/orchestration/task.js +0 -1
- package/dist/domain/project/project-identity.d.ts +0 -6
- package/dist/domain/project/project-identity.js +0 -4
- package/dist/domain/runtime/assistant-delta-normalizer.d.ts +0 -11
- package/dist/domain/runtime/assistant-delta-normalizer.js +0 -19
- package/dist/domain/runtime/resource-limits.d.ts +0 -60
- package/dist/domain/runtime/resource-limits.js +0 -60
- package/dist/domain/session/attachment.d.ts +0 -13
- package/dist/domain/session/attachment.js +0 -1
- package/dist/domain/session/session-schema.d.ts +0 -6
- package/dist/domain/session/session-schema.js +0 -28
- package/dist/domain/session/session.d.ts +0 -27
- package/dist/domain/session/session.js +0 -1
- package/dist/domain/settings/settings-document.d.ts +0 -8
- package/dist/domain/settings/settings-document.js +0 -36
- package/dist/domain/validation/record-schema.d.ts +0 -4
- package/dist/domain/validation/record-schema.js +0 -9
- package/dist/domain/workspace/workspace-settings.d.ts +0 -12
- package/dist/domain/workspace/workspace-settings.js +0 -44
- package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +0 -22
- package/dist/infrastructure/agent-sdk/agent-instance-factory.js +0 -31
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +0 -11
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +0 -447
- package/dist/infrastructure/cache/cache-policy.d.ts +0 -7
- package/dist/infrastructure/cache/cache-policy.js +0 -18
- package/dist/infrastructure/cache/file-cache-store.d.ts +0 -17
- package/dist/infrastructure/cache/file-cache-store.js +0 -121
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +0 -11
- package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +0 -98
- package/dist/infrastructure/clipboard/clipboard-policy.d.ts +0 -8
- package/dist/infrastructure/clipboard/clipboard-policy.js +0 -19
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +0 -10
- package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +0 -94
- package/dist/infrastructure/clipboard/image-normalizer.d.ts +0 -12
- package/dist/infrastructure/clipboard/image-normalizer.js +0 -78
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +0 -7
- package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +0 -66
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +0 -7
- package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +0 -70
- package/dist/infrastructure/config/config-loader.d.ts +0 -19
- package/dist/infrastructure/config/config-loader.js +0 -76
- package/dist/infrastructure/config/environment-values.d.ts +0 -2
- package/dist/infrastructure/config/environment-values.js +0 -7
- package/dist/infrastructure/credentials/composite-credential-store.d.ts +0 -11
- package/dist/infrastructure/credentials/composite-credential-store.js +0 -32
- package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +0 -17
- package/dist/infrastructure/credentials/encrypted-file-credential-store.js +0 -181
- package/dist/infrastructure/credentials/environment-credential-store.d.ts +0 -11
- package/dist/infrastructure/credentials/environment-credential-store.js +0 -37
- package/dist/infrastructure/credentials/secret-input.d.ts +0 -7
- package/dist/infrastructure/credentials/secret-input.js +0 -44
- package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +0 -9
- package/dist/infrastructure/extensions/composite-mcp-config-store.js +0 -10
- package/dist/infrastructure/extensions/extension-directory-reader.d.ts +0 -2
- package/dist/infrastructure/extensions/extension-directory-reader.js +0 -15
- package/dist/infrastructure/extensions/extension-source-resolver.d.ts +0 -6
- package/dist/infrastructure/extensions/extension-source-resolver.js +0 -126
- package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +0 -15
- package/dist/infrastructure/extensions/file-mcp-config-store.js +0 -66
- package/dist/infrastructure/extensions/hook-runtime.d.ts +0 -18
- package/dist/infrastructure/extensions/hook-runtime.js +0 -66
- package/dist/infrastructure/extensions/mcp-runtime.d.ts +0 -12
- package/dist/infrastructure/extensions/mcp-runtime.js +0 -52
- package/dist/infrastructure/extensions/plugin-discovery.d.ts +0 -5
- package/dist/infrastructure/extensions/plugin-discovery.js +0 -52
- package/dist/infrastructure/extensions/plugin-manager.d.ts +0 -26
- package/dist/infrastructure/extensions/plugin-manager.js +0 -139
- package/dist/infrastructure/extensions/skill-discovery.d.ts +0 -4
- package/dist/infrastructure/extensions/skill-discovery.js +0 -29
- package/dist/infrastructure/extensions/skill-installer.d.ts +0 -8
- package/dist/infrastructure/extensions/skill-installer.js +0 -88
- package/dist/infrastructure/extensions/skill-manager.d.ts +0 -22
- package/dist/infrastructure/extensions/skill-manager.js +0 -67
- package/dist/infrastructure/extensions/skill-roots.d.ts +0 -19
- package/dist/infrastructure/extensions/skill-roots.js +0 -25
- package/dist/infrastructure/extensions/skill-tool-executor.d.ts +0 -18
- package/dist/infrastructure/extensions/skill-tool-executor.js +0 -53
- package/dist/infrastructure/filesystem/atomic-file-store.d.ts +0 -12
- package/dist/infrastructure/filesystem/atomic-file-store.js +0 -106
- package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +0 -6
- package/dist/infrastructure/filesystem/bounded-file-reader.js +0 -24
- package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +0 -1
- package/dist/infrastructure/filesystem/bounded-json-reader.js +0 -7
- package/dist/infrastructure/filesystem/fs-errors.d.ts +0 -2
- package/dist/infrastructure/filesystem/fs-errors.js +0 -6
- package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +0 -12
- package/dist/infrastructure/filesystem/gateway-media-input-reader.js +0 -49
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +0 -21
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +0 -176
- package/dist/infrastructure/filesystem/path-resolver.d.ts +0 -20
- package/dist/infrastructure/filesystem/path-resolver.js +0 -119
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +0 -13
- package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +0 -152
- package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +0 -20
- package/dist/infrastructure/logging/daily-rotating-file-writer.js +0 -75
- package/dist/infrastructure/logging/log-redactor.d.ts +0 -2
- package/dist/infrastructure/logging/log-redactor.js +0 -26
- package/dist/infrastructure/logging/logging-policy.d.ts +0 -6
- package/dist/infrastructure/logging/logging-policy.js +0 -6
- package/dist/infrastructure/logging/structured-logger.d.ts +0 -24
- package/dist/infrastructure/logging/structured-logger.js +0 -40
- package/dist/infrastructure/network/safe-media-downloader.d.ts +0 -23
- package/dist/infrastructure/network/safe-media-downloader.js +0 -239
- package/dist/infrastructure/platform/host-platform.d.ts +0 -14
- package/dist/infrastructure/platform/host-platform.js +0 -23
- package/dist/infrastructure/platform/host-process.d.ts +0 -17
- package/dist/infrastructure/platform/host-process.js +0 -116
- package/dist/infrastructure/platform/platform-paths.d.ts +0 -25
- package/dist/infrastructure/platform/platform-paths.js +0 -33
- package/dist/infrastructure/project/file-project-trust-store.d.ts +0 -12
- package/dist/infrastructure/project/file-project-trust-store.js +0 -59
- package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +0 -8
- package/dist/infrastructure/sdk/chat-completion-adapter.js +0 -115
- package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +0 -3
- package/dist/infrastructure/sdk/lotagate-client-factory.js +0 -8
- package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +0 -19
- package/dist/infrastructure/sdk/model-catalog-adapter.js +0 -28
- package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +0 -20
- package/dist/infrastructure/sdk/sdk-media-gateway-client.js +0 -97
- package/dist/infrastructure/sessions/file-goal-store.d.ts +0 -21
- package/dist/infrastructure/sessions/file-goal-store.js +0 -160
- package/dist/infrastructure/sessions/file-session-store.d.ts +0 -48
- package/dist/infrastructure/sessions/file-session-store.js +0 -525
- package/dist/infrastructure/sessions/project-session-paths.d.ts +0 -17
- package/dist/infrastructure/sessions/project-session-paths.js +0 -41
- package/dist/infrastructure/sessions/session-index.d.ts +0 -16
- package/dist/infrastructure/sessions/session-index.js +0 -84
- package/dist/infrastructure/sessions/session-journal.d.ts +0 -22
- package/dist/infrastructure/sessions/session-journal.js +0 -137
- package/dist/infrastructure/sessions/subagent-journal-store.d.ts +0 -28
- package/dist/infrastructure/sessions/subagent-journal-store.js +0 -30
- package/dist/infrastructure/shell/shell-tool-executor.d.ts +0 -17
- package/dist/infrastructure/shell/shell-tool-executor.js +0 -115
- package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +0 -18
- package/dist/infrastructure/tokens/tiktoken-token-estimator.js +0 -48
- package/dist/infrastructure/workspace/workspace-settings-store.d.ts +0 -9
- package/dist/infrastructure/workspace/workspace-settings-store.js +0 -75
- package/dist/main.d.ts +0 -7
- package/dist/main.js +0 -66
- package/dist/ports/cache-store.d.ts +0 -10
- package/dist/ports/cache-store.js +0 -1
- package/dist/ports/chat-model.d.ts +0 -30
- package/dist/ports/chat-model.js +0 -1
- package/dist/ports/clipboard-adapter.d.ts +0 -7
- package/dist/ports/clipboard-adapter.js +0 -1
- package/dist/ports/clipboard-text-adapter.d.ts +0 -3
- package/dist/ports/clipboard-text-adapter.js +0 -1
- package/dist/ports/credential-store.d.ts +0 -7
- package/dist/ports/credential-store.js +0 -1
- package/dist/ports/goal-store.d.ts +0 -12
- package/dist/ports/goal-store.js +0 -1
- package/dist/ports/logger.d.ts +0 -8
- package/dist/ports/logger.js +0 -1
- package/dist/ports/media-gateway-client.d.ts +0 -54
- package/dist/ports/media-gateway-client.js +0 -1
- package/dist/ports/model-diagnostics.d.ts +0 -17
- package/dist/ports/model-diagnostics.js +0 -1
- package/dist/ports/project-trust-store.d.ts +0 -12
- package/dist/ports/project-trust-store.js +0 -1
- package/dist/ports/session-store.d.ts +0 -58
- package/dist/ports/session-store.js +0 -1
- package/dist/ports/subagent-lifecycle.d.ts +0 -31
- package/dist/ports/subagent-lifecycle.js +0 -1
- package/dist/ports/tool-activity.d.ts +0 -13
- package/dist/ports/tool-activity.js +0 -1
- package/dist/presentation/themes/theme.d.ts +0 -19
- package/dist/presentation/themes/theme.js +0 -8
- package/dist/presentation/tui/agent-initialization-renderer.d.ts +0 -4
- package/dist/presentation/tui/agent-initialization-renderer.js +0 -37
- package/dist/presentation/tui/context-display.d.ts +0 -21
- package/dist/presentation/tui/context-display.js +0 -33
- package/dist/presentation/tui/formatters.d.ts +0 -6
- package/dist/presentation/tui/formatters.js +0 -60
- package/dist/presentation/tui/ink/choice-window.d.ts +0 -5
- package/dist/presentation/tui/ink/choice-window.js +0 -5
- package/dist/presentation/tui/ink/components/activity-entry.d.ts +0 -6
- package/dist/presentation/tui/ink/components/activity-entry.js +0 -16
- package/dist/presentation/tui/ink/components/activity-status.d.ts +0 -10
- package/dist/presentation/tui/ink/components/activity-status.js +0 -21
- package/dist/presentation/tui/ink/components/choice-modal.d.ts +0 -11
- package/dist/presentation/tui/ink/components/choice-modal.js +0 -29
- package/dist/presentation/tui/ink/components/composer.d.ts +0 -40
- package/dist/presentation/tui/ink/components/composer.js +0 -271
- package/dist/presentation/tui/ink/components/file-diff.d.ts +0 -6
- package/dist/presentation/tui/ink/components/file-diff.js +0 -34
- package/dist/presentation/tui/ink/components/modal.d.ts +0 -8
- package/dist/presentation/tui/ink/components/modal.js +0 -110
- package/dist/presentation/tui/ink/components/shimmer-text.d.ts +0 -6
- package/dist/presentation/tui/ink/components/shimmer-text.js +0 -9
- package/dist/presentation/tui/ink/components/subagent-activity.d.ts +0 -11
- package/dist/presentation/tui/ink/components/subagent-activity.js +0 -61
- package/dist/presentation/tui/ink/components/transcript.d.ts +0 -39
- package/dist/presentation/tui/ink/components/transcript.js +0 -121
- package/dist/presentation/tui/ink/components/welcome-panel.d.ts +0 -6
- package/dist/presentation/tui/ink/components/welcome-panel.js +0 -20
- package/dist/presentation/tui/ink/lotagate-tui.d.ts +0 -6
- package/dist/presentation/tui/ink/lotagate-tui.js +0 -136
- package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +0 -4
- package/dist/presentation/tui/ink/markdown-inline-renderer.js +0 -20
- package/dist/presentation/tui/ink/markdown-inline.d.ts +0 -13
- package/dist/presentation/tui/ink/markdown-inline.js +0 -91
- package/dist/presentation/tui/ink/markdown-message.d.ts +0 -6
- package/dist/presentation/tui/ink/markdown-message.js +0 -66
- package/dist/presentation/tui/ink/markdown-table.d.ts +0 -16
- package/dist/presentation/tui/ink/markdown-table.js +0 -77
- package/dist/presentation/tui/ink/tui-bridge.d.ts +0 -195
- package/dist/presentation/tui/ink/tui-bridge.js +0 -289
- package/dist/presentation/tui/terminal-capabilities.d.ts +0 -15
- package/dist/presentation/tui/terminal-capabilities.js +0 -7
- package/dist/presentation/tui/terminal-mouse.d.ts +0 -5
- package/dist/presentation/tui/terminal-mouse.js +0 -19
- package/dist/presentation/tui/terminal-screen.d.ts +0 -10
- package/dist/presentation/tui/terminal-screen.js +0 -23
- package/dist/presentation/tui/tui-agent-event-runner.d.ts +0 -24
- package/dist/presentation/tui/tui-agent-event-runner.js +0 -69
- package/dist/presentation/tui/tui-application-contract.d.ts +0 -10
- package/dist/presentation/tui/tui-application-contract.js +0 -8
- package/dist/presentation/tui/tui-application.d.ts +0 -62
- package/dist/presentation/tui/tui-application.js +0 -675
- package/dist/presentation/tui/tui-attachment-input.d.ts +0 -2
- package/dist/presentation/tui/tui-attachment-input.js +0 -5
- package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +0 -11
- package/dist/presentation/tui/tui-clipboard-paste-handlers.js +0 -25
- package/dist/presentation/tui/tui-command-context.d.ts +0 -3
- package/dist/presentation/tui/tui-command-context.js +0 -1
- package/dist/presentation/tui/tui-command-executor.d.ts +0 -38
- package/dist/presentation/tui/tui-command-executor.js +0 -214
- package/dist/presentation/tui/tui-command-host-factory.d.ts +0 -40
- package/dist/presentation/tui/tui-command-host-factory.js +0 -23
- package/dist/presentation/tui/tui-context-compaction.d.ts +0 -5
- package/dist/presentation/tui/tui-context-compaction.js +0 -22
- package/dist/presentation/tui/tui-context-service.d.ts +0 -34
- package/dist/presentation/tui/tui-context-service.js +0 -126
- package/dist/presentation/tui/tui-file-suggestions.d.ts +0 -3
- package/dist/presentation/tui/tui-file-suggestions.js +0 -8
- package/dist/presentation/tui/tui-goal-controller.d.ts +0 -14
- package/dist/presentation/tui/tui-goal-controller.js +0 -52
- package/dist/presentation/tui/tui-initial-model.d.ts +0 -3
- package/dist/presentation/tui/tui-initial-model.js +0 -28
- package/dist/presentation/tui/tui-lifecycle-actions.d.ts +0 -13
- package/dist/presentation/tui/tui-lifecycle-actions.js +0 -45
- package/dist/presentation/tui/tui-manual-compaction.d.ts +0 -18
- package/dist/presentation/tui/tui-manual-compaction.js +0 -31
- package/dist/presentation/tui/tui-media-model-selection.d.ts +0 -12
- package/dist/presentation/tui/tui-media-model-selection.js +0 -38
- package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +0 -16
- package/dist/presentation/tui/tui-prompt-dispatcher.js +0 -38
- package/dist/presentation/tui/tui-skill-controller.d.ts +0 -11
- package/dist/presentation/tui/tui-skill-controller.js +0 -13
- package/dist/presentation/tui/tui-tool-approval.d.ts +0 -22
- package/dist/presentation/tui/tui-tool-approval.js +0 -73
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -1
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
import { SdkErrorCode } from '@lotagate/sdk';
|
|
2
|
-
import { AssistantDeltaNormalizer } from '../../domain/runtime/assistant-delta-normalizer.js';
|
|
3
|
-
/**
|
|
4
|
-
* Adapts the published SDK client to the Agent SDK model port and makes the
|
|
5
|
-
* intended tool-calling mode explicit for gateways that do not infer it from
|
|
6
|
-
* the presence of `tools` alone.
|
|
7
|
-
*/
|
|
8
|
-
export function createToolCallingModelClient(client, diagnostics = {}) {
|
|
9
|
-
const create = ((request, requestOptions) => {
|
|
10
|
-
if (request.stream === true) {
|
|
11
|
-
const stream = client.chat.completions.create(withAutomaticToolChoice({ ...request, stream: true }), requestOptions);
|
|
12
|
-
return observeStream(client, request, requestOptions, stream, request.model, diagnostics.onComplete);
|
|
13
|
-
}
|
|
14
|
-
return observeCompletion(client.chat.completions.create(withAutomaticToolChoice({ ...request, stream: false }), requestOptions), request.model, diagnostics.onComplete);
|
|
15
|
-
});
|
|
16
|
-
return { chat: { completions: { create } } };
|
|
17
|
-
}
|
|
18
|
-
async function observeCompletion(responsePromise, model, onComplete) {
|
|
19
|
-
const response = normalizeCompletionResponse(await responsePromise);
|
|
20
|
-
const message = response.choices[0]?.message;
|
|
21
|
-
onComplete?.({
|
|
22
|
-
model,
|
|
23
|
-
stream: false,
|
|
24
|
-
contentLength: textLength(message?.content),
|
|
25
|
-
toolCallCount: message?.tool_calls?.length ?? 0,
|
|
26
|
-
toolNames: (message?.tool_calls ?? []).map((call) => call.function.name),
|
|
27
|
-
...(response.usage === undefined ? {} : { usage: mapUsage(response.usage) }),
|
|
28
|
-
...(response.choices[0]?.finish_reason === undefined ? {} : { finishReason: response.choices[0].finish_reason }),
|
|
29
|
-
});
|
|
30
|
-
return response;
|
|
31
|
-
}
|
|
32
|
-
async function* observeStream(client, request, requestOptions, stream, model, onComplete) {
|
|
33
|
-
let contentLength = 0;
|
|
34
|
-
let finishReason;
|
|
35
|
-
const toolNames = new Set();
|
|
36
|
-
const toolCallIds = new Set();
|
|
37
|
-
const toolCallBuffer = new ToolCallStreamBuffer(request.tools);
|
|
38
|
-
let emittedMeaningfulFrame = false;
|
|
39
|
-
let usage;
|
|
40
|
-
let lastChunk;
|
|
41
|
-
let emittedBufferedToolCalls = false;
|
|
42
|
-
const deltaNormalizer = new AssistantDeltaNormalizer();
|
|
43
|
-
try {
|
|
44
|
-
for await (const rawChunk of stream) {
|
|
45
|
-
const normalizedChunk = normalizeChunkContent(rawChunk, deltaNormalizer);
|
|
46
|
-
const buffered = toolCallBuffer.consume(normalizedChunk);
|
|
47
|
-
const chunk = buffered.chunk;
|
|
48
|
-
const choice = chunk.choices[0];
|
|
49
|
-
if (chunk.usage !== undefined)
|
|
50
|
-
usage = mapUsage(chunk.usage);
|
|
51
|
-
const content = textLength(choice?.delta.content);
|
|
52
|
-
contentLength += content;
|
|
53
|
-
finishReason = choice?.finish_reason ?? finishReason;
|
|
54
|
-
if (content > 0 || buffered.hadToolCalls)
|
|
55
|
-
emittedMeaningfulFrame = true;
|
|
56
|
-
if (choice?.finish_reason === 'tool_calls' && !emittedBufferedToolCalls) {
|
|
57
|
-
const completed = toolCallBuffer.flush(chunk);
|
|
58
|
-
recordToolCalls(completed, toolCallIds, toolNames);
|
|
59
|
-
emittedBufferedToolCalls = true;
|
|
60
|
-
yield chunk;
|
|
61
|
-
yield completed;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
yield chunk;
|
|
65
|
-
}
|
|
66
|
-
lastChunk = chunk;
|
|
67
|
-
}
|
|
68
|
-
if (!emittedBufferedToolCalls && lastChunk !== undefined && toolCallBuffer.hasCalls()) {
|
|
69
|
-
const completed = toolCallBuffer.flush(lastChunk);
|
|
70
|
-
recordToolCalls(completed, toolCallIds, toolNames);
|
|
71
|
-
yield completed;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
if (!emittedMeaningfulFrame && isSseParseError(error) && requestOptions?.signal?.aborted !== true) {
|
|
76
|
-
const response = await client.chat.completions.create(withAutomaticToolChoice({ ...request, stream: false }), requestOptions);
|
|
77
|
-
if (response.usage !== undefined)
|
|
78
|
-
usage = mapUsage(response.usage);
|
|
79
|
-
const message = response.choices[0]?.message;
|
|
80
|
-
const bufferedContent = textLength(message?.content);
|
|
81
|
-
contentLength += bufferedContent;
|
|
82
|
-
for (const call of message?.tool_calls ?? []) {
|
|
83
|
-
if (call.id.length > 0)
|
|
84
|
-
toolCallIds.add(call.id);
|
|
85
|
-
if (call.function.name.length > 0)
|
|
86
|
-
toolNames.add(call.function.name);
|
|
87
|
-
}
|
|
88
|
-
finishReason = response.choices[0]?.finish_reason ?? finishReason;
|
|
89
|
-
yield bufferedResponseChunk(response);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
finally {
|
|
95
|
-
onComplete?.({ model, stream: true, contentLength, toolCallCount: toolCallIds.size || toolNames.size, toolNames: [...toolNames], ...(finishReason === undefined ? {} : { finishReason }), ...(usage === undefined ? {} : { usage }) });
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function withAutomaticToolChoice(request) {
|
|
99
|
-
return request.tools === undefined || request.tools.length === 0
|
|
100
|
-
? request
|
|
101
|
-
: { ...request, tool_choice: 'auto' };
|
|
102
|
-
}
|
|
103
|
-
function bufferedResponseChunk(response) {
|
|
104
|
-
const normalized = normalizeCompletionResponse(response);
|
|
105
|
-
const choice = normalized.choices[0];
|
|
106
|
-
const message = choice?.message;
|
|
107
|
-
return {
|
|
108
|
-
id: normalized.id,
|
|
109
|
-
object: 'chat.completion.chunk',
|
|
110
|
-
created: normalized.created,
|
|
111
|
-
model: normalized.model,
|
|
112
|
-
choices: [{
|
|
113
|
-
index: choice?.index ?? 0,
|
|
114
|
-
delta: {
|
|
115
|
-
role: 'assistant',
|
|
116
|
-
content: textContent(message?.content),
|
|
117
|
-
...(message?.tool_calls === undefined ? {} : {
|
|
118
|
-
tool_calls: message.tool_calls.map((call, index) => ({ ...call, index })),
|
|
119
|
-
}),
|
|
120
|
-
},
|
|
121
|
-
...(choice?.finish_reason === undefined ? {} : { finish_reason: choice.finish_reason }),
|
|
122
|
-
}],
|
|
123
|
-
...(normalized.usage === undefined ? {} : { usage: normalized.usage }),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Some gateways encode streamed assistant text as content parts. The
|
|
128
|
-
* published Agent SDK consumes the portable string form for stream deltas, so
|
|
129
|
-
* normalize that provider representation at the CLI boundary without
|
|
130
|
-
* changing the external SDK contracts.
|
|
131
|
-
*/
|
|
132
|
-
function normalizeChunkContent(chunk, deltaNormalizer) {
|
|
133
|
-
return {
|
|
134
|
-
...chunk,
|
|
135
|
-
choices: chunk.choices.map((choice) => {
|
|
136
|
-
const content = choice.delta.content;
|
|
137
|
-
const normalizedContent = Array.isArray(content)
|
|
138
|
-
? deltaNormalizer.normalize(textContent(content))
|
|
139
|
-
: typeof content === 'string'
|
|
140
|
-
? deltaNormalizer.normalize(content)
|
|
141
|
-
: content;
|
|
142
|
-
const rawDelta = choice.delta;
|
|
143
|
-
const providerToolCalls = [
|
|
144
|
-
...(Array.isArray(content) ? extractProviderToolCalls(content) : []),
|
|
145
|
-
...extractLegacyFunctionCall(rawDelta['function_call'], 0),
|
|
146
|
-
];
|
|
147
|
-
const normalizedChoice = normalizedContent === content && providerToolCalls.length === 0 ? choice : {
|
|
148
|
-
...choice,
|
|
149
|
-
delta: {
|
|
150
|
-
...choice.delta,
|
|
151
|
-
...(normalizedContent === content ? {} : { content: normalizedContent }),
|
|
152
|
-
...(providerToolCalls.length === 0 ? {} : { tool_calls: [...(choice.delta.tool_calls ?? []), ...providerToolCalls] }),
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
return normalizedChoice;
|
|
156
|
-
}),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Gateways can emit several overlapping tool-call frames, especially when a
|
|
161
|
-
* response contains multiple tools. Buffer them at the CLI boundary and emit
|
|
162
|
-
* one complete frame so the external Agent SDK never concatenates duplicated
|
|
163
|
-
* JSON fragments into an invalid argument payload.
|
|
164
|
-
*/
|
|
165
|
-
class ToolCallStreamBuffer {
|
|
166
|
-
knownNames;
|
|
167
|
-
calls = new Map();
|
|
168
|
-
order = [];
|
|
169
|
-
keysByPosition = new Map();
|
|
170
|
-
constructor(tools) {
|
|
171
|
-
this.knownNames = new Set((tools ?? []).flatMap((tool) => getToolNames(tool)));
|
|
172
|
-
}
|
|
173
|
-
consume(chunk) {
|
|
174
|
-
let hadToolCalls = false;
|
|
175
|
-
const choices = chunk.choices.map((choice) => {
|
|
176
|
-
const toolCalls = choice.delta.tool_calls;
|
|
177
|
-
if (toolCalls === undefined || toolCalls.length === 0)
|
|
178
|
-
return choice;
|
|
179
|
-
hadToolCalls = true;
|
|
180
|
-
toolCalls.forEach((call, position) => {
|
|
181
|
-
if (isRecord(call))
|
|
182
|
-
this.append(call, position);
|
|
183
|
-
});
|
|
184
|
-
const delta = { ...choice.delta };
|
|
185
|
-
delete delta.tool_calls;
|
|
186
|
-
return { ...choice, delta };
|
|
187
|
-
});
|
|
188
|
-
return { chunk: { ...chunk, choices }, hadToolCalls };
|
|
189
|
-
}
|
|
190
|
-
hasCalls() { return this.order.length > 0; }
|
|
191
|
-
flush(chunk) {
|
|
192
|
-
const toolCalls = this.order.map((key, index) => {
|
|
193
|
-
const call = this.calls.get(key);
|
|
194
|
-
return {
|
|
195
|
-
id: call.id || `tool-call-${index}`,
|
|
196
|
-
type: call.type,
|
|
197
|
-
function: { name: call.name, arguments: call.arguments },
|
|
198
|
-
...(call.providerMetadata === undefined ? {} : { provider_metadata: call.providerMetadata }),
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
const choices = chunk.choices.map((choice, index) => index === 0
|
|
202
|
-
? { ...choice, delta: { ...choice.delta, tool_calls: toolCalls } }
|
|
203
|
-
: choice);
|
|
204
|
-
return { ...chunk, choices };
|
|
205
|
-
}
|
|
206
|
-
append(call, position) {
|
|
207
|
-
const id = toolCallId(call);
|
|
208
|
-
const type = toolCallType(call);
|
|
209
|
-
const nameFragment = toolCallName(call);
|
|
210
|
-
const argumentFragment = toolCallArguments(call);
|
|
211
|
-
const providerMetadata = readProviderMetadata(call);
|
|
212
|
-
const slot = toolCallSlot(call, position);
|
|
213
|
-
const key = this.keysByPosition.get(slot) ?? toolCallKey(id, slot);
|
|
214
|
-
this.keysByPosition.set(slot, key);
|
|
215
|
-
const current = this.calls.get(key);
|
|
216
|
-
const name = appendToolFragment(current?.name ?? '', nameFragment, this.knownNames);
|
|
217
|
-
const args = appendToolArguments(current?.arguments ?? '', argumentFragment);
|
|
218
|
-
if (current === undefined) {
|
|
219
|
-
this.calls.set(key, { id, type, name, arguments: args, ...(providerMetadata === undefined ? {} : { providerMetadata }) });
|
|
220
|
-
this.order.push(key);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const nextProviderMetadata = current.providerMetadata ?? providerMetadata;
|
|
224
|
-
this.calls.set(key, {
|
|
225
|
-
id: current.id.length === 0 && id.length > 0 ? id : current.id,
|
|
226
|
-
type: type || current.type,
|
|
227
|
-
name: current.name + name,
|
|
228
|
-
arguments: args,
|
|
229
|
-
...(nextProviderMetadata === undefined ? {} : { providerMetadata: nextProviderMetadata }),
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
function readProviderMetadata(value) {
|
|
234
|
-
if (!isRecord(value))
|
|
235
|
-
return undefined;
|
|
236
|
-
const metadata = value['provider_metadata'] ?? value['providerMetadata'];
|
|
237
|
-
if (isRecord(metadata))
|
|
238
|
-
return metadata;
|
|
239
|
-
const signature = value['thoughtSignature'] ?? value['thought_signature'];
|
|
240
|
-
return typeof signature === 'string' && signature.length > 0
|
|
241
|
-
? { google: { thought_signature: signature } }
|
|
242
|
-
: undefined;
|
|
243
|
-
}
|
|
244
|
-
function toolCallSlot(call, position) {
|
|
245
|
-
const index = call.index;
|
|
246
|
-
return typeof index === 'number' && Number.isInteger(index) ? index : position;
|
|
247
|
-
}
|
|
248
|
-
function toolCallKey(id, slot) {
|
|
249
|
-
return id.length > 0 ? `id:${id}` : `index:${slot}`;
|
|
250
|
-
}
|
|
251
|
-
function toolCallId(call) {
|
|
252
|
-
const value = call;
|
|
253
|
-
if (!isRecord(value))
|
|
254
|
-
return '';
|
|
255
|
-
return typeof value['id'] === 'string' ? value['id'] : '';
|
|
256
|
-
}
|
|
257
|
-
function toolCallType(call) {
|
|
258
|
-
const value = call;
|
|
259
|
-
if (!isRecord(value))
|
|
260
|
-
return 'function';
|
|
261
|
-
return typeof value['type'] === 'string' && value['type'].length > 0 ? value['type'] : 'function';
|
|
262
|
-
}
|
|
263
|
-
function toolCallName(call) {
|
|
264
|
-
const value = call;
|
|
265
|
-
if (!isRecord(value))
|
|
266
|
-
return '';
|
|
267
|
-
return isRecord(value['function']) && typeof value['function']['name'] === 'string' ? value['function']['name'] : '';
|
|
268
|
-
}
|
|
269
|
-
function toolCallArguments(call) {
|
|
270
|
-
const value = call;
|
|
271
|
-
if (!isRecord(value))
|
|
272
|
-
return '';
|
|
273
|
-
return isRecord(value['function']) && typeof value['function']['arguments'] === 'string' ? value['function']['arguments'] : '';
|
|
274
|
-
}
|
|
275
|
-
function appendToolFragment(emitted, fragment, knownNames) {
|
|
276
|
-
if (fragment.length === 0)
|
|
277
|
-
return '';
|
|
278
|
-
if (fragment === emitted)
|
|
279
|
-
return '';
|
|
280
|
-
if (knownNames !== undefined && knownNames.has(fragment) && fragment.startsWith(emitted))
|
|
281
|
-
return fragment.slice(emitted.length);
|
|
282
|
-
if (fragment.startsWith(emitted) && emitted.length > 0)
|
|
283
|
-
return fragment.slice(emitted.length);
|
|
284
|
-
return fragment;
|
|
285
|
-
}
|
|
286
|
-
function appendToolArguments(emitted, fragment) {
|
|
287
|
-
if (fragment.length === 0)
|
|
288
|
-
return emitted;
|
|
289
|
-
if (emitted.length === 0 || fragment === emitted)
|
|
290
|
-
return emitted.length === 0 ? fragment : emitted;
|
|
291
|
-
if (fragment.startsWith(emitted))
|
|
292
|
-
return fragment;
|
|
293
|
-
const mergedObject = mergeJsonObjectFragments(emitted, fragment);
|
|
294
|
-
if (mergedObject !== undefined)
|
|
295
|
-
return mergedObject;
|
|
296
|
-
return emitted + fragment;
|
|
297
|
-
}
|
|
298
|
-
function mergeJsonObjectFragments(emitted, fragment) {
|
|
299
|
-
if (emitted.length === 0 || fragment.length === 0)
|
|
300
|
-
return undefined;
|
|
301
|
-
const current = parseJsonObject(emitted);
|
|
302
|
-
const next = parseJsonObject(fragment);
|
|
303
|
-
if (current === undefined || next === undefined)
|
|
304
|
-
return undefined;
|
|
305
|
-
return JSON.stringify({ ...current, ...next });
|
|
306
|
-
}
|
|
307
|
-
function parseJsonObject(value) {
|
|
308
|
-
try {
|
|
309
|
-
const parsed = JSON.parse(value);
|
|
310
|
-
return isRecord(parsed) ? parsed : undefined;
|
|
311
|
-
}
|
|
312
|
-
catch {
|
|
313
|
-
return undefined;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
function recordToolCalls(chunk, ids, names) {
|
|
317
|
-
for (const call of chunk.choices[0]?.delta.tool_calls ?? []) {
|
|
318
|
-
const id = toolCallId(call);
|
|
319
|
-
const name = toolCallName(call);
|
|
320
|
-
if (id.length > 0)
|
|
321
|
-
ids.add(id);
|
|
322
|
-
if (name.length > 0)
|
|
323
|
-
names.add(name);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function getToolNames(tool) {
|
|
327
|
-
if ('function' in tool && typeof tool.function.name === 'string')
|
|
328
|
-
return [tool.function.name];
|
|
329
|
-
if ('name' in tool && typeof tool.name === 'string')
|
|
330
|
-
return [tool.name];
|
|
331
|
-
if ('functionDeclarations' in tool)
|
|
332
|
-
return tool.functionDeclarations.flatMap((declaration) => typeof declaration.name === 'string' ? [declaration.name] : []);
|
|
333
|
-
return [];
|
|
334
|
-
}
|
|
335
|
-
function normalizeCompletionResponse(response) {
|
|
336
|
-
return {
|
|
337
|
-
...response,
|
|
338
|
-
choices: response.choices.map((choice) => ({
|
|
339
|
-
...choice,
|
|
340
|
-
message: normalizeAssistantMessage(choice.message),
|
|
341
|
-
})),
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function normalizeAssistantMessage(message) {
|
|
345
|
-
const rawMessage = message;
|
|
346
|
-
const providerToolCalls = [
|
|
347
|
-
...(Array.isArray(message.content) ? extractProviderToolCalls(message.content) : []),
|
|
348
|
-
...extractLegacyFunctionCall(rawMessage['function_call'], 0),
|
|
349
|
-
];
|
|
350
|
-
if (!Array.isArray(message.content) && providerToolCalls.length === 0)
|
|
351
|
-
return message;
|
|
352
|
-
return {
|
|
353
|
-
...message,
|
|
354
|
-
...(Array.isArray(message.content) ? { content: textContent(message.content) } : {}),
|
|
355
|
-
...(providerToolCalls.length === 0 ? {} : { tool_calls: [...(message.tool_calls ?? []), ...providerToolCalls] }),
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function extractProviderToolCalls(content) {
|
|
359
|
-
const calls = [];
|
|
360
|
-
for (const [index, part] of content.entries()) {
|
|
361
|
-
if (typeof part !== 'object' || part === null)
|
|
362
|
-
continue;
|
|
363
|
-
if ('functionCall' in part && isRecord(part.functionCall) && typeof part.functionCall['name'] === 'string') {
|
|
364
|
-
const args = part.functionCall['args'];
|
|
365
|
-
calls.push({
|
|
366
|
-
id: typeof part.functionCall['id'] === 'string' && part.functionCall['id'].length > 0 ? part.functionCall['id'] : `provider-call-${index}`,
|
|
367
|
-
type: 'function',
|
|
368
|
-
function: { name: part.functionCall['name'], arguments: serializeToolArguments(args) },
|
|
369
|
-
...(readProviderMetadata(part) === undefined ? {} : { provider_metadata: readProviderMetadata(part) }),
|
|
370
|
-
});
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
if ('tool_use' in part && isRecord(part.tool_use) && typeof part.tool_use['name'] === 'string') {
|
|
374
|
-
const input = part.tool_use['input'];
|
|
375
|
-
calls.push({
|
|
376
|
-
id: typeof part.tool_use['id'] === 'string' && part.tool_use['id'].length > 0 ? part.tool_use['id'] : `provider-call-${index}`,
|
|
377
|
-
type: 'function',
|
|
378
|
-
function: { name: part.tool_use['name'], arguments: JSON.stringify(input ?? {}) },
|
|
379
|
-
...(readProviderMetadata(part) === undefined ? {} : { provider_metadata: readProviderMetadata(part) }),
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return calls;
|
|
384
|
-
}
|
|
385
|
-
function extractLegacyFunctionCall(value, index) {
|
|
386
|
-
if (!isRecord(value) || typeof value['name'] !== 'string')
|
|
387
|
-
return [];
|
|
388
|
-
const args = value['arguments'];
|
|
389
|
-
return [{
|
|
390
|
-
id: typeof value['id'] === 'string' && value['id'].length > 0 ? value['id'] : `provider-call-${index}`,
|
|
391
|
-
type: 'function',
|
|
392
|
-
function: { name: value['name'], arguments: serializeToolArguments(args) },
|
|
393
|
-
...(readProviderMetadata(value) === undefined ? {} : { provider_metadata: readProviderMetadata(value) }),
|
|
394
|
-
}];
|
|
395
|
-
}
|
|
396
|
-
function serializeToolArguments(value) {
|
|
397
|
-
if (value === undefined)
|
|
398
|
-
return '';
|
|
399
|
-
if (typeof value === 'string')
|
|
400
|
-
return value;
|
|
401
|
-
try {
|
|
402
|
-
return JSON.stringify(value);
|
|
403
|
-
}
|
|
404
|
-
catch {
|
|
405
|
-
return '';
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
function isRecord(value) {
|
|
409
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
410
|
-
}
|
|
411
|
-
function isSseParseError(error) {
|
|
412
|
-
return typeof error === 'object'
|
|
413
|
-
&& error !== null
|
|
414
|
-
&& 'errorCode' in error
|
|
415
|
-
&& error.errorCode === SdkErrorCode.ResponseParseError;
|
|
416
|
-
}
|
|
417
|
-
function textContent(content) {
|
|
418
|
-
if (typeof content === 'string')
|
|
419
|
-
return content;
|
|
420
|
-
if (!Array.isArray(content))
|
|
421
|
-
return '';
|
|
422
|
-
return content.reduce((result, part) => {
|
|
423
|
-
if (typeof part !== 'object' || part === null || !('text' in part))
|
|
424
|
-
return result;
|
|
425
|
-
const text = part.text;
|
|
426
|
-
return result + (typeof text === 'string' ? text : '');
|
|
427
|
-
}, '');
|
|
428
|
-
}
|
|
429
|
-
function textLength(content) {
|
|
430
|
-
if (typeof content === 'string')
|
|
431
|
-
return content.length;
|
|
432
|
-
if (!Array.isArray(content))
|
|
433
|
-
return 0;
|
|
434
|
-
return content.reduce((total, part) => {
|
|
435
|
-
if (typeof part !== 'object' || part === null || !('text' in part))
|
|
436
|
-
return total;
|
|
437
|
-
const text = part.text;
|
|
438
|
-
return total + (typeof text === 'string' ? text.length : 0);
|
|
439
|
-
}, 0);
|
|
440
|
-
}
|
|
441
|
-
function mapUsage(usage) {
|
|
442
|
-
return {
|
|
443
|
-
...(typeof usage.prompt_tokens === 'number' ? { promptTokens: usage.prompt_tokens } : {}),
|
|
444
|
-
...(typeof usage.completion_tokens === 'number' ? { completionTokens: usage.completion_tokens } : {}),
|
|
445
|
-
...(typeof usage.total_tokens === 'number' ? { totalTokens: usage.total_tokens } : {}),
|
|
446
|
-
};
|
|
447
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function resolveCachePolicy(env = process.env) {
|
|
2
|
-
return {
|
|
3
|
-
enabled: parseBoolean(env['LOTAGATE_CACHE_ENABLED'], true),
|
|
4
|
-
modelCatalogTtlMs: readBoundedEnvironmentInteger(env['LOTAGATE_MODEL_CACHE_TTL_SECONDS'], 300, 1, 86_400) * 1_000,
|
|
5
|
-
maxEntryBytes: readBoundedEnvironmentInteger(env['LOTAGATE_CACHE_MAX_ENTRY_BYTES'], 5 * 1024 * 1024, 1_024, 50 * 1024 * 1024),
|
|
6
|
-
maxTotalBytes: readBoundedEnvironmentInteger(env['LOTAGATE_CACHE_MAX_BYTES'], 50 * 1024 * 1024, 1 * 1024 * 1024, 500 * 1024 * 1024),
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function parseBoolean(value, fallback) {
|
|
10
|
-
if (value === undefined)
|
|
11
|
-
return fallback;
|
|
12
|
-
if (value.trim().toLowerCase() === 'true')
|
|
13
|
-
return true;
|
|
14
|
-
if (value.trim().toLowerCase() === 'false')
|
|
15
|
-
return false;
|
|
16
|
-
return fallback;
|
|
17
|
-
}
|
|
18
|
-
import { readBoundedEnvironmentInteger } from '../config/environment-values.js';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CacheStore, CacheWriteOptions } from '../../ports/cache-store.js';
|
|
2
|
-
import type { CachePolicy } from './cache-policy.js';
|
|
3
|
-
export declare class FileCacheStore implements CacheStore {
|
|
4
|
-
private readonly root;
|
|
5
|
-
private readonly policy;
|
|
6
|
-
private readonly now;
|
|
7
|
-
private prunePromise;
|
|
8
|
-
constructor(root: string, policy: CachePolicy, now?: () => number);
|
|
9
|
-
get<T>(namespace: string, key: string): Promise<T | undefined>;
|
|
10
|
-
set<T>(namespace: string, key: string, value: T, options: CacheWriteOptions): Promise<void>;
|
|
11
|
-
delete(namespace: string, key: string): Promise<void>;
|
|
12
|
-
clear(namespace?: string): Promise<void>;
|
|
13
|
-
prune(): Promise<void>;
|
|
14
|
-
private schedulePrune;
|
|
15
|
-
private namespacePath;
|
|
16
|
-
private filePath;
|
|
17
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fsSync from 'node:fs';
|
|
3
|
-
import fs from 'node:fs/promises';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { atomicWriteFile, withFileLock } from '../filesystem/atomic-file-store.js';
|
|
6
|
-
import { isFileNotFound } from '../filesystem/fs-errors.js';
|
|
7
|
-
import { readJsonFileBounded } from '../filesystem/bounded-json-reader.js';
|
|
8
|
-
export class FileCacheStore {
|
|
9
|
-
root;
|
|
10
|
-
policy;
|
|
11
|
-
now;
|
|
12
|
-
prunePromise;
|
|
13
|
-
constructor(root, policy, now = Date.now) {
|
|
14
|
-
this.root = root;
|
|
15
|
-
this.policy = policy;
|
|
16
|
-
this.now = now;
|
|
17
|
-
try {
|
|
18
|
-
fsSync.mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
19
|
-
}
|
|
20
|
-
catch { /* Cache is best effort and must not block CLI startup. */ }
|
|
21
|
-
}
|
|
22
|
-
async get(namespace, key) {
|
|
23
|
-
if (!this.policy.enabled)
|
|
24
|
-
return undefined;
|
|
25
|
-
const filePath = this.filePath(namespace, key);
|
|
26
|
-
try {
|
|
27
|
-
const envelope = await readJsonFileBounded(filePath, this.policy.maxEntryBytes);
|
|
28
|
-
if (envelope.schemaVersion !== 1 || envelope.namespace !== namespace || envelope.keyHash !== hashKey(namespace, key) || typeof envelope.expiresAt !== 'string')
|
|
29
|
-
return undefined;
|
|
30
|
-
if (Date.parse(envelope.expiresAt) <= this.now()) {
|
|
31
|
-
await this.delete(namespace, key);
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
return envelope.value;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (!isFileNotFound(error))
|
|
38
|
-
await this.delete(namespace, key).catch(() => undefined);
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async set(namespace, key, value, options) {
|
|
43
|
-
if (!this.policy.enabled || options.ttlMs <= 0)
|
|
44
|
-
return;
|
|
45
|
-
const envelope = {
|
|
46
|
-
schemaVersion: 1,
|
|
47
|
-
namespace,
|
|
48
|
-
keyHash: hashKey(namespace, key),
|
|
49
|
-
createdAt: new Date(this.now()).toISOString(),
|
|
50
|
-
expiresAt: new Date(this.now() + options.ttlMs).toISOString(),
|
|
51
|
-
value,
|
|
52
|
-
};
|
|
53
|
-
const data = `${JSON.stringify(envelope)}\n`;
|
|
54
|
-
if (Buffer.byteLength(data, 'utf8') > this.policy.maxEntryBytes)
|
|
55
|
-
return;
|
|
56
|
-
const filePath = this.filePath(namespace, key);
|
|
57
|
-
await withFileLock(filePath, () => atomicWriteFile(filePath, data));
|
|
58
|
-
this.schedulePrune();
|
|
59
|
-
}
|
|
60
|
-
async delete(namespace, key) {
|
|
61
|
-
await fs.rm(this.filePath(namespace, key), { force: true });
|
|
62
|
-
}
|
|
63
|
-
async clear(namespace) {
|
|
64
|
-
await fs.rm(namespace === undefined ? this.root : this.namespacePath(namespace), { recursive: true, force: true });
|
|
65
|
-
}
|
|
66
|
-
async prune() {
|
|
67
|
-
if (!this.policy.enabled)
|
|
68
|
-
return;
|
|
69
|
-
const files = await listFiles(this.root);
|
|
70
|
-
const entries = [];
|
|
71
|
-
for (const filePath of files) {
|
|
72
|
-
try {
|
|
73
|
-
const stat = await fs.stat(filePath);
|
|
74
|
-
const value = await readJsonFileBounded(filePath, this.policy.maxEntryBytes);
|
|
75
|
-
if (value.schemaVersion !== 1 || typeof value.expiresAt !== 'string' || Date.parse(value.expiresAt) <= this.now()) {
|
|
76
|
-
await fs.rm(filePath, { force: true });
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
entries.push({ filePath, size: stat.size, modifiedAt: stat.mtimeMs });
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
await fs.rm(filePath, { force: true });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
let total = entries.reduce((sum, entry) => sum + entry.size, 0);
|
|
86
|
-
for (const entry of entries.sort((left, right) => left.modifiedAt - right.modifiedAt)) {
|
|
87
|
-
if (total <= this.policy.maxTotalBytes)
|
|
88
|
-
break;
|
|
89
|
-
await fs.rm(entry.filePath, { force: true });
|
|
90
|
-
total -= entry.size;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
schedulePrune() {
|
|
94
|
-
if (this.prunePromise !== undefined)
|
|
95
|
-
return;
|
|
96
|
-
this.prunePromise = this.prune().catch(() => undefined).finally(() => { this.prunePromise = undefined; });
|
|
97
|
-
}
|
|
98
|
-
namespacePath(namespace) { return path.join(this.root, encodeNamespace(namespace)); }
|
|
99
|
-
filePath(namespace, key) { return path.join(this.namespacePath(namespace), `${hashKey(namespace, key)}.json`); }
|
|
100
|
-
}
|
|
101
|
-
function hashKey(namespace, key) { return crypto.createHash('sha256').update(`${namespace}\0${key}`).digest('hex'); }
|
|
102
|
-
function encodeNamespace(namespace) { return Buffer.from(namespace, 'utf8').toString('base64url'); }
|
|
103
|
-
async function listFiles(root) {
|
|
104
|
-
try {
|
|
105
|
-
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
106
|
-
const files = [];
|
|
107
|
-
for (const entry of entries) {
|
|
108
|
-
const candidate = path.join(root, entry.name);
|
|
109
|
-
if (entry.isDirectory())
|
|
110
|
-
files.push(...await listFiles(candidate));
|
|
111
|
-
else if (entry.isFile() && entry.name.endsWith('.json'))
|
|
112
|
-
files.push(candidate);
|
|
113
|
-
}
|
|
114
|
-
return files;
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
if (isFileNotFound(error))
|
|
118
|
-
return [];
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ClipboardAdapter, ClipboardImage } from '../../ports/clipboard-adapter.js';
|
|
2
|
-
import { type HostPlatformContext } from '../platform/host-platform.js';
|
|
3
|
-
export declare function createClipboardAdapter(platform?: HostPlatformContext): ClipboardAdapter;
|
|
4
|
-
export declare class ProcessClipboardAdapter implements ClipboardAdapter {
|
|
5
|
-
private readonly command;
|
|
6
|
-
private readonly args;
|
|
7
|
-
private readonly mimeType;
|
|
8
|
-
private readonly platform;
|
|
9
|
-
constructor(command: string, args: readonly string[], mimeType: string, platform?: HostPlatformContext);
|
|
10
|
-
readImage(): Promise<ClipboardImage | undefined>;
|
|
11
|
-
}
|