byterover-cli 0.4.1 → 1.0.0
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 +1 -9
- package/dist/commands/curate.d.ts +1 -3
- package/dist/commands/curate.js +14 -51
- package/dist/commands/main.d.ts +8 -0
- package/dist/commands/main.js +29 -8
- package/dist/commands/query.d.ts +1 -3
- package/dist/commands/query.js +8 -35
- package/dist/config/context-tree-domains.d.ts +5 -0
- package/dist/config/context-tree-domains.js +6 -1
- package/dist/config/environment.js +9 -9
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +18 -0
- package/dist/core/domain/cipher/agent/agent-info.d.ts +199 -0
- package/dist/core/domain/cipher/agent/agent-info.js +143 -0
- package/dist/core/domain/cipher/agent/agent-registry.d.ts +96 -0
- package/dist/core/domain/cipher/agent/agent-registry.js +254 -0
- package/dist/core/domain/cipher/agent/index.d.ts +4 -1
- package/dist/core/domain/cipher/agent/index.js +7 -1
- package/dist/core/domain/cipher/agent-events/types.d.ts +355 -2
- package/dist/core/domain/cipher/agent-events/types.js +11 -0
- package/dist/core/domain/cipher/errors/error-normalizer.d.ts +156 -0
- package/dist/core/domain/cipher/errors/error-normalizer.js +379 -0
- package/dist/core/domain/cipher/errors/file-system-error.d.ts +2 -1
- package/dist/core/domain/cipher/errors/file-system-error.js +3 -2
- package/dist/core/domain/cipher/errors/system-prompt-error-codes.d.ts +79 -0
- package/dist/core/domain/cipher/errors/system-prompt-error-codes.js +80 -0
- package/dist/core/domain/cipher/errors/system-prompt-error.d.ts +114 -0
- package/dist/core/domain/cipher/errors/system-prompt-error.js +144 -0
- package/dist/core/domain/cipher/file-system/types.d.ts +57 -0
- package/dist/core/domain/cipher/llm/error-codes.d.ts +51 -0
- package/dist/core/domain/cipher/llm/error-codes.js +51 -0
- package/dist/core/domain/cipher/llm/index.d.ts +9 -0
- package/dist/core/domain/cipher/llm/index.js +13 -0
- package/dist/core/domain/cipher/llm/registry.d.ts +113 -0
- package/dist/core/domain/cipher/llm/registry.js +244 -0
- package/dist/core/domain/cipher/llm/schemas.d.ts +155 -0
- package/dist/core/domain/cipher/llm/schemas.js +151 -0
- package/dist/core/domain/cipher/llm/types.d.ts +121 -0
- package/dist/core/domain/cipher/llm/types.js +60 -0
- package/dist/core/domain/cipher/storage/message-storage-types.d.ts +114 -5
- package/dist/core/domain/cipher/streaming/types.d.ts +119 -0
- package/dist/core/domain/cipher/streaming/types.js +16 -0
- package/dist/core/domain/cipher/system-prompt/types.d.ts +44 -0
- package/dist/core/domain/cipher/todos/types.d.ts +34 -0
- package/dist/core/domain/cipher/tools/constants.d.ts +5 -2
- package/dist/core/domain/cipher/tools/constants.js +5 -2
- package/dist/core/domain/cipher/tools/types.d.ts +31 -0
- package/dist/core/domain/errors/connection-error.d.ts +33 -0
- package/dist/core/domain/errors/connection-error.js +54 -0
- package/dist/core/domain/errors/core-process-error.d.ts +27 -0
- package/dist/core/domain/errors/core-process-error.js +43 -0
- package/dist/core/domain/errors/task-error.d.ts +64 -0
- package/dist/core/domain/errors/task-error.js +116 -0
- package/dist/core/domain/errors/transport-error.d.ts +72 -0
- package/dist/core/domain/errors/transport-error.js +114 -0
- package/dist/core/domain/instance/index.d.ts +1 -0
- package/dist/core/domain/instance/index.js +1 -0
- package/dist/core/domain/instance/types.d.ts +57 -0
- package/dist/core/domain/instance/types.js +72 -0
- package/dist/core/domain/knowledge/directory-manager.d.ts +16 -0
- package/dist/core/domain/knowledge/directory-manager.js +31 -0
- package/dist/core/domain/transport/index.d.ts +2 -0
- package/dist/core/domain/transport/index.js +2 -0
- package/dist/core/domain/transport/schemas.d.ts +1149 -0
- package/dist/core/domain/transport/schemas.js +554 -0
- package/dist/core/domain/transport/types.d.ts +67 -0
- package/dist/core/domain/transport/types.js +7 -0
- package/dist/core/interfaces/cipher/cipher-services.d.ts +15 -3
- package/dist/core/interfaces/cipher/i-chat-session.d.ts +47 -5
- package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +39 -4
- package/dist/core/interfaces/cipher/i-content-generator.d.ts +3 -5
- package/dist/core/interfaces/cipher/i-file-system.d.ts +12 -1
- package/dist/core/interfaces/cipher/i-llm-service.d.ts +4 -5
- package/dist/core/interfaces/cipher/i-todo-storage.d.ts +24 -0
- package/dist/core/interfaces/cipher/i-todo-storage.js +1 -0
- package/dist/core/interfaces/cipher/i-tool-plugin.d.ts +90 -0
- package/dist/core/interfaces/cipher/i-tool-plugin.js +1 -0
- package/dist/core/interfaces/cipher/i-tool-provider.d.ts +3 -2
- package/dist/core/interfaces/cipher/i-tool-scheduler.d.ts +4 -0
- package/dist/core/interfaces/cipher/index.d.ts +35 -0
- package/dist/core/interfaces/cipher/index.js +11 -0
- package/dist/core/interfaces/cipher/message-factory.d.ts +155 -0
- package/dist/core/interfaces/cipher/message-factory.js +252 -0
- package/dist/core/interfaces/cipher/message-type-guards.d.ts +139 -0
- package/dist/core/interfaces/cipher/message-type-guards.js +173 -0
- package/dist/core/interfaces/cipher/message-types.d.ts +279 -5
- package/dist/core/interfaces/cipher/message-types.js +6 -0
- package/dist/core/interfaces/cipher/sanitization-types.d.ts +147 -0
- package/dist/core/interfaces/cipher/sanitization-types.js +46 -0
- package/dist/core/interfaces/executor/i-curate-executor.d.ts +34 -0
- package/dist/core/interfaces/executor/i-curate-executor.js +1 -0
- package/dist/core/interfaces/executor/i-query-executor.d.ts +32 -0
- package/dist/core/interfaces/executor/i-query-executor.js +1 -0
- package/dist/core/interfaces/executor/index.d.ts +2 -0
- package/dist/core/interfaces/executor/index.js +2 -0
- package/dist/core/interfaces/instance/i-instance-discovery.d.ts +45 -0
- package/dist/core/interfaces/instance/i-instance-discovery.js +1 -0
- package/dist/core/interfaces/instance/i-instance-manager.d.ts +58 -0
- package/dist/core/interfaces/instance/i-instance-manager.js +1 -0
- package/dist/core/interfaces/instance/index.d.ts +2 -0
- package/dist/core/interfaces/instance/index.js +2 -0
- package/dist/core/interfaces/noop-implementations.d.ts +53 -0
- package/dist/core/interfaces/noop-implementations.js +62 -0
- package/dist/core/interfaces/transport/i-transport-client.d.ts +97 -0
- package/dist/core/interfaces/transport/i-transport-client.js +1 -0
- package/dist/core/interfaces/transport/i-transport-server.d.ts +93 -0
- package/dist/core/interfaces/transport/i-transport-server.js +1 -0
- package/dist/core/interfaces/transport/index.d.ts +2 -0
- package/dist/core/interfaces/transport/index.js +2 -0
- package/dist/infra/cipher/agent/agent-error-codes.d.ts +16 -0
- package/dist/infra/cipher/agent/agent-error-codes.js +17 -0
- package/dist/infra/cipher/agent/agent-error.d.ts +54 -0
- package/dist/infra/cipher/agent/agent-error.js +79 -0
- package/dist/infra/cipher/agent/agent-schemas.d.ts +264 -0
- package/dist/infra/cipher/agent/agent-schemas.js +97 -0
- package/dist/infra/cipher/agent/agent-state-manager.d.ts +140 -0
- package/dist/infra/cipher/agent/agent-state-manager.js +275 -0
- package/dist/infra/cipher/agent/base-agent.d.ts +118 -0
- package/dist/infra/cipher/agent/base-agent.js +240 -0
- package/dist/infra/cipher/agent/cipher-agent.d.ts +165 -0
- package/dist/infra/cipher/agent/cipher-agent.js +546 -0
- package/dist/infra/cipher/agent/index.d.ts +22 -0
- package/dist/infra/cipher/agent/index.js +24 -0
- package/dist/infra/cipher/agent/service-initializer.d.ts +79 -0
- package/dist/infra/cipher/{agent-service-factory.js → agent/service-initializer.js} +117 -68
- package/dist/infra/cipher/agent/types.d.ts +35 -0
- package/dist/infra/cipher/agent/types.js +1 -0
- package/dist/infra/cipher/blob/blob-reference-resolver.d.ts +107 -0
- package/dist/infra/cipher/blob/blob-reference-resolver.js +228 -0
- package/dist/infra/cipher/blob/blob-reference-utils.d.ts +117 -0
- package/dist/infra/cipher/blob/blob-reference-utils.js +230 -0
- package/dist/infra/cipher/consumer/consumer-lock.js +1 -0
- package/dist/infra/cipher/consumer/consumer-service.js +1 -0
- package/dist/infra/cipher/consumer/execution-consumer.d.ts +6 -1
- package/dist/infra/cipher/consumer/execution-consumer.js +54 -16
- package/dist/infra/cipher/consumer/index.d.ts +1 -1
- package/dist/infra/cipher/consumer/index.js +2 -1
- package/dist/infra/cipher/consumer/queue-polling-service.js +1 -0
- package/dist/infra/cipher/file-system/binary-utils.d.ts +43 -0
- package/dist/infra/cipher/file-system/binary-utils.js +164 -0
- package/dist/infra/cipher/file-system/context-tree-file-system-factory.d.ts +9 -0
- package/dist/infra/cipher/file-system/context-tree-file-system-factory.js +24 -0
- package/dist/infra/cipher/file-system/file-system-service.d.ts +17 -1
- package/dist/infra/cipher/file-system/file-system-service.js +327 -36
- package/dist/infra/cipher/file-system/path-validator.d.ts +32 -0
- package/dist/infra/cipher/file-system/path-validator.js +111 -6
- package/dist/infra/cipher/interactive-loop.js +41 -33
- package/dist/infra/cipher/llm/capability-cache.d.ts +87 -0
- package/dist/infra/cipher/llm/capability-cache.js +125 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +32 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.js +44 -3
- package/dist/infra/cipher/llm/context/compression/enhanced-compaction.d.ts +112 -0
- package/dist/infra/cipher/llm/context/compression/enhanced-compaction.js +175 -0
- package/dist/infra/cipher/llm/context/compression/filter-compacted.d.ts +83 -0
- package/dist/infra/cipher/llm/context/compression/filter-compacted.js +150 -0
- package/dist/infra/cipher/llm/context/compression/index.d.ts +5 -0
- package/dist/infra/cipher/llm/context/compression/index.js +6 -0
- package/dist/infra/cipher/llm/context/compression/reactive-overflow.d.ts +107 -0
- package/dist/infra/cipher/llm/context/compression/reactive-overflow.js +272 -0
- package/dist/infra/cipher/llm/context/context-manager.d.ts +47 -1
- package/dist/infra/cipher/llm/context/context-manager.js +129 -0
- package/dist/infra/cipher/llm/context/utils.js +17 -4
- package/dist/infra/cipher/llm/generators/byterover-content-generator.js +4 -2
- package/dist/infra/cipher/llm/internal-llm-service.d.ts +50 -17
- package/dist/infra/cipher/llm/internal-llm-service.js +273 -50
- package/dist/infra/cipher/llm/openrouter-llm-service.d.ts +6 -8
- package/dist/infra/cipher/llm/openrouter-llm-service.js +14 -16
- package/dist/infra/cipher/llm/retry/retry-policy.d.ts +1 -0
- package/dist/infra/cipher/llm/retry/retry-policy.js +11 -0
- package/dist/infra/cipher/llm/retry/retry-with-backoff.js +3 -2
- package/dist/infra/cipher/llm/sanitization/base64-utils.d.ts +102 -0
- package/dist/infra/cipher/llm/sanitization/base64-utils.js +182 -0
- package/dist/infra/cipher/llm/sanitization/index.d.ts +12 -0
- package/dist/infra/cipher/llm/sanitization/index.js +13 -0
- package/dist/infra/cipher/llm/sanitization/tool-sanitizer.d.ts +74 -0
- package/dist/infra/cipher/llm/sanitization/tool-sanitizer.js +398 -0
- package/dist/infra/cipher/llm/stream-processor.d.ts +158 -0
- package/dist/infra/cipher/llm/stream-processor.js +276 -0
- package/dist/infra/cipher/llm/tokenizers/claude-tokenizer.d.ts +13 -20
- package/dist/infra/cipher/llm/tokenizers/claude-tokenizer.js +17 -24
- package/dist/infra/cipher/llm/tokenizers/gemini-tokenizer.d.ts +12 -11
- package/dist/infra/cipher/llm/tokenizers/gemini-tokenizer.js +16 -15
- package/dist/infra/cipher/llm/tokenizers/openrouter-tokenizer.d.ts +15 -7
- package/dist/infra/cipher/llm/tokenizers/openrouter-tokenizer.js +22 -10
- package/dist/infra/cipher/llm/tool-output-processor.d.ts +51 -0
- package/dist/infra/cipher/llm/tool-output-processor.js +139 -0
- package/dist/infra/cipher/process/command-validator.d.ts +23 -0
- package/dist/infra/cipher/process/command-validator.js +75 -0
- package/dist/infra/cipher/process/path-utils.d.ts +66 -0
- package/dist/infra/cipher/process/path-utils.js +94 -0
- package/dist/infra/cipher/process/process-service.d.ts +32 -0
- package/dist/infra/cipher/process/process-service.js +98 -17
- package/dist/infra/cipher/session/chat-session.d.ts +56 -7
- package/dist/infra/cipher/session/chat-session.js +163 -13
- package/dist/infra/cipher/session/index.d.ts +1 -0
- package/dist/infra/cipher/session/index.js +2 -0
- package/dist/infra/cipher/session/message-queue.d.ts +65 -0
- package/dist/infra/cipher/session/message-queue.js +90 -0
- package/dist/infra/cipher/session/session-manager.d.ts +106 -5
- package/dist/infra/cipher/session/session-manager.js +254 -7
- package/dist/infra/cipher/session/session-status.d.ts +137 -0
- package/dist/infra/cipher/session/session-status.js +184 -0
- package/dist/infra/cipher/session/title-generator.d.ts +8 -0
- package/dist/infra/cipher/session/title-generator.js +31 -0
- package/dist/infra/cipher/storage/message-storage-service.d.ts +65 -2
- package/dist/infra/cipher/storage/message-storage-service.js +300 -54
- package/dist/infra/cipher/storage/tool-part-factory.d.ts +116 -0
- package/dist/infra/cipher/storage/tool-part-factory.js +197 -0
- package/dist/infra/cipher/system-prompt/contributor-schemas.d.ts +516 -0
- package/dist/infra/cipher/system-prompt/contributor-schemas.js +85 -0
- package/dist/infra/cipher/system-prompt/contributors/agent-prompt-contributor.d.ts +59 -0
- package/dist/infra/cipher/system-prompt/contributors/agent-prompt-contributor.js +131 -0
- package/dist/infra/cipher/system-prompt/contributors/companion-contributor.d.ts +54 -0
- package/dist/infra/cipher/system-prompt/contributors/companion-contributor.js +107 -0
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +68 -0
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +179 -0
- package/dist/infra/cipher/system-prompt/contributors/datetime-contributor.d.ts +25 -0
- package/dist/infra/cipher/system-prompt/contributors/datetime-contributor.js +29 -0
- package/dist/infra/cipher/system-prompt/contributors/environment-contributor.d.ts +25 -0
- package/dist/infra/cipher/system-prompt/contributors/environment-contributor.js +54 -0
- package/dist/infra/cipher/system-prompt/contributors/file-contributor.d.ts +60 -0
- package/dist/infra/cipher/system-prompt/contributors/file-contributor.js +128 -0
- package/dist/infra/cipher/system-prompt/contributors/index.d.ts +13 -0
- package/dist/infra/cipher/system-prompt/contributors/index.js +8 -0
- package/dist/infra/cipher/system-prompt/contributors/memory-contributor.d.ts +40 -0
- package/dist/infra/cipher/system-prompt/contributors/memory-contributor.js +56 -0
- package/dist/infra/cipher/system-prompt/contributors/static-contributor.d.ts +26 -0
- package/dist/infra/cipher/system-prompt/contributors/static-contributor.js +31 -0
- package/dist/infra/cipher/system-prompt/environment-context-builder.d.ts +112 -0
- package/dist/infra/cipher/system-prompt/environment-context-builder.js +256 -0
- package/dist/infra/cipher/system-prompt/prompt-cache.d.ts +102 -0
- package/dist/infra/cipher/system-prompt/prompt-cache.js +156 -0
- package/dist/infra/cipher/system-prompt/schemas.d.ts +151 -0
- package/dist/infra/cipher/system-prompt/schemas.js +94 -0
- package/dist/infra/cipher/system-prompt/system-prompt-manager.d.ts +136 -0
- package/dist/infra/cipher/system-prompt/system-prompt-manager.js +307 -0
- package/dist/infra/cipher/todos/todo-storage-service.d.ts +26 -0
- package/dist/infra/cipher/todos/todo-storage-service.js +28 -0
- package/dist/infra/cipher/tools/core-tool-scheduler.js +5 -1
- package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
- package/dist/infra/cipher/tools/implementations/bash-exec-tool.d.ts +1 -0
- package/dist/infra/cipher/tools/implementations/bash-exec-tool.js +27 -10
- package/dist/infra/cipher/tools/implementations/bash-output-tool.js +1 -5
- package/dist/infra/cipher/tools/implementations/batch-tool.d.ts +12 -0
- package/dist/infra/cipher/tools/implementations/batch-tool.js +142 -0
- package/dist/infra/cipher/tools/implementations/curate-tool.js +195 -68
- package/dist/infra/cipher/tools/implementations/list-directory-tool.d.ts +12 -0
- package/dist/infra/cipher/tools/implementations/list-directory-tool.js +52 -0
- package/dist/infra/cipher/tools/implementations/read-file-tool.d.ts +8 -1
- package/dist/infra/cipher/tools/implementations/read-file-tool.js +17 -7
- package/dist/infra/cipher/tools/implementations/read-todos-tool.d.ts +11 -0
- package/dist/infra/cipher/tools/implementations/read-todos-tool.js +39 -0
- package/dist/infra/cipher/tools/implementations/{detect-domains-tool.d.ts → spec-analyze-tool.d.ts} +1 -1
- package/dist/infra/cipher/tools/implementations/{detect-domains-tool.js → spec-analyze-tool.js} +9 -7
- package/dist/infra/cipher/tools/implementations/task-tool.d.ts +34 -0
- package/dist/infra/cipher/tools/implementations/task-tool.js +207 -0
- package/dist/infra/cipher/tools/implementations/write-todos-tool.d.ts +4 -1
- package/dist/infra/cipher/tools/implementations/write-todos-tool.js +19 -63
- package/dist/infra/cipher/tools/index.d.ts +1 -1
- package/dist/infra/cipher/tools/index.js +1 -1
- package/dist/infra/cipher/tools/plugins/index.d.ts +3 -0
- package/dist/infra/cipher/tools/plugins/index.js +2 -0
- package/dist/infra/cipher/tools/plugins/logging-plugin.d.ts +28 -0
- package/dist/infra/cipher/tools/plugins/logging-plugin.js +66 -0
- package/dist/infra/cipher/tools/plugins/plugin-manager.d.ts +81 -0
- package/dist/infra/cipher/tools/plugins/plugin-manager.js +122 -0
- package/dist/infra/cipher/tools/streaming/index.d.ts +1 -0
- package/dist/infra/cipher/tools/streaming/index.js +1 -0
- package/dist/infra/cipher/tools/streaming/metadata-handler.d.ts +31 -0
- package/dist/infra/cipher/tools/streaming/metadata-handler.js +39 -0
- package/dist/infra/cipher/tools/tool-description-loader.d.ts +57 -0
- package/dist/infra/cipher/tools/tool-description-loader.js +108 -0
- package/dist/infra/cipher/tools/tool-manager.d.ts +38 -4
- package/dist/infra/cipher/tools/tool-manager.js +107 -11
- package/dist/infra/cipher/tools/tool-provider-getter.d.ts +6 -0
- package/dist/infra/cipher/tools/tool-provider-getter.js +1 -0
- package/dist/infra/cipher/tools/tool-provider.d.ts +32 -7
- package/dist/infra/cipher/tools/tool-provider.js +81 -25
- package/dist/infra/cipher/tools/tool-registry.d.ts +23 -0
- package/dist/infra/cipher/tools/tool-registry.js +58 -16
- package/dist/infra/context-tree/file-context-tree-snapshot-service.js +10 -4
- package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +4 -3
- package/dist/infra/context-tree/file-context-tree-writer-service.js +6 -4
- package/dist/infra/context-tree/path-utils.d.ts +7 -0
- package/dist/infra/context-tree/path-utils.js +7 -0
- package/dist/infra/core/executors/curate-executor.d.ts +35 -0
- package/dist/infra/core/executors/curate-executor.js +123 -0
- package/dist/infra/core/executors/index.d.ts +2 -0
- package/dist/infra/core/executors/index.js +2 -0
- package/dist/infra/core/executors/query-executor.d.ts +23 -0
- package/dist/infra/core/executors/query-executor.js +51 -0
- package/dist/infra/core/task-processor.d.ts +81 -0
- package/dist/infra/core/task-processor.js +115 -0
- package/dist/infra/instance/file-instance-discovery.d.ts +31 -0
- package/dist/infra/instance/file-instance-discovery.js +84 -0
- package/dist/infra/instance/file-instance-manager.d.ts +46 -0
- package/dist/infra/instance/file-instance-manager.js +123 -0
- package/dist/infra/instance/index.d.ts +3 -0
- package/dist/infra/instance/index.js +3 -0
- package/dist/infra/instance/process-utils.d.ts +14 -0
- package/dist/infra/instance/process-utils.js +39 -0
- package/dist/infra/process/agent-worker.d.ts +20 -0
- package/dist/infra/process/agent-worker.js +602 -0
- package/dist/infra/process/index.d.ts +12 -0
- package/dist/infra/process/index.js +11 -0
- package/dist/infra/process/ipc-types.d.ts +55 -0
- package/dist/infra/process/ipc-types.js +12 -0
- package/dist/infra/process/process-manager.d.ts +154 -0
- package/dist/infra/process/process-manager.js +471 -0
- package/dist/infra/process/task-queue-manager.d.ts +123 -0
- package/dist/infra/process/task-queue-manager.js +226 -0
- package/dist/infra/process/transport-handlers.d.ts +124 -0
- package/dist/infra/process/transport-handlers.js +348 -0
- package/dist/infra/process/transport-worker.d.ts +20 -0
- package/dist/infra/process/transport-worker.js +168 -0
- package/dist/infra/repl/commands/curate-command.js +0 -5
- package/dist/infra/repl/commands/query-command.js +0 -3
- package/dist/infra/repl/repl-startup.d.ts +4 -0
- package/dist/infra/repl/repl-startup.js +8 -1
- package/dist/infra/repl/transport-client-helper.d.ts +9 -0
- package/dist/infra/repl/transport-client-helper.js +96 -0
- package/dist/infra/transport/index.d.ts +4 -0
- package/dist/infra/transport/index.js +4 -0
- package/dist/infra/transport/port-utils.d.ts +42 -0
- package/dist/infra/transport/port-utils.js +84 -0
- package/dist/infra/transport/socket-io-transport-client.d.ts +45 -0
- package/dist/infra/transport/socket-io-transport-client.js +270 -0
- package/dist/infra/transport/socket-io-transport-server.d.ts +35 -0
- package/dist/infra/transport/socket-io-transport-server.js +207 -0
- package/dist/infra/transport/transport-client-factory.d.ts +76 -0
- package/dist/infra/transport/transport-client-factory.js +168 -0
- package/dist/infra/transport/transport-factory.d.ts +33 -0
- package/dist/infra/transport/transport-factory.js +59 -0
- package/dist/infra/usecase/curate-use-case.d.ts +8 -55
- package/dist/infra/usecase/curate-use-case.js +71 -262
- package/dist/infra/usecase/init-use-case.js +3 -2
- package/dist/infra/usecase/query-use-case.d.ts +18 -45
- package/dist/infra/usecase/query-use-case.js +250 -326
- package/dist/infra/usecase/status-use-case.js +1 -1
- package/dist/resources/prompts/{curate-context-tree-curation.yml → curate.yml} +25 -22
- package/dist/resources/prompts/explore.yml +78 -0
- package/dist/resources/prompts/plan.yml +114 -0
- package/dist/resources/prompts/reflection.yml +1 -1
- package/dist/resources/prompts/system-prompt.yml +15 -8
- package/dist/resources/prompts/tool-outputs.yml +0 -5
- package/dist/resources/tools/bash_exec.txt +98 -0
- package/dist/resources/tools/bash_output.txt +40 -0
- package/dist/resources/tools/batch.txt +28 -0
- package/dist/resources/tools/create_knowledge_topic.txt +23 -0
- package/dist/resources/tools/curate.txt +22 -0
- package/dist/resources/tools/delete_memory.txt +1 -0
- package/dist/resources/tools/detect_domains.txt +11 -0
- package/dist/resources/tools/edit_file.txt +1 -0
- package/dist/resources/tools/edit_memory.txt +1 -0
- package/dist/resources/tools/glob_files.txt +20 -0
- package/dist/resources/tools/grep_content.txt +18 -0
- package/dist/resources/tools/kill_process.txt +16 -0
- package/dist/resources/tools/list_directory.txt +16 -0
- package/dist/resources/tools/list_memories.txt +1 -0
- package/dist/resources/tools/read_file.txt +31 -0
- package/dist/resources/tools/read_memory.txt +1 -0
- package/dist/resources/tools/read_todos.txt +17 -0
- package/dist/resources/tools/search_history.txt +1 -0
- package/dist/resources/tools/task.txt +23 -0
- package/dist/resources/tools/write_file.txt +1 -0
- package/dist/resources/tools/write_memory.txt +1 -0
- package/dist/resources/tools/write_todos.txt +29 -0
- package/dist/tui/app.js +9 -13
- package/dist/tui/components/command-details.d.ts +14 -0
- package/dist/tui/components/command-details.js +35 -0
- package/dist/tui/components/execution/execution-changes.d.ts +5 -0
- package/dist/tui/components/execution/execution-changes.js +19 -4
- package/dist/tui/components/execution/execution-content.d.ts +4 -2
- package/dist/tui/components/execution/execution-content.js +26 -13
- package/dist/tui/components/execution/execution-input.js +3 -3
- package/dist/tui/components/execution/execution-progress.d.ts +2 -2
- package/dist/tui/components/execution/execution-progress.js +8 -6
- package/dist/tui/components/execution/log-item.d.ts +3 -4
- package/dist/tui/components/execution/log-item.js +2 -5
- package/dist/tui/components/footer.js +9 -4
- package/dist/tui/components/header.d.ts +3 -3
- package/dist/tui/components/header.js +5 -3
- package/dist/tui/components/index.d.ts +1 -0
- package/dist/tui/components/index.js +1 -0
- package/dist/tui/components/onboarding/copyable-prompt.d.ts +5 -3
- package/dist/tui/components/onboarding/copyable-prompt.js +7 -8
- package/dist/tui/components/onboarding/onboarding-flow.js +35 -25
- package/dist/tui/components/scrollable-list.js +12 -10
- package/dist/tui/components/suggestions.js +39 -41
- package/dist/tui/components/tab-bar.d.ts +2 -1
- package/dist/tui/components/tab-bar.js +3 -4
- package/dist/tui/constants.d.ts +0 -5
- package/dist/tui/constants.js +0 -5
- package/dist/tui/contexts/auth-context.js +9 -2
- package/dist/tui/contexts/{use-commands.js → commands-context.js} +3 -3
- package/dist/tui/contexts/index.d.ts +6 -1
- package/dist/tui/contexts/index.js +6 -1
- package/dist/tui/contexts/onboarding-context.d.ts +1 -1
- package/dist/tui/contexts/onboarding-context.js +9 -9
- package/dist/tui/contexts/tasks-context.d.ts +84 -0
- package/dist/tui/contexts/tasks-context.js +218 -0
- package/dist/tui/contexts/transport-context.d.ts +29 -0
- package/dist/tui/contexts/transport-context.js +82 -0
- package/dist/tui/hooks/index.d.ts +10 -6
- package/dist/tui/hooks/index.js +7 -6
- package/dist/tui/hooks/use-activity-logs.d.ts +3 -11
- package/dist/tui/hooks/use-activity-logs.js +87 -34
- package/dist/tui/hooks/use-auth-polling.d.ts +24 -0
- package/dist/tui/hooks/use-auth-polling.js +104 -0
- package/dist/tui/hooks/use-slash-command-processor.js +0 -1
- package/dist/tui/hooks/use-slash-completion.js +1 -1
- package/dist/tui/hooks/use-tab-navigation.d.ts +2 -1
- package/dist/tui/hooks/use-tab-navigation.js +16 -7
- package/dist/tui/hooks/use-terminal-breakpoint.d.ts +21 -0
- package/dist/tui/hooks/use-terminal-breakpoint.js +38 -0
- package/dist/tui/hooks/use-ui-heights.d.ts +120 -0
- package/dist/tui/hooks/use-ui-heights.js +88 -0
- package/dist/tui/providers/app-providers.js +2 -6
- package/dist/tui/types/commands.d.ts +0 -26
- package/dist/tui/types/index.d.ts +1 -1
- package/dist/tui/types/ui.d.ts +9 -4
- package/dist/tui/utils/line.d.ts +11 -0
- package/dist/tui/utils/line.js +16 -0
- package/dist/tui/utils/log.d.ts +27 -0
- package/dist/tui/utils/log.js +114 -0
- package/dist/tui/views/command-view.d.ts +7 -0
- package/dist/tui/views/command-view.js +103 -80
- package/dist/tui/views/login-view.js +7 -4
- package/dist/tui/views/logs-view.d.ts +13 -0
- package/dist/tui/views/logs-view.js +27 -52
- package/dist/utils/connection-error-handler.d.ts +16 -0
- package/dist/utils/connection-error-handler.js +49 -0
- package/dist/utils/crash-log.d.ts +14 -0
- package/dist/utils/crash-log.js +19 -0
- package/dist/utils/file-helpers.d.ts +14 -0
- package/dist/utils/file-helpers.js +21 -0
- package/dist/utils/global-logs-path.d.ts +11 -0
- package/dist/utils/global-logs-path.js +37 -0
- package/dist/utils/process-logger.d.ts +53 -0
- package/dist/utils/process-logger.js +253 -0
- package/dist/utils/sandbox-detector.d.ts +31 -0
- package/dist/utils/sandbox-detector.js +122 -0
- package/oclif.manifest.json +10 -198
- package/package.json +5 -1
- package/dist/commands/cipher-agent/run.d.ts +0 -142
- package/dist/commands/cipher-agent/run.js +0 -555
- package/dist/commands/cipher-agent/set-prompt.d.ts +0 -16
- package/dist/commands/cipher-agent/set-prompt.js +0 -58
- package/dist/commands/cipher-agent/show-prompt.d.ts +0 -13
- package/dist/commands/cipher-agent/show-prompt.js +0 -53
- package/dist/commands/foo.d.ts +0 -14
- package/dist/commands/foo.js +0 -66
- package/dist/infra/cipher/agent-service-factory.d.ts +0 -93
- package/dist/infra/cipher/cipher-agent-state-manager.d.ts +0 -63
- package/dist/infra/cipher/cipher-agent-state-manager.js +0 -108
- package/dist/infra/cipher/cipher-agent.d.ts +0 -182
- package/dist/infra/cipher/cipher-agent.js +0 -317
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +0 -106
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +0 -297
- package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.d.ts +0 -7
- package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +0 -424
- package/dist/resources/prompts/modes/autonomous.yml +0 -9
- package/dist/resources/prompts/query-context-tree-retrieval.yml +0 -48
- package/dist/tui/contexts/consumer.d.ts +0 -31
- package/dist/tui/contexts/consumer.js +0 -56
- package/dist/tui/hooks/use-consumer.d.ts +0 -12
- package/dist/tui/hooks/use-consumer.js +0 -50
- package/dist/tui/hooks/use-queue-polling.d.ts +0 -31
- package/dist/tui/hooks/use-queue-polling.js +0 -90
- /package/dist/tui/contexts/{use-commands.d.ts → commands-context.d.ts} +0 -0
- /package/dist/tui/contexts/{use-mode.d.ts → mode-context.d.ts} +0 -0
- /package/dist/tui/contexts/{use-mode.js → mode-context.js} +0 -0
- /package/dist/tui/contexts/{use-theme.d.ts → theme-context.d.ts} +0 -0
- /package/dist/tui/contexts/{use-theme.js → theme-context.js} +0 -0
|
@@ -1,18 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal representation of messages in a conversation.
|
|
3
3
|
* Standardizes message format across different LLM providers.
|
|
4
|
+
*
|
|
5
|
+
* Based on OpenCode's structured message parts pattern with:
|
|
6
|
+
* - Discriminated union parts (text, image, file, reasoning, tool)
|
|
7
|
+
* - Tool state machine (pending → running → completed/error)
|
|
8
|
+
* - Part-level metadata (synthetic flag, cache control)
|
|
9
|
+
* - Tool output attachments
|
|
4
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Base interface for all message parts.
|
|
13
|
+
* Provides common metadata fields for cache hints and synthetic content marking.
|
|
14
|
+
*/
|
|
15
|
+
export interface BasePart {
|
|
16
|
+
/**
|
|
17
|
+
* Part-level metadata for cache hints and custom data.
|
|
18
|
+
* Used for Anthropic cache control and provider-specific features.
|
|
19
|
+
*/
|
|
20
|
+
metadata?: {
|
|
21
|
+
/** Custom metadata fields */
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
/** Anthropic cache control hint */
|
|
24
|
+
cacheControl?: {
|
|
25
|
+
type: 'ephemeral' | 'permanent';
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Whether this is auto-generated content (e.g., "File saved", "Tool completed").
|
|
30
|
+
* Synthetic parts can be filtered or styled differently in UI.
|
|
31
|
+
*/
|
|
32
|
+
synthetic?: boolean;
|
|
33
|
+
}
|
|
5
34
|
/**
|
|
6
35
|
* Text content part
|
|
7
36
|
*/
|
|
8
|
-
export interface TextPart {
|
|
37
|
+
export interface TextPart extends BasePart {
|
|
9
38
|
text: string;
|
|
10
39
|
type: 'text';
|
|
11
40
|
}
|
|
12
41
|
/**
|
|
13
42
|
* Image content part
|
|
14
43
|
*/
|
|
15
|
-
export interface ImagePart {
|
|
44
|
+
export interface ImagePart extends BasePart {
|
|
16
45
|
image: ArrayBuffer | Buffer | string | Uint8Array | URL;
|
|
17
46
|
mimeType?: string;
|
|
18
47
|
type: 'image';
|
|
@@ -20,16 +49,238 @@ export interface ImagePart {
|
|
|
20
49
|
/**
|
|
21
50
|
* File content part
|
|
22
51
|
*/
|
|
23
|
-
export interface FilePart {
|
|
52
|
+
export interface FilePart extends BasePart {
|
|
24
53
|
data: ArrayBuffer | Buffer | string | Uint8Array | URL;
|
|
25
54
|
filename?: string;
|
|
26
55
|
mimeType: string;
|
|
27
56
|
type: 'file';
|
|
28
57
|
}
|
|
29
58
|
/**
|
|
30
|
-
*
|
|
59
|
+
* Reasoning/thinking content part.
|
|
60
|
+
* Represents structured thinking traces from models like Gemini or Claude.
|
|
61
|
+
*/
|
|
62
|
+
export interface ReasoningPart extends BasePart {
|
|
63
|
+
/**
|
|
64
|
+
* Parsed summary for display in UI.
|
|
65
|
+
* Extracted from the raw text for easier rendering.
|
|
66
|
+
*/
|
|
67
|
+
summary?: {
|
|
68
|
+
/** Detailed description of the thought */
|
|
69
|
+
description: string;
|
|
70
|
+
/** Brief subject of the thought */
|
|
71
|
+
subject: string;
|
|
72
|
+
};
|
|
73
|
+
/** Raw reasoning/thinking text from the model */
|
|
74
|
+
text: string;
|
|
75
|
+
type: 'reasoning';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Tool call in pending state (received from LLM, not yet started).
|
|
79
|
+
*/
|
|
80
|
+
export interface ToolStatePending {
|
|
81
|
+
/** Parsed input arguments */
|
|
82
|
+
input: Record<string, unknown>;
|
|
83
|
+
status: 'pending';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Tool call in running state (execution started).
|
|
87
|
+
*/
|
|
88
|
+
export interface ToolStateRunning {
|
|
89
|
+
/** Parsed input arguments */
|
|
90
|
+
input: Record<string, unknown>;
|
|
91
|
+
/** Unix timestamp when execution started */
|
|
92
|
+
startedAt: number;
|
|
93
|
+
status: 'running';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Tool call in completed state (execution finished successfully).
|
|
97
|
+
*/
|
|
98
|
+
export interface ToolStateCompleted {
|
|
99
|
+
/** Attachments produced by the tool (images, files) */
|
|
100
|
+
attachments?: AttachmentPart[];
|
|
101
|
+
/** Unix timestamp when this output was marked as compacted (for pruning) */
|
|
102
|
+
compactedAt?: number;
|
|
103
|
+
/** Parsed input arguments */
|
|
104
|
+
input: Record<string, unknown>;
|
|
105
|
+
/** Additional metadata about the execution */
|
|
106
|
+
metadata?: Record<string, unknown>;
|
|
107
|
+
/** Tool output content */
|
|
108
|
+
output: string;
|
|
109
|
+
status: 'completed';
|
|
110
|
+
/** Execution timing */
|
|
111
|
+
time: {
|
|
112
|
+
end: number;
|
|
113
|
+
start: number;
|
|
114
|
+
};
|
|
115
|
+
/** Human-readable title for display */
|
|
116
|
+
title?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Tool call in error state (execution failed).
|
|
120
|
+
*/
|
|
121
|
+
export interface ToolStateError {
|
|
122
|
+
/** Error message */
|
|
123
|
+
error: string;
|
|
124
|
+
/** Parsed input arguments */
|
|
125
|
+
input: Record<string, unknown>;
|
|
126
|
+
status: 'error';
|
|
127
|
+
/** Execution timing (may have partial timing if failed mid-execution) */
|
|
128
|
+
time: {
|
|
129
|
+
end: number;
|
|
130
|
+
start: number;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Union of all tool states.
|
|
135
|
+
*/
|
|
136
|
+
export type ToolState = ToolStateCompleted | ToolStateError | ToolStatePending | ToolStateRunning;
|
|
137
|
+
/**
|
|
138
|
+
* Attachment produced by a tool (image, file).
|
|
139
|
+
* Used for MCP tools that return binary content.
|
|
140
|
+
*/
|
|
141
|
+
export interface AttachmentPart {
|
|
142
|
+
/** Base64-encoded data or data URL */
|
|
143
|
+
data: string;
|
|
144
|
+
/** Original filename if available */
|
|
145
|
+
filename?: string;
|
|
146
|
+
/** MIME type of the attachment */
|
|
147
|
+
mime: string;
|
|
148
|
+
type: 'file' | 'image';
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Tool call part with state machine.
|
|
152
|
+
* Tracks the full lifecycle of a tool call from pending to completed/error.
|
|
153
|
+
*
|
|
154
|
+
* This replaces the separate tool tracking in the execution queue,
|
|
155
|
+
* integrating tool state directly into message parts for:
|
|
156
|
+
* - Better conversation history representation
|
|
157
|
+
* - Efficient compaction (can mark individual tool outputs as compacted)
|
|
158
|
+
* - Rich UI feedback during execution
|
|
31
159
|
*/
|
|
32
|
-
export
|
|
160
|
+
export interface ToolPart extends BasePart {
|
|
161
|
+
/** Unique identifier for this tool call */
|
|
162
|
+
callId: string;
|
|
163
|
+
/** Current state of the tool call */
|
|
164
|
+
state: ToolState;
|
|
165
|
+
/** Name of the tool being called */
|
|
166
|
+
toolName: string;
|
|
167
|
+
type: 'tool';
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Snapshot part - captures code/file state at a point in time.
|
|
171
|
+
* Used for tracking state before/after operations for undo/revert.
|
|
172
|
+
*/
|
|
173
|
+
export interface SnapshotPart extends BasePart {
|
|
174
|
+
/** Unique identifier for this snapshot */
|
|
175
|
+
id: string;
|
|
176
|
+
/** Snapshot data as JSON string */
|
|
177
|
+
snapshot: string;
|
|
178
|
+
/** Unix timestamp when snapshot was taken */
|
|
179
|
+
timestamp: number;
|
|
180
|
+
type: 'snapshot';
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Patch part - represents a file diff/change.
|
|
184
|
+
* Used for tracking file modifications and enabling rich diff views.
|
|
185
|
+
*/
|
|
186
|
+
export interface PatchPart extends BasePart {
|
|
187
|
+
/** Unified diff content */
|
|
188
|
+
diff: string;
|
|
189
|
+
/** Path to the file that was modified */
|
|
190
|
+
filePath: string;
|
|
191
|
+
/** Unique identifier for this patch */
|
|
192
|
+
id: string;
|
|
193
|
+
/** Number of lines added */
|
|
194
|
+
linesAdded: number;
|
|
195
|
+
/** Number of lines removed */
|
|
196
|
+
linesRemoved: number;
|
|
197
|
+
type: 'patch';
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Step start part - marks the beginning of an execution step.
|
|
201
|
+
* Used for tracking multi-step operations and providing progress feedback.
|
|
202
|
+
*/
|
|
203
|
+
export interface StepStartPart extends BasePart {
|
|
204
|
+
/** Unique identifier for this step */
|
|
205
|
+
id: string;
|
|
206
|
+
/** Step index (0-based) */
|
|
207
|
+
stepIndex: number;
|
|
208
|
+
/** Unix timestamp when step started */
|
|
209
|
+
timestamp: number;
|
|
210
|
+
type: 'step_start';
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Step finish part - marks the end of an execution step with cost/token info.
|
|
214
|
+
* Used for tracking per-step costs and providing detailed analytics.
|
|
215
|
+
*/
|
|
216
|
+
export interface StepFinishPart extends BasePart {
|
|
217
|
+
/** Cost in dollars for this step */
|
|
218
|
+
cost: number;
|
|
219
|
+
/** Why this step finished */
|
|
220
|
+
finishReason: 'max_tokens' | 'stop' | 'tool_calls';
|
|
221
|
+
/** Unique identifier for this step */
|
|
222
|
+
id: string;
|
|
223
|
+
/** Step index (0-based) */
|
|
224
|
+
stepIndex: number;
|
|
225
|
+
/** Unix timestamp when step finished */
|
|
226
|
+
timestamp: number;
|
|
227
|
+
/** Token usage for this step */
|
|
228
|
+
tokens: {
|
|
229
|
+
/** Cache tokens (read/write) */
|
|
230
|
+
cache?: {
|
|
231
|
+
read: number;
|
|
232
|
+
write: number;
|
|
233
|
+
};
|
|
234
|
+
/** Input tokens consumed */
|
|
235
|
+
input: number;
|
|
236
|
+
/** Output tokens generated */
|
|
237
|
+
output: number;
|
|
238
|
+
/** Reasoning tokens (if extended thinking enabled) */
|
|
239
|
+
reasoning?: number;
|
|
240
|
+
};
|
|
241
|
+
type: 'step_finish';
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Compaction part - marks a context compaction boundary.
|
|
245
|
+
* Inserted when context is compacted to preserve summary of removed content.
|
|
246
|
+
*/
|
|
247
|
+
export interface CompactionPart extends BasePart {
|
|
248
|
+
/** IDs of messages that were compacted */
|
|
249
|
+
compactedMessageIds: string[];
|
|
250
|
+
/** Unique identifier for this compaction */
|
|
251
|
+
id: string;
|
|
252
|
+
/** Summary of the compacted content */
|
|
253
|
+
summary: string;
|
|
254
|
+
/** Unix timestamp when compaction occurred */
|
|
255
|
+
timestamp: number;
|
|
256
|
+
/** Number of tokens saved by compaction */
|
|
257
|
+
tokensSaved: number;
|
|
258
|
+
type: 'compaction';
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Retry part - tracks retry attempts for failed operations.
|
|
262
|
+
* Used for debugging and providing visibility into retry behavior.
|
|
263
|
+
*/
|
|
264
|
+
export interface RetryPart extends BasePart {
|
|
265
|
+
/** Current retry attempt number (1-based) */
|
|
266
|
+
attempt: number;
|
|
267
|
+
/** Error message from the failed attempt */
|
|
268
|
+
errorMessage: string;
|
|
269
|
+
/** Unique identifier for this retry */
|
|
270
|
+
id: string;
|
|
271
|
+
/** Maximum number of retry attempts */
|
|
272
|
+
maxAttempts: number;
|
|
273
|
+
/** Unix timestamp of next retry (if scheduled) */
|
|
274
|
+
nextRetryAt?: number;
|
|
275
|
+
/** What operation is being retried */
|
|
276
|
+
operation: string;
|
|
277
|
+
type: 'retry';
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Union type for message content parts.
|
|
281
|
+
* Discriminated by the `type` field.
|
|
282
|
+
*/
|
|
283
|
+
export type MessagePart = CompactionPart | FilePart | ImagePart | PatchPart | ReasoningPart | RetryPart | SnapshotPart | StepFinishPart | StepStartPart | TextPart | ToolPart;
|
|
33
284
|
/**
|
|
34
285
|
* Tool call made by the assistant
|
|
35
286
|
*/
|
|
@@ -68,6 +319,29 @@ export interface InternalMessage {
|
|
|
68
319
|
* - null if an assistant message only contains tool calls.
|
|
69
320
|
*/
|
|
70
321
|
content: Array<MessagePart> | null | string;
|
|
322
|
+
/**
|
|
323
|
+
* Message-level metadata for compression and tracking.
|
|
324
|
+
* Used by compression strategies to mark summary messages and track compaction.
|
|
325
|
+
*/
|
|
326
|
+
metadata?: {
|
|
327
|
+
/** Custom metadata fields */
|
|
328
|
+
[key: string]: unknown;
|
|
329
|
+
/**
|
|
330
|
+
* Unix timestamp when this message was created via compaction.
|
|
331
|
+
* Present on summary messages created by compression strategies.
|
|
332
|
+
*/
|
|
333
|
+
compactedAt?: number;
|
|
334
|
+
/**
|
|
335
|
+
* Whether this message is a summary of prior conversation.
|
|
336
|
+
* When true, messages before this point can be filtered at read-time.
|
|
337
|
+
*/
|
|
338
|
+
isSummary?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Number of messages that were summarized into this one.
|
|
341
|
+
* Present when isSummary is true.
|
|
342
|
+
*/
|
|
343
|
+
summarizedMessageCount?: number;
|
|
344
|
+
};
|
|
71
345
|
/**
|
|
72
346
|
* Name of the tool that produced this result.
|
|
73
347
|
* Only present in tool messages.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal representation of messages in a conversation.
|
|
3
3
|
* Standardizes message format across different LLM providers.
|
|
4
|
+
*
|
|
5
|
+
* Based on OpenCode's structured message parts pattern with:
|
|
6
|
+
* - Discriminated union parts (text, image, file, reasoning, tool)
|
|
7
|
+
* - Tool state machine (pending → running → completed/error)
|
|
8
|
+
* - Part-level metadata (synthetic flag, cache control)
|
|
9
|
+
* - Tool output attachments
|
|
4
10
|
*/
|
|
5
11
|
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for tool output sanitization.
|
|
3
|
+
*
|
|
4
|
+
* These types define the structure of sanitized tool results,
|
|
5
|
+
* enabling consistent handling of tool outputs across the system.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { MessagePart } from './message-types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Resource kind categories for media content.
|
|
11
|
+
*/
|
|
12
|
+
export type ResourceKind = 'audio' | 'binary' | 'image' | 'video';
|
|
13
|
+
/**
|
|
14
|
+
* Resource descriptor created during tool output sanitization.
|
|
15
|
+
* Tracks media resources that were extracted and potentially stored as blobs.
|
|
16
|
+
*/
|
|
17
|
+
export interface ResourceDescriptor {
|
|
18
|
+
/** Original filename if available */
|
|
19
|
+
filename?: string;
|
|
20
|
+
/** Kind of resource based on MIME type */
|
|
21
|
+
kind: ResourceKind;
|
|
22
|
+
/** MIME type of the resource */
|
|
23
|
+
mimeType: string;
|
|
24
|
+
/** Size in bytes if known */
|
|
25
|
+
size?: number;
|
|
26
|
+
/** URI reference to the resource (e.g., "blob:abc123") */
|
|
27
|
+
uri: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Metadata about the tool execution.
|
|
31
|
+
*/
|
|
32
|
+
export interface ToolExecutionMeta {
|
|
33
|
+
/** Any additional metadata from the tool */
|
|
34
|
+
additionalMeta?: Record<string, unknown>;
|
|
35
|
+
/** Duration of tool execution in milliseconds (if tracked) */
|
|
36
|
+
durationMs?: number;
|
|
37
|
+
/** Whether the tool execution succeeded */
|
|
38
|
+
success: boolean;
|
|
39
|
+
/** Unique identifier for this tool call */
|
|
40
|
+
toolCallId: string;
|
|
41
|
+
/** Name of the tool that was executed */
|
|
42
|
+
toolName: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of sanitizing a tool output.
|
|
46
|
+
*
|
|
47
|
+
* Contains the sanitized content parts, resource descriptors for any
|
|
48
|
+
* media that was extracted, and metadata about the tool execution.
|
|
49
|
+
*/
|
|
50
|
+
export interface SanitizedToolResult {
|
|
51
|
+
/** Sanitized content parts ready for message storage */
|
|
52
|
+
content: MessagePart[];
|
|
53
|
+
/** Metadata about the tool execution */
|
|
54
|
+
meta: ToolExecutionMeta;
|
|
55
|
+
/**
|
|
56
|
+
* Resource descriptors for media extracted during sanitization.
|
|
57
|
+
* These may reference blob storage if media was persisted.
|
|
58
|
+
*/
|
|
59
|
+
resources?: ResourceDescriptor[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Options for the tool result sanitization process.
|
|
63
|
+
*/
|
|
64
|
+
export interface SanitizeToolResultOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Blob storage for persisting large media.
|
|
67
|
+
* If not provided, large media will be truncated or omitted.
|
|
68
|
+
*/
|
|
69
|
+
blobStorage?: import('./i-blob-storage.js').IBlobStorage;
|
|
70
|
+
/** Duration of tool execution in milliseconds */
|
|
71
|
+
durationMs?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum size in bytes for inline media (default: 5KB).
|
|
74
|
+
* Media larger than this will be stored as blob references.
|
|
75
|
+
*/
|
|
76
|
+
maxInlineMediaBytes?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Maximum length for text content (default: 8000 chars).
|
|
79
|
+
* Longer text will be truncated with head + tail pattern.
|
|
80
|
+
*/
|
|
81
|
+
maxTextLength?: number;
|
|
82
|
+
/** Whether the tool execution succeeded */
|
|
83
|
+
success: boolean;
|
|
84
|
+
/** Unique identifier for this tool call */
|
|
85
|
+
toolCallId: string;
|
|
86
|
+
/** Name of the tool that produced the output */
|
|
87
|
+
toolName: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Result of normalizing raw tool output to MessagePart array.
|
|
91
|
+
* Intermediate step in the sanitization pipeline.
|
|
92
|
+
*/
|
|
93
|
+
export interface NormalizedToolOutput {
|
|
94
|
+
/** MIME types detected in the output */
|
|
95
|
+
detectedMimeTypes: string[];
|
|
96
|
+
/** Whether any binary content was detected */
|
|
97
|
+
hasBinaryContent: boolean;
|
|
98
|
+
/** Normalized content parts */
|
|
99
|
+
parts: MessagePart[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Result of persisting media to blob storage.
|
|
103
|
+
* Intermediate step in the sanitization pipeline.
|
|
104
|
+
*/
|
|
105
|
+
export interface PersistMediaResult {
|
|
106
|
+
/** Number of blobs created */
|
|
107
|
+
blobsCreated: number;
|
|
108
|
+
/** Total bytes stored */
|
|
109
|
+
bytesStored: number;
|
|
110
|
+
/** Parts with blob references replacing inline data */
|
|
111
|
+
parts: MessagePart[];
|
|
112
|
+
/** Resource descriptors for persisted media */
|
|
113
|
+
resources: ResourceDescriptor[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Configuration for text truncation.
|
|
117
|
+
*/
|
|
118
|
+
export interface TextTruncationConfig {
|
|
119
|
+
/** Characters to keep from the start (default: 4000) */
|
|
120
|
+
headLength: number;
|
|
121
|
+
/** Maximum total length (default: 8000) */
|
|
122
|
+
maxLength: number;
|
|
123
|
+
/** Placeholder text for omitted content */
|
|
124
|
+
placeholder: string;
|
|
125
|
+
/** Characters to keep from the end (default: 1000) */
|
|
126
|
+
tailLength: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Default text truncation configuration.
|
|
130
|
+
*/
|
|
131
|
+
export declare const DEFAULT_TEXT_TRUNCATION: TextTruncationConfig;
|
|
132
|
+
/**
|
|
133
|
+
* Default maximum inline media size (5KB).
|
|
134
|
+
*/
|
|
135
|
+
export declare const DEFAULT_MAX_INLINE_MEDIA_BYTES: number;
|
|
136
|
+
/**
|
|
137
|
+
* MIME types that should always be stored as blobs regardless of size.
|
|
138
|
+
*/
|
|
139
|
+
export declare const ALWAYS_BLOB_MIME_TYPES: string[];
|
|
140
|
+
/**
|
|
141
|
+
* Check if a MIME type should always be stored as a blob.
|
|
142
|
+
*/
|
|
143
|
+
export declare function shouldAlwaysBlob(mimeType: string): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Infer resource kind from MIME type.
|
|
146
|
+
*/
|
|
147
|
+
export declare function inferResourceKind(mimeType: string): ResourceKind;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for tool output sanitization.
|
|
3
|
+
*
|
|
4
|
+
* These types define the structure of sanitized tool results,
|
|
5
|
+
* enabling consistent handling of tool outputs across the system.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default text truncation configuration.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_TEXT_TRUNCATION = {
|
|
12
|
+
headLength: 4000,
|
|
13
|
+
maxLength: 8000,
|
|
14
|
+
placeholder: '\n... [{count} chars omitted] ...\n',
|
|
15
|
+
tailLength: 1000,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Default maximum inline media size (5KB).
|
|
19
|
+
*/
|
|
20
|
+
export const DEFAULT_MAX_INLINE_MEDIA_BYTES = 5 * 1024;
|
|
21
|
+
/**
|
|
22
|
+
* MIME types that should always be stored as blobs regardless of size.
|
|
23
|
+
*/
|
|
24
|
+
export const ALWAYS_BLOB_MIME_TYPES = [
|
|
25
|
+
'audio/',
|
|
26
|
+
'video/',
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Check if a MIME type should always be stored as a blob.
|
|
30
|
+
*/
|
|
31
|
+
export function shouldAlwaysBlob(mimeType) {
|
|
32
|
+
return ALWAYS_BLOB_MIME_TYPES.some((prefix) => mimeType.toLowerCase().startsWith(prefix));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Infer resource kind from MIME type.
|
|
36
|
+
*/
|
|
37
|
+
export function inferResourceKind(mimeType) {
|
|
38
|
+
const lower = mimeType.toLowerCase();
|
|
39
|
+
if (lower.startsWith('image/'))
|
|
40
|
+
return 'image';
|
|
41
|
+
if (lower.startsWith('audio/'))
|
|
42
|
+
return 'audio';
|
|
43
|
+
if (lower.startsWith('video/'))
|
|
44
|
+
return 'video';
|
|
45
|
+
return 'binary';
|
|
46
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ICipherAgent } from '../cipher/i-cipher-agent.js';
|
|
2
|
+
/**
|
|
3
|
+
* Options for executing curate with an injected agent.
|
|
4
|
+
* Agent uses its default session (Single-Session pattern).
|
|
5
|
+
*/
|
|
6
|
+
export interface CurateExecuteOptions {
|
|
7
|
+
/** Context content to curate */
|
|
8
|
+
content: string;
|
|
9
|
+
/** Optional file paths for --files flag */
|
|
10
|
+
files?: string[];
|
|
11
|
+
/** Task ID for event routing (required for concurrent task isolation) */
|
|
12
|
+
taskId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ICurateExecutor - Executes curate tasks with an injected CipherAgent.
|
|
16
|
+
*
|
|
17
|
+
* This is NOT a UseCase (which orchestrates business logic).
|
|
18
|
+
* It's an Executor that wraps agent.execute() with curate-specific options.
|
|
19
|
+
*
|
|
20
|
+
* Architecture:
|
|
21
|
+
* - TaskProcessor injects the long-lived CipherAgent
|
|
22
|
+
* - Event streaming is handled by agent-worker (subscribes to agentEventBus)
|
|
23
|
+
* - Executor focuses solely on curate execution
|
|
24
|
+
*/
|
|
25
|
+
export interface ICurateExecutor {
|
|
26
|
+
/**
|
|
27
|
+
* Execute curate with an injected agent.
|
|
28
|
+
*
|
|
29
|
+
* @param agent - Long-lived CipherAgent (managed by caller)
|
|
30
|
+
* @param options - Execution options (content, file references)
|
|
31
|
+
* @returns Result string from agent execution
|
|
32
|
+
*/
|
|
33
|
+
executeWithAgent(agent: ICipherAgent, options: CurateExecuteOptions): Promise<string>;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ICipherAgent } from '../cipher/i-cipher-agent.js';
|
|
2
|
+
/**
|
|
3
|
+
* Options for executing query with an injected agent.
|
|
4
|
+
* Agent uses its default session (Single-Session pattern).
|
|
5
|
+
*/
|
|
6
|
+
export interface QueryExecuteOptions {
|
|
7
|
+
/** Query content to search in context tree */
|
|
8
|
+
query: string;
|
|
9
|
+
/** Task ID for event routing (required for concurrent task isolation) */
|
|
10
|
+
taskId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* IQueryExecutor - Executes query tasks with an injected CipherAgent.
|
|
14
|
+
*
|
|
15
|
+
* This is NOT a UseCase (which orchestrates business logic).
|
|
16
|
+
* It's an Executor that wraps agent.execute() with query-specific options.
|
|
17
|
+
*
|
|
18
|
+
* Architecture:
|
|
19
|
+
* - TaskProcessor injects the long-lived CipherAgent
|
|
20
|
+
* - Event streaming is handled by agent-worker (subscribes to agentEventBus)
|
|
21
|
+
* - Executor focuses solely on query execution
|
|
22
|
+
*/
|
|
23
|
+
export interface IQueryExecutor {
|
|
24
|
+
/**
|
|
25
|
+
* Execute query with an injected agent.
|
|
26
|
+
*
|
|
27
|
+
* @param agent - Long-lived CipherAgent (managed by caller)
|
|
28
|
+
* @param options - Execution options (query)
|
|
29
|
+
* @returns Result string from agent execution
|
|
30
|
+
*/
|
|
31
|
+
executeWithAgent(agent: ICipherAgent, options: QueryExecuteOptions): Promise<string>;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { InstanceInfo } from '../../domain/instance/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of instance discovery.
|
|
4
|
+
*
|
|
5
|
+
* - no_instance: No .brv/ directory found in tree
|
|
6
|
+
* - instance_crashed: Found instance.json but pid is dead
|
|
7
|
+
*/
|
|
8
|
+
export type DiscoveryResult = {
|
|
9
|
+
found: false;
|
|
10
|
+
reason: 'instance_crashed' | 'no_instance';
|
|
11
|
+
} | {
|
|
12
|
+
found: true;
|
|
13
|
+
instance: InstanceInfo;
|
|
14
|
+
projectRoot: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Interface for discovering running instances via walk-up directory search.
|
|
18
|
+
*
|
|
19
|
+
* Architecture notes (Section 5 - Transport Discovery):
|
|
20
|
+
* Walk up directory tree to find .brv/instance.json, verify pid alive.
|
|
21
|
+
*/
|
|
22
|
+
export interface IInstanceDiscovery {
|
|
23
|
+
/**
|
|
24
|
+
* Discovers a running instance starting from the given directory.
|
|
25
|
+
*
|
|
26
|
+
* Walk-up algorithm:
|
|
27
|
+
* 1. Start from `fromDir`
|
|
28
|
+
* 2. Check if .brv/instance.json exists
|
|
29
|
+
* 3. If yes, verify pid is alive
|
|
30
|
+
* 4. If no, walk up to parent directory
|
|
31
|
+
* 5. Repeat until root or found
|
|
32
|
+
*
|
|
33
|
+
* @param fromDir - Starting directory (usually cwd)
|
|
34
|
+
* @returns DiscoveryResult with instance info and project root if found
|
|
35
|
+
*/
|
|
36
|
+
discover: (fromDir: string) => Promise<DiscoveryResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Finds the project root by walking up from a directory.
|
|
39
|
+
* Returns the directory containing .brv/ or undefined if not found.
|
|
40
|
+
*
|
|
41
|
+
* @param fromDir - Starting directory
|
|
42
|
+
* @returns Project root path or undefined
|
|
43
|
+
*/
|
|
44
|
+
findProjectRoot: (fromDir: string) => Promise<string | undefined>;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|