@limitry/cli 1.0.0-rc.7 → 1.0.0-rc.8
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/CHANGELOG.md +72 -0
- package/README.md +4 -4
- package/dist/limitry.mjs +234 -328
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,78 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in the Limitry CLI (`@limitry/cli`). Generated from the source on each release; newest first.
|
|
4
4
|
|
|
5
|
+
## 1.0.0-rc.8 (2026-10-21)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Limits have `counting`: `fast` answers the instant it decides, and
|
|
10
|
+
`guaranteed` stores every count safely before answering, so the limit
|
|
11
|
+
never goes over, even if a server fails. A `total` balance defaults to
|
|
12
|
+
`guaranteed`, every other window to `fast`. Set it when creating or
|
|
13
|
+
updating a limit (`counting`, `--counting`), or in `limitry.json`.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- - Creating a limit needs only who it is for, the amount and the window:
|
|
18
|
+
`limits.create({ subject: { kind: "user" }, amount: 100, window: "month" })`
|
|
19
|
+
(`limitry limits create --subject '{"kind":"user"}' --amount 100 --window month`).
|
|
20
|
+
`action` defaults to every action (`*`), `unit` to `units`, and `name`
|
|
21
|
+
to the sentence the limit reads as, such as "100 units per user per
|
|
22
|
+
month". If a limit already has that name, the API answers `409`: give
|
|
23
|
+
this one a `name`. `limitry.json` entries still need a `name`.
|
|
24
|
+
- A limit's input names who it is for as `subject: { kind, id }` (was
|
|
25
|
+
`subjectKind` and `subjectId`), the same shape the limit itself has.
|
|
26
|
+
- What a limit counts is fixed once it is created: its subject, action,
|
|
27
|
+
unit, window, `every`, `start` and `rolling`. Changing one answers
|
|
28
|
+
`400 invalid_request`: create a new limit and archive the old one (its
|
|
29
|
+
history stays). Name, amount, fail mode and enabled still change any
|
|
30
|
+
time. `limitry sync` refuses such a change until you rename the entry.
|
|
31
|
+
- A limit says when a check last reached it (`lastCheckedAt`), so you can
|
|
32
|
+
see a limit no check names.
|
|
33
|
+
- One name for each idea, everywhere: the API, both SDKs, the CLI, the MCP
|
|
34
|
+
tools, `limitry.json` and webhooks. Update your code when you upgrade:
|
|
35
|
+
|
|
36
|
+
- `hold()` is `reserve()`: it takes `cost` (was `estimate`), and the block
|
|
37
|
+
gets a `Reservation` (was `Held`; Python `Reservation` and
|
|
38
|
+
`AsyncReservation`), with the same `cost()` and `extend()`.
|
|
39
|
+
- A refusal throws `LimitReached` (was `LimitExceeded`), with `limitId`
|
|
40
|
+
(Python `limit_id`) and `reason` `limit_reached` or
|
|
41
|
+
`too_many_reservations`. When Limitry can't be reached and a limit fails
|
|
42
|
+
closed, you now get a separate `Unavailable` error. "Can't be reached"
|
|
43
|
+
also covers a `402 plan_limit_reached` and a `429` from Limitry's flood
|
|
44
|
+
guard, so each limit's fail mode decides instead of your code getting an
|
|
45
|
+
error.
|
|
46
|
+
- A check's answer lists its limits in `limits` (was `remaining`): read
|
|
47
|
+
`decision.limits[0].remaining`. Every answer that names a limit says
|
|
48
|
+
`limitId`: `reason.limitId`, `limits[].limitId`, `usage.standing`'s
|
|
49
|
+
`limits[].limitId`, and webhook payloads.
|
|
50
|
+
- The refusal code is `limit_reached` (was `limit_exceeded`), and the
|
|
51
|
+
webhook event is `limit.reached` (was `limit.exceeded`): subscribe your
|
|
52
|
+
endpoints to the new name.
|
|
53
|
+
- Usage says `refused` (was `denied`); `usage.subjects` no longer has
|
|
54
|
+
`over` (it is `refused > 0`).
|
|
55
|
+
- Credits: `limits.credits.create()` and `limits.credits.list()` at
|
|
56
|
+
`/v1/limits/{limitId}/credits` (were `limits.grants.*` at `…/grants`),
|
|
57
|
+
ids start `crd_` (were `grt_`), and the approval an agent asks for is
|
|
58
|
+
`limit.credit` (was `limit.grant`).
|
|
59
|
+
- A period that starts on the subject's billing date is
|
|
60
|
+
`start: "billing_date"` (was `"anchor"`), and `subjects.update()` takes
|
|
61
|
+
`billingDate` (was `anchor`); the subject says `billingDate` too.
|
|
62
|
+
- `usage.standing()` and `usage.query()` take one `subject`, written
|
|
63
|
+
`kind:id` (`user:usr_123`), instead of separate kind and id fields
|
|
64
|
+
(`limitry usage standing --subject user:usr_123`).
|
|
65
|
+
- A limit's id starts `lmt_` (was `lim_`); keys still start `lim_test_`
|
|
66
|
+
and `lim_live_`.
|
|
67
|
+
- `limitry sync --preview` (was `--dry-run`), and the API's `preview`
|
|
68
|
+
(was `dryRun`), in what you send and what comes back.
|
|
69
|
+
|
|
70
|
+
### Removed
|
|
71
|
+
|
|
72
|
+
- Limits no longer have `counting` (Fast or Guaranteed), and the CLI no
|
|
73
|
+
longer has `--counting`: every count is now saved before Limitry answers,
|
|
74
|
+
for every limit. Remove `counting` from your code and from
|
|
75
|
+
`limitry.json`; Limitry ignores it.
|
|
76
|
+
|
|
5
77
|
## 1.0.0-rc.7 (2026-10-19)
|
|
6
78
|
|
|
7
79
|
### Added
|
package/README.md
CHANGED
|
@@ -28,15 +28,15 @@ Commands act in **test** unless you say otherwise, so trying things
|
|
|
28
28
|
never touches the limits your customers depend on.
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
# 100 AI replies a day for each user
|
|
32
|
-
limitry limits create --
|
|
33
|
-
--
|
|
31
|
+
# 100 AI replies a day for each user ("100 replies per user per day for ai-call")
|
|
32
|
+
limitry limits create --subject '{"kind":"user"}' --action ai-call \
|
|
33
|
+
--amount 100 --unit replies --window day
|
|
34
34
|
|
|
35
35
|
# Check a user, as your code would
|
|
36
36
|
limitry check user:usr_123 ai-call
|
|
37
37
|
|
|
38
38
|
# Where a user stands, without counting anything
|
|
39
|
-
limitry usage standing --
|
|
39
|
+
limitry usage standing --subject user:usr_123
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
When a limit is right, copy it to live from the **Limits** page in the
|
package/dist/limitry.mjs
CHANGED
|
@@ -5253,7 +5253,7 @@ var OPERATIONS = [
|
|
|
5253
5253
|
"idempotentHint": false
|
|
5254
5254
|
}
|
|
5255
5255
|
},
|
|
5256
|
-
"description": "Asks whether `subject` may do `action` at `cost`, given every enabled limit that applies, and \u2014 in `consume` mode \u2014 uses it. Always 200 for a decision: read `allowed`; `
|
|
5256
|
+
"description": "Asks whether `subject` may do `action` at `cost`, given every enabled limit that applies, and \u2014 in `consume` mode \u2014 uses it. Always 200 for a decision, allowed or refused: read `allowed`; `limits` shows what is left on each limit and `retryAfterSeconds` when to try again. An `Idempotency-Key` header makes a retried check return the same decision without using twice. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.",
|
|
5257
5257
|
"fields": [
|
|
5258
5258
|
{
|
|
5259
5259
|
"name": "subject",
|
|
@@ -5358,7 +5358,7 @@ var OPERATIONS = [
|
|
|
5358
5358
|
"in": "body",
|
|
5359
5359
|
"type": "string",
|
|
5360
5360
|
"required": false,
|
|
5361
|
-
"description": "`consume` (default) decides and uses; `preview` decides without using; `reserve` decides and
|
|
5361
|
+
"description": "`consume` (default) decides and uses; `preview` decides without using; `reserve` decides and reserves `cost` (what it will probably use) until you commit the actual amount or release it \u2014 see `reservation` in the answer. Only a reservation takes a slot of a `concurrent` limit.",
|
|
5362
5362
|
"example": "consume",
|
|
5363
5363
|
"schema": {
|
|
5364
5364
|
"type": "string",
|
|
@@ -5367,7 +5367,7 @@ var OPERATIONS = [
|
|
|
5367
5367
|
"preview",
|
|
5368
5368
|
"reserve"
|
|
5369
5369
|
],
|
|
5370
|
-
"description": "`consume` (default) decides and uses; `preview` decides without using; `reserve` decides and
|
|
5370
|
+
"description": "`consume` (default) decides and uses; `preview` decides without using; `reserve` decides and reserves `cost` (what it will probably use) until you commit the actual amount or release it \u2014 see `reservation` in the answer. Only a reservation takes a slot of a `concurrent` limit."
|
|
5371
5371
|
}
|
|
5372
5372
|
},
|
|
5373
5373
|
{
|
|
@@ -5375,13 +5375,13 @@ var OPERATIONS = [
|
|
|
5375
5375
|
"in": "body",
|
|
5376
5376
|
"type": "number",
|
|
5377
5377
|
"required": false,
|
|
5378
|
-
"description": "With `reserve`: how long the
|
|
5378
|
+
"description": "With `reserve`: how long the reservation lasts before it releases itself. Default 300, at most 3600.",
|
|
5379
5379
|
"example": 300,
|
|
5380
5380
|
"schema": {
|
|
5381
5381
|
"type": "integer",
|
|
5382
5382
|
"minimum": 1,
|
|
5383
5383
|
"maximum": 3600,
|
|
5384
|
-
"description": "With `reserve`: how long the
|
|
5384
|
+
"description": "With `reserve`: how long the reservation lasts before it releases itself. Default 300, at most 3600."
|
|
5385
5385
|
}
|
|
5386
5386
|
}
|
|
5387
5387
|
],
|
|
@@ -5410,14 +5410,14 @@ var OPERATIONS = [
|
|
|
5410
5410
|
"idempotentHint": false
|
|
5411
5411
|
}
|
|
5412
5412
|
},
|
|
5413
|
-
"description": "Stops a limit: checks stop enforcing it
|
|
5413
|
+
"description": "Stops a limit: checks stop enforcing it at once, and it leaves the list. It is archived, not erased \u2014 its usage history and credits stay, and `POST /v1/limits/{limitId}/restore` brings it back. Owners and admins only, for a person's token.",
|
|
5414
5414
|
"fields": [
|
|
5415
5415
|
{
|
|
5416
5416
|
"name": "limitId",
|
|
5417
5417
|
"in": "path",
|
|
5418
5418
|
"type": "string",
|
|
5419
5419
|
"required": true,
|
|
5420
|
-
"example": "
|
|
5420
|
+
"example": "lmt_3f0c\u2026",
|
|
5421
5421
|
"schema": {
|
|
5422
5422
|
"type": "string"
|
|
5423
5423
|
}
|
|
@@ -5446,64 +5446,68 @@ var OPERATIONS = [
|
|
|
5446
5446
|
"idempotentHint": false
|
|
5447
5447
|
}
|
|
5448
5448
|
},
|
|
5449
|
-
"description": "Limits how much
|
|
5449
|
+
"description": "Limits how much a subject may use per window \u2014 for example 200 cents a month for every `user`. Only `subject.kind`, `amount` and `window` are needed: `action` defaults to every action (`*`), `unit` to units, and `name` to the sentence the limit reads as. Checks enforce it from then on. What it counts (subject, action, unit, window, every, start, rolling) is fixed once created. Owners and admins only, for a person's token.",
|
|
5450
5450
|
"fields": [
|
|
5451
5451
|
{
|
|
5452
5452
|
"name": "name",
|
|
5453
5453
|
"in": "body",
|
|
5454
5454
|
"type": "string",
|
|
5455
|
-
"required":
|
|
5456
|
-
"description":
|
|
5455
|
+
"required": false,
|
|
5456
|
+
"description": `A name, unique among the environment's active limits. Default: the sentence the limit reads as, such as "200 cents per user per month". If a limit already has that name, the answer is 409: give this one a name.`,
|
|
5457
5457
|
"example": "AI budget",
|
|
5458
5458
|
"schema": {
|
|
5459
5459
|
"type": "string",
|
|
5460
5460
|
"minLength": 1,
|
|
5461
5461
|
"maxLength": 100,
|
|
5462
|
-
"description":
|
|
5462
|
+
"description": `A name, unique among the environment's active limits. Default: the sentence the limit reads as, such as "200 cents per user per month". If a limit already has that name, the answer is 409: give this one a name.`
|
|
5463
5463
|
}
|
|
5464
5464
|
},
|
|
5465
5465
|
{
|
|
5466
|
-
"name": "
|
|
5466
|
+
"name": "subject",
|
|
5467
5467
|
"in": "body",
|
|
5468
|
-
"type": "
|
|
5468
|
+
"type": "json",
|
|
5469
5469
|
"required": true,
|
|
5470
|
-
"description": "
|
|
5471
|
-
"example":
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
"minLength": 1,
|
|
5475
|
-
"maxLength": 100,
|
|
5476
|
-
"description": "Your own label for who is checked."
|
|
5477
|
-
}
|
|
5478
|
-
},
|
|
5479
|
-
{
|
|
5480
|
-
"name": "subjectId",
|
|
5481
|
-
"in": "body",
|
|
5482
|
-
"type": "string",
|
|
5483
|
-
"required": false,
|
|
5484
|
-
"description": "One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window.",
|
|
5470
|
+
"description": 'Who it applies to: `{"kind": "user"}` for every user, `{"kind": "user", "id": "usr_123"}` for one.',
|
|
5471
|
+
"example": {
|
|
5472
|
+
"kind": "user"
|
|
5473
|
+
},
|
|
5485
5474
|
"schema": {
|
|
5486
|
-
"type":
|
|
5487
|
-
|
|
5488
|
-
"
|
|
5475
|
+
"type": "object",
|
|
5476
|
+
"properties": {
|
|
5477
|
+
"kind": {
|
|
5478
|
+
"type": "string",
|
|
5479
|
+
"minLength": 1,
|
|
5480
|
+
"maxLength": 100,
|
|
5481
|
+
"description": "Your own label for who is checked: user, team, apikey \u2026"
|
|
5482
|
+
},
|
|
5483
|
+
"id": {
|
|
5484
|
+
"type": [
|
|
5485
|
+
"string",
|
|
5486
|
+
"null"
|
|
5487
|
+
],
|
|
5488
|
+
"minLength": 1,
|
|
5489
|
+
"maxLength": 100,
|
|
5490
|
+
"description": "One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window."
|
|
5491
|
+
}
|
|
5492
|
+
},
|
|
5493
|
+
"required": [
|
|
5494
|
+
"kind"
|
|
5489
5495
|
],
|
|
5490
|
-
"
|
|
5491
|
-
"maxLength": 100,
|
|
5492
|
-
"description": "One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window."
|
|
5496
|
+
"description": 'Who it applies to: `{"kind": "user"}` for every user, `{"kind": "user", "id": "usr_123"}` for one.'
|
|
5493
5497
|
}
|
|
5494
5498
|
},
|
|
5495
5499
|
{
|
|
5496
5500
|
"name": "action",
|
|
5497
5501
|
"in": "body",
|
|
5498
5502
|
"type": "string",
|
|
5499
|
-
"required":
|
|
5500
|
-
"description": "The action to limit
|
|
5503
|
+
"required": false,
|
|
5504
|
+
"description": "The action to limit. Default: `*`, every action.",
|
|
5501
5505
|
"example": "ai-call",
|
|
5502
5506
|
"schema": {
|
|
5503
5507
|
"type": "string",
|
|
5504
5508
|
"minLength": 1,
|
|
5505
5509
|
"maxLength": 100,
|
|
5506
|
-
"description": "The action to limit
|
|
5510
|
+
"description": "The action to limit. Default: `*`, every action."
|
|
5507
5511
|
}
|
|
5508
5512
|
},
|
|
5509
5513
|
{
|
|
@@ -5525,13 +5529,13 @@ var OPERATIONS = [
|
|
|
5525
5529
|
"in": "body",
|
|
5526
5530
|
"type": "string",
|
|
5527
5531
|
"required": false,
|
|
5528
|
-
"description": "What the amount counts
|
|
5532
|
+
"description": "What the amount counts, in words. Default: units.",
|
|
5529
5533
|
"example": "cents",
|
|
5530
5534
|
"schema": {
|
|
5531
5535
|
"type": "string",
|
|
5532
5536
|
"minLength": 1,
|
|
5533
5537
|
"maxLength": 40,
|
|
5534
|
-
"description": "What the amount counts
|
|
5538
|
+
"description": "What the amount counts, in words. Default: units."
|
|
5535
5539
|
}
|
|
5536
5540
|
},
|
|
5537
5541
|
{
|
|
@@ -5539,7 +5543,7 @@ var OPERATIONS = [
|
|
|
5539
5543
|
"in": "body",
|
|
5540
5544
|
"type": "string",
|
|
5541
5545
|
"required": true,
|
|
5542
|
-
"description": "`minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them,
|
|
5546
|
+
"description": "`minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, reset where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, raised by credits. `concurrent`: at most `amount` open reservations at once.",
|
|
5543
5547
|
"example": "month",
|
|
5544
5548
|
"schema": {
|
|
5545
5549
|
"type": "string",
|
|
@@ -5553,7 +5557,7 @@ var OPERATIONS = [
|
|
|
5553
5557
|
"total",
|
|
5554
5558
|
"concurrent"
|
|
5555
5559
|
],
|
|
5556
|
-
"description": "`minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them,
|
|
5560
|
+
"description": "`minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, reset where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, raised by credits. `concurrent`: at most `amount` open reservations at once."
|
|
5557
5561
|
}
|
|
5558
5562
|
},
|
|
5559
5563
|
{
|
|
@@ -5575,16 +5579,16 @@ var OPERATIONS = [
|
|
|
5575
5579
|
"in": "body",
|
|
5576
5580
|
"type": "string",
|
|
5577
5581
|
"required": false,
|
|
5578
|
-
"description": "Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `
|
|
5582
|
+
"description": "Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `billing_date`: from the subject's billing date, set with `subjects.update` (its first check until then), so an annual plan can reset monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar.",
|
|
5579
5583
|
"example": "calendar",
|
|
5580
5584
|
"schema": {
|
|
5581
5585
|
"type": "string",
|
|
5582
5586
|
"enum": [
|
|
5583
5587
|
"calendar",
|
|
5584
|
-
"
|
|
5588
|
+
"billing_date",
|
|
5585
5589
|
"first_use"
|
|
5586
5590
|
],
|
|
5587
|
-
"description": "Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `
|
|
5591
|
+
"description": "Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `billing_date`: from the subject's billing date, set with `subjects.update` (its first check until then), so an annual plan can reset monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar."
|
|
5588
5592
|
}
|
|
5589
5593
|
},
|
|
5590
5594
|
{
|
|
@@ -5630,50 +5634,12 @@ var OPERATIONS = [
|
|
|
5630
5634
|
"scope": "limits:write"
|
|
5631
5635
|
},
|
|
5632
5636
|
{
|
|
5633
|
-
"operationId": "limits.
|
|
5634
|
-
"method": "get",
|
|
5635
|
-
"path": "/limits/{limitId}",
|
|
5636
|
-
"summary": "Get a limit",
|
|
5637
|
-
"cli": {
|
|
5638
|
-
"command": "limits get",
|
|
5639
|
-
"args": [
|
|
5640
|
-
"limitId"
|
|
5641
|
-
],
|
|
5642
|
-
"confirm": false
|
|
5643
|
-
},
|
|
5644
|
-
"mcp": {
|
|
5645
|
-
"exposed": true,
|
|
5646
|
-
"name": "limits_get",
|
|
5647
|
-
"hints": {
|
|
5648
|
-
"readOnlyHint": true,
|
|
5649
|
-
"destructiveHint": false,
|
|
5650
|
-
"idempotentHint": true
|
|
5651
|
-
}
|
|
5652
|
-
},
|
|
5653
|
-
"description": "One limit: who it applies to, the action, amount and window.",
|
|
5654
|
-
"fields": [
|
|
5655
|
-
{
|
|
5656
|
-
"name": "limitId",
|
|
5657
|
-
"in": "path",
|
|
5658
|
-
"type": "string",
|
|
5659
|
-
"required": true,
|
|
5660
|
-
"example": "lim_3f0c\u2026",
|
|
5661
|
-
"schema": {
|
|
5662
|
-
"type": "string"
|
|
5663
|
-
}
|
|
5664
|
-
}
|
|
5665
|
-
],
|
|
5666
|
-
"hasBody": false,
|
|
5667
|
-
"workspace": true,
|
|
5668
|
-
"scope": "limits:read"
|
|
5669
|
-
},
|
|
5670
|
-
{
|
|
5671
|
-
"operationId": "limits.grants.create",
|
|
5637
|
+
"operationId": "limits.credits.create",
|
|
5672
5638
|
"method": "post",
|
|
5673
|
-
"path": "/limits/{limitId}/
|
|
5639
|
+
"path": "/limits/{limitId}/credits",
|
|
5674
5640
|
"summary": "Add credits to a balance",
|
|
5675
5641
|
"cli": {
|
|
5676
|
-
"command": "limits
|
|
5642
|
+
"command": "limits credits create",
|
|
5677
5643
|
"args": [
|
|
5678
5644
|
"limitId"
|
|
5679
5645
|
],
|
|
@@ -5681,16 +5647,16 @@ var OPERATIONS = [
|
|
|
5681
5647
|
},
|
|
5682
5648
|
"mcp": {
|
|
5683
5649
|
"exposed": false,
|
|
5684
|
-
"reason": "Adding credits gives value away; an agent asks a person (limit.
|
|
5650
|
+
"reason": "Adding credits gives value away; an agent asks a person (limit.credit approval)"
|
|
5685
5651
|
},
|
|
5686
|
-
"description": "Adds `amount` to one subject's balance \u2014 a limit whose window is `total`. A negative `amount` takes credits back (a refund, a chargeback) and needs a `note` saying why; the balance may go below zero, and checks are refused until
|
|
5652
|
+
"description": "Adds `amount` credits to one subject's balance \u2014 a limit whose window is `total`. A negative `amount` takes credits back (a refund, a chargeback) and needs a `note` saying why; the balance may go below zero, and checks are refused until more credits are added. Owners and admins, or a workspace API key; an agent asks a person (the `limit.credit` approval).",
|
|
5687
5653
|
"fields": [
|
|
5688
5654
|
{
|
|
5689
5655
|
"name": "limitId",
|
|
5690
5656
|
"in": "path",
|
|
5691
5657
|
"type": "string",
|
|
5692
5658
|
"required": true,
|
|
5693
|
-
"example": "
|
|
5659
|
+
"example": "lmt_3f0c\u2026",
|
|
5694
5660
|
"schema": {
|
|
5695
5661
|
"type": "string"
|
|
5696
5662
|
}
|
|
@@ -5744,7 +5710,7 @@ var OPERATIONS = [
|
|
|
5744
5710
|
"type": "string",
|
|
5745
5711
|
"required": false,
|
|
5746
5712
|
"description": "Required when `amount` is negative.",
|
|
5747
|
-
"example": "October
|
|
5713
|
+
"example": "October credits",
|
|
5748
5714
|
"schema": {
|
|
5749
5715
|
"type": "string",
|
|
5750
5716
|
"maxLength": 200,
|
|
@@ -5757,12 +5723,12 @@ var OPERATIONS = [
|
|
|
5757
5723
|
"scope": "limits:write"
|
|
5758
5724
|
},
|
|
5759
5725
|
{
|
|
5760
|
-
"operationId": "limits.
|
|
5726
|
+
"operationId": "limits.credits.list",
|
|
5761
5727
|
"method": "get",
|
|
5762
|
-
"path": "/limits/{limitId}/
|
|
5763
|
-
"summary": "List a balance's
|
|
5728
|
+
"path": "/limits/{limitId}/credits",
|
|
5729
|
+
"summary": "List a balance's credits",
|
|
5764
5730
|
"cli": {
|
|
5765
|
-
"command": "limits
|
|
5731
|
+
"command": "limits credits list",
|
|
5766
5732
|
"args": [
|
|
5767
5733
|
"limitId"
|
|
5768
5734
|
],
|
|
@@ -5770,21 +5736,59 @@ var OPERATIONS = [
|
|
|
5770
5736
|
},
|
|
5771
5737
|
"mcp": {
|
|
5772
5738
|
"exposed": true,
|
|
5773
|
-
"name": "
|
|
5739
|
+
"name": "limits_credits_list",
|
|
5774
5740
|
"hints": {
|
|
5775
5741
|
"readOnlyHint": true,
|
|
5776
5742
|
"destructiveHint": false,
|
|
5777
5743
|
"idempotentHint": true
|
|
5778
5744
|
}
|
|
5779
5745
|
},
|
|
5780
|
-
"description": "Credits added to subjects' balances for this limit, newest first.",
|
|
5746
|
+
"description": "Credits added to (or taken back from) subjects' balances for this limit, newest first.",
|
|
5781
5747
|
"fields": [
|
|
5782
5748
|
{
|
|
5783
5749
|
"name": "limitId",
|
|
5784
5750
|
"in": "path",
|
|
5785
5751
|
"type": "string",
|
|
5786
5752
|
"required": true,
|
|
5787
|
-
"example": "
|
|
5753
|
+
"example": "lmt_3f0c\u2026",
|
|
5754
|
+
"schema": {
|
|
5755
|
+
"type": "string"
|
|
5756
|
+
}
|
|
5757
|
+
}
|
|
5758
|
+
],
|
|
5759
|
+
"hasBody": false,
|
|
5760
|
+
"workspace": true,
|
|
5761
|
+
"scope": "limits:read"
|
|
5762
|
+
},
|
|
5763
|
+
{
|
|
5764
|
+
"operationId": "limits.get",
|
|
5765
|
+
"method": "get",
|
|
5766
|
+
"path": "/limits/{limitId}",
|
|
5767
|
+
"summary": "Get a limit",
|
|
5768
|
+
"cli": {
|
|
5769
|
+
"command": "limits get",
|
|
5770
|
+
"args": [
|
|
5771
|
+
"limitId"
|
|
5772
|
+
],
|
|
5773
|
+
"confirm": false
|
|
5774
|
+
},
|
|
5775
|
+
"mcp": {
|
|
5776
|
+
"exposed": true,
|
|
5777
|
+
"name": "limits_get",
|
|
5778
|
+
"hints": {
|
|
5779
|
+
"readOnlyHint": true,
|
|
5780
|
+
"destructiveHint": false,
|
|
5781
|
+
"idempotentHint": true
|
|
5782
|
+
}
|
|
5783
|
+
},
|
|
5784
|
+
"description": "One limit: who it applies to, the action, amount and window.",
|
|
5785
|
+
"fields": [
|
|
5786
|
+
{
|
|
5787
|
+
"name": "limitId",
|
|
5788
|
+
"in": "path",
|
|
5789
|
+
"type": "string",
|
|
5790
|
+
"required": true,
|
|
5791
|
+
"example": "lmt_3f0c\u2026",
|
|
5788
5792
|
"schema": {
|
|
5789
5793
|
"type": "string"
|
|
5790
5794
|
}
|
|
@@ -5915,7 +5919,7 @@ var OPERATIONS = [
|
|
|
5915
5919
|
"in": "path",
|
|
5916
5920
|
"type": "string",
|
|
5917
5921
|
"required": true,
|
|
5918
|
-
"example": "
|
|
5922
|
+
"example": "lmt_3f0c\u2026",
|
|
5919
5923
|
"schema": {
|
|
5920
5924
|
"type": "string"
|
|
5921
5925
|
}
|
|
@@ -5945,18 +5949,20 @@ var OPERATIONS = [
|
|
|
5945
5949
|
"idempotentHint": false
|
|
5946
5950
|
}
|
|
5947
5951
|
},
|
|
5948
|
-
"description": "Makes the environment's limits match `limits`, by name: creates the missing, changes those that differ (an omitted field means its default) and, with `archiveMissing`, archives active limits the list doesn't name. Running it twice changes nothing the second time. Limitry checks the whole list first, and a problem anywhere changes nothing (400, each problem in `details`); then it writes every change at once. `
|
|
5952
|
+
"description": "Makes the environment's limits match `limits`, by name: creates the missing, changes those that differ (an omitted field means its default) and, with `archiveMissing`, archives active limits the list doesn't name. Running it twice changes nothing the second time. Limitry checks the whole list first, and a problem anywhere changes nothing (400, each problem in `details`); then it writes every change at once. What a limit counts is fixed: a different subject, action, unit or window under an existing name is refused until the entry is renamed. `preview` answers what it would do without writing. For keeping limits in a file in your repository (`limitry sync`). Owners and admins only, for a person's token.",
|
|
5949
5953
|
"fields": [
|
|
5950
5954
|
{
|
|
5951
5955
|
"name": "limits",
|
|
5952
5956
|
"in": "body",
|
|
5953
5957
|
"type": "json",
|
|
5954
5958
|
"required": true,
|
|
5955
|
-
"description": "Every limit you want, each described whole: an omitted field is its default, as on create. Names are the key and must be unique in the list. At most 200.",
|
|
5959
|
+
"description": "Every limit you want, each described whole: an omitted field is its default, as on create. Names are the key and must be unique in the list. What a limit counts (subject, action, unit, window, every, start, rolling) is fixed: to change it, rename the entry, which creates a new limit. At most 200.",
|
|
5956
5960
|
"example": [
|
|
5957
5961
|
{
|
|
5958
5962
|
"name": "AI budget",
|
|
5959
|
-
"
|
|
5963
|
+
"subject": {
|
|
5964
|
+
"kind": "user"
|
|
5965
|
+
},
|
|
5960
5966
|
"action": "ai-call",
|
|
5961
5967
|
"amount": 200,
|
|
5962
5968
|
"unit": "cents",
|
|
@@ -5966,103 +5972,29 @@ var OPERATIONS = [
|
|
|
5966
5972
|
"schema": {
|
|
5967
5973
|
"type": "array",
|
|
5968
5974
|
"items": {
|
|
5969
|
-
"
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
"type": "string",
|
|
5973
|
-
"minLength": 1,
|
|
5974
|
-
"maxLength": 100,
|
|
5975
|
-
"description": "A name for the limit, unique among its environment's active limits."
|
|
5975
|
+
"allOf": [
|
|
5976
|
+
{
|
|
5977
|
+
"$ref": "#/components/schemas/LimitInput"
|
|
5976
5978
|
},
|
|
5977
|
-
|
|
5978
|
-
"type": "
|
|
5979
|
-
"
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
"
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
},
|
|
5992
|
-
"action": {
|
|
5993
|
-
"type": "string",
|
|
5994
|
-
"minLength": 1,
|
|
5995
|
-
"maxLength": 100,
|
|
5996
|
-
"description": "The action to limit; `*` for every action."
|
|
5997
|
-
},
|
|
5998
|
-
"amount": {
|
|
5999
|
-
"type": "integer",
|
|
6000
|
-
"minimum": 1,
|
|
6001
|
-
"maximum": 1e9,
|
|
6002
|
-
"description": "How many units each subject may use per window."
|
|
6003
|
-
},
|
|
6004
|
-
"unit": {
|
|
6005
|
-
"type": "string",
|
|
6006
|
-
"minLength": 1,
|
|
6007
|
-
"maxLength": 40,
|
|
6008
|
-
"description": "What the amount counts (display only). Default: units."
|
|
6009
|
-
},
|
|
6010
|
-
"window": {
|
|
6011
|
-
"type": "string",
|
|
6012
|
-
"enum": [
|
|
6013
|
-
"minute",
|
|
6014
|
-
"hour",
|
|
6015
|
-
"day",
|
|
6016
|
-
"week",
|
|
6017
|
-
"month",
|
|
6018
|
-
"year",
|
|
6019
|
-
"total",
|
|
6020
|
-
"concurrent"
|
|
6021
|
-
],
|
|
6022
|
-
"description": "`minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, refilled where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, topped up by grants. `concurrent`: at most `amount` held reservations at once."
|
|
6023
|
-
},
|
|
6024
|
-
"every": {
|
|
6025
|
-
"type": "integer",
|
|
6026
|
-
"minimum": 1,
|
|
6027
|
-
"maximum": 1e3,
|
|
6028
|
-
"description": 'How many `window` units a period lasts: `window: "month", every: 3` is a quarter, `window: "hour", every: 5` five hours. Default: 1.'
|
|
6029
|
-
},
|
|
6030
|
-
"start": {
|
|
6031
|
-
"type": "string",
|
|
6032
|
-
"enum": [
|
|
6033
|
-
"calendar",
|
|
6034
|
-
"anchor",
|
|
6035
|
-
"first_use"
|
|
6036
|
-
],
|
|
6037
|
-
"description": "Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `anchor`: from the subject's anchor, its billing date, set with `subjects.update` (its first check until then), so an annual plan can refill monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar."
|
|
6038
|
-
},
|
|
6039
|
-
"rolling": {
|
|
6040
|
-
"type": "boolean",
|
|
6041
|
-
"description": "Count the last window instead of the calendar one (minute, hour or day only). Default: false."
|
|
6042
|
-
},
|
|
6043
|
-
"enabled": {
|
|
6044
|
-
"type": "boolean",
|
|
6045
|
-
"description": "Whether checks enforce it. Default: true."
|
|
6046
|
-
},
|
|
6047
|
-
"failMode": {
|
|
6048
|
-
"type": "string",
|
|
6049
|
-
"enum": [
|
|
6050
|
-
"open",
|
|
6051
|
-
"closed"
|
|
6052
|
-
],
|
|
6053
|
-
"description": "What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny). Default: open."
|
|
5979
|
+
{
|
|
5980
|
+
"type": "object",
|
|
5981
|
+
"properties": {
|
|
5982
|
+
"name": {
|
|
5983
|
+
"type": "string",
|
|
5984
|
+
"minLength": 1,
|
|
5985
|
+
"maxLength": 100,
|
|
5986
|
+
"example": "AI budget",
|
|
5987
|
+
"description": "The limit's name: the key a sync matches on, unique in the list."
|
|
5988
|
+
}
|
|
5989
|
+
},
|
|
5990
|
+
"required": [
|
|
5991
|
+
"name"
|
|
5992
|
+
]
|
|
6054
5993
|
}
|
|
6055
|
-
},
|
|
6056
|
-
"required": [
|
|
6057
|
-
"name",
|
|
6058
|
-
"subjectKind",
|
|
6059
|
-
"action",
|
|
6060
|
-
"amount",
|
|
6061
|
-
"window"
|
|
6062
5994
|
]
|
|
6063
5995
|
},
|
|
6064
5996
|
"maxItems": 200,
|
|
6065
|
-
"description": "Every limit you want, each described whole: an omitted field is its default, as on create. Names are the key and must be unique in the list. At most 200."
|
|
5997
|
+
"description": "Every limit you want, each described whole: an omitted field is its default, as on create. Names are the key and must be unique in the list. What a limit counts (subject, action, unit, window, every, start, rolling) is fixed: to change it, rename the entry, which creates a new limit. At most 200."
|
|
6066
5998
|
}
|
|
6067
5999
|
},
|
|
6068
6000
|
{
|
|
@@ -6077,7 +6009,7 @@ var OPERATIONS = [
|
|
|
6077
6009
|
}
|
|
6078
6010
|
},
|
|
6079
6011
|
{
|
|
6080
|
-
"name": "
|
|
6012
|
+
"name": "preview",
|
|
6081
6013
|
"in": "body",
|
|
6082
6014
|
"type": "boolean",
|
|
6083
6015
|
"required": false,
|
|
@@ -6113,14 +6045,14 @@ var OPERATIONS = [
|
|
|
6113
6045
|
"idempotentHint": false
|
|
6114
6046
|
}
|
|
6115
6047
|
},
|
|
6116
|
-
"description": "Changes
|
|
6048
|
+
"description": "Changes a limit's name, amount, fail mode or whether it is enabled; checks use the new rule at once. What a limit counts (subject, action, unit, window, every, start, rolling) is fixed: a different value is refused (400) \u2014 create a new limit and archive this one. Owners and admins only, for a person's token.",
|
|
6117
6049
|
"fields": [
|
|
6118
6050
|
{
|
|
6119
6051
|
"name": "limitId",
|
|
6120
6052
|
"in": "path",
|
|
6121
6053
|
"type": "string",
|
|
6122
6054
|
"required": true,
|
|
6123
|
-
"example": "
|
|
6055
|
+
"example": "lmt_3f0c\u2026",
|
|
6124
6056
|
"schema": {
|
|
6125
6057
|
"type": "string"
|
|
6126
6058
|
}
|
|
@@ -6130,71 +6062,97 @@ var OPERATIONS = [
|
|
|
6130
6062
|
"in": "body",
|
|
6131
6063
|
"type": "string",
|
|
6132
6064
|
"required": false,
|
|
6133
|
-
"description": "A name
|
|
6065
|
+
"description": "A new name, unique among the environment's active limits.",
|
|
6134
6066
|
"example": "AI budget",
|
|
6135
6067
|
"schema": {
|
|
6136
6068
|
"type": "string",
|
|
6137
6069
|
"minLength": 1,
|
|
6138
6070
|
"maxLength": 100,
|
|
6139
|
-
"description": "A name
|
|
6071
|
+
"description": "A new name, unique among the environment's active limits."
|
|
6140
6072
|
}
|
|
6141
6073
|
},
|
|
6142
6074
|
{
|
|
6143
|
-
"name": "
|
|
6075
|
+
"name": "amount",
|
|
6144
6076
|
"in": "body",
|
|
6145
|
-
"type": "
|
|
6077
|
+
"type": "number",
|
|
6146
6078
|
"required": false,
|
|
6147
|
-
"description": "
|
|
6148
|
-
"example":
|
|
6079
|
+
"description": "How many units each subject may use per window.",
|
|
6080
|
+
"example": 300,
|
|
6149
6081
|
"schema": {
|
|
6150
|
-
"type": "
|
|
6151
|
-
"
|
|
6152
|
-
"
|
|
6153
|
-
"description": "
|
|
6082
|
+
"type": "integer",
|
|
6083
|
+
"minimum": 1,
|
|
6084
|
+
"maximum": 1e9,
|
|
6085
|
+
"description": "How many units each subject may use per window."
|
|
6154
6086
|
}
|
|
6155
6087
|
},
|
|
6156
6088
|
{
|
|
6157
|
-
"name": "
|
|
6089
|
+
"name": "enabled",
|
|
6158
6090
|
"in": "body",
|
|
6159
|
-
"type": "
|
|
6091
|
+
"type": "boolean",
|
|
6160
6092
|
"required": false,
|
|
6161
|
-
"description": "
|
|
6093
|
+
"description": "Whether checks enforce it.",
|
|
6162
6094
|
"schema": {
|
|
6163
|
-
"type":
|
|
6164
|
-
|
|
6165
|
-
"null"
|
|
6166
|
-
],
|
|
6167
|
-
"minLength": 1,
|
|
6168
|
-
"maxLength": 100,
|
|
6169
|
-
"description": "One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window."
|
|
6095
|
+
"type": "boolean",
|
|
6096
|
+
"description": "Whether checks enforce it."
|
|
6170
6097
|
}
|
|
6171
6098
|
},
|
|
6172
6099
|
{
|
|
6173
|
-
"name": "
|
|
6100
|
+
"name": "failMode",
|
|
6174
6101
|
"in": "body",
|
|
6175
6102
|
"type": "string",
|
|
6176
6103
|
"required": false,
|
|
6177
|
-
"description": "
|
|
6178
|
-
"example": "ai-call",
|
|
6104
|
+
"description": "What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny).",
|
|
6179
6105
|
"schema": {
|
|
6180
6106
|
"type": "string",
|
|
6181
|
-
"
|
|
6182
|
-
|
|
6183
|
-
|
|
6107
|
+
"enum": [
|
|
6108
|
+
"open",
|
|
6109
|
+
"closed"
|
|
6110
|
+
],
|
|
6111
|
+
"description": "What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny)."
|
|
6184
6112
|
}
|
|
6185
6113
|
},
|
|
6186
6114
|
{
|
|
6187
|
-
"name": "
|
|
6115
|
+
"name": "subject",
|
|
6188
6116
|
"in": "body",
|
|
6189
|
-
"type": "
|
|
6117
|
+
"type": "json",
|
|
6190
6118
|
"required": false,
|
|
6191
|
-
"description": "
|
|
6192
|
-
"example":
|
|
6119
|
+
"description": "Who it applies to. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6120
|
+
"example": {
|
|
6121
|
+
"kind": "user"
|
|
6122
|
+
},
|
|
6193
6123
|
"schema": {
|
|
6194
|
-
"type": "
|
|
6195
|
-
"
|
|
6196
|
-
|
|
6197
|
-
|
|
6124
|
+
"type": "object",
|
|
6125
|
+
"properties": {
|
|
6126
|
+
"kind": {
|
|
6127
|
+
"type": "string",
|
|
6128
|
+
"minLength": 1,
|
|
6129
|
+
"maxLength": 100,
|
|
6130
|
+
"description": "Your own label for who is checked: user, team, apikey \u2026"
|
|
6131
|
+
},
|
|
6132
|
+
"id": {
|
|
6133
|
+
"type": [
|
|
6134
|
+
"string",
|
|
6135
|
+
"null"
|
|
6136
|
+
],
|
|
6137
|
+
"minLength": 1,
|
|
6138
|
+
"maxLength": 100,
|
|
6139
|
+
"description": "One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window."
|
|
6140
|
+
}
|
|
6141
|
+
},
|
|
6142
|
+
"description": "Who it applies to. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6143
|
+
}
|
|
6144
|
+
},
|
|
6145
|
+
{
|
|
6146
|
+
"name": "action",
|
|
6147
|
+
"in": "body",
|
|
6148
|
+
"type": "string",
|
|
6149
|
+
"required": false,
|
|
6150
|
+
"description": "The action. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6151
|
+
"schema": {
|
|
6152
|
+
"type": "string",
|
|
6153
|
+
"minLength": 1,
|
|
6154
|
+
"maxLength": 100,
|
|
6155
|
+
"description": "The action. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6198
6156
|
}
|
|
6199
6157
|
},
|
|
6200
6158
|
{
|
|
@@ -6202,13 +6160,12 @@ var OPERATIONS = [
|
|
|
6202
6160
|
"in": "body",
|
|
6203
6161
|
"type": "string",
|
|
6204
6162
|
"required": false,
|
|
6205
|
-
"description": "What the amount counts
|
|
6206
|
-
"example": "cents",
|
|
6163
|
+
"description": "What the amount counts. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6207
6164
|
"schema": {
|
|
6208
6165
|
"type": "string",
|
|
6209
6166
|
"minLength": 1,
|
|
6210
6167
|
"maxLength": 40,
|
|
6211
|
-
"description": "What the amount counts
|
|
6168
|
+
"description": "What the amount counts. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6212
6169
|
}
|
|
6213
6170
|
},
|
|
6214
6171
|
{
|
|
@@ -6216,8 +6173,7 @@ var OPERATIONS = [
|
|
|
6216
6173
|
"in": "body",
|
|
6217
6174
|
"type": "string",
|
|
6218
6175
|
"required": false,
|
|
6219
|
-
"description": "
|
|
6220
|
-
"example": "month",
|
|
6176
|
+
"description": "The window. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6221
6177
|
"schema": {
|
|
6222
6178
|
"type": "string",
|
|
6223
6179
|
"enum": [
|
|
@@ -6230,7 +6186,7 @@ var OPERATIONS = [
|
|
|
6230
6186
|
"total",
|
|
6231
6187
|
"concurrent"
|
|
6232
6188
|
],
|
|
6233
|
-
"description": "
|
|
6189
|
+
"description": "The window. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6234
6190
|
}
|
|
6235
6191
|
},
|
|
6236
6192
|
{
|
|
@@ -6238,13 +6194,12 @@ var OPERATIONS = [
|
|
|
6238
6194
|
"in": "body",
|
|
6239
6195
|
"type": "number",
|
|
6240
6196
|
"required": false,
|
|
6241
|
-
"description":
|
|
6242
|
-
"example": 1,
|
|
6197
|
+
"description": "How many windows a period lasts. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6243
6198
|
"schema": {
|
|
6244
6199
|
"type": "integer",
|
|
6245
6200
|
"minimum": 1,
|
|
6246
6201
|
"maximum": 1e3,
|
|
6247
|
-
"description":
|
|
6202
|
+
"description": "How many windows a period lasts. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6248
6203
|
}
|
|
6249
6204
|
},
|
|
6250
6205
|
{
|
|
@@ -6252,16 +6207,15 @@ var OPERATIONS = [
|
|
|
6252
6207
|
"in": "body",
|
|
6253
6208
|
"type": "string",
|
|
6254
6209
|
"required": false,
|
|
6255
|
-
"description": "Where a period begins.
|
|
6256
|
-
"example": "calendar",
|
|
6210
|
+
"description": "Where a period begins. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6257
6211
|
"schema": {
|
|
6258
6212
|
"type": "string",
|
|
6259
6213
|
"enum": [
|
|
6260
6214
|
"calendar",
|
|
6261
|
-
"
|
|
6215
|
+
"billing_date",
|
|
6262
6216
|
"first_use"
|
|
6263
6217
|
],
|
|
6264
|
-
"description": "Where a period begins.
|
|
6218
|
+
"description": "Where a period begins. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6265
6219
|
}
|
|
6266
6220
|
},
|
|
6267
6221
|
{
|
|
@@ -6269,36 +6223,10 @@ var OPERATIONS = [
|
|
|
6269
6223
|
"in": "body",
|
|
6270
6224
|
"type": "boolean",
|
|
6271
6225
|
"required": false,
|
|
6272
|
-
"description": "
|
|
6226
|
+
"description": "Whether it counts the last window. Fixed once the limit is created: to change it, create a new limit and archive this one.",
|
|
6273
6227
|
"schema": {
|
|
6274
6228
|
"type": "boolean",
|
|
6275
|
-
"description": "
|
|
6276
|
-
}
|
|
6277
|
-
},
|
|
6278
|
-
{
|
|
6279
|
-
"name": "enabled",
|
|
6280
|
-
"in": "body",
|
|
6281
|
-
"type": "boolean",
|
|
6282
|
-
"required": false,
|
|
6283
|
-
"description": "Whether checks enforce it. Default: true.",
|
|
6284
|
-
"schema": {
|
|
6285
|
-
"type": "boolean",
|
|
6286
|
-
"description": "Whether checks enforce it. Default: true."
|
|
6287
|
-
}
|
|
6288
|
-
},
|
|
6289
|
-
{
|
|
6290
|
-
"name": "failMode",
|
|
6291
|
-
"in": "body",
|
|
6292
|
-
"type": "string",
|
|
6293
|
-
"required": false,
|
|
6294
|
-
"description": "What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny). Default: open.",
|
|
6295
|
-
"schema": {
|
|
6296
|
-
"type": "string",
|
|
6297
|
-
"enum": [
|
|
6298
|
-
"open",
|
|
6299
|
-
"closed"
|
|
6300
|
-
],
|
|
6301
|
-
"description": "What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny). Default: open."
|
|
6229
|
+
"description": "Whether it counts the last window. Fixed once the limit is created: to change it, create a new limit and archive this one."
|
|
6302
6230
|
}
|
|
6303
6231
|
}
|
|
6304
6232
|
],
|
|
@@ -6327,7 +6255,7 @@ var OPERATIONS = [
|
|
|
6327
6255
|
"idempotentHint": false
|
|
6328
6256
|
}
|
|
6329
6257
|
},
|
|
6330
|
-
"description": "
|
|
6258
|
+
"description": "Commits a reservation with the ACTUAL amount used (`cost`): less than reserved gives the rest back at once; more is charged in full \u2014 the work happened. A commit after the reservation expired still charges `cost`. Repeating a commit answers the same. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.",
|
|
6331
6259
|
"fields": [
|
|
6332
6260
|
{
|
|
6333
6261
|
"name": "reservationId",
|
|
@@ -6377,7 +6305,7 @@ var OPERATIONS = [
|
|
|
6377
6305
|
"idempotentHint": false
|
|
6378
6306
|
}
|
|
6379
6307
|
},
|
|
6380
|
-
"description": "Keeps a
|
|
6308
|
+
"description": "Keeps a reservation for longer work: it now expires `ttlSeconds` from now (default 300, at most 3600) \u2014 call it again as a heartbeat. Only an open reservation can be extended. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.",
|
|
6381
6309
|
"fields": [
|
|
6382
6310
|
{
|
|
6383
6311
|
"name": "reservationId",
|
|
@@ -6428,7 +6356,7 @@ var OPERATIONS = [
|
|
|
6428
6356
|
"idempotentHint": false
|
|
6429
6357
|
}
|
|
6430
6358
|
},
|
|
6431
|
-
"description": "Gives the whole
|
|
6359
|
+
"description": "Gives the whole reservation back \u2014 the work did not happen. Repeating a release answers the same; releasing a committed reservation is refused. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.",
|
|
6432
6360
|
"fields": [
|
|
6433
6361
|
{
|
|
6434
6362
|
"name": "reservationId",
|
|
@@ -6466,7 +6394,7 @@ var OPERATIONS = [
|
|
|
6466
6394
|
"idempotentHint": true
|
|
6467
6395
|
}
|
|
6468
6396
|
},
|
|
6469
|
-
"description": "A subject's
|
|
6397
|
+
"description": "A subject's billing date: when its `billing_date` limits' periods start from. A subject is yours (a user, a team, an agent) and exists once a check names it.",
|
|
6470
6398
|
"fields": [
|
|
6471
6399
|
{
|
|
6472
6400
|
"name": "subjectKind",
|
|
@@ -6519,7 +6447,7 @@ var OPERATIONS = [
|
|
|
6519
6447
|
"idempotentHint": false
|
|
6520
6448
|
}
|
|
6521
6449
|
},
|
|
6522
|
-
"description": "
|
|
6450
|
+
"description": "Resets one limit on a subject (`limitId`), or every limit on it (`{}`), at once: for goodwill, a promotion or support. The schedule doesn't move: the next reset is still the usual one. A balance goes back to its amount; a concurrent limit is skipped. Send an Idempotency-Key and a repeat resets once. Owners and admins only, for a person's token.",
|
|
6523
6451
|
"fields": [
|
|
6524
6452
|
{
|
|
6525
6453
|
"name": "subjectKind",
|
|
@@ -6551,7 +6479,7 @@ var OPERATIONS = [
|
|
|
6551
6479
|
"type": "string",
|
|
6552
6480
|
"required": false,
|
|
6553
6481
|
"description": "Just this limit. Default: every limit on the subject.",
|
|
6554
|
-
"example": "
|
|
6482
|
+
"example": "lmt_3f0c\u2026",
|
|
6555
6483
|
"schema": {
|
|
6556
6484
|
"type": "string",
|
|
6557
6485
|
"description": "Just this limit. Default: every limit on the subject."
|
|
@@ -6566,7 +6494,7 @@ var OPERATIONS = [
|
|
|
6566
6494
|
"operationId": "subjects.update",
|
|
6567
6495
|
"method": "patch",
|
|
6568
6496
|
"path": "/subjects/{subjectKind}/{subjectId}",
|
|
6569
|
-
"summary": "Set a subject's
|
|
6497
|
+
"summary": "Set a subject's billing date",
|
|
6570
6498
|
"cli": {
|
|
6571
6499
|
"command": "subjects update",
|
|
6572
6500
|
"args": [
|
|
@@ -6584,7 +6512,7 @@ var OPERATIONS = [
|
|
|
6584
6512
|
"idempotentHint": false
|
|
6585
6513
|
}
|
|
6586
6514
|
},
|
|
6587
|
-
"description": "Sets when a subject's `
|
|
6515
|
+
"description": "Sets when a subject's `billing_date` limits' periods start from: typically its subscription's start date, from your billing system's webhook, so its allowance resets on its own billing day (monthly for an annual plan, too). Owners and admins only, for a person's token.",
|
|
6588
6516
|
"fields": [
|
|
6589
6517
|
{
|
|
6590
6518
|
"name": "subjectKind",
|
|
@@ -6611,7 +6539,7 @@ var OPERATIONS = [
|
|
|
6611
6539
|
}
|
|
6612
6540
|
},
|
|
6613
6541
|
{
|
|
6614
|
-
"name": "
|
|
6542
|
+
"name": "billingDate",
|
|
6615
6543
|
"in": "body",
|
|
6616
6544
|
"type": "string",
|
|
6617
6545
|
"required": true,
|
|
@@ -6647,7 +6575,7 @@ var OPERATIONS = [
|
|
|
6647
6575
|
"idempotentHint": true
|
|
6648
6576
|
}
|
|
6649
6577
|
},
|
|
6650
|
-
"description": "Units used, checks allowed and
|
|
6578
|
+
"description": "Units used, checks allowed and refused for one limit \u2014 across all subjects, or one (`subject`, as `kind:id`) \u2014 per hour or per day (UTC), every bucket in the range included. Up to about a minute behind live checks. Default: the last 30 days, by day.",
|
|
6651
6579
|
"fields": [
|
|
6652
6580
|
{
|
|
6653
6581
|
"name": "limitId",
|
|
@@ -6655,34 +6583,24 @@ var OPERATIONS = [
|
|
|
6655
6583
|
"type": "string",
|
|
6656
6584
|
"required": true,
|
|
6657
6585
|
"description": "The limit.",
|
|
6658
|
-
"example": "
|
|
6586
|
+
"example": "lmt_3f0c\u2026",
|
|
6659
6587
|
"schema": {
|
|
6660
6588
|
"type": "string",
|
|
6661
6589
|
"description": "The limit."
|
|
6662
6590
|
}
|
|
6663
6591
|
},
|
|
6664
6592
|
{
|
|
6665
|
-
"name": "
|
|
6666
|
-
"in": "query",
|
|
6667
|
-
"type": "string",
|
|
6668
|
-
"required": false,
|
|
6669
|
-
"description": "With `subjectId`: one subject's usage, not every subject's.",
|
|
6670
|
-
"example": "user",
|
|
6671
|
-
"schema": {
|
|
6672
|
-
"type": "string",
|
|
6673
|
-
"description": "With `subjectId`: one subject's usage, not every subject's."
|
|
6674
|
-
}
|
|
6675
|
-
},
|
|
6676
|
-
{
|
|
6677
|
-
"name": "subjectId",
|
|
6593
|
+
"name": "subject",
|
|
6678
6594
|
"in": "query",
|
|
6679
6595
|
"type": "string",
|
|
6680
6596
|
"required": false,
|
|
6681
|
-
"description": "
|
|
6682
|
-
"example": "usr_123",
|
|
6597
|
+
"description": "One subject's usage, not every subject's, as `kind:id`.",
|
|
6598
|
+
"example": "user:usr_123",
|
|
6683
6599
|
"schema": {
|
|
6684
6600
|
"type": "string",
|
|
6685
|
-
"
|
|
6601
|
+
"minLength": 3,
|
|
6602
|
+
"maxLength": 301,
|
|
6603
|
+
"description": "One subject's usage, not every subject's, as `kind:id`."
|
|
6686
6604
|
}
|
|
6687
6605
|
},
|
|
6688
6606
|
{
|
|
@@ -6751,34 +6669,20 @@ var OPERATIONS = [
|
|
|
6751
6669
|
"idempotentHint": true
|
|
6752
6670
|
}
|
|
6753
6671
|
},
|
|
6754
|
-
"description": "Every enabled limit on one subject \u2014 and on its shared subjects (`shared`, comma-separated `kind:id`, such as `team:team_42`) \u2014 with what is used, what is left and when it resets, exact as of now. For showing an end user where they stand: call it from your server with your key, never from a browser. Not a check: nothing is counted. A subject with no limit here answers an empty `limits` list.",
|
|
6672
|
+
"description": "Every enabled limit on one subject (`subject`, as `kind:id`, such as `user:usr_123`) \u2014 and on its shared subjects (`shared`, comma-separated `kind:id`, such as `team:team_42`) \u2014 with what is used, what is left and when it resets, exact as of now. For showing an end user where they stand: call it from your server with your key, never from a browser. Not a check: nothing is counted. A subject with no limit here answers an empty `limits` list.",
|
|
6755
6673
|
"fields": [
|
|
6756
6674
|
{
|
|
6757
|
-
"name": "
|
|
6758
|
-
"in": "query",
|
|
6759
|
-
"type": "string",
|
|
6760
|
-
"required": true,
|
|
6761
|
-
"description": "The subject's kind, as your checks send it.",
|
|
6762
|
-
"example": "user",
|
|
6763
|
-
"schema": {
|
|
6764
|
-
"type": "string",
|
|
6765
|
-
"minLength": 1,
|
|
6766
|
-
"maxLength": 100,
|
|
6767
|
-
"description": "The subject's kind, as your checks send it."
|
|
6768
|
-
}
|
|
6769
|
-
},
|
|
6770
|
-
{
|
|
6771
|
-
"name": "id",
|
|
6675
|
+
"name": "subject",
|
|
6772
6676
|
"in": "query",
|
|
6773
6677
|
"type": "string",
|
|
6774
6678
|
"required": true,
|
|
6775
|
-
"description": "The subject
|
|
6776
|
-
"example": "usr_123",
|
|
6679
|
+
"description": "The subject, as `kind:id`: its kind and id as your checks send them.",
|
|
6680
|
+
"example": "user:usr_123",
|
|
6777
6681
|
"schema": {
|
|
6778
6682
|
"type": "string",
|
|
6779
|
-
"minLength":
|
|
6780
|
-
"maxLength":
|
|
6781
|
-
"description": "The subject
|
|
6683
|
+
"minLength": 3,
|
|
6684
|
+
"maxLength": 301,
|
|
6685
|
+
"description": "The subject, as `kind:id`: its kind and id as your checks send them."
|
|
6782
6686
|
}
|
|
6783
6687
|
},
|
|
6784
6688
|
{
|
|
@@ -6817,7 +6721,7 @@ var OPERATIONS = [
|
|
|
6817
6721
|
"idempotentHint": true
|
|
6818
6722
|
}
|
|
6819
6723
|
},
|
|
6820
|
-
"description": "A limit's subjects in its CURRENT window, most used first: units used, what is left, how many checks
|
|
6724
|
+
"description": "A limit's subjects in its CURRENT window, most used first: units used, what is left, and how many checks it refused. Up to about a minute behind live checks.",
|
|
6821
6725
|
"fields": [
|
|
6822
6726
|
{
|
|
6823
6727
|
"name": "limitId",
|
|
@@ -6825,7 +6729,7 @@ var OPERATIONS = [
|
|
|
6825
6729
|
"type": "string",
|
|
6826
6730
|
"required": true,
|
|
6827
6731
|
"description": "The limit.",
|
|
6828
|
-
"example": "
|
|
6732
|
+
"example": "lmt_3f0c\u2026",
|
|
6829
6733
|
"schema": {
|
|
6830
6734
|
"type": "string",
|
|
6831
6735
|
"description": "The limit."
|
|
@@ -7946,7 +7850,7 @@ function parseSubject(value) {
|
|
|
7946
7850
|
var left = (r) => `${r.name}: ${r.remaining} ${r.unit} left${r.resetsAt ? `, resets ${r.resetsAt}` : ""}`;
|
|
7947
7851
|
function answer(decision) {
|
|
7948
7852
|
if (decision.allowed) {
|
|
7949
|
-
return decision.
|
|
7853
|
+
return decision.limits.length === 0 ? "Allowed. No limit applies." : `Allowed. ${decision.limits.map(left).join("; ")}`;
|
|
7950
7854
|
}
|
|
7951
7855
|
return decision.reason?.message ?? "Refused.";
|
|
7952
7856
|
}
|
|
@@ -7955,7 +7859,9 @@ function answer(decision) {
|
|
|
7955
7859
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
7956
7860
|
import { resolve } from "node:path";
|
|
7957
7861
|
var limitsSyncCommand = (program2, ctx) => {
|
|
7958
|
-
const group = program2.commands.find((c) => c.name() === "limits") ?? program2.command("limits").description(
|
|
7862
|
+
const group = program2.commands.find((c) => c.name() === "limits") ?? program2.command("limits").description(
|
|
7863
|
+
"archive, create, credits, get, list, restore, sync, update"
|
|
7864
|
+
);
|
|
7959
7865
|
syncCommand(
|
|
7960
7866
|
group.command("sync"),
|
|
7961
7867
|
ctx,
|
|
@@ -7971,12 +7877,12 @@ Shortcut: \`${brand.name} sync\`, the same command.`
|
|
|
7971
7877
|
);
|
|
7972
7878
|
};
|
|
7973
7879
|
function syncCommand(command, ctx, description, more) {
|
|
7974
|
-
command.description(description).argument("[file]", "the file to read", "limitry.json").option("--
|
|
7880
|
+
command.description(description).argument("[file]", "the file to read", "limitry.json").option("--preview", "show what would change, and change nothing").option("--limits <json>", "the limits as a JSON array, instead of a file").option(
|
|
7975
7881
|
"--archive-missing",
|
|
7976
7882
|
"archive active limits the file doesn't name (restorable)"
|
|
7977
7883
|
).option("--workspace <slug>", "act in this workspace for one call").option("--json", "machine-readable output").addHelpText(
|
|
7978
7884
|
"after",
|
|
7979
|
-
'\nThe file: { "limits": [ { "name": "AI budget", "
|
|
7885
|
+
'\nThe file: { "limits": [ { "name": "AI budget", "subject": { "kind": "user" }, "action": "ai-call", "amount": 200, "unit": "cents", "window": "month" } ] }\nEach limit is described whole: a field left out is its default, as on `limits create`. Names are the key.\nWhat a limit counts (subject, action, unit, window, every, start, rolling) is fixed: to change it, give the entry a new name.' + more
|
|
7980
7886
|
).action(
|
|
7981
7887
|
async (file, options) => {
|
|
7982
7888
|
const limits = options.limits === void 0 ? readLimitsFile(file) : parseLimits(options.limits, "--limits");
|
|
@@ -7984,7 +7890,7 @@ function syncCommand(command, ctx, description, more) {
|
|
|
7984
7890
|
{
|
|
7985
7891
|
limits,
|
|
7986
7892
|
archiveMissing: options.archiveMissing ?? false,
|
|
7987
|
-
|
|
7893
|
+
preview: options.preview ?? false
|
|
7988
7894
|
},
|
|
7989
7895
|
{ idempotencyKey: crypto.randomUUID() }
|
|
7990
7896
|
);
|
|
@@ -8034,7 +7940,7 @@ function parseLimits(text, flag2) {
|
|
|
8034
7940
|
}
|
|
8035
7941
|
var show = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
8036
7942
|
function summary(result) {
|
|
8037
|
-
const dry = result.
|
|
7943
|
+
const dry = result.preview;
|
|
8038
7944
|
const lines = [
|
|
8039
7945
|
...result.created.map(
|
|
8040
7946
|
(name) => `${dry ? "Would create" : "Created"}: ${name}`
|
|
@@ -8054,7 +7960,7 @@ function summary(result) {
|
|
|
8054
7960
|
];
|
|
8055
7961
|
}
|
|
8056
7962
|
if (same2 > 0) lines.push(`Unchanged: ${same2}`);
|
|
8057
|
-
if (dry) lines.push("
|
|
7963
|
+
if (dry) lines.push("Preview: nothing was changed.");
|
|
8058
7964
|
return lines;
|
|
8059
7965
|
}
|
|
8060
7966
|
|
|
@@ -8075,7 +7981,7 @@ function tokenEnvVar() {
|
|
|
8075
7981
|
function build(io) {
|
|
8076
7982
|
let actedIn = null;
|
|
8077
7983
|
let sending;
|
|
8078
|
-
const program2 = new Command().name(brand.name).description(`${brand.productName} command line`).version("1.0.0-rc.
|
|
7984
|
+
const program2 = new Command().name(brand.name).description(`${brand.productName} command line`).version("1.0.0-rc.8").addHelpText(
|
|
8079
7985
|
"after",
|
|
8080
7986
|
`
|
|
8081
7987
|
Token: \`${brand.name} login\` stores it in ~/.config/${brand.name}/; ${tokenEnvVar()} overrides.
|