byterover-cli 2.0.0 → 2.1.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 +6 -81
- package/dist/agent/core/domain/llm/index.d.ts +1 -1
- package/dist/agent/core/domain/llm/index.js +1 -1
- package/dist/agent/core/domain/llm/registry.d.ts +8 -0
- package/dist/agent/core/domain/llm/registry.js +34 -0
- package/dist/agent/core/domain/sandbox/types.d.ts +2 -0
- package/dist/agent/core/domain/tools/constants.d.ts +3 -0
- package/dist/agent/core/domain/tools/constants.js +3 -0
- package/dist/agent/core/interfaces/cipher-services.d.ts +2 -4
- package/dist/agent/core/interfaces/i-cipher-agent.d.ts +9 -1
- package/dist/agent/core/interfaces/i-sandbox-service.d.ts +8 -0
- package/dist/agent/core/interfaces/i-tool-provider.d.ts +10 -0
- package/dist/agent/core/interfaces/i-tool-scheduler.d.ts +9 -0
- package/dist/agent/infra/agent/agent-schemas.d.ts +0 -9
- package/dist/agent/infra/agent/agent-schemas.js +0 -3
- package/dist/agent/infra/agent/cipher-agent.d.ts +25 -1
- package/dist/agent/infra/agent/cipher-agent.js +138 -11
- package/dist/agent/infra/agent/provider-update-config.d.ts +0 -2
- package/dist/agent/infra/agent/service-initializer.d.ts +2 -6
- package/dist/agent/infra/agent/service-initializer.js +45 -38
- package/dist/agent/infra/blob/blob-storage-factory.d.ts +2 -2
- package/dist/agent/infra/blob/blob-storage-factory.js +4 -4
- package/dist/agent/infra/blob/file-blob-storage.d.ts +96 -0
- package/dist/agent/infra/blob/file-blob-storage.js +454 -0
- package/dist/agent/infra/blob/index.d.ts +2 -3
- package/dist/agent/infra/blob/index.js +4 -6
- package/dist/agent/infra/llm/agent-llm-service.d.ts +3 -0
- package/dist/agent/infra/llm/agent-llm-service.js +34 -52
- package/dist/agent/infra/llm/context/compression/compression-helpers.d.ts +35 -0
- package/dist/agent/infra/llm/context/compression/compression-helpers.js +124 -0
- package/dist/agent/infra/llm/context/compression/escalated-compression.d.ts +62 -0
- package/dist/agent/infra/llm/context/compression/escalated-compression.js +144 -0
- package/dist/agent/infra/llm/context/compression/index.d.ts +3 -0
- package/dist/agent/infra/llm/context/compression/index.js +3 -0
- package/dist/agent/infra/llm/context/compression/reactive-overflow.d.ts +0 -27
- package/dist/agent/infra/llm/context/compression/reactive-overflow.js +5 -122
- package/dist/agent/infra/llm/context/context-manager.d.ts +20 -1
- package/dist/agent/infra/llm/context/context-manager.js +37 -7
- package/dist/agent/infra/llm/providers/index.js +0 -2
- package/dist/agent/infra/llm/providers/types.d.ts +1 -5
- package/dist/agent/infra/map/agentic-map-service.d.ts +97 -0
- package/dist/agent/infra/map/agentic-map-service.js +309 -0
- package/dist/agent/infra/map/context-tree-store.d.ts +94 -0
- package/dist/agent/infra/map/context-tree-store.js +278 -0
- package/dist/agent/infra/map/index.d.ts +4 -0
- package/dist/agent/infra/map/index.js +4 -0
- package/dist/agent/infra/map/llm-map-memory.d.ts +59 -0
- package/dist/agent/infra/map/llm-map-memory.js +187 -0
- package/dist/agent/infra/map/llm-map-service.d.ts +36 -0
- package/dist/agent/infra/map/llm-map-service.js +118 -0
- package/dist/agent/infra/map/map-shared.d.ts +140 -0
- package/dist/agent/infra/map/map-shared.js +325 -0
- package/dist/agent/infra/map/worker-pool.d.ts +45 -0
- package/dist/agent/infra/map/worker-pool.js +73 -0
- package/dist/agent/infra/sandbox/curation-helpers.d.ts +62 -0
- package/dist/agent/infra/sandbox/curation-helpers.js +219 -0
- package/dist/agent/infra/sandbox/sandbox-service.d.ts +12 -0
- package/dist/agent/infra/sandbox/sandbox-service.js +39 -7
- package/dist/agent/infra/sandbox/tools-sdk.d.ts +48 -1
- package/dist/agent/infra/sandbox/tools-sdk.js +52 -1
- package/dist/agent/infra/session/session-manager.d.ts +8 -1
- package/dist/agent/infra/session/session-manager.js +24 -4
- package/dist/agent/infra/storage/file-key-storage.d.ts +142 -0
- package/dist/agent/infra/storage/file-key-storage.js +572 -0
- package/dist/agent/infra/storage/granular-history-storage.d.ts +1 -1
- package/dist/agent/infra/storage/granular-history-storage.js +1 -1
- package/dist/agent/infra/system-prompt/contributors/context-tree-structure-contributor.d.ts +4 -0
- package/dist/agent/infra/system-prompt/contributors/context-tree-structure-contributor.js +42 -14
- package/dist/agent/infra/system-prompt/contributors/map-selection-contributor.d.ts +16 -0
- package/dist/agent/infra/system-prompt/contributors/map-selection-contributor.js +47 -0
- package/dist/agent/infra/tools/core-tool-scheduler.js +3 -1
- package/dist/agent/infra/tools/implementations/agentic-map-tool.d.ts +35 -0
- package/dist/agent/infra/tools/implementations/agentic-map-tool.js +156 -0
- package/dist/agent/infra/tools/implementations/code-exec-tool.js +1 -0
- package/dist/agent/infra/tools/implementations/curate-tool.d.ts +9 -9
- package/dist/agent/infra/tools/implementations/expand-knowledge-tool.d.ts +18 -0
- package/dist/agent/infra/tools/implementations/expand-knowledge-tool.js +43 -0
- package/dist/agent/infra/tools/implementations/llm-map-tool.d.ts +24 -0
- package/dist/agent/infra/tools/implementations/llm-map-tool.js +87 -0
- package/dist/agent/infra/tools/implementations/memory-symbol-tree.d.ts +28 -1
- package/dist/agent/infra/tools/implementations/memory-symbol-tree.js +27 -3
- package/dist/agent/infra/tools/implementations/search-knowledge-service.d.ts +1 -0
- package/dist/agent/infra/tools/implementations/search-knowledge-service.js +83 -12
- package/dist/agent/infra/tools/implementations/search-knowledge-tool.js +2 -2
- package/dist/agent/infra/tools/tool-manager.js +6 -0
- package/dist/agent/infra/tools/tool-provider.d.ts +12 -0
- package/dist/agent/infra/tools/tool-provider.js +78 -0
- package/dist/agent/infra/tools/tool-registry.d.ts +14 -0
- package/dist/agent/infra/tools/tool-registry.js +32 -0
- package/dist/agent/resources/prompts/system-prompt.yml +48 -74
- package/dist/agent/resources/tools/expand_knowledge.txt +20 -0
- package/dist/oclif/commands/curate/index.js +1 -2
- package/dist/oclif/commands/main.js +1 -0
- package/dist/oclif/commands/providers/connect.d.ts +1 -3
- package/dist/oclif/commands/providers/connect.js +7 -29
- package/dist/oclif/commands/query.js +1 -2
- package/dist/server/constants.d.ts +7 -0
- package/dist/server/constants.js +8 -0
- package/dist/server/core/domain/entities/provider-registry.js +1 -15
- package/dist/server/core/domain/knowledge/memory-scoring.js +1 -1
- package/dist/server/core/domain/knowledge/summary-types.d.ts +126 -0
- package/dist/server/core/domain/knowledge/summary-types.js +7 -0
- package/dist/server/core/domain/transport/schemas.d.ts +0 -4
- package/dist/server/core/interfaces/context-tree/i-context-tree-archive-service.d.ts +30 -0
- package/dist/server/core/interfaces/context-tree/i-context-tree-archive-service.js +1 -0
- package/dist/server/core/interfaces/context-tree/i-context-tree-manifest-service.d.ts +30 -0
- package/dist/server/core/interfaces/context-tree/i-context-tree-manifest-service.js +1 -0
- package/dist/server/core/interfaces/context-tree/i-context-tree-summary-service.d.ts +29 -0
- package/dist/server/core/interfaces/context-tree/i-context-tree-summary-service.js +1 -0
- package/dist/server/infra/cogit/context-tree-to-push-context-mapper.js +10 -3
- package/dist/server/infra/connectors/skill/skill-connector.d.ts +4 -0
- package/dist/server/infra/connectors/skill/skill-connector.js +4 -0
- package/dist/server/infra/context-tree/children-hash.d.ts +20 -0
- package/dist/server/infra/context-tree/children-hash.js +22 -0
- package/dist/server/infra/context-tree/derived-artifact.d.ts +28 -0
- package/dist/server/infra/context-tree/derived-artifact.js +48 -0
- package/dist/server/infra/context-tree/file-context-tree-archive-service.d.ts +37 -0
- package/dist/server/infra/context-tree/file-context-tree-archive-service.js +219 -0
- package/dist/server/infra/context-tree/file-context-tree-manifest-service.d.ts +50 -0
- package/dist/server/infra/context-tree/file-context-tree-manifest-service.js +278 -0
- package/dist/server/infra/context-tree/file-context-tree-merger.js +4 -0
- package/dist/server/infra/context-tree/file-context-tree-snapshot-service.js +12 -4
- package/dist/server/infra/context-tree/file-context-tree-summary-service.d.ts +44 -0
- package/dist/server/infra/context-tree/file-context-tree-summary-service.js +313 -0
- package/dist/server/infra/context-tree/file-context-tree-writer-service.js +5 -0
- package/dist/server/infra/context-tree/prompts/summary-generation.d.ts +22 -0
- package/dist/server/infra/context-tree/prompts/summary-generation.js +45 -0
- package/dist/server/infra/context-tree/snapshot-diff.d.ts +19 -0
- package/dist/server/infra/context-tree/snapshot-diff.js +39 -0
- package/dist/server/infra/context-tree/summary-frontmatter.d.ts +24 -0
- package/dist/server/infra/context-tree/summary-frontmatter.js +111 -0
- package/dist/server/infra/daemon/agent-process.js +2 -14
- package/dist/server/infra/executor/curate-executor.d.ts +1 -0
- package/dist/server/infra/executor/curate-executor.js +82 -34
- package/dist/server/infra/executor/folder-pack-executor.js +1 -1
- package/dist/server/infra/executor/pre-compaction/compaction-escalation.d.ts +6 -0
- package/dist/server/infra/executor/pre-compaction/compaction-escalation.js +6 -0
- package/dist/server/infra/executor/pre-compaction/index.d.ts +3 -0
- package/dist/server/infra/executor/pre-compaction/index.js +1 -0
- package/dist/server/infra/executor/pre-compaction/pre-compaction-service.d.ts +59 -0
- package/dist/server/infra/executor/pre-compaction/pre-compaction-service.js +124 -0
- package/dist/server/infra/executor/pre-compaction/prompts.d.ts +24 -0
- package/dist/server/infra/executor/pre-compaction/prompts.js +47 -0
- package/dist/server/infra/executor/query-executor.d.ts +3 -0
- package/dist/server/infra/executor/query-executor.js +39 -4
- package/dist/server/infra/http/authenticated-http-client.js +4 -0
- package/dist/server/infra/http/provider-model-fetcher-registry.js +1 -5
- package/dist/server/infra/http/provider-model-fetchers.d.ts +0 -14
- package/dist/server/infra/http/provider-model-fetchers.js +0 -132
- package/dist/server/infra/provider/provider-config-resolver.js +0 -55
- package/dist/server/utils/curate-result-parser.d.ts +4 -4
- package/dist/shared/constants/curation.d.ts +6 -0
- package/dist/shared/constants/curation.js +6 -0
- package/dist/shared/utils/escalation-utils.d.ts +59 -0
- package/dist/shared/utils/escalation-utils.js +141 -0
- package/dist/tui/components/command-input.js +1 -1
- package/dist/tui/components/inline-prompts/inline-confirm.js +6 -1
- package/dist/tui/features/commands/definitions/exit.d.ts +2 -0
- package/dist/tui/features/commands/definitions/exit.js +9 -0
- package/dist/tui/features/commands/definitions/index.js +3 -0
- package/dist/tui/features/exit/components/exit-flow.d.ts +10 -0
- package/dist/tui/features/exit/components/exit-flow.js +19 -0
- package/dist/tui/features/provider/components/provider-flow.js +1 -21
- package/oclif.manifest.json +100 -109
- package/package.json +11 -4
- package/dist/agent/infra/blob/migrations.d.ts +0 -63
- package/dist/agent/infra/blob/migrations.js +0 -148
- package/dist/agent/infra/blob/sqlite-blob-storage.d.ts +0 -82
- package/dist/agent/infra/blob/sqlite-blob-storage.js +0 -307
- package/dist/agent/infra/llm/providers/google-vertex.d.ts +0 -15
- package/dist/agent/infra/llm/providers/google-vertex.js +0 -36
- package/dist/agent/infra/storage/blob-history-storage.d.ts +0 -81
- package/dist/agent/infra/storage/blob-history-storage.js +0 -193
- package/dist/agent/infra/storage/dual-format-history-storage.d.ts +0 -83
- package/dist/agent/infra/storage/dual-format-history-storage.js +0 -165
- package/dist/agent/infra/storage/sqlite-key-storage.d.ts +0 -113
- package/dist/agent/infra/storage/sqlite-key-storage.js +0 -438
- package/dist/server/infra/provider/vertex-ai-utils.d.ts +0 -10
- package/dist/server/infra/provider/vertex-ai-utils.js +0 -28
- package/dist/tui/features/provider/components/credential-path-dialog.d.ts +0 -30
- package/dist/tui/features/provider/components/credential-path-dialog.js +0 -85
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ByteRover CLI
|
|
2
2
|
|
|
3
|
-
Command-line interface for ByteRover — an interactive REPL for managing your project's context tree and knowledge storage. Integrates with 22 AI coding agents
|
|
3
|
+
Command-line interface for ByteRover — an interactive REPL for managing your project's context tree and knowledge storage. Integrates with 22+ AI coding agents.
|
|
4
4
|
|
|
5
5
|
[](https://npmjs.org/package/byterover-cli)
|
|
6
6
|
[](https://npmjs.org/package/byterover-cli)
|
|
@@ -31,102 +31,27 @@ npm install -g byterover-cli
|
|
|
31
31
|
brv --version
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
### Uninstall
|
|
35
|
-
|
|
36
|
-
If installed via `curl`:
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
curl -fsSL https://byterover.dev/uninstall.sh | sh
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
If installed via `npm`:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npm uninstall -g byterover-cli
|
|
46
|
-
```
|
|
47
|
-
|
|
48
34
|
## Quick Start
|
|
49
35
|
|
|
50
|
-
Visit [**ByteRover Docs**](https://docs.byterover.dev) for detailed guides.
|
|
51
|
-
|
|
52
|
-
### 1. Start the REPL
|
|
53
|
-
|
|
54
36
|
```bash
|
|
55
37
|
cd your/project
|
|
56
38
|
brv
|
|
57
39
|
```
|
|
58
40
|
|
|
59
|
-
The REPL auto-configures on first run — no setup
|
|
60
|
-
|
|
61
|
-
### 2. Curate and query
|
|
62
|
-
|
|
63
|
-
Use `/curate` to add knowledge to your context tree and `/query` to retrieve it:
|
|
41
|
+
The REPL auto-configures on first run — no setup needed. Use `/curate` to add knowledge and `/query` to retrieve it:
|
|
64
42
|
|
|
65
43
|
```
|
|
66
44
|
/curate "Auth uses JWT with 24h expiry" @src/middleware/auth.ts
|
|
67
45
|
/query How is authentication implemented?
|
|
68
46
|
```
|
|
69
47
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Authentication is only needed for syncing your context tree to the cloud via `/push` and `/pull`. Local usage works without login.
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
brv login -k <your-api-key>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Get your API key at [app.byterover.dev/settings/keys](https://app.byterover.dev/settings/keys).
|
|
79
|
-
|
|
80
|
-
### 4. (Optional) Connect an LLM provider
|
|
81
|
-
|
|
82
|
-
ByteRover works out of the box with its built-in provider. To use your own models, run `/providers` in the REPL to connect one of 20+ supported providers (Anthropic, OpenAI, Google, Groq, Mistral, and more).
|
|
83
|
-
|
|
84
|
-
## Supported AI Agents
|
|
85
|
-
|
|
86
|
-
ByteRover integrates with 22 AI coding agents including Claude Code, Cursor, Windsurf, GitHub Copilot, Cline, Codex, Gemini CLI, Roo Code, Kiro, and more. Use `/connectors` in the REPL to manage integrations.
|
|
87
|
-
|
|
88
|
-
See [ByteRover Docs](https://docs.byterover.dev) for the full list and integration details.
|
|
89
|
-
|
|
90
|
-
## Key Commands
|
|
91
|
-
|
|
92
|
-
### REPL Commands
|
|
93
|
-
|
|
94
|
-
| Command | Description |
|
|
95
|
-
|-------------------------------------|-------------|
|
|
96
|
-
| `/curate [context] @files @folders` | Add context to the context tree |
|
|
97
|
-
| `/query <question>` | Query the context tree (alias: `/q`) |
|
|
98
|
-
| `/push [-b branch]` | Push context tree to cloud |
|
|
99
|
-
| `/pull [-b branch]` | Pull context tree from cloud |
|
|
100
|
-
| `/connectors` | Manage AI agent connectors |
|
|
101
|
-
| `/hub` | Browse and install skills from the hub |
|
|
102
|
-
| `/providers` | Connect an LLM provider |
|
|
103
|
-
| `/model` | Select an LLM model |
|
|
104
|
-
| `/status` | Show project and CLI status |
|
|
105
|
-
| `/space` | Manage spaces |
|
|
106
|
-
| `/new` | Start a fresh session |
|
|
107
|
-
| `/login` / `/logout` | Authenticate or log out |
|
|
108
|
-
|
|
109
|
-
Type `/` in the REPL to see all commands with auto-completion.
|
|
110
|
-
|
|
111
|
-
### CLI Commands
|
|
112
|
-
|
|
113
|
-
| Command | Description |
|
|
114
|
-
|---------|-------------|
|
|
115
|
-
| `brv` | Start the interactive REPL |
|
|
116
|
-
| `brv login -k <key>` | Authenticate with an API key |
|
|
117
|
-
| `brv status` | Show CLI and project status |
|
|
118
|
-
| `brv query <question>` | Query the context tree |
|
|
119
|
-
| `brv curate [context]` | Curate context to the context tree |
|
|
120
|
-
| `brv push` | Push context tree to cloud |
|
|
121
|
-
| `brv pull` | Pull context tree from cloud |
|
|
48
|
+
Type `/` in the REPL to discover all available commands.
|
|
122
49
|
|
|
123
|
-
|
|
50
|
+
## Documentation
|
|
124
51
|
|
|
125
|
-
|
|
52
|
+
Visit [**docs.byterover.dev**](https://docs.byterover.dev) for full guides on cloud sync, AI agent integrations, LLM providers, and more.
|
|
126
53
|
|
|
127
|
-
|
|
128
|
-
- `brv --help` — CLI help
|
|
129
|
-
- Type `/` in the REPL — Command discovery
|
|
54
|
+
Run `brv --help` for CLI usage.
|
|
130
55
|
|
|
131
56
|
---
|
|
132
57
|
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* Exports types, registry, and utilities for LLM provider abstraction.
|
|
5
5
|
*/
|
|
6
6
|
export { ErrorScope, type ErrorScopeType, ErrorType, type ErrorTypeValue, LLMErrorCode, type LLMErrorCodeType, } from './error-codes.js';
|
|
7
|
-
export { acceptsAnyModel, DEFAULT_CHARS_PER_TOKEN, DEFAULT_MAX_INPUT_TOKENS, getCharsPerToken, getDefaultModelForProvider, getEffectiveMaxInputTokens, getMaxInputTokensForModel, getModelCapabilities, getModelInfo, getModelInfoWithFallback, getProviderFromModel, getSupportedFileTypesForModel, getSupportedModels, isValidProviderModel, LLM_REGISTRY, modelSupportsFileType, } from './registry.js';
|
|
7
|
+
export { acceptsAnyModel, DEFAULT_CHARS_PER_TOKEN, DEFAULT_MAX_INPUT_TOKENS, getCharsPerToken, getDefaultModelForProvider, getEffectiveMaxInputTokens, getMaxInputTokensForModel, getModelCapabilities, getModelInfo, getModelInfoWithFallback, getProviderFromModel, getSupportedFileTypesForModel, getSupportedModels, isValidProviderModel, LLM_REGISTRY, modelSupportsFileType, resolveRegistryProvider, } from './registry.js';
|
|
8
8
|
export { type LLMConfig, LLMConfigBaseSchema, LLMConfigSchema, type LLMUpdates, LLMUpdatesSchema, safeParseLLMConfig, type ValidatedLLMConfig, validateLLMConfig, validateLLMUpdates, } from './schemas.js';
|
|
9
9
|
export { getAllowedMimeTypes, getFileTypeFromMimeType, isSupportedMimeType, LLM_PROVIDERS, type LLMContext, type LLMProvider, type LLMTokenUsage, MIME_TYPE_TO_FILE_TYPE, type ModelCapabilities, type ModelInfo, PROVIDER_TYPES, type ProviderInfo, type ProviderType, SUPPORTED_FILE_TYPES, type SupportedFileType, } from './types.js';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Error Codes
|
|
7
7
|
export { ErrorScope, ErrorType, LLMErrorCode, } from './error-codes.js';
|
|
8
8
|
// Registry
|
|
9
|
-
export { acceptsAnyModel, DEFAULT_CHARS_PER_TOKEN, DEFAULT_MAX_INPUT_TOKENS, getCharsPerToken, getDefaultModelForProvider, getEffectiveMaxInputTokens, getMaxInputTokensForModel, getModelCapabilities, getModelInfo, getModelInfoWithFallback, getProviderFromModel, getSupportedFileTypesForModel, getSupportedModels, isValidProviderModel, LLM_REGISTRY, modelSupportsFileType, } from './registry.js';
|
|
9
|
+
export { acceptsAnyModel, DEFAULT_CHARS_PER_TOKEN, DEFAULT_MAX_INPUT_TOKENS, getCharsPerToken, getDefaultModelForProvider, getEffectiveMaxInputTokens, getMaxInputTokensForModel, getModelCapabilities, getModelInfo, getModelInfoWithFallback, getProviderFromModel, getSupportedFileTypesForModel, getSupportedModels, isValidProviderModel, LLM_REGISTRY, modelSupportsFileType, resolveRegistryProvider, } from './registry.js';
|
|
10
10
|
// Schemas
|
|
11
11
|
export { LLMConfigBaseSchema, LLMConfigSchema, LLMUpdatesSchema, safeParseLLMConfig, validateLLMConfig, validateLLMUpdates, } from './schemas.js';
|
|
12
12
|
// Types
|
|
@@ -104,6 +104,14 @@ export declare function getModelCapabilities(provider: LLMProvider, model: strin
|
|
|
104
104
|
* @returns Effective max input tokens (min of model limit and configured limit)
|
|
105
105
|
*/
|
|
106
106
|
export declare function getEffectiveMaxInputTokens(provider: LLMProvider, model: string, configuredMax?: number): number;
|
|
107
|
+
/**
|
|
108
|
+
* Resolve a user-facing provider ID (e.g. 'anthropic', 'openrouter', 'google-vertex')
|
|
109
|
+
* to a registry provider type ('claude' | 'gemini' | 'openai').
|
|
110
|
+
*
|
|
111
|
+
* Used by both AgentLLMService (tokenizer/formatter selection) and CipherAgent
|
|
112
|
+
* (registry-clamped maxInputTokens for map tools).
|
|
113
|
+
*/
|
|
114
|
+
export declare function resolveRegistryProvider(model: string, explicitProvider?: string): LLMProvider;
|
|
107
115
|
/**
|
|
108
116
|
* Check if OpenRouter accepts any model (custom models).
|
|
109
117
|
* OpenRouter can route to many models not in our registry.
|
|
@@ -622,6 +622,40 @@ export function getEffectiveMaxInputTokens(provider, model, configuredMax) {
|
|
|
622
622
|
// Trust configuredMax when provided — it comes from an authoritative source like the OpenRouter API.
|
|
623
623
|
return configuredMax ?? DEFAULT_MAX_INPUT_TOKENS;
|
|
624
624
|
}
|
|
625
|
+
/**
|
|
626
|
+
* Resolve a user-facing provider ID (e.g. 'anthropic', 'openrouter', 'google-vertex')
|
|
627
|
+
* to a registry provider type ('claude' | 'gemini' | 'openai').
|
|
628
|
+
*
|
|
629
|
+
* Used by both AgentLLMService (tokenizer/formatter selection) and CipherAgent
|
|
630
|
+
* (registry-clamped maxInputTokens for map tools).
|
|
631
|
+
*/
|
|
632
|
+
export function resolveRegistryProvider(model, explicitProvider) {
|
|
633
|
+
// 1. Explicit provider mapping takes priority
|
|
634
|
+
if (explicitProvider) {
|
|
635
|
+
if (explicitProvider === 'anthropic')
|
|
636
|
+
return 'claude';
|
|
637
|
+
if (explicitProvider === 'google' || explicitProvider === 'google-vertex')
|
|
638
|
+
return 'gemini';
|
|
639
|
+
if (['groq', 'mistral', 'openai', 'openai-compatible', 'openrouter', 'xai'].includes(explicitProvider)) {
|
|
640
|
+
return 'openai';
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
// 2. Use registry to detect provider from model name
|
|
644
|
+
const registryProvider = getProviderFromModel(model);
|
|
645
|
+
if (registryProvider)
|
|
646
|
+
return registryProvider;
|
|
647
|
+
// 3. Fallback to string prefix matching for unknown models
|
|
648
|
+
const lowerModel = model.toLowerCase();
|
|
649
|
+
if (lowerModel.startsWith('claude'))
|
|
650
|
+
return 'claude';
|
|
651
|
+
if (lowerModel.startsWith('gpt') ||
|
|
652
|
+
lowerModel.startsWith('o1') ||
|
|
653
|
+
lowerModel.startsWith('o3') ||
|
|
654
|
+
lowerModel.startsWith('o4')) {
|
|
655
|
+
return 'openai';
|
|
656
|
+
}
|
|
657
|
+
return 'gemini';
|
|
658
|
+
}
|
|
625
659
|
/**
|
|
626
660
|
* Check if OpenRouter accepts any model (custom models).
|
|
627
661
|
* OpenRouter can route to many models not in our registry.
|
|
@@ -25,6 +25,8 @@ export interface REPLResult {
|
|
|
25
25
|
* Configuration for sandbox execution.
|
|
26
26
|
*/
|
|
27
27
|
export interface SandboxConfig {
|
|
28
|
+
/** Command type for gating SDK operations (e.g., 'query' disables curate/writeFile) */
|
|
29
|
+
commandType?: string;
|
|
28
30
|
/** Context data to preload as "context" variable */
|
|
29
31
|
contextPayload?: Record<string, unknown> | string | unknown[];
|
|
30
32
|
/** Language: 'javascript' or 'typescript' (default: auto-detect) */
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
* These constants ensure type safety and prevent typos.
|
|
4
4
|
*/
|
|
5
5
|
export declare const ToolName: {
|
|
6
|
+
readonly AGENTIC_MAP: 'agentic_map';
|
|
6
7
|
readonly CODE_EXEC: 'code_exec';
|
|
7
8
|
readonly CURATE: 'curate';
|
|
9
|
+
readonly EXPAND_KNOWLEDGE: 'expand_knowledge';
|
|
8
10
|
readonly GLOB_FILES: 'glob_files';
|
|
9
11
|
readonly GREP_CONTENT: 'grep_content';
|
|
10
12
|
readonly LIST_DIRECTORY: 'list_directory';
|
|
13
|
+
readonly LLM_MAP: 'llm_map';
|
|
11
14
|
readonly READ_FILE: 'read_file';
|
|
12
15
|
readonly SEARCH_KNOWLEDGE: 'search_knowledge';
|
|
13
16
|
readonly WRITE_FILE: 'write_file';
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
* These constants ensure type safety and prevent typos.
|
|
4
4
|
*/
|
|
5
5
|
export const ToolName = {
|
|
6
|
+
AGENTIC_MAP: 'agentic_map',
|
|
6
7
|
CODE_EXEC: 'code_exec',
|
|
7
8
|
CURATE: 'curate',
|
|
9
|
+
EXPAND_KNOWLEDGE: 'expand_knowledge',
|
|
8
10
|
GLOB_FILES: 'glob_files',
|
|
9
11
|
GREP_CONTENT: 'grep_content',
|
|
10
12
|
LIST_DIRECTORY: 'list_directory',
|
|
13
|
+
LLM_MAP: 'llm_map',
|
|
11
14
|
READ_FILE: 'read_file',
|
|
12
15
|
SEARCH_KNOWLEDGE: 'search_knowledge',
|
|
13
16
|
WRITE_FILE: 'write_file',
|
|
@@ -34,17 +34,15 @@ export interface CipherAgentServices {
|
|
|
34
34
|
blobStorage: IBlobStorage;
|
|
35
35
|
/**
|
|
36
36
|
* CompactionService for context overflow management.
|
|
37
|
-
* Only available when granular storage is enabled (useGranularStorage: true).
|
|
38
37
|
*/
|
|
39
|
-
compactionService
|
|
38
|
+
compactionService: CompactionService;
|
|
40
39
|
fileSystemService: FileSystemService;
|
|
41
40
|
historyStorage: IHistoryStorage;
|
|
42
41
|
memoryManager: MemoryManager;
|
|
43
42
|
/**
|
|
44
43
|
* MessageStorageService for direct granular message access.
|
|
45
|
-
* Only available when granular storage is enabled (useGranularStorage: true).
|
|
46
44
|
*/
|
|
47
|
-
messageStorageService
|
|
45
|
+
messageStorageService: MessageStorageService;
|
|
48
46
|
policyEngine: IPolicyEngine;
|
|
49
47
|
processService: ProcessService;
|
|
50
48
|
sandboxService: ISandboxService;
|
|
@@ -70,9 +70,15 @@ export interface ICipherAgent {
|
|
|
70
70
|
*
|
|
71
71
|
* @param taskId - Unique task identifier (used as part of session ID)
|
|
72
72
|
* @param commandType - Command type for agent name tracking ('curate' | 'query')
|
|
73
|
+
* @param options - Optional configuration
|
|
74
|
+
* @param options.mapRootEligible - If true, registers the session as root-eligible for
|
|
75
|
+
* agentic_map calls (Guard C). Only set for top-level task sessions that may invoke
|
|
76
|
+
* agentic_map directly (e.g., curate-executor, folder-pack-executor). Defaults to false.
|
|
73
77
|
* @returns Session ID of the created task session
|
|
74
78
|
*/
|
|
75
|
-
createTaskSession(taskId: string, commandType: string
|
|
79
|
+
createTaskSession(taskId: string, commandType: string, options?: {
|
|
80
|
+
mapRootEligible?: boolean;
|
|
81
|
+
}): Promise<string>;
|
|
76
82
|
/**
|
|
77
83
|
* Delete a sandbox variable from the agent's default session.
|
|
78
84
|
*
|
|
@@ -120,6 +126,8 @@ export interface ICipherAgent {
|
|
|
120
126
|
* @param sessionId - Session to execute on
|
|
121
127
|
* @param input - User input string
|
|
122
128
|
* @param options - Optional execution options
|
|
129
|
+
* @param options.executionContext - Optional context for command-specific behavior (curate/query/chat)
|
|
130
|
+
* @param options.taskId - Optional task ID for event routing (required for concurrent task isolation)
|
|
123
131
|
* @returns Agent response
|
|
124
132
|
*/
|
|
125
133
|
executeOnSession(sessionId: string, input: string, options?: {
|
|
@@ -2,6 +2,7 @@ import type { ISearchKnowledgeService } from '../../infra/sandbox/tools-sdk.js';
|
|
|
2
2
|
import type { SessionManager } from '../../infra/session/session-manager.js';
|
|
3
3
|
import type { EnvironmentContext } from '../domain/environment/types.js';
|
|
4
4
|
import type { REPLResult, SandboxConfig } from '../domain/sandbox/types.js';
|
|
5
|
+
import type { IContentGenerator } from './i-content-generator.js';
|
|
5
6
|
import type { ICurateService } from './i-curate-service.js';
|
|
6
7
|
import type { IFileSystem } from './i-file-system.js';
|
|
7
8
|
/**
|
|
@@ -36,6 +37,13 @@ export interface ISandboxService {
|
|
|
36
37
|
* @returns Execution result with stdout, stderr, and locals
|
|
37
38
|
*/
|
|
38
39
|
executeCode(code: string, sessionId: string, config?: SandboxConfig): Promise<REPLResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Set the content generator for parallel LLM operations (mapExtract).
|
|
42
|
+
* When set, sandboxes will have access to `tools.curation.mapExtract()`.
|
|
43
|
+
*
|
|
44
|
+
* @param contentGenerator - Content generator instance
|
|
45
|
+
*/
|
|
46
|
+
setContentGenerator?(contentGenerator: IContentGenerator): void;
|
|
39
47
|
/**
|
|
40
48
|
* Set the curate service for Tools SDK injection.
|
|
41
49
|
* When set, sandboxes will have access to curate operations via `tools.curate()`.
|
|
@@ -62,4 +62,14 @@ export interface IToolProvider {
|
|
|
62
62
|
* Registers all available tools based on available services.
|
|
63
63
|
*/
|
|
64
64
|
initialize(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Atomically replace specific tools with new service dependencies.
|
|
67
|
+
* Builds new tool instances first, then swaps — if build fails, old tools remain.
|
|
68
|
+
* Throws if any requested tool cannot be rebuilt.
|
|
69
|
+
*
|
|
70
|
+
* @param toolNames - Names of tools to replace
|
|
71
|
+
* @param newServices - Updated services for tool construction (typed as Record at core level;
|
|
72
|
+
* infra implementation casts to Partial<ToolServices> internally)
|
|
73
|
+
*/
|
|
74
|
+
replaceTools(toolNames: string[], newServices: Record<string, unknown>): void;
|
|
65
75
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Based on gemini-cli's CoreToolScheduler pattern, simplified for autonomous mode.
|
|
10
10
|
*/
|
|
11
|
+
import type { MetadataCallback } from '../domain/tools/types.js';
|
|
11
12
|
import type { PolicyEvaluationResult } from './i-policy-engine.js';
|
|
12
13
|
/**
|
|
13
14
|
* Status of a scheduled tool execution.
|
|
@@ -58,6 +59,14 @@ export interface ScheduledToolExecution {
|
|
|
58
59
|
* Context for tool execution.
|
|
59
60
|
*/
|
|
60
61
|
export interface ToolSchedulerContext {
|
|
62
|
+
/**
|
|
63
|
+
* Command type for context-aware tool behavior (e.g., 'curate', 'query').
|
|
64
|
+
*/
|
|
65
|
+
commandType?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Callback for streaming metadata updates during execution.
|
|
68
|
+
*/
|
|
69
|
+
metadata?: MetadataCallback;
|
|
61
70
|
/**
|
|
62
71
|
* Session ID for the current session.
|
|
63
72
|
*/
|
|
@@ -143,8 +143,6 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
143
143
|
providerApiKey: z.ZodOptional<z.ZodString>;
|
|
144
144
|
providerBaseUrl: z.ZodOptional<z.ZodString>;
|
|
145
145
|
providerHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
146
|
-
providerLocation: z.ZodOptional<z.ZodString>;
|
|
147
|
-
providerProject: z.ZodOptional<z.ZodString>;
|
|
148
146
|
region: z.ZodOptional<z.ZodString>;
|
|
149
147
|
sessionKey: z.ZodDefault<z.ZodString>;
|
|
150
148
|
sessions: z.ZodDefault<z.ZodObject<{
|
|
@@ -161,7 +159,6 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
161
159
|
spaceId: z.ZodOptional<z.ZodString>;
|
|
162
160
|
storagePath: z.ZodString;
|
|
163
161
|
teamId: z.ZodOptional<z.ZodString>;
|
|
164
|
-
useGranularStorage: z.ZodDefault<z.ZodBoolean>;
|
|
165
162
|
}, "strict", z.ZodTypeAny, {
|
|
166
163
|
model: string;
|
|
167
164
|
llm: {
|
|
@@ -180,7 +177,6 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
180
177
|
projectId: string;
|
|
181
178
|
sessionKey: string;
|
|
182
179
|
storagePath: string;
|
|
183
|
-
useGranularStorage: boolean;
|
|
184
180
|
maxInputTokens?: number | undefined;
|
|
185
181
|
provider?: string | undefined;
|
|
186
182
|
blobStorage?: {
|
|
@@ -198,8 +194,6 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
198
194
|
providerApiKey?: string | undefined;
|
|
199
195
|
providerBaseUrl?: string | undefined;
|
|
200
196
|
providerHeaders?: Record<string, string> | undefined;
|
|
201
|
-
providerLocation?: string | undefined;
|
|
202
|
-
providerProject?: string | undefined;
|
|
203
197
|
region?: string | undefined;
|
|
204
198
|
siteName?: string | undefined;
|
|
205
199
|
spaceId?: string | undefined;
|
|
@@ -238,14 +232,11 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
238
232
|
providerApiKey?: string | undefined;
|
|
239
233
|
providerBaseUrl?: string | undefined;
|
|
240
234
|
providerHeaders?: Record<string, string> | undefined;
|
|
241
|
-
providerLocation?: string | undefined;
|
|
242
|
-
providerProject?: string | undefined;
|
|
243
235
|
region?: string | undefined;
|
|
244
236
|
sessionKey?: string | undefined;
|
|
245
237
|
siteName?: string | undefined;
|
|
246
238
|
spaceId?: string | undefined;
|
|
247
239
|
teamId?: string | undefined;
|
|
248
|
-
useGranularStorage?: boolean | undefined;
|
|
249
240
|
}>;
|
|
250
241
|
export type AgentConfig = z.input<typeof AgentConfigSchema>;
|
|
251
242
|
export type ValidatedAgentConfig = z.output<typeof AgentConfigSchema>;
|
|
@@ -63,8 +63,6 @@ export const AgentConfigSchema = z
|
|
|
63
63
|
providerApiKey: z.string().optional().describe('API key for direct provider'),
|
|
64
64
|
providerBaseUrl: z.string().optional().describe('Base URL for OpenAI-compatible provider'),
|
|
65
65
|
providerHeaders: z.record(z.string()).optional().describe('Custom headers for provider'),
|
|
66
|
-
providerLocation: z.string().optional().describe('GCP location for Vertex AI (default: us-central1)'),
|
|
67
|
-
providerProject: z.string().optional().describe('GCP project ID for Vertex AI'),
|
|
68
66
|
region: z.string().optional().describe('API region'),
|
|
69
67
|
sessionKey: z.string().default('').describe('ByteRover session key'),
|
|
70
68
|
sessions: SessionConfigSchema.default({}).describe('Session management configuration'),
|
|
@@ -72,7 +70,6 @@ export const AgentConfigSchema = z
|
|
|
72
70
|
spaceId: z.string().optional().describe('ByteRover space ID'),
|
|
73
71
|
storagePath: z.string().min(1).describe('XDG storage directory for blob, key, and session storage'),
|
|
74
72
|
teamId: z.string().optional().describe('ByteRover team ID'),
|
|
75
|
-
useGranularStorage: z.boolean().default(false).describe('Enable granular history storage'),
|
|
76
73
|
})
|
|
77
74
|
.strict();
|
|
78
75
|
/**
|
|
@@ -38,6 +38,8 @@ import { BaseAgent } from './base-agent.js';
|
|
|
38
38
|
export declare class CipherAgent extends BaseAgent implements ICipherAgent {
|
|
39
39
|
private readonly _agentEventBus;
|
|
40
40
|
private readonly _brvConfig?;
|
|
41
|
+
/** Unique ID for this agent instance — scopes nesting registry ownership. */
|
|
42
|
+
private readonly _instanceId;
|
|
41
43
|
private readonly _projectIdProvider?;
|
|
42
44
|
/**
|
|
43
45
|
* Session ID - created once during start().
|
|
@@ -50,6 +52,11 @@ export declare class CipherAgent extends BaseAgent implements ICipherAgent {
|
|
|
50
52
|
private readonly _transportClient?;
|
|
51
53
|
private readonly activeStreamControllers;
|
|
52
54
|
private eventBridge?;
|
|
55
|
+
/**
|
|
56
|
+
* Tracks session IDs this agent instance registered as root-eligible.
|
|
57
|
+
* Used for bulk deregistration on agent teardown (cleanupServices).
|
|
58
|
+
*/
|
|
59
|
+
private readonly rootEligibleSessions;
|
|
53
60
|
private sessionManager?;
|
|
54
61
|
/**
|
|
55
62
|
* Creates a new CipherAgent instance.
|
|
@@ -105,7 +112,9 @@ export declare class CipherAgent extends BaseAgent implements ICipherAgent {
|
|
|
105
112
|
* Create a task-scoped child session for parallel execution.
|
|
106
113
|
* The session gets its own sandbox, context manager, and LLM service.
|
|
107
114
|
*/
|
|
108
|
-
createTaskSession(taskId: string, commandType: string
|
|
115
|
+
createTaskSession(taskId: string, commandType: string, options?: {
|
|
116
|
+
mapRootEligible?: boolean;
|
|
117
|
+
}): Promise<string>;
|
|
109
118
|
/**
|
|
110
119
|
* Delete a sandbox variable from the agent's default session.
|
|
111
120
|
*/
|
|
@@ -255,4 +264,19 @@ export declare class CipherAgent extends BaseAgent implements ICipherAgent {
|
|
|
255
264
|
private getSessionIdInternal;
|
|
256
265
|
private getSessionManagerInternal;
|
|
257
266
|
private getSystemPromptManagerInternal;
|
|
267
|
+
/**
|
|
268
|
+
* Handle SessionManager lifecycle removals (delete/end/TTL-expire) and keep
|
|
269
|
+
* root-eligible tracking synchronized with the global nesting registry.
|
|
270
|
+
*/
|
|
271
|
+
private handleSessionRemoved;
|
|
272
|
+
/**
|
|
273
|
+
* Rebuild map tool dependencies and update ToolProvider + SandboxService.
|
|
274
|
+
* Called from both start() (initial setup) and refreshProviderConfig() (hot-swap).
|
|
275
|
+
*/
|
|
276
|
+
private rebindMapTools;
|
|
277
|
+
/**
|
|
278
|
+
* Register a session as root-eligible and track it for lifecycle cleanup.
|
|
279
|
+
* Routes all root-eligible registrations through a single point.
|
|
280
|
+
*/
|
|
281
|
+
private registerSessionInternal;
|
|
258
282
|
}
|