nebula-notebook-mcp 0.2.0 → 0.3.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/bin/nebula +5 -0
- package/bin/nebula.js +4 -0
- package/dist/cli/compute.d.ts +11 -0
- package/dist/cli/compute.d.ts.map +1 -0
- package/dist/cli/compute.js +405 -0
- package/dist/cli/compute.js.map +1 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +87 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/kernel.d.ts +8 -0
- package/dist/cli/kernel.d.ts.map +1 -0
- package/dist/cli/kernel.js +102 -0
- package/dist/cli/kernel.js.map +1 -0
- package/dist/cli/nb.d.ts +8 -0
- package/dist/cli/nb.d.ts.map +1 -0
- package/dist/cli/nb.js +331 -0
- package/dist/cli/nb.js.map +1 -0
- package/dist/cli/run.d.ts +7 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +120 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/session.d.ts +10 -0
- package/dist/cli/session.d.ts.map +1 -0
- package/dist/cli/session.js +111 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/cli/shared.d.ts +67 -0
- package/dist/cli/shared.d.ts.map +1 -0
- package/dist/cli/shared.js +213 -0
- package/dist/cli/shared.js.map +1 -0
- package/dist/cli/skill.d.ts +12 -0
- package/dist/cli/skill.d.ts.map +1 -0
- package/dist/cli/skill.js +176 -0
- package/dist/cli/skill.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/notebook/client.d.ts +126 -2
- package/dist/notebook/client.d.ts.map +1 -1
- package/dist/notebook/client.js +62 -3
- package/dist/notebook/client.js.map +1 -1
- package/dist/tools/compute.d.ts +62 -0
- package/dist/tools/compute.d.ts.map +1 -0
- package/dist/tools/compute.js +307 -0
- package/dist/tools/compute.js.map +1 -0
- package/dist/tools/files.js +1 -1
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/notebook.js +2 -2
- package/dist/tools/notebook.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/imageResize.d.ts.map +1 -1
- package/dist/utils/imageResize.js +18 -1
- package/dist/utils/imageResize.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nebula kernel …` — kernel status / restart / interrupt for a notebook.
|
|
3
|
+
*
|
|
4
|
+
* Uses the shared NebulaClient kernel-session helpers (same logic as the
|
|
5
|
+
* MCP kernel tools, but addressed by notebook path per invocation).
|
|
6
|
+
*/
|
|
7
|
+
import { CliError, EXIT, makeClient, parse, printHint, printJson, requirePositional, resolveUrl, toCliError, } from './shared.js';
|
|
8
|
+
const KERNEL_HELP = `usage: nebula kernel <status|restart|interrupt> <path>
|
|
9
|
+
|
|
10
|
+
examples:
|
|
11
|
+
nebula kernel status analysis.ipynb # session id, kernel, state
|
|
12
|
+
nebula kernel interrupt analysis.ipynb # stop the running cell
|
|
13
|
+
nebula kernel restart analysis.ipynb # fresh kernel (variables cleared)
|
|
14
|
+
|
|
15
|
+
Exit code 7 means no kernel session exists for the notebook.`;
|
|
16
|
+
export async function cmdKernel(argv) {
|
|
17
|
+
const [sub, ...rest] = argv;
|
|
18
|
+
if (sub === undefined || sub === '--help' || sub === '-h') {
|
|
19
|
+
console.log(KERNEL_HELP);
|
|
20
|
+
return sub === undefined ? EXIT.USAGE : EXIT.OK;
|
|
21
|
+
}
|
|
22
|
+
const { values, positionals } = parse(rest);
|
|
23
|
+
if (values.help) {
|
|
24
|
+
console.log(KERNEL_HELP);
|
|
25
|
+
return EXIT.OK;
|
|
26
|
+
}
|
|
27
|
+
const nbPath = requirePositional(positionals, 0, 'path', `nebula kernel ${sub} <path>`);
|
|
28
|
+
const url = resolveUrl(values.url);
|
|
29
|
+
const client = makeClient(url, nbPath);
|
|
30
|
+
switch (sub) {
|
|
31
|
+
case 'status':
|
|
32
|
+
return kernelStatus(client, nbPath, values);
|
|
33
|
+
case 'restart':
|
|
34
|
+
return kernelRestart(client, nbPath, values);
|
|
35
|
+
case 'interrupt':
|
|
36
|
+
return kernelInterrupt(client, nbPath, values);
|
|
37
|
+
default:
|
|
38
|
+
throw new CliError(`unknown kernel subcommand: ${sub}`, EXIT.USAGE, "run 'nebula kernel --help' for the list");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function kernelStatus(client, nbPath, values) {
|
|
42
|
+
const sessions = await client.listSessions();
|
|
43
|
+
if (!sessions.success)
|
|
44
|
+
throw toCliError(sessions.error, nbPath);
|
|
45
|
+
const matching = (sessions.data ?? []).filter((s) => s.file_path === nbPath);
|
|
46
|
+
if (matching.length === 0) {
|
|
47
|
+
throw new CliError(`no kernel session for ${nbPath}`, EXIT.KERNEL, `one starts automatically on: nebula run ${nbPath} <cell-id>`);
|
|
48
|
+
}
|
|
49
|
+
const session = matching[matching.length - 1];
|
|
50
|
+
if (values.json) {
|
|
51
|
+
printJson(session);
|
|
52
|
+
return EXIT.OK;
|
|
53
|
+
}
|
|
54
|
+
console.log(`session: ${session.id}`);
|
|
55
|
+
console.log(`kernel: ${session.kernel_name}`);
|
|
56
|
+
console.log(`status: ${session.status}`);
|
|
57
|
+
if (session.execution_count !== undefined) {
|
|
58
|
+
console.log(`execution_count: ${session.execution_count}`);
|
|
59
|
+
}
|
|
60
|
+
printHint(`if stuck: nebula kernel interrupt ${nbPath}; for a clean slate: nebula kernel restart ${nbPath}`, values);
|
|
61
|
+
return EXIT.OK;
|
|
62
|
+
}
|
|
63
|
+
async function kernelRestart(client, nbPath, values) {
|
|
64
|
+
// Robust restart (same approach as the MCP kernel_restart tool): shut down
|
|
65
|
+
// any existing session for the file, then start a fresh one.
|
|
66
|
+
const existing = await client.resolveKernelSessionIdForNotebook(nbPath, { createIfMissing: false });
|
|
67
|
+
if (existing.success) {
|
|
68
|
+
const stopped = await client.shutdownKernel(existing.data.sessionId);
|
|
69
|
+
if (!stopped.success && !/not found/i.test(stopped.error ?? '')) {
|
|
70
|
+
throw toCliError(stopped.error, nbPath);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const started = await client.getOrCreateKernelForFile(nbPath);
|
|
74
|
+
if (!started.success)
|
|
75
|
+
throw toCliError(started.error, nbPath);
|
|
76
|
+
if (values.json) {
|
|
77
|
+
printJson({ restarted: true, sessionId: started.data.sessionId, kernelName: started.data.kernelName });
|
|
78
|
+
return EXIT.OK;
|
|
79
|
+
}
|
|
80
|
+
console.log(`kernel restarted: ${started.data.sessionId} (${started.data.kernelName})`);
|
|
81
|
+
printHint('variables were cleared — re-run setup cells before dependent ones', values);
|
|
82
|
+
return EXIT.OK;
|
|
83
|
+
}
|
|
84
|
+
async function kernelInterrupt(client, nbPath, values) {
|
|
85
|
+
const session = await client.resolveKernelSessionIdForNotebook(nbPath, { createIfMissing: false });
|
|
86
|
+
if (!session.success) {
|
|
87
|
+
throw new CliError(`no kernel session for ${nbPath}`, EXIT.KERNEL);
|
|
88
|
+
}
|
|
89
|
+
const result = await client.interruptKernel(session.data.sessionId);
|
|
90
|
+
if (!result.success) {
|
|
91
|
+
const notFound = /not found/i.test(result.error ?? '');
|
|
92
|
+
throw new CliError(result.error ?? 'interrupt failed', notFound ? EXIT.KERNEL : EXIT.ERROR);
|
|
93
|
+
}
|
|
94
|
+
if (values.json) {
|
|
95
|
+
printJson({ interrupted: true, sessionId: session.data.sessionId });
|
|
96
|
+
return EXIT.OK;
|
|
97
|
+
}
|
|
98
|
+
console.log('kernel interrupted');
|
|
99
|
+
printHint(`check state with: nebula kernel status ${nbPath}`, values);
|
|
100
|
+
return EXIT.OK;
|
|
101
|
+
}
|
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CAAC;QACrE,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,SAAS,CAAC,0CAA0C,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC"}
|
package/dist/cli/nb.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nebula nb …` — notebook cell commands (read / edit / insert / delete / search).
|
|
3
|
+
*
|
|
4
|
+
* Thin wrappers over the shared tool objects in ../tools and NebulaClient
|
|
5
|
+
* operations; all HTTP goes through the same code the MCP server uses.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cmdNb(argv: string[]): Promise<number>;
|
|
8
|
+
//# sourceMappingURL=nb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nb.d.ts","sourceRoot":"","sources":["../../src/cli/nb.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuCH,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqB3D"}
|
package/dist/cli/nb.js
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nebula nb …` — notebook cell commands (read / edit / insert / delete / search).
|
|
3
|
+
*
|
|
4
|
+
* Thin wrappers over the shared tool objects in ../tools and NebulaClient
|
|
5
|
+
* operations; all HTTP goes through the same code the MCP server uses.
|
|
6
|
+
*/
|
|
7
|
+
import { randomBytes } from 'node:crypto';
|
|
8
|
+
import { readNotebookTool, readCellTool, insertCellTool, deleteCellTool, searchCellsTool, } from '../tools/notebook.js';
|
|
9
|
+
import { CliError, EXIT, firstLineOf, makeClient, parse, parseIntFlag, printHint, printJson, requirePositional, resolveContentInput, resolveUrl, tailLines, toCliError, } from './shared.js';
|
|
10
|
+
const NB_HELP = `usage: nebula nb <read|edit|insert|delete|search> …
|
|
11
|
+
|
|
12
|
+
examples:
|
|
13
|
+
nebula nb read analysis.ipynb
|
|
14
|
+
nebula nb edit analysis.ipynb cell-3 --content 'x = 42'
|
|
15
|
+
nebula nb insert analysis.ipynb --index -1 --content 'print(x)'
|
|
16
|
+
nebula nb delete analysis.ipynb cell-3
|
|
17
|
+
nebula nb search analysis.ipynb "read_csv"
|
|
18
|
+
|
|
19
|
+
Run 'nebula nb <subcommand> --help' for details.`;
|
|
20
|
+
export async function cmdNb(argv) {
|
|
21
|
+
const [sub, ...rest] = argv;
|
|
22
|
+
switch (sub) {
|
|
23
|
+
case 'read':
|
|
24
|
+
return nbRead(rest);
|
|
25
|
+
case 'edit':
|
|
26
|
+
return nbEdit(rest);
|
|
27
|
+
case 'insert':
|
|
28
|
+
return nbInsert(rest);
|
|
29
|
+
case 'delete':
|
|
30
|
+
return nbDelete(rest);
|
|
31
|
+
case 'search':
|
|
32
|
+
return nbSearch(rest);
|
|
33
|
+
case undefined:
|
|
34
|
+
case '--help':
|
|
35
|
+
case '-h':
|
|
36
|
+
console.log(NB_HELP);
|
|
37
|
+
return sub === undefined ? EXIT.USAGE : EXIT.OK;
|
|
38
|
+
default:
|
|
39
|
+
throw new CliError(`unknown nb subcommand: ${sub}`, EXIT.USAGE, "run 'nebula nb --help' for the list");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// =============================================================================
|
|
43
|
+
// nb read
|
|
44
|
+
// =============================================================================
|
|
45
|
+
const READ_HELP = `usage: nebula nb read <path> [--cells A-B|id,id] [--outputs] [--full]
|
|
46
|
+
|
|
47
|
+
One line per cell: #<idx> <id> <type> [exec_count] <first line…>
|
|
48
|
+
|
|
49
|
+
examples:
|
|
50
|
+
nebula nb read analysis.ipynb # compact listing
|
|
51
|
+
nebula nb read analysis.ipynb --outputs # append truncated output tails
|
|
52
|
+
nebula nb read analysis.ipynb --full # full cell sources
|
|
53
|
+
nebula nb read analysis.ipynb --cells 2-5 # only cells #2..#5
|
|
54
|
+
nebula nb read analysis.ipynb --cells cell-a,cell-b`;
|
|
55
|
+
/** Parse --cells selector: comma list of 1-based indices, A-B ranges, or cell ids. */
|
|
56
|
+
function selectCells(cells, selector) {
|
|
57
|
+
const all = cells.map((cell, index) => ({ cell, index }));
|
|
58
|
+
if (!selector)
|
|
59
|
+
return all;
|
|
60
|
+
const keep = new Set();
|
|
61
|
+
for (const token of selector.split(',').map((t) => t.trim()).filter(Boolean)) {
|
|
62
|
+
const range = token.match(/^(\d+)-(\d+)$/);
|
|
63
|
+
if (range) {
|
|
64
|
+
const from = Number.parseInt(range[1], 10);
|
|
65
|
+
const to = Number.parseInt(range[2], 10);
|
|
66
|
+
for (let i = from; i <= to; i++)
|
|
67
|
+
keep.add(i - 1);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (/^\d+$/.test(token)) {
|
|
71
|
+
keep.add(Number.parseInt(token, 10) - 1);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const byId = cells.findIndex((c) => c.id === token);
|
|
75
|
+
if (byId === -1) {
|
|
76
|
+
throw new CliError(`no cell matches selector "${token}"`, EXIT.ERROR, 'list cell ids with: nebula nb read <path>');
|
|
77
|
+
}
|
|
78
|
+
keep.add(byId);
|
|
79
|
+
}
|
|
80
|
+
return all.filter(({ index }) => keep.has(index));
|
|
81
|
+
}
|
|
82
|
+
function cellLine(cell, index) {
|
|
83
|
+
const exec = cell.executionCount ? ` [${cell.executionCount}]` : '';
|
|
84
|
+
const first = firstLineOf(cell.content);
|
|
85
|
+
return `#${index + 1} ${cell.id} ${cell.type}${exec}${first ? ` ${first}` : ''}`;
|
|
86
|
+
}
|
|
87
|
+
function outputTailLines(cell, maxLines = 3, maxChars = 120) {
|
|
88
|
+
if (!cell.outputs || cell.outputs.length === 0)
|
|
89
|
+
return [];
|
|
90
|
+
const text = cell.outputs
|
|
91
|
+
.map((o) => (o.type === 'image' ? '[image]\n' : o.type === 'error' ? `[error] ${o.content}\n` : o.content))
|
|
92
|
+
.join('');
|
|
93
|
+
return tailLines(text, maxLines).map((line) => {
|
|
94
|
+
const trimmed = line.length > maxChars ? `${line.slice(0, maxChars - 1)}…` : line;
|
|
95
|
+
return ` out: ${trimmed}`;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async function nbRead(argv) {
|
|
99
|
+
const { values, positionals } = parse(argv, {
|
|
100
|
+
cells: { type: 'string' },
|
|
101
|
+
outputs: { type: 'boolean' },
|
|
102
|
+
full: { type: 'boolean' },
|
|
103
|
+
});
|
|
104
|
+
if (values.help) {
|
|
105
|
+
console.log(READ_HELP);
|
|
106
|
+
return EXIT.OK;
|
|
107
|
+
}
|
|
108
|
+
const nbPath = requirePositional(positionals, 0, 'path', 'nebula nb read <path> [--cells …] [--outputs] [--full]');
|
|
109
|
+
const url = resolveUrl(values.url);
|
|
110
|
+
const client = makeClient(url, nbPath);
|
|
111
|
+
const wantOutputs = Boolean(values.outputs);
|
|
112
|
+
const result = await readNotebookTool.execute({ path: nbPath, format: 'content', include_outputs: wantOutputs }, client);
|
|
113
|
+
if (!result.success)
|
|
114
|
+
throw toCliError(result.error, nbPath);
|
|
115
|
+
const { cells, totalCells } = result.data;
|
|
116
|
+
const selected = selectCells(cells, values.cells);
|
|
117
|
+
if (values.json) {
|
|
118
|
+
printJson({ path: nbPath, totalCells, cells: selected.map(({ cell, index }) => ({ index, ...cell })) });
|
|
119
|
+
return EXIT.OK;
|
|
120
|
+
}
|
|
121
|
+
console.log(`${nbPath} (${totalCells} cells)`);
|
|
122
|
+
for (const { cell, index } of selected) {
|
|
123
|
+
if (values.full) {
|
|
124
|
+
console.log('');
|
|
125
|
+
console.log(cellLine(cell, index));
|
|
126
|
+
console.log(cell.content);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.log(cellLine(cell, index));
|
|
130
|
+
}
|
|
131
|
+
if (wantOutputs) {
|
|
132
|
+
for (const line of outputTailLines(cell))
|
|
133
|
+
console.log(line);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (totalCells === 0) {
|
|
137
|
+
printHint(`add a cell with: nebula nb insert ${nbPath} --index -1 --content '…'`, values);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
printHint(`execute a cell with: nebula run ${nbPath} <cell-id>`, values);
|
|
141
|
+
}
|
|
142
|
+
return EXIT.OK;
|
|
143
|
+
}
|
|
144
|
+
// =============================================================================
|
|
145
|
+
// nb edit
|
|
146
|
+
// =============================================================================
|
|
147
|
+
const EDIT_HELP = `usage: nebula nb edit <path> <cell-id> (--content <str> | --content-file <f> | -)
|
|
148
|
+
|
|
149
|
+
Updates a cell's content. The write is OCC-checked: if the cell changed since
|
|
150
|
+
you last read it, the command exits 9 and prints the current content so you
|
|
151
|
+
can retry against it.
|
|
152
|
+
|
|
153
|
+
examples:
|
|
154
|
+
nebula nb edit analysis.ipynb cell-3 --content 'x = 42'
|
|
155
|
+
nebula nb edit analysis.ipynb cell-3 --content-file new_cell.py
|
|
156
|
+
echo 'x = 42' | nebula nb edit analysis.ipynb cell-3 -`;
|
|
157
|
+
async function nbEdit(argv) {
|
|
158
|
+
const { values, positionals } = parse(argv, {
|
|
159
|
+
content: { type: 'string' },
|
|
160
|
+
'content-file': { type: 'string' },
|
|
161
|
+
});
|
|
162
|
+
if (values.help) {
|
|
163
|
+
console.log(EDIT_HELP);
|
|
164
|
+
return EXIT.OK;
|
|
165
|
+
}
|
|
166
|
+
const usage = 'nebula nb edit <path> <cell-id> (--content <str> | --content-file <f> | -)';
|
|
167
|
+
const nbPath = requirePositional(positionals, 0, 'path', usage);
|
|
168
|
+
const cellId = requirePositional(positionals, 1, 'cell-id', usage);
|
|
169
|
+
const stdinMarker = positionals[2] === '-';
|
|
170
|
+
if (positionals.length > 2 && !stdinMarker) {
|
|
171
|
+
throw new CliError(`unexpected argument: ${positionals[2]}`, EXIT.USAGE, `usage: ${usage}`);
|
|
172
|
+
}
|
|
173
|
+
const content = await resolveContentInput(values.content, values['content-file'], stdinMarker);
|
|
174
|
+
const url = resolveUrl(values.url);
|
|
175
|
+
const client = makeClient(url, nbPath);
|
|
176
|
+
// Use the shared operation path directly so OCC conflict metadata
|
|
177
|
+
// (conflict/currentContent) survives to the CLI.
|
|
178
|
+
const result = await client.applyOperation({ type: 'updateContent', notebookPath: nbPath, cellId, content });
|
|
179
|
+
if (!result.success)
|
|
180
|
+
throw toCliError(result.error, nbPath);
|
|
181
|
+
const op = result.data;
|
|
182
|
+
if (!op.success) {
|
|
183
|
+
const isConflict = op.conflict === true || /conflict/i.test(op.error ?? '');
|
|
184
|
+
if (isConflict) {
|
|
185
|
+
let current = op.currentContent;
|
|
186
|
+
if (current === undefined) {
|
|
187
|
+
const read = await readCellTool.execute({ path: nbPath, cell_id: cellId }, client);
|
|
188
|
+
current = read.success ? read.data.cell.content : undefined;
|
|
189
|
+
}
|
|
190
|
+
console.log('CONFLICT: cell changed — current content below; retry your edit against it');
|
|
191
|
+
if (current !== undefined)
|
|
192
|
+
console.log(current);
|
|
193
|
+
console.error(`error: cell ${cellId} was modified since you last read it (OCC conflict)`);
|
|
194
|
+
return EXIT.CONFLICT;
|
|
195
|
+
}
|
|
196
|
+
throw toCliError(op.error, nbPath);
|
|
197
|
+
}
|
|
198
|
+
if (values.json) {
|
|
199
|
+
printJson({ path: nbPath, cellId, updated: true });
|
|
200
|
+
return EXIT.OK;
|
|
201
|
+
}
|
|
202
|
+
console.log(`updated ${cellId}`);
|
|
203
|
+
printHint(`execute it with: nebula run ${nbPath} ${cellId}`, values);
|
|
204
|
+
return EXIT.OK;
|
|
205
|
+
}
|
|
206
|
+
// =============================================================================
|
|
207
|
+
// nb insert
|
|
208
|
+
// =============================================================================
|
|
209
|
+
const INSERT_HELP = `usage: nebula nb insert <path> --index N (--content <str> | --content-file <f> | -)
|
|
210
|
+
[--type code|markdown] [--id ID]
|
|
211
|
+
|
|
212
|
+
--index is 0-based; use -1 to append at the end.
|
|
213
|
+
|
|
214
|
+
examples:
|
|
215
|
+
nebula nb insert analysis.ipynb --index -1 --content 'print(df.shape)'
|
|
216
|
+
nebula nb insert analysis.ipynb --index 0 --type markdown --content '# Intro'
|
|
217
|
+
cat setup.py | nebula nb insert analysis.ipynb --index 2 -`;
|
|
218
|
+
async function nbInsert(argv) {
|
|
219
|
+
const { values, positionals } = parse(argv, {
|
|
220
|
+
index: { type: 'string' },
|
|
221
|
+
content: { type: 'string' },
|
|
222
|
+
'content-file': { type: 'string' },
|
|
223
|
+
type: { type: 'string' },
|
|
224
|
+
id: { type: 'string' },
|
|
225
|
+
});
|
|
226
|
+
if (values.help) {
|
|
227
|
+
console.log(INSERT_HELP);
|
|
228
|
+
return EXIT.OK;
|
|
229
|
+
}
|
|
230
|
+
const usage = 'nebula nb insert <path> --index N (--content … | --content-file … | -) [--type code|markdown] [--id ID]';
|
|
231
|
+
const nbPath = requirePositional(positionals, 0, 'path', usage);
|
|
232
|
+
if (values.index === undefined) {
|
|
233
|
+
throw new CliError('missing --index (use -1 to append)', EXIT.USAGE, `usage: ${usage}`);
|
|
234
|
+
}
|
|
235
|
+
const index = parseIntFlag(values.index, '--index', -1);
|
|
236
|
+
const stdinMarker = positionals[1] === '-';
|
|
237
|
+
const content = await resolveContentInput(values.content, values['content-file'], stdinMarker);
|
|
238
|
+
const cellType = values.type ?? 'code';
|
|
239
|
+
if (cellType !== 'code' && cellType !== 'markdown') {
|
|
240
|
+
throw new CliError(`--type must be code or markdown, got "${cellType}"`, EXIT.USAGE);
|
|
241
|
+
}
|
|
242
|
+
const cellId = values.id ?? `cell-${Date.now().toString(36)}-${randomBytes(2).toString('hex')}`;
|
|
243
|
+
const url = resolveUrl(values.url);
|
|
244
|
+
const client = makeClient(url, nbPath);
|
|
245
|
+
const result = await insertCellTool.execute({ path: nbPath, cell_id: cellId, content, cell_type: cellType, position: index }, client);
|
|
246
|
+
if (!result.success)
|
|
247
|
+
throw toCliError(result.error, nbPath);
|
|
248
|
+
const data = result.data;
|
|
249
|
+
if (values.json) {
|
|
250
|
+
printJson({ path: nbPath, ...data });
|
|
251
|
+
return EXIT.OK;
|
|
252
|
+
}
|
|
253
|
+
let line = `inserted ${data.cellId} at #${data.cellIndex + 1}`;
|
|
254
|
+
if (data.idModified) {
|
|
255
|
+
line += ` (requested id "${data.requestedId}" was taken)`;
|
|
256
|
+
}
|
|
257
|
+
console.log(line);
|
|
258
|
+
printHint(`execute it with: nebula run ${nbPath} ${data.cellId}`, values);
|
|
259
|
+
return EXIT.OK;
|
|
260
|
+
}
|
|
261
|
+
// =============================================================================
|
|
262
|
+
// nb delete
|
|
263
|
+
// =============================================================================
|
|
264
|
+
const DELETE_HELP = `usage: nebula nb delete <path> <cell-id>
|
|
265
|
+
|
|
266
|
+
examples:
|
|
267
|
+
nebula nb delete analysis.ipynb cell-3`;
|
|
268
|
+
async function nbDelete(argv) {
|
|
269
|
+
const { values, positionals } = parse(argv);
|
|
270
|
+
if (values.help) {
|
|
271
|
+
console.log(DELETE_HELP);
|
|
272
|
+
return EXIT.OK;
|
|
273
|
+
}
|
|
274
|
+
const usage = 'nebula nb delete <path> <cell-id>';
|
|
275
|
+
const nbPath = requirePositional(positionals, 0, 'path', usage);
|
|
276
|
+
const cellId = requirePositional(positionals, 1, 'cell-id', usage);
|
|
277
|
+
const url = resolveUrl(values.url);
|
|
278
|
+
const client = makeClient(url, nbPath);
|
|
279
|
+
const result = await deleteCellTool.execute({ path: nbPath, cell_id: cellId }, client);
|
|
280
|
+
if (!result.success)
|
|
281
|
+
throw toCliError(result.error, nbPath);
|
|
282
|
+
if (values.json) {
|
|
283
|
+
printJson({ path: nbPath, cellId, deleted: true });
|
|
284
|
+
return EXIT.OK;
|
|
285
|
+
}
|
|
286
|
+
console.log(`deleted ${cellId}`);
|
|
287
|
+
printHint(`review remaining cells with: nebula nb read ${nbPath}`, values);
|
|
288
|
+
return EXIT.OK;
|
|
289
|
+
}
|
|
290
|
+
// =============================================================================
|
|
291
|
+
// nb search
|
|
292
|
+
// =============================================================================
|
|
293
|
+
const SEARCH_HELP = `usage: nebula nb search <path> <query> [--limit N]
|
|
294
|
+
|
|
295
|
+
examples:
|
|
296
|
+
nebula nb search analysis.ipynb "read_csv"
|
|
297
|
+
nebula nb search analysis.ipynb TODO --limit 20`;
|
|
298
|
+
async function nbSearch(argv) {
|
|
299
|
+
const { values, positionals } = parse(argv, { limit: { type: 'string' } });
|
|
300
|
+
if (values.help) {
|
|
301
|
+
console.log(SEARCH_HELP);
|
|
302
|
+
return EXIT.OK;
|
|
303
|
+
}
|
|
304
|
+
const usage = 'nebula nb search <path> <query> [--limit N]';
|
|
305
|
+
const nbPath = requirePositional(positionals, 0, 'path', usage);
|
|
306
|
+
const query = requirePositional(positionals, 1, 'query', usage);
|
|
307
|
+
const limit = parseIntFlag(values.limit, '--limit', 10);
|
|
308
|
+
const url = resolveUrl(values.url);
|
|
309
|
+
const client = makeClient(url, nbPath);
|
|
310
|
+
const result = await searchCellsTool.execute({ path: nbPath, query, limit }, client);
|
|
311
|
+
if (!result.success)
|
|
312
|
+
throw toCliError(result.error, nbPath);
|
|
313
|
+
const data = result.data;
|
|
314
|
+
if (values.json) {
|
|
315
|
+
printJson(data);
|
|
316
|
+
return EXIT.OK;
|
|
317
|
+
}
|
|
318
|
+
console.log(`${data.matchCount} match${data.matchCount === 1 ? '' : 'es'} for "${query}"`);
|
|
319
|
+
for (const m of data.matches) {
|
|
320
|
+
const loc = m.matchLocation === 'output' ? `output[${m.outputIndex ?? 0}]` : `source:${m.matchLine ?? 0}`;
|
|
321
|
+
console.log(`#${m.cellIndex + 1} ${m.cellId} ${loc} ${m.preview}`);
|
|
322
|
+
}
|
|
323
|
+
if (data.hasMore) {
|
|
324
|
+
console.log(`(showing first ${data.matches.length}; raise --limit for more)`);
|
|
325
|
+
}
|
|
326
|
+
if (data.matchCount > 0) {
|
|
327
|
+
printHint(`view a matching cell with: nebula nb read ${nbPath} --cells <cell-id> --full`, values);
|
|
328
|
+
}
|
|
329
|
+
return EXIT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IAAI,SAAS,KAAK,GAAG,CAAC,CAAC;IAC3F,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;QAC1G,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,OAAO,CAAC,MAAM,2BAA2B,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;QACxB,SAAS,CAAC,6CAA6C,MAAM,2BAA2B,EAAE,MAAM,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nebula run` — the flagship combined operation (AXI): execute a cell and
|
|
3
|
+
* report status, execution count, elapsed time, and the output tail in a
|
|
4
|
+
* single invocation.
|
|
5
|
+
*/
|
|
6
|
+
export declare function cmdRun(argv: string[]): Promise<number>;
|
|
7
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuCH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAgG5D"}
|
package/dist/cli/run.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nebula run` — the flagship combined operation (AXI): execute a cell and
|
|
3
|
+
* report status, execution count, elapsed time, and the output tail in a
|
|
4
|
+
* single invocation.
|
|
5
|
+
*/
|
|
6
|
+
import { EXIT, makeClient, parse, parseIntFlag, printHint, printJson, requirePositional, resolveUrl, tailLines, toCliError, } from './shared.js';
|
|
7
|
+
const RUN_HELP = `usage: nebula run <path> <cell-id> [--tail N] [--max-wait S] [--no-wait]
|
|
8
|
+
|
|
9
|
+
Executes the cell and BLOCKS until it completes (up to --max-wait, default
|
|
10
|
+
300s; 0 = no limit), then prints status, execution_count, elapsed, and the
|
|
11
|
+
last N output lines (default 40). Long runs are followed with cheap internal
|
|
12
|
+
polling — launch this as a background shell task and the process exit IS the
|
|
13
|
+
completion signal (no agent-side polling needed).
|
|
14
|
+
|
|
15
|
+
Non-ok status exits 1 with the error/traceback tail.
|
|
16
|
+
Exit 3 = still running when --max-wait expired (not an error).
|
|
17
|
+
--no-wait = fire-and-forget: start execution and return immediately.
|
|
18
|
+
|
|
19
|
+
examples:
|
|
20
|
+
nebula run analysis.ipynb cell-3
|
|
21
|
+
nebula run analysis.ipynb train-cell --max-wait 0 # wait however long it takes
|
|
22
|
+
nebula run analysis.ipynb train-cell --no-wait # start it and come back later`;
|
|
23
|
+
/** Per-request cap on the server-side long-poll (tunnel/proxy safe). */
|
|
24
|
+
const SERVER_WAIT_CHUNK_S = 25;
|
|
25
|
+
function sleep(ms) {
|
|
26
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
+
}
|
|
28
|
+
export async function cmdRun(argv) {
|
|
29
|
+
const { values, positionals } = parse(argv, {
|
|
30
|
+
tail: { type: 'string' },
|
|
31
|
+
'max-wait': { type: 'string' },
|
|
32
|
+
'no-wait': { type: 'boolean' },
|
|
33
|
+
});
|
|
34
|
+
if (values.help) {
|
|
35
|
+
console.log(RUN_HELP);
|
|
36
|
+
return EXIT.OK;
|
|
37
|
+
}
|
|
38
|
+
const usage = 'nebula run <path> <cell-id> [--tail N] [--max-wait S] [--no-wait]';
|
|
39
|
+
const nbPath = requirePositional(positionals, 0, 'path', usage);
|
|
40
|
+
const cellId = requirePositional(positionals, 1, 'cell-id', usage);
|
|
41
|
+
const tailN = parseIntFlag(values.tail, '--tail', 40);
|
|
42
|
+
const maxWait = parseIntFlag(values['max-wait'], '--max-wait', 300);
|
|
43
|
+
const noWait = values['no-wait'] === true;
|
|
44
|
+
const url = resolveUrl(values.url);
|
|
45
|
+
const client = makeClient(url, nbPath);
|
|
46
|
+
const started = Date.now();
|
|
47
|
+
// --max-wait 0 (CLI) = wait forever. (The MCP's max_wait=0 means "return
|
|
48
|
+
// immediately" — the CLI expresses that as --no-wait instead.)
|
|
49
|
+
const deadline = noWait ? started : maxWait <= 0 ? Number.POSITIVE_INFINITY : started + maxWait * 1000;
|
|
50
|
+
const initialWait = noWait ? 0 : Math.min(maxWait <= 0 ? SERVER_WAIT_CHUNK_S : maxWait, SERVER_WAIT_CHUNK_S);
|
|
51
|
+
const result = await client.executeCellOp(nbPath, { cellId, maxWait: initialWait });
|
|
52
|
+
if (!result.success)
|
|
53
|
+
throw toCliError(result.error, nbPath);
|
|
54
|
+
let d = result.data;
|
|
55
|
+
if (noWait) {
|
|
56
|
+
if (values.json) {
|
|
57
|
+
printJson({ ...d, status: 'started' });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
console.log('status: started');
|
|
61
|
+
printHint(`check on it with: nebula nb read ${nbPath} --cells ${cellId} --outputs`, values);
|
|
62
|
+
}
|
|
63
|
+
return EXIT.OK;
|
|
64
|
+
}
|
|
65
|
+
// Follow the execution: the server long-polls up to SERVER_WAIT_CHUNK_S per
|
|
66
|
+
// request; between requests we back off 2s → 10s. The agent never polls —
|
|
67
|
+
// this process simply doesn't exit until the cell is done (or deadline).
|
|
68
|
+
let pollMs = 2000;
|
|
69
|
+
while (d.executionStatus === 'busy' && Date.now() < deadline) {
|
|
70
|
+
await sleep(Math.min(pollMs, Math.max(0, deadline - Date.now())));
|
|
71
|
+
pollMs = Math.min(pollMs * 1.4, 10_000);
|
|
72
|
+
try {
|
|
73
|
+
const r = await client.readCellOutputOp(nbPath, { cellId });
|
|
74
|
+
if (r.success && r.data) {
|
|
75
|
+
d = {
|
|
76
|
+
...d,
|
|
77
|
+
outputs: r.data.outputs ?? d.outputs,
|
|
78
|
+
executionCount: r.data.executionCount ?? d.executionCount,
|
|
79
|
+
executionStatus: r.data.executionStatus ?? d.executionStatus,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// transient network blip — keep following
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const elapsedSec = d.executionTime !== undefined ? d.executionTime / 1000 : (Date.now() - started) / 1000;
|
|
88
|
+
const failed = d.executionStatus === 'error' || d.outputs.some((o) => o.type === 'error');
|
|
89
|
+
const status = failed ? 'error' : d.executionStatus === 'busy' ? 'busy' : 'ok';
|
|
90
|
+
if (values.json) {
|
|
91
|
+
printJson({ ...d, status, elapsed: elapsedSec });
|
|
92
|
+
return failed ? EXIT.ERROR : status === 'busy' ? EXIT.RUNNING : EXIT.OK;
|
|
93
|
+
}
|
|
94
|
+
console.log(`status: ${status}`);
|
|
95
|
+
console.log(`execution_count: ${d.executionCount ?? '-'}`);
|
|
96
|
+
console.log(`elapsed: ${elapsedSec.toFixed(1)}s`);
|
|
97
|
+
const text = d.outputs
|
|
98
|
+
.map((o) => (o.type === 'image' ? '[image]\n' : o.type === 'error' ? `${o.content}\n` : o.content))
|
|
99
|
+
.join('');
|
|
100
|
+
if (!text.trim()) {
|
|
101
|
+
console.log('(no output)');
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const lines = tailLines(text, tailN);
|
|
105
|
+
console.log(`--- output tail (last ${lines.length} line${lines.length === 1 ? '' : 's'}) ---`);
|
|
106
|
+
for (const line of lines)
|
|
107
|
+
console.log(line);
|
|
108
|
+
}
|
|
109
|
+
if (failed) {
|
|
110
|
+
console.error('error: cell execution failed');
|
|
111
|
+
return EXIT.ERROR;
|
|
112
|
+
}
|
|
113
|
+
if (status === 'busy') {
|
|
114
|
+
printHint(`still running after ${maxWait}s (exit 3); wait to completion with: nebula run ${nbPath} ${cellId} --max-wait 0`, values);
|
|
115
|
+
return EXIT.RUNNING;
|
|
116
|
+
}
|
|
117
|
+
printHint(`see all saved outputs with: nebula nb read ${nbPath} --outputs`, values);
|
|
118
|
+
return EXIT.OK;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,UAAU,EACV,KAAK,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;uFAesE,CAAC;AAExF,wEAAwE;AACxE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE;QAC1C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,IAAI,EAAE,C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AAC,8CAA8C,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;IACpF,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nebula session …` — agent-lock sessions.
|
|
3
|
+
*
|
|
4
|
+
* `session start` acquires the agent lock via the shared client and persists
|
|
5
|
+
* the agent token to $NEBULA_STATE_DIR (or ~/.nebula), keyed by hash of
|
|
6
|
+
* url+path, so separate CLI invocations share the same lock. Other commands
|
|
7
|
+
* attach the token automatically (see makeClient in shared.ts).
|
|
8
|
+
*/
|
|
9
|
+
export declare function cmdSession(argv: string[]): Promise<number>;
|
|
10
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/cli/session.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA6BH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAehE"}
|