@olane/o-lane 0.7.12-alpha.57 → 0.7.12-alpha.59
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/o-capability.intelligence.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.js +16 -3
- package/dist/src/capabilities/o-capability.result.d.ts +1 -0
- package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.result.js +1 -0
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.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 +1 -1
- 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/o-lane.d.ts +5 -0
- package/dist/src/o-lane.d.ts.map +1 -1
- package/dist/src/o-lane.js +113 -13
- package/dist/src/o-lane.tool.d.ts.map +1 -1
- package/dist/src/o-lane.tool.js +2 -0
- package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
- package/dist/src/prompts/agent.prompt.js +11 -5
- package/package.json +7 -7
|
@@ -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 +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;AAIhD,8BAAsB,uBAAwB,SAAQ,WAAW;IACzD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;
|
|
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"}
|
|
@@ -33,10 +33,23 @@ export class oCapabilityIntelligence extends oCapability {
|
|
|
33
33
|
}
|
|
34
34
|
// Use the parsed result value if available, otherwise fall back to full message
|
|
35
35
|
const processedResult = RegexUtils.extractResultFromAI(message);
|
|
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;
|
|
36
39
|
return new oCapabilityIntelligenceResult({
|
|
37
|
-
result: processedResult,
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
},
|
|
40
53
|
error: undefined,
|
|
41
54
|
});
|
|
42
55
|
}
|
|
@@ -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,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
|
|
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"}
|
|
@@ -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;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;
|
|
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"}
|
|
@@ -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;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;
|
|
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"}
|
|
@@ -112,7 +112,7 @@ export class oCapabilitySearch extends oCapability {
|
|
|
112
112
|
searchResultContext += `[Search Results End]`;
|
|
113
113
|
return new oCapabilitySearchResult({
|
|
114
114
|
result: searchResultContext,
|
|
115
|
-
humanResult: searchResults
|
|
115
|
+
humanResult: searchResults,
|
|
116
116
|
type: oCapabilityType.EVALUATE,
|
|
117
117
|
config: this.config,
|
|
118
118
|
});
|
|
@@ -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"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error types for capability execution
|
|
3
|
+
*/
|
|
4
|
+
export var CapabilityErrorType;
|
|
5
|
+
(function (CapabilityErrorType) {
|
|
6
|
+
// Tool/Resource errors
|
|
7
|
+
CapabilityErrorType["NOT_FOUND"] = "not_found";
|
|
8
|
+
CapabilityErrorType["UNAUTHORIZED"] = "unauthorized";
|
|
9
|
+
CapabilityErrorType["FORBIDDEN"] = "forbidden";
|
|
10
|
+
// Configuration errors
|
|
11
|
+
CapabilityErrorType["INVALID_CONFIG"] = "invalid_config";
|
|
12
|
+
CapabilityErrorType["MISSING_PARAMETER"] = "missing_parameter";
|
|
13
|
+
CapabilityErrorType["INVALID_PARAMETER"] = "invalid_parameter";
|
|
14
|
+
// Execution errors
|
|
15
|
+
CapabilityErrorType["TOOL_ERROR"] = "tool_error";
|
|
16
|
+
CapabilityErrorType["TIMEOUT"] = "timeout";
|
|
17
|
+
CapabilityErrorType["NETWORK_ERROR"] = "network_error";
|
|
18
|
+
// State errors
|
|
19
|
+
CapabilityErrorType["INVALID_STATE"] = "invalid_state";
|
|
20
|
+
CapabilityErrorType["RESOURCE_EXHAUSTED"] = "resource_exhausted";
|
|
21
|
+
// Unknown
|
|
22
|
+
CapabilityErrorType["UNKNOWN"] = "unknown";
|
|
23
|
+
})(CapabilityErrorType || (CapabilityErrorType = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Structured capability error with context and remediation suggestions
|
|
26
|
+
*/
|
|
27
|
+
export class CapabilityError extends Error {
|
|
28
|
+
constructor(type, message, context = {}, originalError) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = 'CapabilityError';
|
|
31
|
+
this.type = type;
|
|
32
|
+
this.context = context;
|
|
33
|
+
this.originalError = originalError;
|
|
34
|
+
// Maintain proper stack trace
|
|
35
|
+
if (Error.captureStackTrace) {
|
|
36
|
+
Error.captureStackTrace(this, CapabilityError);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get a human-readable error message with context
|
|
41
|
+
*/
|
|
42
|
+
toHumanReadable() {
|
|
43
|
+
let message = `${this.getErrorTypeLabel()}: ${this.message}`;
|
|
44
|
+
if (this.context.cycle !== undefined) {
|
|
45
|
+
message += `\n\nOccurred in Cycle ${this.context.cycle}`;
|
|
46
|
+
}
|
|
47
|
+
if (this.context.capabilityType) {
|
|
48
|
+
message += `\nCapability: ${this.context.capabilityType}`;
|
|
49
|
+
}
|
|
50
|
+
if (this.context.toolAddress) {
|
|
51
|
+
message += `\nTool: ${this.context.toolAddress}`;
|
|
52
|
+
}
|
|
53
|
+
if (this.context.method) {
|
|
54
|
+
message += `\nMethod: ${this.context.method}`;
|
|
55
|
+
}
|
|
56
|
+
const remediation = this.getRemediation();
|
|
57
|
+
if (remediation) {
|
|
58
|
+
message += `\n\nSuggestion: ${remediation}`;
|
|
59
|
+
}
|
|
60
|
+
return message;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get a friendly label for the error type
|
|
64
|
+
*/
|
|
65
|
+
getErrorTypeLabel() {
|
|
66
|
+
const labels = {
|
|
67
|
+
[CapabilityErrorType.NOT_FOUND]: 'Resource Not Found',
|
|
68
|
+
[CapabilityErrorType.UNAUTHORIZED]: 'Unauthorized',
|
|
69
|
+
[CapabilityErrorType.FORBIDDEN]: 'Forbidden',
|
|
70
|
+
[CapabilityErrorType.INVALID_CONFIG]: 'Invalid Configuration',
|
|
71
|
+
[CapabilityErrorType.MISSING_PARAMETER]: 'Missing Parameter',
|
|
72
|
+
[CapabilityErrorType.INVALID_PARAMETER]: 'Invalid Parameter',
|
|
73
|
+
[CapabilityErrorType.TOOL_ERROR]: 'Tool Execution Error',
|
|
74
|
+
[CapabilityErrorType.TIMEOUT]: 'Timeout',
|
|
75
|
+
[CapabilityErrorType.NETWORK_ERROR]: 'Network Error',
|
|
76
|
+
[CapabilityErrorType.INVALID_STATE]: 'Invalid State',
|
|
77
|
+
[CapabilityErrorType.RESOURCE_EXHAUSTED]: 'Resource Exhausted',
|
|
78
|
+
[CapabilityErrorType.UNKNOWN]: 'Unknown Error',
|
|
79
|
+
};
|
|
80
|
+
return labels[this.type] || 'Error';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get remediation suggestion based on error type
|
|
84
|
+
*/
|
|
85
|
+
getRemediation() {
|
|
86
|
+
const remediations = {
|
|
87
|
+
[CapabilityErrorType.NOT_FOUND]: 'Verify the tool address exists and is accessible. Use search to find available tools.',
|
|
88
|
+
[CapabilityErrorType.UNAUTHORIZED]: 'Check that you have the necessary permissions to access this resource.',
|
|
89
|
+
[CapabilityErrorType.INVALID_CONFIG]: 'Review the configuration parameters and ensure they match the required format.',
|
|
90
|
+
[CapabilityErrorType.MISSING_PARAMETER]: 'Provide all required parameters. Use the tool\'s handshake to see parameter requirements.',
|
|
91
|
+
[CapabilityErrorType.INVALID_PARAMETER]: 'Check that parameter values match the expected types and constraints.',
|
|
92
|
+
[CapabilityErrorType.TOOL_ERROR]: 'Review the tool\'s error message and adjust your request accordingly.',
|
|
93
|
+
[CapabilityErrorType.TIMEOUT]: 'The operation took too long. Try simplifying the request or increasing the timeout.',
|
|
94
|
+
[CapabilityErrorType.NETWORK_ERROR]: 'Check your network connection and try again.',
|
|
95
|
+
[CapabilityErrorType.RESOURCE_EXHAUSTED]: 'You may have hit a rate limit or resource quota. Try again later.',
|
|
96
|
+
};
|
|
97
|
+
return remediations[this.type] || null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Convert to JSON for serialization
|
|
101
|
+
*/
|
|
102
|
+
toJSON() {
|
|
103
|
+
return {
|
|
104
|
+
name: this.name,
|
|
105
|
+
type: this.type,
|
|
106
|
+
message: this.message,
|
|
107
|
+
context: this.context,
|
|
108
|
+
humanReadable: this.toHumanReadable(),
|
|
109
|
+
stack: this.stack,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a CapabilityError from a generic error
|
|
114
|
+
*/
|
|
115
|
+
static from(error, context = {}) {
|
|
116
|
+
if (error instanceof CapabilityError) {
|
|
117
|
+
return error;
|
|
118
|
+
}
|
|
119
|
+
// Try to infer error type from message
|
|
120
|
+
let type = CapabilityErrorType.UNKNOWN;
|
|
121
|
+
const message = error?.message || String(error);
|
|
122
|
+
if (message.includes('not found') || message.includes('404')) {
|
|
123
|
+
type = CapabilityErrorType.NOT_FOUND;
|
|
124
|
+
}
|
|
125
|
+
else if (message.includes('unauthorized') || message.includes('401')) {
|
|
126
|
+
type = CapabilityErrorType.UNAUTHORIZED;
|
|
127
|
+
}
|
|
128
|
+
else if (message.includes('forbidden') || message.includes('403')) {
|
|
129
|
+
type = CapabilityErrorType.FORBIDDEN;
|
|
130
|
+
}
|
|
131
|
+
else if (message.includes('timeout')) {
|
|
132
|
+
type = CapabilityErrorType.TIMEOUT;
|
|
133
|
+
}
|
|
134
|
+
else if (message.includes('network') || message.includes('ECONNREFUSED')) {
|
|
135
|
+
type = CapabilityErrorType.NETWORK_ERROR;
|
|
136
|
+
}
|
|
137
|
+
else if (message.includes('parameter') || message.includes('config')) {
|
|
138
|
+
type = CapabilityErrorType.INVALID_CONFIG;
|
|
139
|
+
}
|
|
140
|
+
return new CapabilityError(type, message, context, error instanceof Error ? error : undefined);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for programmatic markdown generation
|
|
3
|
+
* Used only for system-generated content like execution traces
|
|
4
|
+
* AI-generated responses handle their own formatting via prompts
|
|
5
|
+
*/
|
|
6
|
+
export { MarkdownBuilder } from './markdown-builder.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatters/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class for building markdown formatted strings
|
|
3
|
+
* Used for programmatic content generation (execution traces, etc.)
|
|
4
|
+
* NOT used for AI-generated responses - AI handles its own formatting
|
|
5
|
+
*/
|
|
6
|
+
export declare class MarkdownBuilder {
|
|
7
|
+
private parts;
|
|
8
|
+
/**
|
|
9
|
+
* Add a header
|
|
10
|
+
*/
|
|
11
|
+
header(text: string, level?: number): this;
|
|
12
|
+
/**
|
|
13
|
+
* Add a paragraph
|
|
14
|
+
*/
|
|
15
|
+
paragraph(text: string): this;
|
|
16
|
+
/**
|
|
17
|
+
* Add a bulleted list
|
|
18
|
+
*/
|
|
19
|
+
list(items: string[], ordered?: boolean): this;
|
|
20
|
+
/**
|
|
21
|
+
* Add a code block
|
|
22
|
+
*/
|
|
23
|
+
code(content: string, language?: string): this;
|
|
24
|
+
/**
|
|
25
|
+
* Add inline code
|
|
26
|
+
*/
|
|
27
|
+
inline(text: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Add bold text
|
|
30
|
+
*/
|
|
31
|
+
bold(text: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Add italic text
|
|
34
|
+
*/
|
|
35
|
+
italic(text: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Add a link
|
|
38
|
+
*/
|
|
39
|
+
link(text: string, url: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Add a collapsible details section
|
|
42
|
+
*/
|
|
43
|
+
details(summary: string, content: string): this;
|
|
44
|
+
/**
|
|
45
|
+
* Add a horizontal rule
|
|
46
|
+
*/
|
|
47
|
+
hr(): this;
|
|
48
|
+
/**
|
|
49
|
+
* Add raw text without additional spacing
|
|
50
|
+
*/
|
|
51
|
+
raw(text: string): this;
|
|
52
|
+
/**
|
|
53
|
+
* Add a line break
|
|
54
|
+
*/
|
|
55
|
+
br(): this;
|
|
56
|
+
/**
|
|
57
|
+
* Build the final markdown string
|
|
58
|
+
*/
|
|
59
|
+
build(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new builder instance
|
|
62
|
+
*/
|
|
63
|
+
static create(): MarkdownBuilder;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=markdown-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-builder.d.ts","sourceRoot":"","sources":["../../../src/formatters/markdown-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAgB;IAE7B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,IAAI;IAO7C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQ7B;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,OAAe,GAAG,IAAI;IASrD;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAW,GAAG,IAAI;IAQlD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI5B;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI1B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI5B;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIvC;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAU/C;;OAEG;IACH,EAAE,IAAI,IAAI;IAMV;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKvB;;OAEG;IACH,EAAE,IAAI,IAAI;IAKV;;OAEG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,eAAe;CAGjC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class for building markdown formatted strings
|
|
3
|
+
* Used for programmatic content generation (execution traces, etc.)
|
|
4
|
+
* NOT used for AI-generated responses - AI handles its own formatting
|
|
5
|
+
*/
|
|
6
|
+
export class MarkdownBuilder {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.parts = [];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Add a header
|
|
12
|
+
*/
|
|
13
|
+
header(text, level = 1) {
|
|
14
|
+
const prefix = '#'.repeat(Math.max(1, Math.min(6, level)));
|
|
15
|
+
this.parts.push(`${prefix} ${text}`);
|
|
16
|
+
this.parts.push('');
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Add a paragraph
|
|
21
|
+
*/
|
|
22
|
+
paragraph(text) {
|
|
23
|
+
if (text) {
|
|
24
|
+
this.parts.push(text);
|
|
25
|
+
this.parts.push('');
|
|
26
|
+
}
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Add a bulleted list
|
|
31
|
+
*/
|
|
32
|
+
list(items, ordered = false) {
|
|
33
|
+
items.forEach((item, idx) => {
|
|
34
|
+
const prefix = ordered ? `${idx + 1}. ` : '- ';
|
|
35
|
+
this.parts.push(`${prefix}${item}`);
|
|
36
|
+
});
|
|
37
|
+
this.parts.push('');
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Add a code block
|
|
42
|
+
*/
|
|
43
|
+
code(content, language = '') {
|
|
44
|
+
this.parts.push(`\`\`\`${language}`);
|
|
45
|
+
this.parts.push(content);
|
|
46
|
+
this.parts.push('```');
|
|
47
|
+
this.parts.push('');
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Add inline code
|
|
52
|
+
*/
|
|
53
|
+
inline(text) {
|
|
54
|
+
return `\`${text}\``;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Add bold text
|
|
58
|
+
*/
|
|
59
|
+
bold(text) {
|
|
60
|
+
return `**${text}**`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add italic text
|
|
64
|
+
*/
|
|
65
|
+
italic(text) {
|
|
66
|
+
return `*${text}*`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Add a link
|
|
70
|
+
*/
|
|
71
|
+
link(text, url) {
|
|
72
|
+
return `[${text}](${url})`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add a collapsible details section
|
|
76
|
+
*/
|
|
77
|
+
details(summary, content) {
|
|
78
|
+
this.parts.push('<details>');
|
|
79
|
+
this.parts.push(`<summary>${summary}</summary>`);
|
|
80
|
+
this.parts.push('');
|
|
81
|
+
this.parts.push(content);
|
|
82
|
+
this.parts.push('</details>');
|
|
83
|
+
this.parts.push('');
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Add a horizontal rule
|
|
88
|
+
*/
|
|
89
|
+
hr() {
|
|
90
|
+
this.parts.push('---');
|
|
91
|
+
this.parts.push('');
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Add raw text without additional spacing
|
|
96
|
+
*/
|
|
97
|
+
raw(text) {
|
|
98
|
+
this.parts.push(text);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Add a line break
|
|
103
|
+
*/
|
|
104
|
+
br() {
|
|
105
|
+
this.parts.push('');
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Build the final markdown string
|
|
110
|
+
*/
|
|
111
|
+
build() {
|
|
112
|
+
return this.parts.join('\n').trim();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a new builder instance
|
|
116
|
+
*/
|
|
117
|
+
static create() {
|
|
118
|
+
return new MarkdownBuilder();
|
|
119
|
+
}
|
|
120
|
+
}
|
package/dist/src/o-lane.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export declare class oLane extends oObject {
|
|
|
28
28
|
toCID(): Promise<CID>;
|
|
29
29
|
store(): Promise<CID>;
|
|
30
30
|
get agentHistory(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate a human-readable execution trace of the lane
|
|
33
|
+
* Shows the decision points and flow of execution
|
|
34
|
+
*/
|
|
35
|
+
getExecutionTrace(): string;
|
|
31
36
|
preflight(): Promise<void>;
|
|
32
37
|
execute(): Promise<oCapabilityResult | undefined>;
|
|
33
38
|
get capabilities(): import("./capabilities/o-capability.js").oCapability[];
|
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,EAGR,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;
|
|
1
|
+
{"version":3,"file":"o-lane.d.ts","sourceRoot":"","sources":["../../src/o-lane.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAGR,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;AAIjC,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,WA8Df;IAED;;;OAGG;IACH,iBAAiB,IAAI,MAAM;IA+DrB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAW1B,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IA4BvD,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;IAsDzC,MAAM;IASN;;;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"}
|
package/dist/src/o-lane.js
CHANGED
|
@@ -7,6 +7,7 @@ import { oIntentEncoder } from './intent-encoder/index.js';
|
|
|
7
7
|
import { oLaneStatus } from './enum/o-lane.status-enum.js';
|
|
8
8
|
import { oCapabilityResult, oCapabilityType, } from './capabilities/index.js';
|
|
9
9
|
import { ALL_CAPABILITIES } from './capabilities-all/o-capability.all.js';
|
|
10
|
+
import { MarkdownBuilder } from './formatters/index.js';
|
|
10
11
|
export class oLane extends oObject {
|
|
11
12
|
constructor(config) {
|
|
12
13
|
super('o-lane:' + `[${config.intent.value}]`);
|
|
@@ -85,36 +86,135 @@ export class oLane extends oObject {
|
|
|
85
86
|
}
|
|
86
87
|
get agentHistory() {
|
|
87
88
|
const added = {};
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
const MAX_RESULT_LENGTH = 1000; // Truncate large results
|
|
90
|
+
const KEEP_FULL_DETAIL_COUNT = 3; // Keep full detail for last N cycles
|
|
91
|
+
const filteredSequence = this.sequence?.filter((s) => {
|
|
90
92
|
if (added[s.id]) {
|
|
91
93
|
return false;
|
|
92
94
|
}
|
|
93
95
|
added[s.id] = true;
|
|
94
96
|
return true;
|
|
95
|
-
})
|
|
97
|
+
});
|
|
98
|
+
return (filteredSequence
|
|
96
99
|
?.map((s, index) => {
|
|
100
|
+
const isRecent = index >= filteredSequence.length - KEEP_FULL_DETAIL_COUNT;
|
|
97
101
|
const result = s.result || s.error;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
const params = s.config?.params || {};
|
|
103
|
+
// Extract summary and reasoning if available
|
|
104
|
+
const summary = params.summary || '';
|
|
105
|
+
const reasoning = params.reasoning || '';
|
|
106
|
+
// Format result, truncating if not a recent cycle
|
|
107
|
+
let formattedResult;
|
|
108
|
+
if (typeof result === 'string') {
|
|
109
|
+
formattedResult =
|
|
110
|
+
isRecent || result.length <= MAX_RESULT_LENGTH
|
|
111
|
+
? result
|
|
112
|
+
: result.substring(0, MAX_RESULT_LENGTH) + '... (truncated)';
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const jsonStr = JSON.stringify(result, null, 2);
|
|
116
|
+
formattedResult =
|
|
117
|
+
isRecent || jsonStr.length <= MAX_RESULT_LENGTH
|
|
118
|
+
? jsonStr
|
|
119
|
+
: jsonStr.substring(0, MAX_RESULT_LENGTH) + '... (truncated)';
|
|
120
|
+
}
|
|
121
|
+
// Build formatted history entry
|
|
122
|
+
let entry = `[Cycle ${index + 1}: ${s.type}]\n`;
|
|
123
|
+
entry += `Intent: ${s.config?.intent.toString()}\n`;
|
|
124
|
+
if (summary) {
|
|
125
|
+
entry += `Summary: ${summary}\n`;
|
|
126
|
+
}
|
|
127
|
+
if (reasoning) {
|
|
128
|
+
entry += `Reasoning: ${reasoning}\n`;
|
|
129
|
+
}
|
|
130
|
+
if (s.error) {
|
|
131
|
+
entry += `Error: ${s.error}\n`;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
entry += `Result: ${formattedResult}\n`;
|
|
135
|
+
}
|
|
136
|
+
return entry;
|
|
106
137
|
})
|
|
107
138
|
.join('\n') || '');
|
|
108
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Generate a human-readable execution trace of the lane
|
|
142
|
+
* Shows the decision points and flow of execution
|
|
143
|
+
*/
|
|
144
|
+
getExecutionTrace() {
|
|
145
|
+
const mb = MarkdownBuilder.create();
|
|
146
|
+
mb.header('Execution Trace', 2);
|
|
147
|
+
mb.paragraph(`Intent: ${this.config.intent.value}`);
|
|
148
|
+
mb.paragraph(`Cycles: ${this.sequence.length}`);
|
|
149
|
+
mb.paragraph(`Status: ${this.status}`);
|
|
150
|
+
if (this.sequence.length === 0) {
|
|
151
|
+
mb.paragraph('No execution cycles recorded.');
|
|
152
|
+
return mb.build();
|
|
153
|
+
}
|
|
154
|
+
mb.br();
|
|
155
|
+
mb.header('Cycle Details', 3);
|
|
156
|
+
this.sequence.forEach((step, index) => {
|
|
157
|
+
const params = step.config?.params || {};
|
|
158
|
+
const summary = params.summary || '';
|
|
159
|
+
const reasoning = params.reasoning || '';
|
|
160
|
+
mb.br();
|
|
161
|
+
mb.raw(`${mb.bold(`Cycle ${index + 1}`)} [${step.type}]`);
|
|
162
|
+
if (summary) {
|
|
163
|
+
mb.raw(`\n└─ ${mb.italic('Summary:')} ${summary}`);
|
|
164
|
+
}
|
|
165
|
+
if (reasoning) {
|
|
166
|
+
mb.raw(`\n└─ ${mb.italic('Reasoning:')} ${reasoning}`);
|
|
167
|
+
}
|
|
168
|
+
if (step.error) {
|
|
169
|
+
mb.raw(`\n└─ ❌ ${mb.bold('Error:')} ${step.error}`);
|
|
170
|
+
}
|
|
171
|
+
else if (step.type === oCapabilityType.STOP) {
|
|
172
|
+
mb.raw(`\n└─ ✓ ${mb.bold('Completed')}`);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
// Add final result summary
|
|
176
|
+
if (this.result) {
|
|
177
|
+
mb.br();
|
|
178
|
+
mb.hr();
|
|
179
|
+
mb.header('Final Result', 3);
|
|
180
|
+
const resultParams = this.result.config?.params || {};
|
|
181
|
+
const finalSummary = resultParams.summary || '';
|
|
182
|
+
if (finalSummary) {
|
|
183
|
+
mb.paragraph(finalSummary);
|
|
184
|
+
}
|
|
185
|
+
if (this.result.error) {
|
|
186
|
+
mb.paragraph(`${mb.bold('Status:')} Failed`);
|
|
187
|
+
mb.paragraph(`${mb.bold('Error:')} ${this.result.error}`);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
mb.paragraph(`${mb.bold('Status:')} Success`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return mb.build();
|
|
194
|
+
}
|
|
109
195
|
async preflight() {
|
|
110
196
|
this.logger.debug('Preflight...');
|
|
111
197
|
this.status = oLaneStatus.PREFLIGHT;
|
|
198
|
+
this.logger.debug('Pinging intelligence tool...');
|
|
199
|
+
// ping the intelligence tool to ensure it is available
|
|
200
|
+
await this.node.use(new oAddress('o://intelligence'), {
|
|
201
|
+
method: 'ping',
|
|
202
|
+
params: {},
|
|
203
|
+
});
|
|
112
204
|
}
|
|
113
205
|
async execute() {
|
|
114
206
|
this.logger.debug('Executing...');
|
|
115
|
-
await this.preflight();
|
|
116
|
-
this.status = oLaneStatus.RUNNING;
|
|
117
207
|
try {
|
|
208
|
+
await this.preflight().catch((error) => {
|
|
209
|
+
this.logger.error('Error in preflight: ', error);
|
|
210
|
+
this.result = new oCapabilityResult({
|
|
211
|
+
type: oCapabilityType.ERROR,
|
|
212
|
+
result: null,
|
|
213
|
+
error: 'Intelligence services are not available. Try again later.',
|
|
214
|
+
});
|
|
215
|
+
throw new oError(oErrorCodes.INVALID_STATE, 'Intelligence services are not available. Try again later.');
|
|
216
|
+
});
|
|
217
|
+
this.status = oLaneStatus.RUNNING;
|
|
118
218
|
this.result = await this.loop();
|
|
119
219
|
}
|
|
120
220
|
catch (error) {
|
|
@@ -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;AAQzD,qBAAa,SAAU,SAAQ,SAAS;IACtC,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,EAAE,WAAW;IAKzB,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBrE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"o-lane.tool.d.ts","sourceRoot":"","sources":["../../src/o-lane.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAa,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,WAAW,EACX,SAAS,EACT,cAAc,EAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,qBAAa,SAAU,SAAQ,SAAS;IACtC,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,EAAE,WAAW;IAKzB,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBrE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAmDzD;;;;;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
|
@@ -62,6 +62,8 @@ export class oLaneTool extends oNodeTool {
|
|
|
62
62
|
response = await pc.execute();
|
|
63
63
|
const completeResponse = {
|
|
64
64
|
result: response?.result,
|
|
65
|
+
humanResult: response?.humanResult, // Full human-readable formatted result (AI-generated markdown)
|
|
66
|
+
summary: response?.config?.params?.summary, // Short 1-2 sentence summary
|
|
65
67
|
error: response?.error,
|
|
66
68
|
cycles: pc.sequence.length,
|
|
67
69
|
cid: pc.cid?.toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,WACf,MAAM,WACL,MAAM,gBACD,MAAM,qBACD,MAAM,
|
|
1
|
+
{"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../src/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,WACf,MAAM,WACL,MAAM,gBACD,MAAM,qBACD,MAAM,WA4IxB,CAAC"}
|
|
@@ -43,9 +43,15 @@ Step 5 - Use target tool address
|
|
|
43
43
|
|
|
44
44
|
Step 6 - Review the tool use results
|
|
45
45
|
1. Analyze each tool use result
|
|
46
|
-
2.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
2. When formatting tool results for the user in a Stop Response, present as clean markdown:
|
|
47
|
+
- For general contexts, present as clean markdown:
|
|
48
|
+
* Use headings to organize different sections
|
|
49
|
+
* Use lists for multiple items
|
|
50
|
+
* Use bold for important values or labels
|
|
51
|
+
* Use code blocks for addresses (e.g., \`o://tool-address\`)
|
|
52
|
+
* Transform raw JSON into readable prose and structured lists
|
|
53
|
+
3. In the summary field, provide a 1-2 sentence overview
|
|
54
|
+
4. If it failed, clearly explain why in a user-friendly way
|
|
49
55
|
|
|
50
56
|
|
|
51
57
|
`, `
|
|
@@ -98,10 +104,10 @@ Search Response:
|
|
|
98
104
|
|
|
99
105
|
Stop Response:
|
|
100
106
|
{
|
|
101
|
-
"result": string,
|
|
107
|
+
"result": string, // IMPORTANT: Format this as clean, readable markdown. Use headers (##, ###), lists (-, 1.), bold (**text**), and code blocks (\`code\`) to make the response easy to read. Structure tool outputs, search results, and data clearly. Focus on what the user needs to know, not raw data dumps.
|
|
102
108
|
"reasoning": string,
|
|
103
109
|
"addresses_to_index": [string], // COMMENT: If the results of a tool use include "address_to_index", list them in the "addresses_to_index" array.
|
|
104
|
-
"summary": string,
|
|
110
|
+
"summary": string, // A concise 1-2 sentence summary for the user
|
|
105
111
|
"type": "stop",
|
|
106
112
|
}
|
|
107
113
|
|
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.59",
|
|
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.
|
|
58
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
59
|
-
"@olane/o-node": "0.7.12-alpha.
|
|
60
|
-
"@olane/o-protocol": "0.7.12-alpha.
|
|
61
|
-
"@olane/o-tool": "0.7.12-alpha.
|
|
57
|
+
"@olane/o-config": "0.7.12-alpha.59",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.59",
|
|
59
|
+
"@olane/o-node": "0.7.12-alpha.59",
|
|
60
|
+
"@olane/o-protocol": "0.7.12-alpha.59",
|
|
61
|
+
"@olane/o-tool": "0.7.12-alpha.59",
|
|
62
62
|
"debug": "^4.4.1",
|
|
63
63
|
"dotenv": "^16.5.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "e444856d725e14b45e3ea8bf726fcb6eef021a79"
|
|
66
66
|
}
|