nebula-notebook 0.1.1 → 0.2.1
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/README.md +110 -16
- package/dist/assets/errorwidget-Wy5ajPiM.js +5 -0
- package/dist/assets/fa-brands-400-CEJbCg16.woff +0 -0
- package/dist/assets/fa-brands-400-CSYNqBb_.ttf +0 -0
- package/dist/assets/fa-brands-400-DnkPfk3o.eot +0 -0
- package/dist/assets/fa-brands-400-UxlILjvJ.woff2 +0 -0
- package/dist/assets/fa-brands-400-cH1MgKbP.svg +3717 -0
- package/dist/assets/fa-regular-400-BhTwtT8w.eot +0 -0
- package/dist/assets/fa-regular-400-D1vz6WBx.ttf +0 -0
- package/dist/assets/fa-regular-400-DFnMcJPd.woff +0 -0
- package/dist/assets/fa-regular-400-DGzu1beS.woff2 +0 -0
- package/dist/assets/fa-regular-400-gwj8Pxq-.svg +801 -0
- package/dist/assets/fa-solid-900-B4ZZ7kfP.svg +5034 -0
- package/dist/assets/fa-solid-900-B6Axprfb.eot +0 -0
- package/dist/assets/fa-solid-900-BUswJgRo.woff2 +0 -0
- package/dist/assets/fa-solid-900-DOXgCApm.woff +0 -0
- package/dist/assets/fa-solid-900-mxuxnBEa.ttf +0 -0
- package/dist/assets/index-B_Bs5koo.js +1 -0
- package/dist/assets/index-BtWv4MIT.css +7 -0
- package/dist/assets/index-DK4nS74r.js +829 -0
- package/dist/assets/index-DeQN03nW.js +81 -0
- package/dist/assets/index-DzjpmUak.css +32 -0
- package/dist/assets/index-g6MjT-VG.js +1 -0
- package/dist/assets/services-shim-BirHVsih.js +33 -0
- package/dist/assets/viewlist-uomDf7I7.js +1 -0
- package/dist/assets/widgets-X7J3NxEn.css +1 -0
- package/dist/index.html +2 -2
- package/node-server/dist/auth/auth-middleware.js +22 -4
- package/node-server/dist/auth/auth-service.js +37 -7
- package/node-server/dist/cluster/client-registration.d.ts +12 -1
- package/node-server/dist/cluster/client-registration.js +38 -2
- package/node-server/dist/cluster/kernel-proxy.js +43 -12
- package/node-server/dist/cluster/server-registry.d.ts +17 -0
- package/node-server/dist/cluster/server-registry.js +57 -7
- package/node-server/dist/discovery/conda-locations.d.ts +73 -0
- package/node-server/dist/discovery/conda-locations.js +427 -0
- package/node-server/dist/discovery/discovery-service.d.ts +73 -4
- package/node-server/dist/discovery/discovery-service.js +211 -127
- package/node-server/dist/discovery/types.d.ts +0 -1
- package/node-server/dist/discovery/types.js +1 -2
- package/node-server/dist/environment.d.ts +12 -0
- package/node-server/dist/environment.js +104 -0
- package/node-server/dist/fs/fs-service.d.ts +86 -8
- package/node-server/dist/fs/fs-service.js +640 -99
- package/node-server/dist/fs/notebook-formats/percent.d.ts +25 -0
- package/node-server/dist/fs/notebook-formats/percent.js +286 -0
- package/node-server/dist/fs/notebook-formats/qmd.d.ts +29 -0
- package/node-server/dist/fs/notebook-formats/qmd.js +307 -0
- package/node-server/dist/fs/notebook-formats/registry.d.ts +12 -0
- package/node-server/dist/fs/notebook-formats/registry.js +77 -0
- package/node-server/dist/fs/notebook-formats/types.d.ts +37 -0
- package/node-server/dist/fs/notebook-formats/types.js +13 -0
- package/node-server/dist/fs/types.d.ts +9 -0
- package/node-server/dist/fs/types.js +8 -0
- package/node-server/dist/idle-exit.d.ts +52 -0
- package/node-server/dist/idle-exit.js +83 -0
- package/node-server/dist/index.js +198 -8
- package/node-server/dist/kernel/kernel-service.d.ts +130 -2
- package/node-server/dist/kernel/kernel-service.js +834 -64
- package/node-server/dist/kernel/kernelspec.d.ts +27 -0
- package/node-server/dist/kernel/kernelspec.js +75 -4
- package/node-server/dist/notebook/headless-handler.d.ts +12 -0
- package/node-server/dist/notebook/headless-handler.js +125 -29
- package/node-server/dist/notebook/operation-router.js +7 -2
- package/node-server/dist/notebook/undoRedoManager.d.ts +12 -1
- package/node-server/dist/notebook/undoRedoManager.js +49 -18
- package/node-server/dist/output/display-data.js +2 -0
- package/node-server/dist/private-tmp.d.ts +14 -0
- package/node-server/dist/private-tmp.js +70 -0
- package/node-server/dist/routes/autocomplete.d.ts +19 -0
- package/node-server/dist/routes/autocomplete.js +294 -0
- package/node-server/dist/routes/cluster.js +2 -2
- package/node-server/dist/routes/compute.d.ts +8 -0
- package/node-server/dist/routes/compute.js +136 -0
- package/node-server/dist/routes/fs.js +23 -6
- package/node-server/dist/routes/kernel.js +156 -3
- package/node-server/dist/routes/notebook.js +37 -3
- package/node-server/dist/routes/python.d.ts +1 -2
- package/node-server/dist/routes/python.js +139 -3
- package/node-server/dist/scheduler/allocation-service.d.ts +63 -0
- package/node-server/dist/scheduler/allocation-service.js +285 -0
- package/node-server/dist/scheduler/job-template.d.ts +30 -0
- package/node-server/dist/scheduler/job-template.js +85 -0
- package/node-server/dist/scheduler/mock-scheduler.d.ts +30 -0
- package/node-server/dist/scheduler/mock-scheduler.js +125 -0
- package/node-server/dist/scheduler/slurm-scheduler.d.ts +31 -0
- package/node-server/dist/scheduler/slurm-scheduler.js +406 -0
- package/node-server/dist/scheduler/types.d.ts +118 -0
- package/node-server/dist/scheduler/types.js +8 -0
- package/node-server/dist/scheduler/util.d.ts +7 -0
- package/node-server/dist/scheduler/util.js +20 -0
- package/node-server/dist/terminal/agent-registry.d.ts +87 -0
- package/node-server/dist/terminal/agent-registry.js +246 -0
- package/node-server/dist/terminal/binding-store.d.ts +57 -0
- package/node-server/dist/terminal/binding-store.js +0 -0
- package/node-server/dist/terminal/pty-manager.d.ts +23 -6
- package/node-server/dist/terminal/pty-manager.js +138 -19
- package/node-server/dist/terminal/server.js +155 -23
- package/node-server/dist/terminal/types.d.ts +2 -0
- package/node-server/dist/update-check.d.ts +20 -0
- package/node-server/dist/update-check.js +114 -0
- package/node-server/package.json +2 -0
- package/node_modules/nebula-autocomplete/README.md +145 -0
- package/node_modules/nebula-autocomplete/dist/backends/claude.d.ts +69 -0
- package/node_modules/nebula-autocomplete/dist/backends/claude.js +449 -0
- package/node_modules/nebula-autocomplete/dist/backends/codex.d.ts +45 -0
- package/node_modules/nebula-autocomplete/dist/backends/codex.js +108 -0
- package/node_modules/nebula-autocomplete/dist/client/fetcher.d.ts +16 -0
- package/node_modules/nebula-autocomplete/dist/client/fetcher.js +41 -0
- package/node_modules/nebula-autocomplete/dist/codemirror/ghostText.d.ts +43 -0
- package/node_modules/nebula-autocomplete/dist/codemirror/ghostText.js +175 -0
- package/node_modules/nebula-autocomplete/dist/core/engine.d.ts +17 -0
- package/node_modules/nebula-autocomplete/dist/core/engine.js +135 -0
- package/node_modules/nebula-autocomplete/dist/core/lru.d.ts +7 -0
- package/node_modules/nebula-autocomplete/dist/core/lru.js +26 -0
- package/node_modules/nebula-autocomplete/dist/core/prompt.d.ts +12 -0
- package/node_modules/nebula-autocomplete/dist/core/prompt.js +0 -0
- package/node_modules/nebula-autocomplete/dist/core/text.d.ts +53 -0
- package/node_modules/nebula-autocomplete/dist/core/text.js +169 -0
- package/node_modules/nebula-autocomplete/dist/index.d.ts +7 -0
- package/node_modules/nebula-autocomplete/dist/index.js +5 -0
- package/node_modules/nebula-autocomplete/dist/server/fastify.d.ts +40 -0
- package/node_modules/nebula-autocomplete/dist/server/fastify.js +52 -0
- package/node_modules/nebula-autocomplete/dist/transport.d.ts +55 -0
- package/node_modules/nebula-autocomplete/dist/transport.js +66 -0
- package/node_modules/nebula-autocomplete/dist/types.d.ts +103 -0
- package/node_modules/nebula-autocomplete/dist/types.js +1 -0
- package/node_modules/nebula-autocomplete/package.json +58 -0
- package/node_modules/nebula-autocomplete/server.d.ts +3 -0
- package/node_modules/nebula-autocomplete/server.js +3 -0
- package/package.json +18 -5
- package/scripts/postinstall.cjs +25 -5
- package/dist/assets/index-BvrHu37J.js +0 -648
- package/dist/assets/index-Dfj_xsKU.css +0 -32
- package/node-server/dist/llm/index.d.ts +0 -5
- package/node-server/dist/llm/index.js +0 -21
- package/node-server/dist/llm/llm-service.d.ts +0 -77
- package/node-server/dist/llm/llm-service.js +0 -454
- package/node-server/dist/llm/types.d.ts +0 -40
- package/node-server/dist/llm/types.js +0 -15
- package/node-server/dist/routes/llm.d.ts +0 -8
- package/node-server/dist/routes/llm.js +0 -105
|
@@ -7,6 +7,36 @@
|
|
|
7
7
|
import { KernelOutput, ExecutionResult, ExecutionQueueInfo, StartKernelOptions, SessionInfo, KernelServiceConfig } from './types';
|
|
8
8
|
import { SessionStore } from './session-store';
|
|
9
9
|
import { KernelSpec } from './kernelspec';
|
|
10
|
+
/** Kernel-originated comm event surfaced to onComm listeners. */
|
|
11
|
+
export interface CommEvent {
|
|
12
|
+
msgType: 'comm_open' | 'comm_msg' | 'comm_close';
|
|
13
|
+
commId: string;
|
|
14
|
+
targetName?: string;
|
|
15
|
+
data: Record<string, unknown>;
|
|
16
|
+
/** Binary buffer frames, base64-encoded. Present only when non-empty. */
|
|
17
|
+
buffers?: string[];
|
|
18
|
+
}
|
|
19
|
+
/** Resolved by BoundedAsyncQueue.next() when the queue has been closed. */
|
|
20
|
+
export declare const IOPUB_QUEUE_CLOSED: unique symbol;
|
|
21
|
+
/** Resolved by BoundedAsyncQueue.next(timeoutMs) when the wait timed out. */
|
|
22
|
+
export declare const IOPUB_QUEUE_TIMEOUT: unique symbol;
|
|
23
|
+
/**
|
|
24
|
+
* Polyfill IPython-style `!command` lines for kernels whose language lacks
|
|
25
|
+
* them, by rewriting each such line into the language's own shell-call idiom
|
|
26
|
+
* before the code reaches the kernel. Because the rewritten code still runs
|
|
27
|
+
* in the kernel process, cwd, environment (conda env, loaded modules), and
|
|
28
|
+
* machine (allocation node) are all the kernel's — the same guarantees
|
|
29
|
+
* IPython's native `!` gives Python users.
|
|
30
|
+
*
|
|
31
|
+
* Python kernels are deliberately untouched: IPython's `!` is richer than a
|
|
32
|
+
* plain shell call (output capture `x = !ls`, `{var}` interpolation,
|
|
33
|
+
* streaming output) and a rewrite would break it.
|
|
34
|
+
*
|
|
35
|
+
* Only whole lines that start with `!` are rewritten. Known limits (v1):
|
|
36
|
+
* a line inside a multi-line string that happens to start with `!` would be
|
|
37
|
+
* rewritten too, and R's intern=TRUE buffers output until the command exits.
|
|
38
|
+
*/
|
|
39
|
+
export declare function rewriteShellLines(code: string, language: string | undefined): string;
|
|
10
40
|
export declare class KernelService {
|
|
11
41
|
private sessions;
|
|
12
42
|
private fileToSession;
|
|
@@ -28,7 +58,23 @@ export declare class KernelService {
|
|
|
28
58
|
private cellOutputBuffers;
|
|
29
59
|
private cellOutputTracking;
|
|
30
60
|
private executingCellIds;
|
|
61
|
+
private iopubReaders;
|
|
62
|
+
private iopubParentSubscribers;
|
|
63
|
+
private iopubCatchAllSubscribers;
|
|
64
|
+
private commStates;
|
|
65
|
+
private shellReaders;
|
|
66
|
+
private shellReplyWaiters;
|
|
31
67
|
constructor(config?: KernelServiceConfig, sessionStore?: SessionStore);
|
|
68
|
+
private deadListeners;
|
|
69
|
+
onSessionDead(cb: (sessionId: string) => void): void;
|
|
70
|
+
private notifySessionDead;
|
|
71
|
+
private commListeners;
|
|
72
|
+
onComm(cb: (sessionId: string, comm: CommEvent) => void): void;
|
|
73
|
+
private notifyComm;
|
|
74
|
+
private livenessTimer;
|
|
75
|
+
private startLivenessSweep;
|
|
76
|
+
/** One liveness pass (exposed for tests; normally driven by the timer). */
|
|
77
|
+
sweepLiveness(): void;
|
|
32
78
|
setServerIdentity(serverId: string, serverInstanceId?: string): void;
|
|
33
79
|
/**
|
|
34
80
|
* Check if a PID is still alive.
|
|
@@ -109,6 +155,57 @@ export declare class KernelService {
|
|
|
109
155
|
* @param pid Optional kernel PID — used to distinguish "busy" from "dead" on timeout
|
|
110
156
|
*/
|
|
111
157
|
private waitForReady;
|
|
158
|
+
private startIopubReader;
|
|
159
|
+
private stopIopubReader;
|
|
160
|
+
private closeIopubSubscribers;
|
|
161
|
+
private dispatchIopubMessage;
|
|
162
|
+
/**
|
|
163
|
+
* Subscribe to iopub messages parented by a specific msg_id. Must be called
|
|
164
|
+
* BEFORE sending the request so no reply can slip past the demux. Callers
|
|
165
|
+
* must unsubscribe in a finally block.
|
|
166
|
+
*/
|
|
167
|
+
private subscribeIopubParent;
|
|
168
|
+
private unsubscribeIopubParent;
|
|
169
|
+
/** Subscribe to ALL iopub messages for a session (any parent). */
|
|
170
|
+
private subscribeIopubCatchAll;
|
|
171
|
+
private unsubscribeIopubCatchAll;
|
|
172
|
+
private startShellReader;
|
|
173
|
+
private stopShellReader;
|
|
174
|
+
private closeShellReplyWaiters;
|
|
175
|
+
/**
|
|
176
|
+
* Register a one-shot waiter for the shell reply parented by msgId. Must be
|
|
177
|
+
* called BEFORE sending the request so the reply cannot slip past the
|
|
178
|
+
* dispatch. Resolves 'closed' immediately if no reader loop is alive, or
|
|
179
|
+
* later when the reader stops (kernel stop/restart/cleanup).
|
|
180
|
+
*/
|
|
181
|
+
private registerShellReplyWaiter;
|
|
182
|
+
private removeShellReplyWaiter;
|
|
183
|
+
/**
|
|
184
|
+
* Await a previously registered shell reply with a timeout. The waiter is
|
|
185
|
+
* always deregistered on the way out (timeout, reply, or error), so a late
|
|
186
|
+
* reply is dropped by the reader instead of leaking a waiter.
|
|
187
|
+
*/
|
|
188
|
+
private waitForShellReply;
|
|
189
|
+
private handleKernelCommMessage;
|
|
190
|
+
private rememberOpenComm;
|
|
191
|
+
/**
|
|
192
|
+
* Open comms known for a session (for late-joining clients).
|
|
193
|
+
* Returns comm_id -> { targetName, openData } where openData is the last
|
|
194
|
+
* state-carrying comm_open payload observed for that comm.
|
|
195
|
+
*/
|
|
196
|
+
getOpenComms(sessionId: string): Record<string, {
|
|
197
|
+
targetName: string;
|
|
198
|
+
openData: Record<string, unknown>;
|
|
199
|
+
}>;
|
|
200
|
+
/**
|
|
201
|
+
* Send a comm message (comm_open / comm_msg / comm_close) to the kernel on
|
|
202
|
+
* the shell channel. Comm messages produce NO shell reply, so the queued
|
|
203
|
+
* slot releases as soon as the send completes — we never block waiting for
|
|
204
|
+
* a reply that will not come.
|
|
205
|
+
*
|
|
206
|
+
* @param buffers Optional binary buffer frames, base64-encoded.
|
|
207
|
+
*/
|
|
208
|
+
sendCommMessage(sessionId: string, msgType: 'comm_open' | 'comm_msg' | 'comm_close', content: Record<string, unknown>, buffers?: string[]): Promise<void>;
|
|
112
209
|
/**
|
|
113
210
|
* Monitor a busy reattached kernel on iopub. When its current execution
|
|
114
211
|
* finishes (status: idle on iopub), verify shell connectivity and update
|
|
@@ -128,10 +225,16 @@ export declare class KernelService {
|
|
|
128
225
|
* Get or create kernel for a file (one notebook = one kernel).
|
|
129
226
|
* Returns whether a new session was created.
|
|
130
227
|
*/
|
|
228
|
+
/** In-flight create/attach per normalized file path (single-flight).
|
|
229
|
+
* Without this, two near-simultaneous requests (UI re-render + agent op,
|
|
230
|
+
* double-click) both miss the fileToSession check and spawn TWO kernel
|
|
231
|
+
* processes — the second overwrites the mapping and the first leaks. */
|
|
232
|
+
private inflightKernelCreates;
|
|
131
233
|
getOrCreateKernel(filePath: string, kernelName?: string): Promise<{
|
|
132
234
|
sessionId: string;
|
|
133
235
|
created: boolean;
|
|
134
236
|
}>;
|
|
237
|
+
private getOrCreateKernelInternal;
|
|
135
238
|
/**
|
|
136
239
|
* Get existing kernel session ID for a notebook file (if any).
|
|
137
240
|
* Returns null if no live session is associated with the file.
|
|
@@ -156,7 +259,11 @@ export declare class KernelService {
|
|
|
156
259
|
executeCode(sessionId: string, code: string, onOutput: (output: KernelOutput, cellId?: string | null) => Promise<void>, onQueueInfo?: (info: ExecutionQueueInfo) => void, cellId?: string | null): Promise<ExecutionResult>;
|
|
157
260
|
private enqueueExecution;
|
|
158
261
|
/**
|
|
159
|
-
*
|
|
262
|
+
* Serialize shell socket SENDS. Receives are owned by the unified shell
|
|
263
|
+
* reader, so tasks queued here must be send-only and release the slot as
|
|
264
|
+
* soon as the send completes (register any reply waiter BEFORE enqueueing,
|
|
265
|
+
* await the reply AFTER the slot is released). Holding the slot across a
|
|
266
|
+
* reply wait would let one slow request delay every later send.
|
|
160
267
|
*/
|
|
161
268
|
private enqueueShellRequest;
|
|
162
269
|
private reserveExecutionSlot;
|
|
@@ -174,7 +281,10 @@ export declare class KernelService {
|
|
|
174
281
|
cursor_end: number;
|
|
175
282
|
}>;
|
|
176
283
|
/**
|
|
177
|
-
* Internal completion implementation
|
|
284
|
+
* Internal completion implementation. The send is serialized through the
|
|
285
|
+
* shell queue; the reply is awaited via the unified shell reader, so a
|
|
286
|
+
* timeout here simply drops the waiter and can never block or swallow a
|
|
287
|
+
* later request's reply.
|
|
178
288
|
*/
|
|
179
289
|
private completeInternal;
|
|
180
290
|
/**
|
|
@@ -247,6 +357,15 @@ export declare class KernelService {
|
|
|
247
357
|
*/
|
|
248
358
|
getSessionStatusFast(sessionId: string): SessionInfo | null;
|
|
249
359
|
getSessionStatus(sessionId: string): Promise<SessionInfo | null>;
|
|
360
|
+
/**
|
|
361
|
+
* Activity snapshot for the idle auto-release monitor (client mode):
|
|
362
|
+
* whether any kernel is busy/starting, and the most recent kernel activity
|
|
363
|
+
* across sessions in ms since epoch (sessions track it in seconds).
|
|
364
|
+
*/
|
|
365
|
+
getIdleSnapshot(): {
|
|
366
|
+
anyBusy: boolean;
|
|
367
|
+
lastActivityMs: number | null;
|
|
368
|
+
};
|
|
250
369
|
/**
|
|
251
370
|
* Get all sessions
|
|
252
371
|
*/
|
|
@@ -261,6 +380,15 @@ export declare class KernelService {
|
|
|
261
380
|
status: string;
|
|
262
381
|
lastHeartbeat: number;
|
|
263
382
|
}[];
|
|
383
|
+
/**
|
|
384
|
+
* Auto-delete dead session rows whose kernel process is CONFIRMED gone
|
|
385
|
+
* (no PID, PID not running, or PID reused by another process). These are
|
|
386
|
+
* pure bookkeeping — nothing to kill, nothing to lose — so they need no
|
|
387
|
+
* user confirmation. Rows whose PID is still alive are kept for the
|
|
388
|
+
* explicit "Clean Up" flow (killing a process should stay a user action,
|
|
389
|
+
* and legacy rows without a start-time fingerprint can't be verified).
|
|
390
|
+
*/
|
|
391
|
+
autoCleanupDeadSessions(): Promise<number>;
|
|
264
392
|
/**
|
|
265
393
|
* Cleanup dead sessions by deleting them from the database
|
|
266
394
|
*/
|