@skrr-ai/cli 0.1.182 → 0.1.184
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/commands/balance/usage/events.js +59 -7
- package/dist/commands/machines/list.js +9 -0
- package/dist/lib/machines.d.ts +18 -1
- package/dist/lib/machines.js +35 -2
- package/dist/node_modules/@skrr-ai/data-provider/index.js +9745 -9688
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -5,6 +5,43 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const auth_core_1 = require("@skrr-ai/auth-core");
|
|
6
6
|
const base_command_1 = require("../../../base-command");
|
|
7
7
|
const balance_1 = require("../../../lib/balance");
|
|
8
|
+
/** Why the gateway's own record of a turn disagreed with its charge (OSK-24709). */
|
|
9
|
+
const GATEWAY_VERDICT_LABELS = {
|
|
10
|
+
charge_exceeds_gateway: 'charged more than the gateway recorded',
|
|
11
|
+
gateway_exceeds_charge: 'gateway recorded more than the charge',
|
|
12
|
+
model_mismatch: 'charged at a model the gateway did not serve',
|
|
13
|
+
};
|
|
14
|
+
/** Why part or all of an overcharge was recorded rather than credited. */
|
|
15
|
+
const UNCREDITED_REASON_LABELS = {
|
|
16
|
+
included_allowance: 'paid from included allowance, which a credit does not restore',
|
|
17
|
+
postpaid_accrual: 'accrued to a postpaid bill rather than paid from balance',
|
|
18
|
+
group_settlement: 'paid by its reservation group, not by this turn alone',
|
|
19
|
+
no_captured_hold: 'no captured balance paid for this turn',
|
|
20
|
+
already_refunded: 'the charge was already refunded',
|
|
21
|
+
};
|
|
22
|
+
/** Exact to the micro: a correction is usually sub-cent, and rounding it would misstate it. */
|
|
23
|
+
function exactUsd(micros) {
|
|
24
|
+
return `$${(micros / 1_000_000).toFixed(6)}`;
|
|
25
|
+
}
|
|
26
|
+
function renderGatewayAdjustment(adjustment, log) {
|
|
27
|
+
const why = GATEWAY_VERDICT_LABELS[adjustment.verdict] ?? adjustment.verdict;
|
|
28
|
+
log(` Gateway check: ${why} · charged ${adjustment.chargedUsageMicros} · gateway ${adjustment.gatewayUsageMicros} customer_usage_micros`);
|
|
29
|
+
if (adjustment.kind === 'credit') {
|
|
30
|
+
log(` credited ${exactUsd(adjustment.creditedMicros)} back to balance · ledger entry ${adjustment.balanceLedgerEntryId ?? 'unknown'}`);
|
|
31
|
+
}
|
|
32
|
+
else if (adjustment.differenceUsageMicros > 0) {
|
|
33
|
+
log(` recorded ${adjustment.differenceUsageMicros} customer_usage_micros above the charge; the difference is not debited`);
|
|
34
|
+
}
|
|
35
|
+
else if (adjustment.uncreditedUsageMicros === 0) {
|
|
36
|
+
log(' recorded; within the tolerance, so nothing was credited');
|
|
37
|
+
}
|
|
38
|
+
if (adjustment.uncreditedUsageMicros > 0) {
|
|
39
|
+
const reason = adjustment.uncreditedReason
|
|
40
|
+
? (UNCREDITED_REASON_LABELS[adjustment.uncreditedReason] ?? adjustment.uncreditedReason)
|
|
41
|
+
: 'reason not recorded';
|
|
42
|
+
log(` ${adjustment.uncreditedUsageMicros} customer_usage_micros not credited (${reason})`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
8
45
|
class BalanceUsageEvents extends base_command_1.BaseCommand {
|
|
9
46
|
static description = `List settled ${auth_core_1.FIRST_PARTY_HARNESS.displayName} usage and its run/session attribution`;
|
|
10
47
|
static examples = [
|
|
@@ -15,11 +52,17 @@ class BalanceUsageEvents extends base_command_1.BaseCommand {
|
|
|
15
52
|
];
|
|
16
53
|
static flags = {
|
|
17
54
|
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
18
|
-
from: core_1.Flags.string({
|
|
19
|
-
|
|
55
|
+
from: core_1.Flags.string({
|
|
56
|
+
description: 'Inclusive ISO start time; YYYY-MM-DD means midnight UTC; defaults to 30 days before end',
|
|
57
|
+
}),
|
|
58
|
+
to: core_1.Flags.string({
|
|
59
|
+
description: 'Inclusive ISO end time; YYYY-MM-DD means midnight UTC, not end of day; defaults to now',
|
|
60
|
+
}),
|
|
20
61
|
cursor: core_1.Flags.string({ description: 'Opaque cursor returned by the previous page' }),
|
|
21
62
|
limit: core_1.Flags.integer({ description: 'Rows to return (1-200)', min: 1, max: 200, default: 50 }),
|
|
22
|
-
'legacy-charges': core_1.Flags.boolean({
|
|
63
|
+
'legacy-charges': core_1.Flags.boolean({
|
|
64
|
+
description: 'Show legacy service-charge records; status is not shown and totals overlap settlements',
|
|
65
|
+
}),
|
|
23
66
|
};
|
|
24
67
|
async run() {
|
|
25
68
|
this.requireAuth();
|
|
@@ -40,7 +83,10 @@ class BalanceUsageEvents extends base_command_1.BaseCommand {
|
|
|
40
83
|
}
|
|
41
84
|
if (flags.json) {
|
|
42
85
|
this.log(JSON.stringify(events?.version === 1 && !flags['legacy-charges']
|
|
43
|
-
? {
|
|
86
|
+
? {
|
|
87
|
+
...events,
|
|
88
|
+
scopeWarning: 'This server only returned legacy service-charge records; their status and included allowance usage are not shown.',
|
|
89
|
+
}
|
|
44
90
|
: events, null, 2));
|
|
45
91
|
return;
|
|
46
92
|
}
|
|
@@ -73,18 +119,24 @@ function renderUsageEvents(events, log) {
|
|
|
73
119
|
.join(' · ');
|
|
74
120
|
if (events.version === 2 && 'authorizationId' in item) {
|
|
75
121
|
const usage = item.usageMicros == null ? 'usage unknown' : `${item.usageMicros} customer_usage_micros`;
|
|
76
|
-
const balance = item.balanceMicros == null
|
|
122
|
+
const balance = item.balanceMicros == null
|
|
123
|
+
? 'balance unknown'
|
|
124
|
+
: `${(0, balance_1.formatMicros)(item.balanceMicros)} ${item.postpaid ? 'postpaid accrued' : 'balance'}`;
|
|
77
125
|
log(` ${item.settledAt} ${usage} · ${balance} ${providerModel}`);
|
|
78
126
|
log(` ${incurredBy || 'No run/session attribution'} · ${item.sourceType || 'source unknown'} · authorization ${item.authorizationId}`);
|
|
79
|
-
const extra = [
|
|
127
|
+
const extra = [
|
|
128
|
+
item.sourceId ? `source ${item.sourceId}` : null,
|
|
80
129
|
item.dutyId ? `duty ${item.dutyId}` : null,
|
|
81
130
|
item.memberUserId ? `member ${item.memberUserId}` : null,
|
|
82
|
-
item.parentAuthorizationId ? `parent authorization ${item.parentAuthorizationId}` : null
|
|
131
|
+
item.parentAuthorizationId ? `parent authorization ${item.parentAuthorizationId}` : null,
|
|
132
|
+
].filter(Boolean);
|
|
83
133
|
if (extra.length)
|
|
84
134
|
log(` ${extra.join(' · ')}`);
|
|
85
135
|
if (item.entitlementUsageMicros != null || item.degradedUsageMicros != null) {
|
|
86
136
|
log(` Included allowance ${item.entitlementUsageMicros ?? 'unknown'} · degraded allowance ${item.degradedUsageMicros ?? 'unknown'} customer_usage_micros`);
|
|
87
137
|
}
|
|
138
|
+
if (item.gatewayAdjustment)
|
|
139
|
+
renderGatewayAdjustment(item.gatewayAdjustment, log);
|
|
88
140
|
}
|
|
89
141
|
else if ('chargeId' in item) {
|
|
90
142
|
log(` ${item.createdAt} ${(0, balance_1.formatMicros)(item.amountMicros)} ${providerModel}`);
|
|
@@ -105,6 +105,15 @@ class MachinesList extends base_command_1.BaseCommand {
|
|
|
105
105
|
this.log(` ${m.preferences?.name || m.name}: ${m.statusReason}`);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
// A Dedicated Runtime's Claude Code or Codex that needs its owner's sign-in, or
|
|
109
|
+
// whose sign-in its daemon did not report, with the command (OSK-24457). A
|
|
110
|
+
// harness counted online above can still be one that cannot run a turn.
|
|
111
|
+
const signInNotes = (0, machines_1.harnessSignInNotes)(views);
|
|
112
|
+
if (signInNotes.length > 0) {
|
|
113
|
+
this.log('');
|
|
114
|
+
for (const line of signInNotes)
|
|
115
|
+
this.log(line);
|
|
116
|
+
}
|
|
108
117
|
const foldedHistory = views.reduce((sum, view) => sum + (view.hiddenHarnessCount ?? 0), 0);
|
|
109
118
|
if (foldedHistory > 0) {
|
|
110
119
|
this.log('');
|
package/dist/lib/machines.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DaemonContactState, DaemonMaintenanceSummary, MachineIcon, MachineIconPatch } from '@skrr-ai/data-provider';
|
|
1
|
+
import type { DaemonContactState, DaemonMaintenanceSummary, HarnessSignInView, MachineIcon, MachineIconPatch } from '@skrr-ai/data-provider';
|
|
2
2
|
/**
|
|
3
3
|
* machines.ts — request client for `/api/machines`.
|
|
4
4
|
*
|
|
@@ -79,6 +79,13 @@ export interface MachineHarnessRow {
|
|
|
79
79
|
reconnecting?: boolean;
|
|
80
80
|
/** How long ago the connection closed, in ms. Present with `reconnecting`. */
|
|
81
81
|
disconnectedForMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Whether this harness can run a turn on its own sign-in, and the command when
|
|
84
|
+
* it cannot (OSK-24457): the server's `deriveHarnessSignIn` view, present only
|
|
85
|
+
* where it applies (Claude Code or Codex on a Dedicated Runtime). Absent means
|
|
86
|
+
* there is nothing to say, never "signed in".
|
|
87
|
+
*/
|
|
88
|
+
signIn?: HarnessSignInView;
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
91
|
* What a machine's heartbeats say, apart from what its rows are recorded as
|
|
@@ -294,6 +301,16 @@ export interface MachineListView extends Machine {
|
|
|
294
301
|
* registrations that still stand and says how many it left out; `--all` keeps
|
|
295
302
|
* everything.
|
|
296
303
|
*/
|
|
304
|
+
/**
|
|
305
|
+
* The lines `skrr machines list` prints under its table for harnesses that cannot
|
|
306
|
+
* be shown as signed in (OSK-24457): one that needs its owner's sign-in, and one
|
|
307
|
+
* whose state its daemon did not report, each with the command that signs it in.
|
|
308
|
+
* A signed-in or platform-run harness needs no line. The words are the server's
|
|
309
|
+
* view (`signIn.label`, `signIn.command`), so every surface says the same thing.
|
|
310
|
+
*/
|
|
311
|
+
export declare function harnessSignInNotes(machines: ReadonlyArray<Pick<Machine, 'name' | 'preferences'> & {
|
|
312
|
+
harnesses: readonly MachineHarnessRow[];
|
|
313
|
+
}>): string[];
|
|
297
314
|
export declare function machineListView(machine: Machine, options: {
|
|
298
315
|
all: boolean;
|
|
299
316
|
hardwareMachineUuid: string;
|
package/dist/lib/machines.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.summarizeMachineProfiles = summarizeMachineProfiles;
|
|
|
11
11
|
exports.harnessStateLabel = harnessStateLabel;
|
|
12
12
|
exports.summarizeDaemons = summarizeDaemons;
|
|
13
13
|
exports.isThisComputer = isThisComputer;
|
|
14
|
+
exports.harnessSignInNotes = harnessSignInNotes;
|
|
14
15
|
exports.machineListView = machineListView;
|
|
15
16
|
exports.parseMachineIconFlag = parseMachineIconFlag;
|
|
16
17
|
exports.describeMachineIcon = describeMachineIcon;
|
|
@@ -45,7 +46,10 @@ function machineStateLabel(machine) {
|
|
|
45
46
|
// (OSK-16442).
|
|
46
47
|
if (machine.status === 'degraded') {
|
|
47
48
|
const contact = machine.contact?.state;
|
|
48
|
-
if (contact === 'stale' ||
|
|
49
|
+
if (contact === 'stale' ||
|
|
50
|
+
contact === 'reconnecting' ||
|
|
51
|
+
contact === 'unconfirmed' ||
|
|
52
|
+
contact === 'unknown')
|
|
49
53
|
return data_provider_1.DAEMON_CONTACT_WORDS[contact];
|
|
50
54
|
}
|
|
51
55
|
if (machine.status !== 'offline')
|
|
@@ -144,7 +148,14 @@ function newerStamp(a, b) {
|
|
|
144
148
|
return a;
|
|
145
149
|
return new Date(b).getTime() > new Date(a).getTime() ? b : a;
|
|
146
150
|
}
|
|
147
|
-
const RANK = {
|
|
151
|
+
const RANK = {
|
|
152
|
+
online: 0,
|
|
153
|
+
reconnecting: 1,
|
|
154
|
+
unconfirmed: 2,
|
|
155
|
+
unknown: 3,
|
|
156
|
+
stale: 4,
|
|
157
|
+
offline: 5,
|
|
158
|
+
};
|
|
148
159
|
/** The profile a harness row belongs to: the server's field, else the one its legacy daemon id names. */
|
|
149
160
|
function harnessProfileOf(row) {
|
|
150
161
|
if (row.profile)
|
|
@@ -253,6 +264,28 @@ function isThisComputer(machine, hardwareMachineUuid) {
|
|
|
253
264
|
* registrations that still stand and says how many it left out; `--all` keeps
|
|
254
265
|
* everything.
|
|
255
266
|
*/
|
|
267
|
+
/**
|
|
268
|
+
* The lines `skrr machines list` prints under its table for harnesses that cannot
|
|
269
|
+
* be shown as signed in (OSK-24457): one that needs its owner's sign-in, and one
|
|
270
|
+
* whose state its daemon did not report, each with the command that signs it in.
|
|
271
|
+
* A signed-in or platform-run harness needs no line. The words are the server's
|
|
272
|
+
* view (`signIn.label`, `signIn.command`), so every surface says the same thing.
|
|
273
|
+
*/
|
|
274
|
+
function harnessSignInNotes(machines) {
|
|
275
|
+
const lines = [];
|
|
276
|
+
for (const machine of machines) {
|
|
277
|
+
const machineName = machine.preferences?.name || machine.name;
|
|
278
|
+
for (const row of machine.harnesses) {
|
|
279
|
+
const signIn = row.signIn;
|
|
280
|
+
if (!signIn?.applies || !signIn.command)
|
|
281
|
+
continue;
|
|
282
|
+
if (signIn.state !== 'needs_sign_in' && signIn.state !== 'unknown')
|
|
283
|
+
continue;
|
|
284
|
+
lines.push(` ${machineName}: ${row.name} — ${signIn.label}. Sign in with \`${signIn.command}\`.`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return lines;
|
|
288
|
+
}
|
|
256
289
|
function machineListView(machine, options) {
|
|
257
290
|
const rows = machine.harnesses ?? [];
|
|
258
291
|
const daemons = summarizeDaemons(rows, options.activeProfile);
|