omnigateway 0.9.2 → 0.10.1
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 +2118 -113
- package/gateway.js +2197 -196
- 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,145 @@ 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 NO_CACHE_WRITE = { cacheWrite5m: 0, cacheWrite1h: 0 };
|
|
23534
|
+
var FREE = { input: 0, output: 0, cacheRead: 0, ...NO_CACHE_WRITE };
|
|
23535
|
+
var FLASH_LIMITS = { contextWindow: 1048576, maxOutputTokens: MAX_OUTPUT_TOKENS };
|
|
23536
|
+
var PRO_LIMITS = { contextWindow: 1048576, maxOutputTokens: PRO_MAX_OUTPUT_TOKENS };
|
|
23537
|
+
var ANTIGRAVITY_MODELS = {
|
|
23538
|
+
defaultModel: "gemini-3.8-flash-high",
|
|
23539
|
+
authTypes: ["oauth"],
|
|
23540
|
+
models: [
|
|
23541
|
+
{
|
|
23542
|
+
id: "gemini-3.8-flash-high",
|
|
23543
|
+
label: "Gemini 3.8 Flash (High)",
|
|
23544
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23545
|
+
limits: FLASH_LIMITS
|
|
23546
|
+
},
|
|
23547
|
+
{
|
|
23548
|
+
id: "gemini-3.8-flash-medium",
|
|
23549
|
+
label: "Gemini 3.8 Flash (Medium)",
|
|
23550
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23551
|
+
limits: FLASH_LIMITS
|
|
23552
|
+
},
|
|
23553
|
+
{
|
|
23554
|
+
id: "gemini-3.8-flash-low",
|
|
23555
|
+
label: "Gemini 3.8 Flash (Low)",
|
|
23556
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23557
|
+
limits: FLASH_LIMITS
|
|
23558
|
+
},
|
|
23559
|
+
{
|
|
23560
|
+
id: "gemini-3.7-flash-high",
|
|
23561
|
+
label: "Gemini 3.7 Flash (High)",
|
|
23562
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23563
|
+
limits: FLASH_LIMITS
|
|
23564
|
+
},
|
|
23565
|
+
{
|
|
23566
|
+
id: "gemini-3.7-flash-medium",
|
|
23567
|
+
label: "Gemini 3.7 Flash (Medium)",
|
|
23568
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23569
|
+
limits: FLASH_LIMITS
|
|
23570
|
+
},
|
|
23571
|
+
{
|
|
23572
|
+
id: "gemini-3.7-flash-low",
|
|
23573
|
+
label: "Gemini 3.7 Flash (Low)",
|
|
23574
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23575
|
+
limits: FLASH_LIMITS
|
|
23576
|
+
},
|
|
23577
|
+
{
|
|
23578
|
+
id: "gemini-3.6-flash-high",
|
|
23579
|
+
label: "Gemini 3.6 Flash (High)",
|
|
23580
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23581
|
+
limits: FLASH_LIMITS
|
|
23582
|
+
},
|
|
23583
|
+
{
|
|
23584
|
+
id: "gemini-3.6-flash-medium",
|
|
23585
|
+
label: "Gemini 3.6 Flash (Medium)",
|
|
23586
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23587
|
+
limits: FLASH_LIMITS
|
|
23588
|
+
},
|
|
23589
|
+
{
|
|
23590
|
+
id: "gemini-3.6-flash-low",
|
|
23591
|
+
label: "Gemini 3.6 Flash (Low)",
|
|
23592
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23593
|
+
limits: FLASH_LIMITS
|
|
23594
|
+
},
|
|
23595
|
+
{
|
|
23596
|
+
id: "gemini-3-flash-agent",
|
|
23597
|
+
label: "Gemini 3.5 Flash (High)",
|
|
23598
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23599
|
+
limits: FLASH_LIMITS
|
|
23600
|
+
},
|
|
23601
|
+
{
|
|
23602
|
+
id: "gemini-3.5-flash-low",
|
|
23603
|
+
label: "Gemini 3.5 Flash (Medium)",
|
|
23604
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23605
|
+
limits: FLASH_LIMITS
|
|
23606
|
+
},
|
|
23607
|
+
{
|
|
23608
|
+
id: "gemini-3.5-flash-extra-low",
|
|
23609
|
+
label: "Gemini 3.5 Flash (Low)",
|
|
23610
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23611
|
+
limits: FLASH_LIMITS
|
|
23612
|
+
},
|
|
23613
|
+
{
|
|
23614
|
+
id: "gemini-3-flash",
|
|
23615
|
+
label: "Gemini 3 Flash",
|
|
23616
|
+
pricing: FREE,
|
|
23617
|
+
limits: FLASH_LIMITS
|
|
23618
|
+
},
|
|
23619
|
+
{
|
|
23620
|
+
id: "gemini-3.5-flash-lite",
|
|
23621
|
+
label: "Gemini 3.5 Flash Lite",
|
|
23622
|
+
pricing: { input: 0.3, output: 2.5, cacheRead: 0.03, ...NO_CACHE_WRITE },
|
|
23623
|
+
limits: PRO_LIMITS
|
|
23624
|
+
},
|
|
23625
|
+
{
|
|
23626
|
+
id: "gemini-pro-agent",
|
|
23627
|
+
label: "Gemini 3.1 Pro (High)",
|
|
23628
|
+
pricing: { input: 2, output: 12, cacheRead: 0.2, ...NO_CACHE_WRITE },
|
|
23629
|
+
limits: PRO_LIMITS
|
|
23630
|
+
},
|
|
23631
|
+
{
|
|
23632
|
+
id: "gemini-3.1-pro-low",
|
|
23633
|
+
label: "Gemini 3.1 Pro (Low)",
|
|
23634
|
+
pricing: { input: 2, output: 12, cacheRead: 0.2, ...NO_CACHE_WRITE },
|
|
23635
|
+
limits: PRO_LIMITS
|
|
23636
|
+
},
|
|
23637
|
+
{
|
|
23638
|
+
id: "gemini-3.1-flash-lite",
|
|
23639
|
+
label: "Gemini 3.1 Flash Lite",
|
|
23640
|
+
pricing: { input: 0.25, output: 1.5, cacheRead: 0.025, ...NO_CACHE_WRITE },
|
|
23641
|
+
limits: PRO_LIMITS
|
|
23642
|
+
},
|
|
23643
|
+
{
|
|
23644
|
+
id: "gemini-2.5-pro",
|
|
23645
|
+
label: "Gemini 2.5 Pro",
|
|
23646
|
+
pricing: { input: 1.25, output: 10, cacheRead: 0.125, ...NO_CACHE_WRITE },
|
|
23647
|
+
limits: PRO_LIMITS
|
|
23648
|
+
}
|
|
23649
|
+
]
|
|
23650
|
+
};
|
|
23651
|
+
|
|
23652
|
+
// packages/providers/src/antigravity/descriptor.ts
|
|
23653
|
+
var antigravityDescriptor = {
|
|
23654
|
+
id: "antigravity",
|
|
23655
|
+
capabilities: { tools: true, images: true, reasoning: true },
|
|
23656
|
+
writeOverInput: { fiveMinute: 0, oneHour: 0 },
|
|
23657
|
+
catalog: ANTIGRAVITY_MODELS,
|
|
23658
|
+
modelPrefixes: ["gemini-"],
|
|
23659
|
+
callback: { uri: "http://127.0.0.1:51121/callback", label: "Antigravity" },
|
|
23660
|
+
presentation: {
|
|
23661
|
+
label: "Antigravity",
|
|
23662
|
+
order: 6,
|
|
23663
|
+
tone: "violet",
|
|
23664
|
+
colour: { light: "oklch(0.52 0.14 277)", dark: "oklch(0.74 0.14 277)" },
|
|
23665
|
+
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."
|
|
23666
|
+
}
|
|
23667
|
+
};
|
|
23668
|
+
|
|
23522
23669
|
// packages/providers/src/custom/models.ts
|
|
23523
23670
|
var CUSTOM_MODELS = {
|
|
23524
23671
|
defaultModel: "",
|
|
@@ -23535,7 +23682,7 @@ var customDescriptor = {
|
|
|
23535
23682
|
modelPrefixes: [],
|
|
23536
23683
|
presentation: {
|
|
23537
23684
|
label: "OpenAI Compatible",
|
|
23538
|
-
order:
|
|
23685
|
+
order: 8,
|
|
23539
23686
|
tone: "cyan",
|
|
23540
23687
|
colour: { light: "oklch(0.5 0.03 258)", dark: "oklch(0.72 0.03 258)" },
|
|
23541
23688
|
pasteHint: "Enter endpoint metadata and API key."
|
|
@@ -23860,35 +24007,90 @@ var kimiDescriptor = {
|
|
|
23860
24007
|
}
|
|
23861
24008
|
};
|
|
23862
24009
|
|
|
24010
|
+
// packages/providers/src/muse/models.ts
|
|
24011
|
+
var MUSE_MODELS = {
|
|
24012
|
+
defaultModel: "muse-spark-1.3",
|
|
24013
|
+
authTypes: ["oauth", "apiKey"],
|
|
24014
|
+
models: [
|
|
24015
|
+
{
|
|
24016
|
+
id: "muse-spark-1.3",
|
|
24017
|
+
label: "Muse Spark 1.3",
|
|
24018
|
+
pricing: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24019
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24020
|
+
},
|
|
24021
|
+
{
|
|
24022
|
+
id: "muse-spark-1.3-contributor",
|
|
24023
|
+
label: "Muse Spark 1.3 \u2014 Meta trains on this traffic",
|
|
24024
|
+
pricing: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24025
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24026
|
+
},
|
|
24027
|
+
{
|
|
24028
|
+
id: "muse-spark-1.2",
|
|
24029
|
+
label: "Muse Spark 1.2",
|
|
24030
|
+
pricing: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24031
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24032
|
+
},
|
|
24033
|
+
{
|
|
24034
|
+
id: "muse-spark-1.2-contributor",
|
|
24035
|
+
label: "Muse Spark 1.2 \u2014 Meta trains on this traffic",
|
|
24036
|
+
pricing: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24037
|
+
limits: { contextWindow: 1048576, maxOutputTokens: 943718 }
|
|
24038
|
+
}
|
|
24039
|
+
]
|
|
24040
|
+
};
|
|
24041
|
+
|
|
24042
|
+
// packages/providers/src/muse/descriptor.ts
|
|
24043
|
+
var museDescriptor = {
|
|
24044
|
+
id: "muse",
|
|
24045
|
+
capabilities: { tools: true, images: true, reasoning: true },
|
|
24046
|
+
writeOverInput: { fiveMinute: 0, oneHour: 0 },
|
|
24047
|
+
catalog: MUSE_MODELS,
|
|
24048
|
+
modelPrefixes: ["muse-", "muse-spark"],
|
|
24049
|
+
presentation: {
|
|
24050
|
+
label: "Muse",
|
|
24051
|
+
order: 7,
|
|
24052
|
+
tone: "azure",
|
|
24053
|
+
colour: { light: "oklch(0.55 0.23 262)", dark: "oklch(0.72 0.17 262)" },
|
|
24054
|
+
pasteHint: "Enter the code on Meta's device page. This dialog finishes on its own."
|
|
24055
|
+
}
|
|
24056
|
+
};
|
|
24057
|
+
|
|
23863
24058
|
// packages/providers/src/openai/models.ts
|
|
23864
24059
|
var OPENAI_MODELS = {
|
|
23865
24060
|
defaultModel: "gpt-5.6",
|
|
23866
24061
|
authTypes: ["oauth", "apiKey"],
|
|
23867
24062
|
models: [
|
|
24063
|
+
{
|
|
24064
|
+
id: "gpt-6-astra",
|
|
24065
|
+
label: "GPT-6 Astra",
|
|
24066
|
+
pricing: { input: 10, output: 50, cacheRead: 1, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
24067
|
+
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
24068
|
+
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
24069
|
+
},
|
|
23868
24070
|
{
|
|
23869
24071
|
id: "gpt-5.6",
|
|
23870
24072
|
label: "GPT-5.6 \u2014 routes to Sol",
|
|
23871
|
-
pricing: { input:
|
|
24073
|
+
pricing: { input: 4, output: 20, cacheRead: 0.4, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23872
24074
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23873
24075
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
23874
24076
|
},
|
|
23875
24077
|
{
|
|
23876
24078
|
id: "gpt-5.6-sol",
|
|
23877
|
-
label: "GPT-5.6 Sol
|
|
23878
|
-
pricing: { input:
|
|
24079
|
+
label: "GPT-5.6 Sol",
|
|
24080
|
+
pricing: { input: 4, output: 20, cacheRead: 0.4, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23879
24081
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23880
24082
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
23881
24083
|
},
|
|
23882
24084
|
{
|
|
23883
24085
|
id: "gpt-5.6-terra",
|
|
23884
|
-
label: "GPT-5.6 Terra
|
|
24086
|
+
label: "GPT-5.6 Terra",
|
|
23885
24087
|
pricing: { input: 2, output: 12, cacheRead: 0.2, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23886
24088
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23887
24089
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
23888
24090
|
},
|
|
23889
24091
|
{
|
|
23890
24092
|
id: "gpt-5.6-luna",
|
|
23891
|
-
label: "GPT-5.6 Luna
|
|
24093
|
+
label: "GPT-5.6 Luna",
|
|
23892
24094
|
pricing: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite5m: 0, cacheWrite1h: 0 },
|
|
23893
24095
|
limits: { contextWindow: 922000, maxOutputTokens: 128000 },
|
|
23894
24096
|
oauthLimits: { contextWindow: 272000, maxOutputTokens: 128000 }
|
|
@@ -23926,6 +24128,8 @@ var PROVIDER_DESCRIPTORS = {
|
|
|
23926
24128
|
kimi: kimiDescriptor,
|
|
23927
24129
|
kilo: kiloDescriptor,
|
|
23928
24130
|
grok: grokDescriptor,
|
|
24131
|
+
antigravity: antigravityDescriptor,
|
|
24132
|
+
muse: museDescriptor,
|
|
23929
24133
|
custom: customDescriptor
|
|
23930
24134
|
};
|
|
23931
24135
|
Object.setPrototypeOf(PROVIDER_DESCRIPTORS, null);
|
|
@@ -24356,6 +24560,38 @@ var anthropicBodyOrder = [
|
|
|
24356
24560
|
"stream"
|
|
24357
24561
|
];
|
|
24358
24562
|
|
|
24563
|
+
// packages/providers/src/antigravity/profile.ts
|
|
24564
|
+
var ANTIGRAVITY_IDE_VERSION = env("OMNI_ANTIGRAVITY_IDE_VERSION", "2.12.2");
|
|
24565
|
+
var PLATFORM = "darwin/arm64";
|
|
24566
|
+
var antigravityProfile = {
|
|
24567
|
+
headers: [
|
|
24568
|
+
[
|
|
24569
|
+
"User-Agent",
|
|
24570
|
+
env("OMNI_UA_ANTIGRAVITY", `antigravity/ide/${ANTIGRAVITY_IDE_VERSION} ${PLATFORM}`)
|
|
24571
|
+
],
|
|
24572
|
+
["Content-Type", "application/json"],
|
|
24573
|
+
["Accept", "text/event-stream"]
|
|
24574
|
+
],
|
|
24575
|
+
order: envOrder("OMNI_ORDER_ANTIGRAVITY", [
|
|
24576
|
+
"Host",
|
|
24577
|
+
"Content-Type",
|
|
24578
|
+
"Authorization",
|
|
24579
|
+
"User-Agent",
|
|
24580
|
+
"X-Goog-Api-Client",
|
|
24581
|
+
"Accept",
|
|
24582
|
+
"Accept-Encoding",
|
|
24583
|
+
"Content-Length"
|
|
24584
|
+
])
|
|
24585
|
+
};
|
|
24586
|
+
var antigravityBodyOrder = [
|
|
24587
|
+
"project",
|
|
24588
|
+
"requestId",
|
|
24589
|
+
"model",
|
|
24590
|
+
"userAgent",
|
|
24591
|
+
"requestType",
|
|
24592
|
+
"request"
|
|
24593
|
+
];
|
|
24594
|
+
|
|
24359
24595
|
// packages/providers/src/custom/profile.ts
|
|
24360
24596
|
var customProfile = { headers: [], order: [] };
|
|
24361
24597
|
var customBodyOrder = [];
|
|
@@ -24477,6 +24713,43 @@ var kimiBodyOrder = [
|
|
|
24477
24713
|
"stream"
|
|
24478
24714
|
];
|
|
24479
24715
|
|
|
24716
|
+
// packages/providers/src/muse/profile.ts
|
|
24717
|
+
var MUSE_CLI_VERSION = env("OMNI_MUSE_CLI_VERSION", "1.0.3");
|
|
24718
|
+
var museProfile = {
|
|
24719
|
+
headers: [
|
|
24720
|
+
["User-Agent", env("OMNI_UA_MUSE", `muse-code/${MUSE_CLI_VERSION}`)],
|
|
24721
|
+
["x-api-version", env("OMNI_MUSE_API_VERSION", "1.0.0")],
|
|
24722
|
+
["Accept", "text/event-stream"]
|
|
24723
|
+
],
|
|
24724
|
+
order: envOrder("OMNI_ORDER_MUSE", [
|
|
24725
|
+
"Host",
|
|
24726
|
+
"Content-Type",
|
|
24727
|
+
"Authorization",
|
|
24728
|
+
"x-meta-ai-gateway-session-id",
|
|
24729
|
+
"x-api-version",
|
|
24730
|
+
"Accept",
|
|
24731
|
+
"User-Agent",
|
|
24732
|
+
"Accept-Encoding",
|
|
24733
|
+
"Content-Length"
|
|
24734
|
+
])
|
|
24735
|
+
};
|
|
24736
|
+
var museBodyOrder = [
|
|
24737
|
+
"model",
|
|
24738
|
+
"stream",
|
|
24739
|
+
"input",
|
|
24740
|
+
"instructions",
|
|
24741
|
+
"store",
|
|
24742
|
+
"reasoning",
|
|
24743
|
+
"prompt_cache_key",
|
|
24744
|
+
"max_output_tokens",
|
|
24745
|
+
"temperature",
|
|
24746
|
+
"tools",
|
|
24747
|
+
"tool_choice",
|
|
24748
|
+
"include",
|
|
24749
|
+
"parallel_tool_calls",
|
|
24750
|
+
"metadata"
|
|
24751
|
+
];
|
|
24752
|
+
|
|
24480
24753
|
// packages/providers/src/openai/profile.ts
|
|
24481
24754
|
var OPENAI_CLI_VERSION = env("OMNI_OPENAI_CLI_VERSION", "0.144.1");
|
|
24482
24755
|
var OPENAI_UA_PLATFORM = env("OMNI_OPENAI_UA_PLATFORM", "Windows 10.0.26200");
|
|
@@ -24533,6 +24806,8 @@ var BODY_ORDER = {
|
|
|
24533
24806
|
kimi: kimiBodyOrder,
|
|
24534
24807
|
kilo: kiloBodyOrder,
|
|
24535
24808
|
grok: grokBodyOrder,
|
|
24809
|
+
antigravity: antigravityBodyOrder,
|
|
24810
|
+
muse: museBodyOrder,
|
|
24536
24811
|
custom: customBodyOrder
|
|
24537
24812
|
};
|
|
24538
24813
|
Object.setPrototypeOf(BODY_ORDER, null);
|
|
@@ -24626,6 +24901,8 @@ var PROVIDER_MODEL_CATALOG = {
|
|
|
24626
24901
|
kimi: KIMI_MODELS,
|
|
24627
24902
|
kilo: KILO_MODELS,
|
|
24628
24903
|
grok: GROK_MODELS,
|
|
24904
|
+
antigravity: ANTIGRAVITY_MODELS,
|
|
24905
|
+
muse: MUSE_MODELS,
|
|
24629
24906
|
custom: CUSTOM_MODELS
|
|
24630
24907
|
};
|
|
24631
24908
|
Object.setPrototypeOf(PROVIDER_MODEL_CATALOG, null);
|
|
@@ -24656,6 +24933,8 @@ var PROFILES = {
|
|
|
24656
24933
|
kimi: kimiProfile,
|
|
24657
24934
|
kilo: kiloProfile,
|
|
24658
24935
|
grok: grokProfile,
|
|
24936
|
+
antigravity: antigravityProfile,
|
|
24937
|
+
muse: museProfile,
|
|
24659
24938
|
custom: customProfile
|
|
24660
24939
|
};
|
|
24661
24940
|
Object.setPrototypeOf(PROFILES, null);
|
|
@@ -25924,6 +26203,1114 @@ var anthropicOAuthFlow = {
|
|
|
25924
26203
|
return parseAnthropicUsage(parsed(res.body), now());
|
|
25925
26204
|
}
|
|
25926
26205
|
};
|
|
26206
|
+
// packages/providers/src/antigravity/codec.ts
|
|
26207
|
+
import { createHash as createHash2 } from "crypto";
|
|
26208
|
+
|
|
26209
|
+
// packages/providers/src/antigravity/cloak.ts
|
|
26210
|
+
var FUNCTION_NAME = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
26211
|
+
var MAX_NAME = 128;
|
|
26212
|
+
var SUFFIX_LENGTH2 = 6;
|
|
26213
|
+
function aliasFor2(name) {
|
|
26214
|
+
let base = name.replace(/[^A-Za-z0-9_.-]+/g, "_");
|
|
26215
|
+
if (!/^[A-Za-z_]/.test(base))
|
|
26216
|
+
base = `_${base}`;
|
|
26217
|
+
if (base === "_")
|
|
26218
|
+
return { base: "_tool", forced: true };
|
|
26219
|
+
if (base.length > MAX_NAME) {
|
|
26220
|
+
return { base: base.slice(0, MAX_NAME - SUFFIX_LENGTH2), forced: true };
|
|
26221
|
+
}
|
|
26222
|
+
return { base, forced: false };
|
|
26223
|
+
}
|
|
26224
|
+
function clientToolNames2(request2) {
|
|
26225
|
+
const renamable = new Set;
|
|
26226
|
+
const reserved = new Set;
|
|
26227
|
+
const add = (name) => {
|
|
26228
|
+
(FUNCTION_NAME.test(name) ? reserved : renamable).add(name);
|
|
26229
|
+
};
|
|
26230
|
+
const called = new Set;
|
|
26231
|
+
for (const message of request2.messages) {
|
|
26232
|
+
for (const block of message.content) {
|
|
26233
|
+
if (block.type === "toolUse")
|
|
26234
|
+
called.add(block.id);
|
|
26235
|
+
}
|
|
26236
|
+
}
|
|
26237
|
+
for (const tool of request2.tools ?? []) {
|
|
26238
|
+
if (tool.kind === "portable")
|
|
26239
|
+
add(tool.name);
|
|
26240
|
+
}
|
|
26241
|
+
for (const message of request2.messages) {
|
|
26242
|
+
for (const block of message.content) {
|
|
26243
|
+
if (block.type === "toolUse")
|
|
26244
|
+
add(block.name);
|
|
26245
|
+
if (block.type === "toolResult" && !called.has(block.toolUseId))
|
|
26246
|
+
add(block.toolUseId);
|
|
26247
|
+
}
|
|
26248
|
+
}
|
|
26249
|
+
if (request2.toolChoice?.type === "tool")
|
|
26250
|
+
add(request2.toolChoice.name);
|
|
26251
|
+
return { renamable: [...renamable], reserved: [...reserved] };
|
|
26252
|
+
}
|
|
26253
|
+
function suffixFor2(name) {
|
|
26254
|
+
const digest = Bun.hash.xxHash64(Buffer.from(name, "utf8")) & 0xffffffn;
|
|
26255
|
+
return digest.toString(16).padStart(SUFFIX_LENGTH2, "0");
|
|
26256
|
+
}
|
|
26257
|
+
function buildToolCloak2(request2) {
|
|
26258
|
+
const { renamable, reserved } = clientToolNames2(request2);
|
|
26259
|
+
const claims = new Map;
|
|
26260
|
+
const claim2 = (name) => {
|
|
26261
|
+
claims.set(name, (claims.get(name) ?? 0) + 1);
|
|
26262
|
+
};
|
|
26263
|
+
for (const name of reserved)
|
|
26264
|
+
claim2(name);
|
|
26265
|
+
const bases = new Map;
|
|
26266
|
+
for (const name of renamable) {
|
|
26267
|
+
const derived = aliasFor2(name);
|
|
26268
|
+
bases.set(name, derived);
|
|
26269
|
+
claim2(derived.base);
|
|
26270
|
+
}
|
|
26271
|
+
const toWire2 = new Map;
|
|
26272
|
+
const fromWire = new Map;
|
|
26273
|
+
for (const [name, { base, forced }] of bases) {
|
|
26274
|
+
const alias = forced || (claims.get(base) ?? 0) > 1 ? base + suffixFor2(name) : base;
|
|
26275
|
+
toWire2.set(name, alias);
|
|
26276
|
+
fromWire.set(alias, name);
|
|
26277
|
+
}
|
|
26278
|
+
return toWire2.size === 0 ? null : { toWire: toWire2, fromWire };
|
|
26279
|
+
}
|
|
26280
|
+
function cloakName2(cloak, name) {
|
|
26281
|
+
return cloak?.toWire.get(name) ?? name;
|
|
26282
|
+
}
|
|
26283
|
+
function uncloakName2(cloak, name) {
|
|
26284
|
+
return cloak?.fromWire.get(name) ?? name;
|
|
26285
|
+
}
|
|
26286
|
+
|
|
26287
|
+
// packages/providers/src/antigravity/decode.ts
|
|
26288
|
+
var STOP_REASON2 = {
|
|
26289
|
+
STOP: "endTurn",
|
|
26290
|
+
MAX_TOKENS: "maxTokens",
|
|
26291
|
+
SAFETY: "contentFilter",
|
|
26292
|
+
PROHIBITED_CONTENT: "contentFilter",
|
|
26293
|
+
SPII: "contentFilter",
|
|
26294
|
+
BLOCKLIST: "contentFilter",
|
|
26295
|
+
RECITATION: "contentFilter"
|
|
26296
|
+
};
|
|
26297
|
+
var ERROR_CODE = {
|
|
26298
|
+
RESOURCE_EXHAUSTED: "RATE_LIMIT",
|
|
26299
|
+
UNAUTHENTICATED: "AUTH",
|
|
26300
|
+
PERMISSION_DENIED: "AUTH",
|
|
26301
|
+
INVALID_ARGUMENT: "BAD_REQUEST",
|
|
26302
|
+
FAILED_PRECONDITION: "BAD_REQUEST",
|
|
26303
|
+
UNAVAILABLE: "UPSTREAM",
|
|
26304
|
+
INTERNAL: "UPSTREAM",
|
|
26305
|
+
DEADLINE_EXCEEDED: "TIMEOUT"
|
|
26306
|
+
};
|
|
26307
|
+
function json3(data) {
|
|
26308
|
+
try {
|
|
26309
|
+
const value = JSON.parse(data);
|
|
26310
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
26311
|
+
} catch {
|
|
26312
|
+
return null;
|
|
26313
|
+
}
|
|
26314
|
+
}
|
|
26315
|
+
function count(value) {
|
|
26316
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
26317
|
+
}
|
|
26318
|
+
function usageOf(meta3) {
|
|
26319
|
+
return usageFromPromptTotal(count(meta3?.promptTokenCount), count(meta3?.candidatesTokenCount) + count(meta3?.thoughtsTokenCount), count(meta3?.cachedContentTokenCount));
|
|
26320
|
+
}
|
|
26321
|
+
async function* decodeAntigravityStream(messages, opts = {}) {
|
|
26322
|
+
const cloak = opts.cloak ?? null;
|
|
26323
|
+
let started = false;
|
|
26324
|
+
let terminal = false;
|
|
26325
|
+
let nextIndex = 0;
|
|
26326
|
+
let toolCalls = 0;
|
|
26327
|
+
let open2 = null;
|
|
26328
|
+
const closeOpen = function* () {
|
|
26329
|
+
if (open2 === null)
|
|
26330
|
+
return;
|
|
26331
|
+
yield { type: "blockEnd", index: open2.index };
|
|
26332
|
+
open2 = null;
|
|
26333
|
+
};
|
|
26334
|
+
for await (const message of messages) {
|
|
26335
|
+
if (message.data === "[DONE]")
|
|
26336
|
+
continue;
|
|
26337
|
+
const frame = json3(message.data);
|
|
26338
|
+
if (frame === null)
|
|
26339
|
+
continue;
|
|
26340
|
+
const failure = frame.error ?? frame.response?.error;
|
|
26341
|
+
if (failure !== undefined) {
|
|
26342
|
+
terminal = true;
|
|
26343
|
+
yield* closeOpen();
|
|
26344
|
+
const status = String(failure.status ?? "");
|
|
26345
|
+
const code = (Object.hasOwn(ERROR_CODE, status) ? ERROR_CODE[status] : undefined) ?? "UPSTREAM";
|
|
26346
|
+
yield {
|
|
26347
|
+
type: "error",
|
|
26348
|
+
code,
|
|
26349
|
+
message: String(failure.message ?? "upstream error"),
|
|
26350
|
+
retryable: RETRYABLE[code]
|
|
26351
|
+
};
|
|
26352
|
+
return;
|
|
26353
|
+
}
|
|
26354
|
+
const response = frame.response;
|
|
26355
|
+
if (response === undefined)
|
|
26356
|
+
continue;
|
|
26357
|
+
const blocked = response.promptFeedback?.blockReason;
|
|
26358
|
+
if (blocked !== undefined && (response.candidates ?? []).length === 0) {
|
|
26359
|
+
terminal = true;
|
|
26360
|
+
if (!started)
|
|
26361
|
+
yield { type: "start", id: "", model: "" };
|
|
26362
|
+
yield* closeOpen();
|
|
26363
|
+
yield { type: "end", stopReason: "contentFilter", usage: usageOf(response.usageMetadata) };
|
|
26364
|
+
return;
|
|
26365
|
+
}
|
|
26366
|
+
if (!started) {
|
|
26367
|
+
started = true;
|
|
26368
|
+
yield {
|
|
26369
|
+
type: "start",
|
|
26370
|
+
id: String(response.responseId ?? ""),
|
|
26371
|
+
model: String(response.modelVersion ?? "")
|
|
26372
|
+
};
|
|
26373
|
+
}
|
|
26374
|
+
const candidates = response.candidates ?? [];
|
|
26375
|
+
if (candidates.length > 1) {
|
|
26376
|
+
terminal = true;
|
|
26377
|
+
yield* closeOpen();
|
|
26378
|
+
yield {
|
|
26379
|
+
type: "error",
|
|
26380
|
+
code: "UPSTREAM",
|
|
26381
|
+
message: `Antigravity returned ${candidates.length} candidates, which cannot be represented`,
|
|
26382
|
+
retryable: false
|
|
26383
|
+
};
|
|
26384
|
+
return;
|
|
26385
|
+
}
|
|
26386
|
+
const candidate = candidates[0];
|
|
26387
|
+
for (const part of candidate?.content?.parts ?? []) {
|
|
26388
|
+
const call = part.functionCall;
|
|
26389
|
+
if (call !== undefined && typeof call.name === "string") {
|
|
26390
|
+
yield* closeOpen();
|
|
26391
|
+
const index = nextIndex++;
|
|
26392
|
+
yield {
|
|
26393
|
+
type: "blockStart",
|
|
26394
|
+
index,
|
|
26395
|
+
block: {
|
|
26396
|
+
type: "toolUse",
|
|
26397
|
+
id: typeof call.id === "string" && call.id.length > 0 ? call.id : `fc_${toolCalls}`,
|
|
26398
|
+
name: uncloakName2(cloak, call.name)
|
|
26399
|
+
}
|
|
26400
|
+
};
|
|
26401
|
+
yield {
|
|
26402
|
+
type: "blockDelta",
|
|
26403
|
+
index,
|
|
26404
|
+
delta: { type: "toolJson", partial: JSON.stringify(call.args ?? {}) }
|
|
26405
|
+
};
|
|
26406
|
+
yield { type: "blockEnd", index };
|
|
26407
|
+
toolCalls++;
|
|
26408
|
+
continue;
|
|
26409
|
+
}
|
|
26410
|
+
if (typeof part.text !== "string")
|
|
26411
|
+
continue;
|
|
26412
|
+
const kind = part.thought === true ? "thinking" : "text";
|
|
26413
|
+
if (open2 === null || open2.kind !== kind) {
|
|
26414
|
+
yield* closeOpen();
|
|
26415
|
+
open2 = { kind, index: nextIndex++ };
|
|
26416
|
+
yield { type: "blockStart", index: open2.index, block: { type: kind } };
|
|
26417
|
+
}
|
|
26418
|
+
yield {
|
|
26419
|
+
type: "blockDelta",
|
|
26420
|
+
index: open2.index,
|
|
26421
|
+
delta: kind === "thinking" ? { type: "thinking", text: part.text } : { type: "text", text: part.text }
|
|
26422
|
+
};
|
|
26423
|
+
}
|
|
26424
|
+
const finish = candidate?.finishReason;
|
|
26425
|
+
if (finish === undefined || finish === null)
|
|
26426
|
+
continue;
|
|
26427
|
+
terminal = true;
|
|
26428
|
+
yield* closeOpen();
|
|
26429
|
+
const raw = String(finish);
|
|
26430
|
+
if (raw === "MALFORMED_FUNCTION_CALL") {
|
|
26431
|
+
yield {
|
|
26432
|
+
type: "error",
|
|
26433
|
+
code: "BAD_REQUEST",
|
|
26434
|
+
message: "the model emitted a malformed function call",
|
|
26435
|
+
retryable: false
|
|
26436
|
+
};
|
|
26437
|
+
return;
|
|
26438
|
+
}
|
|
26439
|
+
const mapped = Object.hasOwn(STOP_REASON2, raw) ? STOP_REASON2[raw] : undefined;
|
|
26440
|
+
if (mapped === undefined) {
|
|
26441
|
+
yield {
|
|
26442
|
+
type: "error",
|
|
26443
|
+
code: "UPSTREAM",
|
|
26444
|
+
message: `unrecognized Antigravity finish reason "${raw}"`,
|
|
26445
|
+
retryable: false
|
|
26446
|
+
};
|
|
26447
|
+
return;
|
|
26448
|
+
}
|
|
26449
|
+
yield {
|
|
26450
|
+
type: "end",
|
|
26451
|
+
stopReason: toolCalls > 0 ? "toolUse" : mapped,
|
|
26452
|
+
usage: usageOf(response.usageMetadata)
|
|
26453
|
+
};
|
|
26454
|
+
return;
|
|
26455
|
+
}
|
|
26456
|
+
if (!terminal) {
|
|
26457
|
+
yield* closeOpen();
|
|
26458
|
+
yield {
|
|
26459
|
+
type: "error",
|
|
26460
|
+
code: "UPSTREAM",
|
|
26461
|
+
message: "upstream stream ended before the response finished",
|
|
26462
|
+
retryable: RETRYABLE.UPSTREAM
|
|
26463
|
+
};
|
|
26464
|
+
}
|
|
26465
|
+
}
|
|
26466
|
+
|
|
26467
|
+
// packages/providers/src/antigravity/wire.ts
|
|
26468
|
+
var SIGNATURE_BYPASS = "skip_thought_signature_validator";
|
|
26469
|
+
function toolNamesById(req) {
|
|
26470
|
+
const names = new Map;
|
|
26471
|
+
for (const message of req.messages) {
|
|
26472
|
+
for (const block of message.content) {
|
|
26473
|
+
if (block.type === "toolUse")
|
|
26474
|
+
names.set(block.id, block.name);
|
|
26475
|
+
}
|
|
26476
|
+
}
|
|
26477
|
+
return names;
|
|
26478
|
+
}
|
|
26479
|
+
function mergeSameRole(contents) {
|
|
26480
|
+
const merged = [];
|
|
26481
|
+
for (const entry of contents) {
|
|
26482
|
+
const last = merged[merged.length - 1];
|
|
26483
|
+
if (last !== undefined && last.role === entry.role)
|
|
26484
|
+
last.parts.push(...entry.parts);
|
|
26485
|
+
else
|
|
26486
|
+
merged.push({ role: entry.role, parts: [...entry.parts] });
|
|
26487
|
+
}
|
|
26488
|
+
return merged;
|
|
26489
|
+
}
|
|
26490
|
+
function openingTurn(contents, note2) {
|
|
26491
|
+
const first = contents[0];
|
|
26492
|
+
if (first === undefined)
|
|
26493
|
+
return contents;
|
|
26494
|
+
const opensOnTool = first.role === "model" || first.parts[0] !== undefined && "functionResponse" in first.parts[0];
|
|
26495
|
+
if (!opensOnTool)
|
|
26496
|
+
return contents;
|
|
26497
|
+
note2("antigravity:opening-turn-added");
|
|
26498
|
+
return [{ role: "user", parts: [{ text: "" }] }, ...contents];
|
|
26499
|
+
}
|
|
26500
|
+
function closingTurn(contents, note2) {
|
|
26501
|
+
if (contents[contents.length - 1]?.role !== "model")
|
|
26502
|
+
return contents;
|
|
26503
|
+
note2("antigravity:closing-turn-added");
|
|
26504
|
+
return [...contents, { role: "user", parts: [{ text: " " }] }];
|
|
26505
|
+
}
|
|
26506
|
+
var hasCacheControl = (block) => ("cacheControl" in block) && block.cacheControl !== undefined;
|
|
26507
|
+
var PRUNED = "antigravity:tool-schema-pruned";
|
|
26508
|
+
var MAX_STOP_SEQUENCES = 5;
|
|
26509
|
+
var MAX_THINKING_BUDGET = 65535;
|
|
26510
|
+
function scalarValue(kind, value) {
|
|
26511
|
+
const numeric = (v, whole) => {
|
|
26512
|
+
if (typeof v === "number")
|
|
26513
|
+
return Number.isFinite(v) && (!whole || Number.isInteger(v));
|
|
26514
|
+
if (typeof v !== "string")
|
|
26515
|
+
return false;
|
|
26516
|
+
if (whole)
|
|
26517
|
+
return /^-?\d+$/.test(v);
|
|
26518
|
+
return v.trim().length > 0 && Number.isFinite(Number(v));
|
|
26519
|
+
};
|
|
26520
|
+
switch (kind) {
|
|
26521
|
+
case "free":
|
|
26522
|
+
return value;
|
|
26523
|
+
case "text":
|
|
26524
|
+
return typeof value === "string" ? value : undefined;
|
|
26525
|
+
case "texts": {
|
|
26526
|
+
if (typeof value === "string")
|
|
26527
|
+
return value;
|
|
26528
|
+
if (!Array.isArray(value))
|
|
26529
|
+
return;
|
|
26530
|
+
const members2 = value.filter((m) => typeof m === "string");
|
|
26531
|
+
return members2.length === 0 ? undefined : members2;
|
|
26532
|
+
}
|
|
26533
|
+
case "int":
|
|
26534
|
+
return numeric(value, true) ? value : undefined;
|
|
26535
|
+
case "double":
|
|
26536
|
+
return numeric(value, false) ? value : undefined;
|
|
26537
|
+
case "walked":
|
|
26538
|
+
return value;
|
|
26539
|
+
}
|
|
26540
|
+
}
|
|
26541
|
+
var SCHEMA_FIELDS = new Map([
|
|
26542
|
+
["type", "walked"],
|
|
26543
|
+
["items", "walked"],
|
|
26544
|
+
["properties", "walked"],
|
|
26545
|
+
["anyOf", "walked"],
|
|
26546
|
+
["allOf", "walked"],
|
|
26547
|
+
["additionalProperties", "walked"],
|
|
26548
|
+
["format", "text"],
|
|
26549
|
+
["title", "text"],
|
|
26550
|
+
["description", "text"],
|
|
26551
|
+
["pattern", "text"],
|
|
26552
|
+
["enum", "texts"],
|
|
26553
|
+
["required", "texts"],
|
|
26554
|
+
["propertyOrdering", "texts"],
|
|
26555
|
+
["minItems", "int"],
|
|
26556
|
+
["maxItems", "int"],
|
|
26557
|
+
["minLength", "int"],
|
|
26558
|
+
["maxLength", "int"],
|
|
26559
|
+
["minProperties", "int"],
|
|
26560
|
+
["maxProperties", "int"],
|
|
26561
|
+
["minimum", "double"],
|
|
26562
|
+
["maximum", "double"],
|
|
26563
|
+
["default", "free"],
|
|
26564
|
+
["example", "free"],
|
|
26565
|
+
["nullable", "free"]
|
|
26566
|
+
]);
|
|
26567
|
+
var SCHEMA_TYPES = new Set([
|
|
26568
|
+
"string",
|
|
26569
|
+
"number",
|
|
26570
|
+
"integer",
|
|
26571
|
+
"boolean",
|
|
26572
|
+
"array",
|
|
26573
|
+
"object",
|
|
26574
|
+
"null",
|
|
26575
|
+
"type_unspecified"
|
|
26576
|
+
]);
|
|
26577
|
+
var MAX_SCHEMA_DEPTH = 24;
|
|
26578
|
+
var isSchema = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
26579
|
+
function pruneSchema(node2, note2, depth = 0) {
|
|
26580
|
+
const out = {};
|
|
26581
|
+
const drop = () => note2(PRUNED);
|
|
26582
|
+
const sub = (v) => {
|
|
26583
|
+
if (!isSchema(v) || depth >= MAX_SCHEMA_DEPTH) {
|
|
26584
|
+
drop();
|
|
26585
|
+
return;
|
|
26586
|
+
}
|
|
26587
|
+
return pruneSchema(v, note2, depth + 1);
|
|
26588
|
+
};
|
|
26589
|
+
for (const [key, value] of Object.entries(node2)) {
|
|
26590
|
+
if (key === "const") {
|
|
26591
|
+
drop();
|
|
26592
|
+
if (typeof value === "string" && !Object.hasOwn(node2, "enum"))
|
|
26593
|
+
out.enum = [value];
|
|
26594
|
+
continue;
|
|
26595
|
+
}
|
|
26596
|
+
const kind = SCHEMA_FIELDS.get(key);
|
|
26597
|
+
if (kind === undefined) {
|
|
26598
|
+
drop();
|
|
26599
|
+
continue;
|
|
26600
|
+
}
|
|
26601
|
+
switch (key) {
|
|
26602
|
+
case "type": {
|
|
26603
|
+
if (typeof value === "string") {
|
|
26604
|
+
if (SCHEMA_TYPES.has(value.toLowerCase()))
|
|
26605
|
+
out.type = value;
|
|
26606
|
+
else
|
|
26607
|
+
drop();
|
|
26608
|
+
break;
|
|
26609
|
+
}
|
|
26610
|
+
const named = Array.isArray(value) ? value.filter((t) => typeof t === "string" && SCHEMA_TYPES.has(t.toLowerCase())) : [];
|
|
26611
|
+
const real = named.filter((t) => t.toLowerCase() !== "null");
|
|
26612
|
+
if (!Array.isArray(value) || named.length !== value.length || real.length !== 1)
|
|
26613
|
+
drop();
|
|
26614
|
+
if (real[0] !== undefined)
|
|
26615
|
+
out.type = real[0];
|
|
26616
|
+
if (named.length !== real.length)
|
|
26617
|
+
out.nullable = true;
|
|
26618
|
+
break;
|
|
26619
|
+
}
|
|
26620
|
+
case "properties": {
|
|
26621
|
+
if (!isSchema(value)) {
|
|
26622
|
+
drop();
|
|
26623
|
+
break;
|
|
26624
|
+
}
|
|
26625
|
+
const entries = [];
|
|
26626
|
+
for (const [name, member] of Object.entries(value)) {
|
|
26627
|
+
if (name.length === 0) {
|
|
26628
|
+
drop();
|
|
26629
|
+
continue;
|
|
26630
|
+
}
|
|
26631
|
+
const pruned = sub(member);
|
|
26632
|
+
if (pruned !== undefined)
|
|
26633
|
+
entries.push([name, pruned]);
|
|
26634
|
+
}
|
|
26635
|
+
out.properties = Object.fromEntries(entries);
|
|
26636
|
+
break;
|
|
26637
|
+
}
|
|
26638
|
+
case "items": {
|
|
26639
|
+
if (Array.isArray(value)) {
|
|
26640
|
+
drop();
|
|
26641
|
+
const first = sub(value[0]);
|
|
26642
|
+
if (first !== undefined)
|
|
26643
|
+
out.items = first;
|
|
26644
|
+
break;
|
|
26645
|
+
}
|
|
26646
|
+
const pruned = sub(value);
|
|
26647
|
+
if (pruned !== undefined)
|
|
26648
|
+
out.items = pruned;
|
|
26649
|
+
break;
|
|
26650
|
+
}
|
|
26651
|
+
case "anyOf":
|
|
26652
|
+
case "allOf": {
|
|
26653
|
+
if (!Array.isArray(value)) {
|
|
26654
|
+
drop();
|
|
26655
|
+
break;
|
|
26656
|
+
}
|
|
26657
|
+
const arms = [];
|
|
26658
|
+
for (const arm of value) {
|
|
26659
|
+
const pruned = sub(arm);
|
|
26660
|
+
if (pruned !== undefined)
|
|
26661
|
+
arms.push(pruned);
|
|
26662
|
+
}
|
|
26663
|
+
out[key] = arms;
|
|
26664
|
+
break;
|
|
26665
|
+
}
|
|
26666
|
+
case "additionalProperties": {
|
|
26667
|
+
if (typeof value === "boolean") {
|
|
26668
|
+
out[key] = value;
|
|
26669
|
+
break;
|
|
26670
|
+
}
|
|
26671
|
+
const pruned = sub(value);
|
|
26672
|
+
if (pruned !== undefined)
|
|
26673
|
+
out[key] = pruned;
|
|
26674
|
+
break;
|
|
26675
|
+
}
|
|
26676
|
+
default: {
|
|
26677
|
+
const kept = scalarValue(kind, value);
|
|
26678
|
+
if (kept === undefined)
|
|
26679
|
+
drop();
|
|
26680
|
+
else {
|
|
26681
|
+
if (Array.isArray(kept) && Array.isArray(value) && kept.length !== value.length)
|
|
26682
|
+
drop();
|
|
26683
|
+
out[key] = kept;
|
|
26684
|
+
}
|
|
26685
|
+
}
|
|
26686
|
+
}
|
|
26687
|
+
}
|
|
26688
|
+
const declared = typeof out.type === "string" ? out.type.toLowerCase() : undefined;
|
|
26689
|
+
const agree = (want, fields2) => {
|
|
26690
|
+
if (!fields2.some((f) => out[f] !== undefined))
|
|
26691
|
+
return;
|
|
26692
|
+
if (declared === want)
|
|
26693
|
+
return;
|
|
26694
|
+
if (declared === undefined) {
|
|
26695
|
+
out.type = want;
|
|
26696
|
+
return;
|
|
26697
|
+
}
|
|
26698
|
+
drop();
|
|
26699
|
+
for (const f of fields2)
|
|
26700
|
+
delete out[f];
|
|
26701
|
+
};
|
|
26702
|
+
agree("object", ["properties", "required", "propertyOrdering"]);
|
|
26703
|
+
agree("array", ["items"]);
|
|
26704
|
+
for (const key of ["required", "propertyOrdering"]) {
|
|
26705
|
+
const names = out[key];
|
|
26706
|
+
if (!Array.isArray(names))
|
|
26707
|
+
continue;
|
|
26708
|
+
const known = isSchema(out.properties) ? out.properties : {};
|
|
26709
|
+
const kept = names.filter((n) => typeof n === "string" && Object.hasOwn(known, n));
|
|
26710
|
+
if (kept.length === names.length)
|
|
26711
|
+
continue;
|
|
26712
|
+
drop();
|
|
26713
|
+
if (kept.length === 0)
|
|
26714
|
+
delete out[key];
|
|
26715
|
+
else
|
|
26716
|
+
out[key] = kept;
|
|
26717
|
+
}
|
|
26718
|
+
if (out.type === "array" && out.items === undefined) {
|
|
26719
|
+
drop();
|
|
26720
|
+
delete out.type;
|
|
26721
|
+
}
|
|
26722
|
+
return out;
|
|
26723
|
+
}
|
|
26724
|
+
function encodeToolChoice2(choice, cloak) {
|
|
26725
|
+
switch (choice.type) {
|
|
26726
|
+
case "auto":
|
|
26727
|
+
return { functionCallingConfig: { mode: "AUTO" } };
|
|
26728
|
+
case "any":
|
|
26729
|
+
return { functionCallingConfig: { mode: "ANY" } };
|
|
26730
|
+
case "none":
|
|
26731
|
+
return { functionCallingConfig: { mode: "NONE" } };
|
|
26732
|
+
case "tool":
|
|
26733
|
+
return {
|
|
26734
|
+
functionCallingConfig: {
|
|
26735
|
+
mode: "ANY",
|
|
26736
|
+
allowedFunctionNames: [cloakName2(cloak, choice.name)]
|
|
26737
|
+
}
|
|
26738
|
+
};
|
|
26739
|
+
}
|
|
26740
|
+
}
|
|
26741
|
+
function toAntigravityWire(req, model, identity) {
|
|
26742
|
+
const cloak = identity.cloak ?? null;
|
|
26743
|
+
const degradations = [];
|
|
26744
|
+
const note2 = (d) => {
|
|
26745
|
+
if (!degradations.includes(d))
|
|
26746
|
+
degradations.push(d);
|
|
26747
|
+
};
|
|
26748
|
+
const names = toolNamesById(req);
|
|
26749
|
+
const contents = [];
|
|
26750
|
+
for (const message of req.messages) {
|
|
26751
|
+
const parts = [];
|
|
26752
|
+
if (message.role === "system")
|
|
26753
|
+
note2("antigravity:system-turn-as-user");
|
|
26754
|
+
let role = message.role === "assistant" ? "model" : "user";
|
|
26755
|
+
for (const block of message.content) {
|
|
26756
|
+
if (hasCacheControl(block))
|
|
26757
|
+
note2("antigravity:cache-control-dropped");
|
|
26758
|
+
switch (block.type) {
|
|
26759
|
+
case "text":
|
|
26760
|
+
parts.push({ text: block.text });
|
|
26761
|
+
break;
|
|
26762
|
+
case "image":
|
|
26763
|
+
parts.push({ inlineData: { mimeType: block.mediaType, data: block.data } });
|
|
26764
|
+
break;
|
|
26765
|
+
case "thinking":
|
|
26766
|
+
note2("antigravity:thinking-dropped");
|
|
26767
|
+
break;
|
|
26768
|
+
case "toolUse":
|
|
26769
|
+
parts.push({
|
|
26770
|
+
thoughtSignature: SIGNATURE_BYPASS,
|
|
26771
|
+
functionCall: { name: cloakName2(cloak, block.name), args: block.input }
|
|
26772
|
+
});
|
|
26773
|
+
break;
|
|
26774
|
+
case "toolResult": {
|
|
26775
|
+
const name = names.get(block.toolUseId);
|
|
26776
|
+
if (name === undefined)
|
|
26777
|
+
note2("antigravity:tool-result-unmatched");
|
|
26778
|
+
if (block.isError === true)
|
|
26779
|
+
note2("antigravity:tool-result-error-flag-dropped");
|
|
26780
|
+
parts.push({
|
|
26781
|
+
functionResponse: {
|
|
26782
|
+
name: cloakName2(cloak, name ?? block.toolUseId),
|
|
26783
|
+
response: { output: block.content }
|
|
26784
|
+
}
|
|
26785
|
+
});
|
|
26786
|
+
role = "user";
|
|
26787
|
+
break;
|
|
26788
|
+
}
|
|
26789
|
+
case "providerNative":
|
|
26790
|
+
note2("antigravity:provider-native-block-dropped");
|
|
26791
|
+
break;
|
|
26792
|
+
}
|
|
26793
|
+
}
|
|
26794
|
+
if (parts.length > 0)
|
|
26795
|
+
contents.push({ role, parts });
|
|
26796
|
+
}
|
|
26797
|
+
const request2 = {
|
|
26798
|
+
contents: closingTurn(openingTurn(mergeSameRole(contents), note2), note2)
|
|
26799
|
+
};
|
|
26800
|
+
const system = systemText(req.system, "antigravity", note2);
|
|
26801
|
+
if (system !== undefined && system.length > 0) {
|
|
26802
|
+
request2.systemInstruction = { parts: [{ text: system }] };
|
|
26803
|
+
}
|
|
26804
|
+
const generationConfig = {};
|
|
26805
|
+
if (req.maxTokens !== undefined) {
|
|
26806
|
+
if (req.maxTokens > 0)
|
|
26807
|
+
generationConfig.maxOutputTokens = req.maxTokens;
|
|
26808
|
+
else
|
|
26809
|
+
note2("antigravity:max-tokens-dropped");
|
|
26810
|
+
}
|
|
26811
|
+
if (req.temperature !== undefined) {
|
|
26812
|
+
const clamped = Math.min(Math.max(req.temperature, 0), 2);
|
|
26813
|
+
if (clamped !== req.temperature)
|
|
26814
|
+
note2("antigravity:temperature-clamped");
|
|
26815
|
+
generationConfig.temperature = clamped;
|
|
26816
|
+
}
|
|
26817
|
+
if (req.stopSequences !== undefined) {
|
|
26818
|
+
generationConfig.stopSequences = req.stopSequences.slice(0, MAX_STOP_SEQUENCES);
|
|
26819
|
+
if (req.stopSequences.length > MAX_STOP_SEQUENCES)
|
|
26820
|
+
note2("antigravity:stop-sequences-dropped");
|
|
26821
|
+
}
|
|
26822
|
+
if (req.reasoning !== undefined) {
|
|
26823
|
+
switch (req.reasoning.mode) {
|
|
26824
|
+
case "off":
|
|
26825
|
+
generationConfig.thinkingConfig = { thinkingBudget: 0, includeThoughts: false };
|
|
26826
|
+
break;
|
|
26827
|
+
case "budget":
|
|
26828
|
+
{
|
|
26829
|
+
const asked = req.reasoning.budgetTokens;
|
|
26830
|
+
const budget2 = Math.min(Math.max(asked, -1), MAX_THINKING_BUDGET);
|
|
26831
|
+
if (budget2 !== asked)
|
|
26832
|
+
note2("antigravity:thinking-budget-clamped");
|
|
26833
|
+
generationConfig.thinkingConfig = {
|
|
26834
|
+
thinkingBudget: budget2,
|
|
26835
|
+
includeThoughts: budget2 !== 0
|
|
26836
|
+
};
|
|
26837
|
+
}
|
|
26838
|
+
break;
|
|
26839
|
+
case "adaptive":
|
|
26840
|
+
generationConfig.thinkingConfig = {
|
|
26841
|
+
includeThoughts: req.reasoning.display !== "omitted"
|
|
26842
|
+
};
|
|
26843
|
+
if (req.reasoning.effort !== undefined)
|
|
26844
|
+
note2("antigravity:reasoning-effort-dropped");
|
|
26845
|
+
break;
|
|
26846
|
+
}
|
|
26847
|
+
}
|
|
26848
|
+
const max = generationConfig.maxOutputTokens;
|
|
26849
|
+
if (max !== undefined && max > MAX_OUTPUT_TOKENS) {
|
|
26850
|
+
generationConfig.maxOutputTokens = MAX_OUTPUT_TOKENS;
|
|
26851
|
+
note2("antigravity:max-tokens-clamped");
|
|
26852
|
+
}
|
|
26853
|
+
const budget = generationConfig.thinkingConfig?.thinkingBudget;
|
|
26854
|
+
if (budget !== undefined && budget > 0) {
|
|
26855
|
+
const ceiling = generationConfig.maxOutputTokens;
|
|
26856
|
+
if (ceiling === undefined || ceiling <= budget) {
|
|
26857
|
+
generationConfig.maxOutputTokens = Math.min(budget + 1, MAX_OUTPUT_TOKENS);
|
|
26858
|
+
}
|
|
26859
|
+
}
|
|
26860
|
+
if (Object.keys(generationConfig).length > 0)
|
|
26861
|
+
request2.generationConfig = generationConfig;
|
|
26862
|
+
if (req.tools !== undefined) {
|
|
26863
|
+
const portable = req.tools.filter((t) => t.kind === "portable");
|
|
26864
|
+
if (portable.length !== req.tools.length)
|
|
26865
|
+
note2("antigravity:provider-tool-dropped");
|
|
26866
|
+
const seen = new Set;
|
|
26867
|
+
const named = [];
|
|
26868
|
+
for (const tool of portable) {
|
|
26869
|
+
const name = cloakName2(cloak, tool.name);
|
|
26870
|
+
if (seen.has(name)) {
|
|
26871
|
+
note2("antigravity:duplicate-tool-dropped");
|
|
26872
|
+
continue;
|
|
26873
|
+
}
|
|
26874
|
+
seen.add(name);
|
|
26875
|
+
named.push({ name, description: tool.description, inputSchema: tool.inputSchema });
|
|
26876
|
+
}
|
|
26877
|
+
if (cloak !== null && cloak.toWire.size > 0)
|
|
26878
|
+
note2("antigravity:tool-name-renamed");
|
|
26879
|
+
if (named.length > 0) {
|
|
26880
|
+
request2.tools = [
|
|
26881
|
+
{
|
|
26882
|
+
functionDeclarations: named.map((t) => ({
|
|
26883
|
+
name: t.name,
|
|
26884
|
+
description: t.description,
|
|
26885
|
+
parameters: pruneSchema(t.inputSchema, note2)
|
|
26886
|
+
}))
|
|
26887
|
+
}
|
|
26888
|
+
];
|
|
26889
|
+
}
|
|
26890
|
+
}
|
|
26891
|
+
if (req.toolChoice !== undefined)
|
|
26892
|
+
request2.toolConfig = encodeToolChoice2(req.toolChoice, cloak);
|
|
26893
|
+
Object.assign(request2, req.vendor?.antigravity ?? {});
|
|
26894
|
+
return {
|
|
26895
|
+
body: {
|
|
26896
|
+
project: identity.project,
|
|
26897
|
+
requestId: identity.requestId,
|
|
26898
|
+
model,
|
|
26899
|
+
userAgent: "antigravity",
|
|
26900
|
+
requestType: "agent",
|
|
26901
|
+
request: request2
|
|
26902
|
+
},
|
|
26903
|
+
degradations
|
|
26904
|
+
};
|
|
26905
|
+
}
|
|
26906
|
+
|
|
26907
|
+
// packages/providers/src/antigravity/codec.ts
|
|
26908
|
+
var URL2 = "https://daily-cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse";
|
|
26909
|
+
var REQUEST_NAMESPACE = "omni-antigravity-req";
|
|
26910
|
+
function derivedRequestId(seed) {
|
|
26911
|
+
const h = createHash2("sha256").update(`${REQUEST_NAMESPACE}:${seed}`).digest("hex");
|
|
26912
|
+
const variant = (Number.parseInt(h[16], 16) & 3 | 8).toString(16);
|
|
26913
|
+
return [
|
|
26914
|
+
h.slice(0, 8),
|
|
26915
|
+
h.slice(8, 12),
|
|
26916
|
+
`4${h.slice(13, 16)}`,
|
|
26917
|
+
`${variant}${h.slice(17, 20)}`,
|
|
26918
|
+
h.slice(20, 32)
|
|
26919
|
+
].join("-");
|
|
26920
|
+
}
|
|
26921
|
+
function projectOf(input2) {
|
|
26922
|
+
const stored = input2.credentials.providerData.projectId;
|
|
26923
|
+
const project = typeof stored === "string" ? stored.trim() : "";
|
|
26924
|
+
if (project.length === 0) {
|
|
26925
|
+
throw input2.fail("AUTH", "antigravity credential has no Cloud Code project; reconnect the account");
|
|
26926
|
+
}
|
|
26927
|
+
return project;
|
|
26928
|
+
}
|
|
26929
|
+
function cloakOf2(state) {
|
|
26930
|
+
if (state === null || typeof state !== "object")
|
|
26931
|
+
return null;
|
|
26932
|
+
const cloak = state.cloak;
|
|
26933
|
+
if (cloak === null || cloak === undefined || typeof cloak !== "object")
|
|
26934
|
+
return null;
|
|
26935
|
+
const { toWire: toWire2, fromWire } = cloak;
|
|
26936
|
+
return toWire2 instanceof Map && fromWire instanceof Map ? cloak : null;
|
|
26937
|
+
}
|
|
26938
|
+
var antigravityCodec = {
|
|
26939
|
+
buildRequest(input2) {
|
|
26940
|
+
const accessToken = input2.credentials.accessToken;
|
|
26941
|
+
if (accessToken === null || accessToken.length === 0) {
|
|
26942
|
+
throw input2.fail("AUTH", "antigravity credential has no access token");
|
|
26943
|
+
}
|
|
26944
|
+
const project = projectOf(input2);
|
|
26945
|
+
const requestId = input2.requestId !== undefined && input2.requestId.length > 0 ? input2.requestId : derivedRequestId(`${input2.model}:${project}`);
|
|
26946
|
+
const cloak = buildToolCloak2(input2.request);
|
|
26947
|
+
const { body, degradations } = toAntigravityWire(input2.request, input2.model, {
|
|
26948
|
+
project,
|
|
26949
|
+
requestId,
|
|
26950
|
+
cloak
|
|
26951
|
+
});
|
|
26952
|
+
const protocol = [["Authorization", `Bearer ${accessToken}`]];
|
|
26953
|
+
const headers = orderHeaders(mergeHeaders(antigravityProfile.headers, protocol), antigravityProfile.order);
|
|
26954
|
+
return {
|
|
26955
|
+
request: {
|
|
26956
|
+
url: URL2,
|
|
26957
|
+
method: "POST",
|
|
26958
|
+
headers,
|
|
26959
|
+
body: JSON.stringify(body)
|
|
26960
|
+
},
|
|
26961
|
+
decodeState: { cloak },
|
|
26962
|
+
degradations,
|
|
26963
|
+
...cloak === null ? {} : { cloakedTools: cloak.toWire.size }
|
|
26964
|
+
};
|
|
26965
|
+
},
|
|
26966
|
+
decode({ body, decodeState }) {
|
|
26967
|
+
return decodeAntigravityStream(parseSse(body), { cloak: cloakOf2(decodeState) });
|
|
26968
|
+
}
|
|
26969
|
+
};
|
|
26970
|
+
|
|
26971
|
+
// packages/providers/src/antigravity/index.ts
|
|
26972
|
+
var antigravityAdapter = codecAdapter("antigravity", antigravityDescriptor.capabilities, antigravityCodec);
|
|
26973
|
+
// packages/providers/src/antigravity/oauth.ts
|
|
26974
|
+
var MASK = "omnigateway-public-v1";
|
|
26975
|
+
function unmask(bytes) {
|
|
26976
|
+
let out = "";
|
|
26977
|
+
for (let i = 0;i < bytes.length; i++) {
|
|
26978
|
+
out += String.fromCharCode(bytes[i] ^ MASK.charCodeAt(i % MASK.length));
|
|
26979
|
+
}
|
|
26980
|
+
return out;
|
|
26981
|
+
}
|
|
26982
|
+
var ANTIGRAVITY_CLIENT_ID = unmask([
|
|
26983
|
+
94,
|
|
26984
|
+
93,
|
|
26985
|
+
89,
|
|
26986
|
+
88,
|
|
26987
|
+
87,
|
|
26988
|
+
81,
|
|
26989
|
+
66,
|
|
26990
|
+
85,
|
|
26991
|
+
65,
|
|
26992
|
+
81,
|
|
26993
|
+
76,
|
|
26994
|
+
20,
|
|
26995
|
+
65,
|
|
26996
|
+
88,
|
|
26997
|
+
22,
|
|
26998
|
+
1,
|
|
26999
|
+
1,
|
|
27000
|
+
16,
|
|
27001
|
+
94,
|
|
27002
|
+
31,
|
|
27003
|
+
95,
|
|
27004
|
+
93,
|
|
27005
|
+
5,
|
|
27006
|
+
92,
|
|
27007
|
+
88,
|
|
27008
|
+
11,
|
|
27009
|
+
2,
|
|
27010
|
+
6,
|
|
27011
|
+
0,
|
|
27012
|
+
69,
|
|
27013
|
+
82,
|
|
27014
|
+
76,
|
|
27015
|
+
91,
|
|
27016
|
+
4,
|
|
27017
|
+
26,
|
|
27018
|
+
14,
|
|
27019
|
+
3,
|
|
27020
|
+
3,
|
|
27021
|
+
11,
|
|
27022
|
+
25,
|
|
27023
|
+
17,
|
|
27024
|
+
5,
|
|
27025
|
+
95,
|
|
27026
|
+
94,
|
|
27027
|
+
11,
|
|
27028
|
+
25,
|
|
27029
|
+
73,
|
|
27030
|
+
0,
|
|
27031
|
+
4,
|
|
27032
|
+
21,
|
|
27033
|
+
4,
|
|
27034
|
+
79,
|
|
27035
|
+
30,
|
|
27036
|
+
66,
|
|
27037
|
+
31,
|
|
27038
|
+
18,
|
|
27039
|
+
14,
|
|
27040
|
+
9,
|
|
27041
|
+
28,
|
|
27042
|
+
16,
|
|
27043
|
+
72,
|
|
27044
|
+
4,
|
|
27045
|
+
82,
|
|
27046
|
+
0,
|
|
27047
|
+
3,
|
|
27048
|
+
26,
|
|
27049
|
+
12,
|
|
27050
|
+
9,
|
|
27051
|
+
21,
|
|
27052
|
+
90,
|
|
27053
|
+
6,
|
|
27054
|
+
24,
|
|
27055
|
+
12
|
|
27056
|
+
]);
|
|
27057
|
+
var CLIENT_ID2 = ANTIGRAVITY_CLIENT_ID;
|
|
27058
|
+
var CLIENT_SECRET = unmask([
|
|
27059
|
+
40,
|
|
27060
|
+
34,
|
|
27061
|
+
45,
|
|
27062
|
+
58,
|
|
27063
|
+
55,
|
|
27064
|
+
57,
|
|
27065
|
+
89,
|
|
27066
|
+
46,
|
|
27067
|
+
66,
|
|
27068
|
+
89,
|
|
27069
|
+
63,
|
|
27070
|
+
122,
|
|
27071
|
+
34,
|
|
27072
|
+
65,
|
|
27073
|
+
90,
|
|
27074
|
+
90,
|
|
27075
|
+
37,
|
|
27076
|
+
7,
|
|
27077
|
+
97,
|
|
27078
|
+
60,
|
|
27079
|
+
0,
|
|
27080
|
+
2,
|
|
27081
|
+
33,
|
|
27082
|
+
44,
|
|
27083
|
+
81,
|
|
27084
|
+
20,
|
|
27085
|
+
57,
|
|
27086
|
+
55,
|
|
27087
|
+
81,
|
|
27088
|
+
13,
|
|
27089
|
+
87,
|
|
27090
|
+
8,
|
|
27091
|
+
105,
|
|
27092
|
+
49,
|
|
27093
|
+
19
|
|
27094
|
+
]);
|
|
27095
|
+
var AUTHORIZE_URL2 = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
27096
|
+
var TOKEN_URL2 = "https://oauth2.googleapis.com/token";
|
|
27097
|
+
var USERINFO_URL = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json";
|
|
27098
|
+
var CODE_ASSIST = "https://cloudcode-pa.googleapis.com/v1internal";
|
|
27099
|
+
var LOAD_CODE_ASSIST_URL = `${CODE_ASSIST}:loadCodeAssist`;
|
|
27100
|
+
var ONBOARD_USER_URL = `${CODE_ASSIST}:onboardUser`;
|
|
27101
|
+
var QUOTA_SUMMARY_URL = `${CODE_ASSIST}:retrieveUserQuotaSummary`;
|
|
27102
|
+
var SCOPES2 = [
|
|
27103
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
|
27104
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
27105
|
+
"https://www.googleapis.com/auth/userinfo.profile",
|
|
27106
|
+
"https://www.googleapis.com/auth/cclog",
|
|
27107
|
+
"https://www.googleapis.com/auth/experimentsandconfigs"
|
|
27108
|
+
].join(" ");
|
|
27109
|
+
var IDE_METADATA = { ideType: "ANTIGRAVITY" };
|
|
27110
|
+
var DEFAULT_TIER = "legacy-tier";
|
|
27111
|
+
function parseTokenResponse(value) {
|
|
27112
|
+
const record2 = recordOf(value);
|
|
27113
|
+
if (record2 === null || typeof record2.access_token !== "string")
|
|
27114
|
+
return null;
|
|
27115
|
+
return {
|
|
27116
|
+
accessToken: record2.access_token,
|
|
27117
|
+
refreshToken: typeof record2.refresh_token === "string" ? record2.refresh_token : null,
|
|
27118
|
+
expiresIn: typeof record2.expires_in === "number" ? record2.expires_in : null
|
|
27119
|
+
};
|
|
27120
|
+
}
|
|
27121
|
+
async function* postToken2(body, fail) {
|
|
27122
|
+
const res = yield postJsonRequest(TOKEN_URL2, antigravityProfile, {
|
|
27123
|
+
contentType: "application/x-www-form-urlencoded",
|
|
27124
|
+
body: new URLSearchParams(body).toString()
|
|
27125
|
+
});
|
|
27126
|
+
const parsed2 = parsed(res.body);
|
|
27127
|
+
if (res.status < 200 || res.status >= 300) {
|
|
27128
|
+
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
27129
|
+
}
|
|
27130
|
+
const token = parseTokenResponse(parsed2);
|
|
27131
|
+
if (token === null)
|
|
27132
|
+
throw fail("AUTH", "token endpoint returned no access_token");
|
|
27133
|
+
return token;
|
|
27134
|
+
}
|
|
27135
|
+
function projectFrom(value) {
|
|
27136
|
+
const record2 = recordOf(value);
|
|
27137
|
+
if (record2 === null)
|
|
27138
|
+
return "";
|
|
27139
|
+
const project = record2.cloudaicompanionProject;
|
|
27140
|
+
if (typeof project === "string")
|
|
27141
|
+
return project.trim();
|
|
27142
|
+
const nested = recordOf(project);
|
|
27143
|
+
const id = nested?.id;
|
|
27144
|
+
return typeof id === "string" ? id.trim() : "";
|
|
27145
|
+
}
|
|
27146
|
+
function tierFrom(value) {
|
|
27147
|
+
const record2 = recordOf(value);
|
|
27148
|
+
const tiers = record2?.allowedTiers;
|
|
27149
|
+
if (Array.isArray(tiers)) {
|
|
27150
|
+
for (const entry of tiers) {
|
|
27151
|
+
const tier = recordOf(entry);
|
|
27152
|
+
if (tier?.isDefault === true && typeof tier.id === "string")
|
|
27153
|
+
return tier.id;
|
|
27154
|
+
}
|
|
27155
|
+
}
|
|
27156
|
+
const current = recordOf(record2?.currentTier);
|
|
27157
|
+
return typeof current?.id === "string" ? current.id : DEFAULT_TIER;
|
|
27158
|
+
}
|
|
27159
|
+
function codeAssistRequest(url2, accessToken, body) {
|
|
27160
|
+
return postJsonRequest(url2, antigravityProfile, {
|
|
27161
|
+
contentType: "application/json",
|
|
27162
|
+
body: JSON.stringify(body),
|
|
27163
|
+
extraHeaders: [["Authorization", `Bearer ${accessToken}`]]
|
|
27164
|
+
});
|
|
27165
|
+
}
|
|
27166
|
+
async function* bootstrapProject(accessToken) {
|
|
27167
|
+
const loaded = yield codeAssistRequest(LOAD_CODE_ASSIST_URL, accessToken, {
|
|
27168
|
+
metadata: IDE_METADATA
|
|
27169
|
+
});
|
|
27170
|
+
const body = loaded.status >= 200 && loaded.status < 300 ? parsed(loaded.body) : null;
|
|
27171
|
+
const tier = tierFrom(body);
|
|
27172
|
+
const existing = projectFrom(body);
|
|
27173
|
+
if (existing.length > 0)
|
|
27174
|
+
return { projectId: existing, tier };
|
|
27175
|
+
const onboarded = yield codeAssistRequest(ONBOARD_USER_URL, accessToken, {
|
|
27176
|
+
tier_id: tier,
|
|
27177
|
+
metadata: IDE_METADATA
|
|
27178
|
+
});
|
|
27179
|
+
if (onboarded.status < 200 || onboarded.status >= 300)
|
|
27180
|
+
return { projectId: "", tier };
|
|
27181
|
+
const operation = recordOf(parsed(onboarded.body));
|
|
27182
|
+
return { projectId: projectFrom(operation?.response), tier };
|
|
27183
|
+
}
|
|
27184
|
+
async function* readEmail(accessToken) {
|
|
27185
|
+
const res = yield getJsonRequest(USERINFO_URL, antigravityProfile, { accessToken });
|
|
27186
|
+
if (res.status < 200 || res.status >= 300)
|
|
27187
|
+
return null;
|
|
27188
|
+
const record2 = recordOf(parsed(res.body));
|
|
27189
|
+
const email3 = record2?.email;
|
|
27190
|
+
return typeof email3 === "string" && email3.trim().length > 0 ? email3 : null;
|
|
27191
|
+
}
|
|
27192
|
+
function toResult2(token, fallbackRefresh, accountEmail, providerData, now) {
|
|
27193
|
+
return {
|
|
27194
|
+
secrets: {
|
|
27195
|
+
accessToken: token.accessToken,
|
|
27196
|
+
refreshToken: token.refreshToken ?? fallbackRefresh,
|
|
27197
|
+
apiKey: null,
|
|
27198
|
+
idToken: null
|
|
27199
|
+
},
|
|
27200
|
+
expiresAt: token.expiresIn === null ? null : now() + token.expiresIn * 1000,
|
|
27201
|
+
accountEmail,
|
|
27202
|
+
providerData
|
|
27203
|
+
};
|
|
27204
|
+
}
|
|
27205
|
+
var GEMINI_GROUP = /\bgemini\b/;
|
|
27206
|
+
function windowOf(bucket) {
|
|
27207
|
+
const text = `${String(bucket.bucketId ?? "")} ${String(bucket.displayName ?? "")}`.toLowerCase();
|
|
27208
|
+
if (/\bweekly\b|\bweek\b/.test(text))
|
|
27209
|
+
return "weekly";
|
|
27210
|
+
if (/\b5\s*-?\s*hour|\b5h\b|\bfive\s*hour/.test(text))
|
|
27211
|
+
return "fiveHour";
|
|
27212
|
+
return null;
|
|
27213
|
+
}
|
|
27214
|
+
function groupsOf(value) {
|
|
27215
|
+
const root = recordOf(value);
|
|
27216
|
+
if (root === null)
|
|
27217
|
+
return [];
|
|
27218
|
+
if (Array.isArray(root.groups))
|
|
27219
|
+
return root.groups;
|
|
27220
|
+
const nested = recordOf(root.quotaSummary)?.groups;
|
|
27221
|
+
return Array.isArray(nested) ? nested : [];
|
|
27222
|
+
}
|
|
27223
|
+
function parseAntigravityQuota(value, now) {
|
|
27224
|
+
const windows = [];
|
|
27225
|
+
for (const groupValue of groupsOf(value)) {
|
|
27226
|
+
const group = recordOf(groupValue);
|
|
27227
|
+
if (group === null)
|
|
27228
|
+
continue;
|
|
27229
|
+
if (!GEMINI_GROUP.test(String(group.displayName ?? "").toLowerCase()))
|
|
27230
|
+
continue;
|
|
27231
|
+
const buckets = Array.isArray(group.buckets) ? group.buckets : [];
|
|
27232
|
+
for (const bucketValue of buckets) {
|
|
27233
|
+
const bucket = recordOf(bucketValue);
|
|
27234
|
+
if (bucket === null || bucket.disabled === true)
|
|
27235
|
+
continue;
|
|
27236
|
+
const windowType = windowOf(bucket);
|
|
27237
|
+
if (windowType === null)
|
|
27238
|
+
continue;
|
|
27239
|
+
const fraction = numberOf(bucket, ["remainingFraction"]);
|
|
27240
|
+
if (fraction === null)
|
|
27241
|
+
continue;
|
|
27242
|
+
const remaining = Math.max(0, Math.min(1, fraction));
|
|
27243
|
+
windows.push({
|
|
27244
|
+
windowType,
|
|
27245
|
+
used: Math.round((1 - remaining) * 100),
|
|
27246
|
+
limit: 100,
|
|
27247
|
+
resetsAt: resetAtOf(bucket, { absolute: ["resetTime"] }, now),
|
|
27248
|
+
windowMs: null
|
|
27249
|
+
});
|
|
27250
|
+
}
|
|
27251
|
+
}
|
|
27252
|
+
return reportFrom(windows);
|
|
27253
|
+
}
|
|
27254
|
+
var antigravityOAuthFlow = {
|
|
27255
|
+
kind: "pkce",
|
|
27256
|
+
supportsManualPaste: true,
|
|
27257
|
+
async* start({ redirectUri, randomState }) {
|
|
27258
|
+
const state = randomState();
|
|
27259
|
+
const url2 = new URL(AUTHORIZE_URL2);
|
|
27260
|
+
url2.searchParams.set("client_id", CLIENT_ID2);
|
|
27261
|
+
url2.searchParams.set("response_type", "code");
|
|
27262
|
+
url2.searchParams.set("redirect_uri", redirectUri);
|
|
27263
|
+
url2.searchParams.set("scope", SCOPES2);
|
|
27264
|
+
url2.searchParams.set("state", state);
|
|
27265
|
+
url2.searchParams.set("access_type", "offline");
|
|
27266
|
+
url2.searchParams.set("prompt", "consent");
|
|
27267
|
+
return {
|
|
27268
|
+
authorizeUrl: url2.toString(),
|
|
27269
|
+
pending: { verifier: "", challenge: "", state, redirectUri }
|
|
27270
|
+
};
|
|
27271
|
+
},
|
|
27272
|
+
async* exchange({ code, pending, fail, now }) {
|
|
27273
|
+
const [rawCode, pastedState] = code.split("#");
|
|
27274
|
+
if (pastedState !== undefined && pastedState !== pending.state) {
|
|
27275
|
+
throw fail("AUTH", "authorization state mismatch");
|
|
27276
|
+
}
|
|
27277
|
+
const token = yield* postToken2({
|
|
27278
|
+
grant_type: "authorization_code",
|
|
27279
|
+
client_id: CLIENT_ID2,
|
|
27280
|
+
client_secret: CLIENT_SECRET,
|
|
27281
|
+
code: (rawCode ?? "").trim(),
|
|
27282
|
+
redirect_uri: pending.redirectUri
|
|
27283
|
+
}, fail);
|
|
27284
|
+
const email3 = yield* readEmail(token.accessToken);
|
|
27285
|
+
const { projectId, tier } = yield* bootstrapProject(token.accessToken);
|
|
27286
|
+
return toResult2(token, null, email3, { projectId, tier }, now);
|
|
27287
|
+
},
|
|
27288
|
+
async* refresh({ refreshToken, providerData, fail, now }) {
|
|
27289
|
+
const token = yield* postToken2({
|
|
27290
|
+
grant_type: "refresh_token",
|
|
27291
|
+
client_id: CLIENT_ID2,
|
|
27292
|
+
client_secret: CLIENT_SECRET,
|
|
27293
|
+
refresh_token: refreshToken
|
|
27294
|
+
}, fail);
|
|
27295
|
+
return toResult2(token, refreshToken, null, providerData, now);
|
|
27296
|
+
},
|
|
27297
|
+
async* usage({ secrets, providerData, now }) {
|
|
27298
|
+
const project = typeof providerData.projectId === "string" ? providerData.projectId : "";
|
|
27299
|
+
if (project.trim().length === 0)
|
|
27300
|
+
return null;
|
|
27301
|
+
const res = yield {
|
|
27302
|
+
...postJsonRequest(QUOTA_SUMMARY_URL, antigravityProfile, {
|
|
27303
|
+
contentType: "application/json",
|
|
27304
|
+
body: JSON.stringify({ project }),
|
|
27305
|
+
extraHeaders: [["Authorization", `Bearer ${secrets.accessToken}`]]
|
|
27306
|
+
}),
|
|
27307
|
+
timeoutMs: SHORT_TIMEOUT_MS
|
|
27308
|
+
};
|
|
27309
|
+
if (!usageReadable(res.status, "antigravity"))
|
|
27310
|
+
return null;
|
|
27311
|
+
return parseAntigravityQuota(parsed(res.body), now());
|
|
27312
|
+
}
|
|
27313
|
+
};
|
|
25927
27314
|
// packages/providers/src/grok/device.ts
|
|
25928
27315
|
import { randomUUID } from "crypto";
|
|
25929
27316
|
function mintGrokDevice() {
|
|
@@ -25937,10 +27324,10 @@ function grokDeviceHeaders(providerData) {
|
|
|
25937
27324
|
}
|
|
25938
27325
|
|
|
25939
27326
|
// packages/providers/src/grok/oauth.ts
|
|
25940
|
-
var
|
|
27327
|
+
var CLIENT_ID3 = "b1a00492-073a-47ea-816f-4c329264a828";
|
|
25941
27328
|
var ISSUER = "https://auth.x.ai";
|
|
25942
27329
|
var DISCOVERY_URL = `${ISSUER}/.well-known/openid-configuration`;
|
|
25943
|
-
var
|
|
27330
|
+
var SCOPES3 = [
|
|
25944
27331
|
"openid",
|
|
25945
27332
|
"profile",
|
|
25946
27333
|
"email",
|
|
@@ -25986,7 +27373,7 @@ async function* discover(fail) {
|
|
|
25986
27373
|
tokenUrl: trustedEndpoint(parsed2.token_endpoint, "token_endpoint", fail)
|
|
25987
27374
|
};
|
|
25988
27375
|
}
|
|
25989
|
-
function
|
|
27376
|
+
function parseTokenResponse2(value) {
|
|
25990
27377
|
if (!isRecord2(value) || typeof value.access_token !== "string")
|
|
25991
27378
|
return null;
|
|
25992
27379
|
return {
|
|
@@ -26002,15 +27389,15 @@ function emailFromIdToken(idToken) {
|
|
|
26002
27389
|
if (parts.length !== 3 || payload === undefined || payload.length === 0)
|
|
26003
27390
|
return null;
|
|
26004
27391
|
try {
|
|
26005
|
-
const
|
|
26006
|
-
if (!isRecord2(
|
|
27392
|
+
const json4 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
27393
|
+
if (!isRecord2(json4))
|
|
26007
27394
|
return null;
|
|
26008
|
-
return typeof
|
|
27395
|
+
return typeof json4.email === "string" && json4.email.trim().length > 0 ? json4.email : null;
|
|
26009
27396
|
} catch {
|
|
26010
27397
|
return null;
|
|
26011
27398
|
}
|
|
26012
27399
|
}
|
|
26013
|
-
async function*
|
|
27400
|
+
async function* postToken3(tokenUrl, body, fail) {
|
|
26014
27401
|
const res = yield postJsonRequest(tokenUrl, grokProfile, {
|
|
26015
27402
|
contentType: "application/x-www-form-urlencoded",
|
|
26016
27403
|
body: new URLSearchParams(body).toString()
|
|
@@ -26019,7 +27406,7 @@ async function* postToken2(tokenUrl, body, fail) {
|
|
|
26019
27406
|
if (res.status < 200 || res.status >= 300) {
|
|
26020
27407
|
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
26021
27408
|
}
|
|
26022
|
-
const token =
|
|
27409
|
+
const token = parseTokenResponse2(parsed2);
|
|
26023
27410
|
if (token === null) {
|
|
26024
27411
|
throw fail("AUTH", "token endpoint returned no access_token");
|
|
26025
27412
|
}
|
|
@@ -26029,7 +27416,7 @@ function agentIdFrom(providerData) {
|
|
|
26029
27416
|
const stored = providerData.agentId;
|
|
26030
27417
|
return typeof stored === "string" && stored.trim().length > 0 ? stored : mintGrokDevice().agentId;
|
|
26031
27418
|
}
|
|
26032
|
-
function
|
|
27419
|
+
function toResult3(token, fallbackRefresh, agentId, now) {
|
|
26033
27420
|
return {
|
|
26034
27421
|
secrets: {
|
|
26035
27422
|
accessToken: token.accessToken,
|
|
@@ -26051,9 +27438,9 @@ var grokOAuthFlow = {
|
|
|
26051
27438
|
const state = randomState();
|
|
26052
27439
|
const url2 = new URL(authorizeUrl);
|
|
26053
27440
|
url2.searchParams.set("response_type", "code");
|
|
26054
|
-
url2.searchParams.set("client_id",
|
|
27441
|
+
url2.searchParams.set("client_id", CLIENT_ID3);
|
|
26055
27442
|
url2.searchParams.set("redirect_uri", redirectUri);
|
|
26056
|
-
url2.searchParams.set("scope",
|
|
27443
|
+
url2.searchParams.set("scope", SCOPES3);
|
|
26057
27444
|
url2.searchParams.set("code_challenge", challenge);
|
|
26058
27445
|
url2.searchParams.set("code_challenge_method", "S256");
|
|
26059
27446
|
url2.searchParams.set("state", state);
|
|
@@ -26067,19 +27454,19 @@ var grokOAuthFlow = {
|
|
|
26067
27454
|
throw fail("AUTH", "authorization state mismatch");
|
|
26068
27455
|
}
|
|
26069
27456
|
const { tokenUrl } = yield* discover(fail);
|
|
26070
|
-
const token = yield*
|
|
27457
|
+
const token = yield* postToken3(tokenUrl, {
|
|
26071
27458
|
grant_type: "authorization_code",
|
|
26072
27459
|
code: (rawCode ?? "").trim(),
|
|
26073
27460
|
redirect_uri: pending.redirectUri,
|
|
26074
|
-
client_id:
|
|
27461
|
+
client_id: CLIENT_ID3,
|
|
26075
27462
|
code_verifier: pending.verifier
|
|
26076
27463
|
}, fail);
|
|
26077
|
-
return
|
|
27464
|
+
return toResult3(token, null, mintGrokDevice().agentId, now);
|
|
26078
27465
|
},
|
|
26079
27466
|
async* refresh({ refreshToken, providerData, fail, now }) {
|
|
26080
27467
|
const { tokenUrl } = yield* discover(fail);
|
|
26081
|
-
const token = yield*
|
|
26082
|
-
return
|
|
27468
|
+
const token = yield* postToken3(tokenUrl, { grant_type: "refresh_token", client_id: CLIENT_ID3, refresh_token: refreshToken }, fail);
|
|
27469
|
+
return toResult3(token, refreshToken, agentIdFrom(providerData), now);
|
|
26083
27470
|
}
|
|
26084
27471
|
};
|
|
26085
27472
|
|
|
@@ -26239,9 +27626,9 @@ function kimiDeviceHeaders(providerData) {
|
|
|
26239
27626
|
}
|
|
26240
27627
|
|
|
26241
27628
|
// packages/providers/src/kimi/oauth.ts
|
|
26242
|
-
var
|
|
27629
|
+
var CLIENT_ID4 = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
26243
27630
|
var DEVICE_CODE_URL = "https://auth.kimi.com/api/oauth/device_authorization";
|
|
26244
|
-
var
|
|
27631
|
+
var TOKEN_URL3 = "https://auth.kimi.com/api/oauth/token";
|
|
26245
27632
|
var USAGE_URL2 = "https://api.kimi.com/coding/v1/usages";
|
|
26246
27633
|
var DEFAULT_INTERVAL_SECONDS = 5;
|
|
26247
27634
|
var PENDING_ERRORS = new Set(["authorization_pending", "slow_down"]);
|
|
@@ -26295,7 +27682,7 @@ function deviceCodeFrom2(value, fail) {
|
|
|
26295
27682
|
async function* post(url2, body, device, fail, keepPolling) {
|
|
26296
27683
|
const res = yield postJsonRequest(url2, kimiProfile, {
|
|
26297
27684
|
contentType: "application/x-www-form-urlencoded",
|
|
26298
|
-
body: new URLSearchParams({ ...body, client_id:
|
|
27685
|
+
body: new URLSearchParams({ ...body, client_id: CLIENT_ID4 }).toString(),
|
|
26299
27686
|
extraHeaders: kimiDeviceHeaders(device)
|
|
26300
27687
|
});
|
|
26301
27688
|
const parsed2 = parsed(res.body);
|
|
@@ -26326,7 +27713,7 @@ function deviceFrom(source) {
|
|
|
26326
27713
|
function deviceForBegin(deviceId) {
|
|
26327
27714
|
return { ...mintKimiDevice(), deviceId };
|
|
26328
27715
|
}
|
|
26329
|
-
function
|
|
27716
|
+
function toResult4(token, device, fallbackRefresh, now) {
|
|
26330
27717
|
return {
|
|
26331
27718
|
secrets: {
|
|
26332
27719
|
accessToken: token.accessToken,
|
|
@@ -26381,17 +27768,17 @@ var kimiOAuthFlow = {
|
|
|
26381
27768
|
throw fail("INTERNAL", "kimi exchange requires a pending flow produced by begin()");
|
|
26382
27769
|
}
|
|
26383
27770
|
const device = deviceFrom(pending.extra);
|
|
26384
|
-
const token = tokenFrom(yield* post(
|
|
27771
|
+
const token = tokenFrom(yield* post(TOKEN_URL3, {
|
|
26385
27772
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
26386
27773
|
device_code: pending.deviceCode,
|
|
26387
27774
|
device_id: device.deviceId
|
|
26388
27775
|
}, device, fail, keepPolling), fail);
|
|
26389
|
-
return
|
|
27776
|
+
return toResult4(token, device, null, now);
|
|
26390
27777
|
},
|
|
26391
27778
|
async* refresh({ refreshToken, providerData, fail, keepPolling, now }) {
|
|
26392
27779
|
const device = deviceFrom(providerData);
|
|
26393
|
-
const token = tokenFrom(yield* post(
|
|
26394
|
-
return
|
|
27780
|
+
const token = tokenFrom(yield* post(TOKEN_URL3, { grant_type: "refresh_token", refresh_token: refreshToken, device_id: device.deviceId }, device, fail, keepPolling), fail);
|
|
27781
|
+
return toResult4(token, device, refreshToken, now);
|
|
26395
27782
|
},
|
|
26396
27783
|
async* usage({ secrets, providerData, now }) {
|
|
26397
27784
|
if (secrets.accessToken === null)
|
|
@@ -26407,13 +27794,225 @@ var kimiOAuthFlow = {
|
|
|
26407
27794
|
}
|
|
26408
27795
|
};
|
|
26409
27796
|
|
|
27797
|
+
// packages/providers/src/muse/endpoint.ts
|
|
27798
|
+
var TRUSTED_HOST2 = "meta.ai";
|
|
27799
|
+
var MUSE_DEFAULT_BASE_URL = "https://api.meta.ai/v1";
|
|
27800
|
+
function trustedBaseUrl(value) {
|
|
27801
|
+
if (typeof value !== "string" || value.length === 0)
|
|
27802
|
+
return null;
|
|
27803
|
+
let url2;
|
|
27804
|
+
try {
|
|
27805
|
+
url2 = new URL(value);
|
|
27806
|
+
} catch {
|
|
27807
|
+
return null;
|
|
27808
|
+
}
|
|
27809
|
+
if (url2.protocol !== "https:")
|
|
27810
|
+
return null;
|
|
27811
|
+
const host2 = url2.hostname;
|
|
27812
|
+
if (host2 !== TRUSTED_HOST2 && !host2.endsWith(`.${TRUSTED_HOST2}`))
|
|
27813
|
+
return null;
|
|
27814
|
+
return `${url2.origin}${url2.pathname}`.replace(/\/$/, "");
|
|
27815
|
+
}
|
|
27816
|
+
function museResponsesUrl(providerData) {
|
|
27817
|
+
return `${trustedBaseUrl(providerData.baseUrl) ?? MUSE_DEFAULT_BASE_URL}/responses`;
|
|
27818
|
+
}
|
|
27819
|
+
|
|
27820
|
+
// packages/providers/src/muse/oauth.ts
|
|
27821
|
+
var AUTH_BASE = "https://auth.meta.com";
|
|
27822
|
+
var DEVICE_CODE_URL2 = `${AUTH_BASE}/oidc/device/authorization/`;
|
|
27823
|
+
var TOKEN_URL4 = `${AUTH_BASE}/oidc/device/token/`;
|
|
27824
|
+
var MINT_URL = "https://api.meta.ai/muse-code/key";
|
|
27825
|
+
var CLIENT_ID5 = "1031625952748946";
|
|
27826
|
+
var DEVICE_CODE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
27827
|
+
var FALLBACK_VERIFICATION_URL2 = "https://auth.meta.com/oauth/device/";
|
|
27828
|
+
var DEFAULT_INTERVAL_SECONDS2 = 5;
|
|
27829
|
+
var PENDING_ERRORS2 = new Set(["authorization_pending", "slow_down"]);
|
|
27830
|
+
function isRecord5(value) {
|
|
27831
|
+
return typeof value === "object" && value !== null;
|
|
27832
|
+
}
|
|
27833
|
+
function recordFrom3(value) {
|
|
27834
|
+
return isRecord5(value) ? value : null;
|
|
27835
|
+
}
|
|
27836
|
+
function stringFrom3(value, field) {
|
|
27837
|
+
const candidate = value[field];
|
|
27838
|
+
return typeof candidate === "string" && candidate.trim().length > 0 ? candidate : null;
|
|
27839
|
+
}
|
|
27840
|
+
function positiveNumberFrom3(value, field) {
|
|
27841
|
+
const candidate = value[field];
|
|
27842
|
+
return typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0 ? candidate : null;
|
|
27843
|
+
}
|
|
27844
|
+
function tokenFrom2(value, fail) {
|
|
27845
|
+
const record2 = recordFrom3(value);
|
|
27846
|
+
const accessToken = record2 === null ? null : stringFrom3(record2, "access_token");
|
|
27847
|
+
if (record2 === null || accessToken === null) {
|
|
27848
|
+
throw fail("AUTH", "token endpoint returned no access_token");
|
|
27849
|
+
}
|
|
27850
|
+
return {
|
|
27851
|
+
accessToken,
|
|
27852
|
+
refreshToken: stringFrom3(record2, "refresh_token"),
|
|
27853
|
+
expiresIn: positiveNumberFrom3(record2, "expires_in")
|
|
27854
|
+
};
|
|
27855
|
+
}
|
|
27856
|
+
function deviceCodeFrom3(value, fail) {
|
|
27857
|
+
const record2 = recordFrom3(value);
|
|
27858
|
+
const deviceCode = record2 === null ? null : stringFrom3(record2, "device_code");
|
|
27859
|
+
const userCode = record2 === null ? null : stringFrom3(record2, "user_code");
|
|
27860
|
+
if (record2 === null || deviceCode === null || userCode === null) {
|
|
27861
|
+
throw fail("AUTH", "device authorization response missing user_code or verification_uri");
|
|
27862
|
+
}
|
|
27863
|
+
return {
|
|
27864
|
+
deviceCode,
|
|
27865
|
+
userCode,
|
|
27866
|
+
verificationUri: stringFrom3(record2, "verification_uri_complete") ?? stringFrom3(record2, "verification_uri") ?? FALLBACK_VERIFICATION_URL2,
|
|
27867
|
+
interval: positiveNumberFrom3(record2, "interval") ?? DEFAULT_INTERVAL_SECONDS2
|
|
27868
|
+
};
|
|
27869
|
+
}
|
|
27870
|
+
async function* postForm(url2, body, fail, keepPolling) {
|
|
27871
|
+
const res = yield postJsonRequest(url2, museProfile, {
|
|
27872
|
+
contentType: "application/x-www-form-urlencoded",
|
|
27873
|
+
body: new URLSearchParams({ ...body, client_id: CLIENT_ID5 }).toString(),
|
|
27874
|
+
extraHeaders: [["Accept", "application/json"]]
|
|
27875
|
+
});
|
|
27876
|
+
const parsed2 = parsed(res.body);
|
|
27877
|
+
if (res.status >= 200 && res.status < 300)
|
|
27878
|
+
return parsed2;
|
|
27879
|
+
const record2 = recordFrom3(parsed2);
|
|
27880
|
+
const code = record2 === null ? `http_${res.status}` : stringFrom3(record2, "error") ?? `http_${res.status}`;
|
|
27881
|
+
if (PENDING_ERRORS2.has(code))
|
|
27882
|
+
throw keepPolling(code);
|
|
27883
|
+
if (code === "expired_token") {
|
|
27884
|
+
throw fail("AUTH", "muse device code expired; start the authorization again");
|
|
27885
|
+
}
|
|
27886
|
+
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
27887
|
+
}
|
|
27888
|
+
async function* mint(accessToken, fail) {
|
|
27889
|
+
const res = yield postJsonRequest(MINT_URL, museProfile, {
|
|
27890
|
+
contentType: "application/json",
|
|
27891
|
+
body: "{}",
|
|
27892
|
+
extraHeaders: [
|
|
27893
|
+
["Authorization", `Bearer ${accessToken}`],
|
|
27894
|
+
["Accept", "application/json"]
|
|
27895
|
+
]
|
|
27896
|
+
});
|
|
27897
|
+
const parsed2 = parsed(res.body);
|
|
27898
|
+
if (res.status < 200 || res.status >= 300) {
|
|
27899
|
+
if (res.status === 401 || res.status === 403) {
|
|
27900
|
+
throw fail("AUTH", "muse rejected the saved login; reconnect the account or use a different one");
|
|
27901
|
+
}
|
|
27902
|
+
if (res.status === 429) {
|
|
27903
|
+
throw fail("RATE_LIMIT", `muse rate limited the key mint: http_${res.status}`);
|
|
27904
|
+
}
|
|
27905
|
+
throw fail("UPSTREAM", `muse key mint failed: http_${res.status}`);
|
|
27906
|
+
}
|
|
27907
|
+
const record2 = recordFrom3(parsed2);
|
|
27908
|
+
if (record2 === null) {
|
|
27909
|
+
throw fail("UPSTREAM", "muse key mint returned an unusable response");
|
|
27910
|
+
}
|
|
27911
|
+
if (record2.require_payment === true) {
|
|
27912
|
+
throw fail("AUTH", "muse requires a payment method on the Meta account; add one at https://dev.meta.ai and reconnect");
|
|
27913
|
+
}
|
|
27914
|
+
const apiKey = stringFrom3(record2, "api_key");
|
|
27915
|
+
if (apiKey === null) {
|
|
27916
|
+
throw fail("AUTH", "muse key mint returned an empty api key; finish onboarding at https://dev.meta.ai and reconnect");
|
|
27917
|
+
}
|
|
27918
|
+
return {
|
|
27919
|
+
apiKey,
|
|
27920
|
+
email: stringFrom3(record2, "user_email"),
|
|
27921
|
+
tierName: stringFrom3(record2, "subs_tier_name"),
|
|
27922
|
+
subscriptionActive: record2.is_subs_active === true,
|
|
27923
|
+
baseUrl: trustedBaseUrl(record2.base_url),
|
|
27924
|
+
usage: record2.subs_usage
|
|
27925
|
+
};
|
|
27926
|
+
}
|
|
27927
|
+
function toResult5(token, key, fallbackRefresh, now) {
|
|
27928
|
+
return {
|
|
27929
|
+
secrets: {
|
|
27930
|
+
accessToken: token.accessToken,
|
|
27931
|
+
refreshToken: token.refreshToken ?? fallbackRefresh,
|
|
27932
|
+
apiKey: key.apiKey,
|
|
27933
|
+
idToken: null
|
|
27934
|
+
},
|
|
27935
|
+
expiresAt: token.expiresIn === null ? null : now() + token.expiresIn * 1000,
|
|
27936
|
+
accountEmail: key.email,
|
|
27937
|
+
providerData: {
|
|
27938
|
+
...key.tierName === null ? {} : { subscriptionTier: key.tierName },
|
|
27939
|
+
subscriptionActive: key.subscriptionActive,
|
|
27940
|
+
...key.baseUrl === null ? {} : { baseUrl: key.baseUrl }
|
|
27941
|
+
}
|
|
27942
|
+
};
|
|
27943
|
+
}
|
|
27944
|
+
var museOAuthFlow = {
|
|
27945
|
+
kind: "device",
|
|
27946
|
+
supportsManualPaste: false,
|
|
27947
|
+
needsDeviceId: false,
|
|
27948
|
+
async* start() {
|
|
27949
|
+
return {
|
|
27950
|
+
authorizeUrl: FALLBACK_VERIFICATION_URL2,
|
|
27951
|
+
pending: { verifier: "", challenge: "", state: "", redirectUri: "" }
|
|
27952
|
+
};
|
|
27953
|
+
},
|
|
27954
|
+
async* begin({ fail, keepPolling }) {
|
|
27955
|
+
const response = deviceCodeFrom3(yield* postForm(DEVICE_CODE_URL2, {}, fail, keepPolling), fail);
|
|
27956
|
+
return {
|
|
27957
|
+
authorizeUrl: response.verificationUri,
|
|
27958
|
+
userCode: response.userCode,
|
|
27959
|
+
pending: {
|
|
27960
|
+
verifier: "",
|
|
27961
|
+
challenge: "",
|
|
27962
|
+
state: "",
|
|
27963
|
+
redirectUri: "",
|
|
27964
|
+
deviceCode: response.deviceCode,
|
|
27965
|
+
interval: response.interval
|
|
27966
|
+
}
|
|
27967
|
+
};
|
|
27968
|
+
},
|
|
27969
|
+
async* exchange({ pending, fail, keepPolling, now }) {
|
|
27970
|
+
if (pending.deviceCode === undefined) {
|
|
27971
|
+
throw fail("INTERNAL", "muse exchange requires a pending flow produced by begin()");
|
|
27972
|
+
}
|
|
27973
|
+
const token = tokenFrom2(yield* postForm(TOKEN_URL4, { grant_type: DEVICE_CODE_GRANT, device_code: pending.deviceCode }, fail, keepPolling), fail);
|
|
27974
|
+
return toResult5(token, yield* mint(token.accessToken, fail), null, now);
|
|
27975
|
+
},
|
|
27976
|
+
async* refresh({ refreshToken, fail, keepPolling, now }) {
|
|
27977
|
+
const token = tokenFrom2(yield* postForm(TOKEN_URL4, { grant_type: "refresh_token", refresh_token: refreshToken }, fail, keepPolling), fail);
|
|
27978
|
+
return toResult5(token, yield* mint(token.accessToken, fail), refreshToken, now);
|
|
27979
|
+
},
|
|
27980
|
+
async* usage({ secrets, now }) {
|
|
27981
|
+
if (secrets.accessToken === null)
|
|
27982
|
+
return null;
|
|
27983
|
+
const res = yield postJsonRequest(MINT_URL, museProfile, {
|
|
27984
|
+
contentType: "application/json",
|
|
27985
|
+
body: "{}",
|
|
27986
|
+
extraHeaders: [
|
|
27987
|
+
["Authorization", `Bearer ${secrets.accessToken}`],
|
|
27988
|
+
["Accept", "application/json"]
|
|
27989
|
+
]
|
|
27990
|
+
});
|
|
27991
|
+
if (!usageReadable(res.status, "muse"))
|
|
27992
|
+
return null;
|
|
27993
|
+
const record2 = recordOf(parsed(res.body));
|
|
27994
|
+
return record2 === null ? null : parseMuseUsage(record2.subs_usage, now());
|
|
27995
|
+
}
|
|
27996
|
+
};
|
|
27997
|
+
function parseMuseUsage(value, now) {
|
|
27998
|
+
const root = recordOf(value);
|
|
27999
|
+
if (root === null)
|
|
28000
|
+
return null;
|
|
28001
|
+
const window = recordOf(root.window);
|
|
28002
|
+
const mins = window === null ? null : numberOf(window, ["window_duration_mins"]);
|
|
28003
|
+
return reportFrom([
|
|
28004
|
+
windowFrom(root.window, "fiveHour", now, mins === null ? null : mins * 60000),
|
|
28005
|
+
windowFrom(root.weekly, "weekly", now)
|
|
28006
|
+
]);
|
|
28007
|
+
}
|
|
28008
|
+
|
|
26410
28009
|
// packages/providers/src/openai/oauth.ts
|
|
26411
|
-
var
|
|
26412
|
-
var
|
|
26413
|
-
var
|
|
26414
|
-
var
|
|
28010
|
+
var CLIENT_ID6 = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
28011
|
+
var AUTHORIZE_URL3 = "https://auth.openai.com/oauth/authorize";
|
|
28012
|
+
var TOKEN_URL5 = "https://auth.openai.com/oauth/token";
|
|
28013
|
+
var SCOPES4 = "openid profile email offline_access";
|
|
26415
28014
|
var USAGE_URL3 = "https://chatgpt.com/backend-api/wham/usage";
|
|
26416
|
-
function
|
|
28015
|
+
function isRecord6(value) {
|
|
26417
28016
|
return typeof value === "object" && value !== null;
|
|
26418
28017
|
}
|
|
26419
28018
|
function nonBlankStringOrNull(value) {
|
|
@@ -26429,20 +28028,20 @@ function decodeClaims(idToken) {
|
|
|
26429
28028
|
return { email: null, accountId: null };
|
|
26430
28029
|
}
|
|
26431
28030
|
try {
|
|
26432
|
-
const
|
|
26433
|
-
if (!
|
|
28031
|
+
const json4 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
28032
|
+
if (!isRecord6(json4))
|
|
26434
28033
|
return { email: null, accountId: null };
|
|
26435
|
-
const auth =
|
|
28034
|
+
const auth = json4["https://api.openai.com/auth"];
|
|
26436
28035
|
return {
|
|
26437
|
-
email: typeof
|
|
26438
|
-
accountId:
|
|
28036
|
+
email: typeof json4.email === "string" ? json4.email : null,
|
|
28037
|
+
accountId: isRecord6(auth) ? nonBlankStringOrNull(auth.chatgpt_account_id) : null
|
|
26439
28038
|
};
|
|
26440
28039
|
} catch {
|
|
26441
28040
|
return { email: null, accountId: null };
|
|
26442
28041
|
}
|
|
26443
28042
|
}
|
|
26444
|
-
function
|
|
26445
|
-
if (!
|
|
28043
|
+
function parseTokenResponse3(value) {
|
|
28044
|
+
if (!isRecord6(value) || typeof value.access_token !== "string")
|
|
26446
28045
|
return null;
|
|
26447
28046
|
return {
|
|
26448
28047
|
accessToken: value.access_token,
|
|
@@ -26451,22 +28050,22 @@ function parseTokenResponse2(value) {
|
|
|
26451
28050
|
idToken: typeof value.id_token === "string" ? value.id_token : null
|
|
26452
28051
|
};
|
|
26453
28052
|
}
|
|
26454
|
-
async function*
|
|
26455
|
-
const res = yield postJsonRequest(
|
|
28053
|
+
async function* postToken4(body, fail) {
|
|
28054
|
+
const res = yield postJsonRequest(TOKEN_URL5, openaiProfile, {
|
|
26456
28055
|
contentType: "application/x-www-form-urlencoded",
|
|
26457
|
-
body: new URLSearchParams({ ...body, client_id:
|
|
28056
|
+
body: new URLSearchParams({ ...body, client_id: CLIENT_ID6 }).toString()
|
|
26458
28057
|
});
|
|
26459
28058
|
const parsed2 = parsed(res.body);
|
|
26460
28059
|
if (res.status < 200 || res.status >= 300) {
|
|
26461
28060
|
throw fail(tokenErrorCode(res.status), tokenErrorMessage(res.status, parsed2));
|
|
26462
28061
|
}
|
|
26463
|
-
const token =
|
|
28062
|
+
const token = parseTokenResponse3(parsed2);
|
|
26464
28063
|
if (token === null) {
|
|
26465
28064
|
throw fail("AUTH", "token endpoint returned no access_token");
|
|
26466
28065
|
}
|
|
26467
28066
|
return token;
|
|
26468
28067
|
}
|
|
26469
|
-
function
|
|
28068
|
+
function toResult6(token, fallbackRefresh, now, fallbackAccountId = null) {
|
|
26470
28069
|
const claims = decodeClaims(token.idToken);
|
|
26471
28070
|
return {
|
|
26472
28071
|
secrets: {
|
|
@@ -26524,11 +28123,11 @@ var openaiOAuthFlow = {
|
|
|
26524
28123
|
async* start({ redirectUri, pkce, randomState }) {
|
|
26525
28124
|
const { verifier, challenge } = pkce();
|
|
26526
28125
|
const state = randomState();
|
|
26527
|
-
const url2 = new URL(
|
|
26528
|
-
url2.searchParams.set("client_id",
|
|
28126
|
+
const url2 = new URL(AUTHORIZE_URL3);
|
|
28127
|
+
url2.searchParams.set("client_id", CLIENT_ID6);
|
|
26529
28128
|
url2.searchParams.set("response_type", "code");
|
|
26530
28129
|
url2.searchParams.set("redirect_uri", redirectUri);
|
|
26531
|
-
url2.searchParams.set("scope",
|
|
28130
|
+
url2.searchParams.set("scope", SCOPES4);
|
|
26532
28131
|
url2.searchParams.set("code_challenge", challenge);
|
|
26533
28132
|
url2.searchParams.set("code_challenge_method", "S256");
|
|
26534
28133
|
url2.searchParams.set("id_token_add_organizations", "true");
|
|
@@ -26543,17 +28142,17 @@ var openaiOAuthFlow = {
|
|
|
26543
28142
|
if (pastedState !== undefined && pastedState !== pending.state) {
|
|
26544
28143
|
throw fail("AUTH", "authorization state mismatch");
|
|
26545
28144
|
}
|
|
26546
|
-
const token = yield*
|
|
28145
|
+
const token = yield* postToken4({
|
|
26547
28146
|
grant_type: "authorization_code",
|
|
26548
28147
|
code: (rawCode ?? "").trim(),
|
|
26549
28148
|
redirect_uri: pending.redirectUri,
|
|
26550
28149
|
code_verifier: pending.verifier
|
|
26551
28150
|
}, fail);
|
|
26552
|
-
return
|
|
28151
|
+
return toResult6(token, null, now);
|
|
26553
28152
|
},
|
|
26554
28153
|
async* refresh({ refreshToken, providerData, fail, now }) {
|
|
26555
|
-
const token = yield*
|
|
26556
|
-
return
|
|
28154
|
+
const token = yield* postToken4({ grant_type: "refresh_token", refresh_token: refreshToken, scope: SCOPES4 }, fail);
|
|
28155
|
+
return toResult6(token, refreshToken, now, accountIdFromProviderData(providerData));
|
|
26557
28156
|
},
|
|
26558
28157
|
async* usage({ secrets, providerData, now }) {
|
|
26559
28158
|
if (secrets.accessToken === null)
|
|
@@ -26576,7 +28175,9 @@ function builtinOAuthFlows() {
|
|
|
26576
28175
|
["openai", openaiOAuthFlow],
|
|
26577
28176
|
["kimi", kimiOAuthFlow],
|
|
26578
28177
|
["kilo", kiloOAuthFlow],
|
|
26579
|
-
["grok", grokOAuthFlow]
|
|
28178
|
+
["grok", grokOAuthFlow],
|
|
28179
|
+
["antigravity", antigravityOAuthFlow],
|
|
28180
|
+
["muse", museOAuthFlow]
|
|
26580
28181
|
];
|
|
26581
28182
|
}
|
|
26582
28183
|
// packages/providers/src/custom/decode.ts
|
|
@@ -26604,7 +28205,7 @@ function reasoningText(delta) {
|
|
|
26604
28205
|
return [];
|
|
26605
28206
|
}).join("");
|
|
26606
28207
|
}
|
|
26607
|
-
function
|
|
28208
|
+
function json4(data) {
|
|
26608
28209
|
try {
|
|
26609
28210
|
const v = JSON.parse(data);
|
|
26610
28211
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -26626,7 +28227,7 @@ async function* decodeCustomChat(messages) {
|
|
|
26626
28227
|
done = true;
|
|
26627
28228
|
break;
|
|
26628
28229
|
}
|
|
26629
|
-
const d =
|
|
28230
|
+
const d = json4(msg.data);
|
|
26630
28231
|
if (d === null)
|
|
26631
28232
|
continue;
|
|
26632
28233
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -26784,7 +28385,7 @@ async function* decodeCustomResponses(messages) {
|
|
|
26784
28385
|
};
|
|
26785
28386
|
return;
|
|
26786
28387
|
}
|
|
26787
|
-
const d =
|
|
28388
|
+
const d = json4(msg.data);
|
|
26788
28389
|
if (d === null)
|
|
26789
28390
|
continue;
|
|
26790
28391
|
switch (msg.event) {
|
|
@@ -27172,10 +28773,10 @@ var customCodec = {
|
|
|
27172
28773
|
// packages/providers/src/custom/index.ts
|
|
27173
28774
|
var customAdapter = codecAdapter("custom", customDescriptor.capabilities, customCodec);
|
|
27174
28775
|
// packages/providers/src/grok/codec.ts
|
|
27175
|
-
import { createHash as
|
|
28776
|
+
import { createHash as createHash4 } from "crypto";
|
|
27176
28777
|
|
|
27177
28778
|
// packages/providers/src/grok/decode.ts
|
|
27178
|
-
var
|
|
28779
|
+
var ERROR_CODE2 = {
|
|
27179
28780
|
rate_limit_exceeded: "RATE_LIMIT",
|
|
27180
28781
|
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
27181
28782
|
invalid_api_key: "AUTH",
|
|
@@ -27209,7 +28810,7 @@ var KNOWN_EVENTS2 = new Set([
|
|
|
27209
28810
|
"response.failed",
|
|
27210
28811
|
"error"
|
|
27211
28812
|
]);
|
|
27212
|
-
function
|
|
28813
|
+
function json5(data) {
|
|
27213
28814
|
try {
|
|
27214
28815
|
const v = JSON.parse(data);
|
|
27215
28816
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -27244,7 +28845,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
27244
28845
|
};
|
|
27245
28846
|
return;
|
|
27246
28847
|
}
|
|
27247
|
-
const d =
|
|
28848
|
+
const d = json5(msg.data);
|
|
27248
28849
|
if (d === null)
|
|
27249
28850
|
continue;
|
|
27250
28851
|
switch (msg.event) {
|
|
@@ -27347,7 +28948,7 @@ async function* decodeGrokResponses(messages) {
|
|
|
27347
28948
|
terminal = true;
|
|
27348
28949
|
const err = d.response?.error ?? d.error ?? {};
|
|
27349
28950
|
const raw = String(err.code ?? err.type);
|
|
27350
|
-
const code = (Object.hasOwn(
|
|
28951
|
+
const code = (Object.hasOwn(ERROR_CODE2, raw) ? ERROR_CODE2[raw] : undefined) ?? "UPSTREAM";
|
|
27351
28952
|
yield {
|
|
27352
28953
|
type: "error",
|
|
27353
28954
|
code,
|
|
@@ -27371,9 +28972,9 @@ async function* decodeGrokResponses(messages) {
|
|
|
27371
28972
|
}
|
|
27372
28973
|
|
|
27373
28974
|
// packages/providers/src/grok/wire.ts
|
|
27374
|
-
import { createHash as
|
|
28975
|
+
import { createHash as createHash3 } from "crypto";
|
|
27375
28976
|
var MAX_TOOLS = 200;
|
|
27376
|
-
function
|
|
28977
|
+
function encodeToolChoice3(c) {
|
|
27377
28978
|
switch (c.type) {
|
|
27378
28979
|
case "auto":
|
|
27379
28980
|
return "auto";
|
|
@@ -27387,7 +28988,7 @@ function encodeToolChoice2(c) {
|
|
|
27387
28988
|
}
|
|
27388
28989
|
function promptCacheKey(instructions, firstInput) {
|
|
27389
28990
|
const stable = JSON.stringify({ instructions, firstInput });
|
|
27390
|
-
return
|
|
28991
|
+
return createHash3("sha256").update(stable).digest("hex").slice(0, 32);
|
|
27391
28992
|
}
|
|
27392
28993
|
function toGrokWire(req, model) {
|
|
27393
28994
|
const degradations = [];
|
|
@@ -27480,7 +29081,7 @@ function toGrokWire(req, model) {
|
|
|
27480
29081
|
}));
|
|
27481
29082
|
}
|
|
27482
29083
|
if (req.toolChoice !== undefined)
|
|
27483
|
-
body.tool_choice =
|
|
29084
|
+
body.tool_choice = encodeToolChoice3(req.toolChoice);
|
|
27484
29085
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
27485
29086
|
if (req.reasoning.mode === "budget") {
|
|
27486
29087
|
note2("grok:reasoning-budget-dropped");
|
|
@@ -27498,7 +29099,7 @@ var PROXY_URL = "https://cli-chat-proxy.grok.com/v1/responses";
|
|
|
27498
29099
|
var API_URL = "https://api.x.ai/v1/responses";
|
|
27499
29100
|
var CONV_NAMESPACE = "omni-grok-conv";
|
|
27500
29101
|
function derivedUuid(value) {
|
|
27501
|
-
const h =
|
|
29102
|
+
const h = createHash4("sha256").update(`${CONV_NAMESPACE}:${value}`).digest("hex");
|
|
27502
29103
|
const variant = (Number.parseInt(h[16], 16) & 3 | 8).toString(16);
|
|
27503
29104
|
return [
|
|
27504
29105
|
h.slice(0, 8),
|
|
@@ -27681,7 +29282,7 @@ function reasoningText2(delta) {
|
|
|
27681
29282
|
return [];
|
|
27682
29283
|
}).join("");
|
|
27683
29284
|
}
|
|
27684
|
-
function
|
|
29285
|
+
function json6(data) {
|
|
27685
29286
|
try {
|
|
27686
29287
|
const v = JSON.parse(data);
|
|
27687
29288
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -27703,7 +29304,7 @@ async function* decodeKiloChat(messages) {
|
|
|
27703
29304
|
done = true;
|
|
27704
29305
|
break;
|
|
27705
29306
|
}
|
|
27706
|
-
const d =
|
|
29307
|
+
const d = json6(msg.data);
|
|
27707
29308
|
if (d === null)
|
|
27708
29309
|
continue;
|
|
27709
29310
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -27803,7 +29404,7 @@ async function* decodeKiloChat(messages) {
|
|
|
27803
29404
|
}
|
|
27804
29405
|
|
|
27805
29406
|
// packages/providers/src/kilo/wire.ts
|
|
27806
|
-
function
|
|
29407
|
+
function encodeToolChoice4(c) {
|
|
27807
29408
|
switch (c.type) {
|
|
27808
29409
|
case "auto":
|
|
27809
29410
|
return "auto";
|
|
@@ -27914,7 +29515,7 @@ function toKiloWire(req, model) {
|
|
|
27914
29515
|
}));
|
|
27915
29516
|
}
|
|
27916
29517
|
if (req.toolChoice !== undefined)
|
|
27917
|
-
body.tool_choice =
|
|
29518
|
+
body.tool_choice = encodeToolChoice4(req.toolChoice);
|
|
27918
29519
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
27919
29520
|
if (req.reasoning.mode === "budget") {
|
|
27920
29521
|
body.reasoning = { max_tokens: req.reasoning.budgetTokens };
|
|
@@ -27973,7 +29574,7 @@ var FINISH2 = {
|
|
|
27973
29574
|
tool_calls: "toolUse",
|
|
27974
29575
|
content_filter: "contentFilter"
|
|
27975
29576
|
};
|
|
27976
|
-
function
|
|
29577
|
+
function json7(data) {
|
|
27977
29578
|
try {
|
|
27978
29579
|
const v = JSON.parse(data);
|
|
27979
29580
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -27995,7 +29596,7 @@ async function* decodeChat(messages) {
|
|
|
27995
29596
|
done = true;
|
|
27996
29597
|
break;
|
|
27997
29598
|
}
|
|
27998
|
-
const d =
|
|
29599
|
+
const d = json7(msg.data);
|
|
27999
29600
|
if (d === null)
|
|
28000
29601
|
continue;
|
|
28001
29602
|
if (!started && (d.id !== undefined || d.model !== undefined)) {
|
|
@@ -28079,7 +29680,7 @@ async function* decodeChat(messages) {
|
|
|
28079
29680
|
}
|
|
28080
29681
|
|
|
28081
29682
|
// packages/providers/src/kimi/wire.ts
|
|
28082
|
-
function
|
|
29683
|
+
function encodeToolChoice5(c) {
|
|
28083
29684
|
switch (c.type) {
|
|
28084
29685
|
case "auto":
|
|
28085
29686
|
return "auto";
|
|
@@ -28170,7 +29771,7 @@ function toChatWire(req, model, vendor = "kimi") {
|
|
|
28170
29771
|
}));
|
|
28171
29772
|
}
|
|
28172
29773
|
if (req.toolChoice !== undefined)
|
|
28173
|
-
body.tool_choice =
|
|
29774
|
+
body.tool_choice = encodeToolChoice5(req.toolChoice);
|
|
28174
29775
|
if (req.reasoning !== undefined)
|
|
28175
29776
|
note2("kimi:reasoning-dropped");
|
|
28176
29777
|
Object.assign(body, req.vendor?.[vendor] ?? {});
|
|
@@ -28210,8 +29811,8 @@ var kimiCodec = {
|
|
|
28210
29811
|
|
|
28211
29812
|
// packages/providers/src/kimi/index.ts
|
|
28212
29813
|
var kimiAdapter = codecAdapter("kimi", kimiDescriptor.capabilities, kimiCodec);
|
|
28213
|
-
// packages/providers/src/
|
|
28214
|
-
var
|
|
29814
|
+
// packages/providers/src/muse/decode.ts
|
|
29815
|
+
var ERROR_CODE3 = {
|
|
28215
29816
|
rate_limit_exceeded: "RATE_LIMIT",
|
|
28216
29817
|
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
28217
29818
|
invalid_api_key: "AUTH",
|
|
@@ -28246,7 +29847,7 @@ var KNOWN_EVENTS3 = new Set([
|
|
|
28246
29847
|
"response.failed",
|
|
28247
29848
|
"error"
|
|
28248
29849
|
]);
|
|
28249
|
-
function
|
|
29850
|
+
function json8(data) {
|
|
28250
29851
|
try {
|
|
28251
29852
|
const v = JSON.parse(data);
|
|
28252
29853
|
return typeof v === "object" && v !== null ? v : null;
|
|
@@ -28254,7 +29855,7 @@ function json7(data) {
|
|
|
28254
29855
|
return null;
|
|
28255
29856
|
}
|
|
28256
29857
|
}
|
|
28257
|
-
async function*
|
|
29858
|
+
async function* decodeMuseResponses(messages, options = {}) {
|
|
28258
29859
|
const nativeReasoning = options.nativeReasoning === true;
|
|
28259
29860
|
const indices = new Map;
|
|
28260
29861
|
let next = 0;
|
|
@@ -28277,12 +29878,12 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28277
29878
|
yield {
|
|
28278
29879
|
type: "error",
|
|
28279
29880
|
code: "UPSTREAM",
|
|
28280
|
-
message: `unrecognized
|
|
29881
|
+
message: `unrecognized muse stream event "${msg.event}"`,
|
|
28281
29882
|
retryable: false
|
|
28282
29883
|
};
|
|
28283
29884
|
return;
|
|
28284
29885
|
}
|
|
28285
|
-
const d =
|
|
29886
|
+
const d = json8(msg.data);
|
|
28286
29887
|
if (d === null)
|
|
28287
29888
|
continue;
|
|
28288
29889
|
switch (msg.event) {
|
|
@@ -28300,7 +29901,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28300
29901
|
yield {
|
|
28301
29902
|
type: "blockStart",
|
|
28302
29903
|
index: irIndex(d.output_index ?? 0),
|
|
28303
|
-
block: nativeReasoning ? { type: "providerNative", provider: "
|
|
29904
|
+
block: nativeReasoning ? { type: "providerNative", provider: "muse", blockType: "reasoning", data: {} } : { type: "thinking" }
|
|
28304
29905
|
};
|
|
28305
29906
|
} else if (item.type === "function_call") {
|
|
28306
29907
|
sawToolCall = true;
|
|
@@ -28335,7 +29936,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28335
29936
|
index: irIndex(d.output_index ?? 0),
|
|
28336
29937
|
delta: nativeReasoning ? {
|
|
28337
29938
|
type: "providerNative",
|
|
28338
|
-
provider: "
|
|
29939
|
+
provider: "muse",
|
|
28339
29940
|
deltaType: "reasoning_summary_text.delta",
|
|
28340
29941
|
data: { text: String(d.delta ?? "") }
|
|
28341
29942
|
} : { type: "thinking", text: String(d.delta ?? "") }
|
|
@@ -28361,7 +29962,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28361
29962
|
index: irIndex(outputIndex),
|
|
28362
29963
|
delta: {
|
|
28363
29964
|
type: "providerNative",
|
|
28364
|
-
provider: "
|
|
29965
|
+
provider: "muse",
|
|
28365
29966
|
deltaType: "response.output_item.done",
|
|
28366
29967
|
fold: "merge",
|
|
28367
29968
|
data: item
|
|
@@ -28386,7 +29987,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28386
29987
|
yield {
|
|
28387
29988
|
type: "error",
|
|
28388
29989
|
code: "UPSTREAM",
|
|
28389
|
-
message: reason !== undefined ? `unrecognized
|
|
29990
|
+
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
29991
|
retryable: false
|
|
28391
29992
|
};
|
|
28392
29993
|
break;
|
|
@@ -28403,7 +30004,7 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28403
30004
|
terminal = true;
|
|
28404
30005
|
const err = d.response?.error ?? d.error ?? {};
|
|
28405
30006
|
const raw = String(err.code ?? err.type);
|
|
28406
|
-
const code = (Object.hasOwn(
|
|
30007
|
+
const code = (Object.hasOwn(ERROR_CODE3, raw) ? ERROR_CODE3[raw] : undefined) ?? "UPSTREAM";
|
|
28407
30008
|
yield {
|
|
28408
30009
|
type: "error",
|
|
28409
30010
|
code,
|
|
@@ -28426,8 +30027,8 @@ async function* decodeResponses(messages, options = {}) {
|
|
|
28426
30027
|
}
|
|
28427
30028
|
}
|
|
28428
30029
|
|
|
28429
|
-
// packages/providers/src/
|
|
28430
|
-
import { createHash as
|
|
30030
|
+
// packages/providers/src/muse/wire.ts
|
|
30031
|
+
import { createHash as createHash5 } from "crypto";
|
|
28431
30032
|
function suppliedKey(req) {
|
|
28432
30033
|
const vendor = req.vendor?.openai;
|
|
28433
30034
|
for (const name of ["prompt_cache_key", "session_id"]) {
|
|
@@ -28439,7 +30040,7 @@ function suppliedKey(req) {
|
|
|
28439
30040
|
}
|
|
28440
30041
|
function cacheKey(req, instructions, firstInput) {
|
|
28441
30042
|
const stable = req.conversationId !== undefined && req.conversationId.length > 0 ? JSON.stringify({ conversation: req.conversationId }) : JSON.stringify({ instructions, firstInput: firstInput ?? null });
|
|
28442
|
-
return
|
|
30043
|
+
return createHash5("sha256").update(stable).digest("hex").slice(0, 32);
|
|
28443
30044
|
}
|
|
28444
30045
|
function repairOrphanedCalls(input2) {
|
|
28445
30046
|
const answered = new Set;
|
|
@@ -28458,7 +30059,407 @@ function repairOrphanedCalls(input2) {
|
|
|
28458
30059
|
input2.splice(i + 1, 0, { type: "function_call_output", call_id: record2.call_id, output: "" });
|
|
28459
30060
|
}
|
|
28460
30061
|
}
|
|
28461
|
-
function
|
|
30062
|
+
function encodeToolChoice6(c) {
|
|
30063
|
+
switch (c.type) {
|
|
30064
|
+
case "auto":
|
|
30065
|
+
return "auto";
|
|
30066
|
+
case "any":
|
|
30067
|
+
return "required";
|
|
30068
|
+
case "none":
|
|
30069
|
+
return "none";
|
|
30070
|
+
case "tool":
|
|
30071
|
+
return { type: "function", name: c.name };
|
|
30072
|
+
}
|
|
30073
|
+
}
|
|
30074
|
+
function toMuseWire(req, model) {
|
|
30075
|
+
const degradations = [];
|
|
30076
|
+
const input2 = [];
|
|
30077
|
+
const note2 = (d) => {
|
|
30078
|
+
if (!degradations.includes(d))
|
|
30079
|
+
degradations.push(d);
|
|
30080
|
+
};
|
|
30081
|
+
if (req.betas?.includes(CONTEXT_1M_BETA))
|
|
30082
|
+
note2("muse:context-1m-dropped");
|
|
30083
|
+
for (const message of req.messages) {
|
|
30084
|
+
const parts = [];
|
|
30085
|
+
const asDeveloper = message.role === "system";
|
|
30086
|
+
if (asDeveloper)
|
|
30087
|
+
note2("muse:system-turn-as-developer");
|
|
30088
|
+
const role = asDeveloper ? "developer" : message.role;
|
|
30089
|
+
const flush = () => {
|
|
30090
|
+
if (parts.length === 0)
|
|
30091
|
+
return;
|
|
30092
|
+
input2.push({ type: "message", role, content: [...parts] });
|
|
30093
|
+
parts.length = 0;
|
|
30094
|
+
};
|
|
30095
|
+
for (const block of message.content) {
|
|
30096
|
+
switch (block.type) {
|
|
30097
|
+
case "text":
|
|
30098
|
+
parts.push({
|
|
30099
|
+
type: role === "assistant" ? "output_text" : "input_text",
|
|
30100
|
+
text: block.text
|
|
30101
|
+
});
|
|
30102
|
+
break;
|
|
30103
|
+
case "image":
|
|
30104
|
+
parts.push({
|
|
30105
|
+
type: "input_image",
|
|
30106
|
+
image_url: `data:${block.mediaType};base64,${block.data}`
|
|
30107
|
+
});
|
|
30108
|
+
break;
|
|
30109
|
+
case "thinking":
|
|
30110
|
+
note2("muse:thinking-dropped");
|
|
30111
|
+
break;
|
|
30112
|
+
case "toolUse":
|
|
30113
|
+
flush();
|
|
30114
|
+
input2.push({
|
|
30115
|
+
type: "function_call",
|
|
30116
|
+
call_id: block.id,
|
|
30117
|
+
name: block.name,
|
|
30118
|
+
arguments: JSON.stringify(block.input)
|
|
30119
|
+
});
|
|
30120
|
+
break;
|
|
30121
|
+
case "toolResult":
|
|
30122
|
+
flush();
|
|
30123
|
+
input2.push({
|
|
30124
|
+
type: "function_call_output",
|
|
30125
|
+
call_id: block.toolUseId,
|
|
30126
|
+
output: block.content
|
|
30127
|
+
});
|
|
30128
|
+
break;
|
|
30129
|
+
case "providerNative":
|
|
30130
|
+
if (block.provider === "muse") {
|
|
30131
|
+
flush();
|
|
30132
|
+
const { id: _id, ...rest } = block.data;
|
|
30133
|
+
input2.push({ type: block.blockType, ...rest });
|
|
30134
|
+
break;
|
|
30135
|
+
}
|
|
30136
|
+
note2("muse:foreign-native-block-dropped");
|
|
30137
|
+
break;
|
|
30138
|
+
}
|
|
30139
|
+
}
|
|
30140
|
+
flush();
|
|
30141
|
+
}
|
|
30142
|
+
repairOrphanedCalls(input2);
|
|
30143
|
+
const body = { model, input: input2, stream: req.stream, store: false };
|
|
30144
|
+
const instructions = systemText(req.system, "muse", note2);
|
|
30145
|
+
if (instructions !== undefined && instructions.length > 0)
|
|
30146
|
+
body.instructions = instructions;
|
|
30147
|
+
if (req.maxTokens !== undefined)
|
|
30148
|
+
body.max_output_tokens = req.maxTokens;
|
|
30149
|
+
if (req.temperature !== undefined)
|
|
30150
|
+
body.temperature = req.temperature;
|
|
30151
|
+
if (req.tools !== undefined) {
|
|
30152
|
+
const portable = req.tools.filter((t) => t.kind === "portable");
|
|
30153
|
+
if (portable.length !== req.tools.length)
|
|
30154
|
+
note2("muse:provider-tool-dropped");
|
|
30155
|
+
body.tools = portable.map((t) => ({
|
|
30156
|
+
type: "function",
|
|
30157
|
+
name: t.name,
|
|
30158
|
+
description: t.description,
|
|
30159
|
+
parameters: t.inputSchema
|
|
30160
|
+
}));
|
|
30161
|
+
}
|
|
30162
|
+
if (req.toolChoice !== undefined)
|
|
30163
|
+
body.tool_choice = encodeToolChoice6(req.toolChoice);
|
|
30164
|
+
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
30165
|
+
if (req.reasoning.mode === "budget") {
|
|
30166
|
+
note2("muse:reasoning-budget-dropped");
|
|
30167
|
+
} else {
|
|
30168
|
+
const effort = req.reasoning.effort ?? "medium";
|
|
30169
|
+
body.reasoning = { effort, summary: "auto" };
|
|
30170
|
+
}
|
|
30171
|
+
}
|
|
30172
|
+
const key = suppliedKey(req) ?? cacheKey(req, instructions ?? "", input2[0]);
|
|
30173
|
+
Object.assign(body, req.vendor?.openai ?? {});
|
|
30174
|
+
body.prompt_cache_key = key;
|
|
30175
|
+
return { body, degradations, cacheKey: key };
|
|
30176
|
+
}
|
|
30177
|
+
|
|
30178
|
+
// packages/providers/src/muse/codec.ts
|
|
30179
|
+
var museCodec = {
|
|
30180
|
+
buildRequest(input2) {
|
|
30181
|
+
const { body, degradations, cacheKey: cacheKey2 } = toMuseWire(input2.request, input2.model);
|
|
30182
|
+
if (input2.credentials.apiKey === null) {
|
|
30183
|
+
throw input2.fail("AUTH", "muse credential has no model api key");
|
|
30184
|
+
}
|
|
30185
|
+
const protocol = [
|
|
30186
|
+
["Content-Type", "application/json"],
|
|
30187
|
+
["Authorization", `Bearer ${input2.credentials.apiKey}`],
|
|
30188
|
+
["x-meta-ai-gateway-session-id", cacheKey2]
|
|
30189
|
+
];
|
|
30190
|
+
const headers = orderHeaders(mergeHeaders(museProfile.headers, protocol), museProfile.order);
|
|
30191
|
+
const include = body.include;
|
|
30192
|
+
const nativeReasoning = Array.isArray(include) && include.includes("reasoning.encrypted_content");
|
|
30193
|
+
return {
|
|
30194
|
+
decodeState: { nativeReasoning },
|
|
30195
|
+
request: {
|
|
30196
|
+
url: museResponsesUrl(input2.credentials.providerData),
|
|
30197
|
+
method: "POST",
|
|
30198
|
+
headers,
|
|
30199
|
+
body: JSON.stringify(orderFields({ ...body, stream: true }, museBodyOrder))
|
|
30200
|
+
},
|
|
30201
|
+
degradations
|
|
30202
|
+
};
|
|
30203
|
+
},
|
|
30204
|
+
decode({ body, decodeState }) {
|
|
30205
|
+
const state = decodeState;
|
|
30206
|
+
return decodeMuseResponses(parseSse(body), {
|
|
30207
|
+
nativeReasoning: state?.nativeReasoning === true
|
|
30208
|
+
});
|
|
30209
|
+
}
|
|
30210
|
+
};
|
|
30211
|
+
|
|
30212
|
+
// packages/providers/src/muse/index.ts
|
|
30213
|
+
var museAdapter = codecAdapter("muse", museDescriptor.capabilities, museCodec);
|
|
30214
|
+
// packages/providers/src/openai/decode.ts
|
|
30215
|
+
var ERROR_CODE4 = {
|
|
30216
|
+
rate_limit_exceeded: "RATE_LIMIT",
|
|
30217
|
+
insufficient_quota: "QUOTA_EXHAUSTED",
|
|
30218
|
+
invalid_api_key: "AUTH",
|
|
30219
|
+
server_error: "UPSTREAM",
|
|
30220
|
+
context_length_exceeded: "BAD_REQUEST",
|
|
30221
|
+
content_policy_violation: "CONTENT_FILTER"
|
|
30222
|
+
};
|
|
30223
|
+
var KNOWN_EVENTS4 = new Set([
|
|
30224
|
+
"keepalive",
|
|
30225
|
+
"response.created",
|
|
30226
|
+
"response.queued",
|
|
30227
|
+
"response.in_progress",
|
|
30228
|
+
"response.output_item.added",
|
|
30229
|
+
"response.output_item.done",
|
|
30230
|
+
"response.content_part.added",
|
|
30231
|
+
"response.content_part.done",
|
|
30232
|
+
"response.output_text.delta",
|
|
30233
|
+
"response.output_text.done",
|
|
30234
|
+
"response.output_text.annotation.added",
|
|
30235
|
+
"response.refusal.delta",
|
|
30236
|
+
"response.refusal.done",
|
|
30237
|
+
"response.reasoning_summary_part.added",
|
|
30238
|
+
"response.reasoning_summary_part.done",
|
|
30239
|
+
"response.reasoning_summary_text.delta",
|
|
30240
|
+
"response.reasoning_summary_text.done",
|
|
30241
|
+
"response.reasoning_text.delta",
|
|
30242
|
+
"response.reasoning_text.done",
|
|
30243
|
+
"response.function_call_arguments.delta",
|
|
30244
|
+
"response.function_call_arguments.done",
|
|
30245
|
+
"response.completed",
|
|
30246
|
+
"response.incomplete",
|
|
30247
|
+
"response.failed",
|
|
30248
|
+
"error"
|
|
30249
|
+
]);
|
|
30250
|
+
function json9(data) {
|
|
30251
|
+
try {
|
|
30252
|
+
const v = JSON.parse(data);
|
|
30253
|
+
return typeof v === "object" && v !== null ? v : null;
|
|
30254
|
+
} catch {
|
|
30255
|
+
return null;
|
|
30256
|
+
}
|
|
30257
|
+
}
|
|
30258
|
+
async function* decodeResponses(messages, options = {}) {
|
|
30259
|
+
const nativeReasoning = options.nativeReasoning === true;
|
|
30260
|
+
const indices = new Map;
|
|
30261
|
+
let next = 0;
|
|
30262
|
+
const irIndex = (outputIndex, contentIndex = 0) => {
|
|
30263
|
+
const key = `${outputIndex}:${contentIndex}`;
|
|
30264
|
+
const existing = indices.get(key);
|
|
30265
|
+
if (existing !== undefined)
|
|
30266
|
+
return existing;
|
|
30267
|
+
const assigned = next++;
|
|
30268
|
+
indices.set(key, assigned);
|
|
30269
|
+
return assigned;
|
|
30270
|
+
};
|
|
30271
|
+
let sawToolCall = false;
|
|
30272
|
+
let terminal = false;
|
|
30273
|
+
const ownsBlock = new Set;
|
|
30274
|
+
for await (const msg of messages) {
|
|
30275
|
+
if (msg.data === "[DONE]")
|
|
30276
|
+
continue;
|
|
30277
|
+
if (!KNOWN_EVENTS4.has(msg.event)) {
|
|
30278
|
+
yield {
|
|
30279
|
+
type: "error",
|
|
30280
|
+
code: "UPSTREAM",
|
|
30281
|
+
message: `unrecognized OpenAI stream event "${msg.event}"`,
|
|
30282
|
+
retryable: false
|
|
30283
|
+
};
|
|
30284
|
+
return;
|
|
30285
|
+
}
|
|
30286
|
+
const d = json9(msg.data);
|
|
30287
|
+
if (d === null)
|
|
30288
|
+
continue;
|
|
30289
|
+
switch (msg.event) {
|
|
30290
|
+
case "response.created":
|
|
30291
|
+
yield {
|
|
30292
|
+
type: "start",
|
|
30293
|
+
id: String(d.response?.id ?? ""),
|
|
30294
|
+
model: String(d.response?.model ?? "")
|
|
30295
|
+
};
|
|
30296
|
+
break;
|
|
30297
|
+
case "response.output_item.added": {
|
|
30298
|
+
const item = d.item ?? {};
|
|
30299
|
+
if (item.type === "reasoning") {
|
|
30300
|
+
ownsBlock.add(d.output_index ?? 0);
|
|
30301
|
+
yield {
|
|
30302
|
+
type: "blockStart",
|
|
30303
|
+
index: irIndex(d.output_index ?? 0),
|
|
30304
|
+
block: nativeReasoning ? { type: "providerNative", provider: "openai", blockType: "reasoning", data: {} } : { type: "thinking" }
|
|
30305
|
+
};
|
|
30306
|
+
} else if (item.type === "function_call") {
|
|
30307
|
+
sawToolCall = true;
|
|
30308
|
+
ownsBlock.add(d.output_index ?? 0);
|
|
30309
|
+
yield {
|
|
30310
|
+
type: "blockStart",
|
|
30311
|
+
index: irIndex(d.output_index ?? 0),
|
|
30312
|
+
block: { type: "toolUse", id: String(item.call_id), name: String(item.name) }
|
|
30313
|
+
};
|
|
30314
|
+
}
|
|
30315
|
+
break;
|
|
30316
|
+
}
|
|
30317
|
+
case "response.content_part.added":
|
|
30318
|
+
if (d.part?.type === "output_text") {
|
|
30319
|
+
yield {
|
|
30320
|
+
type: "blockStart",
|
|
30321
|
+
index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
|
|
30322
|
+
block: { type: "text" }
|
|
30323
|
+
};
|
|
30324
|
+
}
|
|
30325
|
+
break;
|
|
30326
|
+
case "response.output_text.delta":
|
|
30327
|
+
yield {
|
|
30328
|
+
type: "blockDelta",
|
|
30329
|
+
index: irIndex(d.output_index ?? 0, d.content_index ?? 0),
|
|
30330
|
+
delta: { type: "text", text: String(d.delta ?? "") }
|
|
30331
|
+
};
|
|
30332
|
+
break;
|
|
30333
|
+
case "response.reasoning_summary_text.delta":
|
|
30334
|
+
yield {
|
|
30335
|
+
type: "blockDelta",
|
|
30336
|
+
index: irIndex(d.output_index ?? 0),
|
|
30337
|
+
delta: nativeReasoning ? {
|
|
30338
|
+
type: "providerNative",
|
|
30339
|
+
provider: "openai",
|
|
30340
|
+
deltaType: "reasoning_summary_text.delta",
|
|
30341
|
+
data: { text: String(d.delta ?? "") }
|
|
30342
|
+
} : { type: "thinking", text: String(d.delta ?? "") }
|
|
30343
|
+
};
|
|
30344
|
+
break;
|
|
30345
|
+
case "response.function_call_arguments.delta":
|
|
30346
|
+
yield {
|
|
30347
|
+
type: "blockDelta",
|
|
30348
|
+
index: irIndex(d.output_index ?? 0),
|
|
30349
|
+
delta: { type: "toolJson", partial: String(d.delta ?? "") }
|
|
30350
|
+
};
|
|
30351
|
+
break;
|
|
30352
|
+
case "response.content_part.done":
|
|
30353
|
+
yield { type: "blockEnd", index: irIndex(d.output_index ?? 0, d.content_index ?? 0) };
|
|
30354
|
+
break;
|
|
30355
|
+
case "response.output_item.done": {
|
|
30356
|
+
const outputIndex = d.output_index ?? 0;
|
|
30357
|
+
if (ownsBlock.delete(outputIndex)) {
|
|
30358
|
+
const item = d.item ?? {};
|
|
30359
|
+
if (nativeReasoning && item.type === "reasoning") {
|
|
30360
|
+
yield {
|
|
30361
|
+
type: "blockDelta",
|
|
30362
|
+
index: irIndex(outputIndex),
|
|
30363
|
+
delta: {
|
|
30364
|
+
type: "providerNative",
|
|
30365
|
+
provider: "openai",
|
|
30366
|
+
deltaType: "response.output_item.done",
|
|
30367
|
+
fold: "merge",
|
|
30368
|
+
data: item
|
|
30369
|
+
}
|
|
30370
|
+
};
|
|
30371
|
+
}
|
|
30372
|
+
yield { type: "blockEnd", index: irIndex(outputIndex) };
|
|
30373
|
+
}
|
|
30374
|
+
break;
|
|
30375
|
+
}
|
|
30376
|
+
case "response.completed":
|
|
30377
|
+
case "response.incomplete": {
|
|
30378
|
+
terminal = true;
|
|
30379
|
+
const r = d.response ?? {};
|
|
30380
|
+
const reason = r.incomplete_details?.reason;
|
|
30381
|
+
let stopReason = sawToolCall ? "toolUse" : "endTurn";
|
|
30382
|
+
if (reason === "max_output_tokens")
|
|
30383
|
+
stopReason = "maxTokens";
|
|
30384
|
+
else if (reason === "content_filter")
|
|
30385
|
+
stopReason = "contentFilter";
|
|
30386
|
+
else if (reason !== undefined || msg.event === "response.incomplete" || r.status !== undefined && r.status !== "completed") {
|
|
30387
|
+
yield {
|
|
30388
|
+
type: "error",
|
|
30389
|
+
code: "UPSTREAM",
|
|
30390
|
+
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",
|
|
30391
|
+
retryable: false
|
|
30392
|
+
};
|
|
30393
|
+
break;
|
|
30394
|
+
}
|
|
30395
|
+
yield {
|
|
30396
|
+
type: "end",
|
|
30397
|
+
stopReason,
|
|
30398
|
+
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)
|
|
30399
|
+
};
|
|
30400
|
+
break;
|
|
30401
|
+
}
|
|
30402
|
+
case "response.failed":
|
|
30403
|
+
case "error": {
|
|
30404
|
+
terminal = true;
|
|
30405
|
+
const err = d.response?.error ?? d.error ?? {};
|
|
30406
|
+
const raw = String(err.code ?? err.type);
|
|
30407
|
+
const code = (Object.hasOwn(ERROR_CODE4, raw) ? ERROR_CODE4[raw] : undefined) ?? "UPSTREAM";
|
|
30408
|
+
yield {
|
|
30409
|
+
type: "error",
|
|
30410
|
+
code,
|
|
30411
|
+
message: String(err.message ?? "upstream error"),
|
|
30412
|
+
retryable: RETRYABLE[code]
|
|
30413
|
+
};
|
|
30414
|
+
break;
|
|
30415
|
+
}
|
|
30416
|
+
default:
|
|
30417
|
+
break;
|
|
30418
|
+
}
|
|
30419
|
+
}
|
|
30420
|
+
if (!terminal) {
|
|
30421
|
+
yield {
|
|
30422
|
+
type: "error",
|
|
30423
|
+
code: "UPSTREAM",
|
|
30424
|
+
message: "upstream stream ended before response completion",
|
|
30425
|
+
retryable: RETRYABLE.UPSTREAM
|
|
30426
|
+
};
|
|
30427
|
+
}
|
|
30428
|
+
}
|
|
30429
|
+
|
|
30430
|
+
// packages/providers/src/openai/wire.ts
|
|
30431
|
+
import { createHash as createHash6 } from "crypto";
|
|
30432
|
+
function suppliedKey2(req) {
|
|
30433
|
+
const vendor = req.vendor?.openai;
|
|
30434
|
+
for (const name of ["prompt_cache_key", "session_id"]) {
|
|
30435
|
+
const value = vendor?.[name];
|
|
30436
|
+
if (typeof value === "string" && value.length > 0)
|
|
30437
|
+
return value;
|
|
30438
|
+
}
|
|
30439
|
+
return;
|
|
30440
|
+
}
|
|
30441
|
+
function cacheKey2(req, instructions, firstInput) {
|
|
30442
|
+
const stable = req.conversationId !== undefined && req.conversationId.length > 0 ? JSON.stringify({ conversation: req.conversationId }) : JSON.stringify({ instructions, firstInput: firstInput ?? null });
|
|
30443
|
+
return createHash6("sha256").update(stable).digest("hex").slice(0, 32);
|
|
30444
|
+
}
|
|
30445
|
+
function repairOrphanedCalls2(input2) {
|
|
30446
|
+
const answered = new Set;
|
|
30447
|
+
for (const item of input2) {
|
|
30448
|
+
const record2 = item;
|
|
30449
|
+
if (record2.type === "function_call_output" && typeof record2.call_id === "string") {
|
|
30450
|
+
answered.add(record2.call_id);
|
|
30451
|
+
}
|
|
30452
|
+
}
|
|
30453
|
+
for (let i = input2.length - 1;i >= 0; i--) {
|
|
30454
|
+
const record2 = input2[i];
|
|
30455
|
+
if (record2.type !== "function_call" || typeof record2.call_id !== "string")
|
|
30456
|
+
continue;
|
|
30457
|
+
if (answered.has(record2.call_id))
|
|
30458
|
+
continue;
|
|
30459
|
+
input2.splice(i + 1, 0, { type: "function_call_output", call_id: record2.call_id, output: "" });
|
|
30460
|
+
}
|
|
30461
|
+
}
|
|
30462
|
+
function encodeToolChoice7(c) {
|
|
28462
30463
|
switch (c.type) {
|
|
28463
30464
|
case "auto":
|
|
28464
30465
|
return "auto";
|
|
@@ -28540,7 +30541,7 @@ function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
|
28540
30541
|
}
|
|
28541
30542
|
flush();
|
|
28542
30543
|
}
|
|
28543
|
-
|
|
30544
|
+
repairOrphanedCalls2(input2);
|
|
28544
30545
|
const body = { model, input: input2, stream: req.stream, store: false };
|
|
28545
30546
|
const instructions = systemText(req.system, "openai", note2);
|
|
28546
30547
|
if (instructions !== undefined && instructions.length > 0)
|
|
@@ -28569,7 +30570,7 @@ function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
|
28569
30570
|
}));
|
|
28570
30571
|
}
|
|
28571
30572
|
if (req.toolChoice !== undefined)
|
|
28572
|
-
body.tool_choice =
|
|
30573
|
+
body.tool_choice = encodeToolChoice7(req.toolChoice);
|
|
28573
30574
|
if (req.reasoning !== undefined && req.reasoning.mode !== "off") {
|
|
28574
30575
|
if (req.reasoning.mode === "budget") {
|
|
28575
30576
|
degradations.push("openai:reasoning-budget-dropped");
|
|
@@ -28578,7 +30579,7 @@ function toResponsesWire(req, model, opts = { oauth: false }) {
|
|
|
28578
30579
|
body.reasoning = { effort, summary: "auto" };
|
|
28579
30580
|
}
|
|
28580
30581
|
}
|
|
28581
|
-
const key =
|
|
30582
|
+
const key = suppliedKey2(req) ?? cacheKey2(req, instructions ?? "", input2[0]);
|
|
28582
30583
|
Object.assign(body, req.vendor?.openai ?? {});
|
|
28583
30584
|
body.prompt_cache_key = key;
|
|
28584
30585
|
return { body, degradations, cacheKey: key };
|
|
@@ -28590,14 +30591,14 @@ var API_URL3 = "https://api.openai.com/v1/responses";
|
|
|
28590
30591
|
var openaiCodec = {
|
|
28591
30592
|
buildRequest(input2) {
|
|
28592
30593
|
const oauth = input2.credentials.accessToken !== null;
|
|
28593
|
-
const { body, degradations, cacheKey:
|
|
30594
|
+
const { body, degradations, cacheKey: cacheKey3 } = toResponsesWire(input2.request, input2.model, { oauth });
|
|
28594
30595
|
const protocol = [["Content-Type", "application/json"]];
|
|
28595
30596
|
if (oauth) {
|
|
28596
30597
|
protocol.push(["Authorization", `Bearer ${input2.credentials.accessToken}`]);
|
|
28597
30598
|
const accountId = input2.credentials.providerData.accountId;
|
|
28598
30599
|
if (typeof accountId === "string")
|
|
28599
30600
|
protocol.push(["chatgpt-account-id", accountId]);
|
|
28600
|
-
protocol.push(["session_id",
|
|
30601
|
+
protocol.push(["session_id", cacheKey3]);
|
|
28601
30602
|
} else if (input2.credentials.apiKey !== null) {
|
|
28602
30603
|
protocol.push(["Authorization", `Bearer ${input2.credentials.apiKey}`]);
|
|
28603
30604
|
} else {
|
|
@@ -28632,6 +30633,8 @@ var ADAPTERS = {
|
|
|
28632
30633
|
kimi: kimiAdapter,
|
|
28633
30634
|
kilo: kiloAdapter,
|
|
28634
30635
|
grok: grokAdapter,
|
|
30636
|
+
antigravity: antigravityAdapter,
|
|
30637
|
+
muse: museAdapter,
|
|
28635
30638
|
custom: customAdapter
|
|
28636
30639
|
};
|
|
28637
30640
|
Object.setPrototypeOf(ADAPTERS, null);
|
|
@@ -30138,7 +32141,7 @@ import { basename as basename2, join as join3, resolve as resolve2, sep as sep2
|
|
|
30138
32141
|
|
|
30139
32142
|
// packages/plugin-api/src/version.ts
|
|
30140
32143
|
var PLUGIN_API_VERSION = 3;
|
|
30141
|
-
var DASHBOARD_SDK_VERSION = "0.1.
|
|
32144
|
+
var DASHBOARD_SDK_VERSION = "0.1.8";
|
|
30142
32145
|
// packages/plugin-api/src/manifest.ts
|
|
30143
32146
|
var CAPABILITIES = [
|
|
30144
32147
|
"storage",
|
|
@@ -31217,7 +33220,7 @@ function createRefresher(deps) {
|
|
|
31217
33220
|
}
|
|
31218
33221
|
// packages/control/src/pluginProviders.ts
|
|
31219
33222
|
import { join as join5 } from "path";
|
|
31220
|
-
function
|
|
33223
|
+
function isRecord7(value) {
|
|
31221
33224
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31222
33225
|
}
|
|
31223
33226
|
function isNumber(value) {
|
|
@@ -31228,7 +33231,7 @@ function checkAt(ok, id, path, expected) {
|
|
|
31228
33231
|
throw new Error(`provider ${id} descriptor: ${path} must be ${expected}`);
|
|
31229
33232
|
}
|
|
31230
33233
|
function checkLimits(id, path, value) {
|
|
31231
|
-
checkAt(
|
|
33234
|
+
checkAt(isRecord7(value), id, path, "an object");
|
|
31232
33235
|
const limits = value;
|
|
31233
33236
|
checkAt(isNumber(limits.contextWindow), id, `${path}.contextWindow`, "a finite number");
|
|
31234
33237
|
checkAt(isNumber(limits.maxOutputTokens), id, `${path}.maxOutputTokens`, "a finite number");
|
|
@@ -31246,19 +33249,19 @@ function checkDescriptor(id, record2) {
|
|
|
31246
33249
|
}
|
|
31247
33250
|
}
|
|
31248
33251
|
const capabilities2 = record2.capabilities;
|
|
31249
|
-
checkAt(
|
|
33252
|
+
checkAt(isRecord7(capabilities2), id, "capabilities", "an object");
|
|
31250
33253
|
for (const flag of ["tools", "images", "reasoning"]) {
|
|
31251
33254
|
const value = capabilities2[flag];
|
|
31252
33255
|
checkAt(typeof value === "boolean", id, `capabilities.${flag}`, "a boolean");
|
|
31253
33256
|
}
|
|
31254
33257
|
const write = record2.writeOverInput;
|
|
31255
|
-
checkAt(
|
|
33258
|
+
checkAt(isRecord7(write), id, "writeOverInput", "an object");
|
|
31256
33259
|
for (const ttl of ["fiveMinute", "oneHour"]) {
|
|
31257
33260
|
const value = write[ttl];
|
|
31258
33261
|
checkAt(isNumber(value), id, `writeOverInput.${ttl}`, "a finite number");
|
|
31259
33262
|
}
|
|
31260
33263
|
const catalog2 = record2.catalog;
|
|
31261
|
-
checkAt(
|
|
33264
|
+
checkAt(isRecord7(catalog2), id, "catalog", "an object");
|
|
31262
33265
|
const entry = catalog2;
|
|
31263
33266
|
checkAt(typeof entry.defaultModel === "string", id, "catalog.defaultModel", "a string");
|
|
31264
33267
|
checkAt(Array.isArray(entry.authTypes), id, "catalog.authTypes", "an array");
|
|
@@ -31269,11 +33272,11 @@ function checkDescriptor(id, record2) {
|
|
|
31269
33272
|
checkAt(Array.isArray(entry.models), id, "catalog.models", "an array");
|
|
31270
33273
|
for (const [index, model] of entry.models.entries()) {
|
|
31271
33274
|
const at = `catalog.models[${index}]`;
|
|
31272
|
-
checkAt(
|
|
33275
|
+
checkAt(isRecord7(model), id, at, "an object");
|
|
31273
33276
|
const choice = model;
|
|
31274
33277
|
checkAt(typeof choice.id === "string", id, `${at}.id`, "a string");
|
|
31275
33278
|
checkAt(typeof choice.label === "string", id, `${at}.label`, "a string");
|
|
31276
|
-
checkAt(
|
|
33279
|
+
checkAt(isRecord7(choice.pricing), id, `${at}.pricing`, "an object");
|
|
31277
33280
|
const pricing = choice.pricing;
|
|
31278
33281
|
for (const field of ["input", "output", "cacheRead", "cacheWrite5m", "cacheWrite1h"]) {
|
|
31279
33282
|
checkAt(isNumber(pricing[field]), id, `${at}.pricing.${field}`, "a finite number");
|
|
@@ -31289,13 +33292,13 @@ function checkDescriptor(id, record2) {
|
|
|
31289
33292
|
checkAt(typeof prefix === "string", id, `modelPrefixes[${index}]`, "a string");
|
|
31290
33293
|
}
|
|
31291
33294
|
const presentation = record2.presentation;
|
|
31292
|
-
checkAt(
|
|
33295
|
+
checkAt(isRecord7(presentation), id, "presentation", "an object");
|
|
31293
33296
|
const shown = presentation;
|
|
31294
33297
|
for (const field of ["label", "tone"]) {
|
|
31295
33298
|
checkAt(typeof shown[field] === "string", id, `presentation.${field}`, "a string");
|
|
31296
33299
|
}
|
|
31297
33300
|
checkAt(isNumber(shown.order), id, "presentation.order", "a finite number");
|
|
31298
|
-
checkAt(
|
|
33301
|
+
checkAt(isRecord7(shown.colour), id, "presentation.colour", "an object");
|
|
31299
33302
|
for (const scheme of ["light", "dark"]) {
|
|
31300
33303
|
const value = shown.colour[scheme];
|
|
31301
33304
|
checkAt(typeof value === "string", id, `presentation.colour.${scheme}`, "a string");
|
|
@@ -31307,7 +33310,7 @@ function checkDescriptor(id, record2) {
|
|
|
31307
33310
|
function validateOAuthFlow(id, value) {
|
|
31308
33311
|
if (value === undefined)
|
|
31309
33312
|
return;
|
|
31310
|
-
if (!
|
|
33313
|
+
if (!isRecord7(value))
|
|
31311
33314
|
throw new Error(`provider ${id} oauth must be an object`);
|
|
31312
33315
|
const kind = value.kind;
|
|
31313
33316
|
if (kind !== "pkce" && kind !== "device") {
|
|
@@ -31787,7 +33790,9 @@ var TONES = {
|
|
|
31787
33790
|
blue: true,
|
|
31788
33791
|
magenta: true,
|
|
31789
33792
|
cyan: true,
|
|
31790
|
-
orange: true
|
|
33793
|
+
orange: true,
|
|
33794
|
+
violet: true,
|
|
33795
|
+
azure: true
|
|
31791
33796
|
};
|
|
31792
33797
|
function isTone(name) {
|
|
31793
33798
|
return Object.hasOwn(TONES, name);
|
|
@@ -32828,7 +34833,7 @@ var dbMigrate = {
|
|
|
32828
34833
|
emit(ctx, writer, { target: redact(to), ...report }, () => [
|
|
32829
34834
|
fields([
|
|
32830
34835
|
["target", redact(to)],
|
|
32831
|
-
...Object.entries(report.counts).map(([table2,
|
|
34836
|
+
...Object.entries(report.counts).map(([table2, count2]) => [table2, String(count2)])
|
|
32832
34837
|
]),
|
|
32833
34838
|
"",
|
|
32834
34839
|
"not carried:",
|
|
@@ -32999,7 +35004,7 @@ var dbRestore = {
|
|
|
32999
35004
|
emit(ctx, writer, result, () => fields([
|
|
33000
35005
|
["restored", id],
|
|
33001
35006
|
["undo", result.preRestoreSnapshot.id],
|
|
33002
|
-
...Object.entries(result.counts).map(([table2,
|
|
35007
|
+
...Object.entries(result.counts).map(([table2, count2]) => [table2, String(count2)])
|
|
33003
35008
|
]));
|
|
33004
35009
|
}
|
|
33005
35010
|
};
|
|
@@ -33734,7 +35739,7 @@ function createServiceDeps(input2) {
|
|
|
33734
35739
|
}
|
|
33735
35740
|
|
|
33736
35741
|
// apps/cli/src/version.ts
|
|
33737
|
-
var VERSION = "0.
|
|
35742
|
+
var VERSION = "0.10.1";
|
|
33738
35743
|
|
|
33739
35744
|
// apps/cli/src/commands/service.ts
|
|
33740
35745
|
function gatewayArgv(root) {
|