@radkode/neo 1.5.0 → 1.7.0
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/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -112
- package/dist/cli.js.map +1 -1
- package/dist/commands/git/push/index.d.ts.map +1 -1
- package/dist/commands/git/push/index.js +3 -0
- package/dist/commands/git/push/index.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +29 -0
- package/dist/commands/init/index.js.map +1 -1
- package/dist/commands/work/finish/index.d.ts +22 -0
- package/dist/commands/work/finish/index.d.ts.map +1 -0
- package/dist/commands/work/finish/index.js +306 -0
- package/dist/commands/work/finish/index.js.map +1 -0
- package/dist/commands/work/index.d.ts +3 -0
- package/dist/commands/work/index.d.ts.map +1 -0
- package/dist/commands/work/index.js +33 -0
- package/dist/commands/work/index.js.map +1 -0
- package/dist/commands/work/ship/index.d.ts +27 -0
- package/dist/commands/work/ship/index.d.ts.map +1 -0
- package/dist/commands/work/ship/index.js +361 -0
- package/dist/commands/work/ship/index.js.map +1 -0
- package/dist/commands/work/start/index.d.ts +17 -0
- package/dist/commands/work/start/index.d.ts.map +1 -0
- package/dist/commands/work/start/index.js +250 -0
- package/dist/commands/work/start/index.js.map +1 -0
- package/dist/core/errors/index.d.ts +7 -129
- package/dist/core/errors/index.d.ts.map +1 -1
- package/dist/core/errors/index.js +0 -233
- package/dist/core/errors/index.js.map +1 -1
- package/dist/storage/db.d.ts +5 -3
- package/dist/storage/db.d.ts.map +1 -1
- package/dist/storage/db.js +87 -120
- package/dist/storage/db.js.map +1 -1
- package/dist/types/agent.d.ts +0 -8
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +1 -0
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/schemas.js +1 -0
- package/dist/types/schemas.js.map +1 -1
- package/dist/utils/agent.js +1 -1
- package/dist/utils/agent.js.map +1 -1
- package/dist/utils/config.d.ts +0 -6
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +0 -8
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/logger.d.ts +8 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +8 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/prompt.d.ts.map +1 -1
- package/dist/utils/prompt.js +15 -11
- package/dist/utils/prompt.js.map +1 -1
- package/dist/utils/skill-installer.d.ts +10 -0
- package/dist/utils/skill-installer.d.ts.map +1 -0
- package/dist/utils/skill-installer.js +56 -0
- package/dist/utils/skill-installer.js.map +1 -0
- package/package.json +6 -13
- package/templates/skills/neo/SKILL.md +66 -0
- package/dist/core/container/index.d.ts +0 -27
- package/dist/core/container/index.d.ts.map +0 -1
- package/dist/core/container/index.js +0 -90
- package/dist/core/container/index.js.map +0 -1
- package/dist/core/interfaces/index.d.ts +0 -324
- package/dist/core/interfaces/index.d.ts.map +0 -1
- package/dist/core/interfaces/index.js +0 -19
- package/dist/core/interfaces/index.js.map +0 -1
- package/dist/core/plugins/command-registry.d.ts +0 -16
- package/dist/core/plugins/command-registry.d.ts.map +0 -1
- package/dist/core/plugins/command-registry.js +0 -40
- package/dist/core/plugins/command-registry.js.map +0 -1
- package/dist/core/plugins/event-bus.d.ts +0 -12
- package/dist/core/plugins/event-bus.d.ts.map +0 -1
- package/dist/core/plugins/event-bus.js +0 -56
- package/dist/core/plugins/event-bus.js.map +0 -1
- package/dist/core/plugins/index.d.ts +0 -6
- package/dist/core/plugins/index.d.ts.map +0 -1
- package/dist/core/plugins/index.js +0 -6
- package/dist/core/plugins/index.js.map +0 -1
- package/dist/core/plugins/plugin-context.d.ts +0 -3
- package/dist/core/plugins/plugin-context.d.ts.map +0 -1
- package/dist/core/plugins/plugin-context.js +0 -116
- package/dist/core/plugins/plugin-context.js.map +0 -1
- package/dist/core/plugins/plugin-loader.d.ts +0 -30
- package/dist/core/plugins/plugin-loader.d.ts.map +0 -1
- package/dist/core/plugins/plugin-loader.js +0 -149
- package/dist/core/plugins/plugin-loader.js.map +0 -1
- package/dist/core/plugins/plugin-registry.d.ts +0 -21
- package/dist/core/plugins/plugin-registry.d.ts.map +0 -1
- package/dist/core/plugins/plugin-registry.js +0 -150
- package/dist/core/plugins/plugin-registry.js.map +0 -1
- package/dist/utils/ui-examples.d.ts +0 -3
- package/dist/utils/ui-examples.d.ts.map +0 -1
- package/dist/utils/ui-examples.js +0 -188
- package/dist/utils/ui-examples.js.map +0 -1
|
@@ -10,22 +10,16 @@ export declare enum ErrorCategory {
|
|
|
10
10
|
FILESYSTEM = "FILESYSTEM",
|
|
11
11
|
NETWORK = "NETWORK",
|
|
12
12
|
COMMAND = "COMMAND",
|
|
13
|
-
PLUGIN = "PLUGIN",
|
|
14
13
|
AUTHENTICATION = "AUTHENTICATION",
|
|
15
14
|
PERMISSION = "PERMISSION",
|
|
16
15
|
UNKNOWN = "UNKNOWN"
|
|
17
16
|
}
|
|
18
|
-
export interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
readonly category: ErrorCategory;
|
|
23
|
-
readonly timestamp: Date;
|
|
24
|
-
readonly context?: Record<string, unknown> | undefined;
|
|
25
|
-
readonly suggestions?: string[] | undefined;
|
|
26
|
-
readonly originalError?: Error | undefined;
|
|
17
|
+
export interface AppErrorOptions {
|
|
18
|
+
context?: Record<string, unknown>;
|
|
19
|
+
suggestions?: string[];
|
|
20
|
+
originalError?: Error;
|
|
27
21
|
}
|
|
28
|
-
export declare abstract class AppError extends Error
|
|
22
|
+
export declare abstract class AppError extends Error {
|
|
29
23
|
abstract readonly code: string;
|
|
30
24
|
abstract readonly severity: ErrorSeverity;
|
|
31
25
|
abstract readonly category: ErrorCategory;
|
|
@@ -33,101 +27,14 @@ export declare abstract class AppError extends Error implements IError {
|
|
|
33
27
|
readonly context?: Record<string, unknown> | undefined;
|
|
34
28
|
readonly suggestions?: string[] | undefined;
|
|
35
29
|
readonly originalError?: Error | undefined;
|
|
36
|
-
constructor(message: string, options?:
|
|
37
|
-
context?: Record<string, unknown>;
|
|
38
|
-
suggestions?: string[];
|
|
39
|
-
originalError?: Error;
|
|
40
|
-
});
|
|
41
|
-
getUserMessage(): string;
|
|
42
|
-
getDetailedReport(): string;
|
|
43
|
-
toJSON(): Record<string, unknown>;
|
|
30
|
+
constructor(message: string, options?: AppErrorOptions);
|
|
44
31
|
}
|
|
45
32
|
export declare class CommandError extends AppError {
|
|
46
33
|
readonly commandName: string;
|
|
47
34
|
readonly code = "COMMAND_ERROR";
|
|
48
35
|
readonly severity = ErrorSeverity.MEDIUM;
|
|
49
36
|
readonly category = ErrorCategory.COMMAND;
|
|
50
|
-
constructor(message: string, commandName: string, options?:
|
|
51
|
-
context?: Record<string, unknown>;
|
|
52
|
-
suggestions?: string[];
|
|
53
|
-
originalError?: Error;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export declare class ValidationError extends AppError {
|
|
57
|
-
readonly field?: string | undefined;
|
|
58
|
-
readonly value?: unknown | undefined;
|
|
59
|
-
readonly code = "VALIDATION_ERROR";
|
|
60
|
-
readonly severity = ErrorSeverity.LOW;
|
|
61
|
-
readonly category = ErrorCategory.VALIDATION;
|
|
62
|
-
constructor(message: string, field?: string | undefined, value?: unknown | undefined, options?: {
|
|
63
|
-
context?: Record<string, unknown>;
|
|
64
|
-
suggestions?: string[];
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
export declare class ConfigurationError extends AppError {
|
|
68
|
-
readonly configKey?: string | undefined;
|
|
69
|
-
readonly code = "CONFIGURATION_ERROR";
|
|
70
|
-
readonly severity = ErrorSeverity.HIGH;
|
|
71
|
-
readonly category = ErrorCategory.CONFIGURATION;
|
|
72
|
-
constructor(message: string, configKey?: string | undefined, options?: {
|
|
73
|
-
context?: Record<string, unknown>;
|
|
74
|
-
suggestions?: string[];
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
export declare class FileSystemError extends AppError {
|
|
78
|
-
readonly path: string;
|
|
79
|
-
readonly operation: 'read' | 'write' | 'delete' | 'create' | 'access';
|
|
80
|
-
readonly code = "FILESYSTEM_ERROR";
|
|
81
|
-
readonly severity = ErrorSeverity.MEDIUM;
|
|
82
|
-
readonly category = ErrorCategory.FILESYSTEM;
|
|
83
|
-
constructor(message: string, path: string, operation: 'read' | 'write' | 'delete' | 'create' | 'access', options?: {
|
|
84
|
-
context?: Record<string, unknown>;
|
|
85
|
-
suggestions?: string[];
|
|
86
|
-
originalError?: Error;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
export declare class NetworkError extends AppError {
|
|
90
|
-
readonly url?: string | undefined;
|
|
91
|
-
readonly statusCode?: number | undefined;
|
|
92
|
-
readonly code = "NETWORK_ERROR";
|
|
93
|
-
readonly severity = ErrorSeverity.MEDIUM;
|
|
94
|
-
readonly category = ErrorCategory.NETWORK;
|
|
95
|
-
constructor(message: string, url?: string | undefined, statusCode?: number | undefined, options?: {
|
|
96
|
-
context?: Record<string, unknown>;
|
|
97
|
-
suggestions?: string[];
|
|
98
|
-
originalError?: Error;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
export declare class PluginError extends AppError {
|
|
102
|
-
readonly pluginName: string;
|
|
103
|
-
readonly code = "PLUGIN_ERROR";
|
|
104
|
-
readonly severity = ErrorSeverity.MEDIUM;
|
|
105
|
-
readonly category = ErrorCategory.PLUGIN;
|
|
106
|
-
constructor(message: string, pluginName: string, options?: {
|
|
107
|
-
context?: Record<string, unknown>;
|
|
108
|
-
suggestions?: string[];
|
|
109
|
-
originalError?: Error;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
export declare class AuthenticationError extends AppError {
|
|
113
|
-
readonly code = "AUTHENTICATION_ERROR";
|
|
114
|
-
readonly severity = ErrorSeverity.HIGH;
|
|
115
|
-
readonly category = ErrorCategory.AUTHENTICATION;
|
|
116
|
-
constructor(message?: string, options?: {
|
|
117
|
-
context?: Record<string, unknown>;
|
|
118
|
-
suggestions?: string[];
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
export declare class PermissionError extends AppError {
|
|
122
|
-
readonly resource: string;
|
|
123
|
-
readonly requiredPermission?: string | undefined;
|
|
124
|
-
readonly code = "PERMISSION_ERROR";
|
|
125
|
-
readonly severity = ErrorSeverity.HIGH;
|
|
126
|
-
readonly category = ErrorCategory.PERMISSION;
|
|
127
|
-
constructor(message: string, resource: string, requiredPermission?: string | undefined, options?: {
|
|
128
|
-
context?: Record<string, unknown>;
|
|
129
|
-
suggestions?: string[];
|
|
130
|
-
});
|
|
37
|
+
constructor(message: string, commandName: string, options?: AppErrorOptions);
|
|
131
38
|
}
|
|
132
39
|
export type Result<T, E extends AppError = AppError> = {
|
|
133
40
|
success: true;
|
|
@@ -138,37 +45,8 @@ export type Result<T, E extends AppError = AppError> = {
|
|
|
138
45
|
};
|
|
139
46
|
export declare function success<T>(data: T): Result<T>;
|
|
140
47
|
export declare function failure<E extends AppError>(error: E): Result<never, E>;
|
|
141
|
-
export declare function isSuccess<T, E extends AppError>(result: Result<T, E>): result is {
|
|
142
|
-
success: true;
|
|
143
|
-
data: T;
|
|
144
|
-
};
|
|
145
48
|
export declare function isFailure<T, E extends AppError>(result: Result<T, E>): result is {
|
|
146
49
|
success: false;
|
|
147
50
|
error: E;
|
|
148
51
|
};
|
|
149
|
-
export interface ErrorRecoveryStrategy<E extends AppError = AppError> {
|
|
150
|
-
canRecover(error: E): boolean;
|
|
151
|
-
recover(error: E): Promise<void>;
|
|
152
|
-
}
|
|
153
|
-
export declare class RetryStrategy implements ErrorRecoveryStrategy {
|
|
154
|
-
private maxRetries;
|
|
155
|
-
private delayMs;
|
|
156
|
-
private backoff;
|
|
157
|
-
constructor(maxRetries?: number, delayMs?: number, backoff?: boolean);
|
|
158
|
-
canRecover(error: AppError): boolean;
|
|
159
|
-
recover(_error: AppError): Promise<void>;
|
|
160
|
-
}
|
|
161
|
-
export declare class ErrorHandler {
|
|
162
|
-
private strategies;
|
|
163
|
-
registerStrategy(strategy: ErrorRecoveryStrategy): void;
|
|
164
|
-
handle(error: unknown): Promise<void>;
|
|
165
|
-
private normalizeError;
|
|
166
|
-
}
|
|
167
|
-
export declare const errorHandler: ErrorHandler;
|
|
168
|
-
export declare function handleCommandResult(result: Result<void>): void;
|
|
169
|
-
export declare function handleCommandResultSync(result: Result<void>, ui: {
|
|
170
|
-
error: (msg: string) => void;
|
|
171
|
-
warn: (msg: string) => void;
|
|
172
|
-
list: (items: string[]) => void;
|
|
173
|
-
}): void;
|
|
174
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAUA,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,oBAAY,aAAa;IACvB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,cAAc,mBAAmB;IACjC,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB;AAED,8BAAsB,QAAS,SAAQ,KAAK;IAC1C,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,aAAa,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe;CASvD;AAED,qBAAa,YAAa,SAAQ,QAAQ;aAOtB,WAAW,EAAE,MAAM;IANrC,QAAQ,CAAC,IAAI,mBAAmB;IAChC,QAAQ,CAAC,QAAQ,wBAAwB;IACzC,QAAQ,CAAC,QAAQ,yBAAyB;gBAGxC,OAAO,EAAE,MAAM,EACC,WAAW,EAAE,MAAM,EACnC,OAAO,CAAC,EAAE,eAAe;CAI5B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAC/C;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEjC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAE7C;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAEtE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,QAAQ,EAC7C,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,MAAM,IAAI;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAExC"}
|
|
@@ -12,7 +12,6 @@ export var ErrorCategory;
|
|
|
12
12
|
ErrorCategory["FILESYSTEM"] = "FILESYSTEM";
|
|
13
13
|
ErrorCategory["NETWORK"] = "NETWORK";
|
|
14
14
|
ErrorCategory["COMMAND"] = "COMMAND";
|
|
15
|
-
ErrorCategory["PLUGIN"] = "PLUGIN";
|
|
16
15
|
ErrorCategory["AUTHENTICATION"] = "AUTHENTICATION";
|
|
17
16
|
ErrorCategory["PERMISSION"] = "PERMISSION";
|
|
18
17
|
ErrorCategory["UNKNOWN"] = "UNKNOWN";
|
|
@@ -31,49 +30,6 @@ export class AppError extends Error {
|
|
|
31
30
|
this.originalError = options?.originalError;
|
|
32
31
|
Error.captureStackTrace(this, this.constructor);
|
|
33
32
|
}
|
|
34
|
-
getUserMessage() {
|
|
35
|
-
let message = this.message;
|
|
36
|
-
if (this.suggestions && this.suggestions.length > 0) {
|
|
37
|
-
message += '\n\nSuggestions:';
|
|
38
|
-
this.suggestions.forEach((suggestion) => {
|
|
39
|
-
message += `\n • ${suggestion}`;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return message;
|
|
43
|
-
}
|
|
44
|
-
getDetailedReport() {
|
|
45
|
-
const report = [
|
|
46
|
-
`Error: ${this.name}`,
|
|
47
|
-
`Code: ${this.code}`,
|
|
48
|
-
`Message: ${this.message}`,
|
|
49
|
-
`Severity: ${this.severity}`,
|
|
50
|
-
`Category: ${this.category}`,
|
|
51
|
-
`Timestamp: ${this.timestamp.toISOString()}`,
|
|
52
|
-
];
|
|
53
|
-
if (this.context) {
|
|
54
|
-
report.push(`Context: ${JSON.stringify(this.context, null, 2)}`);
|
|
55
|
-
}
|
|
56
|
-
if (this.suggestions && this.suggestions.length > 0) {
|
|
57
|
-
report.push(`Suggestions: ${this.suggestions.join(', ')}`);
|
|
58
|
-
}
|
|
59
|
-
if (this.stack) {
|
|
60
|
-
report.push(`Stack Trace:\n${this.stack}`);
|
|
61
|
-
}
|
|
62
|
-
return report.join('\n');
|
|
63
|
-
}
|
|
64
|
-
toJSON() {
|
|
65
|
-
return {
|
|
66
|
-
name: this.name,
|
|
67
|
-
code: this.code,
|
|
68
|
-
message: this.message,
|
|
69
|
-
severity: this.severity,
|
|
70
|
-
category: this.category,
|
|
71
|
-
timestamp: this.timestamp.toISOString(),
|
|
72
|
-
context: this.context,
|
|
73
|
-
suggestions: this.suggestions,
|
|
74
|
-
stack: this.stack,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
33
|
}
|
|
78
34
|
export class CommandError extends AppError {
|
|
79
35
|
commandName;
|
|
@@ -85,202 +41,13 @@ export class CommandError extends AppError {
|
|
|
85
41
|
this.commandName = commandName;
|
|
86
42
|
}
|
|
87
43
|
}
|
|
88
|
-
export class ValidationError extends AppError {
|
|
89
|
-
field;
|
|
90
|
-
value;
|
|
91
|
-
code = 'VALIDATION_ERROR';
|
|
92
|
-
severity = ErrorSeverity.LOW;
|
|
93
|
-
category = ErrorCategory.VALIDATION;
|
|
94
|
-
constructor(message, field, value, options) {
|
|
95
|
-
super(message, options);
|
|
96
|
-
this.field = field;
|
|
97
|
-
this.value = value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export class ConfigurationError extends AppError {
|
|
101
|
-
configKey;
|
|
102
|
-
code = 'CONFIGURATION_ERROR';
|
|
103
|
-
severity = ErrorSeverity.HIGH;
|
|
104
|
-
category = ErrorCategory.CONFIGURATION;
|
|
105
|
-
constructor(message, configKey, options) {
|
|
106
|
-
const defaultSuggestions = [
|
|
107
|
-
'Check your configuration file for syntax errors',
|
|
108
|
-
'Ensure all required configuration values are set',
|
|
109
|
-
'Run "neo config validate" to check your configuration',
|
|
110
|
-
];
|
|
111
|
-
super(message, {
|
|
112
|
-
...options,
|
|
113
|
-
suggestions: options?.suggestions || defaultSuggestions,
|
|
114
|
-
});
|
|
115
|
-
this.configKey = configKey;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
export class FileSystemError extends AppError {
|
|
119
|
-
path;
|
|
120
|
-
operation;
|
|
121
|
-
code = 'FILESYSTEM_ERROR';
|
|
122
|
-
severity = ErrorSeverity.MEDIUM;
|
|
123
|
-
category = ErrorCategory.FILESYSTEM;
|
|
124
|
-
constructor(message, path, operation, options) {
|
|
125
|
-
super(message, options);
|
|
126
|
-
this.path = path;
|
|
127
|
-
this.operation = operation;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export class NetworkError extends AppError {
|
|
131
|
-
url;
|
|
132
|
-
statusCode;
|
|
133
|
-
code = 'NETWORK_ERROR';
|
|
134
|
-
severity = ErrorSeverity.MEDIUM;
|
|
135
|
-
category = ErrorCategory.NETWORK;
|
|
136
|
-
constructor(message, url, statusCode, options) {
|
|
137
|
-
const defaultSuggestions = [
|
|
138
|
-
'Check your internet connection',
|
|
139
|
-
'Verify the API endpoint is correct',
|
|
140
|
-
'Check if you need to configure a proxy',
|
|
141
|
-
];
|
|
142
|
-
super(message, {
|
|
143
|
-
...options,
|
|
144
|
-
suggestions: options?.suggestions || defaultSuggestions,
|
|
145
|
-
});
|
|
146
|
-
this.url = url;
|
|
147
|
-
this.statusCode = statusCode;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
export class PluginError extends AppError {
|
|
151
|
-
pluginName;
|
|
152
|
-
code = 'PLUGIN_ERROR';
|
|
153
|
-
severity = ErrorSeverity.MEDIUM;
|
|
154
|
-
category = ErrorCategory.PLUGIN;
|
|
155
|
-
constructor(message, pluginName, options) {
|
|
156
|
-
super(message, options);
|
|
157
|
-
this.pluginName = pluginName;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export class AuthenticationError extends AppError {
|
|
161
|
-
code = 'AUTHENTICATION_ERROR';
|
|
162
|
-
severity = ErrorSeverity.HIGH;
|
|
163
|
-
category = ErrorCategory.AUTHENTICATION;
|
|
164
|
-
constructor(message = 'Authentication failed', options) {
|
|
165
|
-
const defaultSuggestions = [
|
|
166
|
-
'Check your credentials',
|
|
167
|
-
'Run "neo auth login" to authenticate',
|
|
168
|
-
'Verify your API token is still valid',
|
|
169
|
-
];
|
|
170
|
-
super(message, {
|
|
171
|
-
...options,
|
|
172
|
-
suggestions: options?.suggestions || defaultSuggestions,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
export class PermissionError extends AppError {
|
|
177
|
-
resource;
|
|
178
|
-
requiredPermission;
|
|
179
|
-
code = 'PERMISSION_ERROR';
|
|
180
|
-
severity = ErrorSeverity.HIGH;
|
|
181
|
-
category = ErrorCategory.PERMISSION;
|
|
182
|
-
constructor(message, resource, requiredPermission, options) {
|
|
183
|
-
super(message, options);
|
|
184
|
-
this.resource = resource;
|
|
185
|
-
this.requiredPermission = requiredPermission;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
44
|
export function success(data) {
|
|
189
45
|
return { success: true, data };
|
|
190
46
|
}
|
|
191
47
|
export function failure(error) {
|
|
192
48
|
return { success: false, error };
|
|
193
49
|
}
|
|
194
|
-
export function isSuccess(result) {
|
|
195
|
-
return result.success === true;
|
|
196
|
-
}
|
|
197
50
|
export function isFailure(result) {
|
|
198
51
|
return result.success === false;
|
|
199
52
|
}
|
|
200
|
-
export class RetryStrategy {
|
|
201
|
-
maxRetries;
|
|
202
|
-
delayMs;
|
|
203
|
-
backoff;
|
|
204
|
-
constructor(maxRetries = 3, delayMs = 1000, backoff = true) {
|
|
205
|
-
this.maxRetries = maxRetries;
|
|
206
|
-
this.delayMs = delayMs;
|
|
207
|
-
this.backoff = backoff;
|
|
208
|
-
}
|
|
209
|
-
canRecover(error) {
|
|
210
|
-
return error.category === ErrorCategory.NETWORK || error.category === ErrorCategory.FILESYSTEM;
|
|
211
|
-
}
|
|
212
|
-
async recover(_error) {
|
|
213
|
-
for (let attempt = 1; attempt <= this.maxRetries; attempt++) {
|
|
214
|
-
const delay = this.backoff ? this.delayMs * attempt : this.delayMs;
|
|
215
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
216
|
-
console.log(`Retry attempt ${attempt} after ${delay}ms`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
export class ErrorHandler {
|
|
221
|
-
strategies = [];
|
|
222
|
-
registerStrategy(strategy) {
|
|
223
|
-
this.strategies.push(strategy);
|
|
224
|
-
}
|
|
225
|
-
async handle(error) {
|
|
226
|
-
const appError = this.normalizeError(error);
|
|
227
|
-
for (const strategy of this.strategies) {
|
|
228
|
-
if (strategy.canRecover(appError)) {
|
|
229
|
-
try {
|
|
230
|
-
await strategy.recover(appError);
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
catch {
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
console.error(appError.getDetailedReport());
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}
|
|
241
|
-
normalizeError(error) {
|
|
242
|
-
if (error instanceof AppError) {
|
|
243
|
-
return error;
|
|
244
|
-
}
|
|
245
|
-
if (error instanceof Error) {
|
|
246
|
-
return new (class extends AppError {
|
|
247
|
-
code = 'UNKNOWN_ERROR';
|
|
248
|
-
severity = ErrorSeverity.HIGH;
|
|
249
|
-
category = ErrorCategory.UNKNOWN;
|
|
250
|
-
})(error.message, { originalError: error });
|
|
251
|
-
}
|
|
252
|
-
return new (class extends AppError {
|
|
253
|
-
code = 'UNKNOWN_ERROR';
|
|
254
|
-
severity = ErrorSeverity.CRITICAL;
|
|
255
|
-
category = ErrorCategory.UNKNOWN;
|
|
256
|
-
})(String(error));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
export const errorHandler = new ErrorHandler();
|
|
260
|
-
export function handleCommandResult(result) {
|
|
261
|
-
if (isSuccess(result)) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
import('../../utils/ui.js').then(({ ui }) => {
|
|
265
|
-
const error = result.error;
|
|
266
|
-
ui.error(error.message);
|
|
267
|
-
if (error.suggestions && error.suggestions.length > 0) {
|
|
268
|
-
ui.warn('Suggestions:');
|
|
269
|
-
ui.list(error.suggestions);
|
|
270
|
-
}
|
|
271
|
-
process.exit(1);
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
export function handleCommandResultSync(result, ui) {
|
|
275
|
-
if (isSuccess(result)) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
const error = result.error;
|
|
279
|
-
ui.error(error.message);
|
|
280
|
-
if (error.suggestions && error.suggestions.length > 0) {
|
|
281
|
-
ui.warn('Suggestions:');
|
|
282
|
-
ui.list(error.suggestions);
|
|
283
|
-
}
|
|
284
|
-
process.exit(1);
|
|
285
|
-
}
|
|
286
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,kCAAiB,CAAA;IACjB,8BAAa,CAAA;IACb,sCAAqB,CAAA;AACvB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB,0CAAyB,CAAA;IACzB,gDAA+B,CAAA;IAC/B,0CAAyB,CAAA;IACzB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,kDAAiC,CAAA;IACjC,0CAAyB,CAAA;IACzB,oCAAmB,CAAA;AACrB,CAAC,EATW,aAAa,KAAb,aAAa,QASxB;AAQD,MAAM,OAAgB,QAAS,SAAQ,KAAK;IAIjC,SAAS,CAAO;IAChB,OAAO,CAAuC;IAC9C,WAAW,CAAwB;IACnC,aAAa,CAAqB;IAE3C,YAAY,OAAe,EAAE,OAAyB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,OAAO,EAAE,aAAa,CAAC;QAC5C,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,QAAQ;IAOtB;IANT,IAAI,GAAG,eAAe,CAAC;IACvB,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC;IAChC,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC;IAE1C,YACE,OAAe,EACC,WAAmB,EACnC,OAAyB;QAEzB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAHR,gBAAW,GAAX,WAAW,CAAQ;IAIrC,CAAC;CACF;AAMD,MAAM,UAAU,OAAO,CAAI,IAAO;IAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,OAAO,CAAqB,KAAQ;IAClD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,MAAoB;IAEpB,OAAO,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC;AAClC,CAAC"}
|
package/dist/storage/db.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ContextItem, ContextFilters, AddContextOptions, ContextPriority } from '../types/agent.js';
|
|
2
2
|
export declare class ContextDB {
|
|
3
|
-
private
|
|
3
|
+
private readonly path;
|
|
4
|
+
private contexts;
|
|
4
5
|
private constructor();
|
|
5
|
-
static create(
|
|
6
|
+
static create(path: string): Promise<ContextDB>;
|
|
6
7
|
addContext(options: AddContextOptions): ContextItem;
|
|
7
8
|
listContexts(filters?: ContextFilters): ContextItem[];
|
|
8
9
|
getContext(id: string): ContextItem | null;
|
|
@@ -14,6 +15,7 @@ export declare class ContextDB {
|
|
|
14
15
|
totalTags: number;
|
|
15
16
|
};
|
|
16
17
|
close(): void;
|
|
17
|
-
private
|
|
18
|
+
private toItem;
|
|
19
|
+
private persist;
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/storage/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/storage/db.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/storage/db.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAkC1B,qBAAa,SAAS;IAElB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ;IAFlB,OAAO;WAKM,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAiBrD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW;IAiBnD,YAAY,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,WAAW,EAAE;IAsBrD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAK1C,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAQlC,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,WAAW,GAAG,IAAI;IAalF,QAAQ,IAAI;QACV,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC;KACnB;IAyBD,KAAK,IAAI,IAAI;IAEb,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,OAAO;CAMhB"}
|