fleetlens 1.0.13 → 1.0.14
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/app/apps/web/.next/BUILD_ID +1 -1
- package/app/apps/web/.next/build-manifest.json +3 -3
- package/app/apps/web/.next/prerender-manifest.json +3 -3
- package/app/apps/web/.next/server/app/_global-error.html +1 -1
- package/app/apps/web/.next/server/app/_global-error.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/agent/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/print/[key]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/team/onboarding/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__02.51sr._.js +1 -1
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0zyh554._.js +1 -1
- package/app/apps/web/.next/server/chunks/packages_parser_dist_06d9se1._.js +1 -1
- package/app/apps/web/.next/server/chunks/packages_parser_dist_10ihc3~._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0s~wd1k._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/_0k8yioi._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_0epqfet._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_components_0x014hn._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0n7_p1d._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_0mx_509._.js +1 -1
- package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
- package/app/apps/web/.next/server/middleware-manifest.json +5 -5
- package/app/apps/web/.next/server/pages/500.html +1 -1
- package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
- package/app/apps/web/.next/static/chunks/00_9zw_tjem-o.js +14 -0
- package/app/apps/web/.next/static/chunks/{0r~~~j3kmv7s_.js → 08os0c_3cdpqn.js} +1 -1
- package/app/apps/web/.next/static/chunks/0f9bdjq4n1ykp.js +1 -0
- package/app/apps/web/app/usage/page.tsx +264 -1
- package/app/apps/web/lib/changelog-data.generated.ts +1 -1
- package/app/apps/web/lib/usage-data.ts +1 -1
- package/app/apps/web/lib/usage-display.test.ts +15 -0
- package/app/apps/web/lib/usage-display.ts +22 -3
- package/app/apps/web/package.json +1 -1
- package/app/apps/web/tsconfig.tsbuildinfo +1 -1
- package/dist/daemon-worker.js +358 -92
- package/dist/index.js +564 -155
- package/menubar/Fleetlens.app/Contents/Info.plist +2 -2
- package/menubar/Fleetlens.app/Contents/MacOS/FleetlensMenubar +0 -0
- package/menubar/Fleetlens.app/Contents/Resources/command-code.svg +4 -0
- package/menubar/Fleetlens.app/Contents/_CodeSignature/CodeResources +11 -0
- package/package.json +1 -1
- package/app/apps/web/.next/static/chunks/0lcq6isl3n79m.js +0 -1
- package/app/apps/web/.next/static/chunks/0livk1wjx5m4o.js +0 -14
- /package/app/apps/web/.next/static/{h9pB-Efqh5oayfi0_lGfY → FOCI6RnIt_wZ2j2ZEqW5_}/_buildManifest.js +0 -0
- /package/app/apps/web/.next/static/{h9pB-Efqh5oayfi0_lGfY → FOCI6RnIt_wZ2j2ZEqW5_}/_clientMiddlewareManifest.js +0 -0
- /package/app/apps/web/.next/static/{h9pB-Efqh5oayfi0_lGfY → FOCI6RnIt_wZ2j2ZEqW5_}/_ssgManifest.js +0 -0
package/dist/daemon-worker.js
CHANGED
|
@@ -607,7 +607,7 @@ function getAgentMetadata(kind) {
|
|
|
607
607
|
function isAgentKind(s) {
|
|
608
608
|
return typeof s === "string" && KNOWN_AGENT_KINDS.has(s);
|
|
609
609
|
}
|
|
610
|
-
var CLAUDE_CODE_METADATA, CODEX_METADATA, COPILOT_METADATA, GEMINI_METADATA, ANTIGRAVITY_METADATA, COWORK_METADATA, ZAI_METADATA, GROK_METADATA, agentMetadata, KNOWN_AGENT_KINDS;
|
|
610
|
+
var CLAUDE_CODE_METADATA, CODEX_METADATA, COPILOT_METADATA, GEMINI_METADATA, ANTIGRAVITY_METADATA, COWORK_METADATA, ZAI_METADATA, GROK_METADATA, COMMAND_CODE_METADATA, agentMetadata, KNOWN_AGENT_KINDS;
|
|
611
611
|
var init_agent_metadata = __esm({
|
|
612
612
|
"../parser/dist/agent-metadata.js"() {
|
|
613
613
|
"use strict";
|
|
@@ -668,6 +668,14 @@ var init_agent_metadata = __esm({
|
|
|
668
668
|
accentColor: "rgb(100, 116, 139)",
|
|
669
669
|
iconChar: "\u25C8"
|
|
670
670
|
};
|
|
671
|
+
COMMAND_CODE_METADATA = {
|
|
672
|
+
kind: "command-code",
|
|
673
|
+
displayName: "Command Code",
|
|
674
|
+
shortLabel: "Cmd",
|
|
675
|
+
// Lime — distinct from Codex teal and Claude terracotta.
|
|
676
|
+
accentColor: "rgb(132, 204, 22)",
|
|
677
|
+
iconChar: ">"
|
|
678
|
+
};
|
|
671
679
|
agentMetadata = [
|
|
672
680
|
CLAUDE_CODE_METADATA,
|
|
673
681
|
CODEX_METADATA,
|
|
@@ -676,7 +684,8 @@ var init_agent_metadata = __esm({
|
|
|
676
684
|
ANTIGRAVITY_METADATA,
|
|
677
685
|
COWORK_METADATA,
|
|
678
686
|
ZAI_METADATA,
|
|
679
|
-
GROK_METADATA
|
|
687
|
+
GROK_METADATA,
|
|
688
|
+
COMMAND_CODE_METADATA
|
|
680
689
|
];
|
|
681
690
|
KNOWN_AGENT_KINDS = new Set(agentMetadata.map((m) => m.kind));
|
|
682
691
|
}
|
|
@@ -1533,11 +1542,11 @@ function defaultBranch(commonDir) {
|
|
|
1533
1542
|
}
|
|
1534
1543
|
return void 0;
|
|
1535
1544
|
}
|
|
1536
|
-
function readGitFolder(
|
|
1537
|
-
if (!existsSync(
|
|
1545
|
+
function readGitFolder(path12) {
|
|
1546
|
+
if (!existsSync(path12))
|
|
1538
1547
|
return { exists: false, isWorktree: false };
|
|
1539
1548
|
try {
|
|
1540
|
-
const git = nearestDotGit(realpathOrSelf(
|
|
1549
|
+
const git = nearestDotGit(realpathOrSelf(path12));
|
|
1541
1550
|
if (!git)
|
|
1542
1551
|
return { exists: true, isWorktree: false };
|
|
1543
1552
|
const projectRoot = projectRootFromCommonDir(git.commonDir);
|
|
@@ -6201,9 +6210,9 @@ var init_fs = __esm({
|
|
|
6201
6210
|
import {
|
|
6202
6211
|
appendFileSync as appendFileSync2,
|
|
6203
6212
|
mkdirSync as mkdirSync3,
|
|
6204
|
-
readFileSync as
|
|
6213
|
+
readFileSync as readFileSync9,
|
|
6205
6214
|
writeFileSync as writeFileSync4,
|
|
6206
|
-
existsSync as
|
|
6215
|
+
existsSync as existsSync8,
|
|
6207
6216
|
openSync,
|
|
6208
6217
|
readSync,
|
|
6209
6218
|
fstatSync,
|
|
@@ -6215,8 +6224,8 @@ function appendSnapshot(filePath, snapshot) {
|
|
|
6215
6224
|
appendFileSync2(filePath, JSON.stringify(snapshot) + "\n", "utf8");
|
|
6216
6225
|
}
|
|
6217
6226
|
function readSnapshots(filePath) {
|
|
6218
|
-
if (!
|
|
6219
|
-
const content =
|
|
6227
|
+
if (!existsSync8(filePath)) return [];
|
|
6228
|
+
const content = readFileSync9(filePath, "utf8");
|
|
6220
6229
|
const snapshots = [];
|
|
6221
6230
|
for (const line of content.split("\n")) {
|
|
6222
6231
|
if (!line.trim()) continue;
|
|
@@ -6228,8 +6237,8 @@ function readSnapshots(filePath) {
|
|
|
6228
6237
|
return snapshots;
|
|
6229
6238
|
}
|
|
6230
6239
|
function pruneAgent(filePath, agent) {
|
|
6231
|
-
if (!
|
|
6232
|
-
const kept =
|
|
6240
|
+
if (!existsSync8(filePath)) return;
|
|
6241
|
+
const kept = readFileSync9(filePath, "utf8").split("\n").filter((line) => {
|
|
6233
6242
|
if (!line.trim()) return false;
|
|
6234
6243
|
try {
|
|
6235
6244
|
return JSON.parse(line).agent !== agent;
|
|
@@ -6665,6 +6674,7 @@ __export(dist_exports, {
|
|
|
6665
6674
|
ANTIGRAVITY_METADATA: () => ANTIGRAVITY_METADATA,
|
|
6666
6675
|
CLAUDE_CODE_METADATA: () => CLAUDE_CODE_METADATA,
|
|
6667
6676
|
CODEX_METADATA: () => CODEX_METADATA,
|
|
6677
|
+
COMMAND_CODE_METADATA: () => COMMAND_CODE_METADATA,
|
|
6668
6678
|
COPILOT_METADATA: () => COPILOT_METADATA,
|
|
6669
6679
|
COWORK_METADATA: () => COWORK_METADATA,
|
|
6670
6680
|
GEMINI_METADATA: () => GEMINI_METADATA,
|
|
@@ -6742,7 +6752,7 @@ __export(file_probe_exports, {
|
|
|
6742
6752
|
probeArtifactSignals: () => probeArtifactSignals
|
|
6743
6753
|
});
|
|
6744
6754
|
import { createHash } from "node:crypto";
|
|
6745
|
-
import { existsSync as
|
|
6755
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
|
|
6746
6756
|
import { homedir as homedir3 } from "node:os";
|
|
6747
6757
|
import { join as join9, relative, resolve as resolve3, sep } from "node:path";
|
|
6748
6758
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
@@ -6752,15 +6762,15 @@ function pathHash(relPath) {
|
|
|
6752
6762
|
function defaultScanRoots(extraRoots = []) {
|
|
6753
6763
|
const roots = [];
|
|
6754
6764
|
const home = join9(homedir3(), ".claude");
|
|
6755
|
-
if (
|
|
6765
|
+
if (existsSync13(home)) roots.push({ root: home, label: "user" });
|
|
6756
6766
|
for (const e of extraRoots) {
|
|
6757
6767
|
const r = resolve3(e, ".claude");
|
|
6758
|
-
if (
|
|
6768
|
+
if (existsSync13(r) && r !== home) roots.push({ root: r, label: "project" });
|
|
6759
6769
|
}
|
|
6760
6770
|
return roots;
|
|
6761
6771
|
}
|
|
6762
6772
|
function listMarkdownFiles(dir) {
|
|
6763
|
-
if (!
|
|
6773
|
+
if (!existsSync13(dir)) return [];
|
|
6764
6774
|
const out = [];
|
|
6765
6775
|
let entries;
|
|
6766
6776
|
try {
|
|
@@ -6830,7 +6840,7 @@ function scanAuthored(roots, subdir, day) {
|
|
|
6830
6840
|
const out = [];
|
|
6831
6841
|
for (const r of roots) {
|
|
6832
6842
|
const dir = join9(r.root, subdir);
|
|
6833
|
-
if (!
|
|
6843
|
+
if (!existsSync13(dir)) continue;
|
|
6834
6844
|
for (const f of listMarkdownFiles(dir)) {
|
|
6835
6845
|
const firstSeen = firstSeenDateOf(f);
|
|
6836
6846
|
if (firstSeen !== day) continue;
|
|
@@ -6844,7 +6854,7 @@ function scanEdited(roots, day) {
|
|
|
6844
6854
|
const out = [];
|
|
6845
6855
|
for (const r of roots) {
|
|
6846
6856
|
const dir = join9(r.root, "skills");
|
|
6847
|
-
if (!
|
|
6857
|
+
if (!existsSync13(dir)) continue;
|
|
6848
6858
|
for (const f of listMarkdownFiles(dir)) {
|
|
6849
6859
|
const firstSeen = firstSeenDateOf(f);
|
|
6850
6860
|
if (firstSeen === day) continue;
|
|
@@ -6867,10 +6877,10 @@ function claudemdLineDelta(extraRoots, authorEmail, day) {
|
|
|
6867
6877
|
const candidates = [];
|
|
6868
6878
|
for (const e of extraRoots) {
|
|
6869
6879
|
const f = resolve3(e, "CLAUDE.md");
|
|
6870
|
-
if (
|
|
6880
|
+
if (existsSync13(f)) candidates.push(f);
|
|
6871
6881
|
}
|
|
6872
6882
|
const homeClaudeMd = join9(homedir3(), "CLAUDE.md");
|
|
6873
|
-
if (
|
|
6883
|
+
if (existsSync13(homeClaudeMd)) candidates.push(homeClaudeMd);
|
|
6874
6884
|
for (const file of candidates) {
|
|
6875
6885
|
try {
|
|
6876
6886
|
const out = execFileSync2(
|
|
@@ -6926,7 +6936,7 @@ var init_file_probe = __esm({
|
|
|
6926
6936
|
});
|
|
6927
6937
|
|
|
6928
6938
|
// src/pid.ts
|
|
6929
|
-
import { readFileSync as
|
|
6939
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, unlinkSync as unlinkSync5 } from "node:fs";
|
|
6930
6940
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
6931
6941
|
import { dirname as dirname13 } from "node:path";
|
|
6932
6942
|
function writePid(filePath, pid, port, version) {
|
|
@@ -6940,7 +6950,7 @@ function writePid(filePath, pid, port, version) {
|
|
|
6940
6950
|
}
|
|
6941
6951
|
function readPid(filePath) {
|
|
6942
6952
|
try {
|
|
6943
|
-
const content =
|
|
6953
|
+
const content = readFileSync22(filePath, "utf8").trim();
|
|
6944
6954
|
const [pidStr, portStr, versionStr] = content.split(":");
|
|
6945
6955
|
const pid = parseInt(pidStr, 10);
|
|
6946
6956
|
if (Number.isNaN(pid)) return null;
|
|
@@ -6996,7 +7006,7 @@ var init_pid = __esm({
|
|
|
6996
7006
|
import { spawn as spawn3 } from "node:child_process";
|
|
6997
7007
|
import { join as join14, dirname as dirname14 } from "node:path";
|
|
6998
7008
|
import { fileURLToPath } from "node:url";
|
|
6999
|
-
import { existsSync as
|
|
7009
|
+
import { existsSync as existsSync21, realpathSync as realpathSync3, readFileSync as readFileSync23 } from "node:fs";
|
|
7000
7010
|
import { homedir as homedir7 } from "node:os";
|
|
7001
7011
|
function appDir() {
|
|
7002
7012
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
@@ -7013,10 +7023,10 @@ function cliBinRealPath() {
|
|
|
7013
7023
|
function onDiskVersion() {
|
|
7014
7024
|
try {
|
|
7015
7025
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
7016
|
-
const pkg = JSON.parse(
|
|
7017
|
-
return pkg.version ?? "1.0.
|
|
7026
|
+
const pkg = JSON.parse(readFileSync23(join14(here, "..", "package.json"), "utf8"));
|
|
7027
|
+
return pkg.version ?? "1.0.14";
|
|
7018
7028
|
} catch {
|
|
7019
|
-
return "1.0.
|
|
7029
|
+
return "1.0.14";
|
|
7020
7030
|
}
|
|
7021
7031
|
}
|
|
7022
7032
|
function getServerStatus() {
|
|
@@ -7030,7 +7040,7 @@ function getServerStatus() {
|
|
|
7030
7040
|
async function startServer(opts = {}) {
|
|
7031
7041
|
const port = opts.port ?? (parseInt(process.env.CCLENS_PORT ?? "", 10) || DEFAULT_PORT);
|
|
7032
7042
|
const serverJs = join14(appDir(), "server.js");
|
|
7033
|
-
if (!
|
|
7043
|
+
if (!existsSync21(serverJs)) {
|
|
7034
7044
|
throw new Error(`Server not found at ${serverJs}. Reinstall with: npm install -g fleetlens`);
|
|
7035
7045
|
}
|
|
7036
7046
|
const portInUse = await checkPort(port);
|
|
@@ -7120,7 +7130,7 @@ var init_server = __esm({
|
|
|
7120
7130
|
|
|
7121
7131
|
// src/daemon-worker.ts
|
|
7122
7132
|
import { spawn as spawn4 } from "node:child_process";
|
|
7123
|
-
import { closeSync as closeSync2, existsSync as
|
|
7133
|
+
import { closeSync as closeSync2, existsSync as existsSync22, mkdirSync as mkdirSync15, openSync as openSync2, readFileSync as readFileSync24, writeFileSync as writeFileSync16 } from "node:fs";
|
|
7124
7134
|
import { dirname as dirname15, join as join15 } from "node:path";
|
|
7125
7135
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7126
7136
|
|
|
@@ -7152,9 +7162,9 @@ function readFromCredentialsFile() {
|
|
|
7152
7162
|
join(homedir(), ".claude", ".credentials.json"),
|
|
7153
7163
|
join(homedir(), ".config", "claude", "credentials.json")
|
|
7154
7164
|
];
|
|
7155
|
-
for (const
|
|
7165
|
+
for (const path12 of candidates) {
|
|
7156
7166
|
try {
|
|
7157
|
-
const blob = readFileSync(
|
|
7167
|
+
const blob = readFileSync(path12, "utf8");
|
|
7158
7168
|
const creds = extractCredentials(blob);
|
|
7159
7169
|
if (creds) return creds;
|
|
7160
7170
|
} catch {
|
|
@@ -8060,6 +8070,248 @@ async function fetchCopilotUsage() {
|
|
|
8060
8070
|
}
|
|
8061
8071
|
}
|
|
8062
8072
|
|
|
8073
|
+
// src/usage/command-code.ts
|
|
8074
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
8075
|
+
import os11 from "node:os";
|
|
8076
|
+
import path11 from "node:path";
|
|
8077
|
+
var DEFAULT_API_BASE = "https://api.commandcode.ai";
|
|
8078
|
+
var CREDITS_PATH = "/alpha/billing/credits";
|
|
8079
|
+
var SUBSCRIPTIONS_PATH = "/alpha/billing/subscriptions";
|
|
8080
|
+
var PLAN_NAMES = {
|
|
8081
|
+
"individual-go": "Go",
|
|
8082
|
+
"individual-goat": "GOAT",
|
|
8083
|
+
"individual-pro": "Pro",
|
|
8084
|
+
"individual-pro-v1": "Pro",
|
|
8085
|
+
"individual-provider": "Provider",
|
|
8086
|
+
"individual-max": "Max",
|
|
8087
|
+
"individual-ultra": "Ultra",
|
|
8088
|
+
"teams-pro": "Teams Pro"
|
|
8089
|
+
};
|
|
8090
|
+
var PLAN_CREDITS = {
|
|
8091
|
+
"individual-go": 10,
|
|
8092
|
+
"individual-goat": 70,
|
|
8093
|
+
"individual-pro": 30,
|
|
8094
|
+
"individual-pro-v1": 80,
|
|
8095
|
+
"individual-provider": 15,
|
|
8096
|
+
"individual-max": 150,
|
|
8097
|
+
"individual-ultra": 300,
|
|
8098
|
+
"teams-pro": 40
|
|
8099
|
+
};
|
|
8100
|
+
var CommandCodeApiError = class extends Error {
|
|
8101
|
+
constructor(message, code) {
|
|
8102
|
+
super(message);
|
|
8103
|
+
this.code = code;
|
|
8104
|
+
}
|
|
8105
|
+
};
|
|
8106
|
+
function commandCodeHome() {
|
|
8107
|
+
return process.env.COMMANDCODE_HOME || path11.join(os11.homedir(), ".commandcode");
|
|
8108
|
+
}
|
|
8109
|
+
function authPath3() {
|
|
8110
|
+
return path11.join(commandCodeHome(), "auth.json");
|
|
8111
|
+
}
|
|
8112
|
+
function loadCommandCodeApiKey() {
|
|
8113
|
+
const p = authPath3();
|
|
8114
|
+
if (!existsSync7(p)) {
|
|
8115
|
+
throw new CommandCodeApiError("Command Code not logged in. Run `cmd login`.", "no_auth");
|
|
8116
|
+
}
|
|
8117
|
+
let raw;
|
|
8118
|
+
try {
|
|
8119
|
+
raw = JSON.parse(readFileSync8(p, "utf8"));
|
|
8120
|
+
} catch {
|
|
8121
|
+
throw new CommandCodeApiError("Command Code auth.json is unreadable. Run `cmd login`.", "no_auth");
|
|
8122
|
+
}
|
|
8123
|
+
const key = typeof raw.apiKey === "string" ? raw.apiKey.trim() : "";
|
|
8124
|
+
if (!key) {
|
|
8125
|
+
throw new CommandCodeApiError("Command Code auth has no API key. Run `cmd login`.", "no_auth");
|
|
8126
|
+
}
|
|
8127
|
+
return key;
|
|
8128
|
+
}
|
|
8129
|
+
function apiBase() {
|
|
8130
|
+
const custom2 = process.env.COMMANDCODE_API_URL?.trim();
|
|
8131
|
+
return custom2 && custom2.length > 0 ? custom2.replace(/\/$/, "") : DEFAULT_API_BASE;
|
|
8132
|
+
}
|
|
8133
|
+
function authHeaders3(key) {
|
|
8134
|
+
return {
|
|
8135
|
+
Authorization: `Bearer ${key}`,
|
|
8136
|
+
Accept: "application/json",
|
|
8137
|
+
"User-Agent": "fleetlens"
|
|
8138
|
+
};
|
|
8139
|
+
}
|
|
8140
|
+
function normalizePlanKey(planId) {
|
|
8141
|
+
return planId.trim().toLowerCase().replace(/_/g, "-");
|
|
8142
|
+
}
|
|
8143
|
+
function matchPlanKey(planId) {
|
|
8144
|
+
const key = normalizePlanKey(planId);
|
|
8145
|
+
if (PLAN_NAMES[key] || PLAN_CREDITS[key] !== void 0) return key;
|
|
8146
|
+
return Object.keys(PLAN_NAMES).sort((a, b) => b.length - a.length).find((p) => key.startsWith(p)) ?? null;
|
|
8147
|
+
}
|
|
8148
|
+
function planLabelFromId(planId) {
|
|
8149
|
+
if (typeof planId !== "string" || !planId.trim()) return null;
|
|
8150
|
+
const key = matchPlanKey(planId);
|
|
8151
|
+
return key ? PLAN_NAMES[key] ?? planId.trim() : planId.trim();
|
|
8152
|
+
}
|
|
8153
|
+
function planMonthlyCredits(planId) {
|
|
8154
|
+
if (typeof planId !== "string" || !planId.trim()) return null;
|
|
8155
|
+
const key = matchPlanKey(planId);
|
|
8156
|
+
if (!key) return null;
|
|
8157
|
+
const n = PLAN_CREDITS[key];
|
|
8158
|
+
return typeof n === "number" ? n : null;
|
|
8159
|
+
}
|
|
8160
|
+
function asCredit(raw) {
|
|
8161
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return null;
|
|
8162
|
+
return raw;
|
|
8163
|
+
}
|
|
8164
|
+
function roundCredits(n) {
|
|
8165
|
+
return Math.round(n * 100) / 100;
|
|
8166
|
+
}
|
|
8167
|
+
function isoFromUnknown(raw) {
|
|
8168
|
+
if (typeof raw !== "string" || !raw.trim()) return null;
|
|
8169
|
+
const ms = Date.parse(raw);
|
|
8170
|
+
return Number.isFinite(ms) ? new Date(ms).toISOString() : null;
|
|
8171
|
+
}
|
|
8172
|
+
function parseCommandCodeCredits(body) {
|
|
8173
|
+
if (!body || typeof body !== "object") {
|
|
8174
|
+
throw new CommandCodeApiError("Command Code credits response missing body", "parse");
|
|
8175
|
+
}
|
|
8176
|
+
const credits = body.credits;
|
|
8177
|
+
if (!credits || typeof credits !== "object") {
|
|
8178
|
+
throw new CommandCodeApiError("Command Code credits response missing credits", "parse");
|
|
8179
|
+
}
|
|
8180
|
+
const c = credits;
|
|
8181
|
+
return {
|
|
8182
|
+
remaining: asCredit(c.monthlyCredits),
|
|
8183
|
+
purchased: asCredit(c.purchasedCredits) ?? 0,
|
|
8184
|
+
free: asCredit(c.freeCredits) ?? 0,
|
|
8185
|
+
planId: typeof c.planId === "string" && c.planId.trim() ? c.planId.trim() : null
|
|
8186
|
+
};
|
|
8187
|
+
}
|
|
8188
|
+
function parseCommandCodeWindow(raw) {
|
|
8189
|
+
if (!raw || typeof raw !== "object") {
|
|
8190
|
+
return { utilization: null, resets_at: null };
|
|
8191
|
+
}
|
|
8192
|
+
const w = raw;
|
|
8193
|
+
const used = Number(w.used);
|
|
8194
|
+
const cap = Number(w.cap);
|
|
8195
|
+
let utilization = null;
|
|
8196
|
+
if (Number.isFinite(used) && Number.isFinite(cap) && cap > 0) {
|
|
8197
|
+
utilization = Math.min(100, Math.max(0, used / cap * 100));
|
|
8198
|
+
}
|
|
8199
|
+
let resets_at = null;
|
|
8200
|
+
const resetAt = Number(w.resetAt);
|
|
8201
|
+
if (Number.isFinite(resetAt) && resetAt > 0) {
|
|
8202
|
+
const iso = new Date(resetAt).toISOString();
|
|
8203
|
+
if (!Number.isNaN(Date.parse(iso))) resets_at = iso;
|
|
8204
|
+
}
|
|
8205
|
+
return { utilization, resets_at };
|
|
8206
|
+
}
|
|
8207
|
+
function parseCommandCodeWindows(body) {
|
|
8208
|
+
const empty = { utilization: null, resets_at: null };
|
|
8209
|
+
if (!body || typeof body !== "object") return { five_hour: empty, seven_day: empty };
|
|
8210
|
+
const limits = body.windowLimits;
|
|
8211
|
+
if (!limits || typeof limits !== "object") return { five_hour: empty, seven_day: empty };
|
|
8212
|
+
const l = limits;
|
|
8213
|
+
return {
|
|
8214
|
+
five_hour: parseCommandCodeWindow(l.fiveHour),
|
|
8215
|
+
seven_day: parseCommandCodeWindow(l.weekly)
|
|
8216
|
+
};
|
|
8217
|
+
}
|
|
8218
|
+
function parseCommandCodeSubscription(body) {
|
|
8219
|
+
if (!body || typeof body !== "object") {
|
|
8220
|
+
return { plan_type: null, planId: null, currentPeriodEnd: null };
|
|
8221
|
+
}
|
|
8222
|
+
const data = body.data;
|
|
8223
|
+
const planId = typeof data?.planId === "string" && data.planId.trim() ? data.planId.trim() : null;
|
|
8224
|
+
return {
|
|
8225
|
+
plan_type: planLabelFromId(planId),
|
|
8226
|
+
planId,
|
|
8227
|
+
currentPeriodEnd: isoFromUnknown(data?.currentPeriodEnd)
|
|
8228
|
+
};
|
|
8229
|
+
}
|
|
8230
|
+
function parseCommandCodeMonthly(opts) {
|
|
8231
|
+
const planId = opts.subscription.planId ?? opts.credits.planId;
|
|
8232
|
+
const limit = planMonthlyCredits(planId);
|
|
8233
|
+
const remaining = opts.credits.remaining;
|
|
8234
|
+
let used = null;
|
|
8235
|
+
let utilization = null;
|
|
8236
|
+
if (limit != null && limit > 0 && remaining != null) {
|
|
8237
|
+
used = roundCredits(Math.max(0, limit - remaining));
|
|
8238
|
+
utilization = Math.min(100, Math.max(0, used / limit * 100));
|
|
8239
|
+
}
|
|
8240
|
+
return {
|
|
8241
|
+
monthly: {
|
|
8242
|
+
utilization,
|
|
8243
|
+
resets_at: opts.subscription.currentPeriodEnd
|
|
8244
|
+
},
|
|
8245
|
+
monthly_quota: {
|
|
8246
|
+
used,
|
|
8247
|
+
limit,
|
|
8248
|
+
remaining: remaining == null ? null : roundCredits(Math.max(0, remaining)),
|
|
8249
|
+
unit: "credits",
|
|
8250
|
+
unlimited: false
|
|
8251
|
+
},
|
|
8252
|
+
plan_type: opts.subscription.plan_type ?? planLabelFromId(planId)
|
|
8253
|
+
};
|
|
8254
|
+
}
|
|
8255
|
+
async function fetchJson2(url, key) {
|
|
8256
|
+
let res;
|
|
8257
|
+
try {
|
|
8258
|
+
res = await fetch(url, { headers: authHeaders3(key) });
|
|
8259
|
+
} catch (err) {
|
|
8260
|
+
throw new CommandCodeApiError(
|
|
8261
|
+
`Network error reaching Command Code billing: ${err.message}`,
|
|
8262
|
+
"network"
|
|
8263
|
+
);
|
|
8264
|
+
}
|
|
8265
|
+
let body = null;
|
|
8266
|
+
try {
|
|
8267
|
+
body = await res.json();
|
|
8268
|
+
} catch {
|
|
8269
|
+
}
|
|
8270
|
+
return { status: res.status, body };
|
|
8271
|
+
}
|
|
8272
|
+
async function fetchCommandCodeUsage() {
|
|
8273
|
+
const key = loadCommandCodeApiKey();
|
|
8274
|
+
const base = apiBase();
|
|
8275
|
+
const creditsRes = await fetchJson2(`${base}${CREDITS_PATH}`, key);
|
|
8276
|
+
if (creditsRes.status === 401 || creditsRes.status === 403) {
|
|
8277
|
+
throw new CommandCodeApiError(
|
|
8278
|
+
`Command Code credits returned HTTP ${creditsRes.status}`,
|
|
8279
|
+
"no_auth"
|
|
8280
|
+
);
|
|
8281
|
+
}
|
|
8282
|
+
if (creditsRes.status < 200 || creditsRes.status >= 300) {
|
|
8283
|
+
throw new CommandCodeApiError(
|
|
8284
|
+
`Command Code credits returned HTTP ${creditsRes.status}`,
|
|
8285
|
+
"http"
|
|
8286
|
+
);
|
|
8287
|
+
}
|
|
8288
|
+
const credits = parseCommandCodeCredits(creditsRes.body);
|
|
8289
|
+
const windows = parseCommandCodeWindows(creditsRes.body);
|
|
8290
|
+
let subscription = parseCommandCodeSubscription(null);
|
|
8291
|
+
try {
|
|
8292
|
+
const subRes = await fetchJson2(`${base}${SUBSCRIPTIONS_PATH}`, key);
|
|
8293
|
+
if (subRes.status >= 200 && subRes.status < 300) {
|
|
8294
|
+
subscription = parseCommandCodeSubscription(subRes.body);
|
|
8295
|
+
}
|
|
8296
|
+
} catch {
|
|
8297
|
+
}
|
|
8298
|
+
const monthly = parseCommandCodeMonthly({ credits, subscription });
|
|
8299
|
+
return {
|
|
8300
|
+
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8301
|
+
agent: "command-code",
|
|
8302
|
+
five_hour: windows.five_hour,
|
|
8303
|
+
seven_day: windows.seven_day,
|
|
8304
|
+
monthly: monthly.monthly,
|
|
8305
|
+
monthly_quota: monthly.monthly_quota,
|
|
8306
|
+
seven_day_opus: null,
|
|
8307
|
+
seven_day_sonnet: null,
|
|
8308
|
+
seven_day_oauth_apps: null,
|
|
8309
|
+
seven_day_cowork: null,
|
|
8310
|
+
extra_usage: null,
|
|
8311
|
+
plan_type: monthly.plan_type
|
|
8312
|
+
};
|
|
8313
|
+
}
|
|
8314
|
+
|
|
8063
8315
|
// src/daemon-worker.ts
|
|
8064
8316
|
init_storage();
|
|
8065
8317
|
init_fs();
|
|
@@ -8101,7 +8353,7 @@ import { randomUUID } from "node:crypto";
|
|
|
8101
8353
|
|
|
8102
8354
|
// ../entries/dist/fs.js
|
|
8103
8355
|
init_fs();
|
|
8104
|
-
import { readFileSync as
|
|
8356
|
+
import { readFileSync as readFileSync11, readdirSync as readdirSync2, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, renameSync as renameSync3, existsSync as existsSync10 } from "node:fs";
|
|
8105
8357
|
import { randomBytes } from "node:crypto";
|
|
8106
8358
|
import { join as join6 } from "node:path";
|
|
8107
8359
|
|
|
@@ -8176,12 +8428,12 @@ var PROMPT_FRAME_ORIGIN = {
|
|
|
8176
8428
|
|
|
8177
8429
|
// ../entries/dist/digest-fs.js
|
|
8178
8430
|
init_fs();
|
|
8179
|
-
import { readFileSync as
|
|
8431
|
+
import { readFileSync as readFileSync10, readdirSync, writeFileSync as writeFileSync5, renameSync as renameSync2, chmodSync, mkdirSync as mkdirSync4, existsSync as existsSync9 } from "node:fs";
|
|
8180
8432
|
import { dirname as dirname4, join as join5 } from "node:path";
|
|
8181
8433
|
var digestsDirCached = null;
|
|
8182
|
-
function parseDigestFile(
|
|
8434
|
+
function parseDigestFile(path12, expectedVersion) {
|
|
8183
8435
|
try {
|
|
8184
|
-
const parsed = JSON.parse(
|
|
8436
|
+
const parsed = JSON.parse(readFileSync10(path12, "utf8"));
|
|
8185
8437
|
if (!parsed || typeof parsed !== "object")
|
|
8186
8438
|
return null;
|
|
8187
8439
|
if (parsed.version !== expectedVersion)
|
|
@@ -8221,7 +8473,7 @@ function writeDayDigest(digest) {
|
|
|
8221
8473
|
}
|
|
8222
8474
|
function readDayDigest(date) {
|
|
8223
8475
|
const p = dayDigestPath(date);
|
|
8224
|
-
if (!
|
|
8476
|
+
if (!existsSync9(p))
|
|
8225
8477
|
return null;
|
|
8226
8478
|
return parseDigestFile(p, CURRENT_DAY_DIGEST_SCHEMA_VERSION);
|
|
8227
8479
|
}
|
|
@@ -8254,7 +8506,7 @@ function writeWeekDigest(digest) {
|
|
|
8254
8506
|
}
|
|
8255
8507
|
function readWeekDigest(monday) {
|
|
8256
8508
|
const p = weekDigestPath(monday);
|
|
8257
|
-
if (!
|
|
8509
|
+
if (!existsSync9(p))
|
|
8258
8510
|
return null;
|
|
8259
8511
|
return parseDigestFile(p, CURRENT_WEEK_DIGEST_SCHEMA_VERSION);
|
|
8260
8512
|
}
|
|
@@ -8332,17 +8584,17 @@ function writeEntryPreservingEnrichment(fresh) {
|
|
|
8332
8584
|
}
|
|
8333
8585
|
function readEntry(sessionId, localDay2) {
|
|
8334
8586
|
const p = pathFor(sessionId, localDay2);
|
|
8335
|
-
if (!
|
|
8587
|
+
if (!existsSync10(p))
|
|
8336
8588
|
return null;
|
|
8337
|
-
const raw =
|
|
8589
|
+
const raw = readFileSync11(p, "utf8");
|
|
8338
8590
|
return JSON.parse(raw);
|
|
8339
8591
|
}
|
|
8340
8592
|
function entryExists(sessionId, localDay2) {
|
|
8341
|
-
return
|
|
8593
|
+
return existsSync10(pathFor(sessionId, localDay2));
|
|
8342
8594
|
}
|
|
8343
8595
|
function listEntryKeys() {
|
|
8344
8596
|
const dir = entriesDir();
|
|
8345
|
-
if (!
|
|
8597
|
+
if (!existsSync10(dir))
|
|
8346
8598
|
return [];
|
|
8347
8599
|
return readdirSync2(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length));
|
|
8348
8600
|
}
|
|
@@ -8361,7 +8613,7 @@ function listEntriesForDay(localDay2) {
|
|
|
8361
8613
|
|
|
8362
8614
|
// src/perception/build-entries.ts
|
|
8363
8615
|
init_dist();
|
|
8364
|
-
import { statSync as statSync2, readFileSync as
|
|
8616
|
+
import { statSync as statSync2, readFileSync as readFileSync12 } from "node:fs";
|
|
8365
8617
|
import { basename as basename2, dirname as dirname5 } from "node:path";
|
|
8366
8618
|
|
|
8367
8619
|
// ../entries/dist/signals.js
|
|
@@ -9103,7 +9355,7 @@ function decodeProjectDirName(projectDir) {
|
|
|
9103
9355
|
}
|
|
9104
9356
|
function buildEntriesForFile(filePath) {
|
|
9105
9357
|
const stat = statSync2(filePath);
|
|
9106
|
-
const raw =
|
|
9358
|
+
const raw = readFileSync12(filePath, "utf8");
|
|
9107
9359
|
const rawLines = raw.split("\n").filter(Boolean).map((l) => {
|
|
9108
9360
|
try {
|
|
9109
9361
|
return JSON.parse(l);
|
|
@@ -9369,7 +9621,7 @@ function buildIngestPayload(inputs) {
|
|
|
9369
9621
|
return {
|
|
9370
9622
|
ingestId: randomUUID(),
|
|
9371
9623
|
observedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9372
|
-
cliVersion: "1.0.
|
|
9624
|
+
cliVersion: "1.0.14",
|
|
9373
9625
|
...richRollup || inputs.enrichedExtras || inputs.artifactSignals ? { schemaVersion: RICH_ROLLUP_SCHEMA_VERSION } : {},
|
|
9374
9626
|
...inputs.rollup ? { dailyRollup: inputs.rollup } : {},
|
|
9375
9627
|
...richRollup ? { richRollup } : {},
|
|
@@ -9396,7 +9648,7 @@ async function pushToTeamServer(config, payload) {
|
|
|
9396
9648
|
}
|
|
9397
9649
|
|
|
9398
9650
|
// src/team/git-remote.ts
|
|
9399
|
-
import { existsSync as
|
|
9651
|
+
import { existsSync as existsSync11, readFileSync as readFileSync13, statSync as statSync3 } from "node:fs";
|
|
9400
9652
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join7, resolve as resolve2 } from "node:path";
|
|
9401
9653
|
var GITHUB_URL_RE = /github\.com[:/]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/;
|
|
9402
9654
|
function parseGithubRemote(url) {
|
|
@@ -9422,12 +9674,12 @@ function gitConfigPathFor(dir) {
|
|
|
9422
9674
|
const st = statSync3(dotGit, { throwIfNoEntry: false });
|
|
9423
9675
|
if (!st) return null;
|
|
9424
9676
|
if (st.isDirectory()) return join7(dotGit, "config");
|
|
9425
|
-
const m =
|
|
9677
|
+
const m = readFileSync13(dotGit, "utf8").match(/^gitdir:\s*(.+)\s*$/m);
|
|
9426
9678
|
if (!m) return null;
|
|
9427
9679
|
const gd = isAbsolute2(m[1]) ? m[1] : resolve2(dir, m[1]);
|
|
9428
9680
|
const commondirFile = join7(gd, "commondir");
|
|
9429
|
-
if (
|
|
9430
|
-
const common =
|
|
9681
|
+
if (existsSync11(commondirFile)) {
|
|
9682
|
+
const common = readFileSync13(commondirFile, "utf8").trim();
|
|
9431
9683
|
return join7(isAbsolute2(common) ? common : resolve2(gd, common), "config");
|
|
9432
9684
|
}
|
|
9433
9685
|
return join7(gd, "config");
|
|
@@ -9442,8 +9694,8 @@ function createRepoResolver() {
|
|
|
9442
9694
|
try {
|
|
9443
9695
|
for (let d = dir; ; d = dirname6(d)) {
|
|
9444
9696
|
const config = gitConfigPathFor(d);
|
|
9445
|
-
if (config &&
|
|
9446
|
-
const url = originUrl2(
|
|
9697
|
+
if (config && existsSync11(config)) {
|
|
9698
|
+
const url = originUrl2(readFileSync13(config, "utf8"));
|
|
9447
9699
|
repo = url ? parseGithubRemote(url) : null;
|
|
9448
9700
|
break;
|
|
9449
9701
|
}
|
|
@@ -9459,7 +9711,7 @@ function createRepoResolver() {
|
|
|
9459
9711
|
|
|
9460
9712
|
// src/team/queue.ts
|
|
9461
9713
|
init_fs();
|
|
9462
|
-
import { readFileSync as
|
|
9714
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync7, appendFileSync as appendFileSync4, statSync as statSync4, mkdirSync as mkdirSync6 } from "node:fs";
|
|
9463
9715
|
import { dirname as dirname7 } from "node:path";
|
|
9464
9716
|
var QUEUE_PATH = cclensPath("ingest-queue.jsonl");
|
|
9465
9717
|
var MAX_SIZE_BYTES = 10 * 1024 * 1024;
|
|
@@ -9479,7 +9731,7 @@ function enqueuePayload(payload, queuePath = QUEUE_PATH) {
|
|
|
9479
9731
|
function dequeuePayloads(queuePath = QUEUE_PATH) {
|
|
9480
9732
|
let lines;
|
|
9481
9733
|
try {
|
|
9482
|
-
lines =
|
|
9734
|
+
lines = readFileSync14(queuePath, "utf8").trim().split("\n").filter(Boolean);
|
|
9483
9735
|
} catch {
|
|
9484
9736
|
return [];
|
|
9485
9737
|
}
|
|
@@ -9500,7 +9752,7 @@ function dequeuePayloads(queuePath = QUEUE_PATH) {
|
|
|
9500
9752
|
function pruneOldest(queuePath) {
|
|
9501
9753
|
let lines;
|
|
9502
9754
|
try {
|
|
9503
|
-
lines =
|
|
9755
|
+
lines = readFileSync14(queuePath, "utf8").trim().split("\n").filter(Boolean);
|
|
9504
9756
|
} catch {
|
|
9505
9757
|
return;
|
|
9506
9758
|
}
|
|
@@ -9513,7 +9765,7 @@ init_storage();
|
|
|
9513
9765
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
9514
9766
|
|
|
9515
9767
|
// src/usage/profile.ts
|
|
9516
|
-
import { existsSync as
|
|
9768
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync15, writeFileSync as writeFileSync8 } from "node:fs";
|
|
9517
9769
|
import { dirname as dirname8 } from "node:path";
|
|
9518
9770
|
var PROFILE_ENDPOINT = "https://api.anthropic.com/api/oauth/profile";
|
|
9519
9771
|
var BETA_HEADER2 = "oauth-2025-04-20";
|
|
@@ -9557,9 +9809,9 @@ async function fetchProfile(nowMs = Date.now()) {
|
|
|
9557
9809
|
};
|
|
9558
9810
|
}
|
|
9559
9811
|
function readCachedProfile(cachePath) {
|
|
9560
|
-
if (!
|
|
9812
|
+
if (!existsSync12(cachePath)) return null;
|
|
9561
9813
|
try {
|
|
9562
|
-
const raw = JSON.parse(
|
|
9814
|
+
const raw = JSON.parse(readFileSync15(cachePath, "utf8"));
|
|
9563
9815
|
if (typeof raw.fetchedAtMs !== "number" || !raw.profile) return null;
|
|
9564
9816
|
return raw;
|
|
9565
9817
|
} catch {
|
|
@@ -9728,13 +9980,13 @@ async function runTeamBackfill(log3 = noopLog, filePath = USAGE_LOG, configOverr
|
|
|
9728
9980
|
|
|
9729
9981
|
// src/team/sync-log.ts
|
|
9730
9982
|
init_fs();
|
|
9731
|
-
import { readFileSync as
|
|
9983
|
+
import { readFileSync as readFileSync16 } from "node:fs";
|
|
9732
9984
|
var MAX_LINES = 300;
|
|
9733
9985
|
var MAX_MSG_CHARS = 1900;
|
|
9734
9986
|
function readPendingSyncLog(watermark) {
|
|
9735
9987
|
let raw;
|
|
9736
9988
|
try {
|
|
9737
|
-
raw =
|
|
9989
|
+
raw = readFileSync16(cclensPath("daemon.log"), "utf8");
|
|
9738
9990
|
} catch {
|
|
9739
9991
|
return { lines: [] };
|
|
9740
9992
|
}
|
|
@@ -10360,7 +10612,7 @@ init_fs();
|
|
|
10360
10612
|
|
|
10361
10613
|
// src/perception/state.ts
|
|
10362
10614
|
init_fs();
|
|
10363
|
-
import { existsSync as
|
|
10615
|
+
import { existsSync as existsSync14, readFileSync as readFileSync17, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, renameSync as renameSync4 } from "node:fs";
|
|
10364
10616
|
import { dirname as dirname10 } from "node:path";
|
|
10365
10617
|
var STALE_MS = 15 * 60 * 1e3;
|
|
10366
10618
|
var pathCached = null;
|
|
@@ -10371,7 +10623,7 @@ function statePath() {
|
|
|
10371
10623
|
}
|
|
10372
10624
|
function readState() {
|
|
10373
10625
|
const p = statePath();
|
|
10374
|
-
if (!
|
|
10626
|
+
if (!existsSync14(p)) {
|
|
10375
10627
|
return {
|
|
10376
10628
|
sweep_in_progress: false,
|
|
10377
10629
|
last_sweep_started_at: null,
|
|
@@ -10379,7 +10631,7 @@ function readState() {
|
|
|
10379
10631
|
file_checkpoints: {}
|
|
10380
10632
|
};
|
|
10381
10633
|
}
|
|
10382
|
-
const raw =
|
|
10634
|
+
const raw = readFileSync17(p, "utf8");
|
|
10383
10635
|
return JSON.parse(raw);
|
|
10384
10636
|
}
|
|
10385
10637
|
function writeState(s) {
|
|
@@ -10987,8 +11239,8 @@ function getErrorMap() {
|
|
|
10987
11239
|
|
|
10988
11240
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
10989
11241
|
var makeIssue = (params) => {
|
|
10990
|
-
const { data, path:
|
|
10991
|
-
const fullPath = [...
|
|
11242
|
+
const { data, path: path12, errorMaps, issueData } = params;
|
|
11243
|
+
const fullPath = [...path12, ...issueData.path || []];
|
|
10992
11244
|
const fullIssue = {
|
|
10993
11245
|
...issueData,
|
|
10994
11246
|
path: fullPath
|
|
@@ -11104,11 +11356,11 @@ var errorUtil;
|
|
|
11104
11356
|
|
|
11105
11357
|
// ../../node_modules/zod/v3/types.js
|
|
11106
11358
|
var ParseInputLazyPath = class {
|
|
11107
|
-
constructor(parent, value,
|
|
11359
|
+
constructor(parent, value, path12, key) {
|
|
11108
11360
|
this._cachedPath = [];
|
|
11109
11361
|
this.parent = parent;
|
|
11110
11362
|
this.data = value;
|
|
11111
|
-
this._path =
|
|
11363
|
+
this._path = path12;
|
|
11112
11364
|
this._key = key;
|
|
11113
11365
|
}
|
|
11114
11366
|
get path() {
|
|
@@ -14642,19 +14894,19 @@ var ENRICHMENT_SYSTEM_PROMPT = SYSTEM_PROMPT;
|
|
|
14642
14894
|
// ../entries/dist/llm-runner.js
|
|
14643
14895
|
init_fs();
|
|
14644
14896
|
import { spawn as spawn2 } from "node:child_process";
|
|
14645
|
-
import { mkdirSync as mkdirSync11, appendFileSync as appendFileSync5, writeFileSync as writeFileSync12, existsSync as
|
|
14897
|
+
import { mkdirSync as mkdirSync11, appendFileSync as appendFileSync5, writeFileSync as writeFileSync12, existsSync as existsSync17 } from "node:fs";
|
|
14646
14898
|
import { join as join13 } from "node:path";
|
|
14647
14899
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14648
14900
|
|
|
14649
14901
|
// ../entries/dist/claude-bin.js
|
|
14650
|
-
import { existsSync as
|
|
14902
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
14651
14903
|
import { join as join11, dirname as dirname11, delimiter } from "node:path";
|
|
14652
14904
|
import { homedir as homedir5 } from "node:os";
|
|
14653
14905
|
function resolveClaudeBin(opts = {}) {
|
|
14654
14906
|
const env = opts.env ?? process.env;
|
|
14655
14907
|
const home = opts.home ?? homedir5();
|
|
14656
14908
|
const execPath = opts.execPath ?? process.execPath;
|
|
14657
|
-
const exists = opts.exists ??
|
|
14909
|
+
const exists = opts.exists ?? existsSync15;
|
|
14658
14910
|
for (const dir of (env.PATH ?? "").split(delimiter)) {
|
|
14659
14911
|
if (!dir)
|
|
14660
14912
|
continue;
|
|
@@ -14689,7 +14941,7 @@ var ClaudeBinNotFoundError = class extends Error {
|
|
|
14689
14941
|
};
|
|
14690
14942
|
|
|
14691
14943
|
// ../entries/dist/tmux-runner.js
|
|
14692
|
-
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync11, existsSync as
|
|
14944
|
+
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync11, existsSync as existsSync16, readdirSync as readdirSync5, realpathSync as realpathSync2, readFileSync as readFileSync18, unlinkSync as unlinkSync3, renameSync as renameSync5 } from "node:fs";
|
|
14693
14945
|
import { join as join12 } from "node:path";
|
|
14694
14946
|
import { homedir as homedir6 } from "node:os";
|
|
14695
14947
|
import { spawnSync } from "node:child_process";
|
|
@@ -14720,7 +14972,7 @@ function tmuxRunnerAvailable() {
|
|
|
14720
14972
|
}
|
|
14721
14973
|
function runtimeCwd() {
|
|
14722
14974
|
const dir = join12(homedir6(), ".cclens", "runtime");
|
|
14723
|
-
if (!
|
|
14975
|
+
if (!existsSync16(dir))
|
|
14724
14976
|
mkdirSync10(dir, { recursive: true });
|
|
14725
14977
|
return realpathSync2(dir);
|
|
14726
14978
|
}
|
|
@@ -14728,7 +14980,7 @@ function ensureRuntimeCwdTrusted(cwd) {
|
|
|
14728
14980
|
const cfgPath = join12(homedir6(), ".claude.json");
|
|
14729
14981
|
let cfg;
|
|
14730
14982
|
try {
|
|
14731
|
-
cfg = JSON.parse(
|
|
14983
|
+
cfg = JSON.parse(readFileSync18(cfgPath, "utf8"));
|
|
14732
14984
|
} catch {
|
|
14733
14985
|
return;
|
|
14734
14986
|
}
|
|
@@ -14877,10 +15129,10 @@ function snapshotAllTranscripts() {
|
|
|
14877
15129
|
}
|
|
14878
15130
|
return out;
|
|
14879
15131
|
}
|
|
14880
|
-
function readJsonlCwd(
|
|
15132
|
+
function readJsonlCwd(path12, maxLines = 8) {
|
|
14881
15133
|
let raw;
|
|
14882
15134
|
try {
|
|
14883
|
-
raw =
|
|
15135
|
+
raw = readFileSync18(path12, "utf8");
|
|
14884
15136
|
} catch {
|
|
14885
15137
|
return void 0;
|
|
14886
15138
|
}
|
|
@@ -14934,10 +15186,10 @@ async function discoverTranscript(targetCwd, existingBefore, startMs, timeoutMs,
|
|
|
14934
15186
|
}
|
|
14935
15187
|
throw new TmuxRunError(`timeout waiting for claude to create the session transcript (cwd: ${targetCwd})`);
|
|
14936
15188
|
}
|
|
14937
|
-
function parseTranscript2(
|
|
15189
|
+
function parseTranscript2(path12, defaultModel) {
|
|
14938
15190
|
let raw;
|
|
14939
15191
|
try {
|
|
14940
|
-
raw =
|
|
15192
|
+
raw = readFileSync18(path12, "utf8");
|
|
14941
15193
|
} catch {
|
|
14942
15194
|
return { assembled: "", inputTokens: 0, outputTokens: 0, modelUsed: defaultModel, done: false };
|
|
14943
15195
|
}
|
|
@@ -15012,7 +15264,7 @@ function shellEscape(s) {
|
|
|
15012
15264
|
// ../entries/dist/llm-runner.js
|
|
15013
15265
|
var RUNS_DIR = cclensPath("llm-runs");
|
|
15014
15266
|
function ensureRunsDir() {
|
|
15015
|
-
if (!
|
|
15267
|
+
if (!existsSync17(RUNS_DIR)) {
|
|
15016
15268
|
try {
|
|
15017
15269
|
mkdirSync11(RUNS_DIR, { recursive: true });
|
|
15018
15270
|
} catch {
|
|
@@ -15043,15 +15295,15 @@ function newRunId(kind) {
|
|
|
15043
15295
|
function tracePath(runId) {
|
|
15044
15296
|
return join13(RUNS_DIR, `${runId}.jsonl`);
|
|
15045
15297
|
}
|
|
15046
|
-
function safeAppend(
|
|
15298
|
+
function safeAppend(path12, line) {
|
|
15047
15299
|
try {
|
|
15048
|
-
appendFileSync5(
|
|
15300
|
+
appendFileSync5(path12, line);
|
|
15049
15301
|
} catch {
|
|
15050
15302
|
}
|
|
15051
15303
|
}
|
|
15052
|
-
function safeWrite(
|
|
15304
|
+
function safeWrite(path12, line) {
|
|
15053
15305
|
try {
|
|
15054
|
-
writeFileSync12(
|
|
15306
|
+
writeFileSync12(path12, line);
|
|
15055
15307
|
} catch {
|
|
15056
15308
|
}
|
|
15057
15309
|
}
|
|
@@ -15447,7 +15699,7 @@ function applyEnrichmentError(entry, errorMessage, model, costUsd, generatedAt,
|
|
|
15447
15699
|
|
|
15448
15700
|
// ../entries/dist/budget.js
|
|
15449
15701
|
init_fs();
|
|
15450
|
-
import { appendFileSync as appendFileSync6, readFileSync as
|
|
15702
|
+
import { appendFileSync as appendFileSync6, readFileSync as readFileSync19, existsSync as existsSync18, mkdirSync as mkdirSync12 } from "node:fs";
|
|
15451
15703
|
import { dirname as dirname12 } from "node:path";
|
|
15452
15704
|
var spendPathCached = null;
|
|
15453
15705
|
function spendPath() {
|
|
@@ -15463,12 +15715,12 @@ function appendSpend(record) {
|
|
|
15463
15715
|
}
|
|
15464
15716
|
function monthToDateSpend(now = /* @__PURE__ */ new Date()) {
|
|
15465
15717
|
const p = spendPath();
|
|
15466
|
-
if (!
|
|
15718
|
+
if (!existsSync18(p))
|
|
15467
15719
|
return 0;
|
|
15468
15720
|
const year = now.getUTCFullYear();
|
|
15469
15721
|
const month = now.getUTCMonth();
|
|
15470
15722
|
let total = 0;
|
|
15471
|
-
const raw =
|
|
15723
|
+
const raw = readFileSync19(p, "utf8");
|
|
15472
15724
|
for (const line of raw.split("\n")) {
|
|
15473
15725
|
if (!line)
|
|
15474
15726
|
continue;
|
|
@@ -15490,7 +15742,7 @@ function monthToDateSpend(now = /* @__PURE__ */ new Date()) {
|
|
|
15490
15742
|
|
|
15491
15743
|
// ../entries/dist/pipeline-lock.js
|
|
15492
15744
|
init_fs();
|
|
15493
|
-
import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, existsSync as
|
|
15745
|
+
import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, existsSync as existsSync19, readFileSync as readFileSync20, statSync as statSync7 } from "node:fs";
|
|
15494
15746
|
var STALE_MS2 = 60 * 1e3;
|
|
15495
15747
|
var HEARTBEAT_MS = 30 * 1e3;
|
|
15496
15748
|
var lockPathCached = null;
|
|
@@ -15536,13 +15788,13 @@ function pidAlive(pid) {
|
|
|
15536
15788
|
}
|
|
15537
15789
|
function interactiveLockFresh(nowMs) {
|
|
15538
15790
|
const p = lockPath();
|
|
15539
|
-
if (!
|
|
15791
|
+
if (!existsSync19(p))
|
|
15540
15792
|
return false;
|
|
15541
15793
|
try {
|
|
15542
15794
|
const mtime = statSync7(p).mtimeMs;
|
|
15543
15795
|
if (nowMs - mtime > STALE_MS2)
|
|
15544
15796
|
return false;
|
|
15545
|
-
const pid = Number(
|
|
15797
|
+
const pid = Number(readFileSync20(p, "utf8").trim());
|
|
15546
15798
|
if (!Number.isFinite(pid) || pid <= 0)
|
|
15547
15799
|
return false;
|
|
15548
15800
|
if (!pidAlive(pid))
|
|
@@ -15557,7 +15809,7 @@ function interactiveLockFresh(nowMs) {
|
|
|
15557
15809
|
var THIRTY_MIN_MS = 30 * 60 * 1e3;
|
|
15558
15810
|
|
|
15559
15811
|
// ../entries/dist/settings.js
|
|
15560
|
-
import { readFileSync as
|
|
15812
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, renameSync as renameSync6, chmodSync as chmodSync2, mkdirSync as mkdirSync13, existsSync as existsSync20 } from "node:fs";
|
|
15561
15813
|
init_fs();
|
|
15562
15814
|
var DEFAULT_SETTINGS = {
|
|
15563
15815
|
ai_features: {
|
|
@@ -15589,10 +15841,10 @@ function fromDisk(d) {
|
|
|
15589
15841
|
}
|
|
15590
15842
|
function readSettings() {
|
|
15591
15843
|
const p = settingsPath();
|
|
15592
|
-
if (!
|
|
15844
|
+
if (!existsSync20(p))
|
|
15593
15845
|
return DEFAULT_SETTINGS;
|
|
15594
15846
|
try {
|
|
15595
|
-
const raw =
|
|
15847
|
+
const raw = readFileSync21(p, "utf8");
|
|
15596
15848
|
return fromDisk(JSON.parse(raw));
|
|
15597
15849
|
} catch {
|
|
15598
15850
|
return DEFAULT_SETTINGS;
|
|
@@ -18352,14 +18604,14 @@ async function getUpdateAvailability() {
|
|
|
18352
18604
|
if (isDevMode()) return null;
|
|
18353
18605
|
const latest = await fetchLatestVersion();
|
|
18354
18606
|
if (latest === null) return {
|
|
18355
|
-
current: "1.0.
|
|
18607
|
+
current: "1.0.14",
|
|
18356
18608
|
latest: null,
|
|
18357
18609
|
updateAvailable: false
|
|
18358
18610
|
};
|
|
18359
18611
|
return {
|
|
18360
|
-
current: "1.0.
|
|
18612
|
+
current: "1.0.14",
|
|
18361
18613
|
latest,
|
|
18362
|
-
updateAvailable: shouldUpdate("1.0.
|
|
18614
|
+
updateAvailable: shouldUpdate("1.0.14", latest)
|
|
18363
18615
|
};
|
|
18364
18616
|
}
|
|
18365
18617
|
|
|
@@ -18451,7 +18703,7 @@ var perceptionHandle = setInterval(async () => {
|
|
|
18451
18703
|
}, PERCEPTION_INTERVAL_MS);
|
|
18452
18704
|
function readUpdateState() {
|
|
18453
18705
|
try {
|
|
18454
|
-
return JSON.parse(
|
|
18706
|
+
return JSON.parse(readFileSync24(UPDATE_STATE, "utf8"));
|
|
18455
18707
|
} catch {
|
|
18456
18708
|
return null;
|
|
18457
18709
|
}
|
|
@@ -18503,7 +18755,7 @@ async function runDaemonUpdateCheck() {
|
|
|
18503
18755
|
return;
|
|
18504
18756
|
}
|
|
18505
18757
|
const entry = cliEntryPath();
|
|
18506
|
-
if (!
|
|
18758
|
+
if (!existsSync22(entry)) {
|
|
18507
18759
|
log2("warn", `update check found ${availability.latest}, but CLI entry is missing at ${entry}`);
|
|
18508
18760
|
return;
|
|
18509
18761
|
}
|
|
@@ -18663,6 +18915,20 @@ async function pollAuxiliaryUsage() {
|
|
|
18663
18915
|
log2("warn", `grok poll failed: ${err.message}`);
|
|
18664
18916
|
}
|
|
18665
18917
|
}
|
|
18918
|
+
try {
|
|
18919
|
+
const cmdSnapshot = await fetchCommandCodeUsage();
|
|
18920
|
+
appendSnapshot(USAGE_LOG3, cmdSnapshot);
|
|
18921
|
+
const monthly = cmdSnapshot.monthly?.utilization === null || cmdSnapshot.monthly?.utilization === void 0 ? "\u2014" : `${cmdSnapshot.monthly.utilization}%`;
|
|
18922
|
+
const fiveHour = cmdSnapshot.five_hour.utilization === null ? "\u2014" : `${cmdSnapshot.five_hour.utilization}%`;
|
|
18923
|
+
const sevenDay = cmdSnapshot.seven_day.utilization === null ? "\u2014" : `${cmdSnapshot.seven_day.utilization}%`;
|
|
18924
|
+
log2("info", `command-code snapshot monthly=${monthly} 5h=${fiveHour} 7d=${sevenDay}`);
|
|
18925
|
+
} catch (err) {
|
|
18926
|
+
if (err instanceof CommandCodeApiError && err.code === "no_auth") {
|
|
18927
|
+
pruneAgent(USAGE_LOG3, "command-code");
|
|
18928
|
+
} else {
|
|
18929
|
+
log2("warn", `command-code poll failed: ${err.message}`);
|
|
18930
|
+
}
|
|
18931
|
+
}
|
|
18666
18932
|
}
|
|
18667
18933
|
async function pollClaudeUsage() {
|
|
18668
18934
|
try {
|