@olane/o-lane 0.8.13 → 0.8.14
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/dist/src/capabilities-execute/execute.capability.d.ts +4 -0
- package/dist/src/capabilities-execute/execute.capability.d.ts.map +1 -1
- package/dist/src/capabilities-execute/execute.capability.js +83 -123
- package/dist/src/manager/o-lane.manager.d.ts.map +1 -1
- package/dist/src/o-lane.d.ts +7 -10
- package/dist/src/o-lane.d.ts.map +1 -1
- package/dist/src/o-lane.js +50 -59
- package/dist/src/prompts/custom.prompt.d.ts.map +1 -1
- package/dist/test/execute-capability-address.spec.js +1 -1
- package/package.json +27 -27
|
@@ -9,6 +9,10 @@ export declare class oCapabilityExecute extends oCapabilityIntelligence {
|
|
|
9
9
|
private resolveAddress;
|
|
10
10
|
loadPrompt({ tools, methods }: any): Promise<string>;
|
|
11
11
|
handshake(): Promise<oHandshakeResult>;
|
|
12
|
+
private executeTask;
|
|
13
|
+
private buildResult;
|
|
14
|
+
private buildErrorResult;
|
|
15
|
+
private requestApproval;
|
|
12
16
|
run(): Promise<oCapabilityResult>;
|
|
13
17
|
}
|
|
14
18
|
//# sourceMappingURL=execute.capability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.capability.d.ts","sourceRoot":"","sources":["../../../src/capabilities-execute/execute.capability.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,qBAAa,kBAAmB,SAAQ,uBAAuB;IACtD,MAAM,EAAG,wBAAwB,CAAC;IAEzC,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,OAAO,CAAC,cAAc;IAYhB,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAepD,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.capability.d.ts","sourceRoot":"","sources":["../../../src/capabilities-execute/execute.capability.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,qBAAa,kBAAmB,SAAQ,uBAAuB;IACtD,MAAM,EAAG,wBAAwB,CAAC;IAEzC,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,OAAO,CAAC,cAAc;IAYhB,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAepD,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC;YAU9B,WAAW;IAQzB,OAAO,CAAC,WAAW;IA8BnB,OAAO,CAAC,gBAAgB;YAqBV,eAAe;IA0CvB,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CA+FxC"}
|
|
@@ -40,14 +40,83 @@ export class oCapabilityExecute extends oCapabilityIntelligence {
|
|
|
40
40
|
});
|
|
41
41
|
return response.result.data;
|
|
42
42
|
}
|
|
43
|
+
async executeTask(method, params) {
|
|
44
|
+
this.logger.debug('Executing task:', method);
|
|
45
|
+
return await this.node.use(new oAddress(this.resolveAddress()), {
|
|
46
|
+
method,
|
|
47
|
+
params,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
buildResult(taskResponse, handshakeResult, taskConfig, address) {
|
|
51
|
+
const shouldPersist = taskResponse.result?.data?._save === true;
|
|
52
|
+
if (shouldPersist) {
|
|
53
|
+
this.logger.debug('Tool response contains _save flag - lane will be persisted to config');
|
|
54
|
+
}
|
|
55
|
+
const result = {
|
|
56
|
+
handshakeResult,
|
|
57
|
+
taskConfig,
|
|
58
|
+
response: taskResponse.result,
|
|
59
|
+
};
|
|
60
|
+
if (address) {
|
|
61
|
+
result.address = address;
|
|
62
|
+
}
|
|
63
|
+
return new oCapabilityResult({
|
|
64
|
+
type: oCapabilityType.EVALUATE,
|
|
65
|
+
config: this.config,
|
|
66
|
+
result,
|
|
67
|
+
shouldPersist,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
buildErrorResult(error, handshakeResult, taskConfig) {
|
|
71
|
+
const addr = this.resolveAddress();
|
|
72
|
+
const errorMessage = `Error when trying to use ${addr} with config: ${JSON.stringify(taskConfig)} resulting in error: ${error?.message}`;
|
|
73
|
+
this.logger.error('Failed to execute:', errorMessage);
|
|
74
|
+
return new oCapabilityResult({
|
|
75
|
+
type: oCapabilityType.EVALUATE,
|
|
76
|
+
config: this.config,
|
|
77
|
+
result: {
|
|
78
|
+
handshakeResult,
|
|
79
|
+
taskConfig,
|
|
80
|
+
},
|
|
81
|
+
error: errorMessage,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async requestApproval(method, params) {
|
|
85
|
+
try {
|
|
86
|
+
const approvalResponse = await this.node.use(new oAddress('o://approval'), {
|
|
87
|
+
method: 'request_approval',
|
|
88
|
+
params: {
|
|
89
|
+
toolAddress: this.resolveAddress(),
|
|
90
|
+
method,
|
|
91
|
+
params,
|
|
92
|
+
intent: this.config.intent,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const approved = approvalResponse.result.data?.approved;
|
|
96
|
+
if (!approved) {
|
|
97
|
+
const decision = approvalResponse.result.data?.decision || 'denied';
|
|
98
|
+
this.logger.warn(`Task execution denied by approval system: ${decision}`);
|
|
99
|
+
throw new oError(oErrorCodes.NOT_AUTHORIZED, `Action denied by approval system: ${decision}`);
|
|
100
|
+
}
|
|
101
|
+
this.logger.debug('Task approved, proceeding with execution');
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// If approval service is not available, log warning and continue
|
|
105
|
+
// This ensures backward compatibility
|
|
106
|
+
if (error.message?.includes('No route found')) {
|
|
107
|
+
this.logger.warn('Approval service not available, proceeding without approval check');
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
43
114
|
async run() {
|
|
44
|
-
this.logger.debug('Starting execution capability with config:', this.config);
|
|
45
|
-
//
|
|
115
|
+
this.logger.debug('Starting execution capability with config:', this.config.intent);
|
|
116
|
+
// Replay mode: skip handshake, AI, and approval
|
|
46
117
|
if (this.config.isReplay) {
|
|
47
118
|
this.logger.debug('Execute capability is being replayed - using stored execution data');
|
|
48
|
-
// Extract stored execution data
|
|
49
119
|
const storedExecution = this.config.params;
|
|
50
|
-
// Validate stored data exists (strict mode - fail if missing)
|
|
51
120
|
if (!storedExecution) {
|
|
52
121
|
this.logger.warn('Invalid replay:', this.config);
|
|
53
122
|
throw new oError(oErrorCodes.INVALID_RESPONSE, 'Replay mode enabled but no stored execution data found');
|
|
@@ -64,44 +133,15 @@ export class oCapabilityExecute extends oCapabilityIntelligence {
|
|
|
64
133
|
skipIntelligence: true,
|
|
65
134
|
skipApproval: true,
|
|
66
135
|
});
|
|
67
|
-
// Execute the stored task directly (skip handshake, AI, and approval)
|
|
68
136
|
try {
|
|
69
|
-
const taskResponse = await this.
|
|
70
|
-
|
|
71
|
-
params: params,
|
|
72
|
-
});
|
|
73
|
-
// Check if the tool response contains _save flag
|
|
74
|
-
const shouldPersist = taskResponse.result?.data?._save === true;
|
|
75
|
-
if (shouldPersist) {
|
|
76
|
-
this.logger.debug('Tool response contains _save flag - lane will be persisted to config');
|
|
77
|
-
}
|
|
78
|
-
// Return an EVALUATE result that contains the task execution output
|
|
79
|
-
return new oCapabilityResult({
|
|
80
|
-
type: oCapabilityType.EVALUATE,
|
|
81
|
-
config: this.config,
|
|
82
|
-
result: {
|
|
83
|
-
handshakeResult: handshakeResult,
|
|
84
|
-
taskConfig: taskConfig,
|
|
85
|
-
response: taskResponse.result,
|
|
86
|
-
},
|
|
87
|
-
shouldPersist,
|
|
88
|
-
});
|
|
137
|
+
const taskResponse = await this.executeTask(method, params);
|
|
138
|
+
return this.buildResult(taskResponse, handshakeResult, taskConfig);
|
|
89
139
|
}
|
|
90
140
|
catch (error) {
|
|
91
|
-
|
|
92
|
-
this.logger.error('Failed to execute during replay:', `Error when trying to use ${addr} with config: ${JSON.stringify(taskConfig)} resulting in error: ${error?.message}`);
|
|
93
|
-
return new oCapabilityResult({
|
|
94
|
-
type: oCapabilityType.EVALUATE,
|
|
95
|
-
config: this.config,
|
|
96
|
-
result: {
|
|
97
|
-
handshakeResult: handshakeResult,
|
|
98
|
-
taskConfig: taskConfig,
|
|
99
|
-
},
|
|
100
|
-
error: `Error when trying to use ${addr} with config: ${JSON.stringify(taskConfig)} resulting in error: ${error?.message}`,
|
|
101
|
-
});
|
|
141
|
+
return this.buildErrorResult(error, handshakeResult, taskConfig);
|
|
102
142
|
}
|
|
103
143
|
}
|
|
104
|
-
// Normal execution flow
|
|
144
|
+
// Normal execution flow
|
|
105
145
|
const handshake = await this.handshake();
|
|
106
146
|
if (!handshake.result) {
|
|
107
147
|
throw new oError(oErrorCodes.INVALID_RESPONSE, 'Handshake failed');
|
|
@@ -109,8 +149,6 @@ export class oCapabilityExecute extends oCapabilityIntelligence {
|
|
|
109
149
|
const { tools, methods } = handshake.result;
|
|
110
150
|
const prompt = await this.loadPrompt({ tools, methods });
|
|
111
151
|
const aiResponse = await this.intelligence(prompt);
|
|
112
|
-
// Extract task details from AI response
|
|
113
|
-
// The AI should return the method and params to execute
|
|
114
152
|
const task = aiResponse.result?.task || aiResponse.result;
|
|
115
153
|
if (!task || !task.method) {
|
|
116
154
|
this.logger.warn('AI did not return a valid task to execute', {
|
|
@@ -120,10 +158,7 @@ export class oCapabilityExecute extends oCapabilityIntelligence {
|
|
|
120
158
|
type: oCapabilityType.EVALUATE,
|
|
121
159
|
config: this.config,
|
|
122
160
|
result: {
|
|
123
|
-
handshakeResult: {
|
|
124
|
-
tools: tools,
|
|
125
|
-
methods: methods,
|
|
126
|
-
},
|
|
161
|
+
handshakeResult: { tools, methods },
|
|
127
162
|
address: this.resolveAddress(),
|
|
128
163
|
response: aiResponse.result,
|
|
129
164
|
},
|
|
@@ -132,90 +167,15 @@ export class oCapabilityExecute extends oCapabilityIntelligence {
|
|
|
132
167
|
}
|
|
133
168
|
const method = task.method;
|
|
134
169
|
const params = task.params || {};
|
|
170
|
+
const taskConfig = { method, params };
|
|
135
171
|
this.logger.debug('AI decided to execute:', { method, params });
|
|
136
|
-
|
|
172
|
+
await this.requestApproval(method, params);
|
|
137
173
|
try {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
params: {
|
|
141
|
-
toolAddress: this.resolveAddress(),
|
|
142
|
-
method: method,
|
|
143
|
-
params: params,
|
|
144
|
-
intent: this.config.intent,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
const approved = approvalResponse.result.data?.approved;
|
|
148
|
-
if (!approved) {
|
|
149
|
-
const decision = approvalResponse.result.data?.decision || 'denied';
|
|
150
|
-
this.logger.warn(`Task execution denied by approval system: ${decision}`);
|
|
151
|
-
throw new oError(oErrorCodes.NOT_AUTHORIZED, `Action denied by approval system: ${decision}`);
|
|
152
|
-
}
|
|
153
|
-
this.logger.debug('Task approved, proceeding with execution');
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
// If approval service is not available, log warning and continue
|
|
157
|
-
// This ensures backward compatibility
|
|
158
|
-
if (error.message?.includes('No route found')) {
|
|
159
|
-
this.logger.warn('Approval service not available, proceeding without approval check');
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
try {
|
|
166
|
-
// Execute the task
|
|
167
|
-
const taskResponse = await this.node.use(new oAddress(this.resolveAddress()), {
|
|
168
|
-
method: method,
|
|
169
|
-
params: params,
|
|
170
|
-
});
|
|
171
|
-
// Check if the tool response contains _save flag
|
|
172
|
-
const shouldPersist = taskResponse.result?.data?._save === true;
|
|
173
|
-
if (shouldPersist) {
|
|
174
|
-
this.logger.debug('Tool response contains _save flag - lane will be persisted to config');
|
|
175
|
-
}
|
|
176
|
-
// Return an EVALUATE result that contains the task execution output
|
|
177
|
-
return new oCapabilityResult({
|
|
178
|
-
type: oCapabilityType.EVALUATE,
|
|
179
|
-
config: this.config,
|
|
180
|
-
result: {
|
|
181
|
-
handshakeResult: {
|
|
182
|
-
tools: tools,
|
|
183
|
-
methods: methods,
|
|
184
|
-
},
|
|
185
|
-
taskConfig: {
|
|
186
|
-
method: method,
|
|
187
|
-
params: params,
|
|
188
|
-
},
|
|
189
|
-
address: this.resolveAddress(),
|
|
190
|
-
response: taskResponse.result,
|
|
191
|
-
},
|
|
192
|
-
shouldPersist,
|
|
193
|
-
});
|
|
174
|
+
const taskResponse = await this.executeTask(method, params);
|
|
175
|
+
return this.buildResult(taskResponse, { tools, methods }, taskConfig, this.resolveAddress());
|
|
194
176
|
}
|
|
195
177
|
catch (error) {
|
|
196
|
-
|
|
197
|
-
this.logger.error('Failed to execute:', `Error when trying to use ${addr} with config: ${JSON.stringify({
|
|
198
|
-
method: method,
|
|
199
|
-
params: params,
|
|
200
|
-
})} resulting in error: ${error?.message}`);
|
|
201
|
-
return new oCapabilityResult({
|
|
202
|
-
type: oCapabilityType.EVALUATE,
|
|
203
|
-
config: this.config,
|
|
204
|
-
result: {
|
|
205
|
-
handshakeResult: {
|
|
206
|
-
tools: handshake.result.tools,
|
|
207
|
-
methods: handshake.result.methods,
|
|
208
|
-
},
|
|
209
|
-
taskConfig: {
|
|
210
|
-
method: method,
|
|
211
|
-
params: params,
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
error: `Error when trying to use ${addr} with config: ${JSON.stringify({
|
|
215
|
-
method: method,
|
|
216
|
-
params: params,
|
|
217
|
-
})} resulting in error: ${error?.message}`,
|
|
218
|
-
});
|
|
178
|
+
return this.buildErrorResult(error, { tools, methods }, taskConfig);
|
|
219
179
|
}
|
|
220
180
|
}
|
|
221
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-lane.manager.d.ts","sourceRoot":"","sources":["../../../src/manager/o-lane.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,qBAAa,YAAa,SAAQ,OAAO;IAE3B,QAAQ,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"o-lane.manager.d.ts","sourceRoot":"","sources":["../../../src/manager/o-lane.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,qBAAa,YAAa,SAAQ,OAAO;IAE3B,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB;IADzC,KAAK,EAAE,KAAK,EAAE,CAAM;gBACN,MAAM,CAAC,EAAE,kBAAkB,YAAA;IAIhD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAYrD,UAAU,IAAI,IAAI;IAKlB,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAS7B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAIhC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B,IAAI,WAAW,IAAI,KAAK,EAAE,CAEzB;IAED,IAAI,UAAU,IAAI,KAAK,EAAE,CAExB;CACF"}
|
package/dist/src/o-lane.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { CID } from 'multiformats';
|
|
|
4
4
|
import { oIntent } from './intent/index.js';
|
|
5
5
|
import { oIntentEncoder } from './intent-encoder/index.js';
|
|
6
6
|
import { oLaneStatus } from './enum/o-lane.status-enum.js';
|
|
7
|
-
import {
|
|
8
|
-
import { oCapabilityConfig } from './capabilities/o-capability.config.js';
|
|
7
|
+
import { oCapabilityResult } from './capabilities/index.js';
|
|
9
8
|
import { oLaneStorageManager } from './storage/o-lane.storage-manager.js';
|
|
10
9
|
export declare class oLane extends oObject {
|
|
11
10
|
protected readonly config: oLaneConfig;
|
|
@@ -20,6 +19,9 @@ export declare class oLane extends oObject {
|
|
|
20
19
|
onChunk?: (chunk: any) => void;
|
|
21
20
|
private promptLoader;
|
|
22
21
|
storageManager: oLaneStorageManager;
|
|
22
|
+
private evaluateCapability;
|
|
23
|
+
private executeCapability;
|
|
24
|
+
private capabilitiesByType?;
|
|
23
25
|
constructor(config: oLaneConfig);
|
|
24
26
|
get intent(): oIntent;
|
|
25
27
|
toCIDInput(): any;
|
|
@@ -35,14 +37,9 @@ export declare class oLane extends oObject {
|
|
|
35
37
|
getExecutionTrace(): string;
|
|
36
38
|
preflight(): Promise<void>;
|
|
37
39
|
execute(): Promise<oCapabilityResult | undefined>;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* @returns Array of instantiated capabilities matching the specified types
|
|
42
|
-
*/
|
|
43
|
-
private filterCapabilitiesByType;
|
|
44
|
-
get capabilities(): oCapability[];
|
|
45
|
-
resultToConfig(result: any): oCapabilityConfig;
|
|
40
|
+
private ensureCapabilities;
|
|
41
|
+
private getCapability;
|
|
42
|
+
private buildConfig;
|
|
46
43
|
doCapability(currentStep: oCapabilityResult): Promise<oCapabilityResult>;
|
|
47
44
|
loop(): Promise<oCapabilityResult>;
|
|
48
45
|
emitNonFinalChunk(result: oCapabilityResult, payload: any): Promise<void>;
|
package/dist/src/o-lane.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-lane.d.ts","sourceRoot":"","sources":["../../src/o-lane.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"o-lane.d.ts","sourceRoot":"","sources":["../../src/o-lane.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAEL,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,qBAAa,KAAM,SAAQ,OAAO;IAgBpB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IAf3C,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IACnC,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC;IACrB,EAAE,EAAE,MAAM,CAAY;IACtB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAM;IACxB,MAAM,EAAE,WAAW,CAAuB;IAC1C,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,YAAY,CAAe;IAC5B,cAAc,EAAE,mBAAmB,CAAC;IAC3C,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,kBAAkB,CAAC,CAAoC;gBAEhC,MAAM,EAAE,WAAW;IAuBlD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,IAAI,GAAG;IAIjB,MAAM;IAIN,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAI/B,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAIrB,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAI3B,IAAI,YAAY,WAkBf;IAED;;;OAGG;IACH,iBAAiB,IAAI,MAAM;IA+DrB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAW1B,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IA4BvD,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,WAAW;IAcb,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAuBvB,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAuDlC,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG;IAezD,UAAU,CACd,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAqBzC,MAAM;IAaN;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAejE,IAAI,IAAI,sCAEP;CACF"}
|
package/dist/src/o-lane.js
CHANGED
|
@@ -3,7 +3,8 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
3
3
|
import { oIntentEncoder } from './intent-encoder/index.js';
|
|
4
4
|
import { oLaneStatus } from './enum/o-lane.status-enum.js';
|
|
5
5
|
import { oCapabilityResult, oCapabilityType, } from './capabilities/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { oCapabilityEvaluate } from './capabilities-evaluate/o-capability.evaluate.js';
|
|
7
|
+
import { oCapabilityExecute } from './capabilities-execute/execute.capability.js';
|
|
7
8
|
import { MarkdownBuilder } from './formatters/index.js';
|
|
8
9
|
import { oCapabilityConfig } from './capabilities/o-capability.config.js';
|
|
9
10
|
import { oLaneStorageManager } from './storage/o-lane.storage-manager.js';
|
|
@@ -26,6 +27,13 @@ export class oLane extends oObject {
|
|
|
26
27
|
}
|
|
27
28
|
this.MAX_CYCLES = this.config.maxCycles || this.MAX_CYCLES;
|
|
28
29
|
this.promptLoader = config.promptLoader;
|
|
30
|
+
// Support config.capabilities override (backward compat)
|
|
31
|
+
if (this.config.capabilities) {
|
|
32
|
+
this.capabilitiesByType = new Map();
|
|
33
|
+
for (const cap of this.config.capabilities) {
|
|
34
|
+
this.capabilitiesByType.set(cap.type, cap);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
get intent() {
|
|
31
39
|
return this.config.intent;
|
|
@@ -149,73 +157,54 @@ export class oLane extends oObject {
|
|
|
149
157
|
this.status = oLaneStatus.COMPLETED;
|
|
150
158
|
return this.result;
|
|
151
159
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
filterCapabilitiesByType(types) {
|
|
158
|
-
return ALL_CAPABILITIES.map((CapabilityClass) => {
|
|
159
|
-
const instance = new CapabilityClass({
|
|
160
|
-
promptLoader: this.promptLoader,
|
|
161
|
-
node: this.node,
|
|
162
|
-
});
|
|
163
|
-
return instance;
|
|
164
|
-
}).filter((capability) => types.includes(capability.type));
|
|
165
|
-
}
|
|
166
|
-
get capabilities() {
|
|
167
|
-
// Priority order:
|
|
168
|
-
// 1. If config.capabilities exists, use it (full backward compatibility)
|
|
169
|
-
// 2. If config.enabledCapabilityTypes exists, filter ALL_CAPABILITIES
|
|
170
|
-
// 3. Otherwise, use ALL_CAPABILITIES (default behavior)
|
|
171
|
-
if (this.config.capabilities) {
|
|
172
|
-
return this.config.capabilities;
|
|
160
|
+
ensureCapabilities() {
|
|
161
|
+
if (!this.evaluateCapability) {
|
|
162
|
+
const args = { promptLoader: this.promptLoader, node: this.node };
|
|
163
|
+
this.evaluateCapability = new oCapabilityEvaluate(args);
|
|
164
|
+
this.executeCapability = new oCapabilityExecute(args);
|
|
173
165
|
}
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
}
|
|
167
|
+
getCapability(type) {
|
|
168
|
+
// config.capabilities override takes priority (backward compat)
|
|
169
|
+
if (this.capabilitiesByType) {
|
|
170
|
+
const cap = this.capabilitiesByType.get(type);
|
|
171
|
+
if (cap)
|
|
172
|
+
return cap;
|
|
176
173
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
this.ensureCapabilities();
|
|
175
|
+
if (type === oCapabilityType.EVALUATE)
|
|
176
|
+
return this.evaluateCapability;
|
|
177
|
+
if (type === oCapabilityType.EXECUTE)
|
|
178
|
+
return this.executeCapability;
|
|
179
|
+
throw new oError(oErrorCodes.INVALID_CAPABILITY, 'Unknown capability: ' + type);
|
|
181
180
|
}
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
return {
|
|
185
|
-
...result.config,
|
|
186
|
-
history: this.agentHistory,
|
|
187
|
-
params: typeof obj === 'object' ? obj : {},
|
|
188
|
-
laneConfig: {
|
|
189
|
-
...this.config,
|
|
190
|
-
sequence: this.sequence, // pass the full sequence to the next capability
|
|
191
|
-
},
|
|
192
|
-
useStream: this.config.useStream || false,
|
|
181
|
+
buildConfig(step) {
|
|
182
|
+
const resultData = step.result || step.error;
|
|
183
|
+
return new oCapabilityConfig({
|
|
193
184
|
intent: this.intent,
|
|
194
185
|
node: this.node,
|
|
186
|
+
history: this.agentHistory,
|
|
195
187
|
chatHistory: this.config.chatHistory,
|
|
196
|
-
|
|
188
|
+
useStream: this.config.useStream || false,
|
|
189
|
+
params: typeof resultData === 'object' ? resultData : {},
|
|
190
|
+
laneConfig: { ...this.config, sequence: this.sequence },
|
|
191
|
+
isReplay: step.config?.isReplay,
|
|
192
|
+
});
|
|
197
193
|
}
|
|
198
194
|
async doCapability(currentStep) {
|
|
199
195
|
try {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.logger.debug('Executing capability: ', capabilityType);
|
|
205
|
-
const result = await capability.execute(oCapabilityConfig.fromJSON({
|
|
206
|
-
...capabilityConfig,
|
|
207
|
-
}));
|
|
208
|
-
return result;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
196
|
+
const config = this.buildConfig(currentStep);
|
|
197
|
+
const capability = this.getCapability(currentStep.type);
|
|
198
|
+
this.logger.debug('Executing capability: ', currentStep.type);
|
|
199
|
+
return await capability.execute(config);
|
|
211
200
|
}
|
|
212
201
|
catch (error) {
|
|
213
202
|
this.logger.error('Error in doCapability: ', error);
|
|
214
|
-
|
|
203
|
+
return new oCapabilityResult({
|
|
215
204
|
type: oCapabilityType.EVALUATE,
|
|
216
205
|
result: null,
|
|
217
206
|
error: error instanceof Error ? error.message : 'Unknown error',
|
|
218
|
-
config: oCapabilityConfig
|
|
207
|
+
config: new oCapabilityConfig({
|
|
219
208
|
laneConfig: this.config,
|
|
220
209
|
intent: this.intent,
|
|
221
210
|
node: this.node,
|
|
@@ -223,9 +212,7 @@ export class oLane extends oObject {
|
|
|
223
212
|
chatHistory: this.config.chatHistory,
|
|
224
213
|
}),
|
|
225
214
|
});
|
|
226
|
-
return errorResult;
|
|
227
215
|
}
|
|
228
|
-
throw new oError(oErrorCodes.INVALID_CAPABILITY, 'Unknown capability:' + currentStep.type);
|
|
229
216
|
}
|
|
230
217
|
async loop() {
|
|
231
218
|
if (!this.node) {
|
|
@@ -235,7 +222,7 @@ export class oLane extends oObject {
|
|
|
235
222
|
let currentStep = new oCapabilityResult({
|
|
236
223
|
type: oCapabilityType.EVALUATE,
|
|
237
224
|
result: null,
|
|
238
|
-
config: oCapabilityConfig
|
|
225
|
+
config: new oCapabilityConfig({
|
|
239
226
|
laneConfig: this.config,
|
|
240
227
|
intent: this.intent,
|
|
241
228
|
node: this.node,
|
|
@@ -307,9 +294,13 @@ export class oLane extends oObject {
|
|
|
307
294
|
cancel() {
|
|
308
295
|
this.logger.debug('Cancelling lane...');
|
|
309
296
|
this.status = oLaneStatus.CANCELLED;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
297
|
+
this.evaluateCapability?.cancel();
|
|
298
|
+
this.executeCapability?.cancel();
|
|
299
|
+
// Also cancel any custom capabilities
|
|
300
|
+
if (this.capabilitiesByType) {
|
|
301
|
+
for (const cap of this.capabilitiesByType.values()) {
|
|
302
|
+
cap.cancel();
|
|
303
|
+
}
|
|
313
304
|
}
|
|
314
305
|
}
|
|
315
306
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/custom.prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,kBAAkB,soFAsE9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"custom.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/custom.prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,kBAAkB,soFAsE9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,cAAc,MAAM,EACpB,mBAAmB,MAAM,EACzB,oBAAoB,MAAM,EAC1B,mBAAmB,MAAM,WAyE1B,CAAC"}
|
|
@@ -20,7 +20,7 @@ describe('EVALUATE → EXECUTE handoff: address resolution', () => {
|
|
|
20
20
|
*/
|
|
21
21
|
function simulateResultToConfig(aiResult) {
|
|
22
22
|
const obj = aiResult;
|
|
23
|
-
return oCapabilityConfig
|
|
23
|
+
return new oCapabilityConfig({
|
|
24
24
|
params: typeof obj === 'object' ? obj : {},
|
|
25
25
|
intent,
|
|
26
26
|
node: stubNode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-lane",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -34,38 +34,38 @@
|
|
|
34
34
|
"license": "(MIT OR Apache-2.0)",
|
|
35
35
|
"description": "oLane path tool to help capture agentic processes",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@eslint/eslintrc": "^3.3.
|
|
38
|
-
"@eslint/js": "^
|
|
39
|
-
"@olane/o-test": "0.8.
|
|
40
|
-
"@tsconfig/node20": "^20.1.
|
|
37
|
+
"@eslint/eslintrc": "^3.3.4",
|
|
38
|
+
"@eslint/js": "^10.0.1",
|
|
39
|
+
"@olane/o-test": "0.8.14",
|
|
40
|
+
"@tsconfig/node20": "^20.1.9",
|
|
41
41
|
"@types/handlebars": "^4.1.0",
|
|
42
42
|
"@types/jest": "^30.0.0",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
44
|
-
"@typescript-eslint/parser": "^8.
|
|
45
|
-
"aegir": "^47.0.
|
|
46
|
-
"chai": "^
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"eslint-config-prettier": "^10.1.
|
|
49
|
-
"eslint-plugin-prettier": "^5.5.
|
|
50
|
-
"globals": "^
|
|
51
|
-
"jest": "^30.
|
|
52
|
-
"prettier": "^3.
|
|
53
|
-
"ts-jest": "^29.4.
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
44
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
45
|
+
"aegir": "^47.0.26",
|
|
46
|
+
"chai": "^6.2.2",
|
|
47
|
+
"eslint": "^10.0.2",
|
|
48
|
+
"eslint-config-prettier": "^10.1.8",
|
|
49
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
50
|
+
"globals": "^17.3.0",
|
|
51
|
+
"jest": "^30.2.0",
|
|
52
|
+
"prettier": "^3.8.1",
|
|
53
|
+
"ts-jest": "^29.4.6",
|
|
54
54
|
"ts-node": "^10.9.2",
|
|
55
55
|
"tsconfig-paths": "^4.2.0",
|
|
56
|
-
"tsx": "^4.
|
|
57
|
-
"typescript": "5.
|
|
56
|
+
"tsx": "^4.21.0",
|
|
57
|
+
"typescript": "5.9.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@olane/o-config": "0.8.
|
|
61
|
-
"@olane/o-core": "0.8.
|
|
62
|
-
"@olane/o-node": "0.8.
|
|
63
|
-
"@olane/o-protocol": "0.8.
|
|
64
|
-
"@olane/o-storage": "0.8.
|
|
65
|
-
"@olane/o-tool": "0.8.
|
|
66
|
-
"debug": "^4.4.
|
|
67
|
-
"dotenv": "^
|
|
60
|
+
"@olane/o-config": "0.8.14",
|
|
61
|
+
"@olane/o-core": "0.8.14",
|
|
62
|
+
"@olane/o-node": "0.8.14",
|
|
63
|
+
"@olane/o-protocol": "0.8.14",
|
|
64
|
+
"@olane/o-storage": "0.8.14",
|
|
65
|
+
"@olane/o-tool": "0.8.14",
|
|
66
|
+
"debug": "^4.4.3",
|
|
67
|
+
"dotenv": "^17.3.1",
|
|
68
68
|
"handlebars": "^4.7.8"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "c7df897d10e7c8078255701043f1887e48ccdd84"
|
|
71
71
|
}
|