@code-yeongyu/senpi 2026.8.22 → 2026.8.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/bun-runtime.d.ts +58 -0
  3. package/dist/bun-runtime.d.ts.map +1 -0
  4. package/dist/bun-runtime.js +163 -0
  5. package/dist/bun-runtime.js.map +1 -0
  6. package/dist/cli.js +45 -2
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/agent-session.d.ts +7 -2
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +81 -26
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/agent-settled-delivery.d.ts +13 -1
  13. package/dist/core/agent-settled-delivery.d.ts.map +1 -1
  14. package/dist/core/agent-settled-delivery.js +33 -2
  15. package/dist/core/agent-settled-delivery.js.map +1 -1
  16. package/dist/core/extensions/builtin/goal/cache-warm-renderer.d.ts.map +1 -1
  17. package/dist/core/extensions/builtin/goal/cache-warm-renderer.js +2 -3
  18. package/dist/core/extensions/builtin/goal/cache-warm-renderer.js.map +1 -1
  19. package/dist/core/extensions/builtin/goal/cache-warm.d.ts +6 -0
  20. package/dist/core/extensions/builtin/goal/cache-warm.d.ts.map +1 -1
  21. package/dist/core/extensions/builtin/goal/cache-warm.js +43 -0
  22. package/dist/core/extensions/builtin/goal/cache-warm.js.map +1 -1
  23. package/dist/core/model-config-schema.d.ts +12 -12
  24. package/dist/core/model-config-schema.js +2 -2
  25. package/dist/core/model-config-schema.js.map +1 -1
  26. package/dist/core/model-resolver.js +2 -2
  27. package/dist/core/model-resolver.js.map +1 -1
  28. package/dist/core/session-work-barrier.d.ts.map +1 -1
  29. package/dist/core/session-work-barrier.js +38 -1
  30. package/dist/core/session-work-barrier.js.map +1 -1
  31. package/dist/modes/interactive/components/status-indicator.d.ts +3 -0
  32. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  33. package/dist/modes/interactive/components/status-indicator.js +7 -1
  34. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  35. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  36. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  37. package/dist/modes/interactive/interactive-mode.js +39 -7
  38. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  39. package/dist/senpi +45 -2
  40. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +32 -0
  41. package/node_modules/@code-yeongyu/senpi-codemode/README.md +5 -0
  42. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  43. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-notifier.ts +16 -4
  44. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-factory.ts +4 -1
  45. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-info.ts +41 -0
  46. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +9 -3
  47. package/node_modules/@code-yeongyu/senpi-codemode/src/interpreters/detect.ts +17 -4
  48. package/node_modules/@code-yeongyu/senpi-codemode/src/interpreters/resolve-command.ts +68 -0
  49. package/node_modules/@code-yeongyu/senpi-codemode/src/timeouts/idle-timeout.ts +33 -4
  50. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +5 -1
  51. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +3 -0
  52. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +2 -0
  53. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +60 -3
  54. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/runtime-label.ts +49 -0
  55. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +13 -0
  56. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  57. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +5 -1
  58. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
  59. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +13 -5
  60. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
  61. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.d.ts +27 -0
  62. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.d.ts.map +1 -0
  63. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.js +54 -0
  64. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.js.map +1 -0
  65. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  66. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  67. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  68. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  69. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.d.ts +4 -0
  70. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.d.ts.map +1 -1
  71. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.js +14 -0
  72. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.js.map +1 -1
  73. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.d.ts.map +1 -1
  74. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.js +65 -35
  75. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.js.map +1 -1
  76. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.d.ts.map +1 -1
  77. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.js +40 -12
  78. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.js.map +1 -1
  79. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  80. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  81. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  82. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  83. package/package.json +7 -7
package/dist/senpi CHANGED
@@ -1,13 +1,56 @@
1
1
  #!/usr/bin/env node
2
2
  import "./valid-cwd.js";
3
- import { spawn } from "node:child_process";
4
- import { existsSync } from "node:fs";
3
+ import { spawn, spawnSync } from "node:child_process";
4
+ import { existsSync, realpathSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
+ import { processBunRuntimeOptions, resolveBunReexec } from "./bun-runtime.js";
7
8
  import { enableStartupCompileCache } from "./compile-cache.js";
8
9
  import { APP_NAME, DISPLAY_VERSION, getPackageDir } from "./config.js";
9
10
  import { hasInheritedInspectorOption, releaseInheritedInspectorForChild } from "./inspector-policy.js";
10
11
  import { handleBootstrapSelfUpdate } from "./self-update-bootstrap.js";
12
+ /**
13
+ * Hand a Bun-installed CLI to Bun before anything else runs.
14
+ *
15
+ * `bun install -g` links this script into `~/.bun/bin`, but the shebang still starts it on Node,
16
+ * so a user who chose Bun silently gets the Node runtime. Re-exec through the Bun binary when the
17
+ * script really lives in Bun's global tree (or `SENPI_RUNTIME=bun` asks for it). This runs before
18
+ * `enableStartupCompileCache()` on purpose: a re-exec must not pay for Node's compile-cache setup.
19
+ * Node `execArgv` is deliberately dropped — those flags belong to the Node process, not to Bun.
20
+ */
21
+ function reexecUnderBunIfNeeded() {
22
+ const options = processBunRuntimeOptions(existsSync, realpathSync);
23
+ let scriptRealPath = process.argv[1] ?? fileURLToPath(import.meta.url);
24
+ try {
25
+ // `~/.bun/bin/<name>` is a symlink into the global tree, so the link target is what has
26
+ // to be classified and re-executed. A path that cannot be resolved is simply used as-is;
27
+ // runtime selection must never be the reason startup fails.
28
+ scriptRealPath = realpathSync(scriptRealPath);
29
+ }
30
+ catch { }
31
+ const decision = resolveBunReexec({
32
+ scriptRealPath,
33
+ versions: process.versions,
34
+ hasInheritedInspectorOption: hasInheritedInspectorOption(),
35
+ options,
36
+ });
37
+ if (decision.action === "stay") {
38
+ return false;
39
+ }
40
+ const result = spawnSync(decision.bunPath, [scriptRealPath, ...process.argv.slice(2)], {
41
+ stdio: "inherit",
42
+ windowsHide: true,
43
+ });
44
+ if (result.signal) {
45
+ process.kill(process.pid, result.signal);
46
+ return true;
47
+ }
48
+ process.exitCode = result.status ?? 1;
49
+ return true;
50
+ }
51
+ if (reexecUnderBunIfNeeded()) {
52
+ process.exit();
53
+ }
11
54
  // Must run before cli-main is loaded, by either path: it caches the engine graph this process
12
55
  // imports on the fast path below, and it publishes NODE_COMPILE_CACHE so a spawned cli-main child
13
56
  // inherits this process's cache directory instead of resolving and re-filling its own.
@@ -12,6 +12,38 @@
12
12
 
13
13
  ### Removed
14
14
 
15
+ ## [2026.8.23] - 2026-08-23
16
+
17
+ ### Breaking Changes
18
+
19
+ ### Added
20
+
21
+ ### Changed
22
+
23
+ ### Fixed
24
+
25
+ - Detached eval cell completion notices no longer enter the user-input steering queue. They were delivered via `sendUserMessage`, so hosts projecting that queue (e.g. the OmO desktop composer) rendered the raw `<system-reminder>Detached eval cell …</system-reminder>` notice under the STEERING heading as if the user had typed and queued it. Notices now deliver via `sendMessage` with `customType: "senpi-codemode:notification"` and `display: false` — model-visible, never painted as user input — matching the terminal and monitor notification contract.
26
+
27
+ ### Removed
28
+
29
+ ## [2026.8.22-2] - 2026-08-22
30
+
31
+ ### Breaking Changes
32
+
33
+ ### Added
34
+
35
+ - Eval headers now display the kernel runtime identity, e.g. `eval py (3.14.7, ~/.venv/bin/python3)` and `eval js (node 26.7.0, /opt/…/bin/node)`; the same `runtime` info rides `EvalToolDetails` and its `cells` so RPC consumers receive it, interpreter detection resolves absolute executable paths from PATH, and the eval prompt host line names the JS runtime (`node`/`bun` with version).
36
+
37
+ ### Changed
38
+
39
+ - Running eval cell headers now tick their elapsed time in real time (`eval py running · 13s`) instead of freezing between kernel update events; the renderer derives elapsed time from a render-time clock while a cell is pending/running/detached and repaints once per second, while settled cells keep their exact final duration. `EvalCellResult` gains an additive `startedAt` so RPC consumers can compute the same live value.
40
+
41
+ ### Fixed
42
+
43
+ - A host tool call from inside an eval cell no longer suspends the cell's timeout indefinitely. The idle watchdog previously cleared its timer for the entire duration of a bridge call, so a call that never returned (e.g. an awaited `dag-wait`) left the cell pending — and the agent loop parked, queueing user messages invisibly — until the 1800s hard limit. The pause is now bounded by a max pause grace (default 600s, floored at the cell's own `timeout`): a long bridge call such as a 5-minute build still runs to completion, but a stuck one now trips the cell's `on_timeout` handling and releases the loop.
44
+
45
+ ### Removed
46
+
15
47
  ## [2026.8.22] - 2026-08-22
16
48
 
17
49
  ### Breaking Changes
@@ -30,6 +30,11 @@ task-tool names are known.
30
30
  - TUI and HTML-export rendering for syntax-highlighted cells, status rows,
31
31
  task progress, structured display values, truncation warnings, and image
32
32
  fallbacks.
33
+ - Runtime identity badges in eval headers — `eval py (3.14.7, ~/.venv/bin/python3)`,
34
+ `eval js (node 26.7.0, /opt/…/bin/node)` — with the same `runtime` info on
35
+ `EvalToolDetails` and its `cells` for RPC consumers; interpreter detection
36
+ resolves absolute executable paths, and the eval prompt host line names the
37
+ JS runtime (`node`/`bun`).
33
38
  - JavaScript import rewriting for supported local modules and package imports
34
39
  in the persistent Node.js worker.
35
40
  - GPT models receive a terse `eval` prompt dialect that prioritizes composing
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-codemode",
3
- "version": "2026.8.22",
3
+ "version": "2026.8.23",
4
4
  "private": true,
5
5
  "description": "Source-only senpi extension package for codemode evaluation tools",
6
6
  "type": "module",
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/parser": "8.0.4",
34
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.22",
34
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.23",
35
35
  "typebox": "1.3.16"
36
36
  },
37
37
  "peerDependencies": {
38
- "@code-yeongyu/senpi": "2026.8.22"
38
+ "@code-yeongyu/senpi": "2026.8.23"
39
39
  },
40
40
  "devDependencies": {
41
- "@code-yeongyu/senpi": "2026.8.22"
41
+ "@code-yeongyu/senpi": "2026.8.23"
42
42
  },
43
43
  "keywords": [
44
44
  "senpi",
@@ -3,10 +3,17 @@ import type { EvalDetachedCellNotification, EvalDetachedCellNotifier } from "../
3
3
 
4
4
  const NON_INTERACTIVE_MODES = new Set(["print", "json"]);
5
5
 
6
+ /** Provenance marker for agent-internal detached-cell notices. */
7
+ export const EVAL_NOTIFICATION_CUSTOM_TYPE = "senpi-codemode:notification";
8
+
6
9
  export type EvalNotifyMode = "wake" | "next-turn" | "off";
7
10
 
8
11
  export interface EvalNotifierDeps {
9
- readonly sendUserMessage: (content: string, options?: { deliverAs?: "steer" | "followUp" }) => void;
12
+ /** Deliver a model-visible notification without rendering synthetic user input. */
13
+ readonly sendMessage: (
14
+ message: { customType: string; content: string; display: boolean },
15
+ options: { triggerTurn: boolean; deliverAs: "steer" | "followUp" },
16
+ ) => void;
10
17
  readonly getContext: () => ExtensionContext | undefined;
11
18
  readonly getMode: () => EvalNotifyMode;
12
19
  }
@@ -33,8 +40,13 @@ export class EvalNotifier implements EvalDetachedCellNotifier {
33
40
  const pending = cells.filter((cell) => !this.#notified.has(cell.cellId));
34
41
  if (pending.length === 0) return;
35
42
  for (const cell of pending) this.#notified.add(cell.cellId);
36
- this.#deps.sendUserMessage(pending.map((cell) => cell.content).join("\n\n"), {
37
- deliverAs: mode === "wake" ? "steer" : "followUp",
38
- });
43
+ this.#deps.sendMessage(
44
+ {
45
+ customType: EVAL_NOTIFICATION_CUSTOM_TYPE,
46
+ content: pending.map((cell) => cell.content).join("\n\n"),
47
+ display: false,
48
+ },
49
+ { triggerTurn: true, deliverAs: mode === "wake" ? "steer" : "followUp" },
50
+ );
39
51
  }
40
52
  }
@@ -14,7 +14,8 @@ import {
14
14
  type InterpreterAvailability,
15
15
  } from "../interpreters/detect.ts";
16
16
  import { resolveSessionArtifactsDir } from "../output/streaming-output.ts";
17
- import type { EnabledEvalLanguages, EvalLanguage } from "../tool/types.ts";
17
+ import type { EnabledEvalLanguages, EvalLanguage, EvalRuntimes } from "../tool/types.ts";
18
+ import { jsRuntimeInfo, runtimesFromAvailability } from "./runtime-info.ts";
18
19
  import {
19
20
  type CodemodeSessionManager,
20
21
  type CreateCodemodeSessionManagerOptions,
@@ -39,6 +40,7 @@ export type SessionRuntime = {
39
40
  readonly parallelPoolWidth: number;
40
41
  readonly manager: CodemodeSessionManager;
41
42
  readonly enabledLanguages: EnabledEvalLanguages;
43
+ readonly runtimes: EvalRuntimes;
42
44
  readonly settings: ResolvedCodemodeSettings;
43
45
  readonly artifactsDir: string;
44
46
  readonly executeTool: AgentExecuteTool;
@@ -82,6 +84,7 @@ export async function createRuntime(
82
84
  parallelPoolWidth,
83
85
  manager,
84
86
  enabledLanguages,
87
+ runtimes: runtimesFromAvailability(availability, jsRuntimeInfo()),
85
88
  settings,
86
89
  artifactsDir: artifacts.dir,
87
90
  executeTool,
@@ -0,0 +1,41 @@
1
+ import type { InterpreterAvailability } from "../interpreters/detect.ts";
2
+ import type { EvalLanguage, EvalRuntimeInfo, EvalRuntimes } from "../tool/types.ts";
3
+
4
+ export interface JsRuntimeVersions {
5
+ readonly node: string;
6
+ readonly bun?: string | undefined;
7
+ }
8
+
9
+ /** Identity of the in-process JS kernel host: bun when its marker exists, node otherwise. */
10
+ export function jsRuntimeInfo(
11
+ versions: JsRuntimeVersions = process.versions,
12
+ execPath: string = process.execPath,
13
+ ): EvalRuntimeInfo {
14
+ const bun = versions.bun;
15
+ if (bun !== undefined && bun.length > 0) return { name: "bun", version: bun, path: execPath };
16
+ return { name: "node", version: versions.node, path: execPath };
17
+ }
18
+
19
+ /** Short host-line segment, e.g. "node 26.7.0" or "bun 1.4.0". */
20
+ export function jsRuntimeLabel(versions: JsRuntimeVersions = process.versions): string {
21
+ const info = jsRuntimeInfo(versions, "");
22
+ return `${info.name} ${info.version}`;
23
+ }
24
+
25
+ const subprocessRuntimeNames = { py: "python", rb: "ruby", jl: "julia" } as const;
26
+ const subprocessLanguages = ["py", "rb", "jl"] as const;
27
+
28
+ /** Maps detected interpreters to display runtimes, preferring resolved absolute paths. */
29
+ export function runtimesFromAvailability(availability: InterpreterAvailability, js: EvalRuntimeInfo): EvalRuntimes {
30
+ const runtimes: Partial<Record<EvalLanguage, EvalRuntimeInfo>> = { js };
31
+ for (const language of subprocessLanguages) {
32
+ const detected = availability[language].detected;
33
+ if (!detected.ok) continue;
34
+ runtimes[language] = {
35
+ name: subprocessRuntimeNames[language],
36
+ version: detected.version,
37
+ path: detected.resolvedPath ?? detected.path,
38
+ };
39
+ }
40
+ return runtimes;
41
+ }
@@ -13,6 +13,7 @@ import {
13
13
  enabledLanguagesFrom,
14
14
  type SessionRuntime,
15
15
  } from "./extension/runtime-factory.ts";
16
+ import { jsRuntimeInfo, jsRuntimeLabel } from "./extension/runtime-info.ts";
16
17
  import type { CodemodeSessionManager, CreateCodemodeSessionManagerOptions } from "./extension/session-manager.ts";
17
18
  import { SessionManagerProxy } from "./extension/session-manager-proxy.ts";
18
19
  import { WAKE_SOURCE_STATE_EVENT, type WakeSourceState } from "./extension/wake-source-state.ts";
@@ -43,7 +44,10 @@ export interface CodemodeExtensionAPI {
43
44
  executeTool: AgentExecuteTool;
44
45
  getActiveTools(): string[];
45
46
  getAllTools(): readonly EvalSchemaToolInfo[];
46
- sendUserMessage(content: string, options?: { deliverAs?: "steer" | "followUp" }): void;
47
+ sendMessage(
48
+ message: { customType: string; content: string; display: boolean },
49
+ options?: { triggerTurn?: boolean; deliverAs?: "steer" | "followUp" | "nextTurn" },
50
+ ): void;
47
51
  /** Optional host event bus; a host without one turns extension event emission into a harmless no-op. */
48
52
  events?: { emit(name: string, data: unknown): void };
49
53
  /** Optional host RPC surface for forwarding extension-owned events to connected clients. */
@@ -68,7 +72,7 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
68
72
  let activeContext: ExtensionContext | undefined;
69
73
  let activeCells: EvalDetachedCellManager | undefined;
70
74
  const notifier = new EvalNotifier({
71
- sendUserMessage: (content, notifyOptions) => pi.sendUserMessage(content, notifyOptions),
75
+ sendMessage: (message, notifyOptions) => pi.sendMessage(message, notifyOptions),
72
76
  getContext: () => activeContext,
73
77
  getMode: () => "wake",
74
78
  });
@@ -119,6 +123,7 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
119
123
  spawns: runtime.spawns,
120
124
  spawnDefaultAgent: runtime.settings.taskTools.task,
121
125
  hostLine: hostLine(),
126
+ runtimes: runtime.runtimes,
122
127
  ...(modelId === undefined ? {} : { modelId }),
123
128
  }),
124
129
  );
@@ -152,6 +157,7 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
152
157
  executionTracker: manager,
153
158
  renderers,
154
159
  hostLine: hostLine(),
160
+ runtimes: { js: jsRuntimeInfo() },
155
161
  }),
156
162
  );
157
163
  pi.registerRemovedToolHint(
@@ -206,7 +212,7 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
206
212
 
207
213
  function hostLine(): string {
208
214
  const cpu = os.cpus()[0]?.model?.trim();
209
- return [`${os.platform()} ${os.arch()}`, cpu, `${os.availableParallelism()} cores`]
215
+ return [`${os.platform()} ${os.arch()}`, cpu, `${os.availableParallelism()} cores`, jsRuntimeLabel()]
210
216
  .filter((part): part is string => !!part)
211
217
  .join(" \u00b7 ");
212
218
  }
@@ -2,6 +2,7 @@ import { execFile } from "node:child_process";
2
2
  import { platform as currentPlatform } from "node:os";
3
3
  import { promisify } from "node:util";
4
4
  import type { CodemodeSettings } from "../config/settings.ts";
5
+ import { resolveCommandPath as defaultResolveCommandPath, type ResolveCommandPath } from "./resolve-command.ts";
5
6
 
6
7
  const execFileAsync = promisify(execFile);
7
8
  const probeTimeoutMs = 3_000;
@@ -10,8 +11,11 @@ export type CodemodeLanguage = "py" | "js" | "rb" | "jl";
10
11
 
11
12
  export interface InterpreterDetected {
12
13
  readonly ok: true;
14
+ /** The probe command line that answered, e.g. "python3" or "py -3". */
13
15
  readonly path: string;
14
16
  readonly version: string;
17
+ /** Absolute executable path resolved from PATH, when resolution succeeded. */
18
+ readonly resolvedPath?: string;
15
19
  }
16
20
 
17
21
  export interface InterpreterUnavailable {
@@ -34,6 +38,7 @@ export interface CreateInterpreterDetectorOptions {
34
38
  readonly platform?: NodeJS.Platform;
35
39
  readonly execFile?: ExecFileProbe;
36
40
  readonly nodeVersion?: string;
41
+ readonly resolveCommandPath?: ResolveCommandPath;
37
42
  }
38
43
 
39
44
  export interface InterpreterDetector {
@@ -55,6 +60,7 @@ export function createInterpreterDetector(options: CreateInterpreterDetectorOpti
55
60
  const probe = options.execFile ?? defaultExecFileProbe;
56
61
  const hostPlatform = options.platform ?? currentPlatform();
57
62
  const nodeVersion = options.nodeVersion ?? process.versions.node;
63
+ const resolveCommand = options.resolveCommandPath ?? defaultResolveCommandPath;
58
64
  const cache = new Map<CodemodeLanguage, Promise<InterpreterDetection>>();
59
65
 
60
66
  return {
@@ -64,7 +70,7 @@ export function createInterpreterDetector(options: CreateInterpreterDetectorOpti
64
70
  return cached;
65
71
  }
66
72
 
67
- const pending = detectUncached(language, hostPlatform, probe, nodeVersion);
73
+ const pending = detectUncached(language, hostPlatform, probe, nodeVersion, resolveCommand);
68
74
  cache.set(language, pending);
69
75
  return pending;
70
76
  },
@@ -99,13 +105,14 @@ async function detectUncached(
99
105
  hostPlatform: NodeJS.Platform,
100
106
  probe: ExecFileProbe,
101
107
  nodeVersion: string,
108
+ resolveCommand: ResolveCommandPath,
102
109
  ): Promise<InterpreterDetection> {
103
110
  if (language === "js") {
104
111
  return { ok: true, path: "node", version: nodeVersion };
105
112
  }
106
113
 
107
114
  for (const candidate of candidatesFor(language, hostPlatform)) {
108
- const result = await probeCandidate(candidate, probe);
115
+ const result = await probeCandidate(candidate, probe, resolveCommand);
109
116
  if (result.ok) {
110
117
  return result;
111
118
  }
@@ -114,12 +121,18 @@ async function detectUncached(
114
121
  return unavailable;
115
122
  }
116
123
 
117
- async function probeCandidate(candidate: string, probe: ExecFileProbe): Promise<InterpreterDetection> {
124
+ async function probeCandidate(
125
+ candidate: string,
126
+ probe: ExecFileProbe,
127
+ resolveCommand: ResolveCommandPath,
128
+ ): Promise<InterpreterDetection> {
118
129
  const invocation = candidateInvocation(candidate);
119
130
  try {
120
131
  const result = await probe(invocation.command, [...invocation.args, "--version"], { timeoutMs: probeTimeoutMs });
121
132
  const version = parseVersion(`${result.stdout}\n${result.stderr}`);
122
- return version === null ? unavailable : { ok: true, path: candidate, version };
133
+ if (version === null) return unavailable;
134
+ const resolvedPath = resolveCommand(invocation.command);
135
+ return { ok: true, path: candidate, version, ...(resolvedPath === undefined ? {} : { resolvedPath }) };
123
136
  } catch {
124
137
  return unavailable;
125
138
  }
@@ -0,0 +1,68 @@
1
+ import { accessSync, constants, statSync } from "node:fs";
2
+ import { delimiter, isAbsolute, resolve as resolvePath } from "node:path";
3
+
4
+ export interface ResolveCommandPathOptions {
5
+ readonly env?: NodeJS.ProcessEnv;
6
+ readonly platform?: NodeJS.Platform;
7
+ readonly cwd?: string;
8
+ }
9
+
10
+ export type ResolveCommandPath = (command: string, options?: ResolveCommandPathOptions) => string | undefined;
11
+
12
+ const defaultWindowsPathExt = ".COM;.EXE;.BAT;.CMD";
13
+
14
+ /**
15
+ * Resolves a bare command name to the absolute executable path a spawn would
16
+ * use, by scanning PATH without spawning a process. Returns undefined when the
17
+ * command cannot be resolved; callers treat that as "no display path known".
18
+ */
19
+ export function resolveCommandPath(command: string, options: ResolveCommandPathOptions = {}): string | undefined {
20
+ if (command.length === 0) return undefined;
21
+ const env = options.env ?? process.env;
22
+ const platform = options.platform ?? process.platform;
23
+ const isWindows = platform === "win32";
24
+ if (command.includes("/") || (isWindows && command.includes("\\"))) {
25
+ const absolute = isAbsolute(command) ? command : resolvePath(options.cwd ?? process.cwd(), command);
26
+ return firstExecutable(candidatesFor(absolute, isWindows, env), isWindows);
27
+ }
28
+ const pathValue = env.PATH ?? env.Path ?? "";
29
+ if (pathValue.length === 0) return undefined;
30
+ for (const directory of pathValue.split(delimiter)) {
31
+ if (directory.length === 0) continue;
32
+ const base = `${directory}${directory.endsWith("/") || directory.endsWith("\\") ? "" : pathSeparatorFor(directory, isWindows)}${command}`;
33
+ const found = firstExecutable(candidatesFor(base, isWindows, env), isWindows);
34
+ if (found !== undefined) return found;
35
+ }
36
+ return undefined;
37
+ }
38
+
39
+ function pathSeparatorFor(directory: string, isWindows: boolean): string {
40
+ if (isWindows && directory.includes("\\") && !directory.includes("/")) return "\\";
41
+ return "/";
42
+ }
43
+
44
+ function candidatesFor(base: string, isWindows: boolean, env: NodeJS.ProcessEnv): readonly string[] {
45
+ if (!isWindows) return [base];
46
+ const extensions = (env.PATHEXT ?? defaultWindowsPathExt)
47
+ .split(";")
48
+ .map((extension) => extension.trim())
49
+ .filter((extension) => extension.startsWith("."));
50
+ const candidates = [base];
51
+ for (const extension of extensions) {
52
+ candidates.push(`${base}${extension.toLowerCase()}`, `${base}${extension}`);
53
+ }
54
+ return candidates;
55
+ }
56
+
57
+ function firstExecutable(candidates: readonly string[], isWindows: boolean): string | undefined {
58
+ for (const candidate of candidates) {
59
+ try {
60
+ if (!statSync(candidate).isFile()) continue;
61
+ if (!isWindows) accessSync(candidate, constants.X_OK);
62
+ return candidate;
63
+ } catch {
64
+ // Missing or non-executable candidate: keep scanning the remaining ones.
65
+ }
66
+ }
67
+ return undefined;
68
+ }
@@ -3,9 +3,18 @@ export interface IdleTimeoutEvent {
3
3
  readonly error: Error;
4
4
  }
5
5
 
6
+ /**
7
+ * Upper bound on how long a single host bridge call may suspend a cell's idle watchdog.
8
+ * Generous enough for a long build or a slow model call, short enough that a bridge call which
9
+ * never returns cannot park the cell — and with it the agent loop — until the 1800s hard limit.
10
+ */
11
+ export const DEFAULT_MAX_PAUSE_GRACE_MS = 600_000;
12
+
6
13
  export interface IdleTimeoutOptions {
7
14
  readonly cellId: string;
8
15
  readonly timeoutMs: number;
16
+ /** Defaults to {@link DEFAULT_MAX_PAUSE_GRACE_MS}; floored at `timeoutMs` so a pause never shortens the budget. */
17
+ readonly maxPauseGraceMs?: number;
9
18
  readonly onTimeout: (event: IdleTimeoutEvent) => void;
10
19
  }
11
20
 
@@ -20,7 +29,9 @@ export class IdleTimeout implements TimeoutPauseHandle {
20
29
  readonly #controller = new AbortController();
21
30
  readonly signal = this.#controller.signal;
22
31
  readonly timeoutMs: number;
32
+ readonly maxPauseGraceMs: number;
23
33
  #deadlineMs: number;
34
+ #pausedDeadlineMs: number | undefined;
24
35
  #timer: ReturnType<typeof setTimeout> | undefined;
25
36
  #pauseDepth = 0;
26
37
  #settled = false;
@@ -28,22 +39,32 @@ export class IdleTimeout implements TimeoutPauseHandle {
28
39
  constructor(options: IdleTimeoutOptions) {
29
40
  this.#cellId = options.cellId;
30
41
  this.timeoutMs = Math.max(1, Math.floor(options.timeoutMs));
42
+ this.maxPauseGraceMs = Math.max(
43
+ this.timeoutMs,
44
+ Math.floor(options.maxPauseGraceMs ?? DEFAULT_MAX_PAUSE_GRACE_MS),
45
+ );
31
46
  this.#deadlineMs = Date.now() + this.timeoutMs;
32
47
  this.#onTimeout = options.onTimeout;
33
48
  this.#arm(this.timeoutMs);
34
49
  }
35
50
 
51
+ /**
52
+ * Suspends the idle deadline for the duration of a host bridge call, but only up to the pause grace:
53
+ * the cell still expires if the call never returns. Nested pauses share the outermost pause's deadline.
54
+ */
36
55
  pause(): void {
37
56
  if (this.#settled) return;
38
57
  this.#pauseDepth++;
39
58
  if (this.#pauseDepth !== 1) return;
40
- this.#clearTimer();
59
+ this.#pausedDeadlineMs = Date.now() + this.maxPauseGraceMs;
60
+ this.#arm(this.maxPauseGraceMs);
41
61
  }
42
62
 
43
63
  resume(): void {
44
64
  if (this.#settled || this.#pauseDepth === 0) return;
45
65
  this.#pauseDepth--;
46
66
  if (this.#pauseDepth > 0) return;
67
+ this.#pausedDeadlineMs = undefined;
47
68
  this.#deadlineMs = Date.now() + this.timeoutMs;
48
69
  this.#arm(this.timeoutMs);
49
70
  }
@@ -51,6 +72,7 @@ export class IdleTimeout implements TimeoutPauseHandle {
51
72
  dispose(): void {
52
73
  if (this.#settled) return;
53
74
  this.#settled = true;
75
+ this.#pausedDeadlineMs = undefined;
54
76
  this.#clearTimer();
55
77
  }
56
78
 
@@ -68,15 +90,22 @@ export class IdleTimeout implements TimeoutPauseHandle {
68
90
  }
69
91
 
70
92
  #expire(): void {
71
- if (this.#settled || this.#pauseDepth > 0) return;
72
- const remainingMs = this.#deadlineMs - Date.now();
93
+ if (this.#settled) return;
94
+ const pausedDeadlineMs = this.#pausedDeadlineMs;
95
+ if (this.#pauseDepth > 0 && pausedDeadlineMs === undefined) return;
96
+ const deadlineMs = pausedDeadlineMs ?? this.#deadlineMs;
97
+ const remainingMs = deadlineMs - Date.now();
73
98
  if (remainingMs > 0) {
74
99
  this.#arm(remainingMs);
75
100
  return;
76
101
  }
77
102
  this.#settled = true;
103
+ this.#pausedDeadlineMs = undefined;
78
104
  this.#timer = undefined;
79
- const error = new Error(`Cell timed out after ${this.timeoutMs}ms`);
105
+ const error =
106
+ pausedDeadlineMs === undefined
107
+ ? new Error(`Cell timed out after ${this.timeoutMs}ms`)
108
+ : new Error(`Cell timed out after ${this.maxPauseGraceMs}ms waiting on a host tool call`);
80
109
  error.name = "TimeoutError";
81
110
  this.#controller.abort(error);
82
111
  this.#onTimeout({ cellId: this.#cellId, error });
@@ -2,7 +2,7 @@ import type { AgentToolResult, AgentToolUpdateCallback, ExtensionContext } from
2
2
  import type { KernelToHostMessage } from "../bridge/protocol.ts";
3
3
  import type { EvalToolCallMetric } from "./call-capture.ts";
4
4
  import { type EvalImageResizer, EvalOutputCollector, type EvalOutputResult } from "./image.ts";
5
- import type { EvalStatusEvent, EvalToolDetails, EvalToolInput } from "./types.ts";
5
+ import type { EvalRuntimeInfo, EvalStatusEvent, EvalToolDetails, EvalToolInput } from "./types.ts";
6
6
 
7
7
  type KernelResult = Extract<KernelToHostMessage, { type: "result" }>;
8
8
  type DisplayMessage = Extract<KernelToHostMessage, { type: "display" }>;
@@ -10,6 +10,7 @@ type ToolCall = EvalToolDetails["toolCalls"] extends readonly (infer Item)[] ? I
10
10
 
11
11
  export interface CellState {
12
12
  readonly input: EvalToolInput;
13
+ readonly runtime?: EvalRuntimeInfo;
13
14
  readonly startedAt: number;
14
15
  readonly signal: AbortSignal;
15
16
  readonly onUpdate: AgentToolUpdateCallback<EvalToolDetails> | undefined;
@@ -125,6 +126,7 @@ export class CellResultBuilder {
125
126
  return {
126
127
  language: this.#state.input.language,
127
128
  languages: [this.#state.input.language],
129
+ ...(this.#state.runtime === undefined ? {} : { runtime: this.#state.runtime }),
128
130
  ...(this.#state.input.summary === undefined ? {} : { summary: this.#state.input.summary }),
129
131
  durationMs: this.#state.durationMs,
130
132
  wallDurationMs: Math.max(0, Date.now() - this.#state.startedAt),
@@ -139,9 +141,11 @@ export class CellResultBuilder {
139
141
  ...(this.#state.input.summary === undefined ? {} : { summary: this.#state.input.summary }),
140
142
  code: this.#state.input.code,
141
143
  language: this.#state.input.language,
144
+ ...(this.#state.runtime === undefined ? {} : { runtime: this.#state.runtime }),
142
145
  output: this.#state.output,
143
146
  status: this.#state.status,
144
147
  durationMs: this.#state.durationMs,
148
+ startedAt: this.#state.startedAt,
145
149
  ...(statusEvents === undefined ? {} : { statusEvents }),
146
150
  ...(output?.hasMarkdown ? { hasMarkdown: true } : {}),
147
151
  },
@@ -11,6 +11,7 @@ import type {
11
11
  EnabledEvalLanguages,
12
12
  EvalInputSchema,
13
13
  EvalKernelManager,
14
+ EvalRuntimes,
14
15
  EvalToolDetails,
15
16
  EvalToolInput,
16
17
  ExecuteTool,
@@ -38,6 +39,8 @@ export interface CreateEvalToolOptions {
38
39
  readonly spawnDefaultAgent?: string;
39
40
  readonly modelId?: string;
40
41
  readonly hostLine?: string;
42
+ /** Display identity of each language's runtime, shown in headers and details. */
43
+ readonly runtimes?: EvalRuntimes;
41
44
  }
42
45
 
43
46
  export interface EvalCellInvocation {
@@ -98,8 +98,10 @@ async function runEvalCell(
98
98
  const bridgeAbortController = new AbortController();
99
99
  const cellSignal = AbortSignal.any([invocation.signal, bridgeAbortController.signal]);
100
100
  const bridgeContext: ExtensionContext = { ...invocation.ctx, signal: cellSignal };
101
+ const runtime = options.runtimes?.[invocation.input.language];
101
102
  const state: CellState = {
102
103
  input: invocation.input,
104
+ ...(runtime === undefined ? {} : { runtime }),
103
105
  startedAt: Date.now(),
104
106
  signal: cellSignal,
105
107
  onUpdate: invocation.onUpdate,