@farthershore/cli 0.12.0 → 0.13.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 +73 -42
- package/dist/index.js +97 -89
- package/dist/mcp.js +47 -42
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -240,7 +240,7 @@ farthershore plan create weather-api \
|
|
|
240
240
|
--key included \
|
|
241
241
|
--name "Included" \
|
|
242
242
|
--recurring-fee-cents 2000 \
|
|
243
|
-
--
|
|
243
|
+
--grant recurring:2000 \
|
|
244
244
|
--format json
|
|
245
245
|
|
|
246
246
|
# Free plan
|
|
@@ -269,27 +269,49 @@ Read recent usage off the management API.
|
|
|
269
269
|
farthershore usage summary weather-api --format json
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
### `farthershore
|
|
272
|
+
### `farthershore backend`
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
hashes; the raw token is returned once and should be deployed
|
|
276
|
-
`
|
|
274
|
+
Create BYO backends and provision runtime tokens for upstream services. Core
|
|
275
|
+
stores only token hashes; the raw token is returned once and should be deployed
|
|
276
|
+
as `FS_RUNTIME_TOKEN`.
|
|
277
277
|
|
|
278
278
|
```bash
|
|
279
|
-
farthershore
|
|
280
|
-
farthershore
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
farthershore backend list weather-api --format json
|
|
280
|
+
farthershore backend create weather-api \
|
|
281
|
+
--name "Production API" \
|
|
282
|
+
--origin-url https://api.example.com \
|
|
283
|
+
--format json
|
|
284
|
+
farthershore backend tokens list weather-api --format json
|
|
285
|
+
farthershore backend tokens create weather-api --backend <backendId> --format json
|
|
286
|
+
farthershore backend tokens rotate weather-api <tokenId> --format json
|
|
287
|
+
farthershore backend tokens revoke weather-api <tokenId> --yes --format json
|
|
288
|
+
farthershore backend delete weather-api <backendId> --yes --format json
|
|
283
289
|
```
|
|
284
290
|
|
|
285
291
|
Pair the token with `@farthershore/metering` in the upstream:
|
|
286
292
|
|
|
287
293
|
```ts
|
|
288
|
-
import { withUsage } from "@farthershore/metering";
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
294
|
+
import { fartherShore, withUsage } from "@farthershore/metering";
|
|
295
|
+
|
|
296
|
+
const fs = fartherShore.initFromEnv();
|
|
297
|
+
|
|
298
|
+
export async function POST(request: Request) {
|
|
299
|
+
const url = new URL(request.url);
|
|
300
|
+
const body = await request.clone().arrayBuffer();
|
|
301
|
+
|
|
302
|
+
await fs.verifyRequest({
|
|
303
|
+
method: request.method,
|
|
304
|
+
path: url.pathname,
|
|
305
|
+
query: url.search,
|
|
306
|
+
headers: request.headers,
|
|
307
|
+
body: new Uint8Array(body),
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const result = await runWorkflow(await request.json());
|
|
311
|
+
return withUsage(request, Response.json(result), {
|
|
312
|
+
tokens_used: result.tokensUsed,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
293
315
|
```
|
|
294
316
|
|
|
295
317
|
### `farthershore connect`
|
|
@@ -314,18 +336,17 @@ farthershore token revoke <tokenId> --yes --format json
|
|
|
314
336
|
|
|
315
337
|
#### Plan knobs
|
|
316
338
|
|
|
317
|
-
Every plan is a configuration of
|
|
318
|
-
|
|
319
|
-
|
|
339
|
+
Every plan is a configuration of orthogonal billing knobs. Older shapes with
|
|
340
|
+
`pricing.{model, monthlyPriceCents}`, top-level `billing.strategy`, or scalar
|
|
341
|
+
credit grant fields are no longer accepted by the validator.
|
|
320
342
|
|
|
321
|
-
| Knob
|
|
322
|
-
|
|
|
323
|
-
| `meters[]`
|
|
324
|
-
| `recurring_fee_cents`
|
|
325
|
-
| `
|
|
326
|
-
| `
|
|
327
|
-
| `
|
|
328
|
-
| `max_monthly_spend_cents` | cents (optional) | Hard cap; the gateway blocks once exceeded (orthogonal) |
|
|
343
|
+
| Knob | Cents/unit | Meaning |
|
|
344
|
+
| ------------------------- | ---------------- | ------------------------------------------------------- |
|
|
345
|
+
| `meters[]` | micros/unit | Per-dimension usage price (zero or more dimensions) |
|
|
346
|
+
| `recurring_fee_cents` | cents | Charged each billing period (recurring subscription) |
|
|
347
|
+
| `grants[]` | varies by kind | Credit grants, top-ups, rollover, and recharge policy |
|
|
348
|
+
| `trial_days` | days | Waive everything for N days at the start |
|
|
349
|
+
| `max_monthly_spend_cents` | cents (optional) | Hard cap; the gateway blocks once exceeded (orthogonal) |
|
|
329
350
|
|
|
330
351
|
Billing math (handled by Stripe Billing v2 at invoice finalization):
|
|
331
352
|
`bill = recurring_fee + max(0, total_meter_cost − applied_credit_balance)`.
|
|
@@ -355,7 +376,9 @@ plans:
|
|
|
355
376
|
- key: pro
|
|
356
377
|
name: Pro
|
|
357
378
|
recurring_fee_cents: 2000
|
|
358
|
-
|
|
379
|
+
grants:
|
|
380
|
+
- kind: recurring
|
|
381
|
+
amount_cents: 2000
|
|
359
382
|
meters:
|
|
360
383
|
- dimension: requests
|
|
361
384
|
price_per_unit_micros: 1000 # $0.001/request
|
|
@@ -371,7 +394,9 @@ plans:
|
|
|
371
394
|
# Prepaid: one-time grant + metered
|
|
372
395
|
- key: prepaid
|
|
373
396
|
name: Prepaid
|
|
374
|
-
|
|
397
|
+
grants:
|
|
398
|
+
- kind: one_time
|
|
399
|
+
amount_cents: 10000
|
|
375
400
|
meters:
|
|
376
401
|
- dimension: requests
|
|
377
402
|
price_per_unit_micros: 1000
|
|
@@ -390,13 +415,11 @@ plans:
|
|
|
390
415
|
price_per_unit_micros: 100
|
|
391
416
|
```
|
|
392
417
|
|
|
393
|
-
#### `grants[]` array
|
|
418
|
+
#### `grants[]` array
|
|
394
419
|
|
|
395
|
-
Plans
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
knobs are ignored. When absent, the validator silently synthesizes
|
|
399
|
-
entries from the legacy knobs so existing specs keep working.
|
|
420
|
+
Plans accept a typed `grants[]` array. It is the only public credit surface.
|
|
421
|
+
For CLI plan create/update, pass one or more canonical grants with
|
|
422
|
+
`--grant <kind:amount_cents>`.
|
|
400
423
|
|
|
401
424
|
Valid `kind` values:
|
|
402
425
|
|
|
@@ -410,7 +433,7 @@ Valid `kind` values:
|
|
|
410
433
|
| `top_up` | `sku`, `label`, `price_cents`, `credit_cents` | Buy-extra-credit SKU exposed in checkout |
|
|
411
434
|
| `auto_recharge` | `threshold_cents`, `refill_cents` | "When balance < $X auto-purchase $Y" |
|
|
412
435
|
|
|
413
|
-
`recurring`, `rollover`, and `trial` are single-shot per plan;
|
|
436
|
+
`recurring`, `one_time`, `rollover`, and `trial` are single-shot per plan;
|
|
414
437
|
declaring more than one entry of the same kind triggers a warning
|
|
415
438
|
(only the first is honored).
|
|
416
439
|
|
|
@@ -443,9 +466,8 @@ plans:
|
|
|
443
466
|
Validation surfaces:
|
|
444
467
|
|
|
445
468
|
- **error** — invalid `kind` is rewritten to `Unknown grant kind. Valid kinds: …`
|
|
446
|
-
- **warning** — `grants[]` declares `recurring`/`one_time` _and_ the matching legacy knob is also non-zero (legacy is silently ignored)
|
|
447
469
|
- **warning** — `{ kind: trial }` declared but `trial_days` is 0
|
|
448
|
-
- **warning** — singleton kinds (`recurring`, `rollover`, `trial`) declared more than once
|
|
470
|
+
- **warning** — singleton kinds (`recurring`, `one_time`, `rollover`, `trial`) declared more than once
|
|
449
471
|
|
|
450
472
|
#### Deprecation window (Phase 3b)
|
|
451
473
|
|
|
@@ -498,12 +520,21 @@ farthershore build --format json
|
|
|
498
520
|
|
|
499
521
|
## MCP server
|
|
500
522
|
|
|
501
|
-
The MCP server (`farthershore-mcp`)
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
523
|
+
The MCP server (`farthershore-mcp`) projects tool definitions from the same
|
|
524
|
+
operation registry that generates the CLI command groups. Tool names use the
|
|
525
|
+
`fs_*` prefix and cover the agent-writable product surface:
|
|
526
|
+
|
|
527
|
+
- Products: `fs_product_list`, `fs_brand_update`, `fs_product_publish`
|
|
528
|
+
- Environments: `fs_env_list`, `fs_env_create`
|
|
529
|
+
- Plans: `fs_plan_list`
|
|
530
|
+
- Backends: `fs_backend_list`, `fs_backend_create`, `fs_backend_delete`
|
|
531
|
+
- Runtime tokens: `fs_runtime_token_list`, `fs_runtime_token_mint`,
|
|
532
|
+
`fs_runtime_token_rotate`, `fs_runtime_token_revoke`
|
|
533
|
+
- Personas: `fs_persona_bootstrap`, `fs_persona_list`, `fs_persona_revoke`
|
|
534
|
+
- Usage and maker tokens: `fs_usage_read`, `fs_maker_token_list`
|
|
535
|
+
|
|
536
|
+
Every MCP tool has a sibling CLI operation by construction; the parity test in
|
|
537
|
+
`apps/cli/src/operations/mcp-cli-parity.test.ts` enforces that invariant.
|
|
507
538
|
|
|
508
539
|
## Errors and exit codes
|
|
509
540
|
|