@zergai/ztc 0.26.6-dev.202611240947 → 0.27.0-beta.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.
Files changed (268) hide show
  1. package/README.md +629 -167
  2. package/RUST_THIRD_PARTY_LICENSES.txt +5 -5
  3. package/bin/zmux-darwin-arm64 +0 -0
  4. package/bin/zmux-linux-x64 +0 -0
  5. package/bin/ztc-audio-darwin-arm64 +0 -0
  6. package/bin/ztc-capture-darwin-arm64 +0 -0
  7. package/bin/ztc-computer-darwin-arm64 +0 -0
  8. package/bin/ztc-llm-darwin-arm64 +0 -0
  9. package/bin/ztc-tts-darwin-arm64 +0 -0
  10. package/bin/ztc-tui-darwin-arm64 +0 -0
  11. package/bin/ztc-tui-linux-x64 +0 -0
  12. package/bin/zterm-darwin-arm64 +2 -2
  13. package/dist/App.js +6 -1
  14. package/dist/agent/agent.d.ts +21 -15
  15. package/dist/agent/agent.js +389 -163
  16. package/dist/agent/backends/codex_app_server.d.ts +7 -1
  17. package/dist/agent/backends/codex_app_server.js +11 -1
  18. package/dist/agent/backends/gemini.js +22 -8
  19. package/dist/agent/commands/batch.js +8 -0
  20. package/dist/agent/commands/config.js +10 -0
  21. package/dist/agent/commands/environment.js +5 -5
  22. package/dist/agent/commands/goal.d.ts +1 -0
  23. package/dist/agent/commands/goal.js +2 -1
  24. package/dist/agent/commands/index.js +2 -1
  25. package/dist/agent/commands/manifest.js +4 -0
  26. package/dist/agent/commands/optimize.js +5 -2
  27. package/dist/agent/commands/pane_cli.d.ts +29 -0
  28. package/dist/agent/commands/pane_cli.js +303 -0
  29. package/dist/agent/commands/settings.js +13 -3
  30. package/dist/agent/commands/shannon.js +8 -0
  31. package/dist/agent/commands/update.js +15 -3
  32. package/dist/agent/commands/zerg.js +31 -1
  33. package/dist/agent/commands/ztc_pane.js +3 -1
  34. package/dist/agent/factory.d.ts +4 -0
  35. package/dist/agent/factory.js +11 -1
  36. package/dist/agent/loop_policy.d.ts +42 -5
  37. package/dist/agent/loop_policy.js +206 -3
  38. package/dist/agent/runtime/command_jobs.d.ts +5 -0
  39. package/dist/agent/runtime/command_jobs.js +241 -31
  40. package/dist/agent/runtime/command_wait.d.ts +2 -0
  41. package/dist/agent/runtime/command_wait.js +1 -0
  42. package/dist/agent/runtime/done_report.d.ts +18 -0
  43. package/dist/agent/runtime/done_report.js +130 -0
  44. package/dist/agent/runtime/execution_context.js +4 -1
  45. package/dist/agent/runtime/failure_cause.d.ts +2 -0
  46. package/dist/agent/runtime/failure_cause.js +35 -0
  47. package/dist/agent/runtime/policy.d.ts +14 -2
  48. package/dist/agent/runtime/policy.js +104 -12
  49. package/dist/agent/runtime/quiet_job.d.ts +18 -0
  50. package/dist/agent/runtime/quiet_job.js +48 -0
  51. package/dist/agent/runtime/recovery.d.ts +1 -5
  52. package/dist/agent/runtime/recovery.js +2 -44
  53. package/dist/agent/runtime/tool_runtime.d.ts +1 -0
  54. package/dist/agent/runtime/tool_runtime.js +2 -0
  55. package/dist/agent/subagent.js +6 -1
  56. package/dist/agent/tools/deferred.js +1 -0
  57. package/dist/agent/tools/index.d.ts +2 -0
  58. package/dist/agent/tools/index.js +1 -0
  59. package/dist/agent/tools/outcome.d.ts +15 -0
  60. package/dist/agent/tools/outcome.js +107 -0
  61. package/dist/agent/tools/pane.d.ts +2 -1
  62. package/dist/agent/tools/pane.js +21 -3
  63. package/dist/agent/tools/registry.js +2 -0
  64. package/dist/agent/tools/shell.d.ts +1 -0
  65. package/dist/agent/tools/shell.js +128 -17
  66. package/dist/agent/tools/sim_domain_tools.js +4 -2
  67. package/dist/agent/tools/supervision.js +4 -2
  68. package/dist/agent/tools/types.d.ts +3 -0
  69. package/dist/app/command_context.js +5 -9
  70. package/dist/app/conversation_compaction.d.ts +4 -2
  71. package/dist/app/conversation_compaction.js +16 -5
  72. package/dist/app/headless_shell_mode.d.ts +14 -0
  73. package/dist/app/headless_shell_mode.js +7 -0
  74. package/dist/app/hosted_resident.d.ts +356 -0
  75. package/dist/app/hosted_resident.js +677 -0
  76. package/dist/app/restart.js +11 -2
  77. package/dist/app/session_manager.d.ts +5 -0
  78. package/dist/app/session_manager.js +21 -6
  79. package/dist/app/session_messages.js +6 -6
  80. package/dist/app/workspace_layout_controller.js +7 -0
  81. package/dist/batch/worktree.d.ts +10 -0
  82. package/dist/batch/worktree.js +15 -0
  83. package/dist/bench/registry.js +4 -2
  84. package/dist/cli_args.js +1 -1
  85. package/dist/cli_main.js +80 -10
  86. package/dist/cli_ratatui.d.ts +75 -0
  87. package/dist/cli_ratatui.js +485 -84
  88. package/dist/components/InputArea.js +4 -4
  89. package/dist/config/execution.d.ts +10 -0
  90. package/dist/config/execution.js +10 -0
  91. package/dist/config/hosted_runtime.d.ts +4 -1
  92. package/dist/config/hosted_runtime.js +4 -1
  93. package/dist/config/permission_pin.d.ts +34 -2
  94. package/dist/config/permission_pin.js +52 -2
  95. package/dist/config/person_command_policy.d.ts +38 -0
  96. package/dist/config/person_command_policy.js +11 -0
  97. package/dist/config/profiles.d.ts +21 -0
  98. package/dist/config/profiles.js +56 -2
  99. package/dist/config/types.d.ts +4 -1
  100. package/dist/config.js +34 -19
  101. package/dist/desktop/daily/codex_exec_adapter.js +7 -2
  102. package/dist/desktop/daily/desktop_wiring.d.ts +7 -1
  103. package/dist/desktop/daily/desktop_wiring.js +11 -3
  104. package/dist/desktop/daily/recipes.js +20 -4
  105. package/dist/desktop/health.d.ts +24 -0
  106. package/dist/desktop/health.js +151 -0
  107. package/dist/desktop/native_dialogs.d.ts +37 -0
  108. package/dist/desktop/native_dialogs.js +105 -0
  109. package/dist/diagnostics/session_export.d.ts +1 -0
  110. package/dist/diagnostics/session_export.js +28 -0
  111. package/dist/embedded/registry.js +4 -2
  112. package/dist/emulation/tool_adapters.js +9 -4
  113. package/dist/emulation/ztc_addendum.js +3 -0
  114. package/dist/headless.d.ts +11 -4
  115. package/dist/headless.js +99 -34
  116. package/dist/headless_approval.d.ts +6 -0
  117. package/dist/headless_cli.js +1 -1
  118. package/dist/hooks/runner.js +7 -6
  119. package/dist/library.d.ts +4 -0
  120. package/dist/library.js +3 -0
  121. package/dist/mcp/client.js +3 -3
  122. package/dist/modes/registry.js +13 -4
  123. package/dist/onboarding/setup_environment.js +13 -1
  124. package/dist/optimize/adapters/kernelbench.js +88 -10
  125. package/dist/optimize/adapters/types.d.ts +5 -0
  126. package/dist/optimize/executor.js +21 -0
  127. package/dist/panes/cli_install.d.ts +54 -0
  128. package/dist/panes/cli_install.js +157 -0
  129. package/dist/panes/model_catalog.js +3 -0
  130. package/dist/panes/new_pane_choices.d.ts +6 -2
  131. package/dist/panes/new_pane_choices.js +24 -12
  132. package/dist/panes/pane_cli_launch.d.ts +50 -0
  133. package/dist/panes/pane_cli_launch.js +124 -0
  134. package/dist/panes/pane_clis.d.ts +171 -0
  135. package/dist/panes/pane_clis.js +325 -0
  136. package/dist/panes/person_only_panes.d.ts +45 -0
  137. package/dist/panes/person_only_panes.js +117 -0
  138. package/dist/plugin/simulation_living.js +0 -2
  139. package/dist/plugin/simulation_living_engine.d.ts +1 -0
  140. package/dist/plugin/simulation_living_engine.js +1 -0
  141. package/dist/plugin/simulation_living_labels.d.ts +3 -0
  142. package/dist/plugin/simulation_living_labels.js +2 -0
  143. package/dist/router_auth.js +12 -1
  144. package/dist/session.js +26 -1
  145. package/dist/simulation/art/gemini_image.js +11 -5
  146. package/dist/simulation/domains/loader.js +25 -3
  147. package/dist/simulation/living/cold.d.ts +23 -0
  148. package/dist/simulation/living/cold.js +41 -0
  149. package/dist/simulation/living/context.d.ts +591 -1283
  150. package/dist/simulation/living/context.js +378 -244
  151. package/dist/simulation/living/contradictions.d.ts +14 -0
  152. package/dist/simulation/living/contradictions.js +282 -0
  153. package/dist/simulation/living/core/ids.d.ts +53 -0
  154. package/dist/simulation/living/core/ids.js +39 -0
  155. package/dist/simulation/living/core/kind.d.ts +20 -0
  156. package/dist/simulation/living/core/kind.js +15 -0
  157. package/dist/simulation/living/core/laws.d.ts +179 -0
  158. package/dist/simulation/living/core/laws.js +184 -0
  159. package/dist/simulation/living/core/ops.d.ts +257 -0
  160. package/dist/simulation/living/core/ops.js +34 -0
  161. package/dist/simulation/living/definer.d.ts +17 -1
  162. package/dist/simulation/living/definer.js +130 -51
  163. package/dist/simulation/living/definition.d.ts +174 -65
  164. package/dist/simulation/living/definition.js +287 -180
  165. package/dist/simulation/living/director.d.ts +80 -0
  166. package/dist/simulation/living/director.js +363 -0
  167. package/dist/simulation/living/frame.d.ts +108 -21
  168. package/dist/simulation/living/frame.js +111 -66
  169. package/dist/simulation/living/identifiers.d.ts +0 -1
  170. package/dist/simulation/living/identifiers.js +0 -3
  171. package/dist/simulation/living/index.d.ts +18 -9
  172. package/dist/simulation/living/index.js +18 -9
  173. package/dist/simulation/living/inference.d.ts +92 -50
  174. package/dist/simulation/living/inference.js +319 -175
  175. package/dist/simulation/living/knowledge.d.ts +28 -0
  176. package/dist/simulation/living/knowledge.js +73 -0
  177. package/dist/simulation/living/library.json +1177 -0
  178. package/dist/simulation/living/mechanics.d.ts +31 -34
  179. package/dist/simulation/living/mechanics.js +222 -138
  180. package/dist/simulation/living/model-input.d.ts +6 -3
  181. package/dist/simulation/living/model-input.js +18 -26
  182. package/dist/simulation/living/open-world.d.ts +74 -94
  183. package/dist/simulation/living/open-world.js +151 -30
  184. package/dist/simulation/living/phrases.d.ts +3 -0
  185. package/dist/simulation/living/phrases.js +37 -0
  186. package/dist/simulation/living/phrases.json +560 -0
  187. package/dist/simulation/living/projection.d.ts +316 -2
  188. package/dist/simulation/living/projection.js +50 -2
  189. package/dist/simulation/living/prompts/example-spec.json +11 -0
  190. package/dist/simulation/living/prompts/role-text.json +14 -0
  191. package/dist/simulation/living/prompts.d.ts +5 -0
  192. package/dist/simulation/living/prompts.js +275 -0
  193. package/dist/simulation/living/recall.d.ts +2 -2
  194. package/dist/simulation/living/reduce.d.ts +51 -14
  195. package/dist/simulation/living/reduce.js +941 -579
  196. package/dist/simulation/living/replay.d.ts +5 -4
  197. package/dist/simulation/living/replay.js +10 -9
  198. package/dist/simulation/living/runtime.d.ts +135 -25
  199. package/dist/simulation/living/runtime.js +1641 -583
  200. package/dist/simulation/living/scale.d.ts +96 -0
  201. package/dist/simulation/living/scale.js +124 -0
  202. package/dist/simulation/living/script.d.ts +5 -0
  203. package/dist/simulation/living/script.js +115 -0
  204. package/dist/simulation/living/shared-kinds.d.ts +4 -11
  205. package/dist/simulation/living/shared-kinds.js +11 -81
  206. package/dist/simulation/living/space.d.ts +14 -0
  207. package/dist/simulation/living/space.js +132 -0
  208. package/dist/simulation/living/state.d.ts +100 -0
  209. package/dist/simulation/living/state.js +393 -0
  210. package/dist/simulation/living/types.d.ts +829 -512
  211. package/dist/simulation/living/types.js +162 -187
  212. package/dist/simulation/living/world-rules.d.ts +100 -0
  213. package/dist/simulation/living/world-rules.js +267 -0
  214. package/dist/simulation/plugins/loader.js +11 -0
  215. package/dist/skills/loader.js +4 -0
  216. package/dist/tools.d.ts +1 -0
  217. package/dist/tools.js +1 -0
  218. package/dist/ui/ratatui/headless_pane_manager.d.ts +4 -1
  219. package/dist/ui/ratatui/headless_pane_manager.js +13 -9
  220. package/dist/ui/ratatui/pane_relay.js +29 -0
  221. package/dist/ui/ratatui/pane_type.d.ts +10 -0
  222. package/dist/ui/ratatui/pane_type.js +11 -0
  223. package/dist/ui/ratatui/process.d.ts +30 -0
  224. package/dist/ui/ratatui/process.js +133 -19
  225. package/dist/ui/ratatui/protocol.d.ts +124 -2
  226. package/dist/ui/ratatui/protocol.js +35 -0
  227. package/dist/ui/ratatui/relay_policy.js +3 -0
  228. package/dist/ui/ratatui/ztc_launch_trust.d.ts +2 -1
  229. package/dist/ui/ratatui/ztc_launch_trust.js +8 -1
  230. package/dist/ui/terminal_image.d.ts +12 -0
  231. package/dist/ui/terminal_image.js +21 -1
  232. package/dist/utils/codex_project_trust.d.ts +19 -0
  233. package/dist/utils/codex_project_trust.js +37 -0
  234. package/dist/utils/compaction.js +103 -20
  235. package/dist/utils/git_program_files.d.ts +19 -12
  236. package/dist/utils/git_program_files.js +411 -83
  237. package/dist/utils/host_shell.d.ts +10 -1
  238. package/dist/utils/host_shell.js +14 -1
  239. package/dist/utils/mid_turn_compaction.d.ts +2 -0
  240. package/dist/utils/mid_turn_compaction.js +2 -0
  241. package/dist/utils/models.js +6 -1
  242. package/dist/utils/sandbox.d.ts +109 -8
  243. package/dist/utils/sandbox.js +981 -187
  244. package/dist/utils/shell.d.ts +2 -0
  245. package/dist/utils/shell.js +10 -4
  246. package/dist/utils/subprocess_env.d.ts +47 -11
  247. package/dist/utils/subprocess_env.js +107 -15
  248. package/dist/utils/system_ps.d.ts +8 -0
  249. package/dist/utils/system_ps.js +39 -7
  250. package/dist/utils/unattended_compaction.d.ts +9 -0
  251. package/dist/utils/unattended_compaction.js +13 -0
  252. package/dist/utils/ztc_own_state.d.ts +8 -5
  253. package/dist/utils/ztc_own_state.js +17 -11
  254. package/dist/web/mirror_client.js +1 -0
  255. package/dist/web/mirror_stream.d.ts +50 -6
  256. package/dist/web/mirror_stream.js +160 -15
  257. package/dist/workflows/registry.js +3 -1
  258. package/dist/workspace/controller.js +12 -0
  259. package/dist/workspace_collision.d.ts +3 -0
  260. package/dist/workspace_collision.js +14 -1
  261. package/dist/workspace_session_context.js +2 -1
  262. package/dist/zlm-embed.mjs +3823 -1970
  263. package/node_modules/@zerg/model-contracts/README.md +16 -4
  264. package/node_modules/@zerg/model-contracts/index.js +6 -1
  265. package/npm-shrinkwrap.json +1 -1
  266. package/package.json +42 -24
  267. package/packages/model-contracts/README.md +16 -4
  268. package/packages/model-contracts/index.js +6 -1
@@ -38,6 +38,50 @@ function parse_limit(spec) {
38
38
  }
39
39
  return null;
40
40
  }
41
+ // A KernelBench target a person names: target=NAME in the request, or in the evaluator's selector
42
+ // (--eval kernelbench:target=NAME). The harness takes it as --target NAME, so the adapter names no target of the
43
+ // harness's but PTX, which keeps its own word (--ptx). NAME starts with a letter or digit and holds letters, digits, -
44
+ // and _; it is passed lowercased. Punctuation or a quote right after it (. , ; : ) ] } ! ? and quotes) ends it, as in
45
+ // a sentence or a selector, and so does a bracket or quote before target=. A target= that names nothing so, and two
46
+ // targets that differ, are refused: the harness never runs its CUDA path in place of a target a person asked for.
47
+ const KERNELBENCH_TARGET_MENTION = /(?:^|[\s:,;([{"'`])target=/gi;
48
+ const KERNELBENCH_TARGET_NAME = /^([a-z0-9][a-z0-9_-]*)(?=$|[\s:,]|[.;)\]}!?"'`]+(?:$|[\s:,]))/i;
49
+ // A target=NAME mention as a whole, with the punctuation after it: what is left out of the task selector.
50
+ const KERNELBENCH_TARGET_WORD = /(^|[\s:,;([{"'`])target=[^\s:,]*/gi;
51
+ function parse_kernelbench_target(spec) {
52
+ const names = new Set();
53
+ const unread = [];
54
+ for (const source of [spec.evaluator?.ref || '', spec.request]) {
55
+ for (const mention of source.matchAll(KERNELBENCH_TARGET_MENTION)) {
56
+ const rest = source.slice((mention.index ?? 0) + mention[0].length);
57
+ const name = KERNELBENCH_TARGET_NAME.exec(rest)?.[1];
58
+ if (name) {
59
+ names.add(name.toLowerCase());
60
+ }
61
+ else {
62
+ unread.push(`target=${rest.split(/\s/)[0].slice(0, 40)}`);
63
+ }
64
+ }
65
+ }
66
+ if (unread.length > 0) {
67
+ return {
68
+ name: null,
69
+ refusal: `${unread[0]} names no KernelBench target: name one as target=NAME, NAME a letter or digit and then letters, digits, - and _. Nothing ran.`,
70
+ };
71
+ }
72
+ if (names.size > 1) {
73
+ const sorted = [...names].sort();
74
+ return {
75
+ name: null,
76
+ refusal: `The request names ${sorted.length === 2 ? 'two' : sorted.length} KernelBench targets, ${sorted.slice(0, -1).join(', ')} and ${sorted[sorted.length - 1]}: name one. Nothing ran.`,
77
+ };
78
+ }
79
+ return { name: [...names][0] ?? null, refusal: null };
80
+ }
81
+ /** SOURCE without its target=NAME words: a KernelBench target is no part of a task selector. */
82
+ function without_kernelbench_target(source) {
83
+ return source.replace(KERNELBENCH_TARGET_WORD, '$1').replace(/::+/g, ':').replace(/:$/, '').trim();
84
+ }
41
85
  function build_kernelbench_flags(spec) {
42
86
  return {
43
87
  level: parse_level(spec) ?? 1,
@@ -45,8 +89,7 @@ function build_kernelbench_flags(spec) {
45
89
  random: request_includes(spec, 'random') || request_includes(spec, 'sample'),
46
90
  gpu: !request_includes(spec, 'structural only') && !request_includes(spec, 'structural-only'),
47
91
  ptx: request_includes(spec, 'ptx'),
48
- dimc: request_includes(spec, 'dimc') && !request_includes(spec, 'dimc mlir'),
49
- dimcMlir: request_includes(spec, 'dimc mlir') || request_includes(spec, 'dimc-mlir'),
92
+ target: parse_kernelbench_target(spec).name,
50
93
  };
51
94
  }
52
95
  function kernelbench_stack_profile_args(spec) {
@@ -198,7 +241,7 @@ function parse_kernelbench_task_selector(spec) {
198
241
  let problemId = null;
199
242
  let taskContains = null;
200
243
  for (const source of sources) {
201
- const normalized = source.replace(/^kernelbench:/i, '').trim();
244
+ const normalized = without_kernelbench_target(source.replace(/^kernelbench:/i, '').trim());
202
245
  const compact = normalized.match(/level\s*([1-4])\s*[/:_-]\s*(\d+)(?:[\s_:-]+(.+))?/i)
203
246
  || normalized.match(/level([1-4])[/:_-](\d+)(?:[\s_:-]+(.+))?/i);
204
247
  if (compact?.[1] && compact?.[2]) {
@@ -284,8 +327,29 @@ function build_candidate_plan(spec) {
284
327
  const repoRoot = resolve_benchmark_repo_root(spec.cwd);
285
328
  const notes = [
286
329
  'KernelBench native search is runtime-owned: MPE/TGE/ARL run in src/optimize and this adapter evaluates one concrete candidate file against one task.',
287
- 'Native candidate evaluation currently targets the CUDA/structural KernelBench path; PTX and DIMC remain legacy-backed.',
330
+ 'Native candidate evaluation currently targets the CUDA/structural KernelBench path; PTX and the harness\'s other targets remain legacy-backed.',
288
331
  ];
332
+ // A KernelBench target, named or not: this path cannot take it, and evaluating the candidate on the CUDA path in its
333
+ // place is not what was asked.
334
+ const target = parse_kernelbench_target(spec);
335
+ if (target.name || target.refusal) {
336
+ const task = selector
337
+ ? ` of level ${selector.level} problem ${selector.problemId}${selector.taskContains ? ` (tasks containing ${selector.taskContains})` : ''}`
338
+ : '';
339
+ return {
340
+ adapterId: 'kernelbench',
341
+ supportedStages,
342
+ deferredStages,
343
+ command: null,
344
+ refused: true,
345
+ notes: [
346
+ ...notes,
347
+ 'KernelBench native candidate evaluation runs the CUDA/structural path only, so it takes no target=NAME: to run a harness target, name it without a file target, and the harness\'s multi-task run gets --target NAME.',
348
+ ...(target.refusal ? [target.refusal] : []),
349
+ ],
350
+ summary: `KernelBench native candidate evaluation${task} takes no KernelBench target${target.name ? ` (${target.name})` : ''}: nothing ran.`,
351
+ };
352
+ }
289
353
  if (!repoRoot || !candidatePath || !selector) {
290
354
  return {
291
355
  adapterId: 'kernelbench',
@@ -417,6 +481,18 @@ function build_command(spec, model) {
417
481
  const usesMpe = supportedStages.includes('mpe');
418
482
  const usesTge = supportedStages.includes('tge');
419
483
  const usesArl = supportedStages.includes('arl');
484
+ const target = parse_kernelbench_target(spec);
485
+ if (target.refusal) {
486
+ return {
487
+ adapterId: 'kernelbench',
488
+ supportedStages,
489
+ deferredStages,
490
+ command: null,
491
+ refused: true,
492
+ notes: [target.refusal],
493
+ summary: 'KernelBench was asked for a target it cannot pass to the harness: nothing ran.',
494
+ };
495
+ }
420
496
  if (!repoRoot) {
421
497
  return {
422
498
  adapterId: 'kernelbench',
@@ -448,11 +524,8 @@ function build_command(spec, model) {
448
524
  if (flags.ptx) {
449
525
  args.push('--ptx');
450
526
  }
451
- if (flags.dimc) {
452
- args.push('--dimc');
453
- }
454
- if (flags.dimcMlir) {
455
- args.push('--dimc-mlir');
527
+ if (flags.target) {
528
+ args.push('--target', flags.target);
456
529
  }
457
530
  if (modeValue) {
458
531
  args.push('--mode', modeValue);
@@ -487,7 +560,12 @@ export const kernelbenchCandidateOptimizationAdapter = {
487
560
  if (spec.evaluator?.kind !== 'benchmark' || !spec.evaluator.ref.toLowerCase().startsWith('kernelbench')) {
488
561
  return false;
489
562
  }
490
- return Boolean(parse_candidate_target(spec) && parse_kernelbench_task_selector(spec));
563
+ if (!parse_candidate_target(spec)) {
564
+ return false;
565
+ }
566
+ // A KernelBench target beside a file target is this path's to refuse, task selector or not.
567
+ const target = parse_kernelbench_target(spec);
568
+ return Boolean(parse_kernelbench_task_selector(spec) || target.name || target.refusal);
491
569
  },
492
570
  plan: (spec) => build_candidate_plan(spec),
493
571
  evaluate: async (spec, deps, artifacts) => evaluate_candidate_spec(spec, deps, artifacts),
@@ -55,6 +55,11 @@ export interface OptimizationAdapterPlan {
55
55
  command: string | null;
56
56
  notes: string[];
57
57
  summary: string;
58
+ /**
59
+ * The adapter refuses the spec outright: it names something the adapter cannot run as asked. The executor then runs
60
+ * nothing for it, no stage and no generation, and reports the plan's summary and notes.
61
+ */
62
+ refused?: boolean;
58
63
  }
59
64
  export interface OptimizationExecutionMetrics {
60
65
  objectiveKind: string;
@@ -198,6 +198,27 @@ async function run_native_pipeline_stages(spec, deps, artifacts, stages, initial
198
198
  export async function execute_optimization_spec(spec, deps, artifacts) {
199
199
  mkdirSync(artifacts.runDir, { recursive: true });
200
200
  const executionSpecPath = join(artifacts.runDir, 'resolved_execution_spec.json');
201
+ // An adapter that refuses the spec outright runs nothing for it: no MPE candidate, no stage, no generation.
202
+ const refusing = resolve_optimization_adapter(spec);
203
+ const refusal = refusing?.plan(spec);
204
+ if (refusing && refusal?.refused) {
205
+ const result = {
206
+ ok: false,
207
+ status: 'unsupported',
208
+ adapterId: refusing.id,
209
+ summary: refusal.summary,
210
+ command: null,
211
+ planPath: artifacts.planPath,
212
+ specPath: artifacts.specPath,
213
+ runDir: artifacts.runDir,
214
+ deferredStages: refusal.deferredStages,
215
+ notes: refusal.notes,
216
+ };
217
+ writeFileSync(join(artifacts.runDir, 'execution_plan.json'), JSON.stringify(refusal, null, 2), 'utf-8');
218
+ writeFileSync(join(artifacts.runDir, 'execution_result.json'), JSON.stringify(result, null, 2), 'utf-8');
219
+ emit_progress(deps, `Optimization refused by adapter ${refusing.id}: ${refusal.summary}`);
220
+ return result;
221
+ }
201
222
  const materialized = await materialize_mpe_candidates(spec, deps, artifacts);
202
223
  const executionSpec = materialized.candidates[0]?.spec || spec;
203
224
  writeFileSync(executionSpecPath, JSON.stringify(executionSpec, null, 2), 'utf-8');
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Installing a coding-agent CLI the person doesn't have yet, with one of its vendor's own install commands
3
+ * (pane_clis.ts), in a new pane where they see it run and answer whatever it asks.
4
+ *
5
+ * Only the person's own input starts an install (installRefusal): an agent's ztc_command, input relayed into this ZTC
6
+ * (another pane's message, a pane's typing, a /loop tick) and, where a host runs ZTC or pins its permissions, its
7
+ * controllers' are refused. The person picks the command in ZTC's chooser, which lists only the registry's commands for
8
+ * this platform whose first program is found, "Don't install" first; ZTC never runs a command of anyone's typing, never
9
+ * sudo, and never one with no pane to show it in. The pane runs the command verbatim from the person's login shell, in
10
+ * their home folder (a project's own .npmrc or the like configures nothing there), with a PATH of the folders ZTC looked
11
+ * in, the project's left out (a project's bin folder on PATH runs nothing there), writes its exit status to a file in
12
+ * a private temporary folder of ZTC's, and waits for Enter, so its output stays to be read; ZTC reads the status as the
13
+ * pane closes. macOS and Linux only: on Windows the commands are shown, to run in PowerShell.
14
+ */
15
+ import type { PaneCommandTransport } from '../ui/ratatui/pane_relay.js';
16
+ import { type InstallMethod, type PaneCliId, type PaneCliLookup } from './pane_clis.js';
17
+ /** Who entered the command that asks for an install (CommandContext.commandOrigin; absent is the person). */
18
+ export type InstallOrigin = 'user' | 'agent' | 'relayed' | undefined;
19
+ /** Why ORIGIN can't start an install here, or null when the person can. */
20
+ export declare function installRefusal(origin: InstallOrigin, env?: NodeJS.ProcessEnv): string | null;
21
+ /** One of the CLI's install commands for this platform, and where the program it runs first was found, if it was. */
22
+ export interface InstallChoice {
23
+ method: InstallMethod;
24
+ found: string | null;
25
+ }
26
+ /** The CLI's install commands for this platform, none with sudo, each with whether its first program is found. */
27
+ export declare function installChoices(id: PaneCliId, lookup?: PaneCliLookup): InstallChoice[];
28
+ /**
29
+ * What the install pane runs, under /bin/sh: $1 the status file, $2 the CLI's name, $3 the command, run by eval as the
30
+ * person's own shell would run it, verbatim.
31
+ */
32
+ export declare const INSTALL_SCRIPT: string;
33
+ /** An install pane that opened, and its command's exit status once the pane closes (null: it closed before one). */
34
+ export interface StartedInstall {
35
+ paneId: number;
36
+ finished: Promise<number | null>;
37
+ }
38
+ export interface StartInstallOptions {
39
+ cli: PaneCliId;
40
+ method: InstallMethod;
41
+ /** Source of SHELL and the variables ZTC blanks (default: this process). */
42
+ env?: NodeJS.ProcessEnv;
43
+ platform?: NodeJS.Platform;
44
+ /** Where the pane runs: the home folder (default: the env's HOME, else the user's). */
45
+ home?: string;
46
+ /** The folder ZTC works in: a PATH entry inside it is the project's, left out of the pane's PATH (installSearchDirs). */
47
+ cwd?: string;
48
+ /** Where the private status folder is made (default: the system's temporary folder). */
49
+ statusRoot?: string;
50
+ }
51
+ /** Open a pane that runs METHOD's command, as the person picked it. */
52
+ export declare function startInstallPane(transport: PaneCommandTransport, options: StartInstallOptions): Promise<StartedInstall | {
53
+ error: string;
54
+ }>;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Installing a coding-agent CLI the person doesn't have yet, with one of its vendor's own install commands
3
+ * (pane_clis.ts), in a new pane where they see it run and answer whatever it asks.
4
+ *
5
+ * Only the person's own input starts an install (installRefusal): an agent's ztc_command, input relayed into this ZTC
6
+ * (another pane's message, a pane's typing, a /loop tick) and, where a host runs ZTC or pins its permissions, its
7
+ * controllers' are refused. The person picks the command in ZTC's chooser, which lists only the registry's commands for
8
+ * this platform whose first program is found, "Don't install" first; ZTC never runs a command of anyone's typing, never
9
+ * sudo, and never one with no pane to show it in. The pane runs the command verbatim from the person's login shell, in
10
+ * their home folder (a project's own .npmrc or the like configures nothing there), with a PATH of the folders ZTC looked
11
+ * in, the project's left out (a project's bin folder on PATH runs nothing there), writes its exit status to a file in
12
+ * a private temporary folder of ZTC's, and waits for Enter, so its output stays to be read; ZTC reads the status as the
13
+ * pane closes. macOS and Linux only: on Windows the commands are shown, to run in PowerShell.
14
+ */
15
+ import { randomUUID } from 'node:crypto';
16
+ import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
17
+ import { homedir, tmpdir } from 'node:os';
18
+ import { join } from 'node:path';
19
+ import { waitForPaneCreatedOrError } from '../agent/tools/pane.js';
20
+ import { hostedOrPinnedRuntime } from '../config/hosted_runtime.js';
21
+ import { personProgramRefusal } from '../config/permission_pin.js';
22
+ import { buildUserSubprocessEnvOverrides } from '../utils/subprocess_env.js';
23
+ import { loginShellExec } from './agent_cli.js';
24
+ import { sessionNamePaneTitle } from './labels.js';
25
+ import { PANE_CLIS, findInstallProgram, installMethodsFor, installSearchDirs, } from './pane_clis.js';
26
+ /** Why ORIGIN can't start an install here, or null when the person can. */
27
+ export function installRefusal(origin, env = process.env) {
28
+ if (origin === 'agent' || origin === 'relayed') {
29
+ return 'Only the person can install a CLI: they type its command, or /agents install <cli>, in Main (pane 0) and pick the install '
30
+ + 'command themselves. An agent\'s command, a message and another pane\'s input install nothing.';
31
+ }
32
+ if (hostedOrPinnedRuntime(env)) {
33
+ return 'ZTC installs nothing where its host runs it or pins its permissions (ZTC_HOSTED, ZTC_PERMISSION_PROFILE_PINNED), since its '
34
+ + 'controllers would choose what runs on the host: ask the host to install it.';
35
+ }
36
+ return null;
37
+ }
38
+ /** The CLI's install commands for this platform, none with sudo, each with whether its first program is found. */
39
+ export function installChoices(id, lookup = {}) {
40
+ const platform = lookup.platform ?? process.platform;
41
+ return installMethodsFor(id, platform)
42
+ .filter(method => !/(^|[\s;&|(])sudo(\s|$)/.test(method.command))
43
+ .map(method => ({ method, found: findInstallProgram(method.needs, lookup) }));
44
+ }
45
+ /**
46
+ * What the install pane runs, under /bin/sh: $1 the status file, $2 the CLI's name, $3 the command, run by eval as the
47
+ * person's own shell would run it, verbatim.
48
+ */
49
+ export const INSTALL_SCRIPT = [
50
+ 'printf \'$ %s\\n\\n\' "$3"',
51
+ 'eval "$3"',
52
+ 'status=$?',
53
+ 'printf \'%s\\n\' "$status" > "$1"',
54
+ 'if [ "$status" -eq 0 ]; then printf \'\\nDone. Press Enter to close this pane; ZTC then opens %s.\\n\' "$2";',
55
+ 'else printf \'\\nIt exited with status %s. Press Enter to close this pane.\\n\' "$status"; fi',
56
+ 'read -r _ || true',
57
+ ': > "$1.done"',
58
+ 'exit "$status"',
59
+ ].join('\n');
60
+ /** Open a pane that runs METHOD's command, as the person picked it. */
61
+ export async function startInstallPane(transport, options) {
62
+ const spec = PANE_CLIS[options.cli];
63
+ const pinRefusal = personProgramRefusal(`No ${spec.label} install pane was opened`, `installing ${spec.label}`, 'Ask the host to install it instead.');
64
+ if (pinRefusal)
65
+ return { error: pinRefusal };
66
+ const platform = options.platform ?? process.platform;
67
+ if (platform === 'win32') {
68
+ return { error: `ZTC runs an install in a pane on macOS and Linux; on Windows, run it in PowerShell: ${options.method.command}` };
69
+ }
70
+ if (!transport.isMuxMode)
71
+ return { error: `Installing ${spec.label} runs in a pane, which needs ZTC's panes.` };
72
+ const env = options.env ?? process.env;
73
+ const home = options.home ?? env.HOME ?? homedir();
74
+ const folder = mkdtempSync(join(options.statusRoot ?? tmpdir(), 'ztc-install-'));
75
+ const statusFile = join(folder, 'status');
76
+ const readStatus = () => {
77
+ try {
78
+ const text = readFileSync(statusFile, 'utf8').trim();
79
+ return /^\d+$/.test(text) ? Number(text) : null;
80
+ }
81
+ catch {
82
+ return null;
83
+ }
84
+ finally {
85
+ rmSync(folder, { recursive: true, force: true });
86
+ }
87
+ };
88
+ const program = loginShellExec('/bin/sh', ['-c', INSTALL_SCRIPT, 'ztc-install', statusFile, spec.label, options.method.command], env.SHELL, platform);
89
+ // The pane's PATH is the folders ZTC looked in for the command's first program, the project's left out, so the command
90
+ // runs the npm, curl or brew ZTC found and the bash or sh it pipes to from the person's own folders; /bin last.
91
+ const path = [...new Set([...installSearchDirs({ env, home, platform, ...(options.cwd ? { cwd: options.cwd } : {}) }), '/bin'])];
92
+ const title = `Install ${spec.label}`;
93
+ const requestId = `cli-install:${options.cli}:${randomUUID()}`;
94
+ // Listening before the pane is asked for, so a close that comes at once is never missed.
95
+ let paneId = null;
96
+ const closedEarly = new Set();
97
+ let settle = () => { };
98
+ const finished = new Promise(resolve => { settle = resolve; });
99
+ // The script writes STATUS.done once the person presses Enter. zmux and the desktop app keep a pane whose program
100
+ // exited, and send no pane_closed, so ZTC then closes the pane itself.
101
+ let poll;
102
+ const stopListening = transport.on(event => {
103
+ if (event.type !== 'pane_closed')
104
+ return;
105
+ if (paneId === null)
106
+ closedEarly.add(event.pane_id);
107
+ else if (event.pane_id === paneId) {
108
+ stop();
109
+ settle(readStatus());
110
+ }
111
+ });
112
+ const stop = () => {
113
+ if (poll)
114
+ clearInterval(poll);
115
+ poll = undefined;
116
+ stopListening();
117
+ };
118
+ const created = waitForPaneCreatedOrError(transport, { requestId }, 15000);
119
+ const sent = transport.send({ type: 'create_pane', request_id: requestId, command: program.command, args: program.args, cwd: home,
120
+ title, pane_type: 'command', env: { ...buildUserSubprocessEnvOverrides(env), PATH: path.join(':') } });
121
+ const fail = (error) => {
122
+ stop();
123
+ rmSync(folder, { recursive: true, force: true });
124
+ return { error };
125
+ };
126
+ if (!sent) {
127
+ created.catch(() => { });
128
+ return fail(`Could not install ${spec.label}: the renderer is not connected.`);
129
+ }
130
+ let event;
131
+ try {
132
+ event = await created;
133
+ }
134
+ catch (error) {
135
+ return fail(`Could not install ${spec.label}: no pane appeared (${error.message}).`);
136
+ }
137
+ if (event.type !== 'pane_created') {
138
+ return fail(`Could not install ${spec.label}: the renderer refused the pane${event.type === 'error' ? ` (${event.message})` : ''}.`);
139
+ }
140
+ paneId = event.pane_id;
141
+ const opened = paneId;
142
+ transport.send(sessionNamePaneTitle(paneId, title));
143
+ if (closedEarly.has(paneId)) {
144
+ stop();
145
+ settle(readStatus());
146
+ return { paneId, finished };
147
+ }
148
+ poll = setInterval(() => {
149
+ if (!existsSync(`${statusFile}.done`))
150
+ return;
151
+ stop();
152
+ transport.send({ type: 'close_pane', pane_id: opened });
153
+ settle(readStatus());
154
+ }, 250);
155
+ poll.unref?.();
156
+ return { paneId, finished };
157
+ }
@@ -49,6 +49,9 @@ export const MODEL_CATALOG = [
49
49
  { id: 'gemini-3.5-flash-lite', name: 'Gemini 3.5 Flash Lite', aliases: ['gemini-3.5-lite', 'gemini 3.5 flash lite'] },
50
50
  { id: 'gemini-3.1-pro-preview', name: 'Gemini 3.1 Pro', aliases: ['gemini-3.1-pro', 'gemini 3.1 pro'] },
51
51
  { id: 'gemini-3-flash-preview', name: 'Gemini 3 Flash', aliases: ['gemini-3-flash', 'gemini 3 flash'] },
52
+ // Paid tier only (no free tier, https://aistudio.google.com/docs/pricing); Google's default level is high.
53
+ { id: 'gemini-4-neon', name: 'Gemini 4 Neon', aliases: ['gemini-neon', 'gemini 4 neon'],
54
+ defaultReasoningEffort: 'high', supportedReasoningEfforts: modelContract('gemini', 'gemini-4-neon')?.reasoningEfforts },
52
55
  ],
53
56
  },
54
57
  {
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * The rows of the new-pane chooser (Ctrl+B c): a shell, a ZTC agent, the
3
- * agent CLIs the user has installed, then their own custom options.
3
+ * coding-agent CLIs the user has installed (Claude Code and Codex first, then
4
+ * the others pane_clis.ts lists), then their own custom options.
4
5
  */
5
6
  import type { CustomPaneOption } from '../config/types.js';
6
7
  import { type AgentCliId } from './agent_cli.js';
8
+ import { type PaneCliId } from './pane_clis.js';
7
9
  export interface NewPaneChoice {
8
10
  value: string;
9
11
  label: string;
@@ -11,4 +13,6 @@ export interface NewPaneChoice {
11
13
  }
12
14
  /** `agent:claude` and `agent:codex` name the agent CLI rows. */
13
15
  export declare function agentCliFromChoice(value: string): AgentCliId | null;
14
- export declare function newPaneChoices(custom: readonly CustomPaneOption[], installed: Partial<Record<AgentCliId, string | null>>): NewPaneChoice[];
16
+ /** `agent:pi`, `agent:antigravity`…: the rows of the CLIs the shared launcher opens (pane_cli_launch.ts). */
17
+ export declare function paneCliFromChoice(value: string): PaneCliId | null;
18
+ export declare function newPaneChoices(custom: readonly CustomPaneOption[], installed: Partial<Record<PaneCliId, string | null>>): NewPaneChoice[];
@@ -1,33 +1,45 @@
1
1
  /**
2
2
  * The rows of the new-pane chooser (Ctrl+B c): a shell, a ZTC agent, the
3
- * agent CLIs the user has installed, then their own custom options.
3
+ * coding-agent CLIs the user has installed (Claude Code and Codex first, then
4
+ * the others pane_clis.ts lists), then their own custom options.
4
5
  */
5
6
  import { basename } from 'node:path';
6
- import { AGENT_CLIS, AGENT_CLI_IDS } from './agent_cli.js';
7
+ import { AGENT_CLI_IDS } from './agent_cli.js';
8
+ import { PANE_CLIS, PANE_CLI_IDS, isPaneCliId, isPersonOnlyCli } from './pane_clis.js';
7
9
  /** `agent:claude` and `agent:codex` name the agent CLI rows. */
8
10
  export function agentCliFromChoice(value) {
9
11
  const id = value.startsWith('agent:') ? value.slice('agent:'.length) : '';
10
12
  return AGENT_CLI_IDS.includes(id) ? id : null;
11
13
  }
12
- function runsBinary(command, binary) {
14
+ /** `agent:pi`, `agent:antigravity`…: the rows of the CLIs the shared launcher opens (pane_cli_launch.ts). */
15
+ export function paneCliFromChoice(value) {
16
+ const id = value.startsWith('agent:') ? value.slice('agent:'.length) : '';
17
+ return isPaneCliId(id) && PANE_CLIS[id].opens === 'terminal' ? id : null;
18
+ }
19
+ function runsBinary(command, binaries) {
13
20
  const first = command.trim().split(/\s+/)[0] ?? '';
14
- return basename(first) === binary;
21
+ return binaries.includes(basename(first));
22
+ }
23
+ /** What a CLI's row says of it. */
24
+ function describe(id) {
25
+ const spec = PANE_CLIS[id];
26
+ if (spec.opens === 'agent-cli')
27
+ return `${spec.label} on your own account, with ZTC's pane and message tools`;
28
+ if (isPersonOnlyCli(id))
29
+ return `${spec.label} on your own account; only you drive it, no agent types into it`;
30
+ return spec.workspaceMcp ? `${spec.label} on your own account, with ZTC's pane tools` : `${spec.label} on your own account`;
15
31
  }
16
32
  export function newPaneChoices(custom, installed) {
17
33
  const choices = [
18
34
  { value: 'bash', label: 'bash', description: 'A shell pane' },
19
35
  { value: 'ztc', label: 'ZTC', description: 'A ZTC agent pane' },
20
36
  ];
21
- for (const id of AGENT_CLI_IDS) {
22
- const spec = AGENT_CLIS[id];
37
+ for (const id of PANE_CLI_IDS) {
38
+ const spec = PANE_CLIS[id];
23
39
  // Not installed, or already offered by the user's own custom option.
24
- if (!installed[id] || custom.some(option => runsBinary(option.command, spec.binary)))
40
+ if (!installed[id] || custom.some(option => runsBinary(option.command, spec.binaries)))
25
41
  continue;
26
- choices.push({
27
- value: `agent:${id}`,
28
- label: spec.label,
29
- description: `${spec.label} on your own account, with ZTC's pane and message tools`,
30
- });
42
+ choices.push({ value: `agent:${id}`, label: spec.label, description: describe(id) });
31
43
  }
32
44
  custom.forEach((option, index) => {
33
45
  choices.push({ value: `custom:${index}`, label: option.label, description: option.command });
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Opening a coding-agent CLI other than Claude Code and Codex in a pane (pane_clis.ts: Antigravity, Pi, OpenCode, Gemini
3
+ * CLI, GitHub Copilot CLI, Cursor CLI), as a terminal would: the person's own executable, unmodified, from their login
4
+ * shell, in the folder given, signed in with their own account through its own flow. ZTC adds only what the CLI takes
5
+ * for one run without ZTC editing the person's configuration: Copilot's --additional-mcp-config for ZTC's workspace
6
+ * server. No permission flag of ZTC's is passed: each CLI asks, or doesn't, as its own settings say.
7
+ *
8
+ * A person-only CLI's pane (Antigravity) is noted as it opens (person_only_panes.ts), so that no agent types into it,
9
+ * messages it or restarts it, and it never runs through MotSi, whose remote view another program reads.
10
+ */
11
+ import type { PaneCommandTransport } from '../ui/ratatui/pane_relay.js';
12
+ import type { SplitDirection } from '../ui/ratatui/protocol.js';
13
+ import { type PaneProgram } from './agent_cli.js';
14
+ import { type PaneCliId, type PaneCliRequest } from './pane_clis.js';
15
+ /** Request ids of these launches start with this; Claude Code's and Codex's start with agent_panes.ts's own. */
16
+ export declare const CLI_PANE_REQUEST_PREFIX = "cli-pane:";
17
+ /** Which CLI a create_pane request id launched, if one of these did. */
18
+ export declare function paneCliFromRequestId(requestId: string | undefined): PaneCliId | null;
19
+ export interface OpenPaneCliOptions {
20
+ cli: PaneCliId;
21
+ request?: PaneCliRequest;
22
+ cwd?: string;
23
+ /** Pane name; defaults to the next free one for the CLI ("Pi", "Pi 2"…). */
24
+ title?: string;
25
+ direction?: SplitDirection;
26
+ ratio?: number;
27
+ target?: number;
28
+ newWindow?: boolean;
29
+ findBinary?: (id: PaneCliId) => string | null;
30
+ /** The workspace server for a CLI that takes one; an Error opens the pane without it. Default: this installation's. */
31
+ server?: PaneProgram | Error | null;
32
+ /** Source of SHELL, PATH and the workspace variables (default: this process). */
33
+ env?: NodeJS.ProcessEnv;
34
+ /** The `motsi` to start the pane through; null for none. Default: MotSi's remote view, never for a person-only CLI. */
35
+ motsi?: string | null;
36
+ /** The person (their own command, ZTC's menus and splits) or an agent (ztc_command). */
37
+ openedBy: 'person' | 'agent';
38
+ }
39
+ export interface OpenPaneCliResult {
40
+ paneId?: number;
41
+ title?: string;
42
+ cwd?: string;
43
+ error?: string;
44
+ /** What is worth saying though the pane opened. */
45
+ notice?: string;
46
+ /** The command line as the person would type it: the executable's name and their own words. */
47
+ shown?: string;
48
+ }
49
+ /** Open the person's own CLI in a new pane. */
50
+ export declare function openPaneCli(transport: PaneCommandTransport | null, options: OpenPaneCliOptions): Promise<OpenPaneCliResult>;