@hasna/switcher 0.2.5 → 0.2.7
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/README.md +31 -2
- package/dist/antigravity-config.d.ts +7 -0
- package/dist/bedrock.d.ts +2 -0
- package/dist/cli/index.js +508 -230
- package/dist/domain.d.ts +18 -8
- package/dist/generated/api.d.ts +17 -5
- package/dist/harnesses.d.ts +2 -2
- package/dist/index.js +23 -4
- package/dist/junie-config.d.ts +8 -0
- package/dist/launcher.d.ts +1 -1
- package/dist/mcp/index.js +84 -10
- package/dist/model-policy-schema.d.ts +3 -0
- package/dist/model-policy.d.ts +1 -0
- package/dist/native-cli-settings.d.ts +6 -0
- package/dist/native-model-policy.d.ts +1 -1
- package/dist/sdk.d.ts +18 -9
- package/dist/sdk.js +23 -4
- package/dist/serve/index.js +80 -9
- package/docs/MODEL-POLICY.md +6 -2
- package/openapi.json +53 -1
- package/package.json +1 -1
package/dist/domain.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { type RoutingEvent } from "./model-policy-schema";
|
|
|
3
3
|
export { modelPolicySchema, routingEventSchema, routingEventsSchema } from "./model-policy-schema";
|
|
4
4
|
export type { ModelPolicy, RoutingEvent } from "./model-policy-schema";
|
|
5
5
|
export type { AuthStyle } from "./auth";
|
|
6
|
-
export declare const VERSION = "0.2.
|
|
7
|
-
export declare const harnessSchema: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
|
|
6
|
+
export declare const VERSION = "0.2.7";
|
|
7
|
+
export declare const harnessSchema: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "antigravity", "junie", "aider", "kilo"]>;
|
|
8
8
|
export declare const protocolSchema: z.ZodEnum<["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]>;
|
|
9
9
|
export declare const idSchema: z.ZodString;
|
|
10
10
|
export declare function endpoint(value: string): string;
|
|
@@ -444,10 +444,11 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
444
444
|
id: z.ZodString;
|
|
445
445
|
name: z.ZodString;
|
|
446
446
|
providerId: z.ZodString;
|
|
447
|
-
harness: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
|
|
447
|
+
harness: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "antigravity", "junie", "aider", "kilo"]>;
|
|
448
448
|
model: z.ZodString;
|
|
449
449
|
modelPolicy: z.ZodOptional<z.ZodObject<{
|
|
450
450
|
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
451
|
+
selection: z.ZodOptional<z.ZodEnum<["restricted", "catalog"]>>;
|
|
451
452
|
roles: z.ZodOptional<z.ZodObject<{
|
|
452
453
|
subagent: z.ZodOptional<z.ZodString>;
|
|
453
454
|
fast: z.ZodOptional<z.ZodString>;
|
|
@@ -481,6 +482,7 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
481
482
|
fallbacks: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>, Record<string, string[]>, Record<string, string[]>>>;
|
|
482
483
|
}, "strict", z.ZodTypeAny, {
|
|
483
484
|
version: 1;
|
|
485
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
484
486
|
roles?: {
|
|
485
487
|
subagent?: string | undefined;
|
|
486
488
|
fast?: string | undefined;
|
|
@@ -496,6 +498,7 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
496
498
|
fallbacks?: Record<string, string[]> | undefined;
|
|
497
499
|
}, {
|
|
498
500
|
version?: 1 | undefined;
|
|
501
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
499
502
|
roles?: {
|
|
500
503
|
subagent?: string | undefined;
|
|
501
504
|
fast?: string | undefined;
|
|
@@ -514,10 +517,11 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
514
517
|
id: string;
|
|
515
518
|
name: string;
|
|
516
519
|
providerId: string;
|
|
517
|
-
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
520
|
+
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "antigravity" | "junie" | "aider" | "kilo";
|
|
518
521
|
model: string;
|
|
519
522
|
modelPolicy?: {
|
|
520
523
|
version: 1;
|
|
524
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
521
525
|
roles?: {
|
|
522
526
|
subagent?: string | undefined;
|
|
523
527
|
fast?: string | undefined;
|
|
@@ -536,10 +540,11 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
536
540
|
id: string;
|
|
537
541
|
name: string;
|
|
538
542
|
providerId: string;
|
|
539
|
-
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
543
|
+
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "antigravity" | "junie" | "aider" | "kilo";
|
|
540
544
|
model: string;
|
|
541
545
|
modelPolicy?: {
|
|
542
546
|
version?: 1 | undefined;
|
|
547
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
543
548
|
roles?: {
|
|
544
549
|
subagent?: string | undefined;
|
|
545
550
|
fast?: string | undefined;
|
|
@@ -558,10 +563,11 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
558
563
|
export declare const runInputSchema: z.ZodObject<{
|
|
559
564
|
modelPolicyVersion: z.ZodLiteral<1>;
|
|
560
565
|
profileId: z.ZodString;
|
|
561
|
-
harness: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
|
|
566
|
+
harness: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "antigravity", "junie", "aider", "kilo"]>;
|
|
562
567
|
model: z.ZodString;
|
|
563
568
|
modelPolicy: z.ZodOptional<z.ZodObject<{
|
|
564
569
|
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
570
|
+
selection: z.ZodOptional<z.ZodEnum<["restricted", "catalog"]>>;
|
|
565
571
|
roles: z.ZodOptional<z.ZodObject<{
|
|
566
572
|
subagent: z.ZodOptional<z.ZodString>;
|
|
567
573
|
fast: z.ZodOptional<z.ZodString>;
|
|
@@ -595,6 +601,7 @@ export declare const runInputSchema: z.ZodObject<{
|
|
|
595
601
|
fallbacks: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>, Record<string, string[]>, Record<string, string[]>>>;
|
|
596
602
|
}, "strict", z.ZodTypeAny, {
|
|
597
603
|
version: 1;
|
|
604
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
598
605
|
roles?: {
|
|
599
606
|
subagent?: string | undefined;
|
|
600
607
|
fast?: string | undefined;
|
|
@@ -610,6 +617,7 @@ export declare const runInputSchema: z.ZodObject<{
|
|
|
610
617
|
fallbacks?: Record<string, string[]> | undefined;
|
|
611
618
|
}, {
|
|
612
619
|
version?: 1 | undefined;
|
|
620
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
613
621
|
roles?: {
|
|
614
622
|
subagent?: string | undefined;
|
|
615
623
|
fast?: string | undefined;
|
|
@@ -626,13 +634,14 @@ export declare const runInputSchema: z.ZodObject<{
|
|
|
626
634
|
}>>;
|
|
627
635
|
planToken: z.ZodString;
|
|
628
636
|
}, "strict", z.ZodTypeAny, {
|
|
629
|
-
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
637
|
+
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "antigravity" | "junie" | "aider" | "kilo";
|
|
630
638
|
model: string;
|
|
631
639
|
modelPolicyVersion: 1;
|
|
632
640
|
profileId: string;
|
|
633
641
|
planToken: string;
|
|
634
642
|
modelPolicy?: {
|
|
635
643
|
version: 1;
|
|
644
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
636
645
|
roles?: {
|
|
637
646
|
subagent?: string | undefined;
|
|
638
647
|
fast?: string | undefined;
|
|
@@ -648,13 +657,14 @@ export declare const runInputSchema: z.ZodObject<{
|
|
|
648
657
|
fallbacks?: Record<string, string[]> | undefined;
|
|
649
658
|
} | undefined;
|
|
650
659
|
}, {
|
|
651
|
-
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
660
|
+
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "antigravity" | "junie" | "aider" | "kilo";
|
|
652
661
|
model: string;
|
|
653
662
|
modelPolicyVersion: 1;
|
|
654
663
|
profileId: string;
|
|
655
664
|
planToken: string;
|
|
656
665
|
modelPolicy?: {
|
|
657
666
|
version?: 1 | undefined;
|
|
667
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
658
668
|
roles?: {
|
|
659
669
|
subagent?: string | undefined;
|
|
660
670
|
fast?: string | undefined;
|
package/dist/generated/api.d.ts
CHANGED
|
@@ -432,7 +432,7 @@ export interface components {
|
|
|
432
432
|
name: string;
|
|
433
433
|
providerId: string;
|
|
434
434
|
/** @enum {string} */
|
|
435
|
-
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "kilo";
|
|
435
|
+
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "antigravity" | "junie" | "aider" | "kilo";
|
|
436
436
|
model: string;
|
|
437
437
|
modelPolicy?: {
|
|
438
438
|
/**
|
|
@@ -440,6 +440,8 @@ export interface components {
|
|
|
440
440
|
* @enum {number}
|
|
441
441
|
*/
|
|
442
442
|
version: 1;
|
|
443
|
+
/** @enum {string} */
|
|
444
|
+
selection?: "restricted" | "catalog";
|
|
443
445
|
roles?: {
|
|
444
446
|
subagent?: string;
|
|
445
447
|
fast?: string;
|
|
@@ -464,7 +466,7 @@ export interface components {
|
|
|
464
466
|
name: string;
|
|
465
467
|
providerId: string;
|
|
466
468
|
/** @enum {string} */
|
|
467
|
-
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "kilo";
|
|
469
|
+
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "antigravity" | "junie" | "aider" | "kilo";
|
|
468
470
|
model: string;
|
|
469
471
|
modelPolicy?: {
|
|
470
472
|
/**
|
|
@@ -472,6 +474,8 @@ export interface components {
|
|
|
472
474
|
* @enum {number}
|
|
473
475
|
*/
|
|
474
476
|
version: 1;
|
|
477
|
+
/** @enum {string} */
|
|
478
|
+
selection?: "restricted" | "catalog";
|
|
475
479
|
roles?: {
|
|
476
480
|
subagent?: string;
|
|
477
481
|
fast?: string;
|
|
@@ -513,6 +517,8 @@ export interface components {
|
|
|
513
517
|
* @enum {number}
|
|
514
518
|
*/
|
|
515
519
|
version: 1;
|
|
520
|
+
/** @enum {string} */
|
|
521
|
+
selection?: "restricted" | "catalog";
|
|
516
522
|
roles?: {
|
|
517
523
|
subagent?: string;
|
|
518
524
|
fast?: string;
|
|
@@ -658,7 +664,7 @@ export interface components {
|
|
|
658
664
|
name: string;
|
|
659
665
|
providerId: string;
|
|
660
666
|
/** @enum {string} */
|
|
661
|
-
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "kilo";
|
|
667
|
+
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "antigravity" | "junie" | "aider" | "kilo";
|
|
662
668
|
model: string;
|
|
663
669
|
modelPolicy?: {
|
|
664
670
|
/**
|
|
@@ -666,6 +672,8 @@ export interface components {
|
|
|
666
672
|
* @enum {number}
|
|
667
673
|
*/
|
|
668
674
|
version: 1;
|
|
675
|
+
/** @enum {string} */
|
|
676
|
+
selection?: "restricted" | "catalog";
|
|
669
677
|
roles?: {
|
|
670
678
|
subagent?: string;
|
|
671
679
|
fast?: string;
|
|
@@ -715,7 +723,7 @@ export interface components {
|
|
|
715
723
|
modelPolicyVersion: 1;
|
|
716
724
|
profileId: string;
|
|
717
725
|
/** @enum {string} */
|
|
718
|
-
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "kilo";
|
|
726
|
+
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "antigravity" | "junie" | "aider" | "kilo";
|
|
719
727
|
model: string;
|
|
720
728
|
modelPolicy?: {
|
|
721
729
|
/**
|
|
@@ -723,6 +731,8 @@ export interface components {
|
|
|
723
731
|
* @enum {number}
|
|
724
732
|
*/
|
|
725
733
|
version: 1;
|
|
734
|
+
/** @enum {string} */
|
|
735
|
+
selection?: "restricted" | "catalog";
|
|
726
736
|
roles?: {
|
|
727
737
|
subagent?: string;
|
|
728
738
|
fast?: string;
|
|
@@ -770,7 +780,7 @@ export interface components {
|
|
|
770
780
|
modelPolicyVersion?: 1;
|
|
771
781
|
profileId: string;
|
|
772
782
|
/** @enum {string} */
|
|
773
|
-
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "kilo";
|
|
783
|
+
harness: "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "gemini" | "antigravity" | "junie" | "aider" | "kilo";
|
|
774
784
|
model: string;
|
|
775
785
|
modelPolicy?: {
|
|
776
786
|
/**
|
|
@@ -778,6 +788,8 @@ export interface components {
|
|
|
778
788
|
* @enum {number}
|
|
779
789
|
*/
|
|
780
790
|
version: 1;
|
|
791
|
+
/** @enum {string} */
|
|
792
|
+
selection?: "restricted" | "catalog";
|
|
781
793
|
roles?: {
|
|
782
794
|
subagent?: string;
|
|
783
795
|
fast?: string;
|
package/dist/harnesses.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { type ProviderRequestTiming } from "./provider-request";
|
|
|
2
2
|
import { type ReasoningEffort } from "./reasoning";
|
|
3
3
|
import type { HarnessId, HarnessLaunchInput, PreparedLaunch } from "./harness-types";
|
|
4
4
|
export declare function detectHarness(harness: HarnessId, override?: string): Promise<{
|
|
5
|
-
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
5
|
+
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "antigravity" | "junie" | "aider" | "kilo";
|
|
6
6
|
executable: string;
|
|
7
7
|
available: boolean;
|
|
8
8
|
version: string;
|
|
9
9
|
installation: import("./harness-installation").HarnessInstallation;
|
|
10
10
|
} | {
|
|
11
|
-
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
11
|
+
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "antigravity" | "junie" | "aider" | "kilo";
|
|
12
12
|
executable: string;
|
|
13
13
|
available: boolean;
|
|
14
14
|
version: undefined;
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var fallbacksSchema = z2.record(policyModelIdSchema, z2.array(policyModelIdSchem
|
|
|
21
21
|
});
|
|
22
22
|
var modelPolicySchema = z2.object({
|
|
23
23
|
version: z2.literal(1).default(1),
|
|
24
|
+
selection: z2.enum(["restricted", "catalog"]).optional(),
|
|
24
25
|
roles: z2.object({
|
|
25
26
|
subagent: policyModelIdSchema.optional(),
|
|
26
27
|
fast: policyModelIdSchema.optional(),
|
|
@@ -51,7 +52,7 @@ var routingEventSchema = z2.object({
|
|
|
51
52
|
}).strict();
|
|
52
53
|
var routingEventsSchema = z2.array(routingEventSchema).max(1000);
|
|
53
54
|
// src/domain.ts
|
|
54
|
-
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
|
|
55
|
+
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "antigravity", "junie", "aider", "kilo"]);
|
|
55
56
|
var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
|
|
56
57
|
var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
|
|
57
58
|
var label = z3.string().min(1).max(200);
|
|
@@ -175,7 +176,7 @@ function compatible(harness, protocol) {
|
|
|
175
176
|
return protocol === "anthropic-messages";
|
|
176
177
|
if (harness === "codex")
|
|
177
178
|
return protocol === "openai-responses";
|
|
178
|
-
if (harness === "gemini")
|
|
179
|
+
if (harness === "gemini" || harness === "antigravity")
|
|
179
180
|
return protocol === "gemini-generate-content";
|
|
180
181
|
if (protocol === "gemini-generate-content")
|
|
181
182
|
return false;
|
|
@@ -219,6 +220,19 @@ async function boundedJson(response, maxBytes = MAX_BYTES) {
|
|
|
219
220
|
// src/sdk.ts
|
|
220
221
|
import { createClientTransport } from "@hasna/contracts/client";
|
|
221
222
|
|
|
223
|
+
// src/bedrock.ts
|
|
224
|
+
function bedrockMantleOrigin(value) {
|
|
225
|
+
let url;
|
|
226
|
+
try {
|
|
227
|
+
url = new URL(value);
|
|
228
|
+
} catch {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (url.protocol !== "https:" || url.port || url.username || url.password || url.search || url.hash || url.pathname.replace(/\/+$/, "") !== "/anthropic/v1")
|
|
232
|
+
return;
|
|
233
|
+
return /^bedrock-mantle\.[a-z]{2}(?:-[a-z]+)+-\d+\.api\.aws$/.test(url.hostname) ? url.origin : undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
222
236
|
// src/presets.ts
|
|
223
237
|
var route = (protocol, baseUrl, options = {}) => ({
|
|
224
238
|
protocol,
|
|
@@ -251,8 +265,10 @@ var providerPresets = [
|
|
|
251
265
|
], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
|
|
252
266
|
preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none", credentialCheck: { method: "GET", path: "key" } })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
|
|
253
267
|
preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
|
|
268
|
+
preset("bedrock", "Amazon Bedrock (Mantle)", [route("anthropic-messages", undefined, { authStyle: "x-api-key", catalogAuthStyle: "bearer", notes: ["Pass the regional https://bedrock-mantle.<region>.api.aws/anthropic/v1 endpoint and a Bedrock API key. The authenticated catalog is /v1/models on that same origin. Model access and regional availability remain controlled by the AWS account; this route does not distribute or inherit AWS administrative credentials."] })], ["https://docs.aws.amazon.com/bedrock/latest/userguide/inference-messages-api.html", "https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html"], "AWS_BEARER_TOKEN_BEDROCK"),
|
|
254
269
|
preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
|
|
255
270
|
authStyle: "x-api-key",
|
|
271
|
+
credentialCheck: { method: "GET", path: "models" },
|
|
256
272
|
catalogBaseUrl: "https://generativelanguage.googleapis.com/v1beta",
|
|
257
273
|
catalogFormat: "gemini",
|
|
258
274
|
catalogAuthStyle: "x-api-key",
|
|
@@ -323,16 +339,19 @@ function providerFromPreset(presetId, options = {}) {
|
|
|
323
339
|
const baseUrl = options.baseUrl ?? selected.baseUrl;
|
|
324
340
|
if (!baseUrl)
|
|
325
341
|
throw new Fault(400, "endpoint_required", "This preset requires an explicit --url for its inference endpoint.");
|
|
342
|
+
const bedrockOrigin = presetId === "bedrock" ? bedrockMantleOrigin(endpoint(baseUrl)) : undefined;
|
|
343
|
+
if (presetId === "bedrock" && !bedrockOrigin)
|
|
344
|
+
throw new Fault(400, "invalid_url", "Bedrock requires a regional HTTPS Mantle endpoint ending in /anthropic/v1.");
|
|
326
345
|
if (presetId === "azure-openai" && !/\/openai\/v1$/.test(endpoint(baseUrl)))
|
|
327
346
|
throw new Fault(400, "invalid_url", "Azure OpenAI v1 requires an explicit endpoint ending in /openai/v1; deployment and api-version URLs are unsupported.");
|
|
328
347
|
if (options.baseUrl && selected.baseUrl && new URL(endpoint(options.baseUrl)).origin !== new URL(selected.baseUrl).origin && preset2.credentialEnv && !options.credentialEnv)
|
|
329
348
|
throw new Fault(422, "credential_authority", "An endpoint on another origin requires an explicit --credential-env reference.");
|
|
330
|
-
const suffix = selected.protocol === "anthropic-messages" ? "messages" : selected.protocol === "openai-responses" ? "responses" : "chat";
|
|
349
|
+
const suffix = selected.protocol === "anthropic-messages" ? "messages" : selected.protocol === "openai-responses" ? "responses" : selected.protocol === "gemini-generate-content" ? "generate-content" : "chat";
|
|
331
350
|
if (presetId === "fireworks" && !options.catalogBaseUrl && !options.catalogAccountId)
|
|
332
351
|
throw new Fault(400, "catalog_account_required", "Fireworks model discovery requires --catalog-account-id or an explicit --catalog-url.");
|
|
333
352
|
if (selected.catalogFormat === "none" && options.catalogFormat && options.catalogFormat !== "none" && !options.catalogBaseUrl)
|
|
334
353
|
throw new Fault(400, "catalog_url_required", "This preset requires an explicit --catalog-url when enabling a catalog parser.");
|
|
335
|
-
const catalogBaseUrl = options.catalogBaseUrl ?? (presetId === "fireworks" && options.catalogAccountId ? `https://api.fireworks.ai/v1/accounts/${encodeURIComponent(options.catalogAccountId)}` : options.baseUrl ? undefined : selected.catalogBaseUrl);
|
|
354
|
+
const catalogBaseUrl = options.catalogBaseUrl ?? (bedrockOrigin ? `${bedrockOrigin}/v1` : presetId === "fireworks" && options.catalogAccountId ? `https://api.fireworks.ai/v1/accounts/${encodeURIComponent(options.catalogAccountId)}` : options.baseUrl ? undefined : selected.catalogBaseUrl);
|
|
336
355
|
return parse(providerInputSchema, {
|
|
337
356
|
id: options.id ?? `${preset2.id}-${suffix}`,
|
|
338
357
|
name: preset2.name,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HarnessLaunchInput, PreparedLaunch } from "./harness-types";
|
|
2
|
+
export declare function validateJunieConfiguration(cwd: string, env?: NodeJS.ProcessEnv): Promise<{
|
|
3
|
+
configs: Record<string, any>[];
|
|
4
|
+
settings: Record<string, any>[];
|
|
5
|
+
allowlist: string | undefined;
|
|
6
|
+
globalInstructions: string | undefined;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function prepareJunie(input: HarnessLaunchInput): Promise<PreparedLaunch>;
|
package/dist/launcher.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ type OriPreparationOptions = Pick<LaunchOptions, "oriExecutable" | "args" | "res
|
|
|
29
29
|
cwd?: string;
|
|
30
30
|
onRoutingEvent?: (event: RoutingEvent) => void;
|
|
31
31
|
};
|
|
32
|
-
type OriSupportedHarness = Exclude<LaunchPlan["profile"]["harness"], "omp" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "opencode" | "kilo">;
|
|
32
|
+
type OriSupportedHarness = Exclude<LaunchPlan["profile"]["harness"], "omp" | "cline" | "hermes" | "prime-agent" | "gemini" | "aider" | "opencode" | "kilo" | "antigravity" | "junie">;
|
|
33
33
|
export declare function validateOriForPlan(plan: LaunchPlan, options?: Pick<OriPreparationOptions, "oriExecutable" | "args" | "credentialEnv" | "cwd">): Promise<{
|
|
34
34
|
contract: OriContract;
|
|
35
35
|
request: ReturnType<typeof buildOriRequest>;
|
package/dist/mcp/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var fallbacksSchema = z2.record(policyModelIdSchema, z2.array(policyModelIdSchem
|
|
|
35
35
|
});
|
|
36
36
|
var modelPolicySchema = z2.object({
|
|
37
37
|
version: z2.literal(1).default(1),
|
|
38
|
+
selection: z2.enum(["restricted", "catalog"]).optional(),
|
|
38
39
|
roles: z2.object({
|
|
39
40
|
subagent: policyModelIdSchema.optional(),
|
|
40
41
|
fast: policyModelIdSchema.optional(),
|
|
@@ -69,8 +70,8 @@ function canonicalPolicyJSON(value) {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// src/domain.ts
|
|
72
|
-
var VERSION = "0.2.
|
|
73
|
-
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
|
|
73
|
+
var VERSION = "0.2.7";
|
|
74
|
+
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "antigravity", "junie", "aider", "kilo"]);
|
|
74
75
|
var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
|
|
75
76
|
var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
|
|
76
77
|
var label = z3.string().min(1).max(200);
|
|
@@ -202,7 +203,7 @@ function compatible(harness, protocol) {
|
|
|
202
203
|
return protocol === "anthropic-messages";
|
|
203
204
|
if (harness === "codex")
|
|
204
205
|
return protocol === "openai-responses";
|
|
205
|
-
if (harness === "gemini")
|
|
206
|
+
if (harness === "gemini" || harness === "antigravity")
|
|
206
207
|
return protocol === "gemini-generate-content";
|
|
207
208
|
if (protocol === "gemini-generate-content")
|
|
208
209
|
return false;
|
|
@@ -211,7 +212,7 @@ function compatible(harness, protocol) {
|
|
|
211
212
|
function validateHarnessProvider(harness, provider) {
|
|
212
213
|
if (!compatible(harness, provider.protocol))
|
|
213
214
|
throw new Fault(422, "protocol_mismatch", "Harness does not support this provider protocol.");
|
|
214
|
-
if (harness === "gemini" && provider.authStyle !== "x-api-key")
|
|
215
|
+
if ((harness === "gemini" || harness === "antigravity") && provider.authStyle !== "x-api-key")
|
|
215
216
|
throw new Fault(422, "auth_mismatch", "Gemini CLI requires x-api-key authentication for its native generateContent protocol.");
|
|
216
217
|
}
|
|
217
218
|
function modelExpired(model, now = new Date) {
|
|
@@ -261,6 +262,19 @@ async function boundedJson(response, maxBytes = MAX_BYTES) {
|
|
|
261
262
|
// src/sdk.ts
|
|
262
263
|
import { createClientTransport } from "@hasna/contracts/client";
|
|
263
264
|
|
|
265
|
+
// src/bedrock.ts
|
|
266
|
+
function bedrockMantleOrigin(value) {
|
|
267
|
+
let url;
|
|
268
|
+
try {
|
|
269
|
+
url = new URL(value);
|
|
270
|
+
} catch {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (url.protocol !== "https:" || url.port || url.username || url.password || url.search || url.hash || url.pathname.replace(/\/+$/, "") !== "/anthropic/v1")
|
|
274
|
+
return;
|
|
275
|
+
return /^bedrock-mantle\.[a-z]{2}(?:-[a-z]+)+-\d+\.api\.aws$/.test(url.hostname) ? url.origin : undefined;
|
|
276
|
+
}
|
|
277
|
+
|
|
264
278
|
// src/presets.ts
|
|
265
279
|
var route = (protocol, baseUrl, options = {}) => ({
|
|
266
280
|
protocol,
|
|
@@ -293,8 +307,10 @@ var providerPresets = [
|
|
|
293
307
|
], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
|
|
294
308
|
preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none", credentialCheck: { method: "GET", path: "key" } })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
|
|
295
309
|
preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
|
|
310
|
+
preset("bedrock", "Amazon Bedrock (Mantle)", [route("anthropic-messages", undefined, { authStyle: "x-api-key", catalogAuthStyle: "bearer", notes: ["Pass the regional https://bedrock-mantle.<region>.api.aws/anthropic/v1 endpoint and a Bedrock API key. The authenticated catalog is /v1/models on that same origin. Model access and regional availability remain controlled by the AWS account; this route does not distribute or inherit AWS administrative credentials."] })], ["https://docs.aws.amazon.com/bedrock/latest/userguide/inference-messages-api.html", "https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html"], "AWS_BEARER_TOKEN_BEDROCK"),
|
|
296
311
|
preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
|
|
297
312
|
authStyle: "x-api-key",
|
|
313
|
+
credentialCheck: { method: "GET", path: "models" },
|
|
298
314
|
catalogBaseUrl: "https://generativelanguage.googleapis.com/v1beta",
|
|
299
315
|
catalogFormat: "gemini",
|
|
300
316
|
catalogAuthStyle: "x-api-key",
|
|
@@ -362,7 +378,7 @@ function providerCredential(provider, env = process.env) {
|
|
|
362
378
|
return;
|
|
363
379
|
let value = env[provider.credentialEnv];
|
|
364
380
|
if (!value) {
|
|
365
|
-
const preset2 = providerPresets.find((p) => p.credentialEnv === provider.credentialEnv && p.protocols.some((route2) => route2.protocol === provider.protocol && (route2.baseUrl ? new URL(route2.baseUrl).origin === new URL(provider.baseUrl).origin : p.id === "azure-openai")));
|
|
381
|
+
const preset2 = providerPresets.find((p) => p.credentialEnv === provider.credentialEnv && p.protocols.some((route2) => route2.protocol === provider.protocol && (route2.baseUrl ? new URL(route2.baseUrl).origin === new URL(provider.baseUrl).origin : p.id === "azure-openai" || p.id === "bedrock" && !!bedrockMantleOrigin(provider.baseUrl))));
|
|
366
382
|
value = preset2?.credentialAliases.map((name) => env[name]).find(Boolean);
|
|
367
383
|
}
|
|
368
384
|
if (value && /[\r\n]/.test(value))
|
|
@@ -976,6 +992,8 @@ async function discoverBase(provider, env = process.env, resolveCredential) {
|
|
|
976
992
|
reasoningEfforts: row.reasoning?.supported_efforts,
|
|
977
993
|
...provider.catalogFormat === "gemini" && row.supportedGenerationMethods !== undefined ? { supportedGenerationMethods: row.supportedGenerationMethods } : {}
|
|
978
994
|
};
|
|
995
|
+
if (provider.protocol === "anthropic-messages" && bedrockMantleOrigin(provider.baseUrl) && !id.startsWith("anthropic."))
|
|
996
|
+
candidate.available = false;
|
|
979
997
|
if (provider.catalogFormat === "mistral") {
|
|
980
998
|
const capabilities = row.capabilities;
|
|
981
999
|
if (typeof capabilities?.function_calling === "boolean")
|
|
@@ -1141,6 +1159,7 @@ function compileModelPolicy(model, catalog, policy) {
|
|
|
1141
1159
|
throw new Fault(400, "invalid_model_policy", "Model policy allowedModels is too large.");
|
|
1142
1160
|
for (const value of explicitAllowed)
|
|
1143
1161
|
requireAvailable(value, "An allowed model is not present in the eligible catalog.");
|
|
1162
|
+
const catalogAllowed = p.selection === "catalog" ? [...available] : [];
|
|
1144
1163
|
const aliases = Object.create(null);
|
|
1145
1164
|
for (const [name, target] of Object.entries(p.aliases ?? {})) {
|
|
1146
1165
|
if (Object.keys(aliases).length >= 200 || !/^[A-Za-z0-9._/-]{1,120}$/.test(name) || ["__proto__", "prototype", "constructor"].includes(name))
|
|
@@ -1152,7 +1171,7 @@ function compileModelPolicy(model, catalog, policy) {
|
|
|
1152
1171
|
aliases[name] = canonical;
|
|
1153
1172
|
}
|
|
1154
1173
|
const fallbacks = Object.create(null);
|
|
1155
|
-
const allowedSources = new Set([selected, ...Object.values(compiledRoles), ...explicitAllowed]);
|
|
1174
|
+
const allowedSources = new Set([selected, ...Object.values(compiledRoles), ...explicitAllowed, ...catalogAllowed]);
|
|
1156
1175
|
for (const [source, targets] of Object.entries(p.fallbacks ?? {})) {
|
|
1157
1176
|
if (!allowedSources.has(source) || !available.has(source) || !Array.isArray(targets) || Object.keys(fallbacks).length >= 200 || targets.length > 20)
|
|
1158
1177
|
throw new Fault(400, "invalid_model_policy", "Fallback source or list is invalid.");
|
|
@@ -1163,7 +1182,7 @@ function compileModelPolicy(model, catalog, policy) {
|
|
|
1163
1182
|
throw new Fault(400, "invalid_model_policy", "A model cannot fall back to itself.");
|
|
1164
1183
|
fallbacks[source] = uniq(values);
|
|
1165
1184
|
}
|
|
1166
|
-
const allowedModels = uniq([selected, ...Object.values(compiledRoles), ...explicitAllowed, ...Object.values(fallbacks).flat()]).sort();
|
|
1185
|
+
const allowedModels = uniq([selected, ...Object.values(compiledRoles), ...explicitAllowed, ...catalogAllowed, ...Object.values(fallbacks).flat()]).sort();
|
|
1167
1186
|
if (Object.values(aliases).some((value) => !allowedModels.includes(value)))
|
|
1168
1187
|
throw new Fault(422, "model_not_allowed", "A model alias target must be explicitly allowed by the launch policy.");
|
|
1169
1188
|
const result = { version: 1, model: selected, roles: compiledRoles, allowedModels, aliases, fallbacks };
|
|
@@ -1174,7 +1193,7 @@ var openapi_default = {
|
|
|
1174
1193
|
openapi: "3.0.3",
|
|
1175
1194
|
info: {
|
|
1176
1195
|
title: "Switcher API",
|
|
1177
|
-
version: "0.2.
|
|
1196
|
+
version: "0.2.7",
|
|
1178
1197
|
description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
|
|
1179
1198
|
},
|
|
1180
1199
|
security: [
|
|
@@ -3247,6 +3266,8 @@ var openapi_default = {
|
|
|
3247
3266
|
"hermes",
|
|
3248
3267
|
"prime-agent",
|
|
3249
3268
|
"gemini",
|
|
3269
|
+
"antigravity",
|
|
3270
|
+
"junie",
|
|
3250
3271
|
"aider",
|
|
3251
3272
|
"kilo"
|
|
3252
3273
|
]
|
|
@@ -3266,6 +3287,13 @@ var openapi_default = {
|
|
|
3266
3287
|
],
|
|
3267
3288
|
default: 1
|
|
3268
3289
|
},
|
|
3290
|
+
selection: {
|
|
3291
|
+
type: "string",
|
|
3292
|
+
enum: [
|
|
3293
|
+
"restricted",
|
|
3294
|
+
"catalog"
|
|
3295
|
+
]
|
|
3296
|
+
},
|
|
3269
3297
|
roles: {
|
|
3270
3298
|
type: "object",
|
|
3271
3299
|
properties: {
|
|
@@ -3396,6 +3424,8 @@ var openapi_default = {
|
|
|
3396
3424
|
"hermes",
|
|
3397
3425
|
"prime-agent",
|
|
3398
3426
|
"gemini",
|
|
3427
|
+
"antigravity",
|
|
3428
|
+
"junie",
|
|
3399
3429
|
"aider",
|
|
3400
3430
|
"kilo"
|
|
3401
3431
|
]
|
|
@@ -3415,6 +3445,13 @@ var openapi_default = {
|
|
|
3415
3445
|
],
|
|
3416
3446
|
default: 1
|
|
3417
3447
|
},
|
|
3448
|
+
selection: {
|
|
3449
|
+
type: "string",
|
|
3450
|
+
enum: [
|
|
3451
|
+
"restricted",
|
|
3452
|
+
"catalog"
|
|
3453
|
+
]
|
|
3454
|
+
},
|
|
3418
3455
|
roles: {
|
|
3419
3456
|
type: "object",
|
|
3420
3457
|
properties: {
|
|
@@ -3625,6 +3662,13 @@ var openapi_default = {
|
|
|
3625
3662
|
],
|
|
3626
3663
|
default: 1
|
|
3627
3664
|
},
|
|
3665
|
+
selection: {
|
|
3666
|
+
type: "string",
|
|
3667
|
+
enum: [
|
|
3668
|
+
"restricted",
|
|
3669
|
+
"catalog"
|
|
3670
|
+
]
|
|
3671
|
+
},
|
|
3628
3672
|
roles: {
|
|
3629
3673
|
type: "object",
|
|
3630
3674
|
properties: {
|
|
@@ -4394,6 +4438,8 @@ var openapi_default = {
|
|
|
4394
4438
|
"hermes",
|
|
4395
4439
|
"prime-agent",
|
|
4396
4440
|
"gemini",
|
|
4441
|
+
"antigravity",
|
|
4442
|
+
"junie",
|
|
4397
4443
|
"aider",
|
|
4398
4444
|
"kilo"
|
|
4399
4445
|
]
|
|
@@ -4413,6 +4459,13 @@ var openapi_default = {
|
|
|
4413
4459
|
],
|
|
4414
4460
|
default: 1
|
|
4415
4461
|
},
|
|
4462
|
+
selection: {
|
|
4463
|
+
type: "string",
|
|
4464
|
+
enum: [
|
|
4465
|
+
"restricted",
|
|
4466
|
+
"catalog"
|
|
4467
|
+
]
|
|
4468
|
+
},
|
|
4416
4469
|
roles: {
|
|
4417
4470
|
type: "object",
|
|
4418
4471
|
properties: {
|
|
@@ -4686,6 +4739,8 @@ var openapi_default = {
|
|
|
4686
4739
|
"hermes",
|
|
4687
4740
|
"prime-agent",
|
|
4688
4741
|
"gemini",
|
|
4742
|
+
"antigravity",
|
|
4743
|
+
"junie",
|
|
4689
4744
|
"aider",
|
|
4690
4745
|
"kilo"
|
|
4691
4746
|
]
|
|
@@ -4705,6 +4760,13 @@ var openapi_default = {
|
|
|
4705
4760
|
],
|
|
4706
4761
|
default: 1
|
|
4707
4762
|
},
|
|
4763
|
+
selection: {
|
|
4764
|
+
type: "string",
|
|
4765
|
+
enum: [
|
|
4766
|
+
"restricted",
|
|
4767
|
+
"catalog"
|
|
4768
|
+
]
|
|
4769
|
+
},
|
|
4708
4770
|
roles: {
|
|
4709
4771
|
type: "object",
|
|
4710
4772
|
properties: {
|
|
@@ -4951,6 +5013,8 @@ var openapi_default = {
|
|
|
4951
5013
|
"hermes",
|
|
4952
5014
|
"prime-agent",
|
|
4953
5015
|
"gemini",
|
|
5016
|
+
"antigravity",
|
|
5017
|
+
"junie",
|
|
4954
5018
|
"aider",
|
|
4955
5019
|
"kilo"
|
|
4956
5020
|
]
|
|
@@ -4970,6 +5034,13 @@ var openapi_default = {
|
|
|
4970
5034
|
],
|
|
4971
5035
|
default: 1
|
|
4972
5036
|
},
|
|
5037
|
+
selection: {
|
|
5038
|
+
type: "string",
|
|
5039
|
+
enum: [
|
|
5040
|
+
"restricted",
|
|
5041
|
+
"catalog"
|
|
5042
|
+
]
|
|
5043
|
+
},
|
|
4973
5044
|
roles: {
|
|
4974
5045
|
type: "object",
|
|
4975
5046
|
properties: {
|
|
@@ -5472,7 +5543,7 @@ function createHandler(store, authentication, providerEnv = process.env, resolve
|
|
|
5472
5543
|
}
|
|
5473
5544
|
if (resource === "providers" && id2 && parts[3] === "refresh" && parts.length === 4 && request.method === "POST") {
|
|
5474
5545
|
if (store.engine === "postgresql")
|
|
5475
|
-
await db.unsafe("SELECT id FROM switcher_providers WHERE id = $1 FOR
|
|
5546
|
+
await db.unsafe("SELECT id FROM switcher_providers WHERE id = $1 FOR UPDATE", [id2]);
|
|
5476
5547
|
const provider = await store.get("providers", id2, db);
|
|
5477
5548
|
if (!refreshed || provider.version !== refreshed.provider.version)
|
|
5478
5549
|
throw new Fault(409, "provider_changed", "Provider changed during discovery; refresh again.");
|
|
@@ -5489,7 +5560,7 @@ function createHandler(store, authentication, providerEnv = process.env, resolve
|
|
|
5489
5560
|
}
|
|
5490
5561
|
if (resource === "providers" && id2 && parts[3] === "catalog" && parts.length === 4 && request.method === "PUT") {
|
|
5491
5562
|
if (store.engine === "postgresql")
|
|
5492
|
-
await db.unsafe("SELECT id FROM switcher_providers WHERE id = $1 FOR
|
|
5563
|
+
await db.unsafe("SELECT id FROM switcher_providers WHERE id = $1 FOR UPDATE", [id2]);
|
|
5493
5564
|
const provider = await store.get("providers", id2, db);
|
|
5494
5565
|
if (provider.version !== version())
|
|
5495
5566
|
throw new Fault(409, "provider_changed", "Provider changed during local discovery; refresh again.");
|
|
@@ -6271,6 +6342,9 @@ function authenticationProbe(provider) {
|
|
|
6271
6342
|
return { url, method: provider.credentialCheck.method ?? "GET", authStyle: provider.authStyle ?? "bearer" };
|
|
6272
6343
|
}
|
|
6273
6344
|
const base = new URL(provider.baseUrl);
|
|
6345
|
+
const bedrockOrigin = bedrockMantleOrigin(provider.baseUrl);
|
|
6346
|
+
if (provider.protocol === "anthropic-messages" && bedrockOrigin)
|
|
6347
|
+
return { url: new URL("/v1/models", bedrockOrigin), method: "GET", authStyle: "bearer" };
|
|
6274
6348
|
if (provider.credentialEnv === "SWITCHER_PROVIDER_OPENROUTER" && base.origin === "https://openrouter.ai" && base.pathname.replace(/\/+$/, "") === "/api/v1")
|
|
6275
6349
|
return { url: new URL("https://openrouter.ai/api/v1/key"), method: "GET", authStyle: provider.authStyle ?? "bearer" };
|
|
6276
6350
|
return;
|
|
@@ -5,6 +5,7 @@ export declare const modelPolicyRoleSchema: z.ZodEnum<["subagent", "fast", "plan
|
|
|
5
5
|
export type ModelPolicyRole = z.infer<typeof modelPolicyRoleSchema>;
|
|
6
6
|
export declare const modelPolicySchema: z.ZodObject<{
|
|
7
7
|
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
8
|
+
selection: z.ZodOptional<z.ZodEnum<["restricted", "catalog"]>>;
|
|
8
9
|
roles: z.ZodOptional<z.ZodObject<{
|
|
9
10
|
subagent: z.ZodOptional<z.ZodString>;
|
|
10
11
|
fast: z.ZodOptional<z.ZodString>;
|
|
@@ -38,6 +39,7 @@ export declare const modelPolicySchema: z.ZodObject<{
|
|
|
38
39
|
fallbacks: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>, Record<string, string[]>, Record<string, string[]>>>;
|
|
39
40
|
}, "strict", z.ZodTypeAny, {
|
|
40
41
|
version: 1;
|
|
42
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
41
43
|
roles?: {
|
|
42
44
|
subagent?: string | undefined;
|
|
43
45
|
fast?: string | undefined;
|
|
@@ -53,6 +55,7 @@ export declare const modelPolicySchema: z.ZodObject<{
|
|
|
53
55
|
fallbacks?: Record<string, string[]> | undefined;
|
|
54
56
|
}, {
|
|
55
57
|
version?: 1 | undefined;
|
|
58
|
+
selection?: "restricted" | "catalog" | undefined;
|
|
56
59
|
roles?: {
|
|
57
60
|
subagent?: string | undefined;
|
|
58
61
|
fast?: string | undefined;
|