negotium 0.23.0 → 0.23.2

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 (37) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-helpers.js +136 -30
  3. package/dist/agent-helpers.js.map +12 -11
  4. package/dist/{chunk-pr8p6pap.js → chunk-6cnpkzkb.js} +7 -2
  5. package/dist/{chunk-pr8p6pap.js.map → chunk-6cnpkzkb.js.map} +3 -3
  6. package/dist/{chunk-z4r7tt2p.js → chunk-cez5m5hm.js} +1 -1
  7. package/dist/{chunk-qmpbb92y.js → chunk-s34sv3d2.js} +20 -8
  8. package/dist/chunk-s34sv3d2.js.map +12 -0
  9. package/dist/hosted-agent.js +97 -13
  10. package/dist/hosted-agent.js.map +8 -7
  11. package/dist/main.js +717 -72
  12. package/dist/main.js.map +18 -16
  13. package/dist/mcp-factories.js +136 -30
  14. package/dist/mcp-factories.js.map +12 -11
  15. package/dist/prompts.js +9 -10
  16. package/dist/prompts.js.map +3 -3
  17. package/dist/registry.js +5 -5
  18. package/dist/registry.js.map +3 -3
  19. package/dist/rollout.js +2 -2
  20. package/dist/runtime/src/agents/codex-native-multi-agent.ts +28 -6
  21. package/dist/runtime/src/agents/codex-provider.ts +14 -1
  22. package/dist/runtime/src/agents/codex-registry.ts +6 -7
  23. package/dist/runtime/src/agents/codex-tier-resolver.ts +74 -0
  24. package/dist/runtime/src/agents/explicit-agent-switch.ts +6 -1
  25. package/dist/runtime/src/agents/model-catalog.ts +34 -23
  26. package/dist/runtime/src/runtime/turn-event-stream.ts +13 -1
  27. package/dist/runtime/src/storage/token-stats.ts +2 -1
  28. package/dist/runtime/src/version.ts +1 -1
  29. package/dist/storage.js +2 -1
  30. package/dist/storage.js.map +3 -3
  31. package/dist/types/packages/core/src/agents/codex-native-multi-agent.d.ts +9 -0
  32. package/dist/types/packages/core/src/agents/codex-tier-resolver.d.ts +10 -0
  33. package/dist/types/packages/core/src/agents/model-catalog.d.ts +2 -2
  34. package/dist/types/packages/core/src/version.d.ts +1 -1
  35. package/package.json +4 -3
  36. package/dist/chunk-qmpbb92y.js.map +0 -12
  37. /package/dist/{chunk-z4r7tt2p.js.map → chunk-cez5m5hm.js.map} +0 -0
package/dist/main.js CHANGED
@@ -1503,9 +1503,14 @@ function agentAliases(agent) {
1503
1503
  return [
1504
1504
  "codex",
1505
1505
  "\uCF54\uB371\uC2A4",
1506
+ "astra",
1507
+ "sol",
1508
+ "luna",
1509
+ "terra",
1506
1510
  "gpt-6-luna",
1507
1511
  "gpt-6-sol",
1508
1512
  "gpt-5.6-luna",
1513
+ "gpt-6.1-terra",
1509
1514
  "gpt-5.6-terra",
1510
1515
  "gpt-5.6-sol",
1511
1516
  "gpt-6-astra"
@@ -1533,7 +1538,7 @@ function hasExplicitAgentSwitchRequest(prompt, agent) {
1533
1538
  if (!prompt?.trim())
1534
1539
  return false;
1535
1540
  const text = prompt.toLowerCase().replace(/\s+/g, " ").trim();
1536
- const target = `(?:${agentAliases(agent).map(escapeRegExp).join("|")})`;
1541
+ const target = `(?<![A-Za-z0-9_-])(?:${agentAliases(agent).map(escapeRegExp).join("|")})(?![A-Za-z0-9_-])`;
1537
1542
  const switchVerb = "(?:\uBC14\uAFD4|\uBC14\uAFD4\uC918|\uBCC0\uACBD|\uBCC0\uACBD\uD574|\uC804\uD658|\uC804\uD658\uD574|\uC124\uC815|\uC124\uC815\uD574|\uC368\uC918|\uC0AC\uC6A9|\uAC00|switch|change|set|use)";
1538
1543
  const switchSubject = "(?:agent|runtime|model|\uC5D0\uC774\uC804\uD2B8|\uB7F0\uD0C0\uC784|\uBAA8\uB378)";
1539
1544
  return [
@@ -6559,7 +6564,7 @@ var exports_version = {};
6559
6564
  __export(exports_version, {
6560
6565
  NEGOTIUM_VERSION: () => NEGOTIUM_VERSION
6561
6566
  });
6562
- var NEGOTIUM_VERSION = "0.23.0";
6567
+ var NEGOTIUM_VERSION = "0.23.2";
6563
6568
 
6564
6569
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
6565
6570
  import { spawn as spawn2 } from "child_process";
@@ -6575,9 +6580,22 @@ import {
6575
6580
  unlinkSync as unlinkSync5,
6576
6581
  writeFileSync as writeFileSync4
6577
6582
  } from "fs";
6578
- import { createRequire as createRequire2 } from "module";
6579
6583
  import { tmpdir } from "os";
6580
6584
  import { dirname as dirname7, join as join9 } from "path";
6585
+ import { fileURLToPath as fileURLToPath2 } from "url";
6586
+ function findPackageJson(specifier, searchFromDir) {
6587
+ let dir = searchFromDir;
6588
+ for (;; ) {
6589
+ const candidate = join9(dir, "node_modules", specifier, "package.json");
6590
+ if (existsSync7(candidate))
6591
+ return candidate;
6592
+ const parent = dirname7(dir);
6593
+ if (parent === dir) {
6594
+ throw new Error(`Could not locate node_modules/${specifier} starting from ${searchFromDir}`);
6595
+ }
6596
+ dir = parent;
6597
+ }
6598
+ }
6581
6599
  function readPackageVersion(packageJsonPath) {
6582
6600
  const parsed = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
6583
6601
  if (typeof parsed.version !== "string" || !parsed.version.trim()) {
@@ -6802,12 +6820,11 @@ function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath)
6802
6820
  writePrivateFileAtomic(outputPath, contents);
6803
6821
  return outputPath;
6804
6822
  }
6805
- var moduleRequire, codexSdkPackagePath, codexSdkRequire, bundledCodexPackagePath, BUNDLED_CODEX_VERSION, SAFE_BUNDLED_CODEX_VERSION, NEGOTIUM_MODEL_CACHE, NEGOTIUM_MODEL_CATALOG, CODEX_BOOTSTRAP_EXIT_WAIT_MS = 3000;
6823
+ var thisModuleDir, codexSdkPackagePath, bundledCodexPackagePath, BUNDLED_CODEX_VERSION, SAFE_BUNDLED_CODEX_VERSION, NEGOTIUM_MODEL_CACHE, NEGOTIUM_MODEL_CATALOG, CODEX_BOOTSTRAP_EXIT_WAIT_MS = 3000;
6806
6824
  var init_codex_native_multi_agent = __esm(() => {
6807
- moduleRequire = createRequire2(import.meta.url);
6808
- codexSdkPackagePath = moduleRequire.resolve("@openai/codex-sdk/package.json");
6809
- codexSdkRequire = createRequire2(codexSdkPackagePath);
6810
- bundledCodexPackagePath = codexSdkRequire.resolve("@openai/codex/package.json");
6825
+ thisModuleDir = dirname7(fileURLToPath2(import.meta.url));
6826
+ codexSdkPackagePath = findPackageJson("@openai/codex-sdk", thisModuleDir);
6827
+ bundledCodexPackagePath = findPackageJson("@openai/codex", dirname7(codexSdkPackagePath));
6811
6828
  BUNDLED_CODEX_VERSION = readPackageVersion(bundledCodexPackagePath);
6812
6829
  SAFE_BUNDLED_CODEX_VERSION = BUNDLED_CODEX_VERSION.replace(/[^a-zA-Z0-9._-]/g, "_");
6813
6830
  NEGOTIUM_MODEL_CACHE = `negotium-models-cache-${SAFE_BUNDLED_CODEX_VERSION}.json`;
@@ -6951,7 +6968,7 @@ var init_codex_registry = __esm(async () => {
6951
6968
  VALID_EFFORTS2 = new Set(CODEX_EFFORT_VALUES);
6952
6969
  codexRegistry = {
6953
6970
  kind: "codex",
6954
- defaultModel: "gpt-6-luna",
6971
+ defaultModel: "luna",
6955
6972
  expandModelAlias(s) {
6956
6973
  return s;
6957
6974
  },
@@ -8308,6 +8325,76 @@ var init_claude_provider = __esm(async () => {
8308
8325
  claudeProcessExitListeners = new WeakMap;
8309
8326
  });
8310
8327
 
8328
+ // ../../packages/core/src/agents/codex-tier-resolver.ts
8329
+ function codexTiersFromCache(cache) {
8330
+ const result = {};
8331
+ const priorities = {};
8332
+ if (!cache || typeof cache !== "object" || !("models" in cache))
8333
+ return result;
8334
+ const models = cache.models;
8335
+ if (!Array.isArray(models))
8336
+ return result;
8337
+ for (const model of models) {
8338
+ if (!model || typeof model !== "object")
8339
+ continue;
8340
+ const { slug, visibility, priority } = model;
8341
+ if (typeof slug !== "string" || visibility !== "list")
8342
+ continue;
8343
+ if (typeof priority !== "number" || !Number.isFinite(priority))
8344
+ continue;
8345
+ const suffix = slug.slice(slug.lastIndexOf("-") + 1);
8346
+ if (!Object.hasOwn(CODEX_TIER_FALLBACKS, suffix))
8347
+ continue;
8348
+ const tier = suffix;
8349
+ if (priorities[tier] === undefined || priority < priorities[tier]) {
8350
+ priorities[tier] = priority;
8351
+ result[tier] = slug;
8352
+ }
8353
+ }
8354
+ return result;
8355
+ }
8356
+ function resolveCodexTierModel(tier, cachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE ?? bundledCodexModelCachePath(hostedCodexAuthFilePath())) {
8357
+ try {
8358
+ const selected = codexTiersFromCache(readCompatibleCodexModelCache(cachePath).parsed)[tier];
8359
+ if (selected) {
8360
+ if (!pricedSlugs.has(selected) && !warnedUnpricedSlugs.has(selected)) {
8361
+ warnedUnpricedSlugs.add(selected);
8362
+ logger.warn({ tier, model: selected }, "Codex tier model has no token-stats price");
8363
+ }
8364
+ return selected;
8365
+ }
8366
+ } catch (error) {
8367
+ if (!warnedCachePaths.has(cachePath)) {
8368
+ warnedCachePaths.add(cachePath);
8369
+ logger.warn({ err: error, cachePath }, "Codex tier cache unavailable; using fallback ids");
8370
+ }
8371
+ }
8372
+ return CODEX_TIER_FALLBACKS[tier];
8373
+ }
8374
+ var CODEX_TIER_FALLBACKS, warnedCachePaths, warnedUnpricedSlugs, pricedSlugs;
8375
+ var init_codex_tier_resolver = __esm(async () => {
8376
+ init_codex_native_multi_agent();
8377
+ init_logger();
8378
+ await init_execution_host();
8379
+ CODEX_TIER_FALLBACKS = {
8380
+ astra: "gpt-6-astra",
8381
+ sol: "gpt-6-sol",
8382
+ luna: "gpt-6-luna",
8383
+ terra: "gpt-6.1-terra"
8384
+ };
8385
+ warnedCachePaths = new Set;
8386
+ warnedUnpricedSlugs = new Set;
8387
+ pricedSlugs = new Set([
8388
+ "gpt-6-astra",
8389
+ "gpt-6-sol",
8390
+ "gpt-6-luna",
8391
+ "gpt-6.1-terra",
8392
+ "gpt-5.6-sol",
8393
+ "gpt-5.6-luna",
8394
+ "gpt-5.6-terra"
8395
+ ]);
8396
+ });
8397
+
8311
8398
  // ../../packages/core/src/agents/codex-windows-wrapper.ts
8312
8399
  import { execFile } from "child_process";
8313
8400
  import { createHash as createHash4, randomUUID as randomUUID5 } from "crypto";
@@ -8471,7 +8558,7 @@ import { chmod, copyFile, mkdtemp, rm as rm2, writeFile as writeFile2 } from "fs
8471
8558
  import { createServer } from "net";
8472
8559
  import { tmpdir as tmpdir2 } from "os";
8473
8560
  import { dirname as dirname10, join as join15, resolve as resolve8 } from "path";
8474
- import { fileURLToPath as fileURLToPath2 } from "url";
8561
+ import { fileURLToPath as fileURLToPath3 } from "url";
8475
8562
  function evaluateCodexVaultPreToolUse(input, userId, operations) {
8476
8563
  if (operations.referencesSensitiveStorage(input.tool_input)) {
8477
8564
  return {
@@ -8499,7 +8586,7 @@ function shellQuote(value) {
8499
8586
  return `'${value.replaceAll("'", `'"'"'`)}'`;
8500
8587
  }
8501
8588
  function hookClientPath() {
8502
- const moduleDir = dirname10(fileURLToPath2(import.meta.url));
8589
+ const moduleDir = dirname10(fileURLToPath3(import.meta.url));
8503
8590
  const adjacent = resolve8(moduleDir, "codex-vault-hook.mjs");
8504
8591
  if (existsSync15(adjacent))
8505
8592
  return adjacent;
@@ -9568,6 +9655,7 @@ async function* codexProvider(opts) {
9568
9655
  ...codexEnvironment ? { env: codexEnvironment } : {},
9569
9656
  config: {
9570
9657
  agents: { enabled: false },
9658
+ tools: { update_plan: { enabled: false } },
9571
9659
  features: {
9572
9660
  hooks: true,
9573
9661
  goals: false,
@@ -9591,7 +9679,9 @@ async function* codexProvider(opts) {
9591
9679
  webSearchMode: "disabled",
9592
9680
  webSearchEnabled: false
9593
9681
  } : {},
9594
- ...opts.model ? { model: opts.model } : {},
9682
+ ...opts.model ? {
9683
+ model: Object.hasOwn(CODEX_TIER_FALLBACKS, opts.model) ? resolveCodexTierModel(opts.model) : opts.model
9684
+ } : {},
9595
9685
  ...opts.effort ? { modelReasoningEffort: mapEffort(opts.effort) } : {}
9596
9686
  };
9597
9687
  let currentSessionId = opts.sessionId;
@@ -9853,6 +9943,7 @@ var init_codex_provider = __esm(async () => {
9853
9943
  init_file_events();
9854
9944
  init_logger();
9855
9945
  await __promiseAll([
9946
+ init_codex_tier_resolver(),
9856
9947
  init_codex_vault_hook_bridge(),
9857
9948
  init_execution_host(),
9858
9949
  init_codex(),
@@ -12025,10 +12116,13 @@ __export(exports_model_catalog, {
12025
12116
  FALLBACK_ORDER: () => FALLBACK_ORDER,
12026
12117
  AGENT_DISPLAY_NAME: () => AGENT_DISPLAY_NAME
12027
12118
  });
12119
+ function canonicalModelCasing() {
12120
+ return Object.fromEntries(SELECTABLE_MODELS.map((candidate) => [candidate.model.toLowerCase(), candidate.model]));
12121
+ }
12028
12122
  function canonicalModelId(value) {
12029
12123
  const trimmed = value.trim();
12030
12124
  const lower = trimmed.toLowerCase();
12031
- return SELECTABLE_MODEL_ALIASES[lower] ?? CANONICAL_MODEL_CASING[lower] ?? trimmed;
12125
+ return SELECTABLE_MODEL_ALIASES[lower] ?? canonicalModelCasing()[lower] ?? trimmed;
12032
12126
  }
12033
12127
  function formatSelectableModel(candidate) {
12034
12128
  const tier = `${candidate.intelligenceTier[0].toUpperCase()}${candidate.intelligenceTier.slice(1)}`;
@@ -12073,7 +12167,7 @@ function resolveModelForAgent(agent, requested, registry) {
12073
12167
  return registry.validateModel(candidate) ? candidate : defaultModel;
12074
12168
  }
12075
12169
  function resolveWorkerDefaultModel(agent, registry) {
12076
- return agent === "codex" ? "gpt-5.6-terra" : registry.defaultModel;
12170
+ return agent === "codex" ? "terra" : registry.defaultModel;
12077
12171
  }
12078
12172
  function resolveWorkerModel(agent, requested, registry) {
12079
12173
  const workerDefault = resolveWorkerDefaultModel(agent, registry);
@@ -12090,7 +12184,7 @@ function resolveCompactionExecution(agent, registry) {
12090
12184
  const effort = registry.validateEffort("medium") ? "medium" : registry.defaultEffort;
12091
12185
  return { model, ...effort ? { effort } : {} };
12092
12186
  }
12093
- var MODEL_OWNER, MODEL_COST_RESEARCHED_AT = "2026-09-05", MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.", CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month", CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)", CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month", CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)", SELECTABLE_MODELS, SELECTABLE_MODEL_ALIASES, CANONICAL_MODEL_CASING, FALLBACK_ORDER, AGENT_DISPLAY_NAME;
12187
+ var MODEL_OWNER, MODEL_COST_RESEARCHED_AT = "2026-09-05", MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.", CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month", CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)", CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month", CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)", SELECTABLE_MODELS, SELECTABLE_MODEL_ALIASES, FALLBACK_ORDER, AGENT_DISPLAY_NAME;
12094
12188
  var init_model_catalog = __esm(() => {
12095
12189
  init_config();
12096
12190
  MODEL_OWNER = {
@@ -12098,9 +12192,14 @@ var init_model_catalog = __esm(() => {
12098
12192
  opus: "claude",
12099
12193
  haiku: "claude",
12100
12194
  fable: "claude",
12195
+ astra: "codex",
12196
+ sol: "codex",
12197
+ luna: "codex",
12198
+ terra: "codex",
12101
12199
  "gpt-6-astra": "codex",
12102
12200
  "gpt-6-sol": "codex",
12103
12201
  "gpt-6-luna": "codex",
12202
+ "gpt-6.1-terra": "codex",
12104
12203
  "gpt-5.6-luna": "codex",
12105
12204
  "gpt-5.6-terra": "codex",
12106
12205
  "gpt-5.6-sol": "codex",
@@ -12121,7 +12220,7 @@ var init_model_catalog = __esm(() => {
12121
12220
  };
12122
12221
  SELECTABLE_MODELS = [
12123
12222
  {
12124
- model: "gpt-6-astra",
12223
+ model: "astra",
12125
12224
  agent: "codex",
12126
12225
  description: "Newest OpenAI flagship; Codex's highest-capability route.",
12127
12226
  intelligenceTier: "fable",
@@ -12131,7 +12230,7 @@ var init_model_catalog = __esm(() => {
12131
12230
  estimatedUsage: `Released 2026-09-03; became Codex CLI's bundled default in v0.153.4 (2026-09-05). Local message-count/quota-weight ranges not yet published as of the last catalog check \u2014 expect a quota weight above gpt-6-sol given the higher per-token cost. ${CODEX_COMMUNITY_WEEKLY}`
12132
12231
  },
12133
12232
  {
12134
- model: "gpt-6-sol",
12233
+ model: "sol",
12135
12234
  agent: "codex",
12136
12235
  description: "GPT-6 generation Sol route (2026-09-22) for demanding coding and agentic work.",
12137
12236
  intelligenceTier: "opus",
@@ -12141,7 +12240,7 @@ var init_model_catalog = __esm(() => {
12141
12240
  estimatedUsage: `Released 2026-09-22; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
12142
12241
  },
12143
12242
  {
12144
- model: "gpt-6-luna",
12243
+ model: "luna",
12145
12244
  agent: "codex",
12146
12245
  description: "Default Codex route (GPT-6 Luna, 2026-09-22): fast, high-volume, lowest cost.",
12147
12246
  intelligenceTier: "sonnet",
@@ -12151,14 +12250,14 @@ var init_model_catalog = __esm(() => {
12151
12250
  estimatedUsage: `Released 2026-09-22; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
12152
12251
  },
12153
12252
  {
12154
- model: "gpt-5.6-terra",
12253
+ model: "terra",
12155
12254
  agent: "codex",
12156
- description: "High-capability Codex route for complex coding and reasoning.",
12255
+ description: "GPT-6.1 Terra route (2026-10-26) for complex coding, visual reasoning, and computer use.",
12157
12256
  intelligenceTier: "opus",
12158
- routingSummary: "complex coding and reasoning; 2.5x Codex quota cost",
12257
+ routingSummary: "capable coding and computer use at a lower cost than GPT-5.6 Terra",
12159
12258
  accessCost: CODEX_PRO_20X_COST,
12160
- marginalTokenCost: "Codex credits: $2.50/M uncached input, $0.25/M cached input, $15/M output",
12161
- estimatedUsage: `Official Pro 20x range: 400\u20132,200 local messages per 5 hours; quota weight 2.5x the retired GPT-5.6 Luna. ${CODEX_COMMUNITY_WEEKLY}`
12259
+ marginalTokenCost: "Codex credits (OpenAI API rate): $1/M uncached input, $0.05/M cached input, $5/M output",
12260
+ estimatedUsage: `Released 2026-10-26; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
12162
12261
  },
12163
12262
  {
12164
12263
  model: "fable",
@@ -12252,8 +12351,13 @@ var init_model_catalog = __esm(() => {
12252
12351
  }
12253
12352
  ];
12254
12353
  SELECTABLE_MODEL_ALIASES = {
12255
- "gpt-5.6-sol": "gpt-6-sol",
12256
- "gpt-5.6-luna": "gpt-6-luna",
12354
+ "gpt-6-astra": "astra",
12355
+ "gpt-5.6-sol": "sol",
12356
+ "gpt-6-sol": "sol",
12357
+ "gpt-5.6-luna": "luna",
12358
+ "gpt-6-luna": "luna",
12359
+ "gpt-5.6-terra": "terra",
12360
+ "gpt-6.1-terra": "terra",
12257
12361
  kimi: "kimi-k3",
12258
12362
  "kimi-pro": "kimi-k3",
12259
12363
  "kimi-code": "kimi-k2.7-code",
@@ -12261,18 +12365,17 @@ var init_model_catalog = __esm(() => {
12261
12365
  "glm-pro": "glm-5.3",
12262
12366
  "glm-flash": "glm-5.3-flash"
12263
12367
  };
12264
- CANONICAL_MODEL_CASING = Object.fromEntries(SELECTABLE_MODELS.map((candidate) => [candidate.model.toLowerCase(), candidate.model]));
12265
12368
  FALLBACK_ORDER = {
12266
12369
  claude: [
12267
12370
  { agent: "maestro", model: "deepseek-pro" },
12268
- { agent: "codex", model: "gpt-6-luna" }
12371
+ { agent: "codex", model: "luna" }
12269
12372
  ],
12270
12373
  codex: [
12271
12374
  { agent: "maestro", model: "deepseek-pro" },
12272
12375
  { agent: "claude", model: "sonnet" }
12273
12376
  ],
12274
12377
  maestro: [
12275
- { agent: "codex", model: "gpt-6-luna" },
12378
+ { agent: "codex", model: "luna" },
12276
12379
  { agent: "claude", model: "sonnet" }
12277
12380
  ]
12278
12381
  };
@@ -16400,6 +16503,7 @@ var init_token_stats = __esm(async () => {
16400
16503
  "codex:gpt-6-astra": { input: 10, cacheWrite: 12.5, cacheRead: 1, output: 50 },
16401
16504
  "codex:gpt-6-sol": { input: 2, cacheRead: 0.2, output: 10 },
16402
16505
  "codex:gpt-6-luna": { input: 0.1, cacheRead: 0.01, output: 0.5 },
16506
+ "codex:gpt-6.1-terra": { input: 1, cacheRead: 0.05, output: 5 },
16403
16507
  "codex:gpt-5.6-sol": { input: 5, cacheRead: 0.5, output: 30 },
16404
16508
  "codex:gpt-5.6-terra": { input: 2.5, cacheRead: 0.25, output: 15 },
16405
16509
  "codex:gpt-5.6-luna": { input: 1, cacheRead: 0.1, output: 6 },
@@ -21603,12 +21707,13 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
21603
21707
  const toolSummaryOptions = {
21604
21708
  cwd: control.injectParams?.cwd ?? workspaceCwdFor(topicId)
21605
21709
  };
21710
+ const pricedModel = agentType === "codex" && Object.hasOwn(CODEX_TIER_FALLBACKS, model) ? resolveCodexTierModel(model) : model;
21606
21711
  const recordEventUsage = (usage) => {
21607
21712
  recordUsage(userId, topicTitle, usage, {
21608
21713
  topicId,
21609
21714
  ...control.sessionId ? { providerSessionId: control.sessionId } : {},
21610
21715
  agent: agentType,
21611
- model
21716
+ model: pricedModel
21612
21717
  });
21613
21718
  };
21614
21719
  const broadcastContextProgress = (force = false) => {
@@ -22190,6 +22295,7 @@ var init_turn_event_stream = __esm(async () => {
22190
22295
  init_usage_alert();
22191
22296
  init_sensitive_path();
22192
22297
  await __promiseAll([
22298
+ init_codex_tier_resolver(),
22193
22299
  init_fork(),
22194
22300
  init_idle_archiver(),
22195
22301
  init_idle_compact(),
@@ -38114,7 +38220,7 @@ var init_scheduler = __esm(async () => {
38114
38220
 
38115
38221
  // ../../packages/module-cron/src/module.ts
38116
38222
  import { existsSync as existsSync36 } from "fs";
38117
- import { fileURLToPath as fileURLToPath3 } from "url";
38223
+ import { fileURLToPath as fileURLToPath4 } from "url";
38118
38224
  function envMs(name, fallback) {
38119
38225
  const parsed = Number.parseInt(process.env[name] ?? "", 10);
38120
38226
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
@@ -38243,8 +38349,8 @@ var init_module = __esm(async () => {
38243
38349
  init_scripts(),
38244
38350
  init_store()
38245
38351
  ]);
38246
- SOURCE_MCP_SERVER_FILE = fileURLToPath3(new URL("./mcp-server.ts", import.meta.url));
38247
- PACKAGED_MCP_SERVER_FILE = fileURLToPath3(new URL("./runtime/cron/mcp-server.ts", import.meta.url));
38352
+ SOURCE_MCP_SERVER_FILE = fileURLToPath4(new URL("./mcp-server.ts", import.meta.url));
38353
+ PACKAGED_MCP_SERVER_FILE = fileURLToPath4(new URL("./runtime/cron/mcp-server.ts", import.meta.url));
38248
38354
  });
38249
38355
 
38250
38356
  // ../../packages/module-cron/src/summarize.ts
@@ -41575,6 +41681,15 @@ function commandSuggestions(input) {
41575
41681
  const normalized = token.toLowerCase();
41576
41682
  return TERMINAL_COMMANDS.filter((command) => command.name.startsWith(normalized));
41577
41683
  }
41684
+ function isKnownTerminalCommand(text3) {
41685
+ if (!text3.startsWith("/"))
41686
+ return false;
41687
+ const firstLine = text3.split(`
41688
+ `, 1)[0] ?? "";
41689
+ const [token = ""] = firstLine.slice(1).trim().split(/\s+/);
41690
+ const normalized = token.toLowerCase();
41691
+ return TERMINAL_COMMANDS.some((command) => command.name === normalized);
41692
+ }
41578
41693
  function completeCommand(input, index) {
41579
41694
  const suggestions = commandSuggestions(input);
41580
41695
  if (suggestions.length === 0)
@@ -41932,6 +42047,10 @@ function createInitialState(userId) {
41932
42047
  taskPanelScrollOffset: 0,
41933
42048
  topicsPanelEnabled: true,
41934
42049
  topicsPanelScrollOffset: 0,
42050
+ sidePanelWidth: SIDE_PANEL_WIDTH_DEFAULT,
42051
+ terminalPaneOpen: false,
42052
+ terminalPaneFocused: false,
42053
+ terminalPaneWidth: null,
41935
42054
  topicsPanelSort: "activity",
41936
42055
  overlay: null,
41937
42056
  topicPickerRoot: false,
@@ -41950,6 +42069,24 @@ function toggleTopicsPanel(state) {
41950
42069
  function cycleTopicsPanelSort(state) {
41951
42070
  return { ...state, topicsPanelSort: state.topicsPanelSort === "activity" ? "name" : "activity" };
41952
42071
  }
42072
+ function openTerminalPane(state) {
42073
+ return { ...state, terminalPaneOpen: true, terminalPaneFocused: true };
42074
+ }
42075
+ function closeTerminalPane(state) {
42076
+ return { ...state, terminalPaneOpen: false, terminalPaneFocused: false };
42077
+ }
42078
+ function focusTerminalPane(state, focused) {
42079
+ const next = focused && state.terminalPaneOpen;
42080
+ return next === state.terminalPaneFocused ? state : { ...state, terminalPaneFocused: next };
42081
+ }
42082
+ function setTerminalPaneWidth(state, width, maxWidth) {
42083
+ const next = Math.max(TERMINAL_PANE_WIDTH_MIN, Math.min(Math.round(width), maxWidth));
42084
+ return next === state.terminalPaneWidth ? state : { ...state, terminalPaneWidth: next };
42085
+ }
42086
+ function setSidePanelWidth(state, width, maxWidth) {
42087
+ const next = Math.min(SIDE_PANEL_WIDTH_MAX, Math.max(SIDE_PANEL_WIDTH_MIN, Math.min(Math.round(width), maxWidth)));
42088
+ return next === state.sidePanelWidth ? state : { ...state, sidePanelWidth: next };
42089
+ }
41953
42090
  function scrollTopicsPanel(state, delta, maxOffset) {
41954
42091
  const next = Math.min(maxOffset, Math.max(0, state.topicsPanelScrollOffset + delta));
41955
42092
  return next === state.topicsPanelScrollOffset ? state : { ...state, topicsPanelScrollOffset: next };
@@ -42580,7 +42717,7 @@ function applyRuntimeEvent(state, event) {
42580
42717
  }
42581
42718
  return state;
42582
42719
  }
42583
- var NO_TOPIC_PICKER_SELECTION = -1, TOOL_OUTPUT_EXCLUDED_PREFIXES;
42720
+ var SIDE_PANEL_WIDTH_DEFAULT = 36, SIDE_PANEL_WIDTH_MIN = 22, SIDE_PANEL_WIDTH_MAX = 64, TERMINAL_PANE_WIDTH_MIN = 30, NO_TOPIC_PICKER_SELECTION = -1, TOOL_OUTPUT_EXCLUDED_PREFIXES;
42584
42721
  var init_state2 = __esm(async () => {
42585
42722
  init_decision_graph();
42586
42723
  init_subagent_graph();
@@ -43831,18 +43968,32 @@ function taskLines(state, width) {
43831
43968
  line("")
43832
43969
  ];
43833
43970
  }
43971
+ function maxSidePanelWidth(columns) {
43972
+ return Math.max(SIDE_PANEL_WIDTH_MIN, columns - SIDE_PANEL_GAP - CONVERSATION_MIN_WIDTH);
43973
+ }
43834
43974
  function terminalBodyLayout(state, width) {
43835
- const wideEnough = width >= SIDE_PANEL_MIN_WIDTH && state.topicsPanelEnabled && (!state.overlay || state.overlay === "background-session") && !state.creatingTopic;
43975
+ const terminalReserve = state.terminalPaneOpen ? TERMINAL_PANE_WIDTH_MIN + TERMINAL_PANE_GAP : 0;
43976
+ const wideEnough = width - terminalReserve >= SIDE_PANEL_MIN_WIDTH && state.topicsPanelEnabled && (!state.overlay || state.overlay === "background-session") && !state.creatingTopic;
43836
43977
  const showTaskPanel = wideEnough && taskItems(state).length > 0;
43837
43978
  const showTopicsPanel = wideEnough && (state.topics.length > 1 || visibleBackgroundSessions(state).length > 0);
43838
43979
  const showSide = showTaskPanel || showTopicsPanel;
43980
+ const maxSideWidth = maxSidePanelWidth(width) - terminalReserve;
43981
+ const sideWidth = showSide ? Math.min(SIDE_PANEL_WIDTH_MAX, Math.max(SIDE_PANEL_WIDTH_MIN, state.sidePanelWidth), maxSideWidth) : 0;
43982
+ const afterSide = showSide ? width - sideWidth - SIDE_PANEL_GAP : width;
43983
+ const maxTerminalWidth = afterSide - TERMINAL_PANE_GAP - CONVERSATION_MIN_WIDTH;
43984
+ const terminalWidth = state.terminalPaneOpen && maxTerminalWidth >= TERMINAL_PANE_WIDTH_MIN ? Math.min(maxTerminalWidth, Math.max(TERMINAL_PANE_WIDTH_MIN, state.terminalPaneWidth ?? Math.floor(afterSide * 0.32))) : 0;
43839
43985
  return {
43840
- conversationWidth: showSide ? width - SIDE_PANEL_WIDTH - SIDE_PANEL_GAP : width,
43841
- sideWidth: showSide ? SIDE_PANEL_WIDTH : 0,
43986
+ conversationWidth: terminalWidth > 0 ? afterSide - terminalWidth - TERMINAL_PANE_GAP : afterSide,
43987
+ sideWidth,
43842
43988
  showTaskPanel,
43843
- showTopicsPanel
43989
+ showTopicsPanel,
43990
+ terminalWidth,
43991
+ maxTerminalWidth: Math.max(TERMINAL_PANE_WIDTH_MIN, maxTerminalWidth)
43844
43992
  };
43845
43993
  }
43994
+ function maxTerminalPaneWidth(state, columns) {
43995
+ return terminalBodyLayout(state, Math.max(1, columns)).maxTerminalWidth;
43996
+ }
43846
43997
  function topicStatusIndicator(state, topic, animationFrame) {
43847
43998
  const blockedText = blockedQuestionText(state, topic.id);
43848
43999
  if (blockedText !== undefined)
@@ -44052,7 +44203,7 @@ function renderSideColumn(state, layout, bodyHeight, animationFrame) {
44052
44203
  function maxTopicsPanelScrollOffset(state, columns, rows) {
44053
44204
  const width = Math.max(1, columns);
44054
44205
  const height = Math.max(14, rows);
44055
- if (state.overlay)
44206
+ if (state.overlay && state.overlay !== "background-session")
44056
44207
  return 0;
44057
44208
  const layout = terminalBodyLayout(state, width);
44058
44209
  if (!layout.showTopicsPanel)
@@ -44065,7 +44216,7 @@ function maxTopicsPanelScrollOffset(state, columns, rows) {
44065
44216
  function maxTaskPanelScrollOffset(state, columns, rows) {
44066
44217
  const width = Math.max(1, columns);
44067
44218
  const height = Math.max(14, rows);
44068
- if (state.overlay)
44219
+ if (state.overlay && state.overlay !== "background-session")
44069
44220
  return 0;
44070
44221
  const layout = terminalBodyLayout(state, width);
44071
44222
  if (!layout.showTaskPanel)
@@ -44085,7 +44236,8 @@ function helpLines() {
44085
44236
  line(" Cmd-Backspace works when forwarded \xB7 Ctrl-W/K aliases"),
44086
44237
  line(" Mouse wheel / PgUp/PgDn scroll \xB7 Ctrl-E load older"),
44087
44238
  line(" Ctrl-P topics + tasks panel \xB7 click/hover a row to switch \xB7 drag scrollbar"),
44088
- line(" Ctrl-R sort topics panel (activity / name)"),
44239
+ line(" Ctrl-R sort topics panel (activity / name) \xB7 drag a \u2502 divider to resize"),
44240
+ line(" Ctrl-T open/close a shell on the right (closing ends it) \xB7 click it to type"),
44089
44241
  line(" Ctrl-O topics \xB7 Ctrl-G subagents \xB7 Ctrl-D decisions \xB7 Ctrl-X abort"),
44090
44242
  line(" In topics: type to filter \xB7 Ctrl-N new \xB7 Ctrl-D delete"),
44091
44243
  line(" Esc/Ctrl-C stop active turn \xB7 Ctrl-C twice when idle to quit"),
@@ -44810,8 +44962,11 @@ function shiftComposerPane(pane, marginWidth) {
44810
44962
  cursor: { x: pane.cursor.x + marginWidth, y: pane.cursor.y }
44811
44963
  };
44812
44964
  }
44965
+ function shortcutHint(width) {
44966
+ return SHORTCUT_HINTS.find((hint) => displayWidth(hint) + 2 <= width) ?? SHORTCUT_HINTS[2];
44967
+ }
44813
44968
  function composerPane(state, width) {
44814
- const title = state.creatingTopic ? "new topic \xB7 type a name \xB7 Enter create" : state.overlay === "vault" ? state.vaultMode === "list" ? "Vault command \xB7 Enter run \xB7 Esc close" : `${state.vaultMode === "key" ? "key" : state.vaultMode === "value" ? "secret value" : "description"} \xB7 Enter continue \xB7 Esc cancel` : "Ctrl-O topics \xB7 Ctrl-G subagents \xB7 Ctrl-D decisions";
44969
+ const title = state.creatingTopic ? "new topic \xB7 type a name \xB7 Enter create" : state.overlay === "vault" ? state.vaultMode === "list" ? "Vault command \xB7 Enter run \xB7 Esc close" : `${state.vaultMode === "key" ? "key" : state.vaultMode === "value" ? "secret value" : "description"} \xB7 Enter continue \xB7 Esc cancel` : shortcutHint(width);
44815
44970
  const visual = inputVisualLines(state, width);
44816
44971
  let inputStart = Math.max(0, visual.lines.length - 5);
44817
44972
  if (visual.cursorLine < inputStart)
@@ -45050,7 +45205,7 @@ function renderBody(lines, width, height) {
45050
45205
  function renderApp(state, columns, rows, animationFrame = 0, nowMs = terminalNowMs()) {
45051
45206
  return renderAppFrame(state, columns, rows, animationFrame, nowMs).frame;
45052
45207
  }
45053
- function renderAppFrame(state, columns, rows, animationFrame = 0, nowMs = terminalNowMs()) {
45208
+ function renderAppFrame(state, columns, rows, animationFrame = 0, nowMs = terminalNowMs(), extras = {}) {
45054
45209
  const width = Math.max(1, columns);
45055
45210
  const height = Math.max(14, rows);
45056
45211
  const layout = terminalBodyLayout(state, width);
@@ -45067,7 +45222,7 @@ function renderAppFrame(state, columns, rows, animationFrame = 0, nowMs = termin
45067
45222
  const conversationBody = renderBody(conversation, layout.conversationWidth, bodyHeight);
45068
45223
  const sideColumn = layout.showTaskPanel || layout.showTopicsPanel ? renderSideColumn(state, layout, bodyHeight, animationFrame) : null;
45069
45224
  const body = sideColumn?.lines.length ? (() => {
45070
- const gap = paint(" ".repeat(SIDE_PANEL_GAP), { bg: theme.canvas });
45225
+ const gap = paint("\u2502".repeat(SIDE_PANEL_GAP), { fg: theme.border, bg: theme.canvas });
45071
45226
  return sideColumn.lines.map((row, index) => `${row}${gap}${conversationBody[index] ?? ""}`);
45072
45227
  })() : conversationBody;
45073
45228
  const codeCopyTargets = conversation.flatMap((item, index) => {
@@ -45109,19 +45264,114 @@ function renderAppFrame(state, columns, rows, animationFrame = 0, nowMs = termin
45109
45264
  }
45110
45265
  return { xStart: 1, xEnd: layout.sideWidth, sections };
45111
45266
  })() : null;
45267
+ const sidePanelResizeHandle = sideColumn ? {
45268
+ xStart: Math.max(1, layout.sideWidth),
45269
+ xEnd: layout.sideWidth + SIDE_PANEL_GAP,
45270
+ yStart: 1,
45271
+ yEnd: bodyHeight
45272
+ } : null;
45112
45273
  const cursorY = composer.cursor ? body.length + decision.length + composer.cursor.y : Number.POSITIVE_INFINITY;
45113
45274
  const overlayCursor = topicOverlayCursor(state, layout.conversationWidth, body.length);
45114
- const cursor = composer.cursor && cursorY <= height ? { x: Math.min(composer.cursor.x, width), y: cursorY } : overlayCursor && overlayCursor.y <= height ? overlayCursor : null;
45275
+ const leftRows = [...body, ...decision, ...composer.lines, ...footer].slice(0, height);
45276
+ let terminalPane = null;
45277
+ let frameRows = leftRows;
45278
+ if (layout.terminalWidth > 0) {
45279
+ const leftWidth = width - layout.terminalWidth - TERMINAL_PANE_GAP;
45280
+ const shellRows = shellPaneRows(extras.shell ?? null, layout.terminalWidth, leftRows.length);
45281
+ const divider = paint("\u2502".repeat(TERMINAL_PANE_GAP), {
45282
+ fg: state.terminalPaneFocused ? theme.borderActive : theme.border,
45283
+ bg: theme.canvas
45284
+ });
45285
+ frameRows = leftRows.map((row, index) => `${padToWidth(row, leftWidth)}${divider}${shellRows[index] ?? ""}`);
45286
+ terminalPane = {
45287
+ xStart: leftWidth + TERMINAL_PANE_GAP + 1,
45288
+ xEnd: width,
45289
+ yStart: 1,
45290
+ yEnd: leftRows.length,
45291
+ dividerX: leftWidth + 1,
45292
+ cols: layout.terminalWidth,
45293
+ rows: leftRows.length
45294
+ };
45295
+ }
45296
+ const shellCursor = terminalPane && state.terminalPaneFocused && extras.shell?.cursor ? {
45297
+ x: terminalPane.xStart + extras.shell.cursor.x,
45298
+ y: terminalPane.yStart + extras.shell.cursor.y
45299
+ } : null;
45300
+ const cursor = state.terminalPaneFocused && terminalPane ? shellCursor : composer.cursor && cursorY <= height ? { x: Math.min(composer.cursor.x, width), y: cursorY } : overlayCursor && overlayCursor.y <= height ? overlayCursor : null;
45115
45301
  return {
45116
- frame: linkifyUrls([...body, ...decision, ...composer.lines, ...footer].slice(0, height).join(`
45302
+ frame: linkifyUrls(frameRows.join(`
45117
45303
  `)),
45118
45304
  cursor,
45119
45305
  codeCopyTargets,
45120
45306
  topicPickerTargets,
45121
45307
  sidePanelTracks,
45122
- sideColumnBounds
45308
+ sideColumnBounds,
45309
+ sidePanelResizeHandle,
45310
+ conversationBounds: {
45311
+ xStart: conversationXStart,
45312
+ xEnd: conversationXStart + layout.conversationWidth - 1
45313
+ },
45314
+ terminalPane
45123
45315
  };
45124
45316
  }
45317
+ function padToWidth(row, width) {
45318
+ const visible = displayWidth(stripAnsi(row));
45319
+ return visible >= width ? row : `${row}${paint(" ".repeat(width - visible), { bg: theme.canvas })}`;
45320
+ }
45321
+ function shellColorCode(color, background, fallback) {
45322
+ if (color.kind === "rgb")
45323
+ return background ? bg(color.rgb) : fg(color.rgb);
45324
+ if (color.kind === "palette") {
45325
+ const index = color.index;
45326
+ if (index < 8)
45327
+ return `${ESC}${(background ? 40 : 30) + index}m`;
45328
+ if (index < 16)
45329
+ return `${ESC}${(background ? 100 : 90) + index - 8}m`;
45330
+ return `${ESC}${background ? 48 : 38};5;${index}m`;
45331
+ }
45332
+ return background ? bg(fallback) : fg(fallback);
45333
+ }
45334
+ function paintShellRun(run) {
45335
+ if (colorDepth === "none")
45336
+ return run.text;
45337
+ const fgColor = run.inverse ? run.bg : run.fg;
45338
+ const bgColor = run.inverse ? run.fg : run.bg;
45339
+ const fgFallback = run.inverse ? theme.canvas : theme.text;
45340
+ const bgFallback = run.inverse ? theme.text : theme.canvas;
45341
+ return `${shellColorCode(fgColor, false, fgFallback)}${shellColorCode(bgColor, true, bgFallback)}${run.bold ? `${ESC}1m` : ""}${run.dim ? `${ESC}2m` : ""}${run.italic ? `${ESC}3m` : ""}${run.underline ? `${ESC}4m` : ""}${run.text}${RESET}`;
45342
+ }
45343
+ function shellPaneRows(snapshot, width, height) {
45344
+ const rows = [];
45345
+ for (let index = 0;index < height; index += 1) {
45346
+ const runs = snapshot?.lines[index];
45347
+ if (!runs) {
45348
+ const text3 = !snapshot && index === 0 ? fit(" starting shell\u2026", width) : " ".repeat(width);
45349
+ rows.push(paint(text3, { fg: theme.muted, bg: theme.canvas }));
45350
+ continue;
45351
+ }
45352
+ let used = 0;
45353
+ let row = "";
45354
+ for (const run of runs) {
45355
+ if (used >= width)
45356
+ break;
45357
+ if (used + run.width > width) {
45358
+ row += paintShellRun({
45359
+ ...run,
45360
+ text: sliceWidth(run.text, width - used),
45361
+ width: width - used
45362
+ });
45363
+ used = width;
45364
+ break;
45365
+ }
45366
+ row += paintShellRun(run);
45367
+ used += run.width;
45368
+ }
45369
+ if (used < width)
45370
+ row += paint(" ".repeat(width - used), { bg: theme.canvas });
45371
+ rows.push(row);
45372
+ }
45373
+ return rows;
45374
+ }
45125
45375
  function maxConversationScrollOffset(state, columns, rows) {
45126
45376
  const width = Math.max(1, columns);
45127
45377
  const height = Math.max(14, rows);
@@ -45171,7 +45421,7 @@ var theme, WORKING_FRAMES, CODE_COPY_MARKER = "\u29C9", WORKING_FRAME_INTERVAL_M
45171
45421
  default:
45172
45422
  return `${ESC}48;2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
45173
45423
  }
45174
- }, BARE_URL_PATTERN, URL_TRAILING_PUNCTUATION, RENDERED_TAB_WIDTH = 4, CIRCLED_DIGIT_START = 9312, CIRCLED_DIGIT_END = 9331, CIRCLED_ZERO = 9450, isWrapSpace = (character) => character === " " || character === "\t", isWideBreak = (character) => runeWidth(character) === 2, NO_ROW_START, NO_ROW_END, WRAP_MIN_WIDTH = 2, FRAME_MIN_INNER_WIDTH = 4, FRAME_TITLE_MIN_INNER_WIDTH = 8, TABLE_MAX_WIDTH_FRACTION = 0.92, TABLE_MIN_COL_WIDTH = 4, TOOL_PREVIEW_MAX_LINES = 12, messageLayoutCache, INLINE_TASK_LIMIT = 5, SIDE_PANEL_MIN_WIDTH = 110, SIDE_PANEL_WIDTH = 36, SIDE_PANEL_GAP = 1, TOPIC_FILTER_ROW_INDEX = 2, TOPIC_FILTER_LABEL = " Filter: ", POPUP_PANE_MAX_WIDTH = 72, COMPOSER_GUTTER = 4, COMPOSER_RIGHT_MARGIN = 1, COMPOSER_MIN_CONTENT_WIDTH = 4, NOTICE_STYLE;
45424
+ }, BARE_URL_PATTERN, URL_TRAILING_PUNCTUATION, RENDERED_TAB_WIDTH = 4, CIRCLED_DIGIT_START = 9312, CIRCLED_DIGIT_END = 9331, CIRCLED_ZERO = 9450, isWrapSpace = (character) => character === " " || character === "\t", isWideBreak = (character) => runeWidth(character) === 2, NO_ROW_START, NO_ROW_END, WRAP_MIN_WIDTH = 2, FRAME_MIN_INNER_WIDTH = 4, FRAME_TITLE_MIN_INNER_WIDTH = 8, TABLE_MAX_WIDTH_FRACTION = 0.92, TABLE_MIN_COL_WIDTH = 4, TOOL_PREVIEW_MAX_LINES = 12, messageLayoutCache, INLINE_TASK_LIMIT = 5, SIDE_PANEL_MIN_WIDTH = 110, SIDE_PANEL_GAP = 1, CONVERSATION_MIN_WIDTH = 60, TERMINAL_PANE_GAP = 1, TOPIC_FILTER_ROW_INDEX = 2, TOPIC_FILTER_LABEL = " Filter: ", POPUP_PANE_MAX_WIDTH = 72, COMPOSER_GUTTER = 4, COMPOSER_RIGHT_MARGIN = 1, COMPOSER_MIN_CONTENT_WIDTH = 4, SHORTCUT_HINTS, NOTICE_STYLE;
45175
45425
  var init_render = __esm(async () => {
45176
45426
  init_color_depth();
45177
45427
  init_commands();
@@ -45212,6 +45462,11 @@ var init_render = __esm(async () => {
45212
45462
  NO_ROW_START = new Set(Array.from(".,;:!?)]}>\xBB\u201D\u2019\u3001\u3002\uFF0C\uFF0E\uFF01\uFF1F\uFF1A\uFF1B\uFF09\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u3015\u30FB\u2026\u30FC"));
45213
45463
  NO_ROW_END = new Set(Array.from("([{<\xAB\u201C\u2018\uFF08\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014"));
45214
45464
  messageLayoutCache = new WeakMap;
45465
+ SHORTCUT_HINTS = [
45466
+ "Ctrl-O topics \xB7 Ctrl-P panel \xB7 Ctrl-T terminal \xB7 Ctrl-G subagents \xB7 Ctrl-D decisions",
45467
+ "Ctrl-O topics \xB7 Ctrl-P panel \xB7 Ctrl-T term \xB7 Ctrl-G agents \xB7 Ctrl-D decisions",
45468
+ "^O topics \xB7 ^P panel \xB7 ^T term \xB7 ^G agents \xB7 ^D decisions"
45469
+ ];
45215
45470
  NOTICE_STYLE = {
45216
45471
  info: { glyph: "\xB7", fg: theme.muted },
45217
45472
  success: { glyph: "\u2713", fg: theme.green },
@@ -46632,12 +46887,16 @@ function columnSlice(value, from2, to) {
46632
46887
  }
46633
46888
  function screenSelectionText(lines, selection) {
46634
46889
  const [start, end] = ordered(selection);
46890
+ const clipFrom = selection.paneClip ? selection.paneClip.xStart - 1 : 0;
46891
+ const clipTo = selection.paneClip ? selection.paneClip.xEnd : Number.POSITIVE_INFINITY;
46635
46892
  const selected = [];
46636
46893
  for (let row = start.y;row <= end.y; row += 1) {
46637
46894
  const value = lines[row - 1] ?? "";
46638
- const from2 = row === start.y ? Math.max(0, start.x - 1) : 0;
46639
- const to = row === end.y ? Math.max(from2, end.x) : Number.POSITIVE_INFINITY;
46640
- selected.push(columnSlice(value, from2, to).trimEnd());
46895
+ const rowFrom = row === start.y ? Math.max(0, start.x - 1) : 0;
46896
+ const rowTo = row === end.y ? Math.max(rowFrom, end.x) : Number.POSITIVE_INFINITY;
46897
+ const from2 = Math.max(rowFrom, clipFrom);
46898
+ const to = Math.min(rowTo, clipTo);
46899
+ selected.push(to > from2 ? columnSlice(value, from2, to).trimEnd() : "");
46641
46900
  }
46642
46901
  return selected.join(`
46643
46902
  `).replace(/\n+$/, "");
@@ -46678,14 +46937,18 @@ function highlightRow(value, from2, to) {
46678
46937
  }
46679
46938
  function highlightScreenSelection(frame, selection) {
46680
46939
  const [start, end] = ordered(selection);
46940
+ const clipFrom = selection.paneClip ? selection.paneClip.xStart - 1 : 0;
46941
+ const clipTo = selection.paneClip ? selection.paneClip.xEnd : Number.POSITIVE_INFINITY;
46681
46942
  return frame.split(`
46682
46943
  `).map((line2, index) => {
46683
46944
  const row = index + 1;
46684
46945
  if (row < start.y || row > end.y)
46685
46946
  return line2;
46686
- const from2 = row === start.y ? Math.max(0, start.x - 1) : 0;
46687
- const to = row === end.y ? Math.max(from2, end.x) : Number.POSITIVE_INFINITY;
46688
- return highlightRow(line2, from2, to);
46947
+ const rowFrom = row === start.y ? Math.max(0, start.x - 1) : 0;
46948
+ const rowTo = row === end.y ? Math.max(rowFrom, end.x) : Number.POSITIVE_INFINITY;
46949
+ const from2 = Math.max(rowFrom, clipFrom);
46950
+ const to = Math.min(rowTo, clipTo);
46951
+ return to > from2 ? highlightRow(line2, from2, to) : line2;
46689
46952
  }).join(`
46690
46953
  `);
46691
46954
  }
@@ -46695,6 +46958,210 @@ var init_selection = __esm(() => {
46695
46958
  ANSI_PATTERN = new RegExp("\\u001b\\]8;[^\\u0007\\u001b]*(?:\\u0007|\\u001b\\\\)|\\u001b\\[[0-?]*[ -/]*[@-~]", "y");
46696
46959
  });
46697
46960
 
46961
+ // ../../adapters/terminal/src/shell-pane.ts
46962
+ import xterm from "@xterm/headless";
46963
+ function ptySupport() {
46964
+ const candidate = globalThis.Bun?.Terminal;
46965
+ return typeof candidate === "function" ? candidate : null;
46966
+ }
46967
+ function cellColor(isDefault, isPalette, isRgb, value) {
46968
+ if (isDefault)
46969
+ return DEFAULT_COLOR;
46970
+ if (isPalette)
46971
+ return { kind: "palette", index: value };
46972
+ if (isRgb) {
46973
+ return {
46974
+ kind: "rgb",
46975
+ rgb: [value >> 16 & 255, value >> 8 & 255, value & 255]
46976
+ };
46977
+ }
46978
+ return DEFAULT_COLOR;
46979
+ }
46980
+ function sameColor(a, b) {
46981
+ if (a.kind !== b.kind)
46982
+ return false;
46983
+ if (a.kind === "palette" && b.kind === "palette")
46984
+ return a.index === b.index;
46985
+ if (a.kind === "rgb" && b.kind === "rgb") {
46986
+ return a.rgb[0] === b.rgb[0] && a.rgb[1] === b.rgb[1] && a.rgb[2] === b.rgb[2];
46987
+ }
46988
+ return true;
46989
+ }
46990
+ function sameStyle(a, b) {
46991
+ return sameColor(a.fg, b.fg) && sameColor(a.bg, b.bg) && a.bold === b.bold && a.dim === b.dim && a.italic === b.italic && a.underline === b.underline && a.inverse === b.inverse;
46992
+ }
46993
+ function blankRun(width) {
46994
+ return {
46995
+ text: " ".repeat(width),
46996
+ width,
46997
+ fg: DEFAULT_COLOR,
46998
+ bg: DEFAULT_COLOR,
46999
+ bold: false,
47000
+ dim: false,
47001
+ italic: false,
47002
+ underline: false,
47003
+ inverse: false
47004
+ };
47005
+ }
47006
+ function shellPastePayload(text3, bracketed) {
47007
+ const safe = text3.replaceAll("\x1B[201~", "");
47008
+ return bracketed ? `\x1B[200~${safe}\x1B[201~` : safe;
47009
+ }
47010
+
47011
+ class ShellPane {
47012
+ #xterm;
47013
+ #pty;
47014
+ #process;
47015
+ #cols;
47016
+ #rows;
47017
+ #disposed = false;
47018
+ constructor(options) {
47019
+ const Pty = ptySupport();
47020
+ if (!Pty)
47021
+ throw new Error("the shell pane needs Bun >= 1.3.5 (Bun.Terminal)");
47022
+ this.#cols = Math.max(2, options.cols);
47023
+ this.#rows = Math.max(1, options.rows);
47024
+ const Terminal = xterm.Terminal;
47025
+ this.#xterm = new Terminal({
47026
+ cols: this.#cols,
47027
+ rows: this.#rows,
47028
+ scrollback: 5000,
47029
+ allowProposedApi: true
47030
+ });
47031
+ this.#pty = new Pty({
47032
+ cols: this.#cols,
47033
+ rows: this.#rows,
47034
+ data: (_terminal, data) => {
47035
+ if (this.#disposed)
47036
+ return;
47037
+ this.#xterm.write(data, options.onChange);
47038
+ }
47039
+ });
47040
+ this.#xterm.onData((data) => {
47041
+ if (!this.#disposed)
47042
+ this.#pty.write(data);
47043
+ });
47044
+ const shell2 = options.shell || process.env.SHELL || "/bin/zsh";
47045
+ const env = { ...options.env ?? process.env };
47046
+ env.TERM = "xterm-256color";
47047
+ env.COLORTERM = "truecolor";
47048
+ delete env.TERM_SESSION_ID;
47049
+ const spawn9 = globalThis.Bun.spawn;
47050
+ this.#process = spawn9([shell2, "-l"], {
47051
+ cwd: options.cwd ?? process.cwd(),
47052
+ env,
47053
+ terminal: this.#pty
47054
+ });
47055
+ this.#process.exited.then((code) => {
47056
+ if (this.#disposed)
47057
+ return;
47058
+ this.dispose();
47059
+ options.onExit(code);
47060
+ });
47061
+ }
47062
+ get cols() {
47063
+ return this.#cols;
47064
+ }
47065
+ get rows() {
47066
+ return this.#rows;
47067
+ }
47068
+ get disposed() {
47069
+ return this.#disposed;
47070
+ }
47071
+ write(data) {
47072
+ if (this.#disposed || !data)
47073
+ return;
47074
+ this.#xterm.scrollToBottom();
47075
+ this.#pty.write(data);
47076
+ }
47077
+ paste(text3) {
47078
+ this.write(shellPastePayload(text3, this.#xterm.modes.bracketedPasteMode));
47079
+ }
47080
+ scroll(delta) {
47081
+ if (this.#disposed || delta === 0)
47082
+ return;
47083
+ this.#xterm.scrollLines(-delta);
47084
+ }
47085
+ resize(cols, rows) {
47086
+ const nextCols = Math.max(2, cols);
47087
+ const nextRows = Math.max(1, rows);
47088
+ if (this.#disposed || nextCols === this.#cols && nextRows === this.#rows)
47089
+ return;
47090
+ this.#cols = nextCols;
47091
+ this.#rows = nextRows;
47092
+ this.#xterm.resize(nextCols, nextRows);
47093
+ this.#pty.resize(nextCols, nextRows);
47094
+ }
47095
+ snapshot() {
47096
+ const buffer = this.#xterm.buffer.active;
47097
+ const lines = [];
47098
+ let reusable;
47099
+ for (let y = 0;y < this.#rows; y += 1) {
47100
+ const line2 = buffer.getLine(buffer.viewportY + y);
47101
+ const runs = [];
47102
+ let used = 0;
47103
+ if (line2) {
47104
+ for (let x = 0;x < this.#cols; x += 1) {
47105
+ const cell = line2.getCell(x, reusable);
47106
+ if (!cell)
47107
+ break;
47108
+ reusable = cell;
47109
+ const width = cell.getWidth();
47110
+ if (width === 0)
47111
+ continue;
47112
+ if (used + width > this.#cols)
47113
+ break;
47114
+ const style = {
47115
+ fg: cellColor(cell.isFgDefault(), cell.isFgPalette(), cell.isFgRGB(), cell.getFgColor()),
47116
+ bg: cellColor(cell.isBgDefault(), cell.isBgPalette(), cell.isBgRGB(), cell.getBgColor()),
47117
+ bold: cell.isBold() !== 0,
47118
+ dim: cell.isDim() !== 0,
47119
+ italic: cell.isItalic() !== 0,
47120
+ underline: cell.isUnderline() !== 0,
47121
+ inverse: cell.isInverse() !== 0
47122
+ };
47123
+ const text3 = cell.getChars() || " ";
47124
+ const last = runs[runs.length - 1];
47125
+ if (last && sameStyle(last, style)) {
47126
+ last.text += text3;
47127
+ last.width += width;
47128
+ } else {
47129
+ runs.push({ text: text3, width, ...style });
47130
+ }
47131
+ used += width;
47132
+ }
47133
+ }
47134
+ if (used < this.#cols)
47135
+ runs.push(blankRun(this.#cols - used));
47136
+ lines.push(runs);
47137
+ }
47138
+ const atLiveScreen = buffer.viewportY === buffer.baseY;
47139
+ const hidden = this.#xterm._core?.coreService?.isCursorHidden;
47140
+ return {
47141
+ cols: this.#cols,
47142
+ rows: this.#rows,
47143
+ lines,
47144
+ cursor: atLiveScreen && !hidden ? { x: Math.min(buffer.cursorX, this.#cols - 1), y: buffer.cursorY } : null
47145
+ };
47146
+ }
47147
+ dispose() {
47148
+ if (this.#disposed)
47149
+ return;
47150
+ this.#disposed = true;
47151
+ try {
47152
+ this.#process.kill();
47153
+ } catch {}
47154
+ try {
47155
+ this.#pty.close();
47156
+ } catch {}
47157
+ this.#xterm.dispose();
47158
+ }
47159
+ }
47160
+ var DEFAULT_COLOR;
47161
+ var init_shell_pane = __esm(() => {
47162
+ DEFAULT_COLOR = { kind: "default" };
47163
+ });
47164
+
46698
47165
  // ../../adapters/terminal/src/terminal-restore.ts
46699
47166
  import { writeSync } from "fs";
46700
47167
  function isRetryable(error2) {
@@ -47168,6 +47635,7 @@ class InputHistory {
47168
47635
  }
47169
47636
 
47170
47637
  // ../../adapters/terminal/src/app.ts
47638
+ import { hostname as hostname2 } from "os";
47171
47639
  function kittyKeyboardEnabled(env = process.env) {
47172
47640
  const value = env.NEGOTIUM_TUI_DISABLE_KITTY_KEYBOARD;
47173
47641
  return value !== "1" && value !== "true" && value !== "yes";
@@ -47186,18 +47654,20 @@ function canvasFill(depth2) {
47186
47654
  return `\x1B[48;2;${CANVAS_RGB[0]};${CANVAS_RGB[1]};${CANVAS_RGB[2]}m`;
47187
47655
  }
47188
47656
  }
47189
- function altScreenSequences(env = process.env, savedDepth) {
47657
+ function workingDirectoryReport(cwd, host2 = hostname2()) {
47658
+ const path = cwd.split("/").map((segment) => encodeURIComponent(segment)).join("/");
47659
+ return `\x1B]7;file://${host2}${path}\x07`;
47660
+ }
47661
+ function altScreenSequences(env = process.env, savedDepth, cwd = process.cwd()) {
47190
47662
  const push = kittyKeyboardEnabled(env) ? KITTY_KEYBOARD_PUSH : "";
47191
47663
  const pop = kittyKeyboardEnabled(env) ? KITTY_KEYBOARD_POP : "";
47192
47664
  const depth2 = detectColorDepth({ env, isTty: true, savedDepth });
47193
- const colored = depth2 !== "none";
47194
- const setBackground = colored ? "\x1B]11;#0a0b0f\x07" : "";
47195
47665
  const fillCanvas = canvasFill(depth2);
47196
- const resetBackground = colored ? "\x1B]111\x07" : "";
47666
+ const reportCwd = workingDirectoryReport(cwd);
47197
47667
  const modeResets = "\x1B[0m\x1B[?7h\x1B[?1l\x1B[?1006l\x1B[?1003l\x1B[?2004l\x1B[?25h\x1B[?1049l";
47198
47668
  return {
47199
- enter: `${setBackground}\x1B[?1049h${fillCanvas}\x1B[2J\x1B[H\x1B[?25l\x1B[?2004h\x1B[?1003h\x1B[?1006h\x1B[?1l${push}`,
47200
- exit: `${END_SYNCHRONIZED_UPDATE}${pop}${modeResets}${resetBackground}`,
47669
+ enter: `${reportCwd}\x1B[?1049h${fillCanvas}\x1B[2J\x1B[H\x1B[?25l\x1B[?2004h\x1B[?1003h\x1B[?1006h\x1B[?1l${push}`,
47670
+ exit: `${END_SYNCHRONIZED_UPDATE}${pop}${modeResets}${reportCwd}`,
47201
47671
  abortEnter: `${END_SYNCHRONIZED_UPDATE}${modeResets}`
47202
47672
  };
47203
47673
  }
@@ -47236,13 +47706,19 @@ class TerminalApp {
47236
47706
  #messageHistory = new Map;
47237
47707
  #queuedRuntimeEvents = new Map;
47238
47708
  #selection = null;
47709
+ #selectionDragging = false;
47239
47710
  #subagentGraphDragPoint = null;
47240
47711
  #plainFrameLines = [];
47241
47712
  #codeCopyTargets = [];
47242
47713
  #topicPickerTargets = [];
47243
47714
  #sidePanelTracks = [];
47244
47715
  #sideColumnBounds = null;
47716
+ #sidePanelResizeHandle = null;
47245
47717
  #sidePanelDrag = null;
47718
+ #sidePanelResizeDrag = null;
47719
+ #shell = null;
47720
+ #terminalPane = null;
47721
+ #conversationBounds = null;
47246
47722
  #lastInterruptAt = 0;
47247
47723
  #subagentGraphGeneration = 0;
47248
47724
  #subagentGraphAbortController = null;
@@ -47363,8 +47839,9 @@ class TerminalApp {
47363
47839
  }
47364
47840
  }
47365
47841
  #handleRuntimeEvent(event) {
47366
- if (runtimeEventInvalidatesSelection(this.#state, event))
47842
+ if (!this.#selectionDragging && runtimeEventInvalidatesSelection(this.#state, event)) {
47367
47843
  this.#selection = null;
47844
+ }
47368
47845
  if (this.#messageLoadGeneration.has(event.topicId) && runtimeEventWaitsForMessageLoad(event)) {
47369
47846
  const queued = this.#queuedRuntimeEvents.get(event.topicId) ?? [];
47370
47847
  queued.push(event);
@@ -47616,11 +48093,19 @@ class TerminalApp {
47616
48093
  #render() {
47617
48094
  const columns = process.stdout.columns ?? 100;
47618
48095
  const rows = process.stdout.rows ?? 30;
47619
- const rendered = renderAppFrame(this.#state, columns, rows, this.#animationFrame);
48096
+ const rendered = renderAppFrame(this.#state, columns, rows, this.#animationFrame, undefined, {
48097
+ shell: this.#shell?.snapshot() ?? null
48098
+ });
47620
48099
  this.#codeCopyTargets = rendered.codeCopyTargets;
47621
48100
  this.#topicPickerTargets = rendered.topicPickerTargets;
47622
48101
  this.#sidePanelTracks = rendered.sidePanelTracks;
47623
48102
  this.#sideColumnBounds = rendered.sideColumnBounds;
48103
+ this.#sidePanelResizeHandle = rendered.sidePanelResizeHandle;
48104
+ this.#terminalPane = rendered.terminalPane;
48105
+ this.#conversationBounds = rendered.conversationBounds;
48106
+ if (this.#shell && rendered.terminalPane) {
48107
+ this.#shell.resize(rendered.terminalPane.cols, rendered.terminalPane.rows);
48108
+ }
47624
48109
  const baseFrame = rendered.frame;
47625
48110
  this.#plainFrameLines = stripAnsi(baseFrame).split(`
47626
48111
  `);
@@ -47987,6 +48472,10 @@ class TerminalApp {
47987
48472
  }
47988
48473
  #commitPaste(payload) {
47989
48474
  this.#selection = null;
48475
+ if (this.#state.terminalPaneFocused && this.#shell) {
48476
+ this.#shell.paste(payload);
48477
+ return;
48478
+ }
47990
48479
  if (this.#state.overlay === "topics") {
47991
48480
  const filterText = topicFilterPasteText(payload);
47992
48481
  if (filterText) {
@@ -48024,6 +48513,9 @@ class TerminalApp {
48024
48513
  }
48025
48514
  if (this.#handleSidePanelScrollbarDrag(event))
48026
48515
  continue;
48516
+ this.#focusPaneUnderPress(event);
48517
+ if (this.#handleSidePanelResizeDrag(event))
48518
+ continue;
48027
48519
  if (this.#handlePickableRowMouse(event))
48028
48520
  continue;
48029
48521
  this.#handleMouseSelection(event);
@@ -48032,6 +48524,14 @@ class TerminalApp {
48032
48524
  if (!chunk)
48033
48525
  return;
48034
48526
  this.#selection = null;
48527
+ if (chunk === TERMINAL_PANE_KEY) {
48528
+ this.#toggleTerminalPane();
48529
+ return;
48530
+ }
48531
+ if (this.#state.terminalPaneFocused && this.#shell && this.#terminalPane) {
48532
+ this.#shell.write(chunk);
48533
+ return;
48534
+ }
48035
48535
  if (chunk === "\x03") {
48036
48536
  this.#handleInterrupt();
48037
48537
  return;
@@ -48065,6 +48565,23 @@ class TerminalApp {
48065
48565
  this.#toggleDecisionGraph();
48066
48566
  return;
48067
48567
  }
48568
+ if (chunk === NEW_TOPIC_KEY && this.#sideColumnBounds !== null && !this.#state.creatingTopic) {
48569
+ if (editingVaultSecret)
48570
+ return;
48571
+ if (composerHoldsSecret(this.#state) || activeQuestion(this.#state))
48572
+ return;
48573
+ if (this.#input.text) {
48574
+ this.#state = {
48575
+ ...this.#state,
48576
+ notice: "Clear the message box first, then Ctrl-N to start a new topic",
48577
+ noticeLevel: "warn"
48578
+ };
48579
+ this.#queueRender();
48580
+ return;
48581
+ }
48582
+ this.#openNewTopicComposer();
48583
+ return;
48584
+ }
48068
48585
  if (chunk === "\x10") {
48069
48586
  if (editingVaultSecret)
48070
48587
  return;
@@ -48497,7 +49014,7 @@ class TerminalApp {
48497
49014
  notice: undefined,
48498
49015
  noticeLevel: undefined
48499
49016
  };
48500
- if (text3.startsWith("/")) {
49017
+ if (isKnownTerminalCommand(text3) || isVaultCommandLine(text3)) {
48501
49018
  await this.#runCommand(text3);
48502
49019
  return;
48503
49020
  }
@@ -49219,8 +49736,14 @@ class TerminalApp {
49219
49736
  if (events.length === 0)
49220
49737
  return { scrollDelta, horizontalScrollDelta };
49221
49738
  const bounds = this.#sideColumnBounds;
49739
+ const pane = this.#terminalPane;
49222
49740
  let touchedPanel = false;
49223
49741
  for (const event of events) {
49742
+ if (pane && this.#shell && event.x >= pane.xStart && event.x <= pane.xEnd && !event.horizontal) {
49743
+ this.#shell.scroll(event.delta);
49744
+ touchedPanel = true;
49745
+ continue;
49746
+ }
49224
49747
  const section = bounds && event.x >= bounds.xStart && event.x <= bounds.xEnd ? bounds.sections.find((s) => event.y >= s.yStart && event.y <= s.yEnd) : undefined;
49225
49748
  if (!section) {
49226
49749
  if (event.horizontal)
@@ -49238,11 +49761,123 @@ class TerminalApp {
49238
49761
  this.#queueRender();
49239
49762
  return { scrollDelta, horizontalScrollDelta };
49240
49763
  }
49764
+ #toggleTerminalPane() {
49765
+ if (this.#state.terminalPaneOpen) {
49766
+ const shell2 = this.#shell;
49767
+ this.#shell = null;
49768
+ shell2?.dispose();
49769
+ this.#state = closeTerminalPane(this.#state);
49770
+ this.#queueRender();
49771
+ return;
49772
+ }
49773
+ if (!this.#shell) {
49774
+ if (!ptySupport()) {
49775
+ this.#state = {
49776
+ ...this.#state,
49777
+ notice: "Shell pane needs Bun >= 1.3.5 (bun upgrade)",
49778
+ noticeLevel: "warn"
49779
+ };
49780
+ this.#queueRender();
49781
+ return;
49782
+ }
49783
+ try {
49784
+ const columns2 = process.stdout.columns ?? 100;
49785
+ const rows = process.stdout.rows ?? 30;
49786
+ const shell2 = new ShellPane({
49787
+ cols: Math.max(30, Math.floor(columns2 * 0.3)),
49788
+ rows: Math.max(1, rows),
49789
+ cwd: process.cwd(),
49790
+ onChange: () => this.#queueRender(),
49791
+ onExit: () => {
49792
+ if (this.#shell !== shell2)
49793
+ return;
49794
+ this.#shell = null;
49795
+ this.#state = {
49796
+ ...closeTerminalPane(this.#state),
49797
+ notice: "Shell exited",
49798
+ noticeLevel: "info"
49799
+ };
49800
+ this.#queueRender();
49801
+ }
49802
+ });
49803
+ this.#shell = shell2;
49804
+ } catch (error2) {
49805
+ this.#state = {
49806
+ ...this.#state,
49807
+ notice: `Shell pane failed: ${error2 instanceof Error ? error2.message : String(error2)}`,
49808
+ noticeLevel: "error"
49809
+ };
49810
+ this.#queueRender();
49811
+ return;
49812
+ }
49813
+ }
49814
+ this.#state = openTerminalPane(this.#state);
49815
+ const columns = process.stdout.columns ?? 100;
49816
+ if (maxTerminalPaneWidth(this.#state, columns) < 30 || columns < 92) {
49817
+ this.#state = {
49818
+ ...this.#state,
49819
+ notice: "Window too narrow for the shell pane \u2014 widen it to see the pane",
49820
+ noticeLevel: "warn"
49821
+ };
49822
+ }
49823
+ this.#queueRender();
49824
+ }
49825
+ #focusPaneUnderPress(event) {
49826
+ if (event.kind !== "press" || (event.button & 3) !== 0)
49827
+ return;
49828
+ const pane = this.#terminalPane;
49829
+ const inside = !!pane && event.x >= pane.xStart && event.x <= pane.xEnd;
49830
+ const next = focusTerminalPane(this.#state, inside && !!this.#shell);
49831
+ if (next !== this.#state) {
49832
+ this.#state = next;
49833
+ this.#queueRender();
49834
+ }
49835
+ }
49836
+ #handleSidePanelResizeDrag(event) {
49837
+ if (event.kind === "press" && (event.button & 3) === 0) {
49838
+ const pane = this.#terminalPane;
49839
+ if (pane && event.x === pane.dividerX && event.y >= pane.yStart && event.y <= pane.yEnd) {
49840
+ this.#sidePanelResizeDrag = { target: "terminal", startX: event.x, startWidth: pane.cols };
49841
+ return true;
49842
+ }
49843
+ const handle = this.#sidePanelResizeHandle;
49844
+ if (!handle || event.x < handle.xStart || event.x > handle.xEnd || event.y < handle.yStart || event.y > handle.yEnd) {
49845
+ this.#sidePanelResizeDrag = null;
49846
+ return false;
49847
+ }
49848
+ this.#sidePanelResizeDrag = {
49849
+ target: "side",
49850
+ startX: event.x,
49851
+ startWidth: this.#state.sidePanelWidth
49852
+ };
49853
+ return true;
49854
+ }
49855
+ const drag = this.#sidePanelResizeDrag;
49856
+ if (!drag)
49857
+ return false;
49858
+ if (event.kind === "release") {
49859
+ this.#sidePanelResizeDrag = null;
49860
+ return true;
49861
+ }
49862
+ const columns = process.stdout.columns ?? 100;
49863
+ if (drag.target === "terminal") {
49864
+ const nextWidth2 = drag.startWidth - (event.x - drag.startX);
49865
+ this.#state = setTerminalPaneWidth(this.#state, nextWidth2, maxTerminalPaneWidth(this.#state, columns));
49866
+ this.#queueRender();
49867
+ return true;
49868
+ }
49869
+ const nextWidth = drag.startWidth + (event.x - drag.startX);
49870
+ this.#state = setSidePanelWidth(this.#state, nextWidth, maxSidePanelWidth(columns));
49871
+ this.#queueRender();
49872
+ return true;
49873
+ }
49241
49874
  #handleSidePanelScrollbarDrag(event) {
49242
49875
  if (event.kind === "press" && (event.button & 3) === 0) {
49243
49876
  const track2 = this.#sidePanelTracks.find((t) => event.x === t.x && event.y >= t.yStart && event.y < t.yStart + t.viewportRows);
49244
- if (!track2)
49877
+ if (!track2) {
49878
+ this.#sidePanelDrag = null;
49245
49879
  return false;
49880
+ }
49246
49881
  const current3 = track2.panel === "topics" ? this.#state.topicsPanelScrollOffset : this.#state.taskPanelScrollOffset;
49247
49882
  const thumb = scrollbarThumb(track2.rowCount, track2.viewportRows, current3);
49248
49883
  this.#sidePanelDrag = {
@@ -49350,21 +49985,28 @@ class TerminalApp {
49350
49985
  #handleMouseSelection(event) {
49351
49986
  if ((event.button & 3) !== 0 && event.kind !== "release")
49352
49987
  return;
49353
- const point = { x: event.x, y: event.y };
49354
49988
  if (event.kind === "press") {
49989
+ const point = { x: event.x, y: event.y };
49355
49990
  const codeTarget = codeCopyTargetAt(this.#codeCopyTargets, point);
49356
49991
  if (codeTarget) {
49357
49992
  this.#selection = null;
49358
49993
  this.#copyCodeBlock(codeTarget.text);
49359
49994
  return;
49360
49995
  }
49361
- this.#selection = { anchor: point, focus: point };
49996
+ const bounds = this.#sideColumnBounds;
49997
+ const pane = this.#terminalPane;
49998
+ const conversation = this.#conversationBounds;
49999
+ const paneClip = bounds && point.x >= bounds.xStart && point.x <= bounds.xEnd ? { xStart: bounds.xStart, xEnd: bounds.xEnd } : pane && point.x >= pane.xStart && point.x <= pane.xEnd ? { xStart: pane.xStart, xEnd: pane.xEnd } : (bounds || pane) && conversation ? { xStart: conversation.xStart, xEnd: conversation.xEnd } : undefined;
50000
+ this.#selection = { anchor: point, focus: point, paneClip };
50001
+ this.#selectionDragging = true;
49362
50002
  this.#queueRender();
49363
50003
  return;
49364
50004
  }
50005
+ if (event.kind === "release")
50006
+ this.#selectionDragging = false;
49365
50007
  if (!this.#selection)
49366
50008
  return;
49367
- this.#selection = { ...this.#selection, focus: point };
50009
+ this.#selection = { ...this.#selection, focus: { x: event.x, y: event.y } };
49368
50010
  if (event.kind === "drag") {
49369
50011
  this.#queueRender();
49370
50012
  return;
@@ -49605,6 +50247,8 @@ class TerminalApp {
49605
50247
  this.#finishRun = null;
49606
50248
  }
49607
50249
  async#cleanup(clientStartAttempted, uiActive) {
50250
+ this.#shell?.dispose();
50251
+ this.#shell = null;
49608
50252
  this.#subagentGraphGeneration += 1;
49609
50253
  this.#subagentGraphAbortController?.abort();
49610
50254
  this.#subagentGraphAbortController = null;
@@ -49646,7 +50290,7 @@ class TerminalApp {
49646
50290
  await this.#client.stop();
49647
50291
  }
49648
50292
  }
49649
- var KITTY_KEYBOARD_PUSH = "\x1B[>1u", KITTY_KEYBOARD_POP = "\x1B[<u", CANVAS_RGB, ENTER_ALT_SCREEN, EXIT_ALT_SCREEN, ABORT_ENTER_ALT_SCREEN, NEW_TOPIC_KEY = "\x0E", DELETE_TOPIC_KEY = "\x04", FILTER_BACKSPACE_KEYS, CONFIRM_KEYS, CANCEL_KEYS, INPUT_CARRY_FLUSH_MS = 15;
50293
+ var KITTY_KEYBOARD_PUSH = "\x1B[>1u", KITTY_KEYBOARD_POP = "\x1B[<u", CANVAS_RGB, ENTER_ALT_SCREEN, EXIT_ALT_SCREEN, ABORT_ENTER_ALT_SCREEN, NEW_TOPIC_KEY = "\x0E", DELETE_TOPIC_KEY = "\x04", TERMINAL_PANE_KEY = "\x14", FILTER_BACKSPACE_KEYS, CONFIRM_KEYS, CANCEL_KEYS, INPUT_CARRY_FLUSH_MS = 15;
49650
50294
  var init_app = __esm(async () => {
49651
50295
  init_color_depth();
49652
50296
  init_commands();
@@ -49654,6 +50298,7 @@ var init_app = __esm(async () => {
49654
50298
  init_path_suggest();
49655
50299
  init_screen_renderer();
49656
50300
  init_selection();
50301
+ init_shell_pane();
49657
50302
  init_subagent_graph();
49658
50303
  init_terminal_restore();
49659
50304
  await __promiseAll([
@@ -53050,8 +53695,8 @@ var init_canonical_mcp_bridge = __esm(async () => {
53050
53695
  });
53051
53696
 
53052
53697
  // ../../adapters/otium/src/secure-transport.ts
53053
- function isLoopbackHostname(hostname2) {
53054
- const normalized = hostname2.toLowerCase();
53698
+ function isLoopbackHostname(hostname3) {
53699
+ const normalized = hostname3.toLowerCase();
53055
53700
  if (normalized === "localhost" || normalized === "::1" || normalized === "[::1]")
53056
53701
  return true;
53057
53702
  const octets = normalized.split(".");
@@ -56259,7 +56904,7 @@ __export(exports_join_cli, {
56259
56904
  localNodeNameDefault: () => localNodeNameDefault,
56260
56905
  joinCommand: () => joinCommand
56261
56906
  });
56262
- import { hostname as hostname2 } from "os";
56907
+ import { hostname as hostname3 } from "os";
56263
56908
  function option2(args, name) {
56264
56909
  const index = args.indexOf(`--${name}`);
56265
56910
  return index >= 0 ? args[index + 1]?.trim() : undefined;
@@ -56281,7 +56926,7 @@ function localNodeNameDefault() {
56281
56926
  if (normalized)
56282
56927
  return normalized;
56283
56928
  }
56284
- return normalizeNodeNameCandidate(hostname2());
56929
+ return normalizeNodeNameCandidate(hostname3());
56285
56930
  }
56286
56931
  async function confirmEnrollment(message2) {
56287
56932
  if (!process.stdin.isTTY)
@@ -59710,4 +60355,4 @@ switch (command) {
59710
60355
  }
59711
60356
  }
59712
60357
 
59713
- //# debugId=A04216FF3BF92ED864756E2164756E21
60358
+ //# debugId=3FFA808EE892362C64756E2164756E21