@dotobokuri/fleet-console 1.45.0 → 1.46.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/dist/cli.d.ts +4 -0
- package/dist/cli.mjs +416 -899
- package/dist/client/assets/{_baseUniq-DtJH2bh8.js → _baseUniq-CaqaUUIT.js} +1 -1
- package/dist/client/assets/{arc-DHCKMqqF.js → arc-B4MjkR5w.js} +1 -1
- package/dist/client/assets/{architectureDiagram-Q4EWVU46-BOuyINL8.js → architectureDiagram-Q4EWVU46-wP-4WWY-.js} +1 -1
- package/dist/client/assets/{blockDiagram-DXYQGD6D-cIre3_5n.js → blockDiagram-DXYQGD6D-D5Y2AdkX.js} +1 -1
- package/dist/client/assets/{c4Diagram-AHTNJAMY-DTX-qjSW.js → c4Diagram-AHTNJAMY-hKNJrUod.js} +1 -1
- package/dist/client/assets/channel-Cy7Wdt-y.js +1 -0
- package/dist/client/assets/{chunk-4BX2VUAB-DiBwpozK.js → chunk-4BX2VUAB-RdaAserw.js} +1 -1
- package/dist/client/assets/{chunk-4TB4RGXK-uCZ-B3-y.js → chunk-4TB4RGXK-BVvGheRq.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-CmBu2sf0.js → chunk-55IACEB6-BKBu793s.js} +1 -1
- package/dist/client/assets/{chunk-EDXVE4YY-BXpw2VyB.js → chunk-EDXVE4YY-CF6P1HJI.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-Cn9sKTn5.js → chunk-FMBD7UC4-DYrffXxC.js} +1 -1
- package/dist/client/assets/{chunk-OYMX7WX6-BDgH1zlW.js → chunk-OYMX7WX6-ggkv39bf.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-BOdvRibu.js → chunk-QZHKN3VN-DfsoMKS1.js} +1 -1
- package/dist/client/assets/{chunk-YZCP3GAM-BDIEapcU.js → chunk-YZCP3GAM-nK3fd1vK.js} +1 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-BXKZy3mo.js +1 -0
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-BXKZy3mo.js +1 -0
- package/dist/client/assets/clone-BaDkZwuY.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-BVlc3Dad.js → cose-bilkent-S5V4N54A-BXTuHPIj.js} +1 -1
- package/dist/client/assets/{dagre-KV5264BT-raV4BK6w.js → dagre-KV5264BT-Bz4nIBUS.js} +1 -1
- package/dist/client/assets/{diagram-5BDNPKRD-BMAh1LJt.js → diagram-5BDNPKRD-ByqgG2sy.js} +1 -1
- package/dist/client/assets/{diagram-G4DWMVQ6-AM5t2f3j.js → diagram-G4DWMVQ6-D6Bh5CCC.js} +1 -1
- package/dist/client/assets/{diagram-MMDJMWI5-DMw_UwWR.js → diagram-MMDJMWI5-CfDQLuVW.js} +1 -1
- package/dist/client/assets/{diagram-TYMM5635-CiDAD3e9.js → diagram-TYMM5635-KI98IUyc.js} +1 -1
- package/dist/client/assets/{erDiagram-SMLLAGMA-D1IXSwFZ.js → erDiagram-SMLLAGMA-CqprUEiC.js} +1 -1
- package/dist/client/assets/{flowDiagram-DWJPFMVM-pEq1L6HP.js → flowDiagram-DWJPFMVM-ABvSPDqG.js} +1 -1
- package/dist/client/assets/{ganttDiagram-T4ZO3ILL-BAXTU16v.js → ganttDiagram-T4ZO3ILL-Dsx-U_Nn.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-PkEvpSio.js → gitGraphDiagram-UUTBAWPF-BSUFEUnR.js} +1 -1
- package/dist/client/assets/{graph-OOLam9NE.js → graph-CzNfjcWq.js} +1 -1
- package/dist/client/assets/index-DJz5h6Wn.js +482 -0
- package/dist/client/assets/index-DuMyAui7.css +1 -0
- package/dist/client/assets/{infoDiagram-42DDH7IO-CcLveXnw.js → infoDiagram-42DDH7IO-Ds0ENS7R.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-D-p_eX0W.js → ishikawaDiagram-UXIWVN3A-B18YRUdD.js} +1 -1
- package/dist/client/assets/{journeyDiagram-VCZTEJTY-D81ht6ZY.js → journeyDiagram-VCZTEJTY-BupFc-Zd.js} +1 -1
- package/dist/client/assets/{kanban-definition-6JOO6SKY-D8SIIBWy.js → kanban-definition-6JOO6SKY-BSLofAt_.js} +1 -1
- package/dist/client/assets/{layout-CeMy87tl.js → layout-Dv50_a5m.js} +1 -1
- package/dist/client/assets/{linear-C0Txkuhf.js → linear-BrKghOcX.js} +1 -1
- package/dist/client/assets/{mermaid.core-zdTcCzmD.js → mermaid.core-CxEBNiNY.js} +4 -4
- package/dist/client/assets/{min-BPp_9Vnv.js → min-CCGzVC9y.js} +1 -1
- package/dist/client/assets/{mindmap-definition-QFDTVHPH-DRJbMf8W.js → mindmap-definition-QFDTVHPH-BrgndQgy.js} +1 -1
- package/dist/client/assets/{pieDiagram-DEJITSTG-CqPISwE-.js → pieDiagram-DEJITSTG-DaQb845q.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-34T5L4WZ-BGLaujDD.js → quadrantDiagram-34T5L4WZ-BKqKJrUA.js} +1 -1
- package/dist/client/assets/{requirementDiagram-MS252O5E-DWF6sFQ_.js → requirementDiagram-MS252O5E-DDEiXfFB.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-XADWPNL6-Dv2O23aj.js → sankeyDiagram-XADWPNL6-Bz8ZuIVc.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-FGHM5R23-BXgYtweg.js → sequenceDiagram-FGHM5R23-DIKllaFC.js} +1 -1
- package/dist/client/assets/{stateDiagram-FHFEXIEX-COtDK2gC.js → stateDiagram-FHFEXIEX-DVGXi05S.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-BpjJbYdv.js +1 -0
- package/dist/client/assets/{timeline-definition-GMOUNBTQ-B_-QYLHK.js → timeline-definition-GMOUNBTQ-BysxZqEH.js} +1 -1
- package/dist/client/assets/{vennDiagram-DHZGUBPP-BNVDRgAa.js → vennDiagram-DHZGUBPP-zKrKFH0U.js} +1 -1
- package/dist/client/assets/{wardley-RL74JXVD-B3XwoW1A.js → wardley-RL74JXVD-Bfs1dQE_.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-NUSXRM2D-B6-OKLa-.js → wardleyDiagram-NUSXRM2D-9Nv_Fl4e.js} +1 -1
- package/dist/client/assets/{xychartDiagram-5P7HB3ND-DepfDqrZ.js → xychartDiagram-5P7HB3ND-BxnDNWHU.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/fleet-plugins/ledger/routes.mjs +45 -105
- package/dist/fleet-plugins/quota/routes.mjs +455 -64
- package/dist/fleet-plugins/repository/routes.mjs +26 -9
- package/dist/fleet-plugins/scuttlebutt/routes.mjs +150 -703
- package/dist/fleet-plugins/skills/routes.mjs +45 -105
- package/dist/fleet-plugins/terminal/routes.mjs +1297 -975
- package/package.json +1 -1
- package/dist/client/assets/channel-BhciS8jR.js +0 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-BjRUnHce.js +0 -1
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-BjRUnHce.js +0 -1
- package/dist/client/assets/clone-DygBt67n.js +0 -1
- package/dist/client/assets/index-BgHFwZy9.css +0 -1
- package/dist/client/assets/index-CvXOp1di.js +0 -452
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-BzCFtEfV.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFile } from 'child_process';
|
|
3
3
|
import * as fs5 from 'fs';
|
|
4
|
-
import { constants } from 'fs';
|
|
4
|
+
import fs5__default, { constants } from 'fs';
|
|
5
5
|
import fs from 'fs/promises';
|
|
6
6
|
import * as os4 from 'os';
|
|
7
7
|
import os4__default from 'os';
|
|
@@ -19,12 +19,12 @@ var __export = (target, all) => {
|
|
|
19
19
|
function definePlugin(definition) {
|
|
20
20
|
return definition;
|
|
21
21
|
}
|
|
22
|
-
function registerRouter(ctx,
|
|
23
|
-
ctx.registerRouter(normalizePath(
|
|
22
|
+
function registerRouter(ctx, path12, handler) {
|
|
23
|
+
ctx.registerRouter(normalizePath(path12), handler);
|
|
24
24
|
}
|
|
25
|
-
function normalizePath(
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
25
|
+
function normalizePath(path12) {
|
|
26
|
+
if (path12.length === 0 || path12 === "/") return "/";
|
|
27
|
+
return path12;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// ../fleet-plugins/quota/server/handlers.ts
|
|
@@ -840,10 +840,10 @@ function mergeDefs(...defs) {
|
|
|
840
840
|
function cloneDef(schema) {
|
|
841
841
|
return mergeDefs(schema._zod.def);
|
|
842
842
|
}
|
|
843
|
-
function getElementAtPath(obj,
|
|
844
|
-
if (!
|
|
843
|
+
function getElementAtPath(obj, path12) {
|
|
844
|
+
if (!path12)
|
|
845
845
|
return obj;
|
|
846
|
-
return
|
|
846
|
+
return path12.reduce((acc, key) => acc?.[key], obj);
|
|
847
847
|
}
|
|
848
848
|
function promiseAllObject(promisesObj) {
|
|
849
849
|
const keys = Object.keys(promisesObj);
|
|
@@ -1252,11 +1252,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1252
1252
|
}
|
|
1253
1253
|
return false;
|
|
1254
1254
|
}
|
|
1255
|
-
function prefixIssues(
|
|
1255
|
+
function prefixIssues(path12, issues) {
|
|
1256
1256
|
return issues.map((iss) => {
|
|
1257
1257
|
var _a3;
|
|
1258
1258
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1259
|
-
iss.path.unshift(
|
|
1259
|
+
iss.path.unshift(path12);
|
|
1260
1260
|
return iss;
|
|
1261
1261
|
});
|
|
1262
1262
|
}
|
|
@@ -1403,16 +1403,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1405
1405
|
const fieldErrors = { _errors: [] };
|
|
1406
|
-
const processError = (error52,
|
|
1406
|
+
const processError = (error52, path12 = []) => {
|
|
1407
1407
|
for (const issue2 of error52.issues) {
|
|
1408
1408
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1409
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1409
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1410
1410
|
} else if (issue2.code === "invalid_key") {
|
|
1411
|
-
processError({ issues: issue2.issues }, [...
|
|
1411
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1412
1412
|
} else if (issue2.code === "invalid_element") {
|
|
1413
|
-
processError({ issues: issue2.issues }, [...
|
|
1413
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1414
1414
|
} else {
|
|
1415
|
-
const fullpath = [...
|
|
1415
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1416
1416
|
if (fullpath.length === 0) {
|
|
1417
1417
|
fieldErrors._errors.push(mapper(issue2));
|
|
1418
1418
|
} else {
|
|
@@ -1439,17 +1439,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1441
1441
|
const result = { errors: [] };
|
|
1442
|
-
const processError = (error52,
|
|
1442
|
+
const processError = (error52, path12 = []) => {
|
|
1443
1443
|
var _a3, _b;
|
|
1444
1444
|
for (const issue2 of error52.issues) {
|
|
1445
1445
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1446
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1446
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1447
1447
|
} else if (issue2.code === "invalid_key") {
|
|
1448
|
-
processError({ issues: issue2.issues }, [...
|
|
1448
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1449
1449
|
} else if (issue2.code === "invalid_element") {
|
|
1450
|
-
processError({ issues: issue2.issues }, [...
|
|
1450
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1451
1451
|
} else {
|
|
1452
|
-
const fullpath = [...
|
|
1452
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1453
1453
|
if (fullpath.length === 0) {
|
|
1454
1454
|
result.errors.push(mapper(issue2));
|
|
1455
1455
|
continue;
|
|
@@ -1481,8 +1481,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1481
1481
|
}
|
|
1482
1482
|
function toDotPath(_path) {
|
|
1483
1483
|
const segs = [];
|
|
1484
|
-
const
|
|
1485
|
-
for (const seg of
|
|
1484
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1485
|
+
for (const seg of path12) {
|
|
1486
1486
|
if (typeof seg === "number")
|
|
1487
1487
|
segs.push(`[${seg}]`);
|
|
1488
1488
|
else if (typeof seg === "symbol")
|
|
@@ -14146,13 +14146,13 @@ function resolveRef(ref, ctx) {
|
|
|
14146
14146
|
if (!ref.startsWith("#")) {
|
|
14147
14147
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14148
14148
|
}
|
|
14149
|
-
const
|
|
14150
|
-
if (
|
|
14149
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
14150
|
+
if (path12.length === 0) {
|
|
14151
14151
|
return ctx.rootSchema;
|
|
14152
14152
|
}
|
|
14153
14153
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14154
|
-
if (
|
|
14155
|
-
const key =
|
|
14154
|
+
if (path12[0] === defsKey) {
|
|
14155
|
+
const key = path12[1];
|
|
14156
14156
|
if (!key || !ctx.defs[key]) {
|
|
14157
14157
|
throw new Error(`Reference not found: ${ref}`);
|
|
14158
14158
|
}
|
|
@@ -17140,8 +17140,8 @@ function bootEnumDescriptorProto(init) {
|
|
|
17140
17140
|
}
|
|
17141
17141
|
|
|
17142
17142
|
// ../../node_modules/.pnpm/@bufbuild+protobuf@2.13.0/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js
|
|
17143
|
-
function messageDesc(file2,
|
|
17144
|
-
return paths.reduce((acc, cur) => acc.nestedMessages[cur], file2.messages[
|
|
17143
|
+
function messageDesc(file2, path12, ...paths) {
|
|
17144
|
+
return paths.reduce((acc, cur) => acc.nestedMessages[cur], file2.messages[path12]);
|
|
17145
17145
|
}
|
|
17146
17146
|
|
|
17147
17147
|
// ../../node_modules/.pnpm/@bufbuild+protobuf@2.13.0/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js
|
|
@@ -17511,7 +17511,7 @@ new Map(
|
|
|
17511
17511
|
);
|
|
17512
17512
|
var models_default = {
|
|
17513
17513
|
version: 1,
|
|
17514
|
-
updatedAt: "2026-08-
|
|
17514
|
+
updatedAt: "2026-08-03T00:00:00Z",
|
|
17515
17515
|
providers: {
|
|
17516
17516
|
codex: {
|
|
17517
17517
|
name: "Codex",
|
|
@@ -17796,12 +17796,162 @@ var models_default = {
|
|
|
17796
17796
|
]
|
|
17797
17797
|
}
|
|
17798
17798
|
]
|
|
17799
|
+
},
|
|
17800
|
+
opencode: {
|
|
17801
|
+
name: "OpenCode",
|
|
17802
|
+
defaultModel: "minimax-m3",
|
|
17803
|
+
source: "live GET https://opencode.ai/zen/go/v1/models + per-model wire probes on /messages, /responses, /chat/completions (2026-08-03); contextWindow cross-checked against models.dev api.json opencode-go entries and oh-my-pi packages/catalog/src/models.json (2026-08-03, both agree). Excluded: mimo-v2-pro/mimo-v2-omni (upstream server_error), hy3-preview (listed but Router.ModelNotFound)",
|
|
17804
|
+
models: [
|
|
17805
|
+
{
|
|
17806
|
+
modelId: "minimax-m3",
|
|
17807
|
+
name: "MiniMax-M3",
|
|
17808
|
+
contextWindow: 1e6
|
|
17809
|
+
},
|
|
17810
|
+
{
|
|
17811
|
+
modelId: "minimax-m2.7",
|
|
17812
|
+
name: "MiniMax-M2.7",
|
|
17813
|
+
contextWindow: 204800
|
|
17814
|
+
},
|
|
17815
|
+
{
|
|
17816
|
+
modelId: "minimax-m2.5",
|
|
17817
|
+
name: "MiniMax-M2.5",
|
|
17818
|
+
contextWindow: 204800
|
|
17819
|
+
},
|
|
17820
|
+
{
|
|
17821
|
+
modelId: "qwen3.8-max",
|
|
17822
|
+
name: "Qwen3.8-Max",
|
|
17823
|
+
contextWindow: 1e6
|
|
17824
|
+
},
|
|
17825
|
+
{
|
|
17826
|
+
modelId: "qwen3.7-max",
|
|
17827
|
+
name: "Qwen3.7-Max",
|
|
17828
|
+
contextWindow: 1e6
|
|
17829
|
+
},
|
|
17830
|
+
{
|
|
17831
|
+
modelId: "qwen3.7-plus",
|
|
17832
|
+
name: "Qwen3.7-Plus",
|
|
17833
|
+
contextWindow: 1e6
|
|
17834
|
+
},
|
|
17835
|
+
{
|
|
17836
|
+
modelId: "qwen3.6-plus",
|
|
17837
|
+
name: "Qwen3.6-Plus",
|
|
17838
|
+
contextWindow: 1e6
|
|
17839
|
+
},
|
|
17840
|
+
{
|
|
17841
|
+
modelId: "qwen3.5-plus",
|
|
17842
|
+
name: "Qwen3.5-Plus",
|
|
17843
|
+
contextWindow: 262144
|
|
17844
|
+
},
|
|
17845
|
+
{
|
|
17846
|
+
modelId: "gpt-5.6-luna",
|
|
17847
|
+
name: "GPT-5.6-Luna",
|
|
17848
|
+
wire: "responses",
|
|
17849
|
+
contextWindow: 105e4,
|
|
17850
|
+
effort: {
|
|
17851
|
+
supported: true,
|
|
17852
|
+
levels: [
|
|
17853
|
+
"low",
|
|
17854
|
+
"medium",
|
|
17855
|
+
"high",
|
|
17856
|
+
"xhigh",
|
|
17857
|
+
"max"
|
|
17858
|
+
]
|
|
17859
|
+
}
|
|
17860
|
+
},
|
|
17861
|
+
{
|
|
17862
|
+
modelId: "grok-4.5",
|
|
17863
|
+
name: "Grok-4.5",
|
|
17864
|
+
wire: "responses",
|
|
17865
|
+
contextWindow: 5e5,
|
|
17866
|
+
effort: {
|
|
17867
|
+
supported: true,
|
|
17868
|
+
levels: [
|
|
17869
|
+
"low",
|
|
17870
|
+
"medium",
|
|
17871
|
+
"high"
|
|
17872
|
+
]
|
|
17873
|
+
}
|
|
17874
|
+
},
|
|
17875
|
+
{
|
|
17876
|
+
modelId: "deepseek-v4-flash",
|
|
17877
|
+
name: "DeepSeek-V4-Flash",
|
|
17878
|
+
wire: "chat-completions",
|
|
17879
|
+
contextWindow: 1e6
|
|
17880
|
+
},
|
|
17881
|
+
{
|
|
17882
|
+
modelId: "deepseek-v4-pro",
|
|
17883
|
+
name: "DeepSeek-V4-Pro",
|
|
17884
|
+
wire: "chat-completions",
|
|
17885
|
+
contextWindow: 1e6
|
|
17886
|
+
},
|
|
17887
|
+
{
|
|
17888
|
+
modelId: "glm-5.2",
|
|
17889
|
+
name: "GLM-5.2",
|
|
17890
|
+
wire: "chat-completions",
|
|
17891
|
+
contextWindow: 1e6
|
|
17892
|
+
},
|
|
17893
|
+
{
|
|
17894
|
+
modelId: "glm-5.1",
|
|
17895
|
+
name: "GLM-5.1",
|
|
17896
|
+
wire: "chat-completions",
|
|
17897
|
+
contextWindow: 202752
|
|
17898
|
+
},
|
|
17899
|
+
{
|
|
17900
|
+
modelId: "glm-5",
|
|
17901
|
+
name: "GLM-5",
|
|
17902
|
+
wire: "chat-completions",
|
|
17903
|
+
contextWindow: 202752
|
|
17904
|
+
},
|
|
17905
|
+
{
|
|
17906
|
+
modelId: "kimi-k3",
|
|
17907
|
+
name: "Kimi-K3",
|
|
17908
|
+
wire: "chat-completions",
|
|
17909
|
+
contextWindow: 1048576
|
|
17910
|
+
},
|
|
17911
|
+
{
|
|
17912
|
+
modelId: "kimi-k2.7-code",
|
|
17913
|
+
name: "Kimi-K2.7-Code",
|
|
17914
|
+
wire: "chat-completions",
|
|
17915
|
+
contextWindow: 262144
|
|
17916
|
+
},
|
|
17917
|
+
{
|
|
17918
|
+
modelId: "kimi-k2.6",
|
|
17919
|
+
name: "Kimi-K2.6",
|
|
17920
|
+
wire: "chat-completions",
|
|
17921
|
+
contextWindow: 262144
|
|
17922
|
+
},
|
|
17923
|
+
{
|
|
17924
|
+
modelId: "kimi-k2.5",
|
|
17925
|
+
name: "Kimi-K2.5",
|
|
17926
|
+
wire: "chat-completions",
|
|
17927
|
+
contextWindow: 262144
|
|
17928
|
+
},
|
|
17929
|
+
{
|
|
17930
|
+
modelId: "mimo-v2.5-pro",
|
|
17931
|
+
name: "MiMo-V2.5-Pro",
|
|
17932
|
+
wire: "chat-completions",
|
|
17933
|
+
contextWindow: 1048576
|
|
17934
|
+
},
|
|
17935
|
+
{
|
|
17936
|
+
modelId: "mimo-v2.5",
|
|
17937
|
+
name: "MiMo-V2.5",
|
|
17938
|
+
wire: "chat-completions",
|
|
17939
|
+
contextWindow: 1e6
|
|
17940
|
+
},
|
|
17941
|
+
{
|
|
17942
|
+
modelId: "hy3",
|
|
17943
|
+
name: "HY3",
|
|
17944
|
+
wire: "chat-completions",
|
|
17945
|
+
contextWindow: 256e3
|
|
17946
|
+
}
|
|
17947
|
+
]
|
|
17799
17948
|
}
|
|
17800
17949
|
}
|
|
17801
17950
|
};
|
|
17802
17951
|
var KIMI_AUTH_PROVIDER_ID = "Claude Code with Moonshot Kimi";
|
|
17803
17952
|
var KIMI_CODE_API_BASE_URL = "https://api.kimi.com/coding";
|
|
17804
|
-
var GATEWAY_PROVIDERS = ["codex", "cursor", "kimi"];
|
|
17953
|
+
var GATEWAY_PROVIDERS = ["codex", "cursor", "kimi", "opencode"];
|
|
17954
|
+
var GATEWAY_MODEL_WIRES = ["anthropic", "responses", "chat-completions"];
|
|
17805
17955
|
var GATEWAY_REASONING_EFFORTS = [
|
|
17806
17956
|
"low",
|
|
17807
17957
|
"medium",
|
|
@@ -17834,6 +17984,7 @@ var GatewayModelEntrySchema = external_exports.object({
|
|
|
17834
17984
|
serviceTier: external_exports.literal("priority").optional(),
|
|
17835
17985
|
cursorMaxMode: external_exports.literal(true).optional(),
|
|
17836
17986
|
quotaScope: external_exports.enum(GATEWAY_QUOTA_SCOPES).optional(),
|
|
17987
|
+
wire: external_exports.enum(GATEWAY_MODEL_WIRES).optional(),
|
|
17837
17988
|
aliases: external_exports.array(external_exports.string().min(1)).optional(),
|
|
17838
17989
|
contextWindow: external_exports.number().int().positive().optional(),
|
|
17839
17990
|
effort: GatewayModelEffortSchema.optional()
|
|
@@ -17850,7 +18001,8 @@ var GatewayModelsRegistrySchema = external_exports.object({
|
|
|
17850
18001
|
providers: external_exports.object({
|
|
17851
18002
|
codex: GatewayProviderSchema,
|
|
17852
18003
|
cursor: GatewayProviderSchema,
|
|
17853
|
-
kimi: GatewayProviderSchema
|
|
18004
|
+
kimi: GatewayProviderSchema,
|
|
18005
|
+
opencode: GatewayProviderSchema
|
|
17854
18006
|
}).strict()
|
|
17855
18007
|
}).strict();
|
|
17856
18008
|
var UNSUPPORTED_GATEWAY_MODEL_EFFORT = Object.freeze({ supported: false });
|
|
@@ -17875,6 +18027,7 @@ var GATEWAY_MODELS = Object.freeze(
|
|
|
17875
18027
|
providerModels("codex");
|
|
17876
18028
|
providerModels("cursor");
|
|
17877
18029
|
providerModels("kimi");
|
|
18030
|
+
providerModels("opencode");
|
|
17878
18031
|
function upstreamModelId(model) {
|
|
17879
18032
|
return model.upstreamId ?? model.id;
|
|
17880
18033
|
}
|
|
@@ -17900,6 +18053,7 @@ function toGatewayModel(provider, providerName, entry) {
|
|
|
17900
18053
|
...entry.serviceTier ? { serviceTier: entry.serviceTier } : {},
|
|
17901
18054
|
...entry.cursorMaxMode ? { cursorMaxMode: entry.cursorMaxMode } : {},
|
|
17902
18055
|
...entry.quotaScope ? { quotaScope: entry.quotaScope } : {},
|
|
18056
|
+
...entry.wire ? { wire: entry.wire } : {},
|
|
17903
18057
|
...entry.description ? { description: entry.description } : {},
|
|
17904
18058
|
...entry.contextWindow ? { contextWindow: entry.contextWindow } : {},
|
|
17905
18059
|
effort: freezeGatewayModelEffort(entry.effort),
|
|
@@ -17934,6 +18088,9 @@ function validateRegistry(value) {
|
|
|
17934
18088
|
if (model.quotaScope && provider !== "cursor") {
|
|
17935
18089
|
throw new Error(`Gateway quota scope is only supported by Cursor: ${provider}/${model.modelId}`);
|
|
17936
18090
|
}
|
|
18091
|
+
if (model.wire && provider !== "opencode") {
|
|
18092
|
+
throw new Error(`Gateway model wire is only supported by OpenCode: ${provider}/${model.modelId}`);
|
|
18093
|
+
}
|
|
17937
18094
|
if (model.effort?.supported) {
|
|
17938
18095
|
if (new Set(model.effort.levels).size !== model.effort.levels.length) {
|
|
17939
18096
|
throw new Error(`Gateway effort levels contain duplicates: ${provider}/${model.modelId}`);
|
|
@@ -18874,6 +19031,7 @@ async function resolveCodexCredentials(deps) {
|
|
|
18874
19031
|
return null;
|
|
18875
19032
|
}
|
|
18876
19033
|
}
|
|
19034
|
+
var OPENCODE_AUTH_PROVIDER_ID = "Claude Code with OpenCode Go";
|
|
18877
19035
|
var FLEET_DATA_DIR_NAME = ".fleet";
|
|
18878
19036
|
function getFleetDataDir() {
|
|
18879
19037
|
return path.join(os4.homedir(), FLEET_DATA_DIR_NAME);
|
|
@@ -19265,12 +19423,199 @@ async function resolveClaudeCredentials(deps) {
|
|
|
19265
19423
|
return null;
|
|
19266
19424
|
}
|
|
19267
19425
|
}
|
|
19426
|
+
var OPENCODE_GO_SESSION_CAP_USD = 12;
|
|
19427
|
+
var OPENCODE_GO_WEEKLY_CAP_USD = 30;
|
|
19428
|
+
var OPENCODE_GO_MONTHLY_CAP_USD = 60;
|
|
19429
|
+
var SESSION_MS = 5 * 36e5;
|
|
19430
|
+
var WEEK_MS = 7 * 864e5;
|
|
19431
|
+
var SCAN_DAYS_BACK = 33;
|
|
19432
|
+
function resolveOpencodeDataDir(env = process.env, homeDir = os4__default.homedir()) {
|
|
19433
|
+
const override = env.OPENCODE_DATA_DIR?.trim();
|
|
19434
|
+
if (override) return expandHome(override, homeDir).replace(/\/+$/, "");
|
|
19435
|
+
const xdg = env.XDG_DATA_HOME?.trim();
|
|
19436
|
+
if (xdg) return `${expandHome(xdg, homeDir).replace(/\/+$/, "")}/opencode`;
|
|
19437
|
+
return path__default.join(homeDir, ".local", "share", "opencode");
|
|
19438
|
+
}
|
|
19439
|
+
function listOpencodeDatabases(dataDir) {
|
|
19440
|
+
let names;
|
|
19441
|
+
try {
|
|
19442
|
+
names = fs5__default.readdirSync(dataDir);
|
|
19443
|
+
} catch (error51) {
|
|
19444
|
+
if (!fs5__default.existsSync(dataDir)) return [];
|
|
19445
|
+
throw error51;
|
|
19446
|
+
}
|
|
19447
|
+
return names.filter((name) => name.startsWith("opencode") && name.endsWith(".db")).sort().map((name) => path__default.join(dataDir, name));
|
|
19448
|
+
}
|
|
19449
|
+
async function scanOpencodeGoWindows(deps = {}) {
|
|
19450
|
+
const nowMs = (deps.now ?? Date.now)();
|
|
19451
|
+
const dataDir = resolveOpencodeDataDir(deps.env ?? process.env, deps.homeDir ?? os4__default.homedir());
|
|
19452
|
+
const databases = listOpencodeDatabases(dataDir);
|
|
19453
|
+
if (databases.length === 0) return null;
|
|
19454
|
+
const { DatabaseSync } = await import('sqlite');
|
|
19455
|
+
const cutoffMs = nowMs - SCAN_DAYS_BACK * 864e5;
|
|
19456
|
+
const costs = [];
|
|
19457
|
+
let anchorMs;
|
|
19458
|
+
let failures = 0;
|
|
19459
|
+
for (const databasePath of databases) {
|
|
19460
|
+
let db;
|
|
19461
|
+
try {
|
|
19462
|
+
db = new DatabaseSync(databasePath, { readOnly: true });
|
|
19463
|
+
const rows = db.prepare(
|
|
19464
|
+
`SELECT time_created AS ms, json_extract(data,'$.cost') AS cost
|
|
19465
|
+
FROM message
|
|
19466
|
+
WHERE time_created >= ?
|
|
19467
|
+
AND json_valid(data)
|
|
19468
|
+
AND json_extract(data,'$.role') = 'assistant'
|
|
19469
|
+
AND json_extract(data,'$.providerID') = 'opencode-go'
|
|
19470
|
+
AND json_type(data,'$.cost') IN ('integer','real')`
|
|
19471
|
+
).all(cutoffMs);
|
|
19472
|
+
for (const row of rows) {
|
|
19473
|
+
if (typeof row.ms !== "number" || typeof row.cost !== "number" || row.cost < 0) continue;
|
|
19474
|
+
costs.push({ ms: row.ms, cost: row.cost });
|
|
19475
|
+
}
|
|
19476
|
+
const anchorRow = db.prepare(
|
|
19477
|
+
`SELECT MIN(time_created) AS ms FROM message
|
|
19478
|
+
WHERE json_valid(data)
|
|
19479
|
+
AND json_extract(data,'$.role') = 'assistant'
|
|
19480
|
+
AND json_extract(data,'$.providerID') = 'opencode-go'
|
|
19481
|
+
AND json_type(data,'$.cost') IN ('integer','real')`
|
|
19482
|
+
).get();
|
|
19483
|
+
if (typeof anchorRow?.ms === "number") {
|
|
19484
|
+
anchorMs = anchorMs === void 0 ? anchorRow.ms : Math.min(anchorMs, anchorRow.ms);
|
|
19485
|
+
}
|
|
19486
|
+
} catch {
|
|
19487
|
+
failures += 1;
|
|
19488
|
+
} finally {
|
|
19489
|
+
db?.close();
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
if (failures === databases.length) {
|
|
19493
|
+
throw new Error("Every OpenCode database exists but could not be read");
|
|
19494
|
+
}
|
|
19495
|
+
return computeOpencodeGoWindows(costs, anchorMs, nowMs);
|
|
19496
|
+
}
|
|
19497
|
+
function computeOpencodeGoWindows(costs, anchorMs, nowMs) {
|
|
19498
|
+
const sessionStart = nowMs - SESSION_MS;
|
|
19499
|
+
const sessionSpend = sumRange(costs, sessionStart, nowMs);
|
|
19500
|
+
const oldestInSession = costs.filter((row) => row.ms >= sessionStart && row.ms < nowMs).reduce((min, row) => min === void 0 ? row.ms : Math.min(min, row.ms), void 0);
|
|
19501
|
+
const sessionResetsAt = (oldestInSession ?? nowMs) + SESSION_MS;
|
|
19502
|
+
const weekStart = startOfUtcWeek(nowMs);
|
|
19503
|
+
const weekEnd = weekStart + WEEK_MS;
|
|
19504
|
+
const weeklySpend = sumRange(costs, weekStart, weekEnd);
|
|
19505
|
+
const month = anchoredMonthBounds(nowMs, anchorMs);
|
|
19506
|
+
const monthlySpend = sumRange(costs, month.start, month.end);
|
|
19507
|
+
return {
|
|
19508
|
+
windows: [
|
|
19509
|
+
{
|
|
19510
|
+
id: "session",
|
|
19511
|
+
usedPercent: percent(sessionSpend, OPENCODE_GO_SESSION_CAP_USD),
|
|
19512
|
+
resetsAt: sessionResetsAt,
|
|
19513
|
+
period: {
|
|
19514
|
+
durationMs: SESSION_MS,
|
|
19515
|
+
durationBasis: "catalog",
|
|
19516
|
+
startsAt: sessionResetsAt - SESSION_MS,
|
|
19517
|
+
startsAtBasis: "derived"
|
|
19518
|
+
}
|
|
19519
|
+
},
|
|
19520
|
+
{
|
|
19521
|
+
id: "weekly",
|
|
19522
|
+
usedPercent: percent(weeklySpend, OPENCODE_GO_WEEKLY_CAP_USD),
|
|
19523
|
+
resetsAt: weekEnd,
|
|
19524
|
+
period: {
|
|
19525
|
+
durationMs: WEEK_MS,
|
|
19526
|
+
durationBasis: "catalog",
|
|
19527
|
+
startsAt: weekStart,
|
|
19528
|
+
startsAtBasis: "derived"
|
|
19529
|
+
}
|
|
19530
|
+
},
|
|
19531
|
+
{
|
|
19532
|
+
id: "cycle",
|
|
19533
|
+
usedPercent: percent(monthlySpend, OPENCODE_GO_MONTHLY_CAP_USD),
|
|
19534
|
+
resetsAt: month.end,
|
|
19535
|
+
period: {
|
|
19536
|
+
durationMs: month.end - month.start,
|
|
19537
|
+
durationBasis: "catalog",
|
|
19538
|
+
startsAt: month.start,
|
|
19539
|
+
startsAtBasis: "derived"
|
|
19540
|
+
}
|
|
19541
|
+
}
|
|
19542
|
+
],
|
|
19543
|
+
cycleDays: Math.round((month.end - month.start) / 864e5)
|
|
19544
|
+
};
|
|
19545
|
+
}
|
|
19546
|
+
function percent(spend, cap) {
|
|
19547
|
+
return Math.max(0, Math.min(100, Math.round(spend / cap * 100)));
|
|
19548
|
+
}
|
|
19549
|
+
function sumRange(costs, start, end) {
|
|
19550
|
+
const total = costs.reduce(
|
|
19551
|
+
(partial2, row) => row.ms >= start && row.ms < end ? partial2 + row.cost : partial2,
|
|
19552
|
+
0
|
|
19553
|
+
);
|
|
19554
|
+
return Math.round(total * 1e4) / 1e4;
|
|
19555
|
+
}
|
|
19556
|
+
function startOfUtcWeek(nowMs) {
|
|
19557
|
+
const now = new Date(nowMs);
|
|
19558
|
+
const dayStart = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
|
|
19559
|
+
const daysSinceMonday = (new Date(dayStart).getUTCDay() + 6) % 7;
|
|
19560
|
+
return dayStart - daysSinceMonday * 864e5;
|
|
19561
|
+
}
|
|
19562
|
+
function anchoredMonthBounds(nowMs, anchorMs) {
|
|
19563
|
+
const now = new Date(nowMs);
|
|
19564
|
+
if (anchorMs === void 0 || !Number.isFinite(anchorMs)) {
|
|
19565
|
+
return {
|
|
19566
|
+
start: Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1),
|
|
19567
|
+
end: Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1)
|
|
19568
|
+
};
|
|
19569
|
+
}
|
|
19570
|
+
const anchor = new Date(anchorMs);
|
|
19571
|
+
let year = now.getUTCFullYear();
|
|
19572
|
+
let month = now.getUTCMonth();
|
|
19573
|
+
let start = anchoredMonthStart(year, month, anchor);
|
|
19574
|
+
if (start > nowMs) {
|
|
19575
|
+
month -= 1;
|
|
19576
|
+
start = anchoredMonthStart(year, month, anchor);
|
|
19577
|
+
}
|
|
19578
|
+
const end = anchoredMonthStart(year, month + 1, anchor);
|
|
19579
|
+
return { start, end };
|
|
19580
|
+
}
|
|
19581
|
+
function anchoredMonthStart(year, month, anchor) {
|
|
19582
|
+
const daysInMonth = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
19583
|
+
const day = Math.min(anchor.getUTCDate(), daysInMonth);
|
|
19584
|
+
return Date.UTC(
|
|
19585
|
+
year,
|
|
19586
|
+
month,
|
|
19587
|
+
day,
|
|
19588
|
+
anchor.getUTCHours(),
|
|
19589
|
+
anchor.getUTCMinutes(),
|
|
19590
|
+
anchor.getUTCSeconds(),
|
|
19591
|
+
anchor.getUTCMilliseconds()
|
|
19592
|
+
);
|
|
19593
|
+
}
|
|
19594
|
+
function expandHome(value, homeDir) {
|
|
19595
|
+
if (value === "~") return homeDir;
|
|
19596
|
+
if (value.startsWith("~/")) return path__default.join(homeDir, value.slice(2));
|
|
19597
|
+
return value;
|
|
19598
|
+
}
|
|
19268
19599
|
|
|
19269
19600
|
// ../fleet-plugins/quota/server/providers.ts
|
|
19270
19601
|
var REQUEST_TIMEOUT_MS = 1e4;
|
|
19271
19602
|
var MAX_RESPONSE_BYTES = 262144;
|
|
19272
19603
|
var MAX_WINDOWS = 8;
|
|
19273
19604
|
var MAX_CREDIT_ENTRIES = 256;
|
|
19605
|
+
var HOUR_MS = 36e5;
|
|
19606
|
+
var WEEK_MS2 = 7 * 24 * HOUR_MS;
|
|
19607
|
+
var CLAUDE_SESSION_MS = 5 * HOUR_MS;
|
|
19608
|
+
var MAX_WINDOW_DURATION_MS = 400 * 24 * HOUR_MS;
|
|
19609
|
+
function windowPeriod(durationMs, durationBasis, resetsAt) {
|
|
19610
|
+
if (!Number.isFinite(durationMs) || durationMs <= 0 || durationMs > MAX_WINDOW_DURATION_MS) return void 0;
|
|
19611
|
+
const rounded = Math.round(durationMs);
|
|
19612
|
+
const startsAt = resetsAt !== void 0 && resetsAt > rounded ? resetsAt - rounded : void 0;
|
|
19613
|
+
return {
|
|
19614
|
+
durationMs: rounded,
|
|
19615
|
+
durationBasis,
|
|
19616
|
+
...startsAt !== void 0 ? { startsAt, startsAtBasis: "derived" } : {}
|
|
19617
|
+
};
|
|
19618
|
+
}
|
|
19274
19619
|
var sharedAuthService;
|
|
19275
19620
|
function authServiceFor(deps) {
|
|
19276
19621
|
return deps.authService ?? (sharedAuthService ??= createAuthService({ authPath: DEFAULT_AUTH_PATH }));
|
|
@@ -19310,7 +19655,7 @@ function safeTimestamp(value) {
|
|
|
19310
19655
|
const rounded = Math.round(result);
|
|
19311
19656
|
return Number.isSafeInteger(rounded) ? rounded : void 0;
|
|
19312
19657
|
}
|
|
19313
|
-
function
|
|
19658
|
+
function percent2(value) {
|
|
19314
19659
|
if (typeof value !== "number" || !Number.isFinite(value)) return 0;
|
|
19315
19660
|
return Math.min(100, Math.max(0, Math.round(value)));
|
|
19316
19661
|
}
|
|
@@ -19335,27 +19680,29 @@ function modelLabel(value) {
|
|
|
19335
19680
|
function firstClaudePercent(row) {
|
|
19336
19681
|
for (const key of ["percent", "used_percentage", "utilization"]) {
|
|
19337
19682
|
const value = row[key];
|
|
19338
|
-
if (typeof value === "number" && Number.isFinite(value)) return
|
|
19683
|
+
if (typeof value === "number" && Number.isFinite(value)) return percent2(value);
|
|
19339
19684
|
}
|
|
19340
19685
|
return void 0;
|
|
19341
19686
|
}
|
|
19342
|
-
function claudeWindow(id, source, label) {
|
|
19687
|
+
function claudeWindow(id, source, durationMs, label) {
|
|
19343
19688
|
const row = object2(source);
|
|
19344
19689
|
if (!row) return null;
|
|
19345
19690
|
const usedPercent = firstClaudePercent(row);
|
|
19346
19691
|
if (usedPercent === void 0) return null;
|
|
19347
19692
|
const resetsAt = safeTimestamp(row.resets_at);
|
|
19693
|
+
const period = windowPeriod(durationMs, "catalog", resetsAt);
|
|
19348
19694
|
return {
|
|
19349
19695
|
id,
|
|
19350
19696
|
...label ? { label } : {},
|
|
19351
19697
|
usedPercent,
|
|
19352
|
-
...resetsAt !== void 0 ? { resetsAt } : {}
|
|
19698
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
19699
|
+
...period ? { period } : {}
|
|
19353
19700
|
};
|
|
19354
19701
|
}
|
|
19355
19702
|
function parseClaudeUsage(payload) {
|
|
19356
19703
|
const root = object2(payload) ?? {};
|
|
19357
|
-
const namedSession = claudeWindow("session", root.five_hour);
|
|
19358
|
-
const namedWeekly = claudeWindow("weekly", root.seven_day);
|
|
19704
|
+
const namedSession = claudeWindow("session", root.five_hour, CLAUDE_SESSION_MS);
|
|
19705
|
+
const namedWeekly = claudeWindow("weekly", root.seven_day, WEEK_MS2);
|
|
19359
19706
|
let fallbackSession = null;
|
|
19360
19707
|
let fallbackWeekly = null;
|
|
19361
19708
|
const modelWindows = [];
|
|
@@ -19365,22 +19712,22 @@ function parseClaudeUsage(payload) {
|
|
|
19365
19712
|
const limit = object2(item);
|
|
19366
19713
|
if (!limit) continue;
|
|
19367
19714
|
if (limit.kind === "session" && !namedSession && !fallbackSession) {
|
|
19368
|
-
fallbackSession = claudeWindow("session", limit);
|
|
19715
|
+
fallbackSession = claudeWindow("session", limit, CLAUDE_SESSION_MS);
|
|
19369
19716
|
continue;
|
|
19370
19717
|
}
|
|
19371
19718
|
if (limit.kind === "weekly_all" && !namedWeekly && !fallbackWeekly) {
|
|
19372
|
-
fallbackWeekly = claudeWindow("weekly", limit);
|
|
19719
|
+
fallbackWeekly = claudeWindow("weekly", limit, WEEK_MS2);
|
|
19373
19720
|
continue;
|
|
19374
19721
|
}
|
|
19375
19722
|
if (limit.kind === "weekly_scoped" && modelWindows.length < MAX_WINDOWS) {
|
|
19376
19723
|
const model = object2(object2(limit.scope)?.model);
|
|
19377
|
-
const row = claudeWindow("model", limit, modelLabel(model?.display_name));
|
|
19724
|
+
const row = claudeWindow("model", limit, WEEK_MS2, modelLabel(model?.display_name));
|
|
19378
19725
|
if (row) modelWindows.push(row);
|
|
19379
19726
|
}
|
|
19380
19727
|
}
|
|
19381
19728
|
if (modelWindows.length === 0) {
|
|
19382
19729
|
for (const alias of [root.fable_weekly, root.fable_seven_day, root.seven_day_fable]) {
|
|
19383
|
-
const row = claudeWindow("model", alias, "Fable");
|
|
19730
|
+
const row = claudeWindow("model", alias, WEEK_MS2, "Fable");
|
|
19384
19731
|
if (row) {
|
|
19385
19732
|
modelWindows.push(row);
|
|
19386
19733
|
break;
|
|
@@ -19397,13 +19744,16 @@ function parseClaudeUsage(payload) {
|
|
|
19397
19744
|
function codexWindow(source, fallbackId) {
|
|
19398
19745
|
const row = object2(source);
|
|
19399
19746
|
if (!row) return null;
|
|
19400
|
-
const seconds = typeof row.limit_window_seconds === "number" ? row.limit_window_seconds : 0;
|
|
19747
|
+
const seconds = typeof row.limit_window_seconds === "number" && Number.isFinite(row.limit_window_seconds) ? row.limit_window_seconds : 0;
|
|
19401
19748
|
const minutes = seconds / 60;
|
|
19402
19749
|
const id = minutes >= 240 && minutes <= 360 ? "session" : minutes >= 8064 && minutes <= 12096 ? "weekly" : fallbackId;
|
|
19750
|
+
const resetsAt = safeTimestamp(row.reset_at);
|
|
19751
|
+
const period = seconds > 0 ? windowPeriod(seconds * 1e3, "upstream", resetsAt) : void 0;
|
|
19403
19752
|
return {
|
|
19404
19753
|
id,
|
|
19405
|
-
usedPercent:
|
|
19406
|
-
...
|
|
19754
|
+
usedPercent: percent2(row.used_percent),
|
|
19755
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
19756
|
+
...period ? { period } : {}
|
|
19407
19757
|
};
|
|
19408
19758
|
}
|
|
19409
19759
|
function parseCodexUsage(payload) {
|
|
@@ -19422,6 +19772,21 @@ function parseCursorUsage(payload) {
|
|
|
19422
19772
|
const planUsage = object2(root?.planUsage);
|
|
19423
19773
|
if (root?.enabled === false || !planUsage) return { status: "no_subscription" };
|
|
19424
19774
|
const resetsAt = safeTimestamp(root?.billingCycleEnd);
|
|
19775
|
+
const cycleStart = safeTimestamp(root?.billingCycleStart);
|
|
19776
|
+
let cycleDays;
|
|
19777
|
+
let period;
|
|
19778
|
+
if (cycleStart !== void 0 && resetsAt !== void 0 && resetsAt > cycleStart) {
|
|
19779
|
+
const days = Math.round((resetsAt - cycleStart) / 864e5);
|
|
19780
|
+
if (days >= 1 && days <= 400) {
|
|
19781
|
+
cycleDays = days;
|
|
19782
|
+
period = {
|
|
19783
|
+
durationMs: resetsAt - cycleStart,
|
|
19784
|
+
durationBasis: "upstream",
|
|
19785
|
+
startsAt: cycleStart,
|
|
19786
|
+
startsAtBasis: "upstream"
|
|
19787
|
+
};
|
|
19788
|
+
}
|
|
19789
|
+
}
|
|
19425
19790
|
const windows = [];
|
|
19426
19791
|
for (const [value, scope, label] of [
|
|
19427
19792
|
[planUsage.totalPercentUsed, void 0, void 0],
|
|
@@ -19433,21 +19798,16 @@ function parseCursorUsage(payload) {
|
|
|
19433
19798
|
id: "cycle",
|
|
19434
19799
|
...scope ? { scope } : {},
|
|
19435
19800
|
...label ? { label } : {},
|
|
19436
|
-
usedPercent:
|
|
19437
|
-
...resetsAt !== void 0 ? { resetsAt } : {}
|
|
19801
|
+
usedPercent: percent2(value),
|
|
19802
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
19803
|
+
...period ? { period } : {}
|
|
19438
19804
|
});
|
|
19439
19805
|
}
|
|
19440
19806
|
if (windows.length === 0) return { status: "no_subscription" };
|
|
19441
|
-
const
|
|
19442
|
-
const cycleEnd = safeTimestamp(root?.billingCycleEnd);
|
|
19443
|
-
let cycleDays;
|
|
19444
|
-
if (cycleStart !== void 0 && cycleEnd !== void 0 && cycleEnd > cycleStart) {
|
|
19445
|
-
const days = Math.round((cycleEnd - cycleStart) / 864e5);
|
|
19446
|
-
if (days >= 1 && days <= 400) cycleDays = days;
|
|
19447
|
-
}
|
|
19807
|
+
const taggedWindows = windows.some((window) => window.scope !== void 0) ? windows.map((window) => window.scope === void 0 ? { ...window, isAggregate: true } : window) : windows;
|
|
19448
19808
|
return {
|
|
19449
19809
|
status: "ok",
|
|
19450
|
-
windows,
|
|
19810
|
+
windows: taggedWindows,
|
|
19451
19811
|
...cycleDays !== void 0 ? { cycleDays } : {}
|
|
19452
19812
|
};
|
|
19453
19813
|
}
|
|
@@ -19468,7 +19828,7 @@ var KIMI_WINDOW_BY_MINUTES = {
|
|
|
19468
19828
|
300: "session",
|
|
19469
19829
|
10080: "weekly"
|
|
19470
19830
|
};
|
|
19471
|
-
function kimiWindow(id, detail) {
|
|
19831
|
+
function kimiWindow(id, detail, duration3) {
|
|
19472
19832
|
const row = object2(detail);
|
|
19473
19833
|
if (!row) return null;
|
|
19474
19834
|
const limit = numeric(row.limit);
|
|
@@ -19477,10 +19837,15 @@ function kimiWindow(id, detail) {
|
|
|
19477
19837
|
const used = numeric(row.used) ?? (remaining === void 0 ? void 0 : limit - remaining);
|
|
19478
19838
|
if (used === void 0) return null;
|
|
19479
19839
|
const resetsAt = safeTimestamp(row.resetTime ?? row.resetAt);
|
|
19840
|
+
const period = duration3 ? windowPeriod(duration3.ms, duration3.basis, resetsAt) : void 0;
|
|
19480
19841
|
return {
|
|
19481
19842
|
id,
|
|
19482
|
-
usedPercent:
|
|
19483
|
-
...resetsAt !== void 0 ? { resetsAt } : {}
|
|
19843
|
+
usedPercent: percent2(used / limit * 100),
|
|
19844
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
19845
|
+
...period ? { period } : {},
|
|
19846
|
+
// Kimi quantifies in plain counts, never money, so the absolute figures may
|
|
19847
|
+
// ship; they are what lets a consumer size one more run against the bucket.
|
|
19848
|
+
amounts: { used: String(Math.max(0, used)), limit: String(limit) }
|
|
19484
19849
|
};
|
|
19485
19850
|
}
|
|
19486
19851
|
function kimiPlan(payload) {
|
|
@@ -19497,7 +19862,7 @@ function parseKimiUsage(payload) {
|
|
|
19497
19862
|
const root = object2(payload);
|
|
19498
19863
|
if (!root) return { status: "no_subscription" };
|
|
19499
19864
|
const windows = [];
|
|
19500
|
-
const cycle = kimiWindow("cycle", root.usage);
|
|
19865
|
+
const cycle = kimiWindow("cycle", root.usage, { ms: WEEK_MS2, basis: "catalog" });
|
|
19501
19866
|
if (cycle) windows.push(cycle);
|
|
19502
19867
|
const limits = array2(root.limits);
|
|
19503
19868
|
for (let index = 0; index < limits.length && windows.length < MAX_WINDOWS; index += 1) {
|
|
@@ -19508,7 +19873,7 @@ function parseKimiUsage(payload) {
|
|
|
19508
19873
|
if (duration3 === void 0 || unit === void 0) continue;
|
|
19509
19874
|
const id = KIMI_WINDOW_BY_MINUTES[duration3 * unit];
|
|
19510
19875
|
if (!id || windows.some((window2) => window2.id === id)) continue;
|
|
19511
|
-
const window = kimiWindow(id, entry?.detail);
|
|
19876
|
+
const window = kimiWindow(id, entry?.detail, { ms: duration3 * unit * 6e4, basis: "upstream" });
|
|
19512
19877
|
if (window) windows.push(window);
|
|
19513
19878
|
}
|
|
19514
19879
|
if (windows.length === 0) return { status: "no_subscription" };
|
|
@@ -19718,6 +20083,30 @@ async function fetchKimiUsage(deps = {}) {
|
|
|
19718
20083
|
throw error51;
|
|
19719
20084
|
}
|
|
19720
20085
|
}
|
|
20086
|
+
async function fetchOpencodeUsage(deps = {}) {
|
|
20087
|
+
const apiKey = await authServiceFor(deps).getApiKey(OPENCODE_AUTH_PROVIDER_ID);
|
|
20088
|
+
if (!apiKey) return { status: "signed_out" };
|
|
20089
|
+
const now = deps.now ?? Date.now;
|
|
20090
|
+
try {
|
|
20091
|
+
const scan = await (deps.scanOpencodeGoWindows ?? (() => scanOpencodeGoWindows({ now })))();
|
|
20092
|
+
if (scan !== null) {
|
|
20093
|
+
return {
|
|
20094
|
+
status: "ok",
|
|
20095
|
+
plan: "Go",
|
|
20096
|
+
cycleDays: scan.cycleDays,
|
|
20097
|
+
windows: scan.windows,
|
|
20098
|
+
fetchedAt: now()
|
|
20099
|
+
};
|
|
20100
|
+
}
|
|
20101
|
+
} catch {
|
|
20102
|
+
}
|
|
20103
|
+
return {
|
|
20104
|
+
status: "ok",
|
|
20105
|
+
plan: "Go",
|
|
20106
|
+
windows: [],
|
|
20107
|
+
fetchedAt: now()
|
|
20108
|
+
};
|
|
20109
|
+
}
|
|
19721
20110
|
function sanitizeProviderError(error51) {
|
|
19722
20111
|
if (error51 instanceof ProviderResponseTooLargeError) return "Provider response too large";
|
|
19723
20112
|
if (error51 instanceof DOMException && error51.name === "AbortError") return "Provider request timed out";
|
|
@@ -19739,7 +20128,8 @@ function createQuotaService(deps) {
|
|
|
19739
20128
|
claude: deps.fetchClaude ?? (() => fetchClaudeUsage()),
|
|
19740
20129
|
codex: deps.fetchCodex ?? (() => fetchCodexUsage()),
|
|
19741
20130
|
cursor: deps.fetchCursor ?? (() => fetchCursorUsage()),
|
|
19742
|
-
kimi: deps.fetchKimi ?? (() => fetchKimiUsage())
|
|
20131
|
+
kimi: deps.fetchKimi ?? (() => fetchKimiUsage()),
|
|
20132
|
+
opencode: deps.fetchOpencode ?? (() => fetchOpencodeUsage())
|
|
19743
20133
|
};
|
|
19744
20134
|
const cache = /* @__PURE__ */ new Map();
|
|
19745
20135
|
const lastGood = /* @__PURE__ */ new Map();
|
|
@@ -19774,13 +20164,14 @@ function createQuotaService(deps) {
|
|
|
19774
20164
|
}
|
|
19775
20165
|
return {
|
|
19776
20166
|
async getSummary(options = {}) {
|
|
19777
|
-
const [claude, codex, cursor, kimi] = await Promise.all([
|
|
20167
|
+
const [claude, codex, cursor, kimi, opencode] = await Promise.all([
|
|
19778
20168
|
load("claude", options.force === true || options.forceProvider === "claude"),
|
|
19779
20169
|
load("codex", options.force === true || options.forceProvider === "codex"),
|
|
19780
20170
|
load("cursor", options.force === true || options.forceProvider === "cursor"),
|
|
19781
|
-
load("kimi", options.force === true || options.forceProvider === "kimi")
|
|
20171
|
+
load("kimi", options.force === true || options.forceProvider === "kimi"),
|
|
20172
|
+
load("opencode", options.force === true || options.forceProvider === "opencode")
|
|
19782
20173
|
]);
|
|
19783
|
-
return { providers: { claude, codex, cursor, kimi } };
|
|
20174
|
+
return { providers: { claude, codex, cursor, kimi, opencode } };
|
|
19784
20175
|
}
|
|
19785
20176
|
};
|
|
19786
20177
|
}
|