@hy-sde-org/dsh-code-runtime-kernels 0.2.1-rc.3 → 0.2.2-rc.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 +15 -6
- package/README.zh.md +15 -6
- package/dist/core/kernel.d.ts +53 -12
- package/dist/core/kernel.d.ts.map +1 -1
- package/dist/core/kernel.js +224 -43
- package/dist/core/kernel.js.map +1 -1
- package/dist/core/protocol.d.ts +12 -0
- package/dist/core/protocol.d.ts.map +1 -1
- package/dist/core/python-discovery.d.ts +52 -0
- package/dist/core/python-discovery.d.ts.map +1 -0
- package/dist/core/python-discovery.js +142 -0
- package/dist/core/python-discovery.js.map +1 -0
- package/dist/core/session.d.ts +17 -5
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +108 -58
- package/dist/core/session.js.map +1 -1
- package/dist/index.d.ts +54 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +328 -129
- package/dist/index.js.map +1 -1
- package/dist/nodejs/runner.js +69 -43
- package/dist/nodejs/runner.js.map +1 -1
- package/dist/python/runner.d.ts.map +1 -1
- package/dist/python/runner.js +42 -11
- package/dist/python/runner.js.map +1 -1
- package/package.json +22 -19
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python interpreter discovery and probing for kernel starts. Enumerates the
|
|
3
|
+
* PATH (every match in PATH order, like omp's `$whichAll`) and probes each
|
|
4
|
+
* candidate with a `-c` version check, so a broken shim on PATH falls through
|
|
5
|
+
* to the next candidate instead of failing the kernel start.
|
|
6
|
+
* @module @hy-sde-org/dsh-code-runtime-kernels/src/core/python-discovery
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { accessSync, constants, statSync } from 'node:fs';
|
|
10
|
+
import { delimiter, join } from 'node:path';
|
|
11
|
+
/**
|
|
12
|
+
* Every PATH entry where `command` names an executable file, in PATH order.
|
|
13
|
+
* Empty entries are skipped, matches are deduplicated, and a match must be a
|
|
14
|
+
* regular file with the execute bit (a directory or a non-executable file is
|
|
15
|
+
* not a candidate). There is no PATHEXT or platform-toolchain fallback: the
|
|
16
|
+
* PATH scan is the whole contract. On win32 each entry is tried as
|
|
17
|
+
* `command.exe` before the literal name, matching CreateProcessW's
|
|
18
|
+
* exe-first resolution.
|
|
19
|
+
*/
|
|
20
|
+
export function whichAll(command, env = process.env, platform = process.platform) {
|
|
21
|
+
const names = platform === 'win32' ? [`${command}.exe`, command] : [command];
|
|
22
|
+
const matches = [];
|
|
23
|
+
for (const dir of (env.PATH ?? '').split(delimiter)) {
|
|
24
|
+
if (dir === '')
|
|
25
|
+
continue;
|
|
26
|
+
for (const name of names) {
|
|
27
|
+
const candidate = join(dir, name);
|
|
28
|
+
try {
|
|
29
|
+
if (!statSync(candidate).isFile())
|
|
30
|
+
continue;
|
|
31
|
+
accessSync(candidate, constants.X_OK);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!matches.includes(candidate))
|
|
37
|
+
matches.push(candidate);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return matches;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Ordered python candidates for one resolution: an explicitly configured
|
|
44
|
+
* interpreter first, then every `python` and every `python3` on PATH (each
|
|
45
|
+
* list in PATH order; a `python` match is tried before a `python3` match at
|
|
46
|
+
* the same precedence; on win32, `.exe` matches come before bare names per
|
|
47
|
+
* PATH entry).
|
|
48
|
+
*/
|
|
49
|
+
export function enumeratePythonCandidates(configured, env = process.env, platform = process.platform) {
|
|
50
|
+
return [
|
|
51
|
+
...configured !== undefined ? [configured] : [],
|
|
52
|
+
...whichAll('python', env, platform),
|
|
53
|
+
...whichAll('python3', env, platform),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/** The `-c` probe program: a python ≥3 asserts its major version and prints `MAJOR.MINOR.MICRO`. */
|
|
57
|
+
const PYTHON_PROBE_PROGRAM = "import sys; assert sys.version_info[0] >= 3; print('%d.%d.%d' % sys.version_info[:3])";
|
|
58
|
+
/** Probe stdout that proves the `-c` program ran on a python ≥3. */
|
|
59
|
+
const VERSION_REPORT = /^\d+\.\d+/;
|
|
60
|
+
/** Failure-reason excerpt cap; the resolution error must stay single-line readable. */
|
|
61
|
+
const EXCERPT_MAX_CHARS = 160;
|
|
62
|
+
/** One bounded, whitespace-collapsed excerpt of process output for failure reasons. */
|
|
63
|
+
function outputExcerpt(text) {
|
|
64
|
+
const line = text.replace(/\s+/g, ' ').trim();
|
|
65
|
+
if (line === '')
|
|
66
|
+
return undefined;
|
|
67
|
+
return line.length > EXCERPT_MAX_CHARS ? `${line.slice(0, EXCERPT_MAX_CHARS)}…` : line;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Probe one candidate with the `-c` version check under `timeoutMs`. Resolves
|
|
71
|
+
* `undefined` when the interpreter works, or a single-line reason (spawn
|
|
72
|
+
* error, non-zero exit, timeout, or a missing version report) otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export async function probePythonInterpreter(command, timeoutMs) {
|
|
75
|
+
const child = spawn(command, ['-c', PYTHON_PROBE_PROGRAM], {
|
|
76
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
77
|
+
windowsHide: true,
|
|
78
|
+
});
|
|
79
|
+
return await new Promise((resolve) => {
|
|
80
|
+
let stdout = '';
|
|
81
|
+
let stderr = '';
|
|
82
|
+
let timedOut = false;
|
|
83
|
+
const timer = setTimeout(() => {
|
|
84
|
+
// Settle immediately: the killed shim's grandchildren can inherit the
|
|
85
|
+
// stdio pipes and hold `close` open well past the budget.
|
|
86
|
+
timedOut = true;
|
|
87
|
+
child.kill();
|
|
88
|
+
resolve(`timed out after ${timeoutMs}ms`);
|
|
89
|
+
}, timeoutMs);
|
|
90
|
+
timer.unref();
|
|
91
|
+
child.stdout.on('data', (chunk) => { stdout += chunk.toString('utf8'); });
|
|
92
|
+
child.stderr.on('data', (chunk) => { stderr += chunk.toString('utf8'); });
|
|
93
|
+
child.on('error', (error) => {
|
|
94
|
+
if (timedOut)
|
|
95
|
+
return;
|
|
96
|
+
clearTimeout(timer);
|
|
97
|
+
resolve(`spawn failed (${error.message})`);
|
|
98
|
+
});
|
|
99
|
+
child.on('close', (code, signal) => {
|
|
100
|
+
if (timedOut)
|
|
101
|
+
return;
|
|
102
|
+
clearTimeout(timer);
|
|
103
|
+
if (code === 0 && VERSION_REPORT.test(stdout.trim())) {
|
|
104
|
+
resolve(undefined);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const excerpt = outputExcerpt(stderr) ?? outputExcerpt(stdout);
|
|
108
|
+
if (code === 0) {
|
|
109
|
+
resolve(`no version report${excerpt !== undefined ? ` (${excerpt})` : ''}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const exit = code !== null
|
|
113
|
+
? `exited with code ${code}`
|
|
114
|
+
: `killed by signal ${signal ?? 'unknown'}`;
|
|
115
|
+
resolve(`${exit}${excerpt !== undefined ? `: ${excerpt}` : ''}`);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Probe candidates in order and resolve the first working interpreter. A
|
|
121
|
+
* command in `verified` skips probing (the caller caches successes; failures
|
|
122
|
+
* are never cached, so an interpreter installed mid-session is picked up on
|
|
123
|
+
* the next start). Rejects with one line naming every probed candidate and
|
|
124
|
+
* its failure reason when none works.
|
|
125
|
+
*/
|
|
126
|
+
export async function resolvePythonCommand(candidates, options) {
|
|
127
|
+
const rejections = [];
|
|
128
|
+
for (const command of candidates) {
|
|
129
|
+
if (options.verified?.has(command) === true)
|
|
130
|
+
return command;
|
|
131
|
+
const reason = await probePythonInterpreter(command, options.probeTimeoutMs);
|
|
132
|
+
if (reason === undefined) {
|
|
133
|
+
options.verified?.add(command);
|
|
134
|
+
return command;
|
|
135
|
+
}
|
|
136
|
+
rejections.push({ command, reason });
|
|
137
|
+
}
|
|
138
|
+
throw new Error('dsh-code-runtime-kernels: no working python interpreter found '
|
|
139
|
+
+ `(${rejections.map(rejection => `${rejection.command}: ${rejection.reason}`).join('; ')}); `
|
|
140
|
+
+ 'install a working python3 on PATH or set config.pythonPath');
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=python-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python-discovery.js","sourceRoot":"","sources":["../../src/core/python-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,MAAyB,OAAO,CAAC,GAAG,EAAE,WAA4B,OAAO,CAAC,QAAQ;IAC1H,MAAM,KAAK,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAC5E,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,IAAI,GAAG,KAAK,EAAE;YAAE,SAAQ;QACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YACjC,IAAI,CAAC;gBACH,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE;oBAAE,SAAQ;gBAC3C,UAAU,CAAC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MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;YAC9B,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,gEAAgE;UAC9D,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;UAC5F,4DAA4D,CAC/D,CAAA;AACH,CAAC"}
|
package/dist/core/session.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @module @hy-sde-org/dsh-code-runtime-kernels/src/core/session
|
|
10
10
|
*/
|
|
11
11
|
import type { PtcBindingNamespace } from '@deepseek-ai/dsh-ptc-runtime';
|
|
12
|
+
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
12
13
|
import type { KernelExecResult, KernelHost } from './kernel.ts';
|
|
13
14
|
import type { SnapshotSpec } from './protocol.ts';
|
|
14
15
|
/** Session-management knobs on top of the per-kernel start config. */
|
|
@@ -16,9 +17,16 @@ export interface SessionRegistryConfig {
|
|
|
16
17
|
/** Label for error messages (e.g. `python kernel`). */
|
|
17
18
|
label: string;
|
|
18
19
|
/** Spawn a fresh kernel for a newly acquired session (provider-resolved executable + timeouts). */
|
|
19
|
-
start: () => Promise<KernelHost>;
|
|
20
|
+
start: (signal?: AbortSignal, sandboxSessionId?: SessionId) => Promise<KernelHost>;
|
|
20
21
|
/** Reap a session whose kernel sits unused for this long; 0 disables. */
|
|
21
22
|
sessionIdleMs: number;
|
|
23
|
+
/**
|
|
24
|
+
* True when a caller-cancelled run leaves work still evaluating in the
|
|
25
|
+
* kernel (the JavaScript runner's abandoned-cell ghost): the kernel is then
|
|
26
|
+
* retired and awaited instead of reused, so the ghost cannot mutate state a
|
|
27
|
+
* later run would see. Clean-cancellation kernels keep their kernel.
|
|
28
|
+
*/
|
|
29
|
+
retireOnCancel?: boolean;
|
|
22
30
|
/**
|
|
23
31
|
* Namespace persistence for one session: returns the spec every exec of the
|
|
24
32
|
* session carries, or `undefined` when snapshots are disabled. A missing
|
|
@@ -44,12 +52,16 @@ export interface SessionRunOptions {
|
|
|
44
52
|
cwd?: string;
|
|
45
53
|
/** Per-run environment overrides. */
|
|
46
54
|
env?: Record<string, string>;
|
|
55
|
+
/** Owning DSH session for sandbox policy; never the kernel sub-session id. */
|
|
56
|
+
sandboxSessionId?: SessionId;
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
59
|
* Registers sessions and schedules every run onto its session's serialization
|
|
50
|
-
* tail. A session kernel that died
|
|
51
|
-
*
|
|
52
|
-
*
|
|
60
|
+
* tail. A session kernel that died settling a run is retired (never reused,
|
|
61
|
+
* never asked to re-run model code it died on — replaying would double
|
|
62
|
+
* external effects); the next invocation starts on a fresh kernel. The idle
|
|
63
|
+
* reap deadline is armed only while the session's queue is fully drained, so
|
|
64
|
+
* a queued run can never be killed by the previous run's idle timer.
|
|
53
65
|
*/
|
|
54
66
|
export declare class SessionRegistry {
|
|
55
67
|
#private;
|
|
@@ -58,7 +70,7 @@ export declare class SessionRegistry {
|
|
|
58
70
|
executeOnSession(sessionId: string, code: string, bindings: PtcBindingNamespace[], options?: SessionRunOptions): Promise<KernelExecResult>;
|
|
59
71
|
/** Shut down and drop one session's kernel. */
|
|
60
72
|
close(sessionId: string): Promise<void>;
|
|
61
|
-
/** Terminate every kernel and
|
|
73
|
+
/** Terminate every attached kernel and wait for all queued acquisitions. */
|
|
62
74
|
disposeAll(): Promise<void>;
|
|
63
75
|
}
|
|
64
76
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],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qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,SAAS,CAAA;CAC7B;AAED;;;;;;;GAOG;AACH,qBAAa,eAAe;;gBAKd,MAAM,EAAE,qBAAqB;IAIzC,+EAA+E;IACzE,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC;IA0C5B,+CAA+C;IACzC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7C,4EAA4E;IAC5E,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CA2L5B"}
|
package/dist/core/session.js
CHANGED
|
@@ -25,14 +25,17 @@ class KernelPreloadError extends Error {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Registers sessions and schedules every run onto its session's serialization
|
|
28
|
-
* tail. A session kernel that died
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* tail. A session kernel that died settling a run is retired (never reused,
|
|
29
|
+
* never asked to re-run model code it died on — replaying would double
|
|
30
|
+
* external effects); the next invocation starts on a fresh kernel. The idle
|
|
31
|
+
* reap deadline is armed only while the session's queue is fully drained, so
|
|
32
|
+
* a queued run can never be killed by the previous run's idle timer.
|
|
31
33
|
*/
|
|
32
34
|
export class SessionRegistry {
|
|
33
35
|
#sessions = new Map();
|
|
34
36
|
#config;
|
|
35
37
|
#disposed = false;
|
|
38
|
+
#disposalPromise;
|
|
36
39
|
constructor(config) {
|
|
37
40
|
this.#config = config;
|
|
38
41
|
}
|
|
@@ -46,16 +49,28 @@ export class SessionRegistry {
|
|
|
46
49
|
}
|
|
47
50
|
let session = this.#sessions.get(sessionId);
|
|
48
51
|
if (session === undefined) {
|
|
49
|
-
session = { kernel: null, queue: Promise.resolve() };
|
|
52
|
+
session = { kernel: null, queue: Promise.resolve(), pending: 0 };
|
|
50
53
|
this.#sessions.set(sessionId, session);
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
// Admission marks the session busy; the idle deadline is rearmed only
|
|
56
|
+
// when the LAST queued run settles (a timer armed by an earlier run's
|
|
57
|
+
// finally would fire mid-execution of a later, still-pending run).
|
|
58
|
+
const previousTail = session.queue;
|
|
59
|
+
session.pending += 1;
|
|
60
|
+
const task = previousTail.then(() => this.#settleRun(session, sessionId, code, bindings, options), () => this.#settleRun(session, sessionId, code, bindings, options));
|
|
61
|
+
// The chain tail never rejects: keep it flat for the next admission.
|
|
62
|
+
session.queue = task.then(() => undefined, () => undefined);
|
|
63
|
+
return (await task);
|
|
64
|
+
}
|
|
65
|
+
/** One admission, with the idle deadline rearmed only at queue drain. */
|
|
66
|
+
async #settleRun(session, sessionId, code, bindings, options) {
|
|
54
67
|
try {
|
|
55
|
-
return
|
|
68
|
+
return await this.#runOnSession(session, sessionId, code, bindings, options);
|
|
56
69
|
}
|
|
57
70
|
finally {
|
|
58
|
-
|
|
71
|
+
session.pending -= 1;
|
|
72
|
+
if (session.pending <= 0)
|
|
73
|
+
this.#maybeReap(sessionId);
|
|
59
74
|
}
|
|
60
75
|
}
|
|
61
76
|
/** Shut down and drop one session's kernel. */
|
|
@@ -70,21 +85,27 @@ export class SessionRegistry {
|
|
|
70
85
|
if (kernel !== null)
|
|
71
86
|
await kernel.shutdown().catch(() => { });
|
|
72
87
|
}
|
|
73
|
-
/** Terminate every kernel and
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
/** Terminate every attached kernel and wait for all queued acquisitions. */
|
|
89
|
+
disposeAll() {
|
|
90
|
+
this.#disposalPromise ??= this.#disposeAll();
|
|
91
|
+
return this.#disposalPromise;
|
|
92
|
+
}
|
|
93
|
+
async #disposeAll() {
|
|
77
94
|
this.#disposed = true;
|
|
78
95
|
const sessions = [...this.#sessions.values()];
|
|
79
|
-
this.#sessions.clear();
|
|
80
96
|
const kernels = [];
|
|
81
97
|
for (const session of sessions) {
|
|
82
98
|
clearTimeout(session.idleTimer);
|
|
83
99
|
if (session.kernel !== null)
|
|
84
100
|
kernels.push(session.kernel);
|
|
85
|
-
session.kernel = null;
|
|
86
101
|
}
|
|
87
|
-
await Promise.allSettled(
|
|
102
|
+
await Promise.allSettled([
|
|
103
|
+
...kernels.map(kernel => kernel.shutdown()),
|
|
104
|
+
...sessions.map(session => session.queue),
|
|
105
|
+
]);
|
|
106
|
+
for (const session of sessions)
|
|
107
|
+
session.kernel = null;
|
|
108
|
+
this.#sessions.clear();
|
|
88
109
|
}
|
|
89
110
|
#maybeReap(sessionId) {
|
|
90
111
|
if (this.#disposed)
|
|
@@ -96,6 +117,15 @@ export class SessionRegistry {
|
|
|
96
117
|
return;
|
|
97
118
|
clearTimeout(session.idleTimer);
|
|
98
119
|
session.idleTimer = setTimeout(() => {
|
|
120
|
+
// Re-check at fire time: a run admitted after this deadline was armed
|
|
121
|
+
// may still be executing, and close() must never kill it mid-run. The
|
|
122
|
+
// deadline is only legitimate when the queue has drained again.
|
|
123
|
+
if (this.#sessions.get(sessionId) !== session)
|
|
124
|
+
return;
|
|
125
|
+
if (session.pending > 0)
|
|
126
|
+
return;
|
|
127
|
+
if (session.kernel === null)
|
|
128
|
+
return;
|
|
99
129
|
void this.close(sessionId);
|
|
100
130
|
}, this.#config.sessionIdleMs);
|
|
101
131
|
session.idleTimer.unref();
|
|
@@ -109,7 +139,7 @@ export class SessionRegistry {
|
|
|
109
139
|
throw new Error(`${this.#config.label} session registry disposed while acquiring kernel`);
|
|
110
140
|
}
|
|
111
141
|
}
|
|
112
|
-
async #acquireKernel(sessionId, session) {
|
|
142
|
+
async #acquireKernel(sessionId, session, options) {
|
|
113
143
|
if (session.kernel !== null && session.kernel.isAlive())
|
|
114
144
|
return session.kernel;
|
|
115
145
|
const previous = session.kernel;
|
|
@@ -121,7 +151,7 @@ export class SessionRegistry {
|
|
|
121
151
|
if (this.#sessions.get(sessionId) !== session) {
|
|
122
152
|
throw new Error(`${this.#config.label} session invalidated while acquiring kernel`);
|
|
123
153
|
}
|
|
124
|
-
const kernel = await this.#config.start();
|
|
154
|
+
const kernel = await this.#config.start(options.signal, options.sandboxSessionId);
|
|
125
155
|
if (this.#disposed) {
|
|
126
156
|
await kernel.shutdown().catch(() => { });
|
|
127
157
|
this.#assertNotDisposed();
|
|
@@ -133,10 +163,11 @@ export class SessionRegistry {
|
|
|
133
163
|
session.kernel = kernel;
|
|
134
164
|
const preload = this.#config.preload?.();
|
|
135
165
|
if (preload !== undefined && preload.length > 0) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
166
|
+
const prepared = await kernel.execute(`preload-${randomUUID()}`, preload, [], {
|
|
167
|
+
...options.signal !== undefined ? { signal: options.signal } : {},
|
|
168
|
+
...options.cwd !== undefined ? { cwd: options.cwd } : {},
|
|
169
|
+
...options.env !== undefined ? { env: options.env } : {},
|
|
170
|
+
});
|
|
140
171
|
if (prepared.status !== 'ok' || prepared.killed || prepared.cancelled) {
|
|
141
172
|
await kernel.shutdown().catch(() => { });
|
|
142
173
|
session.kernel = null;
|
|
@@ -146,6 +177,19 @@ export class SessionRegistry {
|
|
|
146
177
|
return kernel;
|
|
147
178
|
}
|
|
148
179
|
async #runOnSession(session, sessionId, code, bindings, options) {
|
|
180
|
+
// An aborted admission fails fast BEFORE any destructive reset work:
|
|
181
|
+
// a caller that already gave up must not pay for a kernel shutdown +
|
|
182
|
+
// snapshot delete it will never use.
|
|
183
|
+
// (The abort check goes through a closure so the early-return below does
|
|
184
|
+
// not narrow the signal for the rest of the function — the caller may
|
|
185
|
+
// abort LATER, during the run, and the retire check must see that.)
|
|
186
|
+
const callerAborted = () => options.signal?.aborted === true;
|
|
187
|
+
if (callerAborted()) {
|
|
188
|
+
return {
|
|
189
|
+
status: 'error', logs: [], cancelled: true, invalidOutput: false,
|
|
190
|
+
message: 'run aborted before the kernel admitted it', killed: false,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
149
193
|
if (options.reset === true) {
|
|
150
194
|
// Reset first, then acquire: prior kernel state is discarded and its
|
|
151
195
|
// shutdown completes before the fresh kernel answers this run. The
|
|
@@ -157,11 +201,23 @@ export class SessionRegistry {
|
|
|
157
201
|
clearTimeout(session.idleTimer);
|
|
158
202
|
await previous.shutdown().catch(() => { });
|
|
159
203
|
}
|
|
160
|
-
|
|
204
|
+
// A snapshot we cannot discard would silently restore the state the
|
|
205
|
+
// reset was meant to drop — fail the reset instead of certifying a
|
|
206
|
+
// discard that did not happen.
|
|
207
|
+
try {
|
|
208
|
+
this.#deleteSnapshot(sessionId);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
return {
|
|
212
|
+
status: 'error', logs: [], cancelled: false, invalidOutput: false, killed: false,
|
|
213
|
+
message: `reset aborted: the previous snapshot could not be discarded (${failureText(error)}); ` +
|
|
214
|
+
'a later start may restore it — delete the snapshot file manually before retrying',
|
|
215
|
+
};
|
|
216
|
+
}
|
|
161
217
|
}
|
|
162
218
|
let kernel;
|
|
163
219
|
try {
|
|
164
|
-
kernel = await this.#acquireKernel(sessionId, session);
|
|
220
|
+
kernel = await this.#acquireKernel(sessionId, session, options);
|
|
165
221
|
}
|
|
166
222
|
catch (error) {
|
|
167
223
|
if (error instanceof KernelPreloadError)
|
|
@@ -169,36 +225,29 @@ export class SessionRegistry {
|
|
|
169
225
|
throw error;
|
|
170
226
|
}
|
|
171
227
|
const first = await this.#executeOnce(kernel, sessionId, code, bindings, options);
|
|
172
|
-
// A kernel that died or was killed settling the run is replaced once and
|
|
173
|
-
// the run retried; otherwise return what we got. A result that came back
|
|
174
|
-
// `cancelled` with the caller still live and the kernel no longer alive is
|
|
175
|
-
// the same dead-kernel case: the runner died settling the cancellation, so
|
|
176
|
-
// a fresh kernel gets one retry (mirrors omp's dead-kernel recovery in
|
|
177
|
-
// `kernel-session-registry.executeOnSession`).
|
|
178
228
|
if (session !== this.#sessions.get(sessionId))
|
|
179
229
|
return first;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (
|
|
230
|
+
// Caller-abort on a kernel whose cancellation leaks (the JavaScript
|
|
231
|
+
// runner's abandoned cell keeps evaluating as a ghost): retire the kernel
|
|
232
|
+
// and AWAIT its shutdown so the ghost cannot mutate state a later run
|
|
233
|
+
// would see. The next invocation starts fresh (restoring the last saved
|
|
234
|
+
// snapshot, when snapshots are on).
|
|
235
|
+
if (first.cancelled && callerAborted() && this.#config.retireOnCancel === true) {
|
|
236
|
+
await kernel.shutdown().catch(() => { });
|
|
237
|
+
if (session.kernel === kernel)
|
|
238
|
+
session.kernel = null;
|
|
186
239
|
return first;
|
|
187
|
-
try {
|
|
188
|
-
kernel = await this.#acquireKernel(sessionId, session);
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
if (error instanceof KernelPreloadError)
|
|
192
|
-
return error.result;
|
|
193
|
-
throw error;
|
|
194
240
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
241
|
+
// A kernel that died settling the run is retired — never reused, and the
|
|
242
|
+
// run is NEVER retried: re-executing model code could duplicate external
|
|
243
|
+
// effects. The next queued invocation starts a fresh kernel.
|
|
244
|
+
if (first.killed || !kernel.isAlive()) {
|
|
245
|
+
await kernel.shutdown().catch(() => { });
|
|
246
|
+
if (session.kernel === kernel)
|
|
247
|
+
session.kernel = null;
|
|
248
|
+
return first;
|
|
200
249
|
}
|
|
201
|
-
return
|
|
250
|
+
return first;
|
|
202
251
|
}
|
|
203
252
|
#executeOnce(kernel, sessionId, code, bindings, options) {
|
|
204
253
|
const snapshot = this.#config.snapshot?.(sessionId);
|
|
@@ -209,20 +258,21 @@ export class SessionRegistry {
|
|
|
209
258
|
...snapshot !== undefined ? { snapshot } : {},
|
|
210
259
|
});
|
|
211
260
|
}
|
|
212
|
-
/**
|
|
261
|
+
/**
|
|
262
|
+
* Delete one session's snapshot file (missing is fine). A denied or failed
|
|
263
|
+
* delete THROWS: the caller fails the reset run with a structured message
|
|
264
|
+
* instead of certifying a discard that did not happen (a stale snapshot
|
|
265
|
+
* would be silently restored by the very next start).
|
|
266
|
+
*/
|
|
213
267
|
#deleteSnapshot(sessionId) {
|
|
214
268
|
const spec = this.#config.snapshot?.(sessionId);
|
|
215
269
|
if (spec === undefined)
|
|
216
270
|
return;
|
|
217
|
-
|
|
218
|
-
rmSync(spec.path, { force: true });
|
|
219
|
-
}
|
|
220
|
-
catch {
|
|
221
|
-
// A failed delete leaves a stale snapshot: the kernel will restore it,
|
|
222
|
-
// which is exactly the surprising outcome reset must prevent. Report by
|
|
223
|
-
// name instead of certifying state was discarded.
|
|
224
|
-
console.warn(`dsh-code-runtime-kernels: could not remove snapshot ${JSON.stringify(spec.path)} for session ${JSON.stringify(sessionId)}`);
|
|
225
|
-
}
|
|
271
|
+
rmSync(spec.path, { force: true });
|
|
226
272
|
}
|
|
227
273
|
}
|
|
274
|
+
/** One-line reason from an unknown throw site (no exported util here). */
|
|
275
|
+
function failureText(error) {
|
|
276
|
+
return error instanceof Error ? error.message : String(error);
|
|
277
|
+
}
|
|
228
278
|
//# sourceMappingURL=session.js.map
|
package/dist/core/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM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