@codebolt/agent 6.1.8 → 6.1.11

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.
@@ -9,6 +9,6 @@ export declare class CapabilityContextModifier extends BaseMessageModifier {
9
9
  constructor(options?: CapabilityContextModifierOptions);
10
10
  modify(originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
11
11
  private normalizeCapabilities;
12
- private resolveCapabilityContext;
13
- private formatCapabilityContext;
12
+ private resolveSelectedCapability;
13
+ private formatSelectedCapabilitiesContext;
14
14
  }
@@ -17,31 +17,24 @@ class CapabilityContextModifier extends base_1.BaseMessageModifier {
17
17
  if (selectedCapabilities.length === 0) {
18
18
  return createdMessage;
19
19
  }
20
- const resolvedContexts = [];
20
+ const skillContexts = [];
21
+ const selectedCapabilityInfo = [];
21
22
  const capabilityErrors = [];
22
23
  for (const capabilityName of selectedCapabilities) {
23
- const resolvedContext = await this.resolveCapabilityContext(capabilityName, originalRequest);
24
+ const resolvedContext = await this.resolveSelectedCapability(capabilityName, originalRequest);
25
+ if (resolvedContext.info) {
26
+ selectedCapabilityInfo.push(resolvedContext.info);
27
+ }
24
28
  if (resolvedContext.context) {
25
- resolvedContexts.push(resolvedContext.context);
29
+ skillContexts.push(resolvedContext.context);
26
30
  }
27
31
  if (resolvedContext.error) {
28
32
  capabilityErrors.push(resolvedContext.error);
29
33
  }
30
34
  }
31
- if (resolvedContexts.length === 0) {
32
- return {
33
- ...createdMessage,
34
- metadata: {
35
- ...createdMessage.metadata,
36
- selectedCapabilities,
37
- selectedCapabilityErrors: capabilityErrors,
38
- selectedCapabilitiesProcessed: false,
39
- },
40
- };
41
- }
42
35
  const contextMessage = {
43
36
  role: 'user',
44
- content: this.formatCapabilityContext(resolvedContexts),
37
+ content: this.formatSelectedCapabilitiesContext(selectedCapabilities, selectedCapabilityInfo, skillContexts),
45
38
  };
46
39
  return {
47
40
  ...(0, promptContext_1.appendUserContextMessage)(createdMessage, contextMessage),
@@ -49,7 +42,7 @@ class CapabilityContextModifier extends base_1.BaseMessageModifier {
49
42
  ...createdMessage.metadata,
50
43
  selectedCapabilities,
51
44
  selectedCapabilitiesProcessed: true,
52
- selectedCapabilityNames: resolvedContexts.map((context) => context.name),
45
+ selectedCapabilityNames: skillContexts.map((context) => context.name),
53
46
  selectedCapabilityErrors: capabilityErrors,
54
47
  },
55
48
  };
@@ -62,7 +55,7 @@ class CapabilityContextModifier extends base_1.BaseMessageModifier {
62
55
  .map((capabilityName) => capabilityName.trim())
63
56
  .filter(Boolean)));
64
57
  }
65
- async resolveCapabilityContext(capabilityName, originalRequest) {
58
+ async resolveSelectedCapability(capabilityName, originalRequest) {
66
59
  var _a, _b;
67
60
  try {
68
61
  const capabilityDetail = await codeboltjs_1.default.capability.getCapabilityDetail(capabilityName);
@@ -75,16 +68,31 @@ class CapabilityContextModifier extends base_1.BaseMessageModifier {
75
68
  };
76
69
  }
77
70
  const capabilityType = capabilityDetail.capability.type;
78
- const response = await codeboltjs_1.default.capability.startCapability(capabilityName, capabilityType, {
71
+ if (capabilityType !== 'skill') {
72
+ return {
73
+ info: {
74
+ name: capabilityName,
75
+ type: capabilityType,
76
+ autoLoaded: false,
77
+ reason: 'Only skill capabilities are auto-loaded. Talents and powers stay selected and must be invoked with the capability tool if needed.',
78
+ },
79
+ };
80
+ }
81
+ const response = await codeboltjs_1.default.capability.startSkill(capabilityName, {
79
82
  arguments: originalRequest.userMessage,
80
83
  input: originalRequest.userMessage,
81
84
  task: originalRequest.userMessage,
82
85
  }, this.options.timeout);
83
86
  if (!(response === null || response === void 0 ? void 0 : response.success)) {
84
87
  return {
88
+ info: {
89
+ name: capabilityName,
90
+ type: capabilityType,
91
+ autoLoaded: false,
92
+ },
85
93
  error: {
86
94
  name: capabilityName,
87
- error: (response === null || response === void 0 ? void 0 : response.error) || 'Capability did not return a successful response',
95
+ error: (response === null || response === void 0 ? void 0 : response.error) || 'Skill did not return a successful response',
88
96
  },
89
97
  };
90
98
  }
@@ -92,16 +100,26 @@ class CapabilityContextModifier extends base_1.BaseMessageModifier {
92
100
  const prompt = typeof (skillPrompt === null || skillPrompt === void 0 ? void 0 : skillPrompt.prompt) === 'string' ? skillPrompt.prompt.trim() : '';
93
101
  if (!prompt) {
94
102
  return {
103
+ info: {
104
+ name: capabilityName,
105
+ type: capabilityType,
106
+ autoLoaded: false,
107
+ },
95
108
  error: {
96
109
  name: capabilityName,
97
- error: 'Capability response did not include prompt context',
110
+ error: 'Skill response did not include prompt context',
98
111
  },
99
112
  };
100
113
  }
101
114
  return {
115
+ info: {
116
+ name: capabilityName,
117
+ type: capabilityType,
118
+ autoLoaded: true,
119
+ },
102
120
  context: {
103
121
  name: skillPrompt.skillName || capabilityName,
104
- type: capabilityType,
122
+ type: 'skill',
105
123
  prompt,
106
124
  refs: skillPrompt.refs,
107
125
  metadata: skillPrompt.metadata,
@@ -117,17 +135,31 @@ class CapabilityContextModifier extends base_1.BaseMessageModifier {
117
135
  };
118
136
  }
119
137
  }
120
- formatCapabilityContext(resolvedContexts) {
121
- const contextSections = resolvedContexts.map((context) => {
138
+ formatSelectedCapabilitiesContext(selectedCapabilities, selectedCapabilityInfo, skillContexts) {
139
+ const infoByName = new Map(selectedCapabilityInfo.map((info) => [info.name, info]));
140
+ const selectedSections = selectedCapabilities.map((capabilityName) => {
141
+ const info = infoByName.get(capabilityName);
142
+ const type = (info === null || info === void 0 ? void 0 : info.type) ? ` (${info.type})` : '';
143
+ const status = (info === null || info === void 0 ? void 0 : info.autoLoaded) ? 'skill context loaded' : 'not auto-loaded';
144
+ const reason = (info === null || info === void 0 ? void 0 : info.reason) ? ` - ${info.reason}` : '';
145
+ return `- ${capabilityName}${type}: ${status}${reason}`;
146
+ });
147
+ const skillContextSections = skillContexts.map((context) => {
122
148
  const refs = Array.isArray(context.refs) && context.refs.length > 0
123
149
  ? `\n\nCapability references:\n${context.refs.map((ref) => `- ${JSON.stringify(ref)}`).join('\n')}`
124
150
  : '';
125
- return `--- Selected capability: ${context.name} (${context.type}) ---\n${context.prompt}${refs}`;
151
+ return `--- Selected skill capability: ${context.name} ---\n${context.prompt}${refs}`;
126
152
  });
127
153
  return [
128
- 'The user selected the following capabilities for this turn. Use this capability context while answering the user.',
129
- ...contextSections,
130
- ].join('\n\n');
154
+ 'The user selected the following capabilities for this turn:',
155
+ ...selectedSections,
156
+ '',
157
+ 'Skill capabilities are auto-loaded as prompt context below. Talents and powers are not auto-started.',
158
+ 'Use the capability tool to inspect or invoke selected talents/powers only if the user request needs them.',
159
+ ...(skillContextSections.length > 0
160
+ ? ['', ...skillContextSections]
161
+ : []),
162
+ ].join('\n');
131
163
  }
132
164
  }
133
165
  exports.CapabilityContextModifier = CapabilityContextModifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/agent",
3
- "version": "6.1.8",
3
+ "version": "6.1.11",
4
4
  "description": "CodeBolt Agent utilities for building and managing AI agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",