foldrun 4.0.1 → 5.0.1

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/docs/api.md CHANGED
@@ -41,7 +41,7 @@ read (a deploy with issues, an `Idempotency-Key` reused with a different body),
41
41
  than the person who minted it, and opens every route below with that — except
42
42
  the ones that are about people: `/api/team` (invite, roles, scope, remove,
43
43
  transfer), `/api/auth/*` (profile, password, MFA, sessions), a user's
44
- `/api/avatars/user/<id>`, and the super admin console. Those need a signed-in
44
+ `/api/avatars/user/<id>`. Those need a signed-in
45
45
  session and answer a key with `401` (a user's avatar answers a key with
46
46
  `403`: the key is read, then refused because it is not that person). Everything a workspace or an account
47
47
  *does* — files, runs, secrets, shares, schedules, hooks, storage, billing —
@@ -404,7 +404,7 @@ person: a key names an account, never a who.
404
404
  | `/api/billing/wallet` | GET, PUT | the balance summary (burn, runway, daily spend, month to date, the suggested top-up), the refill rule and the low-balance email — GET `{ enabled, stripe, summary, cardSaved, autoTopUp, email, dunning }`, PUT `autoTopUp`, `email`. `dunning.status` is `none`, `grace` (a plan invoice failed; runs go on until `graceUntil`) or `suspended` (new runs paused until it is paid), with `payUrl`, `amountDue` (minor units) and `currency` |
405
405
  | `/api/billing/plans` | GET | the catalogue (four plans: fee, credits, per-credit price, runs at once, workspaces, lane), where this account stands (plan, status, this cycle's credits and what is left, when it resets), the balance in dollars and credits, and any overdraft the platform has allowed |
406
406
  | `/api/billing/subscribe` | POST, DELETE | POST `plan` — starter, creator, pro or scale. With no subscription yet, answers `url`: a Stripe Checkout in subscription mode; the return trip starts the first cycle. With a live one, changes it at Stripe at once, prorated (an upgrade is invoiced today and the bigger bundle lands with it; a downgrade comes back as credit on the next invoice), and answers `changed: true` — only once its prorated invoice is paid: when the payment needs the customer (a declined card, 3-D Secure) the change waits at Stripe as a pending update, nothing about the plan moves, and the answer is 402 `{ pending: true, payUrl }` — paying that invoice applies it; unpaid, Stripe drops it and voids the invoice after 23 hours. A plan set to stop and changed this way stays set to stop once paid — resuming it is the customer's own choice (`resume: true`); nothing resumes on its own. A plan set to stop at the period's end is still that live subscription: choosing a plan takes the stop off (and changes it if it is another plan) — never a second Checkout. With no subscription known here but one still billing at Stripe for the account's customer, 409: a second is not started. POST `resume: true` takes a pending cancellation off — nothing is charged and no cycle moves. DELETE ends the plan with the current cycle: the credits stand until then, and credits bought on top are kept |
407
- | `/api/billing/stripe` | POST | Stripe's webhook — signature-verified, not for you. Every delivery is logged (see `/api/admin/stripe-events`). Beside top-ups it turns plan cycles: one grant per (subscription, plan, period), whichever of the checkout, `invoice.paid` (either invoice shape) or `customer.subscription.updated` arrives first; `invoice.payment_failed` marks the plan past due and starts dunning (an email, a grace period, then new runs paused — see budgets-and-billing.md), `invoice.paid` and `invoice.voided` end it, `customer.subscription.deleted` ends the plan that subscription paid for — what is left of the bundle expires, the levers come off, money the customer added stays. `charge.refunded` debits a refunded top-up (never a plan fee), `charge.dispute.created` debits a chargeback and `charge.dispute.closed` returns it when won. Answers 500 — so Stripe redelivers — only when a lookup the event needs failed. The full event list is in budgets-and-billing.md |
407
+ | `/api/billing/stripe` | POST | Stripe's webhook — signature-verified, not for you. Every delivery is logged. Beside top-ups it turns plan cycles: one grant per (subscription, plan, period), whichever of the checkout, `invoice.paid` (either invoice shape) or `customer.subscription.updated` arrives first; `invoice.payment_failed` marks the plan past due and starts dunning (an email, a grace period, then new runs paused — see budgets-and-billing.md), `invoice.paid` and `invoice.voided` end it, `customer.subscription.deleted` ends the plan that subscription paid for — what is left of the bundle expires, the levers come off, money the customer added stays. `charge.refunded` debits a refunded top-up (never a plan fee), `charge.dispute.created` debits a chargeback and `charge.dispute.closed` returns it when won. Answers 500 — so Stripe redelivers — only when a lookup the event needs failed. The full event list is in budgets-and-billing.md |
408
408
 
409
409
  ## Versions
410
410
 
@@ -198,7 +198,7 @@ and on the audit; it is a term, never a surprise.
198
198
 
199
199
  **Charges an account does not pay.** The platform can waive any of the three
200
200
  meters for one account: model tokens, sandbox time, network. It is set per
201
- account from the admin console, never as an install-wide rate, because a
201
+ account by the platform, never as an install-wide rate, because a
202
202
  rate turned off globally would quietly stop charging every customer. The
203
203
  meters still run and the Usage page still shows everything measured; what
204
204
  changes is the bill. Every run still writes a ledger line — at zero when
@@ -390,26 +390,6 @@ runs, schedules stop firing — while the platform team settles the last
390
390
  invoice and any refund. Nothing is deleted by the request itself; people can
391
391
  still sign in and take the copy.
392
392
 
393
- ## The admin console's money levers
394
-
395
- Each customer (account) in the super admin console has a Billing tab with
396
- every lever that changes what the customer pays, each behind a confirmation
397
- that names the amount and the account: **credit or debit** with a reason on
398
- the ledger (the console sends an idempotency key, so a double click is one
399
- line), **extend the trial** (more trial credits as a grant, with whatever
400
- trial credit is left carried into it; not for an account on a plan), the
401
- **plan** (grant a cycle by hand, end it, and the lane and limits that ride
402
- with it), **going into minus**, and **charges this account does not pay**.
403
- The overview beside it holds the contact on record (name, email, phone,
404
- company, ABN), notes, suspension, and the customer's Stripe customer and
405
- subscription with links into Stripe's own dashboard — test or live, read
406
- from the install's key.
407
-
408
- Revenue has a CSV per month for the accountant (`GET /api/admin/export`):
409
- one row per customer and a total, charges by leg, fees, top-ups, grants,
410
- expiries, refunds, disputes, adjustments and net, with Stripe's own figures
411
- for the month beside them when Stripe is connected.
412
-
413
393
  ## The wallet
414
394
 
415
395
  Usage is settled from a credit balance. Add credit by card, once or with
@@ -469,11 +449,7 @@ dispute-won, plan, trial, grant-expired, credits-expired — and lines written
469
449
  before the field have theirs derived from their key and note. Statements
470
450
  label lines by it. **Burn**, the 30-day spend and month-to-date count usage
471
451
  and the daily fees only — not expiries, refunds, chargebacks or an
472
- operator's debit. The admin console's **charged** figure is usage (runs and
473
- account pod sessions) in the customer list and the money report alike;
474
- **paid in** is top-ups paid plus plan fees from the invoices Stripe said
475
- were paid; **held in wallets** is credit bought and unspent — granted
476
- credit is shown apart, because nobody paid for it by the dollar.
452
+ operator's debit.
477
453
 
478
454
  **Hand-placed plans renew.** A plan the super admin grants runs a month and
479
455
  is renewed by the hourly sweep at its period's end, with the same grant and
@@ -482,9 +458,6 @@ rollover rules. Granting a plan to an account Stripe is billing is refused
482
458
  the subscription at Stripe first, at once, and changes nothing if Stripe
483
459
  refuses.
484
460
 
485
- **An operator's credit or debit is written once** per idempotency key the
486
- console sends, and audited once.
487
-
488
461
  **Stripe.** Every call pins its API version (`2025-03-31.basil`;
489
462
  `STRIPE_API_VERSION` overrides) — create the webhook endpoint on the same
490
463
  version — and charges in `FOLDRUN_CURRENCY` (default `usd`), which is also
@@ -513,12 +486,10 @@ kept too, for the types above only, up to 256 KB, set when it first
513
486
  arrives and emptied after **180 days**: Stripe keeps events for 30, and a
514
487
  replay after that needs a copy. It carries what Stripe sends (names,
515
488
  emails, addresses, a card's last four digits — never a full card number),
516
- so only the super admin's console reads it and lists never load it. The
517
- super admin lists the log at `GET /api/admin/stripe-events` and replays
518
- one event with `POST /api/admin/stripe-events/<id>/replay` — Stripe's copy
519
- while Stripe has it, the kept copy after — through the same handler; every
520
- write it makes is keyed once, so a replay of an event that was handled
521
- changes nothing.
489
+ so it is never shown to the account. The platform can replay an event
490
+ through the same handler — Stripe's copy while Stripe has it, the kept
491
+ copy after; every write it makes is keyed once, so a replay of an event
492
+ that was handled changes nothing.
522
493
 
523
494
  ## Plan gates
524
495
 
package/docs/cli.md CHANGED
@@ -449,7 +449,7 @@ this way: they can take it back without changing a password.
449
449
 
450
450
  **You reset it, as the platform.** Only the platform's own super admin can,
451
451
  only on the hosted platform, and it ends every session that account had:
452
- `/admin/<account>` → the member → **reset password**. The new password is
452
+ from its console, the member → **reset password**. The new password is
453
453
  shown once. Sign in as them in a private window, then `foldrun login
454
454
  --profile <name>` and approve the code in that window.
455
455
 
@@ -46,11 +46,8 @@ foldrun flags --json
46
46
 
47
47
  ## Running the platform yourself
48
48
 
49
- On a hosted install the super admin changes flags at **/admin → Flags**:
50
- the install-wide on/off and rollout, and an override per account. The same
51
- is `PUT`/`DELETE /api/admin/flags/<flag>` and
52
- `/api/admin/flags/<flag>/accounts/<account>` (see the API reference's
53
- super admin section). Every change is on the platform's audit as
49
+ On the hosted platform the operator changes flags from its own console:
50
+ the install-wide on/off and rollout, and an override per account. Every change is on the platform's audit as
54
51
  `operator.flag.global`, `operator.flag.global_cleared`,
55
52
  `operator.flag.account` or `operator.flag.account_cleared`, with who made
56
53
  it and what it was before. The settings are rows in Postgres
package/docs/status.md CHANGED
@@ -46,8 +46,7 @@ not see a network problem between you and the platform — the page saying
46
46
 
47
47
  ## Incidents and maintenance
48
48
 
49
- The super admin posts them from **Admin → Incidents** (or
50
- `/api/admin/incidents`): a title, what customers should read, the impact
49
+ The platform's operator posts them from its console: a title, what customers should read, the impact
51
50
  (minor or major) and the components affected. Each update adds a line with
52
51
  a status — `investigating`, `identified`, `monitoring`, `resolved`.
53
52
  Maintenance is a window with a start and an end; it shows as upcoming before
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldrun",
3
- "version": "4.0.1",
3
+ "version": "5.0.1",
4
4
  "description": "Agents are just folders. Write them, check them, run them — on your machine.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "node": ">=22"
12
12
  },
13
13
  "dependencies": {
14
- "@foldrun/core": "^3.0.0"
14
+ "@foldrun/core": "^4.0.0"
15
15
  },
16
16
  "files": [
17
17
  "bin",