@testsprite/testsprite-cli 0.3.0 → 0.5.0
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 +55 -29
- package/dist/commands/agent.js +17 -6
- package/dist/commands/auth.d.ts +51 -0
- package/dist/commands/auth.js +46 -2
- package/dist/commands/completion.d.ts +36 -0
- package/dist/commands/completion.js +111 -0
- package/dist/commands/doctor.js +56 -16
- package/dist/commands/init.d.ts +32 -1
- package/dist/commands/init.js +40 -10
- package/dist/commands/project.d.ts +102 -4
- package/dist/commands/project.js +250 -47
- package/dist/commands/test.d.ts +253 -11
- package/dist/commands/test.js +1822 -390
- package/dist/commands/usage.d.ts +56 -17
- package/dist/commands/usage.js +144 -29
- package/dist/index.js +172 -29
- package/dist/lib/browser.d.ts +6 -0
- package/dist/lib/browser.js +54 -0
- package/dist/lib/bundle.d.ts +32 -31
- package/dist/lib/bundle.js +144 -84
- package/dist/lib/client-factory.d.ts +29 -0
- package/dist/lib/client-factory.js +49 -1
- package/dist/lib/config.js +7 -3
- package/dist/lib/credentials.d.ts +17 -1
- package/dist/lib/credentials.js +175 -16
- package/dist/lib/dry-run/samples.js +51 -1
- package/dist/lib/errors.d.ts +33 -1
- package/dist/lib/errors.js +110 -19
- package/dist/lib/failing-fe-resolver.d.ts +15 -0
- package/dist/lib/failing-fe-resolver.js +49 -1
- package/dist/lib/flaky.d.ts +12 -1
- package/dist/lib/flaky.js +7 -12
- package/dist/lib/gh-output.d.ts +62 -0
- package/dist/lib/gh-output.js +99 -0
- package/dist/lib/http.d.ts +86 -16
- package/dist/lib/http.js +181 -11
- package/dist/lib/interrupt.d.ts +65 -10
- package/dist/lib/interrupt.js +94 -9
- package/dist/lib/org-render.d.ts +52 -0
- package/dist/lib/org-render.js +59 -0
- package/dist/lib/poll.d.ts +11 -0
- package/dist/lib/poll.js +71 -6
- package/dist/lib/render-error.d.ts +14 -0
- package/dist/lib/render-error.js +30 -0
- package/dist/lib/response-schemas.d.ts +83 -0
- package/dist/lib/response-schemas.js +272 -0
- package/dist/lib/runs.types.d.ts +62 -8
- package/dist/lib/skill-nudge.d.ts +17 -0
- package/dist/lib/skill-nudge.js +19 -0
- package/dist/lib/telemetry.d.ts +90 -0
- package/dist/lib/telemetry.js +171 -0
- package/dist/lib/text-table.d.ts +14 -0
- package/dist/lib/text-table.js +45 -0
- package/dist/lib/v3-advisory.d.ts +22 -0
- package/dist/lib/v3-advisory.js +32 -0
- package/dist/lib/version-notice.d.ts +37 -0
- package/dist/lib/version-notice.js +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +16 -5
- package/schemas/plan.schema.json +61 -0
- package/skills/testsprite-verify.codex.md +8 -2
- package/skills/testsprite-verify.skill.md +18 -7
package/dist/commands/usage.d.ts
CHANGED
|
@@ -2,39 +2,38 @@
|
|
|
2
2
|
* `testsprite usage` — show the account's credit balance and plan/entitlement
|
|
3
3
|
* info as a proactive pre-flight before a large `test run` fan-out.
|
|
4
4
|
*
|
|
5
|
-
* Backend note:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Add `credits`, `subPlan` to the `/me` response, or add a dedicated
|
|
13
|
-
* `GET /api/cli/v1/usage` endpoint returning `{ credits, subPlan, creditsPerRun }`.
|
|
5
|
+
* Backend note: `GET /me` now includes the `credits` / `subPlan` projection
|
|
6
|
+
* (this shipped; the CLI's old "requires a backend update"
|
|
7
|
+
* wording is stale and was removed). This command calls `/me` and surfaces
|
|
8
|
+
* the `credits` / `subPlan` / `creditsPerRun` fields when and only when the
|
|
9
|
+
* backend response includes them — kept absent-safe/forward-compat since not
|
|
10
|
+
* every account shape is guaranteed to populate all three (e.g. `creditsPerRun`
|
|
11
|
+
* has no server-side source at all today).
|
|
14
12
|
*/
|
|
15
13
|
import { Command } from 'commander';
|
|
16
14
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
17
15
|
import type { FetchImpl } from '../lib/http.js';
|
|
16
|
+
import type { CliOrgBinding, CliOrgSummary } from '../lib/org-render.js';
|
|
18
17
|
/**
|
|
19
18
|
* Usage/balance response from `/me` (when the backend supplies it) or a future
|
|
20
19
|
* `/usage` endpoint.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* `credits` / `subPlan` now ship on `/me` (live). Still
|
|
22
|
+
* kept optional/absent-safe: `userId`/`keyId`/`env` are the only fields every
|
|
23
|
+
* backend and account shape is guaranteed to populate.
|
|
24
24
|
*/
|
|
25
25
|
export interface UsageResponse {
|
|
26
26
|
userId: string;
|
|
27
27
|
keyId: string;
|
|
28
28
|
env: 'development' | 'staging' | 'production';
|
|
29
29
|
/**
|
|
30
|
-
* Remaining credit balance. Present
|
|
31
|
-
* includes the User.credits projection
|
|
30
|
+
* Remaining credit balance. Present when the backend /me (or /usage)
|
|
31
|
+
* includes the User.credits projection (live).
|
|
32
32
|
*/
|
|
33
33
|
credits?: number;
|
|
34
34
|
/**
|
|
35
|
-
* Subscription plan name (e.g. "Free", "Standard", "Pro"). Present
|
|
36
|
-
* the backend /me (or /usage) includes the User.subPlan projection.
|
|
37
|
-
* BACKEND FOLLOW-UP: me.controller.ts.
|
|
35
|
+
* Subscription plan name (e.g. "Free", "Standard", "Pro"). Present when
|
|
36
|
+
* the backend /me (or /usage) includes the User.subPlan projection (live).
|
|
38
37
|
*/
|
|
39
38
|
subPlan?: string;
|
|
40
39
|
/**
|
|
@@ -42,6 +41,45 @@ export interface UsageResponse {
|
|
|
42
41
|
* backend supplies it.
|
|
43
42
|
*/
|
|
44
43
|
creditsPerRun?: number;
|
|
44
|
+
/**
|
|
45
|
+
* The caller's organization wallet — the billing subject on org-based
|
|
46
|
+
* accounts. Rendered only together with `v3Enabled: true` (see
|
|
47
|
+
* `renderUsage`): the org wallet supersedes the legacy `credits`/`subPlan`
|
|
48
|
+
* pair only for callers whose commands actually bill it. Absent-safe like
|
|
49
|
+
* every other optional field.
|
|
50
|
+
*/
|
|
51
|
+
activeOrg?: ActiveOrg;
|
|
52
|
+
/**
|
|
53
|
+
* Authoritative per-caller routing bit: true when this caller's commands
|
|
54
|
+
* run (and bill) on the V3 platform. Always present on current backends;
|
|
55
|
+
* absent on older ones.
|
|
56
|
+
*/
|
|
57
|
+
v3Enabled?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Every organization the underlying user belongs to (account-wide
|
|
60
|
+
* membership list, personal org included). Absent-safe: omitted on a
|
|
61
|
+
* server-side lookup failure or an older backend.
|
|
62
|
+
*/
|
|
63
|
+
organizations?: CliOrgSummary[];
|
|
64
|
+
/**
|
|
65
|
+
* The calling key's own org binding. Present only when the request
|
|
66
|
+
* authenticated with a Postgres-backed membership key (`sk-member-…`).
|
|
67
|
+
*/
|
|
68
|
+
org?: CliOrgBinding;
|
|
69
|
+
}
|
|
70
|
+
/** Slim org-wallet view shipped on `/me` (see the backend `Me` schema). */
|
|
71
|
+
export interface ActiveOrg {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
/** Org plan (`Free` | `Starter` | `Standard`). */
|
|
75
|
+
plan: string;
|
|
76
|
+
/** Caller's role in the org (`owner` | `admin` | `member`). */
|
|
77
|
+
role: string;
|
|
78
|
+
/** Spendable balance: the caller's member bucket + the org's shared top-up pool. */
|
|
79
|
+
remaining: number;
|
|
80
|
+
/** Monthly per-seat credit allowance for the org's plan. */
|
|
81
|
+
includedCredits: number;
|
|
82
|
+
seats: number;
|
|
45
83
|
}
|
|
46
84
|
export interface UsageDeps {
|
|
47
85
|
env?: NodeJS.ProcessEnv;
|
|
@@ -56,7 +94,8 @@ export declare const DRY_RUN_USAGE_SAMPLE: UsageResponse;
|
|
|
56
94
|
/**
|
|
57
95
|
* Run the `usage` command. Calls `GET /me`, surfaces identity + any
|
|
58
96
|
* credits/plan fields the backend supplies. Absent fields are silently
|
|
59
|
-
* omitted (forward-compat
|
|
97
|
+
* omitted (forward-compat in case a given account/backend version doesn't
|
|
98
|
+
* populate them).
|
|
60
99
|
*/
|
|
61
100
|
export declare function runUsage(opts: CommonOptions, deps?: UsageDeps): Promise<UsageResponse>;
|
|
62
101
|
export declare function createUsageCommand(deps?: UsageDeps): Command;
|
package/dist/commands/usage.js
CHANGED
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
* `testsprite usage` — show the account's credit balance and plan/entitlement
|
|
3
3
|
* info as a proactive pre-flight before a large `test run` fan-out.
|
|
4
4
|
*
|
|
5
|
-
* Backend note:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Add `credits`, `subPlan` to the `/me` response, or add a dedicated
|
|
13
|
-
* `GET /api/cli/v1/usage` endpoint returning `{ credits, subPlan, creditsPerRun }`.
|
|
5
|
+
* Backend note: `GET /me` now includes the `credits` / `subPlan` projection
|
|
6
|
+
* (this shipped; the CLI's old "requires a backend update"
|
|
7
|
+
* wording is stale and was removed). This command calls `/me` and surfaces
|
|
8
|
+
* the `credits` / `subPlan` / `creditsPerRun` fields when and only when the
|
|
9
|
+
* backend response includes them — kept absent-safe/forward-compat since not
|
|
10
|
+
* every account shape is guaranteed to populate all three (e.g. `creditsPerRun`
|
|
11
|
+
* has no server-side source at all today).
|
|
14
12
|
*/
|
|
15
13
|
import { Command } from 'commander';
|
|
16
14
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
17
15
|
import { loadConfig } from '../lib/config.js';
|
|
18
16
|
import { resolvePortalBase } from '../lib/facade.js';
|
|
17
|
+
import { formatOrgBinding, formatOrgsSummary } from '../lib/org-render.js';
|
|
19
18
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
20
19
|
/** Dry-run canned response — matches what the real /me + User lookup would return. */
|
|
21
20
|
export const DRY_RUN_USAGE_SAMPLE = {
|
|
@@ -25,18 +24,29 @@ export const DRY_RUN_USAGE_SAMPLE = {
|
|
|
25
24
|
credits: 42,
|
|
26
25
|
subPlan: 'Standard',
|
|
27
26
|
creditsPerRun: 2,
|
|
27
|
+
v3Enabled: true,
|
|
28
|
+
activeOrg: {
|
|
29
|
+
id: '22222222-2222-4222-8222-222222222222',
|
|
30
|
+
name: 'Dry Run Workspace',
|
|
31
|
+
plan: 'Standard',
|
|
32
|
+
role: 'owner',
|
|
33
|
+
remaining: 1650,
|
|
34
|
+
includedCredits: 1600,
|
|
35
|
+
seats: 1,
|
|
36
|
+
},
|
|
28
37
|
};
|
|
29
38
|
/**
|
|
30
39
|
* Run the `usage` command. Calls `GET /me`, surfaces identity + any
|
|
31
40
|
* credits/plan fields the backend supplies. Absent fields are silently
|
|
32
|
-
* omitted (forward-compat
|
|
41
|
+
* omitted (forward-compat in case a given account/backend version doesn't
|
|
42
|
+
* populate them).
|
|
33
43
|
*/
|
|
34
44
|
export async function runUsage(opts, deps = {}) {
|
|
35
45
|
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
36
46
|
const out = makeOutput(opts.output, deps);
|
|
37
47
|
if (opts.dryRun) {
|
|
38
48
|
emitDryRunBanner(stderr);
|
|
39
|
-
stderr('[note]
|
|
49
|
+
stderr('[note] --dry-run showing canned sample values, not your real balance');
|
|
40
50
|
out.print(DRY_RUN_USAGE_SAMPLE, data => renderUsage(data));
|
|
41
51
|
return DRY_RUN_USAGE_SAMPLE;
|
|
42
52
|
}
|
|
@@ -59,28 +69,109 @@ export async function runUsage(opts, deps = {}) {
|
|
|
59
69
|
const billingUrl = portalBase !== undefined
|
|
60
70
|
? `${portalBase}/dashboard/settings/billing`
|
|
61
71
|
: 'the portal Billing page (/dashboard/settings/billing)';
|
|
62
|
-
// /me is the only available source of credits/plan today.
|
|
63
|
-
//
|
|
64
|
-
//
|
|
72
|
+
// /me is the only available source of credits/plan today. If the backend
|
|
73
|
+
// adds a dedicated /usage endpoint later, this single get call is where
|
|
74
|
+
// it would be swapped in — no other code change needed in the CLI.
|
|
65
75
|
const me = await client.get('/me');
|
|
66
76
|
out.print(me, data => renderUsage(data, portalBase));
|
|
67
|
-
// In text mode, emit a
|
|
68
|
-
// user
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
// In text mode, emit a note when NO balance was shown at all — neither the
|
|
78
|
+
// legacy per-user `credits` nor an org wallet. A V3-routed org account can
|
|
79
|
+
// legitimately have no DDB `credits` field (org-native members never get a
|
|
80
|
+
// legacy user row), and its balance already rendered in the organization
|
|
81
|
+
// block — the note would contradict the output right above it.
|
|
82
|
+
//
|
|
83
|
+
// "Is this key org-bound" and "do I have a balance number to show" are two
|
|
84
|
+
// different questions and must not be conflated. `me.org` is the key's own
|
|
85
|
+
// binding — always present, no I/O, populated whenever the request
|
|
86
|
+
// authenticated with a membership key (`sk-member-…`). `activeOrg` is the
|
|
87
|
+
// *enriched* org balance: the backend does a best-effort Postgres read for
|
|
88
|
+
// it and swallows the exception on failure, so `org` can be present while
|
|
89
|
+
// `activeOrg` (and, for a V3-native user with no legacy DynamoDB row,
|
|
90
|
+
// `credits` too) is absent. Deciding org-boundedness from `activeOrg`
|
|
91
|
+
// (i.e. `orgWalletShown`) alone means that degraded state falls through to
|
|
92
|
+
// this personal-billing note — pointing an org-key operator at the wrong
|
|
93
|
+
// wallet in exactly the situation this whole surface exists to prevent.
|
|
94
|
+
const isOrgBound = me.org !== undefined;
|
|
95
|
+
const orgWalletShown = me.v3Enabled === true && me.activeOrg !== undefined;
|
|
96
|
+
if (opts.output === 'text' && me.credits === undefined && !orgWalletShown) {
|
|
97
|
+
stderr(isOrgBound
|
|
98
|
+
? "[note] this key is organization-bound, but the org balance could not be loaded right now. Retry `testsprite usage`, or check the Portal's organization billing settings (ask an org admin if you don't have access)."
|
|
99
|
+
: `[note] credit balance not returned for this account. Check ${billingUrl} for your current balance.`);
|
|
72
100
|
}
|
|
73
101
|
return me;
|
|
74
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Org-wallet low-balance threshold: the cost of a generation action —
|
|
105
|
+
* the priciest common single action on org billing. Below this, the next
|
|
106
|
+
* AI-assisted operation may fail; cheaper actions can still succeed.
|
|
107
|
+
*/
|
|
108
|
+
const LOW_ORG_BALANCE_CREDITS = 2;
|
|
75
109
|
function renderUsage(u, portalBase) {
|
|
76
110
|
const lines = [];
|
|
77
111
|
// Identity block (always present)
|
|
78
112
|
lines.push(`userId: ${u.userId}`);
|
|
79
113
|
lines.push(`keyId: ${u.keyId}`);
|
|
80
114
|
lines.push(`env: ${u.env}`);
|
|
81
|
-
//
|
|
115
|
+
// Org attribution — rendered only when the backend supplies it.
|
|
116
|
+
const orgsSummary = formatOrgsSummary(u.organizations);
|
|
117
|
+
if (orgsSummary)
|
|
118
|
+
lines.push(`orgs: ${orgsSummary}`);
|
|
119
|
+
const orgBinding = formatOrgBinding(u.org);
|
|
120
|
+
if (orgBinding)
|
|
121
|
+
lines.push(`org binding: ${orgBinding}`);
|
|
122
|
+
// Whether the CALLING KEY is org-bound — read from `u.org` (the key's own
|
|
123
|
+
// membership binding: always present, no I/O, populated whenever the
|
|
124
|
+
// request authenticated with a `sk-member-…` key), NOT from `activeOrg`.
|
|
125
|
+
// `activeOrg` is the *enriched* org balance: the backend does a best-effort
|
|
126
|
+
// Postgres read for it and swallows the exception on failure, so a caller
|
|
127
|
+
// can be genuinely org-bound (`org` present) while `activeOrg` — and, for a
|
|
128
|
+
// V3-native user with no legacy DynamoDB row, `credits` too — is absent.
|
|
129
|
+
// "Is this key org-bound" and "do I have a balance number to show" are two
|
|
130
|
+
// different questions; conflating them (deciding org-boundedness from
|
|
131
|
+
// `orgWallet`/`activeOrg` alone) sends a degraded-enrichment org caller
|
|
132
|
+
// down the personal-wallet branches below.
|
|
133
|
+
const isOrgBound = u.org !== undefined;
|
|
134
|
+
// Org wallet block — the billing subject on org-based accounts. Rendered
|
|
135
|
+
// only when the caller is actually V3-routed: `v3Enabled` is the
|
|
136
|
+
// authoritative routing bit, so wallet selection never rests on field
|
|
137
|
+
// presence alone. A V2-routed caller keeps the legacy block below (their
|
|
138
|
+
// billable commands still charge the legacy wallet); older backends send
|
|
139
|
+
// neither field and degrade the same way.
|
|
140
|
+
// `?? undefined` also normalizes a hypothetical explicit `null` from the
|
|
141
|
+
// wire so the block below can't dereference it.
|
|
142
|
+
const orgWallet = u.v3Enabled === true ? (u.activeOrg ?? undefined) : undefined;
|
|
143
|
+
if (orgWallet !== undefined) {
|
|
144
|
+
const org = orgWallet;
|
|
145
|
+
lines.push('');
|
|
146
|
+
lines.push('--- organization ---');
|
|
147
|
+
lines.push(`org: ${org.name} (${org.role})`);
|
|
148
|
+
lines.push(`plan: ${org.plan}`);
|
|
149
|
+
// Labeled `balance:` (not `credits:`) — `--output json` exposes the
|
|
150
|
+
// legacy per-user number under `.credits`, and giving the org wallet the
|
|
151
|
+
// same label in text mode would make one word mean two different values.
|
|
152
|
+
lines.push(`balance: ${org.remaining} remaining (${org.includedCredits}/mo per seat)`);
|
|
153
|
+
lines.push(`seats: ${org.seats}`);
|
|
154
|
+
// No "~N runs" estimate here: org billing prices actions individually and
|
|
155
|
+
// the API does not expose a per-run rate for the org wallet — an estimate
|
|
156
|
+
// computed from the legacy frontend rate would be wrong.
|
|
157
|
+
}
|
|
158
|
+
else if (isOrgBound) {
|
|
159
|
+
// Org-bound key, but the enrichment that would have populated `activeOrg`
|
|
160
|
+
// degraded (best-effort Postgres read failed server-side, or `v3Enabled`
|
|
161
|
+
// itself couldn't be resolved). Say so honestly — never fall through to
|
|
162
|
+
// the legacy per-user blocks below (this key's commands bill the org
|
|
163
|
+
// wallet, not the personal one, regardless of whether we could load its
|
|
164
|
+
// number just now), and never fabricate an org-scoped URL.
|
|
165
|
+
lines.push('');
|
|
166
|
+
lines.push('--- organization ---');
|
|
167
|
+
lines.push("balance: could not be loaded right now. Retry `testsprite usage`, or check the Portal's organization billing settings (ask an org admin if you don't have access).");
|
|
168
|
+
}
|
|
169
|
+
// Legacy balance block — shown only when the backend supplies it, no org
|
|
170
|
+
// wallet superseded it (older backends / V2-routed accounts), AND the key
|
|
171
|
+
// isn't org-bound (an org-bound key's commands never charge these numbers,
|
|
172
|
+
// even if a legacy row happens to still carry them).
|
|
82
173
|
const hasBalanceData = u.credits !== undefined || u.subPlan !== undefined;
|
|
83
|
-
if (hasBalanceData) {
|
|
174
|
+
if (orgWallet === undefined && !isOrgBound && hasBalanceData) {
|
|
84
175
|
lines.push('');
|
|
85
176
|
lines.push('--- credits & plan ---');
|
|
86
177
|
if (u.subPlan !== undefined) {
|
|
@@ -91,7 +182,7 @@ function renderUsage(u, portalBase) {
|
|
|
91
182
|
}
|
|
92
183
|
if (u.creditsPerRun !== undefined) {
|
|
93
184
|
lines.push(`cost per frontend run: ${u.creditsPerRun} credit(s)`);
|
|
94
|
-
// Backend runs DO consume credits (confirmed by design 2026-06-30
|
|
185
|
+
// Backend runs DO consume credits (confirmed by design 2026-06-30).
|
|
95
186
|
// The API exposes no backend-specific per-run cost field, and it differs from
|
|
96
187
|
// the frontend rate, so state that it bills without asserting a possibly-wrong
|
|
97
188
|
// number — check your balance before/after, or see the billing page.
|
|
@@ -103,13 +194,35 @@ function renderUsage(u, portalBase) {
|
|
|
103
194
|
lines.push(`can trigger: ~${maxRuns} run(s) at current balance`);
|
|
104
195
|
}
|
|
105
196
|
}
|
|
106
|
-
// Actionable upgrade line for Free or low-balance keys
|
|
107
|
-
|
|
108
|
-
|
|
197
|
+
// Actionable upgrade line for Free or low-balance keys. Prefer the org
|
|
198
|
+
// wallet's plan/balance when present. `!isOrgBound` guards the personal
|
|
199
|
+
// branch of each: an org-bound key with degraded enrichment has no
|
|
200
|
+
// `orgWallet` to compute from, but must not fall back to reading `u.credits`
|
|
201
|
+
// / `u.subPlan` either (a legacy row that happens to coexist with an org
|
|
202
|
+
// binding is not what this key's commands actually bill).
|
|
203
|
+
const isLowBalance = orgWallet !== undefined
|
|
204
|
+
? orgWallet.remaining < LOW_ORG_BALANCE_CREDITS
|
|
205
|
+
: !isOrgBound &&
|
|
206
|
+
u.credits !== undefined &&
|
|
207
|
+
u.creditsPerRun !== undefined &&
|
|
208
|
+
u.credits < u.creditsPerRun;
|
|
209
|
+
const isFree = orgWallet !== undefined
|
|
210
|
+
? orgWallet.plan.toLowerCase() === 'free'
|
|
211
|
+
: !isOrgBound && u.subPlan?.toLowerCase() === 'free';
|
|
109
212
|
if (isLowBalance) {
|
|
110
213
|
lines.push('');
|
|
111
|
-
|
|
112
|
-
|
|
214
|
+
// The org wallet is billed under the ORGANIZATION's own settings, not the
|
|
215
|
+
// personal `/dashboard/settings/billing` page (that page manages the
|
|
216
|
+
// legacy per-user DDB balance, a different column entirely) — so the
|
|
217
|
+
// org branch deliberately does not point at that URL. No org-scoped
|
|
218
|
+
// settings URL is fabricated here either: the CLI has no confirmed route
|
|
219
|
+
// for one, so "ask an org admin" is the honest next step.
|
|
220
|
+
lines.push(orgWallet !== undefined
|
|
221
|
+
? // Org billing prices actions individually, and cheaper actions (e.g.
|
|
222
|
+
// a 1-credit backend run) may still succeed below the threshold —
|
|
223
|
+
// so this is "low", not "cannot run".
|
|
224
|
+
`warning: organization balance is low (under the ${LOW_ORG_BALANCE_CREDITS}-credit cost of a generation action). Top up in the Portal's organization billing settings (ask an org admin if you don't have access).`
|
|
225
|
+
: `warning: credit balance is below the per-run cost. Top up at: ${portalBase !== undefined ? `${portalBase}/dashboard/settings/billing` : 'the portal Billing page (/dashboard/settings/billing)'}`);
|
|
113
226
|
}
|
|
114
227
|
else if (isFree) {
|
|
115
228
|
lines.push('');
|
|
@@ -132,8 +245,10 @@ export function createUsageCommand(deps = {}) {
|
|
|
132
245
|
' 0 success (or --dry-run)\n' +
|
|
133
246
|
' 3 auth error — run `testsprite setup` to configure credentials\n' +
|
|
134
247
|
' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
|
|
135
|
-
|
|
136
|
-
|
|
248
|
+
"\nNote: if credit balance isn't shown for your account, check your portal's\n" +
|
|
249
|
+
' Billing page (/dashboard/settings/billing) for a personal key, or your\n' +
|
|
250
|
+
' organization billing settings (ask an org admin) if this key is\n' +
|
|
251
|
+
' organization-bound.')
|
|
137
252
|
.action(async (_cmdOpts, command) => {
|
|
138
253
|
await runUsage(resolveCommonOptions(command), deps);
|
|
139
254
|
});
|