claude-discover 1.10.17 → 1.11.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/out/main/main.js +295 -31
- package/out/preload/preload.cjs +1 -0
- package/out/renderer/assets/{index-DkK-CcW5.css → index-D2BlPCj3.css} +362 -11
- package/out/renderer/assets/{index-DwoKHxnT.js → index-RKOr5gww.js} +17672 -1488
- package/out/renderer/assets/vendors-EA0PPPlA.js +61062 -0
- package/out/renderer/index.html +3 -3
- package/package.json +2 -3
- package/out/renderer/assets/vendors-CLjIyzGq.js +0 -267393
package/out/main/main.js
CHANGED
|
@@ -272,7 +272,7 @@ var require_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
272
272
|
_a = signalExitWrap(processOk(process) ? new SignalExit(process) : new SignalExitFallback()), exports.onExit = _a.onExit, exports.load = _a.load, exports.unload = _a.unload;
|
|
273
273
|
}));
|
|
274
274
|
// src/main/config/ConfigFile.js
|
|
275
|
-
var import_lib$1 = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
275
|
+
var import_lib$1 = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
276
276
|
module.exports = writeFile;
|
|
277
277
|
module.exports.sync = writeFileSync;
|
|
278
278
|
module.exports._getTmpname = getTmpname;
|
|
@@ -425,7 +425,7 @@ var import_lib$1 = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
425
425
|
if (threw) cleanup();
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
})))();
|
|
428
|
+
})))(), 1);
|
|
429
429
|
var ConfigFile = class {
|
|
430
430
|
dataDir = join(homedir(), ".claude-discover");
|
|
431
431
|
configFile = join(this.dataDir, "config.json");
|
|
@@ -654,6 +654,11 @@ function startOfWeek(date, options) {
|
|
|
654
654
|
_date.setHours(0, 0, 0, 0);
|
|
655
655
|
return _date;
|
|
656
656
|
}
|
|
657
|
+
// node_modules/date-fns/_lib/normalizeDates.js
|
|
658
|
+
function normalizeDates(context, ...dates) {
|
|
659
|
+
const normalize = constructFrom.bind(null, context || dates.find((date) => typeof date === "object"));
|
|
660
|
+
return dates.map(normalize);
|
|
661
|
+
}
|
|
657
662
|
// node_modules/date-fns/startOfDay.js
|
|
658
663
|
/**
|
|
659
664
|
* The {@link startOfDay} function options.
|
|
@@ -685,6 +690,43 @@ function startOfDay(date, options) {
|
|
|
685
690
|
_date.setHours(0, 0, 0, 0);
|
|
686
691
|
return _date;
|
|
687
692
|
}
|
|
693
|
+
// node_modules/date-fns/isSameDay.js
|
|
694
|
+
/**
|
|
695
|
+
* The {@link isSameDay} function options.
|
|
696
|
+
*/
|
|
697
|
+
/**
|
|
698
|
+
* @name isSameDay
|
|
699
|
+
* @category Day Helpers
|
|
700
|
+
* @summary Are the given dates in the same day (and year and month)?
|
|
701
|
+
*
|
|
702
|
+
* @description
|
|
703
|
+
* Are the given dates in the same day (and year and month)?
|
|
704
|
+
*
|
|
705
|
+
* @param laterDate - The first date to check
|
|
706
|
+
* @param earlierDate - The second date to check
|
|
707
|
+
* @param options - An object with options
|
|
708
|
+
*
|
|
709
|
+
* @returns The dates are in the same day (and year and month)
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
|
|
713
|
+
* const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
|
|
714
|
+
* //=> true
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* // Are 4 September and 4 October in the same day?
|
|
718
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
|
|
719
|
+
* //=> false
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* // Are 4 September, 2014 and 4 September, 2015 in the same day?
|
|
723
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
|
|
724
|
+
* //=> false
|
|
725
|
+
*/
|
|
726
|
+
function isSameDay(laterDate, earlierDate, options) {
|
|
727
|
+
const [dateLeft_, dateRight_] = normalizeDates(options?.in, laterDate, earlierDate);
|
|
728
|
+
return +startOfDay(dateLeft_) === +startOfDay(dateRight_);
|
|
729
|
+
}
|
|
688
730
|
// node_modules/date-fns/endOfDay.js
|
|
689
731
|
/**
|
|
690
732
|
* The {@link endOfDay} function options.
|
|
@@ -823,6 +865,37 @@ function endOfWeek(date, options) {
|
|
|
823
865
|
_date.setHours(23, 59, 59, 999);
|
|
824
866
|
return _date;
|
|
825
867
|
}
|
|
868
|
+
// node_modules/date-fns/getDaysInMonth.js
|
|
869
|
+
/**
|
|
870
|
+
* The {@link getDaysInMonth} function options.
|
|
871
|
+
*/
|
|
872
|
+
/**
|
|
873
|
+
* @name getDaysInMonth
|
|
874
|
+
* @category Month Helpers
|
|
875
|
+
* @summary Get the number of days in a month of the given date.
|
|
876
|
+
*
|
|
877
|
+
* @description
|
|
878
|
+
* Get the number of days in a month of the given date, considering the context if provided.
|
|
879
|
+
*
|
|
880
|
+
* @param date - The given date
|
|
881
|
+
* @param options - An object with options
|
|
882
|
+
*
|
|
883
|
+
* @returns The number of days in a month
|
|
884
|
+
*
|
|
885
|
+
* @example
|
|
886
|
+
* // How many days are in February 2000?
|
|
887
|
+
* const result = getDaysInMonth(new Date(2000, 1))
|
|
888
|
+
* //=> 29
|
|
889
|
+
*/
|
|
890
|
+
function getDaysInMonth(date, options) {
|
|
891
|
+
const _date = toDate(date, options?.in);
|
|
892
|
+
const year = _date.getFullYear();
|
|
893
|
+
const monthIndex = _date.getMonth();
|
|
894
|
+
const lastDayOfMonth = constructFrom(_date, 0);
|
|
895
|
+
lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
|
|
896
|
+
lastDayOfMonth.setHours(0, 0, 0, 0);
|
|
897
|
+
return lastDayOfMonth.getDate();
|
|
898
|
+
}
|
|
826
899
|
// node_modules/date-fns/parseISO.js
|
|
827
900
|
/**
|
|
828
901
|
* The {@link parseISO} function options.
|
|
@@ -1020,6 +1093,93 @@ function validateTime(hours, minutes, seconds) {
|
|
|
1020
1093
|
function validateTimezone(_hours, minutes) {
|
|
1021
1094
|
return minutes >= 0 && minutes <= 59;
|
|
1022
1095
|
}
|
|
1096
|
+
// node_modules/date-fns/setMonth.js
|
|
1097
|
+
/**
|
|
1098
|
+
* The {@link setMonth} function options.
|
|
1099
|
+
*/
|
|
1100
|
+
/**
|
|
1101
|
+
* @name setMonth
|
|
1102
|
+
* @category Month Helpers
|
|
1103
|
+
* @summary Set the month to the given date.
|
|
1104
|
+
*
|
|
1105
|
+
* @description
|
|
1106
|
+
* Set the month to the given date.
|
|
1107
|
+
*
|
|
1108
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
1109
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
1110
|
+
*
|
|
1111
|
+
* @param date - The date to be changed
|
|
1112
|
+
* @param month - The month index to set (0-11)
|
|
1113
|
+
* @param options - The options
|
|
1114
|
+
*
|
|
1115
|
+
* @returns The new date with the month set
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* // Set February to 1 September 2014:
|
|
1119
|
+
* const result = setMonth(new Date(2014, 8, 1), 1)
|
|
1120
|
+
* //=> Sat Feb 01 2014 00:00:00
|
|
1121
|
+
*/
|
|
1122
|
+
function setMonth(date, month, options) {
|
|
1123
|
+
const _date = toDate(date, options?.in);
|
|
1124
|
+
const year = _date.getFullYear();
|
|
1125
|
+
const day = _date.getDate();
|
|
1126
|
+
const midMonth = constructFrom(options?.in || date, 0);
|
|
1127
|
+
midMonth.setFullYear(year, month, 15);
|
|
1128
|
+
midMonth.setHours(0, 0, 0, 0);
|
|
1129
|
+
const daysInMonth = getDaysInMonth(midMonth);
|
|
1130
|
+
_date.setMonth(month, Math.min(day, daysInMonth));
|
|
1131
|
+
return _date;
|
|
1132
|
+
}
|
|
1133
|
+
// node_modules/date-fns/set.js
|
|
1134
|
+
/**
|
|
1135
|
+
* The {@link set} function options.
|
|
1136
|
+
*/
|
|
1137
|
+
/**
|
|
1138
|
+
* @name set
|
|
1139
|
+
* @category Common Helpers
|
|
1140
|
+
* @summary Set date values to a given date.
|
|
1141
|
+
*
|
|
1142
|
+
* @description
|
|
1143
|
+
* Set date values to a given date.
|
|
1144
|
+
*
|
|
1145
|
+
* Sets time values to date from object `values`.
|
|
1146
|
+
* A value is not set if it is undefined or null or doesn't exist in `values`.
|
|
1147
|
+
*
|
|
1148
|
+
* Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts
|
|
1149
|
+
* to use native `Date#setX` methods. If you use this function, you may not want to include the
|
|
1150
|
+
* other `setX` functions that date-fns provides if you are concerned about the bundle size.
|
|
1151
|
+
*
|
|
1152
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
1153
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
1154
|
+
*
|
|
1155
|
+
* @param date - The date to be changed
|
|
1156
|
+
* @param values - The date values to be set
|
|
1157
|
+
* @param options - The options
|
|
1158
|
+
*
|
|
1159
|
+
* @returns The new date with options set
|
|
1160
|
+
*
|
|
1161
|
+
* @example
|
|
1162
|
+
* // Transform 1 September 2014 into 20 October 2015 in a single line:
|
|
1163
|
+
* const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })
|
|
1164
|
+
* //=> Tue Oct 20 2015 00:00:00
|
|
1165
|
+
*
|
|
1166
|
+
* @example
|
|
1167
|
+
* // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:
|
|
1168
|
+
* const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })
|
|
1169
|
+
* //=> Mon Sep 01 2014 12:23:45
|
|
1170
|
+
*/
|
|
1171
|
+
function set(date, values, options) {
|
|
1172
|
+
let _date = toDate(date, options?.in);
|
|
1173
|
+
if (isNaN(+_date)) return constructFrom(options?.in || date, NaN);
|
|
1174
|
+
if (values.year != null) _date.setFullYear(values.year);
|
|
1175
|
+
if (values.month != null) _date = setMonth(_date, values.month);
|
|
1176
|
+
if (values.date != null) _date.setDate(values.date);
|
|
1177
|
+
if (values.hours != null) _date.setHours(values.hours);
|
|
1178
|
+
if (values.minutes != null) _date.setMinutes(values.minutes);
|
|
1179
|
+
if (values.seconds != null) _date.setSeconds(values.seconds);
|
|
1180
|
+
if (values.milliseconds != null) _date.setMilliseconds(values.milliseconds);
|
|
1181
|
+
return _date;
|
|
1182
|
+
}
|
|
1023
1183
|
// src/main/sessions/SessionFile.js
|
|
1024
1184
|
var SessionFile = class {
|
|
1025
1185
|
constructor(filePath) {
|
|
@@ -1252,6 +1412,8 @@ var toStrip = (rec, source, file_path, label, content) => {
|
|
|
1252
1412
|
};
|
|
1253
1413
|
var texts = (c) => (Array.isArray(c) ? c.map((p) => p?.text) : [c]).filter((t) => typeof t === "string");
|
|
1254
1414
|
var injectedTexts = (req) => (req?.messages || []).filter((m) => m?.role !== "assistant").flatMap((m) => texts(m.content));
|
|
1415
|
+
var addedTools = (req) => (req?.messages || []).flatMap((m) => Array.isArray(m?.content) ? m.content : []).filter((p) => p?.type === "tool_addition" && p.tool?.type === "tool_definition" && p.tool.definition).map((p) => p.tool.definition);
|
|
1416
|
+
var isBilled = (text) => !text.startsWith("x-anthropic-billing-header");
|
|
1255
1417
|
var RequestParser = class {
|
|
1256
1418
|
constructor() {
|
|
1257
1419
|
this.hashes = /* @__PURE__ */ new Map();
|
|
@@ -1311,7 +1473,7 @@ var RequestParser = class {
|
|
|
1311
1473
|
systemPrompt(rec) {
|
|
1312
1474
|
const sys = rec.request?.system;
|
|
1313
1475
|
if (sys == null || sys.$ref) return null;
|
|
1314
|
-
return toStrip(rec, "system", "System Prompt", "", typeof sys === "string" ? splitClaudeMd(sys).rest : sys.map((b) =>
|
|
1476
|
+
return toStrip(rec, "system", "System Prompt", "", typeof sys === "string" ? splitClaudeMd(sys).rest : sys.map((b) => b?.text ?? "").filter(isBilled).map((t) => splitClaudeMd(t).rest).join("\n\n"));
|
|
1315
1477
|
}
|
|
1316
1478
|
deferredTools(rec) {
|
|
1317
1479
|
if (this.deferred) return this.deferred;
|
|
@@ -1352,9 +1514,8 @@ var RequestParser = class {
|
|
|
1352
1514
|
};
|
|
1353
1515
|
}
|
|
1354
1516
|
systemTools(rec) {
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1357
|
-
const fresh = tools.filter((t) => t?.name && !this.seenTools.has(t.name));
|
|
1517
|
+
const listed = rec.request?.tools;
|
|
1518
|
+
const fresh = [...Array.isArray(listed) ? listed : [], ...addedTools(rec.request)].filter((t) => t?.name && !this.seenTools.has(t.name));
|
|
1358
1519
|
for (const t of fresh) this.seenTools.add(t.name);
|
|
1359
1520
|
const json = (v) => "```json\n" + JSON.stringify(v, null, 2) + "\n```";
|
|
1360
1521
|
const schema = (t) => t.input_schema ? json(t.input_schema) : "";
|
|
@@ -1362,7 +1523,8 @@ var RequestParser = class {
|
|
|
1362
1523
|
const strip = (file_path, pick) => {
|
|
1363
1524
|
const list = fresh.filter((t) => pick(t.name)).map((t) => ({
|
|
1364
1525
|
name: t.name,
|
|
1365
|
-
content: [t.description || "", schema(t)].filter(Boolean).join("\n\n") || definition(t)
|
|
1526
|
+
content: [t.description || "", schema(t)].filter(Boolean).join("\n\n") || definition(t),
|
|
1527
|
+
...t.defer_loading && { deferred: true }
|
|
1366
1528
|
}));
|
|
1367
1529
|
if (!list.length) return null;
|
|
1368
1530
|
const content = list.map((t) => [`## ${t.name}`, t.content].filter(Boolean).join("\n\n")).join("\n\n");
|
|
@@ -1799,12 +1961,6 @@ function parseMcpLog(text) {
|
|
|
1799
1961
|
return processes;
|
|
1800
1962
|
}
|
|
1801
1963
|
// src/shared/usage.js
|
|
1802
|
-
var advisorIterations = (u) => (u.iterations ?? []).filter((i) => i?.type === "advisor_message");
|
|
1803
|
-
function contextSize(u) {
|
|
1804
|
-
const last = u.iterations?.findLast((i) => i.type !== "advisor_message") ?? u;
|
|
1805
|
-
return (last.input_tokens || 0) + (last.cache_read_input_tokens || 0) + (last.cache_creation_input_tokens || 0);
|
|
1806
|
-
}
|
|
1807
|
-
// src/main/sessions/usage/buckets.js
|
|
1808
1964
|
var TOKEN_FIELDS = [
|
|
1809
1965
|
"input",
|
|
1810
1966
|
"output",
|
|
@@ -1813,6 +1969,12 @@ var TOKEN_FIELDS = [
|
|
|
1813
1969
|
"cacheCreation5m",
|
|
1814
1970
|
"cacheCreation1h"
|
|
1815
1971
|
];
|
|
1972
|
+
var advisorIterations = (u) => (u.iterations ?? []).filter((i) => i?.type === "advisor_message");
|
|
1973
|
+
function contextSize(u) {
|
|
1974
|
+
const last = u.iterations?.findLast((i) => i.type !== "advisor_message") ?? u;
|
|
1975
|
+
return (last.input_tokens || 0) + (last.cache_read_input_tokens || 0) + (last.cache_creation_input_tokens || 0);
|
|
1976
|
+
}
|
|
1977
|
+
// src/main/sessions/usage/buckets.js
|
|
1816
1978
|
var emptyBucket = () => Object.fromEntries(TOKEN_FIELDS.map((k) => [k, 0]));
|
|
1817
1979
|
var isEmpty = (bucket) => TOKEN_FIELDS.every((k) => !bucket[k]);
|
|
1818
1980
|
var tokenCount = (b) => b.input + b.output + b.cacheRead + b.cacheCreation;
|
|
@@ -2000,6 +2162,7 @@ function freshMetrics() {
|
|
|
2000
2162
|
hasScheduledTask: false,
|
|
2001
2163
|
activityPeriods: [],
|
|
2002
2164
|
costSamples: [],
|
|
2165
|
+
serverToolSamples: [],
|
|
2003
2166
|
seenMessageIds: /* @__PURE__ */ new Set()
|
|
2004
2167
|
};
|
|
2005
2168
|
}
|
|
@@ -2190,8 +2353,15 @@ var SessionParser = class {
|
|
|
2190
2353
|
if (this.pricing && this.pricing.fastMultiplier(model) == null) meta.fastPricingUnknown = true;
|
|
2191
2354
|
} else if (u.speed && meta.speed !== "fast") meta.speed = u.speed;
|
|
2192
2355
|
if (u.server_tool_use) {
|
|
2193
|
-
|
|
2194
|
-
|
|
2356
|
+
const webSearch = u.server_tool_use.web_search_requests || 0;
|
|
2357
|
+
const webFetch = u.server_tool_use.web_fetch_requests || 0;
|
|
2358
|
+
meta.serverToolUse.webSearch += webSearch;
|
|
2359
|
+
meta.serverToolUse.webFetch += webFetch;
|
|
2360
|
+
if (obj._ts != null && (webSearch || webFetch)) meta.serverToolSamples.push({
|
|
2361
|
+
end: obj._ts,
|
|
2362
|
+
webSearch,
|
|
2363
|
+
webFetch
|
|
2364
|
+
});
|
|
2195
2365
|
}
|
|
2196
2366
|
}
|
|
2197
2367
|
this._addGrowth(obj, model, fast, this._growth(msgId, usage));
|
|
@@ -2217,7 +2387,8 @@ var SessionParser = class {
|
|
|
2217
2387
|
start: prevTs != null && prevTs < obj._ts ? prevTs : obj._ts,
|
|
2218
2388
|
end: obj._ts,
|
|
2219
2389
|
cost: cost || 0,
|
|
2220
|
-
tokens
|
|
2390
|
+
tokens,
|
|
2391
|
+
usage: { ...growth }
|
|
2221
2392
|
});
|
|
2222
2393
|
}
|
|
2223
2394
|
}
|
|
@@ -2954,6 +3125,11 @@ var SessionsService = class extends EventEmitter {
|
|
|
2954
3125
|
const side = [...own.strips, ...shown(source.side)];
|
|
2955
3126
|
const compacts = [...shown(source.compacts), ...own.compacts];
|
|
2956
3127
|
if (start?.length && !loop.includes(start[0])) loop.unshift(...start);
|
|
3128
|
+
const stamped = items.map((o) => Date.parse(o.timestamp) > 0 ? o._ts : null);
|
|
3129
|
+
let prev = stamped.find((t) => t != null);
|
|
3130
|
+
items.forEach((o, i) => {
|
|
3131
|
+
o._ts = prev = stamped[i] ?? prev ?? o._ts;
|
|
3132
|
+
});
|
|
2957
3133
|
items.sort((a, b) => a._ts - b._ts);
|
|
2958
3134
|
const keys = new Set(loop.map((s) => s.hash));
|
|
2959
3135
|
const isBrought = (o) => USER_ATTACHMENTS.has(o.attachment?.type);
|
|
@@ -3326,16 +3502,21 @@ var AgentRunner = class {
|
|
|
3326
3502
|
}
|
|
3327
3503
|
return { code: 0 };
|
|
3328
3504
|
}
|
|
3329
|
-
async usage() {
|
|
3505
|
+
async usage({ behaviors = false } = {}) {
|
|
3330
3506
|
const { query } = await import("@anthropic-ai/claude-agent-sdk");
|
|
3507
|
+
const env = {
|
|
3508
|
+
...process.env,
|
|
3509
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1"
|
|
3510
|
+
};
|
|
3331
3511
|
const q = query({
|
|
3332
3512
|
prompt: (async function* () {})(),
|
|
3333
3513
|
options: {
|
|
3334
3514
|
tools: [],
|
|
3335
|
-
settingSources: []
|
|
3515
|
+
settingSources: [],
|
|
3516
|
+
env
|
|
3336
3517
|
}
|
|
3337
3518
|
});
|
|
3338
|
-
return withTimeout(Promise.all([q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors:
|
|
3519
|
+
return withTimeout(Promise.all([q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors: !behaviors }), q.accountInfo()]).then(([usage, account]) => ({
|
|
3339
3520
|
...usage,
|
|
3340
3521
|
account
|
|
3341
3522
|
})), USAGE_TIMEOUT, () => q.close());
|
|
@@ -3958,7 +4139,7 @@ var Switchers = class {
|
|
|
3958
4139
|
}
|
|
3959
4140
|
};
|
|
3960
4141
|
// src/main/services/RateLimits.js
|
|
3961
|
-
var EVERY = 6e4;
|
|
4142
|
+
var EVERY$1 = 6e4;
|
|
3962
4143
|
var toWindow = (w) => w?.utilization == null ? null : {
|
|
3963
4144
|
utilization: w.utilization,
|
|
3964
4145
|
resetsAt: w.resets_at ? Math.round(Date.parse(w.resets_at) / 6e4) * 6e4 : null
|
|
@@ -3971,6 +4152,11 @@ var toExtra = (e) => e && {
|
|
|
3971
4152
|
currency: e.currency,
|
|
3972
4153
|
decimals: e.decimal_places ?? 2
|
|
3973
4154
|
};
|
|
4155
|
+
var toShare = (shares, models) => shares?.length === 1 && models.length === 1 ? {
|
|
4156
|
+
name: models[0].display_name,
|
|
4157
|
+
used: shares[0].used_percent_of_weekly,
|
|
4158
|
+
allowance: shares[0].allowance_percent_of_weekly
|
|
4159
|
+
} : null;
|
|
3974
4160
|
var RateLimits = class {
|
|
3975
4161
|
#agentRunner;
|
|
3976
4162
|
#limits = null;
|
|
@@ -3983,25 +4169,28 @@ var RateLimits = class {
|
|
|
3983
4169
|
this.#active = true;
|
|
3984
4170
|
}
|
|
3985
4171
|
get({ ifActive = false } = {}) {
|
|
3986
|
-
if (Date.now() - this.#fetchedAt >= EVERY && (this.#active || !ifActive))
|
|
3987
|
-
this.#fetchedAt = Date.now();
|
|
3988
|
-
this.#active = false;
|
|
3989
|
-
this.#limits = this.#fetch();
|
|
3990
|
-
}
|
|
4172
|
+
if (Date.now() - this.#fetchedAt >= EVERY$1 && (this.#active || !ifActive)) this.use(this.#agentRunner.usage());
|
|
3991
4173
|
return this.#limits;
|
|
3992
4174
|
}
|
|
3993
|
-
|
|
4175
|
+
use(usage) {
|
|
4176
|
+
this.#fetchedAt = Date.now();
|
|
4177
|
+
this.#active = false;
|
|
4178
|
+
this.#limits = this.#map(usage);
|
|
4179
|
+
}
|
|
4180
|
+
async #map(usage) {
|
|
3994
4181
|
try {
|
|
3995
|
-
const { subscription_type: type, account, rate_limits: rl } = await
|
|
4182
|
+
const { subscription_type: type, account, rate_limits: rl } = await usage;
|
|
4183
|
+
const models = (rl?.model_scoped ?? []).filter((m) => m.utilization != null);
|
|
3996
4184
|
return rl && {
|
|
3997
4185
|
at: Date.now(),
|
|
3998
4186
|
plan: account?.subscriptionType?.replace(/^Claude /, "") ?? type,
|
|
3999
4187
|
fiveHour: toWindow(rl.five_hour),
|
|
4000
4188
|
sevenDay: toWindow(rl.seven_day),
|
|
4001
|
-
models:
|
|
4189
|
+
models: models.map((m) => ({
|
|
4002
4190
|
name: m.display_name,
|
|
4003
4191
|
...toWindow(m)
|
|
4004
4192
|
})),
|
|
4193
|
+
share: toShare(rl.weekly_scoped_shares, models),
|
|
4005
4194
|
sources: (rl.seven_day_breakdown?.rows ?? []).filter((r) => r.percent > 0).map((r) => ({
|
|
4006
4195
|
name: r.display_name,
|
|
4007
4196
|
pct: r.percent
|
|
@@ -4014,6 +4203,75 @@ var RateLimits = class {
|
|
|
4014
4203
|
}
|
|
4015
4204
|
}
|
|
4016
4205
|
};
|
|
4206
|
+
// src/main/services/UsageInsights.js
|
|
4207
|
+
var EVERY = 36e5;
|
|
4208
|
+
var DAY_CLOSE = {
|
|
4209
|
+
hours: 23,
|
|
4210
|
+
minutes: 55
|
|
4211
|
+
};
|
|
4212
|
+
var UsageInsights = class {
|
|
4213
|
+
#agentRunner;
|
|
4214
|
+
#file;
|
|
4215
|
+
#onScan;
|
|
4216
|
+
#insights = null;
|
|
4217
|
+
#fetchedAt = 0;
|
|
4218
|
+
#active = false;
|
|
4219
|
+
#saving = Promise.resolve();
|
|
4220
|
+
constructor(agentRunner, { file = path.join(DATA_DIR$1, "usage-insights.jsonl"), onScan } = {}) {
|
|
4221
|
+
this.#agentRunner = agentRunner;
|
|
4222
|
+
this.#file = file;
|
|
4223
|
+
this.#onScan = onScan;
|
|
4224
|
+
}
|
|
4225
|
+
start() {
|
|
4226
|
+
setInterval(() => this.tick(), 6e4);
|
|
4227
|
+
}
|
|
4228
|
+
markActive() {
|
|
4229
|
+
this.#active = true;
|
|
4230
|
+
}
|
|
4231
|
+
tick() {
|
|
4232
|
+
if (!this.#active) return;
|
|
4233
|
+
const close = set(Date.now(), DAY_CLOSE);
|
|
4234
|
+
if (Date.now() - this.#fetchedAt >= EVERY || Date.now() >= close && this.#fetchedAt < close) this.#scan();
|
|
4235
|
+
}
|
|
4236
|
+
async get({ date, granularity, force = false }) {
|
|
4237
|
+
if (force || !this.#insights) this.#scan();
|
|
4238
|
+
const { start, end } = periodBounds(date, granularity);
|
|
4239
|
+
if (Date.now() <= end) return this.#insights;
|
|
4240
|
+
await this.#saving;
|
|
4241
|
+
return (await this.#read()).findLast((s) => s.at >= start && s.at <= end) ?? null;
|
|
4242
|
+
}
|
|
4243
|
+
#scan() {
|
|
4244
|
+
const previous = this.#insights;
|
|
4245
|
+
this.#fetchedAt = Date.now();
|
|
4246
|
+
this.#active = false;
|
|
4247
|
+
const usage = this.#agentRunner.usage({ behaviors: true });
|
|
4248
|
+
this.#onScan?.(usage);
|
|
4249
|
+
this.#insights = usage.then(({ behaviors }) => {
|
|
4250
|
+
if (!behaviors) return previous;
|
|
4251
|
+
const snapshot = {
|
|
4252
|
+
at: Date.now(),
|
|
4253
|
+
...behaviors
|
|
4254
|
+
};
|
|
4255
|
+
this.#saving = this.#saving.then(() => this.#save(snapshot)).catch((err) => console.warn("[usage-insights] not saved:", err.message));
|
|
4256
|
+
return snapshot;
|
|
4257
|
+
}, (err) => {
|
|
4258
|
+
console.warn("[usage-insights]", err.message);
|
|
4259
|
+
return previous;
|
|
4260
|
+
});
|
|
4261
|
+
}
|
|
4262
|
+
async #save(snapshot) {
|
|
4263
|
+
const kept = [...(await this.#read()).filter((s) => !isSameDay(s.at, snapshot.at)), snapshot];
|
|
4264
|
+
await fsp.mkdir(path.dirname(this.#file), { recursive: true });
|
|
4265
|
+
await (0, import_lib$1.default)(this.#file, kept.map((s) => `${JSON.stringify(s)}\n`).join(""));
|
|
4266
|
+
}
|
|
4267
|
+
async #read() {
|
|
4268
|
+
try {
|
|
4269
|
+
return (await fsp.readFile(this.#file, "utf8")).split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
4270
|
+
} catch {
|
|
4271
|
+
return [];
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
};
|
|
4017
4275
|
// node_modules/ansi-styles/index.js
|
|
4018
4276
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
4019
4277
|
var ANSI_UNDERLINE_OFFSET = 20;
|
|
@@ -14192,7 +14450,7 @@ var MainWindow = class {
|
|
|
14192
14450
|
// src/main/updater.js
|
|
14193
14451
|
var updater = new NpmUpdater({
|
|
14194
14452
|
name: "claude-discover",
|
|
14195
|
-
version: "1.
|
|
14453
|
+
version: "1.11.0",
|
|
14196
14454
|
bin: { "claude-discover": "bin/claude-discover.mjs" }
|
|
14197
14455
|
}, { dev: false });
|
|
14198
14456
|
// src/main/Application.js
|
|
@@ -14204,14 +14462,19 @@ var Application = class {
|
|
|
14204
14462
|
this.workHours = new WorkHours();
|
|
14205
14463
|
this.sessionsService = new SessionsService();
|
|
14206
14464
|
this.rateLimits = new RateLimits(this.agentRunner);
|
|
14465
|
+
this.usageInsights = new UsageInsights(this.agentRunner, { onScan: (usage) => this.rateLimits.use(usage) });
|
|
14207
14466
|
this.switchers = new Switchers({ restart: () => this.restart() });
|
|
14208
14467
|
}
|
|
14209
14468
|
start() {
|
|
14210
|
-
const { deepLink, win, agentRunner, workHours, sessionsService, rateLimits, switchers } = this;
|
|
14469
|
+
const { deepLink, win, agentRunner, workHours, sessionsService, rateLimits, usageInsights, switchers } = this;
|
|
14211
14470
|
Menu.setApplicationMenu(this.#buildMenu());
|
|
14212
14471
|
sessionsService.on("update", (update) => win.send("sessions:update", update));
|
|
14213
14472
|
sessionsService.on("progress", (p) => win.send("sessions:scan-progress", p));
|
|
14214
|
-
sessionsService.on("activity", () =>
|
|
14473
|
+
sessionsService.on("activity", () => {
|
|
14474
|
+
rateLimits.markActive();
|
|
14475
|
+
usageInsights.markActive();
|
|
14476
|
+
});
|
|
14477
|
+
usageInsights.start();
|
|
14215
14478
|
deepLink?.on("open", (target) => {
|
|
14216
14479
|
win.focus();
|
|
14217
14480
|
win.send("deeplink:open-session", target);
|
|
@@ -14230,6 +14493,7 @@ var Application = class {
|
|
|
14230
14493
|
ipcMain.handle("auto-update:check", () => updater.check());
|
|
14231
14494
|
ipcMain.handle("auto-update:install", () => updater.install());
|
|
14232
14495
|
ipcMain.handle("rate-limits:get", (_e, opts) => rateLimits.get(opts));
|
|
14496
|
+
ipcMain.handle("usage-insights:get", (_e, opts) => usageInsights.get(opts));
|
|
14233
14497
|
ipcMain.handle("agent:run", (e, run) => agentRunner.run(run, e.sender));
|
|
14234
14498
|
ipcMain.handle("shell:open-link", (_e, href, baseFile) => openLinkSafely(href, baseFile));
|
|
14235
14499
|
ipcMain.handle("deeplink:take-pending", () => deepLink?.takePending() ?? null);
|
package/out/preload/preload.cjs
CHANGED
|
@@ -29,6 +29,7 @@ electron.contextBridge.exposeInMainWorld("api", {
|
|
|
29
29
|
checkUpdate: () => electron.ipcRenderer.invoke("auto-update:check"),
|
|
30
30
|
installUpdate: () => electron.ipcRenderer.invoke("auto-update:install"),
|
|
31
31
|
getRateLimits: (opts) => electron.ipcRenderer.invoke("rate-limits:get", opts),
|
|
32
|
+
getUsageInsights: (opts) => electron.ipcRenderer.invoke("usage-insights:get", opts),
|
|
32
33
|
openLink: (href, baseFile) => electron.ipcRenderer.invoke("shell:open-link", href, baseFile),
|
|
33
34
|
onFindActive: subscribe("find:active"),
|
|
34
35
|
findClose: () => electron.ipcRenderer.send("find:close"),
|