@dotobokuri/fleet-console 1.59.0 → 1.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/dist/cli.d.ts +13 -2
- package/dist/cli.mjs +126 -30
- package/dist/client/assets/{_baseUniq-CKkDoWU8.js → _baseUniq-9W447fNf.js} +1 -1
- package/dist/client/assets/{arc-CcRdX8oF.js → arc-hoitnVWi.js} +1 -1
- package/dist/client/assets/{architectureDiagram-Q4EWVU46-gaFzE1W7.js → architectureDiagram-Q4EWVU46-DYd58Vfc.js} +1 -1
- package/dist/client/assets/{blockDiagram-DXYQGD6D-Bzybih30.js → blockDiagram-DXYQGD6D-kuFqPdP_.js} +1 -1
- package/dist/client/assets/{c4Diagram-AHTNJAMY-Dz8bwV9j.js → c4Diagram-AHTNJAMY-C7n41zCn.js} +1 -1
- package/dist/client/assets/channel-D2TsEFjE.js +1 -0
- package/dist/client/assets/{chunk-4BX2VUAB-DmgZtGyV.js → chunk-4BX2VUAB-DrHeb54-.js} +1 -1
- package/dist/client/assets/{chunk-4TB4RGXK-DX1WxV3U.js → chunk-4TB4RGXK-DFjT6kwT.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-Bk4b3T9u.js → chunk-55IACEB6-DxEzuA7W.js} +1 -1
- package/dist/client/assets/{chunk-EDXVE4YY-BzGadfvT.js → chunk-EDXVE4YY-aAlF0YEo.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-44f7YyvW.js → chunk-FMBD7UC4-DwqRMFL1.js} +1 -1
- package/dist/client/assets/{chunk-OYMX7WX6-CyUAky9W.js → chunk-OYMX7WX6-DCkUlaRi.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-C11OUntR.js → chunk-QZHKN3VN-B1Dx8Zhl.js} +1 -1
- package/dist/client/assets/{chunk-YZCP3GAM-DVTmWawU.js → chunk-YZCP3GAM-J2bgJmn-.js} +1 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-DhjJiPic.js +1 -0
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-DhjJiPic.js +1 -0
- package/dist/client/assets/clone-DwVC2-Mi.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-CEatGsZv.js → cose-bilkent-S5V4N54A-BxzLzyJp.js} +1 -1
- package/dist/client/assets/{dagre-KV5264BT-DlrgN02H.js → dagre-KV5264BT-D1ixDJxZ.js} +1 -1
- package/dist/client/assets/{diagram-5BDNPKRD-BZ3hRO5t.js → diagram-5BDNPKRD-DZPIz1Pa.js} +1 -1
- package/dist/client/assets/{diagram-G4DWMVQ6-B-izS46x.js → diagram-G4DWMVQ6-Pbcr-a5H.js} +1 -1
- package/dist/client/assets/{diagram-MMDJMWI5-Cw-wnJGs.js → diagram-MMDJMWI5-CBssBmPY.js} +1 -1
- package/dist/client/assets/{diagram-TYMM5635-BoWnyd4_.js → diagram-TYMM5635-cVQUs6jp.js} +1 -1
- package/dist/client/assets/{erDiagram-SMLLAGMA-BUmyXZbP.js → erDiagram-SMLLAGMA-ChMSAXos.js} +1 -1
- package/dist/client/assets/{flowDiagram-DWJPFMVM-COS3kjS0.js → flowDiagram-DWJPFMVM-FEIrU5mu.js} +1 -1
- package/dist/client/assets/{ganttDiagram-T4ZO3ILL-BTr1fdio.js → ganttDiagram-T4ZO3ILL-D6ELHTJY.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-BkGkaosN.js → gitGraphDiagram-UUTBAWPF-DTJ6HgV4.js} +1 -1
- package/dist/client/assets/{graph-DmbgK-mH.js → graph-uscjDdHm.js} +1 -1
- package/dist/client/assets/index-DMjY1OQ0.js +465 -0
- package/dist/client/assets/index-Ec4RaE0g.css +1 -0
- package/dist/client/assets/{infoDiagram-42DDH7IO-B8zI6k1l.js → infoDiagram-42DDH7IO-C2AlA___.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-cIcEzrcK.js → ishikawaDiagram-UXIWVN3A-BZGfIhBp.js} +1 -1
- package/dist/client/assets/{journeyDiagram-VCZTEJTY-DhuabHCk.js → journeyDiagram-VCZTEJTY-DnGNMdvj.js} +1 -1
- package/dist/client/assets/{kanban-definition-6JOO6SKY-uHTkqxhX.js → kanban-definition-6JOO6SKY-BkuplZGR.js} +1 -1
- package/dist/client/assets/{layout-Cfgk_duA.js → layout-BBayH8iU.js} +1 -1
- package/dist/client/assets/{linear-BKvV0sr5.js → linear-BQvaHed0.js} +1 -1
- package/dist/client/assets/{mermaid.core-DozmrCuG.js → mermaid.core-CO0f3d6Y.js} +4 -4
- package/dist/client/assets/{min-ke46otlW.js → min-B610GdeY.js} +1 -1
- package/dist/client/assets/{mindmap-definition-QFDTVHPH-d7xzxhzf.js → mindmap-definition-QFDTVHPH-gwkhgCyj.js} +1 -1
- package/dist/client/assets/{pieDiagram-DEJITSTG-C4S9Jy5A.js → pieDiagram-DEJITSTG-DYU2zgk8.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-34T5L4WZ-CoQnj3kv.js → quadrantDiagram-34T5L4WZ-B5Vkk65i.js} +1 -1
- package/dist/client/assets/{requirementDiagram-MS252O5E-CdopMDtg.js → requirementDiagram-MS252O5E-D4EcF7kq.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-XADWPNL6-DdR4zdh4.js → sankeyDiagram-XADWPNL6-DFk-RMV4.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-FGHM5R23-NeYZWVQm.js → sequenceDiagram-FGHM5R23-B-beo9e0.js} +1 -1
- package/dist/client/assets/{stateDiagram-FHFEXIEX-D0CQGKV_.js → stateDiagram-FHFEXIEX-VDT0TOd7.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-wHPBl_p1.js +1 -0
- package/dist/client/assets/{timeline-definition-GMOUNBTQ-Bz2b3nfQ.js → timeline-definition-GMOUNBTQ-By4DMNqG.js} +1 -1
- package/dist/client/assets/{vennDiagram-DHZGUBPP-CVO2Ja80.js → vennDiagram-DHZGUBPP-DzlBrijd.js} +1 -1
- package/dist/client/assets/{wardley-RL74JXVD-Ba_GKs5u.js → wardley-RL74JXVD-BHSHTMU6.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-NUSXRM2D-yP3xvrPy.js → wardleyDiagram-NUSXRM2D-COB-cWHQ.js} +1 -1
- package/dist/client/assets/{xychartDiagram-5P7HB3ND-BLSs6w4C.js → xychartDiagram-5P7HB3ND-C-GVSBHd.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/fleet-plugins/file-explorer/routes.mjs +132 -13
- package/dist/fleet-plugins/ledger/routes.mjs +223 -16
- package/dist/fleet-plugins/quota/routes.mjs +33 -2
- package/dist/fleet-plugins/scuttlebutt/routes.mjs +5 -5
- package/dist/fleet-plugins/terminal/routes.mjs +653 -79
- package/dist/fleet.mjs +383 -66
- package/package.json +1 -1
- package/dist/client/assets/channel-CAhLkt5l.js +0 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-BSvLoE2t.js +0 -1
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-BSvLoE2t.js +0 -1
- package/dist/client/assets/clone-o26VS_sk.js +0 -1
- package/dist/client/assets/index-C-3spb_b.js +0 -465
- package/dist/client/assets/index-FU1PGEfG.css +0 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-hM1GV37r.js +0 -1
package/dist/fleet.mjs
CHANGED
|
@@ -21548,6 +21548,10 @@ var CLAUDE_COMPAT_CONTEXT_WINDOW = 1e6;
|
|
|
21548
21548
|
var CLAUDE_DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
21549
21549
|
var CLAUDE_COMPACT_RESERVE = 32e3;
|
|
21550
21550
|
var PROVIDER_COMPACT_RESERVE = 16e3;
|
|
21551
|
+
var COMPACT_CEILING_EARLY_PERCENT = 88;
|
|
21552
|
+
var COMPACT_CEILING_LATE_PERCENT = 97;
|
|
21553
|
+
var COMPACT_CEILING_CUSTOM_MIN = 70;
|
|
21554
|
+
var COMPACT_CEILING_CUSTOM_MAX = 99;
|
|
21551
21555
|
var DEFAULT_MAX_JSON_BYTES = 16 * 1024 * 1024;
|
|
21552
21556
|
var DEFAULT_MAX_SSE_FRAME_BYTES = 1024 * 1024;
|
|
21553
21557
|
var MAX_SSE_SEPARATOR_BYTES = 4;
|
|
@@ -21565,20 +21569,41 @@ function hasClaudeOneMillionMarker(modelId) {
|
|
|
21565
21569
|
function stripClaudeOneMillionMarker(modelId) {
|
|
21566
21570
|
return modelId.replace(/\[1m\]$/i, "");
|
|
21567
21571
|
}
|
|
21568
|
-
function projectClaudeContextInputTokens(inputTokens, advertisedContextWindow, upstreamContextWindow = advertisedContextWindow) {
|
|
21572
|
+
function projectClaudeContextInputTokens(inputTokens, advertisedContextWindow, upstreamContextWindow = advertisedContextWindow, compactCeiling) {
|
|
21569
21573
|
if (!Number.isFinite(inputTokens) || inputTokens < 0) return inputTokens;
|
|
21570
21574
|
const advertisedWindow = positiveContextWindow(advertisedContextWindow);
|
|
21571
21575
|
if (advertisedWindow === void 0) return inputTokens;
|
|
21572
21576
|
const projectionWindow = positiveContextWindow(upstreamContextWindow) ?? advertisedWindow;
|
|
21573
21577
|
const coordinate = advertisedWindow >= CLAUDE_COMPAT_CONTEXT_WINDOW ? CLAUDE_COMPAT_CONTEXT_WINDOW : CLAUDE_DEFAULT_CONTEXT_WINDOW;
|
|
21574
21578
|
const claudeCompactThreshold = coordinate - CLAUDE_COMPACT_RESERVE;
|
|
21575
|
-
const providerCompactThreshold = projectionWindow
|
|
21579
|
+
const providerCompactThreshold = compactThresholdTokens(projectionWindow, compactCeiling);
|
|
21576
21580
|
if (providerCompactThreshold <= 0) return Math.min(coordinate, inputTokens);
|
|
21577
21581
|
return Math.min(
|
|
21578
21582
|
coordinate,
|
|
21579
21583
|
Math.ceil(inputTokens * claudeCompactThreshold / providerCompactThreshold)
|
|
21580
21584
|
);
|
|
21581
21585
|
}
|
|
21586
|
+
function compactThresholdTokens(window, compactCeiling) {
|
|
21587
|
+
if (!Number.isFinite(window) || window <= 0) return window;
|
|
21588
|
+
const percent2 = compactCeilingPercent(compactCeiling);
|
|
21589
|
+
if (percent2 === void 0) return window - PROVIDER_COMPACT_RESERVE;
|
|
21590
|
+
return Math.floor(window * percent2 / 100);
|
|
21591
|
+
}
|
|
21592
|
+
function compactCeilingPercent(compactCeiling) {
|
|
21593
|
+
if (compactCeiling === "early") return COMPACT_CEILING_EARLY_PERCENT;
|
|
21594
|
+
if (compactCeiling === "late") return COMPACT_CEILING_LATE_PERCENT;
|
|
21595
|
+
if (typeof compactCeiling === "number" && Number.isInteger(compactCeiling) && compactCeiling >= COMPACT_CEILING_CUSTOM_MIN && compactCeiling <= COMPACT_CEILING_CUSTOM_MAX) {
|
|
21596
|
+
return compactCeiling;
|
|
21597
|
+
}
|
|
21598
|
+
return void 0;
|
|
21599
|
+
}
|
|
21600
|
+
function normalizeCompactCeiling(value) {
|
|
21601
|
+
if (value === "early" || value === "late") return value;
|
|
21602
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= COMPACT_CEILING_CUSTOM_MIN && value <= COMPACT_CEILING_CUSTOM_MAX) {
|
|
21603
|
+
return value;
|
|
21604
|
+
}
|
|
21605
|
+
return void 0;
|
|
21606
|
+
}
|
|
21582
21607
|
async function* projectAnthropicResponseUsage(chunks, options) {
|
|
21583
21608
|
const contextWindow = positiveContextWindow(options.contextWindow);
|
|
21584
21609
|
const responseModel = typeof options.responseModel === "string" && options.responseModel.length > 0 ? options.responseModel : void 0;
|
|
@@ -21592,7 +21617,8 @@ async function* projectAnthropicResponseUsage(chunks, options) {
|
|
|
21592
21617
|
chunks,
|
|
21593
21618
|
contextWindow,
|
|
21594
21619
|
responseModel,
|
|
21595
|
-
positiveLimit(options.maxSseFrameBytes, DEFAULT_MAX_SSE_FRAME_BYTES)
|
|
21620
|
+
positiveLimit(options.maxSseFrameBytes, DEFAULT_MAX_SSE_FRAME_BYTES),
|
|
21621
|
+
options.compactCeiling
|
|
21596
21622
|
);
|
|
21597
21623
|
return;
|
|
21598
21624
|
}
|
|
@@ -21601,13 +21627,14 @@ async function* projectAnthropicResponseUsage(chunks, options) {
|
|
|
21601
21627
|
chunks,
|
|
21602
21628
|
contextWindow,
|
|
21603
21629
|
responseModel,
|
|
21604
|
-
positiveLimit(options.maxJsonBytes, DEFAULT_MAX_JSON_BYTES)
|
|
21630
|
+
positiveLimit(options.maxJsonBytes, DEFAULT_MAX_JSON_BYTES),
|
|
21631
|
+
options.compactCeiling
|
|
21605
21632
|
);
|
|
21606
21633
|
return;
|
|
21607
21634
|
}
|
|
21608
21635
|
yield* chunks;
|
|
21609
21636
|
}
|
|
21610
|
-
async function* projectJsonUsage(chunks, contextWindow, responseModel, maxBytes) {
|
|
21637
|
+
async function* projectJsonUsage(chunks, contextWindow, responseModel, maxBytes, compactCeiling) {
|
|
21611
21638
|
const buffered = [];
|
|
21612
21639
|
let bufferedBytes = 0;
|
|
21613
21640
|
let passthrough = false;
|
|
@@ -21627,10 +21654,10 @@ async function* projectJsonUsage(chunks, contextWindow, responseModel, maxBytes)
|
|
|
21627
21654
|
}
|
|
21628
21655
|
if (passthrough || bufferedBytes === 0) return;
|
|
21629
21656
|
const original = concatChunks(buffered, bufferedBytes);
|
|
21630
|
-
const projected = projectJsonBytes(original, contextWindow, responseModel);
|
|
21657
|
+
const projected = projectJsonBytes(original, contextWindow, responseModel, compactCeiling);
|
|
21631
21658
|
yield projected ?? original;
|
|
21632
21659
|
}
|
|
21633
|
-
async function* projectSseUsage(chunks, contextWindow, responseModel, maxFrameBytes) {
|
|
21660
|
+
async function* projectSseUsage(chunks, contextWindow, responseModel, maxFrameBytes, compactCeiling) {
|
|
21634
21661
|
let buffered = new Uint8Array(0);
|
|
21635
21662
|
let oversizedFrame = false;
|
|
21636
21663
|
for await (const chunk of chunks) {
|
|
@@ -21657,7 +21684,7 @@ async function* projectSseUsage(chunks, contextWindow, responseModel, maxFrameBy
|
|
|
21657
21684
|
const frame = buffered.slice(0, separator.index);
|
|
21658
21685
|
const separatorBytes = buffered.slice(separator.index, separator.index + separator.length);
|
|
21659
21686
|
const originalFrame = buffered.slice(0, separator.index + separator.length);
|
|
21660
|
-
const projectedFrame = frame.byteLength > maxFrameBytes ? void 0 : projectSseFrame(frame, contextWindow, responseModel);
|
|
21687
|
+
const projectedFrame = frame.byteLength > maxFrameBytes ? void 0 : projectSseFrame(frame, contextWindow, responseModel, compactCeiling);
|
|
21661
21688
|
yield projectedFrame === void 0 ? originalFrame : concatBytes(projectedFrame, separatorBytes);
|
|
21662
21689
|
buffered = buffered.slice(separator.index + separator.length);
|
|
21663
21690
|
}
|
|
@@ -21671,17 +21698,17 @@ async function* projectSseUsage(chunks, contextWindow, responseModel, maxFrameBy
|
|
|
21671
21698
|
}
|
|
21672
21699
|
if (buffered.byteLength > 0) yield buffered;
|
|
21673
21700
|
}
|
|
21674
|
-
function projectJsonBytes(bytes, contextWindow, responseModel) {
|
|
21701
|
+
function projectJsonBytes(bytes, contextWindow, responseModel, compactCeiling) {
|
|
21675
21702
|
let parsed;
|
|
21676
21703
|
try {
|
|
21677
21704
|
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
21678
21705
|
} catch {
|
|
21679
21706
|
return void 0;
|
|
21680
21707
|
}
|
|
21681
|
-
const projected = projectAnthropicUsageEnvelope(parsed, contextWindow, responseModel);
|
|
21708
|
+
const projected = projectAnthropicUsageEnvelope(parsed, contextWindow, responseModel, compactCeiling);
|
|
21682
21709
|
return projected.changed ? new TextEncoder().encode(JSON.stringify(projected.value)) : void 0;
|
|
21683
21710
|
}
|
|
21684
|
-
function projectSseFrame(frame, contextWindow, responseModel) {
|
|
21711
|
+
function projectSseFrame(frame, contextWindow, responseModel, compactCeiling) {
|
|
21685
21712
|
let text;
|
|
21686
21713
|
try {
|
|
21687
21714
|
text = new TextDecoder("utf-8", { fatal: true }).decode(frame);
|
|
@@ -21707,7 +21734,7 @@ function projectSseFrame(frame, contextWindow, responseModel) {
|
|
|
21707
21734
|
} catch {
|
|
21708
21735
|
return void 0;
|
|
21709
21736
|
}
|
|
21710
|
-
const projected = projectAnthropicUsageEnvelope(parsed, contextWindow, responseModel);
|
|
21737
|
+
const projected = projectAnthropicUsageEnvelope(parsed, contextWindow, responseModel, compactCeiling);
|
|
21711
21738
|
if (!projected.changed) return void 0;
|
|
21712
21739
|
const firstDataIndex = dataIndexes[0];
|
|
21713
21740
|
const dataIndexSet = new Set(dataIndexes);
|
|
@@ -21721,19 +21748,19 @@ function projectSseFrame(frame, contextWindow, responseModel) {
|
|
|
21721
21748
|
}
|
|
21722
21749
|
return new TextEncoder().encode(outputLines.join(newline));
|
|
21723
21750
|
}
|
|
21724
|
-
function projectAnthropicUsageEnvelope(value, contextWindow, responseModel) {
|
|
21751
|
+
function projectAnthropicUsageEnvelope(value, contextWindow, responseModel, compactCeiling) {
|
|
21725
21752
|
if (!isRecord2(value)) return { changed: false, value };
|
|
21726
21753
|
let projectedValue = value;
|
|
21727
21754
|
let changed = false;
|
|
21728
21755
|
if (contextWindow !== void 0) {
|
|
21729
|
-
const topLevelUsage = projectUsageProperty(projectedValue, "usage", contextWindow);
|
|
21756
|
+
const topLevelUsage = projectUsageProperty(projectedValue, "usage", contextWindow, compactCeiling);
|
|
21730
21757
|
if (topLevelUsage.changed) {
|
|
21731
21758
|
projectedValue = topLevelUsage.value;
|
|
21732
21759
|
changed = true;
|
|
21733
21760
|
}
|
|
21734
21761
|
const message = projectedValue.message;
|
|
21735
21762
|
if (isRecord2(message)) {
|
|
21736
|
-
const messageUsage = projectUsageProperty(message, "usage", contextWindow);
|
|
21763
|
+
const messageUsage = projectUsageProperty(message, "usage", contextWindow, compactCeiling);
|
|
21737
21764
|
if (messageUsage.changed) {
|
|
21738
21765
|
projectedValue = { ...projectedValue, message: messageUsage.value };
|
|
21739
21766
|
changed = true;
|
|
@@ -21753,7 +21780,7 @@ function projectAnthropicUsageEnvelope(value, contextWindow, responseModel) {
|
|
|
21753
21780
|
}
|
|
21754
21781
|
return { changed, value: projectedValue };
|
|
21755
21782
|
}
|
|
21756
|
-
function projectUsageProperty(container, property, contextWindow) {
|
|
21783
|
+
function projectUsageProperty(container, property, contextWindow, compactCeiling) {
|
|
21757
21784
|
const usage4 = container[property];
|
|
21758
21785
|
if (!isRecord2(usage4)) return { changed: false, value: container };
|
|
21759
21786
|
const coordinates = ANTHROPIC_INPUT_USAGE_FIELDS.map((field) => {
|
|
@@ -21762,7 +21789,7 @@ function projectUsageProperty(container, property, contextWindow) {
|
|
|
21762
21789
|
}).filter((entry) => entry !== void 0);
|
|
21763
21790
|
if (coordinates.length === 0) return { changed: false, value: container };
|
|
21764
21791
|
const total = coordinates.reduce((sum, entry) => sum + entry.tokens, 0);
|
|
21765
|
-
const projectedTotal = projectClaudeContextInputTokens(total, contextWindow);
|
|
21792
|
+
const projectedTotal = projectClaudeContextInputTokens(total, contextWindow, contextWindow, compactCeiling);
|
|
21766
21793
|
if (projectedTotal === total) return { changed: false, value: container };
|
|
21767
21794
|
const projectedUsage = { ...usage4 };
|
|
21768
21795
|
const remainderField = coordinates.some((entry) => entry.field === "input_tokens") ? "input_tokens" : coordinates[0].field;
|
|
@@ -23426,12 +23453,13 @@ function stringMetadata(metadata) {
|
|
|
23426
23453
|
);
|
|
23427
23454
|
return entries.length === 0 ? void 0 : Object.fromEntries(entries);
|
|
23428
23455
|
}
|
|
23429
|
-
function toAnthropicCacheAwareUsage(rawInputTokens, cachedInputTokens, cacheWriteInputTokens, outputTokens, advertisedContextWindow, upstreamContextWindow) {
|
|
23456
|
+
function toAnthropicCacheAwareUsage(rawInputTokens, cachedInputTokens, cacheWriteInputTokens, outputTokens, advertisedContextWindow, upstreamContextWindow, compactCeiling) {
|
|
23430
23457
|
const safeInputTokens = Number.isFinite(rawInputTokens) && rawInputTokens > 0 ? rawInputTokens : 0;
|
|
23431
23458
|
const projectedTotal = projectClaudeContextInputTokens(
|
|
23432
23459
|
safeInputTokens,
|
|
23433
23460
|
advertisedContextWindow,
|
|
23434
|
-
upstreamContextWindow
|
|
23461
|
+
upstreamContextWindow,
|
|
23462
|
+
compactCeiling
|
|
23435
23463
|
);
|
|
23436
23464
|
if (safeInputTokens === 0) {
|
|
23437
23465
|
return {
|
|
@@ -23481,7 +23509,8 @@ function anthropicUsageFromCanonical(usage4, advertisedContextWindow, options =
|
|
|
23481
23509
|
usage4?.cache_write_input_tokens,
|
|
23482
23510
|
options.forceOutputZero ? 0 : usage4?.output_tokens ?? 0,
|
|
23483
23511
|
advertisedContextWindow,
|
|
23484
|
-
usage4?.context_window
|
|
23512
|
+
usage4?.context_window,
|
|
23513
|
+
options.compactCeiling
|
|
23485
23514
|
);
|
|
23486
23515
|
}
|
|
23487
23516
|
async function collectAnthropicMessage(events, fallbackModel, options = {}) {
|
|
@@ -23584,7 +23613,8 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
|
|
|
23584
23613
|
cacheWriteInputTokens,
|
|
23585
23614
|
outputTokens,
|
|
23586
23615
|
options.contextWindow,
|
|
23587
|
-
upstreamContextWindow
|
|
23616
|
+
upstreamContextWindow,
|
|
23617
|
+
options.compactCeiling
|
|
23588
23618
|
)
|
|
23589
23619
|
};
|
|
23590
23620
|
}
|
|
@@ -23662,7 +23692,8 @@ data: ${JSON.stringify(data)}
|
|
|
23662
23692
|
stop_reason: null,
|
|
23663
23693
|
stop_sequence: null,
|
|
23664
23694
|
usage: anthropicUsageFromCanonical(event.response.usage, options.contextWindow, {
|
|
23665
|
-
forceOutputZero: true
|
|
23695
|
+
forceOutputZero: true,
|
|
23696
|
+
compactCeiling: options.compactCeiling
|
|
23666
23697
|
})
|
|
23667
23698
|
}
|
|
23668
23699
|
});
|
|
@@ -23828,7 +23859,9 @@ data: ${JSON.stringify(data)}
|
|
|
23828
23859
|
// Claude Code updates context occupancy from the terminal cumulative
|
|
23829
23860
|
// usage frame. Sending output-only leaves Responses-backed models at
|
|
23830
23861
|
// zero input usage even though Kimi's native Anthropic stream works.
|
|
23831
|
-
usage: anthropicUsageFromCanonical(event.response.usage, options.contextWindow
|
|
23862
|
+
usage: anthropicUsageFromCanonical(event.response.usage, options.contextWindow, {
|
|
23863
|
+
compactCeiling: options.compactCeiling
|
|
23864
|
+
})
|
|
23832
23865
|
});
|
|
23833
23866
|
yield encode3("message_stop", { type: "message_stop" });
|
|
23834
23867
|
messageStopped = true;
|
|
@@ -24073,6 +24106,20 @@ function nextEventBoundary(buffer) {
|
|
|
24073
24106
|
const match = /\r\n\r\n|\n\n|\r\r/.exec(buffer);
|
|
24074
24107
|
return match === null ? void 0 : { index: match.index, length: match[0].length };
|
|
24075
24108
|
}
|
|
24109
|
+
function nextEventBoundaryBytes(buffer) {
|
|
24110
|
+
for (let index = 0; index < buffer.byteLength; index += 1) {
|
|
24111
|
+
const first = buffer[index];
|
|
24112
|
+
if (first === 10) {
|
|
24113
|
+
if (buffer[index + 1] === 10) return { index, length: 2 };
|
|
24114
|
+
continue;
|
|
24115
|
+
}
|
|
24116
|
+
if (first !== 13) continue;
|
|
24117
|
+
if (buffer[index + 1] === 13) return { index, length: 2 };
|
|
24118
|
+
if (buffer[index + 1] !== 10) continue;
|
|
24119
|
+
if (buffer[index + 2] === 13 && buffer[index + 3] === 10) return { index, length: 4 };
|
|
24120
|
+
}
|
|
24121
|
+
return void 0;
|
|
24122
|
+
}
|
|
24076
24123
|
function parseSseFrameFields(frame) {
|
|
24077
24124
|
let eventName;
|
|
24078
24125
|
const data = [];
|
|
@@ -24216,6 +24263,104 @@ async function* logCanonicalEvents(events, event) {
|
|
|
24216
24263
|
yield item;
|
|
24217
24264
|
}
|
|
24218
24265
|
}
|
|
24266
|
+
function logRawWireEvent(label, eventName, data) {
|
|
24267
|
+
if (!wireLogEnabled()) return;
|
|
24268
|
+
wireLog(label, {
|
|
24269
|
+
...eventName === void 0 ? {} : { event: eventName },
|
|
24270
|
+
data
|
|
24271
|
+
});
|
|
24272
|
+
}
|
|
24273
|
+
var RAW_EVENT_MAX_FRAME_BYTES = 1024 * 1024;
|
|
24274
|
+
var RAW_EVENT_MAX_JSON_BYTES = 16 * 1024 * 1024;
|
|
24275
|
+
async function* logRawPassthroughBody(chunks, options) {
|
|
24276
|
+
if (!wireLogEnabled()) {
|
|
24277
|
+
yield* chunks;
|
|
24278
|
+
return;
|
|
24279
|
+
}
|
|
24280
|
+
const mediaType = options.contentType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
24281
|
+
if (mediaType === "text/event-stream") {
|
|
24282
|
+
yield* tapPassthroughSse(chunks, options.label);
|
|
24283
|
+
return;
|
|
24284
|
+
}
|
|
24285
|
+
if (mediaType === "application/json" || mediaType?.endsWith("+json")) {
|
|
24286
|
+
yield* tapPassthroughJson(chunks, options.label);
|
|
24287
|
+
return;
|
|
24288
|
+
}
|
|
24289
|
+
yield* chunks;
|
|
24290
|
+
}
|
|
24291
|
+
async function* tapPassthroughSse(chunks, label) {
|
|
24292
|
+
let pending = new Uint8Array(0);
|
|
24293
|
+
let oversizedFrame = false;
|
|
24294
|
+
for await (const chunk of chunks) {
|
|
24295
|
+
pending = concatBytes2(pending, chunk);
|
|
24296
|
+
let boundary = nextEventBoundaryBytes(pending);
|
|
24297
|
+
while (boundary !== void 0) {
|
|
24298
|
+
const frame = pending.slice(0, boundary.index);
|
|
24299
|
+
pending = pending.slice(boundary.index + boundary.length);
|
|
24300
|
+
if (!oversizedFrame && frame.byteLength <= RAW_EVENT_MAX_FRAME_BYTES) {
|
|
24301
|
+
tapPassthroughFrameBytes(label, frame);
|
|
24302
|
+
}
|
|
24303
|
+
oversizedFrame = false;
|
|
24304
|
+
boundary = nextEventBoundaryBytes(pending);
|
|
24305
|
+
}
|
|
24306
|
+
if (pending.byteLength > RAW_EVENT_MAX_FRAME_BYTES) {
|
|
24307
|
+
pending = pending.slice(Math.max(0, pending.byteLength - 3));
|
|
24308
|
+
oversizedFrame = true;
|
|
24309
|
+
}
|
|
24310
|
+
yield chunk;
|
|
24311
|
+
}
|
|
24312
|
+
if (!oversizedFrame && pending.byteLength > 0) {
|
|
24313
|
+
tapPassthroughFrameBytes(label, pending);
|
|
24314
|
+
}
|
|
24315
|
+
}
|
|
24316
|
+
function tapPassthroughFrameBytes(label, frameBytes) {
|
|
24317
|
+
let frame;
|
|
24318
|
+
try {
|
|
24319
|
+
frame = new TextDecoder("utf-8", { fatal: true }).decode(frameBytes);
|
|
24320
|
+
} catch {
|
|
24321
|
+
return;
|
|
24322
|
+
}
|
|
24323
|
+
const { event: eventName, data } = parseSseFrameFields(frame);
|
|
24324
|
+
if (data.length === 0 || data === "[DONE]") return;
|
|
24325
|
+
let parsed;
|
|
24326
|
+
try {
|
|
24327
|
+
parsed = JSON.parse(data);
|
|
24328
|
+
} catch {
|
|
24329
|
+
return;
|
|
24330
|
+
}
|
|
24331
|
+
logRawWireEvent(label, eventName, parsed);
|
|
24332
|
+
}
|
|
24333
|
+
async function* tapPassthroughJson(chunks, label) {
|
|
24334
|
+
let pending = new Uint8Array(0);
|
|
24335
|
+
let oversized = false;
|
|
24336
|
+
for await (const chunk of chunks) {
|
|
24337
|
+
if (!oversized) {
|
|
24338
|
+
if (pending.byteLength + chunk.byteLength > RAW_EVENT_MAX_JSON_BYTES) {
|
|
24339
|
+
oversized = true;
|
|
24340
|
+
pending = new Uint8Array(0);
|
|
24341
|
+
} else {
|
|
24342
|
+
pending = concatBytes2(pending, chunk);
|
|
24343
|
+
}
|
|
24344
|
+
}
|
|
24345
|
+
yield chunk;
|
|
24346
|
+
}
|
|
24347
|
+
if (oversized || pending.byteLength === 0) return;
|
|
24348
|
+
let parsed;
|
|
24349
|
+
try {
|
|
24350
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(pending));
|
|
24351
|
+
} catch {
|
|
24352
|
+
return;
|
|
24353
|
+
}
|
|
24354
|
+
logRawWireEvent(label, void 0, parsed);
|
|
24355
|
+
}
|
|
24356
|
+
function concatBytes2(left, right) {
|
|
24357
|
+
if (left.byteLength === 0) return right;
|
|
24358
|
+
if (right.byteLength === 0) return left;
|
|
24359
|
+
const combined = new Uint8Array(left.byteLength + right.byteLength);
|
|
24360
|
+
combined.set(left, 0);
|
|
24361
|
+
combined.set(right, left.byteLength);
|
|
24362
|
+
return combined;
|
|
24363
|
+
}
|
|
24219
24364
|
var OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses";
|
|
24220
24365
|
var CHATGPT_CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
24221
24366
|
var DEFAULT_MAX_UPSTREAM_BODY_BYTES = 64 * 1024 * 1024;
|
|
@@ -24646,6 +24791,7 @@ function parseEventFrame(frame) {
|
|
|
24646
24791
|
`OpenAI SSE contained invalid JSON: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
24647
24792
|
);
|
|
24648
24793
|
}
|
|
24794
|
+
logRawWireEvent("openai.wire.event", eventName, parsed);
|
|
24649
24795
|
if (isRecord3(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
|
|
24650
24796
|
parsed = { ...parsed, type: eventName };
|
|
24651
24797
|
}
|
|
@@ -25143,12 +25289,14 @@ var AnthropicMessagesGateway = class {
|
|
|
25143
25289
|
}),
|
|
25144
25290
|
body: withSseKeepAlive(encodeAnthropicSse(events, {
|
|
25145
25291
|
contextWindow: options.contextWindow,
|
|
25292
|
+
compactCeiling: options.compactCeiling,
|
|
25146
25293
|
model: request.model
|
|
25147
25294
|
}))
|
|
25148
25295
|
};
|
|
25149
25296
|
}
|
|
25150
25297
|
const message = await collectAnthropicMessage(events, request.model, {
|
|
25151
25298
|
contextWindow: options.contextWindow,
|
|
25299
|
+
compactCeiling: options.compactCeiling,
|
|
25152
25300
|
model: request.model
|
|
25153
25301
|
});
|
|
25154
25302
|
return {
|
|
@@ -25531,10 +25679,12 @@ function parseClaudeCredentialJson(raw, method) {
|
|
|
25531
25679
|
const oauth = credentialRecord(parsed.claudeAiOauth);
|
|
25532
25680
|
const accessToken = optionalString(oauth?.accessToken ?? parsed.accessToken);
|
|
25533
25681
|
if (!accessToken) return null;
|
|
25682
|
+
const rateLimitTier = optionalString(oauth?.rateLimitTier ?? parsed.rateLimitTier);
|
|
25534
25683
|
return {
|
|
25535
25684
|
accessToken,
|
|
25536
25685
|
expiresAt: optionalEpoch(oauth?.expiresAt ?? parsed.expiresAt),
|
|
25537
25686
|
subscriptionType: optionalString(oauth?.subscriptionType ?? parsed.subscriptionType),
|
|
25687
|
+
...rateLimitTier === void 0 ? {} : { rateLimitTier },
|
|
25538
25688
|
method
|
|
25539
25689
|
};
|
|
25540
25690
|
} catch {
|
|
@@ -25563,6 +25713,13 @@ async function resolveClaudeCredentials(deps) {
|
|
|
25563
25713
|
}
|
|
25564
25714
|
}
|
|
25565
25715
|
var CLAUDE_SESSION_MS = 5 * HOUR_MS;
|
|
25716
|
+
function formatClaudePlan(subscriptionType, rateLimitTier) {
|
|
25717
|
+
const base = titleCase(subscriptionType);
|
|
25718
|
+
if (!base) return void 0;
|
|
25719
|
+
if (base.toLowerCase() !== "max" || typeof rateLimitTier !== "string") return base;
|
|
25720
|
+
const match = /\d+x/i.exec(rateLimitTier.trim());
|
|
25721
|
+
return match ? titleCase(`${base} ${match[0].toLowerCase()}`) : base;
|
|
25722
|
+
}
|
|
25566
25723
|
function firstClaudePercent(row) {
|
|
25567
25724
|
for (const key of ["percent", "used_percentage", "utilization"]) {
|
|
25568
25725
|
const value = row[key];
|
|
@@ -25646,7 +25803,7 @@ async function fetchClaudeUsage(deps = {}) {
|
|
|
25646
25803
|
return {
|
|
25647
25804
|
status: "ok",
|
|
25648
25805
|
method: credentials.method,
|
|
25649
|
-
plan:
|
|
25806
|
+
plan: formatClaudePlan(credentials.subscriptionType, credentials.rateLimitTier),
|
|
25650
25807
|
windows: parsed.windows,
|
|
25651
25808
|
fetchedAt: (deps.now ?? Date.now)()
|
|
25652
25809
|
};
|
|
@@ -25691,6 +25848,17 @@ function codexWindow(source, fallbackId) {
|
|
|
25691
25848
|
...period ? { period } : {}
|
|
25692
25849
|
};
|
|
25693
25850
|
}
|
|
25851
|
+
function formatCodexPlan(value) {
|
|
25852
|
+
if (typeof value !== "string") return titleCase(value);
|
|
25853
|
+
switch (value.trim().toLowerCase()) {
|
|
25854
|
+
case "prolite":
|
|
25855
|
+
return "Pro 5x";
|
|
25856
|
+
case "pro":
|
|
25857
|
+
return "Pro 20x";
|
|
25858
|
+
default:
|
|
25859
|
+
return titleCase(value);
|
|
25860
|
+
}
|
|
25861
|
+
}
|
|
25694
25862
|
function parseCodexUsage(payload) {
|
|
25695
25863
|
const root = object2(payload) ?? {};
|
|
25696
25864
|
const rateLimit = object2(root.rate_limit) ?? {};
|
|
@@ -25699,7 +25867,7 @@ function parseCodexUsage(payload) {
|
|
|
25699
25867
|
codexWindow(rateLimit.primary_window, "session"),
|
|
25700
25868
|
codexWindow(rateLimit.secondary_window, "weekly")
|
|
25701
25869
|
].filter((row) => row !== null),
|
|
25702
|
-
plan:
|
|
25870
|
+
plan: formatCodexPlan(root.plan_type)
|
|
25703
25871
|
};
|
|
25704
25872
|
}
|
|
25705
25873
|
function parseResetCredits(payload) {
|
|
@@ -26164,6 +26332,7 @@ async function resolveXaiCliCredentials(deps, nowOrOptions = Date.now) {
|
|
|
26164
26332
|
return result.status === "ok" ? result.credentials : null;
|
|
26165
26333
|
}
|
|
26166
26334
|
var XAI_CLI_CREDITS_URL = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
|
|
26335
|
+
var XAI_CLI_SETTINGS_URL = "https://cli-chat-proxy.grok.com/v1/settings";
|
|
26167
26336
|
var WEEKLY_PERIOD = "USAGE_PERIOD_TYPE_WEEKLY";
|
|
26168
26337
|
function parseXaiCredits(payload) {
|
|
26169
26338
|
const root = object2(payload);
|
|
@@ -26197,6 +26366,9 @@ function parseXaiCredits(payload) {
|
|
|
26197
26366
|
}
|
|
26198
26367
|
};
|
|
26199
26368
|
}
|
|
26369
|
+
function parseXaiPlan(payload) {
|
|
26370
|
+
return titleCase(object2(payload)?.subscription_tier_display);
|
|
26371
|
+
}
|
|
26200
26372
|
function creditsHeaders(credentials) {
|
|
26201
26373
|
const headers = {
|
|
26202
26374
|
Accept: "application/json",
|
|
@@ -26241,8 +26413,15 @@ async function fetchXaiUsage(deps = {}) {
|
|
|
26241
26413
|
}
|
|
26242
26414
|
const parsed = parseXaiCredits(payload);
|
|
26243
26415
|
if (!parsed) throw new Error("Grok returned an unsupported quota response");
|
|
26416
|
+
let plan;
|
|
26417
|
+
try {
|
|
26418
|
+
plan = parseXaiPlan(await getJson(fetchImpl, XAI_CLI_SETTINGS_URL, creditsHeaders(credentials)));
|
|
26419
|
+
} catch {
|
|
26420
|
+
plan = void 0;
|
|
26421
|
+
}
|
|
26244
26422
|
return {
|
|
26245
26423
|
status: "ok",
|
|
26424
|
+
...plan ? { plan } : {},
|
|
26246
26425
|
windows: parsed.status === "weekly" ? [parsed.window] : [],
|
|
26247
26426
|
fetchedAt: now()
|
|
26248
26427
|
};
|
|
@@ -26606,6 +26785,7 @@ function parseEventFrame2(frame) {
|
|
|
26606
26785
|
`Grok CLI SSE contained invalid JSON: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
26607
26786
|
);
|
|
26608
26787
|
}
|
|
26788
|
+
logRawWireEvent("xai-responses.wire.event", eventName, parsed);
|
|
26609
26789
|
if (isRecord5(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
|
|
26610
26790
|
parsed = { ...parsed, type: eventName };
|
|
26611
26791
|
}
|
|
@@ -30609,6 +30789,7 @@ ${argumentsText}`;
|
|
|
30609
30789
|
continue;
|
|
30610
30790
|
}
|
|
30611
30791
|
const decodedFrame = decodeCursorServerMessage(frame.payload);
|
|
30792
|
+
logRawWireEvent("cursor.wire.event", void 0, decodedFrame);
|
|
30612
30793
|
if (!isCursorHeartbeatFrame(decodedFrame)) noteSemanticProgress();
|
|
30613
30794
|
handleFrame(decodedFrame);
|
|
30614
30795
|
}
|
|
@@ -31231,12 +31412,14 @@ function normalizeAiGatewaySettings(value) {
|
|
|
31231
31412
|
}];
|
|
31232
31413
|
}) : [];
|
|
31233
31414
|
const providerPriority = sanitizeProviderPriority(value.providerPriority);
|
|
31415
|
+
const compactCeiling = normalizeCompactCeiling(value.compactCeiling);
|
|
31234
31416
|
return {
|
|
31235
31417
|
version: 1,
|
|
31236
31418
|
...models.length > 0 ? { models } : {},
|
|
31237
31419
|
...value.cursorDiagnosticsEnabled === true ? { cursorDiagnosticsEnabled: true } : {},
|
|
31238
31420
|
...typeof value.wireLogEnabled === "boolean" ? { wireLogEnabled: value.wireLogEnabled } : {},
|
|
31239
|
-
...providerPriority ? { providerPriority: [...providerPriority] } : {}
|
|
31421
|
+
...providerPriority ? { providerPriority: [...providerPriority] } : {},
|
|
31422
|
+
...compactCeiling !== void 0 ? { compactCeiling } : {}
|
|
31240
31423
|
};
|
|
31241
31424
|
}
|
|
31242
31425
|
function sanitizeProviderPriority(value) {
|
|
@@ -31743,17 +31926,19 @@ async function* translateChatCompletionsStream(body2, options, toolSchemas) {
|
|
|
31743
31926
|
while (boundary !== void 0) {
|
|
31744
31927
|
const frame = buffer.slice(0, boundary.index);
|
|
31745
31928
|
buffer = buffer.slice(boundary.index + boundary.length);
|
|
31746
|
-
const
|
|
31747
|
-
if (
|
|
31748
|
-
|
|
31929
|
+
const frameData = chatFrameData(frame);
|
|
31930
|
+
if (frameData !== void 0) {
|
|
31931
|
+
logRawWireEvent("openai-chat.wire.event", frameData.event, frameData.data);
|
|
31932
|
+
yield* consumeChunk(frameData.data);
|
|
31749
31933
|
}
|
|
31750
31934
|
boundary = nextEventBoundary(buffer);
|
|
31751
31935
|
}
|
|
31752
31936
|
}
|
|
31753
31937
|
if (buffer.trim().length > 0) {
|
|
31754
|
-
const
|
|
31755
|
-
if (
|
|
31756
|
-
|
|
31938
|
+
const frameData = chatFrameData(buffer);
|
|
31939
|
+
if (frameData !== void 0) {
|
|
31940
|
+
logRawWireEvent("openai-chat.wire.event", frameData.event, frameData.data);
|
|
31941
|
+
yield* consumeChunk(frameData.data);
|
|
31757
31942
|
}
|
|
31758
31943
|
}
|
|
31759
31944
|
yield* finish();
|
|
@@ -31763,12 +31948,15 @@ async function* translateChatCompletionsStream(body2, options, toolSchemas) {
|
|
|
31763
31948
|
}
|
|
31764
31949
|
}
|
|
31765
31950
|
function chatFrameData(frame) {
|
|
31766
|
-
const { data } = parseSseFrameFields(frame);
|
|
31951
|
+
const { event: eventName, data } = parseSseFrameFields(frame);
|
|
31767
31952
|
if (data.length === 0 || data === "[DONE]") {
|
|
31768
31953
|
return void 0;
|
|
31769
31954
|
}
|
|
31770
31955
|
try {
|
|
31771
|
-
return
|
|
31956
|
+
return {
|
|
31957
|
+
...eventName === void 0 ? {} : { event: eventName },
|
|
31958
|
+
data: JSON.parse(data)
|
|
31959
|
+
};
|
|
31772
31960
|
} catch (error51) {
|
|
31773
31961
|
throw new UpstreamProtocolError(
|
|
31774
31962
|
`Chat Completions SSE contained invalid JSON: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
@@ -31966,6 +32154,7 @@ function parseEventFrame3(frame) {
|
|
|
31966
32154
|
`OpenCode Go SSE contained invalid JSON: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
31967
32155
|
);
|
|
31968
32156
|
}
|
|
32157
|
+
logRawWireEvent("opencode-go-responses.wire.event", eventName, parsed);
|
|
31969
32158
|
if (isRecord11(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
|
|
31970
32159
|
parsed = { ...parsed, type: eventName };
|
|
31971
32160
|
}
|
|
@@ -32412,9 +32601,14 @@ async function proxyAnthropicMessages(res, body2, options) {
|
|
|
32412
32601
|
}
|
|
32413
32602
|
const rawBody = readResponseBody(upstream.body);
|
|
32414
32603
|
const contentType = upstream.headers.get("content-type");
|
|
32415
|
-
const
|
|
32604
|
+
const observedBody = options.wireEventLabel === void 0 ? rawBody : logRawPassthroughBody(rawBody, {
|
|
32605
|
+
label: options.wireEventLabel,
|
|
32606
|
+
contentType
|
|
32607
|
+
});
|
|
32608
|
+
const projectedBody = options.contextWindow === void 0 && options.responseModel === void 0 ? observedBody : projectAnthropicResponseUsage(observedBody, {
|
|
32416
32609
|
contentType,
|
|
32417
32610
|
contextWindow: options.contextWindow,
|
|
32611
|
+
compactCeiling: options.compactCeiling,
|
|
32418
32612
|
responseModel: options.responseModel
|
|
32419
32613
|
});
|
|
32420
32614
|
const responseBody = options.keepAlive === true && contentType?.split(";", 1)[0]?.trim().toLowerCase() === "text/event-stream" ? withSseKeepAlive(projectedBody) : projectedBody;
|
|
@@ -32465,17 +32659,19 @@ function isOpencodeAnthropicPassthrough(model) {
|
|
|
32465
32659
|
function createOpencodeGateway(wire) {
|
|
32466
32660
|
return new AnthropicMessagesGateway(createOpencodeGoAdapter(wire));
|
|
32467
32661
|
}
|
|
32468
|
-
async function proxyToOpencode(requestHeaders, res, body2, model, contextWindow, apiKey, fetchImpl, signal) {
|
|
32662
|
+
async function proxyToOpencode(requestHeaders, res, body2, model, contextWindow, compactCeiling, apiKey, fetchImpl, signal) {
|
|
32469
32663
|
const headers = opencodeAnthropicHeaders(requestHeaders, apiKey);
|
|
32470
32664
|
const responseModel = typeof body2.model === "string" ? body2.model : void 0;
|
|
32471
32665
|
await proxyAnthropicMessages(res, opencodeRequestBody(body2, model), {
|
|
32472
32666
|
contextWindow,
|
|
32667
|
+
compactCeiling,
|
|
32473
32668
|
responseModel,
|
|
32474
32669
|
keepAlive: true,
|
|
32475
32670
|
fetchImpl,
|
|
32476
32671
|
headers,
|
|
32477
32672
|
signal,
|
|
32478
|
-
url: OPENCODE_GO_MESSAGES_URL
|
|
32673
|
+
url: OPENCODE_GO_MESSAGES_URL,
|
|
32674
|
+
wireEventLabel: "opencode-go-anthropic.wire.event"
|
|
32479
32675
|
});
|
|
32480
32676
|
}
|
|
32481
32677
|
var AI_GATEWAY_ROUTE_SEGMENT = "ai-gateway";
|
|
@@ -32528,6 +32724,13 @@ function createAiGatewayRouter(deps) {
|
|
|
32528
32724
|
return false;
|
|
32529
32725
|
}
|
|
32530
32726
|
};
|
|
32727
|
+
const compactCeiling = () => {
|
|
32728
|
+
try {
|
|
32729
|
+
return gatewaySettings()?.compactCeiling;
|
|
32730
|
+
} catch {
|
|
32731
|
+
return void 0;
|
|
32732
|
+
}
|
|
32733
|
+
};
|
|
32531
32734
|
const handle = async ({ req, res, pathname }) => {
|
|
32532
32735
|
if (pathname.endsWith("/api/hello")) {
|
|
32533
32736
|
res.writeHead(200, { "content-type": "application/json" });
|
|
@@ -32647,6 +32850,7 @@ function createAiGatewayRouter(deps) {
|
|
|
32647
32850
|
return true;
|
|
32648
32851
|
}
|
|
32649
32852
|
const claudeContextWindow = target2.contextWindow;
|
|
32853
|
+
const ceiling = compactCeiling();
|
|
32650
32854
|
if (target2.provider === "kimi") {
|
|
32651
32855
|
await proxyToKimi(
|
|
32652
32856
|
req.headers,
|
|
@@ -32654,6 +32858,7 @@ function createAiGatewayRouter(deps) {
|
|
|
32654
32858
|
body2,
|
|
32655
32859
|
upstreamModelId(target2),
|
|
32656
32860
|
claudeContextWindow,
|
|
32861
|
+
ceiling,
|
|
32657
32862
|
credential,
|
|
32658
32863
|
fetchImpl,
|
|
32659
32864
|
controller.signal
|
|
@@ -32667,6 +32872,7 @@ function createAiGatewayRouter(deps) {
|
|
|
32667
32872
|
body2,
|
|
32668
32873
|
upstreamModelId(target2),
|
|
32669
32874
|
claudeContextWindow,
|
|
32875
|
+
ceiling,
|
|
32670
32876
|
credential,
|
|
32671
32877
|
fetchImpl,
|
|
32672
32878
|
controller.signal
|
|
@@ -32679,6 +32885,7 @@ function createAiGatewayRouter(deps) {
|
|
|
32679
32885
|
const upstream = await gateway.stream(body2, {
|
|
32680
32886
|
apiKey: credential,
|
|
32681
32887
|
...claudeContextWindow ? { contextWindow: claudeContextWindow } : {},
|
|
32888
|
+
...ceiling === void 0 ? {} : { compactCeiling: ceiling },
|
|
32682
32889
|
...modelContextWindow === void 0 ? {} : { modelContextWindow },
|
|
32683
32890
|
...diagnosticsEnabled === void 0 ? {} : { diagnosticsEnabled },
|
|
32684
32891
|
signal: controller.signal,
|
|
@@ -32722,20 +32929,23 @@ async function proxyToAnthropic(requestHeaders, res, body2, fetchImpl, signal) {
|
|
|
32722
32929
|
fetchImpl,
|
|
32723
32930
|
headers,
|
|
32724
32931
|
signal,
|
|
32725
|
-
url: ANTHROPIC_MESSAGES_URL
|
|
32932
|
+
url: ANTHROPIC_MESSAGES_URL,
|
|
32933
|
+
wireEventLabel: "anthropic.wire.event"
|
|
32726
32934
|
});
|
|
32727
32935
|
}
|
|
32728
|
-
async function proxyToKimi(requestHeaders, res, body2, model, contextWindow, apiKey, fetchImpl, signal) {
|
|
32936
|
+
async function proxyToKimi(requestHeaders, res, body2, model, contextWindow, compactCeiling, apiKey, fetchImpl, signal) {
|
|
32729
32937
|
const headers = kimiAnthropicHeaders(requestHeaders, apiKey);
|
|
32730
32938
|
const responseModel = typeof body2.model === "string" ? body2.model : void 0;
|
|
32731
32939
|
await proxyAnthropicMessages(res, kimiRequestBody(body2, model), {
|
|
32732
32940
|
contextWindow,
|
|
32941
|
+
compactCeiling,
|
|
32733
32942
|
responseModel,
|
|
32734
32943
|
keepAlive: true,
|
|
32735
32944
|
fetchImpl,
|
|
32736
32945
|
headers,
|
|
32737
32946
|
signal,
|
|
32738
|
-
url: KIMI_MESSAGES_URL
|
|
32947
|
+
url: KIMI_MESSAGES_URL,
|
|
32948
|
+
wireEventLabel: "kimi-anthropic.wire.event"
|
|
32739
32949
|
});
|
|
32740
32950
|
}
|
|
32741
32951
|
function createGatewayFor(model, chatgptAccountId, originator) {
|
|
@@ -32830,6 +33040,7 @@ function createAiGatewaySettingsStore(deps = {}) {
|
|
|
32830
33040
|
// 우선순위는 이 update 계약이 나르지 않는 별도 표면의 설정이다. 이월하지 않으면
|
|
32831
33041
|
// 무관한 모델 노출 저장 한 번이 사용자의 소진 순서를 지운다.
|
|
32832
33042
|
...current.providerPriority ? { providerPriority: current.providerPriority } : {},
|
|
33043
|
+
...current.compactCeiling !== void 0 ? { compactCeiling: current.compactCeiling } : {},
|
|
32833
33044
|
...value ?? {}
|
|
32834
33045
|
})),
|
|
32835
33046
|
writeCursorDiagnosticsEnabled: (enabled) => update((current) => normalizeAiGatewaySettings({
|
|
@@ -32845,6 +33056,16 @@ function createAiGatewaySettingsStore(deps = {}) {
|
|
|
32845
33056
|
const withoutWireLog = { ...next };
|
|
32846
33057
|
delete withoutWireLog.wireLogEnabled;
|
|
32847
33058
|
return withoutWireLog;
|
|
33059
|
+
}),
|
|
33060
|
+
writeCompactCeiling: (ceiling) => update((current) => {
|
|
33061
|
+
const next = normalizeAiGatewaySettings({
|
|
33062
|
+
...current,
|
|
33063
|
+
...ceiling === void 0 ? {} : { compactCeiling: ceiling }
|
|
33064
|
+
});
|
|
33065
|
+
if (ceiling !== void 0) return next;
|
|
33066
|
+
const withoutCeiling = { ...next };
|
|
33067
|
+
delete withoutCeiling.compactCeiling;
|
|
33068
|
+
return withoutCeiling;
|
|
32848
33069
|
})
|
|
32849
33070
|
};
|
|
32850
33071
|
}
|
|
@@ -32873,7 +33094,7 @@ function readLegacySettings(legacyPath) {
|
|
|
32873
33094
|
return hasStoredValue(settings2) ? { kind: "adopt", settings: settings2 } : { kind: "nothing" };
|
|
32874
33095
|
}
|
|
32875
33096
|
function hasStoredValue(settings2) {
|
|
32876
|
-
return (settings2.models?.length ?? 0) > 0 || settings2.cursorDiagnosticsEnabled !== void 0 || settings2.wireLogEnabled !== void 0;
|
|
33097
|
+
return (settings2.models?.length ?? 0) > 0 || settings2.cursorDiagnosticsEnabled !== void 0 || settings2.wireLogEnabled !== void 0 || settings2.providerPriority !== void 0 || settings2.compactCeiling !== void 0;
|
|
32877
33098
|
}
|
|
32878
33099
|
|
|
32879
33100
|
// ../../packages/fleet-admiral/src/protocols/standing-orders/gateway.ts
|
|
@@ -46532,23 +46753,88 @@ function buildFleetHelpText(options = {}) {
|
|
|
46532
46753
|
|
|
46533
46754
|
// core/host/console-lifecycle.ts
|
|
46534
46755
|
init_src();
|
|
46756
|
+
var SPAWN_GRACE_MS = 250;
|
|
46535
46757
|
function openBrowser(url2, deps = {}) {
|
|
46536
46758
|
const platform = deps.platform ?? os3__default.platform();
|
|
46537
|
-
const spawnBrowser = deps.spawnBrowser ??
|
|
46538
|
-
|
|
46539
|
-
|
|
46759
|
+
const spawnBrowser = deps.spawnBrowser ?? defaultSpawnBrowser;
|
|
46760
|
+
const options = { detached: true, stdio: "ignore", windowsHide: true };
|
|
46761
|
+
if (platform === "darwin") return normalize(spawnBrowser("open", [url2], options));
|
|
46762
|
+
if (platform === "win32") return normalize(spawnBrowser("cmd", ["/c", "start", "", url2], options));
|
|
46763
|
+
return normalize(spawnBrowser("xdg-open", [url2], options));
|
|
46764
|
+
}
|
|
46765
|
+
async function normalize(result) {
|
|
46766
|
+
const resolved = await result;
|
|
46767
|
+
return resolved ?? { opened: true };
|
|
46768
|
+
}
|
|
46769
|
+
function defaultSpawnBrowser(command2, args, options) {
|
|
46770
|
+
return new Promise((resolve3) => {
|
|
46771
|
+
let child;
|
|
46772
|
+
try {
|
|
46773
|
+
child = spawn(command2, [...args], options);
|
|
46774
|
+
} catch (error51) {
|
|
46775
|
+
resolve3({ opened: false, reason: describe3(error51, command2) });
|
|
46776
|
+
return;
|
|
46777
|
+
}
|
|
46778
|
+
const timer = setTimeout(() => {
|
|
46779
|
+
child.unref();
|
|
46780
|
+
resolve3({ opened: true });
|
|
46781
|
+
}, SPAWN_GRACE_MS);
|
|
46782
|
+
child.once("error", (error51) => {
|
|
46783
|
+
clearTimeout(timer);
|
|
46784
|
+
child.unref();
|
|
46785
|
+
resolve3({ opened: false, reason: describe3(error51, command2) });
|
|
46786
|
+
});
|
|
46787
|
+
child.once("exit", (code) => {
|
|
46788
|
+
clearTimeout(timer);
|
|
46789
|
+
child.unref();
|
|
46790
|
+
if (code === null || code === 0) resolve3({ opened: true });
|
|
46791
|
+
else resolve3({ opened: false, reason: `${command2} exited with status ${code}` });
|
|
46540
46792
|
});
|
|
46541
|
-
child.unref();
|
|
46542
46793
|
});
|
|
46543
|
-
|
|
46544
|
-
|
|
46545
|
-
|
|
46546
|
-
}
|
|
46547
|
-
if (
|
|
46548
|
-
|
|
46549
|
-
|
|
46794
|
+
}
|
|
46795
|
+
function describe3(error51, command2) {
|
|
46796
|
+
const code = error51?.code;
|
|
46797
|
+
if (code === "ENOENT") return `${command2} is not on PATH`;
|
|
46798
|
+
if (code === "EACCES") return `${command2} is not executable`;
|
|
46799
|
+
return error51 instanceof Error ? error51.message : String(error51);
|
|
46800
|
+
}
|
|
46801
|
+
|
|
46802
|
+
// core/host/failure-notice.ts
|
|
46803
|
+
function formatFailureNotice(notice) {
|
|
46804
|
+
const lines = [notice.what, ` Why ${notice.why}`];
|
|
46805
|
+
notice.next.forEach((step, index) => {
|
|
46806
|
+
lines.push(` ${index === 0 ? "Next " : " "} ${step}`);
|
|
46807
|
+
});
|
|
46808
|
+
return lines.join("\n");
|
|
46809
|
+
}
|
|
46810
|
+
function describeConsoleLaunch(successLine, outcome) {
|
|
46811
|
+
if (outcome.browserOpened) return successLine;
|
|
46812
|
+
return formatFailureNotice({
|
|
46813
|
+
what: "Fleet Console is running, but no browser opened on this machine.",
|
|
46814
|
+
why: outcome.browserError ?? "the browser launcher did not start",
|
|
46815
|
+
next: [`Open this address yourself: ${outcome.url}`]
|
|
46816
|
+
});
|
|
46817
|
+
}
|
|
46818
|
+
function describeDaemonStartFailure(input) {
|
|
46819
|
+
if (input.spawnError) {
|
|
46820
|
+
return formatFailureNotice({
|
|
46821
|
+
what: "Fleet Console server did not start.",
|
|
46822
|
+
why: `the server process could not be spawned \u2014 ${input.spawnError}`,
|
|
46823
|
+
next: [
|
|
46824
|
+
"Check that this Node install can run the Console: node --version",
|
|
46825
|
+
"Reinstall if the package is incomplete: npm install -g @dotobokuri/fleet-console"
|
|
46826
|
+
]
|
|
46827
|
+
});
|
|
46550
46828
|
}
|
|
46551
|
-
|
|
46829
|
+
return formatFailureNotice({
|
|
46830
|
+
what: "Fleet Console server did not start.",
|
|
46831
|
+
why: input.probeError ? `it was started but never answered a health check \u2014 ${input.probeError}` : "it was started but never answered a health check within 3 seconds",
|
|
46832
|
+
next: [
|
|
46833
|
+
`Check that this directory is writable: ${input.dataDir}`,
|
|
46834
|
+
"Show the current state: fleet console status",
|
|
46835
|
+
"Then try again: fleet console restart"
|
|
46836
|
+
]
|
|
46837
|
+
});
|
|
46552
46838
|
}
|
|
46553
46839
|
|
|
46554
46840
|
// core/host/health.ts
|
|
@@ -52468,11 +52754,12 @@ var SDK_API_VERSION = 1;
|
|
|
52468
52754
|
var SHIM_NAMED_EXPORTS = {
|
|
52469
52755
|
"react": ["Activity", "Children", "Component", "Fragment", "Profiler", "PureComponent", "StrictMode", "Suspense", "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE", "__COMPILER_RUNTIME", "act", "cache", "cacheSignal", "captureOwnerStack", "cloneElement", "createContext", "createElement", "createRef", "forwardRef", "isValidElement", "lazy", "memo", "startTransition", "unstable_useCacheRefresh", "use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useEffectEvent", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition", "version"],
|
|
52470
52756
|
"react/jsx-runtime": ["Fragment", "jsx", "jsxs"],
|
|
52471
|
-
"@fleet-console/sdk/plugin/browser": ["React", "createClientCapabilities", "defineOperationKind", "definePlugin", "
|
|
52757
|
+
"@fleet-console/sdk/plugin/browser": ["React", "createClientCapabilities", "defineOperationKind", "definePlugin", "useOperationRuntime", "useOperationRuntimeHydration", "useOperations", "usePluginApi", "usePluginSettings", "usePluginStorage", "useStoreSnapshot"],
|
|
52472
52758
|
"@fleet-console/sdk/settings/browser": ["ExperimentalBadge", "SettingsCard", "SettingsField", "SettingsRow", "SettingsSelect", "SettingsToggle", "defineSettingsSection"],
|
|
52473
52759
|
"@fleet-console/sdk/operations/browser": ["ApiError", "OperationBody", "assertOperationNode", "fetchOperationCatalog", "hasForbiddenBrowserPayloadKey"],
|
|
52474
52760
|
"@fleet-console/sdk/notifications/browser": ["defineNotificationKind"],
|
|
52475
|
-
"@fleet-console/sdk/react/browser": ["PluginErrorBoundary", "React", "Select", "useSelect"]
|
|
52761
|
+
"@fleet-console/sdk/react/browser": ["PluginErrorBoundary", "React", "Select", "useSelect"],
|
|
52762
|
+
"@fleet-console/sdk/components/failure-notice": ["FailureNotice"]
|
|
52476
52763
|
};
|
|
52477
52764
|
|
|
52478
52765
|
// core/host/plugin-host/plugin-host.ts
|
|
@@ -52605,7 +52892,8 @@ var SHIM_DEFINITIONS = [
|
|
|
52605
52892
|
{ name: "sdk-settings-browser", specifier: "@fleet-console/sdk/settings/browser", globalKey: "@fleet-console/sdk/settings/browser", namedExports: SHIM_NAMED_EXPORTS["@fleet-console/sdk/settings/browser"] ?? [] },
|
|
52606
52893
|
{ name: "sdk-operations-browser", specifier: "@fleet-console/sdk/operations/browser", globalKey: "@fleet-console/sdk/operations/browser", namedExports: SHIM_NAMED_EXPORTS["@fleet-console/sdk/operations/browser"] ?? [] },
|
|
52607
52894
|
{ name: "sdk-notifications-browser", specifier: "@fleet-console/sdk/notifications/browser", globalKey: "@fleet-console/sdk/notifications/browser", namedExports: SHIM_NAMED_EXPORTS["@fleet-console/sdk/notifications/browser"] ?? [] },
|
|
52608
|
-
{ name: "sdk-react-browser", specifier: "@fleet-console/sdk/react/browser", globalKey: "@fleet-console/sdk/react/browser", namedExports: SHIM_NAMED_EXPORTS["@fleet-console/sdk/react/browser"] ?? [] }
|
|
52895
|
+
{ name: "sdk-react-browser", specifier: "@fleet-console/sdk/react/browser", globalKey: "@fleet-console/sdk/react/browser", namedExports: SHIM_NAMED_EXPORTS["@fleet-console/sdk/react/browser"] ?? [] },
|
|
52896
|
+
{ name: "sdk-components-failure-notice", specifier: "@fleet-console/sdk/components/failure-notice", globalKey: "@fleet-console/sdk/components/failure-notice", namedExports: SHIM_NAMED_EXPORTS["@fleet-console/sdk/components/failure-notice"] ?? [] }
|
|
52609
52897
|
];
|
|
52610
52898
|
var SHIM_URL_BY_SPECIFIER = new Map(SHIM_DEFINITIONS.map((definition) => [definition.specifier, `/plugin-runtime/shim/${definition.name}.mjs`]));
|
|
52611
52899
|
var SHIM_BY_NAME = new Map(SHIM_DEFINITIONS.map((definition) => [definition.name, definition]));
|
|
@@ -52616,9 +52904,11 @@ var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
|
52616
52904
|
function createPluginClientAssets(deps) {
|
|
52617
52905
|
const clientSources = /* @__PURE__ */ new Map();
|
|
52618
52906
|
const preparedPlugins = /* @__PURE__ */ new Set();
|
|
52907
|
+
const skippedPlugins = /* @__PURE__ */ new Map();
|
|
52619
52908
|
async function prepare() {
|
|
52620
52909
|
clientSources.clear();
|
|
52621
52910
|
preparedPlugins.clear();
|
|
52911
|
+
skippedPlugins.clear();
|
|
52622
52912
|
for (const plugin of deps.plugins) {
|
|
52623
52913
|
if (!plugin.external || !plugin.clientEntry) continue;
|
|
52624
52914
|
try {
|
|
@@ -52627,17 +52917,24 @@ function createPluginClientAssets(deps) {
|
|
|
52627
52917
|
preparedPlugins.add(plugin.manifest.id);
|
|
52628
52918
|
} catch (error51) {
|
|
52629
52919
|
console.warn(`[fleet-console] Plugin ${plugin.manifest.id} client skipped: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
52920
|
+
skippedPlugins.set(plugin.manifest.id, {
|
|
52921
|
+
id: plugin.manifest.id,
|
|
52922
|
+
...plugin.manifest.name ? { name: plugin.manifest.name } : {},
|
|
52923
|
+
reason: error51?.message === "unsupported_client_entry" ? "unsupported_client_entry" : "client_build_failed"
|
|
52924
|
+
});
|
|
52630
52925
|
}
|
|
52631
52926
|
}
|
|
52632
52927
|
}
|
|
52633
52928
|
function manifest() {
|
|
52929
|
+
const skipped = [...skippedPlugins.values()];
|
|
52634
52930
|
return {
|
|
52635
52931
|
plugins: deps.plugins.filter((plugin) => plugin.external && !!plugin.clientEntry && preparedPlugins.has(plugin.manifest.id)).map((plugin) => ({
|
|
52636
52932
|
id: plugin.manifest.id,
|
|
52637
52933
|
...plugin.manifest.name ? { name: plugin.manifest.name } : {},
|
|
52638
52934
|
clientUrl: `/plugin-runtime/client/${plugin.manifest.id}.mjs`,
|
|
52639
52935
|
apiVersion: plugin.manifest.apiVersion ?? SDK_API_VERSION
|
|
52640
|
-
}))
|
|
52936
|
+
})),
|
|
52937
|
+
...skipped.length > 0 ? { skipped } : {}
|
|
52641
52938
|
};
|
|
52642
52939
|
}
|
|
52643
52940
|
function getClient(id) {
|
|
@@ -56181,15 +56478,25 @@ function isValidConsoleStaticPort2(value) {
|
|
|
56181
56478
|
function sanitizeLaunchKind(value) {
|
|
56182
56479
|
if (!isPlainObject2(value) || typeof value.id !== "string" || typeof value.type !== "string" || typeof value.title !== "string") return null;
|
|
56183
56480
|
const variants = readLaunchVariantGroups(value.variants);
|
|
56481
|
+
const launchViews = readLaunchViews(value.launchViews);
|
|
56184
56482
|
return {
|
|
56185
56483
|
id: value.id,
|
|
56186
56484
|
type: value.type,
|
|
56187
56485
|
title: value.title,
|
|
56188
56486
|
...typeof value.disabled === "boolean" ? { disabled: value.disabled } : {},
|
|
56189
56487
|
...typeof value.disabledReason === "string" ? { disabledReason: value.disabledReason } : {},
|
|
56190
|
-
...variants.length > 0 ? { variants } : {}
|
|
56488
|
+
...variants.length > 0 ? { variants } : {},
|
|
56489
|
+
...launchViews.length > 0 ? { launchViews } : {}
|
|
56191
56490
|
};
|
|
56192
56491
|
}
|
|
56492
|
+
function readLaunchViews(value) {
|
|
56493
|
+
if (!Array.isArray(value)) return [];
|
|
56494
|
+
const seen = /* @__PURE__ */ new Set();
|
|
56495
|
+
for (const entry of value) {
|
|
56496
|
+
if (entry === "terminal" || entry === "chat") seen.add(entry);
|
|
56497
|
+
}
|
|
56498
|
+
return seen.has("chat") ? [...seen] : [];
|
|
56499
|
+
}
|
|
56193
56500
|
function requestHasBody(req) {
|
|
56194
56501
|
const contentLength = req.headers["content-length"];
|
|
56195
56502
|
if (typeof contentLength === "string" && contentLength !== "0") return true;
|
|
@@ -56370,9 +56677,11 @@ function createConsoleDaemonLifecycle(deps = {}) {
|
|
|
56370
56677
|
const childEnv = env.FLEET_CONSOLE_NO_SYSTEM_CA === "1" ? env : withNodeSystemCa(env);
|
|
56371
56678
|
const execPath = deps.execPath ?? V2.execPath;
|
|
56372
56679
|
const serverModulePath = deps.serverModulePath ?? resolveDefaultServerModulePath2();
|
|
56680
|
+
let lastSpawnError = null;
|
|
56373
56681
|
const spawnDetached = deps.spawnDetached ?? ((bin, args, options) => {
|
|
56374
56682
|
const child = spawn(bin, [...args], options);
|
|
56375
|
-
child.once("error", () => {
|
|
56683
|
+
child.once("error", (error51) => {
|
|
56684
|
+
lastSpawnError = error51 instanceof Error ? error51.message : String(error51);
|
|
56376
56685
|
});
|
|
56377
56686
|
child.unref();
|
|
56378
56687
|
});
|
|
@@ -56425,13 +56734,20 @@ function createConsoleDaemonLifecycle(deps = {}) {
|
|
|
56425
56734
|
if (typeof probeResult.health?.workspaceCount === "number" && probeResult.health.workspaceCount > 0) return current.endpoint;
|
|
56426
56735
|
}
|
|
56427
56736
|
if (current) await stop();
|
|
56737
|
+
lastSpawnError = null;
|
|
56428
56738
|
spawnDetached(execPath, [serverModulePath, "serve"], withHidden({ detached: true, env: childEnv, stdio: "ignore" }));
|
|
56739
|
+
let lastProbeError = null;
|
|
56429
56740
|
for (let i = 0; i < 30; i += 1) {
|
|
56430
56741
|
await sleep(100);
|
|
56431
56742
|
const next = await probe();
|
|
56432
56743
|
if (next.healthy && next.lock) return next.lock.endpoint;
|
|
56744
|
+
if (next.error) lastProbeError = next.error;
|
|
56433
56745
|
}
|
|
56434
|
-
throw new Error(
|
|
56746
|
+
throw new Error(describeDaemonStartFailure({
|
|
56747
|
+
spawnError: lastSpawnError,
|
|
56748
|
+
probeError: lastProbeError,
|
|
56749
|
+
dataDir: paths.dir
|
|
56750
|
+
}));
|
|
56435
56751
|
}
|
|
56436
56752
|
return { ensureDaemon, probe, runServer, stop };
|
|
56437
56753
|
function readTrustedLock(options = {}) {
|
|
@@ -56460,8 +56776,9 @@ async function openFleetConsole(deps = {}) {
|
|
|
56460
56776
|
throw new Error("Fleet Console server is not healthy after ensure");
|
|
56461
56777
|
}
|
|
56462
56778
|
const url2 = `${status2.lock.endpoint}console/`;
|
|
56463
|
-
(deps.openBrowser ?? openBrowser)(url2);
|
|
56464
|
-
|
|
56779
|
+
const browser = await (deps.openBrowser ?? openBrowser)(url2);
|
|
56780
|
+
const result = browser ?? { opened: true };
|
|
56781
|
+
return result.opened ? { url: url2, browserOpened: true } : { url: url2, browserOpened: false, browserError: result.reason };
|
|
56465
56782
|
}
|
|
56466
56783
|
async function runConsoleStatus(deps = {}) {
|
|
56467
56784
|
const lifecycle = deps.lifecycle ?? createConsoleDaemonLifecycle();
|
|
@@ -56574,14 +56891,14 @@ async function dispatchFleetArgv(argv, options) {
|
|
|
56574
56891
|
return 0;
|
|
56575
56892
|
}
|
|
56576
56893
|
if (mode === "restart") {
|
|
56577
|
-
await runConsoleRestart();
|
|
56578
|
-
io.stdout.write(
|
|
56894
|
+
const restarted = await runConsoleRestart();
|
|
56895
|
+
io.stdout.write(`${describeConsoleLaunch("Fleet Console restarted.", restarted)}
|
|
56579
56896
|
${await runConsoleStatus()}
|
|
56580
56897
|
`);
|
|
56581
56898
|
return 0;
|
|
56582
56899
|
}
|
|
56583
|
-
await openFleetConsole();
|
|
56584
|
-
io.stdout.write(
|
|
56900
|
+
const opened = await openFleetConsole();
|
|
56901
|
+
io.stdout.write(`${describeConsoleLaunch("Fleet Console opened.", opened)}
|
|
56585
56902
|
${await runConsoleStatus()}
|
|
56586
56903
|
`);
|
|
56587
56904
|
return 0;
|