omnigateway 0.9.2 → 0.10.0
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/bin/omni.js +1754 -113
- package/gateway.js +1831 -194
- package/package.json +1 -1
- package/public/assets/{Chip-Did4Zhvj.js → Chip-BeKVtewW.js} +1 -1
- package/public/assets/{CopyValue-Cjg9QXrD.js → CopyValue-NTHhiCuT.js} +1 -1
- package/public/assets/{Rack-D0_N-xsd.js → Rack-sUGRoZUx.js} +1 -1
- package/public/assets/{RequestTable-i9paP_7e.js → RequestTable-C2RLARWy.js} +1 -1
- package/public/assets/{SummaryDeck-g4yLDeXB.js → SummaryDeck-BHXcb_Ji.js} +1 -1
- package/public/assets/{Toggle-D-NDlneh.js → Toggle-DwKz1aVq.js} +1 -1
- package/public/assets/{TokenBreakdown-D5ZIngM6.js → TokenBreakdown-DM-1HvOr.js} +1 -1
- package/public/assets/{_app.accounts-DFhyE62a.js → _app.accounts-DUYxItf0.js} +1 -1
- package/public/assets/{_app.console-BfHcfQMp.js → _app.console-BQJMLRv4.js} +1 -1
- package/public/assets/{_app.database-Cgw9z3rK.js → _app.database-BIiajZm6.js} +1 -1
- package/public/assets/{_app.index-Blw3S4-3.js → _app.index-DagK0Pqp.js} +1 -1
- package/public/assets/{_app.keys-DrdfnfIk.js → _app.keys-DLAG_bmt.js} +1 -1
- package/public/assets/{_app.logs-DUOqlJzB.js → _app.logs-AyVq3lLb.js} +1 -1
- package/public/assets/{_app.models-Dm83HRaM.js → _app.models-CwlkGPrx.js} +1 -1
- package/public/assets/{_app.plugins._pluginId-BmJGDYxw.js → _app.plugins._pluginId-BhvEnawY.js} +1 -1
- package/public/assets/{_app.settings-66rm4vHJ.js → _app.settings-BKA-1YLs.js} +1 -1
- package/public/assets/{_app.usage-BCufy5XR.js → _app.usage-C7JEWKZM.js} +1 -1
- package/public/assets/{chevron-right-BZ4QmUDM.js → chevron-right-S84SGCvk.js} +1 -1
- package/public/assets/{client-De1_cEH5.js → client-DCvpw0LS.js} +1 -1
- package/public/assets/{index-PP8vsvw3.js → index-pZbadEun.js} +3 -3
- package/public/assets/{login-CkZlwcdd.js → login-CitmheGz.js} +1 -1
- package/public/assets/plus-E7qLz9CF.js +1 -0
- package/public/assets/{trash-2-BLc5o7DN.js → trash-2-DmtElUHr.js} +1 -1
- package/public/index.html +2 -2
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/assets/plus-D5AwIXj3.js +0 -1
package/bin/omni.js
CHANGED
|
@@ -25,7 +25,9 @@ var ANSI = {
|
|
|
25
25
|
blue: "\x1B[34m",
|
|
26
26
|
magenta: "\x1B[35m",
|
|
27
27
|
cyan: "\x1B[36m",
|
|
28
|
-
orange: "\x1B[38;5;208m"
|
|
28
|
+
orange: "\x1B[38;5;208m",
|
|
29
|
+
violet: "\x1B[38;5;99m",
|
|
30
|
+
azure: "\x1B[38;5;33m"
|
|
29
31
|
};
|
|
30
32
|
var consoleWriter = {
|
|
31
33
|
out: (line) => {
|
|
@@ -23466,6 +23468,12 @@ var ANTHROPIC_MODELS = {
|
|
|
23466
23468
|
defaultModel: "claude-opus-5",
|
|
23467
23469
|
authTypes: ["oauth", "apiKey"],
|
|
23468
23470
|
models: [
|
|
23471
|
+
{
|
|
23472
|
+
id: "claude-fable-5-1",
|
|
23473
|
+
label: "Claude Fable 5.1",
|
|
23474
|
+
pricing: { input: 10, output: 50, cacheRead: 0.25, cacheWrite5m: 12.5, cacheWrite1h: 20 },
|
|
23475
|
+
limits: { contextWindow: 1e6, maxOutputTokens: 128000 }
|
|
23476
|
+
},
|
|
23469
23477
|
{
|
|
23470
23478
|
id: "claude-fable-5",
|
|
23471
23479
|
label: "Claude Fable 5",
|
|
@@ -23481,7 +23489,7 @@ var ANTHROPIC_MODELS = {
|
|
|
23481
23489
|
{
|
|
23482
23490
|
id: "claude-sonnet-5",
|
|
23483
23491
|
label: "Claude Sonnet 5",
|
|
23484
|
-
pricing: { input:
|
|
23492
|
+
pricing: { input: 2, output: 10, cacheRead: 0.2, cacheWrite5m: 2.5, cacheWrite1h: 4 },
|
|
23485
23493
|
limits: { contextWindow: 1e6, maxOutputTokens: 128000 }
|
|
23486
23494
|
},
|
|
23487
23495
|
{
|
|
@@ -23519,6 +23527,144 @@ var anthropicDescriptor = {
|
|
|
23519
23527
|
}
|
|
23520
23528
|
};
|
|
23521
23529
|
|
|
23530
|
+
// packages/providers/src/antigravity/models.ts
|
|
23531
|
+
var MAX_OUTPUT_TOKENS = 65536;
|
|
23532
|
+
var PRO_MAX_OUTPUT_TOKENS = 65535;
|
|
23533
|
+
var FREE = { input: 0, output: 0, cacheRead: 0, cacheWrite5m: 0, cacheWrite1h: 0 };
|
|
23534
|
+
var FLASH_LIMITS = { contextWindow: 1048576, maxOutputTokens: MAX_OUTPUT_TOKENS };
|
|
23535
|
+
var PRO_LIMITS = { contextWindow: 1048576, maxOutputTokens: PRO_MAX_OUTPUT_TOKENS };
|
|
23536
|
+
var ANTIGRAVITY_MODELS = {
|
|
23537
|
+
defaultModel: "gemini-3.8-flash-high",
|
|
23538
|
+
authTypes: ["oauth"],
|
|
23539
|
+
models: [
|
|
23540
|
+
{
|
|
23541
|
+
id: "gemini-3.8-flash-high",
|
|
23542
|
+
label: "Gemini 3.8 Flash (High)",
|
|
23543
|
+
pricing: FREE,
|
|
23544
|
+
limits: FLASH_LIMITS
|
|
23545
|
+
},
|
|
23546
|
+
{
|
|
23547
|
+
id: "gemini-3.8-flash-medium",
|
|
23548
|
+
label: "Gemini 3.8 Flash (Medium)",
|
|
23549
|
+
pricing: FREE,
|
|
23550
|
+
limits: FLASH_LIMITS
|
|
23551
|
+
},
|
|
23552
|
+
{
|
|
23553
|
+
id: "gemini-3.8-flash-low",
|
|
23554
|
+
label: "Gemini 3.8 Flash (Low)",
|
|
23555
|
+
pricing: FREE,
|
|
23556
|
+
limits: FLASH_LIMITS
|
|
23557
|
+
},
|
|
23558
|
+
{
|
|
23559
|
+
id: "gemini-3.7-flash-high",
|
|
23560
|
+
label: "Gemini 3.7 Flash (High)",
|
|
23561
|
+
pricing: FREE,
|
|
23562
|
+
limits: FLASH_LIMITS
|
|
23563
|
+
},
|
|
23564
|
+
{
|
|
23565
|
+
id: "gemini-3.7-flash-medium",
|
|
23566
|
+
label: "Gemini 3.7 Flash (Medium)",
|
|
23567
|
+
pricing: FREE,
|
|
23568
|
+
limits: FLASH_LIMITS
|
|
23569
|
+
},
|
|
23570
|
+
{
|
|
23571
|
+
id: "gemini-3.7-flash-low",
|
|
23572
|
+
label: "Gemini 3.7 Flash (Low)",
|
|
23573
|
+
pricing: FREE,
|
|
23574
|
+
limits: FLASH_LIMITS
|
|
23575
|
+
},
|
|
23576
|
+
{
|
|
23577
|
+
id: "gemini-3.6-flash-high",
|
|
23578
|
+
label: "Gemini 3.6 Flash (High)",
|
|
23579
|
+
pricing: FREE,
|
|
23580
|
+
limits: FLASH_LIMITS
|
|
23581
|
+
},
|
|
23582
|
+
{
|
|
23583
|
+
id: "gemini-3.6-flash-medium",
|
|
23584
|
+
label: "Gemini 3.6 Flash (Medium)",
|
|
23585
|
+
pricing: FREE,
|
|
23586
|
+
limits: FLASH_LIMITS
|
|
23587
|
+
},
|
|
23588
|
+
{
|
|
23589
|
+
id: "gemini-3.6-flash-low",
|
|
23590
|
+
label: "Gemini 3.6 Flash (Low)",
|
|
23591
|
+
pricing: FREE,
|
|
23592
|
+
limits: FLASH_LIMITS
|
|
23593
|
+
},
|
|
23594
|
+
{
|
|
23595
|
+
id: "gemini-3-flash-agent",
|
|
23596
|
+
label: "Gemini 3.5 Flash (High)",
|
|
23597
|
+
pricing: FREE,
|
|
23598
|
+
limits: FLASH_LIMITS
|
|
23599
|
+
},
|
|
23600
|
+
{
|
|
23601
|
+
id: "gemini-3.5-flash-low",
|
|
23602
|
+
label: "Gemini 3.5 Flash (Medium)",
|
|
23603
|
+
pricing: FREE,
|
|
23604
|
+
limits: FLASH_LIMITS
|
|
23605
|
+
},
|
|
23606
|
+
{
|
|
23607
|
+
id: "gemini-3.5-flash-extra-low",
|
|
23608
|
+
label: "Gemini 3.5 Flash (Low)",
|
|
23609
|
+
pricing: FREE,
|
|
23610
|
+
limits: FLASH_LIMITS
|
|
23611
|
+
},
|
|
23612
|
+
{
|
|
23613
|
+
id: "gemini-3-flash",
|
|
23614
|
+
label: "Gemini 3 Flash",
|
|
23615
|
+
pricing: FREE,
|
|
23616
|
+
limits: FLASH_LIMITS
|
|
23617
|
+
},
|
|
23618
|
+
{
|
|
23619
|
+
id: "gemini-3.5-flash-lite",
|
|
23620
|
+
label: "Gemini 3.5 Flash Lite",
|
|
23621
|
+
pricing: FREE,
|
|
23622
|
+
limits: PRO_LIMITS
|
|
23623
|
+
},
|
|
23624
|
+
{
|
|
23625
|
+
id: "gemini-3.1-pro-high",
|
|
23626
|
+
label: "Gemini 3.1 Pro (High)",
|
|
23627
|
+
pricing: FREE,
|
|
23628
|
+
limits: PRO_LIMITS
|
|
23629
|
+
},
|
|
23630
|
+
{
|
|
23631
|
+
id: "gemini-3.1-pro-low",
|
|
23632
|
+
label: "Gemini 3.1 Pro (Low)",
|
|
23633
|
+
pricing: FREE,
|
|
23634
|
+
limits: PRO_LIMITS
|
|
23635
|
+
},
|
|
23636
|
+
{
|
|
23637
|
+
id: "gemini-3.1-flash-lite",
|
|
23638
|
+
label: "Gemini 3.1 Flash Lite",
|
|
23639
|
+
pricing: FREE,
|
|
23640
|
+
limits: PRO_LIMITS
|
|
23641
|
+
},
|
|
23642
|
+
{
|
|
23643
|
+
id: "gemini-2.5-pro",
|
|
23644
|
+
label: "Gemini 2.5 Pro",
|
|
23645
|
+
pricing: FREE,
|
|
23646
|
+
limits: PRO_LIMITS
|
|
23647
|
+
}
|
|
23648
|
+
]
|
|
23649
|
+
};
|
|
23650
|
+
|
|
23651
|
+
// packages/providers/src/antigravity/descriptor.ts
|
|
23652
|
+
var antigravityDescriptor = {
|
|
23653
|
+
id: "antigravity",
|
|
23654
|
+
capabilities: { tools: true, images: true, reasoning: true },
|
|
23655
|
+
writeOverInput: { fiveMinute: 0, oneHour: 0 },
|
|
23656
|
+
catalog: ANTIGRAVITY_MODELS,
|
|
23657
|
+
modelPrefixes: ["gemini-"],
|
|
23658
|
+
callback: { uri: "http://127.0.0.1:51121/callback", label: "Antigravity" },
|
|
23659
|
+
presentation: {
|
|
23660
|
+
label: "Antigravity",
|
|
23661
|
+
order: 6,
|
|
23662
|
+
tone: "violet",
|
|
23663
|
+
colour: { light: "oklch(0.52 0.14 277)", dark: "oklch(0.74 0.14 277)" },
|
|
23664
|
+
pasteHint: "Approve in a browser on the gateway's own machine \u2014 or SSH-forward port 51121 first. When it redirects to 127.0.0.1, paste the whole URL."
|
|
23665
|
+
}
|
|
23666
|
+
};
|
|
23667
|
+
|
|
23522
23668
|
// packages/providers/src/custom/models.ts
|
|
23523
23669
|
var CUSTOM_MODELS = {
|
|
23524
23670
|
defaultModel: "",
|
|
@@ -23535,7 +23681,7 @@ var customDescriptor = {
|
|
|
23535
23681
|
modelPrefixes: [],
|
|
23536
23682
|
presentation: {
|
|
23537
23683
|
label: "OpenAI Compatible",
|
|
23538
|
-
order:
|
|
23684
|
+
order: 8,
|
|
23539
23685
|
tone: "cyan",
|
|
23540
23686
|
colour: { light: "oklch(0.5 0.03 258)", dark: "oklch(0.72 0.03 258)" },
|
|
23541
23687
|
pasteHint: "Enter endpoint metadata and API key."
|
|
@@ -23860,35 +24006,90 @@ var kimiDescriptor = {
|
|
|
23860
24006
|
}
|
|
23861
24007
|
};
|
|
23862
24008
|
|
|
24009
|
+
// packages/providers/src/muse/models.ts
|
|
24010
|
+
var MUSE_MODELS = {
|
|
24011
|
+
defaultModel: "muse-spark-1.3",
|
|
24012
|
+
authTypes: ["oauth", "apiKey"],
|
|
24013
|
+
models: [
|
|
24014
|
+
{
|
|
24015
|
+
id: "muse-spark-1.3",
|
|
24016
|
+
label: "Muse Spark 1.3",
|
|
24017
|
+
pricing: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24018
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24019
|
+
},
|
|
24020
|
+
{
|
|
24021
|
+
id: "muse-spark-1.3-contributor",
|
|
24022
|
+
label: "Muse Spark 1.3 \u2014 Meta trains on this traffic",
|
|
24023
|
+
pricing: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24024
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24025
|
+
},
|
|
24026
|
+
{
|
|
24027
|
+
id: "muse-spark-1.2",
|
|
24028
|
+
label: "Muse Spark 1.2",
|
|
24029
|
+
pricing: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24030
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24031
|
+
},
|
|
24032
|
+
{
|
|
24033
|
+
id: "muse-spark-1.2-contributor",
|
|
24034
|
+
label: "Muse Spark 1.2 \u2014 Meta trains on this traffic",
|
|
24035
|
+
pricing: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24036
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24037
|
+
}
|
|
24038
|
+
]
|
|
24039
|
+
};
|
|
24040
|
+
|
|
24041
|
+
// packages/providers/src/muse/descriptor.ts
|
|
24042
|
+
var museDescriptor = {
|
|
24043
|
+
id: "muse",
|
|
24044
|
+
capabilities: { tools: true, images: true, reasoning: true },
|
|
24045
|
+
writeOverInput: { fiveMinute: 0, oneHour: 0 },
|
|
24046
|
+
catalog: MUSE_MODELS,
|
|
24047
|
+
modelPrefixes: ["muse-", "muse-spark"],
|
|
24048
|
+
presentation: {
|
|
24049
|
+
label: "Muse",
|
|
24050
|
+
order: 7,
|
|
24051
|
+
tone: "azure",
|
|
24052
|
+
colour: { light: "oklch(0.55 0.23 262)", dark: "oklch(0.72 0.17 262)" },
|
|
24053
|
+
pasteHint: "Enter the code on Meta's device page. This dialog finishes on its own."
|
|
24054
|
+
}
|
|
24055
|
+
};
|
|
24056
|
+
|
|
23863
24057
|
// packages/providers/src/openai/models.ts
|
|
23864
24058
|
var OPENAI_MODELS = {
|
|
23865
24059
|
defaultModel: "gpt-5.6",
|
|
23866
24060
|
authTypes: ["oauth", "apiKey"],
|
|
23867
24061
|
models: [
|
|
24062
|
+
{
|
|
24063
|
+
id: "gpt-6-astra",
|
|
24064
|
+
label: "GPT-6 Astra",
|
|
24065
|
+
pricing: { input: 10, output: 50, cacheRead: 1, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24066
|
+
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
24067
|
+
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
24068
|
+
},
|
|
23868
24069
|
{
|
|
23869
24070
|
id: "gpt-5.6",
|
|
23870
24071
|
label: "GPT-5.6 \u2014 routes to Sol",
|
|
23871
|
-
pricing: { input:
|
|
24072
|
+
pricing: { input: 4, output: 20, cacheRead: 0.4, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23872
24073
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23873
24074
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
23874
24075
|
},
|
|
23875
24076
|
{
|
|
23876
24077
|
id: "gpt-5.6-sol",
|
|
23877
|
-
label: "GPT-5.6 Sol
|
|
23878
|
-
pricing: { input:
|
|
24078
|
+
label: "GPT-5.6 Sol",
|
|
24079
|
+
pricing: { input: 4, output: 20, cacheRead: 0.4, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23879
24080
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23880
24081
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
23881
24082
|
},
|
|
23882
24083
|
{
|
|
23883
24084
|
id: "gpt-5.6-terra",
|
|
23884
|
-
label: "GPT-5.6 Terra
|
|
24085
|
+
label: "GPT-5.6 Terra",
|
|
23885
24086
|
pricing: { input: 2, output: 12, cacheRead: 0.2, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23886
24087
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23887
24088
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
23888
24089
|
},
|
|
23889
24090
|
{
|
|
23890
24091
|
id: "gpt-5.6-luna",
|
|
23891
|
-
label: "GPT-5.6 Luna
|
|
24092
|
+
label: "GPT-5.6 Luna",
|
|
23892
24093
|
pricing: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23893
24094
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23894
24095
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
@@ -23926,6 +24127,8 @@ var PROVIDER_DESCRIPTORS = {
|
|
|
23926
24127
|
kimi: kimiDescriptor,
|
|
23927
24128
|
kilo: kiloDescriptor,
|
|
23928
24129
|
grok: grokDescriptor,
|
|
24130
|
+
antigravity: antigravityDescriptor,
|
|
24131
|
+
muse: museDescriptor,
|
|
23929
24132
|
custom: customDescriptor
|
|
23930
24133
|
};
|
|
23931
24134
|
Object.setPrototypeOf(PROVIDER_DESCRIPTORS, null);
|
|
@@ -24356,6 +24559,38 @@ var anthropicBodyOrder = [
|
|
|
24356
24559
|
"stream"
|
|
24357
24560
|
];
|
|
24358
24561
|
|
|
24562
|
+
// packages/providers/src/antigravity/profile.ts
|
|
24563
|
+
var ANTIGRAVITY_IDE_VERSION = env("OMNI_ANTIGRAVITY_IDE_VERSION", "2.12.2");
|
|
24564
|
+
var PLATFORM = "darwin/arm64";
|
|
24565
|
+
var antigravityProfile = {
|
|
24566
|
+
headers: [
|
|
24567
|
+
[
|
|
24568
|
+
"User-Agent",
|
|
24569
|
+
env("OMNI_UA_ANTIGRAVITY", `antigravity/ide/${ANTIGRAVITY_IDE_VERSION} ${PLATFORM}`)
|
|
24570
|
+
],
|
|
24571
|
+
["Content-Type", "application/json"],
|
|
24572
|
+
["Accept", "text/event-stream"]
|
|
24573
|
+
],
|
|
24574
|
+
order: envOrder("OMNI_ORDER_ANTIGRAVITY", [
|
|
24575
|
+
"Host",
|
|
24576
|
+
"Content-Type",
|
|
24577
|
+
"Authorization",
|
|
24578
|
+
"User-Agent",
|
|
24579
|
+
"X-Goog-Api-Client",
|
|
24580
|
+
"Accept",
|
|
24581
|
+
"Accept-Encoding",
|
|
24582
|
+
"Content-Length"
|
|
24583
|
+
])
|
|
24584
|
+
};
|
|
24585
|
+
var antigravityBodyOrder = [
|
|
24586
|
+
"project",
|
|
24587
|
+
"requestId",
|
|
24588
|
+
"model",
|
|
24589
|
+
"userAgent",
|
|
24590
|
+
"requestType",
|
|
24591
|
+
"request"
|
|
24592
|
+
];
|
|
24593
|
+
|
|
24359
24594
|
// packages/providers/src/custom/profile.ts
|
|
24360
24595
|
var customProfile = { headers: [], order: [] };
|
|
24361
24596
|
var customBodyOrder = [];
|
|
@@ -24477,6 +24712,43 @@ var kimiBodyOrder = [
|
|
|
24477
24712
|
"stream"
|
|
24478
24713
|
];
|
|
24479
24714
|
|
|
24715
|
+
// packages/providers/src/muse/profile.ts
|
|
24716
|
+
var MUSE_CLI_VERSION = env("OMNI_MUSE_CLI_VERSION", "1.0.3");
|
|
24717
|
+
var museProfile = {
|
|
24718
|
+
headers: [
|
|
24719
|
+
["User-Agent", env("OMNI_UA_MUSE", `muse-code/${MUSE_CLI_VERSION}`)],
|
|
24720
|
+
["x-api-version", env("OMNI_MUSE_API_VERSION", "1.0.0")],
|
|
24721
|
+
["Accept", "text/event-stream"]
|
|
24722
|
+
],
|
|
24723
|
+
order: envOrder("OMNI_ORDER_MUSE", [
|
|
24724
|
+
"Host",
|
|
24725
|
+
"Content-Type",
|
|
24726
|
+
"Authorization",
|
|
24727
|
+
"x-meta-ai-gateway-session-id",
|
|
24728
|
+
"x-api-version",
|
|
24729
|
+
"Accept",
|
|
24730
|
+
"User-Agent",
|
|
24731
|
+
"Accept-Encoding",
|
|
24732
|
+
"Content-Length"
|
|
24733
|
+
])
|
|
24734
|
+
};
|
|
24735
|
+
var museBodyOrder = [
|
|
24736
|
+
"model",
|
|
24737
|
+
"stream",
|
|
24738
|
+
"input",
|
|
24739
|
+
"instructions",
|
|
24740
|
+
"store",
|
|
24741
|
+
"reasoning",
|
|
24742
|
+
"prompt_cache_key",
|
|
24743
|
+
"max_output_tokens",
|
|
24744
|
+
"temperature",
|
|
24745
|
+
"tools",
|
|
24746
|
+
"tool_choice",
|
|
24747
|
+
"include",
|
|
24748
|
+
"parallel_tool_calls",
|
|
24749
|
+
"metadata"
|
|
24750
|
+
];
|
|
24751
|
+
|
|
24480
24752
|
// packages/providers/src/openai/profile.ts
|
|
24481
24753
|
var OPENAI_CLI_VERSION = env("OMNI_OPENAI_CLI_VERSION", "0.144.1");
|
|
24482
24754
|
var OPENAI_UA_PLATFORM = env("OMNI_OPENAI_UA_PLATFORM", "Windows 10.0.26200");
|
|
@@ -24533,6 +24805,8 @@ var BODY_ORDER = {
|
|
|
24533
24805
|
kimi: kimiBodyOrder,
|
|
24534
24806
|
kilo: kiloBodyOrder,
|
|
24535
24807
|
grok: grokBodyOrder,
|
|
24808
|
+
antigravity: antigravityBodyOrder,
|
|
24809
|
+
muse: museBodyOrder,
|
|
24536
24810
|
custom: customBodyOrder
|
|
24537
24811
|
};
|
|
24538
24812
|
Object.setPrototypeOf(BODY_ORDER, null);
|
|
@@ -24626,6 +24900,8 @@ var PROVIDER_MODEL_CATALOG = {
|
|
|
24626
24900
|
kimi: KIMI_MODELS,
|
|
24627
24901
|
kilo: KILO_MODELS,
|
|
24628
24902
|
grok: GROK_MODELS,
|
|
24903
|
+
antigravity: ANTIGRAVITY_MODELS,
|
|
24904
|
+
muse: MUSE_MODELS,
|
|
24629
24905
|
custom: CUSTOM_MODELS
|
|
24630
24906
|
};
|
|
24631
24907
|
Object.setPrototypeOf(PROVIDER_MODEL_CATALOG, null);
|
|
@@ -24656,6 +24932,8 @@ var PROFILES = {
|
|
|
24656
24932
|
kimi: kimiProfile,
|
|
24657
24933
|
kilo: kiloProfile,
|
|
24658
24934
|
grok: grokProfile,
|
|
24935
|
+
antigravity: antigravityProfile,
|
|
24936
|
+
muse: museProfile,
|
|
24659
24937
|
custom: customProfile
|
|
24660
24938
|
};
|
|
24661
24939
|
Object.setPrototypeOf(PROFILES, null);
|
|
@@ -25924,6 +26202,751 @@ var anthropicOAuthFlow = {
|
|
|
25924
26202
|
return parseAnthropicUsage(parsed(res.body), now());
|
|
25925
26203
|
}
|
|
25926
26204
|
};
|
|
26205
|
+
// packages/providers/src/antigravity/codec.ts
|
|
26206
|
+
import { createHash as createHash2 } from "crypto";
|
|
26207
|
+
|
|
26208
|
+
// packages/providers/src/antigravity/decode.ts
|
|
26209
|
+
var STOP_REASON2 = {
|
|
26210
|
+
STOP: "endTurn",
|
|
26211
|
+
MAX_TOKENS: "maxTokens",
|
|
26212
|
+
SAFETY: "contentFilter",
|
|
26213
|
+
PROHIBITED_CONTENT: "contentFilter",
|
|
26214
|
+
SPII: "contentFilter",
|
|
26215
|
+
BLOCKLIST: "contentFilter",
|
|
26216
|
+
RECITATION: "contentFilter"
|
|
26217
|
+
};
|
|
26218
|
+
var ERROR_CODE = {
|
|
26219
|
+
RESOURCE_EXHAUSTED: "RATE_LIMIT",
|
|
26220
|
+
UNAUTHENTICATED: "AUTH",
|
|
26221
|
+
PERMISSION_DENIED: "AUTH",
|
|
26222
|
+
INVALID_ARGUMENT: "BAD_REQUEST",
|
|
26223
|
+
FAILED_PRECONDITION: "BAD_REQUEST",
|
|
26224
|
+
UNAVAILABLE: "UPSTREAM",
|
|
26225
|
+
INTERNAL: "UPSTREAM",
|
|
26226
|
+
DEADLINE_EXCEEDED: "TIMEOUT"
|
|
26227
|
+
};
|
|
26228
|
+
function json3(data) {
|
|
26229
|
+
try {
|
|
26230
|
+
const value = JSON.parse(data);
|
|
26231
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
26232
|
+
} catch {
|
|
26233
|
+
return null;
|
|
26234
|
+
}
|
|
26235
|
+
}
|
|
26236
|
+
function count(value) {
|
|
26237
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
26238
|
+
}
|
|
26239
|
+
function usageOf(meta3) {
|
|
26240
|
+
return usageFromPromptTotal(count(meta3?.promptTokenCount), count(meta3?.candidatesTokenCount) + count(meta3?.thoughtsTokenCount), count(meta3?.cachedContentTokenCount));
|
|
26241
|
+
}
|
|
26242
|
+
async function* decodeAntigravityStream(messages) {
|
|
26243
|
+
let started = false;
|
|
26244
|
+
let terminal = false;
|
|
26245
|
+
let nextIndex = 0;
|
|
26246
|
+
let toolCalls = 0;
|
|
26247
|
+
let open2 = null;
|
|
26248
|
+
const closeOpen = function* () {
|
|
26249
|
+
if (open2 === null)
|
|
26250
|
+
return;
|
|
26251
|
+
yield { type: "blockEnd", index: open2.index };
|
|
26252
|
+
open2 = null;
|
|
26253
|
+
};
|
|
26254
|
+
for await (const message of messages) {
|
|
26255
|
+
if (message.data === "[DONE]")
|
|
26256
|
+
continue;
|
|
26257
|
+
const frame = json3(message.data);
|
|
26258
|
+
if (frame === null)
|
|
26259
|
+
continue;
|
|
26260
|
+
const failure = frame.error ?? frame.response?.error;
|
|
26261
|
+
if (failure !== undefined) {
|
|
26262
|
+
terminal = true;
|
|
26263
|
+
yield* closeOpen();
|
|
26264
|
+
const status = String(failure.status ?? "");
|
|
26265
|
+
const code = (Object.hasOwn(ERROR_CODE, status) ? ERROR_CODE[status] : undefined) ?? "UPSTREAM";
|
|
26266
|
+
yield {
|
|
26267
|
+
type: "error",
|
|
26268
|
+
code,
|
|
26269
|
+
message: String(failure.message ?? "upstream error"),
|
|
26270
|
+
retryable: RETRYABLE[code]
|
|
26271
|
+
};
|
|
26272
|
+
return;
|
|
26273
|
+
}
|
|
26274
|
+
const response = frame.response;
|
|
26275
|
+
if (response === undefined)
|
|
26276
|
+
continue;
|
|
26277
|
+
const blocked = response.promptFeedback?.blockReason;
|
|
26278
|
+
if (blocked !== undefined && (response.candidates ?? []).length === 0) {
|
|
26279
|
+
terminal = true;
|
|
26280
|
+
if (!started)
|
|
26281
|
+
yield { type: "start", id: "", model: "" };
|
|
26282
|
+
yield* closeOpen();
|
|
26283
|
+
yield { type: "end", stopReason: "contentFilter", usage: usageOf(response.usageMetadata) };
|
|
26284
|
+
return;
|
|
26285
|
+
}
|
|
26286
|
+
if (!started) {
|
|
26287
|
+
started = true;
|
|
26288
|
+
yield {
|
|
26289
|
+
type: "start",
|
|
26290
|
+
id: String(response.responseId ?? ""),
|
|
26291
|
+
model: String(response.modelVersion ?? "")
|
|
26292
|
+
};
|
|
26293
|
+
}
|
|
26294
|
+
const candidates = response.candidates ?? [];
|
|
26295
|
+
if (candidates.length > 1) {
|
|
26296
|
+
terminal = true;
|
|
26297
|
+
yield* closeOpen();
|
|
26298
|
+
yield {
|
|
26299
|
+
type: "error",
|
|
26300
|
+
code: "UPSTREAM",
|
|
26301
|
+
message: `Antigravity returned ${candidates.length} candidates, which cannot be represented`,
|
|
26302
|
+
retryable: false
|
|
26303
|
+
};
|
|
26304
|
+
return;
|
|
26305
|
+
}
|
|
26306
|
+
const candidate = candidates[0];
|
|
26307
|
+
for (const part of candidate?.content?.parts ?? []) {
|
|
26308
|
+
const call = part.functionCall;
|
|
26309
|
+
if (call !== undefined && typeof call.name === "string") {
|
|
26310
|
+
yield* closeOpen();
|
|
26311
|
+
const index = nextIndex++;
|
|
26312
|
+
yield {
|
|
26313
|
+
type: "blockStart",
|
|
26314
|
+
index,
|
|
26315
|
+
block: {
|
|
26316
|
+
type: "toolUse",
|
|
26317
|
+
id: typeof call.id === "string" && call.id.length > 0 ? call.id : `fc_${toolCalls}`,
|
|
26318
|
+
name: call.name
|
|
26319
|
+
}
|
|
26320
|
+
};
|
|
26321
|
+
yield {
|
|
26322
|
+
type: "blockDelta",
|
|
26323
|
+
index,
|
|
26324
|
+
delta: { type: "toolJson", partial: JSON.stringify(call.args ?? {}) }
|
|
26325
|
+
};
|
|
26326
|
+
yield { type: "blockEnd", index };
|
|
26327
|
+
toolCalls++;
|
|
26328
|
+
continue;
|
|
26329
|
+
}
|
|
26330
|
+
if (typeof part.text !== "string")
|
|
26331
|
+
continue;
|
|
26332
|
+
const kind = part.thought === true ? "thinking" : "text";
|
|
26333
|
+
if (open2 === null || open2.kind !== kind) {
|
|
26334
|
+
yield* closeOpen();
|
|
26335
|
+
open2 = { kind, index: nextIndex++ };
|
|
26336
|
+
yield { type: "blockStart", index: open2.index, block: { type: kind } };
|
|
26337
|
+
}
|
|
26338
|
+
yield {
|
|
26339
|
+
type: "blockDelta",
|
|
26340
|
+
index: open2.index,
|
|
26341
|
+
delta: kind === "thinking" ? { type: "thinking", text: part.text } : { type: "text", text: part.text }
|
|
26342
|
+
};
|
|
26343
|
+
}
|
|
26344
|
+
const finish = candidate?.finishReason;
|
|
26345
|
+
if (finish === undefined || finish === null)
|
|
26346
|
+
continue;
|
|
26347
|
+
terminal = true;
|
|
26348
|
+
yield* closeOpen();
|
|
26349
|
+
const raw = String(finish);
|
|
26350
|
+
if (raw === "MALFORMED_FUNCTION_CALL") {
|
|
26351
|
+
yield {
|
|
26352
|
+
type: "error",
|
|
26353
|
+
code: "BAD_REQUEST",
|
|
26354
|
+
message: "the model emitted a malformed function call",
|
|
26355
|
+
retryable: false
|
|
26356
|
+
};
|
|
26357
|
+
return;
|
|
26358
|
+
}
|
|
26359
|
+
const mapped = Object.hasOwn(STOP_REASON2, raw) ? STOP_REASON2[raw] : undefined;
|
|
26360
|
+
if (mapped === undefined) {
|
|
26361
|
+
yield {
|
|
26362
|
+
type: "error",
|
|
26363
|
+
code: "UPSTREAM",
|
|
26364
|
+
message: `unrecognized Antigravity finish reason "${raw}"`,
|
|
26365
|
+
retryable: false
|
|
26366
|
+
};
|
|
26367
|
+
return;
|
|
26368
|
+
}
|
|
26369
|
+
yield {
|
|
26370
|
+
type: "end",
|
|
26371
|
+
stopReason: toolCalls > 0 ? "toolUse" : mapped,
|
|
26372
|
+
usage: usageOf(response.usageMetadata)
|
|
26373
|
+
};
|
|
26374
|
+
return;
|
|
26375
|
+
}
|
|
26376
|
+
if (!terminal) {
|
|
26377
|
+
yield* closeOpen();
|
|
26378
|
+
yield {
|
|
26379
|
+
type: "error",
|
|
26380
|
+
code: "UPSTREAM",
|
|
26381
|
+
message: "upstream stream ended before the response finished",
|
|
26382
|
+
retryable: RETRYABLE.UPSTREAM
|
|
26383
|
+
};
|
|
26384
|
+
}
|
|
26385
|
+
}
|
|
26386
|
+
|
|
26387
|
+
// packages/providers/src/antigravity/wire.ts
|
|
26388
|
+
var SIGNATURE_BYPASS = "skip_thought_signature_validator";
|
|
26389
|
+
function toolNamesById(req) {
|
|
26390
|
+
const names = new Map;
|
|
26391
|
+
for (const message of req.messages) {
|
|
26392
|
+
for (const block of message.content) {
|
|
26393
|
+
if (block.type === "toolUse")
|
|
26394
|
+
names.set(block.id, block.name);
|
|
26395
|
+
}
|
|
26396
|
+
}
|
|
26397
|
+
return names;
|
|
26398
|
+
}
|
|
26399
|
+
function mergeSameRole(contents) {
|
|
26400
|
+
const merged = [];
|
|
26401
|
+
for (const entry of contents) {
|
|
26402
|
+
const last = merged[merged.length - 1];
|
|
26403
|
+
if (last !== undefined && last.role === entry.role)
|
|
26404
|
+
last.parts.push(...entry.parts);
|
|
26405
|
+
else
|
|
26406
|
+
merged.push({ role: entry.role, parts: [...entry.parts] });
|
|
26407
|
+
}
|
|
26408
|
+
return merged;
|
|
26409
|
+
}
|
|
26410
|
+
var hasCacheControl = (block) => ("cacheControl" in block) && block.cacheControl !== undefined;
|
|
26411
|
+
function encodeToolChoice2(choice) {
|
|
26412
|
+
switch (choice.type) {
|
|
26413
|
+
case "auto":
|
|
26414
|
+
return { functionCallingConfig: { mode: "AUTO" } };
|
|
26415
|
+
case "any":
|
|
26416
|
+
return { functionCallingConfig: { mode: "ANY" } };
|
|
26417
|
+
case "none":
|
|
26418
|
+
return { functionCallingConfig: { mode: "NONE" } };
|
|
26419
|
+
case "tool":
|
|
26420
|
+
return { functionCallingConfig: { mode: "ANY", allowedFunctionNames: [choice.name] } };
|
|
26421
|
+
}
|
|
26422
|
+
}
|
|
26423
|
+
function toAntigravityWire(req, model, identity) {
|
|
26424
|
+
const degradations = [];
|
|
26425
|
+
const note2 = (d) => {
|
|
26426
|
+
if (!degradations.includes(d))
|
|
26427
|
+
degradations.push(d);
|
|
26428
|
+
};
|
|
26429
|
+
const names = toolNamesById(req);
|
|
26430
|
+
const contents = [];
|
|
26431
|
+
for (const message of req.messages) {
|
|
26432
|
+
const parts = [];
|
|
26433
|
+
if (message.role === "system")
|
|
26434
|
+
note2("antigravity:system-turn-as-user");
|
|
26435
|
+
let role = message.role === "assistant" ? "model" : "user";
|
|
26436
|
+
for (const block of message.content) {
|
|
26437
|
+
if (hasCacheControl(block))
|
|
26438
|
+
note2("antigravity:cache-control-dropped");
|
|
26439
|
+
switch (block.type) {
|
|
26440
|
+
case "text":
|
|
26441
|
+
parts.push({ text: block.text });
|
|
26442
|
+
break;
|
|
26443
|
+
case "image":
|
|
26444
|
+
parts.push({ inlineData: { mimeType: block.mediaType, data: block.data } });
|
|
26445
|
+
break;
|
|
26446
|
+
case "thinking":
|
|
26447
|
+
note2("antigravity:thinking-dropped");
|
|
26448
|
+
break;
|
|
26449
|
+
case "toolUse":
|
|
26450
|
+
parts.push({
|
|
26451
|
+
thoughtSignature: SIGNATURE_BYPASS,
|
|
26452
|
+
functionCall: { name: block.name, args: block.input }
|
|
26453
|
+
});
|
|
26454
|
+
break;
|
|
26455
|
+
case "toolResult": {
|
|
26456
|
+
const name = names.get(block.toolUseId);
|
|
26457
|
+
if (name === undefined)
|
|
26458
|
+
note2("antigravity:tool-result-unmatched");
|
|
26459
|
+
if (block.isError === true)
|
|
26460
|
+
note2("antigravity:tool-result-error-flag-dropped");
|
|
26461
|
+
parts.push({
|
|
26462
|
+
functionResponse: {
|
|
26463
|
+
name: name ?? block.toolUseId,
|
|
26464
|
+
response: { output: block.content }
|
|
26465
|
+
}
|
|
26466
|
+
});
|
|
26467
|
+
role = "user";
|
|
26468
|
+
break;
|
|
26469
|
+
}
|
|
26470
|
+
case "providerNative":
|
|
26471
|
+
note2("antigravity:provider-native-block-dropped");
|
|
26472
|
+
break;
|
|
26473
|
+
}
|
|
26474
|
+
}
|
|
26475
|
+
if (parts.length > 0)
|
|
26476
|
+
contents.push({ role, parts });
|
|
26477
|
+
}
|
|
26478
|
+
const request2 = { contents: mergeSameRole(contents) };
|
|
26479
|
+
const system = systemText(req.system, "antigravity", note2);
|
|
26480
|
+
if (system !== undefined && system.length > 0) {
|
|
26481
|
+
request2.systemInstruction = { parts: [{ text: system }] };
|
|
26482
|
+
}
|
|
26483
|
+
const generationConfig = {};
|
|
26484
|
+
if (req.maxTokens !== undefined)
|
|
26485
|
+
generationConfig.maxOutputTokens = req.maxTokens;
|
|
26486
|
+
if (req.temperature !== undefined)
|
|
26487
|
+
generationConfig.temperature = req.temperature;
|
|
26488
|
+
if (req.stopSequences !== undefined)
|
|
26489
|
+
generationConfig.stopSequences = req.stopSequences;
|
|
26490
|
+
if (req.reasoning !== undefined) {
|
|
26491
|
+
switch (req.reasoning.mode) {
|
|
26492
|
+
case "off":
|
|
26493
|
+
generationConfig.thinkingConfig = { thinkingBudget: 0, includeThoughts: false };
|
|
26494
|
+
break;
|
|
26495
|
+
case "budget":
|
|
26496
|
+
generationConfig.thinkingConfig = {
|
|
26497
|
+
thinkingBudget: req.reasoning.budgetTokens,
|
|
26498
|
+
includeThoughts: req.reasoning.budgetTokens !== 0
|
|
26499
|
+
};
|
|
26500
|
+
break;
|
|
26501
|
+
case "adaptive":
|
|
26502
|
+
generationConfig.thinkingConfig = {
|
|
26503
|
+
includeThoughts: req.reasoning.display !== "omitted"
|
|
26504
|
+
};
|
|
26505
|
+
if (req.reasoning.effort !== undefined)
|
|
26506
|
+
note2("antigravity:reasoning-effort-dropped");
|
|
26507
|
+
break;
|
|
26508
|
+
}
|
|
26509
|
+
}
|
|
26510
|
+
const max = generationConfig.maxOutputTokens;
|
|
26511
|
+
if (max !== undefined && max > MAX_OUTPUT_TOKENS) {
|
|
26512
|
+
generationConfig.maxOutputTokens = MAX_OUTPUT_TOKENS;
|
|
26513
|
+
note2("antigravity:max-tokens-clamped");
|
|
26514
|
+
}
|
|
26515
|
+
const budget = generationConfig.thinkingConfig?.thinkingBudget;
|
|
26516
|
+
if (budget !== undefined && budget > 0) {
|
|
26517
|
+
const ceiling = generationConfig.maxOutputTokens;
|
|
26518
|
+
if (ceiling === undefined || ceiling <= budget) {
|
|
26519
|
+
generationConfig.maxOutputTokens = Math.min(budget + 1, MAX_OUTPUT_TOKENS);
|
|
26520
|
+
}
|
|
26521
|
+
}
|
|
26522
|
+
if (Object.keys(generationConfig).length > 0)
|
|
26523
|
+
request2.generationConfig = generationConfig;
|
|
26524
|
+
if (req.tools !== undefined) {
|
|
26525
|
+
const portable = req.tools.filter((t) => t.kind === "portable");
|
|
26526
|
+
if (portable.length !== req.tools.length)
|
|
26527
|
+
note2("antigravity:provider-tool-dropped");
|
|
26528
|
+
if (portable.length > 0) {
|
|
26529
|
+
request2.tools = [
|
|
26530
|
+
{
|
|
26531
|
+
functionDeclarations: portable.map((t) => ({
|
|
26532
|
+
name: t.name,
|
|
26533
|
+
description: t.description,
|
|
26534
|
+
parameters: t.inputSchema
|
|
26535
|
+
}))
|
|
26536
|
+
}
|
|
26537
|
+
];
|
|
26538
|
+
}
|
|
26539
|
+
}
|
|
26540
|
+
if (req.toolChoice !== undefined)
|
|
26541
|
+
request2.toolConfig = encodeToolChoice2(req.toolChoice);
|
|
26542
|
+
Object.assign(request2, req.vendor?.antigravity ?? {});
|
|
26543
|
+
return {
|
|
26544
|
+
body: {
|
|
26545
|
+
project: identity.project,
|
|
26546
|
+
requestId: identity.requestId,
|
|
26547
|
+
model,
|
|
26548
|
+
userAgent: "antigravity",
|
|
26549
|
+
requestType: "agent",
|
|
26550
|
+
request: request2
|
|
26551
|
+
},
|
|
26552
|
+
degradations
|
|
26553
|
+
};
|
|
26554
|
+
}
|
|
26555
|
+
|
|
26556
|
+
// packages/providers/src/antigravity/codec.ts
|
|
26557
|
+
var URL2 = "https://daily-cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse";
|
|
26558
|
+
var REQUEST_NAMESPACE = "omni-antigravity-req";
|
|
26559
|
+
function derivedRequestId(seed) {
|
|
26560
|
+
const h = createHash2("sha256").update(`${REQUEST_NAMESPACE}:${seed}`).digest("hex");
|
|
26561
|
+
const variant = (Number.parseInt(h[16], 16) & 3 | 8).toString(16);
|
|
26562
|
+
return [
|
|
26563
|
+
h.slice(0, 8),
|
|
26564
|
+
h.slice(8, 12),
|
|
26565
|
+
`4${h.slice(13, 16)}`,
|
|
26566
|
+
`${variant}${h.slice(17, 20)}`,
|
|
26567
|
+
h.slice(20, 32)
|
|
26568
|
+
].join("-");
|
|
26569
|
+
}
|
|
26570
|
+
function projectOf(input2) {
|
|
26571
|
+
const stored = input2.credentials.providerData.projectId;
|
|
26572
|
+
const project = typeof stored === "string" ? stored.trim() : "";
|
|
26573
|
+
if (project.length === 0) {
|
|
26574
|
+
throw input2.fail("AUTH", "antigravity credential has no Cloud Code project; reconnect the account");
|
|
26575
|
+
}
|
|
26576
|
+
return project;
|
|
26577
|
+
}
|
|
26578
|
+
var antigravityCodec = {
|
|
26579
|
+
buildRequest(input2) {
|
|
26580
|
+
const accessToken = input2.credentials.accessToken;
|
|
26581
|
+
if (accessToken === null || accessToken.length === 0) {
|
|
26582
|
+
throw input2.fail("AUTH", "antigravity credential has no access token");
|
|
26583
|
+
}
|
|
26584
|
+
const project = projectOf(input2);
|
|
26585
|
+
const requestId = input2.requestId !== undefined && input2.requestId.length > 0 ? input2.requestId : derivedRequestId(`${input2.model}:${project}`);
|
|
26586
|
+
const { body, degradations } = toAntigravityWire(input2.request, input2.model, {
|
|
26587
|
+
project,
|
|
26588
|
+
requestId
|
|
26589
|
+
});
|
|
26590
|
+
const protocol = [["Authorization", `Bearer ${accessToken}`]];
|
|
26591
|
+
const headers = orderHeaders(mergeHeaders(antigravityProfile.headers, protocol), antigravityProfile.order);
|
|
26592
|
+
return {
|
|
26593
|
+
request: {
|
|
26594
|
+
url: URL2,
|
|
26595
|
+
method: "POST",
|
|
26596
|
+
headers,
|
|
26597
|
+
body: JSON.stringify(body)
|
|
26598
|
+
},
|
|
26599
|
+
degradations
|
|
26600
|
+
};
|
|
26601
|
+
},
|
|
26602
|
+
decode({ body }) {
|
|
26603
|
+
return decodeAntigravityStream(parseSse(body));
|
|
26604
|
+
}
|
|
26605
|
+
};
|
|
26606
|
+
|
|
26607
|
+
// packages/providers/src/antigravity/index.ts
|
|
26608
|
+
var antigravityAdapter = codecAdapter("antigravity", antigravityDescriptor.capabilities, antigravityCodec);
|
|
26609
|
+
// packages/providers/src/antigravity/oauth.ts
|
|
26610
|
+
var MASK = "omnigateway-public-v1";
|
|
26611
|
+
function unmask(bytes) {
|
|
26612
|
+
let out = "";
|
|
26613
|
+
for (let i = 0;i < bytes.length; i++) {
|
|
26614
|
+
out += String.fromCharCode(bytes[i] ^ MASK.charCodeAt(i % MASK.length));
|
|
26615
|
+
}
|
|
26616
|
+
return out;
|
|
26617
|
+
}
|
|
26618
|
+
var ANTIGRAVITY_CLIENT_ID = unmask([
|
|
26619
|
+
94,
|
|
26620
|
+
93,
|
|
26621
|
+
89,
|
|
26622
|
+
88,
|
|
26623
|
+
87,
|
|
26624
|
+
81,
|
|
26625
|
+
66,
|
|
26626
|
+
85,
|
|
26627
|
+
65,
|
|
26628
|
+
81,
|
|
26629
|
+
76,
|
|
26630
|
+
20,
|
|
26631
|
+
65,
|
|
26632
|
+
88,
|
|
26633
|
+
22,
|
|
26634
|
+
1,
|
|
26635
|
+
1,
|
|
26636
|
+
16,
|
|
26637
|
+
94,
|
|
26638
|
+
31,
|
|
26639
|
+
95,
|
|
26640
|
+
93,
|
|
26641
|
+
5,
|
|
26642
|
+
92,
|
|
26643
|
+
88,
|
|
26644
|
+
11,
|
|
26645
|
+
2,
|
|
26646
|
+
6,
|
|
26647
|
+
0,
|
|
26648
|
+
69,
|
|
26649
|
+
82,
|
|
26650
|
+
76,
|
|
26651
|
+
91,
|
|
26652
|
+
4,
|
|
26653
|
+
26,
|
|
26654
|
+
14,
|
|
26655
|
+
3,
|
|
26656
|
+
3,
|
|
26657
|
+
11,
|
|
26658
|
+
25,
|
|
26659
|
+
17,
|
|
26660
|
+
5,
|
|
26661
|
+
95,
|
|
26662
|
+
94,
|
|
26663
|
+
11,
|
|
26664
|
+
25,
|
|
26665
|
+
73,
|
|
26666
|
+
0,
|
|
26667
|
+
4,
|
|
26668
|
+
21,
|
|
26669
|
+
4,
|
|
26670
|
+
79,
|
|
26671
|
+
30,
|
|
26672
|
+
66,
|
|
26673
|
+
31,
|
|
26674
|
+
18,
|
|
26675
|
+
14,
|
|
26676
|
+
9,
|
|
26677
|
+
28,
|
|
26678
|
+
16,
|
|
26679
|
+
72,
|
|
26680
|
+
4,
|
|
26681
|
+
82,
|
|
26682
|
+
0,
|
|
26683
|
+
3,
|
|
26684
|
+
26,
|
|
26685
|
+
12,
|
|
26686
|
+
9,
|
|
26687
|
+
21,
|
|
26688
|
+
90,
|
|
26689
|
+
6,
|
|
26690
|
+
24,
|
|
26691
|
+
12
|
|
26692
|
+
]);
|
|
26693
|
+
var CLIENT_ID2 = ANTIGRAVITY_CLIENT_ID;
|
|
26694
|
+
var CLIENT_SECRET = unmask([
|
|
26695
|
+
40,
|
|
26696
|
+
34,
|
|
26697
|
+
45,
|
|
26698
|
+
58,
|
|
26699
|
+
55,
|
|
26700
|
+
57,
|
|
26701
|
+
89,
|
|
26702
|
+
46,
|
|
26703
|
+
66,
|
|
26704
|
+
89,
|
|
26705
|
+
63,
|
|
26706
|
+
122,
|
|
26707
|
+
34,
|
|
26708
|
+
65,
|
|
26709
|
+
90,
|
|
26710
|
+
90,
|
|
26711
|
+
37,
|
|
26712
|
+
7,
|
|
26713
|
+
97,
|
|
26714
|
+
60,
|
|
26715
|
+
0,
|
|
26716
|
+
2,
|
|
26717
|
+
33,
|
|
26718
|
+
44,
|
|
26719
|
+
81,
|
|
26720
|
+
20,
|
|
26721
|
+
57,
|
|
26722
|
+
55,
|
|
26723
|
+
81,
|
|
26724
|
+
13,
|
|
26725
|
+
87,
|
|
26726
|
+
8,
|
|
26727
|
+
105,
|
|
26728
|
+
49,
|
|
26729
|
+
19
|
|
26730
|
+
]);
|
|
26731
|
+
var AUTHORIZE_URL2 = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
26732
|
+
var TOKEN_URL2 = "https://oauth2.googleapis.com/token";
|
|
26733
|
+
var USERINFO_URL = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json";
|
|
26734
|
+
var CODE_ASSIST = "https://cloudcode-pa.googleapis.com/v1internal";
|
|
26735
|
+
var LOAD_CODE_ASSIST_URL = `${CODE_ASSIST}:loadCodeAssist`;
|
|
26736
|
+
var ONBOARD_USER_URL = `${CODE_ASSIST}:onboardUser`;
|
|
26737
|
+
var QUOTA_SUMMARY_URL = `${CODE_ASSIST}:retrieveUserQuotaSummary`;
|
|
26738
|
+
var SCOPES2 = [
|
|
26739
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
|
26740
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
26741
|
+
"https://www.googleapis.com/auth/userinfo.profile",
|
|
26742
|
+
"https://www.googleapis.com/auth/cclog",
|
|
26743
|
+
"https://www.googleapis.com/auth/experimentsandconfigs"
|
|
26744
|
+
].join(" ");
|
|
26745
|
+
var IDE_METADATA = { ideType: "ANTIGRAVITY" };
|
|
26746
|
+
var DEFAULT_TIER = "legacy-tier";
|
|
26747
|
+
function parseTokenResponse(value) {
|
|
26748
|
+
const record2 = recordOf(value);
|
|
26749
|
+
if (record2 === null || typeof record2.access_token !== "string")
|
|
26750
|
+
return null;
|
|
26751
|
+
return {
|
|
26752
|
+
accessToken: record2.access_token,
|
|
26753
|
+
refreshToken: typeof record2.refresh_token === "string" ? record2.refresh_token : null,
|
|
26754
|
+
expiresIn: typeof record2.expires_in === "number" ? record2.expires_in : null
|
|
26755
|
+
};
|
|
26756
|
+
}
|
|
26757
|
+
async function* postToken2(body, fail) {
|
|
26758
|
+
const res = yield postJsonRequest(TOKEN_URL2, antigravityProfile, {
|
|
26759
|
+
contentType: "application/x-www-form-urlencoded",
|
|
26760
|
+
body: new URLSearchParams(body).toString()
|
|
26761
|
+
});
|
|
26762
|
+
const parsed2 = parsed(res.body);
|
|
26763
|
+
if (res.status < 200 || res.status >= 300) {
|
|
26764
|
+
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
26765
|
+
}
|
|
26766
|
+
const token = parseTokenResponse(parsed2);
|
|
26767
|
+
if (token === null)
|
|
26768
|
+
throw fail("AUTH", "token endpoint returned no access_token");
|
|
26769
|
+
return token;
|
|
26770
|
+
}
|
|
26771
|
+
function projectFrom(value) {
|
|
26772
|
+
const record2 = recordOf(value);
|
|
26773
|
+
if (record2 === null)
|
|
26774
|
+
return "";
|
|
26775
|
+
const project = record2.cloudaicompanionProject;
|
|
26776
|
+
if (typeof project === "string")
|
|
26777
|
+
return project.trim();
|
|
26778
|
+
const nested = recordOf(project);
|
|
26779
|
+
const id = nested?.id;
|
|
26780
|
+
return typeof id === "string" ? id.trim() : "";
|
|
26781
|
+
}
|
|
26782
|
+
function tierFrom(value) {
|
|
26783
|
+
const record2 = recordOf(value);
|
|
26784
|
+
const tiers = record2?.allowedTiers;
|
|
26785
|
+
if (Array.isArray(tiers)) {
|
|
26786
|
+
for (const entry of tiers) {
|
|
26787
|
+
const tier = recordOf(entry);
|
|
26788
|
+
if (tier?.isDefault === true && typeof tier.id === "string")
|
|
26789
|
+
return tier.id;
|
|
26790
|
+
}
|
|
26791
|
+
}
|
|
26792
|
+
const current = recordOf(record2?.currentTier);
|
|
26793
|
+
return typeof current?.id === "string" ? current.id : DEFAULT_TIER;
|
|
26794
|
+
}
|
|
26795
|
+
function codeAssistRequest(url2, accessToken, body) {
|
|
26796
|
+
return postJsonRequest(url2, antigravityProfile, {
|
|
26797
|
+
contentType: "application/json",
|
|
26798
|
+
body: JSON.stringify(body),
|
|
26799
|
+
extraHeaders: [["Authorization", `Bearer ${accessToken}`]]
|
|
26800
|
+
});
|
|
26801
|
+
}
|
|
26802
|
+
async function* bootstrapProject(accessToken) {
|
|
26803
|
+
const loaded = yield codeAssistRequest(LOAD_CODE_ASSIST_URL, accessToken, {
|
|
26804
|
+
metadata: IDE_METADATA
|
|
26805
|
+
});
|
|
26806
|
+
const body = loaded.status >= 200 && loaded.status < 300 ? parsed(loaded.body) : null;
|
|
26807
|
+
const tier = tierFrom(body);
|
|
26808
|
+
const existing = projectFrom(body);
|
|
26809
|
+
if (existing.length > 0)
|
|
26810
|
+
return { projectId: existing, tier };
|
|
26811
|
+
const onboarded = yield codeAssistRequest(ONBOARD_USER_URL, accessToken, {
|
|
26812
|
+
tier_id: tier,
|
|
26813
|
+
metadata: IDE_METADATA
|
|
26814
|
+
});
|
|
26815
|
+
if (onboarded.status < 200 || onboarded.status >= 300)
|
|
26816
|
+
return { projectId: "", tier };
|
|
26817
|
+
const operation = recordOf(parsed(onboarded.body));
|
|
26818
|
+
return { projectId: projectFrom(operation?.response), tier };
|
|
26819
|
+
}
|
|
26820
|
+
async function* readEmail(accessToken) {
|
|
26821
|
+
const res = yield getJsonRequest(USERINFO_URL, antigravityProfile, { accessToken });
|
|
26822
|
+
if (res.status < 200 || res.status >= 300)
|
|
26823
|
+
return null;
|
|
26824
|
+
const record2 = recordOf(parsed(res.body));
|
|
26825
|
+
const email3 = record2?.email;
|
|
26826
|
+
return typeof email3 === "string" && email3.trim().length > 0 ? email3 : null;
|
|
26827
|
+
}
|
|
26828
|
+
function toResult2(token, fallbackRefresh, accountEmail, providerData, now) {
|
|
26829
|
+
return {
|
|
26830
|
+
secrets: {
|
|
26831
|
+
accessToken: token.accessToken,
|
|
26832
|
+
refreshToken: token.refreshToken ?? fallbackRefresh,
|
|
26833
|
+
apiKey: null,
|
|
26834
|
+
idToken: null
|
|
26835
|
+
},
|
|
26836
|
+
expiresAt: token.expiresIn === null ? null : now() + token.expiresIn * 1000,
|
|
26837
|
+
accountEmail,
|
|
26838
|
+
providerData
|
|
26839
|
+
};
|
|
26840
|
+
}
|
|
26841
|
+
var GEMINI_GROUP = /\bgemini\b/;
|
|
26842
|
+
function windowOf(bucket) {
|
|
26843
|
+
const text = `${String(bucket.bucketId ?? "")} ${String(bucket.displayName ?? "")}`.toLowerCase();
|
|
26844
|
+
if (/\bweekly\b|\bweek\b/.test(text))
|
|
26845
|
+
return "weekly";
|
|
26846
|
+
if (/\b5\s*-?\s*hour|\b5h\b|\bfive\s*hour/.test(text))
|
|
26847
|
+
return "fiveHour";
|
|
26848
|
+
return null;
|
|
26849
|
+
}
|
|
26850
|
+
function groupsOf(value) {
|
|
26851
|
+
const root = recordOf(value);
|
|
26852
|
+
if (root === null)
|
|
26853
|
+
return [];
|
|
26854
|
+
if (Array.isArray(root.groups))
|
|
26855
|
+
return root.groups;
|
|
26856
|
+
const nested = recordOf(root.quotaSummary)?.groups;
|
|
26857
|
+
return Array.isArray(nested) ? nested : [];
|
|
26858
|
+
}
|
|
26859
|
+
function parseAntigravityQuota(value, now) {
|
|
26860
|
+
const windows = [];
|
|
26861
|
+
for (const groupValue of groupsOf(value)) {
|
|
26862
|
+
const group = recordOf(groupValue);
|
|
26863
|
+
if (group === null)
|
|
26864
|
+
continue;
|
|
26865
|
+
if (!GEMINI_GROUP.test(String(group.displayName ?? "").toLowerCase()))
|
|
26866
|
+
continue;
|
|
26867
|
+
const buckets = Array.isArray(group.buckets) ? group.buckets : [];
|
|
26868
|
+
for (const bucketValue of buckets) {
|
|
26869
|
+
const bucket = recordOf(bucketValue);
|
|
26870
|
+
if (bucket === null || bucket.disabled === true)
|
|
26871
|
+
continue;
|
|
26872
|
+
const windowType = windowOf(bucket);
|
|
26873
|
+
if (windowType === null)
|
|
26874
|
+
continue;
|
|
26875
|
+
const fraction = numberOf(bucket, ["remainingFraction"]);
|
|
26876
|
+
if (fraction === null)
|
|
26877
|
+
continue;
|
|
26878
|
+
const remaining = Math.max(0, Math.min(1, fraction));
|
|
26879
|
+
windows.push({
|
|
26880
|
+
windowType,
|
|
26881
|
+
used: Math.round((1 - remaining) * 100),
|
|
26882
|
+
limit: 100,
|
|
26883
|
+
resetsAt: resetAtOf(bucket, { absolute: ["resetTime"] }, now),
|
|
26884
|
+
windowMs: null
|
|
26885
|
+
});
|
|
26886
|
+
}
|
|
26887
|
+
}
|
|
26888
|
+
return reportFrom(windows);
|
|
26889
|
+
}
|
|
26890
|
+
var antigravityOAuthFlow = {
|
|
26891
|
+
kind: "pkce",
|
|
26892
|
+
supportsManualPaste: true,
|
|
26893
|
+
async* start({ redirectUri, randomState }) {
|
|
26894
|
+
const state = randomState();
|
|
26895
|
+
const url2 = new URL(AUTHORIZE_URL2);
|
|
26896
|
+
url2.searchParams.set("client_id", CLIENT_ID2);
|
|
26897
|
+
url2.searchParams.set("response_type", "code");
|
|
26898
|
+
url2.searchParams.set("redirect_uri", redirectUri);
|
|
26899
|
+
url2.searchParams.set("scope", SCOPES2);
|
|
26900
|
+
url2.searchParams.set("state", state);
|
|
26901
|
+
url2.searchParams.set("access_type", "offline");
|
|
26902
|
+
url2.searchParams.set("prompt", "consent");
|
|
26903
|
+
return {
|
|
26904
|
+
authorizeUrl: url2.toString(),
|
|
26905
|
+
pending: { verifier: "", challenge: "", state, redirectUri }
|
|
26906
|
+
};
|
|
26907
|
+
},
|
|
26908
|
+
async* exchange({ code, pending, fail, now }) {
|
|
26909
|
+
const [rawCode, pastedState] = code.split("#");
|
|
26910
|
+
if (pastedState !== undefined && pastedState !== pending.state) {
|
|
26911
|
+
throw fail("AUTH", "authorization state mismatch");
|
|
26912
|
+
}
|
|
26913
|
+
const token = yield* postToken2({
|
|
26914
|
+
grant_type: "authorization_code",
|
|
26915
|
+
client_id: CLIENT_ID2,
|
|
26916
|
+
client_secret: CLIENT_SECRET,
|
|
26917
|
+
code: (rawCode ?? "").trim(),
|
|
26918
|
+
redirect_uri: pending.redirectUri
|
|
26919
|
+
}, fail);
|
|
26920
|
+
const email3 = yield* readEmail(token.accessToken);
|
|
26921
|
+
const { projectId, tier } = yield* bootstrapProject(token.accessToken);
|
|
26922
|
+
return toResult2(token, null, email3, { projectId, tier }, now);
|
|
26923
|
+
},
|
|
26924
|
+
async* refresh({ refreshToken, providerData, fail, now }) {
|
|
26925
|
+
const token = yield* postToken2({
|
|
26926
|
+
grant_type: "refresh_token",
|
|
26927
|
+
client_id: CLIENT_ID2,
|
|
26928
|
+
client_secret: CLIENT_SECRET,
|
|
26929
|
+
refresh_token: refreshToken
|
|
26930
|
+
}, fail);
|
|
26931
|
+
return toResult2(token, refreshToken, null, providerData, now);
|
|
26932
|
+
},
|
|
26933
|
+
async* usage({ secrets, providerData, now }) {
|
|
26934
|
+
const project = typeof providerData.projectId === "string" ? providerData.projectId : "";
|
|
26935
|
+
if (project.trim().length === 0)
|
|
26936
|
+
return null;
|
|
26937
|
+
const res = yield {
|
|
26938
|
+
...postJsonRequest(QUOTA_SUMMARY_URL, antigravityProfile, {
|
|
26939
|
+
contentType: "application/json",
|
|
26940
|
+
body: JSON.stringify({ project }),
|
|
26941
|
+
extraHeaders: [["Authorization", `Bearer ${secrets.accessToken}`]]
|
|
26942
|
+
}),
|
|
26943
|
+
timeoutMs: SHORT_TIMEOUT_MS
|
|
26944
|
+
};
|
|
26945
|
+
if (!usageReadable(res.status, "antigravity"))
|
|
26946
|
+
return null;
|
|
26947
|
+
return parseAntigravityQuota(parsed(res.body), now());
|
|
26948
|
+
}
|
|
26949
|
+
};
|
|
25927
26950
|
// packages/providers/src/grok/device.ts
|
|
25928
26951
|
import { randomUUID } from "crypto";
|
|
25929
26952
|
function mintGrokDevice() {
|
|
@@ -25937,10 +26960,10 @@ function grokDeviceHeaders(providerData) {
|
|
|
25937
26960
|
}
|
|
25938
26961
|
|
|
25939
26962
|
// packages/providers/src/grok/oauth.ts
|
|
25940
|
-
var
|
|
26963
|
+
var CLIENT_ID3 = "b1a00492-073a-47ea-816f-4c329264a828";
|
|
25941
26964
|
var ISSUER = "https://auth.x.ai";
|
|
25942
26965
|
var DISCOVERY_URL = `${ISSUER}/.well-known/openid-configuration`;
|
|
25943
|
-
var
|
|
26966
|
+
var SCOPES3 = [
|
|
25944
26967
|
"openid",
|
|
25945
26968
|
"profile",
|
|
25946
26969
|
"email",
|
|
@@ -25986,7 +27009,7 @@ async function* discover(fail) {
|
|
|
25986
27009
|
tokenUrl: trustedEndpoint(parsed2.token_endpoint, "token_endpoint", fail)
|
|
25987
27010
|
};
|
|
25988
27011
|
}
|
|
25989
|
-
function
|
|
27012
|
+
function parseTokenResponse2(value) {
|
|
25990
27013
|
if (!isRecord2(value) || typeof value.access_token !== "string")
|
|
25991
27014
|
return null;
|
|
25992
27015
|
return {
|
|
@@ -26002,15 +27025,15 @@ function emailFromIdToken(idToken) {
|
|
|
26002
27025
|
if (parts.length !== 3 || payload === undefined || payload.length === 0)
|
|
26003
27026
|
return null;
|
|
26004
27027
|
try {
|
|
26005
|
-
const
|
|
26006
|
-
if (!isRecord2(
|
|
27028
|
+
const json4 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
27029
|
+
if (!isRecord2(json4))
|
|
26007
27030
|
return null;
|
|
26008
|
-
return typeof
|
|
27031
|
+
return typeof json4.email === "string" && json4.email.trim().length > 0 ? json4.email : null;
|
|
26009
27032
|
} catch {
|
|
26010
27033
|
return null;
|
|
26011
27034
|
}
|
|
26012
27035
|
}
|
|
26013
|
-
async function*
|
|
27036
|
+
async function* postToken3(tokenUrl, body, fail) {
|
|
26014
27037
|
const res = yield postJsonRequest(tokenUrl, grokProfile, {
|
|
26015
27038
|
contentType: "application/x-www-form-urlencoded",
|
|
26016
27039
|
body: new URLSearchParams(body).toString()
|
|
@@ -26019,7 +27042,7 @@ async function* postToken2(tokenUrl, body, fail) {
|
|
|
26019
27042
|
if (res.status < 200 || res.status >= 300) {
|
|
26020
27043
|
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
26021
27044
|
}
|
|
26022
|
-
const token =
|
|
27045
|
+
const token = parseTokenResponse2(parsed2);
|
|
26023
27046
|
if (token === null) {
|
|
26024
27047
|
throw fail("AUTH", "token endpoint returned no access_token");
|
|
26025
27048
|
}
|
|
@@ -26029,7 +27052,7 @@ function agentIdFrom(providerData) {
|
|
|
26029
27052
|
const stored = providerData.agentId;
|
|
26030
27053
|
return typeof stored === "string" && stored.trim().length > 0 ? stored : mintGrokDevice().agentId;
|
|
26031
27054
|
}
|
|
26032
|
-
function
|
|
27055
|
+
function toResult3(token, fallbackRefresh, agentId, now) {
|
|
26033
27056
|
return {
|
|
26034
27057
|
secrets: {
|
|
26035
27058
|
accessToken: token.accessToken,
|
|
@@ -26051,9 +27074,9 @@ var grokOAuthFlow = {
|
|
|
26051
27074
|
const state = randomState();
|
|
26052
27075
|
const url2 = new URL(authorizeUrl);
|
|
26053
27076
|
url2.searchParams.set("response_type", "code");
|
|
26054
|
-
url2.searchParams.set("client_id",
|
|
27077
|
+
url2.searchParams.set("client_id", CLIENT_ID3);
|
|
26055
27078
|
url2.searchParams.set("redirect_uri", redirectUri);
|
|
26056
|
-
url2.searchParams.set("scope",
|
|
27079
|
+
url2.searchParams.set("scope", SCOPES3);
|
|
26057
27080
|
url2.searchParams.set("code_challenge", challenge);
|
|
26058
27081
|
url2.searchParams.set("code_challenge_method", "S256");
|
|
26059
27082
|
url2.searchParams.set("state", state);
|
|
@@ -26067,19 +27090,19 @@ var grokOAuthFlow = {
|
|
|
26067
27090
|
throw fail("AUTH", "authorization state mismatch");
|
|
26068
27091
|
}
|
|
26069
27092
|
const { tokenUrl } = yield* discover(fail);
|
|
26070
|
-
const token = yield*
|
|
27093
|
+
const token = yield* postToken3(tokenUrl, {
|
|
26071
27094
|
grant_type: "authorization_code",
|
|
26072
27095
|
code: (rawCode ?? "").trim(),
|
|
26073
27096
|
redirect_uri: pending.redirectUri,
|
|
26074
|
-
client_id:
|
|
27097
|
+
client_id: CLIENT_ID3,
|
|
26075
27098
|
code_verifier: pending.verifier
|
|
26076
27099
|
}, fail);
|
|
26077
|
-
return
|
|
27100
|
+
return toResult3(token, null, mintGrokDevice().agentId, now);
|
|
26078
27101
|
},
|
|
26079
27102
|
async* refresh({ refreshToken, providerData, fail, now }) {
|
|
26080
27103
|
const { tokenUrl } = yield* discover(fail);
|
|
26081
|
-
const token = yield*
|
|
26082
|
-
return
|
|
27104
|
+
const token = yield* postToken3(tokenUrl, { grant_type: "refresh_token", client_id: CLIENT_ID3, refresh_token: refreshToken }, fail);
|
|
27105
|
+
return toResult3(token, refreshToken, agentIdFrom(providerData), now);
|
|
26083
27106
|
}
|
|
26084
27107
|
};
|
|
26085
27108
|
|
|
@@ -26239,9 +27262,9 @@ function kimiDeviceHeaders(providerData) {
|
|
|
26239
27262
|
}
|
|
26240
27263
|
|
|
26241
27264
|
// packages/providers/src/kimi/oauth.ts
|
|
26242
|
-
var
|
|
27265
|
+
var CLIENT_ID4 = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
26243
27266
|
var DEVICE_CODE_URL = "https://auth.kimi.com/api/oauth/device_authorization";
|
|
26244
|
-
var
|
|
27267
|
+
var TOKEN_URL3 = "https://auth.kimi.com/api/oauth/token";
|
|
26245
27268
|
var USAGE_URL2 = "https://api.kimi.com/coding/v1/usages";
|
|
26246
27269
|
var DEFAULT_INTERVAL_SECONDS = 5;
|
|
26247
27270
|
var PENDING_ERRORS = new Set(["authorization_pending", "slow_down"]);
|
|
@@ -26295,7 +27318,7 @@ function deviceCodeFrom2(value, fail) {
|
|
|
26295
27318
|
async function* post(url2, body, device, fail, keepPolling) {
|
|
26296
27319
|
const res = yield postJsonRequest(url2, kimiProfile, {
|
|
26297
27320
|
contentType: "application/x-www-form-urlencoded",
|
|
26298
|
-
body: new URLSearchParams({ ...body, client_id:
|
|
27321
|
+
body: new URLSearchParams({ ...body, client_id: CLIENT_ID4 }).toString(),
|
|
26299
27322
|
extraHeaders: kimiDeviceHeaders(device)
|
|
26300
27323
|
});
|
|
26301
27324
|
const parsed2 = parsed(res.body);
|
|
@@ -26326,7 +27349,7 @@ function deviceFrom(source) {
|
|
|
26326
27349
|
function deviceForBegin(deviceId) {
|
|
26327
27350
|
return { ...mintKimiDevice(), deviceId };
|
|
26328
27351
|
}
|
|
26329
|
-
function
|
|
27352
|
+
function toResult4(token, device, fallbackRefresh, now) {
|
|
26330
27353
|
return {
|
|
26331
27354
|
secrets: {
|
|
26332
27355
|
accessToken: token.accessToken,
|
|
@@ -26381,17 +27404,17 @@ var kimiOAuthFlow = {
|
|
|
26381
27404
|
throw fail("INTERNAL", "kimi exchange requires a pending flow produced by begin()");
|
|
26382
27405
|
}
|
|
26383
27406
|
const device = deviceFrom(pending.extra);
|
|
26384
|
-
const token = tokenFrom(yield* post(
|
|
27407
|
+
const token = tokenFrom(yield* post(TOKEN_URL3, {
|
|
26385
27408
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
26386
27409
|
device_code: pending.deviceCode,
|
|
26387
27410
|
device_id: device.deviceId
|
|
26388
27411
|
}, device, fail, keepPolling), fail);
|
|
26389
|
-
return
|
|
27412
|
+
return toResult4(token, device, null, now);
|
|
26390
27413
|
},
|
|
26391
27414
|
async* refresh({ refreshToken, providerData, fail, keepPolling, now }) {
|
|
26392
27415
|
const device = deviceFrom(providerData);
|
|
26393
|
-
const token = tokenFrom(yield* post(
|
|
26394
|
-
return
|
|
27416
|
+
const token = tokenFrom(yield* post(TOKEN_URL3, { grant_type: "refresh_token", refresh_token: refreshToken, device_id: device.deviceId }, device, fail, keepPolling), fail);
|
|
27417
|
+
return toResult4(token, device, refreshToken, now);
|
|
26395
27418
|
},
|
|
26396
27419
|
async* usage({ secrets, providerData, now }) {
|
|
26397
27420
|
if (secrets.accessToken === null)
|
|
@@ -26407,13 +27430,225 @@ var kimiOAuthFlow = {
|
|
|
26407
27430
|
}
|
|
26408
27431
|
};
|
|
26409
27432
|
|
|
27433
|
+
// packages/providers/src/muse/endpoint.ts
|
|
27434
|
+
var TRUSTED_HOST2 = "meta.ai";
|
|
27435
|
+
var MUSE_DEFAULT_BASE_URL = "https://api.meta.ai/v1";
|
|
27436
|
+
function trustedBaseUrl(value) {
|
|
27437
|
+
if (typeof value !== "string" || value.length === 0)
|
|
27438
|
+
return null;
|
|
27439
|
+
let url2;
|
|
27440
|
+
try {
|
|
27441
|
+
url2 = new URL(value);
|
|
27442
|
+
} catch {
|
|
27443
|
+
return null;
|
|
27444
|
+
}
|
|
27445
|
+
if (url2.protocol !== "https:")
|
|
27446
|
+
return null;
|
|
27447
|
+
const host2 = url2.hostname;
|
|
27448
|
+
if (host2 !== TRUSTED_HOST2 && !host2.endsWith(`.${TRUSTED_HOST2}`))
|
|
27449
|
+
return null;
|
|
27450
|
+
return `${url2.origin}${url2.pathname}`.replace(/\/$/, "");
|
|
27451
|
+
}
|
|
27452
|
+
function museResponsesUrl(providerData) {
|
|
27453
|
+
return `${trustedBaseUrl(providerData.baseUrl) ?? MUSE_DEFAULT_BASE_URL}/responses`;
|
|
27454
|
+
}
|
|
27455
|
+
|
|
27456
|
+
// packages/providers/src/muse/oauth.ts
|
|
27457
|
+
var AUTH_BASE = "https://auth.meta.com";
|
|
27458
|
+
var DEVICE_CODE_URL2 = `${AUTH_BASE}/oidc/device/authorization/`;
|
|
27459
|
+
var TOKEN_URL4 = `${AUTH_BASE}/oidc/device/token/`;
|
|
27460
|
+
var MINT_URL = "https://api.meta.ai/muse-code/key";
|
|
27461
|
+
var CLIENT_ID5 = "1031625952748946";
|
|
27462
|
+
var DEVICE_CODE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
27463
|
+
var FALLBACK_VERIFICATION_URL2 = "https://auth.meta.com/oauth/device/";
|
|
27464
|
+
var DEFAULT_INTERVAL_SECONDS2 = 5;
|
|
27465
|
+
var PENDING_ERRORS2 = new Set(["authorization_pending", "slow_down"]);
|
|
27466
|
+
function isRecord5(value) {
|
|
27467
|
+
return typeof value === "object" && value !== null;
|
|
27468
|
+
}
|
|
27469
|
+
function recordFrom3(value) {
|
|
27470
|
+
return isRecord5(value) ? value : null;
|
|
27471
|
+
}
|
|
27472
|
+
function stringFrom3(value, field) {
|
|
27473
|
+
const candidate = value[field];
|
|
27474
|
+
return typeof candidate === "string" && candidate.trim().length > 0 ? candidate : null;
|
|
27475
|
+
}
|
|
27476
|
+
function positiveNumberFrom3(value, field) {
|
|
27477
|
+
const candidate = value[field];
|
|
27478
|
+
return typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0 ? candidate : null;
|
|
27479
|
+
}
|
|
27480
|
+
function tokenFrom2(value, fail) {
|
|
27481
|
+
const record2 = recordFrom3(value);
|
|
27482
|
+
const accessToken = record2 === null ? null : stringFrom3(record2, "access_token");
|
|
27483
|
+
if (record2 === null || accessToken === null) {
|
|
27484
|
+
throw fail("AUTH", "token endpoint returned no access_token");
|
|
27485
|
+
}
|
|
27486
|
+
return {
|
|
27487
|
+
accessToken,
|
|
27488
|
+
refreshToken: stringFrom3(record2, "refresh_token"),
|
|
27489
|
+
expiresIn: positiveNumberFrom3(record2, "expires_in")
|
|
27490
|
+
};
|
|
27491
|
+
}
|
|
27492
|
+
function deviceCodeFrom3(value, fail) {
|
|
27493
|
+
const record2 = recordFrom3(value);
|
|
27494
|
+
const deviceCode = record2 === null ? null : stringFrom3(record2, "device_code");
|
|
27495
|
+
const userCode = record2 === null ? null : stringFrom3(record2, "user_code");
|
|
27496
|
+
if (record2 === null || deviceCode === null || userCode === null) {
|
|
27497
|
+
throw fail("AUTH", "device authorization response missing user_code or verification_uri");
|
|
27498
|
+
}
|
|
27499
|
+
return {
|
|
27500
|
+
deviceCode,
|
|
27501
|
+
userCode,
|
|
27502
|
+
verificationUri: stringFrom3(record2, "verification_uri_complete") ?? stringFrom3(record2, "verification_uri") ?? FALLBACK_VERIFICATION_URL2,
|
|
27503
|
+
interval: positiveNumberFrom3(record2, "interval") ?? DEFAULT_INTERVAL_SECONDS2
|
|
27504
|
+
};
|
|
27505
|
+
}
|
|
27506
|
+
async function* postForm(url2, body, fail, keepPolling) {
|
|
27507
|
+
const res = yield postJsonRequest(url2, museProfile, {
|
|
27508
|
+
contentType: "application/x-www-form-urlencoded",
|
|
27509
|
+
body: new URLSearchParams({ ...body, client_id: CLIENT_ID5 }).toString(),
|
|
27510
|
+
extraHeaders: [["Accept", "application/json"]]
|
|
27511
|
+
});
|
|
27512
|
+
const parsed2 = parsed(res.body);
|
|
27513
|
+
if (res.status >= 200 && res.status < 300)
|
|
27514
|
+
return parsed2;
|
|
27515
|
+
const record2 = recordFrom3(parsed2);
|
|
27516
|
+
const code = record2 === null ? `http_${res.status}` : stringFrom3(record2, "error") ?? `http_${res.status}`;
|
|
27517
|
+
if (PENDING_ERRORS2.has(code))
|
|
27518
|
+
throw keepPolling(code);
|
|
27519
|
+
if (code === "expired_token") {
|
|
27520
|
+
throw fail("AUTH", "muse device code expired; start the authorization again");
|
|
27521
|
+
}
|
|
27522
|
+
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
27523
|
+
}
|
|
27524
|
+
async function* mint(accessToken, fail) {
|
|
27525
|
+
const res = yield postJsonRequest(MINT_URL, museProfile, {
|
|
27526
|
+
contentType: "application/json",
|
|
27527
|
+
body: "{}",
|
|
27528
|
+
extraHeaders: [
|
|
27529
|
+
["Authorization", `Bearer ${accessToken}`],
|
|
27530
|
+
["Accept", "application/json"]
|
|
27531
|
+
]
|
|
27532
|
+
});
|
|
27533
|
+
const parsed2 = parsed(res.body);
|
|
27534
|
+
if (res.status < 200 || res.status >= 300) {
|
|
27535
|
+
if (res.status === 401 || res.status === 403) {
|
|
27536
|
+
throw fail("AUTH", "muse rejected the saved login; reconnect the account or use a different one");
|
|
27537
|
+
}
|
|
27538
|
+
if (res.status === 429) {
|
|
27539
|
+
throw fail("RATE_LIMIT", `muse rate limited the key mint: http_${res.status}`);
|
|
27540
|
+
}
|
|
27541
|
+
throw fail("UPSTREAM", `muse key mint failed: http_${res.status}`);
|
|
27542
|
+
}
|
|
27543
|
+
const record2 = recordFrom3(parsed2);
|
|
27544
|
+
if (record2 === null) {
|
|
27545
|
+
throw fail("UPSTREAM", "muse key mint returned an unusable response");
|
|
27546
|
+
}
|
|
27547
|
+
if (record2.require_payment === true) {
|
|
27548
|
+
throw fail("AUTH", "muse requires a payment method on the Meta account; add one at https://dev.meta.ai and reconnect");
|
|
27549
|
+
}
|
|
27550
|
+
const apiKey = stringFrom3(record2, "api_key");
|
|
27551
|
+
if (apiKey === null) {
|
|
27552
|
+
throw fail("AUTH", "muse key mint returned an empty api key; finish onboarding at https://dev.meta.ai and reconnect");
|
|
27553
|
+
}
|
|
27554
|
+
return {
|
|
27555
|
+
apiKey,
|
|
27556
|
+
email: stringFrom3(record2, "user_email"),
|
|
27557
|
+
tierName: stringFrom3(record2, "subs_tier_name"),
|
|
27558
|
+
subscriptionActive: record2.is_subs_active === true,
|
|
27559
|
+
baseUrl: trustedBaseUrl(record2.base_url),
|
|
27560
|
+
usage: record2.subs_usage
|
|
27561
|
+
};
|
|
27562
|
+
}
|
|
27563
|
+
function toResult5(token, key, fallbackRefresh, now) {
|
|
27564
|
+
return {
|
|
27565
|
+
secrets: {
|
|
27566
|
+
accessToken: token.accessToken,
|
|
27567
|
+
refreshToken: token.refreshToken ?? fallbackRefresh,
|
|
27568
|
+
apiKey: key.apiKey,
|
|
27569
|
+
idToken: null
|
|
27570
|
+
},
|
|
27571
|
+
expiresAt: token.expiresIn === null ? null : now() + token.expiresIn * 1000,
|
|
27572
|
+
accountEmail: key.email,
|
|
27573
|
+
providerData: {
|
|
27574
|
+
...key.tierName === null ? {} : { subscriptionTier: key.tierName },
|
|
27575
|
+
subscriptionActive: key.subscriptionActive,
|
|
27576
|
+
...key.baseUrl === null ? {} : { baseUrl: key.baseUrl }
|
|
27577
|
+
}
|
|
27578
|
+
};
|
|
27579
|
+
}
|
|
27580
|
+
var museOAuthFlow = {
|
|
27581
|
+
kind: "device",
|
|
27582
|
+
supportsManualPaste: false,
|
|
27583
|
+
needsDeviceId: false,
|
|
27584
|
+
async* start() {
|
|
27585
|
+
return {
|
|
27586
|
+
authorizeUrl: FALLBACK_VERIFICATION_URL2,
|
|
27587
|
+
pending: { verifier: "", challenge: "", state: "", redirectUri: "" }
|
|
27588
|
+
};
|
|
27589
|
+
},
|
|
27590
|
+
async* begin({ fail, keepPolling }) {
|
|
27591
|
+
const response = deviceCodeFrom3(yield* postForm(DEVICE_CODE_URL2, {}, fail, keepPolling), fail);
|
|
27592
|
+
return {
|
|
27593
|
+
authorizeUrl: response.verificationUri,
|
|
27594
|
+
userCode: response.userCode,
|
|
27595
|
+
pending: {
|
|
27596
|
+
verifier: "",
|
|
27597
|
+
challenge: "",
|
|
27598
|
+
state: "",
|
|
27599
|
+
redirectUri: "",
|
|
27600
|
+
deviceCode: response.deviceCode,
|
|
27601
|
+
interval: response.interval
|
|
27602
|
+
}
|
|
27603
|
+
};
|
|
27604
|
+
},
|
|
27605
|
+
async* exchange({ pending, fail, keepPolling, now }) {
|
|
27606
|
+
if (pending.deviceCode === undefined) {
|
|
27607
|
+
throw fail("INTERNAL", "muse exchange requires a pending flow produced by begin()");
|
|
27608
|
+
}
|
|
27609
|
+
const token = tokenFrom2(yield* postForm(TOKEN_URL4, { grant_type: DEVICE_CODE_GRANT, device_code: pending.deviceCode }, fail, keepPolling), fail);
|
|
27610
|
+
return toResult5(token, yield* mint(token.accessToken, fail), null, now);
|
|
27611
|
+
},
|
|
27612
|
+
async* refresh({ refreshToken, fail, keepPolling, now }) {
|
|
27613
|
+
const token = tokenFrom2(yield* postForm(TOKEN_URL4, { grant_type: "refresh_token", refresh_token: refreshToken }, fail, keepPolling), fail);
|
|
27614
|
+
return toResult5(token, yield* mint(token.accessToken, fail), refreshToken, now);
|
|
27615
|
+
},
|
|
27616
|
+
async* usage({ secrets, now }) {
|
|
27617
|
+
if (secrets.accessToken === null)
|
|
27618
|
+
return null;
|
|
27619
|
+
const res = yield postJsonRequest(MINT_URL, museProfile, {
|
|
27620
|
+
contentType: "application/json",
|
|
27621
|
+
body: "{}",
|
|
27622
|
+
extraHeaders: [
|
|
27623
|
+
["Authorization", `Bearer ${secrets.accessToken}`],
|
|
27624
|
+
["Accept", "application/json"]
|
|
27625
|
+
]
|
|
27626
|
+
});
|
|
27627
|
+
if (!usageReadable(res.status, "muse"))
|
|
27628
|
+
return null;
|
|
27629
|
+
const record2 = recordOf(parsed(res.body));
|
|
27630
|
+
return record2 === null ? null : parseMuseUsage(record2.subs_usage, now());
|
|
27631
|
+
}
|
|
27632
|
+
};
|
|
27633
|
+
function parseMuseUsage(value, now) {
|
|
27634
|
+
const root = recordOf(value);
|
|
27635
|
+
if (root === null)
|
|
27636
|
+
return null;
|
|
27637
|
+
const window = recordOf(root.window);
|
|
27638
|
+
const mins = window === null ? null : numberOf(window, ["window_duration_mins"]);
|
|
27639
|
+
return reportFrom([
|
|
27640
|
+
windowFrom(root.window, "fiveHour", now, mins === null ? null : mins * 60000),
|
|
27641
|
+
windowFrom(root.weekly, "weekly", now)
|
|
27642
|
+
]);
|
|
27643
|
+
}
|
|
27644
|
+
|
|
26410
27645
|
// packages/providers/src/openai/oauth.ts
|
|
26411
|
-
var
|
|
26412
|
-
var
|
|
26413
|
-
var
|
|
26414
|
-
var
|
|
27646
|
+
var CLIENT_ID6 = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
27647
|
+
var AUTHORIZE_URL3 = "https://auth.openai.com/oauth/authorize";
|
|
27648
|
+
var TOKEN_URL5 = "https://auth.openai.com/oauth/token";
|
|
27649
|
+
var SCOPES4 = "openid profile email offline_access";
|
|
26415
27650
|
var USAGE_URL3 = "https://chatgpt.com/backend-api/wham/usage";
|
|
26416
|
-
function
|
|
27651
|
+
function isRecord6(value) {
|
|
26417
27652
|
return typeof value === "object" && value !== null;
|
|
26418
27653
|
}
|
|
26419
27654
|
function nonBlankStringOrNull(value) {
|
|
@@ -26429,20 +27664,20 @@ function decodeClaims(idToken) {
|
|
|
26429
27664
|
return { email: null, accountId: null };
|
|
26430
27665
|
}
|
|
26431
27666
|
try {
|
|
26432
|
-
const
|
|
26433
|
-
if (!
|
|
27667
|
+
const json4 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
27668
|
+
if (!isRecord6(json4))
|
|
26434
27669
|
return { email: null, accountId: null };
|
|
26435
|
-
const auth =
|
|
27670
|
+
const auth = json4["https://api.openai.com/auth"];
|
|
26436
27671
|
return {
|
|
26437
|
-
email: typeof
|
|
26438
|
-
accountId:
|
|
27672
|
+
email: typeof json4.email === "string" ? json4.email : null,
|
|
27673
|
+
accountId: isRecord6(auth) ? nonBlankStringOrNull(auth.chatgpt_account_id) : null
|
|
26439
27674
|
};
|
|
26440
27675
|
} catch {
|
|
26441
27676
|
return { email: null, accountId: null };
|
|
26442
27677
|
}
|
|
26443
27678
|
}
|
|
26444
|
-
function
|
|
26445
|
-
if (!
|
|
27679
|
+
function parseTokenResponse3(value) {
|
|
27680
|
+
if (!isRecord6(value) || typeof value.access_token !== "string")
|
|
26446
27681
|
return null;
|
|
26447
27682
|
return {
|
|
26448
27683
|
accessToken: value.access_token,
|
|
@@ -26451,22 +27686,22 @@ function parseTokenResponse2(value) {
|
|
|
26451
27686
|
idToken: typeof value.id_token === "string" ? value.id_token : null
|
|
26452
27687
|
};
|
|
26453
27688
|
}
|
|
26454
|
-
async function*
|
|
26455
|
-
const res = yield postJsonRequest(
|
|
27689
|
+
async function* postToken4(body, fail) {
|
|
27690
|
+
const res = yield postJsonRequest(TOKEN_URL5, openaiProfile, {
|
|
26456
27691
|
contentType: "application/x-www-form-urlencoded",
|
|
26457
|
-
body: new URLSearchParams({ ...body, client_id:
|
|
27692
|
+
body: new URLSearchParams({ ...body, client_id: CLIENT_ID6 }).toString()
|
|
26458
27693
|
});
|
|
26459
27694
|
const parsed2 = parsed(res.body);
|
|
26460
27695
|
if (res.status < 200 || res.status >= 300) {
|
|
26461
27696
|
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
26462
27697
|
}
|
|
26463
|
-
const token =
|
|
27698
|
+
const token = parseTokenResponse3(parsed2);
|
|
26464
27699
|
if (token === null) {
|
|
26465
27700
|
throw fail("AUTH", "token endpoint returned no access_token");
|
|
26466
27701
|
}
|
|
26467
27702
|
return token;
|
|
26468
27703
|
}
|
|
26469
|
-
function
|
|
27704
|
+
function toResult6(token, fallbackRefresh, now, fallbackAccountId = null) {
|
|
26470
27705
|
const claims = decodeClaims(token.idToken);
|
|
26471
27706
|
return {
|
|
26472
27707
|
secrets: {
|
|
@@ -26524,11 +27759,11 @@ var openaiOAuthFlow = {
|
|
|
26524
27759
|
async* start({ redirectUri, pkce, randomState }) {
|
|
26525
27760
|
const { verifier, challenge } = pkce();
|
|
26526
27761
|
const state = randomState();
|
|
26527
|
-
const url2 = new URL(
|
|
26528
|
-
url2.searchParams.set("client_id",
|
|
27762
|
+
const url2 = new URL(AUTHORIZE_URL3);
|
|
27763
|
+
url2.searchParams.set("client_id", CLIENT_ID6);
|
|
26529
27764
|
url2.searchParams.set("response_type", "code");
|
|
26530
27765
|
url2.searchParams.set("redirect_uri", redirectUri);
|
|
26531
|
-
url2.searchParams.set("scope",
|
|
27766
|
+
url2.searchParams.set("scope", SCOPES4);
|
|
26532
27767
|
url2.searchParams.set("code_challenge", challenge);
|
|
26533
27768
|
url2.searchParams.set("code_challenge_method", "S256");
|
|
26534
27769
|
url2.searchParams.set("id_token_add_organizations", "true");
|
|
@@ -26543,17 +27778,17 @@ var openaiOAuthFlow = {
|
|
|
26543
27778
|
if (pastedState !== undefined && pastedState !== pending.state) {
|
|
26544
27779
|
throw fail("AUTH", "authorization state mismatch");
|
|
26545
27780
|
}
|
|
26546
|
-
const token = yield*
|
|
27781
|
+
const token = yield* postToken4({
|
|
26547
27782
|
grant_type: "authorization_code",
|
|
26548
27783
|
code: (rawCode ?? "").trim(),
|
|
26549
27784
|
redirect_uri: pending.redirectUri,
|
|
26550
27785
|
code_verifier: pending.verifier
|
|
26551
27786
|
}, fail);
|
|
26552
|
-
return
|
|
27787
|
+
return toResult6(token, null, now);
|
|
26553
27788
|
},
|
|
26554
27789
|
async* refresh({ refreshToken, providerData, fail, now }) {
|
|
26555
|
-
const token = yield*
|
|
26556
|
-
return
|
|
27790
|
+
const token = yield* postToken4({ grant_type: "refresh_token", refresh_token: refreshToken, scope: SCOPES4 }, fail);
|
|
27791
|
+
return toResult6(token, refreshToken, now, accountIdFromProviderData(providerData));
|
|
26557
27792
|
},
|
|
26558
27793
|
async* usage({ secrets, providerData, now }) {
|
|
26559
27794
|
if (secrets.accessToken === null)
|
|
@@ -26576,7 +27811,9 @@ function builtinOAuthFlows() {
|
|
|
26576
27811
|
["openai", openaiOAuthFlow],
|
|
26577
27812
|
["kimi", kimiOAuthFlow],
|
|
26578
27813
|
["kilo", kiloOAuthFlow],
|
|
26579
|
-
["grok", grokOAuthFlow]
|
|
27814
|
+
["grok", grokOAuthFlow],
|
|
27815
|
+
["antigravity", antigravityOAuthFlow],
|
|
27816
|
+
["muse", museOAuthFlow]
|
|
26580
27817
|
];
|
|
26581
27818
|
}
|
|
26582
27819
|
// packages/providers/src/custom/decode.ts
|
|
@@ -26604,7 +27841,7 @@ function reasoningText(delta) {
|
|
|
26604
27841
|
return [];
|
|
26605
27842
|
}).join("");
|
|
26606
27843
|
}
|
|
26607
|
-
function
|
|
27844
|
+
function json4(data) {
|
|
26608
27845
|
try {
|
|
26609
27846
|
const v = JSON.parse(data);
|
|
26610
27847
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -26626,7 +27863,7 @@ async function* decodeCustomChat(messages) {
|
|
|
26626
27863
|
done = true;
|
|
26627
27864
|
break;
|
|
26628
27865
|
}
|
|
26629
|
-
const d =
|
|
27866
|
+
const d = json4(msg.data);
|
|
26630
27867
|
if (d === null)
|
|
26631
27868
|
continue;
|
|
26632
27869
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -26784,7 +28021,7 @@ async function* decodeCustomResponses(messages) {
|
|
|
26784
28021
|
};
|
|
26785
28022
|
return;
|
|
26786
28023
|
}
|
|
26787
|
-
const d =
|
|
28024
|
+
const d = json4(msg.data);
|
|
26788
28025
|
if (d === null)
|
|
26789
28026
|
continue;
|
|
26790
28027
|
switch (msg.event) {
|
|
@@ -27172,10 +28409,10 @@ var customCodec = {
|
|
|
27172
28409
|
// packages/providers/src/custom/index.ts
|
|
27173
28410
|
var customAdapter = codecAdapter("custom", customDescriptor.capabilities, customCodec);
|
|
27174
28411
|
// packages/providers/src/grok/codec.ts
|
|
27175
|
-
import { createHash as
|
|
28412
|
+
import { createHash as createHash4 } from "crypto";
|
|
27176
28413
|
|
|
27177
28414
|
// packages/providers/src/grok/decode.ts
|
|
27178
|
-
var
|
|
28415
|
+
var ERROR_CODE2 = {
|
|
27179
28416
|
rate_limit_exceeded: "RATE_LIMIT",
|
|
27180
28417
|
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
27181
28418
|
invalid_api_key: "AUTH",
|
|
@@ -27209,7 +28446,7 @@ var KNOWN_EVENTS2 = new Set([
|
|
|
27209
28446
|
"response.failed",
|
|
27210
28447
|
"error"
|
|
27211
28448
|
]);
|
|
27212
|
-
function
|
|
28449
|
+
function json5(data) {
|
|
27213
28450
|
try {
|
|
27214
28451
|
const v = JSON.parse(data);
|
|
27215
28452
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -27244,7 +28481,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
27244
28481
|
};
|
|
27245
28482
|
return;
|
|
27246
28483
|
}
|
|
27247
|
-
const d =
|
|
28484
|
+
const d = json5(msg.data);
|
|
27248
28485
|
if (d === null)
|
|
27249
28486
|
continue;
|
|
27250
28487
|
switch (msg.event) {
|
|
@@ -27347,7 +28584,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
27347
28584
|
terminal = true;
|
|
27348
28585
|
const err = d.response?.error ?? d.error ?? {};
|
|
27349
28586
|
const raw = String(err.code ?? err.type);
|
|
27350
|
-
const code = (Object.hasOwn(
|
|
28587
|
+
const code = (Object.hasOwn(ERROR_CODE2, raw) ? ERROR_CODE2[raw] : undefined) ?? "UPSTREAM";
|
|
27351
28588
|
yield {
|
|
27352
28589
|
type: "error",
|
|
27353
28590
|
code,
|
|
@@ -27371,9 +28608,9 @@ async function* decodeGrokResponses(messages) {
|
|
|
27371
28608
|
}
|
|
27372
28609
|
|
|
27373
28610
|
// packages/providers/src/grok/wire.ts
|
|
27374
|
-
import { createHash as
|
|
28611
|
+
import { createHash as createHash3 } from "crypto";
|
|
27375
28612
|
var MAX_TOOLS = 200;
|
|
27376
|
-
function
|
|
28613
|
+
function encodeToolChoice3(c) {
|
|
27377
28614
|
switch (c.type) {
|
|
27378
28615
|
case "auto":
|
|
27379
28616
|
return "auto";
|
|
@@ -27387,7 +28624,7 @@ function encodeToolChoice2(c) {
|
|
|
27387
28624
|
}
|
|
27388
28625
|
function promptCacheKey(instructions, firstInput) {
|
|
27389
28626
|
const stable = JSON.stringify({ instructions, firstInput });
|
|
27390
|
-
return
|
|
28627
|
+
return createHash3("sha256").update(stable).digest("hex").slice(0, 32);
|
|
27391
28628
|
}
|
|
27392
28629
|
function toGrokWire(req, model) {
|
|
27393
28630
|
const degradations = [];
|
|
@@ -27480,7 +28717,7 @@ function toGrokWire(req, model) {
|
|
|
27480
28717
|
}));
|
|
27481
28718
|
}
|
|
27482
28719
|
if (req.toolChoice !== undefined)
|
|
27483
|
-
body.tool_choice =
|
|
28720
|
+
body.tool_choice = encodeToolChoice3(req.toolChoice);
|
|
27484
28721
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
27485
28722
|
if (req.reasoning.mode === "budget") {
|
|
27486
28723
|
note2("grok:reasoning-budget-dropped");
|
|
@@ -27498,7 +28735,7 @@ var PROXY_URL = "https://cli-chat-proxy.grok.com/v1/responses";
|
|
|
27498
28735
|
var API_URL = "https://api.x.ai/v1/responses";
|
|
27499
28736
|
var CONV_NAMESPACE = "omni-grok-conv";
|
|
27500
28737
|
function derivedUuid(value) {
|
|
27501
|
-
const h =
|
|
28738
|
+
const h = createHash4("sha256").update(`${CONV_NAMESPACE}:${value}`).digest("hex");
|
|
27502
28739
|
const variant = (Number.parseInt(h[16], 16) & 3 | 8).toString(16);
|
|
27503
28740
|
return [
|
|
27504
28741
|
h.slice(0, 8),
|
|
@@ -27681,7 +28918,7 @@ function reasoningText2(delta) {
|
|
|
27681
28918
|
return [];
|
|
27682
28919
|
}).join("");
|
|
27683
28920
|
}
|
|
27684
|
-
function
|
|
28921
|
+
function json6(data) {
|
|
27685
28922
|
try {
|
|
27686
28923
|
const v = JSON.parse(data);
|
|
27687
28924
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -27703,7 +28940,7 @@ async function* decodeKiloChat(messages) {
|
|
|
27703
28940
|
done = true;
|
|
27704
28941
|
break;
|
|
27705
28942
|
}
|
|
27706
|
-
const d =
|
|
28943
|
+
const d = json6(msg.data);
|
|
27707
28944
|
if (d === null)
|
|
27708
28945
|
continue;
|
|
27709
28946
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -27803,7 +29040,7 @@ async function* decodeKiloChat(messages) {
|
|
|
27803
29040
|
}
|
|
27804
29041
|
|
|
27805
29042
|
// packages/providers/src/kilo/wire.ts
|
|
27806
|
-
function
|
|
29043
|
+
function encodeToolChoice4(c) {
|
|
27807
29044
|
switch (c.type) {
|
|
27808
29045
|
case "auto":
|
|
27809
29046
|
return "auto";
|
|
@@ -27914,7 +29151,7 @@ function toKiloWire(req, model) {
|
|
|
27914
29151
|
}));
|
|
27915
29152
|
}
|
|
27916
29153
|
if (req.toolChoice !== undefined)
|
|
27917
|
-
body.tool_choice =
|
|
29154
|
+
body.tool_choice = encodeToolChoice4(req.toolChoice);
|
|
27918
29155
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
27919
29156
|
if (req.reasoning.mode === "budget") {
|
|
27920
29157
|
body.reasoning = { max_tokens: req.reasoning.budgetTokens };
|
|
@@ -27973,7 +29210,7 @@ var FINISH2 = {
|
|
|
27973
29210
|
tool_calls: "toolUse",
|
|
27974
29211
|
content_filter: "contentFilter"
|
|
27975
29212
|
};
|
|
27976
|
-
function
|
|
29213
|
+
function json7(data) {
|
|
27977
29214
|
try {
|
|
27978
29215
|
const v = JSON.parse(data);
|
|
27979
29216
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -27995,7 +29232,7 @@ async function* decodeChat(messages) {
|
|
|
27995
29232
|
done = true;
|
|
27996
29233
|
break;
|
|
27997
29234
|
}
|
|
27998
|
-
const d =
|
|
29235
|
+
const d = json7(msg.data);
|
|
27999
29236
|
if (d === null)
|
|
28000
29237
|
continue;
|
|
28001
29238
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -28079,7 +29316,7 @@ async function* decodeChat(messages) {
|
|
|
28079
29316
|
}
|
|
28080
29317
|
|
|
28081
29318
|
// packages/providers/src/kimi/wire.ts
|
|
28082
|
-
function
|
|
29319
|
+
function encodeToolChoice5(c) {
|
|
28083
29320
|
switch (c.type) {
|
|
28084
29321
|
case "auto":
|
|
28085
29322
|
return "auto";
|
|
@@ -28170,7 +29407,7 @@ function toChatWire(req, model, vendor = "kimi") {
|
|
|
28170
29407
|
}));
|
|
28171
29408
|
}
|
|
28172
29409
|
if (req.toolChoice !== undefined)
|
|
28173
|
-
body.tool_choice =
|
|
29410
|
+
body.tool_choice = encodeToolChoice5(req.toolChoice);
|
|
28174
29411
|
if (req.reasoning !== undefined)
|
|
28175
29412
|
note2("kimi:reasoning-dropped");
|
|
28176
29413
|
Object.assign(body, req.vendor?.[vendor] ?? {});
|
|
@@ -28210,8 +29447,8 @@ var kimiCodec = {
|
|
|
28210
29447
|
|
|
28211
29448
|
// packages/providers/src/kimi/index.ts
|
|
28212
29449
|
var kimiAdapter = codecAdapter("kimi", kimiDescriptor.capabilities, kimiCodec);
|
|
28213
|
-
// packages/providers/src/
|
|
28214
|
-
var
|
|
29450
|
+
// packages/providers/src/muse/decode.ts
|
|
29451
|
+
var ERROR_CODE3 = {
|
|
28215
29452
|
rate_limit_exceeded: "RATE_LIMIT",
|
|
28216
29453
|
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
28217
29454
|
invalid_api_key: "AUTH",
|
|
@@ -28246,7 +29483,7 @@ var KNOWN_EVENTS3 = new Set([
|
|
|
28246
29483
|
"response.failed",
|
|
28247
29484
|
"error"
|
|
28248
29485
|
]);
|
|
28249
|
-
function
|
|
29486
|
+
function json8(data) {
|
|
28250
29487
|
try {
|
|
28251
29488
|
const v = JSON.parse(data);
|
|
28252
29489
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -28254,7 +29491,7 @@ function json7(data) {
|
|
|
28254
29491
|
return null;
|
|
28255
29492
|
}
|
|
28256
29493
|
}
|
|
28257
|
-
async function*
|
|
29494
|
+
async function* decodeMuseResponses(messages, options = {}) {
|
|
28258
29495
|
const nativeReasoning = options.nativeReasoning === true;
|
|
28259
29496
|
const indices = new Map;
|
|
28260
29497
|
let next = 0;
|
|
@@ -28277,12 +29514,12 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28277
29514
|
yield {
|
|
28278
29515
|
type: "error",
|
|
28279
29516
|
code: "UPSTREAM",
|
|
28280
|
-
message: `unrecognized
|
|
29517
|
+
message: `unrecognized muse stream event "${msg.event}"`,
|
|
28281
29518
|
retryable: false
|
|
28282
29519
|
};
|
|
28283
29520
|
return;
|
|
28284
29521
|
}
|
|
28285
|
-
const d =
|
|
29522
|
+
const d = json8(msg.data);
|
|
28286
29523
|
if (d === null)
|
|
28287
29524
|
continue;
|
|
28288
29525
|
switch (msg.event) {
|
|
@@ -28300,7 +29537,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28300
29537
|
yield {
|
|
28301
29538
|
type: "blockStart",
|
|
28302
29539
|
index: irIndex(d.output_index ?? 0),
|
|
28303
|
-
block: nativeReasoning ? { type: "providerNative", provider: "
|
|
29540
|
+
block: nativeReasoning ? { type: "providerNative", provider: "muse", blockType: "reasoning", data: {} } : { type: "thinking" }
|
|
28304
29541
|
};
|
|
28305
29542
|
} else if (item.type === "function_call") {
|
|
28306
29543
|
sawToolCall = true;
|
|
@@ -28335,7 +29572,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28335
29572
|
index: irIndex(d.output_index ?? 0),
|
|
28336
29573
|
delta: nativeReasoning ? {
|
|
28337
29574
|
type: "providerNative",
|
|
28338
|
-
provider: "
|
|
29575
|
+
provider: "muse",
|
|
28339
29576
|
deltaType: "reasoning_summary_text.delta",
|
|
28340
29577
|
data: { text: String(d.delta ?? "") }
|
|
28341
29578
|
} : { type: "thinking", text: String(d.delta ?? "") }
|
|
@@ -28361,7 +29598,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28361
29598
|
index: irIndex(outputIndex),
|
|
28362
29599
|
delta: {
|
|
28363
29600
|
type: "providerNative",
|
|
28364
|
-
provider: "
|
|
29601
|
+
provider: "muse",
|
|
28365
29602
|
deltaType: "response.output_item.done",
|
|
28366
29603
|
fold: "merge",
|
|
28367
29604
|
data: item
|
|
@@ -28386,7 +29623,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28386
29623
|
yield {
|
|
28387
29624
|
type: "error",
|
|
28388
29625
|
code: "UPSTREAM",
|
|
28389
|
-
message: reason !== undefined ? `unrecognized
|
|
29626
|
+
message: reason !== undefined ? `unrecognized muse incomplete reason "${String(reason)}"` : r.status !== undefined && r.status !== "incomplete" ? `muse reported terminal response status "${String(r.status)}"` : "muse reported the response incomplete without a reason",
|
|
28390
29627
|
retryable: false
|
|
28391
29628
|
};
|
|
28392
29629
|
break;
|
|
@@ -28403,7 +29640,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28403
29640
|
terminal = true;
|
|
28404
29641
|
const err = d.response?.error ?? d.error ?? {};
|
|
28405
29642
|
const raw = String(err.code ?? err.type);
|
|
28406
|
-
const code = (Object.hasOwn(
|
|
29643
|
+
const code = (Object.hasOwn(ERROR_CODE3, raw) ? ERROR_CODE3[raw] : undefined) ?? "UPSTREAM";
|
|
28407
29644
|
yield {
|
|
28408
29645
|
type: "error",
|
|
28409
29646
|
code,
|
|
@@ -28426,8 +29663,8 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28426
29663
|
}
|
|
28427
29664
|
}
|
|
28428
29665
|
|
|
28429
|
-
// packages/providers/src/
|
|
28430
|
-
import { createHash as
|
|
29666
|
+
// packages/providers/src/muse/wire.ts
|
|
29667
|
+
import { createHash as createHash5 } from "crypto";
|
|
28431
29668
|
function suppliedKey(req) {
|
|
28432
29669
|
const vendor = req.vendor?.openai;
|
|
28433
29670
|
for (const name of ["prompt_cache_key", "session_id"]) {
|
|
@@ -28439,7 +29676,7 @@ function suppliedKey(req) {
|
|
|
28439
29676
|
}
|
|
28440
29677
|
function cacheKey(req, instructions, firstInput) {
|
|
28441
29678
|
const stable = req.conversationId !== undefined && req.conversationId.length > 0 ? JSON.stringify({ conversation: req.conversationId }) : JSON.stringify({ instructions, firstInput: firstInput ?? null });
|
|
28442
|
-
return
|
|
29679
|
+
return createHash5("sha256").update(stable).digest("hex").slice(0, 32);
|
|
28443
29680
|
}
|
|
28444
29681
|
function repairOrphanedCalls(input2) {
|
|
28445
29682
|
const answered = new Set;
|
|
@@ -28458,7 +29695,407 @@ function repairOrphanedCalls(input2) {
|
|
|
28458
29695
|
input2.splice(i + 1, 0, { type: "function_call_output", call_id: record2.call_id, output: "" });
|
|
28459
29696
|
}
|
|
28460
29697
|
}
|
|
28461
|
-
function
|
|
29698
|
+
function encodeToolChoice6(c) {
|
|
29699
|
+
switch (c.type) {
|
|
29700
|
+
case "auto":
|
|
29701
|
+
return "auto";
|
|
29702
|
+
case "any":
|
|
29703
|
+
return "required";
|
|
29704
|
+
case "none":
|
|
29705
|
+
return "none";
|
|
29706
|
+
case "tool":
|
|
29707
|
+
return { type: "function", name: c.name };
|
|
29708
|
+
}
|
|
29709
|
+
}
|
|
29710
|
+
function toMuseWire(req, model) {
|
|
29711
|
+
const degradations = [];
|
|
29712
|
+
const input2 = [];
|
|
29713
|
+
const note2 = (d) => {
|
|
29714
|
+
if (!degradations.includes(d))
|
|
29715
|
+
degradations.push(d);
|
|
29716
|
+
};
|
|
29717
|
+
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
29718
|
+
note2("muse:context-1m-dropped");
|
|
29719
|
+
for (const message of req.messages) {
|
|
29720
|
+
const parts = [];
|
|
29721
|
+
const asDeveloper = message.role === "system";
|
|
29722
|
+
if (asDeveloper)
|
|
29723
|
+
note2("muse:system-turn-as-developer");
|
|
29724
|
+
const role = asDeveloper ? "developer" : message.role;
|
|
29725
|
+
const flush = () => {
|
|
29726
|
+
if (parts.length === 0)
|
|
29727
|
+
return;
|
|
29728
|
+
input2.push({ type: "message", role, content: [...parts] });
|
|
29729
|
+
parts.length = 0;
|
|
29730
|
+
};
|
|
29731
|
+
for (const block of message.content) {
|
|
29732
|
+
switch (block.type) {
|
|
29733
|
+
case "text":
|
|
29734
|
+
parts.push({
|
|
29735
|
+
type: role === "assistant" ? "output_text" : "input_text",
|
|
29736
|
+
text: block.text
|
|
29737
|
+
});
|
|
29738
|
+
break;
|
|
29739
|
+
case "image":
|
|
29740
|
+
parts.push({
|
|
29741
|
+
type: "input_image",
|
|
29742
|
+
image_url: `data:${block.mediaType};base64,${block.data}`
|
|
29743
|
+
});
|
|
29744
|
+
break;
|
|
29745
|
+
case "thinking":
|
|
29746
|
+
note2("muse:thinking-dropped");
|
|
29747
|
+
break;
|
|
29748
|
+
case "toolUse":
|
|
29749
|
+
flush();
|
|
29750
|
+
input2.push({
|
|
29751
|
+
type: "function_call",
|
|
29752
|
+
call_id: block.id,
|
|
29753
|
+
name: block.name,
|
|
29754
|
+
arguments: JSON.stringify(block.input)
|
|
29755
|
+
});
|
|
29756
|
+
break;
|
|
29757
|
+
case "toolResult":
|
|
29758
|
+
flush();
|
|
29759
|
+
input2.push({
|
|
29760
|
+
type: "function_call_output",
|
|
29761
|
+
call_id: block.toolUseId,
|
|
29762
|
+
output: block.content
|
|
29763
|
+
});
|
|
29764
|
+
break;
|
|
29765
|
+
case "providerNative":
|
|
29766
|
+
if (block.provider === "muse") {
|
|
29767
|
+
flush();
|
|
29768
|
+
const { id: _id, ...rest } = block.data;
|
|
29769
|
+
input2.push({ type: block.blockType, ...rest });
|
|
29770
|
+
break;
|
|
29771
|
+
}
|
|
29772
|
+
note2("muse:foreign-native-block-dropped");
|
|
29773
|
+
break;
|
|
29774
|
+
}
|
|
29775
|
+
}
|
|
29776
|
+
flush();
|
|
29777
|
+
}
|
|
29778
|
+
repairOrphanedCalls(input2);
|
|
29779
|
+
const body = { model, input: input2, stream: req.stream, store: false };
|
|
29780
|
+
const instructions = systemText(req.system, "muse", note2);
|
|
29781
|
+
if (instructions !== undefined && instructions.length > 0)
|
|
29782
|
+
body.instructions = instructions;
|
|
29783
|
+
if (req.maxTokens !== undefined)
|
|
29784
|
+
body.max_output_tokens = req.maxTokens;
|
|
29785
|
+
if (req.temperature !== undefined)
|
|
29786
|
+
body.temperature = req.temperature;
|
|
29787
|
+
if (req.tools !== undefined) {
|
|
29788
|
+
const portable = req.tools.filter((t) => t.kind === "portable");
|
|
29789
|
+
if (portable.length !== req.tools.length)
|
|
29790
|
+
note2("muse:provider-tool-dropped");
|
|
29791
|
+
body.tools = portable.map((t) => ({
|
|
29792
|
+
type: "function",
|
|
29793
|
+
name: t.name,
|
|
29794
|
+
description: t.description,
|
|
29795
|
+
parameters: t.inputSchema
|
|
29796
|
+
}));
|
|
29797
|
+
}
|
|
29798
|
+
if (req.toolChoice !== undefined)
|
|
29799
|
+
body.tool_choice = encodeToolChoice6(req.toolChoice);
|
|
29800
|
+
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
29801
|
+
if (req.reasoning.mode === "budget") {
|
|
29802
|
+
note2("muse:reasoning-budget-dropped");
|
|
29803
|
+
} else {
|
|
29804
|
+
const effort = req.reasoning.effort ?? "medium";
|
|
29805
|
+
body.reasoning = { effort, summary: "auto" };
|
|
29806
|
+
}
|
|
29807
|
+
}
|
|
29808
|
+
const key = suppliedKey(req) ?? cacheKey(req, instructions ?? "", input2[0]);
|
|
29809
|
+
Object.assign(body, req.vendor?.openai ?? {});
|
|
29810
|
+
body.prompt_cache_key = key;
|
|
29811
|
+
return { body, degradations, cacheKey: key };
|
|
29812
|
+
}
|
|
29813
|
+
|
|
29814
|
+
// packages/providers/src/muse/codec.ts
|
|
29815
|
+
var museCodec = {
|
|
29816
|
+
buildRequest(input2) {
|
|
29817
|
+
const { body, degradations, cacheKey: cacheKey2 } = toMuseWire(input2.request, input2.model);
|
|
29818
|
+
if (input2.credentials.apiKey === null) {
|
|
29819
|
+
throw input2.fail("AUTH", "muse credential has no model api key");
|
|
29820
|
+
}
|
|
29821
|
+
const protocol = [
|
|
29822
|
+
["Content-Type", "application/json"],
|
|
29823
|
+
["Authorization", `Bearer ${input2.credentials.apiKey}`],
|
|
29824
|
+
["x-meta-ai-gateway-session-id", cacheKey2]
|
|
29825
|
+
];
|
|
29826
|
+
const headers = orderHeaders(mergeHeaders(museProfile.headers, protocol), museProfile.order);
|
|
29827
|
+
const include = body.include;
|
|
29828
|
+
const nativeReasoning = Array.isArray(include) && include.includes("reasoning.encrypted_content");
|
|
29829
|
+
return {
|
|
29830
|
+
decodeState: { nativeReasoning },
|
|
29831
|
+
request: {
|
|
29832
|
+
url: museResponsesUrl(input2.credentials.providerData),
|
|
29833
|
+
method: "POST",
|
|
29834
|
+
headers,
|
|
29835
|
+
body: JSON.stringify(orderFields({ ...body, stream: true }, museBodyOrder))
|
|
29836
|
+
},
|
|
29837
|
+
degradations
|
|
29838
|
+
};
|
|
29839
|
+
},
|
|
29840
|
+
decode({ body, decodeState }) {
|
|
29841
|
+
const state = decodeState;
|
|
29842
|
+
return decodeMuseResponses(parseSse(body), {
|
|
29843
|
+
nativeReasoning: state?.nativeReasoning === true
|
|
29844
|
+
});
|
|
29845
|
+
}
|
|
29846
|
+
};
|
|
29847
|
+
|
|
29848
|
+
// packages/providers/src/muse/index.ts
|
|
29849
|
+
var museAdapter = codecAdapter("muse", museDescriptor.capabilities, museCodec);
|
|
29850
|
+
// packages/providers/src/openai/decode.ts
|
|
29851
|
+
var ERROR_CODE4 = {
|
|
29852
|
+
rate_limit_exceeded: "RATE_LIMIT",
|
|
29853
|
+
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
29854
|
+
invalid_api_key: "AUTH",
|
|
29855
|
+
server_error: "UPSTREAM",
|
|
29856
|
+
context_length_exceeded: "BAD_REQUEST",
|
|
29857
|
+
content_policy_violation: "CONTENT_FILTER"
|
|
29858
|
+
};
|
|
29859
|
+
var KNOWN_EVENTS4 = new Set([
|
|
29860
|
+
"keepalive",
|
|
29861
|
+
"response.created",
|
|
29862
|
+
"response.queued",
|
|
29863
|
+
"response.in_progress",
|
|
29864
|
+
"response.output_item.added",
|
|
29865
|
+
"response.output_item.done",
|
|
29866
|
+
"response.content_part.added",
|
|
29867
|
+
"response.content_part.done",
|
|
29868
|
+
"response.output_text.delta",
|
|
29869
|
+
"response.output_text.done",
|
|
29870
|
+
"response.output_text.annotation.added",
|
|
29871
|
+
"response.refusal.delta",
|
|
29872
|
+
"response.refusal.done",
|
|
29873
|
+
"response.reasoning_summary_part.added",
|
|
29874
|
+
"response.reasoning_summary_part.done",
|
|
29875
|
+
"response.reasoning_summary_text.delta",
|
|
29876
|
+
"response.reasoning_summary_text.done",
|
|
29877
|
+
"response.reasoning_text.delta",
|
|
29878
|
+
"response.reasoning_text.done",
|
|
29879
|
+
"response.function_call_arguments.delta",
|
|
29880
|
+
"response.function_call_arguments.done",
|
|
29881
|
+
"response.completed",
|
|
29882
|
+
"response.incomplete",
|
|
29883
|
+
"response.failed",
|
|
29884
|
+
"error"
|
|
29885
|
+
]);
|
|
29886
|
+
function json9(data) {
|
|
29887
|
+
try {
|
|
29888
|
+
const v = JSON.parse(data);
|
|
29889
|
+
return typeof v === "object" && v !== null ? v : null;
|
|
29890
|
+
} catch {
|
|
29891
|
+
return null;
|
|
29892
|
+
}
|
|
29893
|
+
}
|
|
29894
|
+
async function* decodeResponses(messages, options = {}) {
|
|
29895
|
+
const nativeReasoning = options.nativeReasoning === true;
|
|
29896
|
+
const indices = new Map;
|
|
29897
|
+
let next = 0;
|
|
29898
|
+
const irIndex = (outputIndex, contentIndex = 0) => {
|
|
29899
|
+
const key = `${outputIndex}:${contentIndex}`;
|
|
29900
|
+
const existing = indices.get(key);
|
|
29901
|
+
if (existing !== undefined)
|
|
29902
|
+
return existing;
|
|
29903
|
+
const assigned = next++;
|
|
29904
|
+
indices.set(key, assigned);
|
|
29905
|
+
return assigned;
|
|
29906
|
+
};
|
|
29907
|
+
let sawToolCall = false;
|
|
29908
|
+
let terminal = false;
|
|
29909
|
+
const ownsBlock = new Set;
|
|
29910
|
+
for await (const msg of messages) {
|
|
29911
|
+
if (msg.data === "[DONE]")
|
|
29912
|
+
continue;
|
|
29913
|
+
if (!KNOWN_EVENTS4.has(msg.event)) {
|
|
29914
|
+
yield {
|
|
29915
|
+
type: "error",
|
|
29916
|
+
code: "UPSTREAM",
|
|
29917
|
+
message: `unrecognized OpenAI stream event "${msg.event}"`,
|
|
29918
|
+
retryable: false
|
|
29919
|
+
};
|
|
29920
|
+
return;
|
|
29921
|
+
}
|
|
29922
|
+
const d = json9(msg.data);
|
|
29923
|
+
if (d === null)
|
|
29924
|
+
continue;
|
|
29925
|
+
switch (msg.event) {
|
|
29926
|
+
case "response.created":
|
|
29927
|
+
yield {
|
|
29928
|
+
type: "start",
|
|
29929
|
+
id: String(d.response?.id ?? ""),
|
|
29930
|
+
model: String(d.response?.model ?? "")
|
|
29931
|
+
};
|
|
29932
|
+
break;
|
|
29933
|
+
case "response.output_item.added": {
|
|
29934
|
+
const item = d.item ?? {};
|
|
29935
|
+
if (item.type === "reasoning") {
|
|
29936
|
+
ownsBlock.add(d.output_index ?? 0);
|
|
29937
|
+
yield {
|
|
29938
|
+
type: "blockStart",
|
|
29939
|
+
index: irIndex(d.output_index ?? 0),
|
|
29940
|
+
block: nativeReasoning ? { type: "providerNative", provider: "openai", blockType: "reasoning", data: {} } : { type: "thinking" }
|
|
29941
|
+
};
|
|
29942
|
+
} else if (item.type === "function_call") {
|
|
29943
|
+
sawToolCall = true;
|
|
29944
|
+
ownsBlock.add(d.output_index ?? 0);
|
|
29945
|
+
yield {
|
|
29946
|
+
type: "blockStart",
|
|
29947
|
+
index: irIndex(d.output_index ?? 0),
|
|
29948
|
+
block: { type: "toolUse", id: String(item.call_id), name: String(item.name) }
|
|
29949
|
+
};
|
|
29950
|
+
}
|
|
29951
|
+
break;
|
|
29952
|
+
}
|
|
29953
|
+
case "response.content_part.added":
|
|
29954
|
+
if (d.part?.type === "output_text") {
|
|
29955
|
+
yield {
|
|
29956
|
+
type: "blockStart",
|
|
29957
|
+
index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
|
|
29958
|
+
block: { type: "text" }
|
|
29959
|
+
};
|
|
29960
|
+
}
|
|
29961
|
+
break;
|
|
29962
|
+
case "response.output_text.delta":
|
|
29963
|
+
yield {
|
|
29964
|
+
type: "blockDelta",
|
|
29965
|
+
index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
|
|
29966
|
+
delta: { type: "text", text: String(d.delta ?? "") }
|
|
29967
|
+
};
|
|
29968
|
+
break;
|
|
29969
|
+
case "response.reasoning_summary_text.delta":
|
|
29970
|
+
yield {
|
|
29971
|
+
type: "blockDelta",
|
|
29972
|
+
index: irIndex(d.output_index ?? 0),
|
|
29973
|
+
delta: nativeReasoning ? {
|
|
29974
|
+
type: "providerNative",
|
|
29975
|
+
provider: "openai",
|
|
29976
|
+
deltaType: "reasoning_summary_text.delta",
|
|
29977
|
+
data: { text: String(d.delta ?? "") }
|
|
29978
|
+
} : { type: "thinking", text: String(d.delta ?? "") }
|
|
29979
|
+
};
|
|
29980
|
+
break;
|
|
29981
|
+
case "response.function_call_arguments.delta":
|
|
29982
|
+
yield {
|
|
29983
|
+
type: "blockDelta",
|
|
29984
|
+
index: irIndex(d.output_index ?? 0),
|
|
29985
|
+
delta: { type: "toolJson", partial: String(d.delta ?? "") }
|
|
29986
|
+
};
|
|
29987
|
+
break;
|
|
29988
|
+
case "response.content_part.done":
|
|
29989
|
+
yield { type: "blockEnd", index: irIndex(d.output_index ?? 0, d.content_index ?? 0) };
|
|
29990
|
+
break;
|
|
29991
|
+
case "response.output_item.done": {
|
|
29992
|
+
const outputIndex = d.output_index ?? 0;
|
|
29993
|
+
if (ownsBlock.delete(outputIndex)) {
|
|
29994
|
+
const item = d.item ?? {};
|
|
29995
|
+
if (nativeReasoning && item.type === "reasoning") {
|
|
29996
|
+
yield {
|
|
29997
|
+
type: "blockDelta",
|
|
29998
|
+
index: irIndex(outputIndex),
|
|
29999
|
+
delta: {
|
|
30000
|
+
type: "providerNative",
|
|
30001
|
+
provider: "openai",
|
|
30002
|
+
deltaType: "response.output_item.done",
|
|
30003
|
+
fold: "merge",
|
|
30004
|
+
data: item
|
|
30005
|
+
}
|
|
30006
|
+
};
|
|
30007
|
+
}
|
|
30008
|
+
yield { type: "blockEnd", index: irIndex(outputIndex) };
|
|
30009
|
+
}
|
|
30010
|
+
break;
|
|
30011
|
+
}
|
|
30012
|
+
case "response.completed":
|
|
30013
|
+
case "response.incomplete": {
|
|
30014
|
+
terminal = true;
|
|
30015
|
+
const r = d.response ?? {};
|
|
30016
|
+
const reason = r.incomplete_details?.reason;
|
|
30017
|
+
let stopReason = sawToolCall ? "toolUse" : "endTurn";
|
|
30018
|
+
if (reason === "max_output_tokens")
|
|
30019
|
+
stopReason = "maxTokens";
|
|
30020
|
+
else if (reason === "content_filter")
|
|
30021
|
+
stopReason = "contentFilter";
|
|
30022
|
+
else if (reason !== undefined || msg.event === "response.incomplete" || r.status !== undefined && r.status !== "completed") {
|
|
30023
|
+
yield {
|
|
30024
|
+
type: "error",
|
|
30025
|
+
code: "UPSTREAM",
|
|
30026
|
+
message: reason !== undefined ? `unrecognized OpenAI incomplete reason "${String(reason)}"` : r.status !== undefined && r.status !== "incomplete" ? `OpenAI reported terminal response status "${String(r.status)}"` : "OpenAI reported the response incomplete without a reason",
|
|
30027
|
+
retryable: false
|
|
30028
|
+
};
|
|
30029
|
+
break;
|
|
30030
|
+
}
|
|
30031
|
+
yield {
|
|
30032
|
+
type: "end",
|
|
30033
|
+
stopReason,
|
|
30034
|
+
usage: usageFromPromptTotal(r.usage?.input_tokens ?? 0, r.usage?.output_tokens ?? 0, r.usage?.input_tokens_details?.cached_tokens ?? r.usage?.prompt_tokens_details?.cached_tokens ?? 0)
|
|
30035
|
+
};
|
|
30036
|
+
break;
|
|
30037
|
+
}
|
|
30038
|
+
case "response.failed":
|
|
30039
|
+
case "error": {
|
|
30040
|
+
terminal = true;
|
|
30041
|
+
const err = d.response?.error ?? d.error ?? {};
|
|
30042
|
+
const raw = String(err.code ?? err.type);
|
|
30043
|
+
const code = (Object.hasOwn(ERROR_CODE4, raw) ? ERROR_CODE4[raw] : undefined) ?? "UPSTREAM";
|
|
30044
|
+
yield {
|
|
30045
|
+
type: "error",
|
|
30046
|
+
code,
|
|
30047
|
+
message: String(err.message ?? "upstream error"),
|
|
30048
|
+
retryable: RETRYABLE[code]
|
|
30049
|
+
};
|
|
30050
|
+
break;
|
|
30051
|
+
}
|
|
30052
|
+
default:
|
|
30053
|
+
break;
|
|
30054
|
+
}
|
|
30055
|
+
}
|
|
30056
|
+
if (!terminal) {
|
|
30057
|
+
yield {
|
|
30058
|
+
type: "error",
|
|
30059
|
+
code: "UPSTREAM",
|
|
30060
|
+
message: "upstream stream ended before response completion",
|
|
30061
|
+
retryable: RETRYABLE.UPSTREAM
|
|
30062
|
+
};
|
|
30063
|
+
}
|
|
30064
|
+
}
|
|
30065
|
+
|
|
30066
|
+
// packages/providers/src/openai/wire.ts
|
|
30067
|
+
import { createHash as createHash6 } from "crypto";
|
|
30068
|
+
function suppliedKey2(req) {
|
|
30069
|
+
const vendor = req.vendor?.openai;
|
|
30070
|
+
for (const name of ["prompt_cache_key", "session_id"]) {
|
|
30071
|
+
const value = vendor?.[name];
|
|
30072
|
+
if (typeof value === "string" && value.length > 0)
|
|
30073
|
+
return value;
|
|
30074
|
+
}
|
|
30075
|
+
return;
|
|
30076
|
+
}
|
|
30077
|
+
function cacheKey2(req, instructions, firstInput) {
|
|
30078
|
+
const stable = req.conversationId !== undefined && req.conversationId.length > 0 ? JSON.stringify({ conversation: req.conversationId }) : JSON.stringify({ instructions, firstInput: firstInput ?? null });
|
|
30079
|
+
return createHash6("sha256").update(stable).digest("hex").slice(0, 32);
|
|
30080
|
+
}
|
|
30081
|
+
function repairOrphanedCalls2(input2) {
|
|
30082
|
+
const answered = new Set;
|
|
30083
|
+
for (const item of input2) {
|
|
30084
|
+
const record2 = item;
|
|
30085
|
+
if (record2.type === "function_call_output" && typeof record2.call_id === "string") {
|
|
30086
|
+
answered.add(record2.call_id);
|
|
30087
|
+
}
|
|
30088
|
+
}
|
|
30089
|
+
for (let i = input2.length - 1;i >= 0; i--) {
|
|
30090
|
+
const record2 = input2[i];
|
|
30091
|
+
if (record2.type !== "function_call" || typeof record2.call_id !== "string")
|
|
30092
|
+
continue;
|
|
30093
|
+
if (answered.has(record2.call_id))
|
|
30094
|
+
continue;
|
|
30095
|
+
input2.splice(i + 1, 0, { type: "function_call_output", call_id: record2.call_id, output: "" });
|
|
30096
|
+
}
|
|
30097
|
+
}
|
|
30098
|
+
function encodeToolChoice7(c) {
|
|
28462
30099
|
switch (c.type) {
|
|
28463
30100
|
case "auto":
|
|
28464
30101
|
return "auto";
|
|
@@ -28540,7 +30177,7 @@ function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
|
28540
30177
|
}
|
|
28541
30178
|
flush();
|
|
28542
30179
|
}
|
|
28543
|
-
|
|
30180
|
+
repairOrphanedCalls2(input2);
|
|
28544
30181
|
const body = { model, input: input2, stream: req.stream, store: false };
|
|
28545
30182
|
const instructions = systemText(req.system, "openai", note2);
|
|
28546
30183
|
if (instructions !== undefined && instructions.length > 0)
|
|
@@ -28569,7 +30206,7 @@ function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
|
28569
30206
|
}));
|
|
28570
30207
|
}
|
|
28571
30208
|
if (req.toolChoice !== undefined)
|
|
28572
|
-
body.tool_choice =
|
|
30209
|
+
body.tool_choice = encodeToolChoice7(req.toolChoice);
|
|
28573
30210
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
28574
30211
|
if (req.reasoning.mode === "budget") {
|
|
28575
30212
|
degradations.push("openai:reasoning-budget-dropped");
|
|
@@ -28578,7 +30215,7 @@ function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
|
28578
30215
|
body.reasoning = { effort, summary: "auto" };
|
|
28579
30216
|
}
|
|
28580
30217
|
}
|
|
28581
|
-
const key =
|
|
30218
|
+
const key = suppliedKey2(req) ?? cacheKey2(req, instructions ?? "", input2[0]);
|
|
28582
30219
|
Object.assign(body, req.vendor?.openai ?? {});
|
|
28583
30220
|
body.prompt_cache_key = key;
|
|
28584
30221
|
return { body, degradations, cacheKey: key };
|
|
@@ -28590,14 +30227,14 @@ var API_URL3 = "https://api.openai.com/v1/responses";
|
|
|
28590
30227
|
var openaiCodec = {
|
|
28591
30228
|
buildRequest(input2) {
|
|
28592
30229
|
const oauth = input2.credentials.accessToken !== null;
|
|
28593
|
-
const { body, degradations, cacheKey:
|
|
30230
|
+
const { body, degradations, cacheKey: cacheKey3 } = toResponsesWire(input2.request, input2.model, { oauth });
|
|
28594
30231
|
const protocol = [["Content-Type", "application/json"]];
|
|
28595
30232
|
if (oauth) {
|
|
28596
30233
|
protocol.push(["Authorization", `Bearer ${input2.credentials.accessToken}`]);
|
|
28597
30234
|
const accountId = input2.credentials.providerData.accountId;
|
|
28598
30235
|
if (typeof accountId === "string")
|
|
28599
30236
|
protocol.push(["chatgpt-account-id", accountId]);
|
|
28600
|
-
protocol.push(["session_id",
|
|
30237
|
+
protocol.push(["session_id", cacheKey3]);
|
|
28601
30238
|
} else if (input2.credentials.apiKey !== null) {
|
|
28602
30239
|
protocol.push(["Authorization", `Bearer ${input2.credentials.apiKey}`]);
|
|
28603
30240
|
} else {
|
|
@@ -28632,6 +30269,8 @@ var ADAPTERS = {
|
|
|
28632
30269
|
kimi: kimiAdapter,
|
|
28633
30270
|
kilo: kiloAdapter,
|
|
28634
30271
|
grok: grokAdapter,
|
|
30272
|
+
antigravity: antigravityAdapter,
|
|
30273
|
+
muse: museAdapter,
|
|
28635
30274
|
custom: customAdapter
|
|
28636
30275
|
};
|
|
28637
30276
|
Object.setPrototypeOf(ADAPTERS, null);
|
|
@@ -30138,7 +31777,7 @@ import { basename as basename2, join as join3, resolve as resolve2, sep as sep2
|
|
|
30138
31777
|
|
|
30139
31778
|
// packages/plugin-api/src/version.ts
|
|
30140
31779
|
var PLUGIN_API_VERSION = 3;
|
|
30141
|
-
var DASHBOARD_SDK_VERSION = "0.1.
|
|
31780
|
+
var DASHBOARD_SDK_VERSION = "0.1.8";
|
|
30142
31781
|
// packages/plugin-api/src/manifest.ts
|
|
30143
31782
|
var CAPABILITIES = [
|
|
30144
31783
|
"storage",
|
|
@@ -31217,7 +32856,7 @@ function createRefresher(deps) {
|
|
|
31217
32856
|
}
|
|
31218
32857
|
// packages/control/src/pluginProviders.ts
|
|
31219
32858
|
import { join as join5 } from "path";
|
|
31220
|
-
function
|
|
32859
|
+
function isRecord7(value) {
|
|
31221
32860
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31222
32861
|
}
|
|
31223
32862
|
function isNumber(value) {
|
|
@@ -31228,7 +32867,7 @@ function checkAt(ok, id, path, expected) {
|
|
|
31228
32867
|
throw new Error(`provider ${id} descriptor: ${path} must be ${expected}`);
|
|
31229
32868
|
}
|
|
31230
32869
|
function checkLimits(id, path, value) {
|
|
31231
|
-
checkAt(
|
|
32870
|
+
checkAt(isRecord7(value), id, path, "an object");
|
|
31232
32871
|
const limits = value;
|
|
31233
32872
|
checkAt(isNumber(limits.contextWindow), id, `${path}.contextWindow`, "a finite number");
|
|
31234
32873
|
checkAt(isNumber(limits.maxOutputTokens), id, `${path}.maxOutputTokens`, "a finite number");
|
|
@@ -31246,19 +32885,19 @@ function checkDescriptor(id, record2) {
|
|
|
31246
32885
|
}
|
|
31247
32886
|
}
|
|
31248
32887
|
const capabilities2 = record2.capabilities;
|
|
31249
|
-
checkAt(
|
|
32888
|
+
checkAt(isRecord7(capabilities2), id, "capabilities", "an object");
|
|
31250
32889
|
for (const flag of ["tools", "images", "reasoning"]) {
|
|
31251
32890
|
const value = capabilities2[flag];
|
|
31252
32891
|
checkAt(typeof value === "boolean", id, `capabilities.${flag}`, "a boolean");
|
|
31253
32892
|
}
|
|
31254
32893
|
const write = record2.writeOverInput;
|
|
31255
|
-
checkAt(
|
|
32894
|
+
checkAt(isRecord7(write), id, "writeOverInput", "an object");
|
|
31256
32895
|
for (const ttl of ["fiveMinute", "oneHour"]) {
|
|
31257
32896
|
const value = write[ttl];
|
|
31258
32897
|
checkAt(isNumber(value), id, `writeOverInput.${ttl}`, "a finite number");
|
|
31259
32898
|
}
|
|
31260
32899
|
const catalog2 = record2.catalog;
|
|
31261
|
-
checkAt(
|
|
32900
|
+
checkAt(isRecord7(catalog2), id, "catalog", "an object");
|
|
31262
32901
|
const entry = catalog2;
|
|
31263
32902
|
checkAt(typeof entry.defaultModel === "string", id, "catalog.defaultModel", "a string");
|
|
31264
32903
|
checkAt(Array.isArray(entry.authTypes), id, "catalog.authTypes", "an array");
|
|
@@ -31269,11 +32908,11 @@ function checkDescriptor(id, record2) {
|
|
|
31269
32908
|
checkAt(Array.isArray(entry.models), id, "catalog.models", "an array");
|
|
31270
32909
|
for (const [index, model] of entry.models.entries()) {
|
|
31271
32910
|
const at = `catalog.models[${index}]`;
|
|
31272
|
-
checkAt(
|
|
32911
|
+
checkAt(isRecord7(model), id, at, "an object");
|
|
31273
32912
|
const choice = model;
|
|
31274
32913
|
checkAt(typeof choice.id === "string", id, `${at}.id`, "a string");
|
|
31275
32914
|
checkAt(typeof choice.label === "string", id, `${at}.label`, "a string");
|
|
31276
|
-
checkAt(
|
|
32915
|
+
checkAt(isRecord7(choice.pricing), id, `${at}.pricing`, "an object");
|
|
31277
32916
|
const pricing = choice.pricing;
|
|
31278
32917
|
for (const field of ["input", "output", "cacheRead", "cacheWrite5m", "cacheWrite1h"]) {
|
|
31279
32918
|
checkAt(isNumber(pricing[field]), id, `${at}.pricing.${field}`, "a finite number");
|
|
@@ -31289,13 +32928,13 @@ function checkDescriptor(id, record2) {
|
|
|
31289
32928
|
checkAt(typeof prefix === "string", id, `modelPrefixes[${index}]`, "a string");
|
|
31290
32929
|
}
|
|
31291
32930
|
const presentation = record2.presentation;
|
|
31292
|
-
checkAt(
|
|
32931
|
+
checkAt(isRecord7(presentation), id, "presentation", "an object");
|
|
31293
32932
|
const shown = presentation;
|
|
31294
32933
|
for (const field of ["label", "tone"]) {
|
|
31295
32934
|
checkAt(typeof shown[field] === "string", id, `presentation.${field}`, "a string");
|
|
31296
32935
|
}
|
|
31297
32936
|
checkAt(isNumber(shown.order), id, "presentation.order", "a finite number");
|
|
31298
|
-
checkAt(
|
|
32937
|
+
checkAt(isRecord7(shown.colour), id, "presentation.colour", "an object");
|
|
31299
32938
|
for (const scheme of ["light", "dark"]) {
|
|
31300
32939
|
const value = shown.colour[scheme];
|
|
31301
32940
|
checkAt(typeof value === "string", id, `presentation.colour.${scheme}`, "a string");
|
|
@@ -31307,7 +32946,7 @@ function checkDescriptor(id, record2) {
|
|
|
31307
32946
|
function validateOAuthFlow(id, value) {
|
|
31308
32947
|
if (value === undefined)
|
|
31309
32948
|
return;
|
|
31310
|
-
if (!
|
|
32949
|
+
if (!isRecord7(value))
|
|
31311
32950
|
throw new Error(`provider ${id} oauth must be an object`);
|
|
31312
32951
|
const kind = value.kind;
|
|
31313
32952
|
if (kind !== "pkce" && kind !== "device") {
|
|
@@ -31787,7 +33426,9 @@ var TONES = {
|
|
|
31787
33426
|
blue: true,
|
|
31788
33427
|
magenta: true,
|
|
31789
33428
|
cyan: true,
|
|
31790
|
-
orange: true
|
|
33429
|
+
orange: true,
|
|
33430
|
+
violet: true,
|
|
33431
|
+
azure: true
|
|
31791
33432
|
};
|
|
31792
33433
|
function isTone(name) {
|
|
31793
33434
|
return Object.hasOwn(TONES, name);
|
|
@@ -32828,7 +34469,7 @@ var dbMigrate = {
|
|
|
32828
34469
|
emit(ctx, writer, { target: redact(to), ...report }, () => [
|
|
32829
34470
|
fields([
|
|
32830
34471
|
["target", redact(to)],
|
|
32831
|
-
...Object.entries(report.counts).map(([table2,
|
|
34472
|
+
...Object.entries(report.counts).map(([table2, count2]) => [table2, String(count2)])
|
|
32832
34473
|
]),
|
|
32833
34474
|
"",
|
|
32834
34475
|
"not carried:",
|
|
@@ -32999,7 +34640,7 @@ var dbRestore = {
|
|
|
32999
34640
|
emit(ctx, writer, result, () => fields([
|
|
33000
34641
|
["restored", id],
|
|
33001
34642
|
["undo", result.preRestoreSnapshot.id],
|
|
33002
|
-
...Object.entries(result.counts).map(([table2,
|
|
34643
|
+
...Object.entries(result.counts).map(([table2, count2]) => [table2, String(count2)])
|
|
33003
34644
|
]));
|
|
33004
34645
|
}
|
|
33005
34646
|
};
|
|
@@ -33734,7 +35375,7 @@ function createServiceDeps(input2) {
|
|
|
33734
35375
|
}
|
|
33735
35376
|
|
|
33736
35377
|
// apps/cli/src/version.ts
|
|
33737
|
-
var VERSION = "0.
|
|
35378
|
+
var VERSION = "0.10.0";
|
|
33738
35379
|
|
|
33739
35380
|
// apps/cli/src/commands/service.ts
|
|
33740
35381
|
function gatewayArgv(root) {
|