@hy-sde-org/dsh-code-runtime-kernels 0.1.0-rc.8
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/LICENSE +32 -0
- package/README.md +85 -0
- package/README.zh.md +85 -0
- package/cordis.patch.yml +34 -0
- package/dist/core/invariant.d.ts +16 -0
- package/dist/core/invariant.d.ts.map +1 -0
- package/dist/core/invariant.js +23 -0
- package/dist/core/invariant.js.map +1 -0
- package/dist/core/kernel.d.ts +133 -0
- package/dist/core/kernel.d.ts.map +1 -0
- package/dist/core/kernel.js +565 -0
- package/dist/core/kernel.js.map +1 -0
- package/dist/core/protocol.d.ts +115 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +12 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/core/session.d.ts +49 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +153 -0
- package/dist/core/session.js.map +1 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +478 -0
- package/dist/index.js.map +1 -0
- package/dist/nodejs/runner.d.ts +26 -0
- package/dist/nodejs/runner.d.ts.map +1 -0
- package/dist/nodejs/runner.js +298 -0
- package/dist/nodejs/runner.js.map +1 -0
- package/dist/python/runner.d.ts +26 -0
- package/dist/python/runner.d.ts.map +1 -0
- package/dist/python/runner.js +615 -0
- package/dist/python/runner.js.map +1 -0
- package/package.json +85 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `run_kernel_code` — the persistent kernel tool for DeepSeek Harness,
|
|
3
|
+
* self-contained (no upstream harness changes required, same as the sibling
|
|
4
|
+
* dsh-tool-ast plugin). One long-lived `python3` or `node` subprocess per
|
|
5
|
+
* `session` keeps state across calls; runs without a session are one-shot
|
|
6
|
+
* (a fresh kernel spawning for exactly one program). The host driver, session
|
|
7
|
+
* registry, and output ledger in `core/` are shared by both languages; each
|
|
8
|
+
* language's runner program lives in `src/python` / `src/nodejs`.
|
|
9
|
+
* This is process confinement, not a security boundary: model code has
|
|
10
|
+
* bash-equivalent trust.
|
|
11
|
+
* @module @hy-sde-org/dsh-code-runtime-kernels
|
|
12
|
+
*/
|
|
13
|
+
import { randomUUID } from 'node:crypto';
|
|
14
|
+
import z from '@deepseek-ai/schemastery';
|
|
15
|
+
import { DUNDER_MEMBER, PORTABLE_RESERVED_WORDS, RESERVED_BINDING_GLOBALS, RESERVED_ERROR_MEMBERS, } from '@deepseek-ai/dsh-code-runtime';
|
|
16
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
17
|
+
import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout';
|
|
18
|
+
import { KernelHost, nodejsKernelProfile } from "./core/kernel.js";
|
|
19
|
+
import { SessionRegistry } from "./core/session.js";
|
|
20
|
+
import { PYTHON_RUNNER } from "./python/runner.js";
|
|
21
|
+
/** Cordis plugin name for loader diagnostics. */
|
|
22
|
+
export const name = 'code-runtime-kernels';
|
|
23
|
+
/** Services this plugin requires: the tool registry and the system-prompt builder. */
|
|
24
|
+
export const inject = ['tools', 'systemPrompt'];
|
|
25
|
+
/** Schemastery schema for {@link Config}: defaults filled at load time. */
|
|
26
|
+
export const Config = z.object({
|
|
27
|
+
languages: z.array(z.union(['python', 'typescript'])).default(['python', 'typescript']),
|
|
28
|
+
pythonPath: z.string(),
|
|
29
|
+
nodePath: z.string(),
|
|
30
|
+
toolTimeoutMs: z.number().default(30_000),
|
|
31
|
+
maxWallMs: z.number().default(600_000),
|
|
32
|
+
maxOutputBytes: z.number().default(67_108_864),
|
|
33
|
+
sessionIdleMs: z.number().default(0),
|
|
34
|
+
interruptEscalationMs: z.number().default(5_000),
|
|
35
|
+
startupTimeoutMs: z.number().default(15_000),
|
|
36
|
+
shutdownGraceMs: z.number().default(1_000),
|
|
37
|
+
});
|
|
38
|
+
/** Smallest cap that can represent the counted payloads: an empty logs array plus an empty JSON failure message. */
|
|
39
|
+
const MIN_OUTPUT_BYTES = 4;
|
|
40
|
+
/** Constructor for a timeout-flavored abort reason, surfacing the budget in the result. */
|
|
41
|
+
class RunTimeoutError extends Error {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = 'TimeoutError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The language-portable identifier subset (see `CodeBindingNamespace.global`). */
|
|
48
|
+
const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
49
|
+
/**
|
|
50
|
+
* Outer-output ledger for one run: admits log entries, the completion value,
|
|
51
|
+
* and the failure message against one combined byte cap (same semantics as the
|
|
52
|
+
* worker-thread backend's ledger — a value is a compact JSON serialization,
|
|
53
|
+
* text is UTF-8 byte-counted).
|
|
54
|
+
*/
|
|
55
|
+
class OutputLedger {
|
|
56
|
+
maxBytes;
|
|
57
|
+
bytes = 2; // JSON serialization of the empty logs array: []
|
|
58
|
+
entries = 0;
|
|
59
|
+
constructor(maxBytes) {
|
|
60
|
+
this.maxBytes = maxBytes;
|
|
61
|
+
}
|
|
62
|
+
textBytes(text) {
|
|
63
|
+
return Buffer.byteLength(text, 'utf8');
|
|
64
|
+
}
|
|
65
|
+
/** Admit one exact log entry, or report that the hard cap was crossed. */
|
|
66
|
+
admit(text, sink) {
|
|
67
|
+
const separatorBytes = this.entries > 0 ? 1 : 0;
|
|
68
|
+
const stringBytes = this.textBytes(text);
|
|
69
|
+
if (this.bytes + stringBytes + separatorBytes > this.maxBytes)
|
|
70
|
+
return false;
|
|
71
|
+
this.bytes += stringBytes + separatorBytes;
|
|
72
|
+
this.entries += 1;
|
|
73
|
+
sink.push(text);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/** Finalize a successful absent-or-JSON completion against the combined cap. */
|
|
77
|
+
success(logs, value) {
|
|
78
|
+
if (value === undefined)
|
|
79
|
+
return { logs };
|
|
80
|
+
const valueBytes = this.compactJsonBytes(value);
|
|
81
|
+
if (valueBytes === undefined || this.bytes + valueBytes > this.maxBytes)
|
|
82
|
+
return this.limit(logs);
|
|
83
|
+
return { logs, value };
|
|
84
|
+
}
|
|
85
|
+
/** Finalize a failure diagnostic, with output-limit taking precedence over the cap. */
|
|
86
|
+
failure(logs, error) {
|
|
87
|
+
const messageBytes = this.textBytes(error.message);
|
|
88
|
+
if (this.bytes + messageBytes <= this.maxBytes)
|
|
89
|
+
return { logs, error };
|
|
90
|
+
return this.limit(logs);
|
|
91
|
+
}
|
|
92
|
+
/** Build the explicit output-limit failure while retaining fitting logs. */
|
|
93
|
+
limit(logs) {
|
|
94
|
+
const fullMessage = `outer output exceeded ${this.maxBytes} bytes`;
|
|
95
|
+
const messageBytes = this.textBytes(fullMessage);
|
|
96
|
+
const retained = [];
|
|
97
|
+
let retainedBytes = 2;
|
|
98
|
+
for (const text of logs) {
|
|
99
|
+
const separatorBytes = retained.length > 0 ? 1 : 0;
|
|
100
|
+
if (retainedBytes + this.textBytes(text) + separatorBytes + messageBytes > this.maxBytes)
|
|
101
|
+
break;
|
|
102
|
+
retained.push(text);
|
|
103
|
+
retainedBytes += this.textBytes(text) + separatorBytes;
|
|
104
|
+
}
|
|
105
|
+
return { logs: retained, error: { kind: 'output-limit', message: fullMessage } };
|
|
106
|
+
}
|
|
107
|
+
compactJsonBytes(value) {
|
|
108
|
+
let text;
|
|
109
|
+
try {
|
|
110
|
+
text = JSON.stringify(value);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return this.textBytes(text);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Owns the two persistent kernel registries and maps one `KernelRunRequest`
|
|
120
|
+
* onto the same outcome vocabulary as the code-execution seam
|
|
121
|
+
* (`CodeRunResult` + `CodeRunFailure` kinds), so programs behave like the
|
|
122
|
+
* seam's persistent backends. Exported for programmatic use and the tests; the
|
|
123
|
+
* model-facing surface is the `run_kernel_code` tool registered in `apply`.
|
|
124
|
+
*/
|
|
125
|
+
export class KernelManager {
|
|
126
|
+
#config;
|
|
127
|
+
#registries = new Map();
|
|
128
|
+
#ledgerFactory;
|
|
129
|
+
#disposed = false;
|
|
130
|
+
constructor(config) {
|
|
131
|
+
// Fill defaults here too: the plugin path gets them from the schemastery
|
|
132
|
+
// schema, but programmatic callers (tests, tooling) may pass a partial
|
|
133
|
+
// config and must get the same validated behavior.
|
|
134
|
+
const resolved = {
|
|
135
|
+
languages: config.languages ?? ['python', 'typescript'],
|
|
136
|
+
...config.pythonPath !== undefined ? { pythonPath: config.pythonPath } : {},
|
|
137
|
+
...config.nodePath !== undefined ? { nodePath: config.nodePath } : {},
|
|
138
|
+
toolTimeoutMs: config.toolTimeoutMs ?? 30_000,
|
|
139
|
+
maxWallMs: config.maxWallMs ?? 600_000,
|
|
140
|
+
maxOutputBytes: config.maxOutputBytes ?? 67_108_864,
|
|
141
|
+
sessionIdleMs: config.sessionIdleMs ?? 0,
|
|
142
|
+
interruptEscalationMs: config.interruptEscalationMs ?? 5_000,
|
|
143
|
+
startupTimeoutMs: config.startupTimeoutMs ?? 15_000,
|
|
144
|
+
shutdownGraceMs: config.shutdownGraceMs ?? 1_000,
|
|
145
|
+
};
|
|
146
|
+
const numericKeys = ['maxWallMs', 'maxOutputBytes', 'sessionIdleMs',
|
|
147
|
+
'interruptEscalationMs', 'startupTimeoutMs', 'shutdownGraceMs'];
|
|
148
|
+
for (const key of numericKeys) {
|
|
149
|
+
const value = resolved[key];
|
|
150
|
+
if (!(Number.isFinite(value) && value >= 0)) {
|
|
151
|
+
throw new Error(`dsh-code-runtime-kernels: config.${key} must be a non-negative number, got ${String(value)}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!Number.isSafeInteger(resolved.maxOutputBytes) || resolved.maxOutputBytes < MIN_OUTPUT_BYTES) {
|
|
155
|
+
throw new Error(`dsh-code-runtime-kernels: config.maxOutputBytes must be a safe integer of at least ${MIN_OUTPUT_BYTES}`);
|
|
156
|
+
}
|
|
157
|
+
if (resolved.maxWallMs > MAX_TIMER_DELAY_MS) {
|
|
158
|
+
throw new Error(`dsh-code-runtime-kernels: config.maxWallMs must be at most ${MAX_TIMER_DELAY_MS} (Node clamps a longer setTimeout delay to 1ms)`);
|
|
159
|
+
}
|
|
160
|
+
if (resolved.languages.length === 0) {
|
|
161
|
+
throw new Error('dsh-code-runtime-kernels: config.languages must not be empty');
|
|
162
|
+
}
|
|
163
|
+
for (const language of resolved.languages) {
|
|
164
|
+
if (language !== 'python' && language !== 'typescript') {
|
|
165
|
+
throw new Error(`dsh-code-runtime-kernels: unknown language ${JSON.stringify(language)}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
this.#config = resolved;
|
|
169
|
+
this.#ledgerFactory = () => new OutputLedger(resolved.maxOutputBytes);
|
|
170
|
+
for (const language of resolved.languages) {
|
|
171
|
+
this.#registries.set(language, new SessionRegistry({
|
|
172
|
+
label: language === 'python' ? 'python kernel' : 'nodejs kernel',
|
|
173
|
+
start: () => this.#startKernel(language === 'python' ? 'python' : 'typescript'),
|
|
174
|
+
sessionIdleMs: resolved.sessionIdleMs,
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Terminate every session kernel to quiescence (plugin teardown). */
|
|
179
|
+
async teardown() {
|
|
180
|
+
this.#disposed = true;
|
|
181
|
+
await Promise.allSettled([...this.#registries.values()].map(registry => registry.disposeAll()));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Execute one program. Program outcomes resolve with `error` as a result
|
|
185
|
+
* field; the method rejects only for contract misuse (an unknown language, a
|
|
186
|
+
* disposed manager, an invalid binding namespace). With a non-empty
|
|
187
|
+
* `sessionId` the program runs in that session's persistent kernel and
|
|
188
|
+
* `executionCount` is reported; `reset: true` discards prior state first.
|
|
189
|
+
*/
|
|
190
|
+
async run(request) {
|
|
191
|
+
if (this.#disposed)
|
|
192
|
+
throw new Error('dsh-code-runtime-kernels: run() after disposal');
|
|
193
|
+
const registry = this.#registries.get(request.language);
|
|
194
|
+
if (registry === undefined) {
|
|
195
|
+
throw new Error(`dsh-code-runtime-kernels: language ${JSON.stringify(request.language)} not enabled (config.languages)`);
|
|
196
|
+
}
|
|
197
|
+
const bindings = this.validateBindings(request.bindings ?? []);
|
|
198
|
+
if (request.signal?.aborted) {
|
|
199
|
+
return this.#ledgerFactory().failure([], { kind: 'abort', message: String(request.signal.reason) });
|
|
200
|
+
}
|
|
201
|
+
// Wall-clock budget: this run's abort source. The kernel turns it into
|
|
202
|
+
// SIGINT (and escalation), so a busy cell is interrupted hard.
|
|
203
|
+
const controller = new AbortController();
|
|
204
|
+
let timedOut = false;
|
|
205
|
+
const timer = setTimeout(() => {
|
|
206
|
+
timedOut = true;
|
|
207
|
+
controller.abort(new RunTimeoutError(`wall-clock ceiling reached (${this.#config.maxWallMs}ms)`));
|
|
208
|
+
}, this.#config.maxWallMs);
|
|
209
|
+
timer.unref();
|
|
210
|
+
const onOuter = () => { controller.abort(request.signal?.reason); };
|
|
211
|
+
request.signal?.addEventListener('abort', onOuter, { once: true });
|
|
212
|
+
try {
|
|
213
|
+
const sessionId = request.sessionId;
|
|
214
|
+
const outcome = sessionId !== undefined && sessionId.length > 0
|
|
215
|
+
? await registry.executeOnSession(sessionId, request.code, bindings, {
|
|
216
|
+
...request.reset !== undefined ? { reset: request.reset } : {},
|
|
217
|
+
signal: controller.signal,
|
|
218
|
+
})
|
|
219
|
+
: await this.#runOneShot(request.language, request.code, bindings, controller.signal);
|
|
220
|
+
return this.finalize(outcome, timedOut);
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
clearTimeout(timer);
|
|
224
|
+
request.signal?.removeEventListener('abort', onOuter);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
#startKernel(language) {
|
|
228
|
+
return language === 'python'
|
|
229
|
+
? this.#startPython()
|
|
230
|
+
: this.#startNodejs();
|
|
231
|
+
}
|
|
232
|
+
#startPython() {
|
|
233
|
+
const profile = {
|
|
234
|
+
key: 'python',
|
|
235
|
+
command: this.#config.pythonPath ?? 'python3',
|
|
236
|
+
argvPrefix: ['-u'],
|
|
237
|
+
stagedSource: PYTHON_RUNNER,
|
|
238
|
+
stagedSuffix: '.py',
|
|
239
|
+
env: {
|
|
240
|
+
PYTHONUNBUFFERED: '1',
|
|
241
|
+
PYTHONIOENCODING: 'utf-8',
|
|
242
|
+
PYTHONDONTWRITEBYTECODE: '1',
|
|
243
|
+
DSH_KERNEL_CWD: process.cwd(),
|
|
244
|
+
},
|
|
245
|
+
prefix: 'dsh-code-runtime-python',
|
|
246
|
+
idPrefix: 'py-',
|
|
247
|
+
label: 'python kernel',
|
|
248
|
+
};
|
|
249
|
+
return KernelHost.start(profile, this.#startConfig());
|
|
250
|
+
}
|
|
251
|
+
#startNodejs() {
|
|
252
|
+
return KernelHost.start(nodejsKernelProfile(this.#config.nodePath ?? 'node'), this.#startConfig());
|
|
253
|
+
}
|
|
254
|
+
#startConfig() {
|
|
255
|
+
return {
|
|
256
|
+
cwd: process.cwd(),
|
|
257
|
+
env: process.env,
|
|
258
|
+
startupTimeoutMs: this.#config.startupTimeoutMs,
|
|
259
|
+
interruptEscalationMs: this.#config.interruptEscalationMs,
|
|
260
|
+
shutdownGraceMs: this.#config.shutdownGraceMs,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** One fresh kernel for exactly one program: the one-shot path. */
|
|
264
|
+
async #runOneShot(language, code, bindings, signal) {
|
|
265
|
+
const kernel = await this.#startKernel(language);
|
|
266
|
+
try {
|
|
267
|
+
return await kernel.execute(randomUUID(), code, bindings, { signal });
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
return { status: 'error', logs: [], cancelled: false, invalidOutput: false, message: String(error), killed: false };
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
await kernel.shutdown().catch(() => { });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Map a kernel outcome onto the failure taxonomy through the output ledger.
|
|
278
|
+
* Budget expiry owns a run that hit the wall clock (whether or not the
|
|
279
|
+
* kernel survived to acknowledge it); everything else interrupted is an
|
|
280
|
+
* abort; a died kernel is an abort unless the budget already owns the run.
|
|
281
|
+
*/
|
|
282
|
+
finalize(outcome, timedOut) {
|
|
283
|
+
const ledger = this.#ledgerFactory();
|
|
284
|
+
const logs = outcome.logs.map(entry => entry.text);
|
|
285
|
+
if (timedOut) {
|
|
286
|
+
const message = outcome.killed
|
|
287
|
+
? `wall-clock ceiling reached (${this.#config.maxWallMs}ms); kernel killed after unresponsive interrupt`
|
|
288
|
+
: `wall-clock ceiling reached (${this.#config.maxWallMs}ms)`;
|
|
289
|
+
return ledger.failure(logs, { kind: 'timeout', message });
|
|
290
|
+
}
|
|
291
|
+
if (outcome.killed) {
|
|
292
|
+
return ledger.failure(logs, { kind: 'abort', message: outcome.message || 'run interrupted' });
|
|
293
|
+
}
|
|
294
|
+
if (outcome.cancelled) {
|
|
295
|
+
return ledger.failure(logs, { kind: 'abort', message: outcome.message || 'run interrupted' });
|
|
296
|
+
}
|
|
297
|
+
if (outcome.status === 'error') {
|
|
298
|
+
if (outcome.invalidOutput) {
|
|
299
|
+
return ledger.failure(logs, { kind: 'invalid-output', message: outcome.message || 'program completion must be lossless JSON' });
|
|
300
|
+
}
|
|
301
|
+
return ledger.failure(logs, { kind: 'exception', message: outcome.message || 'program failed' });
|
|
302
|
+
}
|
|
303
|
+
const result = outcome.value === undefined
|
|
304
|
+
? ledger.success(logs)
|
|
305
|
+
: ledger.success(logs, outcome.value);
|
|
306
|
+
return { ...result, ...outcome.executionCount !== undefined ? { executionCount: outcome.executionCount } : {} };
|
|
307
|
+
}
|
|
308
|
+
/** Reject malformed binding globals or typed-error declarations as contract misuse. */
|
|
309
|
+
validateBindings(bindings) {
|
|
310
|
+
const seen = new Map();
|
|
311
|
+
for (const namespace of bindings) {
|
|
312
|
+
if (!IDENTIFIER.test(namespace.global) || PORTABLE_RESERVED_WORDS.has(namespace.global)) {
|
|
313
|
+
throw new Error(`dsh-code-runtime-kernels: binding global ${JSON.stringify(namespace.global)} is not a usable identifier`);
|
|
314
|
+
}
|
|
315
|
+
if (RESERVED_BINDING_GLOBALS.has(namespace.global) || seen.has(namespace.global)) {
|
|
316
|
+
throw new Error(`dsh-code-runtime-kernels: reserved or duplicate binding global ${JSON.stringify(namespace.global)}`);
|
|
317
|
+
}
|
|
318
|
+
seen.set(namespace.global, namespace);
|
|
319
|
+
}
|
|
320
|
+
const errorClassNames = new Set();
|
|
321
|
+
for (const namespace of bindings) {
|
|
322
|
+
const descriptor = namespace.errorClass;
|
|
323
|
+
if (descriptor === undefined)
|
|
324
|
+
continue;
|
|
325
|
+
if (!IDENTIFIER.test(descriptor.name) || PORTABLE_RESERVED_WORDS.has(descriptor.name)) {
|
|
326
|
+
throw new Error(`dsh-code-runtime-kernels: binding error class ${JSON.stringify(descriptor.name)} is not a usable identifier`);
|
|
327
|
+
}
|
|
328
|
+
if (RESERVED_BINDING_GLOBALS.has(descriptor.name) || seen.has(descriptor.name) || errorClassNames.has(descriptor.name)) {
|
|
329
|
+
throw new Error(`dsh-code-runtime-kernels: reserved or duplicate injected global ${JSON.stringify(descriptor.name)}`);
|
|
330
|
+
}
|
|
331
|
+
const member = descriptor.memberNameProperty;
|
|
332
|
+
if (member.length === 0 || RESERVED_ERROR_MEMBERS.has(member) || DUNDER_MEMBER.test(member)) {
|
|
333
|
+
throw new Error(`dsh-code-runtime-kernels: binding error member property ${JSON.stringify(descriptor.memberNameProperty)} is not usable`);
|
|
334
|
+
}
|
|
335
|
+
errorClassNames.add(descriptor.name);
|
|
336
|
+
}
|
|
337
|
+
return bindings;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/** Model-facing guide for when and how to use `run_kernel_code`. */
|
|
341
|
+
const TOOL_GUIDE = [
|
|
342
|
+
'Prefer run_kernel_code to reading/writing scratch files when the work is computation with intermediate results',
|
|
343
|
+
'— sessions keep kernel state (variables, imports, working data) across calls. Omit `session` for one-off',
|
|
344
|
+
'computations; give related calls the same `session` id to carry state forward, and pass `reset: true` when',
|
|
345
|
+
'the session\'s state is corrupted or unwanted. Python programs persist module-level variables; JavaScript',
|
|
346
|
+
'programs persist via `state` and top-level assignments. A session reaps idle kernels after the configured',
|
|
347
|
+
'timeout, so long-lived work should resume promptly or persist to disk.',
|
|
348
|
+
].join(' ');
|
|
349
|
+
/** Render the result for the model: successful value, or the failure line. */
|
|
350
|
+
function renderResult(value) {
|
|
351
|
+
const head = [];
|
|
352
|
+
if (value.error === undefined) {
|
|
353
|
+
if (value.value !== undefined)
|
|
354
|
+
head.push(`value: ${JSON.stringify(value.value)}`);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
head.push(`${value.error.kind}: ${value.error.message}`);
|
|
358
|
+
}
|
|
359
|
+
if (value.logs.length > 0) {
|
|
360
|
+
head.push('logs:', ...value.logs.map(log => ` ${log.replace(/\n/g, '\n ')}`));
|
|
361
|
+
}
|
|
362
|
+
if (value.executionCount !== undefined)
|
|
363
|
+
head.push(`execution_count: ${value.executionCount}`);
|
|
364
|
+
return head.length > 0 ? head.join('\n') : '(no output)';
|
|
365
|
+
}
|
|
366
|
+
/** Project the durable, replayable presentation payload for a completed run. */
|
|
367
|
+
export function runKernelCodeMeta(value) {
|
|
368
|
+
return {
|
|
369
|
+
summary: value.error === undefined
|
|
370
|
+
? (value.value === undefined ? 'completed with no value' : 'completed')
|
|
371
|
+
: 'failed',
|
|
372
|
+
...value.value !== undefined ? { value: value.value } : {},
|
|
373
|
+
...value.error !== undefined ? { error: { kind: value.error.kind, message: value.error.message } } : {},
|
|
374
|
+
...value.executionCount !== undefined ? { executionCount: value.executionCount } : {},
|
|
375
|
+
logs: value.logs.slice(-20),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/** Present a pending `run_kernel_code` call as a terminal card (a cell is a foreground command). */
|
|
379
|
+
export function presentRunKernelCodeCall(args) {
|
|
380
|
+
return {
|
|
381
|
+
card: 'terminal',
|
|
382
|
+
title: `run_kernel_code ${args.language}${args.session !== undefined ? ` [${args.session}]` : ''}: ${args.code.length > 120 ? `${args.code.slice(0, 120)}…` : args.code}`,
|
|
383
|
+
...args.reset === true ? { description: 'resets the session kernel first' } : {},
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/** Present a completed run from its persisted meta as a terminal card, or undefined on failure. */
|
|
387
|
+
export function presentRunKernelCodeResult(_args, result) {
|
|
388
|
+
if (result.isError)
|
|
389
|
+
return undefined;
|
|
390
|
+
const meta = result.meta;
|
|
391
|
+
if (meta === undefined || !Array.isArray(meta.logs))
|
|
392
|
+
return undefined;
|
|
393
|
+
const parts = [];
|
|
394
|
+
if (meta.error !== undefined)
|
|
395
|
+
parts.push(`${meta.error.kind}: ${meta.error.message}`);
|
|
396
|
+
else if (meta.value !== undefined)
|
|
397
|
+
parts.push(`value: ${JSON.stringify(meta.value)}`);
|
|
398
|
+
if (meta.logs.length > 0)
|
|
399
|
+
parts.push(...meta.logs);
|
|
400
|
+
return {
|
|
401
|
+
card: 'terminal',
|
|
402
|
+
title: meta.summary,
|
|
403
|
+
output: parts.join('\n'),
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Cordis plugin `apply`: resolve config, own the kernel manager (disposed with
|
|
408
|
+
* the plugin), and register `run_kernel_code` against `ctx.tools` so a plain
|
|
409
|
+
* upstream harness exposes the persistent kernels with zero source changes.
|
|
410
|
+
*/
|
|
411
|
+
export async function apply(ctx, config) {
|
|
412
|
+
const toolTimeoutMs = config.toolTimeoutMs ?? 30_000;
|
|
413
|
+
if (toolTimeoutMs > MAX_TIMER_DELAY_MS) {
|
|
414
|
+
throw new Error(`dsh-code-runtime-kernels: config.toolTimeoutMs must be no greater than ${MAX_TIMER_DELAY_MS}`);
|
|
415
|
+
}
|
|
416
|
+
const manager = new KernelManager(config);
|
|
417
|
+
ctx.effect(() => () => { void manager.teardown().catch(() => { }); });
|
|
418
|
+
ctx.systemPrompt.section({
|
|
419
|
+
name: 'tool:code-runtime-kernels',
|
|
420
|
+
order: 106,
|
|
421
|
+
text: TOOL_GUIDE,
|
|
422
|
+
});
|
|
423
|
+
const tool = defineTool({
|
|
424
|
+
name: 'run_kernel_code',
|
|
425
|
+
description: 'Execute model code in a persistent kernel and return its JSON completion '
|
|
426
|
+
+ 'and printed output. `language` picks the runtime: `python` or `typescript`. '
|
|
427
|
+
+ 'For `typescript` every cell runs as an async function body, so top-level '
|
|
428
|
+
+ '`await` and `return` work. For `python` a cell runs as a module: top-level '
|
|
429
|
+
+ '`await` works, statements persist into the session namespace, and the LAST '
|
|
430
|
+
+ 'expression is the completion value (a top-level `return` is invalid Python). '
|
|
431
|
+
+ 'Carry the same non-empty `session` across calls to keep kernel state (variables, '
|
|
432
|
+
+ 'imports, working data); omit it for a one-shot run in fresh state. Pass '
|
|
433
|
+
+ '`reset: true` to discard the session\'s prior kernel state before this run '
|
|
434
|
+
+ '(one reset instead of endless retries after state corruption).',
|
|
435
|
+
parameters: {
|
|
436
|
+
language: { type: 'string', enum: ['python', 'typescript'], required: true, description: 'Which runtime executes the code.' },
|
|
437
|
+
code: { type: 'string', required: true, description: 'The program source. Runs as the body of an async function: top-level `await` and `return` are available; return a JSON value to surface it as the result value.' },
|
|
438
|
+
session: { type: 'string', description: 'Optional persistent-kernel identity: runs sharing a session id keep kernel state. Omit for one-shot.' },
|
|
439
|
+
reset: { type: 'boolean', description: 'Discard the session\'s prior kernel state (variables, imports) before this run. Costs one reset instead of many retries; requires `session` to be meaningful.' },
|
|
440
|
+
},
|
|
441
|
+
timeoutMs: toolTimeoutMs,
|
|
442
|
+
output: {
|
|
443
|
+
schema: {
|
|
444
|
+
type: 'object',
|
|
445
|
+
additionalProperties: false,
|
|
446
|
+
properties: {
|
|
447
|
+
value: { type: 'json', description: 'The program\'s completion value (JSON), when it returned one.' },
|
|
448
|
+
logs: { type: 'array', items: { type: 'string' }, required: true, description: 'Program output lines, in emission order.' },
|
|
449
|
+
executionCount: { type: 'integer', description: 'The session\'s execution count after this run (persistent sessions only).' },
|
|
450
|
+
error: {
|
|
451
|
+
type: 'object',
|
|
452
|
+
additionalProperties: false,
|
|
453
|
+
properties: {
|
|
454
|
+
kind: { type: 'string', enum: ['exception', 'timeout', 'abort', 'worker-exit', 'invalid-output', 'output-limit'], required: true, description: 'The failure class.' },
|
|
455
|
+
message: { type: 'string', required: true, description: 'Model-feedable failure detail.' },
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
render: (_args, value) => [{ type: 'text', text: renderResult(value) }],
|
|
461
|
+
presentationMeta: (_args, value) => runKernelCodeMeta(value),
|
|
462
|
+
},
|
|
463
|
+
async execute(args, exec) {
|
|
464
|
+
const result = await manager.run({
|
|
465
|
+
language: args.language,
|
|
466
|
+
code: args.code,
|
|
467
|
+
...args.session !== undefined ? { sessionId: args.session } : {},
|
|
468
|
+
...args.reset !== undefined ? { reset: args.reset } : {},
|
|
469
|
+
signal: exec.signal,
|
|
470
|
+
});
|
|
471
|
+
return result;
|
|
472
|
+
},
|
|
473
|
+
presentCall: presentRunKernelCodeCall,
|
|
474
|
+
presentResult: presentRunKernelCodeResult,
|
|
475
|
+
});
|
|
476
|
+
ctx.tools.register(tool);
|
|
477
|
+
}
|
|
478
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,+BAA+B,CAAA;AAO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ACD,WAAW,EAAE,wBAAwB;QACrC,aAAa,EAAE,0BAA0B;KAC1C,CAAC,CAAA;IACF,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The spawned Node.js kernel runner. One `node <this-file>` subprocess is one
|
|
3
|
+
* persistent kernel: it owns the wire-protocol peers described in
|
|
4
|
+
* `protocol.ts`, a persistent `state` object (plus the process-global object)
|
|
5
|
+
* that survives every run of the session, and a per-run evaluation cell with
|
|
6
|
+
* async-function-body semantics — top-level `await` and `return` work exactly
|
|
7
|
+
* like the worker-thread backend, and bindings are materialized as ordinary
|
|
8
|
+
* globals whose members bridge `call`/`reply` frames to the host.
|
|
9
|
+
*
|
|
10
|
+
* This file must stay self-contained (Node builtins only, no imports of other package
|
|
11
|
+
* sources): tsc emits it as ESM under the package output and development tests
|
|
12
|
+
* spawn the raw source directly (Node 22.18+/24+ runs erasable TypeScript).
|
|
13
|
+
*
|
|
14
|
+
* Persistence contract (mirrors the Python provider's user namespace):
|
|
15
|
+
* - `state` is a long-lived object exposed to every program; mutations
|
|
16
|
+
* survive until the session resets or the kernel exits.
|
|
17
|
+
* - sloppy-mode assignments like `x = 41` land on the process global and
|
|
18
|
+
* persist; `globalThis` itself persists.
|
|
19
|
+
* - `const`/`let`/`var`/`function`/`class` declared at cell top level are
|
|
20
|
+
* scoped to that cell (async-function body), exactly like a Node REPL
|
|
21
|
+
* line that uses top-level `await` — use `state` or the global object to
|
|
22
|
+
* persist values.
|
|
23
|
+
* @module @deepseek-ai/dsh-code-runtime-nodejs/src/runner
|
|
24
|
+
*/
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/nodejs/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|