@olane/o-lane 0.7.6 → 0.7.7

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.
@@ -7,5 +7,6 @@ export interface oCapabilityConfig {
7
7
  laneConfig: oLaneConfig;
8
8
  history: string;
9
9
  params?: any;
10
+ isReplay?: boolean;
10
11
  }
11
12
  //# sourceMappingURL=o-capability.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/interfaces/o-capability.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd"}
1
+ {"version":3,"file":"o-capability.config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/interfaces/o-capability.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -5,5 +5,6 @@ export interface oCapabilityResultInterface {
5
5
  type: oCapabilityType;
6
6
  error?: string;
7
7
  config?: oCapabilityConfig;
8
+ shouldPersist?: boolean;
8
9
  }
9
10
  //# sourceMappingURL=o-capability.result-interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.result-interface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/interfaces/o-capability.result-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B"}
1
+ {"version":3,"file":"o-capability.result-interface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/interfaces/o-capability.result-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -10,12 +10,14 @@ export declare class oCapabilityResult implements oCapabilityResultInterface {
10
10
  type: oCapabilityType;
11
11
  error?: string;
12
12
  config?: oCapabilityConfig;
13
+ shouldPersist?: boolean;
13
14
  constructor(config: oCapabilityResultInterface);
14
15
  toJSON(): {
15
16
  id: string;
16
17
  result: any;
17
18
  type: oCapabilityType;
18
19
  error: string | undefined;
20
+ shouldPersist: boolean | undefined;
19
21
  config: {
20
22
  intent: import("../index.js").oIntent | undefined;
21
23
  params: any;
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.result.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,+EAA+E,CAAC;AAC9H,OAAO,EAAE,uBAAuB,EAAE,MAAM,iEAAiE,CAAC;AAC1G,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAG3F,qBAAa,iBAAkB,YAAW,0BAA0B;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EACH,uBAAuB,GACvB,6BAA6B,GAC7B,qBAAqB,GACrB,GAAG,CAAC;IACR,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC;gBAEf,MAAM,EAAE,0BAA0B;IAQ9C,MAAM;;;;;;;;;;;IAcN,QAAQ;CAGT"}
1
+ {"version":3,"file":"o-capability.result.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,+EAA+E,CAAC;AAC9H,OAAO,EAAE,uBAAuB,EAAE,MAAM,iEAAiE,CAAC;AAC1G,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAG3F,qBAAa,iBAAkB,YAAW,0BAA0B;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EACH,uBAAuB,GACvB,6BAA6B,GAC7B,qBAAqB,GACrB,GAAG,CAAC;IACR,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;gBAEZ,MAAM,EAAE,0BAA0B;IAS9C,MAAM;;;;;;;;;;;;IAeN,QAAQ;CAGT"}
@@ -7,6 +7,7 @@ export class oCapabilityResult {
7
7
  this.type = config.type || oCapabilityType.UNKNOWN;
8
8
  this.error = config.error || '';
9
9
  this.config = config.config;
10
+ this.shouldPersist = config.shouldPersist;
10
11
  }
11
12
  toJSON() {
12
13
  return {
@@ -14,6 +15,7 @@ export class oCapabilityResult {
14
15
  result: this.result,
15
16
  type: this.type,
16
17
  error: this.error,
18
+ shouldPersist: this.shouldPersist,
17
19
  config: {
18
20
  intent: this.config?.intent,
19
21
  params: this.config?.params,
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.configure.d.ts","sourceRoot":"","sources":["../../../src/capabilities-configure/o-capability.configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,OAAO,EAAE,OAAO,EAA+B,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,qBAAa,oBAAqB,SAAQ,uBAAuB;IACxD,MAAM,EAAG,0BAA0B,CAAC;IAE3C,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,MAAM;IAetE,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAatC,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAYxC"}
1
+ {"version":3,"file":"o-capability.configure.d.ts","sourceRoot":"","sources":["../../../src/capabilities-configure/o-capability.configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,OAAO,EAAE,OAAO,EAA+B,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,qBAAa,oBAAqB,SAAQ,uBAAuB;IACxD,MAAM,EAAG,0BAA0B,CAAC;IAE3C,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,MAAM;IAetE,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAatC,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAmBxC"}
@@ -17,7 +17,7 @@ export class oCapabilityConfigure extends oCapabilityIntelligence {
17
17
  `[Method Metadata Begin]\n${JSON.stringify(methods, null, 2)}\n[Method Metadata End]`,
18
18
  `[Method Options Begin]\n${(tools || []).join(', ')}\n[Method Options End]`,
19
19
  ]);
20
- const configureIntent = `Configure the tool use, prioritize "Use Tool Instructions". You have already found the tool to resolve the user's intent: ${this.config.params.toolAddress}. Configure the request to use the tool with user intent: ${this.config.params.intent}`;
20
+ const configureIntent = `Configure the tool use, prioritize "Use Tool Instructions". You have already found the tool to resolve the user's intent: ${this.config.params.toolAddress}. DO NOT USE parameter values that are not explicitly mentioned in the agent history, provided context or intent. Configure the request to use the tool with user intent: ${this.config.params.intent}`;
21
21
  return AGENT_PROMPT(configureIntent, context.toString(), this.config.history || '', CONFIGURE_INSTRUCTIONS);
22
22
  }
23
23
  async handshake() {
@@ -30,11 +30,15 @@ export class oCapabilityConfigure extends oCapabilityIntelligence {
30
30
  return response.result.data;
31
31
  }
32
32
  async run() {
33
+ // Check if we're in replay mode
34
+ if (this.config.isReplay) {
35
+ this.logger.debug('Configure capability is being replayed - re-executing to restore state');
36
+ }
33
37
  const handshake = await this.handshake();
34
38
  if (!handshake.result) {
35
39
  throw new oError(oErrorCodes.INVALID_RESPONSE, 'Handshake failed');
36
40
  }
37
- this.logger.debug('Handshake: ', handshake.result);
41
+ // this.logger.debug('Handshake: ', handshake.result);
38
42
  const { tools, methods } = handshake.result;
39
43
  const prompt = this.generatePrompt(tools, methods);
40
44
  const response = await this.intelligence(prompt);
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.task.d.ts","sourceRoot":"","sources":["../../../src/capabilities-task/o-capability.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,qBAAa,eAAgB,SAAQ,WAAW;IACvC,MAAM,EAAG,qBAAqB,CAAC;IAEtC,IAAI,IAAI;;;;;;;;MAEP;IAED,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAWK,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC;CA+D5C"}
1
+ {"version":3,"file":"o-capability.task.d.ts","sourceRoot":"","sources":["../../../src/capabilities-task/o-capability.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,qBAAa,eAAgB,SAAQ,WAAW;IACvC,MAAM,EAAG,qBAAqB,CAAC;IAEtC,IAAI,IAAI;;;;;;;;MAEP;IAED,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,MAAM,KAAK,IAAI,oBAEd;IAWK,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAyH5C"}
@@ -24,6 +24,10 @@ export class oCapabilityTask extends oCapability {
24
24
  try {
25
25
  // do MCP handshake to get the method + parameters + dependencies
26
26
  this.logger.debug('Running task: ', this.config);
27
+ // Check if we're in replay mode
28
+ if (this.config.isReplay) {
29
+ this.logger.debug('Task is being replayed - re-executing to restore state');
30
+ }
27
31
  const { task } = this.config.params;
28
32
  this.logger.debug('Task to do: ', task);
29
33
  if (!task || !task.address) {
@@ -52,14 +56,49 @@ export class oCapabilityTask extends oCapability {
52
56
  // }
53
57
  // return value;
54
58
  // });
59
+ // Request approval before executing the task
60
+ try {
61
+ const approvalResponse = await this.node.use(new oAddress('o://approval'), {
62
+ method: 'request_approval',
63
+ params: {
64
+ toolAddress: task.address,
65
+ method: task.payload?.method,
66
+ params: params,
67
+ intent: this.config.intent,
68
+ },
69
+ });
70
+ const approved = approvalResponse.result.data?.approved;
71
+ if (!approved) {
72
+ const decision = approvalResponse.result.data?.decision || 'denied';
73
+ this.logger.warn(`Task execution denied by approval system: ${decision}`);
74
+ throw new oError(oErrorCodes.NOT_AUTHORIZED, `Action denied by approval system: ${decision}`);
75
+ }
76
+ this.logger.debug('Task approved, proceeding with execution');
77
+ }
78
+ catch (error) {
79
+ // If approval service is not available, log warning and continue
80
+ // This ensures backward compatibility
81
+ if (error.message?.includes('No route found')) {
82
+ this.logger.warn('Approval service not available, proceeding without approval check');
83
+ }
84
+ else {
85
+ throw error;
86
+ }
87
+ }
55
88
  const response = await this.node.use(new oAddress(task.address), {
56
89
  method: task.payload?.method,
57
90
  params: params,
58
91
  });
92
+ // Check if the tool response contains _save flag
93
+ const shouldPersist = response.result?.data?._save === true;
94
+ if (shouldPersist) {
95
+ this.logger.debug('Tool response contains _save flag - lane will be persisted to config');
96
+ }
59
97
  return new oCapabilityTaskResult({
60
98
  result: `Tool Address Use output: ${JSON.stringify(response.result, null, 2)}`,
61
99
  type: oCapabilityType.EVALUATE,
62
100
  config: this.config,
101
+ shouldPersist,
63
102
  });
64
103
  }
65
104
  catch (error) {
@@ -14,5 +14,6 @@ export interface oLaneConfig {
14
14
  extraInstructions?: string;
15
15
  parentLaneId?: string;
16
16
  maxCycles?: number;
17
+ persistToConfig?: boolean;
17
18
  }
18
19
  //# sourceMappingURL=o-lane.config.d.ts.map
@@ -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,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAEjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAG7B,WAAW,EAAE,SAAS,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
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,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAEjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAG7B,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;CAC3B"}
@@ -25,7 +25,7 @@ export declare class oLane extends oObject {
25
25
  };
26
26
  addSequence(result: oCapabilityResult): void;
27
27
  toCID(): Promise<CID>;
28
- store(): Promise<void>;
28
+ store(): Promise<CID>;
29
29
  get agentHistory(): string;
30
30
  preflight(): Promise<void>;
31
31
  execute(): Promise<oCapabilityResult | undefined>;
@@ -35,6 +35,17 @@ export declare class oLane extends oObject {
35
35
  loop(): Promise<oCapabilityResult>;
36
36
  postflight(response?: oCapabilityResult): Promise<oCapabilityResult | undefined>;
37
37
  cancel(): void;
38
+ /**
39
+ * Replay a stored lane from storage by CID
40
+ * This method loads a lane's execution sequence and replays it to restore network state
41
+ */
42
+ replay(cid: string): Promise<oCapabilityResult | undefined>;
43
+ /**
44
+ * Determine if a capability should be re-executed during replay
45
+ * Task and Configure capabilities are re-executed as they modify network state
46
+ * Other capabilities use cached results
47
+ */
48
+ private shouldReplayCapability;
38
49
  get node(): import("./o-lane.tool.js").oLaneTool;
39
50
  }
40
51
  //# sourceMappingURL=o-lane.d.ts.map
@@ -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;AAInC,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,EACjB,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAGjC,qBAAa,KAAM,SAAQ,OAAO;IAUpB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IAT3C,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;gBAEd,MAAM,EAAE,WAAW;IAalD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,IAAI,GAAG;IAQjB,MAAM;;;;;IAQN,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAgB/B,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAUrB,KAAK;IAeX,IAAI,YAAY,WA8Bf;IACK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAevD,IAAI,YAAY,2DAEf;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAaxC,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAevB,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAqClC,UAAU,CACd,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAYzC,MAAM;IAKN,IAAI,IAAI,yCAEP;CACF"}
1
+ {"version":3,"file":"o-lane.d.ts","sourceRoot":"","sources":["../../src/o-lane.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,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,EACjB,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAGjC,qBAAa,KAAM,SAAQ,OAAO;IAUpB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IAT3C,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;gBAEd,MAAM,EAAE,WAAW;IAalD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,IAAI,GAAG;IAQjB,MAAM;;;;;IAQN,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAgB/B,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAUrB,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAuB3B,IAAI,YAAY,WA8Bf;IACK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAevD,IAAI,YAAY,2DAEf;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAaxC,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAevB,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA8ClC,UAAU,CACd,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAiDzC,MAAM;IAKN;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAwEjE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAS9B,IAAI,IAAI,yCAEP;CACF"}
@@ -1,4 +1,4 @@
1
- import { oError, oErrorCodes, oObject, } from '@olane/o-core';
1
+ import { oAddress, oError, oErrorCodes, NodeState, oObject, } from '@olane/o-core';
2
2
  import { CID } from 'multiformats';
3
3
  import * as json from 'multiformats/codecs/json';
4
4
  import { sha256 } from 'multiformats/hashes/sha2';
@@ -29,7 +29,7 @@ export class oLane extends oObject {
29
29
  }
30
30
  toCIDInput() {
31
31
  return {
32
- intent: this.config.intent,
32
+ intent: this.config.intent.toString(),
33
33
  address: this.config.caller?.toString(),
34
34
  context: this.config.context?.toString() || '',
35
35
  };
@@ -68,15 +68,19 @@ export class oLane extends oObject {
68
68
  async store() {
69
69
  this.logger.debug('Storing plan...');
70
70
  const cid = await this.toCID();
71
+ if (this.node.state !== NodeState.RUNNING) {
72
+ throw new oError(oErrorCodes.INVALID_STATE, 'Node is not in a valid state to store a lane');
73
+ }
71
74
  const params = {
72
75
  key: cid.toString(),
73
76
  value: JSON.stringify(this.toJSON()),
74
77
  };
75
78
  this.logger.debug('Storing plan params: ', params);
76
- // await this.node.use(oAddress.lane(), {
77
- // method: 'put',
78
- // params: params,
79
- // });
79
+ await this.node.use(oAddress.lane(), {
80
+ method: 'put',
81
+ params: params,
82
+ });
83
+ return cid;
80
84
  }
81
85
  get agentHistory() {
82
86
  const added = {};
@@ -91,7 +95,7 @@ export class oLane extends oObject {
91
95
  ?.map((s, index) => {
92
96
  const result = s.result || s.error;
93
97
  return `[Cycle ${index + 1} Begin ${s.id}]\n
94
- Cycle Intent: ${s.config?.intent}\n
98
+ Cycle Intent: ${s.config?.intent.toString()}\n
95
99
  Cycle Result:\n
96
100
  ${typeof result === 'string'
97
101
  ? result
@@ -172,6 +176,11 @@ export class oLane extends oObject {
172
176
  // perform the latest capability
173
177
  const result = await this.doCapability(currentStep);
174
178
  this.addSequence(result);
179
+ // Check if the capability result indicates persistence is needed
180
+ if (result.shouldPersist && !this.config.persistToConfig) {
181
+ this.logger.debug('Capability result flagged for persistence - automatically setting persistToConfig');
182
+ this.config.persistToConfig = true;
183
+ }
175
184
  if (result.type === oCapabilityType.STOP) {
176
185
  return result;
177
186
  }
@@ -184,8 +193,36 @@ export class oLane extends oObject {
184
193
  this.logger.debug('Postflight...');
185
194
  this.status = oLaneStatus.POSTFLIGHT;
186
195
  try {
187
- await this.store();
188
- this.logger.debug('Saving plan...', response);
196
+ this.cid = await this.store();
197
+ this.logger.debug('Saving plan with CID: ', this.cid.toString(), response);
198
+ // If this lane is marked for persistence to config, store it directly in os-config storage
199
+ if (this.config.persistToConfig && this.cid) {
200
+ this.logger.debug('Lane marked for persistence (auto-triggered by tool response or explicitly set), saving to config...');
201
+ try {
202
+ // Get the OS instance name from the node's system name
203
+ const systemName = this.node.config.systemName || 'default-os';
204
+ await this.node.use(new oAddress('o://os-config'), {
205
+ method: 'add_lane_to_config',
206
+ params: {
207
+ osName: systemName,
208
+ cid: this.cid.toString(),
209
+ },
210
+ });
211
+ const data = response?.result;
212
+ if (data.addresses_to_index) {
213
+ for (const address of data.addresses_to_index) {
214
+ await this.node.use(new oAddress(address), {
215
+ method: 'index_network',
216
+ params: {},
217
+ });
218
+ }
219
+ }
220
+ this.logger.debug('Lane CID added to startup config via o://os-config');
221
+ }
222
+ catch (error) {
223
+ this.logger.error('Failed to add lane to startup config: ', error);
224
+ }
225
+ }
189
226
  }
190
227
  catch (error) {
191
228
  this.logger.error('Error in postflight: ', error);
@@ -196,6 +233,84 @@ export class oLane extends oObject {
196
233
  this.logger.debug('Cancelling lane...');
197
234
  this.status = oLaneStatus.CANCELLED;
198
235
  }
236
+ /**
237
+ * Replay a stored lane from storage by CID
238
+ * This method loads a lane's execution sequence and replays it to restore network state
239
+ */
240
+ async replay(cid) {
241
+ this.logger.debug('Replaying lane from CID: ', cid);
242
+ this.status = oLaneStatus.RUNNING;
243
+ try {
244
+ // Load the lane data from storage
245
+ const laneData = await this.node.use(oAddress.lane(), {
246
+ method: 'get',
247
+ params: { key: cid },
248
+ });
249
+ if (!laneData || !laneData.result) {
250
+ throw new Error(`Lane not found in storage for CID: ${cid}`);
251
+ }
252
+ const data = laneData.result.data;
253
+ const storedLane = JSON.parse(data.value);
254
+ // Replay the sequence
255
+ if (!storedLane.sequence || !Array.isArray(storedLane.sequence)) {
256
+ throw new Error('Invalid lane data: missing or invalid sequence');
257
+ }
258
+ // Iterate through the stored sequence and replay capabilities
259
+ for (const sequenceItem of storedLane.sequence) {
260
+ const capabilityType = sequenceItem.type;
261
+ // Determine if this capability should be replayed
262
+ if (this.shouldReplayCapability(capabilityType)) {
263
+ this.logger.debug(`Replaying capability: ${capabilityType}`);
264
+ // Create a capability result with replay flag
265
+ const replayStep = new oCapabilityResult({
266
+ type: capabilityType,
267
+ config: {
268
+ ...sequenceItem.config,
269
+ isReplay: true,
270
+ node: this.node,
271
+ history: this.agentHistory,
272
+ },
273
+ result: sequenceItem.result,
274
+ error: sequenceItem.error,
275
+ });
276
+ // Execute the capability in replay mode
277
+ const result = await this.doCapability(replayStep);
278
+ this.addSequence(result);
279
+ // If the capability is STOP, end replay
280
+ if (result.type === oCapabilityType.STOP) {
281
+ this.result = result;
282
+ break;
283
+ }
284
+ }
285
+ else {
286
+ this.logger.debug(`Skipping capability (using cached result): ${capabilityType}`);
287
+ // Add the cached result to sequence without re-executing
288
+ this.addSequence(sequenceItem);
289
+ }
290
+ }
291
+ this.status = oLaneStatus.COMPLETED;
292
+ this.logger.debug('Lane replay completed successfully');
293
+ return this.result;
294
+ }
295
+ catch (error) {
296
+ this.logger.error('Error during lane replay: ', error);
297
+ this.status = oLaneStatus.FAILED;
298
+ throw error;
299
+ }
300
+ }
301
+ /**
302
+ * Determine if a capability should be re-executed during replay
303
+ * Task and Configure capabilities are re-executed as they modify network state
304
+ * Other capabilities use cached results
305
+ */
306
+ shouldReplayCapability(capabilityType) {
307
+ const replayTypes = [
308
+ oCapabilityType.TASK,
309
+ oCapabilityType.CONFIGURE,
310
+ oCapabilityType.MULTIPLE_STEP,
311
+ ];
312
+ return replayTypes.includes(capabilityType);
313
+ }
199
314
  get node() {
200
315
  return this.config.currentNode;
201
316
  }
@@ -11,6 +11,13 @@ export declare class oLaneTool extends oNodeTool {
11
11
  * @returns
12
12
  */
13
13
  _tool_intent(request: oRequest): Promise<any>;
14
+ /**
15
+ * Replay a stored lane from storage by CID
16
+ * This restores network state from a previously executed lane
17
+ * @param request - Request containing the CID of the lane to replay
18
+ * @returns The result of the replayed lane
19
+ */
20
+ _tool_replay(request: oRequest): Promise<any>;
14
21
  teardown(): Promise<void>;
15
22
  }
16
23
  //# sourceMappingURL=o-lane.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-lane.tool.d.ts","sourceRoot":"","sources":["../../src/o-lane.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD,qBAAa,SAAU,SAAQ,SAAS;IACtC,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,EAAE,WAAW;IAKzB,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBrE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA2B7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
1
+ {"version":3,"file":"o-lane.tool.d.ts","sourceRoot":"","sources":["../../src/o-lane.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD,qBAAa,SAAU,SAAQ,SAAS;IACtC,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,EAAE,WAAW;IAKzB,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBrE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA4BnD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA8B7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
@@ -52,11 +52,45 @@ export class oLaneTool extends oNodeTool {
52
52
  result: response?.result,
53
53
  error: response?.error,
54
54
  cycles: pc.sequence.length,
55
+ cid: pc.cid?.toString(),
55
56
  sequence: pc.sequence.map((s) => {
56
57
  return s.result;
57
58
  }),
58
59
  };
59
60
  }
61
+ /**
62
+ * Replay a stored lane from storage by CID
63
+ * This restores network state from a previously executed lane
64
+ * @param request - Request containing the CID of the lane to replay
65
+ * @returns The result of the replayed lane
66
+ */
67
+ async _tool_replay(request) {
68
+ this.logger.debug('Lane replay called: ', request.params);
69
+ const { cid } = request.params;
70
+ if (!cid || typeof cid !== 'string') {
71
+ throw new Error('CID parameter is required and must be a string');
72
+ }
73
+ // Create a lane instance for replay
74
+ const lane = await this.manager.createLane({
75
+ intent: new oIntent({ intent: 'replay' }),
76
+ currentNode: this,
77
+ caller: this.address,
78
+ });
79
+ try {
80
+ const response = await lane.replay(cid);
81
+ this.logger.debug('Lane replay response: ', response);
82
+ return {
83
+ result: response?.result,
84
+ error: response?.error,
85
+ cycles: lane.sequence.length,
86
+ cid: cid,
87
+ };
88
+ }
89
+ catch (error) {
90
+ this.logger.error('Lane replay failed: ', error);
91
+ throw error;
92
+ }
93
+ }
60
94
  async teardown() {
61
95
  await this.manager.teardown();
62
96
  await super.teardown();
@@ -1 +1 @@
1
- {"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,WACf,MAAM,WACL,MAAM,gBACD,MAAM,qBACD,MAAM,WA6HxB,CAAC"}
1
+ {"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,WACf,MAAM,WACL,MAAM,gBACD,MAAM,qBACD,MAAM,WA+HxB,CAAC"}
@@ -32,7 +32,8 @@ Step 4 - Configure the target tool address use
32
32
  1. Identify the tool address that most likely will help you complete the user intent.
33
33
  2. Review the provided context for past cycles that contain configuration instructions for the target tool address.
34
34
  3. If there is no configuration instructions for the target tool address, return the "Configure Response" using the [RETURN INSTRUCTIONS]
35
- 4. If the tool use configuration is already known, continue to step 5
35
+ 4. Identify if there are any missing parameter values for the target tool address and search for them if so.
36
+ 5. If the tool use configuration is already known including all parameter values, continue to step 5
36
37
 
37
38
  Step 5 - Use target tool address
38
39
  1. If the target tool address configuration is known, return the "Use Tool Response" using the [RETURN INSTRUCTIONS]
@@ -95,6 +96,7 @@ Stop Response:
95
96
  {
96
97
  "result": string,
97
98
  "reasoning": string,
99
+ "addresses_to_index": [string], // COMMENT: If the results of a tool use include "address_to_index", list them in the "addresses_to_index" array.
98
100
  "type": "stop",
99
101
  }
100
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-lane",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -56,10 +56,10 @@
56
56
  "typescript": "5.4.5"
57
57
  },
58
58
  "peerDependencies": {
59
- "@olane/o-config": "^0.7.5",
60
- "@olane/o-core": "^0.7.5",
61
- "@olane/o-protocol": "^0.7.5",
62
- "@olane/o-tool": "^0.7.5"
59
+ "@olane/o-config": "^0.7.6",
60
+ "@olane/o-core": "^0.7.6",
61
+ "@olane/o-protocol": "^0.7.6",
62
+ "@olane/o-tool": "^0.7.6"
63
63
  },
64
64
  "dependencies": {
65
65
  "debug": "^4.4.1",