@cavelon/cli 0.2.17 → 0.2.19

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)
@@ -602,9 +602,18 @@ export function previewText(p, context = {}) {
602
602
  lines.push(["not applied", notAppliedLines(skipped)]);
603
603
  const impact = p.impact ?? {};
604
604
  const active = (impact.active_harnesses ?? []).map((h) => {
605
- const via = [...(h.tools ?? []), ...(h.knowledge_bases ?? []), ...(h.sandboxes ?? [])];
606
- return `${h.name ?? h.harness_slug} (${h.harness_slug})${via.length ? ` through ${list(via, 5)}` : ""}`;
605
+ const via = [...(h.tools ?? []), ...(h.knowledge_bases ?? []), ...(h.skills ?? []), ...(h.guardrails ?? []), ...(h.sandboxes ?? [])];
606
+ const steps = h.nodes?.length ? `; workflow step${h.nodes.length === 1 ? "" : "s"} ${list(h.nodes, 5)}` : "";
607
+ return `${h.name ?? h.harness_slug} (${h.harness_slug})${via.length ? ` through ${list(via, 5)}` : ""}${steps}`;
607
608
  });
609
+ const changed = [
610
+ ["tools", impact.changed_tools],
611
+ ["knowledge bases", impact.changed_knowledge_bases],
612
+ ["skills", impact.changed_skills],
613
+ ["guardrails", impact.changed_guardrails],
614
+ ].filter((entry) => Array.isArray(entry[1]) && entry[1].length > 0);
615
+ if (changed.length)
616
+ lines.push(["changes shared", changed.map(([what, names]) => `${what} ${list(names, 5)}`).join("; ")]);
608
617
  if (active.length)
609
618
  lines.push(["reaches active", active.map((a) => `\n - ${a}`).join("")]);
610
619
  if (impact.sandbox_writers?.length)
@@ -1017,7 +1026,20 @@ function graphDraftTarget(preview, harness) {
1017
1026
  Number.isSafeInteger(p.draft_revision) && p.draft_revision >= 0 &&
1018
1027
  Array.isArray(preview.impact?.active_harnesses));
1019
1028
  }
1020
- function personReason(preview, harness, mode, env, shared = [], sharedReaches = [], live = []) {
1029
+ const UNFOLLOWED_UPDATES = ["skills", "guardrails", "tools", "knowledge_bases", "tool_bindings"];
1030
+ export function unfollowedRows(preview, pkg) {
1031
+ const impact = preview.impact;
1032
+ if (!impact || (Array.isArray(impact.changed_skills) && Array.isArray(impact.changed_guardrails)))
1033
+ return [];
1034
+ const updates = preview.summary?.updates ?? {};
1035
+ const rows = UNFOLLOWED_UPDATES.filter((section) => (updates[section] ?? 0) > 0);
1036
+ if ((preview.summary?.creates?.tool_bindings ?? 0) > 0 && !rows.includes("tool_bindings"))
1037
+ rows.push("tool_bindings");
1038
+ if (Array.isArray(pkg.web_sources) && pkg.web_sources.length)
1039
+ rows.push("web_sources");
1040
+ return rows;
1041
+ }
1042
+ function personReason(preview, harness, mode, env, shared = [], sharedReaches = [], live = [], unfollowed = []) {
1021
1043
  if (shared.length) {
1022
1044
  const reaching = sharedReaches.length ? `, reaching the active solution${sharedReaches.length === 1 ? "" : "s"} ${list(sharedReaches, 5)}` : "";
1023
1045
  return `changes what the whole tenant shares (${list(shared, 5)})${reaching}`;
@@ -1031,6 +1053,11 @@ function personReason(preview, harness, mode, env, shared = [], sharedReaches =
1031
1053
  return `changes ${list(live, 5)}, which visitors of the active solution ${harness.slug} see at once, without a publication`;
1032
1054
  if (preview.impact?.active_harnesses?.length)
1033
1055
  return "reaches an active solution";
1056
+ if (unfollowed.length) {
1057
+ const rows = unfollowed.map((s) => s.replace(/_/g, " "));
1058
+ const named = rows.length > 1 ? `${rows.slice(0, -1).join(", ")} and ${rows.at(-1)}` : rows[0];
1059
+ return `changes ${named} that other solutions may use, and this instance's preview does not say which active solutions that reaches`;
1060
+ }
1034
1061
  if (counts(preview.summary?.deletes) || mode === "replace")
1035
1062
  return "deletes";
1036
1063
  if (env === "prod")
@@ -1269,7 +1296,7 @@ export const apply = {
1269
1296
  if (!preview.preview_id) {
1270
1297
  ctx.warn("This instance's preview returns no preview id, so `apply --confirm` cannot import exactly it; update the instance.");
1271
1298
  }
1272
- const reason = personReason(preview, harness, mode, envFile?.name, sharedImported, reaches, livePointers);
1299
+ const reason = personReason(preview, harness, mode, envFile?.name, sharedImported, reaches, livePointers, unfollowedRows(preview, sent.package));
1273
1300
  if (preview.preview_id) {
1274
1301
  const stored = {
1275
1302
  preview_id: preview.preview_id,
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)}%)`}`;
@@ -277,7 +277,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
277
277
 
278
278
  ---
279
279
 
280
- typebox 1.4.3
280
+ typebox 1.4.7
281
281
  TypeBox
282
282
 
283
283
  The MIT License (MIT)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": 1,
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "entries": {
5
5
  "omp": [
6
6
  "omp-extension.mjs"
@@ -45,8 +45,8 @@
45
45
  },
46
46
  {
47
47
  "path": "omp-extension.mjs",
48
- "size": 1149112,
49
- "sha256": "4c2546c4516e940bbc3118601fc53dd6938fb70329af59ecb8b1044e44b5f0c2"
48
+ "size": 1149595,
49
+ "sha256": "192ad9c0bcc9db892d9af36a315f9ce52cbc3b9e045562c832d1dcacf0e81fce"
50
50
  },
51
51
  {
52
52
  "path": "opencode-server.mjs",
@@ -60,13 +60,13 @@
60
60
  },
61
61
  {
62
62
  "path": "pi-extension.mjs",
63
- "size": 1149020,
64
- "sha256": "dfdc37d005db9c839ab4f5b07e600953cca04c181f0951001540033dfb2592e8"
63
+ "size": 1149503,
64
+ "sha256": "eae7c35025daa4507e26e3eddc9d6b012cee80614f6de82031d9c618fd503096"
65
65
  },
66
66
  {
67
67
  "path": "THIRD-PARTY-NOTICES",
68
68
  "size": 18302,
69
- "sha256": "7ed44d7c1e35f82897bcb4e89d28a07b85a915533074590250afd7f2c3b828c3"
69
+ "sha256": "9406e824f04bc08788f8ede3a4b5e4e0d4ef2e971d3a8147dc0cece1b89ec1ef"
70
70
  },
71
71
  {
72
72
  "path": "TYPEBOX-LICENSE",
@@ -18014,8 +18014,8 @@ function BindArgument(context, state, name, extends_, type) {
18014
18014
  return memory_exports.Assign(context, { [name]: instantiatedArgument });
18015
18015
  }
18016
18016
  function BindArguments(context, state, parameterLeft, parameterRight, arguments_) {
18017
- const instantiatedExtends = InstantiateType(context, state, parameterLeft.extends);
18018
- const instantiatedEquals = InstantiateType(context, state, parameterLeft.equals);
18017
+ const instantiatedExtends = InstantiateType(context, State(state.callstack, []), parameterLeft.extends);
18018
+ const instantiatedEquals = InstantiateType(context, State(state.callstack, []), parameterLeft.equals);
18019
18019
  return guard_exports.ShiftLeft(arguments_, (left, right) => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, left), state, parameterRight, right), () => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
18020
18020
  }
18021
18021
  function BindParameters(context, state, parameters, arguments_) {
@@ -18047,16 +18047,21 @@ function Peek(state) {
18047
18047
  const result = guard_exports.IsGreaterThan(state.callstack.length, 0) ? state.callstack[state.callstack.length - 1] : "";
18048
18048
  return result;
18049
18049
  }
18050
- function IsTailCall(state, name) {
18050
+ function IsTailReturn(state, name) {
18051
18051
  const result = guard_exports.IsEqual(Peek(state), name);
18052
18052
  return result;
18053
18053
  }
18054
+ function IsTailCall(returnType, name) {
18055
+ const result = IsCall(returnType) && IsRef(returnType.target) && guard_exports.IsEqual(name, returnType["target"]["$ref"]);
18056
+ return result;
18057
+ }
18054
18058
  function CallDispatch(context, state, target, parameters, expression, arguments_) {
18055
18059
  InstantiationIncrement();
18056
18060
  try {
18057
18061
  const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
18058
18062
  const returnType = InstantiateType(argumentsContext, State([...state["callstack"], target["$ref"]], state["visited"]), expression);
18059
- return InstantiateType(argumentsContext, State([], []), returnType);
18063
+ const tailArguments = IsCall(returnType) ? InstantiateTypes(argumentsContext, State([], []), returnType.arguments) : [];
18064
+ return IsTailCall(returnType, target["$ref"]) ? CallDispatch(context, State([], []), target, parameters, expression, tailArguments) : InstantiateType(argumentsContext, State([], []), returnType);
18060
18065
  } finally {
18061
18066
  InstantiationDecrement();
18062
18067
  }
@@ -18078,7 +18083,7 @@ function CallInstantiate(context, state, target, arguments_) {
18078
18083
  const resolved = ResolveTarget(context, target, arguments_);
18079
18084
  const name = resolved[0];
18080
18085
  const type = resolved[1];
18081
- const result = IsGeneric(type) ? IsTailCall(state, name) ? CallConstruct(Ref(name), instantiatedArguments) : CallImmediate(context, state, Ref(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
18086
+ const result = IsGeneric(type) ? IsTailReturn(state, name) ? CallConstruct(Ref(name), instantiatedArguments) : CallImmediate(context, state, Ref(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
18082
18087
  return result;
18083
18088
  }
18084
18089
 
@@ -18011,8 +18011,8 @@ function BindArgument(context, state, name, extends_, type) {
18011
18011
  return memory_exports.Assign(context, { [name]: instantiatedArgument });
18012
18012
  }
18013
18013
  function BindArguments(context, state, parameterLeft, parameterRight, arguments_) {
18014
- const instantiatedExtends = InstantiateType(context, state, parameterLeft.extends);
18015
- const instantiatedEquals = InstantiateType(context, state, parameterLeft.equals);
18014
+ const instantiatedExtends = InstantiateType(context, State(state.callstack, []), parameterLeft.extends);
18015
+ const instantiatedEquals = InstantiateType(context, State(state.callstack, []), parameterLeft.equals);
18016
18016
  return guard_exports.ShiftLeft(arguments_, (left, right) => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, left), state, parameterRight, right), () => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
18017
18017
  }
18018
18018
  function BindParameters(context, state, parameters, arguments_) {
@@ -18044,16 +18044,21 @@ function Peek(state) {
18044
18044
  const result = guard_exports.IsGreaterThan(state.callstack.length, 0) ? state.callstack[state.callstack.length - 1] : "";
18045
18045
  return result;
18046
18046
  }
18047
- function IsTailCall(state, name) {
18047
+ function IsTailReturn(state, name) {
18048
18048
  const result = guard_exports.IsEqual(Peek(state), name);
18049
18049
  return result;
18050
18050
  }
18051
+ function IsTailCall(returnType, name) {
18052
+ const result = IsCall(returnType) && IsRef(returnType.target) && guard_exports.IsEqual(name, returnType["target"]["$ref"]);
18053
+ return result;
18054
+ }
18051
18055
  function CallDispatch(context, state, target, parameters, expression, arguments_) {
18052
18056
  InstantiationIncrement();
18053
18057
  try {
18054
18058
  const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
18055
18059
  const returnType = InstantiateType(argumentsContext, State([...state["callstack"], target["$ref"]], state["visited"]), expression);
18056
- return InstantiateType(argumentsContext, State([], []), returnType);
18060
+ const tailArguments = IsCall(returnType) ? InstantiateTypes(argumentsContext, State([], []), returnType.arguments) : [];
18061
+ return IsTailCall(returnType, target["$ref"]) ? CallDispatch(context, State([], []), target, parameters, expression, tailArguments) : InstantiateType(argumentsContext, State([], []), returnType);
18057
18062
  } finally {
18058
18063
  InstantiationDecrement();
18059
18064
  }
@@ -18075,7 +18080,7 @@ function CallInstantiate(context, state, target, arguments_) {
18075
18080
  const resolved = ResolveTarget(context, target, arguments_);
18076
18081
  const name = resolved[0];
18077
18082
  const type = resolved[1];
18078
- const result = IsGeneric(type) ? IsTailCall(state, name) ? CallConstruct(Ref(name), instantiatedArguments) : CallImmediate(context, state, Ref(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
18083
+ const result = IsGeneric(type) ? IsTailReturn(state, name) ? CallConstruct(Ref(name), instantiatedArguments) : CallImmediate(context, state, Ref(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
18079
18084
  return result;
18080
18085
  }
18081
18086
 
@@ -24,6 +24,9 @@ const KB_WITHOUT_SEARCH_CODE = "knowledge_base_without_search_tool";
24
24
  const SEARCH_DOCS = "/docs/reference/builtin-tools#binding-knowledge-bases-to-search_documents";
25
25
  const SEARCH_TOOL = "search_documents";
26
26
  const LIST_TOOL = "list_documents";
27
+ const KB_FILING_CODE = "kb_filing_access_invalid";
28
+ const KB_FILING_DOCS = "/docs/concepts/agent-graph#what-a-solutions-package-may-change";
29
+ const KB_READERS = "kb_readers";
27
30
  const PERSONA_MESSAGE_CODE = "persona_message_empty";
28
31
  const PERSONA_DOCS = "/docs/concepts/personas";
29
32
  const PERSONA_MESSAGES = [
@@ -102,6 +105,15 @@ export const KIT_CODES = [
102
105
  "what it lists) to the tool_assignments of the skill that names the knowledge base, or of the agent. `cavelon docs get reference/builtin-tools` shows the binding.",
103
106
  docs: SEARCH_DOCS,
104
107
  },
108
+ {
109
+ code: KB_FILING_CODE,
110
+ area: "package",
111
+ message: "A knowledge base that accepts email attachments needs at least one default_acl_groups entry, or filing_access " +
112
+ "'kb_readers' so every reader of it may read them; with 'kb_readers' it names no default_acl_groups.",
113
+ hint: "Name the group that reads the filed attachments in default_acl_groups, or set filing_access: kb_readers and leave " +
114
+ "default_acl_groups empty. The import preview blocks the knowledge base until then.",
115
+ docs: KB_FILING_DOCS,
116
+ },
105
117
  {
106
118
  code: ASSERTION_UNCHECKED_CODE,
107
119
  area: "package",
@@ -398,6 +410,7 @@ export function checkPackage(disk, options) {
398
410
  findings.push(...checkEndpointLimits(disk, options.schema));
399
411
  findings.push(...checkBranchConcurrency(disk, options.limits));
400
412
  findings.push(...checkKnowledgeSearch(disk));
413
+ findings.push(...checkFilingAccess(disk, options.schema));
401
414
  findings.push(...checkAttachedDocuments(disk, options.schema));
402
415
  findings.push(...checkUnknownFields(disk, options.schema, findings));
403
416
  findings.push(...checkReferences(disk, options.inventory));
@@ -595,6 +608,42 @@ function checkKnowledgeSearch(disk) {
595
608
  });
596
609
  return findings;
597
610
  }
611
+ function checkFilingAccess(disk, schema) {
612
+ const entry = schemaNode(schema, listItems(schema, schema.properties?.knowledge_bases));
613
+ const fields = asObject(entry?.properties) ?? {};
614
+ if (!["accepts_email_attachments", "filing_access", "default_acl_groups"].every((f) => f in fields))
615
+ return [];
616
+ const findings = [];
617
+ asList(disk.package.knowledge_bases).forEach((kb, i) => {
618
+ const stated = (field) => kb[field] !== undefined && kb[field] !== null;
619
+ const groups = Array.isArray(kb.default_acl_groups) ? kb.default_acl_groups.filter((g) => typeof g === "string") : [];
620
+ const readers = kb.filing_access === KB_READERS;
621
+ const name = typeof kb.name === "string" ? ` "${kb.name}"` : "";
622
+ let problem;
623
+ if (readers && groups.length) {
624
+ problem = {
625
+ pointer: `/knowledge_bases/${i}/default_acl_groups`,
626
+ certain: true,
627
+ message: `The knowledge base${name} lets every reader of it read its filings (filing_access: kb_readers), so it names no default_acl_groups: ` +
628
+ "remove the groups, or set filing_access to default_groups.",
629
+ };
630
+ }
631
+ else if (kb.accepts_email_attachments === true && !readers && !groups.length) {
632
+ const left = ["default_acl_groups", "filing_access"].filter((f) => !stated(f));
633
+ const certain = !left.length;
634
+ problem = {
635
+ pointer: `/knowledge_bases/${i}/accepts_email_attachments`,
636
+ certain,
637
+ message: `The knowledge base${name} accepts email attachments, but no one may read them: name a group in default_acl_groups, ` +
638
+ `or set filing_access: kb_readers so every reader of the knowledge base may.` +
639
+ (certain ? "" : ` The entry leaves ${left.join(" and ")} out: an existing knowledge base keeps ${left.length === 1 ? "its value" : "its values"}, a new one is blocked by the import.`),
640
+ };
641
+ }
642
+ if (problem)
643
+ findings.push({ code: KB_FILING_CODE, severity: problem.certain ? "error" : "warning", ...locate(disk, problem.pointer), message: problem.message });
644
+ });
645
+ return findings;
646
+ }
598
647
  function schemaNode(schema, node) {
599
648
  let at = asObject(node);
600
649
  for (let hops = 0; at && typeof at.$ref === "string" && hops < 10; hops++) {
@@ -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
@@ -340,6 +342,13 @@ personal access token holding `playground.use` reaches the draft; without
340
342
  nothing. Without such a tool the
341
343
  agent answers from memory; `cavelon validate` warns
342
344
  (`knowledge_base_without_search_tool`).
345
+ - **A knowledge base that accepts email attachments names who reads them.**
346
+ With `accepts_email_attachments: true`, give it at least one
347
+ `default_acl_groups` entry, or `filing_access: kb_readers` (every reader of
348
+ the knowledge base may read them); `kb_readers` names no groups. Pick the
349
+ group with the person: it decides who reads a mailbox's filings. The import
350
+ preview blocks it otherwise, and `cavelon validate` reports it first
351
+ (`kb_filing_access_invalid`).
343
352
  - **The model comes from the tenant.** Set an agent's `llm_model` and
344
353
  `llm_provider` to a row of `cavelon models list` (MODEL_ID, PROVIDER); the
345
354
  models differ per instance and tenant, and the preview blocks one the tenant
@@ -375,6 +375,9 @@ when:
375
375
 
376
376
  - the preview lists an active solution under "reaches active", or the target
377
377
  solution is active without explicit isolated-draft metadata;
378
+ - the preview says it changes skills, guardrails, tools, knowledge bases,
379
+ tool bindings or web sources "that other solutions may use": an older
380
+ instance's preview does not say which active solutions they reach;
378
381
  - the environment is `prod` (`--env prod`), or the preview deletes anything
379
382
  (`--mode replace`);
380
383
  - the preview changes tenant-wide sections (`tenant-wide: … change for every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
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",
@@ -46,7 +46,7 @@
46
46
  "@types/node": "^20.19.0",
47
47
  "esbuild": "0.28.2",
48
48
  "eslint": "^10.12.0",
49
- "typebox": "1.4.3",
49
+ "typebox": "1.4.7",
50
50
  "typescript": "~6.0.3",
51
51
  "typescript-eslint": "^8.71.0",
52
52
  "vitest": "^4.0.0",