@olane/o-lane 0.7.12-alpha.24 → 0.7.12-alpha.26

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.
@@ -8,5 +8,6 @@ export interface oCapabilityConfig {
8
8
  history: string;
9
9
  params?: any;
10
10
  isReplay?: boolean;
11
+ onChunk?: (chunk: any) => void;
11
12
  }
12
13
  //# 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,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC"}
@@ -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;CAgE3E"}
@@ -1,25 +1,44 @@
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
+ let message = '';
13
+ const parser = new ResultStreamParser();
14
+ await this.node.useStream(new oAddress(RestrictedAddresses.INTELLIGENCE), {
12
15
  method: 'prompt',
13
16
  params: {
14
17
  prompt: prompt,
18
+ _isStream: this.config.onChunk ? true : false,
19
+ },
20
+ }, {
21
+ onChunk: (chunk) => {
22
+ const delta = chunk.result.data.delta;
23
+ message += delta;
24
+ // Extract only new content from "result" field
25
+ const resultDelta = parser.processChunk(delta);
26
+ if (resultDelta && this.config.onChunk) {
27
+ // Emit only the result field content
28
+ const chunkData = chunk.result.data;
29
+ this.config.onChunk({
30
+ ...chunkData,
31
+ delta: resultDelta,
32
+ });
33
+ }
15
34
  },
16
35
  });
17
- const data = intelligenceResponse.result.data;
18
- const message = data.message;
19
36
  if (!message) {
20
37
  throw new Error('No message returned from intelligence');
21
38
  }
22
- const processedResult = RegexUtils.extractResultFromAI(message);
39
+ // Use the parsed result value if available, otherwise fall back to full message
40
+ const resultValue = parser.getResultValue();
41
+ const processedResult = RegexUtils.extractResultFromAI(resultValue || message);
23
42
  this.logger.debug('Processed result: ', processedResult);
24
43
  return new oCapabilityIntelligenceResult({
25
44
  result: processedResult,
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Stateful parser for extracting "result" 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
+ /**
12
+ * Process a new chunk and return only the new content from "result" field
13
+ * @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
15
+ */
16
+ processChunk(delta: string): string | null;
17
+ /**
18
+ * Get the complete result value accumulated so far
19
+ * @returns The full "result" field value
20
+ */
21
+ getResultValue(): string;
22
+ /**
23
+ * Check if the parser has found and is processing the result field
24
+ * @returns true if currently inside the result field value
25
+ */
26
+ isInResult(): boolean;
27
+ /**
28
+ * Reset the parser state for reuse
29
+ */
30
+ reset(): void;
31
+ }
32
+ //# 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;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"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Stateful parser for extracting "result" field values from streaming JSON
3
+ * Emits only new content (deltas) as it arrives
4
+ */
5
+ export class ResultStreamParser {
6
+ constructor() {
7
+ this.buffer = '';
8
+ this.isInResultValue = false;
9
+ this.resultStartIndex = -1;
10
+ this.lastEmittedLength = 0;
11
+ this.resultValue = '';
12
+ }
13
+ /**
14
+ * Process a new chunk and return only the new content from "result" field
15
+ * @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
17
+ */
18
+ processChunk(delta) {
19
+ this.buffer += delta;
20
+ // If we haven't found the result field yet, look for it
21
+ if (!this.isInResultValue) {
22
+ const match = this.buffer.match(/"result"\s*:\s*"/);
23
+ if (match) {
24
+ this.isInResultValue = true;
25
+ this.resultStartIndex = (match.index ?? 0) + match[0].length;
26
+ this.lastEmittedLength = 0;
27
+ }
28
+ else {
29
+ return null; // Haven't reached result field yet
30
+ }
31
+ }
32
+ // Extract content after "result": "
33
+ if (this.isInResultValue && this.resultStartIndex >= 0) {
34
+ const contentAfterResult = this.buffer.substring(this.resultStartIndex);
35
+ // Find the end of the string value (unescaped quote)
36
+ let endIndex = -1;
37
+ let i = 0;
38
+ while (i < contentAfterResult.length) {
39
+ if (contentAfterResult[i] === '\\') {
40
+ i += 2; // Skip escaped character
41
+ continue;
42
+ }
43
+ if (contentAfterResult[i] === '"') {
44
+ endIndex = i;
45
+ break;
46
+ }
47
+ i++;
48
+ }
49
+ // Extract the result value (up to end quote or current position)
50
+ const currentValue = endIndex >= 0
51
+ ? contentAfterResult.substring(0, endIndex)
52
+ : contentAfterResult;
53
+ // Calculate and emit only the NEW content (delta)
54
+ const newContent = currentValue.substring(this.lastEmittedLength);
55
+ this.lastEmittedLength = currentValue.length;
56
+ this.resultValue = currentValue;
57
+ return newContent || null;
58
+ }
59
+ return null;
60
+ }
61
+ /**
62
+ * Get the complete result value accumulated so far
63
+ * @returns The full "result" field value
64
+ */
65
+ getResultValue() {
66
+ return this.resultValue;
67
+ }
68
+ /**
69
+ * Check if the parser has found and is processing the result field
70
+ * @returns true if currently inside the result field value
71
+ */
72
+ isInResult() {
73
+ return this.isInResultValue;
74
+ }
75
+ /**
76
+ * Reset the parser state for reuse
77
+ */
78
+ reset() {
79
+ this.buffer = '';
80
+ this.isInResultValue = false;
81
+ this.resultStartIndex = -1;
82
+ this.lastEmittedLength = 0;
83
+ this.resultValue = '';
84
+ }
85
+ }
@@ -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;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;IA0BtD;;OAEG;YACW,cAAc;YAyBd,gBAAgB;IAgC9B;;OAEG;YACW,cAAc;IAoBtB,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAOxC"}
@@ -19,7 +19,8 @@ export class oCapabilitySearch extends oCapability {
19
19
  return this.config.params.explanation;
20
20
  }
21
21
  async doExternalSearch(query) {
22
- const response = await this.node.use(new oAddress('o://perplexity'), {
22
+ let message = '';
23
+ await this.node.useStream(new oAddress('o://perplexity'), {
23
24
  method: 'completion',
24
25
  params: {
25
26
  model: 'sonar',
@@ -30,9 +31,13 @@ export class oCapabilitySearch extends oCapability {
30
31
  },
31
32
  ],
32
33
  },
34
+ }, {
35
+ onChunk: (chunk) => {
36
+ message += chunk.result.data.delta;
37
+ this.config.onChunk?.(chunk);
38
+ },
33
39
  });
34
- const data = response.result.data;
35
- return data.message;
40
+ return message;
36
41
  }
37
42
  /**
38
43
  * Search external providers.
@@ -66,6 +71,9 @@ export class oCapabilitySearch extends oCapability {
66
71
  limit: limit || 20,
67
72
  },
68
73
  });
74
+ if (this.config.onChunk) {
75
+ this.config.onChunk(response);
76
+ }
69
77
  let searchResultContext = ``;
70
78
  const data = response.result.data;
71
79
  let filteredSearchResults = data;
@@ -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;CA4H5C"}
@@ -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) {
@@ -15,5 +15,6 @@ export interface oLaneConfig {
15
15
  parentLaneId?: string;
16
16
  maxCycles?: number;
17
17
  persistToConfig?: boolean;
18
+ onChunk?: (chunk: any) => void;
18
19
  }
19
20
  //# sourceMappingURL=o-lane.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-lane.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-lane.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAEjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAG7B,WAAW,EAAE,SAAS,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
1
+ {"version":3,"file":"o-lane.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-lane.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAEjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAG7B,WAAW,EAAE,SAAS,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC"}
@@ -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;IAC1C,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;gBAEd,MAAM,EAAE,WAAW;IAalD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,IAAI,GAAG;IAQjB,MAAM;;;;;IAQN,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAgB/B,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAUrB,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAuB3B,IAAI,YAAY,WA8Bf;IACK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAevD,IAAI,YAAY,2DAEf;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAaxC,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAevB,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA8ClC,UAAU,CACd,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAiDzC,MAAM;IAKN;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAwEjE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAS9B,IAAI,IAAI,yCAEP;CACF"}
1
+ {"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;IAWpB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IAV3C,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IACnC,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC;IACrB,EAAE,EAAE,MAAM,CAAY;IACtB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAM;IACxB,MAAM,EAAE,WAAW,CAAuB;IAC1C,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;gBAEP,MAAM,EAAE,WAAW;IAalD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,IAAI,GAAG;IAQjB,MAAM;;;;;IAQN,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAgB/B,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAUrB,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAuB3B,IAAI,YAAY,WA8Bf;IACK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAevD,IAAI,YAAY,2DAEf;IAED,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAaxC,YAAY,CAChB,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAiBvB,IAAI,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA8ClC,UAAU,CACd,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAiDzC,MAAM;IAKN;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAwEjE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAS9B,IAAI,IAAI,yCAEP;CACF"}
@@ -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);
@@ -144,8 +145,10 @@ export class oLane extends oObject {
144
145
  for (const capability of this.capabilities) {
145
146
  if (capability.type === capabilityType && currentStep.config) {
146
147
  const capabilityConfig = this.resultToConfig(currentStep);
148
+ this.logger.debug('Executing capability: ', capabilityType);
147
149
  const result = await capability.execute({
148
150
  ...capabilityConfig,
151
+ onChunk: this.onChunk,
149
152
  });
150
153
  return result;
151
154
  }
@@ -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;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;IA6CzD;;;;;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,20 +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, _isStream = 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
+ onChunk: _isStream
44
+ ? async (chunk) => {
45
+ this.logger.debug('Sending stream response: ', chunk);
46
+ await CoreUtils.sendStreamResponse(new oResponse({
47
+ id: request.id,
48
+ data: chunk,
49
+ _last: false,
50
+ _requestMethod: request.method,
51
+ _connectionId: request.params?._connectionId,
52
+ }), request.stream);
53
+ }
54
+ : undefined,
43
55
  context: context
44
56
  ? new oLaneContext([
45
57
  `[Chat History Context Begin]\n${context}\n[Chat History Context End]`,
46
58
  ])
47
59
  : undefined,
48
60
  });
49
- const response = await pc.execute();
50
- this.logger.debug('Intent resolution response: ', response);
61
+ let response;
62
+ response = await pc.execute();
51
63
  return {
52
64
  result: response?.result,
53
65
  error: response?.error,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-lane",
3
- "version": "0.7.12-alpha.24",
3
+ "version": "0.7.12-alpha.26",
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.24",
58
- "@olane/o-core": "0.7.12-alpha.24",
59
- "@olane/o-node": "0.7.12-alpha.24",
60
- "@olane/o-protocol": "0.7.12-alpha.24",
61
- "@olane/o-tool": "0.7.12-alpha.24",
57
+ "@olane/o-config": "0.7.12-alpha.26",
58
+ "@olane/o-core": "0.7.12-alpha.26",
59
+ "@olane/o-node": "0.7.12-alpha.26",
60
+ "@olane/o-protocol": "0.7.12-alpha.26",
61
+ "@olane/o-tool": "0.7.12-alpha.26",
62
62
  "debug": "^4.4.1",
63
63
  "dotenv": "^16.5.0"
64
64
  },
65
- "gitHead": "ac75e0acc3a0a232a5cdeb9271060d90cf1e5a2c"
65
+ "gitHead": "d0436ce9eed9cad0e64561cf0428b0e791c57058"
66
66
  }