@olane/o-lane 0.7.12-alpha.5 → 0.7.12-alpha.50

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 (39) hide show
  1. package/dist/src/capabilities/interfaces/o-capability.config.d.ts +2 -0
  2. package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +1 -1
  3. package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +1 -0
  4. package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -1
  5. package/dist/src/capabilities/o-capability.d.ts +1 -0
  6. package/dist/src/capabilities/o-capability.d.ts.map +1 -1
  7. package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -1
  8. package/dist/src/capabilities/o-capability.intelligence.js +17 -5
  9. package/dist/src/capabilities/o-capability.js +3 -0
  10. package/dist/src/capabilities/o-capability.result.d.ts +1 -0
  11. package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
  12. package/dist/src/capabilities/o-capability.result.js +1 -0
  13. package/dist/src/capabilities/utils/result-stream-parser.d.ts +37 -0
  14. package/dist/src/capabilities/utils/result-stream-parser.d.ts.map +1 -0
  15. package/dist/src/capabilities/utils/result-stream-parser.js +90 -0
  16. package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +1 -0
  17. package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -1
  18. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts +2 -0
  19. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -1
  20. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +12 -0
  21. package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +1 -0
  22. package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -1
  23. package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
  24. package/dist/src/capabilities-search/o-capability.search.js +24 -6
  25. package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +1 -0
  26. package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +1 -1
  27. package/dist/src/capabilities-task/o-capability.task.d.ts.map +1 -1
  28. package/dist/src/capabilities-task/o-capability.task.js +4 -0
  29. package/dist/src/interfaces/o-lane.config.d.ts +2 -0
  30. package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
  31. package/dist/src/o-lane.d.ts +1 -0
  32. package/dist/src/o-lane.d.ts.map +1 -1
  33. package/dist/src/o-lane.js +29 -2
  34. package/dist/src/o-lane.tool.d.ts +2 -2
  35. package/dist/src/o-lane.tool.d.ts.map +1 -1
  36. package/dist/src/o-lane.tool.js +19 -6
  37. package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
  38. package/dist/src/prompts/agent.prompt.js +8 -1
  39. package/package.json +7 -7
@@ -8,5 +8,7 @@ export interface oCapabilityConfig {
8
8
  history: string;
9
9
  params?: any;
10
10
  isReplay?: boolean;
11
+ useStream?: boolean;
12
+ onChunk?: (chunk: any) => void;
11
13
  }
12
14
  //# 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;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
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;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC"}
@@ -2,6 +2,7 @@ import { oCapabilityConfig } from '../interfaces/o-capability.config.js';
2
2
  import { oCapabilityType } from '../enums/o-capability.type-enum.js';
3
3
  export interface oCapabilityResultInterface {
4
4
  result?: any;
5
+ humanResult?: any;
5
6
  type: oCapabilityType;
6
7
  error?: string;
7
8
  config?: oCapabilityConfig;
@@ -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;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
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,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -12,5 +12,6 @@ export declare abstract class oCapability extends oObject {
12
12
  get intent(): oIntent;
13
13
  get type(): oCapabilityType;
14
14
  static get type(): oCapabilityType;
15
+ cancel(): void;
15
16
  }
16
17
  //# sourceMappingURL=o-capability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,8BAAsB,WAAY,SAAQ,OAAO;IACxC,MAAM,EAAG,iBAAiB,CAAC;IAClC,QAAQ,CAAC,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAE1C,IAAI,IAAI,IAAI,SAAS,CAEpB;IAEK,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKpE,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,IAAI,oBAEP;IAED,MAAM,KAAK,IAAI,oBAEd;CACF"}
1
+ {"version":3,"file":"o-capability.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,8BAAsB,WAAY,SAAQ,OAAO;IACxC,MAAM,EAAG,iBAAiB,CAAC;IAClC,QAAQ,CAAC,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAE1C,IAAI,IAAI,IAAI,SAAS,CAEpB;IAEK,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKpE,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,IAAI,oBAEP;IAED,MAAM,KAAK,IAAI,oBAEd;IAED,MAAM;CAGP"}
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.intelligence.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.intelligence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,kDAAkD,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,8BAAsB,uBAAwB,SAAQ,WAAW;IACzD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;CAsC3E"}
1
+ {"version":3,"file":"o-capability.intelligence.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.intelligence.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,MAAM,kDAAkD,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,8BAAsB,uBAAwB,SAAQ,WAAW;IACzD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;CAqD3E"}
@@ -1,26 +1,38 @@
1
- import { oAddress, RegexUtils, RestrictedAddresses } from '@olane/o-core';
1
+ import { oAddress, RegexUtils, RestrictedAddresses, } from '@olane/o-core';
2
2
  import { oCapabilityIntelligenceResult } from './interfaces/o-capability.intelligence-result.js';
3
3
  import { oCapability } from './o-capability.js';
4
4
  import { oCapabilityType } from './enums/o-capability.type-enum.js';
5
+ import { ResultStreamParser } from './utils/result-stream-parser.js';
5
6
  export class oCapabilityIntelligence extends oCapability {
6
7
  async intelligence(prompt) {
7
8
  try {
8
9
  if (!this.node.isRunning) {
9
10
  throw new Error('Node is not running, cannot use intelligence capability');
10
11
  }
11
- const intelligenceResponse = await this.node.use(new oAddress(RestrictedAddresses.INTELLIGENCE), {
12
+ const _isStreaming = this.config.useStream || false;
13
+ const parser = new ResultStreamParser('result');
14
+ const response = await this.node.useStream(new oAddress(RestrictedAddresses.INTELLIGENCE), {
12
15
  method: 'prompt',
13
16
  params: {
14
17
  prompt: prompt,
18
+ _isStreaming: _isStreaming,
19
+ },
20
+ }, {
21
+ onChunk: (chunk) => {
22
+ // if (chunk.result.data.delta) {
23
+ // const parseResult = parser.processChunk(chunk.result.data.delta);
24
+ // if (parseResult) {
25
+ // this.config.onChunk?.(oResponse.fromJSON(parseResult));
26
+ // }
27
+ // }
15
28
  },
16
29
  });
17
- const data = intelligenceResponse.result.data;
18
- const message = data.message;
30
+ const message = response.result.data.message;
19
31
  if (!message) {
20
32
  throw new Error('No message returned from intelligence');
21
33
  }
34
+ // Use the parsed result value if available, otherwise fall back to full message
22
35
  const processedResult = RegexUtils.extractResultFromAI(message);
23
- this.logger.debug('Processed result: ', processedResult);
24
36
  return new oCapabilityIntelligenceResult({
25
37
  result: processedResult,
26
38
  type: processedResult.type,
@@ -17,4 +17,7 @@ export class oCapability extends oObject {
17
17
  static get type() {
18
18
  return oCapabilityType.UNKNOWN;
19
19
  }
20
+ cancel() {
21
+ // do nothing
22
+ }
20
23
  }
@@ -7,6 +7,7 @@ import { oCapabilityResultInterface } from './interfaces/o-capability.result-int
7
7
  export declare class oCapabilityResult implements oCapabilityResultInterface {
8
8
  id: string;
9
9
  result?: oCapabilitySearchConfig | oCapabilityMultipleStepConfig | oCapabilityTaskConfig | any;
10
+ humanResult?: any;
10
11
  type: oCapabilityType;
11
12
  error?: string;
12
13
  config?: oCapabilityConfig;
@@ -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;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;gBAEZ,MAAM,EAAE,0BAA0B;IAS9C,MAAM;;;;;;;;;;;;IAeN,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,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,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;IAU9C,MAAM;;;;;;;;;;;;IAeN,QAAQ;CAGT"}
@@ -4,6 +4,7 @@ export class oCapabilityResult {
4
4
  constructor(config) {
5
5
  this.id = uuidv4();
6
6
  this.result = config.result;
7
+ this.humanResult = config.humanResult;
7
8
  this.type = config.type || oCapabilityType.UNKNOWN;
8
9
  this.error = config.error || '';
9
10
  this.config = config.config;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Stateful parser for extracting field values from streaming JSON
3
+ * Emits only new content (deltas) as it arrives
4
+ */
5
+ export declare class ResultStreamParser {
6
+ private buffer;
7
+ private isInResultValue;
8
+ private resultStartIndex;
9
+ private lastEmittedLength;
10
+ private resultValue;
11
+ private attributeName;
12
+ /**
13
+ * @param attributeName - The JSON attribute name to extract (defaults to "result")
14
+ */
15
+ constructor(attributeName?: string);
16
+ /**
17
+ * Process a new chunk and return only the new content from the specified field
18
+ * @param delta - The new chunk of JSON string data
19
+ * @returns Only the new content within the field value, or null if not yet in field
20
+ */
21
+ processChunk(delta: string): string | null;
22
+ /**
23
+ * Get the complete field value accumulated so far
24
+ * @returns The full field value
25
+ */
26
+ getResultValue(): string;
27
+ /**
28
+ * Check if the parser has found and is processing the target field
29
+ * @returns true if currently inside the field value
30
+ */
31
+ isInResult(): boolean;
32
+ /**
33
+ * Reset the parser state for reuse
34
+ */
35
+ reset(): void;
36
+ }
37
+ //# sourceMappingURL=result-stream-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-stream-parser.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/utils/result-stream-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,aAAa,CAAS;IAE9B;;OAEG;gBACS,aAAa,GAAE,MAAiB;IAI5C;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAyD1C;;;OAGG;IACH,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Stateful parser for extracting field values from streaming JSON
3
+ * Emits only new content (deltas) as it arrives
4
+ */
5
+ export class ResultStreamParser {
6
+ /**
7
+ * @param attributeName - The JSON attribute name to extract (defaults to "result")
8
+ */
9
+ constructor(attributeName = 'result') {
10
+ this.buffer = '';
11
+ this.isInResultValue = false;
12
+ this.resultStartIndex = -1;
13
+ this.lastEmittedLength = 0;
14
+ this.resultValue = '';
15
+ this.attributeName = attributeName;
16
+ }
17
+ /**
18
+ * Process a new chunk and return only the new content from the specified field
19
+ * @param delta - The new chunk of JSON string data
20
+ * @returns Only the new content within the field value, or null if not yet in field
21
+ */
22
+ processChunk(delta) {
23
+ this.buffer += delta;
24
+ // If we haven't found the field yet, look for it
25
+ if (!this.isInResultValue) {
26
+ const escapedAttributeName = this.attributeName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
27
+ const match = this.buffer.match(new RegExp(`"${escapedAttributeName}"\\s*:\\s*"`));
28
+ if (match) {
29
+ this.isInResultValue = true;
30
+ this.resultStartIndex = (match.index ?? 0) + match[0].length;
31
+ this.lastEmittedLength = 0;
32
+ }
33
+ else {
34
+ return null; // Haven't reached the target field yet
35
+ }
36
+ }
37
+ // Extract content after the attribute: "
38
+ if (this.isInResultValue && this.resultStartIndex >= 0) {
39
+ const contentAfterResult = this.buffer.substring(this.resultStartIndex);
40
+ // Find the end of the string value (unescaped quote)
41
+ let endIndex = -1;
42
+ let i = 0;
43
+ while (i < contentAfterResult.length) {
44
+ if (contentAfterResult[i] === '\\') {
45
+ i += 2; // Skip escaped character
46
+ continue;
47
+ }
48
+ if (contentAfterResult[i] === '"') {
49
+ endIndex = i;
50
+ break;
51
+ }
52
+ i++;
53
+ }
54
+ // Extract the result value (up to end quote or current position)
55
+ const currentValue = endIndex >= 0
56
+ ? contentAfterResult.substring(0, endIndex)
57
+ : contentAfterResult;
58
+ // Calculate and emit only the NEW content (delta)
59
+ const newContent = currentValue.substring(this.lastEmittedLength);
60
+ this.lastEmittedLength = currentValue.length;
61
+ this.resultValue = currentValue;
62
+ return newContent || null;
63
+ }
64
+ return null;
65
+ }
66
+ /**
67
+ * Get the complete field value accumulated so far
68
+ * @returns The full field value
69
+ */
70
+ getResultValue() {
71
+ return this.resultValue;
72
+ }
73
+ /**
74
+ * Check if the parser has found and is processing the target field
75
+ * @returns true if currently inside the field value
76
+ */
77
+ isInResult() {
78
+ return this.isInResultValue;
79
+ }
80
+ /**
81
+ * Reset the parser state for reuse
82
+ */
83
+ reset() {
84
+ this.buffer = '';
85
+ this.isInResultValue = false;
86
+ this.resultStartIndex = -1;
87
+ this.lastEmittedLength = 0;
88
+ this.resultValue = '';
89
+ }
90
+ }
@@ -8,5 +8,6 @@ export interface oCapabilityMultipleStepConfig extends oCapabilityConfig {
8
8
  intents: oIntent[];
9
9
  explanation: string;
10
10
  };
11
+ summary: string;
11
12
  }
12
13
  //# sourceMappingURL=o-capability.multiple-step-config.d.ts.map
@@ -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":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,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;CACH"}
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":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,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"}
@@ -5,10 +5,12 @@ import { oCapabilityType } from '../capabilities/enums/o-capability.type-enum.js
5
5
  import { oCapabilityResult } from '../capabilities/o-capability.result.js';
6
6
  export declare class oCapabilityMultipleStep extends oCapabilityIntelligence {
7
7
  config: oCapabilityMultipleStepConfig;
8
+ private subLanes;
8
9
  get type(): oCapabilityType;
9
10
  static get type(): oCapabilityType;
10
11
  get intents(): oIntent[];
11
12
  get explanation(): string;
12
13
  run(): Promise<oCapabilityResult>;
14
+ cancel(): void;
13
15
  }
14
16
  //# sourceMappingURL=o-capability.multiple-step.d.ts.map
@@ -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;IAE9C,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;CAkBxC"}
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"}
@@ -3,6 +3,10 @@ import { oCapabilityIntelligence } from '../capabilities/o-capability.intelligen
3
3
  import { oCapabilityType } from '../capabilities/enums/o-capability.type-enum.js';
4
4
  import { oCapabilityResult } from '../capabilities/o-capability.result.js';
5
5
  export class oCapabilityMultipleStep extends oCapabilityIntelligence {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.subLanes = new Map();
9
+ }
6
10
  get type() {
7
11
  return oCapabilityType.MULTIPLE_STEP;
8
12
  }
@@ -25,12 +29,20 @@ export class oCapabilityMultipleStep extends oCapabilityIntelligence {
25
29
  sequence: this.config.laneConfig.sequence,
26
30
  parentLaneId: this.config.parentLaneId,
27
31
  });
32
+ this.subLanes.set(subLane.id, subLane);
28
33
  await subLane.execute();
34
+ this.subLanes.delete(subLane.id);
29
35
  results.concat(subLane.sequence);
30
36
  }
31
37
  return new oCapabilityResult({
32
38
  result: results,
39
+ humanResult: results,
33
40
  type: oCapabilityType.EVALUATE,
34
41
  });
35
42
  }
43
+ cancel() {
44
+ for (const subLane of this.subLanes.values()) {
45
+ subLane.cancel();
46
+ }
47
+ }
36
48
  }
@@ -7,6 +7,7 @@ export interface oCapabilitySearchConfig extends oCapabilityConfig {
7
7
  }[];
8
8
  isExternal: boolean;
9
9
  explanation: string;
10
+ summary: string;
10
11
  };
11
12
  }
12
13
  //# sourceMappingURL=o-capability.search-config.d.ts.map
@@ -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,sDAAsD,CAAC;AAEzF,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;KACrB,CAAC;CACH"}
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,sDAAsD,CAAC;AAEzF,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;AAE3E,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;IAiBtD;;OAEG;YACW,cAAc;YAyBd,gBAAgB;IA6B9B;;OAEG;YACW,cAAc;IAoBtB,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAOxC"}
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;YA0Bd,gBAAgB;IAmC9B;;OAEG;YACW,cAAc;IAuBtB,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAOxC"}
@@ -2,6 +2,7 @@ import { oAddress } from '@olane/o-core';
2
2
  import { oCapability } from '../capabilities/o-capability.js';
3
3
  import { oCapabilityType } from '../capabilities/enums/o-capability.type-enum.js';
4
4
  import { oCapabilitySearchResult } from './o-capability.search-result.js';
5
+ import { ResultStreamParser } from '../capabilities/utils/result-stream-parser.js';
5
6
  export class oCapabilitySearch extends oCapability {
6
7
  get type() {
7
8
  return oCapabilityType.SEARCH;
@@ -19,7 +20,8 @@ export class oCapabilitySearch extends oCapability {
19
20
  return this.config.params.explanation;
20
21
  }
21
22
  async doExternalSearch(query) {
22
- const response = await this.node.use(new oAddress('o://perplexity'), {
23
+ const parser = new ResultStreamParser('message');
24
+ const response = await this.node.useStream(new oAddress('o://perplexity'), {
23
25
  method: 'completion',
24
26
  params: {
25
27
  model: 'sonar',
@@ -30,9 +32,18 @@ export class oCapabilitySearch extends oCapability {
30
32
  },
31
33
  ],
32
34
  },
35
+ }, {
36
+ onChunk: (chunk) => {
37
+ // message += (chunk.result.data as any).delta;
38
+ // if (chunk.result.data.delta) {
39
+ // const parseResult = parser.processChunk(chunk.result.data.delta);
40
+ // if (parseResult) {
41
+ // this.config.onChunk?.(oResponse.fromJSON(parseResult));
42
+ // }
43
+ // }
44
+ },
33
45
  });
34
- const data = response.result.data;
35
- return data.message;
46
+ return response.result.data.message;
36
47
  }
37
48
  /**
38
49
  * Search external providers.
@@ -43,7 +54,7 @@ export class oCapabilitySearch extends oCapability {
43
54
  const searchResult = await this.doExternalSearch(query.query);
44
55
  searchResults.push(searchResult);
45
56
  }
46
- let searchResultContext = `[Search Results Begin]`;
57
+ let searchResultContext = `[Search Results Begin]\n`;
47
58
  if (searchResults.length === 0) {
48
59
  searchResultContext += `No more search results found!\n\n`;
49
60
  }
@@ -54,6 +65,7 @@ export class oCapabilitySearch extends oCapability {
54
65
  searchResultContext += `[Search Results End]`;
55
66
  return new oCapabilitySearchResult({
56
67
  result: searchResultContext,
68
+ humanResult: searchResults,
57
69
  type: oCapabilityType.EVALUATE,
58
70
  config: this.config,
59
71
  });
@@ -80,7 +92,10 @@ export class oCapabilitySearch extends oCapability {
80
92
  searchResultContext += `Tool Address: ${searchResult?.metadata?.address || 'unknown'}\nTool Data: ${searchResult?.pageContent || 'unknown'}\n\n`;
81
93
  }
82
94
  }
83
- return searchResultContext;
95
+ return {
96
+ rawResult: filteredSearchResults,
97
+ formattedResult: searchResultContext,
98
+ };
84
99
  }
85
100
  /**
86
101
  * Search internal providers such as the local vector store, local database, etc.
@@ -88,13 +103,16 @@ export class oCapabilitySearch extends oCapability {
88
103
  async internalSearch() {
89
104
  // find all tools that are search tools
90
105
  let searchResultContext = `[Search Results Begin]`;
106
+ const searchResults = [];
91
107
  for (const query of this.queries) {
92
108
  const searchResult = await this.doInternalSearch(query.query, query.limit);
93
- searchResultContext += searchResult;
109
+ searchResults.push(searchResult.rawResult);
110
+ searchResultContext += searchResult.formattedResult;
94
111
  }
95
112
  searchResultContext += `[Search Results End]`;
96
113
  return new oCapabilitySearchResult({
97
114
  result: searchResultContext,
115
+ humanResult: searchResults?.flat() || [],
98
116
  type: oCapabilityType.EVALUATE,
99
117
  config: this.config,
100
118
  });
@@ -10,6 +10,7 @@ export interface oCapabilityTaskConfig extends oCapabilityConfig {
10
10
  };
11
11
  };
12
12
  };
13
+ summary: string;
13
14
  };
14
15
  }
15
16
  //# sourceMappingURL=o-capability.task-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-capability.task-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-task/interfaces/o-capability.task-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AAEzF,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC;YAChB,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,CAAC;gBACf,MAAM,EAAE;oBAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;iBAAE,CAAC;aAChC,CAAC;SACH,CAAC;KACH,CAAC;CACH"}
1
+ {"version":3,"file":"o-capability.task-config.d.ts","sourceRoot":"","sources":["../../../../src/capabilities-task/interfaces/o-capability.task-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AAEzF,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC;YAChB,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,CAAC;gBACf,MAAM,EAAE;oBAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;iBAAE,CAAC;aAChC,CAAC;SACH,CAAC;QACF,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -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;CAyH5C"}
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;CA6H5C"}
@@ -89,6 +89,9 @@ export class oCapabilityTask extends oCapability {
89
89
  method: task.payload?.method,
90
90
  params: params,
91
91
  });
92
+ if (this.config.onChunk) {
93
+ this.config.onChunk(response);
94
+ }
92
95
  // Check if the tool response contains _save flag
93
96
  const shouldPersist = response.result?.data?._save === true;
94
97
  if (shouldPersist) {
@@ -96,6 +99,7 @@ export class oCapabilityTask extends oCapability {
96
99
  }
97
100
  return new oCapabilityTaskResult({
98
101
  result: `Tool Address Use output: ${JSON.stringify(response.result, null, 2)}`,
102
+ humanResult: response.result.data,
99
103
  type: oCapabilityType.EVALUATE,
100
104
  config: this.config,
101
105
  shouldPersist,
@@ -15,5 +15,7 @@ export interface oLaneConfig {
15
15
  parentLaneId?: string;
16
16
  maxCycles?: number;
17
17
  persistToConfig?: boolean;
18
+ onChunk?: (chunk: any) => void;
19
+ useStream?: boolean;
18
20
  }
19
21
  //# 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,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B,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;CACrB"}
@@ -15,6 +15,7 @@ export declare class oLane extends oObject {
15
15
  MAX_CYCLES: number;
16
16
  status: oLaneStatus;
17
17
  result: oCapabilityResult | undefined;
18
+ onChunk?: (chunk: any) => void;
18
19
  constructor(config: oLaneConfig);
19
20
  get intent(): oIntent;
20
21
  toCIDInput(): any;
@@ -1 +1 @@
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;IAC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M,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAwEjE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAS9B,IAAI,IAAI,yCAEP;CACF"}
@@ -1,4 +1,4 @@
1
- import { oAddress, oError, oErrorCodes, NodeState, oObject, } from '@olane/o-core';
1
+ import { oAddress, oError, oErrorCodes, NodeState, oObject, oResponse, } 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';
@@ -18,6 +18,7 @@ export class oLane extends oObject {
18
18
  this.sequence = Object.assign([], this.config.sequence || []);
19
19
  this.parentLaneId = this.config.parentLaneId;
20
20
  this.intentEncoder = new oIntentEncoder();
21
+ this.onChunk = this.config.onChunk;
21
22
  // set a max cycles if one is not provided
22
23
  if (!!process.env.MAX_CYCLES) {
23
24
  this.MAX_CYCLES = parseInt(process.env.MAX_CYCLES);
@@ -120,6 +121,7 @@ export class oLane extends oObject {
120
121
  this.logger.error('Error in execute: ', error);
121
122
  this.status = oLaneStatus.FAILED;
122
123
  }
124
+ this.logger.debug('Completed loop...');
123
125
  await this.postflight(this.result);
124
126
  this.status = oLaneStatus.COMPLETED;
125
127
  return this.result;
@@ -137,6 +139,7 @@ export class oLane extends oObject {
137
139
  ...this.config,
138
140
  sequence: this.sequence, // pass the full sequence to the next capability
139
141
  },
142
+ useStream: this.config.useStream || false,
140
143
  };
141
144
  }
142
145
  async doCapability(currentStep) {
@@ -144,8 +147,10 @@ export class oLane extends oObject {
144
147
  for (const capability of this.capabilities) {
145
148
  if (capability.type === capabilityType && currentStep.config) {
146
149
  const capabilityConfig = this.resultToConfig(currentStep);
150
+ this.logger.debug('Executing capability: ', capabilityType);
147
151
  const result = await capability.execute({
148
152
  ...capabilityConfig,
153
+ onChunk: this.onChunk,
149
154
  });
150
155
  return result;
151
156
  }
@@ -181,6 +186,19 @@ export class oLane extends oObject {
181
186
  this.logger.debug('Capability result flagged for persistence - automatically setting persistToConfig');
182
187
  this.config.persistToConfig = true;
183
188
  }
189
+ if (this.config.useStream && this.onChunk) {
190
+ this.onChunk(new oResponse({
191
+ data: {
192
+ ...result,
193
+ config: undefined,
194
+ },
195
+ _last: false,
196
+ _isStreaming: true,
197
+ _connectionId: this.node.address.toString(),
198
+ _requestMethod: 'unknown',
199
+ id: uuidv4(),
200
+ }));
201
+ }
184
202
  if (result.type === oCapabilityType.STOP) {
185
203
  return result;
186
204
  }
@@ -211,9 +229,14 @@ export class oLane extends oObject {
211
229
  const data = response?.result;
212
230
  if (data.addresses_to_index) {
213
231
  for (const address of data.addresses_to_index) {
214
- await this.node.use(new oAddress(address), {
232
+ this.logger.debug('Indexing address: ', address.toString());
233
+ await this.node
234
+ .use(new oAddress(address), {
215
235
  method: 'index_network',
216
236
  params: {},
237
+ })
238
+ .catch((error) => {
239
+ this.logger.error('Error indexing address: ', error);
217
240
  });
218
241
  }
219
242
  }
@@ -232,6 +255,10 @@ export class oLane extends oObject {
232
255
  cancel() {
233
256
  this.logger.debug('Cancelling lane...');
234
257
  this.status = oLaneStatus.CANCELLED;
258
+ // tell all capabilities to cancel
259
+ for (const capability of this.capabilities) {
260
+ capability.cancel();
261
+ }
235
262
  }
236
263
  /**
237
264
  * Replay a stored lane from storage by CID
@@ -1,5 +1,5 @@
1
1
  import { oRequest } from '@olane/o-core';
2
- import { oNodeConfig, oNodeTool } from '@olane/o-node';
2
+ import { oNodeConfig, oNodeTool, oStreamRequest } from '@olane/o-node';
3
3
  import { oHandshakeResult } from './interfaces/index.js';
4
4
  export declare class oLaneTool extends oNodeTool {
5
5
  private manager;
@@ -10,7 +10,7 @@ export declare class oLaneTool extends oNodeTool {
10
10
  * @param request
11
11
  * @returns
12
12
  */
13
- _tool_intent(request: oRequest): Promise<any>;
13
+ _tool_intent(request: oStreamRequest): Promise<any>;
14
14
  /**
15
15
  * Replay a stored lane from storage by CID
16
16
  * This restores network state from a previously executed lane
@@ -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;IA4BnD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA8B7C,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,EAAuB,QAAQ,EAAa,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,WAAW,EACX,SAAS,EACT,cAAc,EAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,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,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAgDzD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA8B7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
@@ -1,5 +1,5 @@
1
- import { oAddress } from '@olane/o-core';
2
- import { oNodeTool } from '@olane/o-node';
1
+ import { CoreUtils, oAddress, oResponse } from '@olane/o-core';
2
+ import { oNodeTool, } from '@olane/o-node';
3
3
  import { oCapabilityType } from './capabilities/index.js';
4
4
  import { oIntent } from './intent/index.js';
5
5
  import { oLaneContext } from './o-lane.context.js';
@@ -34,21 +34,32 @@ export class oLaneTool extends oNodeTool {
34
34
  */
35
35
  async _tool_intent(request) {
36
36
  this.logger.debug('Intent resolution called: ', request.params);
37
- const { intent, context, streamTo } = request.params;
37
+ const { intent, context, streamTo, _isStreaming = false } = request.params;
38
38
  const pc = await this.manager.createLane({
39
39
  intent: new oIntent({ intent: intent }),
40
40
  currentNode: this,
41
41
  caller: this.address,
42
42
  streamTo: streamTo ? new oAddress(streamTo) : undefined,
43
+ useStream: _isStreaming,
44
+ onChunk: _isStreaming
45
+ ? async (chunk) => {
46
+ await CoreUtils.sendStreamResponse(oResponse.fromJSON(chunk), request.stream);
47
+ }
48
+ : undefined,
43
49
  context: context
44
50
  ? new oLaneContext([
45
51
  `[Chat History Context Begin]\n${context}\n[Chat History Context End]`,
46
52
  ])
47
53
  : undefined,
48
54
  });
49
- const response = await pc.execute();
50
- this.logger.debug('Intent resolution response: ', response);
51
- return {
55
+ const stream = request.stream;
56
+ stream.addEventListener('close', () => {
57
+ this.logger.debug('Stream closed, cancelling lane for intent:', intent);
58
+ pc.cancel();
59
+ });
60
+ let response;
61
+ response = await pc.execute();
62
+ const completeResponse = {
52
63
  result: response?.result,
53
64
  error: response?.error,
54
65
  cycles: pc.sequence.length,
@@ -57,6 +68,8 @@ export class oLaneTool extends oNodeTool {
57
68
  return s.result;
58
69
  }),
59
70
  };
71
+ console.log('completeResponse', completeResponse);
72
+ return completeResponse;
60
73
  }
61
74
  /**
62
75
  * Replay a stored lane from storage by CID
@@ -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,WA+HxB,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,WAsIxB,CAAC"}
@@ -58,6 +58,7 @@ All Return Step Instructions:
58
58
  3. Output the respective results using the matching output type.
59
59
  4. Generate a reasoning key value pair for why this result was returned.
60
60
  5. The reasoning should be no longer than 1 sentence.
61
+ 6. 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.
61
62
  6. Do not include \`\`\`json or \`\`\` in your output.
62
63
 
63
64
  Complex Intent Results:
@@ -67,6 +68,7 @@ Complex Intent Results:
67
68
  "simple intent 2",
68
69
  "simple intent 3",
69
70
  ],
71
+ "summary": string,
70
72
  "reasoning": string,
71
73
  "type": "multiple_step",
72
74
  }
@@ -76,6 +78,7 @@ Configure Response:
76
78
  "intent": string,
77
79
  "toolAddress": string,
78
80
  "reasoning": string,
81
+ "summary": string,
79
82
  "type": "configure",
80
83
  }
81
84
 
@@ -89,6 +92,7 @@ Search Response:
89
92
  ],
90
93
  "isExternal": boolean,
91
94
  "reasoning": string,
95
+ "summary": string,
92
96
  "type": "search",
93
97
  }
94
98
 
@@ -97,12 +101,14 @@ Stop Response:
97
101
  "result": string,
98
102
  "reasoning": string,
99
103
  "addresses_to_index": [string], // COMMENT: If the results of a tool use include "address_to_index", list them in the "addresses_to_index" array.
104
+ "summary": string,
100
105
  "type": "stop",
101
106
  }
102
107
 
103
108
  Error Response:
104
109
  {
105
110
  "result": "string explaining the error",
111
+ "summary": string,
106
112
  "reasoning": string,
107
113
  "type": "evaluate",
108
114
  }
@@ -112,7 +118,8 @@ Use Tool Response:
112
118
  "task": {
113
119
  "address": string,
114
120
  "payload": { "method": string, "params": any }
115
- }
121
+ },
122
+ "summary": string,
116
123
  "type": "task",
117
124
  }
118
125
  [RETURN INSTRUCTIONS END]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-lane",
3
- "version": "0.7.12-alpha.5",
3
+ "version": "0.7.12-alpha.50",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -54,13 +54,13 @@
54
54
  "typescript": "5.4.5"
55
55
  },
56
56
  "dependencies": {
57
- "@olane/o-config": "0.7.12-alpha.5",
58
- "@olane/o-core": "0.7.12-alpha.4",
59
- "@olane/o-node": "0.7.12-alpha.5",
60
- "@olane/o-protocol": "0.7.12-alpha.4",
61
- "@olane/o-tool": "0.7.12-alpha.5",
57
+ "@olane/o-config": "0.7.12-alpha.50",
58
+ "@olane/o-core": "0.7.12-alpha.50",
59
+ "@olane/o-node": "0.7.12-alpha.50",
60
+ "@olane/o-protocol": "0.7.12-alpha.50",
61
+ "@olane/o-tool": "0.7.12-alpha.50",
62
62
  "debug": "^4.4.1",
63
63
  "dotenv": "^16.5.0"
64
64
  },
65
- "gitHead": "f0b799131f025624da04374b76e9aa373402f787"
65
+ "gitHead": "b39adebc281eb6f08e49985b8d85c84ce331e76a"
66
66
  }