agent-nuvira 3.5.2 → 3.5.6
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 +66 -0
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +72 -19
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +17 -3
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/execute.js +63 -22
- package/dist/cli/execute.js.map +1 -1
- package/dist/cli/failover-runner.js +4 -4
- package/dist/cli/failover-runner.js.map +1 -1
- package/dist/cli/gateway.js +13 -13
- package/dist/cli/gateway.js.map +1 -1
- package/dist/cli/loop-executor.d.ts +22 -0
- package/dist/cli/loop-executor.d.ts.map +1 -1
- package/dist/cli/loop-executor.js +56 -12
- package/dist/cli/loop-executor.js.map +1 -1
- package/dist/cli/stats.d.ts +62 -4
- package/dist/cli/stats.d.ts.map +1 -1
- package/dist/cli/stats.js +282 -5
- package/dist/cli/stats.js.map +1 -1
- package/dist/cli/ui/index.d.ts +2 -2
- package/dist/cli/ui/index.d.ts.map +1 -1
- package/dist/cli/ui/index.js +1 -1
- package/dist/cli/ui/index.js.map +1 -1
- package/dist/cli/ui/presenter.d.ts +43 -0
- package/dist/cli/ui/presenter.d.ts.map +1 -1
- package/dist/cli/ui/presenter.js +88 -1
- package/dist/cli/ui/presenter.js.map +1 -1
- package/dist/config/manager.d.ts +29 -1
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/config/manager.js +178 -143
- package/dist/config/manager.js.map +1 -1
- package/dist/config/paths.d.ts +48 -1
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +59 -9
- package/dist/config/paths.js.map +1 -1
- package/dist/config/service-catalog.js +1 -1
- package/dist/config/service-catalog.js.map +1 -1
- package/dist/config/service-probe.js +1 -1
- package/dist/config/service-probe.js.map +1 -1
- package/dist/config/types.d.ts +22 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/gateway/adapters.js +8 -8
- package/dist/gateway/adapters.js.map +1 -1
- package/dist/gateway/registry.js +1 -1
- package/dist/gateway/registry.js.map +1 -1
- package/dist/learning/auto-router.d.ts +30 -4
- package/dist/learning/auto-router.d.ts.map +1 -1
- package/dist/learning/auto-router.js +54 -38
- package/dist/learning/auto-router.js.map +1 -1
- package/dist/learning/cost-classification.d.ts +188 -0
- package/dist/learning/cost-classification.d.ts.map +1 -0
- package/dist/learning/cost-classification.js +294 -0
- package/dist/learning/cost-classification.js.map +1 -0
- package/dist/learning/cost-ledger-maintenance.d.ts +122 -0
- package/dist/learning/cost-ledger-maintenance.d.ts.map +1 -0
- package/dist/learning/cost-ledger-maintenance.js +289 -0
- package/dist/learning/cost-ledger-maintenance.js.map +1 -0
- package/dist/learning/cost-reconcile.d.ts +160 -0
- package/dist/learning/cost-reconcile.d.ts.map +1 -0
- package/dist/learning/cost-reconcile.js +238 -0
- package/dist/learning/cost-reconcile.js.map +1 -0
- package/dist/learning/cost-tracker.d.ts +134 -13
- package/dist/learning/cost-tracker.d.ts.map +1 -1
- package/dist/learning/cost-tracker.js +190 -68
- package/dist/learning/cost-tracker.js.map +1 -1
- package/dist/learning/model-pricing.d.ts +240 -0
- package/dist/learning/model-pricing.d.ts.map +1 -0
- package/dist/learning/model-pricing.js +309 -0
- package/dist/learning/model-pricing.js.map +1 -0
- package/dist/learning/model-selection.d.ts +15 -0
- package/dist/learning/model-selection.d.ts.map +1 -1
- package/dist/learning/model-selection.js +22 -2
- package/dist/learning/model-selection.js.map +1 -1
- package/dist/learning/model-warmup.d.ts.map +1 -1
- package/dist/learning/model-warmup.js +4 -1
- package/dist/learning/model-warmup.js.map +1 -1
- package/dist/learning/session-store.d.ts +1 -5
- package/dist/learning/session-store.d.ts.map +1 -1
- package/dist/learning/session-store.js +10 -1
- package/dist/learning/session-store.js.map +1 -1
- package/dist/learning/step-checkpoint.d.ts +32 -3
- package/dist/learning/step-checkpoint.d.ts.map +1 -1
- package/dist/learning/step-checkpoint.js +33 -4
- package/dist/learning/step-checkpoint.js.map +1 -1
- package/dist/mcp/settings.d.ts +15 -3
- package/dist/mcp/settings.d.ts.map +1 -1
- package/dist/mcp/settings.js +30 -15
- package/dist/mcp/settings.js.map +1 -1
- package/dist/parity/drivers.d.ts.map +1 -1
- package/dist/parity/drivers.js +31 -5
- package/dist/parity/drivers.js.map +1 -1
- package/dist/tools/child-agent-runtime.d.ts.map +1 -1
- package/dist/tools/child-agent-runtime.js +13 -7
- package/dist/tools/child-agent-runtime.js.map +1 -1
- package/dist/tools/followup-utils.d.ts +36 -0
- package/dist/tools/followup-utils.d.ts.map +1 -1
- package/dist/tools/followup-utils.js +66 -0
- package/dist/tools/followup-utils.js.map +1 -1
- package/dist/tools/modality/browser.js +2 -2
- package/dist/tools/modality/browser.js.map +1 -1
- package/dist/tools/modality/image-gen.d.ts +1 -1
- package/dist/tools/modality/image-gen.js +1 -1
- package/dist/tools/modality/image-providers.js +1 -1
- package/dist/tools/modality/image-providers.js.map +1 -1
- package/dist/tools/modality/vision.d.ts +1 -1
- package/dist/tools/modality/vision.js +1 -1
- package/dist/tools/modality/voice.js +2 -2
- package/dist/tools/modality/voice.js.map +1 -1
- package/dist/tools/neutts-synth.d.ts +3 -3
- package/dist/tools/neutts-synth.js +3 -3
- package/dist/tools/neutts-synth.js.map +1 -1
- package/dist/tools/process-liveness.d.ts +50 -0
- package/dist/tools/process-liveness.d.ts.map +1 -1
- package/dist/tools/process-liveness.js +82 -9
- package/dist/tools/process-liveness.js.map +1 -1
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +27 -4
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/run-registry.d.ts.map +1 -1
- package/dist/tools/run-registry.js +14 -1
- package/dist/tools/run-registry.js.map +1 -1
- package/dist/tools/run-terminal.d.ts.map +1 -1
- package/dist/tools/run-terminal.js +18 -1
- package/dist/tools/run-terminal.js.map +1 -1
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +5 -3
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/tools/web-research.d.ts +1 -1
- package/dist/tools/web-research.js +3 -3
- package/dist/tools/web-research.js.map +1 -1
- package/dist/web-dashboard/chat-console.d.ts +56 -0
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js +57 -1
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +122 -2
- package/dist/web-dashboard/server.js.map +1 -1
- package/dist/web-dashboard/src/types.d.ts +63 -0
- package/dist/web-dashboard/src/types.d.ts.map +1 -1
- package/dist/web-dashboard/task-runner.d.ts +17 -1
- package/dist/web-dashboard/task-runner.d.ts.map +1 -1
- package/dist/web-dashboard/task-runner.js +84 -9
- package/dist/web-dashboard/task-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/web-dashboard/public/assets/index-DeSsNU94.css +1 -0
- package/src/web-dashboard/public/assets/index-Do_O67Kv.js +236 -0
- package/src/web-dashboard/public/assets/index-Do_O67Kv.js.map +1 -0
- package/src/web-dashboard/public/index.html +2 -2
- package/src/web-dashboard/public/assets/index-DycGBWwy.js +0 -236
- package/src/web-dashboard/public/assets/index-DycGBWwy.js.map +0 -1
- package/src/web-dashboard/public/assets/index-aO3aG7ex.css +0 -1
package/dist/cli/stats.d.ts
CHANGED
|
@@ -2,17 +2,75 @@
|
|
|
2
2
|
* Stats command — View usage statistics and cost tracking.
|
|
3
3
|
*
|
|
4
4
|
* Usage:
|
|
5
|
-
* nuvira stats
|
|
6
|
-
* nuvira stats cost
|
|
7
|
-
* nuvira stats cost --clear
|
|
8
|
-
* nuvira stats
|
|
5
|
+
* nuvira stats — Show all stats summary
|
|
6
|
+
* nuvira stats cost — Show cost tracking details
|
|
7
|
+
* nuvira stats cost --clear — Reset cost tracking data
|
|
8
|
+
* nuvira stats cost reconcile ... — compare the ledger to a provider invoice
|
|
9
|
+
* nuvira stats cost reprice — re-price legacy rows (dry run; --apply writes)
|
|
10
|
+
* nuvira stats history — Show conversation history stats
|
|
11
|
+
*
|
|
12
|
+
* ─── WHY reconcile / reprice EXIST (read before editing their defaults) ─────
|
|
13
|
+
*
|
|
14
|
+
* `stats cost` prints what the ledger can EVIDENCE, and the ledger cannot see a
|
|
15
|
+
* provider's invoice. That is not a defect to paper over with a nicer estimate:
|
|
16
|
+
* the fix is to let the operator supply the one number that is actual — the
|
|
17
|
+
* provider's own charge for a stated window — and to say honestly how far the
|
|
18
|
+
* ledger is from it, and what the gap consists of. `reconcile` is therefore the
|
|
19
|
+
* only command in this file that reports a figure no local computation could
|
|
20
|
+
* produce, and it never adjusts the ledger to agree.
|
|
21
|
+
*
|
|
22
|
+
* `reprice` is the explicit, dry-run-default repair of the rows already on disk
|
|
23
|
+
* (legacy prices from the retired hardcoded table, test-origin rows). Both are
|
|
24
|
+
* documented in `learning/cost-reconcile.ts` and `learning/cost-ledger-maintenance.ts`.
|
|
9
25
|
*/
|
|
10
26
|
import { Command } from 'commander';
|
|
11
27
|
import { BaseCommand } from './commands.js';
|
|
12
28
|
export declare class StatsCommand extends BaseCommand {
|
|
13
29
|
create(): Command;
|
|
14
30
|
private showCost;
|
|
31
|
+
/**
|
|
32
|
+
* `stats cost reconcile` — the provider's own figure vs this ledger.
|
|
33
|
+
*
|
|
34
|
+
* Two rules the defaults encode:
|
|
35
|
+
* 1. A WINDOW IS MANDATORY. Comparing an all-time ledger to a monthly invoice
|
|
36
|
+
* is a meaningless subtraction that would print a delta as if it meant
|
|
37
|
+
* something. The default is the current calendar month, and the window is
|
|
38
|
+
* always printed so a partial (still-running) period can be judged as such.
|
|
39
|
+
* 2. THE PROVIDER IS VALIDATED. An unknown id would otherwise read as "no
|
|
40
|
+
* rows", i.e. a silent zero that looks like "you used nothing" rather than
|
|
41
|
+
* "you typed the wrong id".
|
|
42
|
+
*/
|
|
43
|
+
private reconcileCost;
|
|
44
|
+
/**
|
|
45
|
+
* Turn the CLI flags into an invoice claim, or explain why they cannot be.
|
|
46
|
+
* Returns null after printing the reason — the command exits without a report
|
|
47
|
+
* rather than reconciling against a window we had to guess.
|
|
48
|
+
*/
|
|
49
|
+
private buildClaim;
|
|
50
|
+
/**
|
|
51
|
+
* Record the billing fact, but ONLY one the invoice does not contradict.
|
|
52
|
+
*
|
|
53
|
+
* This is the whole point of the exercise: `billingTier` moves the headline
|
|
54
|
+
* from "unverified" to "billed", so letting a user declare `free` while holding
|
|
55
|
+
* an invoice that charged $18 would reintroduce exactly the fabricated picture
|
|
56
|
+
* this change removed. A refusal is the useful answer.
|
|
57
|
+
*/
|
|
58
|
+
private applyTierDeclaration;
|
|
59
|
+
/**
|
|
60
|
+
* `stats cost reprice` — the explicit repair of the rows already on disk.
|
|
61
|
+
*
|
|
62
|
+
* Dry run by default: the ledger is the user's billing history, and a reprice
|
|
63
|
+
* changes every legacy figure in it. `--apply` writes once, after taking a
|
|
64
|
+
* backup, and the report says exactly what changed either way.
|
|
65
|
+
*/
|
|
66
|
+
private repriceLedger;
|
|
15
67
|
private showHistoryStats;
|
|
16
68
|
private showAllStats;
|
|
17
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse a currency amount the way a user copies it off a dashboard: `$12.34`,
|
|
72
|
+
* `1,234.56`, ` 12.34 `. Returns null when it is not a non-negative finite
|
|
73
|
+
* number — a reconciled figure is money, and "NaN" must never reach a report.
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseAmount(raw: string | undefined): number | null;
|
|
18
76
|
//# sourceMappingURL=stats.d.ts.map
|
package/dist/cli/stats.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/cli/stats.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/cli/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAuC5C,qBAAa,YAAa,SAAQ,WAAW;IAC3C,MAAM,IAAI,OAAO;YAgEH,QAAQ;IAWtB;;;;;;;;;;;OAWG;YACW,aAAa;IA8B3B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAkHlB;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAwD5B;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,YAAY;CAYrB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAOlE"}
|
package/dist/cli/stats.js
CHANGED
|
@@ -2,16 +2,38 @@
|
|
|
2
2
|
* Stats command — View usage statistics and cost tracking.
|
|
3
3
|
*
|
|
4
4
|
* Usage:
|
|
5
|
-
* nuvira stats
|
|
6
|
-
* nuvira stats cost
|
|
7
|
-
* nuvira stats cost --clear
|
|
8
|
-
* nuvira stats
|
|
5
|
+
* nuvira stats — Show all stats summary
|
|
6
|
+
* nuvira stats cost — Show cost tracking details
|
|
7
|
+
* nuvira stats cost --clear — Reset cost tracking data
|
|
8
|
+
* nuvira stats cost reconcile ... — compare the ledger to a provider invoice
|
|
9
|
+
* nuvira stats cost reprice — re-price legacy rows (dry run; --apply writes)
|
|
10
|
+
* nuvira stats history — Show conversation history stats
|
|
11
|
+
*
|
|
12
|
+
* ─── WHY reconcile / reprice EXIST (read before editing their defaults) ─────
|
|
13
|
+
*
|
|
14
|
+
* `stats cost` prints what the ledger can EVIDENCE, and the ledger cannot see a
|
|
15
|
+
* provider's invoice. That is not a defect to paper over with a nicer estimate:
|
|
16
|
+
* the fix is to let the operator supply the one number that is actual — the
|
|
17
|
+
* provider's own charge for a stated window — and to say honestly how far the
|
|
18
|
+
* ledger is from it, and what the gap consists of. `reconcile` is therefore the
|
|
19
|
+
* only command in this file that reports a figure no local computation could
|
|
20
|
+
* produce, and it never adjusts the ledger to agree.
|
|
21
|
+
*
|
|
22
|
+
* `reprice` is the explicit, dry-run-default repair of the rows already on disk
|
|
23
|
+
* (legacy prices from the retired hardcoded table, test-origin rows). Both are
|
|
24
|
+
* documented in `learning/cost-reconcile.ts` and `learning/cost-ledger-maintenance.ts`.
|
|
9
25
|
*/
|
|
10
26
|
import { Command } from 'commander';
|
|
11
27
|
import { BaseCommand } from './commands.js';
|
|
12
|
-
import { getCostTracker } from '../learning/cost-tracker.js';
|
|
28
|
+
import { getCostTracker, resetPricingContextCache, } from '../learning/cost-tracker.js';
|
|
29
|
+
import { asBillingTier, BILLING_TIERS } from '../learning/model-pricing.js';
|
|
30
|
+
import { formatReconciliation, reconcileEntries, recordReconciliation, reconciliationLedgerPath, } from '../learning/cost-reconcile.js';
|
|
31
|
+
import { formatMaintenanceReport, maintainCostLedger } from '../learning/cost-ledger-maintenance.js';
|
|
32
|
+
import { CATALOG_PROVIDER_IDS } from '../inference/provider-catalog.js';
|
|
13
33
|
import { getChatHistory } from '../context/history.js';
|
|
14
34
|
import { logger } from '../utils/logger.js';
|
|
35
|
+
/** One day in ms — the unit the CLI's window flags speak in. */
|
|
36
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
15
37
|
export class StatsCommand extends BaseCommand {
|
|
16
38
|
create() {
|
|
17
39
|
const command = new Command('stats')
|
|
@@ -23,6 +45,30 @@ export class StatsCommand extends BaseCommand {
|
|
|
23
45
|
.action(async (options) => {
|
|
24
46
|
await this.showCost(options);
|
|
25
47
|
});
|
|
48
|
+
// ── cost reconcile ───────────────────────────────────────────────────
|
|
49
|
+
costCmd.addCommand(new Command('reconcile')
|
|
50
|
+
.description("Compare this ledger to a provider's OWN invoice for a window (the only 'actual' figure)")
|
|
51
|
+
.requiredOption('-p, --provider <id>', 'provider id the invoice line belongs to (e.g. deepseek)')
|
|
52
|
+
.requiredOption('-a, --amount <usd>', "the provider's own charge for the window, in USD (e.g. 12.34)")
|
|
53
|
+
.option('--days <n>', `window: the last N days, ending now (default: the current calendar month)`)
|
|
54
|
+
.option('--since <iso|epochMs>', 'window start (overrides --days)')
|
|
55
|
+
.option('--until <iso|epochMs>', 'window end, exclusive (default: now)')
|
|
56
|
+
.option('--note <text>', 'where the figure came from, printed with the result (e.g. "dashboard, Oct 2026")')
|
|
57
|
+
.option('--declare-tier [tier]', 'record the billing fact this invoice EVIDENCES (paid|free|subscription); no value = the tier the invoice proves')
|
|
58
|
+
.option('--json', 'machine-readable JSON report')
|
|
59
|
+
.action(async (options) => {
|
|
60
|
+
await this.reconcileCost(options);
|
|
61
|
+
}));
|
|
62
|
+
// ── cost reprice ─────────────────────────────────────────────────────
|
|
63
|
+
costCmd.addCommand(new Command('reprice')
|
|
64
|
+
.description('Re-price legacy ledger rows with the ONE price source; drop test rows (dry run by default)')
|
|
65
|
+
.option('--apply', 'write the repaired ledger (a .bak is kept beside it)')
|
|
66
|
+
.option('--keep-test-rows', 're-price only: do NOT drop test-origin / fixture-id rows')
|
|
67
|
+
.option('--file <path>', 'a specific cost ledger file (default: the resolved profile ledger)')
|
|
68
|
+
.option('--json', 'machine-readable JSON report')
|
|
69
|
+
.action((options) => {
|
|
70
|
+
this.repriceLedger(options);
|
|
71
|
+
}));
|
|
26
72
|
command.addCommand(costCmd);
|
|
27
73
|
// ── history ──────────────────────────────────────────────────────────
|
|
28
74
|
const historyCmd = new Command('history')
|
|
@@ -46,6 +92,221 @@ export class StatsCommand extends BaseCommand {
|
|
|
46
92
|
const tracker = getCostTracker();
|
|
47
93
|
console.log(`\n${tracker.formatSummary()}`);
|
|
48
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* `stats cost reconcile` — the provider's own figure vs this ledger.
|
|
97
|
+
*
|
|
98
|
+
* Two rules the defaults encode:
|
|
99
|
+
* 1. A WINDOW IS MANDATORY. Comparing an all-time ledger to a monthly invoice
|
|
100
|
+
* is a meaningless subtraction that would print a delta as if it meant
|
|
101
|
+
* something. The default is the current calendar month, and the window is
|
|
102
|
+
* always printed so a partial (still-running) period can be judged as such.
|
|
103
|
+
* 2. THE PROVIDER IS VALIDATED. An unknown id would otherwise read as "no
|
|
104
|
+
* rows", i.e. a silent zero that looks like "you used nothing" rather than
|
|
105
|
+
* "you typed the wrong id".
|
|
106
|
+
*/
|
|
107
|
+
async reconcileCost(options) {
|
|
108
|
+
const claim = this.buildClaim(options);
|
|
109
|
+
if (!claim)
|
|
110
|
+
return;
|
|
111
|
+
const report = reconcileEntries(claim, getCostTracker().getAllEntries());
|
|
112
|
+
// The record is the audit trail: "this was checked against the October
|
|
113
|
+
// invoice, and the gap was $0.03". A later check appends; nothing is erased.
|
|
114
|
+
recordReconciliation(report);
|
|
115
|
+
if (options.json) {
|
|
116
|
+
console.log(JSON.stringify(report, null, 2));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
console.log(`\n${formatReconciliation(report)}`);
|
|
120
|
+
console.log(` Recorded in ${reconciliationLedgerPath()}\n`);
|
|
121
|
+
if (options.declareTier !== undefined) {
|
|
122
|
+
this.applyTierDeclaration(claim.provider, options.declareTier, report);
|
|
123
|
+
}
|
|
124
|
+
else if (report.tierEvidence) {
|
|
125
|
+
// Evidence was found but recording it is the operator's call: writing a
|
|
126
|
+
// config field on the strength of a run they may not have intended as a
|
|
127
|
+
// declaration would be its own kind of assumption.
|
|
128
|
+
logger.info(` This invoice EVIDENCES billingTier=${report.tierEvidence.tier} for ${claim.provider}. Record it with:\n` +
|
|
129
|
+
` nuvira stats cost reconcile --provider ${claim.provider} --amount ${claim.invoiceUsd} --declare-tier`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Turn the CLI flags into an invoice claim, or explain why they cannot be.
|
|
134
|
+
* Returns null after printing the reason — the command exits without a report
|
|
135
|
+
* rather than reconciling against a window we had to guess.
|
|
136
|
+
*/
|
|
137
|
+
buildClaim(options) {
|
|
138
|
+
const provider = (options.provider || '').trim();
|
|
139
|
+
const known = new Set([
|
|
140
|
+
...CATALOG_PROVIDER_IDS,
|
|
141
|
+
...Object.keys(this.configManager.getAll().providers || {}),
|
|
142
|
+
// Ids that appear in the ledger are real even when they are not in the
|
|
143
|
+
// catalog (a plugin provider, a sidecar gateway) — never reject those.
|
|
144
|
+
...getCostTracker()
|
|
145
|
+
.getAllEntries()
|
|
146
|
+
.map((e) => e.provider),
|
|
147
|
+
]);
|
|
148
|
+
if (!known.has(provider)) {
|
|
149
|
+
logger.error(`Unknown provider "${provider}". Known ids: ${[...known].sort().join(', ')}`);
|
|
150
|
+
logger.info(' Use the id the ledger records (the `By Provider` table of `nuvira stats cost`) — reconciling against a typo would report zero usage.');
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const invoiceUsd = parseAmount(options.amount);
|
|
154
|
+
if (invoiceUsd === null) {
|
|
155
|
+
logger.error(`Invalid --amount "${options.amount}". Pass the provider's charge in USD, e.g. --amount 12.34 (0 is valid: nothing was charged).`);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const now = Date.now();
|
|
159
|
+
let since;
|
|
160
|
+
let until;
|
|
161
|
+
const parseWhen = (raw, label) => {
|
|
162
|
+
const asNumber = Number(raw);
|
|
163
|
+
if (Number.isFinite(asNumber) && asNumber > 0)
|
|
164
|
+
return asNumber;
|
|
165
|
+
const parsed = Date.parse(raw);
|
|
166
|
+
if (Number.isFinite(parsed))
|
|
167
|
+
return parsed;
|
|
168
|
+
logger.error(`Invalid ${label} "${raw}". Use an ISO date (2026-10-01) or epoch milliseconds.`);
|
|
169
|
+
return null;
|
|
170
|
+
};
|
|
171
|
+
if (options.since !== undefined) {
|
|
172
|
+
if (options.days !== undefined) {
|
|
173
|
+
logger.error('Use either --since or --days, not both — the window must be unambiguous.');
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const parsed = parseWhen(options.since, '--since');
|
|
177
|
+
if (parsed === null)
|
|
178
|
+
return null;
|
|
179
|
+
since = parsed;
|
|
180
|
+
}
|
|
181
|
+
else if (options.days !== undefined) {
|
|
182
|
+
const days = Number(options.days);
|
|
183
|
+
if (!Number.isFinite(days) || days <= 0) {
|
|
184
|
+
logger.error(`Invalid --days "${options.days}". Pass a positive number of days.`);
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
since = now - days * DAY_MS;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// The current calendar month, local time — what most providers bill in.
|
|
191
|
+
const start = new Date(now);
|
|
192
|
+
start.setDate(1);
|
|
193
|
+
start.setHours(0, 0, 0, 0);
|
|
194
|
+
since = start.getTime();
|
|
195
|
+
if (since > now) {
|
|
196
|
+
// A clock at the very start of the month: fall back to the last 24h so
|
|
197
|
+
// the window is never empty-by-construction.
|
|
198
|
+
since = now - DAY_MS;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (options.until !== undefined) {
|
|
202
|
+
const parsed = parseWhen(options.until, '--until');
|
|
203
|
+
if (parsed === null)
|
|
204
|
+
return null;
|
|
205
|
+
until = parsed;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// HALF-OPEN WINDOW, INCLUSIVE-AT-THE-END DEFAULT. A ledger row's timestamp
|
|
209
|
+
// is `Date.now()` at record time and so is this one, in the SAME
|
|
210
|
+
// millisecond resolution — so a default end of exactly `now` drops a row
|
|
211
|
+
// recorded a moment earlier. MEASURED while writing these tests: the row
|
|
212
|
+
// landed ON `until` and the report said "no ledger rows in this window".
|
|
213
|
+
// A boundary the operator did not state has no business excluding
|
|
214
|
+
// anything, so the default end is one millisecond past now. An EXPLICIT
|
|
215
|
+
// `--until` keeps the half-open meaning, so reconciling September and then
|
|
216
|
+
// October cannot count a midnight-boundary row twice.
|
|
217
|
+
until = now + 1;
|
|
218
|
+
}
|
|
219
|
+
if (until <= since) {
|
|
220
|
+
logger.error('The window end must be after its start.');
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const startOfMonth = new Date(since);
|
|
224
|
+
if (until > now - 60_000 && startOfMonth.getDate() === 1) {
|
|
225
|
+
logger.info(' Note: the window runs up to now, so if this billing period has not closed the invoice may still be partial.');
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
provider,
|
|
229
|
+
invoiceUsd,
|
|
230
|
+
since,
|
|
231
|
+
until,
|
|
232
|
+
...(options.note ? { note: options.note } : {}),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Record the billing fact, but ONLY one the invoice does not contradict.
|
|
237
|
+
*
|
|
238
|
+
* This is the whole point of the exercise: `billingTier` moves the headline
|
|
239
|
+
* from "unverified" to "billed", so letting a user declare `free` while holding
|
|
240
|
+
* an invoice that charged $18 would reintroduce exactly the fabricated picture
|
|
241
|
+
* this change removed. A refusal is the useful answer.
|
|
242
|
+
*/
|
|
243
|
+
applyTierDeclaration(provider, requested, report) {
|
|
244
|
+
let tier;
|
|
245
|
+
if (requested === true) {
|
|
246
|
+
if (!report.tierEvidence) {
|
|
247
|
+
logger.error('This reconciliation does not prove a billing tier — the CLI will not guess one. Pass it explicitly if you know it: --declare-tier paid|free|subscription');
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
tier = report.tierEvidence.tier;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const typed = asBillingTier(String(requested).trim().toLowerCase());
|
|
254
|
+
if (!BILLING_TIERS.includes(String(requested).trim().toLowerCase())) {
|
|
255
|
+
logger.error(`Invalid tier "${String(requested)}". Valid values: ${BILLING_TIERS.join(' | ')}.`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
tier = typed;
|
|
259
|
+
}
|
|
260
|
+
// The invoice is evidence against these two claims; refuse rather than write
|
|
261
|
+
// a fact the provider's own bill contradicts.
|
|
262
|
+
if ((tier === 'free' || tier === 'subscription') && report.invoiceUsd > 0) {
|
|
263
|
+
logger.error(`Refusing to declare "${tier}": the invoice you entered charged $${report.invoiceUsd.toFixed(6)} for this window, so this key IS billed per call. Declare \`paid\` (metered), or \`subscription\` only if a flat plan covers these calls and the charge you entered is that plan's fee.`);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (tier === 'paid' && report.invoiceUsd === 0 && report.requests > 0) {
|
|
267
|
+
logger.error(`Refusing to declare "paid": the invoice you entered is $0 across ${report.requests} call(s), so nothing was charged. Declare \`free\`, or re-run with the correct invoice amount.`);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.configManager.save({ providers: { [provider]: { billingTier: tier } } });
|
|
271
|
+
// The classification context caches a config read for the process; drop it so
|
|
272
|
+
// any later read in this process (tests, a wrapper) sees the new fact.
|
|
273
|
+
resetPricingContextCache();
|
|
274
|
+
logger.success(`Recorded providers.${provider}.billingTier = ${tier} — evidenced by the invoice, not assumed.`);
|
|
275
|
+
if (tier === 'paid') {
|
|
276
|
+
logger.info(' List-priced calls for this provider now count as an estimated bill (the invoice remains the actual figure).');
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
logger.info(' Calls for this provider are now $0 billed by evidence; their list price is reported as value, never spend.');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* `stats cost reprice` — the explicit repair of the rows already on disk.
|
|
284
|
+
*
|
|
285
|
+
* Dry run by default: the ledger is the user's billing history, and a reprice
|
|
286
|
+
* changes every legacy figure in it. `--apply` writes once, after taking a
|
|
287
|
+
* backup, and the report says exactly what changed either way.
|
|
288
|
+
*/
|
|
289
|
+
repriceLedger(options) {
|
|
290
|
+
const report = maintainCostLedger({
|
|
291
|
+
...(options.file ? { file: options.file } : {}),
|
|
292
|
+
apply: options.apply === true,
|
|
293
|
+
pruneTestRows: options.keepTestRows !== true,
|
|
294
|
+
});
|
|
295
|
+
if (options.json) {
|
|
296
|
+
console.log(JSON.stringify(report, null, 2));
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
console.log(`\n${formatMaintenanceReport(report)}`);
|
|
300
|
+
if (report.applied) {
|
|
301
|
+
logger.success(`Ledger re-priced: ${report.rows.repriced} row(s) repaired, ${report.rows.testOriginRemoved + report.rows.fixtureRemoved} test row(s) removed.`);
|
|
302
|
+
// A reprice rewrites the stored figures; anything cached for classification
|
|
303
|
+
// in this process is now stale by definition.
|
|
304
|
+
resetPricingContextCache();
|
|
305
|
+
}
|
|
306
|
+
else if (report.rows.repriced + report.rows.testOriginRemoved + report.rows.fixtureRemoved > 0) {
|
|
307
|
+
logger.info(' Re-run with --apply to write (a .bak is kept beside the ledger).');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
49
310
|
showHistoryStats() {
|
|
50
311
|
const history = getChatHistory();
|
|
51
312
|
const total = history.count();
|
|
@@ -75,4 +336,20 @@ export class StatsCommand extends BaseCommand {
|
|
|
75
336
|
}
|
|
76
337
|
}
|
|
77
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Parse a currency amount the way a user copies it off a dashboard: `$12.34`,
|
|
341
|
+
* `1,234.56`, ` 12.34 `. Returns null when it is not a non-negative finite
|
|
342
|
+
* number — a reconciled figure is money, and "NaN" must never reach a report.
|
|
343
|
+
*/
|
|
344
|
+
export function parseAmount(raw) {
|
|
345
|
+
if (raw === undefined)
|
|
346
|
+
return null;
|
|
347
|
+
const cleaned = String(raw).replace(/[$,\s]/g, '');
|
|
348
|
+
if (cleaned === '')
|
|
349
|
+
return null;
|
|
350
|
+
const value = Number(cleaned);
|
|
351
|
+
if (!Number.isFinite(value) || value < 0)
|
|
352
|
+
return null;
|
|
353
|
+
return Math.round(value * 1e6) / 1e6;
|
|
354
|
+
}
|
|
78
355
|
//# sourceMappingURL=stats.js.map
|
package/dist/cli/stats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.js","s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OAAO,IAAI,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnD,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACvC,CAAC"}
|
package/dist/cli/ui/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export { attachShellCards, diffLineRole, formatDuration, gitDiffCard, shellCard,
|
|
|
16
16
|
export type { ShellEndPayload, ToolCallCardInfo } from './cards.js';
|
|
17
17
|
export { LiveAnswer } from './answer-view.js';
|
|
18
18
|
export type { LiveAnswerProps } from './answer-view.js';
|
|
19
|
-
export { AnswerStream, createCardSink, presentAnswer, presentCard, renderAnswer, shouldUseRichUi, } from './presenter.js';
|
|
20
|
-
export type { CardSinkOverrides, PresenterOptions, StreamMeta } from './presenter.js';
|
|
19
|
+
export { AnswerStream, createCardSink, createRunStream, presentAnswer, presentCard, renderAnswer, shouldUseRichUi, THINKING_NOTE, } from './presenter.js';
|
|
20
|
+
export type { CardSinkOverrides, PresenterOptions, RunStream, RunStreamOverrides, StreamMeta, } from './presenter.js';
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,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OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrF,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,UAAU,GACX,MAAM,gBAAgB,CAAC"}
|
package/dist/cli/ui/index.js
CHANGED
|
@@ -10,5 +10,5 @@ export { parseMarkdown, parseInline, inlineText, blocksToPlainText } from './mar
|
|
|
10
10
|
export { renderMarkdown, renderBlocks, renderCard, visibleWidth } from './render.js';
|
|
11
11
|
export { attachShellCards, diffLineRole, formatDuration, gitDiffCard, shellCard, toolCallCard, } from './cards.js';
|
|
12
12
|
export { LiveAnswer } from './answer-view.js';
|
|
13
|
-
export { AnswerStream, createCardSink, presentAnswer, presentCard, renderAnswer, shouldUseRichUi, } from './presenter.js';
|
|
13
|
+
export { AnswerStream, createCardSink, createRunStream, presentAnswer, presentCard, renderAnswer, shouldUseRichUi, THINKING_NOTE, } from './presenter.js';
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAG1F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGrF,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAG1F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGrF,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,gBAAgB,CAAC"}
|
|
@@ -73,6 +73,49 @@ export interface StreamMeta {
|
|
|
73
73
|
headerColor?: ThemeRole;
|
|
74
74
|
note?: string;
|
|
75
75
|
}
|
|
76
|
+
/** The live seams a RUNNING turn exposes to a view (all optional). */
|
|
77
|
+
export interface RunStreamOverrides extends CardSinkOverrides {
|
|
78
|
+
/** Verbatim model tokens: the answer as it is written. */
|
|
79
|
+
onToken?: (token: string) => void;
|
|
80
|
+
/** The step the run is on — the executor's own progress line. */
|
|
81
|
+
onProgress?: (line: string) => void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The live EXECUTION view — what the turn is doing, while it does it.
|
|
85
|
+
*
|
|
86
|
+
* Wraps {@link AnswerStream} with the seams a whole turn has (not just the final
|
|
87
|
+
* answer):
|
|
88
|
+
*
|
|
89
|
+
* - `start()` mounts the frame IMMEDIATELY with a `thinking…` note, so the
|
|
90
|
+
* seconds spent waiting for the first token are visible instead of looking
|
|
91
|
+
* like a hang;
|
|
92
|
+
* - `onToken` streams the answer text as it is written (`begin()` on the first
|
|
93
|
+
* token, exactly like the chat surfaces' live preview);
|
|
94
|
+
* - `onToolCall` / `onGitDiff` / the shell bus archive a CARD per completed
|
|
95
|
+
* call, and put the RUNNING call in the note (`⚙ edit_file …`) so the
|
|
96
|
+
* execution half is visible too, not only the prose;
|
|
97
|
+
* - `onProgress` shows the executor's own progress line in the same note slot;
|
|
98
|
+
* - `commit(content)` unmounts the transient frame and prints the FINAL answer
|
|
99
|
+
* once. The live frame is a preview of a stream that may be discarded by the
|
|
100
|
+
* engine (a rejected step, a repair); the authoritative text is what the
|
|
101
|
+
* caller passes here, so it can never be printed twice.
|
|
102
|
+
*
|
|
103
|
+
* Off a real terminal (`pipes`, CI, `--json-events`, `NUVIRA_UI=plain`) this is
|
|
104
|
+
* INERT: no overrides, no frame, and `commit` falls through to `presentAnswer` —
|
|
105
|
+
* the exact bytes those consumers saw before this existed.
|
|
106
|
+
*/
|
|
107
|
+
export interface RunStream {
|
|
108
|
+
overrides: RunStreamOverrides;
|
|
109
|
+
/** Mount the live view now, with a note (rich output only). */
|
|
110
|
+
start: (note?: string) => void;
|
|
111
|
+
/** Unmount the live view and print the FINAL answer exactly once. */
|
|
112
|
+
commit: (content: string) => void;
|
|
113
|
+
/** Detach the shell subscription and leave the terminal clean. */
|
|
114
|
+
stop: () => void;
|
|
115
|
+
}
|
|
116
|
+
/** The note shown while the model is working and nothing has arrived yet. */
|
|
117
|
+
export declare const THINKING_NOTE = "thinking\u2026";
|
|
118
|
+
export declare function createRunStream(meta?: StreamMeta, opts?: PresenterOptions): RunStream;
|
|
76
119
|
/**
|
|
77
120
|
* Live-streaming answer view.
|
|
78
121
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenter.d.ts","sourceRoot":"","sources":["../../../src/cli/ui/presenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAA+C,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAgB,KAAK,KAAK,EAAkB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,sDAAsD;IACtD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,C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CAAC,CAAW;IAC7B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,GAAG,CAAyB;IACpC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,IAAI,GAAE,UAAe,EAAE,IAAI,GAAE,gBAAqB;IAK9D,oEAAoE;IACpE,KAAK,CAAC,IAAI,GAAE,UAAe,GAAG,IAAI;IAMlC,sEAAsE;IACtE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAMvC,+DAA+D;IAC/D,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAMvC;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;IAMb,mCAAmC;IACnC,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;;;;;OAOG;IACH,KAAK,IAAI,IAAI;IAiBb,kFAAkF;IAClF,MAAM,IAAI,IAAI;IAOd;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAS7B,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,OAAO;IAUf,kEAAkE;IAClE,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,OAAO;IASf;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,GAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,MAAM;CAyBjD"}
|
package/dist/cli/ui/presenter.js
CHANGED
|
@@ -36,7 +36,13 @@ function resolve(opts) {
|
|
|
36
36
|
const env = opts.env ?? process.env;
|
|
37
37
|
const stream = opts.stream ?? process.stdout;
|
|
38
38
|
const { name, theme } = resolveTheme(env);
|
|
39
|
-
|
|
39
|
+
// A terminal that does not KNOW its size reports `columns` as 0 (or undefined),
|
|
40
|
+
// and `?? 80` only catches the undefined half: a 0 flowed all the way into the
|
|
41
|
+
// renderer, where `Painter` floors the width at 20 — measured on a PTY with no
|
|
42
|
+
// window size, a code box came out 14 columns wide with its lines cut mid-token
|
|
43
|
+
// ("const cap = 20 / 0;"). A width that cannot be read is 80, not 20.
|
|
44
|
+
const columns = opts.width ?? stream.columns;
|
|
45
|
+
const width = typeof columns === 'number' && columns > 0 ? columns : 80;
|
|
40
46
|
const rich = shouldUseRichUi(opts);
|
|
41
47
|
const color = opts.color ?? (name !== 'none' && !('NO_COLOR' in env));
|
|
42
48
|
return { rich, theme: opts.theme ?? theme, themeName: name, width, color, stream };
|
|
@@ -115,6 +121,87 @@ export function createCardSink(opts = {}) {
|
|
|
115
121
|
stop: attachShellCards(write),
|
|
116
122
|
};
|
|
117
123
|
}
|
|
124
|
+
/** The note shown while the model is working and nothing has arrived yet. */
|
|
125
|
+
export const THINKING_NOTE = 'thinking…';
|
|
126
|
+
export function createRunStream(meta = {}, opts = {}) {
|
|
127
|
+
if (!shouldUseRichUi(opts)) {
|
|
128
|
+
return {
|
|
129
|
+
overrides: {},
|
|
130
|
+
start: () => { },
|
|
131
|
+
// Byte-identical to the pre-layer path: the plain answer, written the way
|
|
132
|
+
// this CLI has always written it.
|
|
133
|
+
commit: (content) => {
|
|
134
|
+
presentAnswer(content, opts);
|
|
135
|
+
},
|
|
136
|
+
stop: () => { },
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const stream = new AnswerStream(meta, opts);
|
|
140
|
+
let started = false;
|
|
141
|
+
let stopped = false;
|
|
142
|
+
const detachShell = attachShellCards((card) => stream.card(card));
|
|
143
|
+
/** Show a note without losing the frame (mounting it if it is not up yet). */
|
|
144
|
+
const noteFor = (note) => {
|
|
145
|
+
if (!started) {
|
|
146
|
+
started = true;
|
|
147
|
+
stream.begin({ ...meta, ...(note === undefined ? {} : { note }) });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
stream.setNote(note);
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
overrides: {
|
|
154
|
+
onToken: (token) => {
|
|
155
|
+
if (!started) {
|
|
156
|
+
started = true;
|
|
157
|
+
stream.begin(meta);
|
|
158
|
+
}
|
|
159
|
+
// The text is the signal now — a stale `thinking…` beside streaming
|
|
160
|
+
// prose reads as a hang that is not happening.
|
|
161
|
+
stream.setNote(undefined);
|
|
162
|
+
stream.append(token);
|
|
163
|
+
},
|
|
164
|
+
onProgress: (line) => noteFor(line),
|
|
165
|
+
onToolCall: (phase, info) => {
|
|
166
|
+
if (phase === 'started') {
|
|
167
|
+
// The step's preamble is not the answer: clear it so the preview shows
|
|
168
|
+
// the call that is actually running (same rule as the chat REPL).
|
|
169
|
+
if (started)
|
|
170
|
+
stream.reset();
|
|
171
|
+
noteFor(`⚙ ${info.tool} …`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (started)
|
|
175
|
+
stream.setNote(undefined);
|
|
176
|
+
stream.card(toolCallCard({
|
|
177
|
+
tool: info.tool,
|
|
178
|
+
ok: info.ok,
|
|
179
|
+
error: info.error,
|
|
180
|
+
result: info.result,
|
|
181
|
+
durationMs: info.durationMs,
|
|
182
|
+
args: info.args,
|
|
183
|
+
}));
|
|
184
|
+
},
|
|
185
|
+
onGitDiff: (payload) => stream.card(gitDiffCard(payload)),
|
|
186
|
+
},
|
|
187
|
+
start: (note) => noteFor(note ?? THINKING_NOTE),
|
|
188
|
+
commit: (content) => {
|
|
189
|
+
// Unmount WITHOUT archiving: the preview is not authoritative, and the
|
|
190
|
+
// caller's sanitized answer is written right below.
|
|
191
|
+
stream.finish({ archive: false });
|
|
192
|
+
presentAnswer(content, opts);
|
|
193
|
+
},
|
|
194
|
+
stop: () => {
|
|
195
|
+
// Idempotent on purpose: a caller stops on the failure path AND in a
|
|
196
|
+
// `finally`, and detaching the shell bus twice must not be a problem.
|
|
197
|
+
if (stopped)
|
|
198
|
+
return;
|
|
199
|
+
stopped = true;
|
|
200
|
+
detachShell();
|
|
201
|
+
stream.finish({ archive: false });
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
118
205
|
/**
|
|
119
206
|
* Live-streaming answer view.
|
|
120
207
|
*
|