@codebolt/agent 6.1.21 → 6.1.23

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.
Files changed (30) hide show
  1. package/README.md +1 -0
  2. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.d.ts +2 -1
  3. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.js +24 -9
  4. package/dist/processor-pieces/messageModifiers/index.d.ts +1 -0
  5. package/dist/processor-pieces/messageModifiers/index.js +3 -1
  6. package/dist/processor-pieces/messageModifiers/toolManifestPromptModifier.d.ts +18 -0
  7. package/dist/processor-pieces/messageModifiers/toolManifestPromptModifier.js +57 -0
  8. package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.js +13 -5
  9. package/dist/types/libFunctionTypes.d.ts +147 -10
  10. package/dist/types/socketMessageTypes.d.ts +10 -2
  11. package/dist/unified/agent/agent.d.ts +3 -0
  12. package/dist/unified/agent/agent.js +14 -4
  13. package/dist/unified/base/agentStep.d.ts +1 -1
  14. package/dist/unified/base/agentStep.js +8 -5
  15. package/dist/unified/base/initialPromptGenerator.js +2 -1
  16. package/dist/unified/base/responseExecutor.js +49 -26
  17. package/dist/unified/index.d.ts +1 -0
  18. package/dist/unified/index.js +3 -1
  19. package/dist/unified/services/compaction/autoCompact.d.ts +2 -1
  20. package/dist/unified/services/compaction/autoCompact.js +14 -6
  21. package/dist/unified/services/compaction/compactionOrchestrator.d.ts +1 -0
  22. package/dist/unified/services/compaction/compactionOrchestrator.js +8 -0
  23. package/dist/unified/services/compaction/contextCollapse.d.ts +2 -1
  24. package/dist/unified/services/compaction/contextCollapse.js +15 -7
  25. package/dist/unified/services/compaction/reactiveCompact.d.ts +3 -0
  26. package/dist/unified/services/compaction/reactiveCompact.js +12 -3
  27. package/dist/unified/types/libTypes.d.ts +187 -14
  28. package/dist/unified/utils/agentToolLoader.d.ts +17 -1
  29. package/dist/unified/utils/agentToolLoader.js +166 -20
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -27,6 +27,7 @@ import { createAgent } from '@codebolt/agent/unified';
27
27
 
28
28
  const agent = createAgent({
29
29
  systemPrompt: 'You are a concise CodeBolt coding assistant.',
30
+ llmRole: 'codebolt.standard.text.fast',
30
31
  allowedTools: ['read_file', 'write_file'],
31
32
  maxTurns: 10,
32
33
  });
@@ -16,8 +16,9 @@ export declare class ChatHistoryMessageModifier extends BaseMessageModifier {
16
16
  private getChatHistory;
17
17
  setMaxHistoryMessages(max: number): void;
18
18
  private addMissingToolResponses;
19
+ private normalizeLegacyToolResponseMessage;
19
20
  private getStandaloneToolCall;
20
- private getFunctionCallOutputId;
21
+ private getStandaloneToolResponseId;
21
22
  private getAssistantToolCallId;
22
23
  private getAssistantToolCallName;
23
24
  private getAssistantToolCallArguments;
@@ -82,9 +82,9 @@ class ChatHistoryMessageModifier extends base_1.BaseMessageModifier {
82
82
  addMissingToolResponses(historyMessages) {
83
83
  const existingToolResponseIds = new Set();
84
84
  for (const message of historyMessages) {
85
- const functionCallOutputId = this.getFunctionCallOutputId(message);
86
- if (functionCallOutputId) {
87
- existingToolResponseIds.add(functionCallOutputId);
85
+ const standaloneToolResponseId = this.getStandaloneToolResponseId(message);
86
+ if (standaloneToolResponseId) {
87
+ existingToolResponseIds.add(standaloneToolResponseId);
88
88
  }
89
89
  if (typeof message.tool_call_id === 'string') {
90
90
  existingToolResponseIds.add(message.tool_call_id);
@@ -92,7 +92,7 @@ class ChatHistoryMessageModifier extends base_1.BaseMessageModifier {
92
92
  }
93
93
  const repairedMessages = [];
94
94
  for (const message of historyMessages) {
95
- repairedMessages.push(message);
95
+ repairedMessages.push(this.normalizeLegacyToolResponseMessage(message));
96
96
  const standaloneToolCall = this.getStandaloneToolCall(message);
97
97
  if (standaloneToolCall && !existingToolResponseIds.has(standaloneToolCall.id)) {
98
98
  repairedMessages.push({
@@ -112,15 +112,29 @@ class ChatHistoryMessageModifier extends base_1.BaseMessageModifier {
112
112
  const toolName = this.getAssistantToolCallName(toolCall);
113
113
  const toolArguments = this.getAssistantToolCallArguments(toolCall);
114
114
  repairedMessages.push({
115
- role: 'tool',
116
- content: this.buildMissingToolResponseContent(toolName, toolArguments),
117
- tool_call_id: toolCallId,
115
+ type: 'function_call_output',
116
+ call_id: toolCallId,
117
+ output: this.buildMissingToolResponseContent(toolName, toolArguments),
118
+ status: 'completed',
118
119
  });
119
120
  existingToolResponseIds.add(toolCallId);
120
121
  }
121
122
  }
122
123
  return repairedMessages;
123
124
  }
125
+ normalizeLegacyToolResponseMessage(message) {
126
+ if (message.role !== 'tool' || typeof message.tool_call_id !== 'string') {
127
+ return message;
128
+ }
129
+ return {
130
+ type: 'function_call_output',
131
+ call_id: message.tool_call_id,
132
+ output: typeof message.content === 'string'
133
+ ? message.content
134
+ : JSON.stringify(message.content),
135
+ status: 'completed',
136
+ };
137
+ }
124
138
  getStandaloneToolCall(message) {
125
139
  var _a, _b;
126
140
  const typedMessage = message;
@@ -151,9 +165,10 @@ class ChatHistoryMessageModifier extends base_1.BaseMessageModifier {
151
165
  arguments: toolArguments,
152
166
  };
153
167
  }
154
- getFunctionCallOutputId(message) {
168
+ getStandaloneToolResponseId(message) {
155
169
  const typedMessage = message;
156
- if (typedMessage.type === 'function_call_output' &&
170
+ if ((typedMessage.type === 'function_call_output' ||
171
+ typedMessage.type === 'tool_search_output') &&
157
172
  typeof typedMessage.call_id === 'string') {
158
173
  return typedMessage.call_id;
159
174
  }
@@ -8,6 +8,7 @@ export { ArgumentProcessorModifier, type ArgumentProcessorOptions } from './argu
8
8
  export { MemoryImportModifier, type MemoryImportOptions } from './memoryImportModifier';
9
9
  export { LoopDetectionModifier, type LoopDetectionOptions } from '../postInferenceProcessors/loopDetectionModifier';
10
10
  export { ToolInjectionModifier, type ToolInjectionOptions } from './toolInjectionModifier';
11
+ export { ToolManifestPromptModifier, type ToolManifestPromptModifierOptions } from './toolManifestPromptModifier';
11
12
  export { ChatRecordingModifier, type ChatRecordingOptions } from './chatRecordingModifier';
12
13
  export { ChatHistoryMessageModifier, type ChatHistoryMessageModifierOptions } from './chatHistoryMessageModifier';
13
14
  export { ContextAssemblyModifier, type ContextAssemblyModifierOptions } from './contextAssemblyModifier';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MemoryTypeContextModifier = exports.RuleBasedContextModifier = exports.ContextAssemblyModifier = exports.ChatHistoryMessageModifier = exports.ChatRecordingModifier = exports.ToolInjectionModifier = exports.LoopDetectionModifier = exports.MemoryImportModifier = exports.ArgumentProcessorModifier = exports.CapabilityContextModifier = exports.AtFileProcessorModifier = exports.IdeContextModifier = exports.DirectoryContextModifier = exports.CoreSystemPromptModifier = exports.EnvironmentContextModifier = void 0;
3
+ exports.MemoryTypeContextModifier = exports.RuleBasedContextModifier = exports.ContextAssemblyModifier = exports.ChatHistoryMessageModifier = exports.ChatRecordingModifier = exports.ToolManifestPromptModifier = exports.ToolInjectionModifier = exports.LoopDetectionModifier = exports.MemoryImportModifier = exports.ArgumentProcessorModifier = exports.CapabilityContextModifier = exports.AtFileProcessorModifier = exports.IdeContextModifier = exports.DirectoryContextModifier = exports.CoreSystemPromptModifier = exports.EnvironmentContextModifier = void 0;
4
4
  // Gemini-CLI equivalent modifiers
5
5
  var environmentContextModifier_1 = require("./environmentContextModifier");
6
6
  Object.defineProperty(exports, "EnvironmentContextModifier", { enumerable: true, get: function () { return environmentContextModifier_1.EnvironmentContextModifier; } });
@@ -22,6 +22,8 @@ var loopDetectionModifier_1 = require("../postInferenceProcessors/loopDetectionM
22
22
  Object.defineProperty(exports, "LoopDetectionModifier", { enumerable: true, get: function () { return loopDetectionModifier_1.LoopDetectionModifier; } });
23
23
  var toolInjectionModifier_1 = require("./toolInjectionModifier");
24
24
  Object.defineProperty(exports, "ToolInjectionModifier", { enumerable: true, get: function () { return toolInjectionModifier_1.ToolInjectionModifier; } });
25
+ var toolManifestPromptModifier_1 = require("./toolManifestPromptModifier");
26
+ Object.defineProperty(exports, "ToolManifestPromptModifier", { enumerable: true, get: function () { return toolManifestPromptModifier_1.ToolManifestPromptModifier; } });
25
27
  var chatRecordingModifier_1 = require("./chatRecordingModifier");
26
28
  Object.defineProperty(exports, "ChatRecordingModifier", { enumerable: true, get: function () { return chatRecordingModifier_1.ChatRecordingModifier; } });
27
29
  var chatHistoryMessageModifier_1 = require("./chatHistoryMessageModifier");
@@ -0,0 +1,18 @@
1
+ import { ProcessedMessage } from "@codebolt/types/agent";
2
+ import { BaseMessageModifier } from "../base";
3
+ import { FlatUserMessage } from "@codebolt/types/sdk";
4
+ export interface ToolManifestPromptModifierOptions {
5
+ mode?: "categories" | "list";
6
+ category?: string;
7
+ pattern?: string;
8
+ limit?: number;
9
+ includeDescriptions?: boolean;
10
+ includeResources?: boolean;
11
+ runtimeToolSetId?: string;
12
+ title?: string;
13
+ }
14
+ export declare class ToolManifestPromptModifier extends BaseMessageModifier {
15
+ private readonly options;
16
+ constructor(options?: ToolManifestPromptModifierOptions);
17
+ modify(_originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
18
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolManifestPromptModifier = void 0;
4
+ const base_1 = require("../base");
5
+ const promptContext_1 = require("../../unified/base/promptContext");
6
+ class ToolManifestPromptModifier extends base_1.BaseMessageModifier {
7
+ constructor(options = {}) {
8
+ super();
9
+ this.options = options;
10
+ }
11
+ async modify(_originalRequest, createdMessage) {
12
+ const codeboltjs = await import("@codebolt/codeboltjs");
13
+ const codeboltTools = codeboltjs.tools;
14
+ if (!(codeboltTools === null || codeboltTools === void 0 ? void 0 : codeboltTools.getAvailableToolsManifest) && !(codeboltTools === null || codeboltTools === void 0 ? void 0 : codeboltTools.getAvailableToolsManifestAsync)) {
15
+ return createdMessage;
16
+ }
17
+ const manifestOptions = {
18
+ mode: this.options.mode || "categories",
19
+ };
20
+ if (this.options.category !== undefined) {
21
+ manifestOptions.category = this.options.category;
22
+ }
23
+ if (this.options.pattern !== undefined) {
24
+ manifestOptions.pattern = this.options.pattern;
25
+ }
26
+ if (this.options.limit !== undefined) {
27
+ manifestOptions.limit = this.options.limit;
28
+ }
29
+ if (this.options.includeDescriptions !== undefined) {
30
+ manifestOptions.includeDescriptions = this.options.includeDescriptions;
31
+ }
32
+ if (this.options.includeResources !== undefined) {
33
+ manifestOptions.includeResources = this.options.includeResources;
34
+ }
35
+ if (this.options.runtimeToolSetId !== undefined) {
36
+ manifestOptions.runtimeToolSetId = this.options.runtimeToolSetId;
37
+ }
38
+ const manifest = codeboltTools.getAvailableToolsManifestAsync
39
+ ? await codeboltTools.getAvailableToolsManifestAsync(manifestOptions)
40
+ : codeboltTools.getAvailableToolsManifest(manifestOptions);
41
+ const contextMessage = {
42
+ role: "user",
43
+ content: `<tool_capability_catalogue title="${this.options.title || "Available CodeBolt tool areas"}">\n${manifest.text}\n</tool_capability_catalogue>`,
44
+ };
45
+ const updatedMessage = (0, promptContext_1.appendUserContextMessage)(createdMessage, contextMessage);
46
+ return {
47
+ ...updatedMessage,
48
+ metadata: {
49
+ ...updatedMessage.metadata,
50
+ toolManifestInjected: true,
51
+ toolManifestMode: manifest.mode,
52
+ toolManifestTotalMatches: manifest.totalMatches,
53
+ },
54
+ };
55
+ }
56
+ }
57
+ exports.ToolManifestPromptModifier = ToolManifestPromptModifier;
@@ -517,12 +517,16 @@ CRITICAL RULES:
517
517
  var _a;
518
518
  try {
519
519
  const prompt = this.getCompressionPrompt(historyToCompress);
520
- const response = await codeboltjs_1.default.llm.inference({
520
+ const inferencePayload = {
521
+ formatVersion: 'codebolt.llm.v2',
521
522
  input: [
522
523
  { role: 'system', content: 'You are a precise conversation compression assistant.' },
523
524
  { role: 'user', content: prompt }
524
525
  ],
525
- });
526
+ llmrole: this.options.llmRole,
527
+ };
528
+ console.log('[ConversationCompactor] llm.inference payload:', inferencePayload);
529
+ const response = await codeboltjs_1.default.llm.inference(inferencePayload);
526
530
  const summary = ((_a = response.completion) === null || _a === void 0 ? void 0 : _a.content) || '';
527
531
  if (this.options.enableLogging) {
528
532
  console.log(`[ConversationCompactor] Generated summary (${summary.length} chars)`);
@@ -553,12 +557,16 @@ ORIGINAL MESSAGES COUNT: ${originalHistory.length}
553
557
  If the snapshot is accurate and complete, respond with just the original snapshot.
554
558
  If there are inaccuracies or missing critical information, provide a corrected version.
555
559
  Keep the same XML format.`;
556
- const response = await codeboltjs_1.default.llm.inference({
560
+ const inferencePayload = {
561
+ formatVersion: 'codebolt.llm.v2',
557
562
  input: [
558
563
  { role: 'system', content: 'You are verifying a conversation compression for accuracy.' },
559
564
  { role: 'user', content: verificationPrompt }
560
- ]
561
- });
565
+ ],
566
+ llmrole: this.options.llmRole,
567
+ };
568
+ console.log('[ConversationCompactor] llm.inference verification payload:', inferencePayload);
569
+ const response = await codeboltjs_1.default.llm.inference(inferencePayload);
562
570
  return ((_a = response.completion) === null || _a === void 0 ? void 0 : _a.content) || summary;
563
571
  }
564
572
  catch (error) {
@@ -186,6 +186,16 @@ export interface UserMessage {
186
186
  mentionedFolders: string[];
187
187
  /** Images uploaded with the message */
188
188
  uploadedImages: string[];
189
+ /** Agent Prompt name for this message, when one was selected */
190
+ selectedAgentPromptName?: string;
191
+ /** Agent id that owns the selected Agent Prompt */
192
+ selectedAgentPromptAgentId?: string;
193
+ /** Prompt contributed by the selected Agent Prompt */
194
+ selectedAgentPromptText?: string;
195
+ /** Agent Prompt argument values used when rendering the prompt */
196
+ selectedAgentPromptArguments?: Record<string, string>;
197
+ /** Agent Prompt text combined with the raw user message */
198
+ effectiveUserMessage?: string;
189
199
  /** Selected agent information */
190
200
  selectedAgent: {
191
201
  id: string;
@@ -224,25 +234,152 @@ export interface EmitAgentEventResponse {
224
234
  };
225
235
  error?: string;
226
236
  }
237
+ export type ToolSourceType = 'built-in' | 'mcp' | 'plugin' | 'project-local' | 'agent-local' | 'unknown';
238
+ export interface ToolNamespace {
239
+ namespace: string;
240
+ sourceType?: ToolSourceType;
241
+ sourceId?: string;
242
+ displayName?: string;
243
+ toolCount?: number;
244
+ }
245
+ export interface ToolSource {
246
+ sourceId: string;
247
+ sourceType: ToolSourceType;
248
+ displayName?: string;
249
+ namespaces?: string[];
250
+ toolCount?: number;
251
+ }
252
+ export interface RuntimeToolDescriptor {
253
+ name: string;
254
+ toolName: string;
255
+ namespace: string;
256
+ sourceType: ToolSourceType;
257
+ sourceId?: string;
258
+ displayName?: string;
259
+ description?: string;
260
+ inputSchema: Record<string, unknown>;
261
+ outputSchema?: Record<string, unknown>;
262
+ metadata?: Record<string, unknown>;
263
+ }
227
264
  /**
228
265
  * Interface for codebolt API functionality
229
266
  */
230
267
  export interface CodeboltAPI {
231
- mcp: {
232
- listMcpFromServers: (servers: string[]) => Promise<{
233
- data: OpenAITool[];
268
+ tools?: {
269
+ listBuiltInTools: (options?: {
270
+ namespace?: string;
271
+ grep?: string;
272
+ limit?: number;
273
+ }) => Promise<{
274
+ data: {
275
+ tools: RuntimeToolDescriptor[];
276
+ };
234
277
  }>;
235
- getRegisteredTools: () => Promise<{
236
- data?: {
237
- tools: OpenAITool[];
278
+ listExternalTools: (options?: {
279
+ namespace?: string;
280
+ sourceType?: ToolSourceType;
281
+ sourceId?: string;
282
+ grep?: string;
283
+ limit?: number;
284
+ }) => Promise<{
285
+ data: {
286
+ tools: RuntimeToolDescriptor[];
238
287
  };
239
288
  }>;
240
- getTools: (mcps: any[]) => Promise<{
241
- data: OpenAITool[];
289
+ listRuntimeTools: (options?: {
290
+ includeBuiltIn?: boolean;
291
+ includeExternal?: boolean;
292
+ includeAgentLocal?: boolean;
293
+ agentLocalTools?: Array<OpenAITool | RuntimeToolDescriptor>;
294
+ namespace?: string;
295
+ sourceType?: ToolSourceType;
296
+ sourceId?: string;
297
+ grep?: string;
298
+ limit?: number;
299
+ }) => Promise<{
300
+ data: {
301
+ tools: RuntimeToolDescriptor[];
302
+ };
242
303
  }>;
243
- executeTool: (toolboxName: string, actualToolName: string, toolInput: any) => Promise<{
244
- data: any;
304
+ listToolNamespaces: (options?: {
305
+ includeBuiltIn?: boolean;
306
+ includeExternal?: boolean;
307
+ includeAgentLocal?: boolean;
308
+ agentLocalTools?: Array<OpenAITool | RuntimeToolDescriptor>;
309
+ namespace?: string;
310
+ sourceType?: ToolSourceType;
311
+ sourceId?: string;
312
+ grep?: string;
313
+ limit?: number;
314
+ }) => Promise<{
315
+ data: {
316
+ namespaces: ToolNamespace[];
317
+ };
318
+ }>;
319
+ listToolsByNamespace: (namespace: string, options?: {
320
+ includeBuiltIn?: boolean;
321
+ includeExternal?: boolean;
322
+ includeAgentLocal?: boolean;
323
+ agentLocalTools?: Array<OpenAITool | RuntimeToolDescriptor>;
324
+ sourceType?: ToolSourceType;
325
+ sourceId?: string;
326
+ grep?: string;
327
+ limit?: number;
328
+ }) => Promise<{
329
+ data: {
330
+ tools: RuntimeToolDescriptor[];
331
+ };
245
332
  }>;
333
+ listToolSources: (options?: {
334
+ includeBuiltIn?: boolean;
335
+ includeExternal?: boolean;
336
+ includeAgentLocal?: boolean;
337
+ agentLocalTools?: Array<OpenAITool | RuntimeToolDescriptor>;
338
+ namespace?: string;
339
+ sourceType?: ToolSourceType;
340
+ sourceId?: string;
341
+ grep?: string;
342
+ limit?: number;
343
+ }) => Promise<{
344
+ data: {
345
+ sources: ToolSource[];
346
+ };
347
+ }>;
348
+ listToolsBySource: (sourceId: string, options?: {
349
+ includeBuiltIn?: boolean;
350
+ includeExternal?: boolean;
351
+ includeAgentLocal?: boolean;
352
+ agentLocalTools?: Array<OpenAITool | RuntimeToolDescriptor>;
353
+ namespace?: string;
354
+ sourceType?: ToolSourceType;
355
+ grep?: string;
356
+ limit?: number;
357
+ }) => Promise<{
358
+ data: {
359
+ tools: RuntimeToolDescriptor[];
360
+ };
361
+ }>;
362
+ getRuntimeTool: (name: string) => Promise<{
363
+ data: {
364
+ tool?: RuntimeToolDescriptor;
365
+ };
366
+ }>;
367
+ execute: (toolName: string, toolInput?: any, options?: {
368
+ namespace?: string;
369
+ sourceId?: string;
370
+ }) => Promise<{
371
+ data?: any;
372
+ result?: any;
373
+ }>;
374
+ };
375
+ mcp: {
376
+ getEnabledMCPServers: () => Promise<unknown>;
377
+ getLocalMCPServers: () => Promise<unknown>;
378
+ getMentionedMCPServers: (userMessage: unknown) => Promise<unknown>;
379
+ searchAvailableMCPServers: (query: string) => Promise<unknown>;
380
+ configureMCPServer: (name: string, config: Record<string, unknown>) => Promise<unknown>;
381
+ getMcpList: () => Promise<unknown>;
382
+ getEnabledMcps: () => Promise<unknown>;
246
383
  };
247
384
  fs: {
248
385
  readFile: (filepath: string) => Promise<string>;
@@ -45,7 +45,11 @@ export interface UserMessage {
45
45
  mentionedMultiFile: string[];
46
46
  mentionedMCPs: string[];
47
47
  uploadedImages: string[];
48
- actions: any[];
48
+ selectedAgentPromptAgentId?: string;
49
+ selectedAgentPromptName?: string;
50
+ selectedAgentPromptText?: string;
51
+ selectedAgentPromptArguments?: Record<string, string>;
52
+ effectiveUserMessage?: string;
49
53
  mentionedAgents: any[];
50
54
  mentionedDocs: any[];
51
55
  mentionedEnvironments?: any[];
@@ -90,7 +94,11 @@ export interface ChatMessageFromUser {
90
94
  mentionedMultiFile: string[];
91
95
  mentionedMCPs: string[];
92
96
  uploadedImages: string[];
93
- actions: any[];
97
+ selectedAgentPromptAgentId?: string;
98
+ selectedAgentPromptName?: string;
99
+ selectedAgentPromptText?: string;
100
+ selectedAgentPromptArguments?: Record<string, string>;
101
+ effectiveUserMessage?: string;
94
102
  mentionedAgents: any[];
95
103
  mentionedDocs: any[];
96
104
  mentionedEnvironments?: any[];
@@ -5,6 +5,7 @@ import type { CompactionOrchestratorOptions } from "../services/compaction/types
5
5
  export interface AgentOptions extends AgentConfig {
6
6
  context?: ProcessedMessage;
7
7
  allowedTools?: string[];
8
+ llmRole?: string;
8
9
  compaction?: CompactionOrchestratorOptions;
9
10
  loopDetectionService?: LoopDetectionService;
10
11
  maxTurns?: number;
@@ -55,6 +56,7 @@ export declare class Agent implements AgentInterface {
55
56
  private readonly compactionOrchestrator;
56
57
  private readonly loopDetectionService;
57
58
  private readonly maxTurns;
59
+ private readonly llmRole;
58
60
  private readonly localToolSchemas;
59
61
  private readonly localToolsByExecutionName;
60
62
  private readonly runtimeToolSetId;
@@ -76,6 +78,7 @@ export declare class Agent implements AgentInterface {
76
78
  getPostToolCallProcessors(): PostToolCallProcessor[];
77
79
  private resolveRunContext;
78
80
  private getResumeMessageModifiers;
81
+ private normalizeLLMRole;
79
82
  private isProcessedMessage;
80
83
  private applyCompaction;
81
84
  private hydratePromptFromServerCompaction;
@@ -100,7 +100,7 @@ function collectProcessors(fromNested, fromTopLevel) {
100
100
  }
101
101
  class Agent {
102
102
  constructor(config) {
103
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
103
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
104
104
  const localToolRegistry = (0, agentToolLoader_1.createAgentLocalToolRegistry)(config.tools || []);
105
105
  const includeDefaultModifiers = (_b = (_a = config.includeDefaultModifiers) !== null && _a !== void 0 ? _a : config.defaultProcessors) !== null && _b !== void 0 ? _b : true;
106
106
  const includeDefaultProcessors = (_d = (_c = config.includeDefaultProcessors) !== null && _c !== void 0 ? _c : config.defaultProcessors) !== null && _d !== void 0 ? _d : true;
@@ -113,14 +113,19 @@ class Agent {
113
113
  this.baseSystemPrompt = config.instructions || DEFAULT_SYSTEM_PROMPT;
114
114
  this.context = config.context;
115
115
  this.allowedTools = config.allowedTools;
116
+ this.llmRole = this.normalizeLLMRole(config.llmRole);
116
117
  this.messageModifiers = mergeProcessors(defaultMessageModifiers, customMessageModifiers);
117
118
  this.preInferenceProcessors = mergeProcessors(includeDefaultProcessors ? createDefaultPreInferenceProcessors() : [], collectProcessors((_f = config.processors) === null || _f === void 0 ? void 0 : _f.preInferenceProcessors, config.preInferenceProcessors));
118
119
  this.postInferenceProcessors = mergeProcessors(includeDefaultProcessors ? createDefaultPostInferenceProcessors() : [], collectProcessors((_g = config.processors) === null || _g === void 0 ? void 0 : _g.postInferenceProcessors, config.postInferenceProcessors));
119
120
  this.preToolCallProcessors = mergeProcessors(includeDefaultProcessors ? createDefaultPreToolCallProcessors() : [], collectProcessors((_h = config.processors) === null || _h === void 0 ? void 0 : _h.preToolCallProcessors, config.preToolCallProcessors));
120
121
  this.postToolCallProcessors = mergeProcessors(includeDefaultProcessors ? createDefaultPostToolCallProcessors() : [], collectProcessors((_j = config.processors) === null || _j === void 0 ? void 0 : _j.postToolCallProcessors, config.postToolCallProcessors));
121
- this.compactionOrchestrator = new compactionOrchestrator_1.CompactionOrchestrator(config.compaction);
122
+ const compactionLLMRole = (_l = this.normalizeLLMRole((_k = config.compaction) === null || _k === void 0 ? void 0 : _k.llmRole)) !== null && _l !== void 0 ? _l : this.llmRole;
123
+ this.compactionOrchestrator = new compactionOrchestrator_1.CompactionOrchestrator({
124
+ ...config.compaction,
125
+ ...(compactionLLMRole ? { llmRole: compactionLLMRole } : {}),
126
+ });
122
127
  this.loopDetectionService = config.loopDetectionService;
123
- this.maxTurns = (_l = (_k = config.maxTurns) !== null && _k !== void 0 ? _k : config.maxIterations) !== null && _l !== void 0 ? _l : 25;
128
+ this.maxTurns = (_o = (_m = config.maxTurns) !== null && _m !== void 0 ? _m : config.maxIterations) !== null && _o !== void 0 ? _o : 25;
124
129
  this.localToolSchemas = localToolRegistry.schemas;
125
130
  this.localToolsByExecutionName = localToolRegistry.byExecutionName;
126
131
  this.runtimeToolSetId = `agent-${(0, crypto_1.randomUUID)()}`;
@@ -165,7 +170,8 @@ class Agent {
165
170
  prompt = await this.refreshAvailableTools(reqMessage, prompt);
166
171
  const agentStep = new agentStep_1.AgentStep({
167
172
  preInferenceProcessors: this.preInferenceProcessors,
168
- postInferenceProcessors: this.postInferenceProcessors
173
+ postInferenceProcessors: this.postInferenceProcessors,
174
+ ...(this.llmRole ? { llmRole: this.llmRole } : {}),
169
175
  });
170
176
  let stepResult;
171
177
  while (!stepResult) {
@@ -306,6 +312,10 @@ class Agent {
306
312
  getResumeMessageModifiers() {
307
313
  return this.messageModifiers.filter((modifier) => { var _a; return ((_a = modifier.constructor) === null || _a === void 0 ? void 0 : _a.name) !== 'ChatHistoryMessageModifier'; });
308
314
  }
315
+ normalizeLLMRole(llmRole) {
316
+ const normalized = llmRole === null || llmRole === void 0 ? void 0 : llmRole.trim();
317
+ return normalized ? normalized : undefined;
318
+ }
309
319
  isProcessedMessage(value) {
310
320
  return 'message' in value && 'metadata' in value;
311
321
  }
@@ -25,7 +25,7 @@ export declare class AgentStep implements AgentStepInterface {
25
25
  /**
26
26
  * Get current LLM configuration
27
27
  */
28
- getLLMConfig(): string;
28
+ getLLMConfig(): string | undefined;
29
29
  updatePreInferenceProcessors(processors: PreInferenceProcessor[]): void;
30
30
  getPreInferenceProcessors(): PreInferenceProcessor[];
31
31
  updatePostInferenceProcessors(processors: PostInferenceProcessor[]): void;
@@ -13,7 +13,7 @@ class AgentStep {
13
13
  constructor(options = {}) {
14
14
  this.preInferenceProcessors = options.preInferenceProcessors || [];
15
15
  this.postInferenceProcessors = options.postInferenceProcessors || [];
16
- this.llmRole = options.llmRole || 'default';
16
+ this.llmRole = options.llmRole;
17
17
  }
18
18
  /**
19
19
  * Execute a single agent step
@@ -33,7 +33,10 @@ class AgentStep {
33
33
  }
34
34
  const actualMessageSentToLLM = {
35
35
  ...preparedMessage,
36
- message: (0, promptContext_1.buildInferenceParams)(preparedMessage),
36
+ message: {
37
+ ...(0, promptContext_1.buildInferenceParams)(preparedMessage),
38
+ ...(this.llmRole ? { llmrole: this.llmRole } : {}),
39
+ },
37
40
  };
38
41
  const rawLLMResponse = await this.generateResponse(actualMessageSentToLLM.message);
39
42
  const assistantResponseItems = ((_a = rawLLMResponse.items) !== null && _a !== void 0 ? _a : [])
@@ -64,6 +67,7 @@ class AgentStep {
64
67
  }
65
68
  async generateResponse(messageForLLM) {
66
69
  var _a, _b, _c, _d, _e;
70
+ console.log('[AgentStep] llm.inference payload:', messageForLLM);
67
71
  const response = await codeboltjs_1.default.llm.inference(messageForLLM);
68
72
  const completion = this.extractCompletion(response);
69
73
  if (!completion) {
@@ -129,7 +133,8 @@ class AgentStep {
129
133
  * Update LLM configuration
130
134
  */
131
135
  setLLMConfig(config) {
132
- this.llmRole = config;
136
+ const normalized = config.trim();
137
+ this.llmRole = normalized ? normalized : undefined;
133
138
  }
134
139
  /**
135
140
  * Get current LLM configuration
@@ -140,14 +145,12 @@ class AgentStep {
140
145
  updatePreInferenceProcessors(processors) {
141
146
  this.preInferenceProcessors = processors;
142
147
  }
143
- ;
144
148
  getPreInferenceProcessors() {
145
149
  return this.preInferenceProcessors;
146
150
  }
147
151
  updatePostInferenceProcessors(processors) {
148
152
  this.postInferenceProcessors = processors;
149
153
  }
150
- ;
151
154
  getPostInferenceProcessors() {
152
155
  return this.postInferenceProcessors;
153
156
  }
@@ -145,9 +145,10 @@ class InitialPromptGenerator {
145
145
  if (!isResumedPrompt && this.baseSystemPrompt !== undefined) {
146
146
  createdMessage = (0, promptContext_1.setSystemPrompt)(createdMessage, this.baseSystemPrompt);
147
147
  }
148
+ const userMessageText = input.effectiveUserMessage || input.userMessage || '';
148
149
  createdMessage = (0, promptContext_1.appendTranscriptMessage)(createdMessage, {
149
150
  role: 'user',
150
- content: buildUserMessageContent(input.userMessage || '', input.uploadedImages),
151
+ content: buildUserMessageContent(userMessageText, input.uploadedImages),
151
152
  });
152
153
  const flagContext = formatFlagContext(input.flags, input.mentionedFlags);
153
154
  if (flagContext) {