@cavelon/cli 0.2.17 → 0.2.18

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.
@@ -3,7 +3,7 @@ import { positional } from "../command.js";
3
3
  import { CavelonError, ExitCode, usageError } from "../errors.js";
4
4
  import { confirmation, PERSON_CONFIRMS_HELP } from "../confirm-token.js";
5
5
  import { callOperation, openapiOrWarn, workflowOperation } from "../invoke.js";
6
- import { changedBy, docsPage, formatValue, isOperatorChange, LIMIT_ABOVE_CEILING, limitRef, quotaSetting, readLimits, } from "../limits.js";
6
+ import { changedBy, docsPage, formatValue, isOperatorChange, LIMIT_ABOVE_CEILING, limitRef, NO_LIMIT, quotaSetting, readLimits, } from "../limits.js";
7
7
  import { deref, jsonBodySchema, operationForPath, validateBody } from "../openapi.js";
8
8
  import { readGlobalRole, readPrincipal } from "../principal.js";
9
9
  import { cavelonCommand } from "../printed.js";
@@ -18,8 +18,10 @@ const UNIT_WORDS = {
18
18
  const TRUE_WORDS = new Set(["true", "on", "yes", "enabled"]);
19
19
  const FALSE_WORDS = new Set(["false", "off", "no", "disabled"]);
20
20
  const CLEAR_WORDS = new Set(["none", "null"]);
21
+ const NO_LIMIT_WORDS = new Set(["unlimited", "no-limit", "no_limit", "nolimit"]);
21
22
  const RUN_CAPS_PAGE = "Platform › Operations › Rate limits › Run caps";
22
23
  const TENANT_LIMITS_PAGE = "the tenant's Limits section (Concurrent Agent Runs)";
24
+ const CAPACITY_PAGE = "the tenant's Limits section (Capacity)";
23
25
  const FEATURE_FLAGS_PAGE = "Configure › Feature Flags";
24
26
  function notPublished(message, hint, details = {}) {
25
27
  return new CavelonError(ExitCode.failure, { code: "operation_unavailable", message, hint, details: { ...details, sent: false } });
@@ -173,14 +175,19 @@ function bareExtension(word) {
173
175
  start++;
174
176
  return word.slice(start);
175
177
  }
178
+ function liftsLimit(target) {
179
+ return target.change.null_means === NO_LIMIT;
180
+ }
176
181
  function clears(target) {
177
182
  if (target.flag)
178
183
  return false;
179
- return target.kind === "limit" || Boolean(target.quota);
184
+ return target.kind === "limit" || Boolean(target.quota) || liftsLimit(target);
180
185
  }
181
186
  function parseValue(raw, kind, target) {
182
187
  const word = raw.trim();
183
188
  const lower = word.toLowerCase();
189
+ if (liftsLimit(target) && NO_LIMIT_WORDS.has(lower))
190
+ return null;
184
191
  if (CLEAR_WORDS.has(lower)) {
185
192
  if (!clears(target)) {
186
193
  throw usageError(target.flag
@@ -206,8 +213,9 @@ function parseValue(raw, kind, target) {
206
213
  const { digits, rest } = splitNumber(word, kind === "number");
207
214
  const unit = target.limit?.unit ?? target.quota?.unit ?? "count";
208
215
  const units = unit === "count" || unit === "processing_steps" ? "" : ` of ${unit}`;
216
+ const clearWith = liftsLimit(target) ? ", or none for no limit (0 allows none)" : clears(target) ? ", or none to clear it" : "";
209
217
  if (!digits)
210
- throw usageError(`${target.key} takes a ${kind === "number" ? "number" : "whole number"}${units}${clears(target) ? ", or none to clear it" : ""}; got "${raw}".`);
218
+ throw usageError(`${target.key} takes a ${kind === "number" ? "number" : "whole number"}${units}${clearWith}; got "${raw}".`);
211
219
  if (rest && !(UNIT_WORDS[unit] ?? []).includes(rest)) {
212
220
  throw usageError(`${target.key} is in ${unit}; "${raw}" is not. Give the number of ${unit}${UNIT_WORDS[unit] ? ` (e.g. ${digits} or ${digits}${UNIT_WORDS[unit][0]})` : ""}.`);
213
221
  }
@@ -270,6 +278,8 @@ function anyOf(names, none = "a permission the instance does not name") {
270
278
  function adminPage(target) {
271
279
  if (target.flag)
272
280
  return FEATURE_FLAGS_PAGE;
281
+ if (liftsLimit(target))
282
+ return CAPACITY_PAGE;
273
283
  if (target.change.field.startsWith("max_database_"))
274
284
  return "the tenant's Limits section (Database connections and Database queries)";
275
285
  return target.scope === "one_tenant" ? TENANT_LIMITS_PAGE : RUN_CAPS_PAGE;
@@ -368,6 +378,12 @@ async function pathParams(ctx, change, principal) {
368
378
  function valueText(target, value, kind) {
369
379
  if (value === undefined)
370
380
  return "not published";
381
+ if (liftsLimit(target)) {
382
+ if (value === null)
383
+ return "no limit";
384
+ if (value === 0)
385
+ return "0 (none allowed)";
386
+ }
371
387
  if (value === null) {
372
388
  if (target.quota)
373
389
  return "none (no cap)";
@@ -420,7 +436,9 @@ function noChange(target, previous, value, from) {
420
436
  return previous === value ? `${target.key} is already ${from} (${target.flag.setting})` : undefined;
421
437
  if (target.kind === "quota") {
422
438
  const wanted = target.quota ? capValue(value) : value;
423
- return previous !== undefined && sameValue(previous, wanted) ? `${target.key} is already ${from}` : undefined;
439
+ if (previous !== undefined && sameValue(previous, wanted))
440
+ return `${target.key} is already ${from}${target.scope === "one_tenant" ? " for this tenant" : ""}`;
441
+ return undefined;
424
442
  }
425
443
  const limit = target.limit;
426
444
  if (target.scope === "one_tenant") {
@@ -478,6 +496,8 @@ export const limitsSet = {
478
496
  description: "Reads the limit's published change (operation, body field, bounds, permissions, roles) and checks the value against it\n" +
479
497
  "before sending. Without --confirm, shows the old and new value, the operation and who may run it, and changes nothing.\n" +
480
498
  "Also changes the tenant quotas in tenant_quotas.changes (the inference budget, the monthly Processing Step cap).\n" +
499
+ "An operator sets a tenant's capacity limits (max_agents, max_tools, max_knowledge_bases, max_documents_per_kb,\n" +
500
+ "max_storage_bytes) where the instance publishes them: none lifts one (no limit), 0 allows none.\n" +
481
501
  "An operator's change (a run cap) is sent only with a personal access token in Platform mode of a role it names, without\n" +
482
502
  "X-Tenant-Id; --tenant <id|slug> then sets one tenant's override, including database connection/query caps. An environment or licence limit, a value out of bounds,\n" +
483
503
  "an instance that does not publish how to change the limit, and a credential without the permission or the role are refused\n" +
@@ -491,7 +511,8 @@ export const limitsSet = {
491
511
  { name: "key", description: "The limit's key, as `cavelon limits` lists it (e.g. kb_upload_max_file_size_mb).", required: true },
492
512
  {
493
513
  name: "value",
494
- description: "The new value in the limit's unit (50 or 50MB), a comma-separated list of file types, true/false, or none to clear the tenant's own value.",
514
+ description: "The new value in the limit's unit (50 or 50MB), a comma-separated list of file types, true/false, or none to clear the tenant's own value " +
515
+ "(on a capacity limit, none is no limit and 0 allows none).",
495
516
  required: true,
496
517
  },
497
518
  ],
@@ -507,6 +528,7 @@ export const limitsSet = {
507
528
  "cavelon limits set monthly_processing_step_cap none --confirm",
508
529
  "cavelon limits set max_concurrent_agent_runs_global 150 --confirm",
509
530
  "cavelon limits set max_concurrent_agent_runs_per_tenant 6 --tenant acme --confirm",
531
+ "cavelon limits set max_agents none --tenant acme --confirm",
510
532
  ],
511
533
  async run(ctx, input) {
512
534
  const key = positional(input, "key").trim();
@@ -3,7 +3,7 @@ import { listOption, stringOption } from "../command.js";
3
3
  import { CavelonError, ExitCode } from "../errors.js";
4
4
  import { table } from "../format.js";
5
5
  import { branchConcurrency, branchConcurrencyText } from "../branches.js";
6
- import { bindsNow, bindsWhenText, changedBy, docsPage, formatQuota, formatQuotaValue, formatValue, isOperatorChange, readLimits, readQuotas, } from "../limits.js";
6
+ import { bindsNow, bindsWhenText, changedBy, docsPage, formatQuota, formatQuotaValue, formatValue, isOperatorChange, NO_LIMIT, quotaLimitText, readLimits, readQuotas, } from "../limits.js";
7
7
  import { cavelonCommand, fill } from "../printed.js";
8
8
  import { databaseLimitsText, readDatabaseLimits } from "../database-limits.js";
9
9
  const SOURCE_ORDER = ["tenant", "platform", "licence"];
@@ -30,8 +30,14 @@ function periodText(quota) {
30
30
  function quotaUse(quota) {
31
31
  if (quota.current !== null || quota.limit !== null)
32
32
  return formatQuota(quota);
33
- const numbers = Object.entries(quota.details).filter(([, v]) => typeof v === "number");
34
- return numbers.length ? numbers.map(([k, v]) => `${k} ${String(v)}`).join(", ") : "-";
33
+ const isLimit = (k) => k.startsWith("limit");
34
+ const shown = Object.entries(quota.details).filter(([k, v]) => typeof v === "number" || (v === null && isLimit(k)));
35
+ const text = (k, v) => {
36
+ if (!isLimit(k) || (typeof v === "number" && !(v === 0 && quota.none_allowed_at_zero)))
37
+ return String(v);
38
+ return quotaLimitText(v, quota.none_allowed_at_zero);
39
+ };
40
+ return shown.length ? shown.map(([k, v]) => `${k} ${text(k, v)}`).join(", ") : "-";
35
41
  }
36
42
  export const limits = {
37
43
  name: "limits",
@@ -129,7 +135,10 @@ export const limits = {
129
135
  text += `\n\nClose to a quota: ${near.map((q) => q.text).join("; ")}`;
130
136
  const quotaChanges = keys.length || source ? [] : (published.tenantQuotas?.changes ?? []);
131
137
  const tenantChangeable = [...values.filter((v) => v.change && !isOperatorChange(v.change)).map((v) => v.key), ...quotaChanges.filter((c) => !isOperatorChange(c)).map((c) => c.key)];
132
- const operatorChangeable = values.filter((v) => [v.change, v.tenant_change].some((c) => c && isOperatorChange(c))).map((v) => v.key);
138
+ const operatorChangeable = [
139
+ ...values.filter((v) => [v.change, v.tenant_change].some((c) => c && isOperatorChange(c))).map((v) => v.key),
140
+ ...quotaChanges.filter((c) => isOperatorChange(c)).map((c) => c.key),
141
+ ];
133
142
  if (tenantChangeable.length) {
134
143
  const owner = quotaValues.filter((q) => q.changeable_by === "tenant_owner" && tenantChangeable.includes(q.key)).map((q) => q.key);
135
144
  text += `\n\nA tenant admin changes ${tenantChangeable.length === 1 ? "it" : "these"} with: ${cavelonCommand("limits", "set", fill("key"), fill("value"))} (shows the change; --confirm sends it)`;
@@ -138,6 +147,9 @@ export const limits = {
138
147
  }
139
148
  if (operatorChangeable.length) {
140
149
  text += `\n\nAn operator changes ${operatorChangeable.join(", ")} with the same command and a personal access token in Platform mode of the role the change names; --tenant <id|slug> selects one tenant's override or flag.`;
150
+ const liftable = quotaChanges.filter((c) => c.null_means === NO_LIMIT).map((c) => c.key);
151
+ if (liftable.length)
152
+ text += ` For ${liftable.join(", ")}, none lifts the limit (no limit) and 0 allows none.`;
141
153
  }
142
154
  const pages = [...new Set(values.map((v) => docsPage(v.docs)).filter(Boolean))];
143
155
  if (pages.length)
package/dist/limits.js CHANGED
@@ -2,6 +2,13 @@ import { CavelonError, ExitCode } from "./errors.js";
2
2
  import { readPrincipal } from "./principal.js";
3
3
  import { cavelonCommand } from "./printed.js";
4
4
  const NEAR = 0.8;
5
+ const NONE_ALLOWED = "none_allowed";
6
+ export const NO_LIMIT = "no_limit";
7
+ export function quotaLimitText(limit, noneAllowedAtZero) {
8
+ if (limit === null || (typeof limit === "number" && limit <= 0 && !(noneAllowedAtZero && limit === 0)))
9
+ return "no limit";
10
+ return limit === 0 ? "0 (none allowed)" : String(limit);
11
+ }
5
12
  export function changedBy(limit) {
6
13
  if (limit.changeable_by === "tenant_admin")
7
14
  return "a tenant admin";
@@ -109,6 +116,7 @@ export function parseChange(raw) {
109
116
  const maximumSetting = text(entry.maximum_setting);
110
117
  const roles = Array.isArray(entry.requires_role) ? entry.requires_role.filter((r) => typeof r === "string" && r !== "") : [];
111
118
  const mode = text(entry.mode);
119
+ const nullMeans = text(entry.null_means);
112
120
  return {
113
121
  operation,
114
122
  method,
@@ -120,6 +128,7 @@ export function parseChange(raw) {
120
128
  ...(maximumSetting ? { maximum_setting: maximumSetting } : {}),
121
129
  ...(roles.length ? { requires_role: roles } : {}),
122
130
  ...(mode ? { mode } : {}),
131
+ ...(nullMeans ? { null_means: nullMeans } : {}),
123
132
  };
124
133
  }
125
134
  export function isOperatorChange(change) {
@@ -233,11 +242,23 @@ export async function limitsOrWarn(ctx) {
233
242
  function quotaOf(key, raw) {
234
243
  const current = typeof raw.current === "number" ? raw.current : null;
235
244
  const limit = typeof raw.limit === "number" ? raw.limit : null;
236
- const ratio = current !== null && limit !== null && limit > 0 ? current / limit : null;
245
+ const noneAllowedAtZero = raw.zero_means === NONE_ALLOWED;
246
+ const full = noneAllowedAtZero && limit === 0 && current !== null;
247
+ const ratio = full ? 1 : current !== null && limit !== null && limit > 0 ? current / limit : null;
237
248
  const warning = typeof raw.warning_ratio === "number" && raw.warning_ratio > 0 ? raw.warning_ratio : NEAR;
238
249
  const link = raw.change;
239
250
  const change = link && typeof link.key === "string" && typeof link.field === "string" ? { key: link.key, field: link.field } : undefined;
240
- return { key, current, limit, ratio, warning_ratio: warning, near: ratio !== null && ratio >= warning, details: raw, ...(change ? { change } : {}) };
251
+ return {
252
+ key,
253
+ current,
254
+ limit,
255
+ ratio,
256
+ warning_ratio: warning,
257
+ near: ratio !== null && ratio >= warning,
258
+ details: raw,
259
+ ...(change ? { change } : {}),
260
+ none_allowed_at_zero: noneAllowedAtZero,
261
+ };
241
262
  }
242
263
  export async function readQuotas(ctx, limits) {
243
264
  const link = limits.tenantQuotas;
@@ -301,6 +322,8 @@ export function formatQuota(quota) {
301
322
  if (quota.current === null && quota.limit === null)
302
323
  return "-";
303
324
  const used = quota.current === null ? "?" : String(quota.current);
325
+ if (quota.limit === 0 && quota.none_allowed_at_zero)
326
+ return `${used} of 0 (none allowed)`;
304
327
  if (quota.limit === null || quota.limit <= 0)
305
328
  return `${used} (no limit)`;
306
329
  return `${used} of ${quota.limit}${quota.ratio === null ? "" : ` (${Math.round(quota.ratio * 100)}%)`}`;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": 1,
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "entries": {
5
5
  "omp": [
6
6
  "omp-extension.mjs"
@@ -88,8 +88,10 @@ for a public widget), **propose the change; the person decides.**
88
88
  operator. Where it publishes a `change` (the run caps), `limits set` sends it
89
89
  only with a personal access token in Platform mode of the role it names, and
90
90
  otherwise refuses naming the role and the Admin page; `--tenant <tenant>`
91
- then sets one tenant's own run cap. Without a `change` it cannot be changed
92
- at runtime. Tell the person who changes it and where, and design within it
91
+ then sets one tenant's own run cap, or a capacity limit (`max_agents`,
92
+ `max_tools`, `max_knowledge_bases`, `max_documents_per_kb`,
93
+ `max_storage_bytes`: `none` is no limit, `0` allows none). Without a
94
+ `change` it cannot be changed at runtime. Tell the person who changes it and where, and design within it
93
95
  meanwhile; never ask for an operator's token. A docs page marked "Platform
94
96
  page" describes such an operator's task: this token can read it, not do it.
95
97
  - A rate limit only goes down to what the operator allows; above the ceiling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",