claudish 14.27.2 → 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.
- package/dist/index.js +1201 -617
- 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.
|
|
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-
|
|
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-
|
|
14254
|
+
generationId: "g-20261116161706980-7c7c9818"
|
|
14255
14255
|
},
|
|
14256
14256
|
source: "https://us-central1-claudish-6da10.cloudfunctions.net"
|
|
14257
14257
|
},
|
|
14258
|
-
catalogGenerationId: "g-
|
|
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-
|
|
15445
|
+
"gemini-4-carbon-medium",
|
|
15446
15446
|
"gemini-4-carbon-low",
|
|
15447
|
-
"gemini-4-carbon-
|
|
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-
|
|
15601
|
-
"gemini-4-hydrogen-low",
|
|
15600
|
+
"gemini-4-hydrogen-xhigh",
|
|
15602
15601
|
"gemini-4-hydrogen-medium",
|
|
15603
|
-
"gemini-4-hydrogen-
|
|
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-
|
|
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: "
|
|
19026
|
+
externalModelId: "gemini-4-argon-medium",
|
|
19021
19027
|
kind: "provider_model",
|
|
19022
19028
|
provider: "antigravity",
|
|
19023
19029
|
resolution: {
|
|
19024
|
-
modelId: "
|
|
19030
|
+
modelId: "gemini-4-argon",
|
|
19025
19031
|
status: "mapped"
|
|
19026
19032
|
},
|
|
19027
|
-
sourceText: "
|
|
19033
|
+
sourceText: "gemini-4-argon-medium"
|
|
19028
19034
|
},
|
|
19029
19035
|
{
|
|
19030
|
-
externalModelId: "gemini-4-
|
|
19036
|
+
externalModelId: "gemini-4-carbon-medium",
|
|
19031
19037
|
kind: "provider_model",
|
|
19032
19038
|
provider: "antigravity",
|
|
19033
19039
|
resolution: {
|
|
19034
|
-
modelId: "gemini-4-
|
|
19040
|
+
modelId: "gemini-4-carbon",
|
|
19035
19041
|
status: "mapped"
|
|
19036
19042
|
},
|
|
19037
|
-
sourceText: "gemini-4-
|
|
19043
|
+
sourceText: "gemini-4-carbon-medium"
|
|
19038
19044
|
},
|
|
19039
19045
|
{
|
|
19040
|
-
externalModelId: "gemini-4-hydrogen-
|
|
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-
|
|
19053
|
+
sourceText: "gemini-4-hydrogen-xhigh"
|
|
19048
19054
|
},
|
|
19049
19055
|
{
|
|
19050
|
-
externalModelId: "gemini-4-carbon-
|
|
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-
|
|
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: "
|
|
19076
|
+
externalModelId: "gemini-4-argon-high",
|
|
19071
19077
|
kind: "provider_model",
|
|
19072
19078
|
provider: "antigravity",
|
|
19073
19079
|
resolution: {
|
|
19074
|
-
modelId: "
|
|
19080
|
+
modelId: "gemini-4-argon",
|
|
19075
19081
|
status: "mapped"
|
|
19076
19082
|
},
|
|
19077
|
-
sourceText: "
|
|
19083
|
+
sourceText: "gemini-4-argon-high"
|
|
19078
19084
|
},
|
|
19079
19085
|
{
|
|
19080
|
-
externalModelId: "
|
|
19086
|
+
externalModelId: "claude-opus-5-5-low",
|
|
19081
19087
|
kind: "provider_model",
|
|
19082
19088
|
provider: "antigravity",
|
|
19083
19089
|
resolution: {
|
|
19084
|
-
modelId: "
|
|
19090
|
+
modelId: "claude-opus-5-5",
|
|
19085
19091
|
status: "mapped"
|
|
19086
19092
|
},
|
|
19087
|
-
sourceText: "
|
|
19093
|
+
sourceText: "claude-opus-5-5-low"
|
|
19088
19094
|
},
|
|
19089
19095
|
{
|
|
19090
|
-
externalModelId: "gemini-4-
|
|
19096
|
+
externalModelId: "gemini-4-argon-low",
|
|
19091
19097
|
kind: "provider_model",
|
|
19092
19098
|
provider: "antigravity",
|
|
19093
19099
|
resolution: {
|
|
19094
|
-
modelId: "gemini-4-
|
|
19100
|
+
modelId: "gemini-4-argon",
|
|
19095
19101
|
status: "mapped"
|
|
19096
19102
|
},
|
|
19097
|
-
sourceText: "gemini-4-
|
|
19103
|
+
sourceText: "gemini-4-argon-low"
|
|
19098
19104
|
},
|
|
19099
19105
|
{
|
|
19100
|
-
externalModelId: "gemini-4-
|
|
19106
|
+
externalModelId: "gemini-4-carbon-high",
|
|
19101
19107
|
kind: "provider_model",
|
|
19102
19108
|
provider: "antigravity",
|
|
19103
19109
|
resolution: {
|
|
19104
|
-
modelId: "gemini-4-
|
|
19110
|
+
modelId: "gemini-4-carbon",
|
|
19105
19111
|
status: "mapped"
|
|
19106
19112
|
},
|
|
19107
|
-
sourceText: "gemini-4-
|
|
19113
|
+
sourceText: "gemini-4-carbon-high"
|
|
19108
19114
|
},
|
|
19109
19115
|
{
|
|
19110
|
-
externalModelId: "
|
|
19116
|
+
externalModelId: "claude-sonnet-5-5-medium",
|
|
19111
19117
|
kind: "provider_model",
|
|
19112
19118
|
provider: "antigravity",
|
|
19113
19119
|
resolution: {
|
|
19114
|
-
modelId: "
|
|
19120
|
+
modelId: "claude-sonnet-5-5",
|
|
19115
19121
|
status: "mapped"
|
|
19116
19122
|
},
|
|
19117
|
-
sourceText: "
|
|
19123
|
+
sourceText: "claude-sonnet-5-5-medium"
|
|
19118
19124
|
},
|
|
19119
19125
|
{
|
|
19120
|
-
externalModelId: "gemini-4-
|
|
19126
|
+
externalModelId: "gemini-4-hydrogen-high",
|
|
19121
19127
|
kind: "provider_model",
|
|
19122
19128
|
provider: "antigravity",
|
|
19123
19129
|
resolution: {
|
|
19124
|
-
modelId: "gemini-4-
|
|
19130
|
+
modelId: "gemini-4-hydrogen",
|
|
19125
19131
|
status: "mapped"
|
|
19126
19132
|
},
|
|
19127
|
-
sourceText: "gemini-4-
|
|
19133
|
+
sourceText: "gemini-4-hydrogen-high"
|
|
19128
19134
|
},
|
|
19129
19135
|
{
|
|
19130
|
-
externalModelId: "claude-sonnet-5-5-
|
|
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-
|
|
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: "
|
|
19156
|
+
externalModelId: "gemini-4-hydrogen-low",
|
|
19151
19157
|
kind: "provider_model",
|
|
19152
19158
|
provider: "antigravity",
|
|
19153
19159
|
resolution: {
|
|
19154
|
-
modelId: "
|
|
19160
|
+
modelId: "gemini-4-hydrogen",
|
|
19155
19161
|
status: "mapped"
|
|
19156
19162
|
},
|
|
19157
|
-
sourceText: "
|
|
19163
|
+
sourceText: "gemini-4-hydrogen-low"
|
|
19158
19164
|
},
|
|
19159
19165
|
{
|
|
19160
|
-
externalModelId: "
|
|
19166
|
+
externalModelId: "claude-opus-5-5-medium",
|
|
19161
19167
|
kind: "provider_model",
|
|
19162
19168
|
provider: "antigravity",
|
|
19163
19169
|
resolution: {
|
|
19164
|
-
modelId: "
|
|
19170
|
+
modelId: "claude-opus-5-5",
|
|
19165
19171
|
status: "mapped"
|
|
19166
19172
|
},
|
|
19167
|
-
sourceText: "
|
|
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: "
|
|
19517
|
+
externalModelId: "glm-5.3-flash",
|
|
19512
19518
|
kind: "provider_model",
|
|
19513
19519
|
provider: "ollamacloud",
|
|
19514
19520
|
resolution: {
|
|
19515
|
-
modelId: "
|
|
19521
|
+
modelId: "glm-5.3-flash",
|
|
19516
19522
|
status: "mapped"
|
|
19517
19523
|
},
|
|
19518
|
-
sourceText: "
|
|
19524
|
+
sourceText: "glm-5.3-flash"
|
|
19519
19525
|
},
|
|
19520
19526
|
{
|
|
19521
|
-
externalModelId: "
|
|
19527
|
+
externalModelId: "kimi-k3.1-pro",
|
|
19522
19528
|
kind: "provider_model",
|
|
19523
19529
|
provider: "ollamacloud",
|
|
19524
19530
|
resolution: {
|
|
19525
|
-
modelId: "
|
|
19531
|
+
modelId: "kimi-k3.1-pro",
|
|
19526
19532
|
status: "mapped"
|
|
19527
19533
|
},
|
|
19528
|
-
sourceText: "
|
|
19534
|
+
sourceText: "kimi-k3.1-pro"
|
|
19529
19535
|
},
|
|
19530
19536
|
{
|
|
19531
|
-
externalModelId: "
|
|
19537
|
+
externalModelId: "minimax-m3.1-flash",
|
|
19532
19538
|
kind: "provider_model",
|
|
19533
19539
|
provider: "ollamacloud",
|
|
19534
19540
|
resolution: {
|
|
19535
|
-
modelId: "
|
|
19541
|
+
modelId: "minimax-m3.1-flash",
|
|
19536
19542
|
status: "mapped"
|
|
19537
19543
|
},
|
|
19538
|
-
sourceText: "
|
|
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: "
|
|
19557
|
+
externalModelId: "mimo-v2.6-flash",
|
|
19552
19558
|
kind: "provider_model",
|
|
19553
19559
|
provider: "ollamacloud",
|
|
19554
19560
|
resolution: {
|
|
19555
|
-
modelId: "
|
|
19561
|
+
modelId: "mimo-v2.6-flash",
|
|
19556
19562
|
status: "mapped"
|
|
19557
19563
|
},
|
|
19558
|
-
sourceText: "
|
|
19564
|
+
sourceText: "mimo-v2.6-flash"
|
|
19559
19565
|
},
|
|
19560
19566
|
{
|
|
19561
|
-
externalModelId: "
|
|
19567
|
+
externalModelId: "mimo-v2.6-pro",
|
|
19562
19568
|
kind: "provider_model",
|
|
19563
19569
|
provider: "ollamacloud",
|
|
19564
19570
|
resolution: {
|
|
19565
|
-
modelId: "
|
|
19571
|
+
modelId: "mimo-v2.6-pro",
|
|
19566
19572
|
status: "mapped"
|
|
19567
19573
|
},
|
|
19568
|
-
sourceText: "
|
|
19574
|
+
sourceText: "mimo-v2.6-pro"
|
|
19569
19575
|
},
|
|
19570
19576
|
{
|
|
19571
|
-
externalModelId: "
|
|
19577
|
+
externalModelId: "glm-5.3",
|
|
19572
19578
|
kind: "provider_model",
|
|
19573
19579
|
provider: "ollamacloud",
|
|
19574
19580
|
resolution: {
|
|
19575
|
-
modelId: "
|
|
19581
|
+
modelId: "glm-5.3",
|
|
19576
19582
|
status: "mapped"
|
|
19577
19583
|
},
|
|
19578
|
-
sourceText: "
|
|
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-
|
|
19839
|
+
generationId: "g-20261116161706980-7c7c9818",
|
|
19834
19840
|
registry: {
|
|
19835
19841
|
contractVersion: 3,
|
|
19836
19842
|
registryVersion: "3.7.0",
|
|
@@ -34845,6 +34851,73 @@ var init_antigravity_fetch = __esm(() => {
|
|
|
34845
34851
|
]);
|
|
34846
34852
|
});
|
|
34847
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
|
+
|
|
34848
34921
|
// src/auth/antigravity-user.ts
|
|
34849
34922
|
function antigravityHost() {
|
|
34850
34923
|
const override = process.env.AICODE_ENDPOINT_URL?.trim();
|
|
@@ -34884,6 +34957,7 @@ function resetAntigravityUserCache() {
|
|
|
34884
34957
|
agServedCacheAt = 0;
|
|
34885
34958
|
agServedCacheVersion = null;
|
|
34886
34959
|
cachedAgLineage = null;
|
|
34960
|
+
accountCallsSentFor = undefined;
|
|
34887
34961
|
}
|
|
34888
34962
|
function syncAccountCaches() {
|
|
34889
34963
|
const lineage = currentAntigravityTokenLineage();
|
|
@@ -34895,6 +34969,17 @@ function syncAccountCaches() {
|
|
|
34895
34969
|
resetAntigravityUserCache();
|
|
34896
34970
|
cachedAgLineage = lineage;
|
|
34897
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
|
+
}
|
|
34898
34983
|
function lineageOfToken(accessToken) {
|
|
34899
34984
|
return lineageForAntigravityAccessToken(accessToken) ?? currentAntigravityTokenLineage();
|
|
34900
34985
|
}
|
|
@@ -34940,6 +35025,7 @@ async function setupAntigravityUser(accessToken) {
|
|
|
34940
35025
|
log("[Antigravity] Token lineage changed during setup; the result is not cached.");
|
|
34941
35026
|
}
|
|
34942
35027
|
log(`[Antigravity] User set up, project: ${projectId}, tier: ${resolvedTier}`);
|
|
35028
|
+
startAccountCalls(accessToken, projectId, lineage);
|
|
34943
35029
|
return { projectId, tierId: resolvedTier };
|
|
34944
35030
|
}
|
|
34945
35031
|
function getAntigravityTierDisplayName() {
|
|
@@ -34955,9 +35041,9 @@ function getAntigravityTierDisplayName() {
|
|
|
34955
35041
|
return "Antigravity Free";
|
|
34956
35042
|
return cachedAgTierName || "Antigravity";
|
|
34957
35043
|
}
|
|
34958
|
-
async function
|
|
35044
|
+
async function retrieveUserQuotaSummary(accessToken, projectId) {
|
|
34959
35045
|
try {
|
|
34960
|
-
const res = await antigravityFetch(`${apiBase()}:
|
|
35046
|
+
const res = await antigravityFetch(`${apiBase()}:retrieveUserQuotaSummary`, {
|
|
34961
35047
|
method: "POST",
|
|
34962
35048
|
headers: {
|
|
34963
35049
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -34967,15 +35053,37 @@ async function retrieveUserQuota(accessToken, projectId) {
|
|
|
34967
35053
|
body: JSON.stringify({ project: projectId })
|
|
34968
35054
|
});
|
|
34969
35055
|
if (!res.ok) {
|
|
34970
|
-
log(`[Antigravity]
|
|
35056
|
+
log(`[Antigravity] retrieveUserQuotaSummary failed: ${res.status}`);
|
|
34971
35057
|
return null;
|
|
34972
35058
|
}
|
|
34973
35059
|
return await res.json();
|
|
34974
35060
|
} catch (err) {
|
|
34975
|
-
log(`[Antigravity]
|
|
35061
|
+
log(`[Antigravity] retrieveUserQuotaSummary error: ${err}`);
|
|
34976
35062
|
return null;
|
|
34977
35063
|
}
|
|
34978
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"}`);
|
|
35069
|
+
return null;
|
|
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 };
|
|
35086
|
+
}
|
|
34979
35087
|
function flattenAgentModelSorts(sorts) {
|
|
34980
35088
|
if (!Array.isArray(sorts))
|
|
34981
35089
|
return;
|
|
@@ -35132,10 +35240,11 @@ function peekServedAntigravityModels() {
|
|
|
35132
35240
|
return null;
|
|
35133
35241
|
return agServedCache;
|
|
35134
35242
|
}
|
|
35135
|
-
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;
|
|
35136
35244
|
var init_antigravity_user = __esm(() => {
|
|
35137
35245
|
init_logger();
|
|
35138
35246
|
init_antigravity_fetch();
|
|
35247
|
+
init_antigravity_side_calls();
|
|
35139
35248
|
init_antigravity_token();
|
|
35140
35249
|
SERVED_MODELS_TTL_MS = 10 * 60 * 1000;
|
|
35141
35250
|
});
|
|
@@ -35165,7 +35274,12 @@ function selectBucket(buckets, activeModelId) {
|
|
|
35165
35274
|
if (match)
|
|
35166
35275
|
return match;
|
|
35167
35276
|
}
|
|
35168
|
-
|
|
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;
|
|
35169
35283
|
}
|
|
35170
35284
|
function windowFromBucket(bucket) {
|
|
35171
35285
|
const used = usedPctOf(bucket);
|
|
@@ -35227,14 +35341,44 @@ function planFromBuckets(buckets, activeModelId) {
|
|
|
35227
35341
|
observed_at: new Date().toISOString()
|
|
35228
35342
|
};
|
|
35229
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
|
+
}
|
|
35230
35368
|
async function fetchPlan(ctx) {
|
|
35231
35369
|
try {
|
|
35232
35370
|
const accessToken = await getValidAntigravityAccessToken();
|
|
35233
35371
|
const { projectId } = await setupAntigravityUser(accessToken);
|
|
35234
|
-
|
|
35235
|
-
|
|
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)
|
|
35236
35380
|
return;
|
|
35237
|
-
return planFromBuckets(quota.buckets, ctx
|
|
35381
|
+
return planFromBuckets(quota.buckets, ctx.modelId);
|
|
35238
35382
|
} catch (err) {
|
|
35239
35383
|
log(`[quota:antigravity] fetch failed: ${err}`);
|
|
35240
35384
|
return;
|
|
@@ -49662,6 +49806,164 @@ function decideCodexSpeed(speed, modelInfo) {
|
|
|
49662
49806
|
}
|
|
49663
49807
|
var CODEX_SERVICE_TIER_POINTER = "/service_tier";
|
|
49664
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
|
+
|
|
49665
49967
|
// src/providers/antigravity-envelope.ts
|
|
49666
49968
|
import { createHash as createHash13, randomBytes as randomBytes7, randomUUID as randomUUID3 } from "crypto";
|
|
49667
49969
|
|
|
@@ -49669,6 +49971,7 @@ class AntigravityConversations {
|
|
|
49669
49971
|
limit;
|
|
49670
49972
|
newId;
|
|
49671
49973
|
byFirstMessage = new Map;
|
|
49974
|
+
newTrajectories = new Set;
|
|
49672
49975
|
sessionId;
|
|
49673
49976
|
constructor(limit = 64, newId = randomUUID3, sessionId = randomSessionId()) {
|
|
49674
49977
|
this.limit = limit;
|
|
@@ -49686,13 +49989,30 @@ ${firstMessageKey(inner)}`;
|
|
|
49686
49989
|
}
|
|
49687
49990
|
const created = { cascadeId: this.newId(), trajectoryId: this.newId(), requestCount: 0 };
|
|
49688
49991
|
this.byFirstMessage.set(key, created);
|
|
49992
|
+
this.newTrajectories.add(created.trajectoryId);
|
|
49689
49993
|
if (this.byFirstMessage.size > this.limit) {
|
|
49690
49994
|
const oldest = this.byFirstMessage.keys().next().value;
|
|
49691
|
-
if (oldest !== undefined)
|
|
49995
|
+
if (oldest !== undefined) {
|
|
49996
|
+
const dropped = this.byFirstMessage.get(oldest);
|
|
49997
|
+
if (dropped)
|
|
49998
|
+
this.newTrajectories.delete(dropped.trajectoryId);
|
|
49692
49999
|
this.byFirstMessage.delete(oldest);
|
|
50000
|
+
}
|
|
49693
50001
|
}
|
|
49694
50002
|
return created;
|
|
49695
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
|
+
}
|
|
49696
50016
|
}
|
|
49697
50017
|
function randomSessionId() {
|
|
49698
50018
|
return randomBytes7(8).readBigInt64BE().toString();
|
|
@@ -49778,7 +50098,22 @@ function buildAntigravityEnvelope(input) {
|
|
|
49778
50098
|
...others
|
|
49779
50099
|
} = inner;
|
|
49780
50100
|
const stepIndex = lastStepIndex(contents);
|
|
49781
|
-
const
|
|
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) };
|
|
49782
50117
|
if (systemInstruction && typeof systemInstruction === "object") {
|
|
49783
50118
|
const { role: _role, ...instruction } = systemInstruction;
|
|
49784
50119
|
request.systemInstruction = { role: "user", ...instruction };
|
|
@@ -49808,6 +50143,7 @@ function buildAntigravityEnvelope(input) {
|
|
|
49808
50143
|
}
|
|
49809
50144
|
var antigravityConversations;
|
|
49810
50145
|
var init_antigravity_envelope = __esm(() => {
|
|
50146
|
+
init_antigravity_content();
|
|
49811
50147
|
antigravityConversations = new AntigravityConversations;
|
|
49812
50148
|
});
|
|
49813
50149
|
|
|
@@ -51824,9 +52160,29 @@ class AntigravityProviderTransport {
|
|
|
51824
52160
|
return this._displayName;
|
|
51825
52161
|
}
|
|
51826
52162
|
streamFormat = "gemini-sse";
|
|
51827
|
-
fetch(url, init) {
|
|
52163
|
+
async fetch(url, init) {
|
|
52164
|
+
await this.writeNewTrajectoryAcls(url, init);
|
|
51828
52165
|
return antigravityFetch(url, init);
|
|
51829
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
|
+
}
|
|
51830
52186
|
modelName;
|
|
51831
52187
|
servedModelName;
|
|
51832
52188
|
accessToken = null;
|
|
@@ -52087,7 +52443,7 @@ class AntigravityProviderTransport {
|
|
|
52087
52443
|
return;
|
|
52088
52444
|
let timer;
|
|
52089
52445
|
const data = await Promise.race([
|
|
52090
|
-
|
|
52446
|
+
retrieveModelQuota(this.accessToken, this.projectId).catch(() => null),
|
|
52091
52447
|
new Promise((resolve) => {
|
|
52092
52448
|
timer = setTimeout(() => resolve(null), QUOTA_CHECK_TIMEOUT_MS);
|
|
52093
52449
|
})
|
|
@@ -52133,7 +52489,7 @@ class AntigravityProviderTransport {
|
|
|
52133
52489
|
if (!this.accessToken || !this.projectId)
|
|
52134
52490
|
return;
|
|
52135
52491
|
try {
|
|
52136
|
-
const data = await
|
|
52492
|
+
const data = await retrieveModelQuota(this.accessToken, this.projectId);
|
|
52137
52493
|
if (!data?.buckets?.length)
|
|
52138
52494
|
return;
|
|
52139
52495
|
const lines = [];
|
|
@@ -52168,7 +52524,7 @@ ${lines.join(`
|
|
|
52168
52524
|
if (!this.accessToken || !this.projectId)
|
|
52169
52525
|
return;
|
|
52170
52526
|
try {
|
|
52171
|
-
const data = await
|
|
52527
|
+
const data = await retrieveModelQuota(this.accessToken, this.projectId);
|
|
52172
52528
|
if (!data?.buckets?.length)
|
|
52173
52529
|
return;
|
|
52174
52530
|
const bucket = data.buckets.find((b) => b.modelId === modelName);
|
|
@@ -52178,9 +52534,10 @@ ${lines.join(`
|
|
|
52178
52534
|
}
|
|
52179
52535
|
}
|
|
52180
52536
|
}
|
|
52181
|
-
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;
|
|
52182
52538
|
var init_antigravity2 = __esm(() => {
|
|
52183
52539
|
init_base_api_format();
|
|
52540
|
+
init_antigravity_side_calls();
|
|
52184
52541
|
init_antigravity_token();
|
|
52185
52542
|
init_antigravity_user();
|
|
52186
52543
|
init_authority();
|
|
@@ -52450,9 +52807,13 @@ class ApiKeyCredentialProvider {
|
|
|
52450
52807
|
}
|
|
52451
52808
|
settle(key, source) {
|
|
52452
52809
|
this.cachedKey = key;
|
|
52453
|
-
this.lastOrigin =
|
|
52810
|
+
this.lastOrigin = this.originOf(key, source);
|
|
52454
52811
|
return { key, source };
|
|
52455
52812
|
}
|
|
52813
|
+
originOf(key, source) {
|
|
52814
|
+
const masked = maskCredential(key);
|
|
52815
|
+
return this.replacement?.key === key ? { source, masked, replaced: true } : { source, masked };
|
|
52816
|
+
}
|
|
52456
52817
|
resolveFromEnvConfig() {
|
|
52457
52818
|
return resolveLocalApiKey({ envVar: this.envVar, aliases: this.aliases }) || realValue(this.resolveDeclared());
|
|
52458
52819
|
}
|
|
@@ -52559,20 +52920,22 @@ class ApiKeyCredentialProvider {
|
|
|
52559
52920
|
this.lastOrigin = undefined;
|
|
52560
52921
|
this.replacement = undefined;
|
|
52561
52922
|
}
|
|
52923
|
+
keyEnvVars() {
|
|
52924
|
+
return [this.envVar, ...this.aliases];
|
|
52925
|
+
}
|
|
52562
52926
|
replaceKey(key, source) {
|
|
52563
52927
|
this.invalidate();
|
|
52564
52928
|
this.replacement = { key, source };
|
|
52929
|
+
this.lastOrigin = this.originOf(key, source);
|
|
52565
52930
|
}
|
|
52566
52931
|
sourcesOutranking(key, savedTo) {
|
|
52567
52932
|
const outranking = [];
|
|
52568
|
-
const
|
|
52569
|
-
|
|
52570
|
-
|
|
52571
|
-
const v = realValueFor(a, process.env[a]);
|
|
52572
|
-
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);
|
|
52573
52936
|
});
|
|
52574
|
-
if (
|
|
52575
|
-
outranking.push("environment");
|
|
52937
|
+
if (exported)
|
|
52938
|
+
outranking.push({ source: "environment", envVar: exported });
|
|
52576
52939
|
if (savedTo !== "environment" && savedTo !== "config") {
|
|
52577
52940
|
let configured;
|
|
52578
52941
|
try {
|
|
@@ -52580,8 +52943,9 @@ class ApiKeyCredentialProvider {
|
|
|
52580
52943
|
} catch {
|
|
52581
52944
|
configured = undefined;
|
|
52582
52945
|
}
|
|
52583
|
-
if (configured && configured !== key)
|
|
52584
|
-
outranking.push("config");
|
|
52946
|
+
if (configured && configured !== key) {
|
|
52947
|
+
outranking.push({ source: "config", envVar: this.envVar });
|
|
52948
|
+
}
|
|
52585
52949
|
}
|
|
52586
52950
|
return outranking;
|
|
52587
52951
|
}
|
|
@@ -56684,6 +57048,9 @@ class CompositeCredentialProvider {
|
|
|
56684
57048
|
this.primary.invalidate?.();
|
|
56685
57049
|
this.fallback.invalidate?.();
|
|
56686
57050
|
}
|
|
57051
|
+
keyEnvVars() {
|
|
57052
|
+
return [...this.primary.keyEnvVars?.() ?? [], ...this.fallback.keyEnvVars?.() ?? []];
|
|
57053
|
+
}
|
|
56687
57054
|
async accountIdentity(opts) {
|
|
56688
57055
|
const primaryAvailable = await this.primary.isAvailable(opts).catch(() => false);
|
|
56689
57056
|
const [half, label] = primaryAvailable ? [this.primary, "primary"] : [this.fallback, "fallback"];
|
|
@@ -58363,53 +58730,6 @@ var init_muse_code_credential = __esm(() => {
|
|
|
58363
58730
|
init_prompt_role();
|
|
58364
58731
|
});
|
|
58365
58732
|
|
|
58366
|
-
// src/auth/credentials/native-anthropic-credential.ts
|
|
58367
|
-
class NativeAnthropicCredentialProvider {
|
|
58368
|
-
catalogName = "native-anthropic";
|
|
58369
|
-
cachedKey;
|
|
58370
|
-
invalidate() {
|
|
58371
|
-
this.cachedKey = undefined;
|
|
58372
|
-
}
|
|
58373
|
-
async resolveKey() {
|
|
58374
|
-
if (this.cachedKey !== undefined)
|
|
58375
|
-
return this.cachedKey;
|
|
58376
|
-
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"));
|
|
58377
|
-
if (local) {
|
|
58378
|
-
this.cachedKey = local;
|
|
58379
|
-
return local;
|
|
58380
|
-
}
|
|
58381
|
-
if (hasOpSources()) {
|
|
58382
|
-
const r = await resolveOpKeyForEnvVars(new Set(["ANTHROPIC_API_KEY"]), {
|
|
58383
|
-
onAuthFailure: "skip"
|
|
58384
|
-
});
|
|
58385
|
-
const v = r.ANTHROPIC_API_KEY;
|
|
58386
|
-
if (v) {
|
|
58387
|
-
process.env.ANTHROPIC_API_KEY = v;
|
|
58388
|
-
this.cachedKey = v;
|
|
58389
|
-
return v;
|
|
58390
|
-
}
|
|
58391
|
-
return "";
|
|
58392
|
-
}
|
|
58393
|
-
this.cachedKey = "";
|
|
58394
|
-
return "";
|
|
58395
|
-
}
|
|
58396
|
-
async isAvailable() {
|
|
58397
|
-
if (realValueFor("ANTHROPIC_API_KEY", process.env.ANTHROPIC_API_KEY) || realValueFor("ANTHROPIC_AUTH_TOKEN", process.env.ANTHROPIC_AUTH_TOKEN)) {
|
|
58398
|
-
return true;
|
|
58399
|
-
}
|
|
58400
|
-
return !!await this.resolveKey();
|
|
58401
|
-
}
|
|
58402
|
-
async getRequestAuth(_ctx) {
|
|
58403
|
-
const key = await this.resolveKey();
|
|
58404
|
-
return key ? { headers: { "x-api-key": key } } : { headers: {} };
|
|
58405
|
-
}
|
|
58406
|
-
}
|
|
58407
|
-
var init_native_anthropic_credential = __esm(() => {
|
|
58408
|
-
init_env_placeholder();
|
|
58409
|
-
init_profile_config();
|
|
58410
|
-
init_op_source();
|
|
58411
|
-
});
|
|
58412
|
-
|
|
58413
58733
|
// src/auth/credentials/vertex-credential.ts
|
|
58414
58734
|
class VertexCredentialProvider {
|
|
58415
58735
|
catalogName = "vertex";
|
|
@@ -59097,12 +59417,16 @@ ${overrides}` : material;
|
|
|
59097
59417
|
} catch {}
|
|
59098
59418
|
}
|
|
59099
59419
|
invalidate(name) {
|
|
59100
|
-
clearSignedArm(name);
|
|
59101
|
-
this.notifyInvalidated(name);
|
|
59102
59420
|
if (name) {
|
|
59421
|
+
for (const registered of this.namesSharing(name)) {
|
|
59422
|
+
clearSignedArm(registered);
|
|
59423
|
+
this.notifyInvalidated(registered);
|
|
59424
|
+
}
|
|
59103
59425
|
this.registry.get(name)?.invalidate?.();
|
|
59104
59426
|
return;
|
|
59105
59427
|
}
|
|
59428
|
+
clearSignedArm();
|
|
59429
|
+
this.notifyInvalidated();
|
|
59106
59430
|
const seen = new Set;
|
|
59107
59431
|
for (const p of this.registry.values()) {
|
|
59108
59432
|
if (seen.has(p))
|
|
@@ -59111,6 +59435,19 @@ ${overrides}` : material;
|
|
|
59111
59435
|
p.invalidate?.();
|
|
59112
59436
|
}
|
|
59113
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
|
+
}
|
|
59114
59451
|
replaceKey(name, key, source) {
|
|
59115
59452
|
this.invalidate(name);
|
|
59116
59453
|
this.registry.get(name)?.replaceKey?.(key, source);
|
|
@@ -59148,7 +59485,6 @@ ${overrides}` : material;
|
|
|
59148
59485
|
for (const name of LOCAL_PROVIDER_NAMES) {
|
|
59149
59486
|
authority.register(new LocalCredentialProvider(name), [name]);
|
|
59150
59487
|
}
|
|
59151
|
-
authority.register(new NativeAnthropicCredentialProvider, ["native-anthropic"]);
|
|
59152
59488
|
const alreadyRegistered = new Set([
|
|
59153
59489
|
"openai-codex",
|
|
59154
59490
|
"antigravity",
|
|
@@ -59156,7 +59492,6 @@ ${overrides}` : material;
|
|
|
59156
59492
|
"kimi",
|
|
59157
59493
|
"kimi-coding",
|
|
59158
59494
|
"vertex",
|
|
59159
|
-
"native-anthropic",
|
|
59160
59495
|
...LOCAL_PROVIDER_NAMES
|
|
59161
59496
|
]);
|
|
59162
59497
|
for (const def of BUILTIN_PROVIDERS) {
|
|
@@ -59175,6 +59510,9 @@ ${overrides}` : material;
|
|
|
59175
59510
|
...def.vaultKeyReadAtUse === true ? { readAtUse: true } : {}
|
|
59176
59511
|
}), [def.name, ...RUNTIME_NAME_ALIASES[def.name] ?? []]);
|
|
59177
59512
|
}
|
|
59513
|
+
const anthropic = authority.get("anthropic");
|
|
59514
|
+
if (anthropic)
|
|
59515
|
+
authority.register(anthropic, ["native-anthropic"]);
|
|
59178
59516
|
return authority;
|
|
59179
59517
|
}
|
|
59180
59518
|
}
|
|
@@ -59192,7 +59530,6 @@ var init_authority = __esm(() => {
|
|
|
59192
59530
|
init_kimi_credential();
|
|
59193
59531
|
init_local_credential();
|
|
59194
59532
|
init_muse_code_credential();
|
|
59195
|
-
init_native_anthropic_credential();
|
|
59196
59533
|
init_vertex_credential();
|
|
59197
59534
|
LOCAL_PROVIDER_NAMES = ["ollama", "lmstudio", "vllm", "mlx"];
|
|
59198
59535
|
RUNTIME_NAME_ALIASES = {
|
|
@@ -61614,18 +61951,47 @@ var init_vision_proxy = __esm(() => {
|
|
|
61614
61951
|
init_catalog_query();
|
|
61615
61952
|
});
|
|
61616
61953
|
|
|
61617
|
-
// src/
|
|
61954
|
+
// src/auth/claude-code-facts.ts
|
|
61955
|
+
import { createHash as createHash18 } from "crypto";
|
|
61618
61956
|
import { homedir as homedir30 } from "os";
|
|
61619
|
-
import { join as join31 } from "path";
|
|
61620
|
-
function
|
|
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) {
|
|
61621
61987
|
const home = env.HOME;
|
|
61622
61988
|
return home && home.length > 0 ? home : homedirFn();
|
|
61623
61989
|
}
|
|
61624
|
-
function sessionsDirFrom(env, homedirFn =
|
|
61990
|
+
function sessionsDirFrom(env, homedirFn = homedir31) {
|
|
61625
61991
|
const explicit = env.CLAUDISH_SESSIONS_DIR;
|
|
61626
61992
|
if (explicit && explicit.length > 0)
|
|
61627
61993
|
return explicit;
|
|
61628
|
-
return
|
|
61994
|
+
return join32(userHomeFrom(env, homedirFn), ".claudish", "sessions");
|
|
61629
61995
|
}
|
|
61630
61996
|
function claudeCodeStringHash(s) {
|
|
61631
61997
|
let h = 0;
|
|
@@ -61799,8 +62165,7 @@ var init_transcript_tailer = () => {};
|
|
|
61799
62165
|
|
|
61800
62166
|
// src/session-events/index.ts
|
|
61801
62167
|
import { existsSync as existsSync22, readFileSync as readFileSync31, readdirSync as readdirSync5 } from "fs";
|
|
61802
|
-
import {
|
|
61803
|
-
import { join as join32 } from "path";
|
|
62168
|
+
import { join as join33 } from "path";
|
|
61804
62169
|
function extractSessionId2(metadata) {
|
|
61805
62170
|
const userId = metadata?.user_id;
|
|
61806
62171
|
if (typeof userId !== "string")
|
|
@@ -61822,12 +62187,21 @@ class SessionEventRegistry {
|
|
|
61822
62187
|
sessions = new Map;
|
|
61823
62188
|
misses = new Map;
|
|
61824
62189
|
subscribers = [];
|
|
61825
|
-
|
|
62190
|
+
resolvedHome;
|
|
62191
|
+
opts;
|
|
61826
62192
|
pollIntervalMs;
|
|
61827
62193
|
constructor(opts = {}) {
|
|
61828
|
-
this.
|
|
62194
|
+
this.opts = opts;
|
|
62195
|
+
this.resolvedHome = opts.claudeHome;
|
|
61829
62196
|
this.pollIntervalMs = opts.pollIntervalMs;
|
|
61830
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
|
+
}
|
|
61831
62205
|
ensureSession(sessionId) {
|
|
61832
62206
|
try {
|
|
61833
62207
|
this.sweepIdle();
|
|
@@ -61911,13 +62285,13 @@ class SessionEventRegistry {
|
|
|
61911
62285
|
}
|
|
61912
62286
|
}
|
|
61913
62287
|
locateTranscript(sessionId) {
|
|
61914
|
-
const projectsDir =
|
|
61915
|
-
const primary =
|
|
62288
|
+
const projectsDir = join33(this.claudeHome, "projects");
|
|
62289
|
+
const primary = join33(projectsDir, slugFromCwd(this.cwd), `${sessionId}.jsonl`);
|
|
61916
62290
|
if (existsSync22(primary))
|
|
61917
62291
|
return primary;
|
|
61918
62292
|
try {
|
|
61919
62293
|
for (const dir of readdirSync5(projectsDir)) {
|
|
61920
|
-
const candidate =
|
|
62294
|
+
const candidate = join33(projectsDir, dir, `${sessionId}.jsonl`);
|
|
61921
62295
|
if (existsSync22(candidate))
|
|
61922
62296
|
return candidate;
|
|
61923
62297
|
}
|
|
@@ -61926,7 +62300,7 @@ class SessionEventRegistry {
|
|
|
61926
62300
|
}
|
|
61927
62301
|
readSettingsEffortLevel() {
|
|
61928
62302
|
try {
|
|
61929
|
-
const settings = JSON.parse(readFileSync31(
|
|
62303
|
+
const settings = JSON.parse(readFileSync31(join33(this.claudeHome, "settings.json"), "utf-8"));
|
|
61930
62304
|
return typeof settings.effortLevel === "string" ? settings.effortLevel : undefined;
|
|
61931
62305
|
} catch {
|
|
61932
62306
|
return;
|
|
@@ -61944,6 +62318,7 @@ class SessionEventRegistry {
|
|
|
61944
62318
|
}
|
|
61945
62319
|
var MISS_TTL_MS = 5000, MAX_MISSES = 5, IDLE_SWEEP_MS, sessionEvents;
|
|
61946
62320
|
var init_session_events = __esm(() => {
|
|
62321
|
+
init_claude_code_facts();
|
|
61947
62322
|
init_logger();
|
|
61948
62323
|
init_home_dir();
|
|
61949
62324
|
init_event_translator();
|
|
@@ -62037,7 +62412,7 @@ import {
|
|
|
62037
62412
|
writeFileSync as writeFileSync12
|
|
62038
62413
|
} from "fs";
|
|
62039
62414
|
import { homedir as homedir32 } from "os";
|
|
62040
|
-
import { join as
|
|
62415
|
+
import { join as join34 } from "path";
|
|
62041
62416
|
function ensureDir() {
|
|
62042
62417
|
if (!existsSync23(CLAUDISH_DIR)) {
|
|
62043
62418
|
mkdirSync17(CLAUDISH_DIR, { recursive: true });
|
|
@@ -62072,7 +62447,7 @@ function writeToDisk(events) {
|
|
|
62072
62447
|
ensureDir();
|
|
62073
62448
|
const trimmed = enforceSizeCap([...events]);
|
|
62074
62449
|
const payload = { version: 1, events: trimmed };
|
|
62075
|
-
const tmpFile =
|
|
62450
|
+
const tmpFile = join34(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
62076
62451
|
writeFileSync12(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
62077
62452
|
renameSync9(tmpFile, BUFFER_FILE);
|
|
62078
62453
|
memoryCache = trimmed;
|
|
@@ -62145,8 +62520,8 @@ function syncFlushOnExit() {
|
|
|
62145
62520
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, flushScheduled = false, SIGNAL_EXIT_CODE;
|
|
62146
62521
|
var init_stats_buffer = __esm(() => {
|
|
62147
62522
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
62148
|
-
CLAUDISH_DIR =
|
|
62149
|
-
BUFFER_FILE =
|
|
62523
|
+
CLAUDISH_DIR = join34(homedir32(), ".claudish");
|
|
62524
|
+
BUFFER_FILE = join34(CLAUDISH_DIR, "stats-buffer.json");
|
|
62150
62525
|
process.on("exit", syncFlushOnExit);
|
|
62151
62526
|
SIGNAL_EXIT_CODE = { SIGTERM: 143, SIGINT: 130 };
|
|
62152
62527
|
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
@@ -64031,15 +64406,68 @@ var init_provider_refused_text = __esm(() => {
|
|
|
64031
64406
|
});
|
|
64032
64407
|
|
|
64033
64408
|
// src/handlers/shared/format/tool-name-alias.ts
|
|
64034
|
-
function
|
|
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) {
|
|
64035
64449
|
if (!Array.isArray(content))
|
|
64036
64450
|
return content;
|
|
64037
|
-
return content.map((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
|
+
});
|
|
64038
64459
|
}
|
|
64039
64460
|
function aliasToolsForProvider(req, providerName) {
|
|
64040
64461
|
const table = PROVIDER_ALIASES[providerName];
|
|
64041
|
-
if (!table)
|
|
64042
|
-
return {
|
|
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] ?? {};
|
|
64043
64471
|
const declared = new Set(Array.isArray(req.tools) ? req.tools.map((tool) => tool?.name) : []);
|
|
64044
64472
|
const forward = new Map;
|
|
64045
64473
|
const backward = new Map;
|
|
@@ -64049,24 +64477,54 @@ function aliasToolsForProvider(req, providerName) {
|
|
|
64049
64477
|
forward.set(claude, native);
|
|
64050
64478
|
backward.set(native, claude);
|
|
64051
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
|
+
};
|
|
64052
64503
|
const out = { ...req };
|
|
64053
64504
|
if (Array.isArray(req.tools)) {
|
|
64054
|
-
out.tools = req.tools.map((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
|
+
});
|
|
64055
64512
|
}
|
|
64056
64513
|
const choice = req.tool_choice;
|
|
64057
64514
|
if (choice && typeof choice.name === "string" && forward.has(choice.name)) {
|
|
64058
64515
|
out.tool_choice = { ...choice, name: forward.get(choice.name) };
|
|
64059
64516
|
}
|
|
64060
64517
|
if (Array.isArray(req.messages)) {
|
|
64061
|
-
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);
|
|
64062
64519
|
}
|
|
64063
64520
|
return {
|
|
64064
64521
|
request: out,
|
|
64065
64522
|
forward: (name) => forward.get(name) ?? name,
|
|
64066
|
-
restore: (name) => backward.get(name) ?? name
|
|
64523
|
+
restore: (name) => backward.get(name) ?? name,
|
|
64524
|
+
restoreArguments
|
|
64067
64525
|
};
|
|
64068
64526
|
}
|
|
64069
|
-
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;
|
|
64070
64528
|
var init_tool_name_alias = __esm(() => {
|
|
64071
64529
|
AGY_TOOL_ALIAS = [
|
|
64072
64530
|
["Bash", "run_command"],
|
|
@@ -64085,6 +64543,30 @@ var init_tool_name_alias = __esm(() => {
|
|
|
64085
64543
|
PROVIDER_ALIASES = {
|
|
64086
64544
|
antigravity: AGY_TOOL_ALIAS
|
|
64087
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
|
+
};
|
|
64088
64570
|
});
|
|
64089
64571
|
|
|
64090
64572
|
// src/handlers/shared/format/tool-reference-text.ts
|
|
@@ -65460,7 +65942,8 @@ data: ${JSON.stringify(data)}
|
|
|
65460
65942
|
const blockIndex = curIdx++;
|
|
65461
65943
|
const toolName = opts.mapToolName ? opts.mapToolName(part.functionCall.name) : part.functionCall.name;
|
|
65462
65944
|
opts.onToolCallObserved?.(toolName);
|
|
65463
|
-
const
|
|
65945
|
+
const upstreamArgs = part.functionCall.args || {};
|
|
65946
|
+
const args = JSON.stringify(opts.mapToolArguments ? opts.mapToolArguments(part.functionCall.name, upstreamArgs) : upstreamArgs);
|
|
65464
65947
|
const t = {
|
|
65465
65948
|
id: toolId,
|
|
65466
65949
|
name: toolName,
|
|
@@ -68310,7 +68793,7 @@ var init_openai_responses_sse = __esm(() => {
|
|
|
68310
68793
|
});
|
|
68311
68794
|
|
|
68312
68795
|
// src/session/token-file.ts
|
|
68313
|
-
import { join as
|
|
68796
|
+
import { join as join35 } from "path";
|
|
68314
68797
|
function assignedTokenFile(env) {
|
|
68315
68798
|
const f = env.CLAUDISH_TOKEN_FILE;
|
|
68316
68799
|
if (!f || f === env.CLAUDISH_PUBLISHED_TOKEN_FILE)
|
|
@@ -68318,7 +68801,7 @@ function assignedTokenFile(env) {
|
|
|
68318
68801
|
return f;
|
|
68319
68802
|
}
|
|
68320
68803
|
function resolveTokenFilePath(port, env = process.env) {
|
|
68321
|
-
return assignedTokenFile(env) ??
|
|
68804
|
+
return assignedTokenFile(env) ?? join35(userHomeFrom(env), ".claudish", `tokens-${port}.json`);
|
|
68322
68805
|
}
|
|
68323
68806
|
var init_token_file = __esm(() => {
|
|
68324
68807
|
init_home_dir();
|
|
@@ -70469,7 +70952,7 @@ class ComposedHandler {
|
|
|
70469
70952
|
output: u.output
|
|
70470
70953
|
};
|
|
70471
70954
|
ledger.finalInput = u.finalInput;
|
|
70472
|
-
}, toolAlias.restore), () => {
|
|
70955
|
+
}, toolAlias.restore, toolAlias.restoreArguments), () => {
|
|
70473
70956
|
clientCancelled = true;
|
|
70474
70957
|
});
|
|
70475
70958
|
ledger.streamOutcome = () => clientCancelled ? "cancelled" : streamApiError !== null || ledger.billed === undefined ? "error" : "ok";
|
|
@@ -70605,7 +71088,7 @@ class ComposedHandler {
|
|
|
70605
71088
|
resolveStreamFormat() {
|
|
70606
71089
|
return this.provider.overrideStreamFormat?.() ?? this.explicitAdapter?.getStreamFormat() ?? this.modelAdapter?.getStreamFormat() ?? this.getAdapter().getStreamFormat();
|
|
70607
71090
|
}
|
|
70608
|
-
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) {
|
|
70609
71092
|
let pendingOnComplete = onComplete;
|
|
70610
71093
|
const billedPerTurn = this.resolveStreamFormat() === "openai-responses-sse";
|
|
70611
71094
|
const onTokenUpdate = (input, output, detail) => {
|
|
@@ -70689,7 +71172,8 @@ class ComposedHandler {
|
|
|
70689
71172
|
onToolCallObserved: observeToolCall,
|
|
70690
71173
|
unwrapResponse: this.options.unwrapGeminiResponse,
|
|
70691
71174
|
priorInputTokens,
|
|
70692
|
-
mapToolName: restoreToolName
|
|
71175
|
+
mapToolName: restoreToolName,
|
|
71176
|
+
mapToolArguments: restoreToolArguments
|
|
70693
71177
|
});
|
|
70694
71178
|
}
|
|
70695
71179
|
case "connect-proto":
|
|
@@ -70926,9 +71410,9 @@ var init_composed_handler = __esm(() => {
|
|
|
70926
71410
|
// src/providers/api-key-provenance.ts
|
|
70927
71411
|
import { existsSync as existsSync24, readFileSync as readFileSync33 } from "fs";
|
|
70928
71412
|
import { homedir as homedir33 } from "os";
|
|
70929
|
-
import { join as
|
|
71413
|
+
import { join as join36, resolve as resolve4 } from "path";
|
|
70930
71414
|
function activeConfigPath() {
|
|
70931
|
-
return activeGlobalConfigFile(
|
|
71415
|
+
return activeGlobalConfigFile(join36(homedir33(), ".claudish", "config.json"));
|
|
70932
71416
|
}
|
|
70933
71417
|
function configLayerLabel() {
|
|
70934
71418
|
return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
|
|
@@ -70946,7 +71430,7 @@ function resolveApiKeyProvenance(envVar, aliases) {
|
|
|
70946
71430
|
const allVars = [envVar, ...aliases || []];
|
|
70947
71431
|
const dotenvValue = readDotenvKey(allVars);
|
|
70948
71432
|
layers.push({
|
|
70949
|
-
source: `.env (${
|
|
71433
|
+
source: `.env (${resolve4(".env")})`,
|
|
70950
71434
|
maskedValue: maskKey(dotenvValue),
|
|
70951
71435
|
isActive: false
|
|
70952
71436
|
});
|
|
@@ -71083,7 +71567,7 @@ function formatProvenanceLog(p) {
|
|
|
71083
71567
|
}
|
|
71084
71568
|
function readDotenvKey(envVars) {
|
|
71085
71569
|
try {
|
|
71086
|
-
const dotenvPath =
|
|
71570
|
+
const dotenvPath = resolve4(".env");
|
|
71087
71571
|
if (!existsSync24(dotenvPath))
|
|
71088
71572
|
return null;
|
|
71089
71573
|
const parsed = readAllowedDotenv(readFileSync33(dotenvPath, "utf-8"));
|
|
@@ -85918,7 +86402,7 @@ function compareByConnectionPrice(a, b) {
|
|
|
85918
86402
|
// src/providers/probe-catalog.ts
|
|
85919
86403
|
import { existsSync as existsSync25, mkdirSync as mkdirSync19, readFileSync as readFileSync34, writeFileSync as writeFileSync14 } from "fs";
|
|
85920
86404
|
import { homedir as homedir34 } from "os";
|
|
85921
|
-
import { dirname as dirname16, join as
|
|
86405
|
+
import { dirname as dirname16, join as join37 } from "path";
|
|
85922
86406
|
function describeProbeCatalogFailure(outcome) {
|
|
85923
86407
|
switch (outcome.kind) {
|
|
85924
86408
|
case "incompatible":
|
|
@@ -86090,7 +86574,7 @@ var init_probe_catalog = __esm(() => {
|
|
|
86090
86574
|
init_catalog_endpoints();
|
|
86091
86575
|
init_catalog_route_bindings();
|
|
86092
86576
|
CACHE_TTL_MS4 = 60 * 60 * 1000;
|
|
86093
|
-
PROBE_MODELS_CACHE_PATH =
|
|
86577
|
+
PROBE_MODELS_CACHE_PATH = join37(homedir34(), ".claudish", "probe-models.json");
|
|
86094
86578
|
});
|
|
86095
86579
|
|
|
86096
86580
|
// src/providers/route-candidates.ts
|
|
@@ -87976,57 +88460,23 @@ function herdrPaneEnv(env = process.env) {
|
|
|
87976
88460
|
return detectFrontEnd(env) === "herdr" ? herdrVars(env) : null;
|
|
87977
88461
|
}
|
|
87978
88462
|
|
|
87979
|
-
// src/auth/claude-code-facts.ts
|
|
87980
|
-
import { createHash as createHash18 } from "crypto";
|
|
87981
|
-
import { homedir as homedir35 } from "os";
|
|
87982
|
-
import { isAbsolute as isAbsolute2, resolve as resolve4 } from "path";
|
|
87983
|
-
function defaultConfigDir(env) {
|
|
87984
|
-
return resolve4(env.HOME || homedir35(), ".claude");
|
|
87985
|
-
}
|
|
87986
|
-
function claudeCodeConfigDir(env = process.env) {
|
|
87987
|
-
const raw = env.CLAUDE_CONFIG_DIR?.trim();
|
|
87988
|
-
if (!raw)
|
|
87989
|
-
return defaultConfigDir(env);
|
|
87990
|
-
return isAbsolute2(raw) ? resolve4(raw) : resolve4(process.cwd(), raw);
|
|
87991
|
-
}
|
|
87992
|
-
function configDirHash(configDir) {
|
|
87993
|
-
return createHash18("sha256").update(configDir).digest("hex").slice(0, 8);
|
|
87994
|
-
}
|
|
87995
|
-
function claudeCodeSecureStorageServices(kind, env = process.env) {
|
|
87996
|
-
const base = `${BASE_KEYCHAIN_SERVICE}${kind}`;
|
|
87997
|
-
const secure = env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
|
|
87998
|
-
const spellings = secure !== undefined ? secure ? [secure] : [] : env.CLAUDE_CONFIG_DIR ? [
|
|
87999
|
-
env.CLAUDE_CONFIG_DIR,
|
|
88000
|
-
claudeCodeConfigDir(env),
|
|
88001
|
-
env.CLAUDE_CONFIG_DIR.replace(/\/+$/, "")
|
|
88002
|
-
] : [];
|
|
88003
|
-
if (spellings.length === 0)
|
|
88004
|
-
return [base];
|
|
88005
|
-
return [...new Set(spellings.map((dir) => `${base}-${configDirHash(dir.normalize("NFC"))}`))];
|
|
88006
|
-
}
|
|
88007
|
-
function claudeCodeGlobalConfigPath(env = process.env) {
|
|
88008
|
-
const raw = env.CLAUDE_CONFIG_DIR?.trim();
|
|
88009
|
-
return raw ? resolve4(claudeCodeConfigDir(env), ".claude.json") : resolve4(env.HOME || homedir35(), ".claude.json");
|
|
88010
|
-
}
|
|
88011
|
-
var BASE_KEYCHAIN_SERVICE = "Claude Code";
|
|
88012
|
-
var init_claude_code_facts = () => {};
|
|
88013
|
-
|
|
88014
88463
|
// src/auth/claude-code-login.ts
|
|
88015
88464
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
88016
88465
|
import { existsSync as existsSync26, readFileSync as readFileSync35 } from "fs";
|
|
88017
|
-
import { join as
|
|
88018
|
-
function keychainLoginPresent(env, presence) {
|
|
88019
|
-
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";
|
|
88020
88469
|
}
|
|
88021
88470
|
function hasClaudeCodeLogin(deps = {}) {
|
|
88022
88471
|
const env = deps.env ?? process.env;
|
|
88472
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
88023
88473
|
const token = env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
88024
88474
|
if (typeof token === "string" && token.trim().length > 0)
|
|
88025
88475
|
return true;
|
|
88026
88476
|
const fileExists = deps.fileExists ?? existsSync26;
|
|
88027
|
-
if (fileExists(
|
|
88477
|
+
if (fileExists(join38(claudeCodeConfigDir(env, cwd), ".credentials.json")))
|
|
88028
88478
|
return true;
|
|
88029
|
-
return (deps.keychainProbe ?? defaultKeychainAnthropicProbe)(env);
|
|
88479
|
+
return (deps.keychainProbe ?? defaultKeychainAnthropicProbe)(env, cwd);
|
|
88030
88480
|
}
|
|
88031
88481
|
function defaultKeychainPresence(service) {
|
|
88032
88482
|
if (process.platform !== "darwin")
|
|
@@ -88050,24 +88500,26 @@ function defaultKeychainPresence(service) {
|
|
|
88050
88500
|
}
|
|
88051
88501
|
function claudeCodeStartupCredential(deps = {}) {
|
|
88052
88502
|
const env = deps.env ?? process.env;
|
|
88503
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
88053
88504
|
const fileExists = deps.fileExists ?? existsSync26;
|
|
88054
88505
|
const readFile = deps.readFile ?? ((path) => readFileSync35(path, "utf-8"));
|
|
88055
88506
|
const presence = deps.keychainPresence ?? defaultKeychainPresence;
|
|
88056
88507
|
const token = env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
88057
88508
|
if (typeof token === "string" && token.trim().length > 0)
|
|
88058
88509
|
return { kind: "login" };
|
|
88059
|
-
if (fileExists(
|
|
88510
|
+
if (fileExists(join38(claudeCodeConfigDir(env, cwd), ".credentials.json"))) {
|
|
88060
88511
|
return { kind: "login" };
|
|
88061
|
-
|
|
88512
|
+
}
|
|
88513
|
+
const oauth = anyPresent(claudeCodeSecureStorageServices("-credentials", env, cwd), presence);
|
|
88062
88514
|
if (oauth === "found")
|
|
88063
88515
|
return { kind: "login" };
|
|
88064
88516
|
if (oauth === "failed")
|
|
88065
88517
|
return { kind: "unknown" };
|
|
88066
|
-
const configPath = claudeCodeGlobalConfigPath(env);
|
|
88518
|
+
const configPath = claudeCodeGlobalConfigPath(env, cwd);
|
|
88067
88519
|
const stored = fileExists(configPath) ? configSetsConsoleKey(configPath, readFile) : "absent";
|
|
88068
88520
|
if (stored === "found")
|
|
88069
88521
|
return { kind: "api-key", where: configPath };
|
|
88070
|
-
const keychainKey = anyPresent(claudeCodeSecureStorageServices("", env), presence);
|
|
88522
|
+
const keychainKey = anyPresent(claudeCodeSecureStorageServices("", env, cwd), presence);
|
|
88071
88523
|
if (keychainKey === "found")
|
|
88072
88524
|
return { kind: "api-key", where: "the macOS Keychain" };
|
|
88073
88525
|
const unanswered = stored === "failed" || keychainKey === "failed";
|
|
@@ -88095,17 +88547,17 @@ function configSetsConsoleKey(path, readFile) {
|
|
|
88095
88547
|
return "failed";
|
|
88096
88548
|
}
|
|
88097
88549
|
}
|
|
88098
|
-
var macosKeychainAnthropicMemo, defaultKeychainAnthropicProbe = (env = process.env) => {
|
|
88550
|
+
var macosKeychainAnthropicMemo, defaultKeychainAnthropicProbe = (env = process.env, cwd = process.cwd()) => {
|
|
88099
88551
|
if (process.platform !== "darwin")
|
|
88100
88552
|
return false;
|
|
88101
88553
|
if (process.env.CLAUDISH_DISABLE_KEYCHAIN === "1" || env.CLAUDISH_DISABLE_KEYCHAIN === "1") {
|
|
88102
88554
|
return false;
|
|
88103
88555
|
}
|
|
88104
|
-
const memoKey = claudeCodeSecureStorageServices("-credentials", env).join("|");
|
|
88556
|
+
const memoKey = claudeCodeSecureStorageServices("-credentials", env, cwd).join("|");
|
|
88105
88557
|
const memoized = macosKeychainAnthropicMemo.get(memoKey);
|
|
88106
88558
|
if (memoized !== undefined)
|
|
88107
88559
|
return memoized;
|
|
88108
|
-
const found = keychainLoginPresent(env, defaultKeychainPresence);
|
|
88560
|
+
const found = keychainLoginPresent(env, defaultKeychainPresence, cwd);
|
|
88109
88561
|
macosKeychainAnthropicMemo.set(memoKey, found);
|
|
88110
88562
|
return found;
|
|
88111
88563
|
}, SECURITY_ITEM_NOT_FOUND = 44;
|
|
@@ -89207,26 +89659,56 @@ var init_magmux_client = __esm(() => {
|
|
|
89207
89659
|
});
|
|
89208
89660
|
|
|
89209
89661
|
// src/pane/own-pane.ts
|
|
89210
|
-
import {
|
|
89211
|
-
|
|
89212
|
-
async function ancestorPids(maxDepth = ANCESTRY_DEPTH) {
|
|
89662
|
+
import { spawn } from "child_process";
|
|
89663
|
+
async function ancestorPids(maxDepth = ANCESTRY_DEPTH, ps = "ps") {
|
|
89213
89664
|
const out = new Set([process.pid]);
|
|
89214
89665
|
let pid = process.ppid;
|
|
89215
89666
|
for (let i = 0;i < maxDepth && pid > 1; i++) {
|
|
89216
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
|
+
};
|
|
89217
89697
|
try {
|
|
89218
|
-
|
|
89219
|
-
|
|
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);
|
|
89220
89707
|
});
|
|
89221
|
-
const next = Number(stdout.trim());
|
|
89222
|
-
if (!Number.isFinite(next) || next <= 1)
|
|
89223
|
-
break;
|
|
89224
|
-
pid = next;
|
|
89225
89708
|
} catch {
|
|
89226
|
-
|
|
89709
|
+
finish(null);
|
|
89227
89710
|
}
|
|
89228
|
-
}
|
|
89229
|
-
return out;
|
|
89711
|
+
});
|
|
89230
89712
|
}
|
|
89231
89713
|
function panesOfList(result) {
|
|
89232
89714
|
const raw = Array.isArray(result) ? result : Array.isArray(result?.panes) ? result.panes : [];
|
|
@@ -89255,14 +89737,12 @@ async function findOwnPane(list, ancestors = () => ancestorPids()) {
|
|
|
89255
89737
|
return p.pane;
|
|
89256
89738
|
return null;
|
|
89257
89739
|
}
|
|
89258
|
-
var
|
|
89259
|
-
var init_own_pane =
|
|
89260
|
-
execFileAsync2 = promisify5(execFile3);
|
|
89261
|
-
});
|
|
89740
|
+
var ANCESTRY_DEPTH = 6, PS_TIMEOUT_MS = 1000, PS_EXIT_DRAIN_MS = 100;
|
|
89741
|
+
var init_own_pane = () => {};
|
|
89262
89742
|
|
|
89263
89743
|
// src/pane/prompt-delivery.ts
|
|
89264
89744
|
import { writeFileSync as writeFileSync15 } from "fs";
|
|
89265
|
-
import { join as
|
|
89745
|
+
import { join as join39 } from "path";
|
|
89266
89746
|
function stripControl(s) {
|
|
89267
89747
|
let out = "";
|
|
89268
89748
|
for (const ch of s) {
|
|
@@ -89329,7 +89809,7 @@ function renderTurnFile(text, limit = READ_LINE_LIMIT) {
|
|
|
89329
89809
|
`), lines: out.length, marker };
|
|
89330
89810
|
}
|
|
89331
89811
|
function turnFilePath(turnDir, turnIndex) {
|
|
89332
|
-
return
|
|
89812
|
+
return join39(turnDir, `turn-${turnIndex}.md`);
|
|
89333
89813
|
}
|
|
89334
89814
|
function fileTemplate(file, marker) {
|
|
89335
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.`;
|
|
@@ -90341,7 +90821,7 @@ import {
|
|
|
90341
90821
|
realpathSync as realpathSync5,
|
|
90342
90822
|
statSync as statSync13
|
|
90343
90823
|
} from "fs";
|
|
90344
|
-
import { join as
|
|
90824
|
+
import { join as join40 } from "path";
|
|
90345
90825
|
function initialFollowerState(resolvePath = safeRealpath) {
|
|
90346
90826
|
return {
|
|
90347
90827
|
turns: [],
|
|
@@ -90926,7 +91406,7 @@ class TranscriptFollower {
|
|
|
90926
91406
|
continue;
|
|
90927
91407
|
let tail = this.subs.get(f);
|
|
90928
91408
|
if (!tail) {
|
|
90929
|
-
tail = new Tail(
|
|
91409
|
+
tail = new Tail(join40(this.subagentsDir, f));
|
|
90930
91410
|
this.subs.set(f, tail);
|
|
90931
91411
|
}
|
|
90932
91412
|
const agentId = AGENT_FILE_RE.exec(f)?.[1];
|
|
@@ -90945,7 +91425,7 @@ class TranscriptFollower {
|
|
|
90945
91425
|
return any;
|
|
90946
91426
|
}
|
|
90947
91427
|
readMeta(name, agentId) {
|
|
90948
|
-
const path =
|
|
91428
|
+
const path = join40(this.subagentsDir, name);
|
|
90949
91429
|
let mtime;
|
|
90950
91430
|
try {
|
|
90951
91431
|
mtime = statSync13(path).mtimeMs;
|
|
@@ -91058,64 +91538,6 @@ var init_transcript_follower = __esm(() => {
|
|
|
91058
91538
|
AGENT_META_RE = /^agent-([A-Za-z0-9_-]+)\.meta\.json$/;
|
|
91059
91539
|
});
|
|
91060
91540
|
|
|
91061
|
-
// src/mcp-session/parent-session.ts
|
|
91062
|
-
import { readFile as readFile7 } from "fs/promises";
|
|
91063
|
-
import { join as join40 } from "path";
|
|
91064
|
-
function positiveInt(value) {
|
|
91065
|
-
if (value === undefined || !/^[1-9][0-9]*$/.test(value))
|
|
91066
|
-
return;
|
|
91067
|
-
const n = Number(value);
|
|
91068
|
-
return Number.isSafeInteger(n) ? n : undefined;
|
|
91069
|
-
}
|
|
91070
|
-
function hostPidFrom(env, ppid) {
|
|
91071
|
-
const launcherPpid = positiveInt(env.CLAUDISH_LAUNCHER_PPID);
|
|
91072
|
-
if (env.CLAUDISH_LAUNCHER_PID === String(ppid) && launcherPpid !== undefined && launcherPpid !== ppid) {
|
|
91073
|
-
return { hostPid: launcherPpid, launcherPid: ppid };
|
|
91074
|
-
}
|
|
91075
|
-
return { hostPid: ppid };
|
|
91076
|
-
}
|
|
91077
|
-
function parentSessionIdFrom(env) {
|
|
91078
|
-
const id = env.CLAUDE_CODE_SESSION_ID;
|
|
91079
|
-
if (id === undefined || !CLAUDE_ID_RE.test(id))
|
|
91080
|
-
return;
|
|
91081
|
-
if (env.CLAUDE_CODE_CHILD_SESSION)
|
|
91082
|
-
return;
|
|
91083
|
-
return id;
|
|
91084
|
-
}
|
|
91085
|
-
function claudeConfigDir(env) {
|
|
91086
|
-
const fromEnv = env.CLAUDE_CONFIG_DIR;
|
|
91087
|
-
return fromEnv && fromEnv.length > 0 ? fromEnv : join40(userHomeFrom(env), ".claude");
|
|
91088
|
-
}
|
|
91089
|
-
async function readHostSessionRecord(opts) {
|
|
91090
|
-
try {
|
|
91091
|
-
const raw = await readFile7(join40(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
|
|
91092
|
-
const parsed = JSON.parse(raw);
|
|
91093
|
-
if (!parsed || typeof parsed !== "object")
|
|
91094
|
-
return;
|
|
91095
|
-
const rec = parsed;
|
|
91096
|
-
if (rec.pid !== opts.hostPid)
|
|
91097
|
-
return;
|
|
91098
|
-
if (typeof rec.sessionId !== "string" || !CLAUDE_ID_RE.test(rec.sessionId))
|
|
91099
|
-
return;
|
|
91100
|
-
return { sessionId: rec.sessionId };
|
|
91101
|
-
} catch {
|
|
91102
|
-
return;
|
|
91103
|
-
}
|
|
91104
|
-
}
|
|
91105
|
-
async function parentSessionForCall(opts) {
|
|
91106
|
-
const env = opts.env ?? process.env;
|
|
91107
|
-
const record = await readHostSessionRecord({
|
|
91108
|
-
configDir: claudeConfigDir(env),
|
|
91109
|
-
hostPid: opts.hostPid
|
|
91110
|
-
});
|
|
91111
|
-
return record?.sessionId ?? parentSessionIdFrom(env);
|
|
91112
|
-
}
|
|
91113
|
-
var CLAUDE_ID_RE;
|
|
91114
|
-
var init_parent_session = __esm(() => {
|
|
91115
|
-
init_home_dir();
|
|
91116
|
-
CLAUDE_ID_RE = /^[A-Za-z0-9_-]{8,128}$/;
|
|
91117
|
-
});
|
|
91118
|
-
|
|
91119
91541
|
// src/session/session-discovery.ts
|
|
91120
91542
|
var exports_session_discovery = {};
|
|
91121
91543
|
__export(exports_session_discovery, {
|
|
@@ -91132,11 +91554,11 @@ __export(exports_session_discovery, {
|
|
|
91132
91554
|
sessionLabel: () => sessionLabel,
|
|
91133
91555
|
transcriptPathFor: () => transcriptPathFor
|
|
91134
91556
|
});
|
|
91135
|
-
import { execFile as
|
|
91557
|
+
import { execFile as execFile3, execFileSync as execFileSync2 } from "child_process";
|
|
91136
91558
|
import { closeSync as closeSync12, openSync as openSync12, readSync as readSync5, readdirSync as readdirSync7, realpathSync as realpathSync6, statSync as statSync14 } from "fs";
|
|
91137
91559
|
import { basename as basename3, join as join41 } from "path";
|
|
91138
|
-
function projectsDir(env = process.env) {
|
|
91139
|
-
return join41(
|
|
91560
|
+
function projectsDir(env = process.env, cwd = process.cwd()) {
|
|
91561
|
+
return join41(claudeCodeConfigDir(env, cwd), "projects");
|
|
91140
91562
|
}
|
|
91141
91563
|
function slugForPath(absPath) {
|
|
91142
91564
|
return projectDirNameFor(absPath);
|
|
@@ -91225,7 +91647,7 @@ function sessionsIn2(dirName) {
|
|
|
91225
91647
|
}
|
|
91226
91648
|
async function enrichWorktreeGit(groups, repoRoot) {
|
|
91227
91649
|
const run = (cwd, args) => new Promise((resolve) => {
|
|
91228
|
-
|
|
91650
|
+
execFile3("git", args, { cwd, encoding: "utf-8" }, (err, stdout) => resolve(err ? "" : stdout));
|
|
91229
91651
|
});
|
|
91230
91652
|
const trackByBranch = new Map;
|
|
91231
91653
|
const refs = await run(repoRoot, [
|
|
@@ -91564,8 +91986,8 @@ function findLatestSessionId(cwd = process.cwd(), sinceMs = 0) {
|
|
|
91564
91986
|
}
|
|
91565
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;
|
|
91566
91988
|
var init_session_discovery = __esm(() => {
|
|
91989
|
+
init_claude_code_facts();
|
|
91567
91990
|
init_home_dir();
|
|
91568
|
-
init_parent_session();
|
|
91569
91991
|
HEAD_BYTES = 64 * 1024;
|
|
91570
91992
|
TAIL_BYTES = 128 * 1024;
|
|
91571
91993
|
HARNESS_ENVELOPES = [
|
|
@@ -92935,7 +93357,7 @@ var init_cache_ttl = __esm(() => {
|
|
|
92935
93357
|
|
|
92936
93358
|
// src/model-loader.ts
|
|
92937
93359
|
import { existsSync as existsSync31, readFileSync as readFileSync37 } from "fs";
|
|
92938
|
-
import { homedir as
|
|
93360
|
+
import { homedir as homedir35 } from "os";
|
|
92939
93361
|
import { join as join45 } from "path";
|
|
92940
93362
|
function isRecommendationTier(value) {
|
|
92941
93363
|
return typeof value === "string" && RECOMMENDATION_TIER_INDEX.has(value);
|
|
@@ -93080,17 +93502,17 @@ function recommendationProjection(recommendations, richModels = []) {
|
|
|
93080
93502
|
plans: cache.plans
|
|
93081
93503
|
} : { catalogGenerationId: "", entries: [], plans: [] }, richModels);
|
|
93082
93504
|
}
|
|
93083
|
-
function
|
|
93505
|
+
function isRecord6(value) {
|
|
93084
93506
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
93085
93507
|
}
|
|
93086
93508
|
function isStringArray(value) {
|
|
93087
93509
|
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
93088
93510
|
}
|
|
93089
93511
|
function isRouteObject(value) {
|
|
93090
|
-
return
|
|
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));
|
|
93091
93513
|
}
|
|
93092
93514
|
function isUsableRow(value) {
|
|
93093
|
-
if (!
|
|
93515
|
+
if (!isRecord6(value))
|
|
93094
93516
|
return false;
|
|
93095
93517
|
if (typeof value.id !== "string" || value.id.length === 0)
|
|
93096
93518
|
return false;
|
|
@@ -93102,7 +93524,7 @@ function isUsableRow(value) {
|
|
|
93102
93524
|
return false;
|
|
93103
93525
|
}
|
|
93104
93526
|
const pricing = value.pricing;
|
|
93105
|
-
if (!
|
|
93527
|
+
if (!isRecord6(pricing) || typeof pricing.input !== "string" || typeof pricing.output !== "string" || typeof pricing.average !== "string") {
|
|
93106
93528
|
return false;
|
|
93107
93529
|
}
|
|
93108
93530
|
if (value.releaseDate !== undefined && typeof value.releaseDate !== "string")
|
|
@@ -93115,7 +93537,7 @@ function isUsableRow(value) {
|
|
|
93115
93537
|
return true;
|
|
93116
93538
|
}
|
|
93117
93539
|
function readProjectedRecommendationsDoc(value) {
|
|
93118
|
-
if (!
|
|
93540
|
+
if (!isRecord6(value))
|
|
93119
93541
|
return null;
|
|
93120
93542
|
if (value.contractVersion !== 3)
|
|
93121
93543
|
return null;
|
|
@@ -93146,8 +93568,8 @@ function readRecommendedModelsCacheFile() {
|
|
|
93146
93568
|
log(`[recommended] unreadable ${RECOMMENDED_MODELS_CACHE_PATH}: ${err instanceof Error ? err.message : String(err)}`);
|
|
93147
93569
|
return null;
|
|
93148
93570
|
}
|
|
93149
|
-
if (!
|
|
93150
|
-
log(`[recommended] ${RECOMMENDED_MODELS_CACHE_PATH} has 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}`);
|
|
93151
93573
|
return null;
|
|
93152
93574
|
}
|
|
93153
93575
|
return readProjectedRecommendationsDoc(parsed);
|
|
@@ -93518,7 +93940,7 @@ var init_model_loader = __esm(() => {
|
|
|
93518
93940
|
{ recommendationTier: "subscription", title: "Subscription", quickPickEligible: true }
|
|
93519
93941
|
];
|
|
93520
93942
|
RECOMMENDATION_TIER_INDEX = new Map(RECOMMENDATION_SECTIONS.map((section, index) => [section.recommendationTier, index]));
|
|
93521
|
-
RECOMMENDED_MODELS_CACHE_PATH = join45(
|
|
93943
|
+
RECOMMENDED_MODELS_CACHE_PATH = join45(homedir35(), ".claudish", "recommended-models-cache-v2.json");
|
|
93522
93944
|
RECOMMENDED_ROUTE_TIER_ORDER = {
|
|
93523
93945
|
native: 0,
|
|
93524
93946
|
general: 1,
|
|
@@ -94845,7 +95267,7 @@ var init_DiscoveryNotice = __esm(() => {
|
|
|
94845
95267
|
|
|
94846
95268
|
// src/providers/model-descriptions.ts
|
|
94847
95269
|
import { existsSync as existsSync32, mkdirSync as mkdirSync21, readFileSync as readFileSync38, writeFileSync as writeFileSync17 } from "fs";
|
|
94848
|
-
import { homedir as
|
|
95270
|
+
import { homedir as homedir36 } from "os";
|
|
94849
95271
|
import { dirname as dirname18, join as join46 } from "path";
|
|
94850
95272
|
function emptyDescriptionIndex() {
|
|
94851
95273
|
return EMPTY_INDEX;
|
|
@@ -94939,7 +95361,7 @@ var init_model_descriptions = __esm(() => {
|
|
|
94939
95361
|
init_logger();
|
|
94940
95362
|
init_model_loader();
|
|
94941
95363
|
init_cache_ttl();
|
|
94942
|
-
MODEL_DESCRIPTIONS_CACHE_PATH = join46(
|
|
95364
|
+
MODEL_DESCRIPTIONS_CACHE_PATH = join46(homedir36(), ".claudish", "model-descriptions.json");
|
|
94943
95365
|
EMPTY_INDEX = { get: () => {
|
|
94944
95366
|
return;
|
|
94945
95367
|
}, size: 0 };
|
|
@@ -101187,15 +101609,15 @@ var init_branding = __esm(() => {
|
|
|
101187
101609
|
|
|
101188
101610
|
// src/update-checker.ts
|
|
101189
101611
|
import { existsSync as existsSync33, mkdirSync as mkdirSync22, readFileSync as readFileSync39, unlinkSync as unlinkSync9, writeFileSync as writeFileSync18 } from "fs";
|
|
101190
|
-
import { homedir as
|
|
101612
|
+
import { homedir as homedir37, platform as platform2, tmpdir } from "os";
|
|
101191
101613
|
import { join as join47 } from "path";
|
|
101192
101614
|
function getCacheFilePath() {
|
|
101193
101615
|
let cacheDir;
|
|
101194
101616
|
if (isWindows) {
|
|
101195
|
-
const localAppData = process.env.LOCALAPPDATA || join47(
|
|
101617
|
+
const localAppData = process.env.LOCALAPPDATA || join47(homedir37(), "AppData", "Local");
|
|
101196
101618
|
cacheDir = join47(localAppData, "claudish");
|
|
101197
101619
|
} else {
|
|
101198
|
-
cacheDir = join47(
|
|
101620
|
+
cacheDir = join47(homedir37(), ".cache", "claudish");
|
|
101199
101621
|
}
|
|
101200
101622
|
try {
|
|
101201
101623
|
if (!existsSync33(cacheDir)) {
|
|
@@ -105693,7 +106115,7 @@ var init_bundled_tagged_cache = __esm(() => {
|
|
|
105693
106115
|
|
|
105694
106116
|
// src/services/pricing-cache.ts
|
|
105695
106117
|
import { existsSync as existsSync34, readFileSync as readFileSync40, statSync as statSync16 } from "fs";
|
|
105696
|
-
import { homedir as
|
|
106118
|
+
import { homedir as homedir38 } from "os";
|
|
105697
106119
|
import { join as join48 } from "path";
|
|
105698
106120
|
function prefixMatch(modelName) {
|
|
105699
106121
|
for (const [key, pricing] of pricingMap) {
|
|
@@ -105766,7 +106188,7 @@ var init_pricing_cache = __esm(() => {
|
|
|
105766
106188
|
init_catalog_client();
|
|
105767
106189
|
init_catalog_route_bindings();
|
|
105768
106190
|
pricingMap = new Map;
|
|
105769
|
-
CACHE_DIR = join48(
|
|
106191
|
+
CACHE_DIR = join48(homedir38(), ".claudish");
|
|
105770
106192
|
CACHE_FILE = join48(CACHE_DIR, "pricing-cache.json");
|
|
105771
106193
|
CACHE_TTL_MS5 = 24 * 60 * 60 * 1000;
|
|
105772
106194
|
});
|
|
@@ -108788,14 +109210,14 @@ import {
|
|
|
108788
109210
|
readdirSync as readdirSync8,
|
|
108789
109211
|
unlinkSync as unlinkSync10
|
|
108790
109212
|
} from "fs";
|
|
108791
|
-
import { homedir as
|
|
109213
|
+
import { homedir as homedir39 } from "os";
|
|
108792
109214
|
import { dirname as dirname19, join as join50 } from "path";
|
|
108793
109215
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
108794
109216
|
function getVersion3() {
|
|
108795
109217
|
return VERSION;
|
|
108796
109218
|
}
|
|
108797
109219
|
function clearAllModelCaches() {
|
|
108798
|
-
const cacheDir = join50(
|
|
109220
|
+
const cacheDir = join50(homedir39(), ".claudish");
|
|
108799
109221
|
if (!existsSync35(cacheDir))
|
|
108800
109222
|
return;
|
|
108801
109223
|
const cachePatterns = ["pricing-cache.json", "recommended-models-cache-v2.json"];
|
|
@@ -110708,9 +111130,9 @@ function samePaneSize(a, b) {
|
|
|
110708
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;
|
|
110709
111131
|
|
|
110710
111132
|
// src/pane/process-identity.ts
|
|
110711
|
-
import { execFile as
|
|
111133
|
+
import { execFile as execFile4, execFileSync as execFileSync3 } from "child_process";
|
|
110712
111134
|
import { lstatSync as lstatSync6 } from "fs";
|
|
110713
|
-
import { basename as basename4, dirname as dirname20, isAbsolute as
|
|
111135
|
+
import { basename as basename4, dirname as dirname20, isAbsolute as isAbsolute2, join as join51, normalize } from "path";
|
|
110714
111136
|
function collapse2(s) {
|
|
110715
111137
|
return s.trim().replace(/\s+/g, " ");
|
|
110716
111138
|
}
|
|
@@ -110781,13 +111203,45 @@ function readProcessTableAsync(cancelAfterMs) {
|
|
|
110781
111203
|
const options = cancelAfterMs === undefined ? PS_OPTIONS : { ...PS_OPTIONS, timeout: cancelAfterMs, killSignal: "SIGKILL" };
|
|
110782
111204
|
return new Promise((resolve) => {
|
|
110783
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
|
+
}
|
|
110784
111225
|
try {
|
|
110785
|
-
psSpawn.execFile("ps", PS_ARGS, options, (err, stdout) =>
|
|
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
|
+
});
|
|
110786
111237
|
} catch {
|
|
110787
|
-
|
|
111238
|
+
finish(null);
|
|
110788
111239
|
}
|
|
110789
111240
|
});
|
|
110790
111241
|
}
|
|
111242
|
+
function isPsChild(value) {
|
|
111243
|
+
return typeof value?.on === "function";
|
|
111244
|
+
}
|
|
110791
111245
|
function magmuxNeedle(paneId) {
|
|
110792
111246
|
return `--id ${paneId} --sock-dir`;
|
|
110793
111247
|
}
|
|
@@ -110952,7 +111406,7 @@ function isPaneRecordPath(root, p, paneId) {
|
|
|
110952
111406
|
return isValidPaneId(paneId) && dirname20(p) === join51(root, "panes") && basename4(p) === `${paneId}.json`;
|
|
110953
111407
|
}
|
|
110954
111408
|
function isForkRecordPath(projectsRoot, p, uuid) {
|
|
110955
|
-
if (!
|
|
111409
|
+
if (!isAbsolute2(projectsRoot) || normalize(projectsRoot) !== projectsRoot)
|
|
110956
111410
|
return false;
|
|
110957
111411
|
if (basename4(projectsRoot) !== "projects" || !FORK_UUID_RE.test(uuid))
|
|
110958
111412
|
return false;
|
|
@@ -110978,7 +111432,7 @@ function watcherArgv(a) {
|
|
|
110978
111432
|
function isPaneWatcherCommand(command, paneId) {
|
|
110979
111433
|
return command.includes(` ${WATCHER_ARGV0} ${paneId} `);
|
|
110980
111434
|
}
|
|
110981
|
-
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 = `
|
|
110982
111436
|
set -f
|
|
110983
111437
|
export LC_ALL=C
|
|
110984
111438
|
PANE=$1 UUID=$2 CTL=$3 SOCKP=$4 REC=$5 TURN=$6 ROOT=$7 PROJ=$8 FORK=$9 FORKDIR=\${10}
|
|
@@ -111073,7 +111527,7 @@ var init_process_identity = __esm(() => {
|
|
|
111073
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?(.*)$/;
|
|
111074
111528
|
PS_ENV = { PATH: "/bin:/usr/bin:/usr/sbin:/sbin", LC_ALL: "C" };
|
|
111075
111529
|
PS_OPTIONS = { env: PS_ENV, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 };
|
|
111076
|
-
psSpawn = { execFile:
|
|
111530
|
+
psSpawn = { execFile: execFile4, execFileSync: execFileSync3 };
|
|
111077
111531
|
LAUNCH_DIR_RE = /^launch-[A-Za-z0-9]{6}$/;
|
|
111078
111532
|
PANE_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
111079
111533
|
FORK_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
@@ -111082,7 +111536,7 @@ var init_process_identity = __esm(() => {
|
|
|
111082
111536
|
});
|
|
111083
111537
|
|
|
111084
111538
|
// src/pane/pane-launch.ts
|
|
111085
|
-
import { spawn } from "child_process";
|
|
111539
|
+
import { spawn as spawn2 } from "child_process";
|
|
111086
111540
|
import { randomBytes as randomBytes15 } from "crypto";
|
|
111087
111541
|
import {
|
|
111088
111542
|
chmodSync as chmodSync4,
|
|
@@ -111189,13 +111643,20 @@ function buildPaneEnv(input) {
|
|
|
111189
111643
|
env.SHELL = join52(input.ctlDir, "sh-shim");
|
|
111190
111644
|
return { magmuxEnv: env };
|
|
111191
111645
|
}
|
|
111192
|
-
function
|
|
111646
|
+
function inheritedReplayEnv(parentEnv) {
|
|
111193
111647
|
const env = {};
|
|
111194
111648
|
for (const k of REPLAY_ENV_ALLOWLIST) {
|
|
111195
|
-
const v =
|
|
111649
|
+
const v = parentEnv[k];
|
|
111196
111650
|
if (v)
|
|
111197
111651
|
env[k] = v;
|
|
111198
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);
|
|
111199
111660
|
if (input.configDirOverride)
|
|
111200
111661
|
env.CLAUDE_CONFIG_DIR = input.configDirOverride;
|
|
111201
111662
|
env.SHELL = join52(input.ctlDir, "sh-shim");
|
|
@@ -111469,7 +111930,7 @@ function runMagmuxVersion(found, timeoutMs, drainMs = EXIT_DRAIN_MS) {
|
|
|
111469
111930
|
done();
|
|
111470
111931
|
};
|
|
111471
111932
|
try {
|
|
111472
|
-
child =
|
|
111933
|
+
child = spawn2(found, ["--version"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
111473
111934
|
child.stdout?.setEncoding("utf8").on("data", read);
|
|
111474
111935
|
child.stderr?.setEncoding("utf8").on("data", read);
|
|
111475
111936
|
child.on("error", (e) => fail(e.message));
|
|
@@ -111526,7 +111987,7 @@ function writeLauncherFiles(ctlDir, script) {
|
|
|
111526
111987
|
writeFileSync19(join52(ctlDir, "sh-shim"), SHELL_SHIM, { mode: 448, flag: "wx" });
|
|
111527
111988
|
}
|
|
111528
111989
|
function spawnPaneWatcher(args) {
|
|
111529
|
-
const proc =
|
|
111990
|
+
const proc = spawn2("/bin/sh", watcherArgv(args), {
|
|
111530
111991
|
stdio: ["pipe", "ignore", "ignore"],
|
|
111531
111992
|
detached: true,
|
|
111532
111993
|
env: { PATH: "/bin:/usr/bin:/usr/sbin:/sbin", LC_ALL: "C" }
|
|
@@ -111557,7 +112018,7 @@ function paneMagmuxArgv(input) {
|
|
|
111557
112018
|
];
|
|
111558
112019
|
}
|
|
111559
112020
|
function spawnPaneMagmux(input) {
|
|
111560
|
-
const proc =
|
|
112021
|
+
const proc = spawn2(input.binary, paneMagmuxArgv(input), {
|
|
111561
112022
|
cwd: input.cwd,
|
|
111562
112023
|
env: input.env,
|
|
111563
112024
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -111583,7 +112044,7 @@ function spawnReplayMagmux(input) {
|
|
|
111583
112044
|
const stdio = ["ignore", "ignore", "pipe"];
|
|
111584
112045
|
if (input.holdFd !== undefined)
|
|
111585
112046
|
stdio.push(input.holdFd);
|
|
111586
|
-
const proc =
|
|
112047
|
+
const proc = spawn2(input.binary, replayMagmuxArgv(input), {
|
|
111587
112048
|
cwd: input.cwd,
|
|
111588
112049
|
env: input.env,
|
|
111589
112050
|
stdio,
|
|
@@ -111597,6 +112058,7 @@ var SOCK_ROOT, PaneRootError, OWNER_START36, TERMINAL_IDENTITY_VARS, TERMINAL_ID
|
|
|
111597
112058
|
exec /bin/sh "$@"
|
|
111598
112059
|
`, FATAL_MAGMUX_STDERR;
|
|
111599
112060
|
var init_pane_launch = __esm(() => {
|
|
112061
|
+
init_claude_code_facts();
|
|
111600
112062
|
init_cli();
|
|
111601
112063
|
init_config();
|
|
111602
112064
|
init_magmux_binary();
|
|
@@ -112300,7 +112762,7 @@ var init_terminal_isolation = __esm(() => {
|
|
|
112300
112762
|
});
|
|
112301
112763
|
|
|
112302
112764
|
// src/claude-runner.ts
|
|
112303
|
-
import { spawn as
|
|
112765
|
+
import { spawn as spawn3 } from "child_process";
|
|
112304
112766
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
112305
112767
|
import {
|
|
112306
112768
|
chmodSync as chmodSync5,
|
|
@@ -112316,7 +112778,7 @@ import {
|
|
|
112316
112778
|
unlinkSync as unlinkSync11,
|
|
112317
112779
|
writeFileSync as writeFileSync20
|
|
112318
112780
|
} from "fs";
|
|
112319
|
-
import { homedir as
|
|
112781
|
+
import { homedir as homedir40, tmpdir as tmpdir2 } from "os";
|
|
112320
112782
|
import { dirname as dirname21, join as join53, resolve as resolve6 } from "path";
|
|
112321
112783
|
import { isatty } from "tty";
|
|
112322
112784
|
function releaseTerminalIsolation() {
|
|
@@ -112371,12 +112833,20 @@ function wantsAnthropicApiBilling(config, env = process.env) {
|
|
|
112371
112833
|
return false;
|
|
112372
112834
|
}
|
|
112373
112835
|
}
|
|
112374
|
-
function shouldHideIncidentalAnthropicKey(config, env = process.env) {
|
|
112375
|
-
if (!hasNativeAnthropicMapping(config))
|
|
112376
|
-
return false;
|
|
112836
|
+
function shouldHideIncidentalAnthropicKey(config, env = process.env, loginDeps = { env }) {
|
|
112377
112837
|
if (!env.ANTHROPIC_API_KEY)
|
|
112378
112838
|
return false;
|
|
112379
|
-
|
|
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");
|
|
112380
112850
|
}
|
|
112381
112851
|
function applyProxyPlaceholderAuth(env, paneChild = isPaneChild()) {
|
|
112382
112852
|
env.ANTHROPIC_AUTH_TOKEN = CLAUDISH_PLACEHOLDER_AUTH_TOKEN;
|
|
@@ -112429,7 +112899,7 @@ function childAuthControl(config, env = process.env, deps = {}) {
|
|
|
112429
112899
|
if (isRealAnthropicEnvCredential(env, "ANTHROPIC_AUTH_TOKEN")) {
|
|
112430
112900
|
return { controlled: false, reason: "user-auth-token", where: "environment" };
|
|
112431
112901
|
}
|
|
112432
|
-
if (isRealAnthropicEnvCredential(env, "ANTHROPIC_API_KEY") && !shouldHideIncidentalAnthropicKey(config, env)) {
|
|
112902
|
+
if (isRealAnthropicEnvCredential(env, "ANTHROPIC_API_KEY") && !shouldHideIncidentalAnthropicKey(config, env, childLoginDeps(env, deps))) {
|
|
112433
112903
|
return { controlled: false, reason: "user-api-key", where: "environment" };
|
|
112434
112904
|
}
|
|
112435
112905
|
}
|
|
@@ -112452,12 +112922,21 @@ function childAuthControl(config, env = process.env, deps = {}) {
|
|
|
112452
112922
|
}
|
|
112453
112923
|
return { controlled: true };
|
|
112454
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
|
+
}
|
|
112455
112933
|
function settingsCredentialFindings(config, env = process.env, deps = {}) {
|
|
112456
112934
|
const findings = [];
|
|
112457
112935
|
if (customHeadersSignWithKey(env.ANTHROPIC_CUSTOM_HEADERS)) {
|
|
112458
112936
|
findings.push({ where: "environment", kind: "custom-headers-auth" });
|
|
112459
112937
|
}
|
|
112460
|
-
|
|
112938
|
+
const layers = claudeSettingsLayers(config.claudeArgs ?? [], env, deps, settingsArgScopeOf(config));
|
|
112939
|
+
for (const layer of layers) {
|
|
112461
112940
|
const where = layer.file ?? layer.where;
|
|
112462
112941
|
if (layer.settings === null) {
|
|
112463
112942
|
findings.push({ where, kind: "unreadable" });
|
|
@@ -112535,13 +113014,8 @@ function settingsArgOccurrences(args) {
|
|
|
112535
113014
|
function settingsArgScopeOf(config) {
|
|
112536
113015
|
return config.modelLineup?.picker ? "every" : "first";
|
|
112537
113016
|
}
|
|
112538
|
-
function
|
|
112539
|
-
|
|
112540
|
-
return settingsArgOccurrences(claudeArgs).flatMap((o) => o.value ? [o.value] : []);
|
|
112541
|
-
}
|
|
112542
|
-
const idx = claudeArgs.indexOf("--settings");
|
|
112543
|
-
const value = idx === -1 ? undefined : claudeArgs[idx + 1];
|
|
112544
|
-
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);
|
|
112545
113019
|
}
|
|
112546
113020
|
function customHeaderAuthNames(value) {
|
|
112547
113021
|
const names = new Set;
|
|
@@ -112581,13 +113055,13 @@ function settingsAuthSource(settings) {
|
|
|
112581
113055
|
return null;
|
|
112582
113056
|
}
|
|
112583
113057
|
function readableClaudeSettingsLayers(config, env, deps) {
|
|
112584
|
-
return claudeSettingsLayers(config, env, deps).filter((layer) => !layer.droppedByMerge);
|
|
113058
|
+
return claudeSettingsLayers(config.claudeArgs ?? [], env, deps, settingsArgScopeOf(config)).filter((layer) => !layer.droppedByMerge);
|
|
112585
113059
|
}
|
|
112586
|
-
function claudeSettingsLayers(
|
|
113060
|
+
function claudeSettingsLayers(claudeArgs, env, deps, scope) {
|
|
112587
113061
|
const readFile = deps.readFile ?? ((path) => readFileSync43(path, "utf-8"));
|
|
112588
|
-
const home = deps.home ??
|
|
113062
|
+
const home = deps.home ?? (env.HOME ? env.HOME : homedir40());
|
|
112589
113063
|
const cwd = deps.cwd ?? process.cwd();
|
|
112590
|
-
const enabled = enabledSettingSources(
|
|
113064
|
+
const enabled = enabledSettingSources(claudeArgs);
|
|
112591
113065
|
const on = (source) => enabled === null || enabled.has(source);
|
|
112592
113066
|
const files = [
|
|
112593
113067
|
[managedSettingsPath(), "managed"],
|
|
@@ -112601,25 +113075,26 @@ function claudeSettingsLayers(config, env, deps) {
|
|
|
112601
113075
|
if (settings)
|
|
112602
113076
|
layers.push({ where: file, settings, tier });
|
|
112603
113077
|
}
|
|
112604
|
-
const occurrences = settingsArgOccurrences(
|
|
112605
|
-
const
|
|
113078
|
+
const occurrences = settingsArgOccurrences(claudeArgs);
|
|
113079
|
+
const first = occurrences.find((o) => o.spelling === "separate");
|
|
113080
|
+
const isMerged = (occurrence) => scope === "every" || occurrence === first;
|
|
112606
113081
|
occurrences.forEach((occurrence, i) => {
|
|
112607
113082
|
const where = occurrences.length > 1 ? `--settings (occurrence ${i + 1})` : "--settings";
|
|
112608
113083
|
if (!occurrence.value)
|
|
112609
113084
|
return;
|
|
112610
113085
|
const settings = readSettingsSource(occurrence.value, readFile);
|
|
112611
113086
|
const file = isInlineSettings(occurrence.value) ? {} : { file: occurrence.value };
|
|
112612
|
-
if (occurrence
|
|
113087
|
+
if (isMerged(occurrence) && !settings) {
|
|
112613
113088
|
layers.push({ where, settings, tier: "cli", droppedByMerge: true, ...file });
|
|
112614
113089
|
return;
|
|
112615
113090
|
}
|
|
112616
|
-
|
|
113091
|
+
const mergedMark = isMerged(occurrence) ? { merged: true } : {};
|
|
113092
|
+
layers.push({ where, settings, tier: "cli", ...file, ...mergedMark });
|
|
112617
113093
|
});
|
|
112618
113094
|
return layers;
|
|
112619
113095
|
}
|
|
112620
113096
|
function userSettingsFile(configDir, home, cwd) {
|
|
112621
|
-
|
|
112622
|
-
return join53(resolve6(cwd, dir), "settings.json");
|
|
113097
|
+
return join53(claudeCodeConfigDir({ CLAUDE_CONFIG_DIR: configDir, HOME: home }, cwd), "settings.json");
|
|
112623
113098
|
}
|
|
112624
113099
|
function localSettingsFiles(cwd, readFile, pathKind) {
|
|
112625
113100
|
const cwdFile = join53(cwd, ".claude", "settings.local.json");
|
|
@@ -112711,7 +113186,8 @@ function modelPickerSources(config, env = process.env, deps = {}) {
|
|
|
112711
113186
|
let userRank = -1;
|
|
112712
113187
|
let managed = null;
|
|
112713
113188
|
const availableModels = [];
|
|
112714
|
-
claudeSettingsLayers(config, env, deps
|
|
113189
|
+
const layers = claudeSettingsLayers(config.claudeArgs ?? [], env, deps, settingsArgScopeOf(config));
|
|
113190
|
+
layers.forEach((layer, index) => {
|
|
112715
113191
|
const settings = layer.settings;
|
|
112716
113192
|
if (settings === null)
|
|
112717
113193
|
return;
|
|
@@ -113029,32 +113505,36 @@ function parseSettingsArg(value) {
|
|
|
113029
113505
|
}
|
|
113030
113506
|
return JSON.parse(readFileSync43(value, "utf-8"));
|
|
113031
113507
|
}
|
|
113032
|
-
function
|
|
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 = {}) {
|
|
113033
113524
|
try {
|
|
113034
|
-
const
|
|
113035
|
-
|
|
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;
|
|
113036
113534
|
} catch {
|
|
113037
113535
|
return null;
|
|
113038
113536
|
}
|
|
113039
113537
|
}
|
|
113040
|
-
function userSettingsFileCandidates(cwd) {
|
|
113041
|
-
return [
|
|
113042
|
-
join53(homedir41(), ".claude", "settings.json"),
|
|
113043
|
-
join53(cwd, ".claude", "settings.json"),
|
|
113044
|
-
join53(cwd, ".claude", "settings.local.json")
|
|
113045
|
-
];
|
|
113046
|
-
}
|
|
113047
|
-
function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd(), scope = "first") {
|
|
113048
|
-
const sources = userSettingsFileCandidates(cwd).filter((file) => existsSync37(file));
|
|
113049
|
-
sources.push(...settingsArgValues(claudeArgs, scope));
|
|
113050
|
-
let effective;
|
|
113051
|
-
for (const source of sources) {
|
|
113052
|
-
const layer = parseSettingsArgSafe(source);
|
|
113053
|
-
if (layer && "statusLine" in layer)
|
|
113054
|
-
effective = layer.statusLine;
|
|
113055
|
-
}
|
|
113056
|
-
return chainableCommandOf(effective);
|
|
113057
|
-
}
|
|
113058
113538
|
function chainableCommandOf(statusLine) {
|
|
113059
113539
|
if (!statusLine || typeof statusLine !== "object")
|
|
113060
113540
|
return null;
|
|
@@ -113205,8 +113685,8 @@ function mergeEverySettingsArg(config, tempSettingsPath, statusLine, proxyAuthMo
|
|
|
113205
113685
|
if (!occurrence.value)
|
|
113206
113686
|
return;
|
|
113207
113687
|
const label = occurrences.length > 1 ? `--settings (occurrence ${i + 1})` : "--settings";
|
|
113208
|
-
const parsed =
|
|
113209
|
-
if (parsed === null
|
|
113688
|
+
const parsed = readSettingsSource(occurrence.value, (path) => readFileSync43(path, "utf-8"));
|
|
113689
|
+
if (parsed === null) {
|
|
113210
113690
|
if (!config.quiet)
|
|
113211
113691
|
console.warn(`[claudish] Warning: could not merge user settings: ${label}`);
|
|
113212
113692
|
return;
|
|
@@ -113314,26 +113794,37 @@ function resolveAdvisorToolEnv(config, processEnv = process.env) {
|
|
|
113314
113794
|
return { vars: {}, source: "inherited" };
|
|
113315
113795
|
return { vars: { [ADVISOR_TOOL_ENV_VAR]: "1" }, source: "claudish" };
|
|
113316
113796
|
}
|
|
113317
|
-
function discoverUserAdvisorModel(claudeArgs = [], cwd = process.cwd(),
|
|
113318
|
-
|
|
113319
|
-
|
|
113320
|
-
|
|
113321
|
-
|
|
113322
|
-
|
|
113323
|
-
|
|
113324
|
-
|
|
113325
|
-
|
|
113326
|
-
|
|
113327
|
-
|
|
113328
|
-
|
|
113329
|
-
|
|
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;
|
|
113330
113815
|
}
|
|
113331
|
-
|
|
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];
|
|
113332
113821
|
}
|
|
113333
113822
|
function resolveAdvisorModelArg(config, cwd = process.cwd()) {
|
|
113334
113823
|
if (!config.advisor)
|
|
113335
113824
|
return { args: [], source: "off" };
|
|
113336
|
-
const userChoice = discoverUserAdvisorModel(config.claudeArgs, cwd,
|
|
113825
|
+
const userChoice = discoverUserAdvisorModel(config.claudeArgs, cwd, {
|
|
113826
|
+
scope: settingsArgScopeOf(config)
|
|
113827
|
+
});
|
|
113337
113828
|
if (userChoice)
|
|
113338
113829
|
return { args: [], model: userChoice, source: "inherited" };
|
|
113339
113830
|
return {
|
|
@@ -113428,7 +113919,9 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
|
|
|
113428
113919
|
if (!gatewayEligible && globalConfig.harnessGateway !== undefined) {
|
|
113429
113920
|
log(gatewayHeldOff ? `[claude-runner] harnessGateway ignored: ${HARNESS_GATEWAY_OFF_VAR}=1` : "[claude-runner] harnessGateway ignored: a monitor session keeps the proxy URL");
|
|
113430
113921
|
}
|
|
113431
|
-
const userStatusLineCommand = discoverUserStatusLineCommand(config.claudeArgs, process.cwd(),
|
|
113922
|
+
const userStatusLineCommand = discoverUserStatusLineCommand(config.claudeArgs, process.cwd(), {
|
|
113923
|
+
scope: settingsArgScopeOf(config)
|
|
113924
|
+
});
|
|
113432
113925
|
const advisorModelArg = resolveAdvisorModelArg(config);
|
|
113433
113926
|
const modelPicker = config.modelLineup?.picker;
|
|
113434
113927
|
const {
|
|
@@ -113574,12 +114067,12 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
|
|
|
113574
114067
|
}
|
|
113575
114068
|
}
|
|
113576
114069
|
};
|
|
113577
|
-
|
|
114070
|
+
const nativeModelNotice = !config.monitor && hasNativeAnthropicMapping(config);
|
|
114071
|
+
if (nativeModelNotice) {
|
|
113578
114072
|
log2("[claudish] Native Claude model detected \u2014 using Claude Code subscription credentials");
|
|
113579
|
-
if (hidAnthropicApiKey) {
|
|
113580
|
-
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"));
|
|
113581
|
-
}
|
|
113582
114073
|
}
|
|
114074
|
+
if (hidAnthropicApiKey)
|
|
114075
|
+
log2(hiddenAnthropicKeyNotice(config, nativeModelNotice));
|
|
113583
114076
|
if (gatewayNotice)
|
|
113584
114077
|
log2(`[claudish] ${gatewayNotice}`);
|
|
113585
114078
|
if (config.interactive) {
|
|
@@ -113604,7 +114097,7 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
|
|
|
113604
114097
|
console.error("Install it from: https://claude.com/claude-code");
|
|
113605
114098
|
console.error(`
|
|
113606
114099
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
113607
|
-
const home =
|
|
114100
|
+
const home = homedir40();
|
|
113608
114101
|
const localPath = isWindows2() ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
|
|
113609
114102
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
113610
114103
|
process.exit(1);
|
|
@@ -113656,7 +114149,7 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
113656
114149
|
stdoutIsTty: Boolean(process.stdout.isTTY),
|
|
113657
114150
|
magmuxBinary: paneCapability.magmux
|
|
113658
114151
|
}) : null;
|
|
113659
|
-
const proc = wrap ?
|
|
114152
|
+
const proc = wrap ? spawn3(wrap.command, wrap.args, { env: wrap.env, stdio, shell: false }) : spawn3(spawnCommand, claudeArgs, {
|
|
113660
114153
|
env,
|
|
113661
114154
|
stdio,
|
|
113662
114155
|
shell: needsShell
|
|
@@ -113854,7 +114347,7 @@ async function findClaudeBinary(env = process.env) {
|
|
|
113854
114347
|
return env.CLAUDE_PATH;
|
|
113855
114348
|
}
|
|
113856
114349
|
}
|
|
113857
|
-
const home =
|
|
114350
|
+
const home = homedir40();
|
|
113858
114351
|
const localPath = isWindows ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
|
|
113859
114352
|
if (existsSync37(localPath)) {
|
|
113860
114353
|
return localPath;
|
|
@@ -113888,7 +114381,7 @@ async function findClaudeBinary(env = process.env) {
|
|
|
113888
114381
|
}
|
|
113889
114382
|
try {
|
|
113890
114383
|
const shellCommand = isWindows ? "where claude" : "command -v claude";
|
|
113891
|
-
const proc =
|
|
114384
|
+
const proc = spawn3(shellCommand, [], {
|
|
113892
114385
|
stdio: "pipe",
|
|
113893
114386
|
shell: true
|
|
113894
114387
|
});
|
|
@@ -113921,6 +114414,7 @@ async function checkClaudeInstalled() {
|
|
|
113921
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;
|
|
113922
114415
|
var init_claude_runner = __esm(() => {
|
|
113923
114416
|
init_model_catalog();
|
|
114417
|
+
init_claude_code_facts();
|
|
113924
114418
|
init_claude_code_login();
|
|
113925
114419
|
init_config();
|
|
113926
114420
|
init_anthropic_forward();
|
|
@@ -115907,7 +116401,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
115907
116401
|
notifyStatus(e.id);
|
|
115908
116402
|
viewServices?.feed.changed(targetOfSlot(runId, e.id), true);
|
|
115909
116403
|
}
|
|
115910
|
-
const projects = projectsDir(parentEnv);
|
|
116404
|
+
const projects = projectsDir(parentEnv, cwd);
|
|
115911
116405
|
function bindingFor(e, uuid) {
|
|
115912
116406
|
const session = {
|
|
115913
116407
|
kind: "team",
|
|
@@ -116516,6 +117010,60 @@ function resolveSetupFrom(arg, workDir, serverCwd) {
|
|
|
116516
117010
|
}
|
|
116517
117011
|
var init_inherited_settings = () => {};
|
|
116518
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
|
+
|
|
116519
117067
|
// src/mcp-session/scrollback-buffer.ts
|
|
116520
117068
|
class ScrollbackBuffer {
|
|
116521
117069
|
lines;
|
|
@@ -116589,7 +117137,7 @@ import {
|
|
|
116589
117137
|
statSync as statSync23,
|
|
116590
117138
|
writeFileSync as writeFileSync23
|
|
116591
117139
|
} from "fs";
|
|
116592
|
-
import { join as
|
|
117140
|
+
import { join as join59, resolve as resolve9, sep as sep2 } from "path";
|
|
116593
117141
|
function normaliseTimeoutSeconds(raw) {
|
|
116594
117142
|
const n = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
|
|
116595
117143
|
if (typeof n !== "number" || !Number.isFinite(n))
|
|
@@ -116762,7 +117310,7 @@ function dropLeadingFragment(tail) {
|
|
|
116762
117310
|
return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
|
|
116763
117311
|
}
|
|
116764
117312
|
function diskAccounting(sessionDir) {
|
|
116765
|
-
const stats = readTokenStatsAt(
|
|
117313
|
+
const stats = readTokenStatsAt(join59(sessionDir, "tokens.json"));
|
|
116766
117314
|
return {
|
|
116767
117315
|
tokensIn: stats?.billed_input_tokens ?? null,
|
|
116768
117316
|
tokensOut: stats?.output_tokens ?? null,
|
|
@@ -116851,7 +117399,7 @@ class SessionManager {
|
|
|
116851
117399
|
let dir = "";
|
|
116852
117400
|
for (let attempt = 0;; attempt++) {
|
|
116853
117401
|
id = `team-${randomUUID9().replace(/-/g, "").slice(0, 8)}`;
|
|
116854
|
-
dir =
|
|
117402
|
+
dir = join59(this.sessionsDir, id);
|
|
116855
117403
|
try {
|
|
116856
117404
|
mkdirSync28(dir);
|
|
116857
117405
|
break;
|
|
@@ -116883,9 +117431,9 @@ class SessionManager {
|
|
|
116883
117431
|
if (dir === null)
|
|
116884
117432
|
throw new Error("not a record id");
|
|
116885
117433
|
const completedAt = new Date().toISOString();
|
|
116886
|
-
const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(
|
|
117434
|
+
const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(join59(dir, "spawn.json"), META_READ_LIMIT)?.startedAt) ?? completedAt;
|
|
116887
117435
|
const elapsedMs = Date.parse(completedAt) - Date.parse(startedAt);
|
|
116888
|
-
writeJsonAtomic(
|
|
117436
|
+
writeJsonAtomic(join59(dir, "meta.json"), {
|
|
116889
117437
|
kind: "team",
|
|
116890
117438
|
status: outcome.status,
|
|
116891
117439
|
startedAt,
|
|
@@ -116917,7 +117465,7 @@ class SessionManager {
|
|
|
116917
117465
|
startedAt,
|
|
116918
117466
|
...rest
|
|
116919
117467
|
};
|
|
116920
|
-
writeJsonAtomic(
|
|
117468
|
+
writeJsonAtomic(join59(dir, "spawn.json"), body);
|
|
116921
117469
|
}
|
|
116922
117470
|
async createSession(opts) {
|
|
116923
117471
|
if (this.activeSessions + this.starting >= this.maxSessions) {
|
|
@@ -116957,7 +117505,7 @@ class SessionManager {
|
|
|
116957
117505
|
throw err;
|
|
116958
117506
|
}
|
|
116959
117507
|
if (inherited.layer) {
|
|
116960
|
-
flags = [...inherited.restFlags, "--settings",
|
|
117508
|
+
flags = [...inherited.restFlags, "--settings", join59(entry.sessionDir, INHERITED_SETTINGS)];
|
|
116961
117509
|
}
|
|
116962
117510
|
this.sessions.set(entry.info.sessionId, entry);
|
|
116963
117511
|
uncount();
|
|
@@ -116982,10 +117530,10 @@ class SessionManager {
|
|
|
116982
117530
|
const timeout = normaliseTimeoutSeconds(opts.timeoutSeconds);
|
|
116983
117531
|
const agentRequested = requestedAgentOf(opts.claudishFlags ?? []);
|
|
116984
117532
|
const startedAt = new Date().toISOString();
|
|
116985
|
-
const sessionDir = opts.sessionDir ??
|
|
117533
|
+
const sessionDir = opts.sessionDir ?? join59(this.sessionsDir, sessionId);
|
|
116986
117534
|
mkdirSync28(sessionDir, { recursive: true });
|
|
116987
117535
|
if (opts.prompt)
|
|
116988
|
-
writeFileSync23(
|
|
117536
|
+
writeFileSync23(join59(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
116989
117537
|
this.writeSpawnRecord(sessionDir, {
|
|
116990
117538
|
kind: "session",
|
|
116991
117539
|
sessionId,
|
|
@@ -116999,13 +117547,13 @@ class SessionManager {
|
|
|
116999
117547
|
taskType: opts.taskType
|
|
117000
117548
|
});
|
|
117001
117549
|
if (inheritedLayer) {
|
|
117002
|
-
writeFileSync23(
|
|
117550
|
+
writeFileSync23(join59(sessionDir, INHERITED_SETTINGS), `${JSON.stringify(inheritedLayer, null, 2)}
|
|
117003
117551
|
`, { encoding: "utf-8", mode: 384 });
|
|
117004
117552
|
}
|
|
117005
117553
|
const cwd = opts.cwd ?? process.cwd();
|
|
117006
117554
|
const parentEnv = opts.parentEnv ?? this.parentEnv;
|
|
117007
117555
|
const spawnModel = opts.spawnModel ?? null;
|
|
117008
|
-
const tokenFile = opts.tokenFile ??
|
|
117556
|
+
const tokenFile = opts.tokenFile ?? join59(sessionDir, "tokens.json");
|
|
117009
117557
|
return {
|
|
117010
117558
|
info: {
|
|
117011
117559
|
sessionId,
|
|
@@ -117036,7 +117584,7 @@ class SessionManager {
|
|
|
117036
117584
|
detail: null,
|
|
117037
117585
|
pendingInputs: opts.prompt ? 1 : 0,
|
|
117038
117586
|
claudeSessionId,
|
|
117039
|
-
transcriptPath: transcriptPathFor(cwd, claudeSessionId, projectsDir(parentEnv)),
|
|
117587
|
+
transcriptPath: transcriptPathFor(cwd, claudeSessionId, projectsDir(parentEnv, cwd)),
|
|
117040
117588
|
...optionalParent(opts.parentClaudeSessionId),
|
|
117041
117589
|
captureSource: null,
|
|
117042
117590
|
turnSource: "transcript",
|
|
@@ -117044,18 +117592,18 @@ class SessionManager {
|
|
|
117044
117592
|
},
|
|
117045
117593
|
session: null,
|
|
117046
117594
|
scrollback: new ScrollbackBuffer(this.scrollbackCapacity),
|
|
117047
|
-
outputLogStream: createWriteStream(
|
|
117595
|
+
outputLogStream: createWriteStream(join59(sessionDir, "output.log")),
|
|
117048
117596
|
sessionDir,
|
|
117049
117597
|
cwd,
|
|
117050
117598
|
tokenFile,
|
|
117051
|
-
eventLogPath:
|
|
117599
|
+
eventLogPath: join59(sessionDir, "events.jsonl"),
|
|
117052
117600
|
eventLogBytes: 0,
|
|
117053
|
-
upstreamErrorLogPath:
|
|
117601
|
+
upstreamErrorLogPath: join59(sessionDir, "upstream-errors.jsonl"),
|
|
117054
117602
|
eventRing: [],
|
|
117055
117603
|
proseBytes: 0,
|
|
117056
117604
|
answeredTurns: new Map,
|
|
117057
117605
|
inboxPath: null,
|
|
117058
|
-
waitLogPath:
|
|
117606
|
+
waitLogPath: join59(sessionDir, "waits.jsonl"),
|
|
117059
117607
|
waitLogBytes: 0,
|
|
117060
117608
|
waitSince: null,
|
|
117061
117609
|
ended: false,
|
|
@@ -117065,7 +117613,7 @@ class SessionManager {
|
|
|
117065
117613
|
anomaliesLogged: new Set,
|
|
117066
117614
|
requestedSize: null,
|
|
117067
117615
|
reapVerified: false,
|
|
117068
|
-
projectsRoot: projectsDir(parentEnv),
|
|
117616
|
+
projectsRoot: projectsDir(parentEnv, cwd),
|
|
117069
117617
|
promptSummary: opts.prompt ? promptSummaryOf(opts.prompt) : null,
|
|
117070
117618
|
lastChangeKey: null,
|
|
117071
117619
|
stopTokenWatch: null
|
|
@@ -117277,7 +117825,7 @@ class SessionManager {
|
|
|
117277
117825
|
try {
|
|
117278
117826
|
const text = screenLines.join(`
|
|
117279
117827
|
`).replace(/\s+$/, "");
|
|
117280
|
-
writeFileSync23(
|
|
117828
|
+
writeFileSync23(join59(entry.sessionDir, "screen.txt"), `${redactSecrets(text)}
|
|
117281
117829
|
`, "utf-8");
|
|
117282
117830
|
} catch {}
|
|
117283
117831
|
}
|
|
@@ -117291,7 +117839,7 @@ class SessionManager {
|
|
|
117291
117839
|
entry.waitSince = null;
|
|
117292
117840
|
}
|
|
117293
117841
|
try {
|
|
117294
|
-
writeJsonAtomic(
|
|
117842
|
+
writeJsonAtomic(join59(entry.sessionDir, "meta.json"), toMetaRecord(entry.info, entry.cwd));
|
|
117295
117843
|
} catch (err) {
|
|
117296
117844
|
process.stderr.write(`[claudish] session ${entry.info.sessionId}: could not write meta.json: ` + `${err instanceof Error ? err.message : String(err)}
|
|
117297
117845
|
`);
|
|
@@ -117561,20 +118109,20 @@ class SessionManager {
|
|
|
117561
118109
|
} catch {
|
|
117562
118110
|
return null;
|
|
117563
118111
|
}
|
|
117564
|
-
const spawnPath =
|
|
117565
|
-
const metaPath =
|
|
118112
|
+
const spawnPath = join59(sessionDir, "spawn.json");
|
|
118113
|
+
const metaPath = join59(sessionDir, "meta.json");
|
|
117566
118114
|
const spawnRecord = readJsonObject(spawnPath, META_READ_LIMIT);
|
|
117567
118115
|
if (spawnRecord?.kind === "team")
|
|
117568
118116
|
return null;
|
|
117569
118117
|
const meta = readJsonObject(metaPath, META_READ_LIMIT);
|
|
117570
118118
|
if (meta?.kind === "team")
|
|
117571
118119
|
return null;
|
|
117572
|
-
const projectsRoot = projectsDir(this.parentEnv);
|
|
117573
118120
|
const uuid = metaString(meta?.claudeSessionId) ?? metaString(spawnRecord?.claudeSessionId) ?? null;
|
|
117574
118121
|
const now = Date.now();
|
|
117575
118122
|
let writerGone;
|
|
117576
118123
|
let transcriptPath = null;
|
|
117577
118124
|
const cwd = meta !== null ? metaString(meta.cwd) : undefined;
|
|
118125
|
+
const projectsRoot = projectsDir(this.parentEnv, cwd ?? process.cwd());
|
|
117578
118126
|
if (meta !== null) {
|
|
117579
118127
|
const completedAt = metaString(meta.completedAt);
|
|
117580
118128
|
const endedMs = completedAt ? Date.parse(completedAt) : Number.NaN;
|
|
@@ -117653,7 +118201,7 @@ class SessionManager {
|
|
|
117653
118201
|
if (!record)
|
|
117654
118202
|
return null;
|
|
117655
118203
|
const info = record.info;
|
|
117656
|
-
return sessionRowOf(info, upstreamRecordsFor(info,
|
|
118204
|
+
return sessionRowOf(info, upstreamRecordsFor(info, join59(record.sessionDir, "upstream-errors.jsonl")));
|
|
117657
118205
|
}
|
|
117658
118206
|
async shutdownAll() {
|
|
117659
118207
|
await Promise.all([...this.pendingStarts]);
|
|
@@ -117684,7 +118232,7 @@ class SessionManager {
|
|
|
117684
118232
|
return null;
|
|
117685
118233
|
const root = resolve9(this.sessionsDir);
|
|
117686
118234
|
const dir = resolve9(root, sessionId);
|
|
117687
|
-
if (dir !==
|
|
118235
|
+
if (dir !== join59(root, sessionId))
|
|
117688
118236
|
return null;
|
|
117689
118237
|
if (!dir.startsWith(root + sep2))
|
|
117690
118238
|
return null;
|
|
@@ -117703,10 +118251,10 @@ class SessionManager {
|
|
|
117703
118251
|
} catch {
|
|
117704
118252
|
return null;
|
|
117705
118253
|
}
|
|
117706
|
-
const spawnRecord = readJsonObject(
|
|
118254
|
+
const spawnRecord = readJsonObject(join59(sessionDir, "spawn.json"), META_READ_LIMIT);
|
|
117707
118255
|
if (spawnRecord?.kind === "team")
|
|
117708
118256
|
return null;
|
|
117709
|
-
const meta = readJsonObject(
|
|
118257
|
+
const meta = readJsonObject(join59(sessionDir, "meta.json"), META_READ_LIMIT);
|
|
117710
118258
|
if (meta?.kind === "team")
|
|
117711
118259
|
return null;
|
|
117712
118260
|
const partial = meta === null;
|
|
@@ -117724,11 +118272,11 @@ class SessionManager {
|
|
|
117724
118272
|
if (stored && existsSync41(stored))
|
|
117725
118273
|
return stored;
|
|
117726
118274
|
if (cwd && uuid)
|
|
117727
|
-
return transcriptPathFor(cwd, uuid, projectsDir(this.parentEnv));
|
|
118275
|
+
return transcriptPathFor(cwd, uuid, projectsDir(this.parentEnv, cwd));
|
|
117728
118276
|
return stored;
|
|
117729
118277
|
}
|
|
117730
118278
|
diskOutput(record, tailLines) {
|
|
117731
|
-
const tail = readTailText(
|
|
118279
|
+
const tail = readTailText(join59(record.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
|
|
117732
118280
|
const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
117733
118281
|
if (tail?.text)
|
|
117734
118282
|
buffer.append(dropLeadingFragment(tail));
|
|
@@ -117748,12 +118296,12 @@ class SessionManager {
|
|
|
117748
118296
|
}
|
|
117749
118297
|
diskDiagnostics(record, limit) {
|
|
117750
118298
|
const { sessionDir, info } = record;
|
|
117751
|
-
const eventLogPath =
|
|
117752
|
-
const upstreamErrorLogPath =
|
|
117753
|
-
const outputLogPath =
|
|
118299
|
+
const eventLogPath = join59(sessionDir, "events.jsonl");
|
|
118300
|
+
const upstreamErrorLogPath = join59(sessionDir, "upstream-errors.jsonl");
|
|
118301
|
+
const outputLogPath = join59(sessionDir, "output.log");
|
|
117754
118302
|
const events = readTailLines2(eventLogPath, EVENT_TAIL_BYTES);
|
|
117755
118303
|
const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
|
|
117756
|
-
const screen = readTailText(
|
|
118304
|
+
const screen = readTailText(join59(sessionDir, "screen.txt"), SCREEN_READ_BYTES);
|
|
117757
118305
|
return {
|
|
117758
118306
|
sessionId: info.sessionId,
|
|
117759
118307
|
state: info.state,
|
|
@@ -118058,7 +118606,7 @@ var init_session_manager = __esm(() => {
|
|
|
118058
118606
|
|
|
118059
118607
|
// src/view/history.ts
|
|
118060
118608
|
import { closeSync as closeSync17, openSync as openSync17, readSync as readSync8, readdirSync as readdirSync12, statSync as statSync24 } from "fs";
|
|
118061
|
-
import { join as
|
|
118609
|
+
import { join as join60 } from "path";
|
|
118062
118610
|
function finishedDetail(promptSummary) {
|
|
118063
118611
|
return {
|
|
118064
118612
|
prompt_summary: promptSummary,
|
|
@@ -118100,7 +118648,7 @@ function runDirs(sessionsDir) {
|
|
|
118100
118648
|
const dated = [];
|
|
118101
118649
|
for (const name of names) {
|
|
118102
118650
|
try {
|
|
118103
|
-
const st = statSync24(
|
|
118651
|
+
const st = statSync24(join60(sessionsDir, name));
|
|
118104
118652
|
if (st.isDirectory())
|
|
118105
118653
|
dated.push({ name, mtimeMs: st.mtimeMs });
|
|
118106
118654
|
} catch {}
|
|
@@ -118137,7 +118685,7 @@ function teamItems(spawn) {
|
|
|
118137
118685
|
return { runId: run.run_id, items };
|
|
118138
118686
|
}
|
|
118139
118687
|
function runItems(sessions, dir, name, seenRuns) {
|
|
118140
|
-
const spawn = readJson(
|
|
118688
|
+
const spawn = readJson(join60(dir, "spawn.json"));
|
|
118141
118689
|
if (spawn?.kind === "team" || name.startsWith("team-")) {
|
|
118142
118690
|
const team = spawn ? teamItems(spawn) : null;
|
|
118143
118691
|
if (!team || seenRuns.has(team.runId) || team.items.length === 0)
|
|
@@ -118145,12 +118693,12 @@ function runItems(sessions, dir, name, seenRuns) {
|
|
|
118145
118693
|
seenRuns.add(team.runId);
|
|
118146
118694
|
return team.items;
|
|
118147
118695
|
}
|
|
118148
|
-
if (!spawn && readJson(
|
|
118696
|
+
if (!spawn && readJson(join60(dir, "meta.json")) === null)
|
|
118149
118697
|
return null;
|
|
118150
118698
|
const row = sessions.diskSessionRow(name);
|
|
118151
118699
|
if (!row)
|
|
118152
118700
|
return null;
|
|
118153
|
-
const prompt = readHead(
|
|
118701
|
+
const prompt = readHead(join60(dir, "prompt.md"), PROMPT_HEAD_BYTES);
|
|
118154
118702
|
return [sessionItem(row, prompt ? promptSummaryOf(prompt) : null)];
|
|
118155
118703
|
}
|
|
118156
118704
|
function readHistory(o = {}) {
|
|
@@ -118163,7 +118711,7 @@ function readHistory(o = {}) {
|
|
|
118163
118711
|
for (const name of runDirs(sessionsDir)) {
|
|
118164
118712
|
if (runs >= limit)
|
|
118165
118713
|
break;
|
|
118166
|
-
const items = runItems(sessions,
|
|
118714
|
+
const items = runItems(sessions, join60(sessionsDir, name), name, seenRuns);
|
|
118167
118715
|
if (!items)
|
|
118168
118716
|
continue;
|
|
118169
118717
|
out.push(...items);
|
|
@@ -118178,15 +118726,15 @@ function findRecordedItem(target, o = {}) {
|
|
|
118178
118726
|
const id = target.slice(2);
|
|
118179
118727
|
if (!id || id.includes("/") || id.startsWith("."))
|
|
118180
118728
|
return null;
|
|
118181
|
-
const items = runItems(sessions,
|
|
118729
|
+
const items = runItems(sessions, join60(sessionsDir, id), id, new Set);
|
|
118182
118730
|
return items?.find((i) => i.target === target) ?? null;
|
|
118183
118731
|
}
|
|
118184
118732
|
if (!target.startsWith("t:"))
|
|
118185
118733
|
return null;
|
|
118186
118734
|
const seenRuns = new Set;
|
|
118187
118735
|
for (const name of runDirs(sessionsDir)) {
|
|
118188
|
-
const dir =
|
|
118189
|
-
if (!name.startsWith("team-") && readJson(
|
|
118736
|
+
const dir = join60(sessionsDir, name);
|
|
118737
|
+
if (!name.startsWith("team-") && readJson(join60(dir, "spawn.json"))?.kind !== "team")
|
|
118190
118738
|
continue;
|
|
118191
118739
|
const found = runItems(sessions, dir, name, seenRuns)?.find((i) => i.target === target);
|
|
118192
118740
|
if (found)
|
|
@@ -118438,9 +118986,9 @@ var init_view_client = __esm(() => {
|
|
|
118438
118986
|
|
|
118439
118987
|
// src/view/feed-relay.ts
|
|
118440
118988
|
import { chmodSync as chmodSync7, readFileSync as readFileSync48, renameSync as renameSync11, rmSync as rmSync16, writeFileSync as writeFileSync24 } from "fs";
|
|
118441
|
-
import { dirname as dirname24, join as
|
|
118989
|
+
import { dirname as dirname24, join as join61 } from "path";
|
|
118442
118990
|
function defaultFeedPath(root) {
|
|
118443
|
-
return
|
|
118991
|
+
return join61(root, FEED_DIR, FEED_FILE);
|
|
118444
118992
|
}
|
|
118445
118993
|
function ownStamp() {
|
|
118446
118994
|
return {
|
|
@@ -118508,7 +119056,7 @@ class FeedRelay {
|
|
|
118508
119056
|
}
|
|
118509
119057
|
async start() {
|
|
118510
119058
|
ensureSockRoot(this.o.root);
|
|
118511
|
-
if (dirname24(this.path) ===
|
|
119059
|
+
if (dirname24(this.path) === join61(this.o.root, FEED_DIR))
|
|
118512
119060
|
ensurePrivateSubdir(this.o.root, FEED_DIR);
|
|
118513
119061
|
const other = readFeedStamp(this.path);
|
|
118514
119062
|
if (other && !this.isOwn(other) && stampAlive(other, await readProcessTableAsync()))
|
|
@@ -118773,7 +119321,7 @@ import {
|
|
|
118773
119321
|
unlinkSync as unlinkSync12,
|
|
118774
119322
|
writeFileSync as writeFileSync25
|
|
118775
119323
|
} from "fs";
|
|
118776
|
-
import { dirname as dirname25, join as
|
|
119324
|
+
import { dirname as dirname25, join as join62 } from "path";
|
|
118777
119325
|
function ownerStartOfSelf() {
|
|
118778
119326
|
if (ownStart)
|
|
118779
119327
|
return ownStart;
|
|
@@ -118794,7 +119342,7 @@ function ownerAlive(owner, table) {
|
|
|
118794
119342
|
return !minted || startedAt(row, minted.startMs);
|
|
118795
119343
|
}
|
|
118796
119344
|
function recordsDir(root) {
|
|
118797
|
-
return
|
|
119345
|
+
return join62(root, "panes");
|
|
118798
119346
|
}
|
|
118799
119347
|
function writeRecord(root, rec) {
|
|
118800
119348
|
const p = recordPathOf(root, rec.paneId);
|
|
@@ -118878,13 +119426,13 @@ function readRecords(root) {
|
|
|
118878
119426
|
}
|
|
118879
119427
|
function readGroupFile(ctlDir) {
|
|
118880
119428
|
try {
|
|
118881
|
-
return parseGroupFile(readFileSync49(
|
|
119429
|
+
return parseGroupFile(readFileSync49(join62(ctlDir, "group"), "utf8"));
|
|
118882
119430
|
} catch {
|
|
118883
119431
|
return null;
|
|
118884
119432
|
}
|
|
118885
119433
|
}
|
|
118886
119434
|
function writeGroupFile(ctlDir, snap) {
|
|
118887
|
-
const p =
|
|
119435
|
+
const p = join62(ctlDir, "group");
|
|
118888
119436
|
const tmp = `${p}.tmp`;
|
|
118889
119437
|
try {
|
|
118890
119438
|
writeFileSync25(tmp, formatGroupFile(snap), { mode: 384 });
|
|
@@ -119178,7 +119726,7 @@ async function sweepRecordlessSocket(root, name, out) {
|
|
|
119178
119726
|
const owner = ownerOfSocketId(id);
|
|
119179
119727
|
if (!owner || ownerAlive(owner, table))
|
|
119180
119728
|
return;
|
|
119181
|
-
const sockPath =
|
|
119729
|
+
const sockPath = join62(root, name);
|
|
119182
119730
|
const magmuxMayLive = !table || table.some((r) => isPaneMagmuxCommand(r.command, id));
|
|
119183
119731
|
const probe = await probeSocket(sockPath, magmuxMayLive);
|
|
119184
119732
|
if (probe.state === "stale") {
|
|
@@ -119306,14 +119854,14 @@ var init_pane_registry = __esm(() => {
|
|
|
119306
119854
|
|
|
119307
119855
|
// src/pane/gate-binding.ts
|
|
119308
119856
|
import { realpathSync as realpathSync8 } from "fs";
|
|
119309
|
-
import { basename as basename8, dirname as dirname26, join as
|
|
119857
|
+
import { basename as basename8, dirname as dirname26, join as join63, resolve as resolve10 } from "path";
|
|
119310
119858
|
function normaliseTranscriptPath(p) {
|
|
119311
119859
|
const abs = resolve10(p);
|
|
119312
119860
|
const tail = [];
|
|
119313
119861
|
let cur = abs;
|
|
119314
119862
|
for (;; ) {
|
|
119315
119863
|
try {
|
|
119316
|
-
return tail.length ?
|
|
119864
|
+
return tail.length ? join63(realpathSync8(cur), ...tail.reverse()) : realpathSync8(cur);
|
|
119317
119865
|
} catch {
|
|
119318
119866
|
const parent = dirname26(cur);
|
|
119319
119867
|
if (parent === cur)
|
|
@@ -119514,7 +120062,7 @@ var init_scroll_input = __esm(() => {
|
|
|
119514
120062
|
|
|
119515
120063
|
// src/pane/session-registry.ts
|
|
119516
120064
|
import { readFileSync as readFileSync50, readdirSync as readdirSync14 } from "fs";
|
|
119517
|
-
import { join as
|
|
120065
|
+
import { join as join64 } from "path";
|
|
119518
120066
|
function parseRegistryRecord(raw) {
|
|
119519
120067
|
let parsed;
|
|
119520
120068
|
try {
|
|
@@ -119559,7 +120107,7 @@ class SessionRegistry {
|
|
|
119559
120107
|
isAlive;
|
|
119560
120108
|
constructor(o) {
|
|
119561
120109
|
this.o = o;
|
|
119562
|
-
this.dir =
|
|
120110
|
+
this.dir = join64(o.configDir, "sessions");
|
|
119563
120111
|
this.now = o.now ?? Date.now;
|
|
119564
120112
|
this.isAlive = o.isAlive ?? pidAlive2;
|
|
119565
120113
|
}
|
|
@@ -119595,7 +120143,7 @@ class SessionRegistry {
|
|
|
119595
120143
|
readPid(pid) {
|
|
119596
120144
|
let raw;
|
|
119597
120145
|
try {
|
|
119598
|
-
raw = readFileSync50(
|
|
120146
|
+
raw = readFileSync50(join64(this.dir, `${pid}.json`), "utf8");
|
|
119599
120147
|
} catch {
|
|
119600
120148
|
return null;
|
|
119601
120149
|
}
|
|
@@ -119740,7 +120288,7 @@ var init_view_socket = __esm(() => {
|
|
|
119740
120288
|
|
|
119741
120289
|
// src/pane/pane-session.ts
|
|
119742
120290
|
import { readFileSync as readFileSync51, realpathSync as realpathSync9, rmSync as rmSync18, statSync as statSync25, writeFileSync as writeFileSync26 } from "fs";
|
|
119743
|
-
import { join as
|
|
120291
|
+
import { join as join65 } from "path";
|
|
119744
120292
|
function iso3(ms) {
|
|
119745
120293
|
return new Date(ms).toISOString();
|
|
119746
120294
|
}
|
|
@@ -119893,9 +120441,9 @@ class PaneSessionImpl {
|
|
|
119893
120441
|
});
|
|
119894
120442
|
this.secondaryQuietMs = o.timings?.secondaryQuietMs ?? SECONDARY_QUIET_MS;
|
|
119895
120443
|
this.corroborationMs = o.timings?.corroborationMs ?? CORROBORATION_MS;
|
|
119896
|
-
this.follower = new TranscriptFollower(o.transcriptPath,
|
|
120444
|
+
this.follower = new TranscriptFollower(o.transcriptPath, join65(o.transcriptPath.replace(/\.jsonl$/, ""), "subagents"));
|
|
119897
120445
|
this.registry = new SessionRegistry({
|
|
119898
|
-
configDir:
|
|
120446
|
+
configDir: claudeCodeConfigDir(o.parentEnv ?? process.env, o.cwd),
|
|
119899
120447
|
sessionUuid: o.sessionUuid
|
|
119900
120448
|
});
|
|
119901
120449
|
this.ready = new Promise((r) => {
|
|
@@ -119940,7 +120488,7 @@ class PaneSessionImpl {
|
|
|
119940
120488
|
return this.spawnFailed(new Error("magmux did not start"));
|
|
119941
120489
|
this.magmux = proc;
|
|
119942
120490
|
try {
|
|
119943
|
-
writeFileSync26(
|
|
120491
|
+
writeFileSync26(join65(this.ctlDir, "magmux.pid"), `${proc.pid}
|
|
119944
120492
|
`, { mode: 384 });
|
|
119945
120493
|
} catch {}
|
|
119946
120494
|
updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
|
|
@@ -122417,9 +122965,9 @@ async function startPaneSession(o) {
|
|
|
122417
122965
|
}
|
|
122418
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;
|
|
122419
122967
|
var init_pane_session = __esm(() => {
|
|
122968
|
+
init_claude_code_facts();
|
|
122420
122969
|
init_queue();
|
|
122421
122970
|
init_logger();
|
|
122422
|
-
init_parent_session();
|
|
122423
122971
|
init_redact();
|
|
122424
122972
|
init_box_locate();
|
|
122425
122973
|
init_contract();
|
|
@@ -122475,7 +123023,7 @@ var init_pane_session = __esm(() => {
|
|
|
122475
123023
|
|
|
122476
123024
|
// src/pane/replay-pane.ts
|
|
122477
123025
|
import { rmSync as rmSync19, writeFileSync as writeFileSync27 } from "fs";
|
|
122478
|
-
import { join as
|
|
123026
|
+
import { join as join66 } from "path";
|
|
122479
123027
|
async function waitUntil(pred, ms) {
|
|
122480
123028
|
const end = Date.now() + ms;
|
|
122481
123029
|
while (!pred() && Date.now() < end)
|
|
@@ -122588,7 +123136,7 @@ class ReplayPane {
|
|
|
122588
123136
|
return failed(new Error("magmux did not start"));
|
|
122589
123137
|
this.magmuxProc = proc;
|
|
122590
123138
|
try {
|
|
122591
|
-
writeFileSync27(
|
|
123139
|
+
writeFileSync27(join66(this.ctlDir, "magmux.pid"), `${proc.pid}
|
|
122592
123140
|
`, { mode: 384 });
|
|
122593
123141
|
} catch {}
|
|
122594
123142
|
updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
|
|
@@ -123041,7 +123589,7 @@ async function startReplayPane(o) {
|
|
|
123041
123589
|
ctlDir: dirs.ctlDir,
|
|
123042
123590
|
cols: o.size.cols,
|
|
123043
123591
|
rows: o.size.rows,
|
|
123044
|
-
|
|
123592
|
+
configDirOverride: replayConfigDirOverride(o.parentEnv, o.cwd, o.configDir)
|
|
123045
123593
|
});
|
|
123046
123594
|
writeRecord(root, {
|
|
123047
123595
|
paneId,
|
|
@@ -123082,7 +123630,6 @@ async function startReplayPane(o) {
|
|
|
123082
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;
|
|
123083
123631
|
var init_replay_pane = __esm(() => {
|
|
123084
123632
|
init_logger();
|
|
123085
|
-
init_parent_session();
|
|
123086
123633
|
init_redact();
|
|
123087
123634
|
init_box_locate();
|
|
123088
123635
|
init_contract();
|
|
@@ -123516,7 +124063,7 @@ import {
|
|
|
123516
124063
|
realpathSync as realpathSync10,
|
|
123517
124064
|
statSync as statSync26
|
|
123518
124065
|
} from "fs";
|
|
123519
|
-
import { basename as basename9, dirname as dirname27, join as
|
|
124066
|
+
import { basename as basename9, dirname as dirname27, join as join67, sep as sep3 } from "path";
|
|
123520
124067
|
function isUuid(v) {
|
|
123521
124068
|
return typeof v === "string" && UUID_RE.test(v);
|
|
123522
124069
|
}
|
|
@@ -123666,7 +124213,7 @@ function locateTranscriptByUuid(projectsRoot, uuid) {
|
|
|
123666
124213
|
}
|
|
123667
124214
|
let hit = null;
|
|
123668
124215
|
for (const d of dirs) {
|
|
123669
|
-
const p =
|
|
124216
|
+
const p = join67(projectsRoot, d, `${uuid}.jsonl`);
|
|
123670
124217
|
try {
|
|
123671
124218
|
if (!statSync26(p).isFile())
|
|
123672
124219
|
continue;
|
|
@@ -124161,7 +124708,7 @@ var init_peer_link = __esm(() => {
|
|
|
124161
124708
|
// src/view/replay-registry.ts
|
|
124162
124709
|
import { randomBytes as randomBytes18 } from "crypto";
|
|
124163
124710
|
import { readFileSync as readFileSync52, readdirSync as readdirSync16, renameSync as renameSync13, rmSync as rmSync20, writeFileSync as writeFileSync28 } from "fs";
|
|
124164
|
-
import { join as
|
|
124711
|
+
import { join as join68 } from "path";
|
|
124165
124712
|
function parseEntry(raw) {
|
|
124166
124713
|
let v;
|
|
124167
124714
|
try {
|
|
@@ -124199,14 +124746,14 @@ class ReplayRegistry {
|
|
|
124199
124746
|
constructor(root, log = () => {}) {
|
|
124200
124747
|
this.root = root;
|
|
124201
124748
|
this.log = log;
|
|
124202
|
-
this.dir =
|
|
124749
|
+
this.dir = join68(root, REPLAYS_DIR);
|
|
124203
124750
|
}
|
|
124204
124751
|
ensure() {
|
|
124205
124752
|
ensureSockRoot(this.root);
|
|
124206
124753
|
return ensurePrivateSubdir(this.root, REPLAYS_DIR);
|
|
124207
124754
|
}
|
|
124208
124755
|
lockPathOf(uuid) {
|
|
124209
|
-
return
|
|
124756
|
+
return join68(this.dir, `${this.key(uuid)}.lock`);
|
|
124210
124757
|
}
|
|
124211
124758
|
tryLock(uuid) {
|
|
124212
124759
|
this.ensure();
|
|
@@ -124221,7 +124768,7 @@ class ReplayRegistry {
|
|
|
124221
124768
|
}
|
|
124222
124769
|
async withLock(fn, waitMs = REGISTRY_LOCK_WAIT_MS) {
|
|
124223
124770
|
this.ensure();
|
|
124224
|
-
const lock = await waitAcquire(
|
|
124771
|
+
const lock = await waitAcquire(join68(this.dir, "registry.lock"), waitMs);
|
|
124225
124772
|
if (!lock)
|
|
124226
124773
|
return null;
|
|
124227
124774
|
try {
|
|
@@ -124299,12 +124846,12 @@ class ReplayRegistry {
|
|
|
124299
124846
|
}
|
|
124300
124847
|
for (const name of now)
|
|
124301
124848
|
if (name.endsWith(".tmp"))
|
|
124302
|
-
rmSync20(
|
|
124849
|
+
rmSync20(join68(this.dir, name), { force: true });
|
|
124303
124850
|
});
|
|
124304
124851
|
return swept;
|
|
124305
124852
|
}
|
|
124306
124853
|
entryPathOf(uuid) {
|
|
124307
|
-
return
|
|
124854
|
+
return join68(this.dir, `${this.key(uuid)}.json`);
|
|
124308
124855
|
}
|
|
124309
124856
|
key(uuid) {
|
|
124310
124857
|
const k = uuid.toLowerCase();
|
|
@@ -125672,10 +126219,10 @@ var init_claude_launch = __esm(() => {
|
|
|
125672
126219
|
});
|
|
125673
126220
|
|
|
125674
126221
|
// src/mcp/run-prompt-claude-code.ts
|
|
125675
|
-
import { spawn as
|
|
126222
|
+
import { spawn as spawn4 } from "child_process";
|
|
125676
126223
|
import { mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync4, rmSync as rmSync21, writeFileSync as writeFileSync29 } from "fs";
|
|
125677
126224
|
import { tmpdir as tmpdir3 } from "os";
|
|
125678
|
-
import { join as
|
|
126225
|
+
import { join as join69 } from "path";
|
|
125679
126226
|
function claudeCodePrintArgv(model, systemPromptFile, opts = {}) {
|
|
125680
126227
|
const head = [
|
|
125681
126228
|
PRINT_FLAGS[0],
|
|
@@ -125811,13 +126358,13 @@ async function runPromptViaClaudeCode(model, prompt, systemPrompt, opts = {}) {
|
|
|
125811
126358
|
} catch (e) {
|
|
125812
126359
|
throw new Error(`cannot start claudish (${parentEnv.CLAUDISH_BIN?.trim() || "claudish"}): ${e instanceof Error ? e.message : String(e)}`);
|
|
125813
126360
|
}
|
|
125814
|
-
const root = mkdtempSync4(
|
|
126361
|
+
const root = mkdtempSync4(join69(tmpdir3(), "claudish-run-prompt-"));
|
|
125815
126362
|
try {
|
|
125816
|
-
const cwd =
|
|
126363
|
+
const cwd = join69(root, "cwd");
|
|
125817
126364
|
mkdirSync29(cwd, { mode: 448 });
|
|
125818
126365
|
let systemPromptFile;
|
|
125819
126366
|
if (typeof systemPrompt === "string" && systemPrompt.length > 0) {
|
|
125820
|
-
systemPromptFile =
|
|
126367
|
+
systemPromptFile = join69(root, "system-prompt.txt");
|
|
125821
126368
|
writeFileSync29(systemPromptFile, systemPrompt, { mode: 384 });
|
|
125822
126369
|
}
|
|
125823
126370
|
const argv = claudeCodePrintArgv(model, systemPromptFile, {
|
|
@@ -125855,7 +126402,7 @@ function runChild(launch, argv, cwd, env, prompt, signal) {
|
|
|
125855
126402
|
return new Promise((resolvePromise, reject) => {
|
|
125856
126403
|
let proc;
|
|
125857
126404
|
try {
|
|
125858
|
-
proc =
|
|
126405
|
+
proc = spawn4(launch.command, [...launch.prefixArgs, ...argv], {
|
|
125859
126406
|
cwd,
|
|
125860
126407
|
env,
|
|
125861
126408
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -125928,7 +126475,7 @@ var init_run_prompt_claude_code = __esm(() => {
|
|
|
125928
126475
|
ENV.CLAUDISH_PANE_CHILD
|
|
125929
126476
|
];
|
|
125930
126477
|
inFlight5 = new Set;
|
|
125931
|
-
EMPTY_PRINT_CWD =
|
|
126478
|
+
EMPTY_PRINT_CWD = join69(tmpdir3(), "claudish-run-prompt-settings-check");
|
|
125932
126479
|
});
|
|
125933
126480
|
|
|
125934
126481
|
// src/providers/bundled-list.ts
|
|
@@ -126927,8 +127474,8 @@ var init_view_server = __esm(() => {
|
|
|
126927
127474
|
|
|
126928
127475
|
// src/mcp-server.ts
|
|
126929
127476
|
import { existsSync as existsSync44, readFileSync as readFileSync53, readdirSync as readdirSync17 } from "fs";
|
|
126930
|
-
import { homedir as
|
|
126931
|
-
import { dirname as dirname29, join as
|
|
127477
|
+
import { homedir as homedir41 } from "os";
|
|
127478
|
+
import { dirname as dirname29, join as join70, resolve as resolve12 } from "path";
|
|
126932
127479
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
126933
127480
|
async function loadAllModels(forceRefresh = false) {
|
|
126934
127481
|
if (!forceRefresh && existsSync44(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
@@ -128222,7 +128769,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128222
128769
|
const promptText = () => {
|
|
128223
128770
|
if (input !== undefined)
|
|
128224
128771
|
return input;
|
|
128225
|
-
const existing =
|
|
128772
|
+
const existing = join70(resolved, "input.md");
|
|
128226
128773
|
return existsSync44(existing) ? readFileSync53(existing, "utf-8") : undefined;
|
|
128227
128774
|
};
|
|
128228
128775
|
const choice = await modelChoiceStop([
|
|
@@ -128407,16 +128954,16 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128407
128954
|
const sp = session_path;
|
|
128408
128955
|
for (const file of ["status.json", "manifest.json", "input.md"]) {
|
|
128409
128956
|
try {
|
|
128410
|
-
sessionData[file] = readFileSync53(
|
|
128957
|
+
sessionData[file] = readFileSync53(join70(sp, file), "utf-8");
|
|
128411
128958
|
} catch {}
|
|
128412
128959
|
}
|
|
128413
128960
|
try {
|
|
128414
|
-
const errorDir =
|
|
128961
|
+
const errorDir = join70(sp, "errors");
|
|
128415
128962
|
if (existsSync44(errorDir)) {
|
|
128416
128963
|
for (const f of readdirSync17(errorDir)) {
|
|
128417
128964
|
if (f.endsWith(".log")) {
|
|
128418
128965
|
try {
|
|
128419
|
-
sessionData[`errors/${f}`] = readFileSync53(
|
|
128966
|
+
sessionData[`errors/${f}`] = readFileSync53(join70(errorDir, f), "utf-8");
|
|
128420
128967
|
} catch {}
|
|
128421
128968
|
}
|
|
128422
128969
|
}
|
|
@@ -128426,7 +128973,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128426
128973
|
for (const f of readdirSync17(sp)) {
|
|
128427
128974
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
128428
128975
|
try {
|
|
128429
|
-
const content = readFileSync53(
|
|
128976
|
+
const content = readFileSync53(join70(sp, f), "utf-8");
|
|
128430
128977
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
128431
128978
|
} catch {}
|
|
128432
128979
|
}
|
|
@@ -128435,7 +128982,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128435
128982
|
}
|
|
128436
128983
|
let version = "unknown";
|
|
128437
128984
|
try {
|
|
128438
|
-
const pkgPath =
|
|
128985
|
+
const pkgPath = join70(__dirname3, "../package.json");
|
|
128439
128986
|
if (existsSync44(pkgPath)) {
|
|
128440
128987
|
version = JSON.parse(readFileSync53(pkgPath, "utf-8")).version;
|
|
128441
128988
|
}
|
|
@@ -129240,8 +129787,8 @@ var init_mcp_server = __esm(() => {
|
|
|
129240
129787
|
init_preflight_chain();
|
|
129241
129788
|
__filename3 = fileURLToPath3(import.meta.url);
|
|
129242
129789
|
__dirname3 = dirname29(__filename3);
|
|
129243
|
-
CLAUDISH_CACHE_DIR =
|
|
129244
|
-
OPENROUTER_MODELS_CACHE_PATH =
|
|
129790
|
+
CLAUDISH_CACHE_DIR = join70(homedir41(), ".claudish");
|
|
129791
|
+
OPENROUTER_MODELS_CACHE_PATH = join70(CLAUDISH_CACHE_DIR, "openrouter-models.json");
|
|
129245
129792
|
NEXT_STEP = {
|
|
129246
129793
|
cancelled: "you stopped this slot; nothing is wrong with it. Re-run it if you still want its vote",
|
|
129247
129794
|
timeout: "grid mode only \u2014 magmux ended the pane. The orchestrator has no deadline",
|
|
@@ -129404,8 +129951,8 @@ var HOOKS_AMBIENT_DTS = '// claudish hook types \u2014 written by `claudish hook
|
|
|
129404
129951
|
|
|
129405
129952
|
// src/hooks/observer/corpus.ts
|
|
129406
129953
|
import { appendFileSync as appendFileSync8, readFileSync as readFileSync55, readdirSync as readdirSync18, statSync as statSync29 } from "fs";
|
|
129407
|
-
import { homedir as
|
|
129408
|
-
import { join as
|
|
129954
|
+
import { homedir as homedir42 } from "os";
|
|
129955
|
+
import { join as join71 } from "path";
|
|
129409
129956
|
function directoryOf2(filePath) {
|
|
129410
129957
|
const slash = filePath.lastIndexOf("/");
|
|
129411
129958
|
return slash > 0 ? filePath.slice(0, slash) : undefined;
|
|
@@ -129484,26 +130031,26 @@ function listTranscripts(root) {
|
|
|
129484
130031
|
return files;
|
|
129485
130032
|
}
|
|
129486
130033
|
for (const project of projects) {
|
|
129487
|
-
const dir =
|
|
130034
|
+
const dir = join71(root, project);
|
|
129488
130035
|
try {
|
|
129489
130036
|
if (!statSync29(dir).isDirectory())
|
|
129490
130037
|
continue;
|
|
129491
130038
|
for (const f of readdirSync18(dir)) {
|
|
129492
130039
|
if (f.endsWith(".jsonl"))
|
|
129493
|
-
files.push(
|
|
130040
|
+
files.push(join71(dir, f));
|
|
129494
130041
|
}
|
|
129495
130042
|
} catch {}
|
|
129496
130043
|
}
|
|
129497
130044
|
return files;
|
|
129498
130045
|
}
|
|
129499
130046
|
function buildCorpus(options = {}) {
|
|
129500
|
-
const root = options.projectsRoot ??
|
|
130047
|
+
const root = options.projectsRoot ?? projectsDir(options.env ?? process.env, options.cwd ?? process.cwd());
|
|
129501
130048
|
const files = listTranscripts(root);
|
|
129502
130049
|
const records = [];
|
|
129503
130050
|
for (const f of files)
|
|
129504
130051
|
records.push(...replayTranscript(f));
|
|
129505
130052
|
if (options.write && records.length > 0) {
|
|
129506
|
-
const outputPath = options.outputPath ??
|
|
130053
|
+
const outputPath = options.outputPath ?? join71(homedir42(), ".claudish", "behavior-divergences.jsonl");
|
|
129507
130054
|
try {
|
|
129508
130055
|
appendFileSync8(outputPath, `${records.map((r) => JSON.stringify(r)).join(`
|
|
129509
130056
|
`)}
|
|
@@ -129515,13 +130062,14 @@ function buildCorpus(options = {}) {
|
|
|
129515
130062
|
}
|
|
129516
130063
|
var RULE_ID = "plan-mode/plan-file-path", WRITE_TOOLS;
|
|
129517
130064
|
var init_corpus = __esm(() => {
|
|
130065
|
+
init_session_discovery();
|
|
129518
130066
|
WRITE_TOOLS = new Set(["Write", "Edit", "NotebookEdit"]);
|
|
129519
130067
|
});
|
|
129520
130068
|
|
|
129521
130069
|
// src/hooks-command.ts
|
|
129522
130070
|
import { existsSync as existsSync46, mkdirSync as mkdirSync30, readFileSync as readFileSync56, writeFileSync as writeFileSync30 } from "fs";
|
|
129523
|
-
import { homedir as
|
|
129524
|
-
import { join as
|
|
130071
|
+
import { homedir as homedir43 } from "os";
|
|
130072
|
+
import { join as join72, resolve as resolve13 } from "path";
|
|
129525
130073
|
function severityColor(sev) {
|
|
129526
130074
|
if (sev === "fix")
|
|
129527
130075
|
return green(sev);
|
|
@@ -129644,10 +130192,10 @@ async function check(file, json) {
|
|
|
129644
130192
|
return valid ? 0 : 1;
|
|
129645
130193
|
}
|
|
129646
130194
|
function init(dirArg) {
|
|
129647
|
-
const dir = dirArg ? resolve13(process.cwd(), dirArg) :
|
|
130195
|
+
const dir = dirArg ? resolve13(process.cwd(), dirArg) : join72(homedir43(), ".claudish", "hooks");
|
|
129648
130196
|
const files = [
|
|
129649
|
-
[
|
|
129650
|
-
[
|
|
130197
|
+
[join72(dir, "example-hook.ts"), EXAMPLE_HOOK],
|
|
130198
|
+
[join72(dir, "claudish-hooks.d.ts"), HOOKS_AMBIENT_DTS]
|
|
129651
130199
|
];
|
|
129652
130200
|
const existing = files.filter(([path]) => existsSync46(path)).map(([path]) => path);
|
|
129653
130201
|
if (existing.length > 0) {
|
|
@@ -129847,10 +130395,10 @@ var init_hooks_command = __esm(() => {
|
|
|
129847
130395
|
});
|
|
129848
130396
|
|
|
129849
130397
|
// src/team-grid.ts
|
|
129850
|
-
import { spawn as
|
|
130398
|
+
import { spawn as spawn5 } from "child_process";
|
|
129851
130399
|
import { existsSync as existsSync47, readFileSync as readFileSync57, writeFileSync as writeFileSync31 } from "fs";
|
|
129852
130400
|
import { connect as netConnect3 } from "net";
|
|
129853
|
-
import { join as
|
|
130401
|
+
import { join as join73 } from "path";
|
|
129854
130402
|
import { setTimeout as wait } from "timers/promises";
|
|
129855
130403
|
function paneRouteLine(explanation) {
|
|
129856
130404
|
const origin = describeRouteExplanation(explanation);
|
|
@@ -130000,9 +130548,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
130000
130548
|
const keep = opts?.keep ?? false;
|
|
130001
130549
|
const manifest = setupSession(sessionPath, models, input);
|
|
130002
130550
|
const startedAt = new Date().toISOString();
|
|
130003
|
-
const gridfilePath =
|
|
130004
|
-
const prompt = readFileSync57(
|
|
130005
|
-
const rawPrompt = readFileSync57(
|
|
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");
|
|
130006
130554
|
const usedBannerColors = new Set;
|
|
130007
130555
|
const routeLines = mode === "interactive" ? new Map : await resolvePaneRouteLines(Object.values(manifest.models).map((entry) => entry.model));
|
|
130008
130556
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
@@ -130022,7 +130570,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
130022
130570
|
if (!keep && mode === "default") {
|
|
130023
130571
|
spawnArgs.push("-w");
|
|
130024
130572
|
}
|
|
130025
|
-
const proc =
|
|
130573
|
+
const proc = spawn5(magmuxPath, spawnArgs, {
|
|
130026
130574
|
stdio: "inherit",
|
|
130027
130575
|
env: { ...process.env }
|
|
130028
130576
|
});
|
|
@@ -130034,7 +130582,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
130034
130582
|
});
|
|
130035
130583
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
130036
130584
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
130037
|
-
const statusPath =
|
|
130585
|
+
const statusPath = join73(sessionPath, "status.json");
|
|
130038
130586
|
writeFileSync31(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
130039
130587
|
return status;
|
|
130040
130588
|
}
|
|
@@ -130055,7 +130603,7 @@ var init_team_grid = __esm(() => {
|
|
|
130055
130603
|
|
|
130056
130604
|
// src/team-cli.ts
|
|
130057
130605
|
import { readFileSync as readFileSync58 } from "fs";
|
|
130058
|
-
import { join as
|
|
130606
|
+
import { join as join74 } from "path";
|
|
130059
130607
|
async function runPaneTeam(sessionPath, models, input, opts) {
|
|
130060
130608
|
installPaneShutdownHooks({ exitAfter: true });
|
|
130061
130609
|
try {
|
|
@@ -130200,7 +130748,7 @@ async function teamCommand(args) {
|
|
|
130200
130748
|
}
|
|
130201
130749
|
case "judge": {
|
|
130202
130750
|
await judgeResponses(sessionPath, { judges });
|
|
130203
|
-
console.log(readFileSync58(
|
|
130751
|
+
console.log(readFileSync58(join74(sessionPath, "verdict.md"), "utf-8"));
|
|
130204
130752
|
break;
|
|
130205
130753
|
}
|
|
130206
130754
|
case "run-and-judge": {
|
|
@@ -130216,7 +130764,7 @@ async function teamCommand(args) {
|
|
|
130216
130764
|
});
|
|
130217
130765
|
printStatus(status);
|
|
130218
130766
|
await judgeResponses(sessionPath, { judges });
|
|
130219
|
-
console.log(readFileSync58(
|
|
130767
|
+
console.log(readFileSync58(join74(sessionPath, "verdict.md"), "utf-8"));
|
|
130220
130768
|
break;
|
|
130221
130769
|
}
|
|
130222
130770
|
case "status": {
|
|
@@ -131899,8 +132447,8 @@ var init_view_cli = __esm(() => {
|
|
|
131899
132447
|
// src/herdr/herdr-cli.ts
|
|
131900
132448
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
131901
132449
|
import { copyFileSync as copyFileSync3, existsSync as existsSync48, mkdirSync as mkdirSync31, readdirSync as readdirSync19, renameSync as renameSync14, statSync as statSync30 } from "fs";
|
|
131902
|
-
import { homedir as
|
|
131903
|
-
import { dirname as dirname30, join as
|
|
132450
|
+
import { homedir as homedir44 } from "os";
|
|
132451
|
+
import { dirname as dirname30, join as join75, resolve as resolve14 } from "path";
|
|
131904
132452
|
function spawnHerdrApp(args) {
|
|
131905
132453
|
const r = spawnSync3("herdr-app", args, { encoding: "utf-8", timeout: 1e4 });
|
|
131906
132454
|
if (r.error)
|
|
@@ -131942,8 +132490,8 @@ function showPanelCommand(rest, out, deps) {
|
|
|
131942
132490
|
function findBuiltAppMod(from = import.meta.dir) {
|
|
131943
132491
|
let dir = from;
|
|
131944
132492
|
for (let i = 0;i < 5; i++) {
|
|
131945
|
-
const candidate =
|
|
131946
|
-
if (existsSync48(
|
|
132493
|
+
const candidate = join75(dir, BUILT_MOD_DIR);
|
|
132494
|
+
if (existsSync48(join75(candidate, "main.js")) && existsSync48(join75(candidate, "mod.json")))
|
|
131947
132495
|
return candidate;
|
|
131948
132496
|
const up = dirname30(dir);
|
|
131949
132497
|
if (up === dir)
|
|
@@ -131956,24 +132504,24 @@ function herdrAppHome(env) {
|
|
|
131956
132504
|
const given = env.HERDR_APP_HOME?.trim();
|
|
131957
132505
|
if (given)
|
|
131958
132506
|
return resolve14(given);
|
|
131959
|
-
return
|
|
132507
|
+
return join75(env.HOME?.trim() || homedir44(), ".config", "herdr-app");
|
|
131960
132508
|
}
|
|
131961
132509
|
function isModFile(name) {
|
|
131962
132510
|
return !name.startsWith(".") && name !== "jsconfig.json" && !name.endsWith(".d.ts");
|
|
131963
132511
|
}
|
|
131964
132512
|
function installAppMod(source, appHome) {
|
|
131965
|
-
if (!existsSync48(
|
|
132513
|
+
if (!existsSync48(join75(source, "main.js")) || !existsSync48(join75(source, "mod.json")))
|
|
131966
132514
|
throw new Error(`${source} holds no built mod (main.js and mod.json); run \`bun run build\``);
|
|
131967
132515
|
if (!existsSync48(appHome) || !statSync30(appHome).isDirectory())
|
|
131968
132516
|
throw new Error(`${appHome} does not exist: start Herdr.app once so it creates its home, then run this again`);
|
|
131969
|
-
const dest =
|
|
132517
|
+
const dest = join75(appHome, "mods", APP_MOD_NAME);
|
|
131970
132518
|
mkdirSync31(dest, { recursive: true });
|
|
131971
|
-
const files = readdirSync19(source).filter((f) => isModFile(f) && statSync30(
|
|
132519
|
+
const files = readdirSync19(source).filter((f) => isModFile(f) && statSync30(join75(source, f)).isFile());
|
|
131972
132520
|
files.sort((a, b) => a === "mod.json" ? -1 : b === "mod.json" ? 1 : a.localeCompare(b));
|
|
131973
132521
|
for (const f of files) {
|
|
131974
|
-
const hidden =
|
|
131975
|
-
copyFileSync3(
|
|
131976
|
-
renameSync14(hidden,
|
|
132522
|
+
const hidden = join75(dest, `.${f}.installing`);
|
|
132523
|
+
copyFileSync3(join75(source, f), hidden);
|
|
132524
|
+
renameSync14(hidden, join75(dest, f));
|
|
131977
132525
|
}
|
|
131978
132526
|
return dest;
|
|
131979
132527
|
}
|
|
@@ -132051,7 +132599,7 @@ var init_herdr_cli = __esm(() => {
|
|
|
132051
132599
|
""
|
|
132052
132600
|
].join(`
|
|
132053
132601
|
`);
|
|
132054
|
-
BUILT_MOD_DIR =
|
|
132602
|
+
BUILT_MOD_DIR = join75("herdr-app-mod", APP_MOD_NAME);
|
|
132055
132603
|
});
|
|
132056
132604
|
|
|
132057
132605
|
// src/auth/credentials/source.ts
|
|
@@ -134284,8 +134832,8 @@ var init_account_command = __esm(() => {
|
|
|
134284
134832
|
// src/auth/antigravity-oauth.ts
|
|
134285
134833
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
134286
134834
|
import { existsSync as existsSync49, unlinkSync as unlinkSync14 } from "fs";
|
|
134287
|
-
import { homedir as
|
|
134288
|
-
import { join as
|
|
134835
|
+
import { homedir as homedir45 } from "os";
|
|
134836
|
+
import { join as join76 } from "path";
|
|
134289
134837
|
async function defaultSuggestModel() {
|
|
134290
134838
|
try {
|
|
134291
134839
|
const token = await getValidAntigravityAccessToken();
|
|
@@ -134404,7 +134952,7 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
|
|
|
134404
134952
|
async logout(deps) {
|
|
134405
134953
|
deleteSharedAntigravityToken(deps);
|
|
134406
134954
|
try {
|
|
134407
|
-
const tokenFile =
|
|
134955
|
+
const tokenFile = join76(homedir45(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
|
|
134408
134956
|
if (existsSync49(tokenFile))
|
|
134409
134957
|
unlinkSync14(tokenFile);
|
|
134410
134958
|
} catch {}
|
|
@@ -134437,13 +134985,13 @@ var init_antigravity_oauth = __esm(() => {
|
|
|
134437
134985
|
});
|
|
134438
134986
|
|
|
134439
134987
|
// src/auth/meta-muse-oauth.ts
|
|
134440
|
-
import { execFile as
|
|
134988
|
+
import { execFile as execFile5 } from "child_process";
|
|
134441
134989
|
function openInBrowser(url) {
|
|
134442
134990
|
if (!/^https:\/\//i.test(url))
|
|
134443
134991
|
return Promise.resolve();
|
|
134444
134992
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
|
|
134445
134993
|
return new Promise((resolve) => {
|
|
134446
|
-
|
|
134994
|
+
execFile5(command, [url], () => resolve());
|
|
134447
134995
|
});
|
|
134448
134996
|
}
|
|
134449
134997
|
function describe2(answer, status) {
|
|
@@ -137980,6 +138528,8 @@ function resolveProviderDetailKeyDisplay(input) {
|
|
|
137980
138528
|
return input.isReady ? "enabled" : "disabled";
|
|
137981
138529
|
if (input.authSource === "oauth")
|
|
137982
138530
|
return "oauth";
|
|
138531
|
+
if (input.replacementKeyMask)
|
|
138532
|
+
return input.replacementKeyMask;
|
|
137983
138533
|
if (input.hasEnvKey)
|
|
137984
138534
|
return input.envKeyMask;
|
|
137985
138535
|
if (input.hasCfgKey)
|
|
@@ -137991,6 +138541,38 @@ function resolveProviderDetailKeyDisplay(input) {
|
|
|
137991
138541
|
function vaultLabel(source) {
|
|
137992
138542
|
return source === "macOS Keychain" ? "keychain" : "1Password";
|
|
137993
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
|
+
}
|
|
137994
138576
|
function validTestNote(input) {
|
|
137995
138577
|
if (input.isLocal)
|
|
137996
138578
|
return " Local provider responded through the shared probe path.";
|
|
@@ -138011,6 +138593,8 @@ function ProviderDetail({
|
|
|
138011
138593
|
hasKcKey,
|
|
138012
138594
|
vaultKeySource,
|
|
138013
138595
|
vaultKeyMask,
|
|
138596
|
+
replacementKeyMask,
|
|
138597
|
+
replacementKeySource,
|
|
138014
138598
|
keySaveTarget,
|
|
138015
138599
|
credentialNote,
|
|
138016
138600
|
cfgKeyMask,
|
|
@@ -138029,7 +138613,17 @@ function ProviderDetail({
|
|
|
138029
138613
|
envKeyMask,
|
|
138030
138614
|
cfgKeyMask,
|
|
138031
138615
|
...vaultKeySource ? { vaultKeySource } : {},
|
|
138032
|
-
...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 } : {}
|
|
138033
138627
|
});
|
|
138034
138628
|
if (isInputMode) {
|
|
138035
138629
|
return /* @__PURE__ */ jsxDEV22("box", {
|
|
@@ -138224,53 +138818,23 @@ function ProviderDetail({
|
|
|
138224
138818
|
attributes: A.bold,
|
|
138225
138819
|
children: "From: "
|
|
138226
138820
|
}, undefined, false, undefined, this),
|
|
138227
|
-
|
|
138228
|
-
|
|
138229
|
-
attributes: A.bold,
|
|
138230
|
-
children: isKcKey ? "keychain" : isOpKey ? "1Password" : "env"
|
|
138231
|
-
}, undefined, false, undefined, this),
|
|
138232
|
-
hasEnvKey && hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
|
|
138233
|
-
fg: C.fgMuted,
|
|
138234
|
-
children: " (used) + "
|
|
138235
|
-
}, undefined, false, undefined, this),
|
|
138236
|
-
hasEnvKey && !hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
|
|
138237
|
-
fg: C.fgMuted,
|
|
138238
|
-
children: " (used)"
|
|
138239
|
-
}, undefined, false, undefined, this),
|
|
138240
|
-
hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
|
|
138241
|
-
fg: hasEnvKey ? C.fgMuted : C.green,
|
|
138242
|
-
attributes: A.boldIf(!hasEnvKey),
|
|
138243
|
-
children: "config"
|
|
138244
|
-
}, undefined, false, undefined, this),
|
|
138245
|
-
hasCfgKey && /* @__PURE__ */ jsxDEV22("span", {
|
|
138246
|
-
fg: C.fgMuted,
|
|
138247
|
-
children: hasEnvKey ? " (shadowed)" : " (used)"
|
|
138248
|
-
}, undefined, false, undefined, this),
|
|
138249
|
-
vaultKeySource && /* @__PURE__ */ jsxDEV22(Fragment12, {
|
|
138250
|
-
children: [
|
|
138251
|
-
/* @__PURE__ */ jsxDEV22("span", {
|
|
138252
|
-
fg: C.green,
|
|
138253
|
-
attributes: A.bold,
|
|
138254
|
-
children: vaultLabel(vaultKeySource)
|
|
138255
|
-
}, undefined, false, undefined, this),
|
|
138256
|
-
/* @__PURE__ */ jsxDEV22("span", {
|
|
138257
|
-
fg: C.fgMuted,
|
|
138258
|
-
children: " (used)"
|
|
138259
|
-
}, undefined, false, undefined, this)
|
|
138260
|
-
]
|
|
138261
|
-
}, undefined, true, undefined, this),
|
|
138262
|
-
hasKcKey && !isKcKey && vaultKeySource !== "macOS Keychain" && /* @__PURE__ */ jsxDEV22(Fragment12, {
|
|
138263
|
-
children: [
|
|
138821
|
+
fromSources.flatMap((source, i) => [
|
|
138822
|
+
...i > 0 ? [
|
|
138264
138823
|
/* @__PURE__ */ jsxDEV22("span", {
|
|
138265
138824
|
fg: C.fgMuted,
|
|
138266
138825
|
children: " + "
|
|
138267
|
-
},
|
|
138268
|
-
|
|
138269
|
-
|
|
138270
|
-
|
|
138271
|
-
|
|
138272
|
-
|
|
138273
|
-
|
|
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
|
+
])
|
|
138274
138838
|
]
|
|
138275
138839
|
}, undefined, true, undefined, this)
|
|
138276
138840
|
]
|
|
@@ -139867,6 +140431,9 @@ var init_TabBar = __esm(() => {
|
|
|
139867
140431
|
});
|
|
139868
140432
|
|
|
139869
140433
|
// src/tui/config-save.ts
|
|
140434
|
+
function invalidateAfterKeychainCopy(outcome) {
|
|
140435
|
+
credentials.invalidateKeyVars(outcome.written);
|
|
140436
|
+
}
|
|
139870
140437
|
function configSaveFailure(err) {
|
|
139871
140438
|
const detail = err instanceof Error ? err.message : String(err);
|
|
139872
140439
|
return `Not saved \u2014 ${detail}`;
|
|
@@ -139875,15 +140442,24 @@ function configKeySavedStatus(displayName, envVar, note, keychainFailure) {
|
|
|
139875
140442
|
return keychainFailure === undefined ? `Key saved for ${displayName} (${envVar}).${note}` : `Keychain write failed (${keychainFailure}) \u2014 saved to config.json instead.${note}`;
|
|
139876
140443
|
}
|
|
139877
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;
|
|
139878
140447
|
const where = [];
|
|
139879
|
-
|
|
139880
|
-
|
|
139881
|
-
|
|
139882
|
-
|
|
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`);
|
|
139883
140454
|
if (where.length === 0)
|
|
139884
140455
|
return "";
|
|
139885
|
-
|
|
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.`;
|
|
139886
140458
|
}
|
|
140459
|
+
var init_config_save = __esm(() => {
|
|
140460
|
+
init_authority();
|
|
140461
|
+
init_key_sources();
|
|
140462
|
+
});
|
|
139887
140463
|
|
|
139888
140464
|
// src/tui/hooks/useProfileWizard.ts
|
|
139889
140465
|
import { useCallback as useCallback2, useState as useState9 } from "react";
|
|
@@ -140236,6 +140812,7 @@ function useProfileWizard(args) {
|
|
|
140236
140812
|
var FIELDS, FIELD_TO_MODE, MODE_TO_FIELD;
|
|
140237
140813
|
var init_useProfileWizard = __esm(() => {
|
|
140238
140814
|
init_profile_config();
|
|
140815
|
+
init_config_save();
|
|
140239
140816
|
init_constants4();
|
|
140240
140817
|
FIELDS = ["opus", "sonnet", "haiku", "subagent"];
|
|
140241
140818
|
FIELD_TO_MODE = {
|
|
@@ -140658,12 +141235,13 @@ async function resolveOpEntrySecrets(entries, auth) {
|
|
|
140658
141235
|
return secrets;
|
|
140659
141236
|
}
|
|
140660
141237
|
function writeSecretsToKeychain(secrets, alreadyStored) {
|
|
140661
|
-
const outcome = { created: 0, replaced: 0, skipped: [] };
|
|
141238
|
+
const outcome = { created: 0, replaced: 0, skipped: [], written: [] };
|
|
140662
141239
|
for (const [name, value] of Object.entries(secrets)) {
|
|
140663
141240
|
if (!value)
|
|
140664
141241
|
continue;
|
|
140665
141242
|
try {
|
|
140666
141243
|
writeKeychainSecret(name, value);
|
|
141244
|
+
outcome.written.push(name);
|
|
140667
141245
|
if (alreadyStored.has(name))
|
|
140668
141246
|
outcome.replaced++;
|
|
140669
141247
|
else
|
|
@@ -140849,6 +141427,9 @@ function App({ requestLogin } = {}) {
|
|
|
140849
141427
|
const isKcKey = hasEnvKey && isKeychainHydratedVar(selectedProvider.apiKeyEnvVar);
|
|
140850
141428
|
const vaultKeySource = hasKey && !hasEnvKey && !hasCfgKey ? readAtUseVaultSource(selectedProvider) : undefined;
|
|
140851
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;
|
|
140852
141433
|
const cfgKeyMask = maskKey2(config.apiKeys?.[selectedProvider.apiKeyEnvVar]);
|
|
140853
141434
|
const envKeyMask = maskKey2(process.env[selectedProvider.apiKeyEnvVar]);
|
|
140854
141435
|
const activeEndpointEnvVar = selectedProvider.endpointEnvVar;
|
|
@@ -141030,7 +141611,7 @@ function App({ requestLogin } = {}) {
|
|
|
141030
141611
|
if (outcome.created + outcome.replaced > 0) {
|
|
141031
141612
|
setKeychainEnabled(true);
|
|
141032
141613
|
refreshKeychainVars();
|
|
141033
|
-
|
|
141614
|
+
invalidateAfterKeychainCopy(outcome);
|
|
141034
141615
|
invalidateProbeProxyHandlers();
|
|
141035
141616
|
refreshConfig();
|
|
141036
141617
|
}
|
|
@@ -142405,6 +142986,8 @@ function App({ requestLogin } = {}) {
|
|
|
142405
142986
|
hasKcKey,
|
|
142406
142987
|
...vaultKeySource ? { vaultKeySource } : {},
|
|
142407
142988
|
...vaultKeyMask ? { vaultKeyMask } : {},
|
|
142989
|
+
...replacementKeyMask ? { replacementKeyMask } : {},
|
|
142990
|
+
...replacementKeySource ? { replacementKeySource } : {},
|
|
142408
142991
|
keySaveTarget: keychainSupported ? "macOS Keychain" : "config.json",
|
|
142409
142992
|
credentialNote: providerCredentialNote(selectedProvider),
|
|
142410
142993
|
cfgKeyMask,
|
|
@@ -142567,6 +143150,7 @@ var init_App = __esm(() => {
|
|
|
142567
143150
|
init_RoutingContent();
|
|
142568
143151
|
init_RoutingDetail();
|
|
142569
143152
|
init_TabBar();
|
|
143153
|
+
init_config_save();
|
|
142570
143154
|
init_constants4();
|
|
142571
143155
|
init_useProfileWizard();
|
|
142572
143156
|
init_useRouteProbe();
|
|
@@ -143275,17 +143859,17 @@ var init_model_lineup = __esm(() => {
|
|
|
143275
143859
|
|
|
143276
143860
|
// src/diag-output.ts
|
|
143277
143861
|
import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync32, unlinkSync as unlinkSync15, writeFileSync as writeFileSync32 } from "fs";
|
|
143278
|
-
import { homedir as
|
|
143279
|
-
import { join as
|
|
143862
|
+
import { homedir as homedir46 } from "os";
|
|
143863
|
+
import { join as join77 } from "path";
|
|
143280
143864
|
function getClaudishDir() {
|
|
143281
|
-
const dir =
|
|
143865
|
+
const dir = join77(homedir46(), ".claudish");
|
|
143282
143866
|
try {
|
|
143283
143867
|
mkdirSync32(dir, { recursive: true });
|
|
143284
143868
|
} catch {}
|
|
143285
143869
|
return dir;
|
|
143286
143870
|
}
|
|
143287
143871
|
function getDiagLogPath() {
|
|
143288
|
-
return
|
|
143872
|
+
return join77(getClaudishDir(), `diag-${process.pid}.log`);
|
|
143289
143873
|
}
|
|
143290
143874
|
|
|
143291
143875
|
class LogFileDiagOutput {
|
|
@@ -145376,11 +145960,11 @@ var init_resume_picker_run = __esm(() => {
|
|
|
145376
145960
|
});
|
|
145377
145961
|
|
|
145378
145962
|
// src/launcher/model-setting-ledger-path.ts
|
|
145379
|
-
import { homedir as
|
|
145380
|
-
import { join as
|
|
145963
|
+
import { homedir as homedir47 } from "os";
|
|
145964
|
+
import { join as join78 } from "path";
|
|
145381
145965
|
function modelSettingLedgerPath(env = process.env) {
|
|
145382
|
-
const home = env.HOME && env.HOME.length > 0 ? env.HOME :
|
|
145383
|
-
return
|
|
145966
|
+
const home = env.HOME && env.HOME.length > 0 ? env.HOME : homedir47();
|
|
145967
|
+
return join78(home, ".claudish", MODEL_SETTING_LEDGER_FILE);
|
|
145384
145968
|
}
|
|
145385
145969
|
var MODEL_SETTING_LEDGER_FILE = "model-setting-restore.json";
|
|
145386
145970
|
var init_model_setting_ledger_path = () => {};
|
|
@@ -145401,18 +145985,18 @@ import {
|
|
|
145401
145985
|
unlinkSync as unlinkSync16,
|
|
145402
145986
|
writeSync as writeSync8
|
|
145403
145987
|
} from "fs";
|
|
145404
|
-
import { homedir as
|
|
145405
|
-
import { basename as basename10, dirname as dirname31, join as
|
|
145988
|
+
import { homedir as homedir48 } from "os";
|
|
145989
|
+
import { basename as basename10, dirname as dirname31, join as join79, resolve as resolve15 } from "path";
|
|
145406
145990
|
function canonicalSettingsPath(path) {
|
|
145407
145991
|
let head = resolve15(path);
|
|
145408
145992
|
const rest = [];
|
|
145409
145993
|
for (;; ) {
|
|
145410
145994
|
try {
|
|
145411
|
-
return
|
|
145995
|
+
return join79(realpathSync12.native(head), ...rest);
|
|
145412
145996
|
} catch {
|
|
145413
145997
|
const parent = dirname31(head);
|
|
145414
145998
|
if (parent === head)
|
|
145415
|
-
return
|
|
145999
|
+
return join79(head, ...rest);
|
|
145416
146000
|
rest.unshift(basename10(head));
|
|
145417
146001
|
head = parent;
|
|
145418
146002
|
}
|
|
@@ -145508,7 +146092,7 @@ function restoreRound(settingsKey, target, entry, deps, fence) {
|
|
|
145508
146092
|
const planned = nextSettingsText(text, entry);
|
|
145509
146093
|
if ("outcome" in planned)
|
|
145510
146094
|
return planned.outcome;
|
|
145511
|
-
const temp =
|
|
146095
|
+
const temp = join79(dirname31(target), `${TEMP_PREFIX}${deps.pid ?? process.pid}-${randomUUID12()}`);
|
|
145512
146096
|
try {
|
|
145513
146097
|
deps.writeNew(temp, planned.next, statA.mode & 4095);
|
|
145514
146098
|
} catch {
|
|
@@ -145700,7 +146284,7 @@ function removeOrphanTemps(ctx, key, table) {
|
|
|
145700
146284
|
if (live)
|
|
145701
146285
|
continue;
|
|
145702
146286
|
try {
|
|
145703
|
-
unlinkSync16(
|
|
146287
|
+
unlinkSync16(join79(dir, name));
|
|
145704
146288
|
} catch {}
|
|
145705
146289
|
}
|
|
145706
146290
|
}
|
|
@@ -145791,7 +146375,7 @@ function selfStartEpochMs() {
|
|
|
145791
146375
|
async function beginModelSettingWatch(listedSpecs, deps = {}) {
|
|
145792
146376
|
const ctx = contextOf(deps);
|
|
145793
146377
|
const env = deps.env ?? process.env;
|
|
145794
|
-
const settingsFile = deps.settingsFile ?? userSettingsFile(env.CLAUDE_CONFIG_DIR, env.HOME && env.HOME.length > 0 ? env.HOME :
|
|
146378
|
+
const settingsFile = deps.settingsFile ?? userSettingsFile(env.CLAUDE_CONFIG_DIR, env.HOME && env.HOME.length > 0 ? env.HOME : homedir48(), deps.cwd ?? process.cwd());
|
|
145795
146379
|
const key = canonicalSettingsPath(settingsFile);
|
|
145796
146380
|
const lockPath = lockPathOf(ctx.ledgerPath);
|
|
145797
146381
|
const lockOpts = {
|
|
@@ -146407,7 +146991,7 @@ init_op_source();
|
|
|
146407
146991
|
init_startup_trace();
|
|
146408
146992
|
init_picker_cancelled();
|
|
146409
146993
|
import { existsSync as existsSync50, readFileSync as readFileSync61 } from "fs";
|
|
146410
|
-
import { join as
|
|
146994
|
+
import { join as join80, resolve as resolve16 } from "path";
|
|
146411
146995
|
|
|
146412
146996
|
// src/tui/runtime/should-open-picker.ts
|
|
146413
146997
|
function noModelConfigured(gate) {
|
|
@@ -146424,7 +147008,7 @@ function requiresExplicitModel(gate, tty) {
|
|
|
146424
147008
|
var autoloadDropped = [...droppedAtLaunch, ...takeLauncherDropped(process.env)];
|
|
146425
147009
|
var dotenvText;
|
|
146426
147010
|
try {
|
|
146427
|
-
dotenvText = readFileSync61(
|
|
147011
|
+
dotenvText = readFileSync61(join80(process.cwd(), ".env"));
|
|
146428
147012
|
} catch {}
|
|
146429
147013
|
if (dotenvText !== undefined) {
|
|
146430
147014
|
await Promise.resolve().then(() => init_dotenv_allowlist());
|
|
@@ -146830,7 +147414,7 @@ async function runCli() {
|
|
|
146830
147414
|
process.exit(1);
|
|
146831
147415
|
}
|
|
146832
147416
|
const mode = cliConfig.teamMode ?? "default";
|
|
146833
|
-
const sessionPath =
|
|
147417
|
+
const sessionPath = join80(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
146834
147418
|
if (mode === "json") {
|
|
146835
147419
|
await Promise.resolve().then(() => init_pane());
|
|
146836
147420
|
await Promise.resolve().then(() => init_team_orchestrator());
|
|
@@ -146850,7 +147434,7 @@ async function runCli() {
|
|
|
146850
147434
|
const status = await runModels(sessionPath);
|
|
146851
147435
|
const result = { ...status, responses: {} };
|
|
146852
147436
|
for (const anonId of Object.keys(status.models)) {
|
|
146853
|
-
const responsePath =
|
|
147437
|
+
const responsePath = join80(sessionPath, `response-${anonId}.md`);
|
|
146854
147438
|
try {
|
|
146855
147439
|
const raw = readFileSync61(responsePath, "utf-8").trim();
|
|
146856
147440
|
try {
|