@codebolt/agent 6.0.0 → 6.1.2
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 +118 -153
- package/dist/index.d.ts +2 -0
- package/dist/index.js +41 -0
- package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.js +2 -4
- package/dist/processor-pieces/messageModifiers/contextAssemblyModifier.d.ts +81 -0
- package/dist/processor-pieces/messageModifiers/contextAssemblyModifier.js +316 -0
- package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.js +2 -19
- package/dist/processor-pieces/messageModifiers/directoryContextModifier.js +2 -6
- package/dist/processor-pieces/messageModifiers/environmentContextModifier.js +2 -7
- package/dist/processor-pieces/messageModifiers/ideContextModifier.js +2 -21
- package/dist/processor-pieces/messageModifiers/index.d.ts +3 -0
- package/dist/processor-pieces/messageModifiers/index.js +7 -1
- package/dist/processor-pieces/messageModifiers/toolInjectionModifier.js +2 -1
- package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.d.ts +34 -5
- package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.js +374 -89
- package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.d.ts +3 -0
- package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.js +50 -27
- package/dist/unified/agent/agent.d.ts +10 -0
- package/dist/unified/agent/agent.js +198 -10
- package/dist/unified/agent/codeboltAgent.d.ts +19 -100
- package/dist/unified/agent/codeboltAgent.js +209 -109
- package/dist/unified/base/agentStep.js +17 -17
- package/dist/unified/base/initialPromptGenerator.js +13 -31
- package/dist/unified/base/promptContext.d.ts +13 -0
- package/dist/unified/base/promptContext.js +213 -0
- package/dist/unified/base/responseExecutor.d.ts +7 -19
- package/dist/unified/base/responseExecutor.js +280 -259
- package/dist/unified/index.d.ts +9 -0
- package/dist/unified/index.js +20 -13
- package/dist/unified/services/CompressionCoordinator.d.ts +67 -0
- package/dist/unified/services/CompressionCoordinator.js +214 -0
- package/dist/unified/services/compaction/autoCompact.d.ts +52 -0
- package/dist/unified/services/compaction/autoCompact.js +294 -0
- package/dist/unified/services/compaction/compactionOrchestrator.d.ts +78 -0
- package/dist/unified/services/compaction/compactionOrchestrator.js +230 -0
- package/dist/unified/services/compaction/contextCollapse.d.ts +63 -0
- package/dist/unified/services/compaction/contextCollapse.js +291 -0
- package/dist/unified/services/compaction/microCompact.d.ts +34 -0
- package/dist/unified/services/compaction/microCompact.js +195 -0
- package/dist/unified/services/compaction/postCompactCleanup.d.ts +15 -0
- package/dist/unified/services/compaction/postCompactCleanup.js +37 -0
- package/dist/unified/services/compaction/reactiveCompact.d.ts +65 -0
- package/dist/unified/services/compaction/reactiveCompact.js +301 -0
- package/dist/unified/services/compaction/snipCompact.d.ts +31 -0
- package/dist/unified/services/compaction/snipCompact.js +124 -0
- package/dist/unified/services/compaction/types.d.ts +66 -0
- package/dist/unified/services/compaction/types.js +39 -0
- package/package.json +25 -29
package/README.md
CHANGED
|
@@ -1,211 +1,176 @@
|
|
|
1
1
|
# CodeBolt Agent Package
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@codebolt/agent` provides TypeScript utilities for building CodeBolt agents with a unified execution pipeline, reusable processor pieces, tool definitions, workflows, loop detection, and conversation compaction.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { ComposableAgent, createTool } from '@codebolt/agent/composable';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
|
|
11
|
-
// Create a simple weather tool
|
|
12
|
-
const weatherTool = createTool({
|
|
13
|
-
id: 'get-weather',
|
|
14
|
-
description: 'Get current weather for a location',
|
|
15
|
-
inputSchema: z.object({ location: z.string() }),
|
|
16
|
-
outputSchema: z.object({ temperature: z.number(), conditions: z.string() }),
|
|
17
|
-
execute: async ({ context }) => {
|
|
18
|
-
return await getWeatherAPI(context.location);
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Create and run agent
|
|
23
|
-
const agent = new ComposableAgent({
|
|
24
|
-
name: 'Weather Agent',
|
|
25
|
-
instructions: 'You are a helpful weather assistant.',
|
|
26
|
-
model: 'gpt-4o-mini',
|
|
27
|
-
tools: { weatherTool },
|
|
28
|
-
memory: createCodeBoltAgentMemory('weather_agent')
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const result = await agent.execute('What is the weather in New York?');
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## ✨ Key Features
|
|
35
|
-
|
|
36
|
-
- **Multiple Patterns**: Choose between Composable, Builder, and Processor patterns
|
|
37
|
-
- **Type Safety**: Full TypeScript support with Zod validation
|
|
38
|
-
- **Memory Management**: Persistent conversation storage with CodeBolt integration
|
|
39
|
-
- **Tool System**: Extensible tool framework with validation
|
|
40
|
-
- **Workflow Orchestration**: Multi-step agent processes with conditional logic
|
|
41
|
-
- **Model Agnostic**: Support for OpenAI, Anthropic, Ollama, and more
|
|
42
|
-
- **Stream Support**: Real-time streaming responses
|
|
43
|
-
|
|
44
|
-
## 📦 Installation
|
|
5
|
+
## Installation
|
|
45
6
|
|
|
46
7
|
```bash
|
|
47
8
|
npm install @codebolt/agent
|
|
48
9
|
```
|
|
49
10
|
|
|
50
|
-
##
|
|
11
|
+
## Public entry points
|
|
51
12
|
|
|
52
|
-
|
|
13
|
+
The package currently publishes these import paths:
|
|
53
14
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
- [Migration Guide](./DOCUMENTATION.md#migration-guide) - Upgrading from previous versions
|
|
15
|
+
| Import path | Purpose |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `@codebolt/agent` | Main entry point; re-exports the unified framework and `ProcessorPieces` namespace. |
|
|
18
|
+
| `@codebolt/agent/unified` | Agent runtime, tools, workflows, compaction services, and core framework types. |
|
|
19
|
+
| `@codebolt/agent/processor-pieces` | Reusable message modifiers and pre/post inference/tool processors. |
|
|
60
20
|
|
|
61
|
-
|
|
21
|
+
Older examples that import from `@codebolt/agent/composable`, `@codebolt/agent/builder`, or `@codebolt/agent/processor` are obsolete for this package version.
|
|
62
22
|
|
|
63
|
-
|
|
64
|
-
**Best for**: Rapid prototyping, simple agents, beginners
|
|
23
|
+
## Quick start
|
|
65
24
|
|
|
66
25
|
```typescript
|
|
67
|
-
import {
|
|
68
|
-
|
|
69
|
-
const agent = new ComposableAgent({
|
|
70
|
-
name: 'My Agent',
|
|
71
|
-
instructions: 'You are a helpful assistant.',
|
|
72
|
-
model: 'gpt-4o-mini',
|
|
73
|
-
tools: { myTool },
|
|
74
|
-
memory: createCodeBoltAgentMemory('agent_id')
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const result = await agent.execute('Help me with this task');
|
|
78
|
-
```
|
|
26
|
+
import { createCodeboltAgent } from '@codebolt/agent/unified';
|
|
79
27
|
|
|
80
|
-
|
|
81
|
-
|
|
28
|
+
const agent = createCodeboltAgent({
|
|
29
|
+
systemPrompt: 'You are a concise CodeBolt coding assistant.',
|
|
30
|
+
allowedTools: ['read_file', 'write_file'],
|
|
31
|
+
maxTurns: 10,
|
|
32
|
+
});
|
|
82
33
|
|
|
83
|
-
|
|
84
|
-
import { Agent, InitialPromptBuilder, LLMOutputHandler } from '@codebolt/agent/builder';
|
|
34
|
+
const result = await agent.processMessage('Inspect the current project and summarize it.');
|
|
85
35
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
.addTaskDetails("Fix compilation errors");
|
|
36
|
+
if (!result.success) {
|
|
37
|
+
throw new Error(result.error);
|
|
38
|
+
}
|
|
90
39
|
|
|
91
|
-
|
|
92
|
-
const agent = new Agent(tools, systemPrompt);
|
|
93
|
-
const result = await agent.runAgent(prompt);
|
|
40
|
+
console.log(result.finalMessage ?? result.result);
|
|
94
41
|
```
|
|
95
42
|
|
|
96
|
-
|
|
97
|
-
|
|
43
|
+
## Unified agent runtime
|
|
44
|
+
|
|
45
|
+
Use `CodeboltAgent` or `createCodeboltAgent` for the default CodeBolt-aware runtime. It automatically adds common message modifiers for chat history, environment context, directory context, IDE context, system prompt injection, tool injection, and `@file` processing.
|
|
98
46
|
|
|
99
47
|
```typescript
|
|
100
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
CodeboltAgent,
|
|
50
|
+
ChatCompressionModifier,
|
|
51
|
+
ToolValidationModifier,
|
|
52
|
+
} from '@codebolt/agent/unified';
|
|
53
|
+
|
|
54
|
+
const agent = new CodeboltAgent({
|
|
55
|
+
instructions: 'Help the user safely modify code.',
|
|
56
|
+
processors: {
|
|
57
|
+
preInferenceProcessors: [new ChatCompressionModifier()],
|
|
58
|
+
preToolCallProcessors: [new ToolValidationModifier()],
|
|
59
|
+
},
|
|
60
|
+
enableLogging: true,
|
|
61
|
+
maxTurns: 25,
|
|
62
|
+
});
|
|
101
63
|
|
|
102
|
-
|
|
103
|
-
async process(messages: any[]): Promise<any> {
|
|
104
|
-
return this.executeCustomFlow(messages);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
64
|
+
const response = await agent.processMessage('Fix the lint errors in this package.');
|
|
107
65
|
```
|
|
108
66
|
|
|
109
|
-
|
|
67
|
+
For lower-level control, use `Agent`, `InitialPromptGenerator`, `AgentStep`, and `ResponseExecutor` from `@codebolt/agent/unified`.
|
|
110
68
|
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
import {
|
|
114
|
-
ComposableAgent, createTool, createWorkflow,
|
|
115
|
-
Memory, createCodeBoltAgentMemory, MDocument
|
|
116
|
-
} from '@codebolt/agent/composable';
|
|
117
|
-
```
|
|
69
|
+
## Processor pieces
|
|
118
70
|
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
import {
|
|
122
|
-
Agent, InitialPromptBuilder, LLMOutputHandler,
|
|
123
|
-
SystemPrompt, TaskInstruction, UserMessage
|
|
124
|
-
} from '@codebolt/agent/builder';
|
|
125
|
-
```
|
|
71
|
+
Reusable processor pieces are available both through `@codebolt/agent/processor-pieces` and through the unified entry point.
|
|
126
72
|
|
|
127
|
-
### Processor Pattern
|
|
128
73
|
```typescript
|
|
129
|
-
import {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
74
|
+
import {
|
|
75
|
+
EnvironmentContextModifier,
|
|
76
|
+
CoreSystemPromptModifier,
|
|
77
|
+
ToolInjectionModifier,
|
|
78
|
+
} from '@codebolt/agent/processor-pieces';
|
|
79
|
+
|
|
80
|
+
const messageModifiers = [
|
|
81
|
+
new EnvironmentContextModifier({ enableFullContext: true }),
|
|
82
|
+
new CoreSystemPromptModifier({ customSystemPrompt: 'You are helpful.' }),
|
|
83
|
+
new ToolInjectionModifier({ includeToolDescriptions: true }),
|
|
84
|
+
];
|
|
133
85
|
```
|
|
134
86
|
|
|
135
|
-
##
|
|
87
|
+
## Tools
|
|
136
88
|
|
|
137
|
-
|
|
89
|
+
`createTool` wraps a Zod input schema, optional output schema, and execution function.
|
|
138
90
|
|
|
139
91
|
```typescript
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
92
|
+
import { createTool } from '@codebolt/agent/unified';
|
|
93
|
+
import { z } from 'zod';
|
|
94
|
+
|
|
95
|
+
const echoTool = createTool({
|
|
96
|
+
id: 'echo',
|
|
97
|
+
description: 'Echoes the provided text.',
|
|
98
|
+
inputSchema: z.object({
|
|
99
|
+
text: z.string(),
|
|
100
|
+
}),
|
|
101
|
+
outputSchema: z.object({
|
|
102
|
+
text: z.string(),
|
|
103
|
+
}),
|
|
104
|
+
execute: async ({ input }) => ({
|
|
105
|
+
text: input.text,
|
|
106
|
+
}),
|
|
154
107
|
});
|
|
155
108
|
|
|
156
|
-
const
|
|
109
|
+
const execution = await echoTool.execute({ text: 'hello' }, {});
|
|
157
110
|
```
|
|
158
111
|
|
|
159
|
-
##
|
|
112
|
+
## Workflows
|
|
160
113
|
|
|
161
|
-
|
|
114
|
+
`Workflow` executes workflow steps defined by `@codebolt/types/agent`. Use `executeAsync` when step implementations are asynchronous.
|
|
162
115
|
|
|
163
116
|
```typescript
|
|
164
|
-
|
|
165
|
-
const agentMemory = createCodeBoltAgentMemory('my_agent');
|
|
117
|
+
import { Workflow } from '@codebolt/agent/unified';
|
|
166
118
|
|
|
167
|
-
|
|
168
|
-
|
|
119
|
+
const workflow = new Workflow({
|
|
120
|
+
name: 'Example Workflow',
|
|
121
|
+
steps: [
|
|
122
|
+
{
|
|
123
|
+
id: 'first-step',
|
|
124
|
+
name: 'First Step',
|
|
125
|
+
type: 'custom',
|
|
126
|
+
execute: async () => ({
|
|
127
|
+
stepId: 'first-step',
|
|
128
|
+
success: true,
|
|
129
|
+
result: 'done',
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
});
|
|
169
134
|
|
|
170
|
-
|
|
171
|
-
const dbMemory = createCodeBoltDbMemory('cache_agent');
|
|
135
|
+
const result = await workflow.executeAsync();
|
|
172
136
|
```
|
|
173
137
|
|
|
174
|
-
##
|
|
138
|
+
## Conversation compaction
|
|
175
139
|
|
|
176
|
-
|
|
177
|
-
# Install dependencies
|
|
178
|
-
npm install
|
|
140
|
+
The unified framework includes layered compaction utilities:
|
|
179
141
|
|
|
180
|
-
|
|
181
|
-
|
|
142
|
+
- `CompactionOrchestrator`
|
|
143
|
+
- `SnipCompact`
|
|
144
|
+
- `MicroCompact`
|
|
145
|
+
- `ContextCollapse`
|
|
146
|
+
- `AutoCompact`
|
|
147
|
+
- `ReactiveCompact`
|
|
148
|
+
- `PostCompactCleanup`
|
|
149
|
+
- `TokenEstimator`
|
|
182
150
|
|
|
183
|
-
|
|
184
|
-
npm run dev
|
|
151
|
+
These are used by `Agent` and `CodeboltAgent` to reduce transcript size and recover from token-limit errors.
|
|
185
152
|
|
|
186
|
-
|
|
187
|
-
npm run test
|
|
153
|
+
## Development
|
|
188
154
|
|
|
189
|
-
|
|
155
|
+
```bash
|
|
156
|
+
npm install
|
|
157
|
+
npm run build
|
|
190
158
|
npm run lint
|
|
159
|
+
npm test
|
|
191
160
|
```
|
|
192
161
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
| Pattern | Complexity | Use Case | Learning Curve |
|
|
196
|
-
|---------|------------|----------|----------------|
|
|
197
|
-
| **Composable** | Low | Rapid prototyping, simple agents | Low |
|
|
198
|
-
| **Builder** | Medium | Complex workflows, custom logic | Medium |
|
|
199
|
-
| **Processor** | High | Advanced customization | High |
|
|
200
|
-
|
|
201
|
-
## 🤝 Contributing
|
|
162
|
+
Additional documentation generation commands:
|
|
202
163
|
|
|
203
|
-
|
|
164
|
+
```bash
|
|
165
|
+
npm run docs
|
|
166
|
+
npm run docs:clean
|
|
167
|
+
npm run docs:watch
|
|
168
|
+
```
|
|
204
169
|
|
|
205
|
-
##
|
|
170
|
+
## Package files
|
|
206
171
|
|
|
207
|
-
|
|
172
|
+
Only built files from `dist`, `README.md`, and `LICENSE` are published. The `dist` directory is generated by `npm run build` and should not be edited directly.
|
|
208
173
|
|
|
209
|
-
|
|
174
|
+
## License
|
|
210
175
|
|
|
211
|
-
|
|
176
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ProcessorPieces = void 0;
|
|
40
|
+
exports.ProcessorPieces = __importStar(require("./processor-pieces"));
|
|
41
|
+
__exportStar(require("./unified"), exports);
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ChatHistoryMessageModifier = void 0;
|
|
7
7
|
const base_1 = require("../base");
|
|
8
8
|
const codeboltjs_1 = __importDefault(require("@codebolt/codeboltjs"));
|
|
9
|
+
const promptContext_1 = require("../../unified/base/promptContext");
|
|
9
10
|
// Using MessageObject from SDK types for chat history messages
|
|
10
11
|
class ChatHistoryMessageModifier extends base_1.BaseMessageModifier {
|
|
11
12
|
constructor(options = {}) {
|
|
@@ -26,10 +27,7 @@ class ChatHistoryMessageModifier extends base_1.BaseMessageModifier {
|
|
|
26
27
|
}
|
|
27
28
|
// Directly use the chat history messages - they're already in MessageObject format
|
|
28
29
|
return {
|
|
29
|
-
|
|
30
|
-
...createdMessage.message,
|
|
31
|
-
messages: [...chatHistory, ...createdMessage.message.messages]
|
|
32
|
-
},
|
|
30
|
+
...(0, promptContext_1.prependTranscriptMessages)(createdMessage, chatHistory),
|
|
33
31
|
metadata: {
|
|
34
32
|
...createdMessage.metadata,
|
|
35
33
|
chatHistoryAdded: true,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ProcessedMessage } from "@codebolt/types/agent";
|
|
2
|
+
import { BaseMessageModifier } from "../base";
|
|
3
|
+
import { FlatUserMessage } from "@codebolt/types/sdk";
|
|
4
|
+
import type { ContextConstraints, MemoryContribution } from "@codebolt/types/lib";
|
|
5
|
+
export interface ContextAssemblyModifierOptions {
|
|
6
|
+
/** Scope variables to pass to the context assembly engine */
|
|
7
|
+
scopeVariables?: Record<string, any>;
|
|
8
|
+
/** Additional variables for memory resolution */
|
|
9
|
+
additionalVariables?: Record<string, any> | undefined;
|
|
10
|
+
/** Explicit memory IDs to include */
|
|
11
|
+
explicitMemory?: string[] | undefined;
|
|
12
|
+
/** Rule engine IDs to use for filtering */
|
|
13
|
+
ruleEngineIds?: string[] | undefined;
|
|
14
|
+
/** Constraints for context assembly */
|
|
15
|
+
constraints?: ContextConstraints | undefined;
|
|
16
|
+
/** Whether to include the user's input in the context request */
|
|
17
|
+
includeUserInput?: boolean;
|
|
18
|
+
/** Whether to inject context as system or user message */
|
|
19
|
+
messageRole?: 'system' | 'user';
|
|
20
|
+
/** Whether to validate the request before assembling */
|
|
21
|
+
validateBeforeAssembly?: boolean;
|
|
22
|
+
/** Custom formatter for memory contributions */
|
|
23
|
+
formatContribution?: ((contribution: MemoryContribution) => string) | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare class ContextAssemblyModifier extends BaseMessageModifier {
|
|
26
|
+
private readonly options;
|
|
27
|
+
constructor(options?: ContextAssemblyModifierOptions);
|
|
28
|
+
modify(_originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
|
|
29
|
+
private buildRequest;
|
|
30
|
+
private formatContext;
|
|
31
|
+
private defaultFormatContribution;
|
|
32
|
+
/** Update scope variables at runtime */
|
|
33
|
+
setScopeVariables(variables: Record<string, any>): void;
|
|
34
|
+
/** Update additional variables at runtime */
|
|
35
|
+
setAdditionalVariables(variables: Record<string, any>): void;
|
|
36
|
+
/** Set explicit memory IDs to include */
|
|
37
|
+
setExplicitMemory(memoryIds: string[]): void;
|
|
38
|
+
/** Set constraints for context assembly */
|
|
39
|
+
setConstraints(constraints: ContextConstraints): void;
|
|
40
|
+
}
|
|
41
|
+
export interface RuleBasedContextModifierOptions {
|
|
42
|
+
/** Scope variables for rule evaluation */
|
|
43
|
+
scopeVariables?: Record<string, any>;
|
|
44
|
+
/** Specific rule engine IDs to evaluate */
|
|
45
|
+
ruleEngineIds?: string[] | undefined;
|
|
46
|
+
/** Whether to inject context as system or user message */
|
|
47
|
+
messageRole?: 'system' | 'user';
|
|
48
|
+
/** Constraints for the final context assembly */
|
|
49
|
+
constraints?: ContextConstraints | undefined;
|
|
50
|
+
}
|
|
51
|
+
export declare class RuleBasedContextModifier extends BaseMessageModifier {
|
|
52
|
+
private readonly options;
|
|
53
|
+
constructor(options?: RuleBasedContextModifierOptions);
|
|
54
|
+
modify(_originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
|
|
55
|
+
/** Update scope variables at runtime */
|
|
56
|
+
setScopeVariables(variables: Record<string, any>): void;
|
|
57
|
+
/** Set specific rule engine IDs to evaluate */
|
|
58
|
+
setRuleEngineIds(ruleEngineIds: string[]): void;
|
|
59
|
+
}
|
|
60
|
+
export interface MemoryTypeContextModifierOptions {
|
|
61
|
+
/** Specific memory type names to fetch */
|
|
62
|
+
memoryNames: string[];
|
|
63
|
+
/** Scope variables for context assembly */
|
|
64
|
+
scopeVariables?: Record<string, any>;
|
|
65
|
+
/** Whether to auto-resolve required variables from the message */
|
|
66
|
+
autoResolveVariables?: boolean;
|
|
67
|
+
/** Whether to inject context as system or user message */
|
|
68
|
+
messageRole?: 'system' | 'user';
|
|
69
|
+
/** Constraints for context assembly */
|
|
70
|
+
constraints?: ContextConstraints | undefined;
|
|
71
|
+
}
|
|
72
|
+
export declare class MemoryTypeContextModifier extends BaseMessageModifier {
|
|
73
|
+
private readonly options;
|
|
74
|
+
constructor(options: MemoryTypeContextModifierOptions);
|
|
75
|
+
modify(_originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
|
|
76
|
+
private resolveVariables;
|
|
77
|
+
/** Update memory names to fetch */
|
|
78
|
+
setMemoryNames(memoryNames: string[]): void;
|
|
79
|
+
/** Update scope variables at runtime */
|
|
80
|
+
setScopeVariables(variables: Record<string, any>): void;
|
|
81
|
+
}
|