byterover-cli 0.3.4 → 0.4.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 +119 -63
- package/bin/dev.js +8 -1
- package/bin/run.js +7 -0
- package/dist/commands/cipher-agent/run.d.ts +30 -0
- package/dist/commands/cipher-agent/run.js +123 -61
- package/dist/commands/cipher-agent/set-prompt.d.ts +2 -0
- package/dist/commands/cipher-agent/set-prompt.js +13 -8
- package/dist/commands/cipher-agent/show-prompt.d.ts +2 -0
- package/dist/commands/cipher-agent/show-prompt.js +17 -12
- package/dist/commands/curate.d.ts +3 -60
- package/dist/commands/curate.js +45 -341
- package/dist/commands/foo.d.ts +4 -2
- package/dist/commands/foo.js +21 -16
- package/dist/commands/main.d.ts +9 -0
- package/dist/commands/main.js +34 -0
- package/dist/commands/query.d.ts +2 -48
- package/dist/commands/query.js +19 -287
- package/dist/commands/status.d.ts +2 -13
- package/dist/commands/status.js +12 -91
- package/dist/commands/watch.d.ts +2 -0
- package/dist/commands/watch.js +23 -19
- package/dist/config/environment.d.ts +1 -1
- package/dist/config/environment.js +2 -2
- package/dist/constants.d.ts +4 -5
- package/dist/constants.js +5 -5
- package/dist/core/domain/cipher/errors/storage-error.d.ts +89 -0
- package/dist/core/domain/cipher/errors/storage-error.js +130 -0
- package/dist/core/domain/cipher/queue/types.d.ts +71 -0
- package/dist/core/domain/cipher/queue/types.js +9 -0
- package/dist/core/domain/cipher/storage/message-storage-types.d.ts +218 -0
- package/dist/core/domain/cipher/storage/message-storage-types.js +18 -0
- package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
- package/dist/core/domain/cipher/tools/constants.js +1 -0
- package/dist/core/domain/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +5 -0
- package/dist/core/domain/entities/global-config.d.ts +36 -0
- package/dist/core/domain/entities/global-config.js +66 -0
- package/dist/core/domain/knowledge/directory-manager.d.ts +10 -0
- package/dist/core/domain/knowledge/directory-manager.js +18 -0
- package/dist/core/domain/knowledge/markdown-writer.d.ts +9 -0
- package/dist/core/domain/knowledge/markdown-writer.js +51 -1
- package/dist/core/interfaces/cipher/i-agent-storage.d.ts +152 -0
- package/dist/core/interfaces/cipher/i-agent-storage.js +1 -0
- package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +2 -0
- package/dist/core/interfaces/cipher/i-key-storage.d.ts +91 -0
- package/dist/core/interfaces/cipher/i-key-storage.js +1 -0
- package/dist/core/interfaces/i-global-config-store.d.ts +34 -0
- package/dist/core/interfaces/i-global-config-store.js +1 -0
- package/dist/core/interfaces/i-onboarding-preference-store.d.ts +20 -0
- package/dist/core/interfaces/i-onboarding-preference-store.js +1 -0
- package/dist/core/interfaces/i-terminal.d.ts +146 -0
- package/dist/core/interfaces/i-terminal.js +1 -0
- package/dist/core/interfaces/i-workspace-detector-service.d.ts +8 -0
- package/dist/core/interfaces/i-workspace-detector-service.js +1 -0
- package/dist/core/interfaces/usecase/i-clear-use-case.d.ts +6 -0
- package/dist/core/interfaces/usecase/i-clear-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-curate-use-case.d.ts +10 -0
- package/dist/core/interfaces/usecase/i-curate-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-init-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-init-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-login-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-login-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-logout-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-logout-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-pull-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-pull-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-push-use-case.d.ts +6 -0
- package/dist/core/interfaces/usecase/i-push-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-query-use-case.d.ts +9 -0
- package/dist/core/interfaces/usecase/i-query-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-space-list-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-space-list-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-space-switch-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-space-switch-use-case.js +1 -0
- package/dist/core/interfaces/usecase/i-status-use-case.d.ts +5 -0
- package/dist/core/interfaces/usecase/i-status-use-case.js +1 -0
- package/dist/hooks/init/update-notifier.js +1 -5
- package/dist/hooks/init/welcome.js +1 -2
- package/dist/infra/cipher/agent-service-factory.d.ts +13 -6
- package/dist/infra/cipher/agent-service-factory.js +40 -16
- package/dist/infra/cipher/cipher-agent.js +4 -4
- package/dist/infra/cipher/consumer/consumer-lock.d.ts +20 -0
- package/dist/infra/cipher/consumer/consumer-lock.js +40 -0
- package/dist/infra/cipher/consumer/consumer-service.d.ts +99 -0
- package/dist/infra/cipher/consumer/consumer-service.js +165 -0
- package/dist/infra/cipher/consumer/execution-consumer.d.ts +121 -0
- package/dist/infra/cipher/consumer/execution-consumer.js +523 -0
- package/dist/infra/cipher/consumer/index.d.ts +33 -0
- package/dist/infra/cipher/consumer/index.js +33 -0
- package/dist/infra/cipher/consumer/queue-polling-service.d.ts +120 -0
- package/dist/infra/cipher/consumer/queue-polling-service.js +248 -0
- package/dist/infra/cipher/http/internal-llm-http-service.d.ts +94 -0
- package/dist/infra/cipher/http/internal-llm-http-service.js +118 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +106 -0
- package/dist/infra/cipher/llm/context/compaction/compaction-service.js +132 -0
- package/dist/infra/cipher/llm/context/compaction/index.d.ts +9 -0
- package/dist/infra/cipher/llm/context/compaction/index.js +9 -0
- package/dist/infra/cipher/llm/context/context-manager.d.ts +46 -2
- package/dist/infra/cipher/llm/context/context-manager.js +68 -4
- package/dist/infra/cipher/llm/context/rw-lock.d.ts +72 -0
- package/dist/infra/cipher/llm/context/rw-lock.js +145 -0
- package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +7 -7
- package/dist/infra/cipher/llm/generators/byterover-content-generator.js +8 -8
- package/dist/infra/cipher/llm/internal-llm-service.js +2 -0
- package/dist/infra/cipher/session/session-manager.d.ts +4 -4
- package/dist/infra/cipher/session/session-manager.js +5 -5
- package/dist/infra/cipher/storage/agent-storage.d.ts +246 -0
- package/dist/infra/cipher/storage/agent-storage.js +956 -0
- package/dist/infra/cipher/storage/dual-format-history-storage.d.ts +77 -0
- package/dist/infra/cipher/storage/dual-format-history-storage.js +149 -0
- package/dist/infra/cipher/storage/granular-history-storage.d.ts +65 -0
- package/dist/infra/cipher/storage/granular-history-storage.js +118 -0
- package/dist/infra/cipher/storage/message-storage-service.d.ts +108 -0
- package/dist/infra/cipher/storage/message-storage-service.js +529 -0
- package/dist/infra/cipher/storage/process-utils.d.ts +16 -0
- package/dist/infra/cipher/storage/process-utils.js +43 -0
- package/dist/infra/cipher/storage/sqlite-key-storage.d.ts +105 -0
- package/dist/infra/cipher/storage/sqlite-key-storage.js +404 -0
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +1 -0
- package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +7 -0
- package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
- package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +10 -0
- package/dist/infra/cipher/tools/implementations/curate-tool.js +371 -0
- package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +11 -8
- package/dist/infra/cipher/tools/tool-manager.d.ts +8 -2
- package/dist/infra/cipher/tools/tool-manager.js +29 -2
- package/dist/infra/cipher/tools/tool-registry.js +7 -0
- package/dist/infra/http/authenticated-http-client.d.ts +21 -0
- package/dist/infra/http/authenticated-http-client.js +38 -0
- package/dist/infra/repl/commands/arg-parser.d.ts +97 -0
- package/dist/infra/repl/commands/arg-parser.js +129 -0
- package/dist/infra/repl/commands/clear-command.d.ts +5 -0
- package/dist/infra/repl/commands/clear-command.js +61 -0
- package/dist/infra/repl/commands/curate-command.d.ts +9 -0
- package/dist/infra/repl/commands/curate-command.js +88 -0
- package/dist/infra/repl/commands/gen-rules-command.d.ts +7 -0
- package/dist/infra/repl/commands/gen-rules-command.js +38 -0
- package/dist/infra/repl/commands/index.d.ts +8 -0
- package/dist/infra/repl/commands/index.js +36 -0
- package/dist/infra/repl/commands/init-command.d.ts +7 -0
- package/dist/infra/repl/commands/init-command.js +83 -0
- package/dist/infra/repl/commands/login-command.d.ts +7 -0
- package/dist/infra/repl/commands/login-command.js +50 -0
- package/dist/infra/repl/commands/logout-command.d.ts +5 -0
- package/dist/infra/repl/commands/logout-command.js +48 -0
- package/dist/infra/repl/commands/pull-command.d.ts +5 -0
- package/dist/infra/repl/commands/pull-command.js +61 -0
- package/dist/infra/repl/commands/push-command.d.ts +5 -0
- package/dist/infra/repl/commands/push-command.js +66 -0
- package/dist/infra/repl/commands/query-command.d.ts +5 -0
- package/dist/infra/repl/commands/query-command.js +66 -0
- package/dist/infra/repl/commands/space/index.d.ts +5 -0
- package/dist/infra/repl/commands/space/index.js +14 -0
- package/dist/infra/repl/commands/space/list-command.d.ts +5 -0
- package/dist/infra/repl/commands/space/list-command.js +70 -0
- package/dist/infra/repl/commands/space/switch-command.d.ts +5 -0
- package/dist/infra/repl/commands/space/switch-command.js +37 -0
- package/dist/infra/repl/commands/status-command.d.ts +5 -0
- package/dist/infra/repl/commands/status-command.js +39 -0
- package/dist/infra/repl/repl-startup.d.ts +18 -0
- package/dist/infra/repl/repl-startup.js +26 -0
- package/dist/infra/storage/file-global-config-store.d.ts +22 -0
- package/dist/infra/storage/file-global-config-store.js +65 -0
- package/dist/infra/storage/file-onboarding-preference-store.d.ts +10 -0
- package/dist/infra/storage/file-onboarding-preference-store.js +46 -0
- package/dist/infra/terminal/oclif-terminal.d.ts +19 -0
- package/dist/infra/terminal/oclif-terminal.js +60 -0
- package/dist/infra/terminal/repl-terminal.d.ts +31 -0
- package/dist/infra/terminal/repl-terminal.js +116 -0
- package/dist/infra/tracking/mixpanel-tracking-service.d.ts +11 -1
- package/dist/infra/tracking/mixpanel-tracking-service.js +18 -13
- package/dist/infra/usecase/clear-use-case.d.ts +20 -0
- package/dist/infra/usecase/clear-use-case.js +58 -0
- package/dist/infra/usecase/curate-use-case.d.ts +66 -0
- package/dist/infra/usecase/curate-use-case.js +283 -0
- package/dist/{commands/gen-rules.d.ts → infra/usecase/generate-rules-use-case.d.ts} +14 -20
- package/dist/{commands/gen-rules.js → infra/usecase/generate-rules-use-case.js} +59 -78
- package/dist/infra/usecase/init-use-case.d.ts +139 -0
- package/dist/{commands/init.js → infra/usecase/init-use-case.js} +184 -230
- package/dist/infra/usecase/login-use-case.d.ts +28 -0
- package/dist/infra/usecase/login-use-case.js +88 -0
- package/dist/infra/usecase/logout-use-case.d.ts +22 -0
- package/dist/infra/usecase/logout-use-case.js +51 -0
- package/dist/infra/usecase/pull-use-case.d.ts +35 -0
- package/dist/infra/usecase/pull-use-case.js +89 -0
- package/dist/infra/usecase/push-use-case.d.ts +37 -0
- package/dist/infra/usecase/push-use-case.js +124 -0
- package/dist/infra/usecase/query-use-case.d.ts +78 -0
- package/dist/infra/usecase/query-use-case.js +401 -0
- package/dist/infra/usecase/space-list-use-case.d.ts +27 -0
- package/dist/infra/usecase/space-list-use-case.js +64 -0
- package/dist/infra/usecase/space-switch-use-case.d.ts +36 -0
- package/dist/infra/usecase/space-switch-use-case.js +140 -0
- package/dist/infra/usecase/status-use-case.d.ts +27 -0
- package/dist/infra/usecase/status-use-case.js +97 -0
- package/dist/infra/workspace/workspace-detector-service.d.ts +3 -6
- package/dist/resources/prompts/curate-context-tree-curation.yml +23 -11
- package/dist/resources/prompts/query-context-tree-retrieval.yml +3 -4
- package/dist/resources/prompts/system-prompt.yml +1 -1
- package/dist/resources/prompts/tool-outputs.yml +4 -3
- package/dist/templates/sections/command-reference.md +12 -0
- package/dist/templates/sections/workflow.md +10 -1
- package/dist/tui/app.d.ts +9 -0
- package/dist/tui/app.js +26 -0
- package/dist/tui/components/enter-prompt.d.ts +13 -0
- package/dist/tui/components/enter-prompt.js +15 -0
- package/dist/tui/components/execution/execution-changes.d.ts +14 -0
- package/dist/tui/components/execution/execution-changes.js +15 -0
- package/dist/tui/components/execution/execution-content.d.ts +25 -0
- package/dist/tui/components/execution/execution-content.js +67 -0
- package/dist/tui/components/execution/execution-input.d.ts +12 -0
- package/dist/tui/components/execution/execution-input.js +16 -0
- package/dist/tui/components/execution/execution-progress.d.ts +21 -0
- package/dist/tui/components/execution/execution-progress.js +21 -0
- package/dist/tui/components/execution/execution-status.d.ts +13 -0
- package/dist/tui/components/execution/execution-status.js +19 -0
- package/dist/tui/components/execution/index.d.ts +11 -0
- package/dist/tui/components/execution/index.js +11 -0
- package/dist/tui/components/execution/log-item.d.ts +17 -0
- package/dist/tui/components/execution/log-item.js +25 -0
- package/dist/tui/components/footer.d.ts +5 -0
- package/dist/tui/components/footer.js +12 -0
- package/dist/tui/components/header.d.ts +18 -0
- package/dist/tui/components/header.js +18 -0
- package/dist/tui/components/index.d.ts +17 -0
- package/dist/tui/components/index.js +14 -0
- package/dist/tui/components/inline-prompts/index.d.ts +15 -0
- package/dist/tui/components/inline-prompts/index.js +10 -0
- package/dist/tui/components/inline-prompts/inline-confirm.d.ts +17 -0
- package/dist/tui/components/inline-prompts/inline-confirm.js +32 -0
- package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +43 -0
- package/dist/tui/components/inline-prompts/inline-file-selector.js +185 -0
- package/dist/tui/components/inline-prompts/inline-input.d.ts +19 -0
- package/dist/tui/components/inline-prompts/inline-input.js +32 -0
- package/dist/tui/components/inline-prompts/inline-search.d.ts +20 -0
- package/dist/tui/components/inline-prompts/inline-search.js +50 -0
- package/dist/tui/components/inline-prompts/inline-select.d.ts +20 -0
- package/dist/tui/components/inline-prompts/inline-select.js +34 -0
- package/dist/tui/components/logo.d.ts +43 -0
- package/dist/tui/components/logo.js +103 -0
- package/dist/tui/components/message-item.d.ts +12 -0
- package/dist/tui/components/message-item.js +12 -0
- package/dist/tui/components/onboarding/copyable-prompt.d.ts +15 -0
- package/dist/tui/components/onboarding/copyable-prompt.js +65 -0
- package/dist/tui/components/onboarding/index.d.ts +7 -0
- package/dist/tui/components/onboarding/index.js +6 -0
- package/dist/tui/components/onboarding/onboarding-flow.d.ts +13 -0
- package/dist/tui/components/onboarding/onboarding-flow.js +304 -0
- package/dist/tui/components/onboarding/onboarding-step.d.ts +23 -0
- package/dist/tui/components/onboarding/onboarding-step.js +12 -0
- package/dist/tui/components/output-log.d.ts +14 -0
- package/dist/tui/components/output-log.js +13 -0
- package/dist/tui/components/scrollable-list.d.ts +30 -0
- package/dist/tui/components/scrollable-list.js +121 -0
- package/dist/tui/components/suggestions.d.ts +16 -0
- package/dist/tui/components/suggestions.js +162 -0
- package/dist/tui/components/tab-bar.d.ts +10 -0
- package/dist/tui/components/tab-bar.js +12 -0
- package/dist/tui/constants.d.ts +11 -0
- package/dist/tui/constants.js +13 -0
- package/dist/tui/contexts/auth-context.d.ts +30 -0
- package/dist/tui/contexts/auth-context.js +153 -0
- package/dist/tui/contexts/consumer.d.ts +31 -0
- package/dist/tui/contexts/consumer.js +56 -0
- package/dist/tui/contexts/index.d.ts +6 -0
- package/dist/tui/contexts/index.js +6 -0
- package/dist/tui/contexts/onboarding-context.d.ts +43 -0
- package/dist/tui/contexts/onboarding-context.js +181 -0
- package/dist/tui/contexts/services-context.d.ts +29 -0
- package/dist/tui/contexts/services-context.js +20 -0
- package/dist/tui/contexts/use-commands.d.ts +29 -0
- package/dist/tui/contexts/use-commands.js +53 -0
- package/dist/tui/contexts/use-mode.d.ts +43 -0
- package/dist/tui/contexts/use-mode.js +76 -0
- package/dist/tui/contexts/use-theme.d.ts +53 -0
- package/dist/tui/contexts/use-theme.js +60 -0
- package/dist/tui/hooks/index.d.ts +17 -0
- package/dist/tui/hooks/index.js +14 -0
- package/dist/tui/hooks/use-activity-logs.d.ts +26 -0
- package/dist/tui/hooks/use-activity-logs.js +90 -0
- package/dist/tui/hooks/use-consumer.d.ts +12 -0
- package/dist/tui/hooks/use-consumer.js +50 -0
- package/dist/tui/hooks/use-onboarding.d.ts +7 -0
- package/dist/tui/hooks/use-onboarding.js +6 -0
- package/dist/tui/hooks/use-queue-polling.d.ts +31 -0
- package/dist/tui/hooks/use-queue-polling.js +90 -0
- package/dist/tui/hooks/use-slash-command-processor.d.ts +16 -0
- package/dist/tui/hooks/use-slash-command-processor.js +132 -0
- package/dist/tui/hooks/use-slash-completion.d.ts +30 -0
- package/dist/tui/hooks/use-slash-completion.js +230 -0
- package/dist/tui/hooks/use-tab-navigation.d.ts +10 -0
- package/dist/tui/hooks/use-tab-navigation.js +35 -0
- package/dist/tui/hooks/use-visible-window.d.ts +22 -0
- package/dist/tui/hooks/use-visible-window.js +37 -0
- package/dist/tui/index.d.ts +1 -0
- package/dist/tui/index.js +1 -0
- package/dist/tui/providers/app-providers.d.ts +25 -0
- package/dist/tui/providers/app-providers.js +9 -0
- package/dist/tui/types/commands.d.ts +252 -0
- package/dist/tui/types/commands.js +16 -0
- package/dist/tui/types/dialogs.d.ts +37 -0
- package/dist/tui/types/dialogs.js +4 -0
- package/dist/tui/types/index.d.ts +11 -0
- package/dist/tui/types/index.js +7 -0
- package/dist/tui/types/messages.d.ts +55 -0
- package/dist/tui/types/messages.js +4 -0
- package/dist/tui/types/prompts.d.ts +100 -0
- package/dist/tui/types/prompts.js +4 -0
- package/dist/tui/types/ui.d.ts +14 -0
- package/dist/tui/types/ui.js +4 -0
- package/dist/tui/types.d.ts +1 -0
- package/dist/tui/types.js +1 -0
- package/dist/tui/views/command-view.d.ts +12 -0
- package/dist/tui/views/command-view.js +451 -0
- package/dist/tui/views/index.d.ts +6 -0
- package/dist/tui/views/index.js +6 -0
- package/dist/tui/views/login-view.d.ts +10 -0
- package/dist/tui/views/login-view.js +30 -0
- package/dist/tui/views/logs-view.d.ts +11 -0
- package/dist/tui/views/logs-view.js +73 -0
- package/dist/utils/file-validator.d.ts +16 -0
- package/dist/utils/file-validator.js +81 -0
- package/dist/utils/global-config-path.d.ts +15 -0
- package/dist/utils/global-config-path.js +38 -0
- package/oclif.manifest.json +29 -315
- package/package.json +11 -4
- package/dist/commands/clear.d.ts +0 -19
- package/dist/commands/clear.js +0 -78
- package/dist/commands/init.d.ts +0 -130
- package/dist/commands/login.d.ts +0 -22
- package/dist/commands/login.js +0 -108
- package/dist/commands/logout.d.ts +0 -16
- package/dist/commands/logout.js +0 -61
- package/dist/commands/pull.d.ts +0 -33
- package/dist/commands/pull.js +0 -115
- package/dist/commands/push.d.ts +0 -35
- package/dist/commands/push.js +0 -160
- package/dist/commands/space/list.d.ts +0 -25
- package/dist/commands/space/list.js +0 -114
- package/dist/commands/space/switch.d.ts +0 -36
- package/dist/commands/space/switch.js +0 -160
- package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +0 -149
- package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +0 -364
- package/dist/infra/cipher/grpc/internal-llm-grpc.proto +0 -94
package/dist/commands/watch.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
import type { IFileWatcherService } from '../core/interfaces/i-file-watcher-service.js';
|
|
3
3
|
import type { IProjectConfigStore } from '../core/interfaces/i-project-config-store.js';
|
|
4
|
+
import type { ITerminal } from '../core/interfaces/i-terminal.js';
|
|
4
5
|
export default class Watch extends Command {
|
|
5
6
|
static description: string;
|
|
6
7
|
static examples: string[];
|
|
@@ -10,6 +11,7 @@ export default class Watch extends Command {
|
|
|
10
11
|
paths: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
13
|
static hidden: boolean;
|
|
14
|
+
protected terminal: ITerminal;
|
|
13
15
|
private lastParseTime;
|
|
14
16
|
private parsingInProgress;
|
|
15
17
|
private pendingParse;
|
package/dist/commands/watch.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isDevelopment } from '../config/environment.js';
|
|
|
3
3
|
import { ProjectConfigStore } from '../infra/config/file-config-store.js';
|
|
4
4
|
import { CleanParserServiceFactory } from '../infra/parsers/clean/clean-parser-service-factory.js';
|
|
5
5
|
import { RawParserServiceFactory } from '../infra/parsers/raw/raw-parser-service-factory.js';
|
|
6
|
+
import { OclifTerminal } from '../infra/terminal/oclif-terminal.js';
|
|
6
7
|
import { FileWatcherService } from '../infra/watcher/file-watcher-service.js';
|
|
7
8
|
export default class Watch extends Command {
|
|
8
9
|
static description = 'Watch file system directories for changes and trigger parsing pipeline [Development only]';
|
|
@@ -30,21 +31,24 @@ export default class Watch extends Command {
|
|
|
30
31
|
}),
|
|
31
32
|
};
|
|
32
33
|
static hidden = !isDevelopment();
|
|
34
|
+
terminal = {};
|
|
33
35
|
lastParseTime = 0;
|
|
34
36
|
parsingInProgress = false;
|
|
35
37
|
pendingParse = false;
|
|
36
38
|
createServices() {
|
|
39
|
+
this.terminal = new OclifTerminal(this);
|
|
37
40
|
return {
|
|
38
41
|
fileWatcherService: new FileWatcherService(),
|
|
39
42
|
projectConfigStore: new ProjectConfigStore(),
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
async run() {
|
|
43
|
-
if (!isDevelopment()) {
|
|
44
|
-
this.error('This command is only available in development environment');
|
|
45
|
-
}
|
|
46
46
|
const { flags } = await this.parse(Watch);
|
|
47
47
|
const { fileWatcherService, projectConfigStore } = this.createServices();
|
|
48
|
+
if (!isDevelopment()) {
|
|
49
|
+
this.terminal.error('This command is only available in development environment');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
48
52
|
let paths = [];
|
|
49
53
|
let ideConfig = null;
|
|
50
54
|
// Use explicit paths if provided
|
|
@@ -60,7 +64,7 @@ export default class Watch extends Command {
|
|
|
60
64
|
if (config?.chatLogPath && config?.ide) {
|
|
61
65
|
paths = [config.chatLogPath];
|
|
62
66
|
ideConfig = config.ide;
|
|
63
|
-
this.log(`ℹ Using chat log path from config (${config.ide})`);
|
|
67
|
+
this.terminal.log(`ℹ Using chat log path from config (${config.ide})`);
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
}
|
|
@@ -68,7 +72,7 @@ export default class Watch extends Command {
|
|
|
68
72
|
// Silently ignore config loading errors
|
|
69
73
|
}
|
|
70
74
|
if (paths.length === 0) {
|
|
71
|
-
this.error('No paths specified. Either:\n' +
|
|
75
|
+
this.terminal.error('No paths specified. Either:\n' +
|
|
72
76
|
' 1. Use --paths flag: brv watch --paths ./logs,./outputs\n' +
|
|
73
77
|
' 2. Run "brv init" to configure IDE and detect workspaces');
|
|
74
78
|
}
|
|
@@ -76,28 +80,28 @@ export default class Watch extends Command {
|
|
|
76
80
|
try {
|
|
77
81
|
// Set up file event handler with parsing pipeline
|
|
78
82
|
fileWatcherService.setFileEventHandler(async (event) => {
|
|
79
|
-
this.log(`[${event.type}] ${event.path}`);
|
|
83
|
+
this.terminal.log(`[${event.type}] ${event.path}`);
|
|
80
84
|
// Only trigger parsing if IDE is configured
|
|
81
85
|
if (ideConfig && (event.type === 'add' || event.type === 'change' || event.type === 'unlink')) {
|
|
82
86
|
this.pendingParse = true;
|
|
83
87
|
// Debounce parsing to avoid too frequent triggers
|
|
84
88
|
if (!this.parsingInProgress && Date.now() - this.lastParseTime > flags.debounce) {
|
|
85
89
|
this.triggerParsing(ideConfig, paths[0]).catch((error) => {
|
|
86
|
-
this.warn(`⚠️ Parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
90
|
+
this.terminal.warn(`⚠️ Parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
await fileWatcherService.start(paths);
|
|
92
|
-
this.log(`\n🔍 Watching paths: ${paths.join(', ')}`);
|
|
96
|
+
this.terminal.log(`\n🔍 Watching paths: ${paths.join(', ')}`);
|
|
93
97
|
if (ideConfig) {
|
|
94
|
-
this.log(`📊 Parsing pipeline enabled for: ${ideConfig}`);
|
|
98
|
+
this.terminal.log(`📊 Parsing pipeline enabled for: ${ideConfig}`);
|
|
95
99
|
}
|
|
96
|
-
this.log('Press Ctrl+C to stop...\n');
|
|
100
|
+
this.terminal.log('Press Ctrl+C to stop...\n');
|
|
97
101
|
await this.waitForShutdownSignal();
|
|
98
102
|
}
|
|
99
103
|
catch (error) {
|
|
100
|
-
this.error(error instanceof Error ? error.message : 'Unknown Error');
|
|
104
|
+
this.terminal.error(error instanceof Error ? error.message : 'Unknown Error');
|
|
101
105
|
}
|
|
102
106
|
finally {
|
|
103
107
|
await fileWatcherService.stop();
|
|
@@ -106,7 +110,7 @@ export default class Watch extends Command {
|
|
|
106
110
|
async waitForShutdownSignal() {
|
|
107
111
|
return new Promise((resolve) => {
|
|
108
112
|
const handleSignal = () => {
|
|
109
|
-
this.log('\nShutting down watcher...');
|
|
113
|
+
this.terminal.log('\nShutting down watcher...');
|
|
110
114
|
process.off('SIGINT', handleSignal);
|
|
111
115
|
process.off('SIGTERM', handleSignal);
|
|
112
116
|
resolve();
|
|
@@ -126,10 +130,10 @@ export default class Watch extends Command {
|
|
|
126
130
|
// Normalize IDE name for factory
|
|
127
131
|
// Validate IDE is supported
|
|
128
132
|
if (!RawParserServiceFactory.isSupported(ide)) {
|
|
129
|
-
this.warn(`⚠️ Unsupported IDE: ${ide}`);
|
|
133
|
+
this.terminal.warn(`⚠️ Unsupported IDE: ${ide}`);
|
|
130
134
|
return;
|
|
131
135
|
}
|
|
132
|
-
this.log('\n📥 Parsing triggered...');
|
|
136
|
+
this.terminal.log('\n📥 Parsing triggered...');
|
|
133
137
|
// Raw parsing phase
|
|
134
138
|
let isRawSuccess = false;
|
|
135
139
|
try {
|
|
@@ -137,7 +141,7 @@ export default class Watch extends Command {
|
|
|
137
141
|
isRawSuccess = await RawParserServiceFactory.parseConversations(ide, chatLogPath);
|
|
138
142
|
}
|
|
139
143
|
catch (error) {
|
|
140
|
-
this.warn(`⚠️ Raw parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
144
|
+
this.terminal.warn(`⚠️ Raw parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
141
145
|
return;
|
|
142
146
|
}
|
|
143
147
|
// Clean parsing phase (if enabled)
|
|
@@ -147,14 +151,14 @@ export default class Watch extends Command {
|
|
|
147
151
|
const rawOutputDir = `${process.cwd()}/.brv/logs/${ide}/raw`;
|
|
148
152
|
const cleanSessions = await CleanParserServiceFactory.parseConversations(ide, rawOutputDir);
|
|
149
153
|
if (cleanSessions.length > 0) {
|
|
150
|
-
this.log('✅ Clean parsing complete\n');
|
|
154
|
+
this.terminal.log('✅ Clean parsing complete\n');
|
|
151
155
|
}
|
|
152
156
|
else {
|
|
153
|
-
this.warn('⚠️ Clean parsing failed');
|
|
157
|
+
this.terminal.warn('⚠️ Clean parsing failed');
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
catch (error) {
|
|
157
|
-
this.warn(`⚠️ Clean parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
161
|
+
this.terminal.warn(`⚠️ Clean parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
}
|
|
@@ -163,7 +167,7 @@ export default class Watch extends Command {
|
|
|
163
167
|
// If more files were added while parsing, queue another parse
|
|
164
168
|
if (this.pendingParse) {
|
|
165
169
|
this.triggerParsing(ide, chatLogPath).catch((error) => {
|
|
166
|
-
this.warn(`⚠️ Parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
+
this.terminal.warn(`⚠️ Parsing error: ${error instanceof Error ? error.message : String(error)}`);
|
|
167
171
|
});
|
|
168
172
|
}
|
|
169
173
|
}
|
|
@@ -15,7 +15,7 @@ export const ENV_CONFIG = {
|
|
|
15
15
|
clientId: 'byterover-cli-client',
|
|
16
16
|
cogitApiBaseUrl: 'https://dev-beta-cgit.byterover.dev/api/v1',
|
|
17
17
|
issuerUrl: 'https://dev-beta-iam.byterover.dev/api/v1/oidc',
|
|
18
|
-
|
|
18
|
+
llmApiBaseUrl: 'https://dev-beta-llm.byterover.dev',
|
|
19
19
|
memoraApiBaseUrl: 'https://dev-beta-memora-retrieve.byterover.dev/api/v3',
|
|
20
20
|
mixpanelToken: '258e1a2b3d44cc634ef28964771b1da0',
|
|
21
21
|
scopes: ['read', 'write', 'debug'],
|
|
@@ -28,7 +28,7 @@ export const ENV_CONFIG = {
|
|
|
28
28
|
clientId: 'byterover-cli',
|
|
29
29
|
cogitApiBaseUrl: 'https://beta-cgit.byterover.dev/api/v1',
|
|
30
30
|
issuerUrl: 'https://beta-iam.byterover.dev/api/v1/oidc',
|
|
31
|
-
|
|
31
|
+
llmApiBaseUrl: 'https://beta-llm.byterover.dev',
|
|
32
32
|
memoraApiBaseUrl: 'https://beta-memora-retrieve.byterover.dev/api/v3',
|
|
33
33
|
mixpanelToken: '4d1198b346d2d6ac75f2e77905cc65ac',
|
|
34
34
|
scopes: ['read', 'write'],
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export declare const BRV_DIR = ".brv";
|
|
2
|
+
export declare const BLOBS_DIR = "blobs";
|
|
2
3
|
export declare const PROJECT_CONFIG_FILE = "config.json";
|
|
3
4
|
export declare const BRV_CONFIG_VERSION = "0.0.1";
|
|
5
|
+
export declare const GLOBAL_CONFIG_DIR = "brv";
|
|
6
|
+
export declare const GLOBAL_CONFIG_FILE = "config.json";
|
|
7
|
+
export declare const GLOBAL_CONFIG_VERSION = "0.0.1";
|
|
4
8
|
export declare const ACE_DIR = "ace";
|
|
5
|
-
export declare const EXECUTOR_OUTPUTS_DIR = "executor-outputs";
|
|
6
|
-
export declare const REFLECTIONS_DIR = "reflections";
|
|
7
|
-
export declare const DELTAS_DIR = "deltas";
|
|
8
|
-
export declare const BULLETS_DIR = "bullets";
|
|
9
|
-
export declare const PLAYBOOK_FILE = "playbook.json";
|
|
10
9
|
export declare const PROJECT = "byterover";
|
|
11
10
|
export declare const CONTEXT_TREE_DIR = "context-tree";
|
|
12
11
|
export declare const CONTEXT_FILE = "context.md";
|
package/dist/constants.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export const BRV_DIR = '.brv';
|
|
2
|
+
export const BLOBS_DIR = 'blobs';
|
|
2
3
|
export const PROJECT_CONFIG_FILE = 'config.json';
|
|
3
4
|
export const BRV_CONFIG_VERSION = '0.0.1';
|
|
5
|
+
// Global config constants (user-level, stored in XDG config directory)
|
|
6
|
+
export const GLOBAL_CONFIG_DIR = 'brv';
|
|
7
|
+
export const GLOBAL_CONFIG_FILE = 'config.json';
|
|
8
|
+
export const GLOBAL_CONFIG_VERSION = '0.0.1';
|
|
4
9
|
// ACE directory structure constants
|
|
5
10
|
export const ACE_DIR = 'ace';
|
|
6
|
-
export const EXECUTOR_OUTPUTS_DIR = 'executor-outputs';
|
|
7
|
-
export const REFLECTIONS_DIR = 'reflections';
|
|
8
|
-
export const DELTAS_DIR = 'deltas';
|
|
9
|
-
export const BULLETS_DIR = 'bullets';
|
|
10
|
-
export const PLAYBOOK_FILE = 'playbook.json';
|
|
11
11
|
export const PROJECT = 'byterover';
|
|
12
12
|
// Context Tree directory structure constants
|
|
13
13
|
export const CONTEXT_TREE_DIR = 'context-tree';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for key-based storage operations
|
|
3
|
+
*/
|
|
4
|
+
export declare enum StorageErrorCode {
|
|
5
|
+
/** Batch operation failed (partial or complete) */
|
|
6
|
+
BATCH_FAILED = "BATCH_FAILED",
|
|
7
|
+
/** Concurrent modification detected */
|
|
8
|
+
CONCURRENT_MODIFICATION = "CONCURRENT_MODIFICATION",
|
|
9
|
+
/** Delete operation failed */
|
|
10
|
+
DELETE_FAILED = "DELETE_FAILED",
|
|
11
|
+
/** Invalid key format (empty, contains invalid characters) */
|
|
12
|
+
KEY_INVALID = "KEY_INVALID",
|
|
13
|
+
/** Key does not exist in storage */
|
|
14
|
+
KEY_NOT_FOUND = "KEY_NOT_FOUND",
|
|
15
|
+
/** Lock acquisition timed out */
|
|
16
|
+
LOCK_TIMEOUT = "LOCK_TIMEOUT",
|
|
17
|
+
/** Storage not initialized */
|
|
18
|
+
NOT_INITIALIZED = "NOT_INITIALIZED",
|
|
19
|
+
/** Read operation failed */
|
|
20
|
+
READ_FAILED = "READ_FAILED",
|
|
21
|
+
/** Serialization/deserialization failed */
|
|
22
|
+
SERIALIZATION_FAILED = "SERIALIZATION_FAILED",
|
|
23
|
+
/** Storage backend unavailable */
|
|
24
|
+
STORAGE_UNAVAILABLE = "STORAGE_UNAVAILABLE",
|
|
25
|
+
/** Write operation failed */
|
|
26
|
+
WRITE_FAILED = "WRITE_FAILED"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Storage error class with factory methods for creating specific error instances.
|
|
30
|
+
* Follows the same pattern as BlobError for consistency.
|
|
31
|
+
*/
|
|
32
|
+
export declare class StorageError extends Error {
|
|
33
|
+
readonly code: StorageErrorCode;
|
|
34
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
35
|
+
readonly suggestion?: string | undefined;
|
|
36
|
+
constructor(message: string, code: StorageErrorCode, details?: Record<string, unknown> | undefined, suggestion?: string | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* Create an error for batch operation failure.
|
|
39
|
+
*/
|
|
40
|
+
static batchFailed(operationCount: number, cause?: Error): StorageError;
|
|
41
|
+
/**
|
|
42
|
+
* Create an error for concurrent modification.
|
|
43
|
+
*/
|
|
44
|
+
static concurrentModification(key: readonly string[]): StorageError;
|
|
45
|
+
/**
|
|
46
|
+
* Create an error for delete failure.
|
|
47
|
+
*/
|
|
48
|
+
static deleteFailed(key: readonly string[], cause?: Error): StorageError;
|
|
49
|
+
/**
|
|
50
|
+
* Check if an error is a specific type of StorageError.
|
|
51
|
+
*/
|
|
52
|
+
static isCode(error: unknown, code: StorageErrorCode): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check if an error is a StorageError.
|
|
55
|
+
*/
|
|
56
|
+
static isStorageError(error: unknown): error is StorageError;
|
|
57
|
+
/**
|
|
58
|
+
* Create an error for invalid key format.
|
|
59
|
+
*/
|
|
60
|
+
static keyInvalid(key: readonly string[], reason: string): StorageError;
|
|
61
|
+
/**
|
|
62
|
+
* Create an error for key not found.
|
|
63
|
+
*/
|
|
64
|
+
static keyNotFound(key: readonly string[]): StorageError;
|
|
65
|
+
/**
|
|
66
|
+
* Create an error for lock timeout.
|
|
67
|
+
*/
|
|
68
|
+
static lockTimeout(target: string, timeoutMs: number): StorageError;
|
|
69
|
+
/**
|
|
70
|
+
* Create an error for uninitialized storage.
|
|
71
|
+
*/
|
|
72
|
+
static notInitialized(): StorageError;
|
|
73
|
+
/**
|
|
74
|
+
* Create an error for read failure.
|
|
75
|
+
*/
|
|
76
|
+
static readFailed(key: readonly string[], cause?: Error): StorageError;
|
|
77
|
+
/**
|
|
78
|
+
* Create an error for serialization failure.
|
|
79
|
+
*/
|
|
80
|
+
static serializationFailed(operation: 'deserialize' | 'serialize', cause?: Error): StorageError;
|
|
81
|
+
/**
|
|
82
|
+
* Create an error for unavailable storage backend.
|
|
83
|
+
*/
|
|
84
|
+
static storageUnavailable(reason: string, cause?: Error): StorageError;
|
|
85
|
+
/**
|
|
86
|
+
* Create an error for write failure.
|
|
87
|
+
*/
|
|
88
|
+
static writeFailed(key: readonly string[], cause?: Error): StorageError;
|
|
89
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for key-based storage operations
|
|
3
|
+
*/
|
|
4
|
+
export var StorageErrorCode;
|
|
5
|
+
(function (StorageErrorCode) {
|
|
6
|
+
/** Batch operation failed (partial or complete) */
|
|
7
|
+
StorageErrorCode["BATCH_FAILED"] = "BATCH_FAILED";
|
|
8
|
+
/** Concurrent modification detected */
|
|
9
|
+
StorageErrorCode["CONCURRENT_MODIFICATION"] = "CONCURRENT_MODIFICATION";
|
|
10
|
+
/** Delete operation failed */
|
|
11
|
+
StorageErrorCode["DELETE_FAILED"] = "DELETE_FAILED";
|
|
12
|
+
/** Invalid key format (empty, contains invalid characters) */
|
|
13
|
+
StorageErrorCode["KEY_INVALID"] = "KEY_INVALID";
|
|
14
|
+
/** Key does not exist in storage */
|
|
15
|
+
StorageErrorCode["KEY_NOT_FOUND"] = "KEY_NOT_FOUND";
|
|
16
|
+
/** Lock acquisition timed out */
|
|
17
|
+
StorageErrorCode["LOCK_TIMEOUT"] = "LOCK_TIMEOUT";
|
|
18
|
+
/** Storage not initialized */
|
|
19
|
+
StorageErrorCode["NOT_INITIALIZED"] = "NOT_INITIALIZED";
|
|
20
|
+
/** Read operation failed */
|
|
21
|
+
StorageErrorCode["READ_FAILED"] = "READ_FAILED";
|
|
22
|
+
/** Serialization/deserialization failed */
|
|
23
|
+
StorageErrorCode["SERIALIZATION_FAILED"] = "SERIALIZATION_FAILED";
|
|
24
|
+
/** Storage backend unavailable */
|
|
25
|
+
StorageErrorCode["STORAGE_UNAVAILABLE"] = "STORAGE_UNAVAILABLE";
|
|
26
|
+
/** Write operation failed */
|
|
27
|
+
StorageErrorCode["WRITE_FAILED"] = "WRITE_FAILED";
|
|
28
|
+
})(StorageErrorCode || (StorageErrorCode = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Storage error class with factory methods for creating specific error instances.
|
|
31
|
+
* Follows the same pattern as BlobError for consistency.
|
|
32
|
+
*/
|
|
33
|
+
export class StorageError extends Error {
|
|
34
|
+
code;
|
|
35
|
+
details;
|
|
36
|
+
suggestion;
|
|
37
|
+
constructor(message, code, details, suggestion) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.details = details;
|
|
41
|
+
this.suggestion = suggestion;
|
|
42
|
+
this.name = 'StorageError';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create an error for batch operation failure.
|
|
46
|
+
*/
|
|
47
|
+
static batchFailed(operationCount, cause) {
|
|
48
|
+
return new StorageError(`Batch operation failed with ${operationCount} operations`, StorageErrorCode.BATCH_FAILED, { cause: cause?.message, operationCount }, 'Check individual operation errors and retry the batch.');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create an error for concurrent modification.
|
|
52
|
+
*/
|
|
53
|
+
static concurrentModification(key) {
|
|
54
|
+
const keyPath = key.join(':');
|
|
55
|
+
return new StorageError(`Concurrent modification detected for: ${keyPath}`, StorageErrorCode.CONCURRENT_MODIFICATION, { key: keyPath }, 'The data was modified by another operation. Retry with fresh data.');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create an error for delete failure.
|
|
59
|
+
*/
|
|
60
|
+
static deleteFailed(key, cause) {
|
|
61
|
+
const keyPath = key.join(':');
|
|
62
|
+
return new StorageError(`Delete failed for key: ${keyPath}`, StorageErrorCode.DELETE_FAILED, { cause: cause?.message, key: keyPath }, 'Check storage permissions.');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if an error is a specific type of StorageError.
|
|
66
|
+
*/
|
|
67
|
+
static isCode(error, code) {
|
|
68
|
+
return error instanceof StorageError && error.code === code;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if an error is a StorageError.
|
|
72
|
+
*/
|
|
73
|
+
static isStorageError(error) {
|
|
74
|
+
return error instanceof StorageError;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create an error for invalid key format.
|
|
78
|
+
*/
|
|
79
|
+
static keyInvalid(key, reason) {
|
|
80
|
+
const keyPath = key.join(':');
|
|
81
|
+
return new StorageError(`Invalid key: ${keyPath} - ${reason}`, StorageErrorCode.KEY_INVALID, { key: keyPath, reason }, 'Keys must be non-empty arrays of strings without colon characters.');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create an error for key not found.
|
|
85
|
+
*/
|
|
86
|
+
static keyNotFound(key) {
|
|
87
|
+
const keyPath = key.join(':');
|
|
88
|
+
return new StorageError(`Key not found: ${keyPath}`, StorageErrorCode.KEY_NOT_FOUND, { key: keyPath }, 'Check if the key exists using exists() before accessing.');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create an error for lock timeout.
|
|
92
|
+
*/
|
|
93
|
+
static lockTimeout(target, timeoutMs) {
|
|
94
|
+
return new StorageError(`Lock acquisition timed out for: ${target} after ${timeoutMs}ms`, StorageErrorCode.LOCK_TIMEOUT, { target, timeoutMs }, 'The resource may be held by another operation. Try again later.');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create an error for uninitialized storage.
|
|
98
|
+
*/
|
|
99
|
+
static notInitialized() {
|
|
100
|
+
return new StorageError('Storage not initialized', StorageErrorCode.NOT_INITIALIZED, undefined, 'Call initialize() before performing any storage operations.');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create an error for read failure.
|
|
104
|
+
*/
|
|
105
|
+
static readFailed(key, cause) {
|
|
106
|
+
const keyPath = key.join(':');
|
|
107
|
+
return new StorageError(`Read failed for key: ${keyPath}`, StorageErrorCode.READ_FAILED, { cause: cause?.message, key: keyPath }, 'Check if the storage is accessible and the data is not corrupted.');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create an error for serialization failure.
|
|
111
|
+
*/
|
|
112
|
+
static serializationFailed(operation, cause) {
|
|
113
|
+
return new StorageError(`Failed to ${operation} data`, StorageErrorCode.SERIALIZATION_FAILED, { cause: cause?.message, operation }, operation === 'serialize'
|
|
114
|
+
? 'Ensure the data is JSON-serializable (no circular references, BigInt, etc.).'
|
|
115
|
+
: 'The stored data may be corrupted or in an unexpected format.');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create an error for unavailable storage backend.
|
|
119
|
+
*/
|
|
120
|
+
static storageUnavailable(reason, cause) {
|
|
121
|
+
return new StorageError(`Storage unavailable: ${reason}`, StorageErrorCode.STORAGE_UNAVAILABLE, { cause: cause?.message, reason }, 'Check database connection and file system access.');
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create an error for write failure.
|
|
125
|
+
*/
|
|
126
|
+
static writeFailed(key, cause) {
|
|
127
|
+
const keyPath = key.join(':');
|
|
128
|
+
return new StorageError(`Write failed for key: ${keyPath}`, StorageErrorCode.WRITE_FAILED, { cause: cause?.message, key: keyPath }, 'Check storage permissions and available space.');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue/Execution domain types for the agent storage system.
|
|
3
|
+
*
|
|
4
|
+
* These types represent the core domain entities for:
|
|
5
|
+
* - Execution queue (curate/query jobs)
|
|
6
|
+
* - Tool call tracking
|
|
7
|
+
* - Consumer lock management
|
|
8
|
+
*/
|
|
9
|
+
export type ExecutionType = 'curate' | 'query';
|
|
10
|
+
export type ExecutionStatus = 'completed' | 'failed' | 'queued' | 'running';
|
|
11
|
+
/**
|
|
12
|
+
* Represents a single execution job in the queue.
|
|
13
|
+
*/
|
|
14
|
+
export interface Execution {
|
|
15
|
+
completedAt?: number;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
error?: string;
|
|
18
|
+
id: string;
|
|
19
|
+
input: string;
|
|
20
|
+
pid?: number;
|
|
21
|
+
result?: string;
|
|
22
|
+
startedAt?: number;
|
|
23
|
+
status: ExecutionStatus;
|
|
24
|
+
type: ExecutionType;
|
|
25
|
+
updatedAt: number;
|
|
26
|
+
}
|
|
27
|
+
export type ToolCallStatus = 'completed' | 'failed' | 'running';
|
|
28
|
+
/**
|
|
29
|
+
* Represents a tool call made during an execution.
|
|
30
|
+
*/
|
|
31
|
+
export interface ToolCall {
|
|
32
|
+
args: string;
|
|
33
|
+
charsCount?: number;
|
|
34
|
+
completedAt?: number;
|
|
35
|
+
description?: string;
|
|
36
|
+
durationMs?: number;
|
|
37
|
+
executionId: string;
|
|
38
|
+
id: string;
|
|
39
|
+
linesCount?: number;
|
|
40
|
+
name: string;
|
|
41
|
+
result?: string;
|
|
42
|
+
resultSummary?: string;
|
|
43
|
+
startedAt: number;
|
|
44
|
+
status: ToolCallStatus;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Input for creating a new tool call record.
|
|
48
|
+
*/
|
|
49
|
+
export interface ToolCallInfo {
|
|
50
|
+
args: Record<string, unknown>;
|
|
51
|
+
description?: string;
|
|
52
|
+
name: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for updating an existing tool call.
|
|
56
|
+
*/
|
|
57
|
+
export interface ToolCallUpdateOptions {
|
|
58
|
+
charsCount?: number;
|
|
59
|
+
linesCount?: number;
|
|
60
|
+
result?: string;
|
|
61
|
+
resultSummary?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Represents an active consumer lock.
|
|
65
|
+
*/
|
|
66
|
+
export interface ConsumerLock {
|
|
67
|
+
id: string;
|
|
68
|
+
lastHeartbeat: number;
|
|
69
|
+
pid: number;
|
|
70
|
+
startedAt: number;
|
|
71
|
+
}
|