@olane/o-lane 0.7.12-alpha.9 → 0.7.12
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/enums/o-capability.type-enum.d.ts +1 -0
- package/dist/src/capabilities/enums/o-capability.type-enum.d.ts.map +1 -1
- package/dist/src/capabilities/enums/o-capability.type-enum.js +1 -0
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts +4 -2
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +1 -1
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +1 -0
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.d.ts +3 -2
- package/dist/src/capabilities/o-capability.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 +33 -8
- package/dist/src/capabilities/o-capability.js +3 -0
- package/dist/src/capabilities/o-capability.result.d.ts +2 -0
- package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.result.js +2 -0
- package/dist/src/capabilities/utils/result-stream-parser.d.ts +37 -0
- package/dist/src/capabilities/utils/result-stream-parser.d.ts.map +1 -0
- package/dist/src/capabilities/utils/result-stream-parser.js +90 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +1 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -1
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts +2 -0
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -1
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +12 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +1 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.js +24 -6
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +1 -0
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +1 -1
- package/dist/src/capabilities-task/o-capability.task.d.ts.map +1 -1
- package/dist/src/capabilities-task/o-capability.task.js +4 -0
- package/dist/src/errors/capability-errors.d.ts +71 -0
- package/dist/src/errors/capability-errors.d.ts.map +1 -0
- package/dist/src/errors/capability-errors.js +142 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +4 -0
- package/dist/src/formatters/index.d.ts +7 -0
- package/dist/src/formatters/index.d.ts.map +1 -0
- package/dist/src/formatters/index.js +6 -0
- package/dist/src/formatters/markdown-builder.d.ts +65 -0
- package/dist/src/formatters/markdown-builder.d.ts.map +1 -0
- package/dist/src/formatters/markdown-builder.js +120 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/interfaces/o-lane.config.d.ts +5 -2
- package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
- package/dist/src/o-lane.d.ts +8 -1
- package/dist/src/o-lane.d.ts.map +1 -1
- package/dist/src/o-lane.js +165 -23
- package/dist/src/o-lane.mixin.d.ts +17 -0
- package/dist/src/o-lane.mixin.d.ts.map +1 -0
- package/dist/src/o-lane.mixin.js +136 -0
- package/dist/src/o-lane.tool.d.ts +12 -19
- package/dist/src/o-lane.tool.d.ts.map +1 -1
- package/dist/src/o-lane.tool.js +11 -93
- package/dist/src/prompts/agent.prompt.d.ts +11 -0
- package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
- package/dist/src/prompts/agent.prompt.js +34 -10
- package/dist/src/prompts/configure.prompt.d.ts +7 -0
- package/dist/src/prompts/configure.prompt.d.ts.map +1 -1
- package/dist/src/prompts/configure.prompt.js +8 -1
- package/dist/src/prompts/custom.prompt.d.ts +7 -0
- package/dist/src/prompts/custom.prompt.d.ts.map +1 -1
- package/dist/src/prompts/custom.prompt.js +77 -0
- package/dist/src/storage/index.d.ts +8 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +12 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.d.ts +102 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.d.ts.map +1 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.js +1 -0
- package/dist/src/storage/methods/prompt-storage.methods.d.ts +9 -0
- package/dist/src/storage/methods/prompt-storage.methods.d.ts.map +1 -0
- package/dist/src/storage/methods/prompt-storage.methods.js +338 -0
- package/dist/src/storage/prompt-loader.d.ts +40 -0
- package/dist/src/storage/prompt-loader.d.ts.map +1 -0
- package/dist/src/storage/prompt-loader.js +126 -0
- package/dist/src/storage/prompt-schema.d.ts +42 -0
- package/dist/src/storage/prompt-schema.d.ts.map +1 -0
- package/dist/src/storage/prompt-schema.js +29 -0
- package/dist/src/storage/prompt-seeder.d.ts +42 -0
- package/dist/src/storage/prompt-seeder.d.ts.map +1 -0
- package/dist/src/storage/prompt-seeder.js +141 -0
- package/dist/src/storage/prompt-storage-provider.tool.d.ts +99 -0
- package/dist/src/storage/prompt-storage-provider.tool.d.ts.map +1 -0
- package/dist/src/storage/prompt-storage-provider.tool.js +320 -0
- package/dist/test/prompt-seeder.spec.d.ts +2 -0
- package/dist/test/prompt-seeder.spec.d.ts.map +1 -0
- package/dist/test/prompt-seeder.spec.js +254 -0
- package/dist/test/prompt-storage-provider.spec.d.ts +2 -0
- package/dist/test/prompt-storage-provider.spec.d.ts.map +1 -0
- package/dist/test/prompt-storage-provider.spec.js +456 -0
- package/package.json +10 -7
- package/dist/test/ai.spec.d.ts +0 -2
- package/dist/test/ai.spec.d.ts.map +0 -1
- package/dist/test/ai.spec.js +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-capability.type-enum.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/enums/o-capability.type-enum.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB"}
|
|
1
|
+
{"version":3,"file":"o-capability.type-enum.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/enums/o-capability.type-enum.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,OAAO,YAAY;CACpB"}
|
|
@@ -7,5 +7,6 @@ export var oCapabilityType;
|
|
|
7
7
|
oCapabilityType["HANDSHAKE"] = "handshake";
|
|
8
8
|
oCapabilityType["EVALUATE"] = "evaluate";
|
|
9
9
|
oCapabilityType["STOP"] = "stop";
|
|
10
|
+
oCapabilityType["ERROR"] = "error";
|
|
10
11
|
oCapabilityType["UNKNOWN"] = "unknown";
|
|
11
12
|
})(oCapabilityType || (oCapabilityType = {}));
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { oIntent } from '../../intent/o-intent.js';
|
|
2
2
|
import { oLaneConfig } from '../../interfaces/o-lane.config.js';
|
|
3
|
-
import
|
|
3
|
+
import { oToolBase } from '@olane/o-tool';
|
|
4
4
|
export interface oCapabilityConfig {
|
|
5
|
-
node:
|
|
5
|
+
node: oToolBase;
|
|
6
6
|
intent: oIntent;
|
|
7
7
|
laneConfig: oLaneConfig;
|
|
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,
|
|
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,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAEhC,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"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { oObject } from '@olane/o-core';
|
|
2
|
+
import { oToolBase } from '@olane/o-tool';
|
|
2
3
|
import { oCapabilityConfig } from './interfaces/o-capability.config.js';
|
|
3
4
|
import { oCapabilityType } from './enums/o-capability.type-enum.js';
|
|
4
5
|
import { oCapabilityResult } from './o-capability.result.js';
|
|
5
|
-
import type { oLaneTool } from '../o-lane.tool.js';
|
|
6
6
|
import { oIntent } from '../intent/o-intent.js';
|
|
7
7
|
export declare abstract class oCapability extends oObject {
|
|
8
8
|
config: oCapabilityConfig;
|
|
9
9
|
abstract run(): Promise<oCapabilityResult>;
|
|
10
|
-
get node():
|
|
10
|
+
get node(): oToolBase;
|
|
11
11
|
execute(config: oCapabilityConfig): Promise<oCapabilityResult>;
|
|
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,
|
|
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,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,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,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":"
|
|
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;CAoE3E"}
|
|
@@ -1,30 +1,55 @@
|
|
|
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
|
|
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
|
|
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
|
-
|
|
36
|
+
// Extract structured fields from AI response
|
|
37
|
+
// The AI returns JSON with fields like: type, summary, reasoning, result, etc.
|
|
38
|
+
const { type, summary, reasoning, ...rest } = processedResult;
|
|
24
39
|
return new oCapabilityIntelligenceResult({
|
|
25
|
-
result: processedResult,
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
result: processedResult, // Keep full result for backwards compatibility
|
|
41
|
+
humanResult: processedResult.result, // AI-generated result is already human-readable
|
|
42
|
+
type: type || oCapabilityType.EVALUATE,
|
|
43
|
+
config: {
|
|
44
|
+
...this.config,
|
|
45
|
+
// Preserve summary and reasoning in params for access
|
|
46
|
+
params: {
|
|
47
|
+
...this.config.params,
|
|
48
|
+
...processedResult, // Store full AI response in params
|
|
49
|
+
summary,
|
|
50
|
+
reasoning,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
28
53
|
error: undefined,
|
|
29
54
|
});
|
|
30
55
|
}
|
|
@@ -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;
|
|
@@ -15,6 +16,7 @@ export declare class oCapabilityResult implements oCapabilityResultInterface {
|
|
|
15
16
|
toJSON(): {
|
|
16
17
|
id: string;
|
|
17
18
|
result: any;
|
|
19
|
+
humanResult: any;
|
|
18
20
|
type: oCapabilityType;
|
|
19
21
|
error: string | undefined;
|
|
20
22
|
shouldPersist: boolean | undefined;
|
|
@@ -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;
|
|
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;;;;;;;;;;;;;IAgBN,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;
|
|
@@ -13,6 +14,7 @@ export class oCapabilityResult {
|
|
|
13
14
|
return {
|
|
14
15
|
id: this.id,
|
|
15
16
|
result: this.result,
|
|
17
|
+
humanResult: this.humanResult, // Include human-readable result in serialization
|
|
16
18
|
type: this.type,
|
|
17
19
|
error: this.error,
|
|
18
20
|
shouldPersist: this.shouldPersist,
|
|
@@ -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
|
+
}
|
package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map
CHANGED
|
@@ -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;
|
|
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;
|
|
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;IAuBvC,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
|
}
|
|
@@ -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;
|
|
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;
|
|
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;IAwBtB,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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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,
|
|
98
116
|
type: oCapabilityType.EVALUATE,
|
|
99
117
|
config: this.config,
|
|
100
118
|
});
|
|
@@ -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;
|
|
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;
|
|
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,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error types for capability execution
|
|
3
|
+
*/
|
|
4
|
+
export declare enum CapabilityErrorType {
|
|
5
|
+
NOT_FOUND = "not_found",
|
|
6
|
+
UNAUTHORIZED = "unauthorized",
|
|
7
|
+
FORBIDDEN = "forbidden",
|
|
8
|
+
INVALID_CONFIG = "invalid_config",
|
|
9
|
+
MISSING_PARAMETER = "missing_parameter",
|
|
10
|
+
INVALID_PARAMETER = "invalid_parameter",
|
|
11
|
+
TOOL_ERROR = "tool_error",
|
|
12
|
+
TIMEOUT = "timeout",
|
|
13
|
+
NETWORK_ERROR = "network_error",
|
|
14
|
+
INVALID_STATE = "invalid_state",
|
|
15
|
+
RESOURCE_EXHAUSTED = "resource_exhausted",
|
|
16
|
+
UNKNOWN = "unknown"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Context information for capability errors
|
|
20
|
+
*/
|
|
21
|
+
export interface CapabilityErrorContext {
|
|
22
|
+
/** The cycle number where the error occurred */
|
|
23
|
+
cycle?: number;
|
|
24
|
+
/** The capability type that failed */
|
|
25
|
+
capabilityType?: string;
|
|
26
|
+
/** The tool address that was being used */
|
|
27
|
+
toolAddress?: string;
|
|
28
|
+
/** The method that was being called */
|
|
29
|
+
method?: string;
|
|
30
|
+
/** Additional context data */
|
|
31
|
+
data?: any;
|
|
32
|
+
/** The user's original intent */
|
|
33
|
+
intent?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Structured capability error with context and remediation suggestions
|
|
37
|
+
*/
|
|
38
|
+
export declare class CapabilityError extends Error {
|
|
39
|
+
readonly type: CapabilityErrorType;
|
|
40
|
+
readonly context: CapabilityErrorContext;
|
|
41
|
+
readonly originalError?: Error;
|
|
42
|
+
constructor(type: CapabilityErrorType, message: string, context?: CapabilityErrorContext, originalError?: Error);
|
|
43
|
+
/**
|
|
44
|
+
* Get a human-readable error message with context
|
|
45
|
+
*/
|
|
46
|
+
toHumanReadable(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get a friendly label for the error type
|
|
49
|
+
*/
|
|
50
|
+
private getErrorTypeLabel;
|
|
51
|
+
/**
|
|
52
|
+
* Get remediation suggestion based on error type
|
|
53
|
+
*/
|
|
54
|
+
private getRemediation;
|
|
55
|
+
/**
|
|
56
|
+
* Convert to JSON for serialization
|
|
57
|
+
*/
|
|
58
|
+
toJSON(): {
|
|
59
|
+
name: string;
|
|
60
|
+
type: CapabilityErrorType;
|
|
61
|
+
message: string;
|
|
62
|
+
context: CapabilityErrorContext;
|
|
63
|
+
humanReadable: string;
|
|
64
|
+
stack: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Create a CapabilityError from a generic error
|
|
68
|
+
*/
|
|
69
|
+
static from(error: Error | any, context?: CapabilityErrorContext): CapabilityError;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=capability-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/capability-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,mBAAmB;IAE7B,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IAGvB,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IAGvC,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAG/B,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IAGzC,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,OAAO,EAAE,sBAAsB,CAAC;IAChD,SAAgB,aAAa,CAAC,EAAE,KAAK,CAAC;gBAGpC,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,sBAA2B,EACpC,aAAa,CAAC,EAAE,KAAK;IAcvB;;OAEG;IACH,eAAe,IAAI,MAAM;IA2BzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAyBtB;;OAEG;IACH,MAAM;;;;;;;;IAWN;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,KAAK,GAAG,GAAG,EAClB,OAAO,GAAE,sBAA2B,GACnC,eAAe;CA8BnB"}
|