@skrr-ai/cli 0.1.161 → 0.1.162
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/breakdown.d.ts +1 -1
- package/dist/commands/balance/usage/breakdown.js +4 -4
- package/dist/commands/balance/usage/events.d.ts +1 -1
- package/dist/commands/balance/usage/events.js +4 -4
- package/dist/commands/goals/create.js +18 -1
- package/dist/commands/triggers/preflight.js +15 -10
- package/dist/lib/balance.d.ts +5 -5
- package/dist/lib/balance.js +4 -4
- package/dist/lib/dedicated-power.js +4 -3
- package/dist/node_modules/@skrr-ai/data-provider/index.js +6445 -6406
- package/oclif.manifest.json +2 -2
- package/package.json +2 -2
|
@@ -11,4 +11,4 @@ export default class BalanceUsageBreakdown extends BaseCommand {
|
|
|
11
11
|
};
|
|
12
12
|
run(): Promise<void>;
|
|
13
13
|
}
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function renderUsageBreakdown(breakdown: TSkyCodeUsageBreakdown, log: (line: string) => void, agentNames?: ReadonlyMap<string, string>): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.renderUsageBreakdown = renderUsageBreakdown;
|
|
4
4
|
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");
|
|
@@ -28,7 +28,7 @@ class BalanceUsageBreakdown extends base_command_1.BaseCommand {
|
|
|
28
28
|
const workspaceId = flags.workspace;
|
|
29
29
|
let breakdown;
|
|
30
30
|
try {
|
|
31
|
-
breakdown = await (0, balance_1.
|
|
31
|
+
breakdown = await (0, balance_1.getUsageBreakdown)(workspaceId, {
|
|
32
32
|
from: flags.from,
|
|
33
33
|
to: flags.to,
|
|
34
34
|
productFamily: flags['product-family'],
|
|
@@ -49,13 +49,13 @@ class BalanceUsageBreakdown extends base_command_1.BaseCommand {
|
|
|
49
49
|
catch {
|
|
50
50
|
lookupFailed = true;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
renderUsageBreakdown(breakdown, (line) => this.log(line), agentNames);
|
|
53
53
|
if (lookupFailed)
|
|
54
54
|
this.log(' Agent names unavailable; showing recorded IDs.');
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
exports.default = BalanceUsageBreakdown;
|
|
58
|
-
function
|
|
58
|
+
function renderUsageBreakdown(breakdown, log, agentNames = new Map()) {
|
|
59
59
|
log(`${auth_core_1.FIRST_PARTY_HARNESS.displayName} usage breakdown · ${breakdown.ownerType} ${breakdown.ownerId}`);
|
|
60
60
|
log(` Window ${breakdown.from} to ${breakdown.to}`);
|
|
61
61
|
log(` Total ${(0, balance_1.formatCreditsWithUsd)(breakdown.total.usageMicros)} across ${breakdown.total.events} settled authorization${breakdown.total.events === 1 ? '' : 's'}`);
|
|
@@ -13,4 +13,4 @@ export default class BalanceUsageEvents extends BaseCommand {
|
|
|
13
13
|
};
|
|
14
14
|
run(): Promise<void>;
|
|
15
15
|
}
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function renderUsageEvents(events: TSkyCodeUsageEvents | TSkyCodeUsageSettlements, log: (line: string) => void): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.renderUsageEvents = renderUsageEvents;
|
|
4
4
|
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");
|
|
@@ -27,7 +27,7 @@ class BalanceUsageEvents extends base_command_1.BaseCommand {
|
|
|
27
27
|
const workspaceId = flags.workspace;
|
|
28
28
|
let events;
|
|
29
29
|
try {
|
|
30
|
-
events = await (0, balance_1.
|
|
30
|
+
events = await (0, balance_1.getUsageEvents)(workspaceId, {
|
|
31
31
|
from: flags.from,
|
|
32
32
|
to: flags.to,
|
|
33
33
|
cursor: flags.cursor,
|
|
@@ -44,11 +44,11 @@ class BalanceUsageEvents extends base_command_1.BaseCommand {
|
|
|
44
44
|
: events, null, 2));
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
renderUsageEvents(events, (line) => this.log(line));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
exports.default = BalanceUsageEvents;
|
|
51
|
-
function
|
|
51
|
+
function renderUsageEvents(events, log) {
|
|
52
52
|
log(`${auth_core_1.FIRST_PARTY_HARNESS.displayName} usage events · ${events.ownerType} ${events.ownerId}`);
|
|
53
53
|
log(` Window ${events.from} to ${events.to}`);
|
|
54
54
|
if (events.version === 1) {
|
|
@@ -142,7 +142,24 @@ class GoalsCreate extends base_command_1.BaseCommand {
|
|
|
142
142
|
// server deliberately routes goal links through this $addToSet endpoint so
|
|
143
143
|
// concurrent edits can't clobber each other (same contract as `spaces
|
|
144
144
|
// labels add`). Re-linking an already-linked goal is a no-op.
|
|
145
|
-
|
|
145
|
+
try {
|
|
146
|
+
await data_provider_1.dataService.linkGoalToSpace({ spaceId: flags.space, goalId });
|
|
147
|
+
}
|
|
148
|
+
catch (linkError) {
|
|
149
|
+
// The create already returned an identity. Never tell the caller
|
|
150
|
+
// that nothing happened or invite a blind retry of the create.
|
|
151
|
+
const failure = linkError;
|
|
152
|
+
const statusText = typeof failure?.status === 'number' ? ` (HTTP ${failure.status})` : '';
|
|
153
|
+
this.failWithCliError({
|
|
154
|
+
code: 'GOAL_CREATED_SPACE_LINK_UNCONFIRMED',
|
|
155
|
+
message: `Goal ${goalId} was created or recovered, but its Space link could not be confirmed${statusText}. Run \`${this.config.bin} goals show ${goalId}\` before retrying.`,
|
|
156
|
+
exit: 1,
|
|
157
|
+
retryable: false,
|
|
158
|
+
...(typeof failure?.status === 'number' ? { status: failure.status } : {}),
|
|
159
|
+
...(typeof failure?.requestId === 'string' ? { requestId: failure.requestId } : {}),
|
|
160
|
+
details: { goalId, spaceId: flags.space },
|
|
161
|
+
});
|
|
162
|
+
}
|
|
146
163
|
}
|
|
147
164
|
}
|
|
148
165
|
catch (err) {
|
|
@@ -35,7 +35,7 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
35
35
|
id: core_1.Args.string({ description: 'Trigger ID', required: true, ignoreStdin: true }),
|
|
36
36
|
};
|
|
37
37
|
static flags = {
|
|
38
|
-
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
38
|
+
json: core_1.Flags.boolean({ description: 'Output the server response as JSON; use exit status for the effective verdict (2 means uncertain)' }),
|
|
39
39
|
'sample-event': core_1.Flags.string({
|
|
40
40
|
description: 'Path to a JSON event payload (or "-" for stdin) to exercise event filters and payload variables',
|
|
41
41
|
}),
|
|
@@ -67,7 +67,8 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
67
67
|
}
|
|
68
68
|
// Preserve machine-readable output while still communicating the verdict
|
|
69
69
|
// through the process contract.
|
|
70
|
-
const
|
|
70
|
+
const legacyResponse = report.decisionVersion !== 2;
|
|
71
|
+
const exitCode = preflightExitCode(legacyResponse ? null : report.wouldFire);
|
|
71
72
|
if (exitCode !== 0)
|
|
72
73
|
process.exitCode = exitCode;
|
|
73
74
|
if (flags.json) {
|
|
@@ -76,13 +77,17 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
76
77
|
}
|
|
77
78
|
// Three outcomes, not two — `suggest` (would run, but as an inbox card) is
|
|
78
79
|
// the most common real answer and must not read as either pass or fail.
|
|
79
|
-
const verdict =
|
|
80
|
-
? '
|
|
81
|
-
: report.wouldFire ===
|
|
82
|
-
? '
|
|
83
|
-
: report.
|
|
84
|
-
? '
|
|
85
|
-
:
|
|
80
|
+
const verdict = legacyResponse
|
|
81
|
+
? 'OUTCOME UNCERTAIN — this server did not report an ordered Trigger claim protocol check'
|
|
82
|
+
: report.wouldFire === true
|
|
83
|
+
? 'CHECKS PASSED — could run if the executing server has the same configuration'
|
|
84
|
+
: report.wouldFire === null
|
|
85
|
+
? 'INDETERMINATE — needs a live event or live state'
|
|
86
|
+
: (report.blockedBy
|
|
87
|
+
? report.gates.find((g) => g.name === report.blockedBy)
|
|
88
|
+
: report.gates.find((g) => g.verdict === 'block' || g.verdict === 'suggest'))?.verdict === 'suggest'
|
|
89
|
+
? 'MAY SUGGEST — an inbox card instead of an autonomous run'
|
|
90
|
+
: 'BLOCKED ON CHECKED SERVER — this check would stop before running';
|
|
86
91
|
// Name the RELATIONSHIP, and use the reason the gate already carries.
|
|
87
92
|
// `blockedBy` is a gate NAME, and rendering it bare produced
|
|
88
93
|
// `WOULD NOT RUN (enabled)` for a disabled trigger — which reads as
|
|
@@ -92,7 +97,7 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
92
97
|
const blocker = report.blockedBy
|
|
93
98
|
? report.gates.find((g) => g.name === report.blockedBy && g.verdict === 'block')
|
|
94
99
|
: undefined;
|
|
95
|
-
const because = report.blockedBy
|
|
100
|
+
const because = report.blockedBy && !legacyResponse
|
|
96
101
|
? ` — blocked by ${report.blockedBy}${blocker?.reason ? `: ${blocker.reason}` : ''}`
|
|
97
102
|
: '';
|
|
98
103
|
this.log(`${verdict}${because}`);
|
package/dist/lib/balance.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSubscription, TSkyCodeUsageBreakdown, TSkyCodeUsageEvents, TSkyCodeUsageSettlements, TSkyCodeUsageSnapshot } from '@skrr-ai/data-provider';
|
|
1
|
+
import type { TSubscription, TSkyCodeUsageBreakdown as TUsageBreakdown, TSkyCodeUsageEvents, TSkyCodeUsageSettlements as TUsageSettlements, TSkyCodeUsageSnapshot } from '@skrr-ai/data-provider';
|
|
2
2
|
/**
|
|
3
3
|
* balance.ts — request client for `/api/balance`.
|
|
4
4
|
*
|
|
@@ -106,18 +106,18 @@ export declare function getSkyCodeSubscription(): Promise<TSubscription>;
|
|
|
106
106
|
export declare function setSkyCodeOverageConsent(enabled: boolean): Promise<{
|
|
107
107
|
enabled: boolean;
|
|
108
108
|
}>;
|
|
109
|
-
export declare function
|
|
109
|
+
export declare function getUsageEvents(workspaceId: string | undefined, params?: {
|
|
110
110
|
from?: string;
|
|
111
111
|
to?: string;
|
|
112
112
|
cursor?: string;
|
|
113
113
|
limit?: number;
|
|
114
114
|
view?: 'settlements';
|
|
115
|
-
}): Promise<TSkyCodeUsageEvents |
|
|
116
|
-
export declare function
|
|
115
|
+
}): Promise<TSkyCodeUsageEvents | TUsageSettlements>;
|
|
116
|
+
export declare function getUsageBreakdown(workspaceId: string | undefined, params?: {
|
|
117
117
|
from?: string;
|
|
118
118
|
to?: string;
|
|
119
119
|
productFamily?: string;
|
|
120
|
-
}): Promise<
|
|
120
|
+
}): Promise<TUsageBreakdown>;
|
|
121
121
|
/** Resolve only identities this caller may VIEW; the server omits denied IDs. */
|
|
122
122
|
export declare function getUsageAgentNames(ids: string[], workspaceId?: string): Promise<Map<string, string>>;
|
|
123
123
|
/** Recent token transactions, newest first. Cursor is an ISO createdAt. */
|
package/dist/lib/balance.js
CHANGED
|
@@ -5,8 +5,8 @@ exports.getBalance = getBalance;
|
|
|
5
5
|
exports.getSkyCodeUsage = getSkyCodeUsage;
|
|
6
6
|
exports.getSkyCodeSubscription = getSkyCodeSubscription;
|
|
7
7
|
exports.setSkyCodeOverageConsent = setSkyCodeOverageConsent;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
8
|
+
exports.getUsageEvents = getUsageEvents;
|
|
9
|
+
exports.getUsageBreakdown = getUsageBreakdown;
|
|
10
10
|
exports.getUsageAgentNames = getUsageAgentNames;
|
|
11
11
|
exports.getBalanceHistory = getBalanceHistory;
|
|
12
12
|
exports.formatCredits = formatCredits;
|
|
@@ -48,7 +48,7 @@ async function setSkyCodeOverageConsent(enabled) {
|
|
|
48
48
|
body: { enabled },
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
async function
|
|
51
|
+
async function getUsageEvents(workspaceId, params = {}) {
|
|
52
52
|
const query = new URLSearchParams();
|
|
53
53
|
if (params.from)
|
|
54
54
|
query.set('from', params.from);
|
|
@@ -66,7 +66,7 @@ async function getSkyCodeUsageEvents(workspaceId, params = {}) {
|
|
|
66
66
|
const suffix = query.toString();
|
|
67
67
|
return (0, api_fetch_1.apiFetch)(suffix ? `${base}?${suffix}` : base);
|
|
68
68
|
}
|
|
69
|
-
async function
|
|
69
|
+
async function getUsageBreakdown(workspaceId, params = {}) {
|
|
70
70
|
const query = new URLSearchParams();
|
|
71
71
|
if (params.from)
|
|
72
72
|
query.set('from', params.from);
|
|
@@ -353,10 +353,11 @@ function describePowerSummary(summary, when = {}) {
|
|
|
353
353
|
lines.push(` - ${formatHolder(h, when)}`);
|
|
354
354
|
}
|
|
355
355
|
lines.push(`This month: ${formatUsage(summary.usage)}`);
|
|
356
|
-
if (power.policy
|
|
356
|
+
if ((0, data_provider_1.scheduledWorkWaitsForStart)(power.policy) && summary.nextExpectedWake) {
|
|
357
357
|
// A manual machine is started only by its owner, so a scheduled firing is work that will wait for
|
|
358
|
-
// that start, not a wake (OSK-22556). The value is the same one; only its label changes.
|
|
359
|
-
|
|
358
|
+
// that start, not a wake (OSK-22556). The value is the same one; only its label changes. The phrase
|
|
359
|
+
// is the shared one, so the web card and this line cannot say it differently.
|
|
360
|
+
lines.push(`Next scheduled work: ${(0, format_1.formatWhen)(summary.nextExpectedWake, when)} (${data_provider_1.SCHEDULED_WORK_WAITS_FOR_START})`);
|
|
360
361
|
}
|
|
361
362
|
else if (summary.workspaceVolumeMissing !== true) {
|
|
362
363
|
// Not for a machine whose workspace disk is recorded gone (OSK-23526): a wake is a start, and a start is
|