@olane/o-lane 0.7.12-alpha.6 → 0.7.12-alpha.60

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.
Files changed (54) hide show
  1. package/dist/src/capabilities/enums/o-capability.type-enum.d.ts +1 -0
  2. package/dist/src/capabilities/enums/o-capability.type-enum.d.ts.map +1 -1
  3. package/dist/src/capabilities/enums/o-capability.type-enum.js +1 -0
  4. package/dist/src/capabilities/interfaces/o-capability.config.d.ts +2 -0
  5. package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +1 -1
  6. package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +1 -0
  7. package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -1
  8. package/dist/src/capabilities/o-capability.d.ts +1 -0
  9. package/dist/src/capabilities/o-capability.d.ts.map +1 -1
  10. package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -1
  11. package/dist/src/capabilities/o-capability.intelligence.js +33 -8
  12. package/dist/src/capabilities/o-capability.js +3 -0
  13. package/dist/src/capabilities/o-capability.result.d.ts +2 -0
  14. package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
  15. package/dist/src/capabilities/o-capability.result.js +2 -0
  16. package/dist/src/capabilities/utils/result-stream-parser.d.ts +37 -0
  17. package/dist/src/capabilities/utils/result-stream-parser.d.ts.map +1 -0
  18. package/dist/src/capabilities/utils/result-stream-parser.js +90 -0
  19. package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +1 -0
  20. package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -1
  21. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts +2 -0
  22. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -1
  23. package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +12 -0
  24. package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +1 -0
  25. package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -1
  26. package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
  27. package/dist/src/capabilities-search/o-capability.search.js +24 -6
  28. package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +1 -0
  29. package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +1 -1
  30. package/dist/src/capabilities-task/o-capability.task.d.ts.map +1 -1
  31. package/dist/src/capabilities-task/o-capability.task.js +4 -0
  32. package/dist/src/errors/capability-errors.d.ts +71 -0
  33. package/dist/src/errors/capability-errors.d.ts.map +1 -0
  34. package/dist/src/errors/capability-errors.js +142 -0
  35. package/dist/src/errors/index.d.ts +5 -0
  36. package/dist/src/errors/index.d.ts.map +1 -0
  37. package/dist/src/errors/index.js +4 -0
  38. package/dist/src/formatters/index.d.ts +7 -0
  39. package/dist/src/formatters/index.d.ts.map +1 -0
  40. package/dist/src/formatters/index.js +6 -0
  41. package/dist/src/formatters/markdown-builder.d.ts +65 -0
  42. package/dist/src/formatters/markdown-builder.d.ts.map +1 -0
  43. package/dist/src/formatters/markdown-builder.js +120 -0
  44. package/dist/src/interfaces/o-lane.config.d.ts +2 -0
  45. package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
  46. package/dist/src/o-lane.d.ts +6 -0
  47. package/dist/src/o-lane.d.ts.map +1 -1
  48. package/dist/src/o-lane.js +142 -15
  49. package/dist/src/o-lane.tool.d.ts +2 -2
  50. package/dist/src/o-lane.tool.d.ts.map +1 -1
  51. package/dist/src/o-lane.tool.js +23 -6
  52. package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
  53. package/dist/src/prompts/agent.prompt.js +18 -5
  54. package/package.json +7 -7
@@ -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,5 @@
1
+ /**
2
+ * Error handling exports
3
+ */
4
+ export { CapabilityError, CapabilityErrorType, type CapabilityErrorContext, } from './capability-errors.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -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,4 @@
1
+ /**
2
+ * Error handling exports
3
+ */
4
+ export { CapabilityError, CapabilityErrorType, } from './capability-errors.js';
@@ -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,6 @@
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';
@@ -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
+ }
@@ -15,5 +15,7 @@ export interface oLaneConfig {
15
15
  parentLaneId?: string;
16
16
  maxCycles?: number;
17
17
  persistToConfig?: boolean;
18
+ onChunk?: (chunk: any) => void;
19
+ useStream?: boolean;
18
20
  }
19
21
  //# sourceMappingURL=o-lane.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-lane.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-lane.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAEjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAG7B,WAAW,EAAE,SAAS,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
1
+ {"version":3,"file":"o-lane.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-lane.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IAEjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAG7B,WAAW,EAAE,SAAS,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -15,6 +15,7 @@ export declare class oLane extends oObject {
15
15
  MAX_CYCLES: number;
16
16
  status: oLaneStatus;
17
17
  result: oCapabilityResult | undefined;
18
+ onChunk?: (chunk: any) => void;
18
19
  constructor(config: oLaneConfig);
19
20
  get intent(): oIntent;
20
21
  toCIDInput(): any;
@@ -27,6 +28,11 @@ export declare class oLane extends oObject {
27
28
  toCID(): Promise<CID>;
28
29
  store(): Promise<CID>;
29
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;
30
36
  preflight(): Promise<void>;
31
37
  execute(): Promise<oCapabilityResult | undefined>;
32
38
  get capabilities(): import("./capabilities/o-capability.js").oCapability[];
@@ -1 +1 @@
1
- {"version":3,"file":"o-lane.d.ts","sourceRoot":"","sources":["../../src/o-lane.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAER,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAGjC,qBAAa,KAAM,SAAQ,OAAO;IAUpB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IAT3C,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IACnC,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC;IACrB,EAAE,EAAE,MAAM,CAAY;IACtB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAM;IACxB,MAAM,EAAE,WAAW,CAAuB;IAC1C,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;gBAEd,MAAM,EAAE,WAAW;IAalD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,IAAI,GAAG;IAQjB,MAAM;;;;;IAQN,WAAW,CAAC,MAAM,EAA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 +1,4 @@
1
- import { oAddress, oError, oErrorCodes, NodeState, oObject, } from '@olane/o-core';
1
+ import { oAddress, oError, oErrorCodes, NodeState, oObject, oResponse, } from '@olane/o-core';
2
2
  import { CID } from 'multiformats';
3
3
  import * as json from 'multiformats/codecs/json';
4
4
  import { sha256 } from 'multiformats/hashes/sha2';
@@ -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}]`);
@@ -18,6 +19,7 @@ export class oLane extends oObject {
18
19
  this.sequence = Object.assign([], this.config.sequence || []);
19
20
  this.parentLaneId = this.config.parentLaneId;
20
21
  this.intentEncoder = new oIntentEncoder();
22
+ this.onChunk = this.config.onChunk;
21
23
  // set a max cycles if one is not provided
22
24
  if (!!process.env.MAX_CYCLES) {
23
25
  this.MAX_CYCLES = parseInt(process.env.MAX_CYCLES);
@@ -84,42 +86,142 @@ export class oLane extends oObject {
84
86
  }
85
87
  get agentHistory() {
86
88
  const added = {};
87
- return (this.sequence
88
- ?.filter((s) => {
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) => {
89
92
  if (added[s.id]) {
90
93
  return false;
91
94
  }
92
95
  added[s.id] = true;
93
96
  return true;
94
- })
97
+ });
98
+ return (filteredSequence
95
99
  ?.map((s, index) => {
100
+ const isRecent = index >= filteredSequence.length - KEEP_FULL_DETAIL_COUNT;
96
101
  const result = s.result || s.error;
97
- return `[Cycle ${index + 1} Begin ${s.id}]\n
98
- Cycle Intent: ${s.config?.intent.toString()}\n
99
- Cycle Result:\n
100
- ${typeof result === 'string'
101
- ? result
102
- : JSON.stringify({
103
- ...result,
104
- }, null, 2)} \n[Cycle ${index + 1} End ${s.id}]`;
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;
105
137
  })
106
138
  .join('\n') || '');
107
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
+ }
108
195
  async preflight() {
109
196
  this.logger.debug('Preflight...');
110
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
+ });
111
204
  }
112
205
  async execute() {
113
206
  this.logger.debug('Executing...');
114
- await this.preflight();
115
- this.status = oLaneStatus.RUNNING;
116
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;
117
218
  this.result = await this.loop();
118
219
  }
119
220
  catch (error) {
120
221
  this.logger.error('Error in execute: ', error);
121
222
  this.status = oLaneStatus.FAILED;
122
223
  }
224
+ this.logger.debug('Completed loop...');
123
225
  await this.postflight(this.result);
124
226
  this.status = oLaneStatus.COMPLETED;
125
227
  return this.result;
@@ -137,6 +239,7 @@ export class oLane extends oObject {
137
239
  ...this.config,
138
240
  sequence: this.sequence, // pass the full sequence to the next capability
139
241
  },
242
+ useStream: this.config.useStream || false,
140
243
  };
141
244
  }
142
245
  async doCapability(currentStep) {
@@ -144,8 +247,10 @@ export class oLane extends oObject {
144
247
  for (const capability of this.capabilities) {
145
248
  if (capability.type === capabilityType && currentStep.config) {
146
249
  const capabilityConfig = this.resultToConfig(currentStep);
250
+ this.logger.debug('Executing capability: ', capabilityType);
147
251
  const result = await capability.execute({
148
252
  ...capabilityConfig,
253
+ onChunk: this.onChunk,
149
254
  });
150
255
  return result;
151
256
  }
@@ -181,6 +286,19 @@ export class oLane extends oObject {
181
286
  this.logger.debug('Capability result flagged for persistence - automatically setting persistToConfig');
182
287
  this.config.persistToConfig = true;
183
288
  }
289
+ if (this.config.useStream && this.onChunk) {
290
+ this.onChunk(new oResponse({
291
+ data: {
292
+ ...result,
293
+ config: undefined,
294
+ },
295
+ _last: false,
296
+ _isStreaming: true,
297
+ _connectionId: this.node.address.toString(),
298
+ _requestMethod: 'unknown',
299
+ id: uuidv4(),
300
+ }));
301
+ }
184
302
  if (result.type === oCapabilityType.STOP) {
185
303
  return result;
186
304
  }
@@ -211,9 +329,14 @@ export class oLane extends oObject {
211
329
  const data = response?.result;
212
330
  if (data.addresses_to_index) {
213
331
  for (const address of data.addresses_to_index) {
214
- await this.node.use(new oAddress(address), {
332
+ this.logger.debug('Indexing address: ', address.toString());
333
+ await this.node
334
+ .use(new oAddress(address), {
215
335
  method: 'index_network',
216
336
  params: {},
337
+ })
338
+ .catch((error) => {
339
+ this.logger.error('Error indexing address: ', error);
217
340
  });
218
341
  }
219
342
  }
@@ -232,6 +355,10 @@ export class oLane extends oObject {
232
355
  cancel() {
233
356
  this.logger.debug('Cancelling lane...');
234
357
  this.status = oLaneStatus.CANCELLED;
358
+ // tell all capabilities to cancel
359
+ for (const capability of this.capabilities) {
360
+ capability.cancel();
361
+ }
235
362
  }
236
363
  /**
237
364
  * Replay a stored lane from storage by CID
@@ -1,5 +1,5 @@
1
1
  import { oRequest } from '@olane/o-core';
2
- import { oNodeConfig, oNodeTool } from '@olane/o-node';
2
+ import { oNodeConfig, oNodeTool, oStreamRequest } from '@olane/o-node';
3
3
  import { oHandshakeResult } from './interfaces/index.js';
4
4
  export declare class oLaneTool extends oNodeTool {
5
5
  private manager;
@@ -10,7 +10,7 @@ export declare class oLaneTool extends oNodeTool {
10
10
  * @param request
11
11
  * @returns
12
12
  */
13
- _tool_intent(request: oRequest): Promise<any>;
13
+ _tool_intent(request: oStreamRequest): Promise<any>;
14
14
  /**
15
15
  * Replay a stored lane from storage by CID
16
16
  * This restores network state from a previously executed lane