claudish 14.27.1 → 14.27.3

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 (2) hide show
  1. package/dist/index.js +1407 -671
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -5542,7 +5542,7 @@ var init_env_placeholder = __esm(() => {
5542
5542
  });
5543
5543
 
5544
5544
  // src/version.ts
5545
- var VERSION = "14.27.1";
5545
+ var VERSION = "14.27.3";
5546
5546
 
5547
5547
  // src/redact.ts
5548
5548
  function isPlaceholder(value) {
@@ -14145,7 +14145,7 @@ var init_bundled_recommended_list = __esm(() => {
14145
14145
  }
14146
14146
  }
14147
14147
  },
14148
- fetchedAt: "2026-11-16T12:10:44.345Z",
14148
+ fetchedAt: "2026-11-16T21:57:46.609Z",
14149
14149
  format: 1,
14150
14150
  recommendations: {
14151
14151
  contractVersion: 3,
@@ -14251,11 +14251,11 @@ var init_bundled_recommended_list = __esm(() => {
14251
14251
  tier: "luxury"
14252
14252
  }
14253
14253
  ],
14254
- generationId: "g-20261115161901457-250a0705"
14254
+ generationId: "g-20261116161706980-7c7c9818"
14255
14255
  },
14256
14256
  source: "https://us-central1-claudish-6da10.cloudfunctions.net"
14257
14257
  },
14258
- catalogGenerationId: "g-20261115161901457-250a0705",
14258
+ catalogGenerationId: "g-20261116161706980-7c7c9818",
14259
14259
  entries: [
14260
14260
  {
14261
14261
  aggregators: [
@@ -15022,8 +15022,8 @@ var init_bundled_recommended_list = __esm(() => {
15022
15022
  aliases: [
15023
15023
  "anthropic/claude-sonnet-5.5",
15024
15024
  "claude-sonnet-5.5",
15025
- "claude-sonnet-5-5-high",
15026
15025
  "claude-sonnet-5-5-medium",
15026
+ "claude-sonnet-5-5-high",
15027
15027
  "claude-sonnet-5-5-low",
15028
15028
  "claude-sonnet-5-5-max",
15029
15029
  "claude-sonnet-5-5-xhigh"
@@ -15287,9 +15287,9 @@ var init_bundled_recommended_list = __esm(() => {
15287
15287
  ],
15288
15288
  aliases: [
15289
15289
  "google/gemini-4-argon",
15290
- "gemini-4-argon-low",
15291
15290
  "gemini-4-argon-medium",
15292
- "gemini-4-argon-high"
15291
+ "gemini-4-argon-high",
15292
+ "gemini-4-argon-low"
15293
15293
  ],
15294
15294
  contextWindow: 1048576,
15295
15295
  contractVersion: 3,
@@ -15442,9 +15442,9 @@ var init_bundled_recommended_list = __esm(() => {
15442
15442
  ],
15443
15443
  aliases: [
15444
15444
  "google/gemini-4-carbon",
15445
- "gemini-4-carbon-high",
15445
+ "gemini-4-carbon-medium",
15446
15446
  "gemini-4-carbon-low",
15447
- "gemini-4-carbon-medium"
15447
+ "gemini-4-carbon-high"
15448
15448
  ],
15449
15449
  contextWindow: 1048576,
15450
15450
  contractVersion: 3,
@@ -15597,10 +15597,10 @@ var init_bundled_recommended_list = __esm(() => {
15597
15597
  ],
15598
15598
  aliases: [
15599
15599
  "google/gemini-4-hydrogen",
15600
- "gemini-4-hydrogen-high",
15601
- "gemini-4-hydrogen-low",
15600
+ "gemini-4-hydrogen-xhigh",
15602
15601
  "gemini-4-hydrogen-medium",
15603
- "gemini-4-hydrogen-xhigh"
15602
+ "gemini-4-hydrogen-high",
15603
+ "gemini-4-hydrogen-low"
15604
15604
  ],
15605
15605
  contextWindow: 1048576,
15606
15606
  contractVersion: 3,
@@ -15610,6 +15610,12 @@ var init_bundled_recommended_list = __esm(() => {
15610
15610
  api: "gemini"
15611
15611
  }
15612
15612
  },
15613
+ inputModalities: [
15614
+ "audio",
15615
+ "image",
15616
+ "text",
15617
+ "video"
15618
+ ],
15613
15619
  maxOutputTokens: 65536,
15614
15620
  modelId: "gemini-4-hydrogen",
15615
15621
  outputModalities: [
@@ -18266,7 +18272,7 @@ var init_bundled_recommended_list = __esm(() => {
18266
18272
  supportsVision: true
18267
18273
  }
18268
18274
  ],
18269
- lastUpdated: "2026-11-15T16:19:01.457Z",
18275
+ lastUpdated: "2026-11-16T16:17:06.980Z",
18270
18276
  models: [],
18271
18277
  plans: [
18272
18278
  {
@@ -19017,44 +19023,44 @@ var init_bundled_recommended_list = __esm(() => {
19017
19023
  id: "google-antigravity",
19018
19024
  inclusions: [
19019
19025
  {
19020
- externalModelId: "claude-sonnet-5-5-high",
19026
+ externalModelId: "gemini-4-argon-medium",
19021
19027
  kind: "provider_model",
19022
19028
  provider: "antigravity",
19023
19029
  resolution: {
19024
- modelId: "claude-sonnet-5-5",
19030
+ modelId: "gemini-4-argon",
19025
19031
  status: "mapped"
19026
19032
  },
19027
- sourceText: "claude-sonnet-5-5-high"
19033
+ sourceText: "gemini-4-argon-medium"
19028
19034
  },
19029
19035
  {
19030
- externalModelId: "gemini-4-hydrogen-high",
19036
+ externalModelId: "gemini-4-carbon-medium",
19031
19037
  kind: "provider_model",
19032
19038
  provider: "antigravity",
19033
19039
  resolution: {
19034
- modelId: "gemini-4-hydrogen",
19040
+ modelId: "gemini-4-carbon",
19035
19041
  status: "mapped"
19036
19042
  },
19037
- sourceText: "gemini-4-hydrogen-high"
19043
+ sourceText: "gemini-4-carbon-medium"
19038
19044
  },
19039
19045
  {
19040
- externalModelId: "gemini-4-hydrogen-low",
19046
+ externalModelId: "gemini-4-hydrogen-xhigh",
19041
19047
  kind: "provider_model",
19042
19048
  provider: "antigravity",
19043
19049
  resolution: {
19044
19050
  modelId: "gemini-4-hydrogen",
19045
19051
  status: "mapped"
19046
19052
  },
19047
- sourceText: "gemini-4-hydrogen-low"
19053
+ sourceText: "gemini-4-hydrogen-xhigh"
19048
19054
  },
19049
19055
  {
19050
- externalModelId: "gemini-4-carbon-high",
19056
+ externalModelId: "gemini-4-carbon-low",
19051
19057
  kind: "provider_model",
19052
19058
  provider: "antigravity",
19053
19059
  resolution: {
19054
19060
  modelId: "gemini-4-carbon",
19055
19061
  status: "mapped"
19056
19062
  },
19057
- sourceText: "gemini-4-carbon-high"
19063
+ sourceText: "gemini-4-carbon-low"
19058
19064
  },
19059
19065
  {
19060
19066
  externalModelId: "gemini-4-hydrogen-medium",
@@ -19067,74 +19073,74 @@ var init_bundled_recommended_list = __esm(() => {
19067
19073
  sourceText: "gemini-4-hydrogen-medium"
19068
19074
  },
19069
19075
  {
19070
- externalModelId: "claude-opus-5-5-low",
19076
+ externalModelId: "gemini-4-argon-high",
19071
19077
  kind: "provider_model",
19072
19078
  provider: "antigravity",
19073
19079
  resolution: {
19074
- modelId: "claude-opus-5-5",
19080
+ modelId: "gemini-4-argon",
19075
19081
  status: "mapped"
19076
19082
  },
19077
- sourceText: "claude-opus-5-5-low"
19083
+ sourceText: "gemini-4-argon-high"
19078
19084
  },
19079
19085
  {
19080
- externalModelId: "gemini-4-carbon-low",
19086
+ externalModelId: "claude-opus-5-5-low",
19081
19087
  kind: "provider_model",
19082
19088
  provider: "antigravity",
19083
19089
  resolution: {
19084
- modelId: "gemini-4-carbon",
19090
+ modelId: "claude-opus-5-5",
19085
19091
  status: "mapped"
19086
19092
  },
19087
- sourceText: "gemini-4-carbon-low"
19093
+ sourceText: "claude-opus-5-5-low"
19088
19094
  },
19089
19095
  {
19090
- externalModelId: "gemini-4-hydrogen-xhigh",
19096
+ externalModelId: "gemini-4-argon-low",
19091
19097
  kind: "provider_model",
19092
19098
  provider: "antigravity",
19093
19099
  resolution: {
19094
- modelId: "gemini-4-hydrogen",
19100
+ modelId: "gemini-4-argon",
19095
19101
  status: "mapped"
19096
19102
  },
19097
- sourceText: "gemini-4-hydrogen-xhigh"
19103
+ sourceText: "gemini-4-argon-low"
19098
19104
  },
19099
19105
  {
19100
- externalModelId: "gemini-4-argon-low",
19106
+ externalModelId: "gemini-4-carbon-high",
19101
19107
  kind: "provider_model",
19102
19108
  provider: "antigravity",
19103
19109
  resolution: {
19104
- modelId: "gemini-4-argon",
19110
+ modelId: "gemini-4-carbon",
19105
19111
  status: "mapped"
19106
19112
  },
19107
- sourceText: "gemini-4-argon-low"
19113
+ sourceText: "gemini-4-carbon-high"
19108
19114
  },
19109
19115
  {
19110
- externalModelId: "gemini-4-argon-medium",
19116
+ externalModelId: "claude-sonnet-5-5-medium",
19111
19117
  kind: "provider_model",
19112
19118
  provider: "antigravity",
19113
19119
  resolution: {
19114
- modelId: "gemini-4-argon",
19120
+ modelId: "claude-sonnet-5-5",
19115
19121
  status: "mapped"
19116
19122
  },
19117
- sourceText: "gemini-4-argon-medium"
19123
+ sourceText: "claude-sonnet-5-5-medium"
19118
19124
  },
19119
19125
  {
19120
- externalModelId: "gemini-4-carbon-medium",
19126
+ externalModelId: "gemini-4-hydrogen-high",
19121
19127
  kind: "provider_model",
19122
19128
  provider: "antigravity",
19123
19129
  resolution: {
19124
- modelId: "gemini-4-carbon",
19130
+ modelId: "gemini-4-hydrogen",
19125
19131
  status: "mapped"
19126
19132
  },
19127
- sourceText: "gemini-4-carbon-medium"
19133
+ sourceText: "gemini-4-hydrogen-high"
19128
19134
  },
19129
19135
  {
19130
- externalModelId: "claude-sonnet-5-5-medium",
19136
+ externalModelId: "claude-sonnet-5-5-high",
19131
19137
  kind: "provider_model",
19132
19138
  provider: "antigravity",
19133
19139
  resolution: {
19134
19140
  modelId: "claude-sonnet-5-5",
19135
19141
  status: "mapped"
19136
19142
  },
19137
- sourceText: "claude-sonnet-5-5-medium"
19143
+ sourceText: "claude-sonnet-5-5-high"
19138
19144
  },
19139
19145
  {
19140
19146
  externalModelId: "claude-sonnet-5-5-low",
@@ -19147,24 +19153,24 @@ var init_bundled_recommended_list = __esm(() => {
19147
19153
  sourceText: "claude-sonnet-5-5-low"
19148
19154
  },
19149
19155
  {
19150
- externalModelId: "claude-opus-5-5-medium",
19156
+ externalModelId: "gemini-4-hydrogen-low",
19151
19157
  kind: "provider_model",
19152
19158
  provider: "antigravity",
19153
19159
  resolution: {
19154
- modelId: "claude-opus-5-5",
19160
+ modelId: "gemini-4-hydrogen",
19155
19161
  status: "mapped"
19156
19162
  },
19157
- sourceText: "claude-opus-5-5-medium"
19163
+ sourceText: "gemini-4-hydrogen-low"
19158
19164
  },
19159
19165
  {
19160
- externalModelId: "gemini-4-argon-high",
19166
+ externalModelId: "claude-opus-5-5-medium",
19161
19167
  kind: "provider_model",
19162
19168
  provider: "antigravity",
19163
19169
  resolution: {
19164
- modelId: "gemini-4-argon",
19170
+ modelId: "claude-opus-5-5",
19165
19171
  status: "mapped"
19166
19172
  },
19167
- sourceText: "gemini-4-argon-high"
19173
+ sourceText: "claude-opus-5-5-medium"
19168
19174
  },
19169
19175
  {
19170
19176
  externalModelId: "claude-opus-5-5-high",
@@ -19508,34 +19514,34 @@ var init_bundled_recommended_list = __esm(() => {
19508
19514
  id: "ollama-cloud",
19509
19515
  inclusions: [
19510
19516
  {
19511
- externalModelId: "mimo-v2.6-flash",
19517
+ externalModelId: "glm-5.3-flash",
19512
19518
  kind: "provider_model",
19513
19519
  provider: "ollamacloud",
19514
19520
  resolution: {
19515
- modelId: "mimo-v2.6-flash",
19521
+ modelId: "glm-5.3-flash",
19516
19522
  status: "mapped"
19517
19523
  },
19518
- sourceText: "mimo-v2.6-flash"
19524
+ sourceText: "glm-5.3-flash"
19519
19525
  },
19520
19526
  {
19521
- externalModelId: "glm-5.3-flash",
19527
+ externalModelId: "kimi-k3.1-pro",
19522
19528
  kind: "provider_model",
19523
19529
  provider: "ollamacloud",
19524
19530
  resolution: {
19525
- modelId: "glm-5.3-flash",
19531
+ modelId: "kimi-k3.1-pro",
19526
19532
  status: "mapped"
19527
19533
  },
19528
- sourceText: "glm-5.3-flash"
19534
+ sourceText: "kimi-k3.1-pro"
19529
19535
  },
19530
19536
  {
19531
- externalModelId: "glm-5.3",
19537
+ externalModelId: "minimax-m3.1-flash",
19532
19538
  kind: "provider_model",
19533
19539
  provider: "ollamacloud",
19534
19540
  resolution: {
19535
- modelId: "glm-5.3",
19541
+ modelId: "minimax-m3.1-flash",
19536
19542
  status: "mapped"
19537
19543
  },
19538
- sourceText: "glm-5.3"
19544
+ sourceText: "minimax-m3.1-flash"
19539
19545
  },
19540
19546
  {
19541
19547
  externalModelId: "deepseek-v4.1-flash",
@@ -19548,34 +19554,34 @@ var init_bundled_recommended_list = __esm(() => {
19548
19554
  sourceText: "deepseek-v4.1-flash"
19549
19555
  },
19550
19556
  {
19551
- externalModelId: "minimax-m3.1-flash",
19557
+ externalModelId: "mimo-v2.6-flash",
19552
19558
  kind: "provider_model",
19553
19559
  provider: "ollamacloud",
19554
19560
  resolution: {
19555
- modelId: "minimax-m3.1-flash",
19561
+ modelId: "mimo-v2.6-flash",
19556
19562
  status: "mapped"
19557
19563
  },
19558
- sourceText: "minimax-m3.1-flash"
19564
+ sourceText: "mimo-v2.6-flash"
19559
19565
  },
19560
19566
  {
19561
- externalModelId: "kimi-k3.1-pro",
19567
+ externalModelId: "mimo-v2.6-pro",
19562
19568
  kind: "provider_model",
19563
19569
  provider: "ollamacloud",
19564
19570
  resolution: {
19565
- modelId: "kimi-k3.1-pro",
19571
+ modelId: "mimo-v2.6-pro",
19566
19572
  status: "mapped"
19567
19573
  },
19568
- sourceText: "kimi-k3.1-pro"
19574
+ sourceText: "mimo-v2.6-pro"
19569
19575
  },
19570
19576
  {
19571
- externalModelId: "mimo-v2.6-pro",
19577
+ externalModelId: "glm-5.3",
19572
19578
  kind: "provider_model",
19573
19579
  provider: "ollamacloud",
19574
19580
  resolution: {
19575
- modelId: "mimo-v2.6-pro",
19581
+ modelId: "glm-5.3",
19576
19582
  status: "mapped"
19577
19583
  },
19578
- sourceText: "mimo-v2.6-pro"
19584
+ sourceText: "glm-5.3"
19579
19585
  }
19580
19586
  ],
19581
19587
  modelDiscovery: "catalog",
@@ -19830,7 +19836,7 @@ var init_bundled_recommended_list = __esm(() => {
19830
19836
  }
19831
19837
  ],
19832
19838
  routeRegistry: {
19833
- generationId: "g-20261115161901457-250a0705",
19839
+ generationId: "g-20261116161706980-7c7c9818",
19834
19840
  registry: {
19835
19841
  contractVersion: 3,
19836
19842
  registryVersion: "3.7.0",
@@ -21107,6 +21113,21 @@ function readModelIdEffort(raw) {
21107
21113
  map.baseServed = record.baseServed;
21108
21114
  return map;
21109
21115
  }
21116
+ function publishedEffortWireId(connection, requested) {
21117
+ const map = readModelIdEffort(connection.modelIdEffort);
21118
+ if (!map)
21119
+ return;
21120
+ const ids = [...Object.values(map.values), ...map.off ? [map.off] : []];
21121
+ if (ids.includes(requested))
21122
+ return requested;
21123
+ const lowered = requested.toLowerCase();
21124
+ const spellings = new Set(ids.filter((id) => id.toLowerCase() === lowered));
21125
+ return spellings.size === 1 ? [...spellings][0] : undefined;
21126
+ }
21127
+ function implicitEffortWireId(connection, requested) {
21128
+ const id = publishedEffortWireId(connection, requested);
21129
+ return id !== undefined && !isOptInWireId(id) ? id : undefined;
21130
+ }
21110
21131
  function asRecord(value) {
21111
21132
  return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
21112
21133
  }
@@ -21129,10 +21150,10 @@ function mapIdForEffort(map, effort) {
21129
21150
  return map.values[chosen];
21130
21151
  }
21131
21152
  function chooseModelIdForEffort(map, effort, provider) {
21132
- if (effort === "none")
21133
- return map.off ? provider.sendable(map.off) : undefined;
21134
- const id = mapIdForEffort(map, effort);
21135
- return id ? provider.sendable(id) : undefined;
21153
+ const id = effort === "none" ? map.off : mapIdForEffort(map, effort);
21154
+ if (!id || isOptInWireId(id))
21155
+ return;
21156
+ return provider.sendable(id);
21136
21157
  }
21137
21158
  var SPEED_PREMIUM_SUFFIXES;
21138
21159
  var init_model_id_effort = __esm(() => {
@@ -21336,7 +21357,12 @@ function resolveSubscriptionRouting(modelId, provider, cachePath) {
21336
21357
  if (included.length !== plans.length)
21337
21358
  return { kind: "unknown" };
21338
21359
  const connection = entry.aggregators?.find((candidate) => candidate.routeStatus === "mapped" && catalogRouteMatchesProvider(candidate.route, provider));
21339
- return connection?.externalModelId ? { kind: "serves", externalId: connection.externalModelId } : { kind: "unknown" };
21360
+ if (!connection?.externalModelId)
21361
+ return { kind: "unknown" };
21362
+ return {
21363
+ kind: "serves",
21364
+ externalId: implicitEffortWireId(connection, modelId) ?? connection.externalModelId
21365
+ };
21340
21366
  }
21341
21367
  if (plans.some((plan) => plan.modelDiscovery !== "catalog"))
21342
21368
  return { kind: "unknown" };
@@ -34044,7 +34070,7 @@ function resolveProbeModel() {
34044
34070
  const cache = JSON.parse(readFileSync15(cachePath, "utf-8"));
34045
34071
  for (const m of cache.models ?? []) {
34046
34072
  const slug = m?.slug ?? m?.id;
34047
- if (typeof slug === "string" && slug.length > 0)
34073
+ if (typeof slug === "string" && slug.length > 0 && !isOptInWireId(slug))
34048
34074
  return slug;
34049
34075
  }
34050
34076
  } catch {}
@@ -34825,6 +34851,73 @@ var init_antigravity_fetch = __esm(() => {
34825
34851
  ]);
34826
34852
  });
34827
34853
 
34854
+ // src/auth/antigravity-side-calls.ts
34855
+ function antigravityAccountCalls(account) {
34856
+ const body = JSON.stringify({ project: account.projectId });
34857
+ const internal = (name) => ({
34858
+ name,
34859
+ url: `${account.apiBase}:${name}`,
34860
+ userAgent: account.userAgent,
34861
+ body
34862
+ });
34863
+ const calls = [];
34864
+ if (account.defaultHost) {
34865
+ calls.push({
34866
+ name: "userinfo",
34867
+ url: GOOGLE_USERINFO_URL,
34868
+ userAgent: GOOGLE_USERINFO_USER_AGENT
34869
+ });
34870
+ }
34871
+ calls.push(internal("fetchAdminControls"), internal("fetchUserInfo"), internal("retrieveUserQuotaSummary"), internal("listExperiments"));
34872
+ if (account.defaultHost) {
34873
+ calls.push({ name: "fetchConfig", url: ANTIGRAVITY_CONFIG_URL, userAgent: account.userAgent });
34874
+ }
34875
+ return calls;
34876
+ }
34877
+ function antigravityTrajectoryAclCall(account, trajectoryId) {
34878
+ return {
34879
+ name: "writeTrajectoryAcls",
34880
+ url: `${account.apiBase}:writeTrajectoryAcls`,
34881
+ userAgent: account.userAgent,
34882
+ body: JSON.stringify({ trajectoryId })
34883
+ };
34884
+ }
34885
+ async function sendAntigravitySideCall(call, accessToken, timeoutMs = ANTIGRAVITY_SIDE_CALL_TIMEOUT_MS, abort) {
34886
+ const headers = {
34887
+ Authorization: `Bearer ${accessToken}`,
34888
+ "User-Agent": call.userAgent
34889
+ };
34890
+ if (call.body !== undefined)
34891
+ headers["Content-Type"] = "application/json";
34892
+ const lease = acquireSigningLease();
34893
+ lease.add([accessToken]);
34894
+ try {
34895
+ const res = await antigravityFetch(call.url, {
34896
+ method: call.body === undefined ? "GET" : "POST",
34897
+ headers,
34898
+ ...call.body === undefined ? {} : { body: call.body },
34899
+ signal: abort ? AbortSignal.any([abort, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs)
34900
+ });
34901
+ await res.arrayBuffer();
34902
+ if (!res.ok)
34903
+ log(`[Antigravity] ${call.name} answered ${res.status}`);
34904
+ } catch (err) {
34905
+ log(`[Antigravity] ${call.name} error: ${err}`);
34906
+ } finally {
34907
+ lease.release();
34908
+ }
34909
+ }
34910
+ async function sendAntigravitySideCalls(calls, accessToken, timeoutMs = ANTIGRAVITY_SIDE_CALL_TIMEOUT_MS) {
34911
+ for (const call of calls)
34912
+ await sendAntigravitySideCall(call, accessToken, timeoutMs);
34913
+ }
34914
+ var GOOGLE_USERINFO_URL = "https://www.googleapis.com/oauth2/v2/userinfo", GOOGLE_USERINFO_USER_AGENT = "Go-http-client/1.1", ANTIGRAVITY_CONFIG_URL = "https://aicode.googleapis.com/v1alpha:fetchConfig", ANTIGRAVITY_SIDE_CALL_TIMEOUT_MS = 1e4;
34915
+ var init_antigravity_side_calls = __esm(() => {
34916
+ init_logger();
34917
+ init_antigravity_fetch();
34918
+ init_redact();
34919
+ });
34920
+
34828
34921
  // src/auth/antigravity-user.ts
34829
34922
  function antigravityHost() {
34830
34923
  const override = process.env.AICODE_ENDPOINT_URL?.trim();
@@ -34864,6 +34957,7 @@ function resetAntigravityUserCache() {
34864
34957
  agServedCacheAt = 0;
34865
34958
  agServedCacheVersion = null;
34866
34959
  cachedAgLineage = null;
34960
+ accountCallsSentFor = undefined;
34867
34961
  }
34868
34962
  function syncAccountCaches() {
34869
34963
  const lineage = currentAntigravityTokenLineage();
@@ -34875,6 +34969,17 @@ function syncAccountCaches() {
34875
34969
  resetAntigravityUserCache();
34876
34970
  cachedAgLineage = lineage;
34877
34971
  }
34972
+ function startAccountCalls(accessToken, projectId, lineage) {
34973
+ if (accountCallsSentFor === lineage)
34974
+ return;
34975
+ accountCallsSentFor = lineage;
34976
+ sendAntigravitySideCalls(antigravityAccountCalls({
34977
+ apiBase: apiBase(),
34978
+ defaultHost: antigravityHost() === ANTIGRAVITY_DEFAULT_HOST,
34979
+ userAgent: buildAntigravityUserAgent(),
34980
+ projectId
34981
+ }), accessToken);
34982
+ }
34878
34983
  function lineageOfToken(accessToken) {
34879
34984
  return lineageForAntigravityAccessToken(accessToken) ?? currentAntigravityTokenLineage();
34880
34985
  }
@@ -34920,6 +35025,7 @@ async function setupAntigravityUser(accessToken) {
34920
35025
  log("[Antigravity] Token lineage changed during setup; the result is not cached.");
34921
35026
  }
34922
35027
  log(`[Antigravity] User set up, project: ${projectId}, tier: ${resolvedTier}`);
35028
+ startAccountCalls(accessToken, projectId, lineage);
34923
35029
  return { projectId, tierId: resolvedTier };
34924
35030
  }
34925
35031
  function getAntigravityTierDisplayName() {
@@ -34935,9 +35041,9 @@ function getAntigravityTierDisplayName() {
34935
35041
  return "Antigravity Free";
34936
35042
  return cachedAgTierName || "Antigravity";
34937
35043
  }
34938
- async function retrieveUserQuota(accessToken, projectId) {
35044
+ async function retrieveUserQuotaSummary(accessToken, projectId) {
34939
35045
  try {
34940
- const res = await antigravityFetch(`${apiBase()}:retrieveUserQuota`, {
35046
+ const res = await antigravityFetch(`${apiBase()}:retrieveUserQuotaSummary`, {
34941
35047
  method: "POST",
34942
35048
  headers: {
34943
35049
  Authorization: `Bearer ${accessToken}`,
@@ -34947,14 +35053,36 @@ async function retrieveUserQuota(accessToken, projectId) {
34947
35053
  body: JSON.stringify({ project: projectId })
34948
35054
  });
34949
35055
  if (!res.ok) {
34950
- log(`[Antigravity] retrieveUserQuota failed: ${res.status}`);
35056
+ log(`[Antigravity] retrieveUserQuotaSummary failed: ${res.status}`);
34951
35057
  return null;
34952
35058
  }
34953
35059
  return await res.json();
34954
35060
  } catch (err) {
34955
- log(`[Antigravity] retrieveUserQuota error: ${err}`);
35061
+ log(`[Antigravity] retrieveUserQuotaSummary error: ${err}`);
35062
+ return null;
35063
+ }
35064
+ }
35065
+ async function retrieveModelQuota(accessToken, projectId, opts) {
35066
+ const raw = await fetchAntigravityAvailableModelsRaw(accessToken, projectId, opts);
35067
+ if (raw.kind !== "answered" || raw.body.kind !== "json") {
35068
+ log(`[Antigravity] model quota not read: ${raw.kind === "answered" ? raw.status : "unreachable"}`);
34956
35069
  return null;
34957
35070
  }
35071
+ const models = raw.body.value?.models ?? {};
35072
+ const buckets = [];
35073
+ for (const [modelId, record] of Object.entries(models)) {
35074
+ const quota = record?.quotaInfo;
35075
+ if (!quota)
35076
+ continue;
35077
+ const bucket = { modelId };
35078
+ if (typeof quota.remainingFraction === "number") {
35079
+ bucket.remainingFraction = quota.remainingFraction;
35080
+ }
35081
+ if (typeof quota.resetTime === "string")
35082
+ bucket.resetTime = quota.resetTime;
35083
+ buckets.push(bucket);
35084
+ }
35085
+ return { buckets };
34958
35086
  }
34959
35087
  function flattenAgentModelSorts(sorts) {
34960
35088
  if (!Array.isArray(sorts))
@@ -35112,10 +35240,11 @@ function peekServedAntigravityModels() {
35112
35240
  return null;
35113
35241
  return agServedCache;
35114
35242
  }
35115
- var ANTIGRAVITY_DEFAULT_HOST = "https://daily-cloudcode-pa.googleapis.com", SERVED_MODELS_TTL_MS, ANTIGRAVITY_IDE_TYPE = "ANTIGRAVITY", AGY_FALLBACK_CLIENT_VERSION = "1.1.9", cachedAgProjectId = null, cachedAgTierId = null, cachedAgTierName = null, cachedAgLineage = null, agServedCache = null, agServedCacheAt = 0, agServedCacheVersion = null;
35243
+ var ANTIGRAVITY_DEFAULT_HOST = "https://daily-cloudcode-pa.googleapis.com", SERVED_MODELS_TTL_MS, ANTIGRAVITY_IDE_TYPE = "ANTIGRAVITY", AGY_FALLBACK_CLIENT_VERSION = "1.1.9", cachedAgProjectId = null, cachedAgTierId = null, cachedAgTierName = null, cachedAgLineage = null, accountCallsSentFor, agServedCache = null, agServedCacheAt = 0, agServedCacheVersion = null;
35116
35244
  var init_antigravity_user = __esm(() => {
35117
35245
  init_logger();
35118
35246
  init_antigravity_fetch();
35247
+ init_antigravity_side_calls();
35119
35248
  init_antigravity_token();
35120
35249
  SERVED_MODELS_TTL_MS = 10 * 60 * 1000;
35121
35250
  });
@@ -35145,7 +35274,12 @@ function selectBucket(buckets, activeModelId) {
35145
35274
  if (match)
35146
35275
  return match;
35147
35276
  }
35148
- return;
35277
+ const variants = usable.filter((b) => REASONING_TIERS.some((tier) => b.modelId === `${activeModelId}-${tier}`));
35278
+ if (variants.length === 0)
35279
+ return;
35280
+ const [first] = variants;
35281
+ const same = variants.every((b) => b.remainingFraction === first.remainingFraction && b.resetTime === first.resetTime);
35282
+ return same ? { ...first, modelId: activeModelId } : undefined;
35149
35283
  }
35150
35284
  function windowFromBucket(bucket) {
35151
35285
  const used = usedPctOf(bucket);
@@ -35207,14 +35341,44 @@ function planFromBuckets(buckets, activeModelId) {
35207
35341
  observed_at: new Date().toISOString()
35208
35342
  };
35209
35343
  }
35344
+ function planFromSummary(groups) {
35345
+ const windows = [];
35346
+ for (const group of groups) {
35347
+ for (const bucket of group.buckets ?? []) {
35348
+ const used = usedPctOf(bucket);
35349
+ if (used === undefined)
35350
+ continue;
35351
+ const name = [group.displayName, bucket.window].filter(Boolean).join(" ");
35352
+ const window2 = { id: name || bucket.bucketId || "quota", used_pct: used };
35353
+ if (bucket.resetTime && !Number.isNaN(Date.parse(bucket.resetTime))) {
35354
+ window2.resets_at = new Date(bucket.resetTime).toISOString();
35355
+ }
35356
+ windows.push(window2);
35357
+ }
35358
+ }
35359
+ if (windows.length === 0)
35360
+ return;
35361
+ return {
35362
+ label: getAntigravityTierDisplayName(),
35363
+ windows,
35364
+ source: "provider",
35365
+ observed_at: new Date().toISOString()
35366
+ };
35367
+ }
35210
35368
  async function fetchPlan(ctx) {
35211
35369
  try {
35212
35370
  const accessToken = await getValidAntigravityAccessToken();
35213
35371
  const { projectId } = await setupAntigravityUser(accessToken);
35214
- const quota = await retrieveUserQuota(accessToken, projectId);
35215
- if (!quota?.buckets?.length)
35372
+ if (!ctx?.modelId) {
35373
+ const summary = await retrieveUserQuotaSummary(accessToken, projectId);
35374
+ if (!summary?.groups?.length)
35375
+ return;
35376
+ return planFromSummary(summary.groups);
35377
+ }
35378
+ const quota = await retrieveModelQuota(accessToken, projectId);
35379
+ if (!quota?.buckets.length)
35216
35380
  return;
35217
- return planFromBuckets(quota.buckets, ctx?.modelId);
35381
+ return planFromBuckets(quota.buckets, ctx.modelId);
35218
35382
  } catch (err) {
35219
35383
  log(`[quota:antigravity] fetch failed: ${err}`);
35220
35384
  return;
@@ -44677,7 +44841,7 @@ async function resolveObserverModel(config) {
44677
44841
  return cachedModel;
44678
44842
  try {
44679
44843
  const models = await fetchOllamaModels({ enrichCapabilities: false });
44680
- const usable = models.filter((m) => !m.isEmbeddingModel && isGenuinelyLocal(m));
44844
+ const usable = models.filter((m) => !m.isEmbeddingModel && isGenuinelyLocal(m) && !isOptInWireId(m.name));
44681
44845
  if (usable.length === 0) {
44682
44846
  log("[hooks:observer] No local Ollama models found \u2014 observer disabled for this run");
44683
44847
  cachedModel = null;
@@ -49642,6 +49806,164 @@ function decideCodexSpeed(speed, modelInfo) {
49642
49806
  }
49643
49807
  var CODEX_SERVICE_TIER_POINTER = "/service_tier";
49644
49808
 
49809
+ // src/providers/antigravity-content.ts
49810
+ function agyLocalTime(date) {
49811
+ const two = (n) => String(n).padStart(2, "0");
49812
+ const offset = -date.getTimezoneOffset();
49813
+ const sign = offset < 0 ? "-" : "+";
49814
+ const zone = offset === 0 ? "Z" : `${sign}${two(Math.floor(Math.abs(offset) / 60))}:${two(Math.abs(offset) % 60)}`;
49815
+ return `${date.getFullYear()}-${two(date.getMonth() + 1)}-${two(date.getDate())}` + `T${two(date.getHours())}:${two(date.getMinutes())}:${two(date.getSeconds())}${zone}`;
49816
+ }
49817
+ function agyUserRequest(text, time, model) {
49818
+ const blocks = [
49819
+ `<USER_REQUEST>
49820
+ ${text}
49821
+ </USER_REQUEST>`,
49822
+ `<ADDITIONAL_METADATA>
49823
+ The current local time is: ${time}.
49824
+ </ADDITIONAL_METADATA>`
49825
+ ];
49826
+ if (model) {
49827
+ blocks.push(`<USER_SETTINGS_CHANGE>
49828
+ The user changed setting \`Model Selection\` from None to ${model}. No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.
49829
+ </USER_SETTINGS_CHANGE>`);
49830
+ }
49831
+ return blocks.join(`
49832
+ `);
49833
+ }
49834
+ function isHarnessText(text) {
49835
+ return text.trimStart().startsWith("<system-reminder>");
49836
+ }
49837
+ function readFileBody(text, args) {
49838
+ const lines = text.split(`
49839
+ `);
49840
+ const whole = args !== null && args.StartLine === undefined && args.EndLine === undefined;
49841
+ if (whole && lines.length > 1 && /^\s*\d+\t$/.test(lines[lines.length - 1]))
49842
+ lines.pop();
49843
+ const numbered = [];
49844
+ for (const line of lines) {
49845
+ const match = NUMBERED_LINE.exec(line);
49846
+ if (!match)
49847
+ return text;
49848
+ numbered.push([Number(match[1]), match[2]]);
49849
+ }
49850
+ if (numbered.length === 0)
49851
+ return text;
49852
+ const body = numbered.map(([n, content]) => `${n}: ${content}`).join(`
49853
+ `);
49854
+ if (!whole || numbered[0][0] !== 1 || numbered.length >= READ_DEFAULT_LINES)
49855
+ return body;
49856
+ const last = numbered[numbered.length - 1][0];
49857
+ return `Showing lines 1-${last} of ${last}
49858
+ ${body}`;
49859
+ }
49860
+ function agyToolResult(tool, text, args, time) {
49861
+ if (!Object.hasOwn(RESULT_BODY, tool))
49862
+ return null;
49863
+ const body = RESULT_BODY[tool];
49864
+ return `Created At: ${time}
49865
+ Completed At: ${time}
49866
+ ${body(text, args)}`;
49867
+ }
49868
+ function agyWordedTools(tools) {
49869
+ const found = new Set;
49870
+ if (!Array.isArray(tools))
49871
+ return found;
49872
+ for (const entry of tools) {
49873
+ const declarations = entry?.functionDeclarations;
49874
+ if (!Array.isArray(declarations))
49875
+ continue;
49876
+ for (const declaration of declarations) {
49877
+ const name = declaration?.name;
49878
+ if (typeof name !== "string" || !(name in AGY_ARGUMENT))
49879
+ continue;
49880
+ const schema = declaration.parameters ?? declaration.parametersJsonSchema;
49881
+ if (schema?.properties && AGY_ARGUMENT[name] in schema.properties)
49882
+ found.add(name);
49883
+ }
49884
+ }
49885
+ return found;
49886
+ }
49887
+ function shapeUserEntry(content, index, options) {
49888
+ const parts = content.parts ?? [];
49889
+ const isRequest = (part) => typeof part.text === "string" && !isHarnessText(part.text);
49890
+ if (!parts.some(isRequest))
49891
+ return content;
49892
+ const time = options.timeOf(`user:${index}`);
49893
+ const out = [];
49894
+ let run = [];
49895
+ let first = true;
49896
+ const closeRun = () => {
49897
+ if (run.length === 0)
49898
+ return;
49899
+ const text = run.map((part) => part.text).join(`
49900
+ `);
49901
+ const model = first && index === 0 ? options.modelDisplayName : undefined;
49902
+ out.push({ ...run[0], text: agyUserRequest(text, time, model) });
49903
+ run = [];
49904
+ first = false;
49905
+ };
49906
+ for (const part of parts) {
49907
+ if (isRequest(part)) {
49908
+ run.push(part);
49909
+ } else {
49910
+ closeRun();
49911
+ out.push(part);
49912
+ }
49913
+ }
49914
+ closeRun();
49915
+ return { ...content, parts: out };
49916
+ }
49917
+ function agyContents(contents, options) {
49918
+ if (!Array.isArray(contents))
49919
+ return contents;
49920
+ const callArgs = new Map;
49921
+ for (const content of contents) {
49922
+ for (const part of content?.parts ?? []) {
49923
+ const call = part?.functionCall;
49924
+ if (call && typeof call.id === "string" && call.args && typeof call.args === "object") {
49925
+ callArgs.set(call.id, call.args);
49926
+ }
49927
+ }
49928
+ }
49929
+ return contents.map((content, index) => {
49930
+ if (!content || content.role !== "user" || !Array.isArray(content.parts))
49931
+ return content;
49932
+ let results = 0;
49933
+ const parts = content.parts.map((part) => {
49934
+ const result = part?.functionResponse;
49935
+ const output = result?.response?.output;
49936
+ if (!result || typeof result.name !== "string" || typeof output !== "string")
49937
+ return part;
49938
+ if (!options.wordedTools.has(result.name))
49939
+ return part;
49940
+ const id = typeof result.id === "string" ? result.id : `${index}:${results}`;
49941
+ results += 1;
49942
+ const text = agyToolResult(result.name, output, callArgs.get(id) ?? null, options.timeOf(`result:${id}`));
49943
+ if (text === null)
49944
+ return part;
49945
+ return { ...part, functionResponse: { ...result, response: { output: text } } };
49946
+ });
49947
+ return shapeUserEntry({ ...content, parts }, index, options);
49948
+ });
49949
+ }
49950
+ var NUMBERED_LINE, READ_DEFAULT_LINES = 2000, RESULT_BODY, AGY_ARGUMENT;
49951
+ var init_antigravity_content = __esm(() => {
49952
+ NUMBERED_LINE = /^\s*(\d+)\t(.*)$/;
49953
+ RESULT_BODY = {
49954
+ run_command: (text) => text,
49955
+ read_file: readFileBody,
49956
+ write_file: (text) => text.startsWith("File created successfully at:") ? "Created file." : text,
49957
+ edit_file: (text) => text
49958
+ };
49959
+ AGY_ARGUMENT = {
49960
+ run_command: "CommandLine",
49961
+ read_file: "Path",
49962
+ write_file: "Content",
49963
+ edit_file: "Target"
49964
+ };
49965
+ });
49966
+
49645
49967
  // src/providers/antigravity-envelope.ts
49646
49968
  import { createHash as createHash13, randomBytes as randomBytes7, randomUUID as randomUUID3 } from "crypto";
49647
49969
 
@@ -49649,6 +49971,7 @@ class AntigravityConversations {
49649
49971
  limit;
49650
49972
  newId;
49651
49973
  byFirstMessage = new Map;
49974
+ newTrajectories = new Set;
49652
49975
  sessionId;
49653
49976
  constructor(limit = 64, newId = randomUUID3, sessionId = randomSessionId()) {
49654
49977
  this.limit = limit;
@@ -49666,13 +49989,30 @@ ${firstMessageKey(inner)}`;
49666
49989
  }
49667
49990
  const created = { cascadeId: this.newId(), trajectoryId: this.newId(), requestCount: 0 };
49668
49991
  this.byFirstMessage.set(key, created);
49992
+ this.newTrajectories.add(created.trajectoryId);
49669
49993
  if (this.byFirstMessage.size > this.limit) {
49670
49994
  const oldest = this.byFirstMessage.keys().next().value;
49671
- if (oldest !== undefined)
49995
+ if (oldest !== undefined) {
49996
+ const dropped = this.byFirstMessage.get(oldest);
49997
+ if (dropped)
49998
+ this.newTrajectories.delete(dropped.trajectoryId);
49672
49999
  this.byFirstMessage.delete(oldest);
50000
+ }
49673
50001
  }
49674
50002
  return created;
49675
50003
  }
50004
+ takeNewTrajectoryIn(body) {
50005
+ for (const id of this.newTrajectories) {
50006
+ if (!body.includes(id))
50007
+ continue;
50008
+ this.newTrajectories.delete(id);
50009
+ return id;
50010
+ }
50011
+ return null;
50012
+ }
50013
+ clearNewTrajectories() {
50014
+ this.newTrajectories.clear();
50015
+ }
49676
50016
  }
49677
50017
  function randomSessionId() {
49678
50018
  return randomBytes7(8).readBigInt64BE().toString();
@@ -49758,7 +50098,22 @@ function buildAntigravityEnvelope(input) {
49758
50098
  ...others
49759
50099
  } = inner;
49760
50100
  const stepIndex = lastStepIndex(contents);
49761
- const request = { contents: toolResultsAsModelEntries(contents) };
50101
+ const now = agyLocalTime(new Date(input.now ?? Date.now()));
50102
+ conversation.times ??= new Map;
50103
+ const times = conversation.times;
50104
+ conversation.firstModelDisplayName ??= meta?.displayName;
50105
+ const worded = agyContents(contents, {
50106
+ timeOf: (key) => {
50107
+ const known = times.get(key);
50108
+ if (known !== undefined)
50109
+ return known;
50110
+ times.set(key, now);
50111
+ return now;
50112
+ },
50113
+ modelDisplayName: conversation.firstModelDisplayName,
50114
+ wordedTools: agyWordedTools(tools)
50115
+ });
50116
+ const request = { contents: toolResultsAsModelEntries(worded) };
49762
50117
  if (systemInstruction && typeof systemInstruction === "object") {
49763
50118
  const { role: _role, ...instruction } = systemInstruction;
49764
50119
  request.systemInstruction = { role: "user", ...instruction };
@@ -49788,6 +50143,7 @@ function buildAntigravityEnvelope(input) {
49788
50143
  }
49789
50144
  var antigravityConversations;
49790
50145
  var init_antigravity_envelope = __esm(() => {
50146
+ init_antigravity_content();
49791
50147
  antigravityConversations = new AntigravityConversations;
49792
50148
  });
49793
50149
 
@@ -50491,13 +50847,13 @@ function getCatalogEntries() {
50491
50847
  function catalogOrigin() {
50492
50848
  return getCatalogSnapshot()?.origin ?? "none";
50493
50849
  }
50494
- function latestAnthropicTierModelId(tier) {
50850
+ function latestAnthropicTierModelId(tier, accept = () => true) {
50495
50851
  const snapshot = getCatalogSnapshot();
50496
50852
  if (snapshot?.origin !== "disk")
50497
50853
  return null;
50498
50854
  const { entries } = snapshot;
50499
50855
  const family = new RegExp(`^claude-${tier}-`, "i");
50500
- const matches = entries.filter((entry) => family.test(entry.modelId));
50856
+ const matches = entries.filter((entry) => family.test(entry.modelId) && accept(entry.modelId));
50501
50857
  if (matches.length === 0)
50502
50858
  return null;
50503
50859
  matches.sort((a, b) => {
@@ -50531,9 +50887,49 @@ function externalIdFor(entry, provider) {
50531
50887
  return wireIds.find((wireId) => !isMovingPointer(wireId)) ?? null;
50532
50888
  }
50533
50889
  function publishesWireIdFor(entry, provider, wireId) {
50534
- return allConnections(entry).some((connection) => connection.routeStatus === "mapped" && connection.externalModelId === wireId && catalogRouteMatchesProvider(connection.route, provider));
50890
+ return allConnections(entry).some((connection) => connection.routeStatus === "mapped" && catalogRouteMatchesProvider(connection.route, provider) && (connection.externalModelId === wireId || effortMapListsWireId(connection, wireId)));
50891
+ }
50892
+ function effortMapListsWireId(connection, wireId) {
50893
+ return publishedEffortWireId(connection, wireId) === wireId;
50894
+ }
50895
+ function publishesImplicitWireIdFor(entry, provider, wireId) {
50896
+ return (entry.aggregators ?? []).some((connection) => connection.routeStatus === "mapped" && catalogRouteMatchesProvider(connection.route, provider) && (connection.externalModelId === wireId || implicitEffortWireId(connection, wireId) === wireId));
50535
50897
  }
50536
50898
  function resolveExternalId(userInput, provider, cachePath) {
50899
+ return resolveWireId(userInput, provider, cachePath, "explicit");
50900
+ }
50901
+ function resolveImplicitExternalId(userInput, provider, cachePath) {
50902
+ return resolveWireId(userInput, provider, cachePath, "implicit");
50903
+ }
50904
+ function effortMapOwnerFor(entries, provider, wireId) {
50905
+ const baseIds = new Set;
50906
+ for (const entry of entries) {
50907
+ const owns = allConnections(entry).some((connection) => connection.routeStatus === "mapped" && catalogRouteMatchesProvider(connection.route, provider) && effortMapListsWireId(connection, wireId));
50908
+ if (!owns)
50909
+ continue;
50910
+ const baseId = externalIdFor(entry, provider);
50911
+ if (baseId)
50912
+ baseIds.add(baseId);
50913
+ }
50914
+ const [first, ...rest] = baseIds;
50915
+ if (first === undefined)
50916
+ return { kind: "none" };
50917
+ if (rest.length > 0)
50918
+ return { kind: "ambiguous" };
50919
+ return { kind: "one", wireId: first };
50920
+ }
50921
+ function answerBeforeLookup(entries, provider, userInput, resolution) {
50922
+ const publishesExactly = resolution === "explicit" ? publishesWireIdFor : publishesImplicitWireIdFor;
50923
+ if (entries.some((entry) => publishesExactly(entry, provider, userInput)))
50924
+ return userInput;
50925
+ if (resolution === "explicit")
50926
+ return isOptInWireId(userInput) ? userInput : undefined;
50927
+ const owner = effortMapOwnerFor(entries, provider, userInput);
50928
+ if (owner.kind === "one")
50929
+ return owner.wireId;
50930
+ return owner.kind === "ambiguous" ? null : undefined;
50931
+ }
50932
+ function resolveWireId(userInput, provider, cachePath, resolution) {
50537
50933
  const entries = cachePath ? readAllModelsCache(cachePath)?.entries : getCatalogEntries();
50538
50934
  if (userInput.includes("/")) {
50539
50935
  if (entries?.some((entry) => allExternalIds(entry).includes(userInput)))
@@ -50542,8 +50938,9 @@ function resolveExternalId(userInput, provider, cachePath) {
50542
50938
  }
50543
50939
  if (!entries)
50544
50940
  return null;
50545
- if (entries.some((entry) => publishesWireIdFor(entry, provider, userInput)))
50546
- return userInput;
50941
+ const answered = answerBeforeLookup(entries, provider, userInput, resolution);
50942
+ if (answered !== undefined)
50943
+ return answered;
50547
50944
  const byModelId = entries.find((entry) => entry.modelId === userInput);
50548
50945
  if (byModelId)
50549
50946
  return externalIdFor(byModelId, provider);
@@ -50594,10 +50991,13 @@ function resolveTargetForCatalog(target, isExplicitProvider, model, provider, re
50594
50991
  };
50595
50992
  }
50596
50993
  function logResolution(userInput, result, quiet = false) {
50597
- if (result.wasResolved && !quiet) {
50598
- process.stderr.write(`[Model] Resolved "${userInput}" \u2192 "${result.resolvedId}" (${result.sourceLabel})
50994
+ if (!result.wasResolved)
50995
+ return;
50996
+ const line = `[Model] Resolved "${userInput}" \u2192 "${result.resolvedId}" (${result.sourceLabel})`;
50997
+ log(line);
50998
+ if (!quiet)
50999
+ process.stderr.write(`${line}
50599
51000
  `);
50600
- }
50601
51001
  }
50602
51002
  function catalogWarmDisabled() {
50603
51003
  return catalogWarmDisabledFor(process.env.CLAUDISH_DISABLE_CATALOG_WARM);
@@ -50947,6 +51347,7 @@ var init_catalog_client = __esm(() => {
50947
51347
  init_catalog_reachability();
50948
51348
  init_catalog_route_bindings();
50949
51349
  init_connection_wire();
51350
+ init_model_id_effort();
50950
51351
  init_probe_discovery();
50951
51352
  });
50952
51353
 
@@ -51303,6 +51704,8 @@ function resolveAntigravityServedModel(requested, served, effort) {
51303
51704
  }
51304
51705
  function chooseAntigravityServedModel(requested, served, effort) {
51305
51706
  const req = requested.trim();
51707
+ if (isOptInWireId(req))
51708
+ return { id: req, effort, source: "exact id" };
51306
51709
  const isMappedBase = findModelIdEffortConnection(req, "antigravity") !== undefined;
51307
51710
  if (!isMappedBase && served.servedIds.includes(req)) {
51308
51711
  return { id: req, effort, source: "exact id" };
@@ -51315,7 +51718,7 @@ function chooseAntigravityServedModel(requested, served, effort) {
51315
51718
  return decision.choice;
51316
51719
  if (servesSelectable(served, req))
51317
51720
  return existingResolutionChoice(req, effort, decision);
51318
- const selectable = served.servedIds.filter((id) => !isExcluded2(served, id));
51721
+ const selectable = served.servedIds.filter((id) => !isExcluded2(served, id) && !isOptInWireId(id));
51319
51722
  const defaultId = served.defaultId && selectable.includes(served.defaultId) ? served.defaultId : null;
51320
51723
  const id = resolveAntigravityModelId(requested, selectable, defaultId, lookupFamilyDefaultVariant(requested, "antigravity"));
51321
51724
  return existingResolutionChoice(id, effort, decision);
@@ -51757,9 +52160,29 @@ class AntigravityProviderTransport {
51757
52160
  return this._displayName;
51758
52161
  }
51759
52162
  streamFormat = "gemini-sse";
51760
- fetch(url, init) {
52163
+ async fetch(url, init) {
52164
+ await this.writeNewTrajectoryAcls(url, init);
51761
52165
  return antigravityFetch(url, init);
51762
52166
  }
52167
+ async writeNewTrajectoryAcls(url, init) {
52168
+ if (!url.includes("GenerateContent"))
52169
+ return;
52170
+ if (typeof init.body !== "string")
52171
+ return;
52172
+ const trajectoryId = antigravityConversations.takeNewTrajectoryIn(init.body);
52173
+ if (trajectoryId === null)
52174
+ return;
52175
+ const headers = new Headers(init.headers);
52176
+ const bearer = headers.get("authorization")?.replace(/^Bearer\s+/i, "");
52177
+ if (!bearer)
52178
+ return;
52179
+ const account = {
52180
+ apiBase: `${antigravityHost()}/v1internal`,
52181
+ userAgent: buildAntigravityUserAgent()
52182
+ };
52183
+ await sendAntigravitySideCall(antigravityTrajectoryAclCall(account, trajectoryId), bearer, TRAJECTORY_ACL_TIMEOUT_MS, init.signal ?? undefined);
52184
+ init.signal?.throwIfAborted();
52185
+ }
51763
52186
  modelName;
51764
52187
  servedModelName;
51765
52188
  accessToken = null;
@@ -51928,7 +52351,7 @@ class AntigravityProviderTransport {
51928
52351
  }
51929
52352
  async handleCapacityExhausted(originalResponse, queue, request, sentId, signal) {
51930
52353
  const excluded = this.served.excludedIds;
51931
- const candidates = this.servedModels.filter((m) => m !== sentId && !excluded?.has(m));
52354
+ const candidates = this.servedModels.filter((m) => m !== sentId && !excluded?.has(m) && !isOptInWireId(m));
51932
52355
  if (candidates.length === 0) {
51933
52356
  log(`[Antigravity] ${sentId} capacity exhausted, no fallback models available`);
51934
52357
  return originalResponse;
@@ -52020,7 +52443,7 @@ class AntigravityProviderTransport {
52020
52443
  return;
52021
52444
  let timer;
52022
52445
  const data = await Promise.race([
52023
- retrieveUserQuota(this.accessToken, this.projectId).catch(() => null),
52446
+ retrieveModelQuota(this.accessToken, this.projectId).catch(() => null),
52024
52447
  new Promise((resolve) => {
52025
52448
  timer = setTimeout(() => resolve(null), QUOTA_CHECK_TIMEOUT_MS);
52026
52449
  })
@@ -52066,7 +52489,7 @@ class AntigravityProviderTransport {
52066
52489
  if (!this.accessToken || !this.projectId)
52067
52490
  return;
52068
52491
  try {
52069
- const data = await retrieveUserQuota(this.accessToken, this.projectId);
52492
+ const data = await retrieveModelQuota(this.accessToken, this.projectId);
52070
52493
  if (!data?.buckets?.length)
52071
52494
  return;
52072
52495
  const lines = [];
@@ -52101,7 +52524,7 @@ ${lines.join(`
52101
52524
  if (!this.accessToken || !this.projectId)
52102
52525
  return;
52103
52526
  try {
52104
- const data = await retrieveUserQuota(this.accessToken, this.projectId);
52527
+ const data = await retrieveModelQuota(this.accessToken, this.projectId);
52105
52528
  if (!data?.buckets?.length)
52106
52529
  return;
52107
52530
  const bucket = data.buckets.find((b) => b.modelId === modelName);
@@ -52111,9 +52534,10 @@ ${lines.join(`
52111
52534
  }
52112
52535
  }
52113
52536
  }
52114
- var MAX_RETRY_ATTEMPTS = 3, DEFAULT_RATE_LIMIT_DELAY_MS = 1e4, UNATTRIBUTED_RETRY_DELAY_MS = 1000, QUOTA_CHECK_TIMEOUT_MS = 3000;
52537
+ var MAX_RETRY_ATTEMPTS = 3, DEFAULT_RATE_LIMIT_DELAY_MS = 1e4, UNATTRIBUTED_RETRY_DELAY_MS = 1000, QUOTA_CHECK_TIMEOUT_MS = 3000, TRAJECTORY_ACL_TIMEOUT_MS = 3000;
52115
52538
  var init_antigravity2 = __esm(() => {
52116
52539
  init_base_api_format();
52540
+ init_antigravity_side_calls();
52117
52541
  init_antigravity_token();
52118
52542
  init_antigravity_user();
52119
52543
  init_authority();
@@ -52383,9 +52807,13 @@ class ApiKeyCredentialProvider {
52383
52807
  }
52384
52808
  settle(key, source) {
52385
52809
  this.cachedKey = key;
52386
- this.lastOrigin = { source, masked: maskCredential(key) };
52810
+ this.lastOrigin = this.originOf(key, source);
52387
52811
  return { key, source };
52388
52812
  }
52813
+ originOf(key, source) {
52814
+ const masked = maskCredential(key);
52815
+ return this.replacement?.key === key ? { source, masked, replaced: true } : { source, masked };
52816
+ }
52389
52817
  resolveFromEnvConfig() {
52390
52818
  return resolveLocalApiKey({ envVar: this.envVar, aliases: this.aliases }) || realValue(this.resolveDeclared());
52391
52819
  }
@@ -52492,20 +52920,22 @@ class ApiKeyCredentialProvider {
52492
52920
  this.lastOrigin = undefined;
52493
52921
  this.replacement = undefined;
52494
52922
  }
52923
+ keyEnvVars() {
52924
+ return [this.envVar, ...this.aliases];
52925
+ }
52495
52926
  replaceKey(key, source) {
52496
52927
  this.invalidate();
52497
52928
  this.replacement = { key, source };
52929
+ this.lastOrigin = this.originOf(key, source);
52498
52930
  }
52499
52931
  sourcesOutranking(key, savedTo) {
52500
52932
  const outranking = [];
52501
- const primary = realValueFor(this.envVar, process.env[this.envVar]);
52502
- const primaryExported = !!primary && primary !== key && !isKeychainHydratedVar(this.envVar) && !isOpHydratedVar(this.envVar);
52503
- const aliasExported = this.aliases.some((a) => {
52504
- const v = realValueFor(a, process.env[a]);
52505
- return !!v && v !== key;
52933
+ const exported = [this.envVar, ...this.aliases].find((name) => {
52934
+ const v = realValueFor(name, process.env[name]);
52935
+ return !!v && v !== key && !isKeychainHydratedVar(name) && !isOpHydratedVar(name);
52506
52936
  });
52507
- if (primaryExported || aliasExported)
52508
- outranking.push("environment");
52937
+ if (exported)
52938
+ outranking.push({ source: "environment", envVar: exported });
52509
52939
  if (savedTo !== "environment" && savedTo !== "config") {
52510
52940
  let configured;
52511
52941
  try {
@@ -52513,8 +52943,9 @@ class ApiKeyCredentialProvider {
52513
52943
  } catch {
52514
52944
  configured = undefined;
52515
52945
  }
52516
- if (configured && configured !== key)
52517
- outranking.push("config");
52946
+ if (configured && configured !== key) {
52947
+ outranking.push({ source: "config", envVar: this.envVar });
52948
+ }
52518
52949
  }
52519
52950
  return outranking;
52520
52951
  }
@@ -56617,6 +57048,9 @@ class CompositeCredentialProvider {
56617
57048
  this.primary.invalidate?.();
56618
57049
  this.fallback.invalidate?.();
56619
57050
  }
57051
+ keyEnvVars() {
57052
+ return [...this.primary.keyEnvVars?.() ?? [], ...this.fallback.keyEnvVars?.() ?? []];
57053
+ }
56620
57054
  async accountIdentity(opts) {
56621
57055
  const primaryAvailable = await this.primary.isAvailable(opts).catch(() => false);
56622
57056
  const [half, label] = primaryAvailable ? [this.primary, "primary"] : [this.fallback, "fallback"];
@@ -58296,53 +58730,6 @@ var init_muse_code_credential = __esm(() => {
58296
58730
  init_prompt_role();
58297
58731
  });
58298
58732
 
58299
- // src/auth/credentials/native-anthropic-credential.ts
58300
- class NativeAnthropicCredentialProvider {
58301
- catalogName = "native-anthropic";
58302
- cachedKey;
58303
- invalidate() {
58304
- this.cachedKey = undefined;
58305
- }
58306
- async resolveKey() {
58307
- if (this.cachedKey !== undefined)
58308
- return this.cachedKey;
58309
- const local = realValueFor("ANTHROPIC_API_KEY", process.env.ANTHROPIC_API_KEY) || realValueFor("ANTHROPIC_AUTH_TOKEN", process.env.ANTHROPIC_AUTH_TOKEN) || realValueFor("ANTHROPIC_API_KEY", getApiKey("ANTHROPIC_API_KEY"));
58310
- if (local) {
58311
- this.cachedKey = local;
58312
- return local;
58313
- }
58314
- if (hasOpSources()) {
58315
- const r = await resolveOpKeyForEnvVars(new Set(["ANTHROPIC_API_KEY"]), {
58316
- onAuthFailure: "skip"
58317
- });
58318
- const v = r.ANTHROPIC_API_KEY;
58319
- if (v) {
58320
- process.env.ANTHROPIC_API_KEY = v;
58321
- this.cachedKey = v;
58322
- return v;
58323
- }
58324
- return "";
58325
- }
58326
- this.cachedKey = "";
58327
- return "";
58328
- }
58329
- async isAvailable() {
58330
- if (realValueFor("ANTHROPIC_API_KEY", process.env.ANTHROPIC_API_KEY) || realValueFor("ANTHROPIC_AUTH_TOKEN", process.env.ANTHROPIC_AUTH_TOKEN)) {
58331
- return true;
58332
- }
58333
- return !!await this.resolveKey();
58334
- }
58335
- async getRequestAuth(_ctx) {
58336
- const key = await this.resolveKey();
58337
- return key ? { headers: { "x-api-key": key } } : { headers: {} };
58338
- }
58339
- }
58340
- var init_native_anthropic_credential = __esm(() => {
58341
- init_env_placeholder();
58342
- init_profile_config();
58343
- init_op_source();
58344
- });
58345
-
58346
58733
  // src/auth/credentials/vertex-credential.ts
58347
58734
  class VertexCredentialProvider {
58348
58735
  catalogName = "vertex";
@@ -59030,12 +59417,16 @@ ${overrides}` : material;
59030
59417
  } catch {}
59031
59418
  }
59032
59419
  invalidate(name) {
59033
- clearSignedArm(name);
59034
- this.notifyInvalidated(name);
59035
59420
  if (name) {
59421
+ for (const registered of this.namesSharing(name)) {
59422
+ clearSignedArm(registered);
59423
+ this.notifyInvalidated(registered);
59424
+ }
59036
59425
  this.registry.get(name)?.invalidate?.();
59037
59426
  return;
59038
59427
  }
59428
+ clearSignedArm();
59429
+ this.notifyInvalidated();
59039
59430
  const seen = new Set;
59040
59431
  for (const p of this.registry.values()) {
59041
59432
  if (seen.has(p))
@@ -59044,6 +59435,19 @@ ${overrides}` : material;
59044
59435
  p.invalidate?.();
59045
59436
  }
59046
59437
  }
59438
+ invalidateKeyVars(names) {
59439
+ const wanted = new Set(names);
59440
+ const seen = new Set;
59441
+ for (const p of this.registry.values()) {
59442
+ if (seen.has(p))
59443
+ continue;
59444
+ seen.add(p);
59445
+ const vars = p.keyEnvVars?.();
59446
+ if (vars && !vars.some((v) => wanted.has(v)))
59447
+ continue;
59448
+ this.invalidate(p.catalogName);
59449
+ }
59450
+ }
59047
59451
  replaceKey(name, key, source) {
59048
59452
  this.invalidate(name);
59049
59453
  this.registry.get(name)?.replaceKey?.(key, source);
@@ -59081,7 +59485,6 @@ ${overrides}` : material;
59081
59485
  for (const name of LOCAL_PROVIDER_NAMES) {
59082
59486
  authority.register(new LocalCredentialProvider(name), [name]);
59083
59487
  }
59084
- authority.register(new NativeAnthropicCredentialProvider, ["native-anthropic"]);
59085
59488
  const alreadyRegistered = new Set([
59086
59489
  "openai-codex",
59087
59490
  "antigravity",
@@ -59089,7 +59492,6 @@ ${overrides}` : material;
59089
59492
  "kimi",
59090
59493
  "kimi-coding",
59091
59494
  "vertex",
59092
- "native-anthropic",
59093
59495
  ...LOCAL_PROVIDER_NAMES
59094
59496
  ]);
59095
59497
  for (const def of BUILTIN_PROVIDERS) {
@@ -59108,6 +59510,9 @@ ${overrides}` : material;
59108
59510
  ...def.vaultKeyReadAtUse === true ? { readAtUse: true } : {}
59109
59511
  }), [def.name, ...RUNTIME_NAME_ALIASES[def.name] ?? []]);
59110
59512
  }
59513
+ const anthropic = authority.get("anthropic");
59514
+ if (anthropic)
59515
+ authority.register(anthropic, ["native-anthropic"]);
59111
59516
  return authority;
59112
59517
  }
59113
59518
  }
@@ -59125,7 +59530,6 @@ var init_authority = __esm(() => {
59125
59530
  init_kimi_credential();
59126
59531
  init_local_credential();
59127
59532
  init_muse_code_credential();
59128
- init_native_anthropic_credential();
59129
59533
  init_vertex_credential();
59130
59534
  LOCAL_PROVIDER_NAMES = ["ollama", "lmstudio", "vllm", "mlx"];
59131
59535
  RUNTIME_NAME_ALIASES = {
@@ -60231,7 +60635,8 @@ function formatWindow(tokens) {
60231
60635
 
60232
60636
  class DevinModelResolver {
60233
60637
  provider = "devin";
60234
- collapse(modelsCatalog) {
60638
+ collapse(listed) {
60639
+ const modelsCatalog = withoutOptIn(listed);
60235
60640
  const groups = new Map;
60236
60641
  for (const entry of modelsCatalog) {
60237
60642
  const key = keyOf(entry);
@@ -60284,9 +60689,14 @@ class DevinModelResolver {
60284
60689
  logModelIdChoice("Devin", selection.trim() || selection, choice);
60285
60690
  return choice.id;
60286
60691
  }
60287
- choose(selection, modelsCatalog, effort) {
60692
+ choose(selection, listed, effort) {
60288
60693
  const requested = selection.trim();
60289
60694
  const lower = requested.toLowerCase();
60695
+ if (isOptInWireId(requested)) {
60696
+ const listedId = listed.find((entry) => entry.wireId.toLowerCase() === lower)?.wireId;
60697
+ return { id: listedId ?? requested, effort, source: "exact id" };
60698
+ }
60699
+ const modelsCatalog = withoutOptIn(listed);
60290
60700
  const exact = modelsCatalog.find((entry) => entry.wireId.toLowerCase() === lower);
60291
60701
  const isMappedBase = requested !== "" && findModelIdEffortConnection(requested, "devin") !== undefined;
60292
60702
  if (exact && !effort && isMappedBase) {
@@ -60327,6 +60737,9 @@ class DevinModelResolver {
60327
60737
  return unmapped(pickForEffort(groups.get(keyOf(chosen)), effort).wireId);
60328
60738
  }
60329
60739
  }
60740
+ function withoutOptIn(modelsCatalog) {
60741
+ return modelsCatalog.filter((entry) => !isOptInWireId(entry.wireId));
60742
+ }
60330
60743
  function mappedWireId(requested, modelsCatalog, effort) {
60331
60744
  const byId = new Map;
60332
60745
  for (const entry of modelsCatalog) {
@@ -61380,12 +61793,12 @@ function getCachedEntries() {
61380
61793
  _memoMtimeMs = mtimeMs;
61381
61794
  return _memoEntries;
61382
61795
  }
61383
- function findEntryByAlias(alias) {
61796
+ function findEntryByAlias(alias, accept = () => true) {
61384
61797
  const entries = getCachedEntries();
61385
61798
  if (!entries || entries.length === 0)
61386
61799
  return null;
61387
61800
  for (const entry of entries) {
61388
- if (entry.aliases.includes(alias)) {
61801
+ if (entry.aliases.includes(alias) && accept(entry.modelId)) {
61389
61802
  return project(entry);
61390
61803
  }
61391
61804
  }
@@ -61407,7 +61820,7 @@ function findVisionAlias(alias) {
61407
61820
  if (!entries || entries.length === 0)
61408
61821
  return null;
61409
61822
  for (const entry of entries) {
61410
- if (entry.supportsVision === true && entry.aliases.includes(alias)) {
61823
+ if (entry.supportsVision === true && entry.aliases.includes(alias) && !isOptInWireId(entry.modelId)) {
61411
61824
  return project(entry);
61412
61825
  }
61413
61826
  }
@@ -61538,18 +61951,47 @@ var init_vision_proxy = __esm(() => {
61538
61951
  init_catalog_query();
61539
61952
  });
61540
61953
 
61541
- // src/mcp-session/home-dir.ts
61954
+ // src/auth/claude-code-facts.ts
61955
+ import { createHash as createHash18 } from "crypto";
61542
61956
  import { homedir as homedir30 } from "os";
61543
- import { join as join31 } from "path";
61544
- function userHomeFrom(env, homedirFn = homedir30) {
61957
+ import { join as join31, resolve as resolve3 } from "path";
61958
+ function claudeCodeConfigDir(env = process.env, cwd = process.cwd()) {
61959
+ const dir = env.CLAUDE_CONFIG_DIR ?? join31(env.HOME ? env.HOME : homedir30(), ".claude");
61960
+ return resolve3(cwd, dir.normalize("NFC"));
61961
+ }
61962
+ function configDirHash(configDir) {
61963
+ return createHash18("sha256").update(configDir).digest("hex").slice(0, 8);
61964
+ }
61965
+ function claudeCodeSecureStorageServices(kind, env = process.env, cwd = process.cwd()) {
61966
+ const base = `${BASE_KEYCHAIN_SERVICE}${kind}`;
61967
+ const secure = env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
61968
+ const spellings = secure !== undefined ? secure ? [secure] : [] : env.CLAUDE_CONFIG_DIR ? [
61969
+ env.CLAUDE_CONFIG_DIR,
61970
+ claudeCodeConfigDir(env, cwd),
61971
+ env.CLAUDE_CONFIG_DIR.replace(/\/+$/, "")
61972
+ ] : [];
61973
+ if (spellings.length === 0)
61974
+ return [base];
61975
+ return [...new Set(spellings.map((dir) => `${base}-${configDirHash(dir.normalize("NFC"))}`))];
61976
+ }
61977
+ function claudeCodeGlobalConfigPath(env = process.env, cwd = process.cwd()) {
61978
+ return env.CLAUDE_CONFIG_DIR ? resolve3(claudeCodeConfigDir(env, cwd), ".claude.json") : resolve3(env.HOME || homedir30(), ".claude.json");
61979
+ }
61980
+ var BASE_KEYCHAIN_SERVICE = "Claude Code";
61981
+ var init_claude_code_facts = () => {};
61982
+
61983
+ // src/mcp-session/home-dir.ts
61984
+ import { homedir as homedir31 } from "os";
61985
+ import { join as join32 } from "path";
61986
+ function userHomeFrom(env, homedirFn = homedir31) {
61545
61987
  const home = env.HOME;
61546
61988
  return home && home.length > 0 ? home : homedirFn();
61547
61989
  }
61548
- function sessionsDirFrom(env, homedirFn = homedir30) {
61990
+ function sessionsDirFrom(env, homedirFn = homedir31) {
61549
61991
  const explicit = env.CLAUDISH_SESSIONS_DIR;
61550
61992
  if (explicit && explicit.length > 0)
61551
61993
  return explicit;
61552
- return join31(userHomeFrom(env, homedirFn), ".claudish", "sessions");
61994
+ return join32(userHomeFrom(env, homedirFn), ".claudish", "sessions");
61553
61995
  }
61554
61996
  function claudeCodeStringHash(s) {
61555
61997
  let h = 0;
@@ -61723,8 +62165,7 @@ var init_transcript_tailer = () => {};
61723
62165
 
61724
62166
  // src/session-events/index.ts
61725
62167
  import { existsSync as existsSync22, readFileSync as readFileSync31, readdirSync as readdirSync5 } from "fs";
61726
- import { homedir as homedir31 } from "os";
61727
- import { join as join32 } from "path";
62168
+ import { join as join33 } from "path";
61728
62169
  function extractSessionId2(metadata) {
61729
62170
  const userId = metadata?.user_id;
61730
62171
  if (typeof userId !== "string")
@@ -61746,12 +62187,21 @@ class SessionEventRegistry {
61746
62187
  sessions = new Map;
61747
62188
  misses = new Map;
61748
62189
  subscribers = [];
61749
- claudeHome;
62190
+ resolvedHome;
62191
+ opts;
61750
62192
  pollIntervalMs;
61751
62193
  constructor(opts = {}) {
61752
- this.claudeHome = opts.claudeHome ?? join32(homedir31(), ".claude");
62194
+ this.opts = opts;
62195
+ this.resolvedHome = opts.claudeHome;
61753
62196
  this.pollIntervalMs = opts.pollIntervalMs;
61754
62197
  }
62198
+ get cwd() {
62199
+ return this.opts.cwd ?? process.cwd();
62200
+ }
62201
+ get claudeHome() {
62202
+ this.resolvedHome ??= claudeCodeConfigDir(this.opts.env ?? process.env, this.cwd);
62203
+ return this.resolvedHome;
62204
+ }
61755
62205
  ensureSession(sessionId) {
61756
62206
  try {
61757
62207
  this.sweepIdle();
@@ -61835,13 +62285,13 @@ class SessionEventRegistry {
61835
62285
  }
61836
62286
  }
61837
62287
  locateTranscript(sessionId) {
61838
- const projectsDir = join32(this.claudeHome, "projects");
61839
- const primary = join32(projectsDir, slugFromCwd(process.cwd()), `${sessionId}.jsonl`);
62288
+ const projectsDir = join33(this.claudeHome, "projects");
62289
+ const primary = join33(projectsDir, slugFromCwd(this.cwd), `${sessionId}.jsonl`);
61840
62290
  if (existsSync22(primary))
61841
62291
  return primary;
61842
62292
  try {
61843
62293
  for (const dir of readdirSync5(projectsDir)) {
61844
- const candidate = join32(projectsDir, dir, `${sessionId}.jsonl`);
62294
+ const candidate = join33(projectsDir, dir, `${sessionId}.jsonl`);
61845
62295
  if (existsSync22(candidate))
61846
62296
  return candidate;
61847
62297
  }
@@ -61850,7 +62300,7 @@ class SessionEventRegistry {
61850
62300
  }
61851
62301
  readSettingsEffortLevel() {
61852
62302
  try {
61853
- const settings = JSON.parse(readFileSync31(join32(this.claudeHome, "settings.json"), "utf-8"));
62303
+ const settings = JSON.parse(readFileSync31(join33(this.claudeHome, "settings.json"), "utf-8"));
61854
62304
  return typeof settings.effortLevel === "string" ? settings.effortLevel : undefined;
61855
62305
  } catch {
61856
62306
  return;
@@ -61868,6 +62318,7 @@ class SessionEventRegistry {
61868
62318
  }
61869
62319
  var MISS_TTL_MS = 5000, MAX_MISSES = 5, IDLE_SWEEP_MS, sessionEvents;
61870
62320
  var init_session_events = __esm(() => {
62321
+ init_claude_code_facts();
61871
62322
  init_logger();
61872
62323
  init_home_dir();
61873
62324
  init_event_translator();
@@ -61961,7 +62412,7 @@ import {
61961
62412
  writeFileSync as writeFileSync12
61962
62413
  } from "fs";
61963
62414
  import { homedir as homedir32 } from "os";
61964
- import { join as join33 } from "path";
62415
+ import { join as join34 } from "path";
61965
62416
  function ensureDir() {
61966
62417
  if (!existsSync23(CLAUDISH_DIR)) {
61967
62418
  mkdirSync17(CLAUDISH_DIR, { recursive: true });
@@ -61996,7 +62447,7 @@ function writeToDisk(events) {
61996
62447
  ensureDir();
61997
62448
  const trimmed = enforceSizeCap([...events]);
61998
62449
  const payload = { version: 1, events: trimmed };
61999
- const tmpFile = join33(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
62450
+ const tmpFile = join34(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
62000
62451
  writeFileSync12(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
62001
62452
  renameSync9(tmpFile, BUFFER_FILE);
62002
62453
  memoryCache = trimmed;
@@ -62069,8 +62520,8 @@ function syncFlushOnExit() {
62069
62520
  var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, flushScheduled = false, SIGNAL_EXIT_CODE;
62070
62521
  var init_stats_buffer = __esm(() => {
62071
62522
  BUFFER_MAX_BYTES = 64 * 1024;
62072
- CLAUDISH_DIR = join33(homedir32(), ".claudish");
62073
- BUFFER_FILE = join33(CLAUDISH_DIR, "stats-buffer.json");
62523
+ CLAUDISH_DIR = join34(homedir32(), ".claudish");
62524
+ BUFFER_FILE = join34(CLAUDISH_DIR, "stats-buffer.json");
62074
62525
  process.on("exit", syncFlushOnExit);
62075
62526
  SIGNAL_EXIT_CODE = { SIGTERM: 143, SIGINT: 130 };
62076
62527
  for (const signal of ["SIGTERM", "SIGINT"]) {
@@ -63955,15 +64406,68 @@ var init_provider_refused_text = __esm(() => {
63955
64406
  });
63956
64407
 
63957
64408
  // src/handlers/shared/format/tool-name-alias.ts
63958
- function renameToolUses(content, forward) {
64409
+ function renameKeys(args, names) {
64410
+ const out = {};
64411
+ for (const [key, value] of Object.entries(args))
64412
+ out[names.get(key) ?? key] = value;
64413
+ return out;
64414
+ }
64415
+ function readRangeToWire(args) {
64416
+ const { offset, limit, ...rest } = args;
64417
+ const out = { ...rest };
64418
+ if (typeof offset === "number")
64419
+ out.StartLine = offset;
64420
+ if (typeof limit === "number")
64421
+ out.EndLine = (typeof offset === "number" ? offset : 1) + limit - 1;
64422
+ return out;
64423
+ }
64424
+ function readRangeFromWire(args) {
64425
+ const { StartLine, EndLine, ...rest } = args;
64426
+ const out = { ...rest };
64427
+ if (typeof StartLine === "number")
64428
+ out.offset = StartLine;
64429
+ if (typeof EndLine === "number") {
64430
+ out.limit = Math.max(1, EndLine - (typeof StartLine === "number" ? StartLine : 1) + 1);
64431
+ }
64432
+ return out;
64433
+ }
64434
+ function schemaToWire(schema, native, names) {
64435
+ if (!isRecord5(schema) || !isRecord5(schema.properties))
64436
+ return schema;
64437
+ let properties = renameKeys(schema.properties, names);
64438
+ if (native === "read_file" && (("offset" in properties) || ("limit" in properties))) {
64439
+ const { offset: _offset, limit: _limit, ...rest } = properties;
64440
+ properties = { ...rest, ...READ_RANGE_PROPERTIES };
64441
+ }
64442
+ const out = { ...schema, properties };
64443
+ if (Array.isArray(schema.required)) {
64444
+ out.required = schema.required.filter((name) => !(native === "read_file" && (name === "offset" || name === "limit"))).map((name) => typeof name === "string" ? names.get(name) ?? name : name);
64445
+ }
64446
+ return out;
64447
+ }
64448
+ function renameToolUses(content, forward, argumentsToWire) {
63959
64449
  if (!Array.isArray(content))
63960
64450
  return content;
63961
- return content.map((block) => block?.type === "tool_use" && typeof block.name === "string" && forward.has(block.name) ? { ...block, name: forward.get(block.name) } : block);
64451
+ return content.map((block) => {
64452
+ if (block?.type !== "tool_use" || typeof block.name !== "string")
64453
+ return block;
64454
+ const native = forward.get(block.name);
64455
+ if (native === undefined)
64456
+ return block;
64457
+ return { ...block, name: native, input: argumentsToWire(native, block.input) };
64458
+ });
63962
64459
  }
63963
64460
  function aliasToolsForProvider(req, providerName) {
63964
64461
  const table = PROVIDER_ALIASES[providerName];
63965
- if (!table)
63966
- return { request: req, forward: identity, restore: identity };
64462
+ if (!table) {
64463
+ return {
64464
+ request: req,
64465
+ forward: identity,
64466
+ restore: identity,
64467
+ restoreArguments: (_name, args) => args
64468
+ };
64469
+ }
64470
+ const argumentTables = PROVIDER_ARGUMENT_ALIASES[providerName] ?? {};
63967
64471
  const declared = new Set(Array.isArray(req.tools) ? req.tools.map((tool) => tool?.name) : []);
63968
64472
  const forward = new Map;
63969
64473
  const backward = new Map;
@@ -63973,24 +64477,54 @@ function aliasToolsForProvider(req, providerName) {
63973
64477
  forward.set(claude, native);
63974
64478
  backward.set(native, claude);
63975
64479
  }
64480
+ const toWire = new Map;
64481
+ const fromWire = new Map;
64482
+ for (const native of backward.keys()) {
64483
+ const pairs = argumentTables[native];
64484
+ if (!pairs)
64485
+ continue;
64486
+ toWire.set(native, new Map(pairs.map(([claude, wire]) => [claude, wire])));
64487
+ fromWire.set(native, new Map(pairs.map(([claude, wire]) => [wire, claude])));
64488
+ }
64489
+ const argumentsToWire = (native, args) => {
64490
+ const names = toWire.get(native);
64491
+ if (!names || !isRecord5(args))
64492
+ return args;
64493
+ const renamed = renameKeys(args, names);
64494
+ return native === "read_file" ? readRangeToWire(renamed) : renamed;
64495
+ };
64496
+ const restoreArguments = (wireName, args) => {
64497
+ const names = fromWire.get(wireName);
64498
+ if (!names || !isRecord5(args))
64499
+ return args;
64500
+ const renamed = renameKeys(args, names);
64501
+ return wireName === "read_file" ? readRangeFromWire(renamed) : renamed;
64502
+ };
63976
64503
  const out = { ...req };
63977
64504
  if (Array.isArray(req.tools)) {
63978
- out.tools = req.tools.map((tool) => typeof tool?.name === "string" && forward.has(tool.name) ? { ...tool, name: forward.get(tool.name) } : tool);
64505
+ out.tools = req.tools.map((tool) => {
64506
+ const native = typeof tool?.name === "string" ? forward.get(tool.name) : undefined;
64507
+ if (native === undefined)
64508
+ return tool;
64509
+ const names = toWire.get(native);
64510
+ return names && "input_schema" in tool ? { ...tool, name: native, input_schema: schemaToWire(tool.input_schema, native, names) } : { ...tool, name: native };
64511
+ });
63979
64512
  }
63980
64513
  const choice = req.tool_choice;
63981
64514
  if (choice && typeof choice.name === "string" && forward.has(choice.name)) {
63982
64515
  out.tool_choice = { ...choice, name: forward.get(choice.name) };
63983
64516
  }
63984
64517
  if (Array.isArray(req.messages)) {
63985
- out.messages = req.messages.map((msg) => msg?.role === "assistant" ? { ...msg, content: renameToolUses(msg.content, forward) } : msg);
64518
+ out.messages = req.messages.map((msg) => msg?.role === "assistant" ? { ...msg, content: renameToolUses(msg.content, forward, argumentsToWire) } : msg);
63986
64519
  }
63987
64520
  return {
63988
64521
  request: out,
63989
64522
  forward: (name) => forward.get(name) ?? name,
63990
- restore: (name) => backward.get(name) ?? name
64523
+ restore: (name) => backward.get(name) ?? name,
64524
+ restoreArguments
63991
64525
  };
63992
64526
  }
63993
- var AGY_TOOL_ALIAS, PROVIDER_ALIASES, identity = (name) => name;
64527
+ var AGY_TOOL_ALIAS, PROVIDER_ALIASES, AGY_ARGUMENT_ALIAS, PROVIDER_ARGUMENT_ALIASES, isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), READ_RANGE_PROPERTIES, identity = (name) => name;
63994
64528
  var init_tool_name_alias = __esm(() => {
63995
64529
  AGY_TOOL_ALIAS = [
63996
64530
  ["Bash", "run_command"],
@@ -64009,6 +64543,30 @@ var init_tool_name_alias = __esm(() => {
64009
64543
  PROVIDER_ALIASES = {
64010
64544
  antigravity: AGY_TOOL_ALIAS
64011
64545
  };
64546
+ AGY_ARGUMENT_ALIAS = {
64547
+ run_command: [
64548
+ ["command", "CommandLine"],
64549
+ ["description", "toolSummary"],
64550
+ ["run_in_background", "IsDaemon"]
64551
+ ],
64552
+ read_file: [["file_path", "Path"]],
64553
+ write_file: [
64554
+ ["file_path", "Path"],
64555
+ ["content", "Content"]
64556
+ ],
64557
+ edit_file: [
64558
+ ["file_path", "Path"],
64559
+ ["old_string", "Target"],
64560
+ ["new_string", "Replacement"]
64561
+ ]
64562
+ };
64563
+ PROVIDER_ARGUMENT_ALIASES = {
64564
+ antigravity: AGY_ARGUMENT_ALIAS
64565
+ };
64566
+ READ_RANGE_PROPERTIES = {
64567
+ StartLine: { type: "integer", description: "The first line to read, counted from 1." },
64568
+ EndLine: { type: "integer", description: "The last line to read, counted from 1." }
64569
+ };
64012
64570
  });
64013
64571
 
64014
64572
  // src/handlers/shared/format/tool-reference-text.ts
@@ -64058,6 +64616,25 @@ function toolReferencesAsText(messages, wording = {}) {
64058
64616
  }
64059
64617
  var identity2 = (name) => name, always = () => true, loadedText = (name) => `Loaded: ${name}. It is in your tool list now.`, notLoadedText = (name) => `Not loaded: ${name}. It is not in your tool list.`, isReference = (item) => item?.type === "tool_reference";
64060
64618
 
64619
+ // src/handlers/shared/repeat-window.ts
64620
+ function firstInWindow(line, now = Date.now()) {
64621
+ const at = lastPrinted.get(line);
64622
+ if (at !== undefined && now - at < REPEAT_WINDOW_MS)
64623
+ return false;
64624
+ lastPrinted.set(line, now);
64625
+ if (lastPrinted.size > 256) {
64626
+ for (const [key, t] of lastPrinted) {
64627
+ if (now - t >= REPEAT_WINDOW_MS)
64628
+ lastPrinted.delete(key);
64629
+ }
64630
+ }
64631
+ return true;
64632
+ }
64633
+ var REPEAT_WINDOW_MS = 30000, lastPrinted;
64634
+ var init_repeat_window = __esm(() => {
64635
+ lastPrinted = new Map;
64636
+ });
64637
+
64061
64638
  // src/handlers/shared/responses-leg-issuer.ts
64062
64639
  function isSameCredentialSilo(turn, next) {
64063
64640
  return (turn.auth?.arm ?? undefined) === (next.auth?.arm ?? undefined) && turn.accountKey === next.accountKey;
@@ -65365,7 +65942,8 @@ data: ${JSON.stringify(data)}
65365
65942
  const blockIndex = curIdx++;
65366
65943
  const toolName = opts.mapToolName ? opts.mapToolName(part.functionCall.name) : part.functionCall.name;
65367
65944
  opts.onToolCallObserved?.(toolName);
65368
- const args = JSON.stringify(part.functionCall.args || {});
65945
+ const upstreamArgs = part.functionCall.args || {};
65946
+ const args = JSON.stringify(opts.mapToolArguments ? opts.mapToolArguments(part.functionCall.name, upstreamArgs) : upstreamArgs);
65369
65947
  const t = {
65370
65948
  id: toolId,
65371
65949
  name: toolName,
@@ -68215,7 +68793,7 @@ var init_openai_responses_sse = __esm(() => {
68215
68793
  });
68216
68794
 
68217
68795
  // src/session/token-file.ts
68218
- import { join as join34 } from "path";
68796
+ import { join as join35 } from "path";
68219
68797
  function assignedTokenFile(env) {
68220
68798
  const f = env.CLAUDISH_TOKEN_FILE;
68221
68799
  if (!f || f === env.CLAUDISH_PUBLISHED_TOKEN_FILE)
@@ -68223,7 +68801,7 @@ function assignedTokenFile(env) {
68223
68801
  return f;
68224
68802
  }
68225
68803
  function resolveTokenFilePath(port, env = process.env) {
68226
- return assignedTokenFile(env) ?? join34(userHomeFrom(env), ".claudish", `tokens-${port}.json`);
68804
+ return assignedTokenFile(env) ?? join35(userHomeFrom(env), ".claudish", `tokens-${port}.json`);
68227
68805
  }
68228
68806
  var init_token_file = __esm(() => {
68229
68807
  init_home_dir();
@@ -70029,7 +70607,11 @@ class ComposedHandler {
70029
70607
  const providerMsg = extractProviderMessage(parsedErrorBody ?? errorText);
70030
70608
  const oneLineMsg = providerMsg.replace(/\s+/g, " ").trim();
70031
70609
  const msgTail = oneLineMsg ? ` (${oneLineMsg.length > 200 ? `${oneLineMsg.slice(0, 200)}\u2026` : oneLineMsg})` : "";
70032
- logStderr(`Error [${this.provider.displayName}]: HTTP ${response.status}. ${hint}${msgTail}`);
70610
+ const errorLine = `Error [${this.provider.displayName}]: HTTP ${response.status}. ${hint}${msgTail}`;
70611
+ if (firstInWindow(errorLine))
70612
+ logStderr(errorLine);
70613
+ else
70614
+ log(errorLine);
70033
70615
  let providerErrorType;
70034
70616
  try {
70035
70617
  const parsed = JSON.parse(errorText);
@@ -70083,7 +70665,7 @@ class ComposedHandler {
70083
70665
  providerMessage: providerMsg,
70084
70666
  leadPhrase: isContextOverflowError(response.status, errorText) ? CONTEXT_OVERFLOW_PHRASE : undefined
70085
70667
  });
70086
- const verdictHeaders = this.signedBilling(binding).subscription && isCredentialRejection(response.status, errorText) ? authVerdictHeaders("terminal") : undefined;
70668
+ const verdictHeaders = isCredentialRejection(response.status, errorText) ? authVerdictHeaders("terminal") : undefined;
70087
70669
  return c.json(wrapAnthropicError(400, surfaced, "invalid_request_error", response.status, providerMsg), 400, verdictHeaders);
70088
70670
  }
70089
70671
  return c.json(ensureAnthropicErrorFormat(response.status, errorBody), response.status);
@@ -70370,7 +70952,7 @@ class ComposedHandler {
70370
70952
  output: u.output
70371
70953
  };
70372
70954
  ledger.finalInput = u.finalInput;
70373
- }, toolAlias.restore), () => {
70955
+ }, toolAlias.restore, toolAlias.restoreArguments), () => {
70374
70956
  clientCancelled = true;
70375
70957
  });
70376
70958
  ledger.streamOutcome = () => clientCancelled ? "cancelled" : streamApiError !== null || ledger.billed === undefined ? "error" : "ok";
@@ -70506,7 +71088,7 @@ class ComposedHandler {
70506
71088
  resolveStreamFormat() {
70507
71089
  return this.provider.overrideStreamFormat?.() ?? this.explicitAdapter?.getStreamFormat() ?? this.modelAdapter?.getStreamFormat() ?? this.getAdapter().getStreamFormat();
70508
71090
  }
70509
- handleStream(c, response, adapter, claudeRequest, billing, toolNameMap, onComplete, onApiError, raw, responsesTurn, onBilled, restoreToolName) {
71091
+ handleStream(c, response, adapter, claudeRequest, billing, toolNameMap, onComplete, onApiError, raw, responsesTurn, onBilled, restoreToolName, restoreToolArguments) {
70510
71092
  let pendingOnComplete = onComplete;
70511
71093
  const billedPerTurn = this.resolveStreamFormat() === "openai-responses-sse";
70512
71094
  const onTokenUpdate = (input, output, detail) => {
@@ -70590,7 +71172,8 @@ class ComposedHandler {
70590
71172
  onToolCallObserved: observeToolCall,
70591
71173
  unwrapResponse: this.options.unwrapGeminiResponse,
70592
71174
  priorInputTokens,
70593
- mapToolName: restoreToolName
71175
+ mapToolName: restoreToolName,
71176
+ mapToolArguments: restoreToolArguments
70594
71177
  });
70595
71178
  }
70596
71179
  case "connect-proto":
@@ -70808,6 +71391,7 @@ var init_composed_handler = __esm(() => {
70808
71391
  init_model_unsupported();
70809
71392
  init_quota_exhaustion();
70810
71393
  init_remote_provider_types();
71394
+ init_repeat_window();
70811
71395
  init_responses_leg_issuer();
70812
71396
  init_stream_head_sniffer();
70813
71397
  init_anthropic_sse();
@@ -70826,9 +71410,9 @@ var init_composed_handler = __esm(() => {
70826
71410
  // src/providers/api-key-provenance.ts
70827
71411
  import { existsSync as existsSync24, readFileSync as readFileSync33 } from "fs";
70828
71412
  import { homedir as homedir33 } from "os";
70829
- import { join as join35, resolve as resolve3 } from "path";
71413
+ import { join as join36, resolve as resolve4 } from "path";
70830
71414
  function activeConfigPath() {
70831
- return activeGlobalConfigFile(join35(homedir33(), ".claudish", "config.json"));
71415
+ return activeGlobalConfigFile(join36(homedir33(), ".claudish", "config.json"));
70832
71416
  }
70833
71417
  function configLayerLabel() {
70834
71418
  return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
@@ -70846,7 +71430,7 @@ function resolveApiKeyProvenance(envVar, aliases) {
70846
71430
  const allVars = [envVar, ...aliases || []];
70847
71431
  const dotenvValue = readDotenvKey(allVars);
70848
71432
  layers.push({
70849
- source: `.env (${resolve3(".env")})`,
71433
+ source: `.env (${resolve4(".env")})`,
70850
71434
  maskedValue: maskKey(dotenvValue),
70851
71435
  isActive: false
70852
71436
  });
@@ -70983,7 +71567,7 @@ function formatProvenanceLog(p) {
70983
71567
  }
70984
71568
  function readDotenvKey(envVars) {
70985
71569
  try {
70986
- const dotenvPath = resolve3(".env");
71570
+ const dotenvPath = resolve4(".env");
70987
71571
  if (!existsSync24(dotenvPath))
70988
71572
  return null;
70989
71573
  const parsed = readAllowedDotenv(readFileSync33(dotenvPath, "utf-8"));
@@ -71298,7 +71882,14 @@ class DevinProviderTransport {
71298
71882
  if (served.length === 0) {
71299
71883
  return { model: null, reason: "Devin reported no models for this subscription" };
71300
71884
  }
71301
- const ranked = [...served].sort((a, b) => {
71885
+ const ordinary = served.filter((model) => !isOptInWireId(model.uid));
71886
+ if (ordinary.length === 0) {
71887
+ return {
71888
+ model: null,
71889
+ reason: "Devin lists only content-use opt-in models for this subscription"
71890
+ };
71891
+ }
71892
+ const ranked = [...ordinary].sort((a, b) => {
71302
71893
  const diff = b.contextWindow - a.contextWindow;
71303
71894
  return diff !== 0 ? diff : a.uid.localeCompare(b.uid);
71304
71895
  });
@@ -71846,9 +72437,10 @@ async function discoverVertexProbeModel(exclude) {
71846
72437
  } catch (e) {
71847
72438
  return fail(`Vertex AI model list failed: ${e instanceof Error ? e.message : String(e)}`);
71848
72439
  }
71849
- const ranked = rankDiscoveredModels(listing.models).map((m) => m.id).filter(isChatCapable);
72440
+ const chatCapable = rankDiscoveredModels(listing.models).map((m) => m.id).filter(isChatCapable);
72441
+ const ranked = chatCapable.filter((id) => !isOptInWireId(id));
71850
72442
  if (ranked.length === 0) {
71851
- return fail(listing.listed === 0 ? `${listing.endpoint} listed no models for this project` : `no chat-capable model among the ${listing.listed} that ${listing.endpoint} listed for this project`);
72443
+ return fail(noCandidateReason(listing, chatCapable.length));
71852
72444
  }
71853
72445
  if (!config) {
71854
72446
  return fail("no Google Cloud project resolved");
@@ -71864,6 +72456,14 @@ async function discoverVertexProbeModel(exclude) {
71864
72456
  _cache3.set(cacheKey, { ranked: served, expiresAt: Date.now() + CACHE_TTL_MS3 });
71865
72457
  return pickFrom(served, undefined, exclude);
71866
72458
  }
72459
+ function noCandidateReason(listing, chatCapableCount) {
72460
+ if (listing.listed === 0)
72461
+ return `${listing.endpoint} listed no models for this project`;
72462
+ if (chatCapableCount > 0) {
72463
+ return `no chat-capable model that is not a content-use opt-in id among the ${listing.listed} that ${listing.endpoint} listed for this project`;
72464
+ }
72465
+ return `no chat-capable model among the ${listing.listed} that ${listing.endpoint} listed for this project`;
72466
+ }
71867
72467
  function pickFrom(ranked, reason, exclude) {
71868
72468
  if (ranked.length === 0)
71869
72469
  return { model: null, reason };
@@ -84547,44 +85147,42 @@ var init_native_route = __esm(() => {
84547
85147
  function decideHopFailure(input) {
84548
85148
  if (input.kind === "thrown")
84549
85149
  return { action: "advance", reason: "thrown" };
84550
- const { status, headers, body, provider, name } = input;
85150
+ const { status, headers, body, name } = input;
84551
85151
  if (hasRecoveryMarker(headers))
84552
85152
  return { action: "stop", reason: "recovery-hold" };
84553
85153
  if (hasStreamFailureMarker(headers))
84554
85154
  return { action: "stop", reason: "stream-failure" };
84555
85155
  const connectionFault = isClaudishConnectionVerdict(headers);
84556
85156
  const verdict = authVerdict(headers);
84557
- const subscriptionRejected = !connectionFault && verdict === "terminal" && !!provider && isSubscriptionProvider(provider);
84558
- if (verdict && !subscriptionRejected)
85157
+ const terminalRejection = !connectionFault && verdict === "terminal";
85158
+ if (verdict && !terminalRejection)
84559
85159
  return { action: "stop", reason: "credential-hold" };
84560
- if (subscriptionRejected || !connectionFault && isSubscriptionCredentialRejection(status, body, provider)) {
84561
- return { action: "advance", reason: "subscription-credential-rejected" };
85160
+ if (terminalRejection || !connectionFault && isRejectedCredentialAnswer(status, body)) {
85161
+ return { action: "advance", reason: "credential-rejected" };
84562
85162
  }
84563
- if (!isRetryableError(status, body, name, headers, provider)) {
85163
+ if (!isRetryableError(status, body, name, headers)) {
84564
85164
  return { action: "stop", reason: "non-retryable" };
84565
85165
  }
84566
85166
  return { action: "advance", reason: "retryable" };
84567
85167
  }
84568
- function isSubscriptionCredentialRejection(status, errorBody, providerId) {
84569
- if (!providerId || !isSubscriptionProvider(providerId))
84570
- return false;
85168
+ function isRejectedCredentialAnswer(status, errorBody) {
84571
85169
  const recovered = status === 400 ? extractUpstreamStatus(errorBody) : undefined;
84572
85170
  if ((status === 401 || recovered === 401) && isCredentialRejection(401, errorBody)) {
84573
85171
  return true;
84574
85172
  }
84575
85173
  return status === 403 && isCredentialRejection(403, errorBody);
84576
85174
  }
84577
- function isRetryableError(status, errorBody, provider, headers, providerId) {
85175
+ function isRetryableError(status, errorBody, provider, headers) {
84578
85176
  if (isClaudishConnectionVerdict(headers))
84579
85177
  return false;
84580
85178
  if (hasStreamFailureMarker(headers))
84581
85179
  return false;
84582
85180
  const verdict = authVerdict(headers);
84583
85181
  if (verdict)
84584
- return verdict === "terminal" && !!providerId && isSubscriptionProvider(providerId);
85182
+ return verdict === "terminal";
84585
85183
  if (hasQuotaExhaustionWording(errorBody))
84586
85184
  return true;
84587
- if (isSubscriptionCredentialRejection(status, errorBody, providerId))
85185
+ if (isRejectedCredentialAnswer(status, errorBody))
84588
85186
  return true;
84589
85187
  const upstream = status === 400 ? extractUpstreamStatus(errorBody) : undefined;
84590
85188
  if (upstream === 401 || upstream === 403 || upstream === 402 || upstream === 429) {
@@ -84634,7 +85232,6 @@ var init_hop_decision = __esm(() => {
84634
85232
  init_anthropic_error();
84635
85233
  init_auth_failure();
84636
85234
  init_quota_exhaustion();
84637
- init_remote_provider_types();
84638
85235
  });
84639
85236
 
84640
85237
  // src/providers/probe-hop-origin.ts
@@ -84780,7 +85377,6 @@ function chainDecisionOf(response, body, provider) {
84780
85377
  status: response.status,
84781
85378
  headers: response.headers,
84782
85379
  body,
84783
- provider,
84784
85380
  name: provider
84785
85381
  });
84786
85382
  return { chainAction: decision.action, chainReason: decision.reason };
@@ -85806,7 +86402,7 @@ function compareByConnectionPrice(a, b) {
85806
86402
  // src/providers/probe-catalog.ts
85807
86403
  import { existsSync as existsSync25, mkdirSync as mkdirSync19, readFileSync as readFileSync34, writeFileSync as writeFileSync14 } from "fs";
85808
86404
  import { homedir as homedir34 } from "os";
85809
- import { dirname as dirname16, join as join36 } from "path";
86405
+ import { dirname as dirname16, join as join37 } from "path";
85810
86406
  function describeProbeCatalogFailure(outcome) {
85811
86407
  switch (outcome.kind) {
85812
86408
  case "incompatible":
@@ -85978,7 +86574,7 @@ var init_probe_catalog = __esm(() => {
85978
86574
  init_catalog_endpoints();
85979
86575
  init_catalog_route_bindings();
85980
86576
  CACHE_TTL_MS4 = 60 * 60 * 1000;
85981
- PROBE_MODELS_CACHE_PATH = join36(homedir34(), ".claudish", "probe-models.json");
86577
+ PROBE_MODELS_CACHE_PATH = join37(homedir34(), ".claudish", "probe-models.json");
85982
86578
  });
85983
86579
 
85984
86580
  // src/providers/route-candidates.ts
@@ -86012,7 +86608,7 @@ function catalogModelId(model, cachePath) {
86012
86608
  const entries = cachePath ? readAllModelsCache(cachePath)?.entries : getCatalogEntries();
86013
86609
  return entries ? findCatalogEntry(entries, model)?.modelId : undefined;
86014
86610
  }
86015
- function gatherFromConnections(entry, candidates, excluded, unmappedRoutes, cachePath) {
86611
+ function gatherFromConnections(model, entry, candidates, excluded, unmappedRoutes, cachePath) {
86016
86612
  for (const connection of entry.aggregators ?? []) {
86017
86613
  if (connection.routeStatus !== "mapped")
86018
86614
  continue;
@@ -86021,9 +86617,10 @@ function gatherFromConnections(entry, candidates, excluded, unmappedRoutes, cach
86021
86617
  const tier = getProviderByName(provider)?.tier;
86022
86618
  if (!tier)
86023
86619
  continue;
86024
- const wireId = externalIdFor(entry, provider);
86025
- if (!wireId || wireId !== connection.externalModelId)
86620
+ const baseWireId = externalIdFor(entry, provider);
86621
+ if (!baseWireId || baseWireId !== connection.externalModelId)
86026
86622
  continue;
86623
+ const wireId = implicitEffortWireId(connection, model) ?? baseWireId;
86027
86624
  const candidate = connectionCandidate(entry, connection, provider, tier, wireId);
86028
86625
  if (tier === "subscription" && resolveSubscriptionRouting(entry.modelId, provider, cachePath).kind === "not-served") {
86029
86626
  excluded.push({ candidate, outcome: "excluded-by-membership" });
@@ -86097,6 +86694,8 @@ function catalogConnects(entry, provider) {
86097
86694
  function gatherVendorClaims(model, entry, candidates) {
86098
86695
  if (!entry || !isChatModelEntry(entry))
86099
86696
  return;
86697
+ if (isOptInWireId(model))
86698
+ return;
86100
86699
  for (const def of getAllProviders()) {
86101
86700
  if (def.tier !== "dynamic-subscription")
86102
86701
  continue;
@@ -86121,6 +86720,8 @@ function listedRow(provider, model, models, excludedIds) {
86121
86720
  return row && !isOptInWireId(row.id) ? row : undefined;
86122
86721
  }
86123
86722
  function gatherAccountListed(model, entry, lists, candidates, excluded, cachePath) {
86723
+ if (isOptInWireId(model))
86724
+ return;
86124
86725
  for (const [provider, list] of lists) {
86125
86726
  const tier = getProviderByName(provider)?.tier;
86126
86727
  if (!tier)
@@ -86174,7 +86775,7 @@ function gatherRouteCandidates(model, cachePath, lists = new Map) {
86174
86775
  const setAside = [];
86175
86776
  const unmappedRoutes = new Set;
86176
86777
  if (entry)
86177
- gatherFromConnections(entry, gathered, setAside, unmappedRoutes, cachePath);
86778
+ gatherFromConnections(model, entry, gathered, setAside, unmappedRoutes, cachePath);
86178
86779
  gatherVendorClaims(model, entry, gathered);
86179
86780
  gatherAccountListed(model, entry, lists, gathered, setAside, cachePath);
86180
86781
  const keyOf = (candidate) => JSON.stringify([candidate.provider, candidate.wireId]);
@@ -86227,6 +86828,12 @@ function catalogMapsOnlyOptIn(provider, model, cachePath) {
86227
86828
  const mapsHere = (connection) => connection.routeStatus === "mapped" && catalogRouteMatchesProvider(connection.route, provider);
86228
86829
  return !(entry.aggregators ?? []).some(mapsHere) && (entry.optInConnections ?? []).some(mapsHere);
86229
86830
  }
86831
+ function isUnvouchedOptInWireId(provider, wireId, cachePath) {
86832
+ if (!isOptInWireId(wireId))
86833
+ return false;
86834
+ const entries = cachePath ? readAllModelsCache(cachePath)?.entries : getCatalogEntries();
86835
+ return !(entries ?? []).some((entry) => (entry.aggregators ?? []).some((connection) => connection.routeStatus === "mapped" && catalogRouteMatchesProvider(connection.route, provider) && connection.externalModelId === wireId));
86836
+ }
86230
86837
  function routeOwnership(provider) {
86231
86838
  const probe = readProbeModelsCache();
86232
86839
  if (!probe)
@@ -86245,6 +86852,7 @@ var init_route_candidates = __esm(() => {
86245
86852
  init_antigravity_model_id();
86246
86853
  init_catalog_client();
86247
86854
  init_catalog_route_bindings();
86855
+ init_model_id_effort();
86248
86856
  init_registry4();
86249
86857
  init_probe_catalog();
86250
86858
  init_provider_definitions();
@@ -86512,7 +87120,7 @@ function resolveRoutingEntries(entries, originalModelName, cachePath, opts = {})
86512
87120
  }
86513
87121
  }
86514
87122
  if (!wireIdResolved) {
86515
- const externalId = resolveExternalId(modelName, provider, cachePath);
87123
+ const externalId = atIdx === -1 ? resolveImplicitExternalId(modelName, provider, cachePath) : resolveExternalId(modelName, provider, cachePath);
86516
87124
  if (externalId === null && atIdx === -1 && readsGatewayList(provider, cachePath)) {
86517
87125
  const answer = gatewayListAnswer(provider, modelName, opts.gatewayLists);
86518
87126
  if (answer.wireId === undefined) {
@@ -86529,6 +87137,13 @@ function resolveRoutingEntries(entries, originalModelName, cachePath, opts = {})
86529
87137
  modelName = externalId ?? modelName;
86530
87138
  }
86531
87139
  }
87140
+ if (atIdx === -1 && isUnvouchedOptInWireId(provider, modelName, cachePath)) {
87141
+ resolved.push({
87142
+ route: routeFor(provider, modelName),
87143
+ exclusion: "excluded-by-content-use"
87144
+ });
87145
+ continue;
87146
+ }
86532
87147
  resolved.push({ route: routeFor(provider, modelName) });
86533
87148
  }
86534
87149
  return resolved;
@@ -86550,7 +87165,7 @@ function gatewayListAnswer(provider, model, gatewayLists) {
86550
87165
  return { wireId: gatewayWireIdFor(entry?.modelId ?? model, entry?.provider, list) };
86551
87166
  }
86552
87167
  function gatewayListsNeeded(entries, model, cachePath) {
86553
- const providers = entries.filter((entry) => !entry.includes("@")).map(ruleEntryProvider).filter((provider) => readsGatewayList(provider, cachePath) && resolveExternalId(model, provider, cachePath) === null);
87168
+ const providers = entries.filter((entry) => !entry.includes("@")).map(ruleEntryProvider).filter((provider) => readsGatewayList(provider, cachePath) && resolveImplicitExternalId(model, provider, cachePath) === null);
86554
87169
  return [...new Set(providers)];
86555
87170
  }
86556
87171
  function routeFor(provider, wireId) {
@@ -87238,6 +87853,18 @@ function describeCatalogOrigin(explanation) {
87238
87853
  }
87239
87854
  return `catalog \xB7 ${firstHopPhrase(explanation)}`;
87240
87855
  }
87856
+ function droppedHopPhrase(candidate) {
87857
+ if (candidate.outcome === "kept")
87858
+ return "";
87859
+ if (candidate.outcome !== "excluded-by-content-use") {
87860
+ return DROPPED_FALLBACK_PHRASE[candidate.outcome];
87861
+ }
87862
+ if (isOptInWireId(candidate.wireId)) {
87863
+ const prefix = PROVIDER_TO_PREFIX[candidate.provider] ?? candidate.provider;
87864
+ return `would send a contributor (content-use opt-in) id, which claudish never chooses; type ${prefix}@${candidate.wireId} to opt in`;
87865
+ }
87866
+ return "maps it only through a contributor (content-use opt-in) id";
87867
+ }
87241
87868
  function describeAbsentEntry(explanation) {
87242
87869
  const head = `catalog has no entry for "${explanation.routedModel}"`;
87243
87870
  const withheld = explanation.fallbackWithheld;
@@ -87250,7 +87877,7 @@ function describeAbsentEntry(explanation) {
87250
87877
  const fallback = explanation.candidates.find((candidate) => candidate.position === "fallback");
87251
87878
  if (!fallback)
87252
87879
  return `${head} \xB7 ${firstHopPhrase(explanation)}`;
87253
- return fallback.outcome === "kept" ? `${head} \xB7 fallback only` : `${head} \xB7 fallback ${fallback.displayName} ${DROPPED_FALLBACK_PHRASE[fallback.outcome]}`;
87880
+ return fallback.outcome === "kept" ? `${head} \xB7 fallback only` : `${head} \xB7 fallback ${fallback.displayName} ${droppedHopPhrase(fallback)}`;
87254
87881
  }
87255
87882
  function firstHopPhrase(explanation) {
87256
87883
  if (explanation.outcome.kind === "no-route")
@@ -87307,7 +87934,6 @@ var init_routing_rules = __esm(() => {
87307
87934
  "credential-unreadable": "has a credential that could not be read",
87308
87935
  "not-served": "does not serve it",
87309
87936
  "excluded-by-membership": "is outside its plan's membership",
87310
- "excluded-by-content-use": "maps it only through a contributor (content-use opt-in) id",
87311
87937
  "unknown-provider": "is not a known provider shortcut",
87312
87938
  "gateway-id-unknown": "has no exact id for it in its models list"
87313
87939
  };
@@ -87834,57 +88460,23 @@ function herdrPaneEnv(env = process.env) {
87834
88460
  return detectFrontEnd(env) === "herdr" ? herdrVars(env) : null;
87835
88461
  }
87836
88462
 
87837
- // src/auth/claude-code-facts.ts
87838
- import { createHash as createHash18 } from "crypto";
87839
- import { homedir as homedir35 } from "os";
87840
- import { isAbsolute as isAbsolute2, resolve as resolve4 } from "path";
87841
- function defaultConfigDir(env) {
87842
- return resolve4(env.HOME || homedir35(), ".claude");
87843
- }
87844
- function claudeCodeConfigDir(env = process.env) {
87845
- const raw = env.CLAUDE_CONFIG_DIR?.trim();
87846
- if (!raw)
87847
- return defaultConfigDir(env);
87848
- return isAbsolute2(raw) ? resolve4(raw) : resolve4(process.cwd(), raw);
87849
- }
87850
- function configDirHash(configDir) {
87851
- return createHash18("sha256").update(configDir).digest("hex").slice(0, 8);
87852
- }
87853
- function claudeCodeSecureStorageServices(kind, env = process.env) {
87854
- const base = `${BASE_KEYCHAIN_SERVICE}${kind}`;
87855
- const secure = env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
87856
- const spellings = secure !== undefined ? secure ? [secure] : [] : env.CLAUDE_CONFIG_DIR ? [
87857
- env.CLAUDE_CONFIG_DIR,
87858
- claudeCodeConfigDir(env),
87859
- env.CLAUDE_CONFIG_DIR.replace(/\/+$/, "")
87860
- ] : [];
87861
- if (spellings.length === 0)
87862
- return [base];
87863
- return [...new Set(spellings.map((dir) => `${base}-${configDirHash(dir.normalize("NFC"))}`))];
87864
- }
87865
- function claudeCodeGlobalConfigPath(env = process.env) {
87866
- const raw = env.CLAUDE_CONFIG_DIR?.trim();
87867
- return raw ? resolve4(claudeCodeConfigDir(env), ".claude.json") : resolve4(env.HOME || homedir35(), ".claude.json");
87868
- }
87869
- var BASE_KEYCHAIN_SERVICE = "Claude Code";
87870
- var init_claude_code_facts = () => {};
87871
-
87872
88463
  // src/auth/claude-code-login.ts
87873
88464
  import { spawnSync as spawnSync2 } from "child_process";
87874
88465
  import { existsSync as existsSync26, readFileSync as readFileSync35 } from "fs";
87875
- import { join as join37 } from "path";
87876
- function keychainLoginPresent(env, presence) {
87877
- return anyPresent(claudeCodeSecureStorageServices("-credentials", env), presence) === "found";
88466
+ import { join as join38 } from "path";
88467
+ function keychainLoginPresent(env, presence, cwd = process.cwd()) {
88468
+ return anyPresent(claudeCodeSecureStorageServices("-credentials", env, cwd), presence) === "found";
87878
88469
  }
87879
88470
  function hasClaudeCodeLogin(deps = {}) {
87880
88471
  const env = deps.env ?? process.env;
88472
+ const cwd = deps.cwd ?? process.cwd();
87881
88473
  const token = env.CLAUDE_CODE_OAUTH_TOKEN;
87882
88474
  if (typeof token === "string" && token.trim().length > 0)
87883
88475
  return true;
87884
88476
  const fileExists = deps.fileExists ?? existsSync26;
87885
- if (fileExists(join37(claudeCodeConfigDir(env), ".credentials.json")))
88477
+ if (fileExists(join38(claudeCodeConfigDir(env, cwd), ".credentials.json")))
87886
88478
  return true;
87887
- return (deps.keychainProbe ?? defaultKeychainAnthropicProbe)(env);
88479
+ return (deps.keychainProbe ?? defaultKeychainAnthropicProbe)(env, cwd);
87888
88480
  }
87889
88481
  function defaultKeychainPresence(service) {
87890
88482
  if (process.platform !== "darwin")
@@ -87908,24 +88500,26 @@ function defaultKeychainPresence(service) {
87908
88500
  }
87909
88501
  function claudeCodeStartupCredential(deps = {}) {
87910
88502
  const env = deps.env ?? process.env;
88503
+ const cwd = deps.cwd ?? process.cwd();
87911
88504
  const fileExists = deps.fileExists ?? existsSync26;
87912
88505
  const readFile = deps.readFile ?? ((path) => readFileSync35(path, "utf-8"));
87913
88506
  const presence = deps.keychainPresence ?? defaultKeychainPresence;
87914
88507
  const token = env.CLAUDE_CODE_OAUTH_TOKEN;
87915
88508
  if (typeof token === "string" && token.trim().length > 0)
87916
88509
  return { kind: "login" };
87917
- if (fileExists(join37(claudeCodeConfigDir(env), ".credentials.json")))
88510
+ if (fileExists(join38(claudeCodeConfigDir(env, cwd), ".credentials.json"))) {
87918
88511
  return { kind: "login" };
87919
- const oauth = anyPresent(claudeCodeSecureStorageServices("-credentials", env), presence);
88512
+ }
88513
+ const oauth = anyPresent(claudeCodeSecureStorageServices("-credentials", env, cwd), presence);
87920
88514
  if (oauth === "found")
87921
88515
  return { kind: "login" };
87922
88516
  if (oauth === "failed")
87923
88517
  return { kind: "unknown" };
87924
- const configPath = claudeCodeGlobalConfigPath(env);
88518
+ const configPath = claudeCodeGlobalConfigPath(env, cwd);
87925
88519
  const stored = fileExists(configPath) ? configSetsConsoleKey(configPath, readFile) : "absent";
87926
88520
  if (stored === "found")
87927
88521
  return { kind: "api-key", where: configPath };
87928
- const keychainKey = anyPresent(claudeCodeSecureStorageServices("", env), presence);
88522
+ const keychainKey = anyPresent(claudeCodeSecureStorageServices("", env, cwd), presence);
87929
88523
  if (keychainKey === "found")
87930
88524
  return { kind: "api-key", where: "the macOS Keychain" };
87931
88525
  const unanswered = stored === "failed" || keychainKey === "failed";
@@ -87953,17 +88547,17 @@ function configSetsConsoleKey(path, readFile) {
87953
88547
  return "failed";
87954
88548
  }
87955
88549
  }
87956
- var macosKeychainAnthropicMemo, defaultKeychainAnthropicProbe = (env = process.env) => {
88550
+ var macosKeychainAnthropicMemo, defaultKeychainAnthropicProbe = (env = process.env, cwd = process.cwd()) => {
87957
88551
  if (process.platform !== "darwin")
87958
88552
  return false;
87959
88553
  if (process.env.CLAUDISH_DISABLE_KEYCHAIN === "1" || env.CLAUDISH_DISABLE_KEYCHAIN === "1") {
87960
88554
  return false;
87961
88555
  }
87962
- const memoKey = claudeCodeSecureStorageServices("-credentials", env).join("|");
88556
+ const memoKey = claudeCodeSecureStorageServices("-credentials", env, cwd).join("|");
87963
88557
  const memoized = macosKeychainAnthropicMemo.get(memoKey);
87964
88558
  if (memoized !== undefined)
87965
88559
  return memoized;
87966
- const found = keychainLoginPresent(env, defaultKeychainPresence);
88560
+ const found = keychainLoginPresent(env, defaultKeychainPresence, cwd);
87967
88561
  macosKeychainAnthropicMemo.set(memoKey, found);
87968
88562
  return found;
87969
88563
  }, SECURITY_ITEM_NOT_FOUND = 44;
@@ -89065,26 +89659,56 @@ var init_magmux_client = __esm(() => {
89065
89659
  });
89066
89660
 
89067
89661
  // src/pane/own-pane.ts
89068
- import { execFile as execFile3 } from "child_process";
89069
- import { promisify as promisify5 } from "util";
89070
- async function ancestorPids(maxDepth = ANCESTRY_DEPTH) {
89662
+ import { spawn } from "child_process";
89663
+ async function ancestorPids(maxDepth = ANCESTRY_DEPTH, ps = "ps") {
89071
89664
  const out = new Set([process.pid]);
89072
89665
  let pid = process.ppid;
89073
89666
  for (let i = 0;i < maxDepth && pid > 1; i++) {
89074
89667
  out.add(pid);
89668
+ const stdout = await readParentPid(ps, pid);
89669
+ if (stdout === null)
89670
+ break;
89671
+ const next = Number(stdout.trim());
89672
+ if (!Number.isFinite(next) || next <= 1)
89673
+ break;
89674
+ pid = next;
89675
+ }
89676
+ return out;
89677
+ }
89678
+ function readParentPid(ps, pid) {
89679
+ return new Promise((resolve) => {
89680
+ let settled = false;
89681
+ let child;
89682
+ let out = "";
89683
+ const timer = setTimeout(() => {
89684
+ try {
89685
+ child?.kill("SIGKILL");
89686
+ } catch {}
89687
+ finish(null);
89688
+ }, PS_TIMEOUT_MS);
89689
+ const finish = (answer) => {
89690
+ if (settled)
89691
+ return;
89692
+ settled = true;
89693
+ clearTimeout(timer);
89694
+ child?.stdout?.destroy();
89695
+ resolve(answer);
89696
+ };
89075
89697
  try {
89076
- const { stdout } = await execFileAsync2("ps", ["-o", "ppid=", "-p", String(pid)], {
89077
- timeout: 1000
89698
+ child = spawn(ps, ["-o", "ppid=", "-p", String(pid)], {
89699
+ stdio: ["ignore", "pipe", "ignore"]
89700
+ });
89701
+ child.stdout?.setEncoding("utf8").on("data", (chunk) => {
89702
+ out += chunk;
89703
+ });
89704
+ child.on("error", () => finish(null));
89705
+ child.on("exit", (code) => {
89706
+ setTimeout(() => finish(code === 0 ? out : null), PS_EXIT_DRAIN_MS);
89078
89707
  });
89079
- const next = Number(stdout.trim());
89080
- if (!Number.isFinite(next) || next <= 1)
89081
- break;
89082
- pid = next;
89083
89708
  } catch {
89084
- break;
89709
+ finish(null);
89085
89710
  }
89086
- }
89087
- return out;
89711
+ });
89088
89712
  }
89089
89713
  function panesOfList(result) {
89090
89714
  const raw = Array.isArray(result) ? result : Array.isArray(result?.panes) ? result.panes : [];
@@ -89113,14 +89737,12 @@ async function findOwnPane(list, ancestors = () => ancestorPids()) {
89113
89737
  return p.pane;
89114
89738
  return null;
89115
89739
  }
89116
- var execFileAsync2, ANCESTRY_DEPTH = 6;
89117
- var init_own_pane = __esm(() => {
89118
- execFileAsync2 = promisify5(execFile3);
89119
- });
89740
+ var ANCESTRY_DEPTH = 6, PS_TIMEOUT_MS = 1000, PS_EXIT_DRAIN_MS = 100;
89741
+ var init_own_pane = () => {};
89120
89742
 
89121
89743
  // src/pane/prompt-delivery.ts
89122
89744
  import { writeFileSync as writeFileSync15 } from "fs";
89123
- import { join as join38 } from "path";
89745
+ import { join as join39 } from "path";
89124
89746
  function stripControl(s) {
89125
89747
  let out = "";
89126
89748
  for (const ch of s) {
@@ -89187,7 +89809,7 @@ function renderTurnFile(text, limit = READ_LINE_LIMIT) {
89187
89809
  `), lines: out.length, marker };
89188
89810
  }
89189
89811
  function turnFilePath(turnDir, turnIndex) {
89190
- return join38(turnDir, `turn-${turnIndex}.md`);
89812
+ return join39(turnDir, `turn-${turnIndex}.md`);
89191
89813
  }
89192
89814
  function fileTemplate(file, marker) {
89193
89815
  const base = `Your task is in the file \`${file}\`. Read all of it with the Read tool (in parts if it is long), then do exactly what it says, treating its content as the user's message.`;
@@ -90199,7 +90821,7 @@ import {
90199
90821
  realpathSync as realpathSync5,
90200
90822
  statSync as statSync13
90201
90823
  } from "fs";
90202
- import { join as join39 } from "path";
90824
+ import { join as join40 } from "path";
90203
90825
  function initialFollowerState(resolvePath = safeRealpath) {
90204
90826
  return {
90205
90827
  turns: [],
@@ -90784,7 +91406,7 @@ class TranscriptFollower {
90784
91406
  continue;
90785
91407
  let tail = this.subs.get(f);
90786
91408
  if (!tail) {
90787
- tail = new Tail(join39(this.subagentsDir, f));
91409
+ tail = new Tail(join40(this.subagentsDir, f));
90788
91410
  this.subs.set(f, tail);
90789
91411
  }
90790
91412
  const agentId = AGENT_FILE_RE.exec(f)?.[1];
@@ -90803,7 +91425,7 @@ class TranscriptFollower {
90803
91425
  return any;
90804
91426
  }
90805
91427
  readMeta(name, agentId) {
90806
- const path = join39(this.subagentsDir, name);
91428
+ const path = join40(this.subagentsDir, name);
90807
91429
  let mtime;
90808
91430
  try {
90809
91431
  mtime = statSync13(path).mtimeMs;
@@ -90916,64 +91538,6 @@ var init_transcript_follower = __esm(() => {
90916
91538
  AGENT_META_RE = /^agent-([A-Za-z0-9_-]+)\.meta\.json$/;
90917
91539
  });
90918
91540
 
90919
- // src/mcp-session/parent-session.ts
90920
- import { readFile as readFile7 } from "fs/promises";
90921
- import { join as join40 } from "path";
90922
- function positiveInt(value) {
90923
- if (value === undefined || !/^[1-9][0-9]*$/.test(value))
90924
- return;
90925
- const n = Number(value);
90926
- return Number.isSafeInteger(n) ? n : undefined;
90927
- }
90928
- function hostPidFrom(env, ppid) {
90929
- const launcherPpid = positiveInt(env.CLAUDISH_LAUNCHER_PPID);
90930
- if (env.CLAUDISH_LAUNCHER_PID === String(ppid) && launcherPpid !== undefined && launcherPpid !== ppid) {
90931
- return { hostPid: launcherPpid, launcherPid: ppid };
90932
- }
90933
- return { hostPid: ppid };
90934
- }
90935
- function parentSessionIdFrom(env) {
90936
- const id = env.CLAUDE_CODE_SESSION_ID;
90937
- if (id === undefined || !CLAUDE_ID_RE.test(id))
90938
- return;
90939
- if (env.CLAUDE_CODE_CHILD_SESSION)
90940
- return;
90941
- return id;
90942
- }
90943
- function claudeConfigDir(env) {
90944
- const fromEnv = env.CLAUDE_CONFIG_DIR;
90945
- return fromEnv && fromEnv.length > 0 ? fromEnv : join40(userHomeFrom(env), ".claude");
90946
- }
90947
- async function readHostSessionRecord(opts) {
90948
- try {
90949
- const raw = await readFile7(join40(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
90950
- const parsed = JSON.parse(raw);
90951
- if (!parsed || typeof parsed !== "object")
90952
- return;
90953
- const rec = parsed;
90954
- if (rec.pid !== opts.hostPid)
90955
- return;
90956
- if (typeof rec.sessionId !== "string" || !CLAUDE_ID_RE.test(rec.sessionId))
90957
- return;
90958
- return { sessionId: rec.sessionId };
90959
- } catch {
90960
- return;
90961
- }
90962
- }
90963
- async function parentSessionForCall(opts) {
90964
- const env = opts.env ?? process.env;
90965
- const record = await readHostSessionRecord({
90966
- configDir: claudeConfigDir(env),
90967
- hostPid: opts.hostPid
90968
- });
90969
- return record?.sessionId ?? parentSessionIdFrom(env);
90970
- }
90971
- var CLAUDE_ID_RE;
90972
- var init_parent_session = __esm(() => {
90973
- init_home_dir();
90974
- CLAUDE_ID_RE = /^[A-Za-z0-9_-]{8,128}$/;
90975
- });
90976
-
90977
91541
  // src/session/session-discovery.ts
90978
91542
  var exports_session_discovery = {};
90979
91543
  __export(exports_session_discovery, {
@@ -90990,11 +91554,11 @@ __export(exports_session_discovery, {
90990
91554
  sessionLabel: () => sessionLabel,
90991
91555
  transcriptPathFor: () => transcriptPathFor
90992
91556
  });
90993
- import { execFile as execFile4, execFileSync as execFileSync2 } from "child_process";
91557
+ import { execFile as execFile3, execFileSync as execFileSync2 } from "child_process";
90994
91558
  import { closeSync as closeSync12, openSync as openSync12, readSync as readSync5, readdirSync as readdirSync7, realpathSync as realpathSync6, statSync as statSync14 } from "fs";
90995
91559
  import { basename as basename3, join as join41 } from "path";
90996
- function projectsDir(env = process.env) {
90997
- return join41(claudeConfigDir(env), "projects");
91560
+ function projectsDir(env = process.env, cwd = process.cwd()) {
91561
+ return join41(claudeCodeConfigDir(env, cwd), "projects");
90998
91562
  }
90999
91563
  function slugForPath(absPath) {
91000
91564
  return projectDirNameFor(absPath);
@@ -91083,7 +91647,7 @@ function sessionsIn2(dirName) {
91083
91647
  }
91084
91648
  async function enrichWorktreeGit(groups, repoRoot) {
91085
91649
  const run = (cwd, args) => new Promise((resolve) => {
91086
- execFile4("git", args, { cwd, encoding: "utf-8" }, (err, stdout) => resolve(err ? "" : stdout));
91650
+ execFile3("git", args, { cwd, encoding: "utf-8" }, (err, stdout) => resolve(err ? "" : stdout));
91087
91651
  });
91088
91652
  const trackByBranch = new Map;
91089
91653
  const refs = await run(repoRoot, [
@@ -91422,8 +91986,8 @@ function findLatestSessionId(cwd = process.cwd(), sinceMs = 0) {
91422
91986
  }
91423
91987
  var ENTRYPOINT_BYTES = 8192, ACTIVE_WINDOW_MS = 120000, HEAD_BYTES, TAIL_BYTES, HARNESS_ENVELOPES, DEEP_TAIL_BYTES, RECENT_AI_TURNS = 5, RECENT_USER_TURNS = 1;
91424
91988
  var init_session_discovery = __esm(() => {
91989
+ init_claude_code_facts();
91425
91990
  init_home_dir();
91426
- init_parent_session();
91427
91991
  HEAD_BYTES = 64 * 1024;
91428
91992
  TAIL_BYTES = 128 * 1024;
91429
91993
  HARNESS_ENVELOPES = [
@@ -92793,7 +93357,7 @@ var init_cache_ttl = __esm(() => {
92793
93357
 
92794
93358
  // src/model-loader.ts
92795
93359
  import { existsSync as existsSync31, readFileSync as readFileSync37 } from "fs";
92796
- import { homedir as homedir36 } from "os";
93360
+ import { homedir as homedir35 } from "os";
92797
93361
  import { join as join45 } from "path";
92798
93362
  function isRecommendationTier(value) {
92799
93363
  return typeof value === "string" && RECOMMENDATION_TIER_INDEX.has(value);
@@ -92938,17 +93502,17 @@ function recommendationProjection(recommendations, richModels = []) {
92938
93502
  plans: cache.plans
92939
93503
  } : { catalogGenerationId: "", entries: [], plans: [] }, richModels);
92940
93504
  }
92941
- function isRecord5(value) {
93505
+ function isRecord6(value) {
92942
93506
  return value !== null && typeof value === "object" && !Array.isArray(value);
92943
93507
  }
92944
93508
  function isStringArray(value) {
92945
93509
  return Array.isArray(value) && value.every((item) => typeof item === "string");
92946
93510
  }
92947
93511
  function isRouteObject(value) {
92948
- return isRecord5(value) && typeof value.plan === "string" && typeof value.command === "string" && (value.prefix === undefined || typeof value.prefix === "string") && (value.planIds === undefined || isStringArray(value.planIds));
93512
+ return isRecord6(value) && typeof value.plan === "string" && typeof value.command === "string" && (value.prefix === undefined || typeof value.prefix === "string") && (value.planIds === undefined || isStringArray(value.planIds));
92949
93513
  }
92950
93514
  function isUsableRow(value) {
92951
- if (!isRecord5(value))
93515
+ if (!isRecord6(value))
92952
93516
  return false;
92953
93517
  if (typeof value.id !== "string" || value.id.length === 0)
92954
93518
  return false;
@@ -92960,7 +93524,7 @@ function isUsableRow(value) {
92960
93524
  return false;
92961
93525
  }
92962
93526
  const pricing = value.pricing;
92963
- if (!isRecord5(pricing) || typeof pricing.input !== "string" || typeof pricing.output !== "string" || typeof pricing.average !== "string") {
93527
+ if (!isRecord6(pricing) || typeof pricing.input !== "string" || typeof pricing.output !== "string" || typeof pricing.average !== "string") {
92964
93528
  return false;
92965
93529
  }
92966
93530
  if (value.releaseDate !== undefined && typeof value.releaseDate !== "string")
@@ -92973,7 +93537,7 @@ function isUsableRow(value) {
92973
93537
  return true;
92974
93538
  }
92975
93539
  function readProjectedRecommendationsDoc(value) {
92976
- if (!isRecord5(value))
93540
+ if (!isRecord6(value))
92977
93541
  return null;
92978
93542
  if (value.contractVersion !== 3)
92979
93543
  return null;
@@ -93004,8 +93568,8 @@ function readRecommendedModelsCacheFile() {
93004
93568
  log(`[recommended] unreadable ${RECOMMENDED_MODELS_CACHE_PATH}: ${err instanceof Error ? err.message : String(err)}`);
93005
93569
  return null;
93006
93570
  }
93007
- if (!isRecord5(parsed) || parsed.projectionVersion !== RECOMMENDED_PROJECTION_VERSION) {
93008
- log(`[recommended] ${RECOMMENDED_MODELS_CACHE_PATH} has projection version ${isRecord5(parsed) ? String(parsed.projectionVersion) : "none"}; this build reads ${RECOMMENDED_PROJECTION_VERSION}`);
93571
+ if (!isRecord6(parsed) || parsed.projectionVersion !== RECOMMENDED_PROJECTION_VERSION) {
93572
+ log(`[recommended] ${RECOMMENDED_MODELS_CACHE_PATH} has projection version ${isRecord6(parsed) ? String(parsed.projectionVersion) : "none"}; this build reads ${RECOMMENDED_PROJECTION_VERSION}`);
93009
93573
  return null;
93010
93574
  }
93011
93575
  return readProjectedRecommendationsDoc(parsed);
@@ -93376,7 +93940,7 @@ var init_model_loader = __esm(() => {
93376
93940
  { recommendationTier: "subscription", title: "Subscription", quickPickEligible: true }
93377
93941
  ];
93378
93942
  RECOMMENDATION_TIER_INDEX = new Map(RECOMMENDATION_SECTIONS.map((section, index) => [section.recommendationTier, index]));
93379
- RECOMMENDED_MODELS_CACHE_PATH = join45(homedir36(), ".claudish", "recommended-models-cache-v2.json");
93943
+ RECOMMENDED_MODELS_CACHE_PATH = join45(homedir35(), ".claudish", "recommended-models-cache-v2.json");
93380
93944
  RECOMMENDED_ROUTE_TIER_ORDER = {
93381
93945
  native: 0,
93382
93946
  general: 1,
@@ -94703,7 +95267,7 @@ var init_DiscoveryNotice = __esm(() => {
94703
95267
 
94704
95268
  // src/providers/model-descriptions.ts
94705
95269
  import { existsSync as existsSync32, mkdirSync as mkdirSync21, readFileSync as readFileSync38, writeFileSync as writeFileSync17 } from "fs";
94706
- import { homedir as homedir37 } from "os";
95270
+ import { homedir as homedir36 } from "os";
94707
95271
  import { dirname as dirname18, join as join46 } from "path";
94708
95272
  function emptyDescriptionIndex() {
94709
95273
  return EMPTY_INDEX;
@@ -94797,7 +95361,7 @@ var init_model_descriptions = __esm(() => {
94797
95361
  init_logger();
94798
95362
  init_model_loader();
94799
95363
  init_cache_ttl();
94800
- MODEL_DESCRIPTIONS_CACHE_PATH = join46(homedir37(), ".claudish", "model-descriptions.json");
95364
+ MODEL_DESCRIPTIONS_CACHE_PATH = join46(homedir36(), ".claudish", "model-descriptions.json");
94801
95365
  EMPTY_INDEX = { get: () => {
94802
95366
  return;
94803
95367
  }, size: 0 };
@@ -101045,15 +101609,15 @@ var init_branding = __esm(() => {
101045
101609
 
101046
101610
  // src/update-checker.ts
101047
101611
  import { existsSync as existsSync33, mkdirSync as mkdirSync22, readFileSync as readFileSync39, unlinkSync as unlinkSync9, writeFileSync as writeFileSync18 } from "fs";
101048
- import { homedir as homedir38, platform as platform2, tmpdir } from "os";
101612
+ import { homedir as homedir37, platform as platform2, tmpdir } from "os";
101049
101613
  import { join as join47 } from "path";
101050
101614
  function getCacheFilePath() {
101051
101615
  let cacheDir;
101052
101616
  if (isWindows) {
101053
- const localAppData = process.env.LOCALAPPDATA || join47(homedir38(), "AppData", "Local");
101617
+ const localAppData = process.env.LOCALAPPDATA || join47(homedir37(), "AppData", "Local");
101054
101618
  cacheDir = join47(localAppData, "claudish");
101055
101619
  } else {
101056
- cacheDir = join47(homedir38(), ".cache", "claudish");
101620
+ cacheDir = join47(homedir37(), ".cache", "claudish");
101057
101621
  }
101058
101622
  try {
101059
101623
  if (!existsSync33(cacheDir)) {
@@ -102817,7 +103381,8 @@ function claudeAdvisorModelFor(model) {
102817
103381
  }
102818
103382
  const tier = claudeCodeTierAlias(normalized);
102819
103383
  if (tier) {
102820
- const resolved = findEntryByAlias(tier)?.modelId ?? latestAnthropicTierModelId(tier);
103384
+ const notOptIn = (modelId) => !isOptInWireId(modelId);
103385
+ const resolved = findEntryByAlias(tier, notOptIn)?.modelId ?? latestAnthropicTierModelId(tier, notOptIn);
102821
103386
  if (resolved)
102822
103387
  return { refused: false, id: resolved };
102823
103388
  return {
@@ -102889,7 +103454,6 @@ class FallbackHandler {
102889
103454
  status: response.status,
102890
103455
  headers: response.headers,
102891
103456
  body: errorBody,
102892
- provider,
102893
103457
  name
102894
103458
  });
102895
103459
  switch (decision.reason) {
@@ -102904,7 +103468,7 @@ class FallbackHandler {
102904
103468
  logStderr(`[Fallback] ${name}: credential ${verdict === "terminal" ? "rejected" : "temporarily unavailable"} \u2014 stopping the chain here.`);
102905
103469
  }
102906
103470
  return response;
102907
- case "subscription-credential-rejected": {
103471
+ case "credential-rejected": {
102908
103472
  errors.push({ provider: name, status: response.status, message: errorBody });
102909
103473
  if (!firstRejection)
102910
103474
  firstRejection = { name, response, body: errorBody };
@@ -102924,7 +103488,8 @@ class FallbackHandler {
102924
103488
  errors.push({ provider: name, status: response.status, message: errorBody });
102925
103489
  if (!isLast) {
102926
103490
  if (hasQuotaExhaustionWording(errorBody)) {
102927
- logStderr(`[Fallback] ${name} subscription allowance is spent \u2014 falling through to the next provider, which is billed PER TOKEN. Use a provider prefix (e.g. \`zgo@model\`) to fail instead of switching.`);
103491
+ const next = this.candidates[(idx + 1) % this.candidates.length];
103492
+ announceSpentAllowance({ name, provider }, response.status, errorBody, next);
102928
103493
  } else {
102929
103494
  logStderr(`[Fallback] ${name} failed (HTTP ${response.status}), trying next provider...`);
102930
103495
  }
@@ -102991,6 +103556,14 @@ function announceCredentialRejection(rejected, status, errorBody, next) {
102991
103556
  announcedRejections.add(key);
102992
103557
  logStderr(line);
102993
103558
  }
103559
+ function announceSpentAllowance(spent, status, errorBody, next) {
103560
+ const upstreamStatus = (status === 400 ? extractUpstreamStatus(errorBody) : undefined) ?? status;
103561
+ const providerMessage = truncate3(parseProviderMessage(redactForClient(errorBody)).replace(/\s+/g, " ").trim(), 200);
103562
+ const shortcut = spent.provider ? getShortestPrefix(spent.provider) : "";
103563
+ const pin = shortcut ? ` Name the provider (${shortcut}@\u2026) to stop here instead of switching.` : "";
103564
+ const spentBilling = spent.provider && isSubscriptionProvider(spent.provider) ? "subscription" : "metered";
103565
+ logStderr(`[Fallback] ${spent.name} (${spentBilling}) has no allowance or balance left ` + `(${upstreamStatus}: ${providerMessage}) \u2014 moving to ${next.name} (${hopBillingWords(next.provider)}).${pin}`);
103566
+ }
102994
103567
  function exhaustedChainStatus(errors) {
102995
103568
  if (errors.length === 0)
102996
103569
  return 400;
@@ -103032,6 +103605,7 @@ function truncate3(s, max) {
103032
103605
  var announcedRejections;
103033
103606
  var init_fallback_handler = __esm(() => {
103034
103607
  init_logger();
103608
+ init_provider_definitions();
103035
103609
  init_redact();
103036
103610
  init_composed_handler();
103037
103611
  init_anthropic_error();
@@ -103351,7 +103925,7 @@ async function classifyHandler(handler, hop) {
103351
103925
  kind: "refused",
103352
103926
  handler,
103353
103927
  message: refusalMessageOf(body),
103354
- chainContinues: isRetryableError(response.status, body, hop.displayName, response.headers, hop.provider)
103928
+ chainContinues: isRetryableError(response.status, body, hop.displayName, response.headers)
103355
103929
  };
103356
103930
  }
103357
103931
  if (handler instanceof ComposedHandler) {
@@ -105541,7 +106115,7 @@ var init_bundled_tagged_cache = __esm(() => {
105541
106115
 
105542
106116
  // src/services/pricing-cache.ts
105543
106117
  import { existsSync as existsSync34, readFileSync as readFileSync40, statSync as statSync16 } from "fs";
105544
- import { homedir as homedir39 } from "os";
106118
+ import { homedir as homedir38 } from "os";
105545
106119
  import { join as join48 } from "path";
105546
106120
  function prefixMatch(modelName) {
105547
106121
  for (const [key, pricing] of pricingMap) {
@@ -105614,7 +106188,7 @@ var init_pricing_cache = __esm(() => {
105614
106188
  init_catalog_client();
105615
106189
  init_catalog_route_bindings();
105616
106190
  pricingMap = new Map;
105617
- CACHE_DIR = join48(homedir39(), ".claudish");
106191
+ CACHE_DIR = join48(homedir38(), ".claudish");
105618
106192
  CACHE_FILE = join48(CACHE_DIR, "pricing-cache.json");
105619
106193
  CACHE_TTL_MS5 = 24 * 60 * 60 * 1000;
105620
106194
  });
@@ -108636,14 +109210,14 @@ import {
108636
109210
  readdirSync as readdirSync8,
108637
109211
  unlinkSync as unlinkSync10
108638
109212
  } from "fs";
108639
- import { homedir as homedir40 } from "os";
109213
+ import { homedir as homedir39 } from "os";
108640
109214
  import { dirname as dirname19, join as join50 } from "path";
108641
109215
  import { fileURLToPath as fileURLToPath2 } from "url";
108642
109216
  function getVersion3() {
108643
109217
  return VERSION;
108644
109218
  }
108645
109219
  function clearAllModelCaches() {
108646
- const cacheDir = join50(homedir40(), ".claudish");
109220
+ const cacheDir = join50(homedir39(), ".claudish");
108647
109221
  if (!existsSync35(cacheDir))
108648
109222
  return;
108649
109223
  const cachePatterns = ["pricing-cache.json", "recommended-models-cache-v2.json"];
@@ -110556,9 +111130,9 @@ function samePaneSize(a, b) {
110556
111130
  var DEFAULT_PANE_COLS = 160, DEFAULT_PANE_ROWS = 50, MIN_PANE_COLS = 40, MAX_PANE_COLS = 9999, MIN_PANE_ROWS = 24, MAX_PANE_ROWS = 9999, MAX_PANE_CELLS = 4000000, RESIZE_QUIET_MS = 2000;
110557
111131
 
110558
111132
  // src/pane/process-identity.ts
110559
- import { execFile as execFile5, execFileSync as execFileSync3 } from "child_process";
111133
+ import { execFile as execFile4, execFileSync as execFileSync3 } from "child_process";
110560
111134
  import { lstatSync as lstatSync6 } from "fs";
110561
- import { basename as basename4, dirname as dirname20, isAbsolute as isAbsolute3, join as join51, normalize } from "path";
111135
+ import { basename as basename4, dirname as dirname20, isAbsolute as isAbsolute2, join as join51, normalize } from "path";
110562
111136
  function collapse2(s) {
110563
111137
  return s.trim().replace(/\s+/g, " ");
110564
111138
  }
@@ -110629,13 +111203,45 @@ function readProcessTableAsync(cancelAfterMs) {
110629
111203
  const options = cancelAfterMs === undefined ? PS_OPTIONS : { ...PS_OPTIONS, timeout: cancelAfterMs, killSignal: "SIGKILL" };
110630
111204
  return new Promise((resolve) => {
110631
111205
  const spawnedAt = Date.now();
111206
+ let settled = false;
111207
+ let child;
111208
+ let cancel;
111209
+ const finish = (stdout) => {
111210
+ if (settled)
111211
+ return;
111212
+ settled = true;
111213
+ clearTimeout(cancel);
111214
+ child?.stdout?.destroy?.();
111215
+ resolve(tableOf(stdout, spawnedAt));
111216
+ };
111217
+ if (cancelAfterMs !== undefined) {
111218
+ cancel = setTimeout(() => {
111219
+ try {
111220
+ child?.kill?.("SIGKILL");
111221
+ } catch {}
111222
+ finish(null);
111223
+ }, cancelAfterMs);
111224
+ }
110632
111225
  try {
110633
- psSpawn.execFile("ps", PS_ARGS, options, (err, stdout) => resolve(tableOf(err ? null : String(stdout), spawnedAt)));
111226
+ const spawned = psSpawn.execFile("ps", PS_ARGS, options, (err, stdout) => finish(err ? null : String(stdout)));
111227
+ if (settled || !isPsChild(spawned))
111228
+ return;
111229
+ child = spawned;
111230
+ const chunks = [];
111231
+ child.stdout?.on("data", (chunk) => {
111232
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), "utf8"));
111233
+ });
111234
+ child.on("exit", (code) => {
111235
+ setTimeout(() => finish(code === 0 ? Buffer.concat(chunks).toString("utf8") : null), PS_EXIT_DRAIN_MS2);
111236
+ });
110634
111237
  } catch {
110635
- resolve(tableOf(null, spawnedAt));
111238
+ finish(null);
110636
111239
  }
110637
111240
  });
110638
111241
  }
111242
+ function isPsChild(value) {
111243
+ return typeof value?.on === "function";
111244
+ }
110639
111245
  function magmuxNeedle(paneId) {
110640
111246
  return `--id ${paneId} --sock-dir`;
110641
111247
  }
@@ -110800,7 +111406,7 @@ function isPaneRecordPath(root, p, paneId) {
110800
111406
  return isValidPaneId(paneId) && dirname20(p) === join51(root, "panes") && basename4(p) === `${paneId}.json`;
110801
111407
  }
110802
111408
  function isForkRecordPath(projectsRoot, p, uuid) {
110803
- if (!isAbsolute3(projectsRoot) || normalize(projectsRoot) !== projectsRoot)
111409
+ if (!isAbsolute2(projectsRoot) || normalize(projectsRoot) !== projectsRoot)
110804
111410
  return false;
110805
111411
  if (basename4(projectsRoot) !== "projects" || !FORK_UUID_RE.test(uuid))
110806
111412
  return false;
@@ -110826,7 +111432,7 @@ function watcherArgv(a) {
110826
111432
  function isPaneWatcherCommand(command, paneId) {
110827
111433
  return command.includes(` ${WATCHER_ARGV0} ${paneId} `);
110828
111434
  }
110829
- var PS_ARGS, PS_ROW, START_TOLERANCE_MS = 2000, PS_ENV, PS_OPTIONS, psSpawn, LAUNCH_DIR_RE, PANE_ID_RE, FORK_UUID_RE, PROJECT_SLUG_RE, WATCHER_FUNCTIONS = `
111435
+ var PS_ARGS, PS_ROW, START_TOLERANCE_MS = 2000, PS_ENV, PS_OPTIONS, psSpawn, PS_EXIT_DRAIN_MS2 = 100, LAUNCH_DIR_RE, PANE_ID_RE, FORK_UUID_RE, PROJECT_SLUG_RE, WATCHER_FUNCTIONS = `
110830
111436
  set -f
110831
111437
  export LC_ALL=C
110832
111438
  PANE=$1 UUID=$2 CTL=$3 SOCKP=$4 REC=$5 TURN=$6 ROOT=$7 PROJ=$8 FORK=$9 FORKDIR=\${10}
@@ -110921,7 +111527,7 @@ var init_process_identity = __esm(() => {
110921
111527
  PS_ROW = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(?:((?:\d+-)?(?:\d+:)?\d+:\d+)\s+)?(\S+\s+\S+\s+\d+\s+\d\d:\d\d:\d\d\s+\d{4})\s?(.*)$/;
110922
111528
  PS_ENV = { PATH: "/bin:/usr/bin:/usr/sbin:/sbin", LC_ALL: "C" };
110923
111529
  PS_OPTIONS = { env: PS_ENV, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 };
110924
- psSpawn = { execFile: execFile5, execFileSync: execFileSync3 };
111530
+ psSpawn = { execFile: execFile4, execFileSync: execFileSync3 };
110925
111531
  LAUNCH_DIR_RE = /^launch-[A-Za-z0-9]{6}$/;
110926
111532
  PANE_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
110927
111533
  FORK_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
@@ -110930,7 +111536,7 @@ var init_process_identity = __esm(() => {
110930
111536
  });
110931
111537
 
110932
111538
  // src/pane/pane-launch.ts
110933
- import { spawn } from "child_process";
111539
+ import { spawn as spawn2 } from "child_process";
110934
111540
  import { randomBytes as randomBytes15 } from "crypto";
110935
111541
  import {
110936
111542
  chmodSync as chmodSync4,
@@ -111037,13 +111643,20 @@ function buildPaneEnv(input) {
111037
111643
  env.SHELL = join52(input.ctlDir, "sh-shim");
111038
111644
  return { magmuxEnv: env };
111039
111645
  }
111040
- function buildReplayEnv(input) {
111646
+ function inheritedReplayEnv(parentEnv) {
111041
111647
  const env = {};
111042
111648
  for (const k of REPLAY_ENV_ALLOWLIST) {
111043
- const v = input.parentEnv[k];
111649
+ const v = parentEnv[k];
111044
111650
  if (v)
111045
111651
  env[k] = v;
111046
111652
  }
111653
+ return env;
111654
+ }
111655
+ function replayConfigDirOverride(parentEnv, cwd, configDir) {
111656
+ return configDir !== claudeCodeConfigDir(inheritedReplayEnv(parentEnv), cwd) ? configDir : undefined;
111657
+ }
111658
+ function buildReplayEnv(input) {
111659
+ const env = inheritedReplayEnv(input.parentEnv);
111047
111660
  if (input.configDirOverride)
111048
111661
  env.CLAUDE_CONFIG_DIR = input.configDirOverride;
111049
111662
  env.SHELL = join52(input.ctlDir, "sh-shim");
@@ -111317,7 +111930,7 @@ function runMagmuxVersion(found, timeoutMs, drainMs = EXIT_DRAIN_MS) {
111317
111930
  done();
111318
111931
  };
111319
111932
  try {
111320
- child = spawn(found, ["--version"], { stdio: ["ignore", "pipe", "pipe"] });
111933
+ child = spawn2(found, ["--version"], { stdio: ["ignore", "pipe", "pipe"] });
111321
111934
  child.stdout?.setEncoding("utf8").on("data", read);
111322
111935
  child.stderr?.setEncoding("utf8").on("data", read);
111323
111936
  child.on("error", (e) => fail(e.message));
@@ -111374,7 +111987,7 @@ function writeLauncherFiles(ctlDir, script) {
111374
111987
  writeFileSync19(join52(ctlDir, "sh-shim"), SHELL_SHIM, { mode: 448, flag: "wx" });
111375
111988
  }
111376
111989
  function spawnPaneWatcher(args) {
111377
- const proc = spawn("/bin/sh", watcherArgv(args), {
111990
+ const proc = spawn2("/bin/sh", watcherArgv(args), {
111378
111991
  stdio: ["pipe", "ignore", "ignore"],
111379
111992
  detached: true,
111380
111993
  env: { PATH: "/bin:/usr/bin:/usr/sbin:/sbin", LC_ALL: "C" }
@@ -111405,7 +112018,7 @@ function paneMagmuxArgv(input) {
111405
112018
  ];
111406
112019
  }
111407
112020
  function spawnPaneMagmux(input) {
111408
- const proc = spawn(input.binary, paneMagmuxArgv(input), {
112021
+ const proc = spawn2(input.binary, paneMagmuxArgv(input), {
111409
112022
  cwd: input.cwd,
111410
112023
  env: input.env,
111411
112024
  stdio: ["ignore", "ignore", "pipe"],
@@ -111431,7 +112044,7 @@ function spawnReplayMagmux(input) {
111431
112044
  const stdio = ["ignore", "ignore", "pipe"];
111432
112045
  if (input.holdFd !== undefined)
111433
112046
  stdio.push(input.holdFd);
111434
- const proc = spawn(input.binary, replayMagmuxArgv(input), {
112047
+ const proc = spawn2(input.binary, replayMagmuxArgv(input), {
111435
112048
  cwd: input.cwd,
111436
112049
  env: input.env,
111437
112050
  stdio,
@@ -111445,6 +112058,7 @@ var SOCK_ROOT, PaneRootError, OWNER_START36, TERMINAL_IDENTITY_VARS, TERMINAL_ID
111445
112058
  exec /bin/sh "$@"
111446
112059
  `, FATAL_MAGMUX_STDERR;
111447
112060
  var init_pane_launch = __esm(() => {
112061
+ init_claude_code_facts();
111448
112062
  init_cli();
111449
112063
  init_config();
111450
112064
  init_magmux_binary();
@@ -112148,7 +112762,7 @@ var init_terminal_isolation = __esm(() => {
112148
112762
  });
112149
112763
 
112150
112764
  // src/claude-runner.ts
112151
- import { spawn as spawn2 } from "child_process";
112765
+ import { spawn as spawn3 } from "child_process";
112152
112766
  import { randomUUID as randomUUID7 } from "crypto";
112153
112767
  import {
112154
112768
  chmodSync as chmodSync5,
@@ -112164,7 +112778,7 @@ import {
112164
112778
  unlinkSync as unlinkSync11,
112165
112779
  writeFileSync as writeFileSync20
112166
112780
  } from "fs";
112167
- import { homedir as homedir41, tmpdir as tmpdir2 } from "os";
112781
+ import { homedir as homedir40, tmpdir as tmpdir2 } from "os";
112168
112782
  import { dirname as dirname21, join as join53, resolve as resolve6 } from "path";
112169
112783
  import { isatty } from "tty";
112170
112784
  function releaseTerminalIsolation() {
@@ -112219,12 +112833,20 @@ function wantsAnthropicApiBilling(config, env = process.env) {
112219
112833
  return false;
112220
112834
  }
112221
112835
  }
112222
- function shouldHideIncidentalAnthropicKey(config, env = process.env) {
112223
- if (!hasNativeAnthropicMapping(config))
112224
- return false;
112836
+ function shouldHideIncidentalAnthropicKey(config, env = process.env, loginDeps = { env }) {
112225
112837
  if (!env.ANTHROPIC_API_KEY)
112226
112838
  return false;
112227
- return !wantsAnthropicApiBilling(config, env);
112839
+ const nativeMapping = hasNativeAnthropicMapping(config);
112840
+ if (!nativeMapping && !classifierPassthroughEnabled(config))
112841
+ return false;
112842
+ if (wantsAnthropicApiBilling(config, env))
112843
+ return false;
112844
+ if (nativeMapping)
112845
+ return true;
112846
+ return hasClaudeCodeLogin(loginDeps);
112847
+ }
112848
+ function hiddenAnthropicKeyNotice(config, nativeMapping) {
112849
+ return `[claudish] ANTHROPIC_API_KEY found but hidden so it can't override ${nativeMapping ? "that subscription" : "your Claude Code subscription"} \xB7 ` + (nativeMapping ? "" : "image descriptions for a non-vision main model are off \xB7 ") + (config.claudeSubscriptionPin ? "use anthropic@<id> to bill the Claude API instead" : "use --anthropic-api-billing (or anthropicApiBilling: true) to bill the API instead");
112228
112850
  }
112229
112851
  function applyProxyPlaceholderAuth(env, paneChild = isPaneChild()) {
112230
112852
  env.ANTHROPIC_AUTH_TOKEN = CLAUDISH_PLACEHOLDER_AUTH_TOKEN;
@@ -112277,7 +112899,7 @@ function childAuthControl(config, env = process.env, deps = {}) {
112277
112899
  if (isRealAnthropicEnvCredential(env, "ANTHROPIC_AUTH_TOKEN")) {
112278
112900
  return { controlled: false, reason: "user-auth-token", where: "environment" };
112279
112901
  }
112280
- if (isRealAnthropicEnvCredential(env, "ANTHROPIC_API_KEY") && !shouldHideIncidentalAnthropicKey(config, env)) {
112902
+ if (isRealAnthropicEnvCredential(env, "ANTHROPIC_API_KEY") && !shouldHideIncidentalAnthropicKey(config, env, childLoginDeps(env, deps))) {
112281
112903
  return { controlled: false, reason: "user-api-key", where: "environment" };
112282
112904
  }
112283
112905
  }
@@ -112300,12 +112922,21 @@ function childAuthControl(config, env = process.env, deps = {}) {
112300
112922
  }
112301
112923
  return { controlled: true };
112302
112924
  }
112925
+ function childLoginDeps(env, deps) {
112926
+ const childEnv = deps.home === undefined ? env : { ...env, HOME: deps.home };
112927
+ return {
112928
+ env: childEnv,
112929
+ ...deps.cwd === undefined ? {} : { cwd: deps.cwd },
112930
+ ...deps.loginDeps
112931
+ };
112932
+ }
112303
112933
  function settingsCredentialFindings(config, env = process.env, deps = {}) {
112304
112934
  const findings = [];
112305
112935
  if (customHeadersSignWithKey(env.ANTHROPIC_CUSTOM_HEADERS)) {
112306
112936
  findings.push({ where: "environment", kind: "custom-headers-auth" });
112307
112937
  }
112308
- for (const layer of claudeSettingsLayers(config, env, deps)) {
112938
+ const layers = claudeSettingsLayers(config.claudeArgs ?? [], env, deps, settingsArgScopeOf(config));
112939
+ for (const layer of layers) {
112309
112940
  const where = layer.file ?? layer.where;
112310
112941
  if (layer.settings === null) {
112311
112942
  findings.push({ where, kind: "unreadable" });
@@ -112383,13 +113014,8 @@ function settingsArgOccurrences(args) {
112383
113014
  function settingsArgScopeOf(config) {
112384
113015
  return config.modelLineup?.picker ? "every" : "first";
112385
113016
  }
112386
- function settingsArgValues(claudeArgs, scope) {
112387
- if (scope === "every") {
112388
- return settingsArgOccurrences(claudeArgs).flatMap((o) => o.value ? [o.value] : []);
112389
- }
112390
- const idx = claudeArgs.indexOf("--settings");
112391
- const value = idx === -1 ? undefined : claudeArgs[idx + 1];
112392
- return value ? [value] : [];
113017
+ function discoverySettingsLayers(claudeArgs, cwd, { scope = "first", env = process.env, deps = {} }) {
113018
+ return claudeSettingsLayers(claudeArgs, env, { ...deps, cwd }, scope).filter((layer) => !layer.droppedByMerge);
112393
113019
  }
112394
113020
  function customHeaderAuthNames(value) {
112395
113021
  const names = new Set;
@@ -112429,13 +113055,13 @@ function settingsAuthSource(settings) {
112429
113055
  return null;
112430
113056
  }
112431
113057
  function readableClaudeSettingsLayers(config, env, deps) {
112432
- return claudeSettingsLayers(config, env, deps).filter((layer) => !layer.droppedByMerge);
113058
+ return claudeSettingsLayers(config.claudeArgs ?? [], env, deps, settingsArgScopeOf(config)).filter((layer) => !layer.droppedByMerge);
112433
113059
  }
112434
- function claudeSettingsLayers(config, env, deps) {
113060
+ function claudeSettingsLayers(claudeArgs, env, deps, scope) {
112435
113061
  const readFile = deps.readFile ?? ((path) => readFileSync43(path, "utf-8"));
112436
- const home = deps.home ?? homedir41();
113062
+ const home = deps.home ?? (env.HOME ? env.HOME : homedir40());
112437
113063
  const cwd = deps.cwd ?? process.cwd();
112438
- const enabled = enabledSettingSources(config.claudeArgs ?? []);
113064
+ const enabled = enabledSettingSources(claudeArgs);
112439
113065
  const on = (source) => enabled === null || enabled.has(source);
112440
113066
  const files = [
112441
113067
  [managedSettingsPath(), "managed"],
@@ -112449,25 +113075,26 @@ function claudeSettingsLayers(config, env, deps) {
112449
113075
  if (settings)
112450
113076
  layers.push({ where: file, settings, tier });
112451
113077
  }
112452
- const occurrences = settingsArgOccurrences(config.claudeArgs ?? []);
112453
- const merged = occurrences.find((o) => o.spelling === "separate");
113078
+ const occurrences = settingsArgOccurrences(claudeArgs);
113079
+ const first = occurrences.find((o) => o.spelling === "separate");
113080
+ const isMerged = (occurrence) => scope === "every" || occurrence === first;
112454
113081
  occurrences.forEach((occurrence, i) => {
112455
113082
  const where = occurrences.length > 1 ? `--settings (occurrence ${i + 1})` : "--settings";
112456
113083
  if (!occurrence.value)
112457
113084
  return;
112458
113085
  const settings = readSettingsSource(occurrence.value, readFile);
112459
113086
  const file = isInlineSettings(occurrence.value) ? {} : { file: occurrence.value };
112460
- if (occurrence === merged && !settings) {
113087
+ if (isMerged(occurrence) && !settings) {
112461
113088
  layers.push({ where, settings, tier: "cli", droppedByMerge: true, ...file });
112462
113089
  return;
112463
113090
  }
112464
- layers.push({ where, settings, tier: "cli", ...file });
113091
+ const mergedMark = isMerged(occurrence) ? { merged: true } : {};
113092
+ layers.push({ where, settings, tier: "cli", ...file, ...mergedMark });
112465
113093
  });
112466
113094
  return layers;
112467
113095
  }
112468
113096
  function userSettingsFile(configDir, home, cwd) {
112469
- const dir = (configDir ?? join53(home, ".claude")).normalize("NFC");
112470
- return join53(resolve6(cwd, dir), "settings.json");
113097
+ return join53(claudeCodeConfigDir({ CLAUDE_CONFIG_DIR: configDir, HOME: home }, cwd), "settings.json");
112471
113098
  }
112472
113099
  function localSettingsFiles(cwd, readFile, pathKind) {
112473
113100
  const cwdFile = join53(cwd, ".claude", "settings.local.json");
@@ -112559,7 +113186,8 @@ function modelPickerSources(config, env = process.env, deps = {}) {
112559
113186
  let userRank = -1;
112560
113187
  let managed = null;
112561
113188
  const availableModels = [];
112562
- claudeSettingsLayers(config, env, deps).forEach((layer, index) => {
113189
+ const layers = claudeSettingsLayers(config.claudeArgs ?? [], env, deps, settingsArgScopeOf(config));
113190
+ layers.forEach((layer, index) => {
112563
113191
  const settings = layer.settings;
112564
113192
  if (settings === null)
112565
113193
  return;
@@ -112877,32 +113505,36 @@ function parseSettingsArg(value) {
112877
113505
  }
112878
113506
  return JSON.parse(readFileSync43(value, "utf-8"));
112879
113507
  }
112880
- function parseSettingsArgSafe(value) {
113508
+ function highestTierValues(layers, key, tiers) {
113509
+ for (const tier of SETTINGS_TIER_ORDER) {
113510
+ if (!tiers.includes(tier))
113511
+ continue;
113512
+ const values = [];
113513
+ for (const layer of layers) {
113514
+ if (layer.tier === tier && layer.settings !== null && key in layer.settings) {
113515
+ values.push(layer.settings[key]);
113516
+ }
113517
+ }
113518
+ if (values.length > 0)
113519
+ return values;
113520
+ }
113521
+ return;
113522
+ }
113523
+ function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd(), options = {}) {
112881
113524
  try {
112882
- const parsed = parseSettingsArg(value);
112883
- return parsed && typeof parsed === "object" ? parsed : null;
113525
+ const layers = discoverySettingsLayers(claudeArgs, cwd, options).filter((layer) => layer.tier !== "cli" || layer.merged);
113526
+ const merged = highestTierValues(layers, "statusLine", ["cli"]);
113527
+ if (merged)
113528
+ return chainableCommandOf(merged.at(-1));
113529
+ const values = highestTierValues(layers, "statusLine", ["local", "project", "user"]);
113530
+ if (!values)
113531
+ return null;
113532
+ const commands = values.map(chainableCommandOf);
113533
+ return commands.every((command) => command === commands[0]) ? commands[0] : null;
112884
113534
  } catch {
112885
113535
  return null;
112886
113536
  }
112887
113537
  }
112888
- function userSettingsFileCandidates(cwd) {
112889
- return [
112890
- join53(homedir41(), ".claude", "settings.json"),
112891
- join53(cwd, ".claude", "settings.json"),
112892
- join53(cwd, ".claude", "settings.local.json")
112893
- ];
112894
- }
112895
- function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd(), scope = "first") {
112896
- const sources = userSettingsFileCandidates(cwd).filter((file) => existsSync37(file));
112897
- sources.push(...settingsArgValues(claudeArgs, scope));
112898
- let effective;
112899
- for (const source of sources) {
112900
- const layer = parseSettingsArgSafe(source);
112901
- if (layer && "statusLine" in layer)
112902
- effective = layer.statusLine;
112903
- }
112904
- return chainableCommandOf(effective);
112905
- }
112906
113538
  function chainableCommandOf(statusLine) {
112907
113539
  if (!statusLine || typeof statusLine !== "object")
112908
113540
  return null;
@@ -113053,8 +113685,8 @@ function mergeEverySettingsArg(config, tempSettingsPath, statusLine, proxyAuthMo
113053
113685
  if (!occurrence.value)
113054
113686
  return;
113055
113687
  const label = occurrences.length > 1 ? `--settings (occurrence ${i + 1})` : "--settings";
113056
- const parsed = parseSettingsArgSafe(occurrence.value);
113057
- if (parsed === null || Array.isArray(parsed)) {
113688
+ const parsed = readSettingsSource(occurrence.value, (path) => readFileSync43(path, "utf-8"));
113689
+ if (parsed === null) {
113058
113690
  if (!config.quiet)
113059
113691
  console.warn(`[claudish] Warning: could not merge user settings: ${label}`);
113060
113692
  return;
@@ -113162,26 +113794,37 @@ function resolveAdvisorToolEnv(config, processEnv = process.env) {
113162
113794
  return { vars: {}, source: "inherited" };
113163
113795
  return { vars: { [ADVISOR_TOOL_ENV_VAR]: "1" }, source: "claudish" };
113164
113796
  }
113165
- function discoverUserAdvisorModel(claudeArgs = [], cwd = process.cwd(), scope = "first") {
113166
- const sources = userSettingsFileCandidates(cwd).filter((file) => existsSync37(file));
113167
- sources.push(...settingsArgValues(claudeArgs, scope));
113168
- const managed = managedSettingsPath();
113169
- if (existsSync37(managed))
113170
- sources.push(managed);
113171
- let effective;
113172
- for (const source of sources) {
113173
- const layer = parseSettingsArgSafe(source);
113174
- if (!layer || !("advisorModel" in layer))
113175
- continue;
113176
- const value = layer.advisorModel;
113177
- effective = typeof value === "string" && value !== "" ? value : undefined;
113797
+ function discoverUserAdvisorModel(claudeArgs = [], cwd = process.cwd(), options = {}) {
113798
+ try {
113799
+ const layers = discoverySettingsLayers(claudeArgs, cwd, options);
113800
+ const asModel = (value) => typeof value === "string" && value !== "" ? value : undefined;
113801
+ for (const tier of SETTINGS_TIER_ORDER) {
113802
+ if (tier === "cli") {
113803
+ const applied = highestTierValues(inChildArgvOrder(layers), "advisorModel", [tier]);
113804
+ if (applied)
113805
+ return asModel(applied.at(-1));
113806
+ continue;
113807
+ }
113808
+ const values = highestTierValues(layers, "advisorModel", [tier]);
113809
+ if (values)
113810
+ return values.map(asModel).find((value) => value !== undefined);
113811
+ }
113812
+ return;
113813
+ } catch {
113814
+ return;
113178
113815
  }
113179
- return effective;
113816
+ }
113817
+ function inChildArgvOrder(layers) {
113818
+ const merged = layers.filter((layer) => layer.tier === "cli" && layer.merged);
113819
+ const rest = layers.filter((layer) => !(layer.tier === "cli" && layer.merged));
113820
+ return [...merged, ...rest];
113180
113821
  }
113181
113822
  function resolveAdvisorModelArg(config, cwd = process.cwd()) {
113182
113823
  if (!config.advisor)
113183
113824
  return { args: [], source: "off" };
113184
- const userChoice = discoverUserAdvisorModel(config.claudeArgs, cwd, settingsArgScopeOf(config));
113825
+ const userChoice = discoverUserAdvisorModel(config.claudeArgs, cwd, {
113826
+ scope: settingsArgScopeOf(config)
113827
+ });
113185
113828
  if (userChoice)
113186
113829
  return { args: [], model: userChoice, source: "inherited" };
113187
113830
  return {
@@ -113276,7 +113919,9 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
113276
113919
  if (!gatewayEligible && globalConfig.harnessGateway !== undefined) {
113277
113920
  log(gatewayHeldOff ? `[claude-runner] harnessGateway ignored: ${HARNESS_GATEWAY_OFF_VAR}=1` : "[claude-runner] harnessGateway ignored: a monitor session keeps the proxy URL");
113278
113921
  }
113279
- const userStatusLineCommand = discoverUserStatusLineCommand(config.claudeArgs, process.cwd(), settingsArgScopeOf(config));
113922
+ const userStatusLineCommand = discoverUserStatusLineCommand(config.claudeArgs, process.cwd(), {
113923
+ scope: settingsArgScopeOf(config)
113924
+ });
113280
113925
  const advisorModelArg = resolveAdvisorModelArg(config);
113281
113926
  const modelPicker = config.modelLineup?.picker;
113282
113927
  const {
@@ -113422,12 +114067,12 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
113422
114067
  }
113423
114068
  }
113424
114069
  };
113425
- if (!config.monitor && hasNativeAnthropicMapping(config)) {
114070
+ const nativeModelNotice = !config.monitor && hasNativeAnthropicMapping(config);
114071
+ if (nativeModelNotice) {
113426
114072
  log2("[claudish] Native Claude model detected \u2014 using Claude Code subscription credentials");
113427
- if (hidAnthropicApiKey) {
113428
- log2("[claudish] ANTHROPIC_API_KEY found but hidden so it can't override that subscription \xB7 " + (config.claudeSubscriptionPin ? "use anthropic@<id> to bill the Claude API instead" : "use --anthropic-api-billing (or anthropicApiBilling: true) to bill the API instead"));
113429
- }
113430
114073
  }
114074
+ if (hidAnthropicApiKey)
114075
+ log2(hiddenAnthropicKeyNotice(config, nativeModelNotice));
113431
114076
  if (gatewayNotice)
113432
114077
  log2(`[claudish] ${gatewayNotice}`);
113433
114078
  if (config.interactive) {
@@ -113452,7 +114097,7 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
113452
114097
  console.error("Install it from: https://claude.com/claude-code");
113453
114098
  console.error(`
113454
114099
  Or set CLAUDE_PATH to your custom installation:`);
113455
- const home = homedir41();
114100
+ const home = homedir40();
113456
114101
  const localPath = isWindows2() ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
113457
114102
  console.error(` export CLAUDE_PATH=${localPath}`);
113458
114103
  process.exit(1);
@@ -113504,7 +114149,7 @@ Or set CLAUDE_PATH to your custom installation:`);
113504
114149
  stdoutIsTty: Boolean(process.stdout.isTTY),
113505
114150
  magmuxBinary: paneCapability.magmux
113506
114151
  }) : null;
113507
- const proc = wrap ? spawn2(wrap.command, wrap.args, { env: wrap.env, stdio, shell: false }) : spawn2(spawnCommand, claudeArgs, {
114152
+ const proc = wrap ? spawn3(wrap.command, wrap.args, { env: wrap.env, stdio, shell: false }) : spawn3(spawnCommand, claudeArgs, {
113508
114153
  env,
113509
114154
  stdio,
113510
114155
  shell: needsShell
@@ -113702,7 +114347,7 @@ async function findClaudeBinary(env = process.env) {
113702
114347
  return env.CLAUDE_PATH;
113703
114348
  }
113704
114349
  }
113705
- const home = homedir41();
114350
+ const home = homedir40();
113706
114351
  const localPath = isWindows ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
113707
114352
  if (existsSync37(localPath)) {
113708
114353
  return localPath;
@@ -113736,7 +114381,7 @@ async function findClaudeBinary(env = process.env) {
113736
114381
  }
113737
114382
  try {
113738
114383
  const shellCommand = isWindows ? "where claude" : "command -v claude";
113739
- const proc = spawn2(shellCommand, [], {
114384
+ const proc = spawn3(shellCommand, [], {
113740
114385
  stdio: "pipe",
113741
114386
  shell: true
113742
114387
  });
@@ -113769,6 +114414,7 @@ async function checkClaudeInstalled() {
113769
114414
  var restoreTerminal = null, SETTINGS_TIER_ORDER, NON_MANAGED_TIER_RANK, STALE_TOKEN_FILE_MS, MAX_TOKEN_FILES_SCANNED = 4000, CLAUDE_CODE_DEFAULT_MAX_CONTEXT = 200000, USER_STATUS_LINE_TIMEOUT_SECONDS = 3, MIN_AUTO_COMPACT_WINDOW = 200000, MAX_AUTO_COMPACT_WINDOW = 1e6, ADVISOR_TOOL_ENV_VAR = "CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL", CLAUDISH_CHILD_ADVISOR_MODEL = "sonnet", CHILD_STDERR_NOISE, SIGNAL_CHILD_EXIT_GRACE_MS = 2000, SIGNAL_CHILD_KILL_WAIT_MS = 500, SIGNAL_DESCENDANT_READ_MS = 200, SIGNAL_SHUTDOWN_BUDGET_MS = 4500, signalShutdownCode = null;
113770
114415
  var init_claude_runner = __esm(() => {
113771
114416
  init_model_catalog();
114417
+ init_claude_code_facts();
113772
114418
  init_claude_code_login();
113773
114419
  init_config();
113774
114420
  init_anthropic_forward();
@@ -115755,7 +116401,7 @@ async function startModelsIn(flight, sessionPath, opts) {
115755
116401
  notifyStatus(e.id);
115756
116402
  viewServices?.feed.changed(targetOfSlot(runId, e.id), true);
115757
116403
  }
115758
- const projects = projectsDir(parentEnv);
116404
+ const projects = projectsDir(parentEnv, cwd);
115759
116405
  function bindingFor(e, uuid) {
115760
116406
  const session = {
115761
116407
  kind: "team",
@@ -116364,6 +117010,60 @@ function resolveSetupFrom(arg, workDir, serverCwd) {
116364
117010
  }
116365
117011
  var init_inherited_settings = () => {};
116366
117012
 
117013
+ // src/mcp-session/parent-session.ts
117014
+ import { readFile as readFile7 } from "fs/promises";
117015
+ import { join as join58 } from "path";
117016
+ function positiveInt(value) {
117017
+ if (value === undefined || !/^[1-9][0-9]*$/.test(value))
117018
+ return;
117019
+ const n = Number(value);
117020
+ return Number.isSafeInteger(n) ? n : undefined;
117021
+ }
117022
+ function hostPidFrom(env, ppid) {
117023
+ const launcherPpid = positiveInt(env.CLAUDISH_LAUNCHER_PPID);
117024
+ if (env.CLAUDISH_LAUNCHER_PID === String(ppid) && launcherPpid !== undefined && launcherPpid !== ppid) {
117025
+ return { hostPid: launcherPpid, launcherPid: ppid };
117026
+ }
117027
+ return { hostPid: ppid };
117028
+ }
117029
+ function parentSessionIdFrom(env) {
117030
+ const id = env.CLAUDE_CODE_SESSION_ID;
117031
+ if (id === undefined || !CLAUDE_ID_RE.test(id))
117032
+ return;
117033
+ if (env.CLAUDE_CODE_CHILD_SESSION)
117034
+ return;
117035
+ return id;
117036
+ }
117037
+ async function readHostSessionRecord(opts) {
117038
+ try {
117039
+ const raw = await readFile7(join58(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
117040
+ const parsed = JSON.parse(raw);
117041
+ if (!parsed || typeof parsed !== "object")
117042
+ return;
117043
+ const rec = parsed;
117044
+ if (rec.pid !== opts.hostPid)
117045
+ return;
117046
+ if (typeof rec.sessionId !== "string" || !CLAUDE_ID_RE.test(rec.sessionId))
117047
+ return;
117048
+ return { sessionId: rec.sessionId };
117049
+ } catch {
117050
+ return;
117051
+ }
117052
+ }
117053
+ async function parentSessionForCall(opts) {
117054
+ const env = opts.env ?? process.env;
117055
+ const record = await readHostSessionRecord({
117056
+ configDir: claudeCodeConfigDir(env),
117057
+ hostPid: opts.hostPid
117058
+ });
117059
+ return record?.sessionId ?? parentSessionIdFrom(env);
117060
+ }
117061
+ var CLAUDE_ID_RE;
117062
+ var init_parent_session = __esm(() => {
117063
+ init_claude_code_facts();
117064
+ CLAUDE_ID_RE = /^[A-Za-z0-9_-]{8,128}$/;
117065
+ });
117066
+
116367
117067
  // src/mcp-session/scrollback-buffer.ts
116368
117068
  class ScrollbackBuffer {
116369
117069
  lines;
@@ -116437,7 +117137,7 @@ import {
116437
117137
  statSync as statSync23,
116438
117138
  writeFileSync as writeFileSync23
116439
117139
  } from "fs";
116440
- import { join as join58, resolve as resolve9, sep as sep2 } from "path";
117140
+ import { join as join59, resolve as resolve9, sep as sep2 } from "path";
116441
117141
  function normaliseTimeoutSeconds(raw) {
116442
117142
  const n = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
116443
117143
  if (typeof n !== "number" || !Number.isFinite(n))
@@ -116610,7 +117310,7 @@ function dropLeadingFragment(tail) {
116610
117310
  return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
116611
117311
  }
116612
117312
  function diskAccounting(sessionDir) {
116613
- const stats = readTokenStatsAt(join58(sessionDir, "tokens.json"));
117313
+ const stats = readTokenStatsAt(join59(sessionDir, "tokens.json"));
116614
117314
  return {
116615
117315
  tokensIn: stats?.billed_input_tokens ?? null,
116616
117316
  tokensOut: stats?.output_tokens ?? null,
@@ -116699,7 +117399,7 @@ class SessionManager {
116699
117399
  let dir = "";
116700
117400
  for (let attempt = 0;; attempt++) {
116701
117401
  id = `team-${randomUUID9().replace(/-/g, "").slice(0, 8)}`;
116702
- dir = join58(this.sessionsDir, id);
117402
+ dir = join59(this.sessionsDir, id);
116703
117403
  try {
116704
117404
  mkdirSync28(dir);
116705
117405
  break;
@@ -116731,9 +117431,9 @@ class SessionManager {
116731
117431
  if (dir === null)
116732
117432
  throw new Error("not a record id");
116733
117433
  const completedAt = new Date().toISOString();
116734
- const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(join58(dir, "spawn.json"), META_READ_LIMIT)?.startedAt) ?? completedAt;
117434
+ const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(join59(dir, "spawn.json"), META_READ_LIMIT)?.startedAt) ?? completedAt;
116735
117435
  const elapsedMs = Date.parse(completedAt) - Date.parse(startedAt);
116736
- writeJsonAtomic(join58(dir, "meta.json"), {
117436
+ writeJsonAtomic(join59(dir, "meta.json"), {
116737
117437
  kind: "team",
116738
117438
  status: outcome.status,
116739
117439
  startedAt,
@@ -116765,7 +117465,7 @@ class SessionManager {
116765
117465
  startedAt,
116766
117466
  ...rest
116767
117467
  };
116768
- writeJsonAtomic(join58(dir, "spawn.json"), body);
117468
+ writeJsonAtomic(join59(dir, "spawn.json"), body);
116769
117469
  }
116770
117470
  async createSession(opts) {
116771
117471
  if (this.activeSessions + this.starting >= this.maxSessions) {
@@ -116805,7 +117505,7 @@ class SessionManager {
116805
117505
  throw err;
116806
117506
  }
116807
117507
  if (inherited.layer) {
116808
- flags = [...inherited.restFlags, "--settings", join58(entry.sessionDir, INHERITED_SETTINGS)];
117508
+ flags = [...inherited.restFlags, "--settings", join59(entry.sessionDir, INHERITED_SETTINGS)];
116809
117509
  }
116810
117510
  this.sessions.set(entry.info.sessionId, entry);
116811
117511
  uncount();
@@ -116830,10 +117530,10 @@ class SessionManager {
116830
117530
  const timeout = normaliseTimeoutSeconds(opts.timeoutSeconds);
116831
117531
  const agentRequested = requestedAgentOf(opts.claudishFlags ?? []);
116832
117532
  const startedAt = new Date().toISOString();
116833
- const sessionDir = opts.sessionDir ?? join58(this.sessionsDir, sessionId);
117533
+ const sessionDir = opts.sessionDir ?? join59(this.sessionsDir, sessionId);
116834
117534
  mkdirSync28(sessionDir, { recursive: true });
116835
117535
  if (opts.prompt)
116836
- writeFileSync23(join58(sessionDir, "prompt.md"), opts.prompt, "utf-8");
117536
+ writeFileSync23(join59(sessionDir, "prompt.md"), opts.prompt, "utf-8");
116837
117537
  this.writeSpawnRecord(sessionDir, {
116838
117538
  kind: "session",
116839
117539
  sessionId,
@@ -116847,13 +117547,13 @@ class SessionManager {
116847
117547
  taskType: opts.taskType
116848
117548
  });
116849
117549
  if (inheritedLayer) {
116850
- writeFileSync23(join58(sessionDir, INHERITED_SETTINGS), `${JSON.stringify(inheritedLayer, null, 2)}
117550
+ writeFileSync23(join59(sessionDir, INHERITED_SETTINGS), `${JSON.stringify(inheritedLayer, null, 2)}
116851
117551
  `, { encoding: "utf-8", mode: 384 });
116852
117552
  }
116853
117553
  const cwd = opts.cwd ?? process.cwd();
116854
117554
  const parentEnv = opts.parentEnv ?? this.parentEnv;
116855
117555
  const spawnModel = opts.spawnModel ?? null;
116856
- const tokenFile = opts.tokenFile ?? join58(sessionDir, "tokens.json");
117556
+ const tokenFile = opts.tokenFile ?? join59(sessionDir, "tokens.json");
116857
117557
  return {
116858
117558
  info: {
116859
117559
  sessionId,
@@ -116884,7 +117584,7 @@ class SessionManager {
116884
117584
  detail: null,
116885
117585
  pendingInputs: opts.prompt ? 1 : 0,
116886
117586
  claudeSessionId,
116887
- transcriptPath: transcriptPathFor(cwd, claudeSessionId, projectsDir(parentEnv)),
117587
+ transcriptPath: transcriptPathFor(cwd, claudeSessionId, projectsDir(parentEnv, cwd)),
116888
117588
  ...optionalParent(opts.parentClaudeSessionId),
116889
117589
  captureSource: null,
116890
117590
  turnSource: "transcript",
@@ -116892,18 +117592,18 @@ class SessionManager {
116892
117592
  },
116893
117593
  session: null,
116894
117594
  scrollback: new ScrollbackBuffer(this.scrollbackCapacity),
116895
- outputLogStream: createWriteStream(join58(sessionDir, "output.log")),
117595
+ outputLogStream: createWriteStream(join59(sessionDir, "output.log")),
116896
117596
  sessionDir,
116897
117597
  cwd,
116898
117598
  tokenFile,
116899
- eventLogPath: join58(sessionDir, "events.jsonl"),
117599
+ eventLogPath: join59(sessionDir, "events.jsonl"),
116900
117600
  eventLogBytes: 0,
116901
- upstreamErrorLogPath: join58(sessionDir, "upstream-errors.jsonl"),
117601
+ upstreamErrorLogPath: join59(sessionDir, "upstream-errors.jsonl"),
116902
117602
  eventRing: [],
116903
117603
  proseBytes: 0,
116904
117604
  answeredTurns: new Map,
116905
117605
  inboxPath: null,
116906
- waitLogPath: join58(sessionDir, "waits.jsonl"),
117606
+ waitLogPath: join59(sessionDir, "waits.jsonl"),
116907
117607
  waitLogBytes: 0,
116908
117608
  waitSince: null,
116909
117609
  ended: false,
@@ -116913,7 +117613,7 @@ class SessionManager {
116913
117613
  anomaliesLogged: new Set,
116914
117614
  requestedSize: null,
116915
117615
  reapVerified: false,
116916
- projectsRoot: projectsDir(parentEnv),
117616
+ projectsRoot: projectsDir(parentEnv, cwd),
116917
117617
  promptSummary: opts.prompt ? promptSummaryOf(opts.prompt) : null,
116918
117618
  lastChangeKey: null,
116919
117619
  stopTokenWatch: null
@@ -117125,7 +117825,7 @@ class SessionManager {
117125
117825
  try {
117126
117826
  const text = screenLines.join(`
117127
117827
  `).replace(/\s+$/, "");
117128
- writeFileSync23(join58(entry.sessionDir, "screen.txt"), `${redactSecrets(text)}
117828
+ writeFileSync23(join59(entry.sessionDir, "screen.txt"), `${redactSecrets(text)}
117129
117829
  `, "utf-8");
117130
117830
  } catch {}
117131
117831
  }
@@ -117139,7 +117839,7 @@ class SessionManager {
117139
117839
  entry.waitSince = null;
117140
117840
  }
117141
117841
  try {
117142
- writeJsonAtomic(join58(entry.sessionDir, "meta.json"), toMetaRecord(entry.info, entry.cwd));
117842
+ writeJsonAtomic(join59(entry.sessionDir, "meta.json"), toMetaRecord(entry.info, entry.cwd));
117143
117843
  } catch (err) {
117144
117844
  process.stderr.write(`[claudish] session ${entry.info.sessionId}: could not write meta.json: ` + `${err instanceof Error ? err.message : String(err)}
117145
117845
  `);
@@ -117409,20 +118109,20 @@ class SessionManager {
117409
118109
  } catch {
117410
118110
  return null;
117411
118111
  }
117412
- const spawnPath = join58(sessionDir, "spawn.json");
117413
- const metaPath = join58(sessionDir, "meta.json");
118112
+ const spawnPath = join59(sessionDir, "spawn.json");
118113
+ const metaPath = join59(sessionDir, "meta.json");
117414
118114
  const spawnRecord = readJsonObject(spawnPath, META_READ_LIMIT);
117415
118115
  if (spawnRecord?.kind === "team")
117416
118116
  return null;
117417
118117
  const meta = readJsonObject(metaPath, META_READ_LIMIT);
117418
118118
  if (meta?.kind === "team")
117419
118119
  return null;
117420
- const projectsRoot = projectsDir(this.parentEnv);
117421
118120
  const uuid = metaString(meta?.claudeSessionId) ?? metaString(spawnRecord?.claudeSessionId) ?? null;
117422
118121
  const now = Date.now();
117423
118122
  let writerGone;
117424
118123
  let transcriptPath = null;
117425
118124
  const cwd = meta !== null ? metaString(meta.cwd) : undefined;
118125
+ const projectsRoot = projectsDir(this.parentEnv, cwd ?? process.cwd());
117426
118126
  if (meta !== null) {
117427
118127
  const completedAt = metaString(meta.completedAt);
117428
118128
  const endedMs = completedAt ? Date.parse(completedAt) : Number.NaN;
@@ -117501,7 +118201,7 @@ class SessionManager {
117501
118201
  if (!record)
117502
118202
  return null;
117503
118203
  const info = record.info;
117504
- return sessionRowOf(info, upstreamRecordsFor(info, join58(record.sessionDir, "upstream-errors.jsonl")));
118204
+ return sessionRowOf(info, upstreamRecordsFor(info, join59(record.sessionDir, "upstream-errors.jsonl")));
117505
118205
  }
117506
118206
  async shutdownAll() {
117507
118207
  await Promise.all([...this.pendingStarts]);
@@ -117532,7 +118232,7 @@ class SessionManager {
117532
118232
  return null;
117533
118233
  const root = resolve9(this.sessionsDir);
117534
118234
  const dir = resolve9(root, sessionId);
117535
- if (dir !== join58(root, sessionId))
118235
+ if (dir !== join59(root, sessionId))
117536
118236
  return null;
117537
118237
  if (!dir.startsWith(root + sep2))
117538
118238
  return null;
@@ -117551,10 +118251,10 @@ class SessionManager {
117551
118251
  } catch {
117552
118252
  return null;
117553
118253
  }
117554
- const spawnRecord = readJsonObject(join58(sessionDir, "spawn.json"), META_READ_LIMIT);
118254
+ const spawnRecord = readJsonObject(join59(sessionDir, "spawn.json"), META_READ_LIMIT);
117555
118255
  if (spawnRecord?.kind === "team")
117556
118256
  return null;
117557
- const meta = readJsonObject(join58(sessionDir, "meta.json"), META_READ_LIMIT);
118257
+ const meta = readJsonObject(join59(sessionDir, "meta.json"), META_READ_LIMIT);
117558
118258
  if (meta?.kind === "team")
117559
118259
  return null;
117560
118260
  const partial = meta === null;
@@ -117572,11 +118272,11 @@ class SessionManager {
117572
118272
  if (stored && existsSync41(stored))
117573
118273
  return stored;
117574
118274
  if (cwd && uuid)
117575
- return transcriptPathFor(cwd, uuid, projectsDir(this.parentEnv));
118275
+ return transcriptPathFor(cwd, uuid, projectsDir(this.parentEnv, cwd));
117576
118276
  return stored;
117577
118277
  }
117578
118278
  diskOutput(record, tailLines) {
117579
- const tail = readTailText(join58(record.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
118279
+ const tail = readTailText(join59(record.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
117580
118280
  const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
117581
118281
  if (tail?.text)
117582
118282
  buffer.append(dropLeadingFragment(tail));
@@ -117596,12 +118296,12 @@ class SessionManager {
117596
118296
  }
117597
118297
  diskDiagnostics(record, limit) {
117598
118298
  const { sessionDir, info } = record;
117599
- const eventLogPath = join58(sessionDir, "events.jsonl");
117600
- const upstreamErrorLogPath = join58(sessionDir, "upstream-errors.jsonl");
117601
- const outputLogPath = join58(sessionDir, "output.log");
118299
+ const eventLogPath = join59(sessionDir, "events.jsonl");
118300
+ const upstreamErrorLogPath = join59(sessionDir, "upstream-errors.jsonl");
118301
+ const outputLogPath = join59(sessionDir, "output.log");
117602
118302
  const events = readTailLines2(eventLogPath, EVENT_TAIL_BYTES);
117603
118303
  const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
117604
- const screen = readTailText(join58(sessionDir, "screen.txt"), SCREEN_READ_BYTES);
118304
+ const screen = readTailText(join59(sessionDir, "screen.txt"), SCREEN_READ_BYTES);
117605
118305
  return {
117606
118306
  sessionId: info.sessionId,
117607
118307
  state: info.state,
@@ -117906,7 +118606,7 @@ var init_session_manager = __esm(() => {
117906
118606
 
117907
118607
  // src/view/history.ts
117908
118608
  import { closeSync as closeSync17, openSync as openSync17, readSync as readSync8, readdirSync as readdirSync12, statSync as statSync24 } from "fs";
117909
- import { join as join59 } from "path";
118609
+ import { join as join60 } from "path";
117910
118610
  function finishedDetail(promptSummary) {
117911
118611
  return {
117912
118612
  prompt_summary: promptSummary,
@@ -117948,7 +118648,7 @@ function runDirs(sessionsDir) {
117948
118648
  const dated = [];
117949
118649
  for (const name of names) {
117950
118650
  try {
117951
- const st = statSync24(join59(sessionsDir, name));
118651
+ const st = statSync24(join60(sessionsDir, name));
117952
118652
  if (st.isDirectory())
117953
118653
  dated.push({ name, mtimeMs: st.mtimeMs });
117954
118654
  } catch {}
@@ -117985,7 +118685,7 @@ function teamItems(spawn) {
117985
118685
  return { runId: run.run_id, items };
117986
118686
  }
117987
118687
  function runItems(sessions, dir, name, seenRuns) {
117988
- const spawn = readJson(join59(dir, "spawn.json"));
118688
+ const spawn = readJson(join60(dir, "spawn.json"));
117989
118689
  if (spawn?.kind === "team" || name.startsWith("team-")) {
117990
118690
  const team = spawn ? teamItems(spawn) : null;
117991
118691
  if (!team || seenRuns.has(team.runId) || team.items.length === 0)
@@ -117993,12 +118693,12 @@ function runItems(sessions, dir, name, seenRuns) {
117993
118693
  seenRuns.add(team.runId);
117994
118694
  return team.items;
117995
118695
  }
117996
- if (!spawn && readJson(join59(dir, "meta.json")) === null)
118696
+ if (!spawn && readJson(join60(dir, "meta.json")) === null)
117997
118697
  return null;
117998
118698
  const row = sessions.diskSessionRow(name);
117999
118699
  if (!row)
118000
118700
  return null;
118001
- const prompt = readHead(join59(dir, "prompt.md"), PROMPT_HEAD_BYTES);
118701
+ const prompt = readHead(join60(dir, "prompt.md"), PROMPT_HEAD_BYTES);
118002
118702
  return [sessionItem(row, prompt ? promptSummaryOf(prompt) : null)];
118003
118703
  }
118004
118704
  function readHistory(o = {}) {
@@ -118011,7 +118711,7 @@ function readHistory(o = {}) {
118011
118711
  for (const name of runDirs(sessionsDir)) {
118012
118712
  if (runs >= limit)
118013
118713
  break;
118014
- const items = runItems(sessions, join59(sessionsDir, name), name, seenRuns);
118714
+ const items = runItems(sessions, join60(sessionsDir, name), name, seenRuns);
118015
118715
  if (!items)
118016
118716
  continue;
118017
118717
  out.push(...items);
@@ -118026,15 +118726,15 @@ function findRecordedItem(target, o = {}) {
118026
118726
  const id = target.slice(2);
118027
118727
  if (!id || id.includes("/") || id.startsWith("."))
118028
118728
  return null;
118029
- const items = runItems(sessions, join59(sessionsDir, id), id, new Set);
118729
+ const items = runItems(sessions, join60(sessionsDir, id), id, new Set);
118030
118730
  return items?.find((i) => i.target === target) ?? null;
118031
118731
  }
118032
118732
  if (!target.startsWith("t:"))
118033
118733
  return null;
118034
118734
  const seenRuns = new Set;
118035
118735
  for (const name of runDirs(sessionsDir)) {
118036
- const dir = join59(sessionsDir, name);
118037
- if (!name.startsWith("team-") && readJson(join59(dir, "spawn.json"))?.kind !== "team")
118736
+ const dir = join60(sessionsDir, name);
118737
+ if (!name.startsWith("team-") && readJson(join60(dir, "spawn.json"))?.kind !== "team")
118038
118738
  continue;
118039
118739
  const found = runItems(sessions, dir, name, seenRuns)?.find((i) => i.target === target);
118040
118740
  if (found)
@@ -118286,9 +118986,9 @@ var init_view_client = __esm(() => {
118286
118986
 
118287
118987
  // src/view/feed-relay.ts
118288
118988
  import { chmodSync as chmodSync7, readFileSync as readFileSync48, renameSync as renameSync11, rmSync as rmSync16, writeFileSync as writeFileSync24 } from "fs";
118289
- import { dirname as dirname24, join as join60 } from "path";
118989
+ import { dirname as dirname24, join as join61 } from "path";
118290
118990
  function defaultFeedPath(root) {
118291
- return join60(root, FEED_DIR, FEED_FILE);
118991
+ return join61(root, FEED_DIR, FEED_FILE);
118292
118992
  }
118293
118993
  function ownStamp() {
118294
118994
  return {
@@ -118356,7 +119056,7 @@ class FeedRelay {
118356
119056
  }
118357
119057
  async start() {
118358
119058
  ensureSockRoot(this.o.root);
118359
- if (dirname24(this.path) === join60(this.o.root, FEED_DIR))
119059
+ if (dirname24(this.path) === join61(this.o.root, FEED_DIR))
118360
119060
  ensurePrivateSubdir(this.o.root, FEED_DIR);
118361
119061
  const other = readFeedStamp(this.path);
118362
119062
  if (other && !this.isOwn(other) && stampAlive(other, await readProcessTableAsync()))
@@ -118621,7 +119321,7 @@ import {
118621
119321
  unlinkSync as unlinkSync12,
118622
119322
  writeFileSync as writeFileSync25
118623
119323
  } from "fs";
118624
- import { dirname as dirname25, join as join61 } from "path";
119324
+ import { dirname as dirname25, join as join62 } from "path";
118625
119325
  function ownerStartOfSelf() {
118626
119326
  if (ownStart)
118627
119327
  return ownStart;
@@ -118642,7 +119342,7 @@ function ownerAlive(owner, table) {
118642
119342
  return !minted || startedAt(row, minted.startMs);
118643
119343
  }
118644
119344
  function recordsDir(root) {
118645
- return join61(root, "panes");
119345
+ return join62(root, "panes");
118646
119346
  }
118647
119347
  function writeRecord(root, rec) {
118648
119348
  const p = recordPathOf(root, rec.paneId);
@@ -118726,13 +119426,13 @@ function readRecords(root) {
118726
119426
  }
118727
119427
  function readGroupFile(ctlDir) {
118728
119428
  try {
118729
- return parseGroupFile(readFileSync49(join61(ctlDir, "group"), "utf8"));
119429
+ return parseGroupFile(readFileSync49(join62(ctlDir, "group"), "utf8"));
118730
119430
  } catch {
118731
119431
  return null;
118732
119432
  }
118733
119433
  }
118734
119434
  function writeGroupFile(ctlDir, snap) {
118735
- const p = join61(ctlDir, "group");
119435
+ const p = join62(ctlDir, "group");
118736
119436
  const tmp = `${p}.tmp`;
118737
119437
  try {
118738
119438
  writeFileSync25(tmp, formatGroupFile(snap), { mode: 384 });
@@ -119026,7 +119726,7 @@ async function sweepRecordlessSocket(root, name, out) {
119026
119726
  const owner = ownerOfSocketId(id);
119027
119727
  if (!owner || ownerAlive(owner, table))
119028
119728
  return;
119029
- const sockPath = join61(root, name);
119729
+ const sockPath = join62(root, name);
119030
119730
  const magmuxMayLive = !table || table.some((r) => isPaneMagmuxCommand(r.command, id));
119031
119731
  const probe = await probeSocket(sockPath, magmuxMayLive);
119032
119732
  if (probe.state === "stale") {
@@ -119154,14 +119854,14 @@ var init_pane_registry = __esm(() => {
119154
119854
 
119155
119855
  // src/pane/gate-binding.ts
119156
119856
  import { realpathSync as realpathSync8 } from "fs";
119157
- import { basename as basename8, dirname as dirname26, join as join62, resolve as resolve10 } from "path";
119857
+ import { basename as basename8, dirname as dirname26, join as join63, resolve as resolve10 } from "path";
119158
119858
  function normaliseTranscriptPath(p) {
119159
119859
  const abs = resolve10(p);
119160
119860
  const tail = [];
119161
119861
  let cur = abs;
119162
119862
  for (;; ) {
119163
119863
  try {
119164
- return tail.length ? join62(realpathSync8(cur), ...tail.reverse()) : realpathSync8(cur);
119864
+ return tail.length ? join63(realpathSync8(cur), ...tail.reverse()) : realpathSync8(cur);
119165
119865
  } catch {
119166
119866
  const parent = dirname26(cur);
119167
119867
  if (parent === cur)
@@ -119362,7 +120062,7 @@ var init_scroll_input = __esm(() => {
119362
120062
 
119363
120063
  // src/pane/session-registry.ts
119364
120064
  import { readFileSync as readFileSync50, readdirSync as readdirSync14 } from "fs";
119365
- import { join as join63 } from "path";
120065
+ import { join as join64 } from "path";
119366
120066
  function parseRegistryRecord(raw) {
119367
120067
  let parsed;
119368
120068
  try {
@@ -119407,7 +120107,7 @@ class SessionRegistry {
119407
120107
  isAlive;
119408
120108
  constructor(o) {
119409
120109
  this.o = o;
119410
- this.dir = join63(o.configDir, "sessions");
120110
+ this.dir = join64(o.configDir, "sessions");
119411
120111
  this.now = o.now ?? Date.now;
119412
120112
  this.isAlive = o.isAlive ?? pidAlive2;
119413
120113
  }
@@ -119443,7 +120143,7 @@ class SessionRegistry {
119443
120143
  readPid(pid) {
119444
120144
  let raw;
119445
120145
  try {
119446
- raw = readFileSync50(join63(this.dir, `${pid}.json`), "utf8");
120146
+ raw = readFileSync50(join64(this.dir, `${pid}.json`), "utf8");
119447
120147
  } catch {
119448
120148
  return null;
119449
120149
  }
@@ -119588,7 +120288,7 @@ var init_view_socket = __esm(() => {
119588
120288
 
119589
120289
  // src/pane/pane-session.ts
119590
120290
  import { readFileSync as readFileSync51, realpathSync as realpathSync9, rmSync as rmSync18, statSync as statSync25, writeFileSync as writeFileSync26 } from "fs";
119591
- import { join as join64 } from "path";
120291
+ import { join as join65 } from "path";
119592
120292
  function iso3(ms) {
119593
120293
  return new Date(ms).toISOString();
119594
120294
  }
@@ -119741,9 +120441,9 @@ class PaneSessionImpl {
119741
120441
  });
119742
120442
  this.secondaryQuietMs = o.timings?.secondaryQuietMs ?? SECONDARY_QUIET_MS;
119743
120443
  this.corroborationMs = o.timings?.corroborationMs ?? CORROBORATION_MS;
119744
- this.follower = new TranscriptFollower(o.transcriptPath, join64(o.transcriptPath.replace(/\.jsonl$/, ""), "subagents"));
120444
+ this.follower = new TranscriptFollower(o.transcriptPath, join65(o.transcriptPath.replace(/\.jsonl$/, ""), "subagents"));
119745
120445
  this.registry = new SessionRegistry({
119746
- configDir: claudeConfigDir(o.parentEnv ?? process.env),
120446
+ configDir: claudeCodeConfigDir(o.parentEnv ?? process.env, o.cwd),
119747
120447
  sessionUuid: o.sessionUuid
119748
120448
  });
119749
120449
  this.ready = new Promise((r) => {
@@ -119788,7 +120488,7 @@ class PaneSessionImpl {
119788
120488
  return this.spawnFailed(new Error("magmux did not start"));
119789
120489
  this.magmux = proc;
119790
120490
  try {
119791
- writeFileSync26(join64(this.ctlDir, "magmux.pid"), `${proc.pid}
120491
+ writeFileSync26(join65(this.ctlDir, "magmux.pid"), `${proc.pid}
119792
120492
  `, { mode: 384 });
119793
120493
  } catch {}
119794
120494
  updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
@@ -122265,9 +122965,9 @@ async function startPaneSession(o) {
122265
122965
  }
122266
122966
  var BOOT_TIMEOUT_MS = 90000, ADMIT_TIMEOUT_MS = 30000, DEGRADED_ENTRY_MS = 1e4, SCREEN_SETTLE_QUIET_MS = 3000, PANEL_SETTLE_MS = 500, SEND_CLIENT_SLACK_MS2 = 2000, MIN_READY_TIMEOUT_MS = 1000, BUSY_RETRY_MS = 250, MISMATCH_SETTLE_MS = 1000, CLEAR_WAIT_MS = 1000, BOOT_STATIC_MS = 5000, TICK_MS2 = 250, WATCH_FPS2 = 4, POLL_BACKSTOP_MS = 1000, TURN_END_MISSING_FACTOR = 3, RESIZE_REPLY_MS = 1e4, RESIZE_SCREEN_MS = 1000, SCROLL_REPLY_MS = 5000, SCROLL_SCREEN_MS = 1000, GATE_POLL_MS = 250, GATE_REPLY_MS = 1000, GATE_STALE_MS2 = 1000, GATE_GRACE_MS, GATE_DEAD_BACKSTOP_MS = 1000, EXIT_CODE_QUERY_MS = 2000, EXIT_CODE_RETRY_MS = 50, GATE_KINDLESS_REASONS, RUNTIME_DIALOG_KINDS, REGISTRY_READ_MS = 250, REGISTRY_DISAGREE_MS = 2000, REGISTRY_GATE_BOOT_DISAGREE_MS = 5000, REGISTRY_MISSING_MS = 5000, MAX_ANOMALY_KEYS = 64, KEPT_ANSWERS = 4, DEFAULT_MAX_CONSECUTIVE2 = 3, EVENT_REASON, VERDICT_EVENT, PaneStartError;
122267
122967
  var init_pane_session = __esm(() => {
122968
+ init_claude_code_facts();
122268
122969
  init_queue();
122269
122970
  init_logger();
122270
- init_parent_session();
122271
122971
  init_redact();
122272
122972
  init_box_locate();
122273
122973
  init_contract();
@@ -122323,7 +123023,7 @@ var init_pane_session = __esm(() => {
122323
123023
 
122324
123024
  // src/pane/replay-pane.ts
122325
123025
  import { rmSync as rmSync19, writeFileSync as writeFileSync27 } from "fs";
122326
- import { join as join65 } from "path";
123026
+ import { join as join66 } from "path";
122327
123027
  async function waitUntil(pred, ms) {
122328
123028
  const end = Date.now() + ms;
122329
123029
  while (!pred() && Date.now() < end)
@@ -122436,7 +123136,7 @@ class ReplayPane {
122436
123136
  return failed(new Error("magmux did not start"));
122437
123137
  this.magmuxProc = proc;
122438
123138
  try {
122439
- writeFileSync27(join65(this.ctlDir, "magmux.pid"), `${proc.pid}
123139
+ writeFileSync27(join66(this.ctlDir, "magmux.pid"), `${proc.pid}
122440
123140
  `, { mode: 384 });
122441
123141
  } catch {}
122442
123142
  updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
@@ -122889,7 +123589,7 @@ async function startReplayPane(o) {
122889
123589
  ctlDir: dirs.ctlDir,
122890
123590
  cols: o.size.cols,
122891
123591
  rows: o.size.rows,
122892
- ...o.configDir !== claudeConfigDir(o.parentEnv) ? { configDirOverride: o.configDir } : {}
123592
+ configDirOverride: replayConfigDirOverride(o.parentEnv, o.cwd, o.configDir)
122893
123593
  });
122894
123594
  writeRecord(root, {
122895
123595
  paneId,
@@ -122930,7 +123630,6 @@ async function startReplayPane(o) {
122930
123630
  var READY_TICK_MS = 250, DIALOG_STABLE_MS = 1000, LIST_POLL_MS = 2000, LIST_REPLY_MS = 1000, WATCH_FPS3 = 4, LAST_FRAME_MS = 500, RESIZE_REPLY_MS2 = 1e4, RESIZE_SCREEN_MS2 = 1000, SCROLL_REPLY_MS2 = 5000, SCROLL_SCREEN_MS2 = 1000, CONNECT_TIMEOUT_MS = 5000, RECONNECT_FIRST_MS2 = 50, RECONNECT_MAX_MS2 = 1000, RECONNECT_ENOENT_LIMIT = 20, STDERR_HEAD_CHARS = 8192;
122931
123631
  var init_replay_pane = __esm(() => {
122932
123632
  init_logger();
122933
- init_parent_session();
122934
123633
  init_redact();
122935
123634
  init_box_locate();
122936
123635
  init_contract();
@@ -123364,7 +124063,7 @@ import {
123364
124063
  realpathSync as realpathSync10,
123365
124064
  statSync as statSync26
123366
124065
  } from "fs";
123367
- import { basename as basename9, dirname as dirname27, join as join66, sep as sep3 } from "path";
124066
+ import { basename as basename9, dirname as dirname27, join as join67, sep as sep3 } from "path";
123368
124067
  function isUuid(v) {
123369
124068
  return typeof v === "string" && UUID_RE.test(v);
123370
124069
  }
@@ -123514,7 +124213,7 @@ function locateTranscriptByUuid(projectsRoot, uuid) {
123514
124213
  }
123515
124214
  let hit = null;
123516
124215
  for (const d of dirs) {
123517
- const p = join66(projectsRoot, d, `${uuid}.jsonl`);
124216
+ const p = join67(projectsRoot, d, `${uuid}.jsonl`);
123518
124217
  try {
123519
124218
  if (!statSync26(p).isFile())
123520
124219
  continue;
@@ -124009,7 +124708,7 @@ var init_peer_link = __esm(() => {
124009
124708
  // src/view/replay-registry.ts
124010
124709
  import { randomBytes as randomBytes18 } from "crypto";
124011
124710
  import { readFileSync as readFileSync52, readdirSync as readdirSync16, renameSync as renameSync13, rmSync as rmSync20, writeFileSync as writeFileSync28 } from "fs";
124012
- import { join as join67 } from "path";
124711
+ import { join as join68 } from "path";
124013
124712
  function parseEntry(raw) {
124014
124713
  let v;
124015
124714
  try {
@@ -124047,14 +124746,14 @@ class ReplayRegistry {
124047
124746
  constructor(root, log = () => {}) {
124048
124747
  this.root = root;
124049
124748
  this.log = log;
124050
- this.dir = join67(root, REPLAYS_DIR);
124749
+ this.dir = join68(root, REPLAYS_DIR);
124051
124750
  }
124052
124751
  ensure() {
124053
124752
  ensureSockRoot(this.root);
124054
124753
  return ensurePrivateSubdir(this.root, REPLAYS_DIR);
124055
124754
  }
124056
124755
  lockPathOf(uuid) {
124057
- return join67(this.dir, `${this.key(uuid)}.lock`);
124756
+ return join68(this.dir, `${this.key(uuid)}.lock`);
124058
124757
  }
124059
124758
  tryLock(uuid) {
124060
124759
  this.ensure();
@@ -124069,7 +124768,7 @@ class ReplayRegistry {
124069
124768
  }
124070
124769
  async withLock(fn, waitMs = REGISTRY_LOCK_WAIT_MS) {
124071
124770
  this.ensure();
124072
- const lock = await waitAcquire(join67(this.dir, "registry.lock"), waitMs);
124771
+ const lock = await waitAcquire(join68(this.dir, "registry.lock"), waitMs);
124073
124772
  if (!lock)
124074
124773
  return null;
124075
124774
  try {
@@ -124147,12 +124846,12 @@ class ReplayRegistry {
124147
124846
  }
124148
124847
  for (const name of now)
124149
124848
  if (name.endsWith(".tmp"))
124150
- rmSync20(join67(this.dir, name), { force: true });
124849
+ rmSync20(join68(this.dir, name), { force: true });
124151
124850
  });
124152
124851
  return swept;
124153
124852
  }
124154
124853
  entryPathOf(uuid) {
124155
- return join67(this.dir, `${this.key(uuid)}.json`);
124854
+ return join68(this.dir, `${this.key(uuid)}.json`);
124156
124855
  }
124157
124856
  key(uuid) {
124158
124857
  const k = uuid.toLowerCase();
@@ -125520,10 +126219,10 @@ var init_claude_launch = __esm(() => {
125520
126219
  });
125521
126220
 
125522
126221
  // src/mcp/run-prompt-claude-code.ts
125523
- import { spawn as spawn3 } from "child_process";
126222
+ import { spawn as spawn4 } from "child_process";
125524
126223
  import { mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync4, rmSync as rmSync21, writeFileSync as writeFileSync29 } from "fs";
125525
126224
  import { tmpdir as tmpdir3 } from "os";
125526
- import { join as join68 } from "path";
126225
+ import { join as join69 } from "path";
125527
126226
  function claudeCodePrintArgv(model, systemPromptFile, opts = {}) {
125528
126227
  const head = [
125529
126228
  PRINT_FLAGS[0],
@@ -125659,13 +126358,13 @@ async function runPromptViaClaudeCode(model, prompt, systemPrompt, opts = {}) {
125659
126358
  } catch (e) {
125660
126359
  throw new Error(`cannot start claudish (${parentEnv.CLAUDISH_BIN?.trim() || "claudish"}): ${e instanceof Error ? e.message : String(e)}`);
125661
126360
  }
125662
- const root = mkdtempSync4(join68(tmpdir3(), "claudish-run-prompt-"));
126361
+ const root = mkdtempSync4(join69(tmpdir3(), "claudish-run-prompt-"));
125663
126362
  try {
125664
- const cwd = join68(root, "cwd");
126363
+ const cwd = join69(root, "cwd");
125665
126364
  mkdirSync29(cwd, { mode: 448 });
125666
126365
  let systemPromptFile;
125667
126366
  if (typeof systemPrompt === "string" && systemPrompt.length > 0) {
125668
- systemPromptFile = join68(root, "system-prompt.txt");
126367
+ systemPromptFile = join69(root, "system-prompt.txt");
125669
126368
  writeFileSync29(systemPromptFile, systemPrompt, { mode: 384 });
125670
126369
  }
125671
126370
  const argv = claudeCodePrintArgv(model, systemPromptFile, {
@@ -125703,7 +126402,7 @@ function runChild(launch, argv, cwd, env, prompt, signal) {
125703
126402
  return new Promise((resolvePromise, reject) => {
125704
126403
  let proc;
125705
126404
  try {
125706
- proc = spawn3(launch.command, [...launch.prefixArgs, ...argv], {
126405
+ proc = spawn4(launch.command, [...launch.prefixArgs, ...argv], {
125707
126406
  cwd,
125708
126407
  env,
125709
126408
  stdio: ["pipe", "pipe", "pipe"],
@@ -125776,7 +126475,7 @@ var init_run_prompt_claude_code = __esm(() => {
125776
126475
  ENV.CLAUDISH_PANE_CHILD
125777
126476
  ];
125778
126477
  inFlight5 = new Set;
125779
- EMPTY_PRINT_CWD = join68(tmpdir3(), "claudish-run-prompt-settings-check");
126478
+ EMPTY_PRINT_CWD = join69(tmpdir3(), "claudish-run-prompt-settings-check");
125780
126479
  });
125781
126480
 
125782
126481
  // src/providers/bundled-list.ts
@@ -126775,8 +127474,8 @@ var init_view_server = __esm(() => {
126775
127474
 
126776
127475
  // src/mcp-server.ts
126777
127476
  import { existsSync as existsSync44, readFileSync as readFileSync53, readdirSync as readdirSync17 } from "fs";
126778
- import { homedir as homedir42 } from "os";
126779
- import { dirname as dirname29, join as join69, resolve as resolve12 } from "path";
127477
+ import { homedir as homedir41 } from "os";
127478
+ import { dirname as dirname29, join as join70, resolve as resolve12 } from "path";
126780
127479
  import { fileURLToPath as fileURLToPath3 } from "url";
126781
127480
  async function loadAllModels(forceRefresh = false) {
126782
127481
  if (!forceRefresh && existsSync44(OPENROUTER_MODELS_CACHE_PATH)) {
@@ -128070,7 +128769,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
128070
128769
  const promptText = () => {
128071
128770
  if (input !== undefined)
128072
128771
  return input;
128073
- const existing = join69(resolved, "input.md");
128772
+ const existing = join70(resolved, "input.md");
128074
128773
  return existsSync44(existing) ? readFileSync53(existing, "utf-8") : undefined;
128075
128774
  };
128076
128775
  const choice = await modelChoiceStop([
@@ -128255,16 +128954,16 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
128255
128954
  const sp = session_path;
128256
128955
  for (const file of ["status.json", "manifest.json", "input.md"]) {
128257
128956
  try {
128258
- sessionData[file] = readFileSync53(join69(sp, file), "utf-8");
128957
+ sessionData[file] = readFileSync53(join70(sp, file), "utf-8");
128259
128958
  } catch {}
128260
128959
  }
128261
128960
  try {
128262
- const errorDir = join69(sp, "errors");
128961
+ const errorDir = join70(sp, "errors");
128263
128962
  if (existsSync44(errorDir)) {
128264
128963
  for (const f of readdirSync17(errorDir)) {
128265
128964
  if (f.endsWith(".log")) {
128266
128965
  try {
128267
- sessionData[`errors/${f}`] = readFileSync53(join69(errorDir, f), "utf-8");
128966
+ sessionData[`errors/${f}`] = readFileSync53(join70(errorDir, f), "utf-8");
128268
128967
  } catch {}
128269
128968
  }
128270
128969
  }
@@ -128274,7 +128973,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
128274
128973
  for (const f of readdirSync17(sp)) {
128275
128974
  if (f.startsWith("response-") && f.endsWith(".md")) {
128276
128975
  try {
128277
- const content = readFileSync53(join69(sp, f), "utf-8");
128976
+ const content = readFileSync53(join70(sp, f), "utf-8");
128278
128977
  sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
128279
128978
  } catch {}
128280
128979
  }
@@ -128283,7 +128982,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
128283
128982
  }
128284
128983
  let version = "unknown";
128285
128984
  try {
128286
- const pkgPath = join69(__dirname3, "../package.json");
128985
+ const pkgPath = join70(__dirname3, "../package.json");
128287
128986
  if (existsSync44(pkgPath)) {
128288
128987
  version = JSON.parse(readFileSync53(pkgPath, "utf-8")).version;
128289
128988
  }
@@ -129088,8 +129787,8 @@ var init_mcp_server = __esm(() => {
129088
129787
  init_preflight_chain();
129089
129788
  __filename3 = fileURLToPath3(import.meta.url);
129090
129789
  __dirname3 = dirname29(__filename3);
129091
- CLAUDISH_CACHE_DIR = join69(homedir42(), ".claudish");
129092
- OPENROUTER_MODELS_CACHE_PATH = join69(CLAUDISH_CACHE_DIR, "openrouter-models.json");
129790
+ CLAUDISH_CACHE_DIR = join70(homedir41(), ".claudish");
129791
+ OPENROUTER_MODELS_CACHE_PATH = join70(CLAUDISH_CACHE_DIR, "openrouter-models.json");
129093
129792
  NEXT_STEP = {
129094
129793
  cancelled: "you stopped this slot; nothing is wrong with it. Re-run it if you still want its vote",
129095
129794
  timeout: "grid mode only \u2014 magmux ended the pane. The orchestrator has no deadline",
@@ -129252,8 +129951,8 @@ var HOOKS_AMBIENT_DTS = '// claudish hook types \u2014 written by `claudish hook
129252
129951
 
129253
129952
  // src/hooks/observer/corpus.ts
129254
129953
  import { appendFileSync as appendFileSync8, readFileSync as readFileSync55, readdirSync as readdirSync18, statSync as statSync29 } from "fs";
129255
- import { homedir as homedir43 } from "os";
129256
- import { join as join70 } from "path";
129954
+ import { homedir as homedir42 } from "os";
129955
+ import { join as join71 } from "path";
129257
129956
  function directoryOf2(filePath) {
129258
129957
  const slash = filePath.lastIndexOf("/");
129259
129958
  return slash > 0 ? filePath.slice(0, slash) : undefined;
@@ -129332,26 +130031,26 @@ function listTranscripts(root) {
129332
130031
  return files;
129333
130032
  }
129334
130033
  for (const project of projects) {
129335
- const dir = join70(root, project);
130034
+ const dir = join71(root, project);
129336
130035
  try {
129337
130036
  if (!statSync29(dir).isDirectory())
129338
130037
  continue;
129339
130038
  for (const f of readdirSync18(dir)) {
129340
130039
  if (f.endsWith(".jsonl"))
129341
- files.push(join70(dir, f));
130040
+ files.push(join71(dir, f));
129342
130041
  }
129343
130042
  } catch {}
129344
130043
  }
129345
130044
  return files;
129346
130045
  }
129347
130046
  function buildCorpus(options = {}) {
129348
- const root = options.projectsRoot ?? join70(homedir43(), ".claude", "projects");
130047
+ const root = options.projectsRoot ?? projectsDir(options.env ?? process.env, options.cwd ?? process.cwd());
129349
130048
  const files = listTranscripts(root);
129350
130049
  const records = [];
129351
130050
  for (const f of files)
129352
130051
  records.push(...replayTranscript(f));
129353
130052
  if (options.write && records.length > 0) {
129354
- const outputPath = options.outputPath ?? join70(homedir43(), ".claudish", "behavior-divergences.jsonl");
130053
+ const outputPath = options.outputPath ?? join71(homedir42(), ".claudish", "behavior-divergences.jsonl");
129355
130054
  try {
129356
130055
  appendFileSync8(outputPath, `${records.map((r) => JSON.stringify(r)).join(`
129357
130056
  `)}
@@ -129363,13 +130062,14 @@ function buildCorpus(options = {}) {
129363
130062
  }
129364
130063
  var RULE_ID = "plan-mode/plan-file-path", WRITE_TOOLS;
129365
130064
  var init_corpus = __esm(() => {
130065
+ init_session_discovery();
129366
130066
  WRITE_TOOLS = new Set(["Write", "Edit", "NotebookEdit"]);
129367
130067
  });
129368
130068
 
129369
130069
  // src/hooks-command.ts
129370
130070
  import { existsSync as existsSync46, mkdirSync as mkdirSync30, readFileSync as readFileSync56, writeFileSync as writeFileSync30 } from "fs";
129371
- import { homedir as homedir44 } from "os";
129372
- import { join as join71, resolve as resolve13 } from "path";
130071
+ import { homedir as homedir43 } from "os";
130072
+ import { join as join72, resolve as resolve13 } from "path";
129373
130073
  function severityColor(sev) {
129374
130074
  if (sev === "fix")
129375
130075
  return green(sev);
@@ -129492,10 +130192,10 @@ async function check(file, json) {
129492
130192
  return valid ? 0 : 1;
129493
130193
  }
129494
130194
  function init(dirArg) {
129495
- const dir = dirArg ? resolve13(process.cwd(), dirArg) : join71(homedir44(), ".claudish", "hooks");
130195
+ const dir = dirArg ? resolve13(process.cwd(), dirArg) : join72(homedir43(), ".claudish", "hooks");
129496
130196
  const files = [
129497
- [join71(dir, "example-hook.ts"), EXAMPLE_HOOK],
129498
- [join71(dir, "claudish-hooks.d.ts"), HOOKS_AMBIENT_DTS]
130197
+ [join72(dir, "example-hook.ts"), EXAMPLE_HOOK],
130198
+ [join72(dir, "claudish-hooks.d.ts"), HOOKS_AMBIENT_DTS]
129499
130199
  ];
129500
130200
  const existing = files.filter(([path]) => existsSync46(path)).map(([path]) => path);
129501
130201
  if (existing.length > 0) {
@@ -129695,10 +130395,10 @@ var init_hooks_command = __esm(() => {
129695
130395
  });
129696
130396
 
129697
130397
  // src/team-grid.ts
129698
- import { spawn as spawn4 } from "child_process";
130398
+ import { spawn as spawn5 } from "child_process";
129699
130399
  import { existsSync as existsSync47, readFileSync as readFileSync57, writeFileSync as writeFileSync31 } from "fs";
129700
130400
  import { connect as netConnect3 } from "net";
129701
- import { join as join72 } from "path";
130401
+ import { join as join73 } from "path";
129702
130402
  import { setTimeout as wait } from "timers/promises";
129703
130403
  function paneRouteLine(explanation) {
129704
130404
  const origin = describeRouteExplanation(explanation);
@@ -129848,9 +130548,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
129848
130548
  const keep = opts?.keep ?? false;
129849
130549
  const manifest = setupSession(sessionPath, models, input);
129850
130550
  const startedAt = new Date().toISOString();
129851
- const gridfilePath = join72(sessionPath, "gridfile.txt");
129852
- const prompt = readFileSync57(join72(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
129853
- const rawPrompt = readFileSync57(join72(sessionPath, "input.md"), "utf-8");
130551
+ const gridfilePath = join73(sessionPath, "gridfile.txt");
130552
+ const prompt = readFileSync57(join73(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
130553
+ const rawPrompt = readFileSync57(join73(sessionPath, "input.md"), "utf-8");
129854
130554
  const usedBannerColors = new Set;
129855
130555
  const routeLines = mode === "interactive" ? new Map : await resolvePaneRouteLines(Object.values(manifest.models).map((entry) => entry.model));
129856
130556
  const gridLines = Object.entries(manifest.models).map(([anonId]) => {
@@ -129870,7 +130570,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
129870
130570
  if (!keep && mode === "default") {
129871
130571
  spawnArgs.push("-w");
129872
130572
  }
129873
- const proc = spawn4(magmuxPath, spawnArgs, {
130573
+ const proc = spawn5(magmuxPath, spawnArgs, {
129874
130574
  stdio: "inherit",
129875
130575
  env: { ...process.env }
129876
130576
  });
@@ -129882,7 +130582,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
129882
130582
  });
129883
130583
  const [{ results }] = await Promise.all([subscription, procExit]);
129884
130584
  const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
129885
- const statusPath = join72(sessionPath, "status.json");
130585
+ const statusPath = join73(sessionPath, "status.json");
129886
130586
  writeFileSync31(statusPath, JSON.stringify(status, null, 2), "utf-8");
129887
130587
  return status;
129888
130588
  }
@@ -129903,7 +130603,7 @@ var init_team_grid = __esm(() => {
129903
130603
 
129904
130604
  // src/team-cli.ts
129905
130605
  import { readFileSync as readFileSync58 } from "fs";
129906
- import { join as join73 } from "path";
130606
+ import { join as join74 } from "path";
129907
130607
  async function runPaneTeam(sessionPath, models, input, opts) {
129908
130608
  installPaneShutdownHooks({ exitAfter: true });
129909
130609
  try {
@@ -130048,7 +130748,7 @@ async function teamCommand(args) {
130048
130748
  }
130049
130749
  case "judge": {
130050
130750
  await judgeResponses(sessionPath, { judges });
130051
- console.log(readFileSync58(join73(sessionPath, "verdict.md"), "utf-8"));
130751
+ console.log(readFileSync58(join74(sessionPath, "verdict.md"), "utf-8"));
130052
130752
  break;
130053
130753
  }
130054
130754
  case "run-and-judge": {
@@ -130064,7 +130764,7 @@ async function teamCommand(args) {
130064
130764
  });
130065
130765
  printStatus(status);
130066
130766
  await judgeResponses(sessionPath, { judges });
130067
- console.log(readFileSync58(join73(sessionPath, "verdict.md"), "utf-8"));
130767
+ console.log(readFileSync58(join74(sessionPath, "verdict.md"), "utf-8"));
130068
130768
  break;
130069
130769
  }
130070
130770
  case "status": {
@@ -131747,8 +132447,8 @@ var init_view_cli = __esm(() => {
131747
132447
  // src/herdr/herdr-cli.ts
131748
132448
  import { spawnSync as spawnSync3 } from "child_process";
131749
132449
  import { copyFileSync as copyFileSync3, existsSync as existsSync48, mkdirSync as mkdirSync31, readdirSync as readdirSync19, renameSync as renameSync14, statSync as statSync30 } from "fs";
131750
- import { homedir as homedir45 } from "os";
131751
- import { dirname as dirname30, join as join74, resolve as resolve14 } from "path";
132450
+ import { homedir as homedir44 } from "os";
132451
+ import { dirname as dirname30, join as join75, resolve as resolve14 } from "path";
131752
132452
  function spawnHerdrApp(args) {
131753
132453
  const r = spawnSync3("herdr-app", args, { encoding: "utf-8", timeout: 1e4 });
131754
132454
  if (r.error)
@@ -131790,8 +132490,8 @@ function showPanelCommand(rest, out, deps) {
131790
132490
  function findBuiltAppMod(from = import.meta.dir) {
131791
132491
  let dir = from;
131792
132492
  for (let i = 0;i < 5; i++) {
131793
- const candidate = join74(dir, BUILT_MOD_DIR);
131794
- if (existsSync48(join74(candidate, "main.js")) && existsSync48(join74(candidate, "mod.json")))
132493
+ const candidate = join75(dir, BUILT_MOD_DIR);
132494
+ if (existsSync48(join75(candidate, "main.js")) && existsSync48(join75(candidate, "mod.json")))
131795
132495
  return candidate;
131796
132496
  const up = dirname30(dir);
131797
132497
  if (up === dir)
@@ -131804,24 +132504,24 @@ function herdrAppHome(env) {
131804
132504
  const given = env.HERDR_APP_HOME?.trim();
131805
132505
  if (given)
131806
132506
  return resolve14(given);
131807
- return join74(env.HOME?.trim() || homedir45(), ".config", "herdr-app");
132507
+ return join75(env.HOME?.trim() || homedir44(), ".config", "herdr-app");
131808
132508
  }
131809
132509
  function isModFile(name) {
131810
132510
  return !name.startsWith(".") && name !== "jsconfig.json" && !name.endsWith(".d.ts");
131811
132511
  }
131812
132512
  function installAppMod(source, appHome) {
131813
- if (!existsSync48(join74(source, "main.js")) || !existsSync48(join74(source, "mod.json")))
132513
+ if (!existsSync48(join75(source, "main.js")) || !existsSync48(join75(source, "mod.json")))
131814
132514
  throw new Error(`${source} holds no built mod (main.js and mod.json); run \`bun run build\``);
131815
132515
  if (!existsSync48(appHome) || !statSync30(appHome).isDirectory())
131816
132516
  throw new Error(`${appHome} does not exist: start Herdr.app once so it creates its home, then run this again`);
131817
- const dest = join74(appHome, "mods", APP_MOD_NAME);
132517
+ const dest = join75(appHome, "mods", APP_MOD_NAME);
131818
132518
  mkdirSync31(dest, { recursive: true });
131819
- const files = readdirSync19(source).filter((f) => isModFile(f) && statSync30(join74(source, f)).isFile());
132519
+ const files = readdirSync19(source).filter((f) => isModFile(f) && statSync30(join75(source, f)).isFile());
131820
132520
  files.sort((a, b) => a === "mod.json" ? -1 : b === "mod.json" ? 1 : a.localeCompare(b));
131821
132521
  for (const f of files) {
131822
- const hidden = join74(dest, `.${f}.installing`);
131823
- copyFileSync3(join74(source, f), hidden);
131824
- renameSync14(hidden, join74(dest, f));
132522
+ const hidden = join75(dest, `.${f}.installing`);
132523
+ copyFileSync3(join75(source, f), hidden);
132524
+ renameSync14(hidden, join75(dest, f));
131825
132525
  }
131826
132526
  return dest;
131827
132527
  }
@@ -131899,7 +132599,7 @@ var init_herdr_cli = __esm(() => {
131899
132599
  ""
131900
132600
  ].join(`
131901
132601
  `);
131902
- BUILT_MOD_DIR = join74("herdr-app-mod", APP_MOD_NAME);
132602
+ BUILT_MOD_DIR = join75("herdr-app-mod", APP_MOD_NAME);
131903
132603
  });
131904
132604
 
131905
132605
  // src/auth/credentials/source.ts
@@ -134132,8 +134832,8 @@ var init_account_command = __esm(() => {
134132
134832
  // src/auth/antigravity-oauth.ts
134133
134833
  import { spawnSync as spawnSync4 } from "child_process";
134134
134834
  import { existsSync as existsSync49, unlinkSync as unlinkSync14 } from "fs";
134135
- import { homedir as homedir46 } from "os";
134136
- import { join as join75 } from "path";
134835
+ import { homedir as homedir45 } from "os";
134836
+ import { join as join76 } from "path";
134137
134837
  async function defaultSuggestModel() {
134138
134838
  try {
134139
134839
  const token = await getValidAntigravityAccessToken();
@@ -134252,7 +134952,7 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
134252
134952
  async logout(deps) {
134253
134953
  deleteSharedAntigravityToken(deps);
134254
134954
  try {
134255
- const tokenFile = join75(homedir46(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
134955
+ const tokenFile = join76(homedir45(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
134256
134956
  if (existsSync49(tokenFile))
134257
134957
  unlinkSync14(tokenFile);
134258
134958
  } catch {}
@@ -134285,13 +134985,13 @@ var init_antigravity_oauth = __esm(() => {
134285
134985
  });
134286
134986
 
134287
134987
  // src/auth/meta-muse-oauth.ts
134288
- import { execFile as execFile6 } from "child_process";
134988
+ import { execFile as execFile5 } from "child_process";
134289
134989
  function openInBrowser(url) {
134290
134990
  if (!/^https:\/\//i.test(url))
134291
134991
  return Promise.resolve();
134292
134992
  const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
134293
134993
  return new Promise((resolve) => {
134294
- execFile6(command, [url], () => resolve());
134994
+ execFile5(command, [url], () => resolve());
134295
134995
  });
134296
134996
  }
134297
134997
  function describe2(answer, status) {
@@ -137828,6 +138528,8 @@ function resolveProviderDetailKeyDisplay(input) {
137828
138528
  return input.isReady ? "enabled" : "disabled";
137829
138529
  if (input.authSource === "oauth")
137830
138530
  return "oauth";
138531
+ if (input.replacementKeyMask)
138532
+ return input.replacementKeyMask;
137831
138533
  if (input.hasEnvKey)
137832
138534
  return input.envKeyMask;
137833
138535
  if (input.hasCfgKey)
@@ -137839,6 +138541,38 @@ function resolveProviderDetailKeyDisplay(input) {
137839
138541
  function vaultLabel(source) {
137840
138542
  return source === "macOS Keychain" ? "keychain" : "1Password";
137841
138543
  }
138544
+ function keySourceLabel(source) {
138545
+ if (source === "environment")
138546
+ return "env";
138547
+ if (source === "config")
138548
+ return "config";
138549
+ return vaultLabel(source);
138550
+ }
138551
+ function resolveProviderDetailSources(input) {
138552
+ if (input.replacementSource) {
138553
+ const used = keySourceLabel(input.replacementSource);
138554
+ const outranked = resolveProviderDetailSources({ ...input, replacementSource: undefined }).map((segment) => segment.label).filter((label) => label !== used);
138555
+ return [
138556
+ { label: used, used: true },
138557
+ ...[...new Set(outranked)].map((label) => ({ label, used: false }))
138558
+ ];
138559
+ }
138560
+ const segments = [];
138561
+ if (input.hasEnvKey) {
138562
+ segments.push({
138563
+ label: input.isKcKey ? "keychain" : input.isOpKey ? "1Password" : "env",
138564
+ used: true
138565
+ });
138566
+ }
138567
+ if (input.hasCfgKey)
138568
+ segments.push({ label: "config", used: !input.hasEnvKey });
138569
+ if (input.vaultKeySource)
138570
+ segments.push({ label: vaultLabel(input.vaultKeySource), used: true });
138571
+ if (input.hasKcKey && !input.isKcKey && input.vaultKeySource !== "macOS Keychain") {
138572
+ segments.push({ label: "keychain", used: false });
138573
+ }
138574
+ return segments;
138575
+ }
137842
138576
  function validTestNote(input) {
137843
138577
  if (input.isLocal)
137844
138578
  return " Local provider responded through the shared probe path.";
@@ -137859,6 +138593,8 @@ function ProviderDetail({
137859
138593
  hasKcKey,
137860
138594
  vaultKeySource,
137861
138595
  vaultKeyMask,
138596
+ replacementKeyMask,
138597
+ replacementKeySource,
137862
138598
  keySaveTarget,
137863
138599
  credentialNote,
137864
138600
  cfgKeyMask,
@@ -137877,7 +138613,17 @@ function ProviderDetail({
137877
138613
  envKeyMask,
137878
138614
  cfgKeyMask,
137879
138615
  ...vaultKeySource ? { vaultKeySource } : {},
137880
- ...vaultKeyMask ? { vaultKeyMask } : {}
138616
+ ...vaultKeyMask ? { vaultKeyMask } : {},
138617
+ ...replacementKeyMask ? { replacementKeyMask } : {}
138618
+ });
138619
+ const fromSources = resolveProviderDetailSources({
138620
+ hasEnvKey,
138621
+ hasCfgKey,
138622
+ isKcKey,
138623
+ isOpKey,
138624
+ hasKcKey,
138625
+ ...vaultKeySource ? { vaultKeySource } : {},
138626
+ ...replacementKeySource ? { replacementSource: replacementKeySource } : {}
137881
138627
  });
137882
138628
  if (isInputMode) {
137883
138629
  return /* @__PURE__ */ jsxDEV22("box", {
@@ -138072,53 +138818,23 @@ function ProviderDetail({
138072
138818
  attributes: A.bold,
138073
138819
  children: "From: "
138074
138820
  }, undefined, false, undefined, this),
138075
- hasEnvKey && /* @__PURE__ */ jsxDEV22("span", {
138076
- fg: C.green,
138077
- attributes: A.bold,
138078
- children: isKcKey ? "keychain" : isOpKey ? "1Password" : "env"
138079
- }, undefined, false, undefined, this),
138080
- hasEnvKey && hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
138081
- fg: C.fgMuted,
138082
- children: " (used) + "
138083
- }, undefined, false, undefined, this),
138084
- hasEnvKey && !hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
138085
- fg: C.fgMuted,
138086
- children: " (used)"
138087
- }, undefined, false, undefined, this),
138088
- hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
138089
- fg: hasEnvKey ? C.fgMuted : C.green,
138090
- attributes: A.boldIf(!hasEnvKey),
138091
- children: "config"
138092
- }, undefined, false, undefined, this),
138093
- hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
138094
- fg: C.fgMuted,
138095
- children: hasEnvKey ? " (shadowed)" : " (used)"
138096
- }, undefined, false, undefined, this),
138097
- vaultKeySource && /* @__PURE__ */ jsxDEV22(Fragment12, {
138098
- children: [
138099
- /* @__PURE__ */ jsxDEV22("span", {
138100
- fg: C.green,
138101
- attributes: A.bold,
138102
- children: vaultLabel(vaultKeySource)
138103
- }, undefined, false, undefined, this),
138104
- /* @__PURE__ */ jsxDEV22("span", {
138105
- fg: C.fgMuted,
138106
- children: " (used)"
138107
- }, undefined, false, undefined, this)
138108
- ]
138109
- }, undefined, true, undefined, this),
138110
- hasKcKey && !isKcKey && vaultKeySource !== "macOS Keychain" && /* @__PURE__ */ jsxDEV22(Fragment12, {
138111
- children: [
138821
+ fromSources.flatMap((source, i) => [
138822
+ ...i > 0 ? [
138112
138823
  /* @__PURE__ */ jsxDEV22("span", {
138113
138824
  fg: C.fgMuted,
138114
138825
  children: " + "
138115
- }, undefined, false, undefined, this),
138116
- /* @__PURE__ */ jsxDEV22("span", {
138117
- fg: C.fgMuted,
138118
- children: "keychain (shadowed)"
138119
- }, undefined, false, undefined, this)
138120
- ]
138121
- }, undefined, true, undefined, this)
138826
+ }, `${source.label}-sep`, false, undefined, this)
138827
+ ] : [],
138828
+ /* @__PURE__ */ jsxDEV22("span", {
138829
+ fg: source.used ? C.green : C.fgMuted,
138830
+ attributes: A.boldIf(source.used),
138831
+ children: source.label
138832
+ }, source.label, false, undefined, this),
138833
+ /* @__PURE__ */ jsxDEV22("span", {
138834
+ fg: C.fgMuted,
138835
+ children: source.used ? " (used)" : " (shadowed)"
138836
+ }, `${source.label}-state`, false, undefined, this)
138837
+ ])
138122
138838
  ]
138123
138839
  }, undefined, true, undefined, this)
138124
138840
  ]
@@ -139715,6 +140431,9 @@ var init_TabBar = __esm(() => {
139715
140431
  });
139716
140432
 
139717
140433
  // src/tui/config-save.ts
140434
+ function invalidateAfterKeychainCopy(outcome) {
140435
+ credentials.invalidateKeyVars(outcome.written);
140436
+ }
139718
140437
  function configSaveFailure(err) {
139719
140438
  const detail = err instanceof Error ? err.message : String(err);
139720
140439
  return `Not saved \u2014 ${detail}`;
@@ -139723,15 +140442,24 @@ function configKeySavedStatus(displayName, envVar, note, keychainFailure) {
139723
140442
  return keychainFailure === undefined ? `Key saved for ${displayName} (${envVar}).${note}` : `Keychain write failed (${keychainFailure}) \u2014 saved to config.json instead.${note}`;
139724
140443
  }
139725
140444
  function outrankedKeyNote(envVar, outranking) {
140445
+ const entries = outranking.map((e) => typeof e === "string" ? { source: e, envVar } : e);
140446
+ const varOf = (source) => entries.find((e) => e.source === source)?.envVar;
139726
140447
  const where = [];
139727
- if (outranking.includes("environment"))
139728
- where.push(`the ${envVar} exported in your shell`);
139729
- if (outranking.includes("config"))
139730
- where.push(`${envVar} in ~/.claudish/config.json apiKeys`);
140448
+ const exported = varOf("environment");
140449
+ if (exported)
140450
+ where.push(`the ${exported} exported in your shell`);
140451
+ const configured = varOf("config");
140452
+ if (configured)
140453
+ where.push(`${configured} in ${configLabel()} apiKeys`);
139731
140454
  if (where.length === 0)
139732
140455
  return "";
139733
- return ` This session signs with it, but new launches still use ${where.join(" and ")}, which outranks it: remove that to use the new key.`;
140456
+ const [verb, pronoun] = where.length > 1 ? ["outrank", "them"] : ["outranks", "that"];
140457
+ return ` This session signs with it, but new launches still use ${where.join(" and ")}, which ${verb} it: remove ${pronoun} to use the new key.`;
139734
140458
  }
140459
+ var init_config_save = __esm(() => {
140460
+ init_authority();
140461
+ init_key_sources();
140462
+ });
139735
140463
 
139736
140464
  // src/tui/hooks/useProfileWizard.ts
139737
140465
  import { useCallback as useCallback2, useState as useState9 } from "react";
@@ -140084,6 +140812,7 @@ function useProfileWizard(args) {
140084
140812
  var FIELDS, FIELD_TO_MODE, MODE_TO_FIELD;
140085
140813
  var init_useProfileWizard = __esm(() => {
140086
140814
  init_profile_config();
140815
+ init_config_save();
140087
140816
  init_constants4();
140088
140817
  FIELDS = ["opus", "sonnet", "haiku", "subagent"];
140089
140818
  FIELD_TO_MODE = {
@@ -140506,12 +141235,13 @@ async function resolveOpEntrySecrets(entries, auth) {
140506
141235
  return secrets;
140507
141236
  }
140508
141237
  function writeSecretsToKeychain(secrets, alreadyStored) {
140509
- const outcome = { created: 0, replaced: 0, skipped: [] };
141238
+ const outcome = { created: 0, replaced: 0, skipped: [], written: [] };
140510
141239
  for (const [name, value] of Object.entries(secrets)) {
140511
141240
  if (!value)
140512
141241
  continue;
140513
141242
  try {
140514
141243
  writeKeychainSecret(name, value);
141244
+ outcome.written.push(name);
140515
141245
  if (alreadyStored.has(name))
140516
141246
  outcome.replaced++;
140517
141247
  else
@@ -140697,6 +141427,9 @@ function App({ requestLogin } = {}) {
140697
141427
  const isKcKey = hasEnvKey && isKeychainHydratedVar(selectedProvider.apiKeyEnvVar);
140698
141428
  const vaultKeySource = hasKey && !hasEnvKey && !hasCfgKey ? readAtUseVaultSource(selectedProvider) : undefined;
140699
141429
  const vaultKeyMask = vaultKeySource ? credentials.describeOrigin(selectedProvider.catalogName)?.masked : undefined;
141430
+ const selectedOrigin = credentials.describeOrigin(selectedProvider.catalogName);
141431
+ const replacementKeyMask = selectedOrigin?.replaced ? selectedOrigin.masked : undefined;
141432
+ const replacementKeySource = selectedOrigin?.replaced ? selectedOrigin.source : undefined;
140700
141433
  const cfgKeyMask = maskKey2(config.apiKeys?.[selectedProvider.apiKeyEnvVar]);
140701
141434
  const envKeyMask = maskKey2(process.env[selectedProvider.apiKeyEnvVar]);
140702
141435
  const activeEndpointEnvVar = selectedProvider.endpointEnvVar;
@@ -140878,7 +141611,7 @@ function App({ requestLogin } = {}) {
140878
141611
  if (outcome.created + outcome.replaced > 0) {
140879
141612
  setKeychainEnabled(true);
140880
141613
  refreshKeychainVars();
140881
- credentials.invalidate();
141614
+ invalidateAfterKeychainCopy(outcome);
140882
141615
  invalidateProbeProxyHandlers();
140883
141616
  refreshConfig();
140884
141617
  }
@@ -142253,6 +142986,8 @@ function App({ requestLogin } = {}) {
142253
142986
  hasKcKey,
142254
142987
  ...vaultKeySource ? { vaultKeySource } : {},
142255
142988
  ...vaultKeyMask ? { vaultKeyMask } : {},
142989
+ ...replacementKeyMask ? { replacementKeyMask } : {},
142990
+ ...replacementKeySource ? { replacementKeySource } : {},
142256
142991
  keySaveTarget: keychainSupported ? "macOS Keychain" : "config.json",
142257
142992
  credentialNote: providerCredentialNote(selectedProvider),
142258
142993
  cfgKeyMask,
@@ -142415,6 +143150,7 @@ var init_App = __esm(() => {
142415
143150
  init_RoutingContent();
142416
143151
  init_RoutingDetail();
142417
143152
  init_TabBar();
143153
+ init_config_save();
142418
143154
  init_constants4();
142419
143155
  init_useProfileWizard();
142420
143156
  init_useRouteProbe();
@@ -143123,17 +143859,17 @@ var init_model_lineup = __esm(() => {
143123
143859
 
143124
143860
  // src/diag-output.ts
143125
143861
  import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync32, unlinkSync as unlinkSync15, writeFileSync as writeFileSync32 } from "fs";
143126
- import { homedir as homedir47 } from "os";
143127
- import { join as join76 } from "path";
143862
+ import { homedir as homedir46 } from "os";
143863
+ import { join as join77 } from "path";
143128
143864
  function getClaudishDir() {
143129
- const dir = join76(homedir47(), ".claudish");
143865
+ const dir = join77(homedir46(), ".claudish");
143130
143866
  try {
143131
143867
  mkdirSync32(dir, { recursive: true });
143132
143868
  } catch {}
143133
143869
  return dir;
143134
143870
  }
143135
143871
  function getDiagLogPath() {
143136
- return join76(getClaudishDir(), `diag-${process.pid}.log`);
143872
+ return join77(getClaudishDir(), `diag-${process.pid}.log`);
143137
143873
  }
143138
143874
 
143139
143875
  class LogFileDiagOutput {
@@ -145224,11 +145960,11 @@ var init_resume_picker_run = __esm(() => {
145224
145960
  });
145225
145961
 
145226
145962
  // src/launcher/model-setting-ledger-path.ts
145227
- import { homedir as homedir48 } from "os";
145228
- import { join as join77 } from "path";
145963
+ import { homedir as homedir47 } from "os";
145964
+ import { join as join78 } from "path";
145229
145965
  function modelSettingLedgerPath(env = process.env) {
145230
- const home = env.HOME && env.HOME.length > 0 ? env.HOME : homedir48();
145231
- return join77(home, ".claudish", MODEL_SETTING_LEDGER_FILE);
145966
+ const home = env.HOME && env.HOME.length > 0 ? env.HOME : homedir47();
145967
+ return join78(home, ".claudish", MODEL_SETTING_LEDGER_FILE);
145232
145968
  }
145233
145969
  var MODEL_SETTING_LEDGER_FILE = "model-setting-restore.json";
145234
145970
  var init_model_setting_ledger_path = () => {};
@@ -145249,18 +145985,18 @@ import {
145249
145985
  unlinkSync as unlinkSync16,
145250
145986
  writeSync as writeSync8
145251
145987
  } from "fs";
145252
- import { homedir as homedir49 } from "os";
145253
- import { basename as basename10, dirname as dirname31, join as join78, resolve as resolve15 } from "path";
145988
+ import { homedir as homedir48 } from "os";
145989
+ import { basename as basename10, dirname as dirname31, join as join79, resolve as resolve15 } from "path";
145254
145990
  function canonicalSettingsPath(path) {
145255
145991
  let head = resolve15(path);
145256
145992
  const rest = [];
145257
145993
  for (;; ) {
145258
145994
  try {
145259
- return join78(realpathSync12.native(head), ...rest);
145995
+ return join79(realpathSync12.native(head), ...rest);
145260
145996
  } catch {
145261
145997
  const parent = dirname31(head);
145262
145998
  if (parent === head)
145263
- return join78(head, ...rest);
145999
+ return join79(head, ...rest);
145264
146000
  rest.unshift(basename10(head));
145265
146001
  head = parent;
145266
146002
  }
@@ -145356,7 +146092,7 @@ function restoreRound(settingsKey, target, entry, deps, fence) {
145356
146092
  const planned = nextSettingsText(text, entry);
145357
146093
  if ("outcome" in planned)
145358
146094
  return planned.outcome;
145359
- const temp = join78(dirname31(target), `${TEMP_PREFIX}${deps.pid ?? process.pid}-${randomUUID12()}`);
146095
+ const temp = join79(dirname31(target), `${TEMP_PREFIX}${deps.pid ?? process.pid}-${randomUUID12()}`);
145360
146096
  try {
145361
146097
  deps.writeNew(temp, planned.next, statA.mode & 4095);
145362
146098
  } catch {
@@ -145548,7 +146284,7 @@ function removeOrphanTemps(ctx, key, table) {
145548
146284
  if (live)
145549
146285
  continue;
145550
146286
  try {
145551
- unlinkSync16(join78(dir, name));
146287
+ unlinkSync16(join79(dir, name));
145552
146288
  } catch {}
145553
146289
  }
145554
146290
  }
@@ -145639,7 +146375,7 @@ function selfStartEpochMs() {
145639
146375
  async function beginModelSettingWatch(listedSpecs, deps = {}) {
145640
146376
  const ctx = contextOf(deps);
145641
146377
  const env = deps.env ?? process.env;
145642
- const settingsFile = deps.settingsFile ?? userSettingsFile(env.CLAUDE_CONFIG_DIR, env.HOME && env.HOME.length > 0 ? env.HOME : homedir49(), deps.cwd ?? process.cwd());
146378
+ const settingsFile = deps.settingsFile ?? userSettingsFile(env.CLAUDE_CONFIG_DIR, env.HOME && env.HOME.length > 0 ? env.HOME : homedir48(), deps.cwd ?? process.cwd());
145643
146379
  const key = canonicalSettingsPath(settingsFile);
145644
146380
  const lockPath = lockPathOf(ctx.ledgerPath);
145645
146381
  const lockOpts = {
@@ -146255,7 +146991,7 @@ init_op_source();
146255
146991
  init_startup_trace();
146256
146992
  init_picker_cancelled();
146257
146993
  import { existsSync as existsSync50, readFileSync as readFileSync61 } from "fs";
146258
- import { join as join79, resolve as resolve16 } from "path";
146994
+ import { join as join80, resolve as resolve16 } from "path";
146259
146995
 
146260
146996
  // src/tui/runtime/should-open-picker.ts
146261
146997
  function noModelConfigured(gate) {
@@ -146272,7 +147008,7 @@ function requiresExplicitModel(gate, tty) {
146272
147008
  var autoloadDropped = [...droppedAtLaunch, ...takeLauncherDropped(process.env)];
146273
147009
  var dotenvText;
146274
147010
  try {
146275
- dotenvText = readFileSync61(join79(process.cwd(), ".env"));
147011
+ dotenvText = readFileSync61(join80(process.cwd(), ".env"));
146276
147012
  } catch {}
146277
147013
  if (dotenvText !== undefined) {
146278
147014
  await Promise.resolve().then(() => init_dotenv_allowlist());
@@ -146678,7 +147414,7 @@ async function runCli() {
146678
147414
  process.exit(1);
146679
147415
  }
146680
147416
  const mode = cliConfig.teamMode ?? "default";
146681
- const sessionPath = join79(process.cwd(), `.claudish-team-${Date.now()}`);
147417
+ const sessionPath = join80(process.cwd(), `.claudish-team-${Date.now()}`);
146682
147418
  if (mode === "json") {
146683
147419
  await Promise.resolve().then(() => init_pane());
146684
147420
  await Promise.resolve().then(() => init_team_orchestrator());
@@ -146698,7 +147434,7 @@ async function runCli() {
146698
147434
  const status = await runModels(sessionPath);
146699
147435
  const result = { ...status, responses: {} };
146700
147436
  for (const anonId of Object.keys(status.models)) {
146701
- const responsePath = join79(sessionPath, `response-${anonId}.md`);
147437
+ const responsePath = join80(sessionPath, `response-${anonId}.md`);
146702
147438
  try {
146703
147439
  const raw = readFileSync61(responsePath, "utf-8").trim();
146704
147440
  try {