@hasna/switcher 0.2.18 → 0.2.20
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/Dockerfile +6 -1
- package/README.md +1 -1
- package/dist/claude-desktop.js +19182 -3734
- package/dist/claude-user-settings.d.ts +7 -2
- package/dist/cli/index.js +771 -364
- package/dist/codex-state-bridge.js +4 -4
- package/dist/credentials.d.ts +36 -184
- package/dist/domain.d.ts +271 -737
- package/dist/gateway-service.d.ts +3 -1
- package/dist/harnesses.d.ts +8 -0
- package/dist/index.js +19188 -3689
- package/dist/inference-gateway.d.ts +2 -0
- package/dist/launcher.d.ts +34 -0
- package/dist/mcp/index.js +19684 -4137
- package/dist/model-policy-schema.d.ts +93 -112
- package/dist/native-state.d.ts +11 -1
- package/dist/opencode2-config.d.ts +8 -12
- package/dist/presets.d.ts +2 -2
- package/dist/private-directory.d.ts +3 -0
- package/dist/process-table.d.ts +7 -0
- package/dist/reasoning.d.ts +11 -2
- package/dist/runtime.d.ts +1 -1
- package/dist/sdk.js +19188 -3689
- package/dist/serve/index.js +269 -223
- package/docs/GATEWAY-SERVICE.md +66 -30
- package/hasna.contract.json +1 -1
- package/openapi.json +264 -218
- package/package.json +9 -6
package/dist/cli/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function childEnvironment(env = process.env) {
|
|
|
26
26
|
// src/kilo-config.ts
|
|
27
27
|
import { parse, parseTree } from "jsonc-parser";
|
|
28
28
|
import { parseDocument } from "yaml";
|
|
29
|
-
import { z } from "zod";
|
|
29
|
+
import { z } from "zod-v4";
|
|
30
30
|
var object = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
31
31
|
var own = (v, k) => Object.hasOwn(v, k);
|
|
32
32
|
var maxFileBytes = 1024 * 1024;
|
|
@@ -448,10 +448,10 @@ function kiloConfigText(config, providerID, keyEnv) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// src/domain.ts
|
|
451
|
-
import { z as z4 } from "zod";
|
|
451
|
+
import { z as z4 } from "zod-v4";
|
|
452
452
|
|
|
453
453
|
// src/reasoning.ts
|
|
454
|
-
import { z as z2 } from "zod";
|
|
454
|
+
import { z as z2 } from "zod-v4";
|
|
455
455
|
var reasoningEffortSchema = z2.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
456
456
|
function codexReasoning(model, baseUrl, selected) {
|
|
457
457
|
const deepseek = new URL(baseUrl).hostname === "api.deepseek.com" && /^deepseek-(flash|v4-(flash|pro)(-.+)?)$/.test(model.id);
|
|
@@ -465,7 +465,7 @@ function codexReasoning(model, baseUrl, selected) {
|
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
// src/model-policy-schema.ts
|
|
468
|
-
import { z as z3 } from "zod";
|
|
468
|
+
import { z as z3 } from "zod-v4";
|
|
469
469
|
var policyModelIdSchema = z3.string().min(1).max(300).regex(/^[^\u0000-\u001f\u007f]+$/);
|
|
470
470
|
var modelPolicyRoleSchema = z3.enum(["subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"]);
|
|
471
471
|
var boundedModelList = z3.array(policyModelIdSchema).max(500);
|
|
@@ -514,7 +514,7 @@ function canonicalPolicyJSON(value) {
|
|
|
514
514
|
return JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
|
|
515
515
|
}
|
|
516
516
|
// package.json
|
|
517
|
-
var version = "0.2.
|
|
517
|
+
var version = "0.2.20";
|
|
518
518
|
|
|
519
519
|
// src/version.ts
|
|
520
520
|
var VERSION = version;
|
|
@@ -2129,7 +2129,7 @@ class Store {
|
|
|
2129
2129
|
// src/service.ts
|
|
2130
2130
|
import { createHash as createHash4, timingSafeEqual } from "crypto";
|
|
2131
2131
|
import { verifyApiKey } from "@hasna/contracts/auth";
|
|
2132
|
-
import { z as z5 } from "zod";
|
|
2132
|
+
import { z as z5 } from "zod-v4";
|
|
2133
2133
|
|
|
2134
2134
|
// src/auth.ts
|
|
2135
2135
|
function authHeader(style, credential) {
|
|
@@ -2570,7 +2570,7 @@ var openapi_default = {
|
|
|
2570
2570
|
openapi: "3.0.3",
|
|
2571
2571
|
info: {
|
|
2572
2572
|
title: "Switcher API",
|
|
2573
|
-
version: "0.2.
|
|
2573
|
+
version: "0.2.20",
|
|
2574
2574
|
description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
|
|
2575
2575
|
},
|
|
2576
2576
|
security: [
|
|
@@ -3881,6 +3881,7 @@ var openapi_default = {
|
|
|
3881
3881
|
}
|
|
3882
3882
|
},
|
|
3883
3883
|
protocols: {
|
|
3884
|
+
minItems: 1,
|
|
3884
3885
|
type: "array",
|
|
3885
3886
|
items: {
|
|
3886
3887
|
type: "object",
|
|
@@ -3910,12 +3911,12 @@ var openapi_default = {
|
|
|
3910
3911
|
type: "object",
|
|
3911
3912
|
properties: {
|
|
3912
3913
|
method: {
|
|
3914
|
+
default: "GET",
|
|
3913
3915
|
type: "string",
|
|
3914
3916
|
enum: [
|
|
3915
3917
|
"GET",
|
|
3916
3918
|
"HEAD"
|
|
3917
|
-
]
|
|
3918
|
-
default: "GET"
|
|
3919
|
+
]
|
|
3919
3920
|
},
|
|
3920
3921
|
path: {
|
|
3921
3922
|
type: "string",
|
|
@@ -3973,8 +3974,7 @@ var openapi_default = {
|
|
|
3973
3974
|
"notes"
|
|
3974
3975
|
],
|
|
3975
3976
|
additionalProperties: false
|
|
3976
|
-
}
|
|
3977
|
-
minItems: 1
|
|
3977
|
+
}
|
|
3978
3978
|
},
|
|
3979
3979
|
sources: {
|
|
3980
3980
|
type: "array",
|
|
@@ -4030,24 +4030,24 @@ var openapi_default = {
|
|
|
4030
4030
|
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
4031
4031
|
},
|
|
4032
4032
|
authStyle: {
|
|
4033
|
+
default: "bearer",
|
|
4033
4034
|
type: "string",
|
|
4034
4035
|
enum: [
|
|
4035
4036
|
"bearer",
|
|
4036
4037
|
"x-api-key",
|
|
4037
4038
|
"api-key"
|
|
4038
|
-
]
|
|
4039
|
-
default: "bearer"
|
|
4039
|
+
]
|
|
4040
4040
|
},
|
|
4041
4041
|
credentialCheck: {
|
|
4042
4042
|
type: "object",
|
|
4043
4043
|
properties: {
|
|
4044
4044
|
method: {
|
|
4045
|
+
default: "GET",
|
|
4045
4046
|
type: "string",
|
|
4046
4047
|
enum: [
|
|
4047
4048
|
"GET",
|
|
4048
4049
|
"HEAD"
|
|
4049
|
-
]
|
|
4050
|
-
default: "GET"
|
|
4050
|
+
]
|
|
4051
4051
|
},
|
|
4052
4052
|
path: {
|
|
4053
4053
|
type: "string",
|
|
@@ -4096,12 +4096,14 @@ var openapi_default = {
|
|
|
4096
4096
|
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
|
4097
4097
|
},
|
|
4098
4098
|
modelsPath: {
|
|
4099
|
+
default: "models",
|
|
4099
4100
|
type: "string",
|
|
4100
|
-
pattern: "^[a-zA-Z0-9_/-]+$",
|
|
4101
4101
|
maxLength: 200,
|
|
4102
|
-
|
|
4102
|
+
pattern: "^[a-zA-Z0-9_/-]+$"
|
|
4103
4103
|
},
|
|
4104
4104
|
manualModels: {
|
|
4105
|
+
default: [],
|
|
4106
|
+
maxItems: 1e4,
|
|
4105
4107
|
type: "array",
|
|
4106
4108
|
items: {
|
|
4107
4109
|
type: "object",
|
|
@@ -4129,39 +4131,42 @@ var openapi_default = {
|
|
|
4129
4131
|
},
|
|
4130
4132
|
contextWindow: {
|
|
4131
4133
|
type: "integer",
|
|
4134
|
+
minimum: 0,
|
|
4132
4135
|
exclusiveMinimum: true,
|
|
4133
|
-
|
|
4136
|
+
maximum: 9007199254740991
|
|
4134
4137
|
},
|
|
4135
4138
|
maxOutputTokens: {
|
|
4136
4139
|
type: "integer",
|
|
4140
|
+
minimum: 0,
|
|
4137
4141
|
exclusiveMinimum: true,
|
|
4138
|
-
|
|
4142
|
+
maximum: 9007199254740991
|
|
4139
4143
|
},
|
|
4140
4144
|
inputModalities: {
|
|
4145
|
+
maxItems: 20,
|
|
4141
4146
|
type: "array",
|
|
4142
4147
|
items: {
|
|
4143
4148
|
type: "string",
|
|
4144
4149
|
maxLength: 50
|
|
4145
|
-
}
|
|
4146
|
-
maxItems: 20
|
|
4150
|
+
}
|
|
4147
4151
|
},
|
|
4148
4152
|
outputModalities: {
|
|
4153
|
+
maxItems: 20,
|
|
4149
4154
|
type: "array",
|
|
4150
4155
|
items: {
|
|
4151
4156
|
type: "string",
|
|
4152
4157
|
maxLength: 50
|
|
4153
|
-
}
|
|
4154
|
-
maxItems: 20
|
|
4158
|
+
}
|
|
4155
4159
|
},
|
|
4156
4160
|
supportedParameters: {
|
|
4161
|
+
maxItems: 100,
|
|
4157
4162
|
type: "array",
|
|
4158
4163
|
items: {
|
|
4159
4164
|
type: "string",
|
|
4160
4165
|
maxLength: 100
|
|
4161
|
-
}
|
|
4162
|
-
maxItems: 100
|
|
4166
|
+
}
|
|
4163
4167
|
},
|
|
4164
4168
|
reasoningEfforts: {
|
|
4169
|
+
maxItems: 8,
|
|
4165
4170
|
type: "array",
|
|
4166
4171
|
items: {
|
|
4167
4172
|
type: "string",
|
|
@@ -4175,17 +4180,16 @@ var openapi_default = {
|
|
|
4175
4180
|
"max",
|
|
4176
4181
|
"ultra"
|
|
4177
4182
|
]
|
|
4178
|
-
}
|
|
4179
|
-
maxItems: 8
|
|
4183
|
+
}
|
|
4180
4184
|
},
|
|
4181
4185
|
supportedGenerationMethods: {
|
|
4186
|
+
maxItems: 100,
|
|
4182
4187
|
type: "array",
|
|
4183
4188
|
items: {
|
|
4184
4189
|
type: "string",
|
|
4185
4190
|
minLength: 1,
|
|
4186
4191
|
maxLength: 100
|
|
4187
|
-
}
|
|
4188
|
-
maxItems: 100
|
|
4192
|
+
}
|
|
4189
4193
|
}
|
|
4190
4194
|
},
|
|
4191
4195
|
required: [
|
|
@@ -4193,11 +4197,10 @@ var openapi_default = {
|
|
|
4193
4197
|
"name"
|
|
4194
4198
|
],
|
|
4195
4199
|
additionalProperties: false
|
|
4196
|
-
}
|
|
4197
|
-
maxItems: 1e4,
|
|
4198
|
-
default: []
|
|
4200
|
+
}
|
|
4199
4201
|
},
|
|
4200
4202
|
additionalModels: {
|
|
4203
|
+
maxItems: 1e4,
|
|
4201
4204
|
type: "array",
|
|
4202
4205
|
items: {
|
|
4203
4206
|
type: "object",
|
|
@@ -4225,39 +4228,42 @@ var openapi_default = {
|
|
|
4225
4228
|
},
|
|
4226
4229
|
contextWindow: {
|
|
4227
4230
|
type: "integer",
|
|
4231
|
+
minimum: 0,
|
|
4228
4232
|
exclusiveMinimum: true,
|
|
4229
|
-
|
|
4233
|
+
maximum: 9007199254740991
|
|
4230
4234
|
},
|
|
4231
4235
|
maxOutputTokens: {
|
|
4232
4236
|
type: "integer",
|
|
4237
|
+
minimum: 0,
|
|
4233
4238
|
exclusiveMinimum: true,
|
|
4234
|
-
|
|
4239
|
+
maximum: 9007199254740991
|
|
4235
4240
|
},
|
|
4236
4241
|
inputModalities: {
|
|
4242
|
+
maxItems: 20,
|
|
4237
4243
|
type: "array",
|
|
4238
4244
|
items: {
|
|
4239
4245
|
type: "string",
|
|
4240
4246
|
maxLength: 50
|
|
4241
|
-
}
|
|
4242
|
-
maxItems: 20
|
|
4247
|
+
}
|
|
4243
4248
|
},
|
|
4244
4249
|
outputModalities: {
|
|
4250
|
+
maxItems: 20,
|
|
4245
4251
|
type: "array",
|
|
4246
4252
|
items: {
|
|
4247
4253
|
type: "string",
|
|
4248
4254
|
maxLength: 50
|
|
4249
|
-
}
|
|
4250
|
-
maxItems: 20
|
|
4255
|
+
}
|
|
4251
4256
|
},
|
|
4252
4257
|
supportedParameters: {
|
|
4258
|
+
maxItems: 100,
|
|
4253
4259
|
type: "array",
|
|
4254
4260
|
items: {
|
|
4255
4261
|
type: "string",
|
|
4256
4262
|
maxLength: 100
|
|
4257
|
-
}
|
|
4258
|
-
maxItems: 100
|
|
4263
|
+
}
|
|
4259
4264
|
},
|
|
4260
4265
|
reasoningEfforts: {
|
|
4266
|
+
maxItems: 8,
|
|
4261
4267
|
type: "array",
|
|
4262
4268
|
items: {
|
|
4263
4269
|
type: "string",
|
|
@@ -4271,17 +4277,16 @@ var openapi_default = {
|
|
|
4271
4277
|
"max",
|
|
4272
4278
|
"ultra"
|
|
4273
4279
|
]
|
|
4274
|
-
}
|
|
4275
|
-
maxItems: 8
|
|
4280
|
+
}
|
|
4276
4281
|
},
|
|
4277
4282
|
supportedGenerationMethods: {
|
|
4283
|
+
maxItems: 100,
|
|
4278
4284
|
type: "array",
|
|
4279
4285
|
items: {
|
|
4280
4286
|
type: "string",
|
|
4281
4287
|
minLength: 1,
|
|
4282
4288
|
maxLength: 100
|
|
4283
|
-
}
|
|
4284
|
-
maxItems: 100
|
|
4289
|
+
}
|
|
4285
4290
|
}
|
|
4286
4291
|
},
|
|
4287
4292
|
required: [
|
|
@@ -4289,8 +4294,7 @@ var openapi_default = {
|
|
|
4289
4294
|
"name"
|
|
4290
4295
|
],
|
|
4291
4296
|
additionalProperties: false
|
|
4292
|
-
}
|
|
4293
|
-
maxItems: 1e4
|
|
4297
|
+
}
|
|
4294
4298
|
}
|
|
4295
4299
|
},
|
|
4296
4300
|
required: [
|
|
@@ -4331,24 +4335,24 @@ var openapi_default = {
|
|
|
4331
4335
|
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
4332
4336
|
},
|
|
4333
4337
|
authStyle: {
|
|
4338
|
+
default: "bearer",
|
|
4334
4339
|
type: "string",
|
|
4335
4340
|
enum: [
|
|
4336
4341
|
"bearer",
|
|
4337
4342
|
"x-api-key",
|
|
4338
4343
|
"api-key"
|
|
4339
|
-
]
|
|
4340
|
-
default: "bearer"
|
|
4344
|
+
]
|
|
4341
4345
|
},
|
|
4342
4346
|
credentialCheck: {
|
|
4343
4347
|
type: "object",
|
|
4344
4348
|
properties: {
|
|
4345
4349
|
method: {
|
|
4350
|
+
default: "GET",
|
|
4346
4351
|
type: "string",
|
|
4347
4352
|
enum: [
|
|
4348
4353
|
"GET",
|
|
4349
4354
|
"HEAD"
|
|
4350
|
-
]
|
|
4351
|
-
default: "GET"
|
|
4355
|
+
]
|
|
4352
4356
|
},
|
|
4353
4357
|
path: {
|
|
4354
4358
|
type: "string",
|
|
@@ -4397,12 +4401,14 @@ var openapi_default = {
|
|
|
4397
4401
|
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
|
4398
4402
|
},
|
|
4399
4403
|
modelsPath: {
|
|
4404
|
+
default: "models",
|
|
4400
4405
|
type: "string",
|
|
4401
|
-
pattern: "^[a-zA-Z0-9_/-]+$",
|
|
4402
4406
|
maxLength: 200,
|
|
4403
|
-
|
|
4407
|
+
pattern: "^[a-zA-Z0-9_/-]+$"
|
|
4404
4408
|
},
|
|
4405
4409
|
manualModels: {
|
|
4410
|
+
default: [],
|
|
4411
|
+
maxItems: 1e4,
|
|
4406
4412
|
type: "array",
|
|
4407
4413
|
items: {
|
|
4408
4414
|
type: "object",
|
|
@@ -4430,39 +4436,42 @@ var openapi_default = {
|
|
|
4430
4436
|
},
|
|
4431
4437
|
contextWindow: {
|
|
4432
4438
|
type: "integer",
|
|
4439
|
+
minimum: 0,
|
|
4433
4440
|
exclusiveMinimum: true,
|
|
4434
|
-
|
|
4441
|
+
maximum: 9007199254740991
|
|
4435
4442
|
},
|
|
4436
4443
|
maxOutputTokens: {
|
|
4437
4444
|
type: "integer",
|
|
4445
|
+
minimum: 0,
|
|
4438
4446
|
exclusiveMinimum: true,
|
|
4439
|
-
|
|
4447
|
+
maximum: 9007199254740991
|
|
4440
4448
|
},
|
|
4441
4449
|
inputModalities: {
|
|
4450
|
+
maxItems: 20,
|
|
4442
4451
|
type: "array",
|
|
4443
4452
|
items: {
|
|
4444
4453
|
type: "string",
|
|
4445
4454
|
maxLength: 50
|
|
4446
|
-
}
|
|
4447
|
-
maxItems: 20
|
|
4455
|
+
}
|
|
4448
4456
|
},
|
|
4449
4457
|
outputModalities: {
|
|
4458
|
+
maxItems: 20,
|
|
4450
4459
|
type: "array",
|
|
4451
4460
|
items: {
|
|
4452
4461
|
type: "string",
|
|
4453
4462
|
maxLength: 50
|
|
4454
|
-
}
|
|
4455
|
-
maxItems: 20
|
|
4463
|
+
}
|
|
4456
4464
|
},
|
|
4457
4465
|
supportedParameters: {
|
|
4466
|
+
maxItems: 100,
|
|
4458
4467
|
type: "array",
|
|
4459
4468
|
items: {
|
|
4460
4469
|
type: "string",
|
|
4461
4470
|
maxLength: 100
|
|
4462
|
-
}
|
|
4463
|
-
maxItems: 100
|
|
4471
|
+
}
|
|
4464
4472
|
},
|
|
4465
4473
|
reasoningEfforts: {
|
|
4474
|
+
maxItems: 8,
|
|
4466
4475
|
type: "array",
|
|
4467
4476
|
items: {
|
|
4468
4477
|
type: "string",
|
|
@@ -4476,17 +4485,16 @@ var openapi_default = {
|
|
|
4476
4485
|
"max",
|
|
4477
4486
|
"ultra"
|
|
4478
4487
|
]
|
|
4479
|
-
}
|
|
4480
|
-
maxItems: 8
|
|
4488
|
+
}
|
|
4481
4489
|
},
|
|
4482
4490
|
supportedGenerationMethods: {
|
|
4491
|
+
maxItems: 100,
|
|
4483
4492
|
type: "array",
|
|
4484
4493
|
items: {
|
|
4485
4494
|
type: "string",
|
|
4486
4495
|
minLength: 1,
|
|
4487
4496
|
maxLength: 100
|
|
4488
|
-
}
|
|
4489
|
-
maxItems: 100
|
|
4497
|
+
}
|
|
4490
4498
|
}
|
|
4491
4499
|
},
|
|
4492
4500
|
required: [
|
|
@@ -4494,11 +4502,10 @@ var openapi_default = {
|
|
|
4494
4502
|
"name"
|
|
4495
4503
|
],
|
|
4496
4504
|
additionalProperties: false
|
|
4497
|
-
}
|
|
4498
|
-
maxItems: 1e4,
|
|
4499
|
-
default: []
|
|
4505
|
+
}
|
|
4500
4506
|
},
|
|
4501
4507
|
additionalModels: {
|
|
4508
|
+
maxItems: 1e4,
|
|
4502
4509
|
type: "array",
|
|
4503
4510
|
items: {
|
|
4504
4511
|
type: "object",
|
|
@@ -4526,39 +4533,42 @@ var openapi_default = {
|
|
|
4526
4533
|
},
|
|
4527
4534
|
contextWindow: {
|
|
4528
4535
|
type: "integer",
|
|
4536
|
+
minimum: 0,
|
|
4529
4537
|
exclusiveMinimum: true,
|
|
4530
|
-
|
|
4538
|
+
maximum: 9007199254740991
|
|
4531
4539
|
},
|
|
4532
4540
|
maxOutputTokens: {
|
|
4533
4541
|
type: "integer",
|
|
4542
|
+
minimum: 0,
|
|
4534
4543
|
exclusiveMinimum: true,
|
|
4535
|
-
|
|
4544
|
+
maximum: 9007199254740991
|
|
4536
4545
|
},
|
|
4537
4546
|
inputModalities: {
|
|
4547
|
+
maxItems: 20,
|
|
4538
4548
|
type: "array",
|
|
4539
4549
|
items: {
|
|
4540
4550
|
type: "string",
|
|
4541
4551
|
maxLength: 50
|
|
4542
|
-
}
|
|
4543
|
-
maxItems: 20
|
|
4552
|
+
}
|
|
4544
4553
|
},
|
|
4545
4554
|
outputModalities: {
|
|
4555
|
+
maxItems: 20,
|
|
4546
4556
|
type: "array",
|
|
4547
4557
|
items: {
|
|
4548
4558
|
type: "string",
|
|
4549
4559
|
maxLength: 50
|
|
4550
|
-
}
|
|
4551
|
-
maxItems: 20
|
|
4560
|
+
}
|
|
4552
4561
|
},
|
|
4553
4562
|
supportedParameters: {
|
|
4563
|
+
maxItems: 100,
|
|
4554
4564
|
type: "array",
|
|
4555
4565
|
items: {
|
|
4556
4566
|
type: "string",
|
|
4557
4567
|
maxLength: 100
|
|
4558
|
-
}
|
|
4559
|
-
maxItems: 100
|
|
4568
|
+
}
|
|
4560
4569
|
},
|
|
4561
4570
|
reasoningEfforts: {
|
|
4571
|
+
maxItems: 8,
|
|
4562
4572
|
type: "array",
|
|
4563
4573
|
items: {
|
|
4564
4574
|
type: "string",
|
|
@@ -4572,17 +4582,16 @@ var openapi_default = {
|
|
|
4572
4582
|
"max",
|
|
4573
4583
|
"ultra"
|
|
4574
4584
|
]
|
|
4575
|
-
}
|
|
4576
|
-
maxItems: 8
|
|
4585
|
+
}
|
|
4577
4586
|
},
|
|
4578
4587
|
supportedGenerationMethods: {
|
|
4588
|
+
maxItems: 100,
|
|
4579
4589
|
type: "array",
|
|
4580
4590
|
items: {
|
|
4581
4591
|
type: "string",
|
|
4582
4592
|
minLength: 1,
|
|
4583
4593
|
maxLength: 100
|
|
4584
|
-
}
|
|
4585
|
-
maxItems: 100
|
|
4594
|
+
}
|
|
4586
4595
|
}
|
|
4587
4596
|
},
|
|
4588
4597
|
required: [
|
|
@@ -4590,13 +4599,13 @@ var openapi_default = {
|
|
|
4590
4599
|
"name"
|
|
4591
4600
|
],
|
|
4592
4601
|
additionalProperties: false
|
|
4593
|
-
}
|
|
4594
|
-
maxItems: 1e4
|
|
4602
|
+
}
|
|
4595
4603
|
},
|
|
4596
4604
|
version: {
|
|
4597
4605
|
type: "integer",
|
|
4606
|
+
minimum: 0,
|
|
4598
4607
|
exclusiveMinimum: true,
|
|
4599
|
-
|
|
4608
|
+
maximum: 9007199254740991
|
|
4600
4609
|
},
|
|
4601
4610
|
updatedAt: {
|
|
4602
4611
|
type: "string"
|
|
@@ -4607,6 +4616,9 @@ var openapi_default = {
|
|
|
4607
4616
|
"name",
|
|
4608
4617
|
"baseUrl",
|
|
4609
4618
|
"protocol",
|
|
4619
|
+
"authStyle",
|
|
4620
|
+
"modelsPath",
|
|
4621
|
+
"manualModels",
|
|
4610
4622
|
"version",
|
|
4611
4623
|
"updatedAt"
|
|
4612
4624
|
],
|
|
@@ -4658,11 +4670,11 @@ var openapi_default = {
|
|
|
4658
4670
|
type: "object",
|
|
4659
4671
|
properties: {
|
|
4660
4672
|
version: {
|
|
4673
|
+
default: 1,
|
|
4661
4674
|
type: "number",
|
|
4662
4675
|
enum: [
|
|
4663
4676
|
1
|
|
4664
|
-
]
|
|
4665
|
-
default: 1
|
|
4677
|
+
]
|
|
4666
4678
|
},
|
|
4667
4679
|
selection: {
|
|
4668
4680
|
type: "string",
|
|
@@ -4726,14 +4738,14 @@ var openapi_default = {
|
|
|
4726
4738
|
additionalProperties: false
|
|
4727
4739
|
},
|
|
4728
4740
|
allowedModels: {
|
|
4741
|
+
maxItems: 500,
|
|
4729
4742
|
type: "array",
|
|
4730
4743
|
items: {
|
|
4731
4744
|
type: "string",
|
|
4732
4745
|
minLength: 1,
|
|
4733
4746
|
maxLength: 300,
|
|
4734
4747
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4735
|
-
}
|
|
4736
|
-
maxItems: 500
|
|
4748
|
+
}
|
|
4737
4749
|
},
|
|
4738
4750
|
aliases: {
|
|
4739
4751
|
type: "object",
|
|
@@ -4747,14 +4759,14 @@ var openapi_default = {
|
|
|
4747
4759
|
fallbacks: {
|
|
4748
4760
|
type: "object",
|
|
4749
4761
|
additionalProperties: {
|
|
4762
|
+
maxItems: 20,
|
|
4750
4763
|
type: "array",
|
|
4751
4764
|
items: {
|
|
4752
4765
|
type: "string",
|
|
4753
4766
|
minLength: 1,
|
|
4754
4767
|
maxLength: 300,
|
|
4755
4768
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4756
|
-
}
|
|
4757
|
-
maxItems: 20
|
|
4769
|
+
}
|
|
4758
4770
|
}
|
|
4759
4771
|
}
|
|
4760
4772
|
},
|
|
@@ -4816,11 +4828,11 @@ var openapi_default = {
|
|
|
4816
4828
|
type: "object",
|
|
4817
4829
|
properties: {
|
|
4818
4830
|
version: {
|
|
4831
|
+
default: 1,
|
|
4819
4832
|
type: "number",
|
|
4820
4833
|
enum: [
|
|
4821
4834
|
1
|
|
4822
|
-
]
|
|
4823
|
-
default: 1
|
|
4835
|
+
]
|
|
4824
4836
|
},
|
|
4825
4837
|
selection: {
|
|
4826
4838
|
type: "string",
|
|
@@ -4884,14 +4896,14 @@ var openapi_default = {
|
|
|
4884
4896
|
additionalProperties: false
|
|
4885
4897
|
},
|
|
4886
4898
|
allowedModels: {
|
|
4899
|
+
maxItems: 500,
|
|
4887
4900
|
type: "array",
|
|
4888
4901
|
items: {
|
|
4889
4902
|
type: "string",
|
|
4890
4903
|
minLength: 1,
|
|
4891
4904
|
maxLength: 300,
|
|
4892
4905
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4893
|
-
}
|
|
4894
|
-
maxItems: 500
|
|
4906
|
+
}
|
|
4895
4907
|
},
|
|
4896
4908
|
aliases: {
|
|
4897
4909
|
type: "object",
|
|
@@ -4905,14 +4917,14 @@ var openapi_default = {
|
|
|
4905
4917
|
fallbacks: {
|
|
4906
4918
|
type: "object",
|
|
4907
4919
|
additionalProperties: {
|
|
4920
|
+
maxItems: 20,
|
|
4908
4921
|
type: "array",
|
|
4909
4922
|
items: {
|
|
4910
4923
|
type: "string",
|
|
4911
4924
|
minLength: 1,
|
|
4912
4925
|
maxLength: 300,
|
|
4913
4926
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4914
|
-
}
|
|
4915
|
-
maxItems: 20
|
|
4927
|
+
}
|
|
4916
4928
|
}
|
|
4917
4929
|
}
|
|
4918
4930
|
},
|
|
@@ -4920,8 +4932,9 @@ var openapi_default = {
|
|
|
4920
4932
|
},
|
|
4921
4933
|
version: {
|
|
4922
4934
|
type: "integer",
|
|
4935
|
+
minimum: 0,
|
|
4923
4936
|
exclusiveMinimum: true,
|
|
4924
|
-
|
|
4937
|
+
maximum: 9007199254740991
|
|
4925
4938
|
},
|
|
4926
4939
|
updatedAt: {
|
|
4927
4940
|
type: "string"
|
|
@@ -4964,39 +4977,42 @@ var openapi_default = {
|
|
|
4964
4977
|
},
|
|
4965
4978
|
contextWindow: {
|
|
4966
4979
|
type: "integer",
|
|
4980
|
+
minimum: 0,
|
|
4967
4981
|
exclusiveMinimum: true,
|
|
4968
|
-
|
|
4982
|
+
maximum: 9007199254740991
|
|
4969
4983
|
},
|
|
4970
4984
|
maxOutputTokens: {
|
|
4971
4985
|
type: "integer",
|
|
4986
|
+
minimum: 0,
|
|
4972
4987
|
exclusiveMinimum: true,
|
|
4973
|
-
|
|
4988
|
+
maximum: 9007199254740991
|
|
4974
4989
|
},
|
|
4975
4990
|
inputModalities: {
|
|
4991
|
+
maxItems: 20,
|
|
4976
4992
|
type: "array",
|
|
4977
4993
|
items: {
|
|
4978
4994
|
type: "string",
|
|
4979
4995
|
maxLength: 50
|
|
4980
|
-
}
|
|
4981
|
-
maxItems: 20
|
|
4996
|
+
}
|
|
4982
4997
|
},
|
|
4983
4998
|
outputModalities: {
|
|
4999
|
+
maxItems: 20,
|
|
4984
5000
|
type: "array",
|
|
4985
5001
|
items: {
|
|
4986
5002
|
type: "string",
|
|
4987
5003
|
maxLength: 50
|
|
4988
|
-
}
|
|
4989
|
-
maxItems: 20
|
|
5004
|
+
}
|
|
4990
5005
|
},
|
|
4991
5006
|
supportedParameters: {
|
|
5007
|
+
maxItems: 100,
|
|
4992
5008
|
type: "array",
|
|
4993
5009
|
items: {
|
|
4994
5010
|
type: "string",
|
|
4995
5011
|
maxLength: 100
|
|
4996
|
-
}
|
|
4997
|
-
maxItems: 100
|
|
5012
|
+
}
|
|
4998
5013
|
},
|
|
4999
5014
|
reasoningEfforts: {
|
|
5015
|
+
maxItems: 8,
|
|
5000
5016
|
type: "array",
|
|
5001
5017
|
items: {
|
|
5002
5018
|
type: "string",
|
|
@@ -5010,17 +5026,16 @@ var openapi_default = {
|
|
|
5010
5026
|
"max",
|
|
5011
5027
|
"ultra"
|
|
5012
5028
|
]
|
|
5013
|
-
}
|
|
5014
|
-
maxItems: 8
|
|
5029
|
+
}
|
|
5015
5030
|
},
|
|
5016
5031
|
supportedGenerationMethods: {
|
|
5032
|
+
maxItems: 100,
|
|
5017
5033
|
type: "array",
|
|
5018
5034
|
items: {
|
|
5019
5035
|
type: "string",
|
|
5020
5036
|
minLength: 1,
|
|
5021
5037
|
maxLength: 100
|
|
5022
|
-
}
|
|
5023
|
-
maxItems: 100
|
|
5038
|
+
}
|
|
5024
5039
|
}
|
|
5025
5040
|
},
|
|
5026
5041
|
required: [
|
|
@@ -5033,11 +5048,11 @@ var openapi_default = {
|
|
|
5033
5048
|
type: "object",
|
|
5034
5049
|
properties: {
|
|
5035
5050
|
version: {
|
|
5051
|
+
default: 1,
|
|
5036
5052
|
type: "number",
|
|
5037
5053
|
enum: [
|
|
5038
5054
|
1
|
|
5039
|
-
]
|
|
5040
|
-
default: 1
|
|
5055
|
+
]
|
|
5041
5056
|
},
|
|
5042
5057
|
selection: {
|
|
5043
5058
|
type: "string",
|
|
@@ -5101,14 +5116,14 @@ var openapi_default = {
|
|
|
5101
5116
|
additionalProperties: false
|
|
5102
5117
|
},
|
|
5103
5118
|
allowedModels: {
|
|
5119
|
+
maxItems: 500,
|
|
5104
5120
|
type: "array",
|
|
5105
5121
|
items: {
|
|
5106
5122
|
type: "string",
|
|
5107
5123
|
minLength: 1,
|
|
5108
5124
|
maxLength: 300,
|
|
5109
5125
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
5110
|
-
}
|
|
5111
|
-
maxItems: 500
|
|
5126
|
+
}
|
|
5112
5127
|
},
|
|
5113
5128
|
aliases: {
|
|
5114
5129
|
type: "object",
|
|
@@ -5122,14 +5137,14 @@ var openapi_default = {
|
|
|
5122
5137
|
fallbacks: {
|
|
5123
5138
|
type: "object",
|
|
5124
5139
|
additionalProperties: {
|
|
5140
|
+
maxItems: 20,
|
|
5125
5141
|
type: "array",
|
|
5126
5142
|
items: {
|
|
5127
5143
|
type: "string",
|
|
5128
5144
|
minLength: 1,
|
|
5129
5145
|
maxLength: 300,
|
|
5130
5146
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
5131
|
-
}
|
|
5132
|
-
maxItems: 20
|
|
5147
|
+
}
|
|
5133
5148
|
}
|
|
5134
5149
|
}
|
|
5135
5150
|
},
|
|
@@ -5140,7 +5155,8 @@ var openapi_default = {
|
|
|
5140
5155
|
properties: {
|
|
5141
5156
|
at: {
|
|
5142
5157
|
type: "string",
|
|
5143
|
-
format: "date-time"
|
|
5158
|
+
format: "date-time",
|
|
5159
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
5144
5160
|
},
|
|
5145
5161
|
requestId: {
|
|
5146
5162
|
type: "string",
|
|
@@ -5249,39 +5265,42 @@ var openapi_default = {
|
|
|
5249
5265
|
},
|
|
5250
5266
|
contextWindow: {
|
|
5251
5267
|
type: "integer",
|
|
5268
|
+
minimum: 0,
|
|
5252
5269
|
exclusiveMinimum: true,
|
|
5253
|
-
|
|
5270
|
+
maximum: 9007199254740991
|
|
5254
5271
|
},
|
|
5255
5272
|
maxOutputTokens: {
|
|
5256
5273
|
type: "integer",
|
|
5274
|
+
minimum: 0,
|
|
5257
5275
|
exclusiveMinimum: true,
|
|
5258
|
-
|
|
5276
|
+
maximum: 9007199254740991
|
|
5259
5277
|
},
|
|
5260
5278
|
inputModalities: {
|
|
5279
|
+
maxItems: 20,
|
|
5261
5280
|
type: "array",
|
|
5262
5281
|
items: {
|
|
5263
5282
|
type: "string",
|
|
5264
5283
|
maxLength: 50
|
|
5265
|
-
}
|
|
5266
|
-
maxItems: 20
|
|
5284
|
+
}
|
|
5267
5285
|
},
|
|
5268
5286
|
outputModalities: {
|
|
5287
|
+
maxItems: 20,
|
|
5269
5288
|
type: "array",
|
|
5270
5289
|
items: {
|
|
5271
5290
|
type: "string",
|
|
5272
5291
|
maxLength: 50
|
|
5273
|
-
}
|
|
5274
|
-
maxItems: 20
|
|
5292
|
+
}
|
|
5275
5293
|
},
|
|
5276
5294
|
supportedParameters: {
|
|
5295
|
+
maxItems: 100,
|
|
5277
5296
|
type: "array",
|
|
5278
5297
|
items: {
|
|
5279
5298
|
type: "string",
|
|
5280
5299
|
maxLength: 100
|
|
5281
|
-
}
|
|
5282
|
-
maxItems: 100
|
|
5300
|
+
}
|
|
5283
5301
|
},
|
|
5284
5302
|
reasoningEfforts: {
|
|
5303
|
+
maxItems: 8,
|
|
5285
5304
|
type: "array",
|
|
5286
5305
|
items: {
|
|
5287
5306
|
type: "string",
|
|
@@ -5295,17 +5314,16 @@ var openapi_default = {
|
|
|
5295
5314
|
"max",
|
|
5296
5315
|
"ultra"
|
|
5297
5316
|
]
|
|
5298
|
-
}
|
|
5299
|
-
maxItems: 8
|
|
5317
|
+
}
|
|
5300
5318
|
},
|
|
5301
5319
|
supportedGenerationMethods: {
|
|
5320
|
+
maxItems: 100,
|
|
5302
5321
|
type: "array",
|
|
5303
5322
|
items: {
|
|
5304
5323
|
type: "string",
|
|
5305
5324
|
minLength: 1,
|
|
5306
5325
|
maxLength: 100
|
|
5307
|
-
}
|
|
5308
|
-
maxItems: 100
|
|
5326
|
+
}
|
|
5309
5327
|
},
|
|
5310
5328
|
codingEligible: {
|
|
5311
5329
|
type: "boolean"
|
|
@@ -5324,13 +5342,19 @@ var openapi_default = {
|
|
|
5324
5342
|
}
|
|
5325
5343
|
},
|
|
5326
5344
|
total: {
|
|
5327
|
-
type: "integer"
|
|
5345
|
+
type: "integer",
|
|
5346
|
+
minimum: -9007199254740991,
|
|
5347
|
+
maximum: 9007199254740991
|
|
5328
5348
|
},
|
|
5329
5349
|
limit: {
|
|
5330
|
-
type: "integer"
|
|
5350
|
+
type: "integer",
|
|
5351
|
+
minimum: -9007199254740991,
|
|
5352
|
+
maximum: 9007199254740991
|
|
5331
5353
|
},
|
|
5332
5354
|
offset: {
|
|
5333
|
-
type: "integer"
|
|
5355
|
+
type: "integer",
|
|
5356
|
+
minimum: -9007199254740991,
|
|
5357
|
+
maximum: 9007199254740991
|
|
5334
5358
|
},
|
|
5335
5359
|
refreshedAt: {
|
|
5336
5360
|
type: "string"
|
|
@@ -5357,6 +5381,7 @@ var openapi_default = {
|
|
|
5357
5381
|
type: "object",
|
|
5358
5382
|
properties: {
|
|
5359
5383
|
models: {
|
|
5384
|
+
maxItems: 1e4,
|
|
5360
5385
|
type: "array",
|
|
5361
5386
|
items: {
|
|
5362
5387
|
type: "object",
|
|
@@ -5384,39 +5409,42 @@ var openapi_default = {
|
|
|
5384
5409
|
},
|
|
5385
5410
|
contextWindow: {
|
|
5386
5411
|
type: "integer",
|
|
5412
|
+
minimum: 0,
|
|
5387
5413
|
exclusiveMinimum: true,
|
|
5388
|
-
|
|
5414
|
+
maximum: 9007199254740991
|
|
5389
5415
|
},
|
|
5390
5416
|
maxOutputTokens: {
|
|
5391
5417
|
type: "integer",
|
|
5418
|
+
minimum: 0,
|
|
5392
5419
|
exclusiveMinimum: true,
|
|
5393
|
-
|
|
5420
|
+
maximum: 9007199254740991
|
|
5394
5421
|
},
|
|
5395
5422
|
inputModalities: {
|
|
5423
|
+
maxItems: 20,
|
|
5396
5424
|
type: "array",
|
|
5397
5425
|
items: {
|
|
5398
5426
|
type: "string",
|
|
5399
5427
|
maxLength: 50
|
|
5400
|
-
}
|
|
5401
|
-
maxItems: 20
|
|
5428
|
+
}
|
|
5402
5429
|
},
|
|
5403
5430
|
outputModalities: {
|
|
5431
|
+
maxItems: 20,
|
|
5404
5432
|
type: "array",
|
|
5405
5433
|
items: {
|
|
5406
5434
|
type: "string",
|
|
5407
5435
|
maxLength: 50
|
|
5408
|
-
}
|
|
5409
|
-
maxItems: 20
|
|
5436
|
+
}
|
|
5410
5437
|
},
|
|
5411
5438
|
supportedParameters: {
|
|
5439
|
+
maxItems: 100,
|
|
5412
5440
|
type: "array",
|
|
5413
5441
|
items: {
|
|
5414
5442
|
type: "string",
|
|
5415
5443
|
maxLength: 100
|
|
5416
|
-
}
|
|
5417
|
-
maxItems: 100
|
|
5444
|
+
}
|
|
5418
5445
|
},
|
|
5419
5446
|
reasoningEfforts: {
|
|
5447
|
+
maxItems: 8,
|
|
5420
5448
|
type: "array",
|
|
5421
5449
|
items: {
|
|
5422
5450
|
type: "string",
|
|
@@ -5430,17 +5458,16 @@ var openapi_default = {
|
|
|
5430
5458
|
"max",
|
|
5431
5459
|
"ultra"
|
|
5432
5460
|
]
|
|
5433
|
-
}
|
|
5434
|
-
maxItems: 8
|
|
5461
|
+
}
|
|
5435
5462
|
},
|
|
5436
5463
|
supportedGenerationMethods: {
|
|
5464
|
+
maxItems: 100,
|
|
5437
5465
|
type: "array",
|
|
5438
5466
|
items: {
|
|
5439
5467
|
type: "string",
|
|
5440
5468
|
minLength: 1,
|
|
5441
5469
|
maxLength: 100
|
|
5442
|
-
}
|
|
5443
|
-
maxItems: 100
|
|
5470
|
+
}
|
|
5444
5471
|
}
|
|
5445
5472
|
},
|
|
5446
5473
|
required: [
|
|
@@ -5448,12 +5475,12 @@ var openapi_default = {
|
|
|
5448
5475
|
"name"
|
|
5449
5476
|
],
|
|
5450
5477
|
additionalProperties: false
|
|
5451
|
-
}
|
|
5452
|
-
maxItems: 1e4
|
|
5478
|
+
}
|
|
5453
5479
|
},
|
|
5454
5480
|
refreshedAt: {
|
|
5455
5481
|
type: "string",
|
|
5456
|
-
format: "date-time"
|
|
5482
|
+
format: "date-time",
|
|
5483
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
5457
5484
|
},
|
|
5458
5485
|
source: {
|
|
5459
5486
|
type: "string",
|
|
@@ -5503,24 +5530,24 @@ var openapi_default = {
|
|
|
5503
5530
|
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
5504
5531
|
},
|
|
5505
5532
|
authStyle: {
|
|
5533
|
+
default: "bearer",
|
|
5506
5534
|
type: "string",
|
|
5507
5535
|
enum: [
|
|
5508
5536
|
"bearer",
|
|
5509
5537
|
"x-api-key",
|
|
5510
5538
|
"api-key"
|
|
5511
|
-
]
|
|
5512
|
-
default: "bearer"
|
|
5539
|
+
]
|
|
5513
5540
|
},
|
|
5514
5541
|
credentialCheck: {
|
|
5515
5542
|
type: "object",
|
|
5516
5543
|
properties: {
|
|
5517
5544
|
method: {
|
|
5545
|
+
default: "GET",
|
|
5518
5546
|
type: "string",
|
|
5519
5547
|
enum: [
|
|
5520
5548
|
"GET",
|
|
5521
5549
|
"HEAD"
|
|
5522
|
-
]
|
|
5523
|
-
default: "GET"
|
|
5550
|
+
]
|
|
5524
5551
|
},
|
|
5525
5552
|
path: {
|
|
5526
5553
|
type: "string",
|
|
@@ -5569,12 +5596,14 @@ var openapi_default = {
|
|
|
5569
5596
|
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
|
5570
5597
|
},
|
|
5571
5598
|
modelsPath: {
|
|
5599
|
+
default: "models",
|
|
5572
5600
|
type: "string",
|
|
5573
|
-
pattern: "^[a-zA-Z0-9_/-]+$",
|
|
5574
5601
|
maxLength: 200,
|
|
5575
|
-
|
|
5602
|
+
pattern: "^[a-zA-Z0-9_/-]+$"
|
|
5576
5603
|
},
|
|
5577
5604
|
manualModels: {
|
|
5605
|
+
default: [],
|
|
5606
|
+
maxItems: 1e4,
|
|
5578
5607
|
type: "array",
|
|
5579
5608
|
items: {
|
|
5580
5609
|
type: "object",
|
|
@@ -5602,39 +5631,42 @@ var openapi_default = {
|
|
|
5602
5631
|
},
|
|
5603
5632
|
contextWindow: {
|
|
5604
5633
|
type: "integer",
|
|
5634
|
+
minimum: 0,
|
|
5605
5635
|
exclusiveMinimum: true,
|
|
5606
|
-
|
|
5636
|
+
maximum: 9007199254740991
|
|
5607
5637
|
},
|
|
5608
5638
|
maxOutputTokens: {
|
|
5609
5639
|
type: "integer",
|
|
5640
|
+
minimum: 0,
|
|
5610
5641
|
exclusiveMinimum: true,
|
|
5611
|
-
|
|
5642
|
+
maximum: 9007199254740991
|
|
5612
5643
|
},
|
|
5613
5644
|
inputModalities: {
|
|
5645
|
+
maxItems: 20,
|
|
5614
5646
|
type: "array",
|
|
5615
5647
|
items: {
|
|
5616
5648
|
type: "string",
|
|
5617
5649
|
maxLength: 50
|
|
5618
|
-
}
|
|
5619
|
-
maxItems: 20
|
|
5650
|
+
}
|
|
5620
5651
|
},
|
|
5621
5652
|
outputModalities: {
|
|
5653
|
+
maxItems: 20,
|
|
5622
5654
|
type: "array",
|
|
5623
5655
|
items: {
|
|
5624
5656
|
type: "string",
|
|
5625
5657
|
maxLength: 50
|
|
5626
|
-
}
|
|
5627
|
-
maxItems: 20
|
|
5658
|
+
}
|
|
5628
5659
|
},
|
|
5629
5660
|
supportedParameters: {
|
|
5661
|
+
maxItems: 100,
|
|
5630
5662
|
type: "array",
|
|
5631
5663
|
items: {
|
|
5632
5664
|
type: "string",
|
|
5633
5665
|
maxLength: 100
|
|
5634
|
-
}
|
|
5635
|
-
maxItems: 100
|
|
5666
|
+
}
|
|
5636
5667
|
},
|
|
5637
5668
|
reasoningEfforts: {
|
|
5669
|
+
maxItems: 8,
|
|
5638
5670
|
type: "array",
|
|
5639
5671
|
items: {
|
|
5640
5672
|
type: "string",
|
|
@@ -5648,17 +5680,16 @@ var openapi_default = {
|
|
|
5648
5680
|
"max",
|
|
5649
5681
|
"ultra"
|
|
5650
5682
|
]
|
|
5651
|
-
}
|
|
5652
|
-
maxItems: 8
|
|
5683
|
+
}
|
|
5653
5684
|
},
|
|
5654
5685
|
supportedGenerationMethods: {
|
|
5686
|
+
maxItems: 100,
|
|
5655
5687
|
type: "array",
|
|
5656
5688
|
items: {
|
|
5657
5689
|
type: "string",
|
|
5658
5690
|
minLength: 1,
|
|
5659
5691
|
maxLength: 100
|
|
5660
|
-
}
|
|
5661
|
-
maxItems: 100
|
|
5692
|
+
}
|
|
5662
5693
|
}
|
|
5663
5694
|
},
|
|
5664
5695
|
required: [
|
|
@@ -5666,11 +5697,10 @@ var openapi_default = {
|
|
|
5666
5697
|
"name"
|
|
5667
5698
|
],
|
|
5668
5699
|
additionalProperties: false
|
|
5669
|
-
}
|
|
5670
|
-
maxItems: 1e4,
|
|
5671
|
-
default: []
|
|
5700
|
+
}
|
|
5672
5701
|
},
|
|
5673
5702
|
additionalModels: {
|
|
5703
|
+
maxItems: 1e4,
|
|
5674
5704
|
type: "array",
|
|
5675
5705
|
items: {
|
|
5676
5706
|
type: "object",
|
|
@@ -5698,39 +5728,42 @@ var openapi_default = {
|
|
|
5698
5728
|
},
|
|
5699
5729
|
contextWindow: {
|
|
5700
5730
|
type: "integer",
|
|
5731
|
+
minimum: 0,
|
|
5701
5732
|
exclusiveMinimum: true,
|
|
5702
|
-
|
|
5733
|
+
maximum: 9007199254740991
|
|
5703
5734
|
},
|
|
5704
5735
|
maxOutputTokens: {
|
|
5705
5736
|
type: "integer",
|
|
5737
|
+
minimum: 0,
|
|
5706
5738
|
exclusiveMinimum: true,
|
|
5707
|
-
|
|
5739
|
+
maximum: 9007199254740991
|
|
5708
5740
|
},
|
|
5709
5741
|
inputModalities: {
|
|
5742
|
+
maxItems: 20,
|
|
5710
5743
|
type: "array",
|
|
5711
5744
|
items: {
|
|
5712
5745
|
type: "string",
|
|
5713
5746
|
maxLength: 50
|
|
5714
|
-
}
|
|
5715
|
-
maxItems: 20
|
|
5747
|
+
}
|
|
5716
5748
|
},
|
|
5717
5749
|
outputModalities: {
|
|
5750
|
+
maxItems: 20,
|
|
5718
5751
|
type: "array",
|
|
5719
5752
|
items: {
|
|
5720
5753
|
type: "string",
|
|
5721
5754
|
maxLength: 50
|
|
5722
|
-
}
|
|
5723
|
-
maxItems: 20
|
|
5755
|
+
}
|
|
5724
5756
|
},
|
|
5725
5757
|
supportedParameters: {
|
|
5758
|
+
maxItems: 100,
|
|
5726
5759
|
type: "array",
|
|
5727
5760
|
items: {
|
|
5728
5761
|
type: "string",
|
|
5729
5762
|
maxLength: 100
|
|
5730
|
-
}
|
|
5731
|
-
maxItems: 100
|
|
5763
|
+
}
|
|
5732
5764
|
},
|
|
5733
5765
|
reasoningEfforts: {
|
|
5766
|
+
maxItems: 8,
|
|
5734
5767
|
type: "array",
|
|
5735
5768
|
items: {
|
|
5736
5769
|
type: "string",
|
|
@@ -5744,17 +5777,16 @@ var openapi_default = {
|
|
|
5744
5777
|
"max",
|
|
5745
5778
|
"ultra"
|
|
5746
5779
|
]
|
|
5747
|
-
}
|
|
5748
|
-
maxItems: 8
|
|
5780
|
+
}
|
|
5749
5781
|
},
|
|
5750
5782
|
supportedGenerationMethods: {
|
|
5783
|
+
maxItems: 100,
|
|
5751
5784
|
type: "array",
|
|
5752
5785
|
items: {
|
|
5753
5786
|
type: "string",
|
|
5754
5787
|
minLength: 1,
|
|
5755
5788
|
maxLength: 100
|
|
5756
|
-
}
|
|
5757
|
-
maxItems: 100
|
|
5789
|
+
}
|
|
5758
5790
|
}
|
|
5759
5791
|
},
|
|
5760
5792
|
required: [
|
|
@@ -5762,13 +5794,13 @@ var openapi_default = {
|
|
|
5762
5794
|
"name"
|
|
5763
5795
|
],
|
|
5764
5796
|
additionalProperties: false
|
|
5765
|
-
}
|
|
5766
|
-
maxItems: 1e4
|
|
5797
|
+
}
|
|
5767
5798
|
},
|
|
5768
5799
|
version: {
|
|
5769
5800
|
type: "integer",
|
|
5801
|
+
minimum: 0,
|
|
5770
5802
|
exclusiveMinimum: true,
|
|
5771
|
-
|
|
5803
|
+
maximum: 9007199254740991
|
|
5772
5804
|
},
|
|
5773
5805
|
updatedAt: {
|
|
5774
5806
|
type: "string"
|
|
@@ -5779,6 +5811,9 @@ var openapi_default = {
|
|
|
5779
5811
|
"name",
|
|
5780
5812
|
"baseUrl",
|
|
5781
5813
|
"protocol",
|
|
5814
|
+
"authStyle",
|
|
5815
|
+
"modelsPath",
|
|
5816
|
+
"manualModels",
|
|
5782
5817
|
"version",
|
|
5783
5818
|
"updatedAt"
|
|
5784
5819
|
],
|
|
@@ -5830,11 +5865,11 @@ var openapi_default = {
|
|
|
5830
5865
|
type: "object",
|
|
5831
5866
|
properties: {
|
|
5832
5867
|
version: {
|
|
5868
|
+
default: 1,
|
|
5833
5869
|
type: "number",
|
|
5834
5870
|
enum: [
|
|
5835
5871
|
1
|
|
5836
|
-
]
|
|
5837
|
-
default: 1
|
|
5872
|
+
]
|
|
5838
5873
|
},
|
|
5839
5874
|
selection: {
|
|
5840
5875
|
type: "string",
|
|
@@ -5898,14 +5933,14 @@ var openapi_default = {
|
|
|
5898
5933
|
additionalProperties: false
|
|
5899
5934
|
},
|
|
5900
5935
|
allowedModels: {
|
|
5936
|
+
maxItems: 500,
|
|
5901
5937
|
type: "array",
|
|
5902
5938
|
items: {
|
|
5903
5939
|
type: "string",
|
|
5904
5940
|
minLength: 1,
|
|
5905
5941
|
maxLength: 300,
|
|
5906
5942
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
5907
|
-
}
|
|
5908
|
-
maxItems: 500
|
|
5943
|
+
}
|
|
5909
5944
|
},
|
|
5910
5945
|
aliases: {
|
|
5911
5946
|
type: "object",
|
|
@@ -5919,14 +5954,14 @@ var openapi_default = {
|
|
|
5919
5954
|
fallbacks: {
|
|
5920
5955
|
type: "object",
|
|
5921
5956
|
additionalProperties: {
|
|
5957
|
+
maxItems: 20,
|
|
5922
5958
|
type: "array",
|
|
5923
5959
|
items: {
|
|
5924
5960
|
type: "string",
|
|
5925
5961
|
minLength: 1,
|
|
5926
5962
|
maxLength: 300,
|
|
5927
5963
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
5928
|
-
}
|
|
5929
|
-
maxItems: 20
|
|
5964
|
+
}
|
|
5930
5965
|
}
|
|
5931
5966
|
}
|
|
5932
5967
|
},
|
|
@@ -5934,8 +5969,9 @@ var openapi_default = {
|
|
|
5934
5969
|
},
|
|
5935
5970
|
version: {
|
|
5936
5971
|
type: "integer",
|
|
5972
|
+
minimum: 0,
|
|
5937
5973
|
exclusiveMinimum: true,
|
|
5938
|
-
|
|
5974
|
+
maximum: 9007199254740991
|
|
5939
5975
|
},
|
|
5940
5976
|
updatedAt: {
|
|
5941
5977
|
type: "string"
|
|
@@ -5956,6 +5992,7 @@ var openapi_default = {
|
|
|
5956
5992
|
type: "object",
|
|
5957
5993
|
properties: {
|
|
5958
5994
|
models: {
|
|
5995
|
+
maxItems: 1e4,
|
|
5959
5996
|
type: "array",
|
|
5960
5997
|
items: {
|
|
5961
5998
|
type: "object",
|
|
@@ -5983,39 +6020,42 @@ var openapi_default = {
|
|
|
5983
6020
|
},
|
|
5984
6021
|
contextWindow: {
|
|
5985
6022
|
type: "integer",
|
|
6023
|
+
minimum: 0,
|
|
5986
6024
|
exclusiveMinimum: true,
|
|
5987
|
-
|
|
6025
|
+
maximum: 9007199254740991
|
|
5988
6026
|
},
|
|
5989
6027
|
maxOutputTokens: {
|
|
5990
6028
|
type: "integer",
|
|
6029
|
+
minimum: 0,
|
|
5991
6030
|
exclusiveMinimum: true,
|
|
5992
|
-
|
|
6031
|
+
maximum: 9007199254740991
|
|
5993
6032
|
},
|
|
5994
6033
|
inputModalities: {
|
|
6034
|
+
maxItems: 20,
|
|
5995
6035
|
type: "array",
|
|
5996
6036
|
items: {
|
|
5997
6037
|
type: "string",
|
|
5998
6038
|
maxLength: 50
|
|
5999
|
-
}
|
|
6000
|
-
maxItems: 20
|
|
6039
|
+
}
|
|
6001
6040
|
},
|
|
6002
6041
|
outputModalities: {
|
|
6042
|
+
maxItems: 20,
|
|
6003
6043
|
type: "array",
|
|
6004
6044
|
items: {
|
|
6005
6045
|
type: "string",
|
|
6006
6046
|
maxLength: 50
|
|
6007
|
-
}
|
|
6008
|
-
maxItems: 20
|
|
6047
|
+
}
|
|
6009
6048
|
},
|
|
6010
6049
|
supportedParameters: {
|
|
6050
|
+
maxItems: 100,
|
|
6011
6051
|
type: "array",
|
|
6012
6052
|
items: {
|
|
6013
6053
|
type: "string",
|
|
6014
6054
|
maxLength: 100
|
|
6015
|
-
}
|
|
6016
|
-
maxItems: 100
|
|
6055
|
+
}
|
|
6017
6056
|
},
|
|
6018
6057
|
reasoningEfforts: {
|
|
6058
|
+
maxItems: 8,
|
|
6019
6059
|
type: "array",
|
|
6020
6060
|
items: {
|
|
6021
6061
|
type: "string",
|
|
@@ -6029,17 +6069,16 @@ var openapi_default = {
|
|
|
6029
6069
|
"max",
|
|
6030
6070
|
"ultra"
|
|
6031
6071
|
]
|
|
6032
|
-
}
|
|
6033
|
-
maxItems: 8
|
|
6072
|
+
}
|
|
6034
6073
|
},
|
|
6035
6074
|
supportedGenerationMethods: {
|
|
6075
|
+
maxItems: 100,
|
|
6036
6076
|
type: "array",
|
|
6037
6077
|
items: {
|
|
6038
6078
|
type: "string",
|
|
6039
6079
|
minLength: 1,
|
|
6040
6080
|
maxLength: 100
|
|
6041
|
-
}
|
|
6042
|
-
maxItems: 100
|
|
6081
|
+
}
|
|
6043
6082
|
}
|
|
6044
6083
|
},
|
|
6045
6084
|
required: [
|
|
@@ -6047,12 +6086,12 @@ var openapi_default = {
|
|
|
6047
6086
|
"name"
|
|
6048
6087
|
],
|
|
6049
6088
|
additionalProperties: false
|
|
6050
|
-
}
|
|
6051
|
-
maxItems: 1e4
|
|
6089
|
+
}
|
|
6052
6090
|
},
|
|
6053
6091
|
refreshedAt: {
|
|
6054
6092
|
type: "string",
|
|
6055
|
-
format: "date-time"
|
|
6093
|
+
format: "date-time",
|
|
6094
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
6056
6095
|
},
|
|
6057
6096
|
source: {
|
|
6058
6097
|
type: "string",
|
|
@@ -6131,11 +6170,11 @@ var openapi_default = {
|
|
|
6131
6170
|
type: "object",
|
|
6132
6171
|
properties: {
|
|
6133
6172
|
version: {
|
|
6173
|
+
default: 1,
|
|
6134
6174
|
type: "number",
|
|
6135
6175
|
enum: [
|
|
6136
6176
|
1
|
|
6137
|
-
]
|
|
6138
|
-
default: 1
|
|
6177
|
+
]
|
|
6139
6178
|
},
|
|
6140
6179
|
selection: {
|
|
6141
6180
|
type: "string",
|
|
@@ -6199,14 +6238,14 @@ var openapi_default = {
|
|
|
6199
6238
|
additionalProperties: false
|
|
6200
6239
|
},
|
|
6201
6240
|
allowedModels: {
|
|
6241
|
+
maxItems: 500,
|
|
6202
6242
|
type: "array",
|
|
6203
6243
|
items: {
|
|
6204
6244
|
type: "string",
|
|
6205
6245
|
minLength: 1,
|
|
6206
6246
|
maxLength: 300,
|
|
6207
6247
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
6208
|
-
}
|
|
6209
|
-
maxItems: 500
|
|
6248
|
+
}
|
|
6210
6249
|
},
|
|
6211
6250
|
aliases: {
|
|
6212
6251
|
type: "object",
|
|
@@ -6220,14 +6259,14 @@ var openapi_default = {
|
|
|
6220
6259
|
fallbacks: {
|
|
6221
6260
|
type: "object",
|
|
6222
6261
|
additionalProperties: {
|
|
6262
|
+
maxItems: 20,
|
|
6223
6263
|
type: "array",
|
|
6224
6264
|
items: {
|
|
6225
6265
|
type: "string",
|
|
6226
6266
|
minLength: 1,
|
|
6227
6267
|
maxLength: 300,
|
|
6228
6268
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
6229
|
-
}
|
|
6230
|
-
maxItems: 20
|
|
6269
|
+
}
|
|
6231
6270
|
}
|
|
6232
6271
|
}
|
|
6233
6272
|
},
|
|
@@ -6264,13 +6303,15 @@ var openapi_default = {
|
|
|
6264
6303
|
maximum: 255
|
|
6265
6304
|
},
|
|
6266
6305
|
routingEvents: {
|
|
6306
|
+
maxItems: 1000,
|
|
6267
6307
|
type: "array",
|
|
6268
6308
|
items: {
|
|
6269
6309
|
type: "object",
|
|
6270
6310
|
properties: {
|
|
6271
6311
|
at: {
|
|
6272
6312
|
type: "string",
|
|
6273
|
-
format: "date-time"
|
|
6313
|
+
format: "date-time",
|
|
6314
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
6274
6315
|
},
|
|
6275
6316
|
requestId: {
|
|
6276
6317
|
type: "string",
|
|
@@ -6347,8 +6388,7 @@ var openapi_default = {
|
|
|
6347
6388
|
"decision"
|
|
6348
6389
|
],
|
|
6349
6390
|
additionalProperties: false
|
|
6350
|
-
}
|
|
6351
|
-
maxItems: 1000
|
|
6391
|
+
}
|
|
6352
6392
|
},
|
|
6353
6393
|
routingEventsDropped: {
|
|
6354
6394
|
type: "integer",
|
|
@@ -6405,11 +6445,11 @@ var openapi_default = {
|
|
|
6405
6445
|
type: "object",
|
|
6406
6446
|
properties: {
|
|
6407
6447
|
version: {
|
|
6448
|
+
default: 1,
|
|
6408
6449
|
type: "number",
|
|
6409
6450
|
enum: [
|
|
6410
6451
|
1
|
|
6411
|
-
]
|
|
6412
|
-
default: 1
|
|
6452
|
+
]
|
|
6413
6453
|
},
|
|
6414
6454
|
selection: {
|
|
6415
6455
|
type: "string",
|
|
@@ -6473,14 +6513,14 @@ var openapi_default = {
|
|
|
6473
6513
|
additionalProperties: false
|
|
6474
6514
|
},
|
|
6475
6515
|
allowedModels: {
|
|
6516
|
+
maxItems: 500,
|
|
6476
6517
|
type: "array",
|
|
6477
6518
|
items: {
|
|
6478
6519
|
type: "string",
|
|
6479
6520
|
minLength: 1,
|
|
6480
6521
|
maxLength: 300,
|
|
6481
6522
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
6482
|
-
}
|
|
6483
|
-
maxItems: 500
|
|
6523
|
+
}
|
|
6484
6524
|
},
|
|
6485
6525
|
aliases: {
|
|
6486
6526
|
type: "object",
|
|
@@ -6494,14 +6534,14 @@ var openapi_default = {
|
|
|
6494
6534
|
fallbacks: {
|
|
6495
6535
|
type: "object",
|
|
6496
6536
|
additionalProperties: {
|
|
6537
|
+
maxItems: 20,
|
|
6497
6538
|
type: "array",
|
|
6498
6539
|
items: {
|
|
6499
6540
|
type: "string",
|
|
6500
6541
|
minLength: 1,
|
|
6501
6542
|
maxLength: 300,
|
|
6502
6543
|
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
6503
|
-
}
|
|
6504
|
-
maxItems: 20
|
|
6544
|
+
}
|
|
6505
6545
|
}
|
|
6506
6546
|
}
|
|
6507
6547
|
},
|
|
@@ -6513,8 +6553,9 @@ var openapi_default = {
|
|
|
6513
6553
|
},
|
|
6514
6554
|
version: {
|
|
6515
6555
|
type: "integer",
|
|
6556
|
+
minimum: 0,
|
|
6516
6557
|
exclusiveMinimum: true,
|
|
6517
|
-
|
|
6558
|
+
maximum: 9007199254740991
|
|
6518
6559
|
},
|
|
6519
6560
|
updatedAt: {
|
|
6520
6561
|
type: "string"
|
|
@@ -6525,13 +6566,15 @@ var openapi_default = {
|
|
|
6525
6566
|
},
|
|
6526
6567
|
providerVersion: {
|
|
6527
6568
|
type: "integer",
|
|
6569
|
+
minimum: 0,
|
|
6528
6570
|
exclusiveMinimum: true,
|
|
6529
|
-
|
|
6571
|
+
maximum: 9007199254740991
|
|
6530
6572
|
},
|
|
6531
6573
|
profileVersion: {
|
|
6532
6574
|
type: "integer",
|
|
6575
|
+
minimum: 0,
|
|
6533
6576
|
exclusiveMinimum: true,
|
|
6534
|
-
|
|
6577
|
+
maximum: 9007199254740991
|
|
6535
6578
|
},
|
|
6536
6579
|
id: {
|
|
6537
6580
|
type: "string",
|
|
@@ -6553,16 +6596,20 @@ var openapi_default = {
|
|
|
6553
6596
|
type: "string"
|
|
6554
6597
|
},
|
|
6555
6598
|
exitCode: {
|
|
6556
|
-
type: "integer"
|
|
6599
|
+
type: "integer",
|
|
6600
|
+
minimum: -9007199254740991,
|
|
6601
|
+
maximum: 9007199254740991
|
|
6557
6602
|
},
|
|
6558
6603
|
routingEvents: {
|
|
6604
|
+
maxItems: 1000,
|
|
6559
6605
|
type: "array",
|
|
6560
6606
|
items: {
|
|
6561
6607
|
type: "object",
|
|
6562
6608
|
properties: {
|
|
6563
6609
|
at: {
|
|
6564
6610
|
type: "string",
|
|
6565
|
-
format: "date-time"
|
|
6611
|
+
format: "date-time",
|
|
6612
|
+
pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
6566
6613
|
},
|
|
6567
6614
|
requestId: {
|
|
6568
6615
|
type: "string",
|
|
@@ -6639,8 +6686,7 @@ var openapi_default = {
|
|
|
6639
6686
|
"decision"
|
|
6640
6687
|
],
|
|
6641
6688
|
additionalProperties: false
|
|
6642
|
-
}
|
|
6643
|
-
maxItems: 1000
|
|
6689
|
+
}
|
|
6644
6690
|
},
|
|
6645
6691
|
routingEventsDropped: {
|
|
6646
6692
|
type: "integer",
|
|
@@ -7153,7 +7199,18 @@ function announceSwitcherLocalMode(home, write = (line) => {
|
|
|
7153
7199
|
import { mkdir as mkdir4, lstat } from "fs/promises";
|
|
7154
7200
|
async function privateDirectory(path) {
|
|
7155
7201
|
await mkdir4(path, { recursive: true, mode: 448 });
|
|
7156
|
-
|
|
7202
|
+
assertPrivateEntry(await lstat(path));
|
|
7203
|
+
}
|
|
7204
|
+
async function checkPrivateDirectory(path) {
|
|
7205
|
+
const info = await lstat(path).catch((error) => {
|
|
7206
|
+
if (error.code === "ENOENT")
|
|
7207
|
+
return;
|
|
7208
|
+
throw error;
|
|
7209
|
+
});
|
|
7210
|
+
if (info)
|
|
7211
|
+
assertPrivateEntry(info);
|
|
7212
|
+
}
|
|
7213
|
+
function assertPrivateEntry(info) {
|
|
7157
7214
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
7158
7215
|
throw new Fault(500, "home_permissions", "Switcher data directory must be a real directory.");
|
|
7159
7216
|
if (process.platform !== "win32" && ((info.mode & 63) !== 0 || info.uid !== process.getuid?.()))
|
|
@@ -8634,16 +8691,25 @@ function createInferenceHandler(input, timing = {}, options = {}) {
|
|
|
8634
8691
|
return fail(error instanceof Fault ? error.status : activity.timedOut() ? 504 : 502, error instanceof Fault ? error.code : activity.timedOut() ? "provider_idle_timeout" : networkError ? "provider_network_error" : "provider_request_failed", error instanceof Fault ? error.code === "opencode_translation_unsupported" ? error.message : undefined : networkError ? `The upstream provider connection ended before response headers. Switcher did not attempt a fallback because delivery is uncertain. ${PROVIDER_FIX}` : activity.timedOut() ? `Switcher gateway: the provider at ${origin} stopped sending data before the request finished. ${PROVIDER_FIX}` : `Switcher gateway: the request to the provider at ${origin} failed before a response arrived. ${PROVIDER_FIX}`);
|
|
8635
8692
|
}
|
|
8636
8693
|
};
|
|
8637
|
-
return {
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8694
|
+
return {
|
|
8695
|
+
bodyLimit,
|
|
8696
|
+
closing: () => closing,
|
|
8697
|
+
handle,
|
|
8698
|
+
close: () => stopped ??= (async () => {
|
|
8699
|
+
closing = true;
|
|
8700
|
+
const pending = [...active];
|
|
8701
|
+
for (const request of pending)
|
|
8702
|
+
request.abort.abort();
|
|
8703
|
+
await Promise.allSettled(pending.map(async (request) => {
|
|
8704
|
+
await request.cancel?.();
|
|
8705
|
+
await request.done;
|
|
8706
|
+
}));
|
|
8707
|
+
})(),
|
|
8708
|
+
drain: () => stopped ??= (async () => {
|
|
8709
|
+
closing = true;
|
|
8710
|
+
await Promise.allSettled([...active].map((request) => request.done));
|
|
8711
|
+
})()
|
|
8712
|
+
};
|
|
8647
8713
|
}
|
|
8648
8714
|
function createInferenceGateway(input, timing = {}) {
|
|
8649
8715
|
const token = crypto.randomUUID() + crypto.randomUUID();
|
|
@@ -8933,7 +8999,7 @@ async function readCodexAgentConfig(path) {
|
|
|
8933
8999
|
}
|
|
8934
9000
|
|
|
8935
9001
|
// src/harnesses.ts
|
|
8936
|
-
import { access as access3, mkdir as mkdir10, readFile as readFile6, readdir as readdir4, writeFile as writeFile13, rm as rm2 } from "fs/promises";
|
|
9002
|
+
import { access as access3, lstat as lstat6, mkdir as mkdir10, readFile as readFile6, readdir as readdir4, rename as rename2, writeFile as writeFile13, rm as rm2 } from "fs/promises";
|
|
8937
9003
|
import { basename as basename2, dirname as dirname7, join as join15, isAbsolute as isAbsolute13, resolve as resolve8 } from "path";
|
|
8938
9004
|
import { homedir as homedir8, tmpdir } from "os";
|
|
8939
9005
|
import { createHash as createHash9, randomUUID as randomUUID4, timingSafeEqual as timingSafeEqual5 } from "crypto";
|
|
@@ -9373,7 +9439,7 @@ import { randomUUID as randomUUID3 } from "crypto";
|
|
|
9373
9439
|
import { Database as Database2 } from "bun:sqlite";
|
|
9374
9440
|
import { parse as parse3, parseTree as parseTree3 } from "jsonc-parser";
|
|
9375
9441
|
import { parseDocument as parseDocument3 } from "yaml";
|
|
9376
|
-
import { z as z6 } from "zod";
|
|
9442
|
+
import { z as z6 } from "zod-v4";
|
|
9377
9443
|
var effect = z6.enum(["allow", "deny", "ask"]);
|
|
9378
9444
|
var rule = z6.object({ action: z6.string(), resource: z6.string(), effect }).strict();
|
|
9379
9445
|
var object4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -10351,6 +10417,33 @@ async function jsonFile(dir, name, value) {
|
|
|
10351
10417
|
`, { mode: 384, flag: "wx" });
|
|
10352
10418
|
return path;
|
|
10353
10419
|
}
|
|
10420
|
+
function claudeSettingsDirectory(sessionDir) {
|
|
10421
|
+
return join15(sessionDir, "settings");
|
|
10422
|
+
}
|
|
10423
|
+
async function durableJsonFile(dir, prefix, value) {
|
|
10424
|
+
const text = JSON.stringify(value, null, 2) + `
|
|
10425
|
+
`;
|
|
10426
|
+
await privateDirectory(dir);
|
|
10427
|
+
const path = join15(dir, `${prefix}-${createHash9("sha256").update(text).digest("hex").slice(0, 32)}.json`);
|
|
10428
|
+
const existing = await lstat6(path).catch(() => {
|
|
10429
|
+
return;
|
|
10430
|
+
});
|
|
10431
|
+
if (existing?.isFile() && (existing.mode & 63) === 0 && existing.uid === process.getuid?.() && await readFile6(path, "utf8").catch(() => {
|
|
10432
|
+
return;
|
|
10433
|
+
}) === text)
|
|
10434
|
+
return path;
|
|
10435
|
+
const temporary = `${path}.${randomUUID4()}.tmp`;
|
|
10436
|
+
await writeFile13(temporary, text, { mode: 384, flag: "wx" });
|
|
10437
|
+
try {
|
|
10438
|
+
await rename2(temporary, path);
|
|
10439
|
+
} catch (error) {
|
|
10440
|
+
await rm2(temporary, { force: true }).catch(() => {
|
|
10441
|
+
return;
|
|
10442
|
+
});
|
|
10443
|
+
throw error;
|
|
10444
|
+
}
|
|
10445
|
+
return path;
|
|
10446
|
+
}
|
|
10354
10447
|
async function projectInstructionPaths(cwd) {
|
|
10355
10448
|
let dir = resolve8(cwd);
|
|
10356
10449
|
while (true) {
|
|
@@ -11025,7 +11118,8 @@ async function prepareNativeLaunch(input, providerBaseUrl = input.providerBaseUr
|
|
|
11025
11118
|
env.ANTHROPIC_API_KEY = "";
|
|
11026
11119
|
env.ANTHROPIC_AUTH_TOKEN = "";
|
|
11027
11120
|
env[input.authStyle === "x-api-key" ? "ANTHROPIC_API_KEY" : "ANTHROPIC_AUTH_TOKEN"] = input.credential ?? "switcher-local-no-auth";
|
|
11028
|
-
const
|
|
11121
|
+
const picker = { modelPicker: { replaceBuiltInOptions: true, options: input.models.map((m) => ({ model: m.id, label: m.name, description: m.description?.slice(0, 300) })) } };
|
|
11122
|
+
const file2 = input.sessionDir ? await durableJsonFile(claudeSettingsDirectory(input.sessionDir), "claude-settings", picker) : await jsonFile(input.stateDir, "claude-settings.json", picker);
|
|
11029
11123
|
configPaths.push(file2);
|
|
11030
11124
|
warnings.push("Claude managed settings and model allowlists can restrict the generated picker.");
|
|
11031
11125
|
return { executable, args: ["--settings", file2, "--model", input.model, ...args], env, configPaths, warnings };
|
|
@@ -11439,16 +11533,16 @@ exec "$SWITCHER_ORI_NATIVE_EXECUTABLE" ${prepared.args.map(quote2).join(" ")}
|
|
|
11439
11533
|
}
|
|
11440
11534
|
|
|
11441
11535
|
// src/launcher.ts
|
|
11442
|
-
import { mkdir as mkdir14, mkdtemp, realpath as realpath8, rm as rm6, writeFile as writeFile18 } from "fs/promises";
|
|
11443
|
-
import { join as join24, resolve as resolve14 } from "path";
|
|
11536
|
+
import { lstat as lstat13, mkdir as mkdir14, mkdtemp, realpath as realpath8, rm as rm6, writeFile as writeFile18 } from "fs/promises";
|
|
11537
|
+
import { join as join24, relative as relative7, resolve as resolve14 } from "path";
|
|
11444
11538
|
|
|
11445
11539
|
// src/provider-credential-onboarding.ts
|
|
11446
|
-
import { z as z9 } from "zod";
|
|
11540
|
+
import { z as z9 } from "zod-v4";
|
|
11447
11541
|
import { createHash as createHash11 } from "crypto";
|
|
11448
11542
|
import { createInterface } from "readline/promises";
|
|
11449
11543
|
|
|
11450
11544
|
// src/opencode-authentication.ts
|
|
11451
|
-
import { z as z7 } from "zod";
|
|
11545
|
+
import { z as z7 } from "zod-v4";
|
|
11452
11546
|
var endpoint3 = "https://opencode.ai/zen/v1/systemone";
|
|
11453
11547
|
var body = JSON.stringify({
|
|
11454
11548
|
model: "jev-1.13-free",
|
|
@@ -11498,10 +11592,10 @@ async function verifyOpenCodeAuthentication(credential, fetchImpl) {
|
|
|
11498
11592
|
}
|
|
11499
11593
|
|
|
11500
11594
|
// src/credentials.ts
|
|
11501
|
-
import { z as z8 } from "zod";
|
|
11595
|
+
import { z as z8 } from "zod-v4";
|
|
11502
11596
|
import { ExecutableTrustError, repairExecutablePermissions, validateExecutable } from "@hasna/contracts/executable-trust";
|
|
11503
11597
|
import { constants as constants5 } from "fs";
|
|
11504
|
-
import { open as open3, readdir as readdir5, unlink, link, lstat as
|
|
11598
|
+
import { open as open3, readdir as readdir5, unlink, link, lstat as lstat7 } from "fs/promises";
|
|
11505
11599
|
import { join as join16, isAbsolute as isAbsolute15 } from "path";
|
|
11506
11600
|
import { createHash as createHash10, randomUUID as randomUUID5 } from "crypto";
|
|
11507
11601
|
import { execFile as execFile3, spawn } from "child_process";
|
|
@@ -11553,7 +11647,7 @@ class CredentialBindings {
|
|
|
11553
11647
|
for (const path of [switcherHome(this.env), join16(switcherHome(this.env), "config"), this.directory]) {
|
|
11554
11648
|
let info;
|
|
11555
11649
|
try {
|
|
11556
|
-
info = await
|
|
11650
|
+
info = await lstat7(path);
|
|
11557
11651
|
} catch (error) {
|
|
11558
11652
|
if (error.code === "ENOENT")
|
|
11559
11653
|
return false;
|
|
@@ -12745,7 +12839,7 @@ import { fileURLToPath } from "url";
|
|
|
12745
12839
|
|
|
12746
12840
|
// src/desktop-state.ts
|
|
12747
12841
|
import { constants as constants7, closeSync as closeSync2, fstatSync, lstatSync, openSync as openSync2, readSync as readSync2 } from "fs";
|
|
12748
|
-
import { open as open4, rm as rm3, lstat as
|
|
12842
|
+
import { open as open4, rm as rm3, lstat as lstat8, rename as rename3, chmod as chmod2, copyFile as copyFile2, link as link2 } from "fs/promises";
|
|
12749
12843
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12750
12844
|
import { resolve as resolve9 } from "path";
|
|
12751
12845
|
import { createHash as createHash12 } from "crypto";
|
|
@@ -12804,7 +12898,7 @@ function desktopSnapshot(bytes, length, opened, after, metadataHash) {
|
|
|
12804
12898
|
}
|
|
12805
12899
|
async function safeDesktopSnapshot(path) {
|
|
12806
12900
|
try {
|
|
12807
|
-
const info = await
|
|
12901
|
+
const info = await lstat8(path);
|
|
12808
12902
|
admitDesktopFile(info);
|
|
12809
12903
|
const metadataHash = admitDesktopMetadata(path, info);
|
|
12810
12904
|
const file = await open4(path, constants7.O_RDONLY | constants7.O_NOFOLLOW);
|
|
@@ -12881,7 +12975,7 @@ async function preserveDesktopFile(source, destination, expected) {
|
|
|
12881
12975
|
var conflictPath = (path, suffix) => path + "." + crypto.randomUUID() + "." + suffix;
|
|
12882
12976
|
async function exists(path) {
|
|
12883
12977
|
try {
|
|
12884
|
-
await
|
|
12978
|
+
await lstat8(path);
|
|
12885
12979
|
return true;
|
|
12886
12980
|
} catch (error) {
|
|
12887
12981
|
if (error.code === "ENOENT")
|
|
@@ -12891,7 +12985,7 @@ async function exists(path) {
|
|
|
12891
12985
|
}
|
|
12892
12986
|
async function preserveConflict(path) {
|
|
12893
12987
|
const target = conflictPath(path, "conflict");
|
|
12894
|
-
await
|
|
12988
|
+
await rename3(path, target);
|
|
12895
12989
|
return target;
|
|
12896
12990
|
}
|
|
12897
12991
|
async function restoreDisplaced(backup, path) {
|
|
@@ -12944,7 +13038,7 @@ async function replaceDesktopFile(path, temporary, expectedCurrent, expectedNew)
|
|
|
12944
13038
|
let displaced = false;
|
|
12945
13039
|
try {
|
|
12946
13040
|
try {
|
|
12947
|
-
await
|
|
13041
|
+
await rename3(path, backup);
|
|
12948
13042
|
displaced = true;
|
|
12949
13043
|
} catch (error) {
|
|
12950
13044
|
if (error.code === "ENOENT")
|
|
@@ -12997,7 +13091,7 @@ async function removeDesktopFile(path, expected, guard) {
|
|
|
12997
13091
|
}
|
|
12998
13092
|
const quarantine = conflictPath(path, "remove");
|
|
12999
13093
|
try {
|
|
13000
|
-
await
|
|
13094
|
+
await rename3(path, quarantine);
|
|
13001
13095
|
} catch (error) {
|
|
13002
13096
|
if (error.code === "ENOENT")
|
|
13003
13097
|
throw new Fault(409, "desktop_state_changed", "Desktop removal target disappeared; existing state was preserved.");
|
|
@@ -13065,7 +13159,7 @@ async function writeDesktopPrivate(path, text, mode = 384, metadataSource, expec
|
|
|
13065
13159
|
}
|
|
13066
13160
|
async function desktopLease(path) {
|
|
13067
13161
|
try {
|
|
13068
|
-
const info = await
|
|
13162
|
+
const info = await lstat8(path);
|
|
13069
13163
|
if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.uid !== process.getuid?.() || (info.mode & 18) !== 0)
|
|
13070
13164
|
throw new Fault(422, "desktop_state_permissions", "Desktop lease must be a regular file owned by this user.");
|
|
13071
13165
|
} catch (error) {
|
|
@@ -13105,7 +13199,7 @@ async function openDesktopLease(path, readOnly2 = false) {
|
|
|
13105
13199
|
}
|
|
13106
13200
|
|
|
13107
13201
|
// src/native-state.ts
|
|
13108
|
-
import { lstat as
|
|
13202
|
+
import { lstat as lstat9, mkdir as mkdir11, open as open5, opendir, readlink, realpath as realpath6, rmdir, symlink as symlink4, unlink as unlink2 } from "fs/promises";
|
|
13109
13203
|
import { constants as constants8, lstatSync as lstatSync2, realpathSync } from "fs";
|
|
13110
13204
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
13111
13205
|
import { homedir as homedir9, userInfo as userInfo3 } from "os";
|
|
@@ -13148,7 +13242,7 @@ var NATIVE_STATE_ENTRIES = {
|
|
|
13148
13242
|
};
|
|
13149
13243
|
async function info(path) {
|
|
13150
13244
|
try {
|
|
13151
|
-
return await
|
|
13245
|
+
return await lstat9(path);
|
|
13152
13246
|
} catch (error) {
|
|
13153
13247
|
if (error.code === "ENOENT")
|
|
13154
13248
|
return;
|
|
@@ -13215,7 +13309,7 @@ function assertSafeAncestor(ancestor, path) {
|
|
|
13215
13309
|
}
|
|
13216
13310
|
async function assertSafeAncestors(path) {
|
|
13217
13311
|
for (let parent = path;; parent = dirname8(parent)) {
|
|
13218
|
-
assertSafeAncestor(await
|
|
13312
|
+
assertSafeAncestor(await lstat9(parent), parent);
|
|
13219
13313
|
if (parent === dirname8(parent))
|
|
13220
13314
|
break;
|
|
13221
13315
|
}
|
|
@@ -13285,19 +13379,24 @@ async function assertNativeStateIsolation(tool, home, environment = process.env)
|
|
|
13285
13379
|
throw new Fault(409, "native_state_isolation_conflict", "This profile redirects its native database. Select a separate isolated profile; Switcher will not rewrite its existing configuration.");
|
|
13286
13380
|
}
|
|
13287
13381
|
}
|
|
13382
|
+
function nativeStateLockPath(state) {
|
|
13383
|
+
return join17(state.home, ".switcher-shared-state.lock");
|
|
13384
|
+
}
|
|
13385
|
+
function nativeStateLockFault(entry) {
|
|
13386
|
+
if (!entry?.isFile() || entry.isSymbolicLink() || entry.uid !== process.getuid?.() || (entry.mode & 63) !== 0)
|
|
13387
|
+
return new Fault(422, "native_state_lock", "The shared-state lock has unsafe ownership, permissions or type.");
|
|
13388
|
+
return new Fault(409, "native_state_busy", "Another Switcher projection/import owns this corpus, or a prior operation ended before releasing its lock. Inspect native processes and the lock before retrying.");
|
|
13389
|
+
}
|
|
13288
13390
|
async function withNativeStateLock(state, operation) {
|
|
13289
13391
|
await ensureNativeStateDirectory(state.home);
|
|
13290
|
-
const path =
|
|
13392
|
+
const path = nativeStateLockPath(state);
|
|
13291
13393
|
let handle;
|
|
13292
13394
|
try {
|
|
13293
13395
|
handle = await open5(path, "wx", 384);
|
|
13294
13396
|
} catch (error) {
|
|
13295
13397
|
if (error.code !== "EEXIST")
|
|
13296
13398
|
throw error;
|
|
13297
|
-
|
|
13298
|
-
if (!entry?.isFile() || entry.isSymbolicLink() || entry.uid !== process.getuid?.() || (entry.mode & 63) !== 0)
|
|
13299
|
-
throw new Fault(422, "native_state_lock", "The shared-state lock has unsafe ownership, permissions or type.");
|
|
13300
|
-
throw new Fault(409, "native_state_busy", "Another Switcher projection/import owns this corpus, or a prior operation ended before releasing its lock. Inspect native processes and the lock before retrying.");
|
|
13399
|
+
throw nativeStateLockFault(await info(path));
|
|
13301
13400
|
}
|
|
13302
13401
|
const identity = await handle.stat();
|
|
13303
13402
|
try {
|
|
@@ -13305,7 +13404,7 @@ async function withNativeStateLock(state, operation) {
|
|
|
13305
13404
|
} finally {
|
|
13306
13405
|
await handle.close();
|
|
13307
13406
|
try {
|
|
13308
|
-
const entry = await
|
|
13407
|
+
const entry = await lstat9(path);
|
|
13309
13408
|
if (entry.dev === identity.dev && entry.ino === identity.ino)
|
|
13310
13409
|
await unlink2(path);
|
|
13311
13410
|
} catch (error) {
|
|
@@ -13338,7 +13437,7 @@ async function assertCorpusLink(link3, root) {
|
|
|
13338
13437
|
for (let hop = 0;; hop++) {
|
|
13339
13438
|
if (hop > 8)
|
|
13340
13439
|
throw refuse("resolves through more than 8 links");
|
|
13341
|
-
const entry = await inspect(current, () =>
|
|
13440
|
+
const entry = await inspect(current, () => lstat9(current));
|
|
13342
13441
|
if (!ownerProbe(entry, current))
|
|
13343
13442
|
throw unsafe(current);
|
|
13344
13443
|
if (!entry.isSymbolicLink()) {
|
|
@@ -13370,7 +13469,7 @@ async function assertCorpusLink(link3, root) {
|
|
|
13370
13469
|
if (strictlyInside(canonical, link3))
|
|
13371
13470
|
throw refuse(`points at its own ancestor ${displayPath(canonical)}`);
|
|
13372
13471
|
for (let directory = dirname8(canonical);directory !== root; directory = dirname8(directory)) {
|
|
13373
|
-
const item2 = await inspect(directory, () =>
|
|
13472
|
+
const item2 = await inspect(directory, () => lstat9(directory));
|
|
13374
13473
|
if (!item2.isDirectory() || !ownerProbe(item2, directory) || writableByOthers(item2))
|
|
13375
13474
|
throw unsafe(directory);
|
|
13376
13475
|
}
|
|
@@ -13398,7 +13497,7 @@ async function assertShareableTree(path, budget = { entries: 0 }, depth = 0, roo
|
|
|
13398
13497
|
await assertCorpusLink(nested, root);
|
|
13399
13498
|
continue;
|
|
13400
13499
|
}
|
|
13401
|
-
const entry = await
|
|
13500
|
+
const entry = await lstat9(nested);
|
|
13402
13501
|
if (!ownerProbe(entry, nested) || writableByOthers(entry))
|
|
13403
13502
|
throw new Fault(422, "native_state_entry", `The shared native state entry ${displayPath(nested)} is not owned by you or is writable by other users. ${writeFix}.`);
|
|
13404
13503
|
if (child.isDirectory()) {
|
|
@@ -13467,10 +13566,13 @@ async function codexInstructionProjection(home, config, allowedExternalFiles = {
|
|
|
13467
13566
|
}
|
|
13468
13567
|
return instructions;
|
|
13469
13568
|
}
|
|
13470
|
-
async function assertNativeInstructionOverlay(state, overlayHome) {
|
|
13569
|
+
async function assertNativeInstructionOverlay(state, overlayHome, options = {}) {
|
|
13471
13570
|
if (state.tool !== "codex" || absolute(overlayHome) === state.home)
|
|
13472
13571
|
return;
|
|
13473
|
-
await
|
|
13572
|
+
if (options.plan && !await info(absolute(overlayHome)))
|
|
13573
|
+
await assertCreatableNativeStateDirectory(absolute(overlayHome));
|
|
13574
|
+
else
|
|
13575
|
+
await assertNativeStateDirectory(overlayHome);
|
|
13474
13576
|
const config = await readCodexStateConfig(overlayHome);
|
|
13475
13577
|
if (config.profiles !== undefined || config.include !== undefined)
|
|
13476
13578
|
throw new Fault(422, "native_state_instruction_overlay", "Private Codex profile/include instruction overlays are not supported. Resolve their effective canonical instructions before launching.");
|
|
@@ -13527,7 +13629,7 @@ async function assertCodexDatabaseRedirectSafe(state, overlayHome) {
|
|
|
13527
13629
|
if (root === (state.sqliteHome ?? state.home) || !await info(root))
|
|
13528
13630
|
continue;
|
|
13529
13631
|
await assertNativeStateDirectory(root);
|
|
13530
|
-
const before = await
|
|
13632
|
+
const before = await lstat9(root);
|
|
13531
13633
|
let inspected = 0;
|
|
13532
13634
|
for await (const entry of await opendir(root)) {
|
|
13533
13635
|
if (++inspected > 1e4)
|
|
@@ -13535,7 +13637,7 @@ async function assertCodexDatabaseRedirectSafe(state, overlayHome) {
|
|
|
13535
13637
|
if (/^(?:state|logs|goals|memories|queue|thread_history)_\d+\.sqlite(?:-(?:wal|shm))?$/.test(entry.name))
|
|
13536
13638
|
throw new Fault(409, "native_state_migration_required", "This profile retains native database metadata. Reconcile its catalog and history before redirecting shared state.");
|
|
13537
13639
|
}
|
|
13538
|
-
const after = await
|
|
13640
|
+
const after = await lstat9(root);
|
|
13539
13641
|
if (after.isSymbolicLink() || before.dev !== after.dev || before.ino !== after.ino || before.mtimeMs !== after.mtimeMs)
|
|
13540
13642
|
throw new Fault(409, "native_state_inventory_changed", "Native database inventory changed; no state was projected.");
|
|
13541
13643
|
}
|
|
@@ -13590,10 +13692,25 @@ async function createTrackedDirectory(path, created) {
|
|
|
13590
13692
|
await assertNativeStateDirectory(path);
|
|
13591
13693
|
}
|
|
13592
13694
|
}
|
|
13593
|
-
async function
|
|
13695
|
+
async function assertCreatableNativeStateDirectory(path) {
|
|
13696
|
+
let existing = dirname8(path);
|
|
13697
|
+
while (!await info(existing) && existing !== dirname8(existing))
|
|
13698
|
+
existing = dirname8(existing);
|
|
13699
|
+
if (await realpath6(existing) !== existing)
|
|
13700
|
+
assertNativeDirectoryEntry(await info(path), path, true);
|
|
13701
|
+
await assertSafeAncestors(existing);
|
|
13702
|
+
}
|
|
13703
|
+
async function preflightNativeStateProjection(state, overlayHome, plan = false) {
|
|
13594
13704
|
overlayHome = absolute(overlayHome);
|
|
13595
|
-
await
|
|
13596
|
-
|
|
13705
|
+
const corpus = !plan || Boolean(await info(state.home)), overlay = !plan || Boolean(await info(overlayHome));
|
|
13706
|
+
if (corpus)
|
|
13707
|
+
await assertNativeStateDirectory(state.home);
|
|
13708
|
+
else
|
|
13709
|
+
await ensureNativeStateDirectory(state.home, false);
|
|
13710
|
+
if (overlay)
|
|
13711
|
+
await assertNativeStateDirectory(overlayHome);
|
|
13712
|
+
else
|
|
13713
|
+
await assertCreatableNativeStateDirectory(overlayHome);
|
|
13597
13714
|
if (overlayHome === state.home)
|
|
13598
13715
|
return;
|
|
13599
13716
|
const contains = (parent, child) => {
|
|
@@ -13605,9 +13722,11 @@ async function projectNativeStateUnlocked(state, overlayHome) {
|
|
|
13605
13722
|
await assertCodexDatabaseRedirectSafe(state, overlayHome);
|
|
13606
13723
|
for (const entry of NATIVE_STATE_ENTRIES[state.tool]) {
|
|
13607
13724
|
const target = join17(state.home, entry.name), destination = join17(overlayHome, entry.name);
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13725
|
+
if (corpus)
|
|
13726
|
+
await ensureNativeStateDirectory(dirname8(target), false);
|
|
13727
|
+
if (overlay)
|
|
13728
|
+
await ensureNativeStateDirectory(dirname8(destination), false);
|
|
13729
|
+
const source = corpus ? await info(target) : undefined, existing = overlay ? await info(destination) : undefined;
|
|
13611
13730
|
if (source && (source.isSymbolicLink() || source.uid !== process.getuid?.() || writableByOthers(source) || source.isFile() && source.nlink !== 1 || (entry.kind === "directory" ? !source.isDirectory() : !source.isFile())))
|
|
13612
13731
|
throw new Fault(422, "native_state_entry", `The shared native state entry ${displayPath(target)} must be a ${entry.kind === "directory" ? "real directory" : "regular file with a single link"} owned by you and not writable by other users. ${writeFix}.`);
|
|
13613
13732
|
if (source?.isDirectory())
|
|
@@ -13615,6 +13734,12 @@ async function projectNativeStateUnlocked(state, overlayHome) {
|
|
|
13615
13734
|
if (existing && (!existing.isSymbolicLink() || resolve10(dirname8(destination), await readlink(destination)) !== target))
|
|
13616
13735
|
throw new Fault(409, "native_state_migration_required", `This launch profile already contains native state at ${displayPath(destination)}, which is not a link to ${displayPath(target)}. Preserve and migrate its noncredential state before linking the shared corpus.`);
|
|
13617
13736
|
}
|
|
13737
|
+
}
|
|
13738
|
+
async function projectNativeStateUnlocked(state, overlayHome) {
|
|
13739
|
+
overlayHome = absolute(overlayHome);
|
|
13740
|
+
await preflightNativeStateProjection(state, overlayHome);
|
|
13741
|
+
if (overlayHome === state.home)
|
|
13742
|
+
return;
|
|
13618
13743
|
const createdLinks = [];
|
|
13619
13744
|
const createdFiles = [], createdDirectories = [];
|
|
13620
13745
|
try {
|
|
@@ -13672,6 +13797,14 @@ async function projectNativeState(state, overlayHome) {
|
|
|
13672
13797
|
return;
|
|
13673
13798
|
return withNativeStateLock(state, () => projectNativeStateUnlocked(state, overlayHome));
|
|
13674
13799
|
}
|
|
13800
|
+
async function checkNativeStateProjection(state, overlayHome) {
|
|
13801
|
+
if (absolute(overlayHome) === state.home)
|
|
13802
|
+
return;
|
|
13803
|
+
const lock = await info(nativeStateLockPath(state));
|
|
13804
|
+
if (lock)
|
|
13805
|
+
throw nativeStateLockFault(lock);
|
|
13806
|
+
return preflightNativeStateProjection(state, overlayHome, true);
|
|
13807
|
+
}
|
|
13675
13808
|
|
|
13676
13809
|
// src/chatgpt-launch.ts
|
|
13677
13810
|
var object5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -13822,7 +13955,7 @@ import { writeFile as writeFile17 } from "fs/promises";
|
|
|
13822
13955
|
import { join as join21 } from "path";
|
|
13823
13956
|
// src/desktop-selection.ts
|
|
13824
13957
|
import { createHash as createHash14, randomUUID as randomUUID6 } from "crypto";
|
|
13825
|
-
import { writeFile as writeFile15, rename as
|
|
13958
|
+
import { writeFile as writeFile15, rename as rename4 } from "fs/promises";
|
|
13826
13959
|
import { join as join19 } from "path";
|
|
13827
13960
|
var hash2 = (text) => createHash14("sha256").update(text).digest("hex");
|
|
13828
13961
|
var conflict = () => new Fault(409, "desktop_config_changed", "Desktop configuration changed; existing bytes and the recovery receipt were preserved.");
|
|
@@ -13994,17 +14127,17 @@ async function recoverDesktopSelection(library) {
|
|
|
13994
14127
|
if (!sameDesktopSnapshot(finalReceipt2, redacted)) {
|
|
13995
14128
|
const foreignPath = recoveredPath + ".foreign-" + randomUUID6();
|
|
13996
14129
|
if (finalReceipt2 !== undefined)
|
|
13997
|
-
await
|
|
14130
|
+
await rename4(recoveredPath, foreignPath);
|
|
13998
14131
|
await writeDesktopPrivate(recoveredPath, retained, 384, undefined, { current: undefined });
|
|
13999
14132
|
throw new Fault(409, "desktop_config_changed", `Desktop recovery receipt changed; redacted receipt preserved at ${recoveredPath}; foreign receipt preserved at ${foreignPath}.`);
|
|
14000
14133
|
}
|
|
14001
14134
|
return;
|
|
14002
14135
|
}
|
|
14003
|
-
await
|
|
14136
|
+
await rename4(path, recoveredPath);
|
|
14004
14137
|
const preserveRecovered = async (snapshot2) => {
|
|
14005
14138
|
const foreignPath = recoveredPath + ".foreign-" + randomUUID6();
|
|
14006
14139
|
if (snapshot2 !== undefined)
|
|
14007
|
-
await
|
|
14140
|
+
await rename4(recoveredPath, foreignPath);
|
|
14008
14141
|
await writeDesktopPrivate(recoveredPath, raw, 384, undefined, { current: undefined });
|
|
14009
14142
|
throw new Fault(409, "desktop_config_changed", `Desktop recovery receipt changed; original receipt preserved at ${recoveredPath}; foreign receipt preserved at ${foreignPath}.`);
|
|
14010
14143
|
};
|
|
@@ -14102,9 +14235,9 @@ async function applyDesktopSelection(library, config, label2, checkpoint) {
|
|
|
14102
14235
|
|
|
14103
14236
|
// src/claude-user-settings.ts
|
|
14104
14237
|
import { constants as constants9 } from "fs";
|
|
14105
|
-
import { lstat as
|
|
14238
|
+
import { lstat as lstat10, open as open6, writeFile as writeFile16 } from "fs/promises";
|
|
14106
14239
|
import { homedir as homedir10 } from "os";
|
|
14107
|
-
import { join as join20, resolve as resolve11 } from "path";
|
|
14240
|
+
import { join as join20, relative as relative6, resolve as resolve11 } from "path";
|
|
14108
14241
|
var preferences = new Set([
|
|
14109
14242
|
"$schema",
|
|
14110
14243
|
"permissions",
|
|
@@ -14152,10 +14285,15 @@ function routingOrCredentialEnvironmentKey(key) {
|
|
|
14152
14285
|
return /^(?:ANTHROPIC_|CLAUDE_CODE_USE_|CLAUDE_CODE_OAUTH|AWS_|GOOGLE_|VERTEX_|CLOUD_ML_|AZURE_|OTEL_EXPORTER_OTLP_HEADERS)/i.test(key) || /TOKEN|KEY|SECRET|PASSWORD|CREDENTIAL|AUTH|PROXY/i.test(key);
|
|
14153
14286
|
}
|
|
14154
14287
|
var invalid4 = (path) => new Fault(422, "claude_user_settings", `Claude user settings ${displayPath(path)} cannot be safely projected. Use a regular JSON file with a single link, owned by you and not writable by other users, with supported preferences and permission policy.`);
|
|
14155
|
-
async function readSettings(home) {
|
|
14288
|
+
async function readSettings(home, created) {
|
|
14289
|
+
const inside3 = created !== undefined && ((suffix) => suffix !== ".." && !suffix.startsWith("../"))(relative6(created, home));
|
|
14290
|
+
if (inside3 && !await lstat10(home).catch(() => {
|
|
14291
|
+
return;
|
|
14292
|
+
}))
|
|
14293
|
+
return;
|
|
14156
14294
|
await ensureNativeStateDirectory(home, false);
|
|
14157
14295
|
const path = join20(home, "settings.json");
|
|
14158
|
-
const entry = await
|
|
14296
|
+
const entry = await lstat10(path).catch((error) => {
|
|
14159
14297
|
if (error.code === "ENOENT")
|
|
14160
14298
|
return;
|
|
14161
14299
|
throw error;
|
|
@@ -14219,10 +14357,10 @@ function project(settings2, existing, path) {
|
|
|
14219
14357
|
}
|
|
14220
14358
|
return { settings: result, dropped };
|
|
14221
14359
|
}
|
|
14222
|
-
async function prepareClaudeUserSettings(overlayHome, environment = process.env, corpusHome) {
|
|
14360
|
+
async function prepareClaudeUserSettings(overlayHome, environment = process.env, corpusHome, options = {}) {
|
|
14223
14361
|
overlayHome = resolve11(overlayHome);
|
|
14224
14362
|
const target = join20(overlayHome, "settings.json");
|
|
14225
|
-
const existing = await readSettings(overlayHome);
|
|
14363
|
+
const existing = await readSettings(overlayHome, options.write === false ? options.created : undefined);
|
|
14226
14364
|
if (existing !== undefined) {
|
|
14227
14365
|
project(existing, true, target);
|
|
14228
14366
|
return [];
|
|
@@ -14234,6 +14372,9 @@ async function prepareClaudeUserSettings(overlayHome, environment = process.env,
|
|
|
14234
14372
|
if (source === undefined)
|
|
14235
14373
|
return [];
|
|
14236
14374
|
const { settings: settings2, dropped } = project(source, false, join20(sourceHome, "settings.json"));
|
|
14375
|
+
const warnings = dropped.length ? [`Claude user settings not copied to this launch's private settings (unsupported keys): ${dropped.map((key) => JSON.stringify(key)).join(", ")}.`] : [];
|
|
14376
|
+
if (options.write === false)
|
|
14377
|
+
return warnings;
|
|
14237
14378
|
await ensureNativeStateDirectory(overlayHome);
|
|
14238
14379
|
try {
|
|
14239
14380
|
await writeFile16(target, JSON.stringify(settings2, null, 2) + `
|
|
@@ -14245,7 +14386,7 @@ async function prepareClaudeUserSettings(overlayHome, environment = process.env,
|
|
|
14245
14386
|
if (concurrent === undefined || JSON.stringify(project(concurrent, true, target).settings) !== JSON.stringify(settings2))
|
|
14246
14387
|
throw new Fault(409, "claude_user_settings_changed", `The private Claude settings ${displayPath(target)} changed during preparation. Existing settings were preserved; retry after resolving the concurrent launch.`);
|
|
14247
14388
|
}
|
|
14248
|
-
return
|
|
14389
|
+
return warnings;
|
|
14249
14390
|
}
|
|
14250
14391
|
|
|
14251
14392
|
// src/claude-desktop-launch.ts
|
|
@@ -14540,13 +14681,13 @@ import { closeSync as closeSync3, openSync as openSync3 } from "fs";
|
|
|
14540
14681
|
// src/gateway-service.ts
|
|
14541
14682
|
import { createHash as createHash16, randomBytes as randomBytes2, randomUUID as randomUUID7 } from "crypto";
|
|
14542
14683
|
import { constants as constants10 } from "fs";
|
|
14543
|
-
import { chmod as chmod3, lstat as
|
|
14684
|
+
import { chmod as chmod3, lstat as lstat11, mkdir as mkdir12, open as open7, readdir as readdir7, rename as rename5, rm as rm5, unlink as unlink3 } from "fs/promises";
|
|
14544
14685
|
import { basename as basename5, dirname as dirname9, isAbsolute as isAbsolute17, join as join22, resolve as resolve13 } from "path";
|
|
14545
|
-
import { z as z10 } from "zod";
|
|
14686
|
+
import { z as z10 } from "zod-v4";
|
|
14546
14687
|
|
|
14547
14688
|
// src/process-table.ts
|
|
14548
14689
|
import { createHash as createHash15 } from "crypto";
|
|
14549
|
-
import { readdir as readdir6, readFile as readFile7 } from "fs/promises";
|
|
14690
|
+
import { readdir as readdir6, readFile as readFile7, readlink as readlink2 } from "fs/promises";
|
|
14550
14691
|
var MAX_PROCESSES = 1e5;
|
|
14551
14692
|
async function darwinTable() {
|
|
14552
14693
|
const child = Bun.spawn(["/bin/ps", "-A", "-o", "pid=", "-o", "ppid=", "-o", "lstart="], {
|
|
@@ -14618,11 +14759,6 @@ function descendants(table, roots, exclude = []) {
|
|
|
14618
14759
|
}
|
|
14619
14760
|
return found;
|
|
14620
14761
|
}
|
|
14621
|
-
function isOrphan(entry, table) {
|
|
14622
|
-
if (entry.ppid === 1)
|
|
14623
|
-
return true;
|
|
14624
|
-
return entry.ppid !== entry.pid && table.get(entry.ppid)?.comm === "systemd";
|
|
14625
|
-
}
|
|
14626
14762
|
var TOKEN_ENTRY = /^[A-Za-z_][A-Za-z0-9_]*=([A-Za-z0-9_-]{43})$/;
|
|
14627
14763
|
var holdsDigest = (entries, digest2) => {
|
|
14628
14764
|
for (const entry of entries) {
|
|
@@ -14675,12 +14811,97 @@ function processesHoldingTokenDigest(pids, digest2) {
|
|
|
14675
14811
|
return linuxDigestHolders(pids, digest2);
|
|
14676
14812
|
return Promise.resolve([]);
|
|
14677
14813
|
}
|
|
14814
|
+
var PEER_LOOKUP_TIMEOUT_MS = 5000;
|
|
14815
|
+
var loopbackAddress = (hex) => hex === "0100007F" || hex === "0000000000000000FFFF00000100007F";
|
|
14816
|
+
var loopbackPeers = (clientPort, serverPort) => {
|
|
14817
|
+
if (!Number.isSafeInteger(clientPort) || !Number.isSafeInteger(serverPort))
|
|
14818
|
+
return Promise.resolve([]);
|
|
14819
|
+
if (process.platform === "darwin")
|
|
14820
|
+
return darwinPeers(clientPort, serverPort).catch(() => []);
|
|
14821
|
+
if (process.platform === "linux")
|
|
14822
|
+
return linuxPeers(clientPort, serverPort).catch(() => []);
|
|
14823
|
+
return Promise.resolve([]);
|
|
14824
|
+
};
|
|
14825
|
+
async function darwinPeers(clientPort, serverPort) {
|
|
14826
|
+
const uid = process.getuid?.();
|
|
14827
|
+
if (uid === undefined)
|
|
14828
|
+
return [];
|
|
14829
|
+
const child = Bun.spawn(["/usr/sbin/lsof", "-nP", "-w", "-a", "-u", String(uid), `-iTCP@127.0.0.1:${clientPort}`, "-sTCP:ESTABLISHED", "-Fpn"], {
|
|
14830
|
+
env: { PATH: "/usr/bin:/bin:/usr/sbin", LC_ALL: "C" },
|
|
14831
|
+
stdin: "ignore",
|
|
14832
|
+
stdout: "pipe",
|
|
14833
|
+
stderr: "pipe"
|
|
14834
|
+
});
|
|
14835
|
+
let timedOut = false;
|
|
14836
|
+
const timer = setTimeout(() => {
|
|
14837
|
+
timedOut = true;
|
|
14838
|
+
child.kill("SIGKILL");
|
|
14839
|
+
}, PEER_LOOKUP_TIMEOUT_MS);
|
|
14840
|
+
const [text, errors] = await Promise.all([new Response(child.stdout).text(), new Response(child.stderr).text(), child.exited]).finally(() => clearTimeout(timer));
|
|
14841
|
+
if (timedOut || errors.trim())
|
|
14842
|
+
return [];
|
|
14843
|
+
const wanted = `n127.0.0.1:${clientPort}->127.0.0.1:${serverPort}`, found = new Set;
|
|
14844
|
+
let pid;
|
|
14845
|
+
for (const line of text.split(`
|
|
14846
|
+
`)) {
|
|
14847
|
+
if (line.startsWith("p"))
|
|
14848
|
+
pid = Number(line.slice(1));
|
|
14849
|
+
else if (line === wanted && pid !== undefined && Number.isSafeInteger(pid))
|
|
14850
|
+
found.add(pid);
|
|
14851
|
+
}
|
|
14852
|
+
return [...found];
|
|
14853
|
+
}
|
|
14854
|
+
async function linuxPeers(clientPort, serverPort) {
|
|
14855
|
+
const uid = process.getuid?.();
|
|
14856
|
+
if (uid === undefined)
|
|
14857
|
+
return [];
|
|
14858
|
+
const inodes = new Set;
|
|
14859
|
+
for (const table of ["/proc/net/tcp", "/proc/net/tcp6"]) {
|
|
14860
|
+
const text = await readFile7(table, "utf8").catch(() => "");
|
|
14861
|
+
for (const line of text.split(`
|
|
14862
|
+
`).slice(1)) {
|
|
14863
|
+
const fields = line.trim().split(/\s+/);
|
|
14864
|
+
if (fields.length < 10)
|
|
14865
|
+
continue;
|
|
14866
|
+
const [localAddress = "", localPort = ""] = fields[1].split(":"), [remoteAddress = "", remotePort = ""] = fields[2].split(":");
|
|
14867
|
+
if (!loopbackAddress(localAddress.toUpperCase()) || !loopbackAddress(remoteAddress.toUpperCase()))
|
|
14868
|
+
continue;
|
|
14869
|
+
if (Number.parseInt(localPort, 16) === clientPort && Number.parseInt(remotePort, 16) === serverPort && fields[3] === "01" && Number(fields[7]) === uid)
|
|
14870
|
+
inodes.add(fields[9]);
|
|
14871
|
+
}
|
|
14872
|
+
}
|
|
14873
|
+
if (!inodes.size)
|
|
14874
|
+
return [];
|
|
14875
|
+
const found = [];
|
|
14876
|
+
for (const name of await readdir6("/proc")) {
|
|
14877
|
+
if (!/^\d+$/.test(name))
|
|
14878
|
+
continue;
|
|
14879
|
+
let descriptors;
|
|
14880
|
+
try {
|
|
14881
|
+
descriptors = await readdir6(`/proc/${name}/fd`);
|
|
14882
|
+
} catch {
|
|
14883
|
+
continue;
|
|
14884
|
+
}
|
|
14885
|
+
for (const descriptor of descriptors) {
|
|
14886
|
+
const target = /^socket:\[(\d+)\]$/.exec(await readlink2(`/proc/${name}/fd/${descriptor}`).catch(() => ""));
|
|
14887
|
+
if (target && inodes.has(target[1])) {
|
|
14888
|
+
found.push(Number(name));
|
|
14889
|
+
break;
|
|
14890
|
+
}
|
|
14891
|
+
}
|
|
14892
|
+
}
|
|
14893
|
+
return found;
|
|
14894
|
+
}
|
|
14678
14895
|
|
|
14679
14896
|
// src/gateway-service.ts
|
|
14680
14897
|
var GATEWAY_PROTOCOL = 1;
|
|
14681
14898
|
var SOCKET_PATH_LIMIT = 100;
|
|
14682
14899
|
var MAX_HOLDERS = 4096;
|
|
14683
|
-
var
|
|
14900
|
+
var MAX_PROBE_CANDIDATES = 4096;
|
|
14901
|
+
var PROBE_INTERVAL_MS = 60000;
|
|
14902
|
+
var ENDED_MS = 30 * 24 * 3600000;
|
|
14903
|
+
var MAX_ENDED = 1000;
|
|
14904
|
+
var REVIVE_RETRY_MS = 5000;
|
|
14684
14905
|
var MAX_EVENTS = 1000;
|
|
14685
14906
|
var MAX_EVENT_BYTES = 512 * 1024;
|
|
14686
14907
|
var DEFAULT_GRACE_MS = 10 * 60000;
|
|
@@ -14693,11 +14914,11 @@ function gatewayPaths(env = process.env) {
|
|
|
14693
14914
|
const name = `${createHash16("sha256").update(root).digest("hex").slice(0, 16)}.sock`;
|
|
14694
14915
|
const runtime = process.platform === "linux" && env.XDG_RUNTIME_DIR && isAbsolute17(env.XDG_RUNTIME_DIR) ? join22(env.XDG_RUNTIME_DIR, "switcher", name) : undefined;
|
|
14695
14916
|
const socket = Buffer.byteLength(preferred) <= SOCKET_PATH_LIMIT ? preferred : runtime && Buffer.byteLength(runtime) <= SOCKET_PATH_LIMIT ? runtime : join22("/tmp", `switcher-${process.getuid?.() ?? 0}`, name);
|
|
14696
|
-
return { root, socket, launches: join22(root, "launches"), config: join22(root, "config.json"), log: join22(root, "service.log") };
|
|
14917
|
+
return { root, socket, launches: join22(root, "launches"), ended: join22(root, "ended"), config: join22(root, "config.json"), log: join22(root, "service.log") };
|
|
14697
14918
|
}
|
|
14698
14919
|
var UNTRUSTED_FIX = "Another account may have created it: remove it (or set HASNA_SWITCHER_HOME to a shorter path) and launch again.";
|
|
14699
14920
|
async function assertPrivateSocketDirectory(directory) {
|
|
14700
|
-
const info2 = await
|
|
14921
|
+
const info2 = await lstat11(directory);
|
|
14701
14922
|
if (!info2.isDirectory() || info2.isSymbolicLink() || (info2.mode & 63) !== 0 || info2.uid !== process.getuid?.())
|
|
14702
14923
|
throw new Fault(503, "gateway_socket_untrusted", `The Switcher gateway socket directory ${directory} is not a private directory owned by this user (mode 0700), so Switcher will not use it. ${UNTRUSTED_FIX}`);
|
|
14703
14924
|
}
|
|
@@ -14712,7 +14933,7 @@ async function assertTrustedControlSocket(socket) {
|
|
|
14712
14933
|
}
|
|
14713
14934
|
let info2;
|
|
14714
14935
|
try {
|
|
14715
|
-
info2 = await
|
|
14936
|
+
info2 = await lstat11(socket);
|
|
14716
14937
|
} catch (error) {
|
|
14717
14938
|
if (error.code === "ENOENT")
|
|
14718
14939
|
throw missing();
|
|
@@ -14859,6 +15080,9 @@ var staticSchema = z10.object({
|
|
|
14859
15080
|
stateDir: z10.string().max(4096).optional()
|
|
14860
15081
|
}).strict();
|
|
14861
15082
|
var holderStateSchema = z10.object({ lastUsedAt: z10.number(), lastHolderAt: z10.number(), released: z10.boolean(), holders: z10.array(holderSchema).max(MAX_HOLDERS), extendedAt: z10.number().optional() }).strict();
|
|
15083
|
+
var endedSchema = staticSchema.omit({ stateDir: true }).extend({ endedAt: z10.number() }).strict();
|
|
15084
|
+
var MAX_FAILED_PORTS = 64;
|
|
15085
|
+
var MAX_LOOKUPS_PER_RETRY = 4;
|
|
14862
15086
|
var processKey = (entry) => `${entry.pid}@${entry.start}`;
|
|
14863
15087
|
var SETTLED_MS = 120000;
|
|
14864
15088
|
var SETTLED_SCAN_FACTOR = 5;
|
|
@@ -14909,14 +15133,14 @@ async function writePrivate(path, text) {
|
|
|
14909
15133
|
} finally {
|
|
14910
15134
|
await file.close();
|
|
14911
15135
|
}
|
|
14912
|
-
await
|
|
15136
|
+
await rename5(temporary, path);
|
|
14913
15137
|
}
|
|
14914
15138
|
async function launchStateDirectory(path) {
|
|
14915
15139
|
if (path === undefined)
|
|
14916
15140
|
return;
|
|
14917
15141
|
if (!isAbsolute17(path) || resolve13(path) !== path || !/^launch-[A-Za-z0-9]{6}$/.test(basename5(path)))
|
|
14918
15142
|
throw new Fault(400, "invalid_state_dir", "The launch state directory must be an absolute launch-XXXXXX directory.");
|
|
14919
|
-
const info2 = await
|
|
15143
|
+
const info2 = await lstat11(path).catch(() => {
|
|
14920
15144
|
return;
|
|
14921
15145
|
});
|
|
14922
15146
|
if (!info2?.isDirectory() || info2.isSymbolicLink() || info2.uid !== process.getuid?.() || (info2.mode & 63) !== 0)
|
|
@@ -14933,6 +15157,7 @@ async function startGatewayService(options = {}) {
|
|
|
14933
15157
|
const graceMs = options.graceMs ?? settings2.graceMs, scanMs = options.scanMs ?? settings2.scanMs;
|
|
14934
15158
|
const processTable = options.processTable ?? readProcessTable;
|
|
14935
15159
|
const environmentProbe = options.environmentProbe ?? processesHoldingTokenDigest;
|
|
15160
|
+
const connectionPeers = options.connectionPeers ?? loopbackPeers;
|
|
14936
15161
|
const log = options.log ?? ((line) => console.error(`switcher-gateway ${new Date().toISOString()} ${line}`));
|
|
14937
15162
|
const resolver = new CredentialResolver(env);
|
|
14938
15163
|
const resolveCredential2 = options.resolveCredential ?? ((provider) => resolver.resolve(provider));
|
|
@@ -14940,6 +15165,7 @@ async function startGatewayService(options = {}) {
|
|
|
14940
15165
|
await privateDirectory(switcherHome(env));
|
|
14941
15166
|
await privateDirectory(paths.root);
|
|
14942
15167
|
await privateDirectory(paths.launches);
|
|
15168
|
+
await privateDirectory(paths.ended);
|
|
14943
15169
|
await socketDirectory(paths);
|
|
14944
15170
|
let persisted = {};
|
|
14945
15171
|
try {
|
|
@@ -14949,6 +15175,7 @@ async function startGatewayService(options = {}) {
|
|
|
14949
15175
|
} catch {}
|
|
14950
15176
|
const requestedPort = options.port ?? settings2.port ?? persisted.port ?? (isDefaultSwitcherHome(env) ? defaultGatewayPort() : 0);
|
|
14951
15177
|
const launches = new Map, byDigest = new Map;
|
|
15178
|
+
const ended = new Map;
|
|
14952
15179
|
let closing = false, stopping, resolveClosed, idleSince = now();
|
|
14953
15180
|
const closed = new Promise((resolve14) => {
|
|
14954
15181
|
resolveClosed = resolve14;
|
|
@@ -15018,32 +15245,73 @@ async function startGatewayService(options = {}) {
|
|
|
15018
15245
|
byDigest.set(record3.tokenDigest, launch);
|
|
15019
15246
|
return launch;
|
|
15020
15247
|
};
|
|
15021
|
-
const
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
await launch.handler.close().catch(() => {
|
|
15027
|
-
return;
|
|
15028
|
-
});
|
|
15029
|
-
await rm5(join22(paths.launches, `${launch.record.id}.holders.json`), { force: true }).catch(() => {
|
|
15248
|
+
const endedPath = (id2) => join22(paths.ended, `${id2}.json`);
|
|
15249
|
+
const forgetEnded = async (entry) => {
|
|
15250
|
+
if (ended.get(entry.record.tokenDigest) === entry)
|
|
15251
|
+
ended.delete(entry.record.tokenDigest);
|
|
15252
|
+
await rm5(endedPath(entry.record.id), { force: true }).catch(() => {
|
|
15030
15253
|
return;
|
|
15031
15254
|
});
|
|
15032
|
-
|
|
15255
|
+
};
|
|
15256
|
+
const pruneEnded = async (at) => {
|
|
15257
|
+
const entries = [...ended.values()].sort((a, b) => a.record.endedAt - b.record.endedAt);
|
|
15258
|
+
for (const [index, entry] of entries.entries())
|
|
15259
|
+
if (at - entry.record.endedAt > ENDED_MS || entries.length - index > MAX_ENDED)
|
|
15260
|
+
await forgetEnded(entry);
|
|
15261
|
+
};
|
|
15262
|
+
const endedEntry = (launch) => {
|
|
15263
|
+
const { stateDir: _state, ...fixed } = staticFields(launch.record);
|
|
15264
|
+
return { record: { ...fixed, endedAt: now() }, ...launch.record.credential.source === "ephemeral" && launch.credential !== undefined ? { credential: launch.credential } : {}, failed: new Map, lookups: [] };
|
|
15265
|
+
};
|
|
15266
|
+
const remove = async (launch, reason, removeState, end = false) => {
|
|
15267
|
+
if (!launches.delete(launch.record.id))
|
|
15033
15268
|
return;
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15269
|
+
const entry = end ? endedEntry(launch) : undefined;
|
|
15270
|
+
let settle;
|
|
15271
|
+
if (entry) {
|
|
15272
|
+
entry.settled = new Promise((resolve14) => {
|
|
15273
|
+
settle = resolve14;
|
|
15274
|
+
});
|
|
15275
|
+
ended.set(launch.record.tokenDigest, entry);
|
|
15276
|
+
}
|
|
15277
|
+
byDigest.delete(launch.record.tokenDigest);
|
|
15278
|
+
try {
|
|
15279
|
+
launch.credential = undefined;
|
|
15280
|
+
if (entry)
|
|
15281
|
+
launch.handler.drain().catch(() => {
|
|
15282
|
+
return;
|
|
15283
|
+
});
|
|
15284
|
+
else
|
|
15285
|
+
await launch.handler.close().catch(() => {
|
|
15286
|
+
return;
|
|
15287
|
+
});
|
|
15288
|
+
if (entry)
|
|
15289
|
+
await writePrivate(endedPath(launch.record.id), JSON.stringify(entry.record)).catch(() => {
|
|
15290
|
+
return;
|
|
15291
|
+
});
|
|
15292
|
+
await rm5(join22(paths.launches, `${launch.record.id}.holders.json`), { force: true }).catch(() => {
|
|
15037
15293
|
return;
|
|
15038
15294
|
});
|
|
15039
|
-
|
|
15040
|
-
|
|
15295
|
+
await rm5(join22(paths.launches, `${launch.record.id}.json`), { force: true }).catch(() => {
|
|
15296
|
+
return;
|
|
15297
|
+
});
|
|
15298
|
+
if (removeState && launch.record.stateDir) {
|
|
15299
|
+
const directory = await launchStateDirectory(launch.record.stateDir).catch(() => {
|
|
15041
15300
|
return;
|
|
15042
15301
|
});
|
|
15302
|
+
if (directory)
|
|
15303
|
+
await rm5(directory, { recursive: true, force: true }).catch(() => {
|
|
15304
|
+
return;
|
|
15305
|
+
});
|
|
15306
|
+
}
|
|
15307
|
+
log(`launch ${launch.record.id.slice(0, 8)} ${reason}`);
|
|
15308
|
+
if (!launches.size)
|
|
15309
|
+
idleSince = now();
|
|
15310
|
+
} finally {
|
|
15311
|
+
settle?.();
|
|
15043
15312
|
}
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
idleSince = now();
|
|
15313
|
+
if (entry)
|
|
15314
|
+
await pruneEnded(now());
|
|
15047
15315
|
};
|
|
15048
15316
|
const liveHolders = (launch, table) => launch.record.holders.filter((holder) => table.get(holder.pid)?.start === holder.start);
|
|
15049
15317
|
const track = (launch, table, at) => {
|
|
@@ -15060,18 +15328,18 @@ async function startGatewayService(options = {}) {
|
|
|
15060
15328
|
if (changed)
|
|
15061
15329
|
launch.dirty = true;
|
|
15062
15330
|
};
|
|
15063
|
-
const
|
|
15064
|
-
|
|
15065
|
-
if (!baseline)
|
|
15331
|
+
const adoptTokenHolders = async (launch, table, at, force = false) => {
|
|
15332
|
+
if (!force && launch.probedAt !== undefined && at - launch.probedAt < PROBE_INTERVAL_MS)
|
|
15066
15333
|
return;
|
|
15067
|
-
launch.
|
|
15334
|
+
launch.probedAt = at;
|
|
15335
|
+
const baseline = launch.baseline;
|
|
15068
15336
|
const known = new Set(launch.record.holders.map(processKey));
|
|
15069
|
-
const candidates = [...table.values()].filter((entry) => entry.pid !== process.pid &&
|
|
15337
|
+
const candidates = [...table.values()].filter((entry) => entry.pid !== process.pid && !known.has(processKey(entry)) && !baseline?.has(processKey(entry)));
|
|
15070
15338
|
if (!candidates.length)
|
|
15071
15339
|
return;
|
|
15072
15340
|
let found;
|
|
15073
15341
|
try {
|
|
15074
|
-
found = await environmentProbe(candidates.slice(-
|
|
15342
|
+
found = await environmentProbe(candidates.slice(-MAX_PROBE_CANDIDATES).map((entry) => entry.pid), launch.record.tokenDigest);
|
|
15075
15343
|
} catch {
|
|
15076
15344
|
return;
|
|
15077
15345
|
}
|
|
@@ -15087,11 +15355,74 @@ async function startGatewayService(options = {}) {
|
|
|
15087
15355
|
if (!adopted)
|
|
15088
15356
|
return;
|
|
15089
15357
|
launch.dirty = true;
|
|
15090
|
-
log(`launch ${launch.record.id.slice(0, 8)} adopted ${adopted}
|
|
15358
|
+
log(`launch ${launch.record.id.slice(0, 8)} adopted ${adopted} process(es) started with its token`);
|
|
15359
|
+
};
|
|
15360
|
+
const revive = (digest2, clientPort, serverPort) => {
|
|
15361
|
+
const entry = ended.get(digest2);
|
|
15362
|
+
if (!entry || closing || clientPort === undefined)
|
|
15363
|
+
return;
|
|
15364
|
+
if (entry.reviving)
|
|
15365
|
+
return entry.reviving;
|
|
15366
|
+
const at = now();
|
|
15367
|
+
if (at - entry.record.endedAt > ENDED_MS) {
|
|
15368
|
+
forgetEnded(entry);
|
|
15369
|
+
return;
|
|
15370
|
+
}
|
|
15371
|
+
const failedAt = entry.failed.get(clientPort);
|
|
15372
|
+
if (failedAt !== undefined && at - failedAt < REVIVE_RETRY_MS)
|
|
15373
|
+
return;
|
|
15374
|
+
entry.lookups = entry.lookups.filter((time) => at - time < REVIVE_RETRY_MS);
|
|
15375
|
+
if (entry.lookups.length >= MAX_LOOKUPS_PER_RETRY)
|
|
15376
|
+
return;
|
|
15377
|
+
entry.lookups.push(at);
|
|
15378
|
+
const fail = () => {
|
|
15379
|
+
entry.failed.delete(clientPort);
|
|
15380
|
+
entry.failed.set(clientPort, at);
|
|
15381
|
+
for (const port2 of entry.failed.keys()) {
|
|
15382
|
+
if (entry.failed.size <= MAX_FAILED_PORTS)
|
|
15383
|
+
break;
|
|
15384
|
+
entry.failed.delete(port2);
|
|
15385
|
+
}
|
|
15386
|
+
return;
|
|
15387
|
+
};
|
|
15388
|
+
return entry.reviving = (async () => {
|
|
15389
|
+
try {
|
|
15390
|
+
await entry.settled;
|
|
15391
|
+
const [peers, table] = await Promise.all([connectionPeers(clientPort, serverPort), processTable()]);
|
|
15392
|
+
const held = new Set([...launches.values()].flatMap((launch2) => liveHolders(launch2, table).map((holder) => holder.pid)));
|
|
15393
|
+
const underHolder = (pid) => {
|
|
15394
|
+
for (let current = pid, depth = 0;current !== undefined && current > 1 && depth < 256; current = table.get(current)?.ppid, depth++)
|
|
15395
|
+
if (held.has(current))
|
|
15396
|
+
return true;
|
|
15397
|
+
return false;
|
|
15398
|
+
};
|
|
15399
|
+
const holders = [...new Set(peers)].filter((pid) => pid !== process.pid && table.has(pid) && underHolder(pid)).slice(0, MAX_HOLDERS).map((pid) => ({ pid, start: table.get(pid).start }));
|
|
15400
|
+
if (byDigest.has(digest2) || ended.get(digest2) !== entry)
|
|
15401
|
+
return byDigest.get(digest2);
|
|
15402
|
+
if (!holders.length)
|
|
15403
|
+
return fail();
|
|
15404
|
+
const { endedAt: _endedAt, ...fixed } = entry.record;
|
|
15405
|
+
const record3 = { ...fixed, lastUsedAt: at, lastHolderAt: at, released: true, holders };
|
|
15406
|
+
await writePrivate(join22(paths.launches, `${record3.id}.json`), JSON.stringify(staticFields(record3)));
|
|
15407
|
+
const launch = adopt(record3, entry.credential);
|
|
15408
|
+
launch.probedAfterLauncher = true;
|
|
15409
|
+
track(launch, table, at);
|
|
15410
|
+
await persist(launch, true);
|
|
15411
|
+
await forgetEnded(entry);
|
|
15412
|
+
log(`launch ${record3.id.slice(0, 8)} revived for a process that still uses it under a current launch`);
|
|
15413
|
+
return launch;
|
|
15414
|
+
} catch {
|
|
15415
|
+
return fail();
|
|
15416
|
+
} finally {
|
|
15417
|
+
entry.reviving = undefined;
|
|
15418
|
+
}
|
|
15419
|
+
})();
|
|
15091
15420
|
};
|
|
15092
15421
|
const launcherGone = (launch) => !launch.record.holders.some((holder) => holder.pid === launch.record.launcherPid);
|
|
15093
15422
|
let scanning;
|
|
15094
15423
|
const runScan = async () => {
|
|
15424
|
+
if (ended.size)
|
|
15425
|
+
await pruneEnded(now());
|
|
15095
15426
|
if (!launches.size)
|
|
15096
15427
|
return;
|
|
15097
15428
|
let table;
|
|
@@ -15103,12 +15434,17 @@ async function startGatewayService(options = {}) {
|
|
|
15103
15434
|
const at = now();
|
|
15104
15435
|
for (const launch of [...launches.values()]) {
|
|
15105
15436
|
track(launch, table, at);
|
|
15106
|
-
if (launch.
|
|
15107
|
-
|
|
15437
|
+
if (!launch.probedAfterLauncher && launcherGone(launch)) {
|
|
15438
|
+
launch.probedAfterLauncher = true;
|
|
15439
|
+
await adoptTokenHolders(launch, table, at, true);
|
|
15440
|
+
track(launch, table, at);
|
|
15441
|
+
}
|
|
15442
|
+
if (!launch.record.holders.length) {
|
|
15443
|
+
await adoptTokenHolders(launch, table, at);
|
|
15108
15444
|
track(launch, table, at);
|
|
15109
15445
|
}
|
|
15110
15446
|
if (!launch.record.holders.length && at - Math.max(launch.record.lastHolderAt, launch.record.lastUsedAt) > graceMs)
|
|
15111
|
-
await remove(launch, "expired: no process holds it", true);
|
|
15447
|
+
await remove(launch, "expired: no process holds it", true, true);
|
|
15112
15448
|
else if (launch.dirty && at - launch.persistedAt >= PERSIST_INTERVAL_MS)
|
|
15113
15449
|
await persist(launch);
|
|
15114
15450
|
}
|
|
@@ -15130,9 +15466,10 @@ async function startGatewayService(options = {}) {
|
|
|
15130
15466
|
const token = presented(request);
|
|
15131
15467
|
if (!token)
|
|
15132
15468
|
return errorBody(401, "switcher_gateway_token_missing", `Switcher gateway: the request carries no launch token. ${LAUNCH_HINT}`);
|
|
15133
|
-
const
|
|
15469
|
+
const digest2 = sha256(token);
|
|
15470
|
+
const launch = byDigest.get(digest2) ?? await revive(digest2, server.requestIP(request)?.port, server.port);
|
|
15134
15471
|
if (!launch)
|
|
15135
|
-
return errorBody(401, "switcher_gateway_launch_unknown", `Switcher gateway: this session's launch is no longer registered (it ended
|
|
15472
|
+
return errorBody(401, "switcher_gateway_launch_unknown", `Switcher gateway: this session's launch is no longer registered (it was revoked, it ended more than 30 days ago, or the gateway state was reset), or this request did not come from a process of this user running under a current launch. ${LAUNCH_HINT}`);
|
|
15136
15473
|
const at = now();
|
|
15137
15474
|
launch.record.lastUsedAt = at;
|
|
15138
15475
|
if (at - launch.usedPersistedAt >= USE_PERSIST_INTERVAL_MS) {
|
|
@@ -15208,7 +15545,7 @@ async function startGatewayService(options = {}) {
|
|
|
15208
15545
|
...stateDir ? { stateDir } : {}
|
|
15209
15546
|
};
|
|
15210
15547
|
const launch = adopt(record3, input.credential);
|
|
15211
|
-
launch.
|
|
15548
|
+
launch.baseline = new Set([...table.values()].map(processKey));
|
|
15212
15549
|
await writePrivate(join22(paths.launches, `${record3.id}.json`), JSON.stringify(staticFields(record3)));
|
|
15213
15550
|
await persist(launch, true);
|
|
15214
15551
|
log(`launch ${record3.id.slice(0, 8)} registered (${record3.gateway.harness}, ${record3.gateway.model})`);
|
|
@@ -15220,7 +15557,8 @@ async function startGatewayService(options = {}) {
|
|
|
15220
15557
|
});
|
|
15221
15558
|
if (table) {
|
|
15222
15559
|
track(launch, table, now());
|
|
15223
|
-
|
|
15560
|
+
launch.probedAfterLauncher = true;
|
|
15561
|
+
await adoptTokenHolders(launch, table, now(), true);
|
|
15224
15562
|
track(launch, table, now());
|
|
15225
15563
|
}
|
|
15226
15564
|
const others = table ? liveHolders(launch, table).filter((holder) => holder.pid !== launch.record.launcherPid) : launch.record.holders;
|
|
@@ -15228,7 +15566,7 @@ async function startGatewayService(options = {}) {
|
|
|
15228
15566
|
launch.events = [];
|
|
15229
15567
|
launch.eventBytes = 0;
|
|
15230
15568
|
if (!others.length) {
|
|
15231
|
-
await remove(launch, "revoked: launch ended", false);
|
|
15569
|
+
await remove(launch, "revoked: launch ended", false, true);
|
|
15232
15570
|
return { retained: false, holders: 0, events, eventsDropped };
|
|
15233
15571
|
}
|
|
15234
15572
|
launch.record.released = true;
|
|
@@ -15298,6 +15636,23 @@ async function startGatewayService(options = {}) {
|
|
|
15298
15636
|
log(`ignored unreadable launch record ${name.slice(0, 8)}`);
|
|
15299
15637
|
}
|
|
15300
15638
|
}
|
|
15639
|
+
for (const name of await readdir7(paths.ended)) {
|
|
15640
|
+
if (!/^[0-9a-f-]{36}\.json$/.test(name))
|
|
15641
|
+
continue;
|
|
15642
|
+
try {
|
|
15643
|
+
const record3 = endedSchema.parse(await readPrivateJson(join22(paths.ended, name)));
|
|
15644
|
+
if (record3.id !== name.slice(0, -5))
|
|
15645
|
+
throw new Error("ended launch record id mismatch");
|
|
15646
|
+
const entry = { record: record3, failed: new Map, lookups: [] };
|
|
15647
|
+
if (launches.has(record3.id) || byDigest.has(record3.tokenDigest))
|
|
15648
|
+
await forgetEnded(entry);
|
|
15649
|
+
else
|
|
15650
|
+
ended.set(record3.tokenDigest, entry);
|
|
15651
|
+
} catch {
|
|
15652
|
+
log(`ignored unreadable ended launch record ${name.slice(0, 8)}`);
|
|
15653
|
+
}
|
|
15654
|
+
}
|
|
15655
|
+
await pruneEnded(restoredAt);
|
|
15301
15656
|
log(`listening on ${url} (pid ${process.pid}, version ${VERSION}, ${launches.size} launch(es) restored)`);
|
|
15302
15657
|
await scan();
|
|
15303
15658
|
let tick = 0;
|
|
@@ -15333,7 +15688,7 @@ async function startGatewayService(options = {}) {
|
|
|
15333
15688
|
|
|
15334
15689
|
// src/gateway-supervisor.ts
|
|
15335
15690
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
15336
|
-
import { lstat as
|
|
15691
|
+
import { lstat as lstat12, mkdir as mkdir13, open as open8, readFile as readFile8, realpath as realpath7, rename as rename6, unlink as unlink4 } from "fs/promises";
|
|
15337
15692
|
import { dirname as dirname10, isAbsolute as isAbsolute18, join as join23 } from "path";
|
|
15338
15693
|
var LAUNCHD_LABEL = "com.hasna.switcher.gateway";
|
|
15339
15694
|
var SYSTEMD_UNIT = "switcher-gateway.service";
|
|
@@ -15358,7 +15713,7 @@ async function assertSafeServiceCommand(command, temporaryRoots = TEMPORARY_ROOT
|
|
|
15358
15713
|
if (temporaryRoots.some((root) => candidate === root || candidate.startsWith(`${root}/`)))
|
|
15359
15714
|
throw refuse(path, `${candidate} is under a temporary directory`);
|
|
15360
15715
|
for (let current = candidate;; current = dirname10(current)) {
|
|
15361
|
-
const info2 = await
|
|
15716
|
+
const info2 = await lstat12(current).catch(() => {
|
|
15362
15717
|
throw refuse(path, `${current} could not be checked`);
|
|
15363
15718
|
});
|
|
15364
15719
|
if (!info2.isSymbolicLink()) {
|
|
@@ -15490,7 +15845,7 @@ async function writeUnit(path, content) {
|
|
|
15490
15845
|
} finally {
|
|
15491
15846
|
await file.close();
|
|
15492
15847
|
}
|
|
15493
|
-
await
|
|
15848
|
+
await rename6(temporary, path);
|
|
15494
15849
|
return true;
|
|
15495
15850
|
}
|
|
15496
15851
|
async function installGatewayService(options) {
|
|
@@ -15849,6 +16204,57 @@ async function prepareOriForPlan(plan, options) {
|
|
|
15849
16204
|
throw error;
|
|
15850
16205
|
}
|
|
15851
16206
|
}
|
|
16207
|
+
async function sharedNativeHome(state, root, profileId, environment = process.env) {
|
|
16208
|
+
const variable = state.tool === "codex" ? "CODEX_HOME" : "CLAUDE_CONFIG_DIR";
|
|
16209
|
+
const configured = environment[variable] ? resolve14(environment[variable]) : undefined;
|
|
16210
|
+
const configuredCorpus = configured !== undefined && await realpath8(configured).catch(() => configured) === state.home;
|
|
16211
|
+
const home = state.tool === "claude" && (!configured || configured === state.home || configuredCorpus) ? join24(root, "native-claude", profileId) : configured ?? state.home;
|
|
16212
|
+
return { home, settingsEnvironment: configuredCorpus ? { ...environment, CLAUDE_CONFIG_DIR: undefined } : environment };
|
|
16213
|
+
}
|
|
16214
|
+
var SESSION_DIRECTORY_HARNESSES = ["pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "opencode", "kilo", "antigravity", "junie", "claude"];
|
|
16215
|
+
function launchSessionDirectory(root, harness, profileId) {
|
|
16216
|
+
return join24(root, "sessions", harness, profileId);
|
|
16217
|
+
}
|
|
16218
|
+
async function checkSharedNativeLaunch(state, root, profileId, options = {}) {
|
|
16219
|
+
const warnings = await legacyNativeStateWarnings(root, state);
|
|
16220
|
+
if (options.desktop)
|
|
16221
|
+
return warnings;
|
|
16222
|
+
const overlay = await sharedNativeHome(state, root, profileId);
|
|
16223
|
+
const suffix = relative7(root, overlay.home);
|
|
16224
|
+
const created = suffix !== ".." && !suffix.startsWith("../") && !await lstat13(root).catch(() => {
|
|
16225
|
+
return;
|
|
16226
|
+
}) ? root : undefined;
|
|
16227
|
+
if (created)
|
|
16228
|
+
await assertCreatableNativeStateDirectory(created);
|
|
16229
|
+
if (state.tool === "claude")
|
|
16230
|
+
warnings.push(...await prepareClaudeUserSettings(overlay.home, overlay.settingsEnvironment, state.home, { write: false, created }));
|
|
16231
|
+
await checkPrivateDirectory(overlay.home);
|
|
16232
|
+
await assertNativeInstructionOverlay(state, overlay.home, { plan: true });
|
|
16233
|
+
await checkNativeStateProjection(state, overlay.home);
|
|
16234
|
+
return warnings;
|
|
16235
|
+
}
|
|
16236
|
+
function isolatedNativeHome(tool, root, profileId, options = {}, environment = process.env) {
|
|
16237
|
+
if (options.desktop)
|
|
16238
|
+
return { home: join24(root, "desktop", profileId, "codex"), private: false };
|
|
16239
|
+
if (options.claudeDesktop)
|
|
16240
|
+
return { home: join24(root, "desktop-claude", profileId), private: false };
|
|
16241
|
+
const configured = environment[tool === "codex" ? "CODEX_HOME" : "CLAUDE_CONFIG_DIR"];
|
|
16242
|
+
return { home: configured ? resolve14(configured) : join24(root, `native-${tool}`, profileId), private: true };
|
|
16243
|
+
}
|
|
16244
|
+
async function checkDirectLaunch(root, profileId, harness, options = {}) {
|
|
16245
|
+
const desktop = Boolean(options.desktop || options.claudeDesktop);
|
|
16246
|
+
await checkPrivateDirectory(root);
|
|
16247
|
+
const warnings = options.sharedState ? await checkSharedNativeLaunch(options.sharedState, root, profileId, { desktop }) : [];
|
|
16248
|
+
if (options.isolated && (harness === "codex" || harness === "claude")) {
|
|
16249
|
+
const isolated = isolatedNativeHome(harness, root, profileId, options);
|
|
16250
|
+
await assertNativeStateIsolation(harness, isolated.home);
|
|
16251
|
+
if (isolated.private)
|
|
16252
|
+
await checkPrivateDirectory(isolated.home);
|
|
16253
|
+
}
|
|
16254
|
+
if (harness === "claude" && !desktop)
|
|
16255
|
+
await checkPrivateDirectory(claudeSettingsDirectory(launchSessionDirectory(root, harness, profileId)));
|
|
16256
|
+
return warnings;
|
|
16257
|
+
}
|
|
15852
16258
|
async function launch(client, profileId, options = {}) {
|
|
15853
16259
|
if (options.backend === "ori" && options.shareNativeState === false)
|
|
15854
16260
|
throw new Fault(400, "native_state_backend", "Explicit native-state isolation requires the direct adapter; Ori isolation is not yet verified.");
|
|
@@ -15959,28 +16365,22 @@ async function launch(client, profileId, options = {}) {
|
|
|
15959
16365
|
const stateWarnings = sharedState ? ["Shared native state is enabled. Resumed conversation history uses this launch's selected provider and model; Switcher does not infer unverified original-provider provenance.", ...await legacyNativeStateWarnings(root, sharedState)] : [];
|
|
15960
16366
|
let nativeHome2;
|
|
15961
16367
|
if (sharedState && !options.desktop && !options.claudeDesktop) {
|
|
15962
|
-
const
|
|
15963
|
-
|
|
15964
|
-
const configuredCorpus = configured && await realpath8(configured).catch(() => configured) === sharedState.home;
|
|
15965
|
-
nativeHome2 = sharedState.tool === "claude" && (!configured || configured === sharedState.home || configuredCorpus) ? join24(root, "native-claude", profileId) : configured ?? sharedState.home;
|
|
16368
|
+
const overlay = await sharedNativeHome(sharedState, root, profileId);
|
|
16369
|
+
nativeHome2 = overlay.home;
|
|
15966
16370
|
if (sharedState.tool === "claude")
|
|
15967
|
-
stateWarnings.push(...await prepareClaudeUserSettings(nativeHome2,
|
|
16371
|
+
stateWarnings.push(...await prepareClaudeUserSettings(nativeHome2, overlay.settingsEnvironment, sharedState.home));
|
|
15968
16372
|
await privateDirectory(nativeHome2);
|
|
15969
16373
|
await assertNativeInstructionOverlay(sharedState, nativeHome2);
|
|
15970
16374
|
await projectNativeState(sharedState, nativeHome2);
|
|
15971
16375
|
}
|
|
15972
16376
|
if (options.shareNativeState === false && backend === "direct") {
|
|
15973
16377
|
const tool = plan.profile.harness;
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
nativeHome2 = process.env[variable] ? resolve14(process.env[variable]) : join24(root, `native-${tool}`, profileId);
|
|
15981
|
-
await assertNativeStateIsolation(tool, nativeHome2);
|
|
15982
|
-
await privateDirectory(nativeHome2);
|
|
15983
|
-
}
|
|
16378
|
+
const isolated = isolatedNativeHome(tool, root, desktopState, { desktop: Boolean(options.desktop), claudeDesktop: Boolean(options.claudeDesktop) });
|
|
16379
|
+
if (isolated.private)
|
|
16380
|
+
nativeHome2 = isolated.home;
|
|
16381
|
+
await assertNativeStateIsolation(tool, isolated.home);
|
|
16382
|
+
if (isolated.private)
|
|
16383
|
+
await privateDirectory(isolated.home);
|
|
15984
16384
|
}
|
|
15985
16385
|
const input = {
|
|
15986
16386
|
harness: plan.profile.harness,
|
|
@@ -16017,7 +16417,7 @@ async function launch(client, profileId, options = {}) {
|
|
|
16017
16417
|
version: detection?.version,
|
|
16018
16418
|
sharedState,
|
|
16019
16419
|
gatewayHost,
|
|
16020
|
-
...
|
|
16420
|
+
...SESSION_DIRECTORY_HARNESSES.includes(plan.profile.harness) ? { sessionDir: launchSessionDirectory(root, plan.profile.harness, profileId) } : {}
|
|
16021
16421
|
});
|
|
16022
16422
|
cleanup = prepared.cleanup;
|
|
16023
16423
|
prepared = { ...prepared, warnings: [...prepared.warnings, ...stateWarnings] };
|
|
@@ -16256,14 +16656,14 @@ async function ensureLaunchProfile(client, provider, harness, model3, modelPolic
|
|
|
16256
16656
|
// src/native-state-import.ts
|
|
16257
16657
|
import { createHash as createHash18 } from "crypto";
|
|
16258
16658
|
import { constants as constants11 } from "fs";
|
|
16259
|
-
import { lstat as
|
|
16260
|
-
import { basename as basename6, dirname as dirname11, isAbsolute as isAbsolute19, join as join25, relative as
|
|
16659
|
+
import { lstat as lstat14, open as open9, opendir as opendir2, link as link3, rmdir as rmdir2, unlink as unlink5 } from "fs/promises";
|
|
16660
|
+
import { basename as basename6, dirname as dirname11, isAbsolute as isAbsolute19, join as join25, relative as relative8, resolve as resolve15 } from "path";
|
|
16261
16661
|
var MAX_FILES = 1e5;
|
|
16262
16662
|
var MAX_BYTES2 = 2 * 1024 * 1024 * 1024;
|
|
16263
16663
|
var refused = () => new Fault(409, "native_state_import_conflict", "Native state import found changed, unsafe or divergent data. No existing file will be replaced. Keep the original directory and resolve the conflict explicitly.");
|
|
16264
16664
|
async function info2(path) {
|
|
16265
16665
|
try {
|
|
16266
|
-
return await
|
|
16666
|
+
return await lstat14(path);
|
|
16267
16667
|
} catch (error) {
|
|
16268
16668
|
if (error.code === "ENOENT")
|
|
16269
16669
|
return;
|
|
@@ -16273,7 +16673,7 @@ async function info2(path) {
|
|
|
16273
16673
|
var identity = (s) => ({ dev: s.dev, ino: s.ino, size: s.size, mtimeMs: s.mtimeMs, ctimeMs: s.ctimeMs });
|
|
16274
16674
|
var same = (a, b) => JSON.stringify(identity(a)) === JSON.stringify(identity(b));
|
|
16275
16675
|
var inside3 = (parent, child) => {
|
|
16276
|
-
const path =
|
|
16676
|
+
const path = relative8(parent, child);
|
|
16277
16677
|
return path !== ".." && !path.startsWith("../") && !isAbsolute19(path);
|
|
16278
16678
|
};
|
|
16279
16679
|
var SESSION_ID = /^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i;
|
|
@@ -16293,7 +16693,7 @@ async function sessionId(path, expected) {
|
|
|
16293
16693
|
length += read.bytesRead;
|
|
16294
16694
|
newline = buffer.indexOf(10, 0);
|
|
16295
16695
|
}
|
|
16296
|
-
const after = await handle.stat(), named = await
|
|
16696
|
+
const after = await handle.stat(), named = await lstat14(path);
|
|
16297
16697
|
if (!same(before, after) || !same(after, named) || after.nlink !== 1 || named.nlink !== 1 || named.isSymbolicLink())
|
|
16298
16698
|
throw refused();
|
|
16299
16699
|
if (newline < 0 && before.size > buffer.length)
|
|
@@ -16392,7 +16792,7 @@ async function fingerprint2(path, copyTo) {
|
|
|
16392
16792
|
offset += (await output.write(chunk, offset, chunk.length - offset)).bytesWritten;
|
|
16393
16793
|
}
|
|
16394
16794
|
}
|
|
16395
|
-
const after = await handle.stat(), named = await
|
|
16795
|
+
const after = await handle.stat(), named = await lstat14(path);
|
|
16396
16796
|
if (named.isSymbolicLink() || after.nlink !== 1 || named.nlink !== 1 || bytes !== before.size || !same(before, after) || !same(after, named))
|
|
16397
16797
|
throw refused();
|
|
16398
16798
|
await output?.sync();
|
|
@@ -17042,16 +17442,23 @@ async function main(args = process.argv.slice(2)) {
|
|
|
17042
17442
|
const sharedNativeState = ["codex", "claude"].includes(plan.profile.harness) && nativeStateRequested(plan.profile.harness, process.env, shareNativeState);
|
|
17043
17443
|
const suffix = plan.profile.harness.toUpperCase();
|
|
17044
17444
|
const marked = process.env[`HASNA_${suffix}_STATE_HOME`] !== undefined || process.env[`SUBSCRIPTIONS_SHARED_HOME_${suffix}`] !== undefined;
|
|
17045
|
-
const nativeState = sharedNativeState ? { shared: true, consent: shareNativeState === true ? "command" : marked ? "environment" : "default" } : shareNativeState === false ? { shared: false, consent: "command" } : undefined;
|
|
17046
17445
|
if ((sharedNativeState || shareNativeState === false) && plan.profile.harness === "codex")
|
|
17047
17446
|
assertHarnessArguments("codex", nativeArgs, { reservedCodexRoots: ["sqlite_home"] });
|
|
17048
|
-
|
|
17447
|
+
const root = resolve16(values2["state-dir"] ?? join26(switcherHome(), "state"));
|
|
17448
|
+
if (backend !== "direct")
|
|
17449
|
+
await checkPrivateDirectory(root);
|
|
17450
|
+
const nativeWarnings = backend === "direct" ? await checkDirectLaunch(root, profileId, plan.profile.harness, {
|
|
17451
|
+
desktop: Boolean(desktop),
|
|
17452
|
+
claudeDesktop: Boolean(claudeApp),
|
|
17453
|
+
isolated: shareNativeState === false,
|
|
17454
|
+
...sharedNativeState ? { sharedState: await resolveNativeState(plan.profile.harness, process.env, { create: false }) } : {}
|
|
17455
|
+
}) : [];
|
|
17456
|
+
const nativeState = sharedNativeState ? { shared: true, consent: shareNativeState === true ? "command" : marked ? "environment" : "default", ...nativeWarnings.length ? { warnings: nativeWarnings } : {} } : shareNativeState === false ? { shared: false, consent: "command" } : undefined;
|
|
17457
|
+
if (sharedNativeState && backend !== "direct")
|
|
17049
17458
|
await resolveNativeState(plan.profile.harness, process.env, { create: false });
|
|
17050
|
-
if (shareNativeState === false) {
|
|
17051
|
-
const tool = plan.profile.harness
|
|
17052
|
-
|
|
17053
|
-
const home = desktop ? join26(root, "desktop", profileId, "codex") : claudeApp ? join26(root, "desktop-claude", profileId) : configured ? resolve16(configured) : join26(root, `native-${tool}`, profileId);
|
|
17054
|
-
await assertNativeStateIsolation(tool, home);
|
|
17459
|
+
if (shareNativeState === false && backend !== "direct") {
|
|
17460
|
+
const tool = plan.profile.harness;
|
|
17461
|
+
await assertNativeStateIsolation(tool, isolatedNativeHome(tool, root, profileId, { desktop: Boolean(desktop), claudeDesktop: Boolean(claudeApp) }).home);
|
|
17055
17462
|
}
|
|
17056
17463
|
if (backend === "ori") {
|
|
17057
17464
|
if (sharedNativeState)
|