@integrity-labs/agt-cli 0.27.164 → 0.27.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/agt.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
success,
|
|
34
34
|
table,
|
|
35
35
|
warn
|
|
36
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-DMZQM4DY.js";
|
|
37
37
|
import {
|
|
38
38
|
CHANNEL_REGISTRY,
|
|
39
39
|
DEPLOYMENT_TEMPLATES,
|
|
@@ -5019,7 +5019,7 @@ import { execFileSync, execSync } from "child_process";
|
|
|
5019
5019
|
import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
|
|
5020
5020
|
import chalk18 from "chalk";
|
|
5021
5021
|
import ora16 from "ora";
|
|
5022
|
-
var cliVersion = true ? "0.27.
|
|
5022
|
+
var cliVersion = true ? "0.27.166" : "dev";
|
|
5023
5023
|
async function fetchLatestVersion() {
|
|
5024
5024
|
const host2 = getHost();
|
|
5025
5025
|
if (!host2) return null;
|
|
@@ -5942,7 +5942,7 @@ function handleError(err) {
|
|
|
5942
5942
|
}
|
|
5943
5943
|
|
|
5944
5944
|
// src/bin/agt.ts
|
|
5945
|
-
var cliVersion2 = true ? "0.27.
|
|
5945
|
+
var cliVersion2 = true ? "0.27.166" : "dev";
|
|
5946
5946
|
var program = new Command();
|
|
5947
5947
|
program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
|
|
5948
5948
|
program.hook("preAction", async (thisCommand, actionCommand) => {
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
provisionStopHook,
|
|
23
23
|
requireHost,
|
|
24
24
|
safeWriteJsonAtomic
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-DMZQM4DY.js";
|
|
26
26
|
import {
|
|
27
27
|
getProjectDir as getProjectDir2,
|
|
28
28
|
getReadyTasks,
|
|
@@ -1988,6 +1988,30 @@ var lastCheckedAt = /* @__PURE__ */ new Map();
|
|
|
1988
1988
|
function emptyTotals() {
|
|
1989
1989
|
return { inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
1990
1990
|
}
|
|
1991
|
+
var MAX_SUBAGENT_DEPTH = 6;
|
|
1992
|
+
function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
|
|
1993
|
+
if (depth > MAX_SUBAGENT_DEPTH) return;
|
|
1994
|
+
let entries;
|
|
1995
|
+
try {
|
|
1996
|
+
entries = readdirSync2(dir);
|
|
1997
|
+
} catch {
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
for (const name of entries) {
|
|
2001
|
+
const p = join4(dir, name);
|
|
2002
|
+
let st;
|
|
2003
|
+
try {
|
|
2004
|
+
st = statSync2(p);
|
|
2005
|
+
} catch {
|
|
2006
|
+
continue;
|
|
2007
|
+
}
|
|
2008
|
+
if (st.isDirectory()) {
|
|
2009
|
+
collectJsonlRecursive(p, minMtimeMs, out, depth + 1);
|
|
2010
|
+
} else if (st.isFile() && name.endsWith(".jsonl") && st.mtimeMs >= minMtimeMs) {
|
|
2011
|
+
out.push(p);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1991
2015
|
function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRANSCRIPT_MTIME_WINDOW_MS2) {
|
|
1992
2016
|
const out = [];
|
|
1993
2017
|
let entries;
|
|
@@ -2009,36 +2033,25 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2009
2033
|
continue;
|
|
2010
2034
|
}
|
|
2011
2035
|
if (st.isDirectory()) {
|
|
2012
|
-
|
|
2013
|
-
let subEntries;
|
|
2014
|
-
try {
|
|
2015
|
-
subEntries = readdirSync2(subDir);
|
|
2016
|
-
} catch {
|
|
2017
|
-
continue;
|
|
2018
|
-
}
|
|
2019
|
-
for (const sub of subEntries) {
|
|
2020
|
-
if (!sub.endsWith(".jsonl")) continue;
|
|
2021
|
-
const subPath = join4(subDir, sub);
|
|
2022
|
-
try {
|
|
2023
|
-
const sst = statSync2(subPath);
|
|
2024
|
-
if (sst.isFile() && sst.mtimeMs >= minMtimeMs) out.push(subPath);
|
|
2025
|
-
} catch {
|
|
2026
|
-
}
|
|
2027
|
-
}
|
|
2036
|
+
collectJsonlRecursive(join4(path, "subagents"), minMtimeMs, out, 0);
|
|
2028
2037
|
}
|
|
2029
2038
|
}
|
|
2030
2039
|
return out;
|
|
2031
2040
|
}
|
|
2032
|
-
function
|
|
2033
|
-
const
|
|
2041
|
+
function sumWindowedUsageByModelAcrossContents(contents, startMs, endMs) {
|
|
2042
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
2034
2043
|
for (const content of contents) {
|
|
2035
2044
|
const r = sumTranscriptUsageInWindow(content, startMs, endMs);
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2045
|
+
for (const [model, t] of r.byModel) {
|
|
2046
|
+
const acc = byModel.get(model) ?? emptyTotals();
|
|
2047
|
+
acc.inputTokens += t.inputTokens;
|
|
2048
|
+
acc.outputTokens += t.outputTokens;
|
|
2049
|
+
acc.cacheCreationTokens += t.cacheCreationTokens;
|
|
2050
|
+
acc.cacheReadTokens += t.cacheReadTokens;
|
|
2051
|
+
byModel.set(model, acc);
|
|
2052
|
+
}
|
|
2040
2053
|
}
|
|
2041
|
-
return
|
|
2054
|
+
return byModel;
|
|
2042
2055
|
}
|
|
2043
2056
|
async function maybeReconcileWorkflowRunTokens(args) {
|
|
2044
2057
|
const { api: api2, codeName, agentId, log: log2 } = args;
|
|
@@ -2075,13 +2088,29 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2075
2088
|
const startMs = new Date(run.started_at).getTime();
|
|
2076
2089
|
const endMs = new Date(run.finished_at).getTime();
|
|
2077
2090
|
if (!Number.isFinite(startMs) || !Number.isFinite(endMs) || endMs < startMs) continue;
|
|
2078
|
-
const
|
|
2091
|
+
const byModel = sumWindowedUsageByModelAcrossContents(contents, startMs, endMs);
|
|
2092
|
+
const totals = emptyTotals();
|
|
2093
|
+
const byModelPayload = [];
|
|
2094
|
+
for (const [model, t] of byModel) {
|
|
2095
|
+
totals.inputTokens += t.inputTokens;
|
|
2096
|
+
totals.outputTokens += t.outputTokens;
|
|
2097
|
+
totals.cacheCreationTokens += t.cacheCreationTokens;
|
|
2098
|
+
totals.cacheReadTokens += t.cacheReadTokens;
|
|
2099
|
+
byModelPayload.push({
|
|
2100
|
+
model,
|
|
2101
|
+
input_tokens: t.inputTokens,
|
|
2102
|
+
output_tokens: t.outputTokens,
|
|
2103
|
+
cache_creation_tokens: t.cacheCreationTokens,
|
|
2104
|
+
cache_read_tokens: t.cacheReadTokens
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2079
2107
|
try {
|
|
2080
2108
|
await api2.post(`/host/workflow-runs/${run.id}/reconcile-tokens`, {
|
|
2081
2109
|
total_input_tokens: totals.inputTokens,
|
|
2082
2110
|
total_output_tokens: totals.outputTokens,
|
|
2083
2111
|
total_cache_creation_tokens: totals.cacheCreationTokens,
|
|
2084
|
-
total_cache_read_tokens: totals.cacheReadTokens
|
|
2112
|
+
total_cache_read_tokens: totals.cacheReadTokens,
|
|
2113
|
+
by_model: byModelPayload
|
|
2085
2114
|
});
|
|
2086
2115
|
reconciled++;
|
|
2087
2116
|
} catch (err) {
|
|
@@ -5012,7 +5041,7 @@ var cachedMaintenanceWindow = null;
|
|
|
5012
5041
|
var lastVersionCheckAt = 0;
|
|
5013
5042
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
5014
5043
|
var lastResponsivenessProbeAt = 0;
|
|
5015
|
-
var agtCliVersion = true ? "0.27.
|
|
5044
|
+
var agtCliVersion = true ? "0.27.166" : "dev";
|
|
5016
5045
|
function resolveBrewPath(execFileSync4) {
|
|
5017
5046
|
try {
|
|
5018
5047
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|