nebula-notebook-mcp 0.1.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.
Files changed (72) hide show
  1. package/README.md +314 -0
  2. package/bin/nebula-mcp.js +10 -0
  3. package/dist/circuit-breaker.d.ts +157 -0
  4. package/dist/circuit-breaker.d.ts.map +1 -0
  5. package/dist/circuit-breaker.js +237 -0
  6. package/dist/circuit-breaker.js.map +1 -0
  7. package/dist/errors.d.ts +72 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +314 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +13 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +41 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/mcp/index.d.ts +8 -0
  16. package/dist/mcp/index.d.ts.map +1 -0
  17. package/dist/mcp/index.js +13 -0
  18. package/dist/mcp/index.js.map +1 -0
  19. package/dist/mcp/server.d.ts +31 -0
  20. package/dist/mcp/server.d.ts.map +1 -0
  21. package/dist/mcp/server.js +237 -0
  22. package/dist/mcp/server.js.map +1 -0
  23. package/dist/notebook/client.d.ts +643 -0
  24. package/dist/notebook/client.d.ts.map +1 -0
  25. package/dist/notebook/client.js +1720 -0
  26. package/dist/notebook/client.js.map +1 -0
  27. package/dist/notebook/index.d.ts +6 -0
  28. package/dist/notebook/index.d.ts.map +1 -0
  29. package/dist/notebook/index.js +6 -0
  30. package/dist/notebook/index.js.map +1 -0
  31. package/dist/notebook/tools.d.ts +244 -0
  32. package/dist/notebook/tools.d.ts.map +1 -0
  33. package/dist/notebook/tools.js +279 -0
  34. package/dist/notebook/tools.js.map +1 -0
  35. package/dist/tools/execution.d.ts +38 -0
  36. package/dist/tools/execution.d.ts.map +1 -0
  37. package/dist/tools/execution.js +116 -0
  38. package/dist/tools/execution.js.map +1 -0
  39. package/dist/tools/files.d.ts +70 -0
  40. package/dist/tools/files.d.ts.map +1 -0
  41. package/dist/tools/files.js +286 -0
  42. package/dist/tools/files.js.map +1 -0
  43. package/dist/tools/index.d.ts +74 -0
  44. package/dist/tools/index.d.ts.map +1 -0
  45. package/dist/tools/index.js +217 -0
  46. package/dist/tools/index.js.map +1 -0
  47. package/dist/tools/kernel.d.ts +36 -0
  48. package/dist/tools/kernel.d.ts.map +1 -0
  49. package/dist/tools/kernel.js +182 -0
  50. package/dist/tools/kernel.js.map +1 -0
  51. package/dist/tools/notebook.d.ts +252 -0
  52. package/dist/tools/notebook.d.ts.map +1 -0
  53. package/dist/tools/notebook.js +1089 -0
  54. package/dist/tools/notebook.js.map +1 -0
  55. package/dist/tools/types.d.ts +78 -0
  56. package/dist/tools/types.d.ts.map +1 -0
  57. package/dist/tools/types.js +8 -0
  58. package/dist/tools/types.js.map +1 -0
  59. package/dist/types.d.ts +473 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +5 -0
  62. package/dist/types.js.map +1 -0
  63. package/dist/utils/imageResize.d.ts +24 -0
  64. package/dist/utils/imageResize.d.ts.map +1 -0
  65. package/dist/utils/imageResize.js +67 -0
  66. package/dist/utils/imageResize.js.map +1 -0
  67. package/dist/utils/polling.d.ts +40 -0
  68. package/dist/utils/polling.d.ts.map +1 -0
  69. package/dist/utils/polling.js +49 -0
  70. package/dist/utils/polling.js.map +1 -0
  71. package/package.json +61 -0
  72. package/setup-mcp.js +468 -0
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Circuit Breaker Pattern Implementation
3
+ *
4
+ * Prevents cascading failures by temporarily disabling requests to a failing service.
5
+ * When a service fails repeatedly, the circuit "opens" and subsequent requests
6
+ * fail immediately without attempting the operation, allowing the service time to recover.
7
+ *
8
+ * States:
9
+ * - CLOSED: Normal operation, requests pass through
10
+ * - OPEN: Service is failing, requests fail immediately
11
+ * - HALF_OPEN: Testing if service has recovered
12
+ */
13
+ import { classifyError, ErrorCategory } from './errors.js';
14
+ /**
15
+ * Circuit breaker states
16
+ */
17
+ export var CircuitState;
18
+ (function (CircuitState) {
19
+ /** Normal operation - requests pass through */
20
+ CircuitState["CLOSED"] = "CLOSED";
21
+ /** Service is failing - requests fail immediately */
22
+ CircuitState["OPEN"] = "OPEN";
23
+ /** Testing recovery - limited requests pass through */
24
+ CircuitState["HALF_OPEN"] = "HALF_OPEN";
25
+ })(CircuitState || (CircuitState = {}));
26
+ /**
27
+ * Circuit Breaker implementation
28
+ */
29
+ export class CircuitBreaker {
30
+ state = CircuitState.CLOSED;
31
+ failures = []; // Timestamps of failures within the window
32
+ successCount = 0;
33
+ lastFailureTime = 0;
34
+ openedAt = 0;
35
+ failureThreshold;
36
+ resetTimeout;
37
+ successThreshold;
38
+ failureWindow;
39
+ tripOnCategories;
40
+ name;
41
+ listeners = [];
42
+ constructor(options = {}) {
43
+ this.failureThreshold = options.failureThreshold ?? 5;
44
+ this.resetTimeout = options.resetTimeout ?? 30000;
45
+ this.successThreshold = options.successThreshold ?? 2;
46
+ this.failureWindow = options.failureWindow ?? 60000;
47
+ this.tripOnCategories = new Set(options.tripOnCategories ?? [ErrorCategory.NETWORK, ErrorCategory.TIMEOUT, ErrorCategory.SERVER]);
48
+ this.name = options.name ?? 'default';
49
+ }
50
+ /**
51
+ * Get current circuit state
52
+ */
53
+ getState() {
54
+ this.checkStateTransition();
55
+ return this.state;
56
+ }
57
+ /**
58
+ * Get circuit breaker metrics
59
+ */
60
+ getMetrics() {
61
+ this.checkStateTransition();
62
+ return {
63
+ state: this.state,
64
+ failureCount: this.getRecentFailureCount(),
65
+ successCount: this.successCount,
66
+ lastFailureTime: this.lastFailureTime,
67
+ openedAt: this.openedAt,
68
+ };
69
+ }
70
+ /**
71
+ * Check if the circuit allows requests
72
+ */
73
+ isAllowed() {
74
+ this.checkStateTransition();
75
+ return this.state !== CircuitState.OPEN;
76
+ }
77
+ /**
78
+ * Execute an operation through the circuit breaker
79
+ */
80
+ async execute(operation) {
81
+ this.checkStateTransition();
82
+ // If circuit is open, reject immediately
83
+ if (this.state === CircuitState.OPEN) {
84
+ this.emit({ type: 'request_rejected', state: this.state });
85
+ return {
86
+ success: false,
87
+ error: `Circuit breaker is open (${this.name}). Service temporarily unavailable.`,
88
+ rejectedByCircuit: true,
89
+ };
90
+ }
91
+ try {
92
+ const result = await operation();
93
+ this.recordSuccess();
94
+ return { success: true, data: result };
95
+ }
96
+ catch (error) {
97
+ const classified = classifyError(error);
98
+ this.recordFailure(classified);
99
+ return {
100
+ success: false,
101
+ error: classified.message,
102
+ rejectedByCircuit: false,
103
+ classifiedError: classified,
104
+ };
105
+ }
106
+ }
107
+ /**
108
+ * Record a successful operation
109
+ */
110
+ recordSuccess() {
111
+ if (this.state === CircuitState.HALF_OPEN) {
112
+ this.successCount++;
113
+ this.emit({ type: 'success_recorded', successCount: this.successCount });
114
+ if (this.successCount >= this.successThreshold) {
115
+ this.transitionTo(CircuitState.CLOSED, 'Success threshold reached');
116
+ }
117
+ }
118
+ else if (this.state === CircuitState.CLOSED) {
119
+ // In closed state, success helps decay the failure count
120
+ this.emit({ type: 'success_recorded', successCount: this.successCount });
121
+ }
122
+ }
123
+ /**
124
+ * Record a failed operation
125
+ */
126
+ recordFailure(error) {
127
+ // Only trip on configured categories
128
+ if (!this.tripOnCategories.has(error.category)) {
129
+ return;
130
+ }
131
+ const now = Date.now();
132
+ this.failures.push(now);
133
+ this.lastFailureTime = now;
134
+ // Clean up old failures outside the window
135
+ this.failures = this.failures.filter((t) => now - t < this.failureWindow);
136
+ this.emit({
137
+ type: 'failure_recorded',
138
+ error,
139
+ failureCount: this.failures.length,
140
+ });
141
+ if (this.state === CircuitState.HALF_OPEN) {
142
+ // Any failure in half-open state reopens the circuit
143
+ this.transitionTo(CircuitState.OPEN, 'Failure in half-open state');
144
+ }
145
+ else if (this.state === CircuitState.CLOSED && this.failures.length >= this.failureThreshold) {
146
+ // Threshold reached in closed state
147
+ this.transitionTo(CircuitState.OPEN, `Failure threshold reached (${this.failures.length}/${this.failureThreshold})`);
148
+ }
149
+ }
150
+ /**
151
+ * Manually reset the circuit breaker to closed state
152
+ */
153
+ reset() {
154
+ this.failures = [];
155
+ this.successCount = 0;
156
+ this.lastFailureTime = 0;
157
+ this.openedAt = 0;
158
+ if (this.state !== CircuitState.CLOSED) {
159
+ this.transitionTo(CircuitState.CLOSED, 'Manual reset');
160
+ }
161
+ }
162
+ /**
163
+ * Force the circuit open (for testing or emergency)
164
+ */
165
+ forceOpen() {
166
+ if (this.state !== CircuitState.OPEN) {
167
+ this.transitionTo(CircuitState.OPEN, 'Forced open');
168
+ }
169
+ }
170
+ /**
171
+ * Add an event listener
172
+ */
173
+ onEvent(listener) {
174
+ this.listeners.push(listener);
175
+ return () => {
176
+ this.listeners = this.listeners.filter((l) => l !== listener);
177
+ };
178
+ }
179
+ /**
180
+ * Check if state should transition based on time
181
+ */
182
+ checkStateTransition() {
183
+ if (this.state === CircuitState.OPEN) {
184
+ const now = Date.now();
185
+ if (now - this.openedAt >= this.resetTimeout) {
186
+ this.transitionTo(CircuitState.HALF_OPEN, 'Reset timeout elapsed');
187
+ }
188
+ }
189
+ }
190
+ /**
191
+ * Transition to a new state
192
+ */
193
+ transitionTo(newState, reason) {
194
+ const oldState = this.state;
195
+ this.state = newState;
196
+ if (newState === CircuitState.OPEN) {
197
+ this.openedAt = Date.now();
198
+ }
199
+ else if (newState === CircuitState.HALF_OPEN) {
200
+ this.successCount = 0;
201
+ }
202
+ else if (newState === CircuitState.CLOSED) {
203
+ this.failures = [];
204
+ this.successCount = 0;
205
+ this.openedAt = 0;
206
+ }
207
+ this.emit({ type: 'state_change', from: oldState, to: newState, reason });
208
+ }
209
+ /**
210
+ * Get count of failures within the window
211
+ */
212
+ getRecentFailureCount() {
213
+ const now = Date.now();
214
+ this.failures = this.failures.filter((t) => now - t < this.failureWindow);
215
+ return this.failures.length;
216
+ }
217
+ /**
218
+ * Emit an event to listeners
219
+ */
220
+ emit(event) {
221
+ for (const listener of this.listeners) {
222
+ try {
223
+ listener(event);
224
+ }
225
+ catch {
226
+ // Ignore listener errors
227
+ }
228
+ }
229
+ }
230
+ }
231
+ /**
232
+ * Create a new circuit breaker instance
233
+ */
234
+ export function createCircuitBreaker(options) {
235
+ return new CircuitBreaker(options);
236
+ }
237
+ //# sourceMappingURL=circuit-breaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circuit-breaker.js","sourceRoot":"","sources":["../src/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAEjF;;GAEG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,+CAA+C;IAC/C,iCAAiB,CAAA;IACjB,qDAAqD;IACrD,6BAAa,CAAA;IACb,uDAAuD;IACvD,uCAAuB,CAAA;AACzB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAyCD;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,KAAK,GAAiB,YAAY,CAAC,MAAM,CAAC;IAC1C,QAAQ,GAAa,EAAE,CAAC,CAAC,2CAA2C;IACpE,YAAY,GAAW,CAAC,CAAC;IACzB,eAAe,GAAW,CAAC,CAAC;IAC5B,QAAQ,GAAW,CAAC,CAAC;IAEZ,gBAAgB,CAAS;IACzB,YAAY,CAAS;IACrB,gBAAgB,CAAS;IACzB,aAAa,CAAS;IACtB,gBAAgB,CAAqB;IACrC,IAAI,CAAS;IAEtB,SAAS,GAA6B,EAAE,CAAC;IAEjD,YAAY,UAAiC,EAAE;QAC7C,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,KAAK,CAAC;QAClD,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;QACpD,IAAI,CAA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;aAAM,IAAI,QAAQ,KAAK,YAAY,CAAC,MAAM,EAAE,CAAC;YAC5C,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;YACnB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;YACtB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACK,qBAAqB;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;OAEG;IACK,IAAI,CAAC,KAA0B;QACrC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC;gBACH,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;YAAC,MAAM,CAAC;gBACP,yBAAyB;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA+B;IAClE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Error classification and handling utilities for nebula-tools
3
+ *
4
+ * Provides structured error types for better error handling and recovery strategies.
5
+ */
6
+ /**
7
+ * Error categories for classification
8
+ */
9
+ export declare enum ErrorCategory {
10
+ /** Network connectivity issues (connection refused, reset, DNS failures) */
11
+ NETWORK = "NETWORK",
12
+ /** Request timeout exceeded */
13
+ TIMEOUT = "TIMEOUT",
14
+ /** Server-side errors (5xx HTTP status) */
15
+ SERVER = "SERVER",
16
+ /** Client-side errors (4xx HTTP status) */
17
+ CLIENT = "CLIENT",
18
+ /** Validation errors (invalid input, out of range, etc.) */
19
+ VALIDATION = "VALIDATION",
20
+ /** Kernel-related errors (not found, crashed, busy) */
21
+ KERNEL = "KERNEL",
22
+ /** Notebook-related errors (parse failures, missing cells) */
23
+ NOTEBOOK = "NOTEBOOK",
24
+ /** Code execution errors (runtime errors, exceptions) */
25
+ EXECUTION = "EXECUTION",
26
+ /** Unknown or uncategorized errors */
27
+ UNKNOWN = "UNKNOWN"
28
+ }
29
+ /**
30
+ * Whether an error is recoverable (can be retried or has a fallback)
31
+ */
32
+ export type RecoverabilityStatus = 'recoverable' | 'non-recoverable' | 'potentially-recoverable';
33
+ /**
34
+ * Structured error information
35
+ */
36
+ export interface ClassifiedError {
37
+ /** Original error message */
38
+ message: string;
39
+ /** Error category for programmatic handling */
40
+ category: ErrorCategory;
41
+ /** HTTP status code if applicable */
42
+ statusCode?: number;
43
+ /** Whether this error can be recovered from */
44
+ recoverable: RecoverabilityStatus;
45
+ /** Whether this error should be retried */
46
+ retryable: boolean;
47
+ /** Suggested retry delay in milliseconds (if retryable) */
48
+ retryDelayMs?: number;
49
+ /** Original error for debugging */
50
+ originalError?: unknown;
51
+ }
52
+ /**
53
+ * Classify an error into a structured format
54
+ */
55
+ export declare function classifyError(error: unknown, statusCode?: number): ClassifiedError;
56
+ /**
57
+ * Extract error message from various error types
58
+ */
59
+ export declare function getErrorMessage(error: unknown): string;
60
+ /**
61
+ * Create a user-friendly error message from a classified error
62
+ */
63
+ export declare function formatErrorMessage(error: ClassifiedError): string;
64
+ /**
65
+ * Check if an error should trigger a retry
66
+ */
67
+ export declare function shouldRetry(error: ClassifiedError, attemptNumber: number, maxRetries: number): boolean;
68
+ /**
69
+ * Calculate retry delay with exponential backoff
70
+ */
71
+ export declare function calculateRetryDelay(error: ClassifiedError, attemptNumber: number): number;
72
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,oBAAY,aAAa;IACvB,4EAA4E;IAC5E,OAAO,YAAY;IACnB,+BAA+B;IAC/B,OAAO,YAAY;IACnB,2CAA2C;IAC3C,MAAM,WAAW;IACjB,2CAA2C;IAC3C,MAAM,WAAW;IACjB,4DAA4D;IAC5D,UAAU,eAAe;IACzB,uDAAuD;IACvD,MAAM,WAAW;IACjB,8DAA8D;IAC9D,QAAQ,aAAa;IACrB,yDAAyD;IACzD,SAAS,cAAc;IACvB,sCAAsC;IACtC,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG,iBAAiB,GAAG,yBAAyB,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,aAAa,CAAC;IACxB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,WAAW,EAAE,oBAAoB,CAAC;IAClC,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,eAAe,CAuGlF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWtD;AA6JD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAiBjE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAKtG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAMzF"}
package/dist/errors.js ADDED
@@ -0,0 +1,314 @@
1
+ /**
2
+ * Error classification and handling utilities for nebula-tools
3
+ *
4
+ * Provides structured error types for better error handling and recovery strategies.
5
+ */
6
+ /**
7
+ * Error categories for classification
8
+ */
9
+ export var ErrorCategory;
10
+ (function (ErrorCategory) {
11
+ /** Network connectivity issues (connection refused, reset, DNS failures) */
12
+ ErrorCategory["NETWORK"] = "NETWORK";
13
+ /** Request timeout exceeded */
14
+ ErrorCategory["TIMEOUT"] = "TIMEOUT";
15
+ /** Server-side errors (5xx HTTP status) */
16
+ ErrorCategory["SERVER"] = "SERVER";
17
+ /** Client-side errors (4xx HTTP status) */
18
+ ErrorCategory["CLIENT"] = "CLIENT";
19
+ /** Validation errors (invalid input, out of range, etc.) */
20
+ ErrorCategory["VALIDATION"] = "VALIDATION";
21
+ /** Kernel-related errors (not found, crashed, busy) */
22
+ ErrorCategory["KERNEL"] = "KERNEL";
23
+ /** Notebook-related errors (parse failures, missing cells) */
24
+ ErrorCategory["NOTEBOOK"] = "NOTEBOOK";
25
+ /** Code execution errors (runtime errors, exceptions) */
26
+ ErrorCategory["EXECUTION"] = "EXECUTION";
27
+ /** Unknown or uncategorized errors */
28
+ ErrorCategory["UNKNOWN"] = "UNKNOWN";
29
+ })(ErrorCategory || (ErrorCategory = {}));
30
+ /**
31
+ * Classify an error into a structured format
32
+ */
33
+ export function classifyError(error, statusCode) {
34
+ const message = getErrorMessage(error);
35
+ const lowerMessage = message.toLowerCase();
36
+ // Priority 1: Check for AbortError (special timeout case from fetch)
37
+ // This takes highest priority as it's a programmatic signal
38
+ if (error instanceof Error && error.name === 'AbortError') {
39
+ return {
40
+ message,
41
+ category: ErrorCategory.TIMEOUT,
42
+ statusCode,
43
+ recoverable: 'recoverable',
44
+ retryable: true,
45
+ retryDelayMs: 1000,
46
+ originalError: error,
47
+ };
48
+ }
49
+ // Priority 2: HTTP status codes take precedence over message-based classification
50
+ // This ensures server responses are correctly classified
51
+ if (statusCode !== undefined) {
52
+ return classifyByStatusCode(message, statusCode, error);
53
+ }
54
+ // Priority 3: Check for timeout errors (message-based)
55
+ if (isTimeoutError(lowerMessage)) {
56
+ return {
57
+ message,
58
+ category: ErrorCategory.TIMEOUT,
59
+ statusCode,
60
+ recoverable: 'recoverable',
61
+ retryable: true,
62
+ retryDelayMs: 1000,
63
+ originalError: error,
64
+ };
65
+ }
66
+ // Priority 4: Check for network errors
67
+ if (isNetworkError(lowerMessage)) {
68
+ return {
69
+ message,
70
+ category: ErrorCategory.NETWORK,
71
+ statusCode,
72
+ recoverable: 'recoverable',
73
+ retryable: true,
74
+ retryDelayMs: 1000,
75
+ originalError: error,
76
+ };
77
+ }
78
+ // Priority 5: Check for kernel errors
79
+ if (isKernelError(lowerMessage)) {
80
+ return {
81
+ message,
82
+ category: ErrorCategory.KERNEL,
83
+ recoverable: isKernelRecoverable(lowerMessage) ? 'potentially-recoverable' : 'non-recoverable',
84
+ retryable: false,
85
+ originalError: error,
86
+ };
87
+ }
88
+ // Priority 6: Check for execution errors (before notebook to catch "in cell" context)
89
+ if (isExecutionError(lowerMessage)) {
90
+ return {
91
+ message,
92
+ category: ErrorCategory.EXECUTION,
93
+ recoverable: 'non-recoverable',
94
+ retryable: false,
95
+ originalError: error,
96
+ };
97
+ }
98
+ // Priority 7: Check for notebook errors
99
+ if (isNotebookError(lowerMessage)) {
100
+ return {
101
+ message,
102
+ category: ErrorCategory.NOTEBOOK,
103
+ recoverable: 'non-recoverable',
104
+ retryable: false,
105
+ originalError: error,
106
+ };
107
+ }
108
+ // Priority 8: Check for validation errors
109
+ if (isValidationError(lowerMessage)) {
110
+ return {
111
+ message,
112
+ category: ErrorCategory.VALIDATION,
113
+ recoverable: 'non-recoverable',
114
+ retryable: false,
115
+ originalError: error,
116
+ };
117
+ }
118
+ // Default to unknown
119
+ return {
120
+ message,
121
+ category: ErrorCategory.UNKNOWN,
122
+ statusCode,
123
+ recoverable: 'potentially-recoverable',
124
+ retryable: false,
125
+ originalError: error,
126
+ };
127
+ }
128
+ /**
129
+ * Extract error message from various error types
130
+ */
131
+ export function getErrorMessage(error) {
132
+ if (error instanceof Error) {
133
+ return error.message;
134
+ }
135
+ if (typeof error === 'string') {
136
+ return error;
137
+ }
138
+ if (error && typeof error === 'object' && 'message' in error) {
139
+ return String(error.message);
140
+ }
141
+ return String(error);
142
+ }
143
+ /**
144
+ * Check if error message indicates a timeout error
145
+ */
146
+ function isTimeoutError(lowerMessage) {
147
+ return lowerMessage.includes('timeout') || lowerMessage.includes('timed out');
148
+ }
149
+ /**
150
+ * Check if error is a network error
151
+ */
152
+ function isNetworkError(lowerMessage) {
153
+ return (lowerMessage.includes('network') ||
154
+ lowerMessage.includes('econnrefused') ||
155
+ lowerMessage.includes('econnreset') ||
156
+ lowerMessage.includes('enotfound') ||
157
+ lowerMessage.includes('connection refused') ||
158
+ lowerMessage.includes('connection reset') ||
159
+ lowerMessage.includes('dns') ||
160
+ lowerMessage.includes('socket'));
161
+ }
162
+ /**
163
+ * Check if error is a kernel error
164
+ */
165
+ function isKernelError(lowerMessage) {
166
+ return (lowerMessage.includes('kernel') ||
167
+ lowerMessage.includes('session not found') ||
168
+ lowerMessage.includes('session_id'));
169
+ }
170
+ /**
171
+ * Check if kernel error is potentially recoverable
172
+ */
173
+ function isKernelRecoverable(lowerMessage) {
174
+ return (lowerMessage.includes('busy') ||
175
+ lowerMessage.includes('starting') ||
176
+ lowerMessage.includes('restarting'));
177
+ }
178
+ /**
179
+ * Check if error is a notebook error
180
+ */
181
+ function isNotebookError(lowerMessage) {
182
+ return (lowerMessage.includes('notebook') ||
183
+ lowerMessage.includes('parse') ||
184
+ lowerMessage.includes('invalid json') ||
185
+ lowerMessage.includes('cell') ||
186
+ lowerMessage.includes('nbformat'));
187
+ }
188
+ /**
189
+ * Check if error is an execution error
190
+ */
191
+ function isExecutionError(lowerMessage) {
192
+ return (lowerMessage.includes('execution') ||
193
+ lowerMessage.includes('runtime error') ||
194
+ lowerMessage.includes('exception') ||
195
+ lowerMessage.includes('traceback'));
196
+ }
197
+ /**
198
+ * Check if error is a validation error
199
+ */
200
+ function isValidationError(lowerMessage) {
201
+ return (lowerMessage.includes('invalid') ||
202
+ lowerMessage.includes('out of range') ||
203
+ lowerMessage.includes('required') ||
204
+ lowerMessage.includes('missing'));
205
+ }
206
+ /**
207
+ * Classify error by HTTP status code
208
+ */
209
+ function classifyByStatusCode(message, statusCode, originalError) {
210
+ if (statusCode >= 500) {
211
+ return {
212
+ message,
213
+ category: ErrorCategory.SERVER,
214
+ statusCode,
215
+ recoverable: 'recoverable',
216
+ retryable: true,
217
+ retryDelayMs: 1000 * Math.min(Math.ceil(statusCode / 100), 5),
218
+ originalError,
219
+ };
220
+ }
221
+ if (statusCode >= 400) {
222
+ // Specific client error handling
223
+ if (statusCode === 404) {
224
+ return {
225
+ message,
226
+ category: ErrorCategory.CLIENT,
227
+ statusCode,
228
+ recoverable: 'non-recoverable',
229
+ retryable: false,
230
+ originalError,
231
+ };
232
+ }
233
+ if (statusCode === 429) {
234
+ // Rate limiting - recoverable with backoff
235
+ return {
236
+ message,
237
+ category: ErrorCategory.CLIENT,
238
+ statusCode,
239
+ recoverable: 'recoverable',
240
+ retryable: true,
241
+ retryDelayMs: 5000,
242
+ originalError,
243
+ };
244
+ }
245
+ if (statusCode === 408) {
246
+ // Request timeout
247
+ return {
248
+ message,
249
+ category: ErrorCategory.TIMEOUT,
250
+ statusCode,
251
+ recoverable: 'recoverable',
252
+ retryable: true,
253
+ retryDelayMs: 1000,
254
+ originalError,
255
+ };
256
+ }
257
+ return {
258
+ message,
259
+ category: ErrorCategory.CLIENT,
260
+ statusCode,
261
+ recoverable: 'non-recoverable',
262
+ retryable: false,
263
+ originalError,
264
+ };
265
+ }
266
+ // Non-error status codes shouldn't reach here, but handle gracefully
267
+ return {
268
+ message,
269
+ category: ErrorCategory.UNKNOWN,
270
+ statusCode,
271
+ recoverable: 'potentially-recoverable',
272
+ retryable: false,
273
+ originalError,
274
+ };
275
+ }
276
+ /**
277
+ * Create a user-friendly error message from a classified error
278
+ */
279
+ export function formatErrorMessage(error) {
280
+ const categoryDescriptions = {
281
+ [ErrorCategory.NETWORK]: 'Network error',
282
+ [ErrorCategory.TIMEOUT]: 'Request timed out',
283
+ [ErrorCategory.SERVER]: 'Server error',
284
+ [ErrorCategory.CLIENT]: 'Client error',
285
+ [ErrorCategory.VALIDATION]: 'Validation error',
286
+ [ErrorCategory.KERNEL]: 'Kernel error',
287
+ [ErrorCategory.NOTEBOOK]: 'Notebook error',
288
+ [ErrorCategory.EXECUTION]: 'Execution error',
289
+ [ErrorCategory.UNKNOWN]: 'Error',
290
+ };
291
+ const prefix = categoryDescriptions[error.category];
292
+ const statusSuffix = error.statusCode ? ` (${error.statusCode})` : '';
293
+ return `${prefix}${statusSuffix}: ${error.message}`;
294
+ }
295
+ /**
296
+ * Check if an error should trigger a retry
297
+ */
298
+ export function shouldRetry(error, attemptNumber, maxRetries) {
299
+ if (!error.retryable) {
300
+ return false;
301
+ }
302
+ return attemptNumber < maxRetries;
303
+ }
304
+ /**
305
+ * Calculate retry delay with exponential backoff
306
+ */
307
+ export function calculateRetryDelay(error, attemptNumber) {
308
+ const baseDelay = error.retryDelayMs || 1000;
309
+ // Exponential backoff with jitter
310
+ const exponentialDelay = baseDelay * Math.pow(2, attemptNumber);
311
+ const jitter = Math.random() * 0.3 * exponentialDelay;
312
+ return Math.min(exponentialDelay + jitter, 30000); // Cap at 30 seconds
313
+ }
314
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA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O,aAAa,GAAG,UAAU,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAsB,EAAE,aAAqB;IAC/E,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC;IAC7C,kCAAkC;IAClC,MAAM,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,gBAAgB,CAAC;IACtD,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,oBAAoB;AACzE,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Nebula MCP tools and client library.
3
+ *
4
+ * This package is installable on the agent/client machine and talks to a
5
+ * running Nebula Notebook server over HTTP/WebSocket.
6
+ */
7
+ export * from './types.js';
8
+ export { classifyError, getErrorMessage, formatErrorMessage, shouldRetry, calculateRetryDelay, ErrorCategory, type ClassifiedError, type RecoverabilityStatus, } from './errors.js';
9
+ export { CircuitBreaker, createCircuitBreaker, CircuitState, type CircuitBreakerOptions, type CircuitBreakerEvent, type CircuitBreakerListener, type CircuitBreakerResult, } from './circuit-breaker.js';
10
+ export { NebulaClient, createNebulaClient, type NebulaClientConfig, type KernelSession, type ExecutionResult, type WriteCellResult, } from './notebook/client.js';
11
+ export { type Tool, type ToolDefinition, type ToolResult, type MCPContent, allTools, toolsByName, toolCategories, notebookTools, kernelTools, executionTools, getToolDefinitions, executeToolByName, executeToolForMCP, getTool, hasTool, getToolNamesByCategory, readNotebookTool, readCellTool, readOutputTool, insertCellTool, updateCellTool, deleteCellTool, createNotebookTool, moveCellTool, duplicateCellTool, searchCellsTool, updateMetadataTool, listKernelsTool, kernelStartTool, kernelStopTool, kernelRestartTool, kernelInterruptTool, executeCellTool, } from './tools/index.js';
12
+ export { readNotebookCells, writeNotebookCell, executeCell, searchNotebookCells, readCellsToolDefinition, writeCellToolDefinition, executeCellToolDefinition, searchCellsToolDefinition, type ReadCellsParams, type ReadCellsResult, type WriteCellParams, type ExecuteCellParams, type ExecuteCellResult, type SearchCellsParams, type SearchCellsResult, } from './notebook/tools.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,cAAc,YAAY,CAAC;AAK3B,OAAO,EACL,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AAKrB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EAGf,QAAQ,EACR,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EAGd,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,sBAAsB,EAGtB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAGlB,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EAGnB,eAAe,GAChB,MAA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