@inerrata-corporation/errata 2.0.0-dev.51 → 2.0.0-dev.52
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/errata.mjs +41 -1
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -20934,6 +20934,11 @@ var init_client = __esm({
|
|
|
20934
20934
|
async me() {
|
|
20935
20935
|
return this.json("GET", "/v2/me");
|
|
20936
20936
|
}
|
|
20937
|
+
/** Current plan/quota/cost status through the gateway. The gateway flushes
|
|
20938
|
+
* this replica's ≤2s usage batch before reading the canonical Hono ledger. */
|
|
20939
|
+
async usage() {
|
|
20940
|
+
return this.json("GET", "/v2/usage");
|
|
20941
|
+
}
|
|
20937
20942
|
// ─── acting-agent switching (gateway control plane, #898) ───────────
|
|
20938
20943
|
/** Agents the authenticated user may act as, plus their default agent.
|
|
20939
20944
|
* Authenticated with the caller's console-signed gateway JWT. */
|
|
@@ -42754,7 +42759,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
42754
42759
|
}
|
|
42755
42760
|
|
|
42756
42761
|
// src/engine.ts
|
|
42757
|
-
var DAEMON_VERSION = true ? "2.0.0-dev.
|
|
42762
|
+
var DAEMON_VERSION = true ? "2.0.0-dev.52" : "2.0.0-alpha.0";
|
|
42758
42763
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
42759
42764
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
42760
42765
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -45967,6 +45972,8 @@ async function main() {
|
|
|
45967
45972
|
return cmdStop();
|
|
45968
45973
|
case "status":
|
|
45969
45974
|
return cmdStatus();
|
|
45975
|
+
case "usage":
|
|
45976
|
+
return cmdUsage();
|
|
45970
45977
|
case "login":
|
|
45971
45978
|
return cmdLogin();
|
|
45972
45979
|
case "logout":
|
|
@@ -46053,6 +46060,8 @@ Commands:
|
|
|
46053
46060
|
start Run the daemon (FS watchers + hook receiver + tick loop)
|
|
46054
46061
|
stop Stop a running daemon (reads .errata/daemon.lock for the pid)
|
|
46055
46062
|
status Print workspace + cloud status (incl. version + pending update)
|
|
46063
|
+
usage Show current cloud plan, units remaining, estimated cost,
|
|
46064
|
+
and per-tool usage (reads the gateway's batched Hono ledger)
|
|
46056
46065
|
update [--channel dev|latest] [--check]
|
|
46057
46066
|
Pull the newest build on this machine's channel via npm.
|
|
46058
46067
|
--check only reports; --channel switches + persists channel.
|
|
@@ -46458,6 +46467,37 @@ function applyCloudUrl(cfg, url2) {
|
|
|
46458
46467
|
function cloudPolicyMessage(cfg, inspection) {
|
|
46459
46468
|
return formatCloudEndpointBlock(cfg.cloudUrl, evaluateCloudEndpoint(cfg.cloudUrl, inspection));
|
|
46460
46469
|
}
|
|
46470
|
+
async function cmdUsage() {
|
|
46471
|
+
const cfg = loadConfig();
|
|
46472
|
+
if (!hasCloudCredential(cfg)) {
|
|
46473
|
+
console.error("not logged in \u2014 run `errata login` first");
|
|
46474
|
+
process.exitCode = 1;
|
|
46475
|
+
return;
|
|
46476
|
+
}
|
|
46477
|
+
try {
|
|
46478
|
+
const status = await authedCloudClient(cfg).usage();
|
|
46479
|
+
const quota = status.quota.unlimited ? `${status.quota.units_used.toLocaleString()} used \xB7 unlimited` : `${status.quota.units_used.toLocaleString()} / ${status.quota.effective_unit_limit?.toLocaleString()} used \xB7 ${status.quota.units_remaining?.toLocaleString()} remaining`;
|
|
46480
|
+
console.log(`inErrata usage \u2014 ${status.plan}`);
|
|
46481
|
+
console.log(` period: ${status.period_start.slice(0, 10)} \u2192 ${status.period_end.slice(0, 10)}`);
|
|
46482
|
+
console.log(` units: ${quota}`);
|
|
46483
|
+
console.log(` calls: ${status.totals.event_count.toLocaleString()}`);
|
|
46484
|
+
if (status.quota.units_reserved > 0) {
|
|
46485
|
+
console.log(` held: ${status.quota.units_reserved.toLocaleString()} units reserved by in-flight calls`);
|
|
46486
|
+
}
|
|
46487
|
+
console.log(` cost: $${(status.quota.estimated_cents_current / 100).toFixed(2)} estimated`);
|
|
46488
|
+
console.log(` rate: $${(status.pricing.cents_per_1000_units / 100).toFixed(2)} / 1,000 units${status.pricing.estimate_only ? " (estimate, not an invoice)" : ""}`);
|
|
46489
|
+
if (status.by_tool.length > 0) {
|
|
46490
|
+
console.log(" tools:");
|
|
46491
|
+
for (const row of [...status.by_tool].sort((a, b) => b.units - a.units).slice(0, 10)) {
|
|
46492
|
+
console.log(` ${row.tool.padEnd(24)} ${row.units.toLocaleString().padStart(8)} units ${row.event_count.toLocaleString().padStart(6)} calls`);
|
|
46493
|
+
}
|
|
46494
|
+
}
|
|
46495
|
+
console.log(` as of: ${status.as_of} (ledger + live reservations; poll again after ${Math.ceil(status.poll_after_ms / 1e3)}s)`);
|
|
46496
|
+
} catch (err2) {
|
|
46497
|
+
console.error(`usage unavailable: ${err2 instanceof Error ? err2.message : err2}`);
|
|
46498
|
+
process.exitCode = 1;
|
|
46499
|
+
}
|
|
46500
|
+
}
|
|
46461
46501
|
async function applyToken(cfg, token) {
|
|
46462
46502
|
const inspection = await inspectCloudEndpoint(cfg.cloudUrl);
|
|
46463
46503
|
try {
|