byterover-cli 0.4.0 → 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/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +3 -1
- 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/hooks/init/welcome.js +9 -24
- 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 +10 -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 +73 -259
- package/dist/infra/usecase/init-use-case.js +19 -8
- package/dist/infra/usecase/login-use-case.js +9 -3
- package/dist/infra/usecase/query-use-case.d.ts +18 -45
- package/dist/infra/usecase/query-use-case.js +251 -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} +6 -5
- 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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Provider types and constants.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the core types for LLM provider abstraction,
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Supported LLM providers as a const array for runtime validation.
|
|
8
|
+
*/
|
|
9
|
+
export const LLM_PROVIDERS = ['claude', 'gemini', 'openrouter'];
|
|
10
|
+
/**
|
|
11
|
+
* Supported file types for multimodal input.
|
|
12
|
+
*/
|
|
13
|
+
export const SUPPORTED_FILE_TYPES = ['audio', 'image', 'pdf'];
|
|
14
|
+
/**
|
|
15
|
+
* MIME type to file type mapping.
|
|
16
|
+
* Used to determine supported file types from MIME types.
|
|
17
|
+
*/
|
|
18
|
+
export const MIME_TYPE_TO_FILE_TYPE = {
|
|
19
|
+
// PDF
|
|
20
|
+
'application/pdf': 'pdf',
|
|
21
|
+
// Audio
|
|
22
|
+
'audio/aac': 'audio',
|
|
23
|
+
'audio/m4a': 'audio',
|
|
24
|
+
'audio/mp3': 'audio',
|
|
25
|
+
'audio/mpeg': 'audio',
|
|
26
|
+
'audio/ogg': 'audio',
|
|
27
|
+
'audio/wav': 'audio',
|
|
28
|
+
'audio/wave': 'audio',
|
|
29
|
+
'audio/webm': 'audio',
|
|
30
|
+
'audio/x-wav': 'audio',
|
|
31
|
+
// Images
|
|
32
|
+
'image/gif': 'image',
|
|
33
|
+
'image/jpeg': 'image',
|
|
34
|
+
'image/jpg': 'image',
|
|
35
|
+
'image/png': 'image',
|
|
36
|
+
'image/webp': 'image',
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get all allowed MIME types.
|
|
40
|
+
* @returns Array of allowed MIME type strings
|
|
41
|
+
*/
|
|
42
|
+
export function getAllowedMimeTypes() {
|
|
43
|
+
return Object.keys(MIME_TYPE_TO_FILE_TYPE);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get file type from MIME type.
|
|
47
|
+
* @param mimeType - MIME type string
|
|
48
|
+
* @returns SupportedFileType or undefined if not supported
|
|
49
|
+
*/
|
|
50
|
+
export function getFileTypeFromMimeType(mimeType) {
|
|
51
|
+
return MIME_TYPE_TO_FILE_TYPE[mimeType];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if a MIME type is supported.
|
|
55
|
+
* @param mimeType - MIME type string
|
|
56
|
+
* @returns true if the MIME type is supported
|
|
57
|
+
*/
|
|
58
|
+
export function isSupportedMimeType(mimeType) {
|
|
59
|
+
return mimeType in MIME_TYPE_TO_FILE_TYPE;
|
|
60
|
+
}
|
|
@@ -102,20 +102,89 @@ export interface StoredMessage {
|
|
|
102
102
|
/** Unix timestamp of last update */
|
|
103
103
|
updatedAt: number;
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Tool state as stored in StoredPart.
|
|
107
|
+
* Mirrors the ToolState types from message-types.ts but optimized for storage.
|
|
108
|
+
*/
|
|
109
|
+
export interface StoredToolState {
|
|
110
|
+
/** Attachments produced by the tool (images, files) */
|
|
111
|
+
attachments?: Array<{
|
|
112
|
+
/** Base64-encoded data or data URL */
|
|
113
|
+
data: string;
|
|
114
|
+
/** Original filename if available */
|
|
115
|
+
filename?: string;
|
|
116
|
+
/** MIME type of the attachment */
|
|
117
|
+
mime: string;
|
|
118
|
+
/** Attachment type */
|
|
119
|
+
type: 'file' | 'image';
|
|
120
|
+
}>;
|
|
121
|
+
/** Unique identifier for this tool call */
|
|
122
|
+
callId: string;
|
|
123
|
+
/** Unix timestamp when execution completed */
|
|
124
|
+
completedAt?: number;
|
|
125
|
+
/** Error message (only for 'error' status) */
|
|
126
|
+
error?: string;
|
|
127
|
+
/** Parsed input arguments */
|
|
128
|
+
input?: Record<string, unknown>;
|
|
129
|
+
/** Tool output content (only for 'completed' status) */
|
|
130
|
+
output?: string;
|
|
131
|
+
/** Unix timestamp when execution started */
|
|
132
|
+
startedAt?: number;
|
|
133
|
+
/** Current status of the tool call */
|
|
134
|
+
status: 'completed' | 'error' | 'pending' | 'running';
|
|
135
|
+
/** Human-readable title for display */
|
|
136
|
+
title?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Reasoning summary as stored in StoredPart.
|
|
140
|
+
*/
|
|
141
|
+
export interface StoredReasoningSummary {
|
|
142
|
+
/** Detailed description of the thought */
|
|
143
|
+
description: string;
|
|
144
|
+
/** Brief subject of the thought */
|
|
145
|
+
subject: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Part-level metadata as stored in StoredPart.
|
|
149
|
+
*/
|
|
150
|
+
export interface StoredPartMetadata {
|
|
151
|
+
/** Custom metadata fields */
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
/** Anthropic cache control hint */
|
|
154
|
+
cacheControl?: {
|
|
155
|
+
type: 'ephemeral' | 'permanent';
|
|
156
|
+
};
|
|
157
|
+
/** Whether this is auto-generated content */
|
|
158
|
+
synthetic?: boolean;
|
|
159
|
+
}
|
|
105
160
|
/**
|
|
106
161
|
* Message part stored at ["part", messageId, partId].
|
|
107
162
|
*
|
|
108
163
|
* Parts contain content that may be pruned independently:
|
|
109
164
|
* - Tool outputs (large, can be marked as compacted)
|
|
165
|
+
* - Tool calls with state machine (pending → running → completed/error)
|
|
110
166
|
* - File attachments
|
|
111
167
|
* - Image data
|
|
168
|
+
* - Reasoning/thinking traces
|
|
112
169
|
*
|
|
113
170
|
* Parts are stored separately to enable:
|
|
114
171
|
* - Selective pruning of old tool outputs
|
|
115
172
|
* - Lazy loading of large content
|
|
116
173
|
* - Efficient streaming without loading all content
|
|
174
|
+
* - Tool state tracking with full lifecycle
|
|
175
|
+
*
|
|
176
|
+
* Blob references:
|
|
177
|
+
* - Large binary content (>5KB) can be stored in blob storage
|
|
178
|
+
* - When stored as blob, content contains "@blob:{id}" reference
|
|
179
|
+
* - Blob refs are resolved lazily at format-time via BlobReferenceResolver
|
|
117
180
|
*/
|
|
118
181
|
export interface StoredPart {
|
|
182
|
+
/**
|
|
183
|
+
* Blob reference ID (without @ prefix) when content is stored externally.
|
|
184
|
+
* Present when isBlob is true. The actual data can be retrieved from
|
|
185
|
+
* blob storage using this ID.
|
|
186
|
+
*/
|
|
187
|
+
blobRef?: string;
|
|
119
188
|
/**
|
|
120
189
|
* Unix timestamp when this part was marked as compacted.
|
|
121
190
|
* If set, the original content has been cleared to save space,
|
|
@@ -125,11 +194,14 @@ export interface StoredPart {
|
|
|
125
194
|
/**
|
|
126
195
|
* The actual content of the part.
|
|
127
196
|
* - Tool output: string (JSON or text)
|
|
128
|
-
* - File: base64 encoded data or
|
|
197
|
+
* - File: base64 encoded data, file path, or blob reference (@blob:id)
|
|
129
198
|
* - Text: raw text content
|
|
130
|
-
* - Image: base64 encoded data
|
|
199
|
+
* - Image: base64 encoded data or blob reference (@blob:id)
|
|
200
|
+
* - Reasoning: thinking text from the model
|
|
201
|
+
* - Tool: empty (state stored in toolState)
|
|
131
202
|
*
|
|
132
203
|
* When compactedAt is set, this will be empty or contain a placeholder.
|
|
204
|
+
* When isBlob is true, this contains the blob reference string.
|
|
133
205
|
*/
|
|
134
206
|
content: string;
|
|
135
207
|
/** Unix timestamp when part was created */
|
|
@@ -138,17 +210,42 @@ export interface StoredPart {
|
|
|
138
210
|
filename?: string;
|
|
139
211
|
/** Unique part identifier (UUID) */
|
|
140
212
|
id: string;
|
|
213
|
+
/**
|
|
214
|
+
* Whether the content field contains a blob reference.
|
|
215
|
+
* When true, content should be resolved via BlobReferenceResolver
|
|
216
|
+
* before use (at format-time for LLM requests).
|
|
217
|
+
*/
|
|
218
|
+
isBlob?: boolean;
|
|
141
219
|
/** ID of the message this part belongs to */
|
|
142
220
|
messageId: string;
|
|
221
|
+
/**
|
|
222
|
+
* Part-level metadata for cache hints and custom data.
|
|
223
|
+
* Follows OpenCode's pattern for part metadata.
|
|
224
|
+
*/
|
|
225
|
+
metadata?: StoredPartMetadata;
|
|
143
226
|
/** MIME type for file and image parts */
|
|
144
227
|
mimeType?: string;
|
|
228
|
+
/**
|
|
229
|
+
* Reasoning summary for 'reasoning' type parts.
|
|
230
|
+
* Contains parsed subject and description for display.
|
|
231
|
+
*/
|
|
232
|
+
reasoningSummary?: StoredReasoningSummary;
|
|
145
233
|
/**
|
|
146
234
|
* For tool_output parts, the name of the tool.
|
|
147
235
|
* Used for display and filtering.
|
|
148
236
|
*/
|
|
149
237
|
toolName?: string;
|
|
150
|
-
/**
|
|
151
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Tool state for 'tool' type parts.
|
|
240
|
+
* Tracks the full lifecycle: pending → running → completed/error.
|
|
241
|
+
* Only present when type is 'tool'.
|
|
242
|
+
*/
|
|
243
|
+
toolState?: StoredToolState;
|
|
244
|
+
/**
|
|
245
|
+
* Type of part content.
|
|
246
|
+
* Extended with 'tool' for tool calls with state machine and 'reasoning' for thinking traces.
|
|
247
|
+
*/
|
|
248
|
+
type: 'compaction' | 'file' | 'image' | 'reasoning' | 'text' | 'tool' | 'tool_output';
|
|
152
249
|
}
|
|
153
250
|
/**
|
|
154
251
|
* Placeholder message shown when tool output has been compacted.
|
|
@@ -197,9 +294,21 @@ export interface PruneToolOutputsOptions {
|
|
|
197
294
|
/**
|
|
198
295
|
* Target token count to keep in tool outputs.
|
|
199
296
|
* Tool outputs beyond this (from oldest) will be marked as compacted.
|
|
200
|
-
* Default: 40000 (same as OpenCode)
|
|
297
|
+
* Default: 40000 (same as OpenCode PRUNE_PROTECT)
|
|
201
298
|
*/
|
|
202
299
|
keepTokens?: number;
|
|
300
|
+
/**
|
|
301
|
+
* Minimum tokens that must be recoverable to perform pruning.
|
|
302
|
+
* If pruning would save less than this, skip it entirely.
|
|
303
|
+
* Default: 20000 (same as OpenCode PRUNE_MINIMUM)
|
|
304
|
+
*/
|
|
305
|
+
minimumTokens?: number;
|
|
306
|
+
/**
|
|
307
|
+
* Number of recent user turns to protect from pruning.
|
|
308
|
+
* Tool outputs in these turns will not be compacted.
|
|
309
|
+
* Default: 2
|
|
310
|
+
*/
|
|
311
|
+
protectedTurns?: number;
|
|
203
312
|
/**
|
|
204
313
|
* Session ID to prune tool outputs from.
|
|
205
314
|
*/
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ExecutionContext } from '../../../interfaces/cipher/i-cipher-agent.js';
|
|
2
|
+
import type { TokenUsage } from '../agent-events/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Streaming event names for CipherAgent.stream()
|
|
5
|
+
* These are the events exposed via the streaming API for real-time chat UIs.
|
|
6
|
+
*/
|
|
7
|
+
export declare const STREAMING_EVENT_NAMES: readonly ["llmservice:thinking", "llmservice:chunk", "llmservice:response", "llmservice:toolCall", "llmservice:toolResult", "llmservice:error", "llmservice:warning", "message:queued", "message:dequeued", "run:complete"];
|
|
8
|
+
export type StreamingEventName = (typeof STREAMING_EVENT_NAMES)[number];
|
|
9
|
+
/**
|
|
10
|
+
* Union type of all streaming events with their payloads.
|
|
11
|
+
* Uses 'name' property as discriminant for type narrowing.
|
|
12
|
+
*/
|
|
13
|
+
export type StreamingEvent = {
|
|
14
|
+
args: Record<string, unknown>;
|
|
15
|
+
callId?: string;
|
|
16
|
+
name: 'llmservice:toolCall';
|
|
17
|
+
sessionId: string;
|
|
18
|
+
taskId?: string;
|
|
19
|
+
toolName: string;
|
|
20
|
+
} | {
|
|
21
|
+
callId?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
name: 'llmservice:toolResult';
|
|
24
|
+
result?: unknown;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
success: boolean;
|
|
27
|
+
taskId?: string;
|
|
28
|
+
toolName: string;
|
|
29
|
+
} | {
|
|
30
|
+
code?: string;
|
|
31
|
+
error: string;
|
|
32
|
+
name: 'llmservice:error';
|
|
33
|
+
recoverable?: boolean;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
taskId?: string;
|
|
36
|
+
} | {
|
|
37
|
+
content: string;
|
|
38
|
+
isComplete?: boolean;
|
|
39
|
+
name: 'llmservice:chunk';
|
|
40
|
+
sessionId: string;
|
|
41
|
+
taskId?: string;
|
|
42
|
+
type: 'reasoning' | 'text';
|
|
43
|
+
} | {
|
|
44
|
+
content: string;
|
|
45
|
+
model?: string;
|
|
46
|
+
name: 'llmservice:response';
|
|
47
|
+
partial?: boolean;
|
|
48
|
+
provider?: string;
|
|
49
|
+
reasoning?: string;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
taskId?: string;
|
|
52
|
+
tokenUsage?: TokenUsage;
|
|
53
|
+
} | {
|
|
54
|
+
count: number;
|
|
55
|
+
name: 'message:dequeued';
|
|
56
|
+
sessionId: string;
|
|
57
|
+
taskId?: string;
|
|
58
|
+
} | {
|
|
59
|
+
durationMs: number;
|
|
60
|
+
error?: Error;
|
|
61
|
+
finishReason: 'cancelled' | 'error' | 'max-iterations' | 'stop' | 'timeout';
|
|
62
|
+
name: 'run:complete';
|
|
63
|
+
sessionId: string;
|
|
64
|
+
stepCount: number;
|
|
65
|
+
taskId?: string;
|
|
66
|
+
} | {
|
|
67
|
+
message: string;
|
|
68
|
+
name: 'llmservice:warning';
|
|
69
|
+
sessionId: string;
|
|
70
|
+
taskId?: string;
|
|
71
|
+
} | {
|
|
72
|
+
message: {
|
|
73
|
+
content: string;
|
|
74
|
+
id: string;
|
|
75
|
+
queuedAt: number;
|
|
76
|
+
};
|
|
77
|
+
name: 'message:queued';
|
|
78
|
+
position: number;
|
|
79
|
+
sessionId: string;
|
|
80
|
+
taskId?: string;
|
|
81
|
+
} | {
|
|
82
|
+
name: 'llmservice:thinking';
|
|
83
|
+
sessionId: string;
|
|
84
|
+
taskId?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Options for stream() method
|
|
88
|
+
*/
|
|
89
|
+
export interface StreamOptions {
|
|
90
|
+
/** Execution context */
|
|
91
|
+
executionContext?: ExecutionContext;
|
|
92
|
+
/** AbortSignal for cancellation */
|
|
93
|
+
signal?: AbortSignal;
|
|
94
|
+
/** Task ID for concurrent task isolation (included in all emitted events) */
|
|
95
|
+
taskId?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Complete response from generate() method (wrapper around stream)
|
|
99
|
+
*/
|
|
100
|
+
export interface GenerateResponse {
|
|
101
|
+
/** The final response content */
|
|
102
|
+
content: string;
|
|
103
|
+
/** Internal reasoning (if available) */
|
|
104
|
+
reasoning?: string;
|
|
105
|
+
/** Session ID */
|
|
106
|
+
sessionId: string;
|
|
107
|
+
/** Tool calls made during execution */
|
|
108
|
+
toolCalls: Array<{
|
|
109
|
+
args: Record<string, unknown>;
|
|
110
|
+
callId: string;
|
|
111
|
+
result?: {
|
|
112
|
+
data: unknown;
|
|
113
|
+
success: boolean;
|
|
114
|
+
};
|
|
115
|
+
toolName: string;
|
|
116
|
+
}>;
|
|
117
|
+
/** Token usage statistics */
|
|
118
|
+
usage: TokenUsage;
|
|
119
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming event names for CipherAgent.stream()
|
|
3
|
+
* These are the events exposed via the streaming API for real-time chat UIs.
|
|
4
|
+
*/
|
|
5
|
+
export const STREAMING_EVENT_NAMES = [
|
|
6
|
+
'llmservice:thinking',
|
|
7
|
+
'llmservice:chunk',
|
|
8
|
+
'llmservice:response',
|
|
9
|
+
'llmservice:toolCall',
|
|
10
|
+
'llmservice:toolResult',
|
|
11
|
+
'llmservice:error',
|
|
12
|
+
'llmservice:warning',
|
|
13
|
+
'message:queued',
|
|
14
|
+
'message:dequeued',
|
|
15
|
+
'run:complete',
|
|
16
|
+
];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { MemoryManager } from '../../../../infra/cipher/memory/memory-manager.js';
|
|
2
|
+
import type { EnvironmentContext } from '../../../../infra/cipher/system-prompt/environment-context-builder.js';
|
|
1
3
|
/**
|
|
2
4
|
* Conversation metadata for execution context
|
|
3
5
|
*/
|
|
@@ -23,6 +25,48 @@ export interface SystemPromptContext {
|
|
|
23
25
|
/** Whether running in JSON input mode (headless with conversation history) */
|
|
24
26
|
isJsonInputMode?: boolean;
|
|
25
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Extended context for contributor execution.
|
|
30
|
+
* Includes runtime dependencies needed by contributors.
|
|
31
|
+
*/
|
|
32
|
+
export interface ContributorContext {
|
|
33
|
+
/** Available markers and their descriptions */
|
|
34
|
+
availableMarkers?: Record<string, string>;
|
|
35
|
+
/** List of available tool names */
|
|
36
|
+
availableTools?: string[];
|
|
37
|
+
/** Type of command being executed */
|
|
38
|
+
commandType?: 'chat' | 'curate' | 'query';
|
|
39
|
+
/** Metadata about the current conversation */
|
|
40
|
+
conversationMetadata?: {
|
|
41
|
+
conversationId?: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Environment context with working directory, git status, file tree, etc. */
|
|
45
|
+
environmentContext?: EnvironmentContext;
|
|
46
|
+
/** Instructions for file reference handling */
|
|
47
|
+
fileReferenceInstructions?: string;
|
|
48
|
+
/** Memory manager instance for accessing memories */
|
|
49
|
+
memoryManager?: MemoryManager;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Interface for system prompt contributors.
|
|
53
|
+
*
|
|
54
|
+
* Contributors generate portions of the system prompt that are
|
|
55
|
+
* combined by the SystemPromptManager.
|
|
56
|
+
*/
|
|
57
|
+
export interface SystemPromptContributor {
|
|
58
|
+
/**
|
|
59
|
+
* Generate the content for this contributor.
|
|
60
|
+
*
|
|
61
|
+
* @param context - Runtime context with dependencies
|
|
62
|
+
* @returns Prompt content string
|
|
63
|
+
*/
|
|
64
|
+
getContent(context: ContributorContext): Promise<string>;
|
|
65
|
+
/** Unique identifier for this contributor */
|
|
66
|
+
id: string;
|
|
67
|
+
/** Priority for ordering (lower = higher priority) */
|
|
68
|
+
priority: number;
|
|
69
|
+
}
|
|
26
70
|
/**
|
|
27
71
|
* Configuration for a static contributor.
|
|
28
72
|
* Static contributors return the base system prompt from YAML or custom content.
|
|
@@ -21,6 +21,11 @@ export interface Todo {
|
|
|
21
21
|
* Example: "Run tests", "Build the project"
|
|
22
22
|
*/
|
|
23
23
|
content: string;
|
|
24
|
+
/**
|
|
25
|
+
* Unique identifier for the todo item.
|
|
26
|
+
* Used for tracking and updating individual todos.
|
|
27
|
+
*/
|
|
28
|
+
id: string;
|
|
24
29
|
/**
|
|
25
30
|
* Current status of the todo.
|
|
26
31
|
* - pending: Not yet started
|
|
@@ -48,10 +53,39 @@ export interface WriteTodosResult {
|
|
|
48
53
|
* Content to send back to the LLM.
|
|
49
54
|
*/
|
|
50
55
|
llmContent: string;
|
|
56
|
+
/**
|
|
57
|
+
* Structured metadata for tool consumption.
|
|
58
|
+
*/
|
|
59
|
+
metadata: {
|
|
60
|
+
todos: Todo[];
|
|
61
|
+
};
|
|
51
62
|
/**
|
|
52
63
|
* Display content for rendering to user.
|
|
53
64
|
*/
|
|
54
65
|
returnDisplay: {
|
|
55
66
|
todos: Todo[];
|
|
56
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Smart title showing incomplete count.
|
|
70
|
+
*/
|
|
71
|
+
title: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Result of read_todos tool execution.
|
|
75
|
+
*/
|
|
76
|
+
export interface ReadTodosResult {
|
|
77
|
+
/**
|
|
78
|
+
* JSON formatted list of all todos.
|
|
79
|
+
*/
|
|
80
|
+
content: string;
|
|
81
|
+
/**
|
|
82
|
+
* Structured metadata for tool consumption.
|
|
83
|
+
*/
|
|
84
|
+
metadata: {
|
|
85
|
+
todos: Todo[];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Smart title showing incomplete count.
|
|
89
|
+
*/
|
|
90
|
+
title: string;
|
|
57
91
|
}
|
|
@@ -5,20 +5,23 @@
|
|
|
5
5
|
export declare const ToolName: {
|
|
6
6
|
readonly BASH_EXEC: 'bash_exec';
|
|
7
7
|
readonly BASH_OUTPUT: 'bash_output';
|
|
8
|
+
readonly BATCH: 'batch';
|
|
8
9
|
readonly CREATE_KNOWLEDGE_TOPIC: 'create_knowledge_topic';
|
|
9
10
|
readonly CURATE: 'curate';
|
|
10
11
|
readonly DELETE_MEMORY: 'delete_memory';
|
|
11
|
-
readonly DETECT_DOMAINS: 'detect_domains';
|
|
12
12
|
readonly EDIT_FILE: 'edit_file';
|
|
13
13
|
readonly EDIT_MEMORY: 'edit_memory';
|
|
14
|
-
readonly FIND_KNOWLEDGE_TOPICS: 'find_knowledge_topics';
|
|
15
14
|
readonly GLOB_FILES: 'glob_files';
|
|
16
15
|
readonly GREP_CONTENT: 'grep_content';
|
|
17
16
|
readonly KILL_PROCESS: 'kill_process';
|
|
17
|
+
readonly LIST_DIRECTORY: 'list_directory';
|
|
18
18
|
readonly LIST_MEMORIES: 'list_memories';
|
|
19
19
|
readonly READ_FILE: 'read_file';
|
|
20
20
|
readonly READ_MEMORY: 'read_memory';
|
|
21
|
+
readonly READ_TODOS: 'read_todos';
|
|
21
22
|
readonly SEARCH_HISTORY: 'search_history';
|
|
23
|
+
readonly SPEC_ANALYZE: 'spec_analyze';
|
|
24
|
+
readonly TASK: 'task';
|
|
22
25
|
readonly WRITE_FILE: 'write_file';
|
|
23
26
|
readonly WRITE_MEMORY: 'write_memory';
|
|
24
27
|
readonly WRITE_TODOS: 'write_todos';
|
|
@@ -5,20 +5,23 @@
|
|
|
5
5
|
export const ToolName = {
|
|
6
6
|
BASH_EXEC: 'bash_exec',
|
|
7
7
|
BASH_OUTPUT: 'bash_output',
|
|
8
|
+
BATCH: 'batch',
|
|
8
9
|
CREATE_KNOWLEDGE_TOPIC: 'create_knowledge_topic',
|
|
9
10
|
CURATE: 'curate',
|
|
10
11
|
DELETE_MEMORY: 'delete_memory',
|
|
11
|
-
DETECT_DOMAINS: 'detect_domains',
|
|
12
12
|
EDIT_FILE: 'edit_file',
|
|
13
13
|
EDIT_MEMORY: 'edit_memory',
|
|
14
|
-
FIND_KNOWLEDGE_TOPICS: 'find_knowledge_topics',
|
|
15
14
|
GLOB_FILES: 'glob_files',
|
|
16
15
|
GREP_CONTENT: 'grep_content',
|
|
17
16
|
KILL_PROCESS: 'kill_process',
|
|
17
|
+
LIST_DIRECTORY: 'list_directory',
|
|
18
18
|
LIST_MEMORIES: 'list_memories',
|
|
19
19
|
READ_FILE: 'read_file',
|
|
20
20
|
READ_MEMORY: 'read_memory',
|
|
21
|
+
READ_TODOS: 'read_todos',
|
|
21
22
|
SEARCH_HISTORY: 'search_history',
|
|
23
|
+
SPEC_ANALYZE: 'spec_analyze',
|
|
24
|
+
TASK: 'task',
|
|
22
25
|
WRITE_FILE: 'write_file',
|
|
23
26
|
WRITE_MEMORY: 'write_memory',
|
|
24
27
|
WRITE_TODOS: 'write_todos',
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import type { ZodSchema } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Callback function for tools to push metadata updates during execution.
|
|
4
|
+
* Called by tools to stream real-time updates to the UI/LLM.
|
|
5
|
+
*/
|
|
6
|
+
export type MetadataCallback = (update: ToolMetadataUpdate) => void;
|
|
2
7
|
/**
|
|
3
8
|
* Risk level for tool execution.
|
|
4
9
|
* Used for logging, auditing, and policy decisions.
|
|
5
10
|
*/
|
|
6
11
|
export type RiskLevel = 'critical' | 'high' | 'low' | 'medium';
|
|
12
|
+
/**
|
|
13
|
+
* Real-time metadata update from a tool during execution.
|
|
14
|
+
* Allows tools to push incremental updates (e.g., streaming bash output).
|
|
15
|
+
*/
|
|
16
|
+
export interface ToolMetadataUpdate {
|
|
17
|
+
/** Additional custom metadata */
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
/** Human-readable description of current status */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Streamed output content (e.g., bash stdout/stderr) */
|
|
22
|
+
output?: string;
|
|
23
|
+
/** Progress indicator (0-100) */
|
|
24
|
+
progress?: number;
|
|
25
|
+
}
|
|
7
26
|
/**
|
|
8
27
|
* Semantic category for tools.
|
|
9
28
|
* Helps classify tools by their primary function.
|
|
@@ -63,8 +82,20 @@ export interface Tool {
|
|
|
63
82
|
* Contains metadata about the execution environment.
|
|
64
83
|
*/
|
|
65
84
|
export interface ToolExecutionContext {
|
|
85
|
+
/**
|
|
86
|
+
* Callback for streaming metadata updates during execution.
|
|
87
|
+
* Tools can use this to push real-time output (e.g., bash streaming).
|
|
88
|
+
*/
|
|
89
|
+
metadata?: MetadataCallback;
|
|
66
90
|
/** Session ID if available */
|
|
67
91
|
sessionId?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Abort signal for cancelling long-running operations.
|
|
94
|
+
* Tools should check this signal periodically and abort gracefully.
|
|
95
|
+
*/
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
/** Task ID from usecase for billing tracking */
|
|
98
|
+
taskId?: string;
|
|
68
99
|
}
|
|
69
100
|
/**
|
|
70
101
|
* Tool set exposed to the LLM.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Array of all supported Events.
|
|
3
3
|
*/
|
|
4
|
-
export declare const EVENT_VALUES: readonly ["auth:
|
|
4
|
+
export declare const EVENT_VALUES: readonly ["repl", "auth:sign_in", "auth:signed_out", "space:init", "space:changed", "rule:generate", "mem:status", "mem:curate", "mem:pull", "mem:push", "mem:query", "onboarding:init_completed", "onboarding:curate_completed", "onboarding:query_completed", "onboarding:skipped", "onboarding:completed", "init"];
|
|
5
5
|
export type EventName = (typeof EVENT_VALUES)[number];
|
|
6
6
|
export interface PropertyDict {
|
|
7
7
|
[key: string]: any;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Array of all supported Events.
|
|
3
3
|
*/
|
|
4
4
|
export const EVENT_VALUES = [
|
|
5
|
-
'
|
|
5
|
+
'repl',
|
|
6
|
+
'auth:sign_in',
|
|
6
7
|
'auth:signed_out',
|
|
7
8
|
'space:init',
|
|
8
9
|
'space:changed',
|
|
@@ -17,4 +18,5 @@ export const EVENT_VALUES = [
|
|
|
17
18
|
'onboarding:query_completed',
|
|
18
19
|
'onboarding:skipped',
|
|
19
20
|
'onboarding:completed',
|
|
21
|
+
'init'
|
|
20
22
|
];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error for client connection failures.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ConnectionError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when no running instance is found.
|
|
9
|
+
*/
|
|
10
|
+
export declare class NoInstanceRunningError extends ConnectionError {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when instance is found but process has crashed.
|
|
15
|
+
*/
|
|
16
|
+
export declare class InstanceCrashedError extends ConnectionError {
|
|
17
|
+
constructor(projectRoot?: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when connection to instance fails.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ConnectionFailedError extends ConnectionError {
|
|
23
|
+
readonly originalError?: Error;
|
|
24
|
+
readonly port?: number;
|
|
25
|
+
constructor(port?: number, originalError?: Error);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error thrown when connection times out.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ConnectionTimeoutError extends ConnectionError {
|
|
31
|
+
readonly timeoutMs: number;
|
|
32
|
+
constructor(timeoutMs: number);
|
|
33
|
+
}
|