@foldrun/core 12.0.2 → 12.1.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/dist/src/runner.js +10 -3
- package/dist/src/store.d.ts +6 -0
- package/dist/src/store.js +9 -1
- package/package.json +1 -1
- package/src/runner.ts +10 -3
- package/src/store.ts +10 -1
package/dist/src/runner.js
CHANGED
|
@@ -2256,8 +2256,15 @@ mayDefer) {
|
|
|
2256
2256
|
// An account refused the platform's credential (below) is never shown
|
|
2257
2257
|
// running on it: the record said "Claude login token" on a step that
|
|
2258
2258
|
// was then refused for having no key (FOL-14, 18 Oct 2026).
|
|
2259
|
-
|
|
2260
|
-
|
|
2259
|
+
// Whether the PRIMARY call rides the platform's credential: only a block
|
|
2260
|
+
// with a base_url fills providerEnv. A block with just a fallback: has a
|
|
2261
|
+
// label ("platform (fallback: …)") yet its first call is the platform's,
|
|
2262
|
+
// so it is judged here by the env, never by the label — the label let it
|
|
2263
|
+
// past the refusal below and recorded it as "provider:", which the meter
|
|
2264
|
+
// bills at $0 (3 Nov 2026).
|
|
2265
|
+
const primaryOnPlatform = Object.keys(providerEnv).length === 0;
|
|
2266
|
+
const noKey = primaryOnPlatform && !platform.platformKeyAllowed(tenant);
|
|
2267
|
+
const credential = !primaryOnPlatform || noKey ? null : resolveModelCredential(isolatedRun() ? platformModelEnv() : process.env);
|
|
2261
2268
|
step.credential = credential ? credential.label : noKey ? "none — this account has no model key" : `provider: ${providerLabel}`;
|
|
2262
2269
|
// Core's own Docker container has no login to fall back to (below):
|
|
2263
2270
|
// there, "none set" is refused with what to do, not described.
|
|
@@ -2272,7 +2279,7 @@ mayDefer) {
|
|
|
2272
2279
|
// operator's key, and not failed later by a provider.
|
|
2273
2280
|
if (!platform.platformKeyAllowed(tenant)) {
|
|
2274
2281
|
const own = Object.values(providerSecrets).concat(Object.values(providerEnv));
|
|
2275
|
-
if (
|
|
2282
|
+
if (primaryOnPlatform) {
|
|
2276
2283
|
push("error", `no model key: this account runs on its own API key, and none is set. Add one in Settings → Model ` +
|
|
2277
2284
|
`(or \`foldrun account model set <provider> --key …\`), or write a provider: block in AGENTS.md`);
|
|
2278
2285
|
step.status = "failed";
|
package/dist/src/store.d.ts
CHANGED
|
@@ -1705,6 +1705,12 @@ export declare function stoppedByText(run: Pick<RunRecord, "stoppedBy"> | null |
|
|
|
1705
1705
|
*/
|
|
1706
1706
|
export declare function runDisplayStatus(run: Pick<RunRecord, "status" | "stopRequested">): string;
|
|
1707
1707
|
export declare function runCost(run: RunRecord): number;
|
|
1708
|
+
/** Whether a step's tokens are the platform's to bill: it ran on the
|
|
1709
|
+
* platform's own model credential, not the account's key ("provider: …" —
|
|
1710
|
+
* a provider: block, or Settings → Model), which the provider bills. The
|
|
1711
|
+
* meter, the Usage page and the ledger split all ask this one question, so
|
|
1712
|
+
* what a page shows is what was charged. */
|
|
1713
|
+
export declare function stepBillsTokens(s: Pick<StepRecord, "credential">): boolean;
|
|
1708
1714
|
/**
|
|
1709
1715
|
* What a finished run consumed, in the units the format itself has — the
|
|
1710
1716
|
* shape ledger.ts prices. Structural, not an import, because ledger.ts
|
package/dist/src/store.js
CHANGED
|
@@ -3248,6 +3248,14 @@ export function runDisplayStatus(run) {
|
|
|
3248
3248
|
export function runCost(run) {
|
|
3249
3249
|
return run.steps.reduce((sum, s) => sum + (s.costUsd ?? 0), 0);
|
|
3250
3250
|
}
|
|
3251
|
+
/** Whether a step's tokens are the platform's to bill: it ran on the
|
|
3252
|
+
* platform's own model credential, not the account's key ("provider: …" —
|
|
3253
|
+
* a provider: block, or Settings → Model), which the provider bills. The
|
|
3254
|
+
* meter, the Usage page and the ledger split all ask this one question, so
|
|
3255
|
+
* what a page shows is what was charged. */
|
|
3256
|
+
export function stepBillsTokens(s) {
|
|
3257
|
+
return !(s.credential ?? "").startsWith("provider:");
|
|
3258
|
+
}
|
|
3251
3259
|
/**
|
|
3252
3260
|
* What a finished run consumed, in the units the format itself has — the
|
|
3253
3261
|
* shape ledger.ts prices. Structural, not an import, because ledger.ts
|
|
@@ -3278,7 +3286,7 @@ export function runMeter(run) {
|
|
|
3278
3286
|
if (s.carriedFrom)
|
|
3279
3287
|
continue;
|
|
3280
3288
|
steps += 1;
|
|
3281
|
-
if (
|
|
3289
|
+
if (stepBillsTokens(s))
|
|
3282
3290
|
tokenCostUsd += s.costUsd ?? 0;
|
|
3283
3291
|
const secs = s.computeSecs ?? 0;
|
|
3284
3292
|
computeSecs += secs;
|
package/package.json
CHANGED
package/src/runner.ts
CHANGED
|
@@ -2449,8 +2449,15 @@ async function runStep(
|
|
|
2449
2449
|
// An account refused the platform's credential (below) is never shown
|
|
2450
2450
|
// running on it: the record said "Claude login token" on a step that
|
|
2451
2451
|
// was then refused for having no key (FOL-14, 18 Oct 2026).
|
|
2452
|
-
|
|
2453
|
-
|
|
2452
|
+
// Whether the PRIMARY call rides the platform's credential: only a block
|
|
2453
|
+
// with a base_url fills providerEnv. A block with just a fallback: has a
|
|
2454
|
+
// label ("platform (fallback: …)") yet its first call is the platform's,
|
|
2455
|
+
// so it is judged here by the env, never by the label — the label let it
|
|
2456
|
+
// past the refusal below and recorded it as "provider:", which the meter
|
|
2457
|
+
// bills at $0 (3 Nov 2026).
|
|
2458
|
+
const primaryOnPlatform = Object.keys(providerEnv).length === 0;
|
|
2459
|
+
const noKey = primaryOnPlatform && !platform.platformKeyAllowed(tenant);
|
|
2460
|
+
const credential = !primaryOnPlatform || noKey ? null : resolveModelCredential(isolatedRun() ? platformModelEnv() : process.env);
|
|
2454
2461
|
step.credential = credential ? credential.label : noKey ? "none — this account has no model key" : `provider: ${providerLabel}`;
|
|
2455
2462
|
// Core's own Docker container has no login to fall back to (below):
|
|
2456
2463
|
// there, "none set" is refused with what to do, not described.
|
|
@@ -2465,7 +2472,7 @@ async function runStep(
|
|
|
2465
2472
|
// operator's key, and not failed later by a provider.
|
|
2466
2473
|
if (!platform.platformKeyAllowed(tenant)) {
|
|
2467
2474
|
const own = Object.values(providerSecrets).concat(Object.values(providerEnv));
|
|
2468
|
-
if (
|
|
2475
|
+
if (primaryOnPlatform) {
|
|
2469
2476
|
push(
|
|
2470
2477
|
"error",
|
|
2471
2478
|
`no model key: this account runs on its own API key, and none is set. Add one in Settings → Model ` +
|
package/src/store.ts
CHANGED
|
@@ -4382,6 +4382,15 @@ export function runCost(run: RunRecord): number {
|
|
|
4382
4382
|
return run.steps.reduce((sum, s) => sum + (s.costUsd ?? 0), 0);
|
|
4383
4383
|
}
|
|
4384
4384
|
|
|
4385
|
+
/** Whether a step's tokens are the platform's to bill: it ran on the
|
|
4386
|
+
* platform's own model credential, not the account's key ("provider: …" —
|
|
4387
|
+
* a provider: block, or Settings → Model), which the provider bills. The
|
|
4388
|
+
* meter, the Usage page and the ledger split all ask this one question, so
|
|
4389
|
+
* what a page shows is what was charged. */
|
|
4390
|
+
export function stepBillsTokens(s: Pick<StepRecord, "credential">): boolean {
|
|
4391
|
+
return !(s.credential ?? "").startsWith("provider:");
|
|
4392
|
+
}
|
|
4393
|
+
|
|
4385
4394
|
/**
|
|
4386
4395
|
* What a finished run consumed, in the units the format itself has — the
|
|
4387
4396
|
* shape ledger.ts prices. Structural, not an import, because ledger.ts
|
|
@@ -4418,7 +4427,7 @@ export function runMeter(run: RunRecord): {
|
|
|
4418
4427
|
// A carried step ran — and was billed — in the run it was carried from.
|
|
4419
4428
|
if (s.carriedFrom) continue;
|
|
4420
4429
|
steps += 1;
|
|
4421
|
-
if (
|
|
4430
|
+
if (stepBillsTokens(s)) tokenCostUsd += s.costUsd ?? 0;
|
|
4422
4431
|
const secs = s.computeSecs ?? 0;
|
|
4423
4432
|
computeSecs += secs;
|
|
4424
4433
|
if (s.size === "small") smallSecs += secs;
|