codesesh 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{chunk-PAP2Q3WV.js → chunk-DE6UJMOY.js} +2 -2
- package/dist/{chunk-YQFEGFWD.js → chunk-EYZ73CYP.js} +2 -2
- package/dist/{chunk-NBJJGH5P.js → chunk-QHWSZFRM.js} +118 -74
- package/dist/chunk-QHWSZFRM.js.map +1 -0
- package/dist/{chunk-WUYSZAYR.js → chunk-SII3M66U.js} +13 -6
- package/dist/chunk-SII3M66U.js.map +1 -0
- package/dist/{chunk-TS3IWH5U.js → chunk-VVCSQU5B.js} +120 -20
- package/dist/chunk-VVCSQU5B.js.map +1 -0
- package/dist/{chunk-FCYCBGEL.js → chunk-WIWK7BXS.js} +3 -3
- package/dist/{chunk-XKZSX5BM.js → chunk-YEQTRALH.js} +3 -3
- package/dist/{discovery-D23RV7FY.js → discovery-4WAEYSTR.js} +7 -5
- package/dist/index.js +217 -150
- package/dist/index.js.map +1 -1
- package/dist/project-identity-worker.js +4 -4
- package/dist/scan-refresh-worker.js +6 -6
- package/dist/search-index-worker.js +6 -6
- package/dist/session-detail-worker.js +6 -6
- package/dist/smart-tag-worker.js +3 -3
- package/dist/web/assets/CustomTimeWindowDialog-CVURkiVO.js +1 -0
- package/dist/web/assets/InteractiveReceipt-DGC-xV7U.js +1 -0
- package/dist/web/assets/OverviewScreen-DoXrZ5qp.js +1 -0
- package/dist/web/assets/{PrismHighlighter-LWITDffT.js → PrismHighlighter-02695Lmx.js} +1 -1
- package/dist/web/assets/Projects-DZiYh6hp.js +1 -0
- package/dist/web/assets/SearchResultsPanel-CAQe8Di0.js +1 -0
- package/dist/web/assets/SessionDetail-Da8EBygt.js +53 -0
- package/dist/web/assets/api-ToidoNW6.js +1 -0
- package/dist/web/assets/index-Bl8pbRFj.js +1423 -0
- package/dist/web/assets/index-CRI1m3xN.css +1 -0
- package/dist/web/assets/session-indexes-D5gps7K8.js +4 -0
- package/dist/web/assets/translate-BDFu3ZiK.js +2 -0
- package/dist/web/assets/utils-BIZi2up3.js +1 -0
- package/dist/web/index.html +7 -7
- package/package.json +3 -3
- package/dist/chunk-NBJJGH5P.js.map +0 -1
- package/dist/chunk-TS3IWH5U.js.map +0 -1
- package/dist/chunk-WUYSZAYR.js.map +0 -1
- package/dist/web/assets/CustomTimeWindowDialog-C9XTZRm0.js +0 -1
- package/dist/web/assets/InteractiveReceipt-Sca1smpv.js +0 -1
- package/dist/web/assets/OverviewScreen-Vq6BQR9_.js +0 -1
- package/dist/web/assets/Projects-CwicV3Dk.js +0 -1
- package/dist/web/assets/SearchResultsPanel-DCO0Ak0c.js +0 -1
- package/dist/web/assets/SessionDetail-mdmTQgo1.js +0 -53
- package/dist/web/assets/api-CXVT9XcZ.js +0 -1
- package/dist/web/assets/contract-BS78VBCV.js +0 -2
- package/dist/web/assets/index-C5cyw58A.css +0 -1
- package/dist/web/assets/index-H2cT-6c6.js +0 -1423
- package/dist/web/assets/session-indexes-yyyWpKLf.js +0 -4
- package/dist/web/assets/utils-C7BqyxxV.js +0 -1
- /package/dist/{chunk-PAP2Q3WV.js.map → chunk-DE6UJMOY.js.map} +0 -0
- /package/dist/{chunk-YQFEGFWD.js.map → chunk-EYZ73CYP.js.map} +0 -0
- /package/dist/{chunk-FCYCBGEL.js.map → chunk-WIWK7BXS.js.map} +0 -0
- /package/dist/{chunk-XKZSX5BM.js.map → chunk-YEQTRALH.js.map} +0 -0
- /package/dist/{discovery-D23RV7FY.js.map → discovery-4WAEYSTR.js.map} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ Your browser will open at `http://localhost:4521` with all your sessions ready t
|
|
|
23
23
|
- **Session Aliases** — Give important sessions memorable local names that carry through search, bookmarks, and activity views
|
|
24
24
|
- **Persistent Themes** — Choose light, dark, or system appearance and keep your UI preferences across sessions
|
|
25
25
|
- **Structured Global Search** — Search titles, messages, tool output, and file paths with filters for agent, project, smart tag, tool, file activity, and cost
|
|
26
|
+
- **UI languages** — English, Simplified Chinese, and Japanese. Follows your browser language by default; use the language selector in the top toolbar to switch and save your preference. Session content and code stay in their original language.
|
|
26
27
|
- **Dashboard & Activity Trends** — See totals, daily activity, agent distribution, model usage, token trends, smart tags, bookmarks, and recent sessions
|
|
27
28
|
- **Project Browse Mode** — Open a dedicated projects view with project-level metrics, sessions, and cross-agent drill-down
|
|
28
29
|
- **Project & Nested Session Tree** — Group sessions by repository or project identity, while keeping subagent sessions under their parent
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
WORKER_LOG_MESSAGE_TYPE,
|
|
7
7
|
isWorkerLogMessage,
|
|
8
8
|
setCoreDiagnostics
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QHWSZFRM.js";
|
|
10
10
|
|
|
11
11
|
// src/logging.ts
|
|
12
12
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -1268,4 +1268,4 @@ export {
|
|
|
1268
1268
|
appLogger,
|
|
1269
1269
|
logSearchIndexSync
|
|
1270
1270
|
};
|
|
1271
|
-
//# sourceMappingURL=chunk-
|
|
1271
|
+
//# sourceMappingURL=chunk-DE6UJMOY.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
appLogger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DE6UJMOY.js";
|
|
5
5
|
|
|
6
6
|
// src/worker-log-drain.ts
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
acknowledgeWorkerLogDrain,
|
|
87
87
|
terminateWorkerAfterLogDrain
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-EYZ73CYP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// ../core/dist/chunk-
|
|
3
|
+
// ../core/dist/chunk-6WFJQ4PU.mjs
|
|
4
4
|
var SMART_TAGS = [
|
|
5
5
|
"bugfix",
|
|
6
6
|
"refactoring",
|
|
@@ -36,7 +36,7 @@ function toPublicReferencedSessionHead(item) {
|
|
|
36
36
|
return { ...item, session: toPublicSessionHead(item.session) };
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
// ../core/dist/chunk-
|
|
39
|
+
// ../core/dist/chunk-VL5JRZM5.mjs
|
|
40
40
|
var SMART_TAG_CLASSIFIER_REVISION = "smart-tags-v1";
|
|
41
41
|
var USER_RULES = [
|
|
42
42
|
["bugfix", /\b(fix|bug|error|crash|exception|fail(?:ed|ure)?)\b|修复|错误|报错|崩溃|异常/i],
|
|
@@ -107,12 +107,12 @@ function hasEditedDocPath(value) {
|
|
|
107
107
|
if (typeof value === "string") return DOC_PATH_RE.test(value);
|
|
108
108
|
if (Array.isArray(value)) return value.some(hasEditedDocPath);
|
|
109
109
|
if (typeof value !== "object") return false;
|
|
110
|
-
const
|
|
110
|
+
const record2 = value;
|
|
111
111
|
for (const key of ["path", "file", "filePath", "file_path", "targetPath", "target_path"]) {
|
|
112
|
-
const raw =
|
|
112
|
+
const raw = record2[key];
|
|
113
113
|
if (typeof raw === "string" && DOC_PATH_RE.test(raw)) return true;
|
|
114
114
|
}
|
|
115
|
-
return Object.values(
|
|
115
|
+
return Object.values(record2).some(hasEditedDocPath);
|
|
116
116
|
}
|
|
117
117
|
var WORKER_LOG_MESSAGE_TYPE = "codesesh.worker-log";
|
|
118
118
|
var WORKER_LOG_CONTEXT_KEYS = /* @__PURE__ */ new Set(["request_id", "operation_id", "publication_id"]);
|
|
@@ -172,7 +172,7 @@ function sessionRoutePath(reference) {
|
|
|
172
172
|
return `${agentRoutePath(normalized.agentName)}/${encodeURIComponent(normalized.sessionId)}`;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
// ../core/dist/chunk-
|
|
175
|
+
// ../core/dist/chunk-665YT5TL.mjs
|
|
176
176
|
var FILE_TOOL_KINDS = {
|
|
177
177
|
read: "read",
|
|
178
178
|
read_file: "read",
|
|
@@ -243,8 +243,8 @@ function collectPaths(value, key, paths, depth = 0) {
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
function extractPatchOperations(input) {
|
|
246
|
-
const
|
|
247
|
-
const content = Array.isArray(input) ? input : Array.isArray(
|
|
246
|
+
const record2 = toRecord(input);
|
|
247
|
+
const content = Array.isArray(input) ? input : Array.isArray(record2.content) ? record2.content : [];
|
|
248
248
|
return content.flatMap((entry) => {
|
|
249
249
|
const patch = toRecord(entry);
|
|
250
250
|
const kind = typeof patch.type === "string" ? PATCH_KINDS[patch.type] : void 0;
|
|
@@ -576,9 +576,16 @@ function buildSessionTree(sessions) {
|
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
578
|
}
|
|
579
|
-
function filterSessionTreeByActivityWindow(sessions, from, to, tree
|
|
579
|
+
function filterSessionTreeByActivityWindow(sessions, from, to, tree) {
|
|
580
580
|
if (from == null && to == null) return sessions;
|
|
581
|
-
|
|
581
|
+
if (tree === void 0 && sessions.every((session) => hasActivityInWindow(session, from, to))) {
|
|
582
|
+
return [...sessions];
|
|
583
|
+
}
|
|
584
|
+
const pending2 = filterSessionTreeEntriesByActivityWindow(
|
|
585
|
+
tree ?? buildSessionTree(sessions),
|
|
586
|
+
from,
|
|
587
|
+
to
|
|
588
|
+
);
|
|
582
589
|
const visible = /* @__PURE__ */ new Set();
|
|
583
590
|
while (pending2.length > 0) {
|
|
584
591
|
const node = pending2.pop();
|
|
@@ -622,11 +629,11 @@ function collectAffectedHierarchyKeys(graph, seedKeys, includeAncestors, collect
|
|
|
622
629
|
for (const child of graph.childrenByKey.get(key) ?? []) pending2.push(child);
|
|
623
630
|
}
|
|
624
631
|
if (!includeAncestors) return;
|
|
632
|
+
const visitedAncestors = /* @__PURE__ */ new Set();
|
|
625
633
|
for (const seed of seedKeys) {
|
|
626
634
|
let key = graph.sessionsByKey.has(seed) ? seed : void 0;
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
onPath.add(key);
|
|
635
|
+
while (key && !visitedAncestors.has(key)) {
|
|
636
|
+
visitedAncestors.add(key);
|
|
630
637
|
collected.add(key);
|
|
631
638
|
key = graph.parentByKey.get(key);
|
|
632
639
|
}
|
|
@@ -666,7 +673,7 @@ function createSessionProjectionContext(previousSessions, nextSessions, changedS
|
|
|
666
673
|
var CODESESH_REQUEST_ID_HEADER = "X-CodeSesh-Request-ID";
|
|
667
674
|
var CODESESH_OPERATION_ID_HEADER = "X-CodeSesh-Operation-ID";
|
|
668
675
|
|
|
669
|
-
// ../core/dist/chunk-
|
|
676
|
+
// ../core/dist/chunk-4COCEPC7.mjs
|
|
670
677
|
function normalizeToolLabel(part) {
|
|
671
678
|
if (part.title?.trim()) {
|
|
672
679
|
return part.title.trim().replace(/^tool:\s*/i, "");
|
|
@@ -808,12 +815,67 @@ function restrictPrivateDatabase(dbPath) {
|
|
|
808
815
|
restrictExistingBackups(dbPath);
|
|
809
816
|
}
|
|
810
817
|
|
|
811
|
-
// ../core/dist/chunk-
|
|
818
|
+
// ../core/dist/chunk-MPV674C3.mjs
|
|
812
819
|
import { createHash } from "crypto";
|
|
813
820
|
import { existsSync as existsSync2, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
814
821
|
import { homedir } from "os";
|
|
815
822
|
import { join as join2 } from "path";
|
|
816
823
|
import { AsyncLocalStorage } from "async_hooks";
|
|
824
|
+
function normalizeModelKey(key) {
|
|
825
|
+
return key.trim().toLowerCase().replaceAll("_", "-");
|
|
826
|
+
}
|
|
827
|
+
var MODELS_DEV_URL = "https://models.dev/api.json";
|
|
828
|
+
var ORIGINAL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
829
|
+
"anthropic",
|
|
830
|
+
"openai",
|
|
831
|
+
"google",
|
|
832
|
+
"deepseek",
|
|
833
|
+
"moonshotai",
|
|
834
|
+
"minimax",
|
|
835
|
+
"mistral",
|
|
836
|
+
"xai",
|
|
837
|
+
"cohere",
|
|
838
|
+
"zai",
|
|
839
|
+
"zhipuai",
|
|
840
|
+
"alibaba",
|
|
841
|
+
"meta",
|
|
842
|
+
"stepfun"
|
|
843
|
+
]);
|
|
844
|
+
function record(value) {
|
|
845
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
846
|
+
}
|
|
847
|
+
function perToken(value) {
|
|
848
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value / 1e6 : void 0;
|
|
849
|
+
}
|
|
850
|
+
function parseModelsDevPricing(data) {
|
|
851
|
+
const providers = Object.entries(record(data) ?? {}).sort(
|
|
852
|
+
([a], [b]) => Number(ORIGINAL_PROVIDERS.has(b)) - Number(ORIGINAL_PROVIDERS.has(a)) || a.localeCompare(b)
|
|
853
|
+
);
|
|
854
|
+
const qualified = /* @__PURE__ */ new Map();
|
|
855
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
856
|
+
for (const [provider, rawProvider] of providers) {
|
|
857
|
+
const models = record(record(rawProvider)?.["models"]);
|
|
858
|
+
for (const [model, rawModel] of Object.entries(models ?? {})) {
|
|
859
|
+
const cost = record(record(rawModel)?.["cost"]);
|
|
860
|
+
if (!cost) continue;
|
|
861
|
+
const input = perToken(cost["input"]);
|
|
862
|
+
const output = perToken(cost["output"]);
|
|
863
|
+
if (input === void 0 || output === void 0) continue;
|
|
864
|
+
const pricing = {
|
|
865
|
+
inputCostPerToken: input,
|
|
866
|
+
outputCostPerToken: output,
|
|
867
|
+
cacheCreateCostPerToken: perToken(cost["cache_write"]) ?? input,
|
|
868
|
+
cacheReadCostPerToken: perToken(cost["cache_read"]) ?? input,
|
|
869
|
+
reasoningCostPerToken: output,
|
|
870
|
+
webSearchCostPerRequest: 0.01
|
|
871
|
+
};
|
|
872
|
+
qualified.set(normalizeModelKey(`${provider}/${model}`), pricing);
|
|
873
|
+
const name = normalizeModelKey(model);
|
|
874
|
+
if (!aliases.has(name)) aliases.set(name, pricing);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return new Map([...aliases, ...qualified]);
|
|
878
|
+
}
|
|
817
879
|
var snapshot_default = {
|
|
818
880
|
"claude-3-5-haiku": [8e-7, 4e-6, 1e-6, 8e-8],
|
|
819
881
|
"claude-3-5-sonnet": [3e-6, 15e-6, 375e-8, 3e-7],
|
|
@@ -857,16 +919,13 @@ var snapshot_default = {
|
|
|
857
919
|
"gemini-2.5-pro": [125e-8, 1e-5, null, 125e-9],
|
|
858
920
|
"gemini-2.5-flash": [3e-7, 25e-7, null, 3e-8]
|
|
859
921
|
};
|
|
860
|
-
var
|
|
861
|
-
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
922
|
+
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
862
923
|
var WEB_SEARCH_COST = 0.01;
|
|
863
924
|
var REFRESH_TIMEOUT_MS = 1e4;
|
|
864
925
|
var published = createPricingGeneration(loadSnapshot());
|
|
865
926
|
var pending = null;
|
|
927
|
+
var refreshInFlight = null;
|
|
866
928
|
published = readDiskCache() ?? published;
|
|
867
|
-
function normalizeModelKey(key) {
|
|
868
|
-
return key.trim().toLowerCase().replaceAll("_", "-");
|
|
869
|
-
}
|
|
870
929
|
function createPricingGeneration(pricing) {
|
|
871
930
|
const hash = createHash("sha256");
|
|
872
931
|
const entries = [...pricing.entries()].sort(
|
|
@@ -890,7 +949,7 @@ function getCacheDir() {
|
|
|
890
949
|
return join2(homedir(), ".cache", "codesesh");
|
|
891
950
|
}
|
|
892
951
|
function getCachePath() {
|
|
893
|
-
return join2(getCacheDir(), "
|
|
952
|
+
return join2(getCacheDir(), "models-dev-pricing.json");
|
|
894
953
|
}
|
|
895
954
|
function loadSnapshot() {
|
|
896
955
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -908,27 +967,19 @@ function loadSnapshot() {
|
|
|
908
967
|
}
|
|
909
968
|
return map;
|
|
910
969
|
}
|
|
911
|
-
function parseLiteLLMEntry(entry) {
|
|
912
|
-
return normalizePricing({
|
|
913
|
-
inputCostPerToken: entry.input_cost_per_token,
|
|
914
|
-
outputCostPerToken: entry.output_cost_per_token,
|
|
915
|
-
cacheCreateCostPerToken: entry.cache_creation_input_token_cost,
|
|
916
|
-
cacheReadCostPerToken: entry.cache_read_input_token_cost,
|
|
917
|
-
reasoningCostPerToken: entry.output_reasoning_cost_per_token,
|
|
918
|
-
webSearchCostPerRequest: entry.web_search_cost_per_request ?? entry.search_context_cost_per_query
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
970
|
function normalizePricing(raw) {
|
|
922
|
-
|
|
923
|
-
const
|
|
971
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
972
|
+
const values = raw;
|
|
973
|
+
const input = costNumber(values["inputCostPerToken"]);
|
|
974
|
+
const output = costNumber(values["outputCostPerToken"]);
|
|
924
975
|
if (input === void 0 || output === void 0) return null;
|
|
925
976
|
return {
|
|
926
977
|
inputCostPerToken: input,
|
|
927
978
|
outputCostPerToken: output,
|
|
928
|
-
cacheCreateCostPerToken: costNumber(
|
|
929
|
-
cacheReadCostPerToken: costNumber(
|
|
930
|
-
reasoningCostPerToken: costNumber(
|
|
931
|
-
webSearchCostPerRequest: costNumber(
|
|
979
|
+
cacheCreateCostPerToken: costNumber(values["cacheCreateCostPerToken"]) ?? input * 1.25,
|
|
980
|
+
cacheReadCostPerToken: costNumber(values["cacheReadCostPerToken"]) ?? input * 0.1,
|
|
981
|
+
reasoningCostPerToken: costNumber(values["reasoningCostPerToken"]) ?? output,
|
|
982
|
+
webSearchCostPerRequest: costNumber(values["webSearchCostPerRequest"]) ?? WEB_SEARCH_COST
|
|
932
983
|
};
|
|
933
984
|
}
|
|
934
985
|
function indexPricing(map, name, pricing) {
|
|
@@ -940,30 +991,25 @@ function indexPricing(map, name, pricing) {
|
|
|
940
991
|
if (!map.has(stripped)) map.set(stripped, pricing);
|
|
941
992
|
}
|
|
942
993
|
}
|
|
943
|
-
function
|
|
944
|
-
const map = /* @__PURE__ */ new Map();
|
|
945
|
-
for (const [name, entry] of Object.entries(data)) {
|
|
946
|
-
const pricing = parseLiteLLMEntry(entry);
|
|
947
|
-
if (pricing) indexPricing(map, name, pricing);
|
|
948
|
-
}
|
|
949
|
-
return map;
|
|
950
|
-
}
|
|
951
|
-
function readDiskCache() {
|
|
994
|
+
function readDiskCache(requireFresh = false) {
|
|
952
995
|
const path = getCachePath();
|
|
953
996
|
if (!existsSync2(path)) return null;
|
|
954
997
|
try {
|
|
955
998
|
const cached = JSON.parse(readFileSync(path, "utf-8"));
|
|
956
|
-
if (!Number.isFinite(cached.timestamp)) return null;
|
|
999
|
+
if (!Number.isFinite(cached.timestamp) || cached.timestamp > Date.now()) return null;
|
|
1000
|
+
if (requireFresh && Date.now() - cached.timestamp >= CACHE_TTL_MS) return null;
|
|
957
1001
|
if (cached.data == null || typeof cached.data !== "object" || Array.isArray(cached.data)) {
|
|
958
1002
|
return null;
|
|
959
1003
|
}
|
|
960
1004
|
const next = loadSnapshot();
|
|
1005
|
+
let validEntries = 0;
|
|
961
1006
|
for (const [name, rawPricing] of Object.entries(cached.data)) {
|
|
962
1007
|
const pricing = normalizePricing(rawPricing);
|
|
963
1008
|
if (!pricing) continue;
|
|
964
1009
|
next.set(normalizeModelKey(name), pricing);
|
|
1010
|
+
validEntries++;
|
|
965
1011
|
}
|
|
966
|
-
return createPricingGeneration(next);
|
|
1012
|
+
return validEntries > 0 ? createPricingGeneration(next) : null;
|
|
967
1013
|
} catch {
|
|
968
1014
|
return null;
|
|
969
1015
|
}
|
|
@@ -1026,25 +1072,21 @@ function writeDiskCacheAtomically(path, generation) {
|
|
|
1026
1072
|
return false;
|
|
1027
1073
|
}
|
|
1028
1074
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
} catch {
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1075
|
+
function refreshPricingCache(options = {}) {
|
|
1076
|
+
refreshInFlight ??= fetchPricing(options).finally(() => {
|
|
1077
|
+
refreshInFlight = null;
|
|
1078
|
+
});
|
|
1079
|
+
return refreshInFlight;
|
|
1080
|
+
}
|
|
1081
|
+
async function fetchPricing(options) {
|
|
1082
|
+
if (pending || readDiskCache(true)) return false;
|
|
1040
1083
|
const timeout = AbortSignal.timeout(options.timeoutMs ?? REFRESH_TIMEOUT_MS);
|
|
1041
1084
|
const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
|
|
1042
1085
|
getCoreDiagnostics()?.info?.("pricing.refresh.started", { generation: published.id });
|
|
1043
1086
|
try {
|
|
1044
|
-
const response = await fetch(
|
|
1087
|
+
const response = await fetch(MODELS_DEV_URL, { signal });
|
|
1045
1088
|
if (!response.ok) return false;
|
|
1046
|
-
const
|
|
1047
|
-
const remote = parseLiteLLMData(data);
|
|
1089
|
+
const remote = parseModelsDevPricing(await response.json());
|
|
1048
1090
|
if (remote.size === 0) return false;
|
|
1049
1091
|
const next = loadSnapshot();
|
|
1050
1092
|
for (const [name, pricing] of remote.entries()) {
|
|
@@ -1132,18 +1174,20 @@ function lookupCandidate(model, registry) {
|
|
|
1132
1174
|
return null;
|
|
1133
1175
|
}
|
|
1134
1176
|
function fuzzyLookup(model, registry) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
if (model
|
|
1139
|
-
|
|
1140
|
-
|
|
1177
|
+
const direct = registry.get(model);
|
|
1178
|
+
if (direct && hasBillablePricing(direct)) return direct;
|
|
1179
|
+
for (let index = model.length - 1; index >= 0; index--) {
|
|
1180
|
+
if (model[index] !== "-" && model[index] !== "@") continue;
|
|
1181
|
+
const pricing = registry.get(model.slice(0, index));
|
|
1182
|
+
if (pricing && hasBillablePricing(pricing)) return pricing;
|
|
1141
1183
|
}
|
|
1142
|
-
return
|
|
1184
|
+
return null;
|
|
1143
1185
|
}
|
|
1144
1186
|
var pricingResolver = {
|
|
1145
1187
|
resolve(rawModelName) {
|
|
1146
1188
|
const registry = getPricingRegistry();
|
|
1189
|
+
const exact = registry.get(normalizeModelKey(rawModelName));
|
|
1190
|
+
if (exact && hasBillablePricing(exact)) return exact;
|
|
1147
1191
|
const candidates = getCandidates(rawModelName);
|
|
1148
1192
|
for (const candidate of candidates) {
|
|
1149
1193
|
const pricing = lookupCandidate(candidate, registry);
|
|
@@ -1192,7 +1236,7 @@ function estimateCostForTokens(model, usage) {
|
|
|
1192
1236
|
return cost > 0 ? { cost: Number(cost.toFixed(8)), source: "estimated" } : null;
|
|
1193
1237
|
}
|
|
1194
1238
|
|
|
1195
|
-
// ../core/dist/chunk-
|
|
1239
|
+
// ../core/dist/chunk-N65P4J7T.mjs
|
|
1196
1240
|
import { closeSync, openSync, readSync } from "fs";
|
|
1197
1241
|
import { StringDecoder } from "string_decoder";
|
|
1198
1242
|
import { basename as basename2 } from "path";
|
|
@@ -1809,9 +1853,9 @@ function normalizeToolState(value, legacyPart) {
|
|
|
1809
1853
|
}
|
|
1810
1854
|
function planText(value) {
|
|
1811
1855
|
if (typeof value === "string") return value;
|
|
1812
|
-
const
|
|
1813
|
-
if (!
|
|
1814
|
-
return planText(
|
|
1856
|
+
const record2 = toRecord2(value);
|
|
1857
|
+
if (!record2) return "";
|
|
1858
|
+
return planText(record2.text ?? record2.plan ?? record2.content);
|
|
1815
1859
|
}
|
|
1816
1860
|
function normalizePlanPart(value, time_created) {
|
|
1817
1861
|
const approval_status = value.approval_status === "fail" ? "fail" : "success";
|
|
@@ -2050,4 +2094,4 @@ export {
|
|
|
2050
2094
|
AGENT_CATALOG,
|
|
2051
2095
|
getAgentCatalogEntry
|
|
2052
2096
|
};
|
|
2053
|
-
//# sourceMappingURL=chunk-
|
|
2097
|
+
//# sourceMappingURL=chunk-QHWSZFRM.js.map
|