@olane/o-lane 0.7.12-alpha.34 → 0.7.12-alpha.35

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.
@@ -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"}
@@ -1 +1 @@
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;AAGhD,8BAAsB,uBAAwB,SAAQ,WAAW;IACzD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;CAkD3E"}
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,7 +1,8 @@
1
- import { oAddress, oResponse, 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 {
@@ -9,6 +10,7 @@ export class oCapabilityIntelligence extends oCapability {
9
10
  throw new Error('Node is not running, cannot use intelligence capability');
10
11
  }
11
12
  const _isStreaming = this.config.useStream || false;
13
+ const parser = new ResultStreamParser('result');
12
14
  const response = await this.node.useStream(new oAddress(RestrictedAddresses.INTELLIGENCE), {
13
15
  method: 'prompt',
14
16
  params: {
@@ -17,10 +19,12 @@ export class oCapabilityIntelligence extends oCapability {
17
19
  },
18
20
  }, {
19
21
  onChunk: (chunk) => {
20
- if (this.config.onChunk) {
21
- // Emit only the result field content
22
- this.config.onChunk(oResponse.fromJSON(chunk));
23
- }
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
+ // }
24
28
  },
25
29
  });
26
30
  const message = response.result.data.message;
@@ -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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Stateful parser for extracting "result" field values from streaming JSON
2
+ * Stateful parser for extracting field values from streaming JSON
3
3
  * Emits only new content (deltas) as it arrives
4
4
  */
5
5
  export declare class ResultStreamParser {
@@ -8,20 +8,25 @@ export declare class ResultStreamParser {
8
8
  private resultStartIndex;
9
9
  private lastEmittedLength;
10
10
  private resultValue;
11
+ private attributeName;
11
12
  /**
12
- * Process a new chunk and return only the new content from "result" field
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
13
18
  * @param delta - The new chunk of JSON string data
14
- * @returns Only the new content within the "result" value, or null if not yet in result field
19
+ * @returns Only the new content within the field value, or null if not yet in field
15
20
  */
16
21
  processChunk(delta: string): string | null;
17
22
  /**
18
- * Get the complete result value accumulated so far
19
- * @returns The full "result" field value
23
+ * Get the complete field value accumulated so far
24
+ * @returns The full field value
20
25
  */
21
26
  getResultValue(): string;
22
27
  /**
23
- * Check if the parser has found and is processing the result field
24
- * @returns true if currently inside the result field value
28
+ * Check if the parser has found and is processing the target field
29
+ * @returns true if currently inside the field value
25
30
  */
26
31
  isInResult(): boolean;
27
32
  /**
@@ -1 +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;IAEzB;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAmD1C;;;OAGG;IACH,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd"}
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"}
@@ -1,35 +1,40 @@
1
1
  /**
2
- * Stateful parser for extracting "result" field values from streaming JSON
2
+ * Stateful parser for extracting field values from streaming JSON
3
3
  * Emits only new content (deltas) as it arrives
4
4
  */
5
5
  export class ResultStreamParser {
6
- constructor() {
6
+ /**
7
+ * @param attributeName - The JSON attribute name to extract (defaults to "result")
8
+ */
9
+ constructor(attributeName = 'result') {
7
10
  this.buffer = '';
8
11
  this.isInResultValue = false;
9
12
  this.resultStartIndex = -1;
10
13
  this.lastEmittedLength = 0;
11
14
  this.resultValue = '';
15
+ this.attributeName = attributeName;
12
16
  }
13
17
  /**
14
- * Process a new chunk and return only the new content from "result" field
18
+ * Process a new chunk and return only the new content from the specified field
15
19
  * @param delta - The new chunk of JSON string data
16
- * @returns Only the new content within the "result" value, or null if not yet in result field
20
+ * @returns Only the new content within the field value, or null if not yet in field
17
21
  */
18
22
  processChunk(delta) {
19
23
  this.buffer += delta;
20
- // If we haven't found the result field yet, look for it
24
+ // If we haven't found the field yet, look for it
21
25
  if (!this.isInResultValue) {
22
- const match = this.buffer.match(/"result"\s*:\s*"/);
26
+ const escapedAttributeName = this.attributeName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
27
+ const match = this.buffer.match(new RegExp(`"${escapedAttributeName}"\\s*:\\s*"`));
23
28
  if (match) {
24
29
  this.isInResultValue = true;
25
30
  this.resultStartIndex = (match.index ?? 0) + match[0].length;
26
31
  this.lastEmittedLength = 0;
27
32
  }
28
33
  else {
29
- return null; // Haven't reached result field yet
34
+ return null; // Haven't reached the target field yet
30
35
  }
31
36
  }
32
- // Extract content after "result": "
37
+ // Extract content after the attribute: "
33
38
  if (this.isInResultValue && this.resultStartIndex >= 0) {
34
39
  const contentAfterResult = this.buffer.substring(this.resultStartIndex);
35
40
  // Find the end of the string value (unescaped quote)
@@ -59,15 +64,15 @@ export class ResultStreamParser {
59
64
  return null;
60
65
  }
61
66
  /**
62
- * Get the complete result value accumulated so far
63
- * @returns The full "result" field value
67
+ * Get the complete field value accumulated so far
68
+ * @returns The full field value
64
69
  */
65
70
  getResultValue() {
66
71
  return this.resultValue;
67
72
  }
68
73
  /**
69
- * Check if the parser has found and is processing the result field
70
- * @returns true if currently inside the result field value
74
+ * Check if the parser has found and is processing the target field
75
+ * @returns true if currently inside the field value
71
76
  */
72
77
  isInResult() {
73
78
  return this.isInResultValue;
@@ -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;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;CAmBxC"}
@@ -30,6 +30,7 @@ export class oCapabilityMultipleStep extends oCapabilityIntelligence {
30
30
  }
31
31
  return new oCapabilityResult({
32
32
  result: results,
33
+ humanResult: results,
33
34
  type: oCapabilityType.EVALUATE,
34
35
  });
35
36
  }
@@ -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,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 -1,7 +1,8 @@
1
- import { oAddress, oResponse } from '@olane/o-core';
1
+ 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,8 +20,8 @@ export class oCapabilitySearch extends oCapability {
19
20
  return this.config.params.explanation;
20
21
  }
21
22
  async doExternalSearch(query) {
22
- let message = '';
23
- await this.node.useStream(new oAddress('o://perplexity'), {
23
+ const parser = new ResultStreamParser('message');
24
+ const response = await this.node.useStream(new oAddress('o://perplexity'), {
24
25
  method: 'completion',
25
26
  params: {
26
27
  model: 'sonar',
@@ -33,11 +34,16 @@ export class oCapabilitySearch extends oCapability {
33
34
  },
34
35
  }, {
35
36
  onChunk: (chunk) => {
36
- message += chunk.result.data.delta;
37
- this.config.onChunk?.(oResponse.fromJSON(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
+ // }
38
44
  },
39
45
  });
40
- return message;
46
+ return response.result.data.message;
41
47
  }
42
48
  /**
43
49
  * Search external providers.
@@ -48,7 +54,7 @@ export class oCapabilitySearch extends oCapability {
48
54
  const searchResult = await this.doExternalSearch(query.query);
49
55
  searchResults.push(searchResult);
50
56
  }
51
- let searchResultContext = `[Search Results Begin]`;
57
+ let searchResultContext = `[Search Results Begin]\n`;
52
58
  if (searchResults.length === 0) {
53
59
  searchResultContext += `No more search results found!\n\n`;
54
60
  }
@@ -59,6 +65,7 @@ export class oCapabilitySearch extends oCapability {
59
65
  searchResultContext += `[Search Results End]`;
60
66
  return new oCapabilitySearchResult({
61
67
  result: searchResultContext,
68
+ humanResult: searchResults,
62
69
  type: oCapabilityType.EVALUATE,
63
70
  config: this.config,
64
71
  });
@@ -71,9 +78,6 @@ export class oCapabilitySearch extends oCapability {
71
78
  limit: limit || 20,
72
79
  },
73
80
  });
74
- if (this.config.onChunk) {
75
- this.config.onChunk(response);
76
- }
77
81
  let searchResultContext = ``;
78
82
  const data = response.result.data;
79
83
  let filteredSearchResults = data;
@@ -88,7 +92,10 @@ export class oCapabilitySearch extends oCapability {
88
92
  searchResultContext += `Tool Address: ${searchResult?.metadata?.address || 'unknown'}\nTool Data: ${searchResult?.pageContent || 'unknown'}\n\n`;
89
93
  }
90
94
  }
91
- return searchResultContext;
95
+ return {
96
+ rawResult: filteredSearchResults,
97
+ formattedResult: searchResultContext,
98
+ };
92
99
  }
93
100
  /**
94
101
  * Search internal providers such as the local vector store, local database, etc.
@@ -96,13 +103,16 @@ export class oCapabilitySearch extends oCapability {
96
103
  async internalSearch() {
97
104
  // find all tools that are search tools
98
105
  let searchResultContext = `[Search Results Begin]`;
106
+ const searchResults = [];
99
107
  for (const query of this.queries) {
100
108
  const searchResult = await this.doInternalSearch(query.query, query.limit);
101
- searchResultContext += searchResult;
109
+ searchResults.push(searchResult.rawResult);
110
+ searchResultContext += searchResult.formattedResult;
102
111
  }
103
112
  searchResultContext += `[Search Results End]`;
104
113
  return new oCapabilitySearchResult({
105
114
  result: searchResultContext,
115
+ humanResult: searchResults?.flat() || [],
106
116
  type: oCapabilityType.EVALUATE,
107
117
  config: this.config,
108
118
  });
@@ -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;CA4H5C"}
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"}
@@ -99,6 +99,7 @@ export class oCapabilityTask extends oCapability {
99
99
  }
100
100
  return new oCapabilityTaskResult({
101
101
  result: `Tool Address Use output: ${JSON.stringify(response.result, null, 2)}`,
102
+ humanResult: response.result.data,
102
103
  type: oCapabilityType.EVALUATE,
103
104
  config: this.config,
104
105
  shouldPersist,
@@ -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,E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AM;;;;;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;IAgBvD,IAAI,YAAY,2DAEf;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAcxC,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAiBvB,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA+DlC,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 { 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';
@@ -121,6 +121,7 @@ export class oLane extends oObject {
121
121
  this.logger.error('Error in execute: ', error);
122
122
  this.status = oLaneStatus.FAILED;
123
123
  }
124
+ this.logger.debug('Completed loop...');
124
125
  await this.postflight(this.result);
125
126
  this.status = oLaneStatus.COMPLETED;
126
127
  return this.result;
@@ -185,6 +186,19 @@ export class oLane extends oObject {
185
186
  this.logger.debug('Capability result flagged for persistence - automatically setting persistToConfig');
186
187
  this.config.persistToConfig = true;
187
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
+ }
188
202
  if (result.type === oCapabilityType.STOP) {
189
203
  return result;
190
204
  }
@@ -1 +1 @@
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;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,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAsCzD;;;;;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;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,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAyCzD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA8B7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
@@ -40,6 +40,7 @@ export class oLaneTool extends oNodeTool {
40
40
  currentNode: this,
41
41
  caller: this.address,
42
42
  streamTo: streamTo ? new oAddress(streamTo) : undefined,
43
+ useStream: _isStreaming,
43
44
  onChunk: _isStreaming
44
45
  ? async (chunk) => {
45
46
  await CoreUtils.sendStreamResponse(oResponse.fromJSON(chunk), request.stream);
@@ -53,7 +54,7 @@ export class oLaneTool extends oNodeTool {
53
54
  });
54
55
  let response;
55
56
  response = await pc.execute();
56
- return {
57
+ const completeResponse = {
57
58
  result: response?.result,
58
59
  error: response?.error,
59
60
  cycles: pc.sequence.length,
@@ -62,6 +63,8 @@ export class oLaneTool extends oNodeTool {
62
63
  return s.result;
63
64
  }),
64
65
  };
66
+ console.log('completeResponse', completeResponse);
67
+ return completeResponse;
65
68
  }
66
69
  /**
67
70
  * Replay a stored lane from storage by CID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-lane",
3
- "version": "0.7.12-alpha.34",
3
+ "version": "0.7.12-alpha.35",
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.34",
58
- "@olane/o-core": "0.7.12-alpha.34",
59
- "@olane/o-node": "0.7.12-alpha.34",
60
- "@olane/o-protocol": "0.7.12-alpha.34",
61
- "@olane/o-tool": "0.7.12-alpha.34",
57
+ "@olane/o-config": "0.7.12-alpha.35",
58
+ "@olane/o-core": "0.7.12-alpha.35",
59
+ "@olane/o-node": "0.7.12-alpha.35",
60
+ "@olane/o-protocol": "0.7.12-alpha.35",
61
+ "@olane/o-tool": "0.7.12-alpha.35",
62
62
  "debug": "^4.4.1",
63
63
  "dotenv": "^16.5.0"
64
64
  },
65
- "gitHead": "cdc88de23ff6a1bb5e818ad00e02da9aebb8cdb2"
65
+ "gitHead": "c5f5289fedab194e9ea5e9a8cdca00da6904dea1"
66
66
  }