@skrr-ai/cli 0.1.151 → 0.1.152
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/agents/chat.d.ts +3 -0
- package/dist/commands/agents/chat.js +27 -0
- package/dist/commands/agents/plan-day.d.ts +3 -0
- package/dist/commands/agents/plan-day.js +31 -8
- package/dist/commands/agents/show.d.ts +3 -0
- package/dist/commands/agents/show.js +59 -3
- package/dist/commands/agents/triggers/list.js +2 -1
- package/dist/commands/balance/usage/breakdown.d.ts +1 -1
- package/dist/commands/balance/usage/breakdown.js +22 -6
- package/dist/commands/balance/usage/events.d.ts +3 -2
- package/dist/commands/balance/usage/events.js +34 -7
- package/dist/commands/duties/observation/summary.js +25 -3
- package/dist/commands/goals/plan-now.js +1 -0
- package/dist/commands/goals/planner-compare.js +11 -0
- package/dist/commands/harnesses/list.d.ts +2 -1
- package/dist/commands/harnesses/list.js +7 -5
- package/dist/commands/harnesses/models.js +1 -1
- package/dist/commands/harnesses/quota.d.ts +9 -11
- package/dist/commands/harnesses/quota.js +83 -18
- package/dist/commands/harnesses/show.js +1 -1
- package/dist/commands/harnesses/usage.d.ts +19 -0
- package/dist/commands/harnesses/usage.js +27 -7
- package/dist/commands/memory/topics/create.js +4 -1
- package/dist/commands/tokens/create.d.ts +3 -4
- package/dist/commands/tokens/create.js +20 -7
- package/dist/commands/triggers/preflight.js +9 -2
- package/dist/lib/agent-model-check.js +3 -1
- package/dist/lib/agentic-stream.js +6 -7
- package/dist/lib/balance.d.ts +5 -2
- package/dist/lib/balance.js +26 -0
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.js +1 -0
- package/dist/lib/harness-labels.d.ts +1 -0
- package/dist/lib/harness-labels.js +4 -0
- package/dist/lib/harnesses.d.ts +35 -0
- package/dist/lib/harnesses.js +8 -0
- package/dist/lib/machines.d.ts +2 -1
- package/dist/lib/machines.js +2 -2
- package/dist/lib/publicEndpoints.generated.d.ts +4 -0
- package/dist/lib/publicEndpoints.generated.js +4 -0
- package/dist/lib/schedule.d.ts +1 -0
- package/dist/lib/schedule.js +4 -4
- package/dist/lib/triggers.d.ts +2 -2
- package/dist/lib/triggers.js +14 -6
- package/dist/lib/update-check.d.ts +1 -1
- package/dist/lib/update-check.js +12 -8
- package/dist/node_modules/@skrr-ai/data-provider/index.js +7367 -7365
- package/oclif.manifest.json +39 -16
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command';
|
|
2
|
+
import { type CurrentQuotaReport } from '../../lib/harnesses';
|
|
2
3
|
/**
|
|
3
4
|
* Claude Code / Codex subscription quota, over time.
|
|
4
5
|
*
|
|
@@ -24,17 +25,9 @@ import { BaseCommand } from '../../base-command';
|
|
|
24
25
|
/**
|
|
25
26
|
* WHY this window is empty — without asserting a cause we cannot know.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* wrong one: three Codex turns were started THROUGH skrr, completed, and were
|
|
31
|
-
* recorded at zero tokens because the harness reported an empty usage envelope.
|
|
32
|
-
* The reader was told, by the one screen whose job is answering "what is my
|
|
33
|
-
* agent costing me", that the cause was something they had not done.
|
|
34
|
-
*
|
|
35
|
-
* The second sentence is the one that was missing, and it is the actionable
|
|
36
|
-
* half: a run skrr saw and could not price is a reportable defect, not a
|
|
37
|
-
* property of the user's habits.
|
|
28
|
+
* The meter belongs to the provider account; our token ledger is per harness
|
|
29
|
+
* and may include several machines. An empty table does not identify the cause
|
|
30
|
+
* of missing usage, and recorded tokens do not imply a reported price.
|
|
38
31
|
*/
|
|
39
32
|
export declare function unpricedWindowLines(): string[];
|
|
40
33
|
export default class HarnessesQuota extends BaseCommand {
|
|
@@ -43,6 +36,7 @@ export default class HarnessesQuota extends BaseCommand {
|
|
|
43
36
|
static flags: {
|
|
44
37
|
provider: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
38
|
account: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
39
|
+
current: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
46
40
|
series: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
47
41
|
windows: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
48
42
|
days: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -61,3 +55,7 @@ export default class HarnessesQuota extends BaseCommand {
|
|
|
61
55
|
private renderWindows;
|
|
62
56
|
private renderDailySpend;
|
|
63
57
|
}
|
|
58
|
+
/** Refuse an incompatible or malformed response rather than interpreting it as empty quota. */
|
|
59
|
+
export declare function isCurrentQuotaReport(value: unknown, provider: 'claude' | 'codex'): value is CurrentQuotaReport;
|
|
60
|
+
/** Describe only observed readings; none establishes current provider readiness. */
|
|
61
|
+
export declare function currentQuotaLines(report: CurrentQuotaReport): string[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unpricedWindowLines = unpricedWindowLines;
|
|
4
|
+
exports.isCurrentQuotaReport = isCurrentQuotaReport;
|
|
5
|
+
exports.currentQuotaLines = currentQuotaLines;
|
|
4
6
|
const core_1 = require("@oclif/core");
|
|
5
7
|
const base_command_1 = require("../../base-command");
|
|
6
8
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
@@ -32,22 +34,15 @@ const quota_render_1 = require("../../lib/quota-render");
|
|
|
32
34
|
/**
|
|
33
35
|
* WHY this window is empty — without asserting a cause we cannot know.
|
|
34
36
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* wrong one: three Codex turns were started THROUGH skrr, completed, and were
|
|
39
|
-
* recorded at zero tokens because the harness reported an empty usage envelope.
|
|
40
|
-
* The reader was told, by the one screen whose job is answering "what is my
|
|
41
|
-
* agent costing me", that the cause was something they had not done.
|
|
42
|
-
*
|
|
43
|
-
* The second sentence is the one that was missing, and it is the actionable
|
|
44
|
-
* half: a run skrr saw and could not price is a reportable defect, not a
|
|
45
|
-
* property of the user's habits.
|
|
37
|
+
* The meter belongs to the provider account; our token ledger is per harness
|
|
38
|
+
* and may include several machines. An empty table does not identify the cause
|
|
39
|
+
* of missing usage, and recorded tokens do not imply a reported price.
|
|
46
40
|
*/
|
|
47
41
|
function unpricedWindowLines() {
|
|
48
42
|
return [
|
|
49
|
-
'The provider meter
|
|
50
|
-
'A run
|
|
43
|
+
'The provider meter is for the account and may include activity outside skrr. Skrr usage is recorded per harness and is not tied to a provider account.',
|
|
44
|
+
'A missing run may be outside the requested history or may not have reported token usage. Recorded tokens do not necessarily include a reported cost.',
|
|
45
|
+
'Check --since-days for the history range, and inspect recorded runs below.',
|
|
51
46
|
' skrr harnesses usage # the runs skrr did see',
|
|
52
47
|
];
|
|
53
48
|
}
|
|
@@ -58,7 +53,8 @@ class HarnessesQuota extends base_command_1.BaseCommand {
|
|
|
58
53
|
'<%= config.bin %> harnesses quota --provider codex',
|
|
59
54
|
'<%= config.bin %> harnesses quota --series weekly --windows 8',
|
|
60
55
|
'<%= config.bin %> harnesses quota --days 30',
|
|
61
|
-
'<%= config.bin %> harnesses quota --json',
|
|
56
|
+
'<%= config.bin %> harnesses quota --since-days 1 --json',
|
|
57
|
+
'<%= config.bin %> harnesses quota --current --json',
|
|
62
58
|
];
|
|
63
59
|
static flags = {
|
|
64
60
|
provider: core_1.Flags.string({
|
|
@@ -69,14 +65,18 @@ class HarnessesQuota extends base_command_1.BaseCommand {
|
|
|
69
65
|
account: core_1.Flags.string({
|
|
70
66
|
description: 'External account id, when several are reporting. Defaults to the newest.',
|
|
71
67
|
}),
|
|
68
|
+
current: core_1.Flags.boolean({
|
|
69
|
+
description: 'Show recent observed quota only; no history or spend (requires a supporting server)',
|
|
70
|
+
exclusive: ['series', 'windows', 'days', 'since-days'],
|
|
71
|
+
}),
|
|
72
72
|
series: core_1.Flags.string({
|
|
73
73
|
description: 'Which limit window the detail sections describe',
|
|
74
74
|
default: 'session',
|
|
75
75
|
}),
|
|
76
|
-
windows: core_1.Flags.integer({ description: 'How many recent windows to list', default: 8 }),
|
|
77
|
-
days: core_1.Flags.integer({ description: 'How many days of spend to list', default: 14 }),
|
|
76
|
+
windows: core_1.Flags.integer({ description: 'How many recent windows to list in text output', default: 8 }),
|
|
77
|
+
days: core_1.Flags.integer({ description: 'How many days of spend to list in text output', default: 14 }),
|
|
78
78
|
'since-days': core_1.Flags.integer({
|
|
79
|
-
description: 'How much history to read.
|
|
79
|
+
description: 'How much history to read (default 90 days). Controls JSON size; clamped to 90 days.',
|
|
80
80
|
}),
|
|
81
81
|
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
82
82
|
};
|
|
@@ -84,6 +84,27 @@ class HarnessesQuota extends base_command_1.BaseCommand {
|
|
|
84
84
|
this.requireAuth();
|
|
85
85
|
const { flags } = await this.parse(HarnessesQuota);
|
|
86
86
|
const provider = flags.provider === 'codex' ? 'codex' : 'claude';
|
|
87
|
+
if (flags.current) {
|
|
88
|
+
let report;
|
|
89
|
+
try {
|
|
90
|
+
report = await (0, harnesses_1.getCurrentQuota)({ provider, externalAccountId: flags.account });
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
if (typeof err === 'object' && err !== null && 'status' in err && err.status === 404) {
|
|
94
|
+
this.failWithCliError({ message: 'This server does not support --current. Use --since-days 1 for history.', code: 'QUOTA_CURRENT_UNSUPPORTED', status: 404, exit: 1, retryable: false });
|
|
95
|
+
}
|
|
96
|
+
this.handleApiError(err);
|
|
97
|
+
}
|
|
98
|
+
if (!isCurrentQuotaReport(report, provider)) {
|
|
99
|
+
this.failWithCliError({ message: 'This server returned an unsupported current quota response. Use --since-days 1 for history.', code: 'QUOTA_CURRENT_UNSUPPORTED', exit: 1, retryable: false });
|
|
100
|
+
}
|
|
101
|
+
if (flags.json)
|
|
102
|
+
this.log(JSON.stringify(report, null, 2));
|
|
103
|
+
else
|
|
104
|
+
for (const line of currentQuotaLines(report))
|
|
105
|
+
this.log(line);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
87
108
|
let accounts;
|
|
88
109
|
try {
|
|
89
110
|
accounts = (await (0, harnesses_1.listQuotaAccounts)()).accounts ?? [];
|
|
@@ -202,7 +223,7 @@ class HarnessesQuota extends base_command_1.BaseCommand {
|
|
|
202
223
|
// The meter can move with nothing in our ledger, so an empty table here
|
|
203
224
|
// is a real and common state that must not read as "you spent nothing".
|
|
204
225
|
this.log('');
|
|
205
|
-
this.log('No skrr-recorded token spend in
|
|
226
|
+
this.log('No skrr-recorded token spend in the requested history.');
|
|
206
227
|
for (const line of unpricedWindowLines()) {
|
|
207
228
|
this.log(line);
|
|
208
229
|
}
|
|
@@ -231,3 +252,47 @@ class HarnessesQuota extends base_command_1.BaseCommand {
|
|
|
231
252
|
}
|
|
232
253
|
}
|
|
233
254
|
exports.default = HarnessesQuota;
|
|
255
|
+
/** Refuse an incompatible or malformed response rather than interpreting it as empty quota. */
|
|
256
|
+
function isCurrentQuotaReport(value, provider) {
|
|
257
|
+
if (!value || typeof value !== 'object')
|
|
258
|
+
return false;
|
|
259
|
+
const report = value;
|
|
260
|
+
if (report.version !== 1 || report.scope !== 'recent_quota_observations' || report.provider !== provider ||
|
|
261
|
+
!Number.isFinite(report.observedAt) || !Number.isFinite(report.sampleFrom) ||
|
|
262
|
+
report.sampleFrom > report.observedAt || !Number.isInteger(report.sampleLimit) || report.sampleLimit <= 0 || report.sampleLimit > 200 || typeof report.truncated !== 'boolean' ||
|
|
263
|
+
!Array.isArray(report.limitations) || !report.limitations.every((item) => typeof item === 'string') ||
|
|
264
|
+
!Array.isArray(report.readings) || report.readings.length > report.sampleLimit)
|
|
265
|
+
return false;
|
|
266
|
+
if (report.account === null && (report.readings.length > 0 || report.truncated))
|
|
267
|
+
return false;
|
|
268
|
+
if (report.account !== null && (!report.account || typeof report.account.externalAccountId !== 'string' ||
|
|
269
|
+
!Number.isFinite(report.account.lastSeenAt) ||
|
|
270
|
+
(report.account.accountLabel !== null && typeof report.account.accountLabel !== 'string')))
|
|
271
|
+
return false;
|
|
272
|
+
return report.readings.every((r) => r && typeof r.limitType === 'string' && typeof r.scopeKey === 'string' &&
|
|
273
|
+
Number.isFinite(r.capturedAt) && Number.isFinite(r.utilization) && r.utilization >= 0 && r.utilization <= 100 &&
|
|
274
|
+
(r.resetsAt === null || Number.isFinite(r.resetsAt)) && typeof r.stale === 'boolean' &&
|
|
275
|
+
typeof r.rateLimited === 'boolean' && ['unknown', 'elapsed', 'upcoming'].includes(r.resetState));
|
|
276
|
+
}
|
|
277
|
+
/** Describe only observed readings; none establishes current provider readiness. */
|
|
278
|
+
function currentQuotaLines(report) {
|
|
279
|
+
const text = (value) => value.replace(/[\u0000-\u001f\u007f-\u009f]/g, ' ').trim();
|
|
280
|
+
const lines = [
|
|
281
|
+
`Recent quota observations (${(0, format_1.localZone)()}); this is not a readiness check or a bill.`,
|
|
282
|
+
'Only observations from the last 24 hours are shown; other limits may be missing.',
|
|
283
|
+
];
|
|
284
|
+
if (!report.account)
|
|
285
|
+
return [...lines, 'No matching account was observed in the retained history.'];
|
|
286
|
+
lines.push(`Account: ${text(report.account.accountLabel ?? report.account.externalAccountId)} · ID ${text(report.account.externalAccountId)} · last seen ${(0, format_1.localStamp)(report.account.lastSeenAt)}`);
|
|
287
|
+
lines.push('The most recently reporting account may not be the one signed in on this machine; use --account to choose another.');
|
|
288
|
+
if (report.truncated)
|
|
289
|
+
lines.push(`Only the newest ${report.sampleLimit} samples were examined; other limits may be missing.`);
|
|
290
|
+
if (report.readings.length === 0)
|
|
291
|
+
return [...lines, 'No samples in the last 24 hours; current quota is unknown.'];
|
|
292
|
+
for (const reading of report.readings) {
|
|
293
|
+
const reset = reading.resetState === 'unknown' ? 'reset unknown' : reading.resetState === 'elapsed' ? `reset elapsed ${(0, format_1.localStamp)(reading.resetsAt)}` : `resets ${(0, format_1.localStamp)(reading.resetsAt)}`;
|
|
294
|
+
const notes = [reading.stale ? 'stale' : null, reading.rateLimited ? '429 observed near sample' : null].filter(Boolean);
|
|
295
|
+
lines.push(`${text(reading.limitType)}${reading.scopeKey ? ` (${text(reading.scopeKey)})` : ''}: ${reading.utilization}% observed ${(0, format_1.localStamp)(reading.capturedAt)} · ${reset}${notes.length ? ` · ${notes.join(', ')}` : ''}`);
|
|
296
|
+
}
|
|
297
|
+
return lines;
|
|
298
|
+
}
|
|
@@ -81,7 +81,7 @@ class HarnessesShow extends base_command_1.BaseCommand {
|
|
|
81
81
|
// Asked of the daemon, so only for a live local row; best-effort.
|
|
82
82
|
const readiness = harness.daemonId &&
|
|
83
83
|
harness.harnessLocation === 'local' &&
|
|
84
|
-
harness
|
|
84
|
+
(0, harness_labels_1.harnessStatusLabel)(harness) === 'online' &&
|
|
85
85
|
!harness.superseded
|
|
86
86
|
? await (0, cli_installers_1.readinessByProvider)(harness.daemonId, this.resolvedCredential)
|
|
87
87
|
: null;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* Usage for one harness, or the rollup across all of them.
|
|
4
|
+
*
|
|
5
|
+
* ONE command over two endpoints, selected by whether an id was given, because
|
|
6
|
+
* "how much did this cost" is one question the caller asks at two scopes. The
|
|
7
|
+
* web makes the same pairing (`usage(id)` and `fleetUsage`).
|
|
8
|
+
*/
|
|
9
|
+
/** Two decimals is how money is read; the API sends full float precision. */
|
|
10
|
+
export declare function usageCost(row: UsageRow): string;
|
|
2
11
|
export type UsageRow = {
|
|
3
12
|
/** Fleet rollup only — one row per harness. */
|
|
4
13
|
harnessId?: string;
|
|
@@ -14,6 +23,8 @@ export type UsageRow = {
|
|
|
14
23
|
provider?: string;
|
|
15
24
|
sessions?: number;
|
|
16
25
|
totalCostUsd?: number;
|
|
26
|
+
costReportedSessions?: number | null;
|
|
27
|
+
costCoverageVerified?: boolean | null;
|
|
17
28
|
inputTokens?: number;
|
|
18
29
|
outputTokens?: number;
|
|
19
30
|
cachedInputTokens?: number;
|
|
@@ -47,6 +58,14 @@ export interface UsageTable {
|
|
|
47
58
|
maxWidth?: number;
|
|
48
59
|
}[];
|
|
49
60
|
}
|
|
61
|
+
export declare const HARNESS_USAGE_COVERAGE: {
|
|
62
|
+
scope: string;
|
|
63
|
+
explanation: string;
|
|
64
|
+
};
|
|
65
|
+
/** Keep the server response intact and add a machine-readable CLI explanation. */
|
|
66
|
+
export declare function withUsageCoverage<T extends object>(report: T): T & {
|
|
67
|
+
cliCoverage: typeof HARNESS_USAGE_COVERAGE;
|
|
68
|
+
};
|
|
50
69
|
/**
|
|
51
70
|
* The rows differ as much as the two envelopes do.
|
|
52
71
|
*
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HARNESS_USAGE_COVERAGE = void 0;
|
|
4
|
+
exports.usageCost = usageCost;
|
|
3
5
|
exports.selectUsageRows = selectUsageRows;
|
|
4
6
|
exports.usageRowHarnessCell = usageRowHarnessCell;
|
|
7
|
+
exports.withUsageCoverage = withUsageCoverage;
|
|
5
8
|
exports.buildUsageTable = buildUsageTable;
|
|
6
9
|
const core_1 = require("@oclif/core");
|
|
10
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
7
11
|
const base_command_1 = require("../../base-command");
|
|
8
12
|
const format_1 = require("../../lib/format");
|
|
9
13
|
const harnesses_1 = require("../../lib/harnesses");
|
|
@@ -15,9 +19,13 @@ const harnesses_1 = require("../../lib/harnesses");
|
|
|
15
19
|
* web makes the same pairing (`usage(id)` and `fleetUsage`).
|
|
16
20
|
*/
|
|
17
21
|
/** Two decimals is how money is read; the API sends full float precision. */
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
|
|
22
|
+
function usageCost(row) {
|
|
23
|
+
const status = (0, data_provider_1.harnessCostReporting)(row);
|
|
24
|
+
if (status === 'idle' || status === 'not_reported' || status === 'unknown' ||
|
|
25
|
+
typeof row.totalCostUsd !== 'number' || !Number.isFinite(row.totalCostUsd))
|
|
26
|
+
return '—';
|
|
27
|
+
const value = status === 'partial' ? Math.floor(row.totalCostUsd * 100) / 100 : row.totalCostUsd;
|
|
28
|
+
return `$${value.toFixed(2)}${status === 'partial' ? '+' : ''}`;
|
|
21
29
|
}
|
|
22
30
|
/** Thousands separators — these run to eight digits and are compared by eye. */
|
|
23
31
|
function count(value) {
|
|
@@ -56,6 +64,14 @@ const SHARED_COLUMNS = [
|
|
|
56
64
|
{ key: 'cached', header: 'CACHED' },
|
|
57
65
|
{ key: 'cacheWrite', header: 'CACHE WRITE' },
|
|
58
66
|
];
|
|
67
|
+
exports.HARNESS_USAGE_COVERAGE = {
|
|
68
|
+
scope: 'skrr_recorded_harness_usage',
|
|
69
|
+
explanation: 'Only usage recorded by Skrr for these harnesses is shown. Other activity or unreported usage may be absent; this is not a provider bill.',
|
|
70
|
+
};
|
|
71
|
+
/** Keep the server response intact and add a machine-readable CLI explanation. */
|
|
72
|
+
function withUsageCoverage(report) {
|
|
73
|
+
return { cliCoverage: exports.HARNESS_USAGE_COVERAGE, ...report };
|
|
74
|
+
}
|
|
59
75
|
/**
|
|
60
76
|
* The rows differ as much as the two envelopes do.
|
|
61
77
|
*
|
|
@@ -73,7 +89,7 @@ function buildUsageTable(rows, perHarness) {
|
|
|
73
89
|
const shared = (r) => ({
|
|
74
90
|
provider: (0, format_1.formatCell)(r.provider),
|
|
75
91
|
sessions: count(r.sessions),
|
|
76
|
-
cost:
|
|
92
|
+
cost: usageCost(r),
|
|
77
93
|
in: count(r.inputTokens),
|
|
78
94
|
out: count(r.outputTokens),
|
|
79
95
|
cached: count(r.cachedInputTokens),
|
|
@@ -100,7 +116,7 @@ function buildUsageTable(rows, perHarness) {
|
|
|
100
116
|
};
|
|
101
117
|
}
|
|
102
118
|
class HarnessesUsage extends base_command_1.BaseCommand {
|
|
103
|
-
static description = '
|
|
119
|
+
static description = 'Skrr-recorded usage for one harness or the fleet; not a complete provider bill';
|
|
104
120
|
static examples = [
|
|
105
121
|
'<%= config.bin %> harnesses usage',
|
|
106
122
|
'<%= config.bin %> harnesses usage <harness-id>',
|
|
@@ -124,7 +140,7 @@ class HarnessesUsage extends base_command_1.BaseCommand {
|
|
|
124
140
|
this.handleApiError(err);
|
|
125
141
|
}
|
|
126
142
|
if (flags.json) {
|
|
127
|
-
this.log(JSON.stringify(report, null, 2));
|
|
143
|
+
this.log(JSON.stringify(withUsageCoverage(report ?? {}), null, 2));
|
|
128
144
|
return;
|
|
129
145
|
}
|
|
130
146
|
// The two endpoints answer in DIFFERENT shapes: the fleet rollup sends
|
|
@@ -136,6 +152,7 @@ class HarnessesUsage extends base_command_1.BaseCommand {
|
|
|
136
152
|
const totals = payload?.grandTotals ?? payload?.totals;
|
|
137
153
|
if (rows.length === 0) {
|
|
138
154
|
this.log(args.harness ? 'No usage recorded for this harness.' : 'No usage recorded.');
|
|
155
|
+
this.log(exports.HARNESS_USAGE_COVERAGE.explanation);
|
|
139
156
|
return;
|
|
140
157
|
}
|
|
141
158
|
if (args.harness) {
|
|
@@ -146,7 +163,7 @@ class HarnessesUsage extends base_command_1.BaseCommand {
|
|
|
146
163
|
(0, format_1.renderTable)(table.rows, table.columns, (line) => this.log(line));
|
|
147
164
|
if (totals) {
|
|
148
165
|
this.log('');
|
|
149
|
-
this.log(`Total: ${count(totals.sessions)} sessions · ${
|
|
166
|
+
this.log(`Total: ${count(totals.sessions)} sessions · ${usageCost(totals)} · ` +
|
|
150
167
|
`${count(totals.inputTokens)} in / ${count(totals.outputTokens)} out / ` +
|
|
151
168
|
`${count(totals.cachedInputTokens)} cached / ${count(totals.cacheCreationInputTokens)} cache write`);
|
|
152
169
|
// SAY WHICH PROVIDERS THAT TOTAL COVERS.
|
|
@@ -167,6 +184,9 @@ class HarnessesUsage extends base_command_1.BaseCommand {
|
|
|
167
184
|
'This is NOT necessarily your whole account.');
|
|
168
185
|
}
|
|
169
186
|
}
|
|
187
|
+
this.log('');
|
|
188
|
+
this.log('Cost: — means unknown, not reported, or no activity; + means a lower bound.');
|
|
189
|
+
this.log(exports.HARNESS_USAGE_COVERAGE.explanation);
|
|
170
190
|
}
|
|
171
191
|
}
|
|
172
192
|
exports.default = HarnessesUsage;
|
|
@@ -18,7 +18,10 @@ class MemoryTopicsCreate extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
|
18
18
|
static description = 'Create a versioned semantic Memory topic';
|
|
19
19
|
static flags = {
|
|
20
20
|
...scoped_memory_command_1.mutationFlags,
|
|
21
|
-
path: core_1.Flags.string({
|
|
21
|
+
path: core_1.Flags.string({
|
|
22
|
+
required: true,
|
|
23
|
+
description: 'Absolute Memory path beginning with /, for example /people/alex',
|
|
24
|
+
}),
|
|
22
25
|
content: core_1.Flags.string({ required: true }),
|
|
23
26
|
title: core_1.Flags.string(),
|
|
24
27
|
kind: core_1.Flags.string({
|
|
@@ -3,10 +3,9 @@ import { BaseCommand } from '../../base-command';
|
|
|
3
3
|
* `skrr tokens create` — mint a personal access token (`osk_pat_*`, OSK-13208)
|
|
4
4
|
* for CI. The secret is printed EXACTLY ONCE.
|
|
5
5
|
*
|
|
6
|
-
* Creating one needs a sign-in session
|
|
7
|
-
* an
|
|
8
|
-
*
|
|
9
|
-
* command asks for it when the server does.
|
|
6
|
+
* Creating one needs a sign-in session and a fresh proof for that session.
|
|
7
|
+
* Accounts with an authenticator use it; eligible accounts without one can
|
|
8
|
+
* request an email code interactively. The server decides which methods apply.
|
|
10
9
|
*/
|
|
11
10
|
export default class TokensCreate extends BaseCommand {
|
|
12
11
|
static description: string;
|
|
@@ -10,10 +10,9 @@ const prompt_1 = require("../../lib/prompt");
|
|
|
10
10
|
* `skrr tokens create` — mint a personal access token (`osk_pat_*`, OSK-13208)
|
|
11
11
|
* for CI. The secret is printed EXACTLY ONCE.
|
|
12
12
|
*
|
|
13
|
-
* Creating one needs a sign-in session
|
|
14
|
-
* an
|
|
15
|
-
*
|
|
16
|
-
* command asks for it when the server does.
|
|
13
|
+
* Creating one needs a sign-in session and a fresh proof for that session.
|
|
14
|
+
* Accounts with an authenticator use it; eligible accounts without one can
|
|
15
|
+
* request an email code interactively. The server decides which methods apply.
|
|
17
16
|
*/
|
|
18
17
|
class TokensCreate extends base_command_1.BaseCommand {
|
|
19
18
|
static description = 'Create a personal access token for CI (use it as SKRR_TOKEN). The secret is shown once and never again.';
|
|
@@ -84,8 +83,20 @@ class TokensCreate extends base_command_1.BaseCommand {
|
|
|
84
83
|
if (!process.stdin.isTTY) {
|
|
85
84
|
return this.refuseStepUp(challenge);
|
|
86
85
|
}
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (challenge.methods.includes('email_code')) {
|
|
87
|
+
try {
|
|
88
|
+
await data_provider_1.dataService.requestStepUpEmailCode({ purpose: data_provider_1.ACCESS_TOKEN_CREATE_STEP_UP_PURPOSE });
|
|
89
|
+
}
|
|
90
|
+
catch (sendErr) {
|
|
91
|
+
return this.handleApiError(sendErr);
|
|
92
|
+
}
|
|
93
|
+
const entered = (await (0, prompt_1.prompt)('Code emailed to your account: ', { hidden: true, output: process.stderr })).trim();
|
|
94
|
+
code = { emailCode: entered };
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const entered = (await (0, prompt_1.prompt)('Code from your authenticator app: ', { hidden: true, output: process.stderr })).trim();
|
|
98
|
+
code = { token: entered };
|
|
99
|
+
}
|
|
89
100
|
await this.verify(code);
|
|
90
101
|
try {
|
|
91
102
|
created = await (0, access_tokens_1.createAccessToken)(input);
|
|
@@ -123,7 +134,9 @@ class TokensCreate extends base_command_1.BaseCommand {
|
|
|
123
134
|
const messages = {
|
|
124
135
|
credential_not_session_bound: `Creating an access token needs a sign-in session, and this credential is not one (an access token cannot create another). Run \`${bin} login\` and try again. Nothing changed.`,
|
|
125
136
|
two_factor_not_enabled: 'Creating an access token needs two-factor authentication on this account. Turn it on in the web app, then try again. Nothing changed.',
|
|
126
|
-
no_recent_step_up:
|
|
137
|
+
no_recent_step_up: challenge.methods.includes('email_code')
|
|
138
|
+
? 'Creating an access token needs email verification. Run this command in an interactive terminal to request and enter the code. Nothing changed.'
|
|
139
|
+
: 'Creating an access token needs a fresh code from your authenticator app. Run this command again with --otp <code> (or --backup-code <code>). Nothing changed.',
|
|
127
140
|
};
|
|
128
141
|
this.error(messages[challenge.reason], { code: 'STEP_UP_REQUIRED', exit: 2 });
|
|
129
142
|
}
|
|
@@ -149,8 +149,15 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
149
149
|
for (const line of fireLines)
|
|
150
150
|
this.log(line);
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
const dutyQueue = ['duty_check', 'duty_reflection', 'enqueue_duty_check', 'enqueue_duty_reflection']
|
|
153
|
+
.includes(report.executorMode ?? '');
|
|
154
|
+
if (dutyQueue) {
|
|
155
|
+
if (!report.notes?.some((note) => note.includes('this preflight does not resolve its model or harness')))
|
|
156
|
+
this.log('\nInference target: not evaluated by this trigger preflight.');
|
|
157
|
+
}
|
|
158
|
+
else if (report.destination) {
|
|
159
|
+
this.log(`\nConversation destination preview: ${(0, triggers_1.destinationLine)(report.destination)}`);
|
|
160
|
+
this.log(' This is an advisory conversation preview, not a model or harness selection.');
|
|
154
161
|
}
|
|
155
162
|
// Non-zero when the trigger would not autonomously run, so this is usable
|
|
156
163
|
// in a script or a pre-deploy check. `2` for indeterminate keeps "blocked"
|
|
@@ -43,7 +43,9 @@ function describeUnlistedModel(model, report, harnessId, bin) {
|
|
|
43
43
|
return (`Model '${id}' is not in the ${provider} harness's ${report.source} model list ` +
|
|
44
44
|
`(${harnessId}). It was saved, but a turn fails when the harness refuses it. ${remedy}`);
|
|
45
45
|
}
|
|
46
|
-
const why = report?.sourceReason
|
|
46
|
+
const why = report?.sourceReason === 'daemon_offline'
|
|
47
|
+
? ' (this server has no live connection to the daemon)'
|
|
48
|
+
: report?.sourceReason ? ` (${report.sourceReason})` : '';
|
|
47
49
|
return (`Model '${id}' is not in the suggested list for the ${provider} harness, and the ` +
|
|
48
50
|
`harness's live list was unavailable${why}, so it could not be checked. It was saved. ` +
|
|
49
51
|
remedy);
|
|
@@ -2902,16 +2902,15 @@ exports.AgenticStreamClient = AgenticStreamClient;
|
|
|
2902
2902
|
* before the cutover still names it, and dropping it would strand exactly the
|
|
2903
2903
|
* sessions the entry exists to carry.
|
|
2904
2904
|
*/
|
|
2905
|
-
const
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2905
|
+
const REALTIME_HOSTS = new Map([
|
|
2906
|
+
...Object.values(publicEndpoints_generated_1.OVERSKY_ENVIRONMENT_ENDPOINTS).map((endpoint) => [
|
|
2907
|
+
new URL(endpoint.appUrl).hostname, new URL(endpoint.realtimeUrl).hostname,
|
|
2908
|
+
]),
|
|
2909
|
+
[new URL(config_1.LEGACY_PROD_BASE_URL).hostname, `api.${new URL(config_1.LEGACY_PROD_BASE_URL).hostname}`],
|
|
2909
2910
|
]);
|
|
2910
2911
|
function toWebSocketOrigin(baseURL) {
|
|
2911
2912
|
const url = new URL(baseURL);
|
|
2912
|
-
|
|
2913
|
-
url.hostname = `api.${url.hostname}`;
|
|
2914
|
-
}
|
|
2913
|
+
url.hostname = REALTIME_HOSTS.get(url.hostname) ?? url.hostname;
|
|
2915
2914
|
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
2916
2915
|
url.pathname = '';
|
|
2917
2916
|
url.search = '';
|
package/dist/lib/balance.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSubscription, TSkyCodeUsageBreakdown, TSkyCodeUsageEvents, TSkyCodeUsageSnapshot } from '@skrr-ai/data-provider';
|
|
1
|
+
import type { TSubscription, TSkyCodeUsageBreakdown, TSkyCodeUsageEvents, TSkyCodeUsageSettlements, TSkyCodeUsageSnapshot } from '@skrr-ai/data-provider';
|
|
2
2
|
/**
|
|
3
3
|
* balance.ts — request client for `/api/balance`.
|
|
4
4
|
*
|
|
@@ -111,12 +111,15 @@ export declare function getSkyCodeUsageEvents(workspaceId: string | undefined, p
|
|
|
111
111
|
to?: string;
|
|
112
112
|
cursor?: string;
|
|
113
113
|
limit?: number;
|
|
114
|
-
|
|
114
|
+
view?: 'settlements';
|
|
115
|
+
}): Promise<TSkyCodeUsageEvents | TSkyCodeUsageSettlements>;
|
|
115
116
|
export declare function getSkyCodeUsageBreakdown(workspaceId: string | undefined, params?: {
|
|
116
117
|
from?: string;
|
|
117
118
|
to?: string;
|
|
118
119
|
productFamily?: string;
|
|
119
120
|
}): Promise<TSkyCodeUsageBreakdown>;
|
|
121
|
+
/** Resolve only identities this caller may VIEW; the server omits denied IDs. */
|
|
122
|
+
export declare function getUsageAgentNames(ids: string[], workspaceId?: string): Promise<Map<string, string>>;
|
|
120
123
|
/** Recent token transactions, newest first. Cursor is an ISO createdAt. */
|
|
121
124
|
export declare function getBalanceHistory(limit: number, cursor?: string): Promise<BalanceHistory>;
|
|
122
125
|
/**
|
package/dist/lib/balance.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getSkyCodeSubscription = getSkyCodeSubscription;
|
|
|
7
7
|
exports.setSkyCodeOverageConsent = setSkyCodeOverageConsent;
|
|
8
8
|
exports.getSkyCodeUsageEvents = getSkyCodeUsageEvents;
|
|
9
9
|
exports.getSkyCodeUsageBreakdown = getSkyCodeUsageBreakdown;
|
|
10
|
+
exports.getUsageAgentNames = getUsageAgentNames;
|
|
10
11
|
exports.getBalanceHistory = getBalanceHistory;
|
|
11
12
|
exports.formatCredits = formatCredits;
|
|
12
13
|
exports.getWorkspaceBalance = getWorkspaceBalance;
|
|
@@ -57,6 +58,8 @@ async function getSkyCodeUsageEvents(workspaceId, params = {}) {
|
|
|
57
58
|
query.set('cursor', params.cursor);
|
|
58
59
|
if (params.limit !== undefined)
|
|
59
60
|
query.set('limit', String(params.limit));
|
|
61
|
+
if (params.view)
|
|
62
|
+
query.set('view', params.view);
|
|
60
63
|
const base = workspaceId
|
|
61
64
|
? `/api/balance/usage/sky-code/workspace/${encodeURIComponent(workspaceId)}/events`
|
|
62
65
|
: '/api/balance/usage/sky-code/events';
|
|
@@ -77,6 +80,29 @@ async function getSkyCodeUsageBreakdown(workspaceId, params = {}) {
|
|
|
77
80
|
const suffix = query.toString();
|
|
78
81
|
return (0, api_fetch_1.apiFetch)(suffix ? `${base}?${suffix}` : base);
|
|
79
82
|
}
|
|
83
|
+
/** Resolve only identities this caller may VIEW; the server omits denied IDs. */
|
|
84
|
+
async function getUsageAgentNames(ids, workspaceId) {
|
|
85
|
+
const uniqueIds = [...new Set(ids.filter((id) => typeof id === 'string' && id.length > 0 && id.length <= 256))].slice(0, 100);
|
|
86
|
+
if (!uniqueIds.length)
|
|
87
|
+
return new Map();
|
|
88
|
+
const result = await (0, api_fetch_1.apiFetch)('/api/agents/identity-batch', {
|
|
89
|
+
method: 'POST', body: { ids: uniqueIds },
|
|
90
|
+
...(workspaceId ? { headers: { 'X-Workspace-Id': workspaceId } } : {}),
|
|
91
|
+
signal: AbortSignal.timeout(3000),
|
|
92
|
+
});
|
|
93
|
+
const requested = new Set(uniqueIds);
|
|
94
|
+
const names = new Map();
|
|
95
|
+
if (!Array.isArray(result?.data))
|
|
96
|
+
throw new Error('Agent identities unavailable');
|
|
97
|
+
for (const row of result.data) {
|
|
98
|
+
if (typeof row?.id !== 'string' || !requested.has(row.id) || typeof row.name !== 'string')
|
|
99
|
+
continue;
|
|
100
|
+
const name = row.name.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ').trim();
|
|
101
|
+
if (name)
|
|
102
|
+
names.set(row.id, name);
|
|
103
|
+
}
|
|
104
|
+
return names;
|
|
105
|
+
}
|
|
80
106
|
/** Recent token transactions, newest first. Cursor is an ISO createdAt. */
|
|
81
107
|
async function getBalanceHistory(limit, cursor) {
|
|
82
108
|
const query = new URLSearchParams({ limit: String(limit) });
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ export declare const LEGACY_PROD_BASE_URL = "https://oversky.ai";
|
|
|
139
139
|
/** `skrr login --env prod`, mirroring the daemon's own environment shorthand. */
|
|
140
140
|
export declare const ENVIRONMENT_BASE_URLS: Record<string, string>;
|
|
141
141
|
/** Which deployment a base URL denotes, or null for a self-hosted server. */
|
|
142
|
-
export declare function environmentForBaseURL(value: string): 'dev' | 'prod' | 'local' | null;
|
|
142
|
+
export declare function environmentForBaseURL(value: string): 'dev' | 'prod' | 'preprod' | 'local' | null;
|
|
143
143
|
/**
|
|
144
144
|
* Fold the skrr-owned spellings onto their canonical form; custom servers are
|
|
145
145
|
* returned untouched.
|
package/dist/lib/config.js
CHANGED
|
@@ -91,6 +91,7 @@ exports.ENVIRONMENT_BASE_URLS = {
|
|
|
91
91
|
local: 'http://localhost:3080',
|
|
92
92
|
dev: exports.CANONICAL_DEV_BASE_URL,
|
|
93
93
|
prod: exports.CANONICAL_PROD_BASE_URL,
|
|
94
|
+
preprod: publicEndpoints_generated_1.OVERSKY_ENVIRONMENT_ENDPOINTS.preprod.appUrl,
|
|
94
95
|
};
|
|
95
96
|
/** Which deployment a base URL denotes, or null for a self-hosted server. */
|
|
96
97
|
function environmentForBaseURL(value) {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
export declare const NO_CODING_AGENT_PROVIDER_LABEL = "none";
|
|
21
21
|
export declare function harnessStatusLabel(row: {
|
|
22
22
|
status?: string | null;
|
|
23
|
+
presenceStatus?: string | null;
|
|
23
24
|
superseded?: boolean | null;
|
|
24
25
|
}): string;
|
|
25
26
|
export declare function isNoCodingAgentProvider(provider: string | null | undefined): boolean;
|
|
@@ -30,6 +30,10 @@ exports.NO_CODING_AGENT_PROVIDER_LABEL = 'none';
|
|
|
30
30
|
function harnessStatusLabel(row) {
|
|
31
31
|
if (row.superseded)
|
|
32
32
|
return 'superseded';
|
|
33
|
+
if (row.presenceStatus === 'unknown')
|
|
34
|
+
return 'unknown';
|
|
35
|
+
if (row.presenceStatus === 'unconfirmed')
|
|
36
|
+
return 'unconfirmed';
|
|
33
37
|
return typeof row.status === 'string' && row.status.length > 0 ? row.status : 'unknown';
|
|
34
38
|
}
|
|
35
39
|
function isNoCodingAgentProvider(provider) {
|
package/dist/lib/harnesses.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export interface Harness {
|
|
|
51
51
|
sharedName?: string;
|
|
52
52
|
aliased?: boolean;
|
|
53
53
|
status?: string;
|
|
54
|
+
/** Whether this server could observe the local daemon's socket. */
|
|
55
|
+
presenceStatus?: 'connected' | 'unconfirmed' | 'unknown';
|
|
54
56
|
/**
|
|
55
57
|
* A later registration on the same machine replaced this row. Sent by both
|
|
56
58
|
* the list and the single-row routes; human output shows it instead of the
|
|
@@ -217,6 +219,39 @@ export declare function getRuntimeMonthlySpend(): Promise<{
|
|
|
217
219
|
export declare function listQuotaAccounts(): Promise<{
|
|
218
220
|
accounts: QuotaAccountSummary[];
|
|
219
221
|
}>;
|
|
222
|
+
export interface CurrentQuotaReport {
|
|
223
|
+
version: 1;
|
|
224
|
+
scope: 'recent_quota_observations';
|
|
225
|
+
provider: 'claude' | 'codex';
|
|
226
|
+
observedAt: number;
|
|
227
|
+
sampleFrom: number;
|
|
228
|
+
sampleLimit: number;
|
|
229
|
+
limitations: string[];
|
|
230
|
+
truncated: boolean;
|
|
231
|
+
account: {
|
|
232
|
+
externalAccountId: string;
|
|
233
|
+
accountLabel: string | null;
|
|
234
|
+
planTier: string | null;
|
|
235
|
+
daemonId: string | null;
|
|
236
|
+
lastSeenAt: number;
|
|
237
|
+
} | null;
|
|
238
|
+
readings: Array<{
|
|
239
|
+
capturedAt: number;
|
|
240
|
+
limitType: string;
|
|
241
|
+
scopeKey: string;
|
|
242
|
+
utilization: number;
|
|
243
|
+
resetsAt: number | null;
|
|
244
|
+
rateLimited: boolean;
|
|
245
|
+
windowSeconds: number | null;
|
|
246
|
+
stale: boolean;
|
|
247
|
+
resetState: 'unknown' | 'elapsed' | 'upcoming';
|
|
248
|
+
}>;
|
|
249
|
+
}
|
|
250
|
+
/** Recent, bounded observations; never falls back to the full history endpoint. */
|
|
251
|
+
export declare function getCurrentQuota(params: {
|
|
252
|
+
provider: 'claude' | 'codex';
|
|
253
|
+
externalAccountId?: string;
|
|
254
|
+
}): Promise<CurrentQuotaReport>;
|
|
220
255
|
/**
|
|
221
256
|
* One account's reading series plus the spend buckets over the same horizon.
|
|
222
257
|
*
|