@olane/o-lane 0.7.18 → 0.7.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/src/capabilities/enums/o-capability.type-enum.d.ts +1 -0
  2. package/dist/src/capabilities/enums/o-capability.type-enum.d.ts.map +1 -1
  3. package/dist/src/capabilities/enums/o-capability.type-enum.js +1 -0
  4. package/dist/src/capabilities/index.d.ts +2 -1
  5. package/dist/src/capabilities/index.d.ts.map +1 -1
  6. package/dist/src/capabilities/index.js +2 -1
  7. package/dist/src/capabilities/interfaces/{o-capability.config.d.ts → o-capability.config-interface.d.ts} +5 -4
  8. package/dist/src/capabilities/interfaces/o-capability.config-interface.d.ts.map +1 -0
  9. package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +1 -2
  10. package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -1
  11. package/dist/src/capabilities/o-capability.config.d.ts +24 -0
  12. package/dist/src/capabilities/o-capability.config.d.ts.map +1 -0
  13. package/dist/src/capabilities/o-capability.config.js +25 -0
  14. package/dist/src/capabilities/o-capability.d.ts +9 -5
  15. package/dist/src/capabilities/o-capability.d.ts.map +1 -1
  16. package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -1
  17. package/dist/src/capabilities/o-capability.intelligence.js +4 -18
  18. package/dist/src/capabilities/o-capability.js +4 -5
  19. package/dist/src/capabilities/o-capability.result.d.ts +6 -12
  20. package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
  21. package/dist/src/capabilities/o-capability.result.js +2 -10
  22. package/dist/src/capabilities-all/o-capability.all.d.ts +2 -3
  23. package/dist/src/capabilities-all/o-capability.all.d.ts.map +1 -1
  24. package/dist/src/capabilities-all/o-capability.all.js +6 -8
  25. package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.d.ts +2 -2
  26. package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.d.ts.map +1 -1
  27. package/dist/src/capabilities-configure/o-capability.configure.d.ts +0 -15
  28. package/dist/src/capabilities-configure/o-capability.configure.d.ts.map +1 -1
  29. package/dist/src/capabilities-configure/o-capability.configure.js +61 -47
  30. package/dist/src/capabilities-evaluate/o-capability.evaluate.d.ts +1 -0
  31. package/dist/src/capabilities-evaluate/o-capability.evaluate.d.ts.map +1 -1
  32. package/dist/src/capabilities-evaluate/o-capability.evaluate.js +17 -2
  33. package/dist/src/capabilities-execute/execute.capability.d.ts +13 -0
  34. package/dist/src/capabilities-execute/execute.capability.d.ts.map +1 -0
  35. package/dist/src/capabilities-execute/execute.capability.js +111 -0
  36. package/dist/src/capabilities-execute/interfaces/o-capability.configure-config.d.ts +8 -0
  37. package/dist/src/capabilities-execute/interfaces/o-capability.configure-config.d.ts.map +1 -0
  38. package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +1 -1
  39. package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -1
  40. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -1
  41. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +0 -1
  42. package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +1 -1
  43. package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -1
  44. package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
  45. package/dist/src/capabilities-search/o-capability.search.js +0 -4
  46. package/dist/src/index.d.ts +1 -2
  47. package/dist/src/index.d.ts.map +1 -1
  48. package/dist/src/index.js +1 -2
  49. package/dist/src/interfaces/o-lane.config.d.ts +5 -0
  50. package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
  51. package/dist/src/o-lane.d.ts +13 -13
  52. package/dist/src/o-lane.d.ts.map +1 -1
  53. package/dist/src/o-lane.js +52 -180
  54. package/dist/src/o-lane.mixin.d.ts.map +1 -1
  55. package/dist/src/o-lane.mixin.js +9 -5
  56. package/dist/src/prompts/agent.prompt.d.ts +1 -12
  57. package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
  58. package/dist/src/prompts/agent.prompt.js +80 -138
  59. package/dist/src/prompts/configure.prompt.d.ts +1 -8
  60. package/dist/src/prompts/configure.prompt.d.ts.map +1 -1
  61. package/dist/src/prompts/configure.prompt.js +68 -47
  62. package/dist/src/prompts/execute.prompt.d.ts +9 -0
  63. package/dist/src/prompts/execute.prompt.d.ts.map +1 -0
  64. package/dist/src/prompts/execute.prompt.js +47 -0
  65. package/dist/src/prompts/index.d.ts +3 -0
  66. package/dist/src/prompts/index.d.ts.map +1 -0
  67. package/dist/src/prompts/index.js +2 -0
  68. package/dist/src/prompts/interfaces/o-prompt.config.d.ts +8 -0
  69. package/dist/src/prompts/interfaces/o-prompt.config.d.ts.map +1 -0
  70. package/dist/src/prompts/interfaces/o-prompt.config.js +1 -0
  71. package/dist/src/prompts/o-prompt.d.ts +36 -0
  72. package/dist/src/prompts/o-prompt.d.ts.map +1 -0
  73. package/dist/src/prompts/o-prompt.js +92 -0
  74. package/dist/src/storage/default.prompt-loader.d.ts +14 -0
  75. package/dist/src/storage/default.prompt-loader.d.ts.map +1 -0
  76. package/dist/src/storage/default.prompt-loader.js +34 -0
  77. package/dist/src/storage/index.d.ts +1 -3
  78. package/dist/src/storage/index.d.ts.map +1 -1
  79. package/dist/src/storage/index.js +1 -5
  80. package/dist/src/storage/o-lane.storage-manager.d.ts +71 -0
  81. package/dist/src/storage/o-lane.storage-manager.d.ts.map +1 -0
  82. package/dist/src/storage/o-lane.storage-manager.js +208 -0
  83. package/dist/src/storage/prompt-loader.d.ts +10 -28
  84. package/dist/src/storage/prompt-loader.d.ts.map +1 -1
  85. package/dist/src/storage/prompt-loader.js +9 -112
  86. package/dist/test/index.d.ts +1 -0
  87. package/dist/test/index.d.ts.map +1 -0
  88. package/dist/test/index.js +2 -0
  89. package/package.json +12 -10
  90. package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +0 -1
  91. package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +0 -16
  92. package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +0 -1
  93. package/dist/src/capabilities-task/o-capability.task-result.d.ts +0 -5
  94. package/dist/src/capabilities-task/o-capability.task-result.d.ts.map +0 -1
  95. package/dist/src/capabilities-task/o-capability.task-result.js +0 -3
  96. package/dist/src/capabilities-task/o-capability.task.d.ts +0 -20
  97. package/dist/src/capabilities-task/o-capability.task.d.ts.map +0 -1
  98. package/dist/src/capabilities-task/o-capability.task.js +0 -124
  99. package/dist/src/storage/prompt-schema.d.ts +0 -42
  100. package/dist/src/storage/prompt-schema.d.ts.map +0 -1
  101. package/dist/src/storage/prompt-schema.js +0 -29
  102. package/dist/src/storage/prompt-seeder.d.ts +0 -42
  103. package/dist/src/storage/prompt-seeder.d.ts.map +0 -1
  104. package/dist/src/storage/prompt-seeder.js +0 -141
  105. package/dist/src/storage/prompt-storage-provider.tool.d.ts +0 -99
  106. package/dist/src/storage/prompt-storage-provider.tool.d.ts.map +0 -1
  107. package/dist/src/storage/prompt-storage-provider.tool.js +0 -320
  108. package/dist/test/prompt-seeder.spec.d.ts +0 -2
  109. package/dist/test/prompt-seeder.spec.d.ts.map +0 -1
  110. package/dist/test/prompt-seeder.spec.js +0 -256
  111. package/dist/test/prompt-storage-provider.spec.d.ts +0 -2
  112. package/dist/test/prompt-storage-provider.spec.d.ts.map +0 -1
  113. package/dist/test/prompt-storage-provider.spec.js +0 -457
  114. /package/dist/src/capabilities/interfaces/{o-capability.config.js → o-capability.config-interface.js} +0 -0
  115. /package/dist/src/{capabilities-task/interfaces/o-capability.task-config.js → capabilities-execute/interfaces/o-capability.configure-config.js} +0 -0
@@ -1,13 +1,12 @@
1
- import { oAddress, oError, oErrorCodes, NodeState, oObject, oResponse, } from '@olane/o-core';
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
- if (this.cid) {
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.logger.debug('Storing plan...');
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
- const isRecent = index >= filteredSequence.length - KEEP_FULL_DETAIL_COUNT;
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
  }
@@ -226,8 +149,37 @@ export class oLane extends oObject {
226
149
  this.status = oLaneStatus.COMPLETED;
227
150
  return this.result;
228
151
  }
152
+ /**
153
+ * Filter capabilities by type from ALL_CAPABILITIES
154
+ * @param types Array of capability types to include
155
+ * @returns Array of instantiated capabilities matching the specified types
156
+ */
157
+ filterCapabilitiesByType(types) {
158
+ return ALL_CAPABILITIES
159
+ .map((CapabilityClass) => {
160
+ const instance = new CapabilityClass({
161
+ promptLoader: this.promptLoader,
162
+ node: this.node
163
+ });
164
+ return instance;
165
+ })
166
+ .filter((capability) => types.includes(capability.type));
167
+ }
229
168
  get capabilities() {
230
- return this.config.capabilities || ALL_CAPABILITIES.map((c) => new c());
169
+ // Priority order:
170
+ // 1. If config.capabilities exists, use it (full backward compatibility)
171
+ // 2. If config.enabledCapabilityTypes exists, filter ALL_CAPABILITIES
172
+ // 3. Otherwise, use ALL_CAPABILITIES (default behavior)
173
+ if (this.config.capabilities) {
174
+ return this.config.capabilities;
175
+ }
176
+ if (this.config.enabledCapabilityTypes) {
177
+ return this.filterCapabilitiesByType(this.config.enabledCapabilityTypes);
178
+ }
179
+ return ALL_CAPABILITIES.map((c) => new c({
180
+ promptLoader: this.promptLoader,
181
+ node: this.node
182
+ }));
231
183
  }
232
184
  resultToConfig(result) {
233
185
  const obj = result.result || result.error;
@@ -240,6 +192,9 @@ export class oLane extends oObject {
240
192
  sequence: this.sequence, // pass the full sequence to the next capability
241
193
  },
242
194
  useStream: this.config.useStream || false,
195
+ intent: this.intent,
196
+ node: this.node,
197
+ chatHistory: this.config.chatHistory,
243
198
  };
244
199
  }
245
200
  async doCapability(currentStep) {
@@ -249,9 +204,9 @@ export class oLane extends oObject {
249
204
  if (capability.type === capabilityType && currentStep.config) {
250
205
  const capabilityConfig = this.resultToConfig(currentStep);
251
206
  this.logger.debug('Executing capability: ', capabilityType);
252
- const result = await capability.execute({
207
+ const result = await capability.execute(oCapabilityConfig.fromJSON({
253
208
  ...capabilityConfig,
254
- });
209
+ }));
255
210
  return result;
256
211
  }
257
212
  }
@@ -275,12 +230,13 @@ export class oLane extends oObject {
275
230
  let currentStep = new oCapabilityResult({
276
231
  type: oCapabilityType.EVALUATE,
277
232
  result: null,
278
- config: {
233
+ config: oCapabilityConfig.fromJSON({
279
234
  laneConfig: this.config,
280
235
  intent: this.intent,
281
236
  node: this.node,
282
237
  history: this.agentHistory,
283
- },
238
+ chatHistory: this.config.chatHistory,
239
+ }),
284
240
  });
285
241
  while (iterations++ < this.MAX_CYCLES &&
286
242
  this.status === oLaneStatus.RUNNING) {
@@ -330,32 +286,8 @@ export class oLane extends oObject {
330
286
  this.logger.debug('Saving plan with CID: ', this.cid.toString(), response);
331
287
  // If this lane is marked for persistence to config, store it directly in os-config storage
332
288
  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
289
  try {
335
- // Get the OS instance name from the node's system name
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');
290
+ await this.storageManager.persistToConfig(this.cid, response);
359
291
  }
360
292
  catch (error) {
361
293
  this.logger.error('Failed to add lane to startup config: ', error);
@@ -380,59 +312,12 @@ export class oLane extends oObject {
380
312
  * This method loads a lane's execution sequence and replays it to restore network state
381
313
  */
382
314
  async replay(cid) {
383
- this.logger.debug('Replaying lane from CID: ', cid);
384
315
  this.status = oLaneStatus.RUNNING;
385
316
  try {
386
- // Load the lane data from storage
387
- const laneData = await this.node.use(oAddress.lane(), {
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
- }
317
+ const result = await this.storageManager.replay(cid);
318
+ this.result = result;
433
319
  this.status = oLaneStatus.COMPLETED;
434
- this.logger.debug('Lane replay completed successfully');
435
- return this.result;
320
+ return result;
436
321
  }
437
322
  catch (error) {
438
323
  this.logger.error('Error during lane replay: ', error);
@@ -440,19 +325,6 @@ export class oLane extends oObject {
440
325
  throw error;
441
326
  }
442
327
  }
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
328
  get node() {
457
329
  return this.config.currentNode;
458
330
  }
@@ -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;AAQ1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAClE,IAAI,EAAE,CAAC,GACN,CAAC,CAiJH"}
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"}
@@ -4,6 +4,7 @@ import { oIntent } from './intent/index.js';
4
4
  import { oLaneContext } from './o-lane.context.js';
5
5
  import { oLaneManager } from './manager/o-lane.manager.js';
6
6
  import { oCapabilityResult } from './capabilities/o-capability.result.js';
7
+ import { PromptLoaderDefault } from './storage/default.prompt-loader.js';
7
8
  /**
8
9
  * withLane mixin - adds lane execution capabilities to any tool base class
9
10
  * This mixin pattern allows lane functionality to be composed with different
@@ -41,6 +42,9 @@ export function withLane(Base) {
41
42
  type: oCapabilityType.HANDSHAKE,
42
43
  });
43
44
  }
45
+ getPromptLoader() {
46
+ return new PromptLoaderDefault();
47
+ }
44
48
  /**
45
49
  * Where all intents go to be resolved.
46
50
  * @param request
@@ -48,14 +52,16 @@ export function withLane(Base) {
48
52
  */
49
53
  async _tool_intent(request) {
50
54
  this.logger.debug('Intent resolution called: ', request.params);
51
- const { intent, context, streamTo, _isStreaming = false } = request.params;
55
+ const { intent, context, chatHistory, streamTo, _isStreaming = false } = request.params;
52
56
  const pc = await this.manager.createLane({
53
57
  intent: new oIntent({ intent: intent }),
54
58
  currentNode: this,
55
59
  caller: this.address,
56
60
  streamTo: streamTo ? new oAddress(streamTo) : undefined,
57
61
  useStream: _isStreaming,
62
+ chatHistory: chatHistory,
58
63
  requestId: request.id, // Pass request ID for proper response correlation
64
+ promptLoader: this.getPromptLoader(),
59
65
  onChunk: _isStreaming
60
66
  ? async (chunk) => {
61
67
  if (chunk?._last ||
@@ -68,9 +74,7 @@ export function withLane(Base) {
68
74
  }
69
75
  : undefined,
70
76
  context: context
71
- ? new oLaneContext([
72
- `[Chat History Context Begin]\n${context}\n[Chat History Context End]`,
73
- ])
77
+ ? new oLaneContext([])
74
78
  : undefined,
75
79
  });
76
80
  // TODO: brendon experiment review
@@ -82,7 +86,6 @@ export function withLane(Base) {
82
86
  response = await pc.execute();
83
87
  const completeResponse = {
84
88
  result: response?.result,
85
- humanResult: response?.humanResult, // Full human-readable formatted result (AI-generated markdown)
86
89
  summary: response?.config?.params?.summary, // Short 1-2 sentence summary
87
90
  error: response?.error,
88
91
  cycles: pc.sequence.length,
@@ -112,6 +115,7 @@ export function withLane(Base) {
112
115
  intent: new oIntent({ intent: 'replay' }),
113
116
  currentNode: this,
114
117
  caller: this.address,
118
+ promptLoader: this.getPromptLoader(),
115
119
  });
116
120
  try {
117
121
  const response = await lane.replay(cid);
@@ -1,13 +1,2 @@
1
- /**
2
- * Cycle instructions for seeding - extracted from agent workflow
3
- */
4
- export declare const CYCLE_INSTRUCTIONS_SEED = "\n Every Step Instructions:\n1. Review the provided user intent, context and agent history\n2. If you can complete the user intent, return the \"Stop Response\" using the [RETURN INSTRUCTIONS] steps\n3. If the intent is already completed in past cycles, return the \"Stop Response\" using the [RETURN INSTRUCTIONS] steps\n4. If you experience 3 similar errors in a row, return the \"Stop Response\" indicating an error and follow the [RETURN INSTRUCTIONS] steps\n5. Review the current step number and perform the instructions associated with that step\n6. Start with step 1\n\nStep 1 - Evaluate the intent\n1. A complex step means there are multiple actions required to complete the user's intent\n2. If the intent is not-complex, continue to step 2\n3. If the intent is complex, break it up into a list of simple concise intents. Return the \"Complex Intent Response\" using the [RETURN INSTRUCTIONS]\n\nStep 2 - Search for tools and context\n1. If all entities and tool addresses are known within the user intent, continue to step 4\n2. If you know the tool address to use to complete the user intent, continue to step 4\n3. If there are unknown tool addresses or entities within the user intent, generate search queries to resolve the unknown entities. \n4. Use the o://mcp search tool to find model context protocol servers (MCP servers) that can help you add tooling that could help you complete the user intent.\n5. If there is a placeholder address used (o://.../placeholder), do not extract the contents of the placeholder address unless necessary for completing the user intent.\n6. Use the search results data & tooling to help you resolve the unknown entities.\n7. Continue to step 3.\n\nStep 3 - Filter Search Results\n1. If all search results are relevant to the user intent resolution, continue to step 4.\n2. Filter the search results for information that may contain supporting data or tooling that can help complete the user intent.\n3. If you do not see anything that can help you. Return the \"Stop Response\" using the [RETURN INSTRUCTIONS]\n4. Continue to step 4\n\nStep 4 - Configure the target tool address use\n1. Identify the tool address that most likely will help you complete the user intent.\n2. Review the provided context for past cycles that contain configuration instructions for the target tool address.\n3. If there is no configuration instructions for the target tool address, return the \"Configure Response\" using the [RETURN INSTRUCTIONS]\n4. Identify if there are any missing parameter values for the target tool address and search for them if so.\n5. If the tool use configuration is already known including all parameter values, continue to step 5\n\nStep 5 - Use target tool address\n1. If the target tool address configuration is known, return the \"Use Tool Response\" using the [RETURN INSTRUCTIONS]\n2. If the target tool address with the same configuration has failed in the past cycles, return the \"Error Response\" using the [RETURN INSTRUCTIONS] steps to indicate the error.\n3. Using this filtered tool list, return the \"Use Tool Response\" using the [RETURN INSTRUCTIONS] steps to return a series of addresses and respective intents to align with the current user intent resolution goal\n4. Continue to step 6\n\nStep 6 - Review the tool use results\n1. Analyze each tool use result\n2. When formatting tool results for the user in a Stop Response, present as clean markdown:\n - For general contexts, present as clean markdown:\n * Use headings to organize different sections\n * Use lists for multiple items\n * Use bold for important values or labels\n * Use code blocks for addresses (e.g., `o://tool-address`)\n * Transform raw JSON into readable prose and structured lists\n3. In the summary field, provide a 1-2 sentence overview\n4. If it failed, clearly explain why in a user-friendly way\n\n\n ";
5
- /**
6
- * Output instructions for seeding - extracted from return format specifications
7
- */
8
- export declare const OUTPUT_INSTRUCTIONS_SEED = "\n[RETURN INSTRUCTIONS BEGIN]\nThese are the types of cycle responses: \"Complex Intent Response\", \"Search Response\", \"Use Tool Response\", \"Stop Response\", \"Error Response\", \"Configure Response\".\n\nAll Return Step Instructions:\n1. Do not explain your reasoning process, just return the output in the correct format.\n2. Determine what type of results we have\n3. Output the respective results using the matching output type.\n4. Generate a reasoning key value pair for why this result was returned.\n5. The reasoning should be no longer than 1 sentence.\n6. The summary should be a short message used to inform the user of the result of the cycle. These updates should be insightful and concise and within 1-2 sentences.\n6. Do not include ```json or ``` in your output.\n\nComplex Intent Results:\n{\n \"intents\": [\n \"simple intent 1\",\n \"simple intent 2\",\n \"simple intent 3\",\n ],\n \"summary\": string,\n \"reasoning\": string,\n \"type\": \"multiple_step\",\n}\n\nConfigure Response:\n{\n \"intent\": string,\n \"toolAddress\": string,\n \"reasoning\": string,\n \"summary\": string,\n \"type\": \"configure\",\n}\n\nSearch Response:\n{\n \"queries\": [\n {\n \"query\": \"vector database query key terms to search for\",\n \"limit\": number,\n }\n ],\n \"isExternal\": boolean,\n \"reasoning\": string,\n \"summary\": string,\n \"type\": \"search\",\n}\n\nStop Response:\n{\n \"result\": string, // IMPORTANT: Format this as clean, readable markdown. Use headers (##, ###), lists (-, 1.), bold (**text**), and code blocks (`code`) to make the response easy to read. Structure tool outputs, search results, and data clearly. Focus on what the user needs to know, not raw data dumps.\n \"reasoning\": string,\n \"addresses_to_index\": [string], // COMMENT: If the results of a tool use include \"address_to_index\", list them in the \"addresses_to_index\" array.\n \"summary\": string, // A concise 1-2 sentence summary for the user\n \"type\": \"stop\",\n}\n\nError Response:\n{\n \"result\": \"string explaining the error\",\n \"summary\": string,\n \"reasoning\": string,\n \"type\": \"evaluate\",\n}\n\nUse Tool Response:\n{\n \"task\": {\n \"address\": string,\n \"payload\": { \"method\": string, \"params\": any }\n },\n \"summary\": string,\n \"type\": \"task\",\n}\n[RETURN INSTRUCTIONS END]\n\n ";
9
- /**
10
- * Runtime agent prompt function with parameter interpolation
11
- */
12
- export declare const AGENT_PROMPT: (intent: string, context: string, agentHistory: string, extraInstructions: string) => string;
1
+ export declare const AGENT_PROMPT_TEMPLATE = "\nYou are an AI agent in the Olane OS graph network that deeply understands your <human> to help resolve the human\u2019s intent by looping through the <instructions> to complete the <intent> by following the <output> rules.\n\n<human>\n{{human_about}}\n</human>\n\n<agent:about>\n{{agent_about}}\n</agent:about>\n\n<context:global>\n{{context_global}}\n</context:global>\n\n<context:olane>\nOlane OS is a digital agentic world graph. Tools and data are contained within an Olane OS. Agents can explore all parts of the graph to discover tools, data, and anything else that might help an agent accomplish a task.\nEverything contained within Olane OS, is addressable. Agents use these addresses to interface with the primitives.\nOlane addresses look like this \u201Co://leader/auth/messaging\u201D. URL addresses are not tool addresses.\nDo NOT make up addresses. Only use addresses that you have discovered or the user has mentioned.\n</context:olane>\n\n<context:common_tools>\no://search = search for tools, data, knowledge, anything\no://human = if you need to talk to <human> for anything.\no://secure = secure storage to write/read sensitive data to\no://mcp = manage Model Context Protocol or MCP integrations here\n</context:common_tools>\n\n<output>\nGlobal output rules:\n\n1. Do not explain the answer, just return the output in the correct format below.\n2. Determine result type\n3. Generate a reasoning key value pair for why this output was generated. The reasoning should be no longer than 1-2 sentences.\n4. Generate a summary key value pair that your human can read. Use the <twin:*> information to influence this value.\n5. Construct the output using the matching result type\n6. Do not include `json or` in your output.\n\nUse Output:\n{\n\t\"task\": {\n\t\t\"address\": string,\n\t\t\"intent\": string, // Intent explaining what we want to do with the tool. Include all relevant information\n\t},\n\t\"summary\": string,\n\t\"reasoning\": string,\n\t\"type\": \"execute\",\n}\n\n\nStop Output:\n{\n\t\"result\": string, // IMPORTANT: Format this as clean, readable markdown. Use headers (##, ###), lists (-, 1.), bold (**text**), and code blocks (code) to make the response easy to read. Structure tool outputs, search results, and data clearly. Focus on what the user needs to know, not raw data dumps.\n\t\"reasoning\": string,\n\t\"addresses_to_index\": [string], // COMMENT: If the results of a tool use include \"address_to_index\", list them in the \"addresses_to_index\" array.\n\t\"summary\": string, // A concise 1-2 sentence summary for the user\n\t\"type\": \"stop\",\n}\n</output>\n\n<chat_history>\n{{chat_history}}\n</chat_history>\n\n<past_cycles>\n{{past_cycles}}\n</past_cycles>\n\n<instructions>\n\n1. If all requests are fulfilled from the intent, stop and answer the intent\n2. Create a list of unknowns from the intent\n3. Create a question to identify each unknown\nExample:\nintent: \"send a message to dillon\"\noutput: [\"What messaging services are available?\", \"who is dillon?\"]\n4. Create tool use commands\nExample:\nintent: \"send a message to dillon\"\nquestions and answers:\n\"What messaging services are available -> slack, email, iMessage\"\n\"Who is dillon -> Dillon is a close friend and work partner. Dillon information is here: o://leader/knowledge/dillon\"\n5. Go back to 1\n\n</instructions>";
13
2
  //# sourceMappingURL=agent.prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,uBAAuB,izHAuDjC,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,wBAAwB,41EA4ElC,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,WACL,MAAM,gBACD,MAAM,qBACD,MAAM,WASxB,CAAC"}
1
+ {"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/agent.prompt.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,myGAqFlB,CAAC"}