@hasna/switcher 0.2.18 → 0.2.19
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 +19180 -3734
- package/dist/cli/index.js +613 -319
- 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/index.js +19122 -3676
- package/dist/inference-gateway.d.ts +2 -0
- package/dist/mcp/index.js +19611 -4119
- package/dist/model-policy-schema.d.ts +93 -112
- package/dist/opencode2-config.d.ts +8 -12
- package/dist/presets.d.ts +2 -2
- package/dist/process-table.d.ts +7 -0
- package/dist/reasoning.d.ts +11 -2
- package/dist/sdk.js +19122 -3676
- package/dist/serve/index.js +269 -223
- package/docs/GATEWAY-SERVICE.md +66 -30
- package/openapi.json +264 -218
- package/package.json +8 -5
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.19";
|
|
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.19",
|
|
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",
|
|
@@ -8634,16 +8680,25 @@ function createInferenceHandler(input, timing = {}, options = {}) {
|
|
|
8634
8680
|
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
8681
|
}
|
|
8636
8682
|
};
|
|
8637
|
-
return {
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8683
|
+
return {
|
|
8684
|
+
bodyLimit,
|
|
8685
|
+
closing: () => closing,
|
|
8686
|
+
handle,
|
|
8687
|
+
close: () => stopped ??= (async () => {
|
|
8688
|
+
closing = true;
|
|
8689
|
+
const pending = [...active];
|
|
8690
|
+
for (const request of pending)
|
|
8691
|
+
request.abort.abort();
|
|
8692
|
+
await Promise.allSettled(pending.map(async (request) => {
|
|
8693
|
+
await request.cancel?.();
|
|
8694
|
+
await request.done;
|
|
8695
|
+
}));
|
|
8696
|
+
})(),
|
|
8697
|
+
drain: () => stopped ??= (async () => {
|
|
8698
|
+
closing = true;
|
|
8699
|
+
await Promise.allSettled([...active].map((request) => request.done));
|
|
8700
|
+
})()
|
|
8701
|
+
};
|
|
8647
8702
|
}
|
|
8648
8703
|
function createInferenceGateway(input, timing = {}) {
|
|
8649
8704
|
const token = crypto.randomUUID() + crypto.randomUUID();
|
|
@@ -8933,7 +8988,7 @@ async function readCodexAgentConfig(path) {
|
|
|
8933
8988
|
}
|
|
8934
8989
|
|
|
8935
8990
|
// 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";
|
|
8991
|
+
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
8992
|
import { basename as basename2, dirname as dirname7, join as join15, isAbsolute as isAbsolute13, resolve as resolve8 } from "path";
|
|
8938
8993
|
import { homedir as homedir8, tmpdir } from "os";
|
|
8939
8994
|
import { createHash as createHash9, randomUUID as randomUUID4, timingSafeEqual as timingSafeEqual5 } from "crypto";
|
|
@@ -9373,7 +9428,7 @@ import { randomUUID as randomUUID3 } from "crypto";
|
|
|
9373
9428
|
import { Database as Database2 } from "bun:sqlite";
|
|
9374
9429
|
import { parse as parse3, parseTree as parseTree3 } from "jsonc-parser";
|
|
9375
9430
|
import { parseDocument as parseDocument3 } from "yaml";
|
|
9376
|
-
import { z as z6 } from "zod";
|
|
9431
|
+
import { z as z6 } from "zod-v4";
|
|
9377
9432
|
var effect = z6.enum(["allow", "deny", "ask"]);
|
|
9378
9433
|
var rule = z6.object({ action: z6.string(), resource: z6.string(), effect }).strict();
|
|
9379
9434
|
var object4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -10351,6 +10406,30 @@ async function jsonFile(dir, name, value) {
|
|
|
10351
10406
|
`, { mode: 384, flag: "wx" });
|
|
10352
10407
|
return path;
|
|
10353
10408
|
}
|
|
10409
|
+
async function durableJsonFile(dir, prefix, value) {
|
|
10410
|
+
const text = JSON.stringify(value, null, 2) + `
|
|
10411
|
+
`;
|
|
10412
|
+
await privateDirectory(dir);
|
|
10413
|
+
const path = join15(dir, `${prefix}-${createHash9("sha256").update(text).digest("hex").slice(0, 32)}.json`);
|
|
10414
|
+
const existing = await lstat6(path).catch(() => {
|
|
10415
|
+
return;
|
|
10416
|
+
});
|
|
10417
|
+
if (existing?.isFile() && (existing.mode & 63) === 0 && existing.uid === process.getuid?.() && await readFile6(path, "utf8").catch(() => {
|
|
10418
|
+
return;
|
|
10419
|
+
}) === text)
|
|
10420
|
+
return path;
|
|
10421
|
+
const temporary = `${path}.${randomUUID4()}.tmp`;
|
|
10422
|
+
await writeFile13(temporary, text, { mode: 384, flag: "wx" });
|
|
10423
|
+
try {
|
|
10424
|
+
await rename2(temporary, path);
|
|
10425
|
+
} catch (error) {
|
|
10426
|
+
await rm2(temporary, { force: true }).catch(() => {
|
|
10427
|
+
return;
|
|
10428
|
+
});
|
|
10429
|
+
throw error;
|
|
10430
|
+
}
|
|
10431
|
+
return path;
|
|
10432
|
+
}
|
|
10354
10433
|
async function projectInstructionPaths(cwd) {
|
|
10355
10434
|
let dir = resolve8(cwd);
|
|
10356
10435
|
while (true) {
|
|
@@ -11025,7 +11104,8 @@ async function prepareNativeLaunch(input, providerBaseUrl = input.providerBaseUr
|
|
|
11025
11104
|
env.ANTHROPIC_API_KEY = "";
|
|
11026
11105
|
env.ANTHROPIC_AUTH_TOKEN = "";
|
|
11027
11106
|
env[input.authStyle === "x-api-key" ? "ANTHROPIC_API_KEY" : "ANTHROPIC_AUTH_TOKEN"] = input.credential ?? "switcher-local-no-auth";
|
|
11028
|
-
const
|
|
11107
|
+
const picker = { modelPicker: { replaceBuiltInOptions: true, options: input.models.map((m) => ({ model: m.id, label: m.name, description: m.description?.slice(0, 300) })) } };
|
|
11108
|
+
const file2 = input.sessionDir ? await durableJsonFile(join15(input.sessionDir, "settings"), "claude-settings", picker) : await jsonFile(input.stateDir, "claude-settings.json", picker);
|
|
11029
11109
|
configPaths.push(file2);
|
|
11030
11110
|
warnings.push("Claude managed settings and model allowlists can restrict the generated picker.");
|
|
11031
11111
|
return { executable, args: ["--settings", file2, "--model", input.model, ...args], env, configPaths, warnings };
|
|
@@ -11443,12 +11523,12 @@ import { mkdir as mkdir14, mkdtemp, realpath as realpath8, rm as rm6, writeFile
|
|
|
11443
11523
|
import { join as join24, resolve as resolve14 } from "path";
|
|
11444
11524
|
|
|
11445
11525
|
// src/provider-credential-onboarding.ts
|
|
11446
|
-
import { z as z9 } from "zod";
|
|
11526
|
+
import { z as z9 } from "zod-v4";
|
|
11447
11527
|
import { createHash as createHash11 } from "crypto";
|
|
11448
11528
|
import { createInterface } from "readline/promises";
|
|
11449
11529
|
|
|
11450
11530
|
// src/opencode-authentication.ts
|
|
11451
|
-
import { z as z7 } from "zod";
|
|
11531
|
+
import { z as z7 } from "zod-v4";
|
|
11452
11532
|
var endpoint3 = "https://opencode.ai/zen/v1/systemone";
|
|
11453
11533
|
var body = JSON.stringify({
|
|
11454
11534
|
model: "jev-1.13-free",
|
|
@@ -11498,10 +11578,10 @@ async function verifyOpenCodeAuthentication(credential, fetchImpl) {
|
|
|
11498
11578
|
}
|
|
11499
11579
|
|
|
11500
11580
|
// src/credentials.ts
|
|
11501
|
-
import { z as z8 } from "zod";
|
|
11581
|
+
import { z as z8 } from "zod-v4";
|
|
11502
11582
|
import { ExecutableTrustError, repairExecutablePermissions, validateExecutable } from "@hasna/contracts/executable-trust";
|
|
11503
11583
|
import { constants as constants5 } from "fs";
|
|
11504
|
-
import { open as open3, readdir as readdir5, unlink, link, lstat as
|
|
11584
|
+
import { open as open3, readdir as readdir5, unlink, link, lstat as lstat7 } from "fs/promises";
|
|
11505
11585
|
import { join as join16, isAbsolute as isAbsolute15 } from "path";
|
|
11506
11586
|
import { createHash as createHash10, randomUUID as randomUUID5 } from "crypto";
|
|
11507
11587
|
import { execFile as execFile3, spawn } from "child_process";
|
|
@@ -11553,7 +11633,7 @@ class CredentialBindings {
|
|
|
11553
11633
|
for (const path of [switcherHome(this.env), join16(switcherHome(this.env), "config"), this.directory]) {
|
|
11554
11634
|
let info;
|
|
11555
11635
|
try {
|
|
11556
|
-
info = await
|
|
11636
|
+
info = await lstat7(path);
|
|
11557
11637
|
} catch (error) {
|
|
11558
11638
|
if (error.code === "ENOENT")
|
|
11559
11639
|
return false;
|
|
@@ -12745,7 +12825,7 @@ import { fileURLToPath } from "url";
|
|
|
12745
12825
|
|
|
12746
12826
|
// src/desktop-state.ts
|
|
12747
12827
|
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
|
|
12828
|
+
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
12829
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12750
12830
|
import { resolve as resolve9 } from "path";
|
|
12751
12831
|
import { createHash as createHash12 } from "crypto";
|
|
@@ -12804,7 +12884,7 @@ function desktopSnapshot(bytes, length, opened, after, metadataHash) {
|
|
|
12804
12884
|
}
|
|
12805
12885
|
async function safeDesktopSnapshot(path) {
|
|
12806
12886
|
try {
|
|
12807
|
-
const info = await
|
|
12887
|
+
const info = await lstat8(path);
|
|
12808
12888
|
admitDesktopFile(info);
|
|
12809
12889
|
const metadataHash = admitDesktopMetadata(path, info);
|
|
12810
12890
|
const file = await open4(path, constants7.O_RDONLY | constants7.O_NOFOLLOW);
|
|
@@ -12881,7 +12961,7 @@ async function preserveDesktopFile(source, destination, expected) {
|
|
|
12881
12961
|
var conflictPath = (path, suffix) => path + "." + crypto.randomUUID() + "." + suffix;
|
|
12882
12962
|
async function exists(path) {
|
|
12883
12963
|
try {
|
|
12884
|
-
await
|
|
12964
|
+
await lstat8(path);
|
|
12885
12965
|
return true;
|
|
12886
12966
|
} catch (error) {
|
|
12887
12967
|
if (error.code === "ENOENT")
|
|
@@ -12891,7 +12971,7 @@ async function exists(path) {
|
|
|
12891
12971
|
}
|
|
12892
12972
|
async function preserveConflict(path) {
|
|
12893
12973
|
const target = conflictPath(path, "conflict");
|
|
12894
|
-
await
|
|
12974
|
+
await rename3(path, target);
|
|
12895
12975
|
return target;
|
|
12896
12976
|
}
|
|
12897
12977
|
async function restoreDisplaced(backup, path) {
|
|
@@ -12944,7 +13024,7 @@ async function replaceDesktopFile(path, temporary, expectedCurrent, expectedNew)
|
|
|
12944
13024
|
let displaced = false;
|
|
12945
13025
|
try {
|
|
12946
13026
|
try {
|
|
12947
|
-
await
|
|
13027
|
+
await rename3(path, backup);
|
|
12948
13028
|
displaced = true;
|
|
12949
13029
|
} catch (error) {
|
|
12950
13030
|
if (error.code === "ENOENT")
|
|
@@ -12997,7 +13077,7 @@ async function removeDesktopFile(path, expected, guard) {
|
|
|
12997
13077
|
}
|
|
12998
13078
|
const quarantine = conflictPath(path, "remove");
|
|
12999
13079
|
try {
|
|
13000
|
-
await
|
|
13080
|
+
await rename3(path, quarantine);
|
|
13001
13081
|
} catch (error) {
|
|
13002
13082
|
if (error.code === "ENOENT")
|
|
13003
13083
|
throw new Fault(409, "desktop_state_changed", "Desktop removal target disappeared; existing state was preserved.");
|
|
@@ -13065,7 +13145,7 @@ async function writeDesktopPrivate(path, text, mode = 384, metadataSource, expec
|
|
|
13065
13145
|
}
|
|
13066
13146
|
async function desktopLease(path) {
|
|
13067
13147
|
try {
|
|
13068
|
-
const info = await
|
|
13148
|
+
const info = await lstat8(path);
|
|
13069
13149
|
if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.uid !== process.getuid?.() || (info.mode & 18) !== 0)
|
|
13070
13150
|
throw new Fault(422, "desktop_state_permissions", "Desktop lease must be a regular file owned by this user.");
|
|
13071
13151
|
} catch (error) {
|
|
@@ -13105,7 +13185,7 @@ async function openDesktopLease(path, readOnly2 = false) {
|
|
|
13105
13185
|
}
|
|
13106
13186
|
|
|
13107
13187
|
// src/native-state.ts
|
|
13108
|
-
import { lstat as
|
|
13188
|
+
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
13189
|
import { constants as constants8, lstatSync as lstatSync2, realpathSync } from "fs";
|
|
13110
13190
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
13111
13191
|
import { homedir as homedir9, userInfo as userInfo3 } from "os";
|
|
@@ -13148,7 +13228,7 @@ var NATIVE_STATE_ENTRIES = {
|
|
|
13148
13228
|
};
|
|
13149
13229
|
async function info(path) {
|
|
13150
13230
|
try {
|
|
13151
|
-
return await
|
|
13231
|
+
return await lstat9(path);
|
|
13152
13232
|
} catch (error) {
|
|
13153
13233
|
if (error.code === "ENOENT")
|
|
13154
13234
|
return;
|
|
@@ -13215,7 +13295,7 @@ function assertSafeAncestor(ancestor, path) {
|
|
|
13215
13295
|
}
|
|
13216
13296
|
async function assertSafeAncestors(path) {
|
|
13217
13297
|
for (let parent = path;; parent = dirname8(parent)) {
|
|
13218
|
-
assertSafeAncestor(await
|
|
13298
|
+
assertSafeAncestor(await lstat9(parent), parent);
|
|
13219
13299
|
if (parent === dirname8(parent))
|
|
13220
13300
|
break;
|
|
13221
13301
|
}
|
|
@@ -13305,7 +13385,7 @@ async function withNativeStateLock(state, operation) {
|
|
|
13305
13385
|
} finally {
|
|
13306
13386
|
await handle.close();
|
|
13307
13387
|
try {
|
|
13308
|
-
const entry = await
|
|
13388
|
+
const entry = await lstat9(path);
|
|
13309
13389
|
if (entry.dev === identity.dev && entry.ino === identity.ino)
|
|
13310
13390
|
await unlink2(path);
|
|
13311
13391
|
} catch (error) {
|
|
@@ -13338,7 +13418,7 @@ async function assertCorpusLink(link3, root) {
|
|
|
13338
13418
|
for (let hop = 0;; hop++) {
|
|
13339
13419
|
if (hop > 8)
|
|
13340
13420
|
throw refuse("resolves through more than 8 links");
|
|
13341
|
-
const entry = await inspect(current, () =>
|
|
13421
|
+
const entry = await inspect(current, () => lstat9(current));
|
|
13342
13422
|
if (!ownerProbe(entry, current))
|
|
13343
13423
|
throw unsafe(current);
|
|
13344
13424
|
if (!entry.isSymbolicLink()) {
|
|
@@ -13370,7 +13450,7 @@ async function assertCorpusLink(link3, root) {
|
|
|
13370
13450
|
if (strictlyInside(canonical, link3))
|
|
13371
13451
|
throw refuse(`points at its own ancestor ${displayPath(canonical)}`);
|
|
13372
13452
|
for (let directory = dirname8(canonical);directory !== root; directory = dirname8(directory)) {
|
|
13373
|
-
const item2 = await inspect(directory, () =>
|
|
13453
|
+
const item2 = await inspect(directory, () => lstat9(directory));
|
|
13374
13454
|
if (!item2.isDirectory() || !ownerProbe(item2, directory) || writableByOthers(item2))
|
|
13375
13455
|
throw unsafe(directory);
|
|
13376
13456
|
}
|
|
@@ -13398,7 +13478,7 @@ async function assertShareableTree(path, budget = { entries: 0 }, depth = 0, roo
|
|
|
13398
13478
|
await assertCorpusLink(nested, root);
|
|
13399
13479
|
continue;
|
|
13400
13480
|
}
|
|
13401
|
-
const entry = await
|
|
13481
|
+
const entry = await lstat9(nested);
|
|
13402
13482
|
if (!ownerProbe(entry, nested) || writableByOthers(entry))
|
|
13403
13483
|
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
13484
|
if (child.isDirectory()) {
|
|
@@ -13527,7 +13607,7 @@ async function assertCodexDatabaseRedirectSafe(state, overlayHome) {
|
|
|
13527
13607
|
if (root === (state.sqliteHome ?? state.home) || !await info(root))
|
|
13528
13608
|
continue;
|
|
13529
13609
|
await assertNativeStateDirectory(root);
|
|
13530
|
-
const before = await
|
|
13610
|
+
const before = await lstat9(root);
|
|
13531
13611
|
let inspected = 0;
|
|
13532
13612
|
for await (const entry of await opendir(root)) {
|
|
13533
13613
|
if (++inspected > 1e4)
|
|
@@ -13535,7 +13615,7 @@ async function assertCodexDatabaseRedirectSafe(state, overlayHome) {
|
|
|
13535
13615
|
if (/^(?:state|logs|goals|memories|queue|thread_history)_\d+\.sqlite(?:-(?:wal|shm))?$/.test(entry.name))
|
|
13536
13616
|
throw new Fault(409, "native_state_migration_required", "This profile retains native database metadata. Reconcile its catalog and history before redirecting shared state.");
|
|
13537
13617
|
}
|
|
13538
|
-
const after = await
|
|
13618
|
+
const after = await lstat9(root);
|
|
13539
13619
|
if (after.isSymbolicLink() || before.dev !== after.dev || before.ino !== after.ino || before.mtimeMs !== after.mtimeMs)
|
|
13540
13620
|
throw new Fault(409, "native_state_inventory_changed", "Native database inventory changed; no state was projected.");
|
|
13541
13621
|
}
|
|
@@ -13822,7 +13902,7 @@ import { writeFile as writeFile17 } from "fs/promises";
|
|
|
13822
13902
|
import { join as join21 } from "path";
|
|
13823
13903
|
// src/desktop-selection.ts
|
|
13824
13904
|
import { createHash as createHash14, randomUUID as randomUUID6 } from "crypto";
|
|
13825
|
-
import { writeFile as writeFile15, rename as
|
|
13905
|
+
import { writeFile as writeFile15, rename as rename4 } from "fs/promises";
|
|
13826
13906
|
import { join as join19 } from "path";
|
|
13827
13907
|
var hash2 = (text) => createHash14("sha256").update(text).digest("hex");
|
|
13828
13908
|
var conflict = () => new Fault(409, "desktop_config_changed", "Desktop configuration changed; existing bytes and the recovery receipt were preserved.");
|
|
@@ -13994,17 +14074,17 @@ async function recoverDesktopSelection(library) {
|
|
|
13994
14074
|
if (!sameDesktopSnapshot(finalReceipt2, redacted)) {
|
|
13995
14075
|
const foreignPath = recoveredPath + ".foreign-" + randomUUID6();
|
|
13996
14076
|
if (finalReceipt2 !== undefined)
|
|
13997
|
-
await
|
|
14077
|
+
await rename4(recoveredPath, foreignPath);
|
|
13998
14078
|
await writeDesktopPrivate(recoveredPath, retained, 384, undefined, { current: undefined });
|
|
13999
14079
|
throw new Fault(409, "desktop_config_changed", `Desktop recovery receipt changed; redacted receipt preserved at ${recoveredPath}; foreign receipt preserved at ${foreignPath}.`);
|
|
14000
14080
|
}
|
|
14001
14081
|
return;
|
|
14002
14082
|
}
|
|
14003
|
-
await
|
|
14083
|
+
await rename4(path, recoveredPath);
|
|
14004
14084
|
const preserveRecovered = async (snapshot2) => {
|
|
14005
14085
|
const foreignPath = recoveredPath + ".foreign-" + randomUUID6();
|
|
14006
14086
|
if (snapshot2 !== undefined)
|
|
14007
|
-
await
|
|
14087
|
+
await rename4(recoveredPath, foreignPath);
|
|
14008
14088
|
await writeDesktopPrivate(recoveredPath, raw, 384, undefined, { current: undefined });
|
|
14009
14089
|
throw new Fault(409, "desktop_config_changed", `Desktop recovery receipt changed; original receipt preserved at ${recoveredPath}; foreign receipt preserved at ${foreignPath}.`);
|
|
14010
14090
|
};
|
|
@@ -14102,7 +14182,7 @@ async function applyDesktopSelection(library, config, label2, checkpoint) {
|
|
|
14102
14182
|
|
|
14103
14183
|
// src/claude-user-settings.ts
|
|
14104
14184
|
import { constants as constants9 } from "fs";
|
|
14105
|
-
import { lstat as
|
|
14185
|
+
import { lstat as lstat10, open as open6, writeFile as writeFile16 } from "fs/promises";
|
|
14106
14186
|
import { homedir as homedir10 } from "os";
|
|
14107
14187
|
import { join as join20, resolve as resolve11 } from "path";
|
|
14108
14188
|
var preferences = new Set([
|
|
@@ -14155,7 +14235,7 @@ var invalid4 = (path) => new Fault(422, "claude_user_settings", `Claude user set
|
|
|
14155
14235
|
async function readSettings(home) {
|
|
14156
14236
|
await ensureNativeStateDirectory(home, false);
|
|
14157
14237
|
const path = join20(home, "settings.json");
|
|
14158
|
-
const entry = await
|
|
14238
|
+
const entry = await lstat10(path).catch((error) => {
|
|
14159
14239
|
if (error.code === "ENOENT")
|
|
14160
14240
|
return;
|
|
14161
14241
|
throw error;
|
|
@@ -14540,13 +14620,13 @@ import { closeSync as closeSync3, openSync as openSync3 } from "fs";
|
|
|
14540
14620
|
// src/gateway-service.ts
|
|
14541
14621
|
import { createHash as createHash16, randomBytes as randomBytes2, randomUUID as randomUUID7 } from "crypto";
|
|
14542
14622
|
import { constants as constants10 } from "fs";
|
|
14543
|
-
import { chmod as chmod3, lstat as
|
|
14623
|
+
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
14624
|
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";
|
|
14625
|
+
import { z as z10 } from "zod-v4";
|
|
14546
14626
|
|
|
14547
14627
|
// src/process-table.ts
|
|
14548
14628
|
import { createHash as createHash15 } from "crypto";
|
|
14549
|
-
import { readdir as readdir6, readFile as readFile7 } from "fs/promises";
|
|
14629
|
+
import { readdir as readdir6, readFile as readFile7, readlink as readlink2 } from "fs/promises";
|
|
14550
14630
|
var MAX_PROCESSES = 1e5;
|
|
14551
14631
|
async function darwinTable() {
|
|
14552
14632
|
const child = Bun.spawn(["/bin/ps", "-A", "-o", "pid=", "-o", "ppid=", "-o", "lstart="], {
|
|
@@ -14618,11 +14698,6 @@ function descendants(table, roots, exclude = []) {
|
|
|
14618
14698
|
}
|
|
14619
14699
|
return found;
|
|
14620
14700
|
}
|
|
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
14701
|
var TOKEN_ENTRY = /^[A-Za-z_][A-Za-z0-9_]*=([A-Za-z0-9_-]{43})$/;
|
|
14627
14702
|
var holdsDigest = (entries, digest2) => {
|
|
14628
14703
|
for (const entry of entries) {
|
|
@@ -14675,12 +14750,97 @@ function processesHoldingTokenDigest(pids, digest2) {
|
|
|
14675
14750
|
return linuxDigestHolders(pids, digest2);
|
|
14676
14751
|
return Promise.resolve([]);
|
|
14677
14752
|
}
|
|
14753
|
+
var PEER_LOOKUP_TIMEOUT_MS = 5000;
|
|
14754
|
+
var loopbackAddress = (hex) => hex === "0100007F" || hex === "0000000000000000FFFF00000100007F";
|
|
14755
|
+
var loopbackPeers = (clientPort, serverPort) => {
|
|
14756
|
+
if (!Number.isSafeInteger(clientPort) || !Number.isSafeInteger(serverPort))
|
|
14757
|
+
return Promise.resolve([]);
|
|
14758
|
+
if (process.platform === "darwin")
|
|
14759
|
+
return darwinPeers(clientPort, serverPort).catch(() => []);
|
|
14760
|
+
if (process.platform === "linux")
|
|
14761
|
+
return linuxPeers(clientPort, serverPort).catch(() => []);
|
|
14762
|
+
return Promise.resolve([]);
|
|
14763
|
+
};
|
|
14764
|
+
async function darwinPeers(clientPort, serverPort) {
|
|
14765
|
+
const uid = process.getuid?.();
|
|
14766
|
+
if (uid === undefined)
|
|
14767
|
+
return [];
|
|
14768
|
+
const child = Bun.spawn(["/usr/sbin/lsof", "-nP", "-w", "-a", "-u", String(uid), `-iTCP@127.0.0.1:${clientPort}`, "-sTCP:ESTABLISHED", "-Fpn"], {
|
|
14769
|
+
env: { PATH: "/usr/bin:/bin:/usr/sbin", LC_ALL: "C" },
|
|
14770
|
+
stdin: "ignore",
|
|
14771
|
+
stdout: "pipe",
|
|
14772
|
+
stderr: "pipe"
|
|
14773
|
+
});
|
|
14774
|
+
let timedOut = false;
|
|
14775
|
+
const timer = setTimeout(() => {
|
|
14776
|
+
timedOut = true;
|
|
14777
|
+
child.kill("SIGKILL");
|
|
14778
|
+
}, PEER_LOOKUP_TIMEOUT_MS);
|
|
14779
|
+
const [text, errors] = await Promise.all([new Response(child.stdout).text(), new Response(child.stderr).text(), child.exited]).finally(() => clearTimeout(timer));
|
|
14780
|
+
if (timedOut || errors.trim())
|
|
14781
|
+
return [];
|
|
14782
|
+
const wanted = `n127.0.0.1:${clientPort}->127.0.0.1:${serverPort}`, found = new Set;
|
|
14783
|
+
let pid;
|
|
14784
|
+
for (const line of text.split(`
|
|
14785
|
+
`)) {
|
|
14786
|
+
if (line.startsWith("p"))
|
|
14787
|
+
pid = Number(line.slice(1));
|
|
14788
|
+
else if (line === wanted && pid !== undefined && Number.isSafeInteger(pid))
|
|
14789
|
+
found.add(pid);
|
|
14790
|
+
}
|
|
14791
|
+
return [...found];
|
|
14792
|
+
}
|
|
14793
|
+
async function linuxPeers(clientPort, serverPort) {
|
|
14794
|
+
const uid = process.getuid?.();
|
|
14795
|
+
if (uid === undefined)
|
|
14796
|
+
return [];
|
|
14797
|
+
const inodes = new Set;
|
|
14798
|
+
for (const table of ["/proc/net/tcp", "/proc/net/tcp6"]) {
|
|
14799
|
+
const text = await readFile7(table, "utf8").catch(() => "");
|
|
14800
|
+
for (const line of text.split(`
|
|
14801
|
+
`).slice(1)) {
|
|
14802
|
+
const fields = line.trim().split(/\s+/);
|
|
14803
|
+
if (fields.length < 10)
|
|
14804
|
+
continue;
|
|
14805
|
+
const [localAddress = "", localPort = ""] = fields[1].split(":"), [remoteAddress = "", remotePort = ""] = fields[2].split(":");
|
|
14806
|
+
if (!loopbackAddress(localAddress.toUpperCase()) || !loopbackAddress(remoteAddress.toUpperCase()))
|
|
14807
|
+
continue;
|
|
14808
|
+
if (Number.parseInt(localPort, 16) === clientPort && Number.parseInt(remotePort, 16) === serverPort && fields[3] === "01" && Number(fields[7]) === uid)
|
|
14809
|
+
inodes.add(fields[9]);
|
|
14810
|
+
}
|
|
14811
|
+
}
|
|
14812
|
+
if (!inodes.size)
|
|
14813
|
+
return [];
|
|
14814
|
+
const found = [];
|
|
14815
|
+
for (const name of await readdir6("/proc")) {
|
|
14816
|
+
if (!/^\d+$/.test(name))
|
|
14817
|
+
continue;
|
|
14818
|
+
let descriptors;
|
|
14819
|
+
try {
|
|
14820
|
+
descriptors = await readdir6(`/proc/${name}/fd`);
|
|
14821
|
+
} catch {
|
|
14822
|
+
continue;
|
|
14823
|
+
}
|
|
14824
|
+
for (const descriptor of descriptors) {
|
|
14825
|
+
const target = /^socket:\[(\d+)\]$/.exec(await readlink2(`/proc/${name}/fd/${descriptor}`).catch(() => ""));
|
|
14826
|
+
if (target && inodes.has(target[1])) {
|
|
14827
|
+
found.push(Number(name));
|
|
14828
|
+
break;
|
|
14829
|
+
}
|
|
14830
|
+
}
|
|
14831
|
+
}
|
|
14832
|
+
return found;
|
|
14833
|
+
}
|
|
14678
14834
|
|
|
14679
14835
|
// src/gateway-service.ts
|
|
14680
14836
|
var GATEWAY_PROTOCOL = 1;
|
|
14681
14837
|
var SOCKET_PATH_LIMIT = 100;
|
|
14682
14838
|
var MAX_HOLDERS = 4096;
|
|
14683
|
-
var
|
|
14839
|
+
var MAX_PROBE_CANDIDATES = 4096;
|
|
14840
|
+
var PROBE_INTERVAL_MS = 60000;
|
|
14841
|
+
var ENDED_MS = 30 * 24 * 3600000;
|
|
14842
|
+
var MAX_ENDED = 1000;
|
|
14843
|
+
var REVIVE_RETRY_MS = 5000;
|
|
14684
14844
|
var MAX_EVENTS = 1000;
|
|
14685
14845
|
var MAX_EVENT_BYTES = 512 * 1024;
|
|
14686
14846
|
var DEFAULT_GRACE_MS = 10 * 60000;
|
|
@@ -14693,11 +14853,11 @@ function gatewayPaths(env = process.env) {
|
|
|
14693
14853
|
const name = `${createHash16("sha256").update(root).digest("hex").slice(0, 16)}.sock`;
|
|
14694
14854
|
const runtime = process.platform === "linux" && env.XDG_RUNTIME_DIR && isAbsolute17(env.XDG_RUNTIME_DIR) ? join22(env.XDG_RUNTIME_DIR, "switcher", name) : undefined;
|
|
14695
14855
|
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") };
|
|
14856
|
+
return { root, socket, launches: join22(root, "launches"), ended: join22(root, "ended"), config: join22(root, "config.json"), log: join22(root, "service.log") };
|
|
14697
14857
|
}
|
|
14698
14858
|
var UNTRUSTED_FIX = "Another account may have created it: remove it (or set HASNA_SWITCHER_HOME to a shorter path) and launch again.";
|
|
14699
14859
|
async function assertPrivateSocketDirectory(directory) {
|
|
14700
|
-
const info2 = await
|
|
14860
|
+
const info2 = await lstat11(directory);
|
|
14701
14861
|
if (!info2.isDirectory() || info2.isSymbolicLink() || (info2.mode & 63) !== 0 || info2.uid !== process.getuid?.())
|
|
14702
14862
|
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
14863
|
}
|
|
@@ -14712,7 +14872,7 @@ async function assertTrustedControlSocket(socket) {
|
|
|
14712
14872
|
}
|
|
14713
14873
|
let info2;
|
|
14714
14874
|
try {
|
|
14715
|
-
info2 = await
|
|
14875
|
+
info2 = await lstat11(socket);
|
|
14716
14876
|
} catch (error) {
|
|
14717
14877
|
if (error.code === "ENOENT")
|
|
14718
14878
|
throw missing();
|
|
@@ -14859,6 +15019,9 @@ var staticSchema = z10.object({
|
|
|
14859
15019
|
stateDir: z10.string().max(4096).optional()
|
|
14860
15020
|
}).strict();
|
|
14861
15021
|
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();
|
|
15022
|
+
var endedSchema = staticSchema.omit({ stateDir: true }).extend({ endedAt: z10.number() }).strict();
|
|
15023
|
+
var MAX_FAILED_PORTS = 64;
|
|
15024
|
+
var MAX_LOOKUPS_PER_RETRY = 4;
|
|
14862
15025
|
var processKey = (entry) => `${entry.pid}@${entry.start}`;
|
|
14863
15026
|
var SETTLED_MS = 120000;
|
|
14864
15027
|
var SETTLED_SCAN_FACTOR = 5;
|
|
@@ -14909,14 +15072,14 @@ async function writePrivate(path, text) {
|
|
|
14909
15072
|
} finally {
|
|
14910
15073
|
await file.close();
|
|
14911
15074
|
}
|
|
14912
|
-
await
|
|
15075
|
+
await rename5(temporary, path);
|
|
14913
15076
|
}
|
|
14914
15077
|
async function launchStateDirectory(path) {
|
|
14915
15078
|
if (path === undefined)
|
|
14916
15079
|
return;
|
|
14917
15080
|
if (!isAbsolute17(path) || resolve13(path) !== path || !/^launch-[A-Za-z0-9]{6}$/.test(basename5(path)))
|
|
14918
15081
|
throw new Fault(400, "invalid_state_dir", "The launch state directory must be an absolute launch-XXXXXX directory.");
|
|
14919
|
-
const info2 = await
|
|
15082
|
+
const info2 = await lstat11(path).catch(() => {
|
|
14920
15083
|
return;
|
|
14921
15084
|
});
|
|
14922
15085
|
if (!info2?.isDirectory() || info2.isSymbolicLink() || info2.uid !== process.getuid?.() || (info2.mode & 63) !== 0)
|
|
@@ -14933,6 +15096,7 @@ async function startGatewayService(options = {}) {
|
|
|
14933
15096
|
const graceMs = options.graceMs ?? settings2.graceMs, scanMs = options.scanMs ?? settings2.scanMs;
|
|
14934
15097
|
const processTable = options.processTable ?? readProcessTable;
|
|
14935
15098
|
const environmentProbe = options.environmentProbe ?? processesHoldingTokenDigest;
|
|
15099
|
+
const connectionPeers = options.connectionPeers ?? loopbackPeers;
|
|
14936
15100
|
const log = options.log ?? ((line) => console.error(`switcher-gateway ${new Date().toISOString()} ${line}`));
|
|
14937
15101
|
const resolver = new CredentialResolver(env);
|
|
14938
15102
|
const resolveCredential2 = options.resolveCredential ?? ((provider) => resolver.resolve(provider));
|
|
@@ -14940,6 +15104,7 @@ async function startGatewayService(options = {}) {
|
|
|
14940
15104
|
await privateDirectory(switcherHome(env));
|
|
14941
15105
|
await privateDirectory(paths.root);
|
|
14942
15106
|
await privateDirectory(paths.launches);
|
|
15107
|
+
await privateDirectory(paths.ended);
|
|
14943
15108
|
await socketDirectory(paths);
|
|
14944
15109
|
let persisted = {};
|
|
14945
15110
|
try {
|
|
@@ -14949,6 +15114,7 @@ async function startGatewayService(options = {}) {
|
|
|
14949
15114
|
} catch {}
|
|
14950
15115
|
const requestedPort = options.port ?? settings2.port ?? persisted.port ?? (isDefaultSwitcherHome(env) ? defaultGatewayPort() : 0);
|
|
14951
15116
|
const launches = new Map, byDigest = new Map;
|
|
15117
|
+
const ended = new Map;
|
|
14952
15118
|
let closing = false, stopping, resolveClosed, idleSince = now();
|
|
14953
15119
|
const closed = new Promise((resolve14) => {
|
|
14954
15120
|
resolveClosed = resolve14;
|
|
@@ -15018,32 +15184,73 @@ async function startGatewayService(options = {}) {
|
|
|
15018
15184
|
byDigest.set(record3.tokenDigest, launch);
|
|
15019
15185
|
return launch;
|
|
15020
15186
|
};
|
|
15021
|
-
const
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
await launch.handler.close().catch(() => {
|
|
15187
|
+
const endedPath = (id2) => join22(paths.ended, `${id2}.json`);
|
|
15188
|
+
const forgetEnded = async (entry) => {
|
|
15189
|
+
if (ended.get(entry.record.tokenDigest) === entry)
|
|
15190
|
+
ended.delete(entry.record.tokenDigest);
|
|
15191
|
+
await rm5(endedPath(entry.record.id), { force: true }).catch(() => {
|
|
15027
15192
|
return;
|
|
15028
15193
|
});
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15194
|
+
};
|
|
15195
|
+
const pruneEnded = async (at) => {
|
|
15196
|
+
const entries = [...ended.values()].sort((a, b) => a.record.endedAt - b.record.endedAt);
|
|
15197
|
+
for (const [index, entry] of entries.entries())
|
|
15198
|
+
if (at - entry.record.endedAt > ENDED_MS || entries.length - index > MAX_ENDED)
|
|
15199
|
+
await forgetEnded(entry);
|
|
15200
|
+
};
|
|
15201
|
+
const endedEntry = (launch) => {
|
|
15202
|
+
const { stateDir: _state, ...fixed } = staticFields(launch.record);
|
|
15203
|
+
return { record: { ...fixed, endedAt: now() }, ...launch.record.credential.source === "ephemeral" && launch.credential !== undefined ? { credential: launch.credential } : {}, failed: new Map, lookups: [] };
|
|
15204
|
+
};
|
|
15205
|
+
const remove = async (launch, reason, removeState, end = false) => {
|
|
15206
|
+
if (!launches.delete(launch.record.id))
|
|
15033
15207
|
return;
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15208
|
+
const entry = end ? endedEntry(launch) : undefined;
|
|
15209
|
+
let settle;
|
|
15210
|
+
if (entry) {
|
|
15211
|
+
entry.settled = new Promise((resolve14) => {
|
|
15212
|
+
settle = resolve14;
|
|
15213
|
+
});
|
|
15214
|
+
ended.set(launch.record.tokenDigest, entry);
|
|
15215
|
+
}
|
|
15216
|
+
byDigest.delete(launch.record.tokenDigest);
|
|
15217
|
+
try {
|
|
15218
|
+
launch.credential = undefined;
|
|
15219
|
+
if (entry)
|
|
15220
|
+
launch.handler.drain().catch(() => {
|
|
15221
|
+
return;
|
|
15222
|
+
});
|
|
15223
|
+
else
|
|
15224
|
+
await launch.handler.close().catch(() => {
|
|
15225
|
+
return;
|
|
15226
|
+
});
|
|
15227
|
+
if (entry)
|
|
15228
|
+
await writePrivate(endedPath(launch.record.id), JSON.stringify(entry.record)).catch(() => {
|
|
15229
|
+
return;
|
|
15230
|
+
});
|
|
15231
|
+
await rm5(join22(paths.launches, `${launch.record.id}.holders.json`), { force: true }).catch(() => {
|
|
15232
|
+
return;
|
|
15233
|
+
});
|
|
15234
|
+
await rm5(join22(paths.launches, `${launch.record.id}.json`), { force: true }).catch(() => {
|
|
15037
15235
|
return;
|
|
15038
15236
|
});
|
|
15039
|
-
if (
|
|
15040
|
-
|
|
15237
|
+
if (removeState && launch.record.stateDir) {
|
|
15238
|
+
const directory = await launchStateDirectory(launch.record.stateDir).catch(() => {
|
|
15041
15239
|
return;
|
|
15042
15240
|
});
|
|
15241
|
+
if (directory)
|
|
15242
|
+
await rm5(directory, { recursive: true, force: true }).catch(() => {
|
|
15243
|
+
return;
|
|
15244
|
+
});
|
|
15245
|
+
}
|
|
15246
|
+
log(`launch ${launch.record.id.slice(0, 8)} ${reason}`);
|
|
15247
|
+
if (!launches.size)
|
|
15248
|
+
idleSince = now();
|
|
15249
|
+
} finally {
|
|
15250
|
+
settle?.();
|
|
15043
15251
|
}
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
idleSince = now();
|
|
15252
|
+
if (entry)
|
|
15253
|
+
await pruneEnded(now());
|
|
15047
15254
|
};
|
|
15048
15255
|
const liveHolders = (launch, table) => launch.record.holders.filter((holder) => table.get(holder.pid)?.start === holder.start);
|
|
15049
15256
|
const track = (launch, table, at) => {
|
|
@@ -15060,18 +15267,18 @@ async function startGatewayService(options = {}) {
|
|
|
15060
15267
|
if (changed)
|
|
15061
15268
|
launch.dirty = true;
|
|
15062
15269
|
};
|
|
15063
|
-
const
|
|
15064
|
-
|
|
15065
|
-
if (!baseline)
|
|
15270
|
+
const adoptTokenHolders = async (launch, table, at, force = false) => {
|
|
15271
|
+
if (!force && launch.probedAt !== undefined && at - launch.probedAt < PROBE_INTERVAL_MS)
|
|
15066
15272
|
return;
|
|
15067
|
-
launch.
|
|
15273
|
+
launch.probedAt = at;
|
|
15274
|
+
const baseline = launch.baseline;
|
|
15068
15275
|
const known = new Set(launch.record.holders.map(processKey));
|
|
15069
|
-
const candidates = [...table.values()].filter((entry) => entry.pid !== process.pid &&
|
|
15276
|
+
const candidates = [...table.values()].filter((entry) => entry.pid !== process.pid && !known.has(processKey(entry)) && !baseline?.has(processKey(entry)));
|
|
15070
15277
|
if (!candidates.length)
|
|
15071
15278
|
return;
|
|
15072
15279
|
let found;
|
|
15073
15280
|
try {
|
|
15074
|
-
found = await environmentProbe(candidates.slice(-
|
|
15281
|
+
found = await environmentProbe(candidates.slice(-MAX_PROBE_CANDIDATES).map((entry) => entry.pid), launch.record.tokenDigest);
|
|
15075
15282
|
} catch {
|
|
15076
15283
|
return;
|
|
15077
15284
|
}
|
|
@@ -15087,11 +15294,74 @@ async function startGatewayService(options = {}) {
|
|
|
15087
15294
|
if (!adopted)
|
|
15088
15295
|
return;
|
|
15089
15296
|
launch.dirty = true;
|
|
15090
|
-
log(`launch ${launch.record.id.slice(0, 8)} adopted ${adopted}
|
|
15297
|
+
log(`launch ${launch.record.id.slice(0, 8)} adopted ${adopted} process(es) started with its token`);
|
|
15298
|
+
};
|
|
15299
|
+
const revive = (digest2, clientPort, serverPort) => {
|
|
15300
|
+
const entry = ended.get(digest2);
|
|
15301
|
+
if (!entry || closing || clientPort === undefined)
|
|
15302
|
+
return;
|
|
15303
|
+
if (entry.reviving)
|
|
15304
|
+
return entry.reviving;
|
|
15305
|
+
const at = now();
|
|
15306
|
+
if (at - entry.record.endedAt > ENDED_MS) {
|
|
15307
|
+
forgetEnded(entry);
|
|
15308
|
+
return;
|
|
15309
|
+
}
|
|
15310
|
+
const failedAt = entry.failed.get(clientPort);
|
|
15311
|
+
if (failedAt !== undefined && at - failedAt < REVIVE_RETRY_MS)
|
|
15312
|
+
return;
|
|
15313
|
+
entry.lookups = entry.lookups.filter((time) => at - time < REVIVE_RETRY_MS);
|
|
15314
|
+
if (entry.lookups.length >= MAX_LOOKUPS_PER_RETRY)
|
|
15315
|
+
return;
|
|
15316
|
+
entry.lookups.push(at);
|
|
15317
|
+
const fail = () => {
|
|
15318
|
+
entry.failed.delete(clientPort);
|
|
15319
|
+
entry.failed.set(clientPort, at);
|
|
15320
|
+
for (const port2 of entry.failed.keys()) {
|
|
15321
|
+
if (entry.failed.size <= MAX_FAILED_PORTS)
|
|
15322
|
+
break;
|
|
15323
|
+
entry.failed.delete(port2);
|
|
15324
|
+
}
|
|
15325
|
+
return;
|
|
15326
|
+
};
|
|
15327
|
+
return entry.reviving = (async () => {
|
|
15328
|
+
try {
|
|
15329
|
+
await entry.settled;
|
|
15330
|
+
const [peers, table] = await Promise.all([connectionPeers(clientPort, serverPort), processTable()]);
|
|
15331
|
+
const held = new Set([...launches.values()].flatMap((launch2) => liveHolders(launch2, table).map((holder) => holder.pid)));
|
|
15332
|
+
const underHolder = (pid) => {
|
|
15333
|
+
for (let current = pid, depth = 0;current !== undefined && current > 1 && depth < 256; current = table.get(current)?.ppid, depth++)
|
|
15334
|
+
if (held.has(current))
|
|
15335
|
+
return true;
|
|
15336
|
+
return false;
|
|
15337
|
+
};
|
|
15338
|
+
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 }));
|
|
15339
|
+
if (byDigest.has(digest2) || ended.get(digest2) !== entry)
|
|
15340
|
+
return byDigest.get(digest2);
|
|
15341
|
+
if (!holders.length)
|
|
15342
|
+
return fail();
|
|
15343
|
+
const { endedAt: _endedAt, ...fixed } = entry.record;
|
|
15344
|
+
const record3 = { ...fixed, lastUsedAt: at, lastHolderAt: at, released: true, holders };
|
|
15345
|
+
await writePrivate(join22(paths.launches, `${record3.id}.json`), JSON.stringify(staticFields(record3)));
|
|
15346
|
+
const launch = adopt(record3, entry.credential);
|
|
15347
|
+
launch.probedAfterLauncher = true;
|
|
15348
|
+
track(launch, table, at);
|
|
15349
|
+
await persist(launch, true);
|
|
15350
|
+
await forgetEnded(entry);
|
|
15351
|
+
log(`launch ${record3.id.slice(0, 8)} revived for a process that still uses it under a current launch`);
|
|
15352
|
+
return launch;
|
|
15353
|
+
} catch {
|
|
15354
|
+
return fail();
|
|
15355
|
+
} finally {
|
|
15356
|
+
entry.reviving = undefined;
|
|
15357
|
+
}
|
|
15358
|
+
})();
|
|
15091
15359
|
};
|
|
15092
15360
|
const launcherGone = (launch) => !launch.record.holders.some((holder) => holder.pid === launch.record.launcherPid);
|
|
15093
15361
|
let scanning;
|
|
15094
15362
|
const runScan = async () => {
|
|
15363
|
+
if (ended.size)
|
|
15364
|
+
await pruneEnded(now());
|
|
15095
15365
|
if (!launches.size)
|
|
15096
15366
|
return;
|
|
15097
15367
|
let table;
|
|
@@ -15103,12 +15373,17 @@ async function startGatewayService(options = {}) {
|
|
|
15103
15373
|
const at = now();
|
|
15104
15374
|
for (const launch of [...launches.values()]) {
|
|
15105
15375
|
track(launch, table, at);
|
|
15106
|
-
if (launch.
|
|
15107
|
-
|
|
15376
|
+
if (!launch.probedAfterLauncher && launcherGone(launch)) {
|
|
15377
|
+
launch.probedAfterLauncher = true;
|
|
15378
|
+
await adoptTokenHolders(launch, table, at, true);
|
|
15379
|
+
track(launch, table, at);
|
|
15380
|
+
}
|
|
15381
|
+
if (!launch.record.holders.length) {
|
|
15382
|
+
await adoptTokenHolders(launch, table, at);
|
|
15108
15383
|
track(launch, table, at);
|
|
15109
15384
|
}
|
|
15110
15385
|
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);
|
|
15386
|
+
await remove(launch, "expired: no process holds it", true, true);
|
|
15112
15387
|
else if (launch.dirty && at - launch.persistedAt >= PERSIST_INTERVAL_MS)
|
|
15113
15388
|
await persist(launch);
|
|
15114
15389
|
}
|
|
@@ -15130,9 +15405,10 @@ async function startGatewayService(options = {}) {
|
|
|
15130
15405
|
const token = presented(request);
|
|
15131
15406
|
if (!token)
|
|
15132
15407
|
return errorBody(401, "switcher_gateway_token_missing", `Switcher gateway: the request carries no launch token. ${LAUNCH_HINT}`);
|
|
15133
|
-
const
|
|
15408
|
+
const digest2 = sha256(token);
|
|
15409
|
+
const launch = byDigest.get(digest2) ?? await revive(digest2, server.requestIP(request)?.port, server.port);
|
|
15134
15410
|
if (!launch)
|
|
15135
|
-
return errorBody(401, "switcher_gateway_launch_unknown", `Switcher gateway: this session's launch is no longer registered (it ended
|
|
15411
|
+
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
15412
|
const at = now();
|
|
15137
15413
|
launch.record.lastUsedAt = at;
|
|
15138
15414
|
if (at - launch.usedPersistedAt >= USE_PERSIST_INTERVAL_MS) {
|
|
@@ -15208,7 +15484,7 @@ async function startGatewayService(options = {}) {
|
|
|
15208
15484
|
...stateDir ? { stateDir } : {}
|
|
15209
15485
|
};
|
|
15210
15486
|
const launch = adopt(record3, input.credential);
|
|
15211
|
-
launch.
|
|
15487
|
+
launch.baseline = new Set([...table.values()].map(processKey));
|
|
15212
15488
|
await writePrivate(join22(paths.launches, `${record3.id}.json`), JSON.stringify(staticFields(record3)));
|
|
15213
15489
|
await persist(launch, true);
|
|
15214
15490
|
log(`launch ${record3.id.slice(0, 8)} registered (${record3.gateway.harness}, ${record3.gateway.model})`);
|
|
@@ -15220,7 +15496,8 @@ async function startGatewayService(options = {}) {
|
|
|
15220
15496
|
});
|
|
15221
15497
|
if (table) {
|
|
15222
15498
|
track(launch, table, now());
|
|
15223
|
-
|
|
15499
|
+
launch.probedAfterLauncher = true;
|
|
15500
|
+
await adoptTokenHolders(launch, table, now(), true);
|
|
15224
15501
|
track(launch, table, now());
|
|
15225
15502
|
}
|
|
15226
15503
|
const others = table ? liveHolders(launch, table).filter((holder) => holder.pid !== launch.record.launcherPid) : launch.record.holders;
|
|
@@ -15228,7 +15505,7 @@ async function startGatewayService(options = {}) {
|
|
|
15228
15505
|
launch.events = [];
|
|
15229
15506
|
launch.eventBytes = 0;
|
|
15230
15507
|
if (!others.length) {
|
|
15231
|
-
await remove(launch, "revoked: launch ended", false);
|
|
15508
|
+
await remove(launch, "revoked: launch ended", false, true);
|
|
15232
15509
|
return { retained: false, holders: 0, events, eventsDropped };
|
|
15233
15510
|
}
|
|
15234
15511
|
launch.record.released = true;
|
|
@@ -15298,6 +15575,23 @@ async function startGatewayService(options = {}) {
|
|
|
15298
15575
|
log(`ignored unreadable launch record ${name.slice(0, 8)}`);
|
|
15299
15576
|
}
|
|
15300
15577
|
}
|
|
15578
|
+
for (const name of await readdir7(paths.ended)) {
|
|
15579
|
+
if (!/^[0-9a-f-]{36}\.json$/.test(name))
|
|
15580
|
+
continue;
|
|
15581
|
+
try {
|
|
15582
|
+
const record3 = endedSchema.parse(await readPrivateJson(join22(paths.ended, name)));
|
|
15583
|
+
if (record3.id !== name.slice(0, -5))
|
|
15584
|
+
throw new Error("ended launch record id mismatch");
|
|
15585
|
+
const entry = { record: record3, failed: new Map, lookups: [] };
|
|
15586
|
+
if (launches.has(record3.id) || byDigest.has(record3.tokenDigest))
|
|
15587
|
+
await forgetEnded(entry);
|
|
15588
|
+
else
|
|
15589
|
+
ended.set(record3.tokenDigest, entry);
|
|
15590
|
+
} catch {
|
|
15591
|
+
log(`ignored unreadable ended launch record ${name.slice(0, 8)}`);
|
|
15592
|
+
}
|
|
15593
|
+
}
|
|
15594
|
+
await pruneEnded(restoredAt);
|
|
15301
15595
|
log(`listening on ${url} (pid ${process.pid}, version ${VERSION}, ${launches.size} launch(es) restored)`);
|
|
15302
15596
|
await scan();
|
|
15303
15597
|
let tick = 0;
|
|
@@ -15333,7 +15627,7 @@ async function startGatewayService(options = {}) {
|
|
|
15333
15627
|
|
|
15334
15628
|
// src/gateway-supervisor.ts
|
|
15335
15629
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
15336
|
-
import { lstat as
|
|
15630
|
+
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
15631
|
import { dirname as dirname10, isAbsolute as isAbsolute18, join as join23 } from "path";
|
|
15338
15632
|
var LAUNCHD_LABEL = "com.hasna.switcher.gateway";
|
|
15339
15633
|
var SYSTEMD_UNIT = "switcher-gateway.service";
|
|
@@ -15358,7 +15652,7 @@ async function assertSafeServiceCommand(command, temporaryRoots = TEMPORARY_ROOT
|
|
|
15358
15652
|
if (temporaryRoots.some((root) => candidate === root || candidate.startsWith(`${root}/`)))
|
|
15359
15653
|
throw refuse(path, `${candidate} is under a temporary directory`);
|
|
15360
15654
|
for (let current = candidate;; current = dirname10(current)) {
|
|
15361
|
-
const info2 = await
|
|
15655
|
+
const info2 = await lstat12(current).catch(() => {
|
|
15362
15656
|
throw refuse(path, `${current} could not be checked`);
|
|
15363
15657
|
});
|
|
15364
15658
|
if (!info2.isSymbolicLink()) {
|
|
@@ -15490,7 +15784,7 @@ async function writeUnit(path, content) {
|
|
|
15490
15784
|
} finally {
|
|
15491
15785
|
await file.close();
|
|
15492
15786
|
}
|
|
15493
|
-
await
|
|
15787
|
+
await rename6(temporary, path);
|
|
15494
15788
|
return true;
|
|
15495
15789
|
}
|
|
15496
15790
|
async function installGatewayService(options) {
|
|
@@ -16017,7 +16311,7 @@ async function launch(client, profileId, options = {}) {
|
|
|
16017
16311
|
version: detection?.version,
|
|
16018
16312
|
sharedState,
|
|
16019
16313
|
gatewayHost,
|
|
16020
|
-
...["pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "opencode", "kilo", "antigravity", "junie"].includes(plan.profile.harness) ? { sessionDir: join24(root, "sessions", plan.profile.harness, profileId) } : {}
|
|
16314
|
+
...["pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "opencode", "kilo", "antigravity", "junie", "claude"].includes(plan.profile.harness) ? { sessionDir: join24(root, "sessions", plan.profile.harness, profileId) } : {}
|
|
16021
16315
|
});
|
|
16022
16316
|
cleanup = prepared.cleanup;
|
|
16023
16317
|
prepared = { ...prepared, warnings: [...prepared.warnings, ...stateWarnings] };
|
|
@@ -16256,14 +16550,14 @@ async function ensureLaunchProfile(client, provider, harness, model3, modelPolic
|
|
|
16256
16550
|
// src/native-state-import.ts
|
|
16257
16551
|
import { createHash as createHash18 } from "crypto";
|
|
16258
16552
|
import { constants as constants11 } from "fs";
|
|
16259
|
-
import { lstat as
|
|
16553
|
+
import { lstat as lstat13, open as open9, opendir as opendir2, link as link3, rmdir as rmdir2, unlink as unlink5 } from "fs/promises";
|
|
16260
16554
|
import { basename as basename6, dirname as dirname11, isAbsolute as isAbsolute19, join as join25, relative as relative6, resolve as resolve15 } from "path";
|
|
16261
16555
|
var MAX_FILES = 1e5;
|
|
16262
16556
|
var MAX_BYTES2 = 2 * 1024 * 1024 * 1024;
|
|
16263
16557
|
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
16558
|
async function info2(path) {
|
|
16265
16559
|
try {
|
|
16266
|
-
return await
|
|
16560
|
+
return await lstat13(path);
|
|
16267
16561
|
} catch (error) {
|
|
16268
16562
|
if (error.code === "ENOENT")
|
|
16269
16563
|
return;
|
|
@@ -16293,7 +16587,7 @@ async function sessionId(path, expected) {
|
|
|
16293
16587
|
length += read.bytesRead;
|
|
16294
16588
|
newline = buffer.indexOf(10, 0);
|
|
16295
16589
|
}
|
|
16296
|
-
const after = await handle.stat(), named = await
|
|
16590
|
+
const after = await handle.stat(), named = await lstat13(path);
|
|
16297
16591
|
if (!same(before, after) || !same(after, named) || after.nlink !== 1 || named.nlink !== 1 || named.isSymbolicLink())
|
|
16298
16592
|
throw refused();
|
|
16299
16593
|
if (newline < 0 && before.size > buffer.length)
|
|
@@ -16392,7 +16686,7 @@ async function fingerprint2(path, copyTo) {
|
|
|
16392
16686
|
offset += (await output.write(chunk, offset, chunk.length - offset)).bytesWritten;
|
|
16393
16687
|
}
|
|
16394
16688
|
}
|
|
16395
|
-
const after = await handle.stat(), named = await
|
|
16689
|
+
const after = await handle.stat(), named = await lstat13(path);
|
|
16396
16690
|
if (named.isSymbolicLink() || after.nlink !== 1 || named.nlink !== 1 || bytes !== before.size || !same(before, after) || !same(after, named))
|
|
16397
16691
|
throw refused();
|
|
16398
16692
|
await output?.sync();
|