@olane/o-lane 0.7.18 → 0.7.19
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/enums/o-capability.type-enum.d.ts +1 -0
- package/dist/src/capabilities/enums/o-capability.type-enum.d.ts.map +1 -1
- package/dist/src/capabilities/enums/o-capability.type-enum.js +1 -0
- package/dist/src/capabilities/index.d.ts +2 -1
- package/dist/src/capabilities/index.d.ts.map +1 -1
- package/dist/src/capabilities/index.js +2 -1
- package/dist/src/capabilities/interfaces/{o-capability.config.d.ts → o-capability.config-interface.d.ts} +5 -4
- package/dist/src/capabilities/interfaces/o-capability.config-interface.d.ts.map +1 -0
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +1 -2
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.config.d.ts +24 -0
- package/dist/src/capabilities/o-capability.config.d.ts.map +1 -0
- package/dist/src/capabilities/o-capability.config.js +25 -0
- package/dist/src/capabilities/o-capability.d.ts +9 -5
- package/dist/src/capabilities/o-capability.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.js +4 -18
- package/dist/src/capabilities/o-capability.js +4 -5
- package/dist/src/capabilities/o-capability.result.d.ts +6 -12
- package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.result.js +2 -10
- package/dist/src/capabilities-all/o-capability.all.d.ts +2 -3
- package/dist/src/capabilities-all/o-capability.all.d.ts.map +1 -1
- package/dist/src/capabilities-all/o-capability.all.js +6 -8
- package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.d.ts +2 -2
- package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.d.ts.map +1 -1
- package/dist/src/capabilities-configure/o-capability.configure.d.ts +0 -15
- package/dist/src/capabilities-configure/o-capability.configure.d.ts.map +1 -1
- package/dist/src/capabilities-configure/o-capability.configure.js +61 -47
- package/dist/src/capabilities-evaluate/o-capability.evaluate.d.ts +1 -0
- package/dist/src/capabilities-evaluate/o-capability.evaluate.d.ts.map +1 -1
- package/dist/src/capabilities-evaluate/o-capability.evaluate.js +17 -2
- package/dist/src/capabilities-execute/execute.capability.d.ts +13 -0
- package/dist/src/capabilities-execute/execute.capability.d.ts.map +1 -0
- package/dist/src/capabilities-execute/execute.capability.js +111 -0
- package/dist/src/capabilities-execute/interfaces/o-capability.configure-config.d.ts +8 -0
- package/dist/src/capabilities-execute/interfaces/o-capability.configure-config.d.ts.map +1 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +1 -1
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -1
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -1
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +0 -1
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +1 -1
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.js +0 -4
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -2
- package/dist/src/interfaces/o-lane.config.d.ts +3 -0
- package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
- package/dist/src/o-lane.d.ts +6 -12
- package/dist/src/o-lane.d.ts.map +1 -1
- package/dist/src/o-lane.js +23 -180
- package/dist/src/o-lane.mixin.d.ts.map +1 -1
- package/dist/src/o-lane.mixin.js +9 -5
- package/dist/src/prompts/agent.prompt.d.ts +1 -12
- package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
- package/dist/src/prompts/agent.prompt.js +80 -138
- package/dist/src/prompts/configure.prompt.d.ts +1 -8
- package/dist/src/prompts/configure.prompt.d.ts.map +1 -1
- package/dist/src/prompts/configure.prompt.js +68 -47
- package/dist/src/prompts/execute.prompt.d.ts +9 -0
- package/dist/src/prompts/execute.prompt.d.ts.map +1 -0
- package/dist/src/prompts/execute.prompt.js +47 -0
- package/dist/src/prompts/index.d.ts +3 -0
- package/dist/src/prompts/index.d.ts.map +1 -0
- package/dist/src/prompts/index.js +2 -0
- package/dist/src/prompts/interfaces/o-prompt.config.d.ts +8 -0
- package/dist/src/prompts/interfaces/o-prompt.config.d.ts.map +1 -0
- package/dist/src/prompts/interfaces/o-prompt.config.js +1 -0
- package/dist/src/prompts/o-prompt.d.ts +36 -0
- package/dist/src/prompts/o-prompt.d.ts.map +1 -0
- package/dist/src/prompts/o-prompt.js +92 -0
- package/dist/src/storage/default.prompt-loader.d.ts +14 -0
- package/dist/src/storage/default.prompt-loader.d.ts.map +1 -0
- package/dist/src/storage/default.prompt-loader.js +34 -0
- package/dist/src/storage/index.d.ts +1 -3
- package/dist/src/storage/index.d.ts.map +1 -1
- package/dist/src/storage/index.js +1 -5
- package/dist/src/storage/o-lane.storage-manager.d.ts +71 -0
- package/dist/src/storage/o-lane.storage-manager.d.ts.map +1 -0
- package/dist/src/storage/o-lane.storage-manager.js +208 -0
- package/dist/src/storage/prompt-loader.d.ts +10 -28
- package/dist/src/storage/prompt-loader.d.ts.map +1 -1
- package/dist/src/storage/prompt-loader.js +9 -112
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +2 -0
- package/package.json +12 -10
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +0 -1
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +0 -16
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +0 -1
- package/dist/src/capabilities-task/o-capability.task-result.d.ts +0 -5
- package/dist/src/capabilities-task/o-capability.task-result.d.ts.map +0 -1
- package/dist/src/capabilities-task/o-capability.task-result.js +0 -3
- package/dist/src/capabilities-task/o-capability.task.d.ts +0 -20
- package/dist/src/capabilities-task/o-capability.task.d.ts.map +0 -1
- package/dist/src/capabilities-task/o-capability.task.js +0 -124
- package/dist/src/storage/prompt-schema.d.ts +0 -42
- package/dist/src/storage/prompt-schema.d.ts.map +0 -1
- package/dist/src/storage/prompt-schema.js +0 -29
- package/dist/src/storage/prompt-seeder.d.ts +0 -42
- package/dist/src/storage/prompt-seeder.d.ts.map +0 -1
- package/dist/src/storage/prompt-seeder.js +0 -141
- package/dist/src/storage/prompt-storage-provider.tool.d.ts +0 -99
- package/dist/src/storage/prompt-storage-provider.tool.d.ts.map +0 -1
- package/dist/src/storage/prompt-storage-provider.tool.js +0 -320
- package/dist/test/prompt-seeder.spec.d.ts +0 -2
- package/dist/test/prompt-seeder.spec.d.ts.map +0 -1
- package/dist/test/prompt-seeder.spec.js +0 -256
- package/dist/test/prompt-storage-provider.spec.d.ts +0 -2
- package/dist/test/prompt-storage-provider.spec.d.ts.map +0 -1
- package/dist/test/prompt-storage-provider.spec.js +0 -457
- /package/dist/src/capabilities/interfaces/{o-capability.config.js → o-capability.config-interface.js} +0 -0
- /package/dist/src/{capabilities-task/interfaces/o-capability.task-config.js → capabilities-execute/interfaces/o-capability.configure-config.js} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { oAddress, oError, oErrorCodes } from '@olane/o-core';
|
|
2
|
+
import { oCapabilityResult, oCapabilityType } from '../capabilities/index.js';
|
|
3
|
+
import { oCapabilityIntelligence } from '../capabilities/o-capability.intelligence.js';
|
|
4
|
+
import { oProtocolMethods } from '@olane/o-protocol';
|
|
5
|
+
export class oCapabilityExecute extends oCapabilityIntelligence {
|
|
6
|
+
get type() {
|
|
7
|
+
return oCapabilityType.EXECUTE;
|
|
8
|
+
}
|
|
9
|
+
static get type() {
|
|
10
|
+
return oCapabilityType.EXECUTE;
|
|
11
|
+
}
|
|
12
|
+
async loadPrompt({ tools, methods }) {
|
|
13
|
+
const prompt = await this.promptLoader?.loadPromptForType(this.type, {
|
|
14
|
+
human_about: '',
|
|
15
|
+
agent_about: '',
|
|
16
|
+
context_global: `
|
|
17
|
+
Tools are hosted in a graph address space.
|
|
18
|
+
You are in a secure environment and are allowed to operate with secure information (api keys, credit card info, etc).`,
|
|
19
|
+
chat_history: '',
|
|
20
|
+
past_cycles: '',
|
|
21
|
+
address: this.config.params.address,
|
|
22
|
+
methods: methods
|
|
23
|
+
});
|
|
24
|
+
return prompt.render();
|
|
25
|
+
}
|
|
26
|
+
async handshake() {
|
|
27
|
+
const response = await this.node.use(new oAddress(this.config.params.address), {
|
|
28
|
+
method: oProtocolMethods.HANDSHAKE,
|
|
29
|
+
params: {
|
|
30
|
+
intent: this.config.intent.value,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return response.result.data;
|
|
34
|
+
}
|
|
35
|
+
async run() {
|
|
36
|
+
// Check if we're in replay mode
|
|
37
|
+
if (this.config.isReplay) {
|
|
38
|
+
this.logger.debug('Execute capability is being replayed - re-executing to restore state');
|
|
39
|
+
}
|
|
40
|
+
const handshake = await this.handshake();
|
|
41
|
+
if (!handshake.result) {
|
|
42
|
+
throw new oError(oErrorCodes.INVALID_RESPONSE, 'Handshake failed');
|
|
43
|
+
}
|
|
44
|
+
// this.logger.debug('Handshake: ', handshake.result);
|
|
45
|
+
const { tools, methods } = handshake.result;
|
|
46
|
+
const prompt = await this.loadPrompt({ tools, methods });
|
|
47
|
+
const aiResponse = await this.intelligence(prompt);
|
|
48
|
+
// Extract task details from AI response
|
|
49
|
+
// The AI should return the method and params to execute
|
|
50
|
+
const task = aiResponse.result?.task || aiResponse.result;
|
|
51
|
+
if (!task || !task.method) {
|
|
52
|
+
this.logger.warn('AI did not return a valid task to execute', { aiResponse });
|
|
53
|
+
return aiResponse; // Return AI response as-is if no task to execute
|
|
54
|
+
}
|
|
55
|
+
const method = task.method;
|
|
56
|
+
const params = task.params || {};
|
|
57
|
+
this.logger.debug('AI decided to execute:', { method, params });
|
|
58
|
+
// Request approval before executing the task
|
|
59
|
+
try {
|
|
60
|
+
const approvalResponse = await this.node.use(new oAddress('o://approval'), {
|
|
61
|
+
method: 'request_approval',
|
|
62
|
+
params: {
|
|
63
|
+
toolAddress: this.config.params.address,
|
|
64
|
+
method: method,
|
|
65
|
+
params: params,
|
|
66
|
+
intent: this.config.intent,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const approved = approvalResponse.result.data?.approved;
|
|
70
|
+
if (!approved) {
|
|
71
|
+
const decision = approvalResponse.result.data?.decision || 'denied';
|
|
72
|
+
this.logger.warn(`Task execution denied by approval system: ${decision}`);
|
|
73
|
+
throw new oError(oErrorCodes.NOT_AUTHORIZED, `Action denied by approval system: ${decision}`);
|
|
74
|
+
}
|
|
75
|
+
this.logger.debug('Task approved, proceeding with execution');
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
// If approval service is not available, log warning and continue
|
|
79
|
+
// This ensures backward compatibility
|
|
80
|
+
if (error.message?.includes('No route found')) {
|
|
81
|
+
this.logger.warn('Approval service not available, proceeding without approval check');
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Execute the task
|
|
88
|
+
const taskResponse = await this.node.use(new oAddress(this.config.params.address), {
|
|
89
|
+
method: method,
|
|
90
|
+
params: params,
|
|
91
|
+
});
|
|
92
|
+
// Check if the tool response contains _save flag
|
|
93
|
+
const shouldPersist = taskResponse.result?.data?._save === true;
|
|
94
|
+
if (shouldPersist) {
|
|
95
|
+
this.logger.debug('Tool response contains _save flag - lane will be persisted to config');
|
|
96
|
+
}
|
|
97
|
+
// Return an EVALUATE result that contains the task execution output
|
|
98
|
+
return new oCapabilityResult({
|
|
99
|
+
type: oCapabilityType.EVALUATE,
|
|
100
|
+
config: this.config,
|
|
101
|
+
result: {
|
|
102
|
+
taskConfig: {
|
|
103
|
+
method: method,
|
|
104
|
+
params: params,
|
|
105
|
+
},
|
|
106
|
+
response: taskResponse.result,
|
|
107
|
+
},
|
|
108
|
+
shouldPersist,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { oCapabilityConfig } from '../../capabilities/o-capability.config.js';
|
|
2
|
+
export interface oCapabilityExecuteConfig extends oCapabilityConfig {
|
|
3
|
+
params: {
|
|
4
|
+
address: string;
|
|
5
|
+
intent: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=o-capability.configure-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"o-capability.configure-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-execute/interfaces/o-capability.configure-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IACjE,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH"}
|
package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { oCapabilityConfig } from '../../capabilities/
|
|
1
|
+
import { oCapabilityConfig } from '../../capabilities/o-capability.config.js';
|
|
2
2
|
import { oIntent } from '../../intent/o-intent.js';
|
|
3
3
|
import { oLaneConfig } from '../../interfaces/index.js';
|
|
4
4
|
export interface oCapabilityMultipleStepConfig extends oCapabilityConfig {
|
package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-capability.multiple-step-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"o-capability.multiple-step-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,WAAW,6BAA8B,SAAQ,iBAAiB;IACtE,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE;QACN,OAAO,EAAE,OAAO,EAAE,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-capability.multiple-step.d.ts","sourceRoot":"","sources":["../../../src/capabilities-multiple-step/o-capability.multiple-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AAElG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,qBAAa,uBAAwB,SAAQ,uBAAuB;IAC3D,MAAM,EAAG,6BAA6B,CAAC;IAC9C,OAAO,CAAC,QAAQ,CAAiC;IAEjD,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,IAAI,OAAO,IAAI,OAAO,EAAE,CAEvB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAEK,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"o-capability.multiple-step.d.ts","sourceRoot":"","sources":["../../../src/capabilities-multiple-step/o-capability.multiple-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AAElG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,qBAAa,uBAAwB,SAAQ,uBAAuB;IAC3D,MAAM,EAAG,6BAA6B,CAAC;IAC9C,OAAO,CAAC,QAAQ,CAAiC;IAEjD,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,IAAI,OAAO,IAAI,OAAO,EAAE,CAEvB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAEK,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAsBvC,MAAM;CAKP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-capability.search-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-search/interfaces/o-capability.search-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"o-capability.search-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-search/interfaces/o-capability.search-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAG9E,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,MAAM,EAAE;QACN,OAAO,EAAE;YACP,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;SACf,EAAE,CAAC;QACJ,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-capability.search.d.ts","sourceRoot":"","sources":["../../../src/capabilities-search/o-capability.search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,qBAAa,iBAAkB,SAAQ,WAAW;IACzC,MAAM,EAAG,uBAAuB,CAAC;IAExC,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,OAAO,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAEjD;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAEK,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA+BtD;;OAEG;YACW,cAAc;
|
|
1
|
+
{"version":3,"file":"o-capability.search.d.ts","sourceRoot":"","sources":["../../../src/capabilities-search/o-capability.search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,qBAAa,iBAAkB,SAAQ,WAAW;IACzC,MAAM,EAAG,uBAAuB,CAAC;IAExC,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,OAAO,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAEjD;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAEK,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA+BtD;;OAEG;YACW,cAAc;YAwBd,gBAAgB;IAmC9B;;OAEG;YACW,cAAc;IAsBtB,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAOxC"}
|
|
@@ -65,9 +65,7 @@ export class oCapabilitySearch extends oCapability {
|
|
|
65
65
|
searchResultContext += `[Search Results End]`;
|
|
66
66
|
return new oCapabilitySearchResult({
|
|
67
67
|
result: searchResultContext,
|
|
68
|
-
humanResult: searchResults,
|
|
69
68
|
type: oCapabilityType.EVALUATE,
|
|
70
|
-
config: this.config,
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
async doInternalSearch(query, limit) {
|
|
@@ -112,9 +110,7 @@ export class oCapabilitySearch extends oCapability {
|
|
|
112
110
|
searchResultContext += `[Search Results End]`;
|
|
113
111
|
return new oCapabilitySearchResult({
|
|
114
112
|
result: searchResultContext,
|
|
115
|
-
humanResult: searchResults,
|
|
116
113
|
type: oCapabilityType.EVALUATE,
|
|
117
|
-
config: this.config,
|
|
118
114
|
});
|
|
119
115
|
}
|
|
120
116
|
async run() {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,11 +7,10 @@ export * from './o-lane.tool.js';
|
|
|
7
7
|
export * from './capabilities/index.js';
|
|
8
8
|
export * from './intent/index.js';
|
|
9
9
|
export * from './capabilities-all/o-capability.all.js';
|
|
10
|
-
export * from './capabilities-configure/o-capability.configure.js';
|
|
11
10
|
export * from './capabilities-evaluate/o-capability.evaluate.js';
|
|
12
11
|
export * from './capabilities-multiple-step/o-capability.multiple-step.js';
|
|
13
12
|
export * from './capabilities-search/o-capability.search.js';
|
|
14
|
-
export * from './
|
|
13
|
+
export * from './prompts/index.js';
|
|
15
14
|
export * from './prompts/custom.prompt.js';
|
|
16
15
|
export * from './intent-encoder/index.js';
|
|
17
16
|
export * from './enum/o-lane.status-enum.js';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wCAAwC,CAAC;AACvD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wCAAwC,CAAC;AACvD,cAAc,kDAAkD,CAAC;AACjE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,8CAA8C,CAAC;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -7,11 +7,10 @@ export * from './o-lane.tool.js';
|
|
|
7
7
|
export * from './capabilities/index.js';
|
|
8
8
|
export * from './intent/index.js';
|
|
9
9
|
export * from './capabilities-all/o-capability.all.js';
|
|
10
|
-
export * from './capabilities-configure/o-capability.configure.js';
|
|
11
10
|
export * from './capabilities-evaluate/o-capability.evaluate.js';
|
|
12
11
|
export * from './capabilities-multiple-step/o-capability.multiple-step.js';
|
|
13
12
|
export * from './capabilities-search/o-capability.search.js';
|
|
14
|
-
export * from './
|
|
13
|
+
export * from './prompts/index.js';
|
|
15
14
|
export * from './prompts/custom.prompt.js';
|
|
16
15
|
export * from './intent-encoder/index.js';
|
|
17
16
|
export * from './enum/o-lane.status-enum.js';
|
|
@@ -3,10 +3,13 @@ import { oToolBase } from '@olane/o-tool';
|
|
|
3
3
|
import { oLaneContext } from '../o-lane.context.js';
|
|
4
4
|
import { oCapability } from '../capabilities/o-capability.js';
|
|
5
5
|
import { oIntent } from '../intent/o-intent.js';
|
|
6
|
+
import { PromptLoader } from '../storage/prompt-loader.js';
|
|
6
7
|
export interface oLaneConfig {
|
|
7
8
|
intent: oIntent;
|
|
8
9
|
caller: oAddress;
|
|
10
|
+
promptLoader: PromptLoader;
|
|
9
11
|
context?: oLaneContext;
|
|
12
|
+
chatHistory?: string;
|
|
10
13
|
sequence?: any[];
|
|
11
14
|
streamTo?: oAddress;
|
|
12
15
|
capabilities?: oCapability[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-lane.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-lane.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"o-lane.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-lane.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAGjB,YAAY,EAAE,YAAY,CAAC;IAG3B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAI7B,WAAW,EAAE,SAAS,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B"}
|
package/dist/src/o-lane.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ 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 {
|
|
7
|
+
import { oCapabilityResult } from './capabilities/index.js';
|
|
8
|
+
import { oCapabilityConfig } from './capabilities/o-capability.config.js';
|
|
9
|
+
import { oLaneStorageManager } from './storage/o-lane.storage-manager.js';
|
|
8
10
|
export declare class oLane extends oObject {
|
|
9
11
|
protected readonly config: oLaneConfig;
|
|
10
12
|
sequence: oCapabilityResult[];
|
|
@@ -16,14 +18,12 @@ export declare class oLane extends oObject {
|
|
|
16
18
|
status: oLaneStatus;
|
|
17
19
|
result: oCapabilityResult | undefined;
|
|
18
20
|
onChunk?: (chunk: any) => void;
|
|
21
|
+
private promptLoader;
|
|
22
|
+
storageManager: oLaneStorageManager;
|
|
19
23
|
constructor(config: oLaneConfig);
|
|
20
24
|
get intent(): oIntent;
|
|
21
25
|
toCIDInput(): any;
|
|
22
|
-
toJSON():
|
|
23
|
-
config: any;
|
|
24
|
-
sequence: oCapabilityResult[];
|
|
25
|
-
result: oCapabilityResult | undefined;
|
|
26
|
-
};
|
|
26
|
+
toJSON(): any;
|
|
27
27
|
addSequence(result: oCapabilityResult): void;
|
|
28
28
|
toCID(): Promise<CID>;
|
|
29
29
|
store(): Promise<CID>;
|
|
@@ -47,12 +47,6 @@ export declare class oLane extends oObject {
|
|
|
47
47
|
* This method loads a lane's execution sequence and replays it to restore network state
|
|
48
48
|
*/
|
|
49
49
|
replay(cid: string): Promise<oCapabilityResult | undefined>;
|
|
50
|
-
/**
|
|
51
|
-
* Determine if a capability should be re-executed during replay
|
|
52
|
-
* Task and Configure capabilities are re-executed as they modify network state
|
|
53
|
-
* Other capabilities use cached results
|
|
54
|
-
*/
|
|
55
|
-
private shouldReplayCapability;
|
|
56
50
|
get node(): import("@olane/o-tool").oToolBase;
|
|
57
51
|
}
|
|
58
52
|
//# sourceMappingURL=o-lane.d.ts.map
|
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,
|
|
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,EACL,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,qBAAa,KAAM,SAAQ,OAAO;IAapB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IAZ3C,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;gBAEZ,MAAM,EAAE,WAAW;IAelD,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,IAAI,YAAY,2DAEf;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAiBxC,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IA0BvB,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;IAyBzC,MAAM;IASN;;;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
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { oAddress, oError, oErrorCodes,
|
|
2
|
-
import { CID } from 'multiformats';
|
|
3
|
-
import * as json from 'multiformats/codecs/json';
|
|
4
|
-
import { sha256 } from 'multiformats/hashes/sha2';
|
|
1
|
+
import { oAddress, oError, oErrorCodes, oObject, oResponse, } from '@olane/o-core';
|
|
5
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
3
|
import { oIntentEncoder } from './intent-encoder/index.js';
|
|
7
4
|
import { oLaneStatus } from './enum/o-lane.status-enum.js';
|
|
8
5
|
import { oCapabilityResult, oCapabilityType, } from './capabilities/index.js';
|
|
9
6
|
import { ALL_CAPABILITIES } from './capabilities-all/o-capability.all.js';
|
|
10
7
|
import { MarkdownBuilder } from './formatters/index.js';
|
|
8
|
+
import { oCapabilityConfig } from './capabilities/o-capability.config.js';
|
|
9
|
+
import { oLaneStorageManager } from './storage/o-lane.storage-manager.js';
|
|
11
10
|
export class oLane extends oObject {
|
|
12
11
|
constructor(config) {
|
|
13
12
|
super('o-lane:' + `[${config.intent.value}]`);
|
|
@@ -20,74 +19,34 @@ export class oLane extends oObject {
|
|
|
20
19
|
this.parentLaneId = this.config.parentLaneId;
|
|
21
20
|
this.intentEncoder = new oIntentEncoder();
|
|
22
21
|
this.onChunk = this.config.onChunk;
|
|
22
|
+
this.storageManager = new oLaneStorageManager(this);
|
|
23
23
|
// set a max cycles if one is not provided
|
|
24
24
|
if (!!process.env.MAX_CYCLES) {
|
|
25
25
|
this.MAX_CYCLES = parseInt(process.env.MAX_CYCLES);
|
|
26
26
|
}
|
|
27
27
|
this.MAX_CYCLES = this.config.maxCycles || this.MAX_CYCLES;
|
|
28
|
+
this.promptLoader = config.promptLoader;
|
|
28
29
|
}
|
|
29
30
|
get intent() {
|
|
30
31
|
return this.config.intent;
|
|
31
32
|
}
|
|
32
33
|
toCIDInput() {
|
|
33
|
-
return
|
|
34
|
-
intent: this.config.intent.toString(),
|
|
35
|
-
address: this.config.caller?.toString(),
|
|
36
|
-
context: this.config.context?.toString() || '',
|
|
37
|
-
};
|
|
34
|
+
return this.storageManager.generateCIDInput();
|
|
38
35
|
}
|
|
39
36
|
toJSON() {
|
|
40
|
-
return
|
|
41
|
-
config: this.toCIDInput(),
|
|
42
|
-
sequence: this.sequence,
|
|
43
|
-
result: this.result,
|
|
44
|
-
};
|
|
37
|
+
return this.storageManager.serialize();
|
|
45
38
|
}
|
|
46
39
|
addSequence(result) {
|
|
47
40
|
this.sequence.push(result);
|
|
48
|
-
if (this.config.streamTo) {
|
|
49
|
-
this.node
|
|
50
|
-
.use(this.config.streamTo, {
|
|
51
|
-
method: 'receive_stream',
|
|
52
|
-
params: {
|
|
53
|
-
data: result.result || result.error || '',
|
|
54
|
-
},
|
|
55
|
-
})
|
|
56
|
-
.catch((error) => {
|
|
57
|
-
this.logger.error('Error sending agent stream: ', error);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
41
|
}
|
|
61
42
|
async toCID() {
|
|
62
|
-
|
|
63
|
-
return this.cid;
|
|
64
|
-
}
|
|
65
|
-
const bytes = json.encode(this.toCIDInput());
|
|
66
|
-
const hash = await sha256.digest(bytes);
|
|
67
|
-
const cid = CID.create(1, json.code, hash);
|
|
68
|
-
return cid;
|
|
43
|
+
return this.storageManager.generateCID();
|
|
69
44
|
}
|
|
70
45
|
async store() {
|
|
71
|
-
this.
|
|
72
|
-
const cid = await this.toCID();
|
|
73
|
-
if (this.node.state !== NodeState.RUNNING) {
|
|
74
|
-
throw new oError(oErrorCodes.INVALID_STATE, 'Node is not in a valid state to store a lane');
|
|
75
|
-
}
|
|
76
|
-
const params = {
|
|
77
|
-
key: cid.toString(),
|
|
78
|
-
value: JSON.stringify(this.toJSON()),
|
|
79
|
-
};
|
|
80
|
-
this.logger.debug('Storing plan params: ', params);
|
|
81
|
-
await this.node.use(oAddress.lane(), {
|
|
82
|
-
method: 'put',
|
|
83
|
-
params: params,
|
|
84
|
-
});
|
|
85
|
-
return cid;
|
|
46
|
+
return this.storageManager.save();
|
|
86
47
|
}
|
|
87
48
|
get agentHistory() {
|
|
88
49
|
const added = {};
|
|
89
|
-
const MAX_RESULT_LENGTH = 1000; // Truncate large results
|
|
90
|
-
const KEEP_FULL_DETAIL_COUNT = 3; // Keep full detail for last N cycles
|
|
91
50
|
const filteredSequence = this.sequence?.filter((s) => {
|
|
92
51
|
if (added[s.id]) {
|
|
93
52
|
return false;
|
|
@@ -97,43 +56,7 @@ export class oLane extends oObject {
|
|
|
97
56
|
});
|
|
98
57
|
return (filteredSequence
|
|
99
58
|
?.map((s, index) => {
|
|
100
|
-
|
|
101
|
-
const result = s.result || s.error;
|
|
102
|
-
const params = s.config?.params || {};
|
|
103
|
-
// Extract summary and reasoning if available
|
|
104
|
-
const summary = params.summary || '';
|
|
105
|
-
const reasoning = params.reasoning || '';
|
|
106
|
-
// Format result, truncating if not a recent cycle
|
|
107
|
-
let formattedResult;
|
|
108
|
-
if (typeof result === 'string') {
|
|
109
|
-
formattedResult =
|
|
110
|
-
isRecent || result.length <= MAX_RESULT_LENGTH
|
|
111
|
-
? result
|
|
112
|
-
: result.substring(0, MAX_RESULT_LENGTH) + '... (truncated)';
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
const jsonStr = JSON.stringify(result, null, 2);
|
|
116
|
-
formattedResult =
|
|
117
|
-
isRecent || jsonStr.length <= MAX_RESULT_LENGTH
|
|
118
|
-
? jsonStr
|
|
119
|
-
: jsonStr.substring(0, MAX_RESULT_LENGTH) + '... (truncated)';
|
|
120
|
-
}
|
|
121
|
-
// Build formatted history entry
|
|
122
|
-
let entry = `[Cycle ${index + 1}: ${s.type}]\n`;
|
|
123
|
-
entry += `Intent: ${s.config?.intent.toString()}\n`;
|
|
124
|
-
if (summary) {
|
|
125
|
-
entry += `Summary: ${summary}\n`;
|
|
126
|
-
}
|
|
127
|
-
if (reasoning) {
|
|
128
|
-
entry += `Reasoning: ${reasoning}\n`;
|
|
129
|
-
}
|
|
130
|
-
if (s.error) {
|
|
131
|
-
entry += `Error: ${s.error}\n`;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
entry += `Result: ${formattedResult}\n`;
|
|
135
|
-
}
|
|
136
|
-
return entry;
|
|
59
|
+
return `\n<cycle_${index}>\n${JSON.stringify(s)}\n</cycle_${index}>`;
|
|
137
60
|
})
|
|
138
61
|
.join('\n') || '');
|
|
139
62
|
}
|
|
@@ -227,7 +150,7 @@ export class oLane extends oObject {
|
|
|
227
150
|
return this.result;
|
|
228
151
|
}
|
|
229
152
|
get capabilities() {
|
|
230
|
-
return this.config.capabilities || ALL_CAPABILITIES.map((c) => new c());
|
|
153
|
+
return this.config.capabilities || ALL_CAPABILITIES.map((c) => new c({ promptLoader: this.promptLoader, node: this.node }));
|
|
231
154
|
}
|
|
232
155
|
resultToConfig(result) {
|
|
233
156
|
const obj = result.result || result.error;
|
|
@@ -240,6 +163,9 @@ export class oLane extends oObject {
|
|
|
240
163
|
sequence: this.sequence, // pass the full sequence to the next capability
|
|
241
164
|
},
|
|
242
165
|
useStream: this.config.useStream || false,
|
|
166
|
+
intent: this.intent,
|
|
167
|
+
node: this.node,
|
|
168
|
+
chatHistory: this.config.chatHistory,
|
|
243
169
|
};
|
|
244
170
|
}
|
|
245
171
|
async doCapability(currentStep) {
|
|
@@ -249,9 +175,9 @@ export class oLane extends oObject {
|
|
|
249
175
|
if (capability.type === capabilityType && currentStep.config) {
|
|
250
176
|
const capabilityConfig = this.resultToConfig(currentStep);
|
|
251
177
|
this.logger.debug('Executing capability: ', capabilityType);
|
|
252
|
-
const result = await capability.execute({
|
|
178
|
+
const result = await capability.execute(oCapabilityConfig.fromJSON({
|
|
253
179
|
...capabilityConfig,
|
|
254
|
-
});
|
|
180
|
+
}));
|
|
255
181
|
return result;
|
|
256
182
|
}
|
|
257
183
|
}
|
|
@@ -275,12 +201,13 @@ export class oLane extends oObject {
|
|
|
275
201
|
let currentStep = new oCapabilityResult({
|
|
276
202
|
type: oCapabilityType.EVALUATE,
|
|
277
203
|
result: null,
|
|
278
|
-
config: {
|
|
204
|
+
config: oCapabilityConfig.fromJSON({
|
|
279
205
|
laneConfig: this.config,
|
|
280
206
|
intent: this.intent,
|
|
281
207
|
node: this.node,
|
|
282
208
|
history: this.agentHistory,
|
|
283
|
-
|
|
209
|
+
chatHistory: this.config.chatHistory,
|
|
210
|
+
}),
|
|
284
211
|
});
|
|
285
212
|
while (iterations++ < this.MAX_CYCLES &&
|
|
286
213
|
this.status === oLaneStatus.RUNNING) {
|
|
@@ -330,32 +257,8 @@ export class oLane extends oObject {
|
|
|
330
257
|
this.logger.debug('Saving plan with CID: ', this.cid.toString(), response);
|
|
331
258
|
// If this lane is marked for persistence to config, store it directly in os-config storage
|
|
332
259
|
if (this.config.persistToConfig && this.cid) {
|
|
333
|
-
this.logger.debug('Lane marked for persistence (auto-triggered by tool response or explicitly set), saving to config...');
|
|
334
260
|
try {
|
|
335
|
-
|
|
336
|
-
const systemName = this.node.config.systemName || 'default-os';
|
|
337
|
-
await this.node.use(new oAddress('o://os-config'), {
|
|
338
|
-
method: 'add_lane_to_config',
|
|
339
|
-
params: {
|
|
340
|
-
osName: systemName,
|
|
341
|
-
cid: this.cid.toString(),
|
|
342
|
-
},
|
|
343
|
-
});
|
|
344
|
-
const data = response?.result;
|
|
345
|
-
if (data.addresses_to_index) {
|
|
346
|
-
for (const address of data.addresses_to_index) {
|
|
347
|
-
this.logger.debug('Indexing address: ', address.toString());
|
|
348
|
-
await this.node
|
|
349
|
-
.use(new oAddress(address), {
|
|
350
|
-
method: 'index_network',
|
|
351
|
-
params: {},
|
|
352
|
-
})
|
|
353
|
-
.catch((error) => {
|
|
354
|
-
this.logger.error('Error indexing address: ', error);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
this.logger.debug('Lane CID added to startup config via o://os-config');
|
|
261
|
+
await this.storageManager.persistToConfig(this.cid, response);
|
|
359
262
|
}
|
|
360
263
|
catch (error) {
|
|
361
264
|
this.logger.error('Failed to add lane to startup config: ', error);
|
|
@@ -380,59 +283,12 @@ export class oLane extends oObject {
|
|
|
380
283
|
* This method loads a lane's execution sequence and replays it to restore network state
|
|
381
284
|
*/
|
|
382
285
|
async replay(cid) {
|
|
383
|
-
this.logger.debug('Replaying lane from CID: ', cid);
|
|
384
286
|
this.status = oLaneStatus.RUNNING;
|
|
385
287
|
try {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
method: 'get',
|
|
389
|
-
params: { key: cid },
|
|
390
|
-
});
|
|
391
|
-
if (!laneData || !laneData.result) {
|
|
392
|
-
throw new Error(`Lane not found in storage for CID: ${cid}`);
|
|
393
|
-
}
|
|
394
|
-
const data = laneData.result.data;
|
|
395
|
-
const storedLane = JSON.parse(data.value);
|
|
396
|
-
// Replay the sequence
|
|
397
|
-
if (!storedLane.sequence || !Array.isArray(storedLane.sequence)) {
|
|
398
|
-
throw new Error('Invalid lane data: missing or invalid sequence');
|
|
399
|
-
}
|
|
400
|
-
// Iterate through the stored sequence and replay capabilities
|
|
401
|
-
for (const sequenceItem of storedLane.sequence) {
|
|
402
|
-
const capabilityType = sequenceItem.type;
|
|
403
|
-
// Determine if this capability should be replayed
|
|
404
|
-
if (this.shouldReplayCapability(capabilityType)) {
|
|
405
|
-
this.logger.debug(`Replaying capability: ${capabilityType}`);
|
|
406
|
-
// Create a capability result with replay flag
|
|
407
|
-
const replayStep = new oCapabilityResult({
|
|
408
|
-
type: capabilityType,
|
|
409
|
-
config: {
|
|
410
|
-
...sequenceItem.config,
|
|
411
|
-
isReplay: true,
|
|
412
|
-
node: this.node,
|
|
413
|
-
history: this.agentHistory,
|
|
414
|
-
},
|
|
415
|
-
result: sequenceItem.result,
|
|
416
|
-
error: sequenceItem.error,
|
|
417
|
-
});
|
|
418
|
-
// Execute the capability in replay mode
|
|
419
|
-
const result = await this.doCapability(replayStep);
|
|
420
|
-
this.addSequence(result);
|
|
421
|
-
// If the capability is STOP, end replay
|
|
422
|
-
if (result.type === oCapabilityType.STOP) {
|
|
423
|
-
this.result = result;
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
this.logger.debug(`Skipping capability (using cached result): ${capabilityType}`);
|
|
429
|
-
// Add the cached result to sequence without re-executing
|
|
430
|
-
this.addSequence(sequenceItem);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
288
|
+
const result = await this.storageManager.replay(cid);
|
|
289
|
+
this.result = result;
|
|
433
290
|
this.status = oLaneStatus.COMPLETED;
|
|
434
|
-
|
|
435
|
-
return this.result;
|
|
291
|
+
return result;
|
|
436
292
|
}
|
|
437
293
|
catch (error) {
|
|
438
294
|
this.logger.error('Error during lane replay: ', error);
|
|
@@ -440,19 +296,6 @@ export class oLane extends oObject {
|
|
|
440
296
|
throw error;
|
|
441
297
|
}
|
|
442
298
|
}
|
|
443
|
-
/**
|
|
444
|
-
* Determine if a capability should be re-executed during replay
|
|
445
|
-
* Task and Configure capabilities are re-executed as they modify network state
|
|
446
|
-
* Other capabilities use cached results
|
|
447
|
-
*/
|
|
448
|
-
shouldReplayCapability(capabilityType) {
|
|
449
|
-
const replayTypes = [
|
|
450
|
-
oCapabilityType.TASK,
|
|
451
|
-
oCapabilityType.CONFIGURE,
|
|
452
|
-
oCapabilityType.MULTIPLE_STEP,
|
|
453
|
-
];
|
|
454
|
-
return replayTypes.includes(capabilityType);
|
|
455
|
-
}
|
|
456
299
|
get node() {
|
|
457
300
|
return this.config.currentNode;
|
|
458
301
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-lane.mixin.d.ts","sourceRoot":"","sources":["../../src/o-lane.mixin.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"o-lane.mixin.d.ts","sourceRoot":"","sources":["../../src/o-lane.mixin.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAU1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAClE,IAAI,EAAE,CAAC,GACN,CAAC,CAqJH"}
|