@olane/o-lane 0.7.12-alpha.3 → 0.7.12-alpha.30
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.
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts +2 -0
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.js +13 -5
- package/dist/src/capabilities/utils/result-stream-parser.d.ts +32 -0
- package/dist/src/capabilities/utils/result-stream-parser.d.ts.map +1 -0
- package/dist/src/capabilities/utils/result-stream-parser.js +85 -0
- package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.js +12 -4
- package/dist/src/capabilities-task/o-capability.task.d.ts.map +1 -1
- package/dist/src/capabilities-task/o-capability.task.js +3 -0
- package/dist/src/interfaces/o-lane.config.d.ts +2 -0
- package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
- package/dist/src/o-lane.d.ts +1 -0
- package/dist/src/o-lane.d.ts.map +1 -1
- package/dist/src/o-lane.js +4 -0
- package/dist/src/o-lane.tool.d.ts +2 -2
- package/dist/src/o-lane.tool.d.ts.map +1 -1
- package/dist/src/o-lane.tool.js +10 -5
- package/package.json +7 -7
|
@@ -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;
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-capability.intelligence.d.ts","sourceRoot":"","sources":["../../../src/capabilities/o-capability.intelligence.ts"],"names":[],"mappings":"
|
|
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;CAkD3E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { oAddress, RegexUtils, RestrictedAddresses } from '@olane/o-core';
|
|
1
|
+
import { oAddress, oResponse, 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';
|
|
@@ -8,19 +8,27 @@ export class oCapabilityIntelligence extends oCapability {
|
|
|
8
8
|
if (!this.node.isRunning) {
|
|
9
9
|
throw new Error('Node is not running, cannot use intelligence capability');
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const _isStreaming = this.config.useStream || false;
|
|
12
|
+
const response = await this.node.useStream(new oAddress(RestrictedAddresses.INTELLIGENCE), {
|
|
12
13
|
method: 'prompt',
|
|
13
14
|
params: {
|
|
14
15
|
prompt: prompt,
|
|
16
|
+
_isStreaming: _isStreaming,
|
|
17
|
+
},
|
|
18
|
+
}, {
|
|
19
|
+
onChunk: (chunk) => {
|
|
20
|
+
if (this.config.onChunk) {
|
|
21
|
+
// Emit only the result field content
|
|
22
|
+
this.config.onChunk(oResponse.fromJSON(chunk));
|
|
23
|
+
}
|
|
15
24
|
},
|
|
16
25
|
});
|
|
17
|
-
const
|
|
18
|
-
const message = data.message;
|
|
26
|
+
const message = response.result.data.message;
|
|
19
27
|
if (!message) {
|
|
20
28
|
throw new Error('No message returned from intelligence');
|
|
21
29
|
}
|
|
30
|
+
// Use the parsed result value if available, otherwise fall back to full message
|
|
22
31
|
const processedResult = RegexUtils.extractResultFromAI(message);
|
|
23
|
-
this.logger.debug('Processed result: ', processedResult);
|
|
24
32
|
return new oCapabilityIntelligenceResult({
|
|
25
33
|
result: processedResult,
|
|
26
34
|
type: processedResult.type,
|
|
@@ -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;
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { oAddress } from '@olane/o-core';
|
|
1
|
+
import { oAddress, oResponse } 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';
|
|
@@ -19,7 +19,8 @@ export class oCapabilitySearch extends oCapability {
|
|
|
19
19
|
return this.config.params.explanation;
|
|
20
20
|
}
|
|
21
21
|
async doExternalSearch(query) {
|
|
22
|
-
|
|
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?.(oResponse.fromJSON(chunk));
|
|
38
|
+
},
|
|
33
39
|
});
|
|
34
|
-
|
|
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;
|
|
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) {
|
|
@@ -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,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,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;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/src/o-lane.d.ts
CHANGED
package/dist/src/o-lane.d.ts.map
CHANGED
|
@@ -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;
|
|
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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AG,SAAS,CAAC;IAwEjE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAS9B,IAAI,IAAI,yCAEP;CACF"}
|
package/dist/src/o-lane.js
CHANGED
|
@@ -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);
|
|
@@ -137,6 +138,7 @@ export class oLane extends oObject {
|
|
|
137
138
|
...this.config,
|
|
138
139
|
sequence: this.sequence, // pass the full sequence to the next capability
|
|
139
140
|
},
|
|
141
|
+
useStream: this.config.useStream || false,
|
|
140
142
|
};
|
|
141
143
|
}
|
|
142
144
|
async doCapability(currentStep) {
|
|
@@ -144,8 +146,10 @@ export class oLane extends oObject {
|
|
|
144
146
|
for (const capability of this.capabilities) {
|
|
145
147
|
if (capability.type === capabilityType && currentStep.config) {
|
|
146
148
|
const capabilityConfig = this.resultToConfig(currentStep);
|
|
149
|
+
this.logger.debug('Executing capability: ', capabilityType);
|
|
147
150
|
const result = await capability.execute({
|
|
148
151
|
...capabilityConfig,
|
|
152
|
+
onChunk: this.onChunk,
|
|
149
153
|
});
|
|
150
154
|
return result;
|
|
151
155
|
}
|
|
@@ -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:
|
|
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,
|
|
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"}
|
package/dist/src/o-lane.tool.js
CHANGED
|
@@ -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,25 @@ 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
|
+
onChunk: _isStreaming
|
|
44
|
+
? async (chunk) => {
|
|
45
|
+
await CoreUtils.sendStreamResponse(oResponse.fromJSON(chunk), request.stream);
|
|
46
|
+
}
|
|
47
|
+
: undefined,
|
|
43
48
|
context: context
|
|
44
49
|
? new oLaneContext([
|
|
45
50
|
`[Chat History Context Begin]\n${context}\n[Chat History Context End]`,
|
|
46
51
|
])
|
|
47
52
|
: undefined,
|
|
48
53
|
});
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
let response;
|
|
55
|
+
response = await pc.execute();
|
|
51
56
|
return {
|
|
52
57
|
result: response?.result,
|
|
53
58
|
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.
|
|
3
|
+
"version": "0.7.12-alpha.30",
|
|
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": "
|
|
58
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
59
|
-
"@olane/o-node": "0.7.12-alpha.
|
|
60
|
-
"@olane/o-protocol": "
|
|
61
|
-
"@olane/o-tool": "0.7.12-alpha.
|
|
57
|
+
"@olane/o-config": "0.7.12-alpha.30",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.30",
|
|
59
|
+
"@olane/o-node": "0.7.12-alpha.30",
|
|
60
|
+
"@olane/o-protocol": "0.7.12-alpha.30",
|
|
61
|
+
"@olane/o-tool": "0.7.12-alpha.30",
|
|
62
62
|
"debug": "^4.4.1",
|
|
63
63
|
"dotenv": "^16.5.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "066e6bda19e79a744779a797664481476b0ea655"
|
|
66
66
|
}
|