@capybara-hq/kernel 0.1.0-rc.77 → 0.1.0-rc.79

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.
Files changed (247) hide show
  1. package/bootstrap.json +6 -6
  2. package/dist/admin/outbox-dead.service.js +4 -1
  3. package/dist/agents/admin-agents.js +2 -0
  4. package/dist/agents/agent-lookup.js +4 -0
  5. package/dist/agents/agent-profile.service.js +3 -0
  6. package/dist/agents/agents.service.js +7 -0
  7. package/dist/agents/org-templates.js +1 -0
  8. package/dist/agents/pending-connector-requests.js +6 -0
  9. package/dist/agents/pending-connectors.service.js +2 -0
  10. package/dist/agents/readiness.service.d.ts +9 -3
  11. package/dist/agents/readiness.service.js +3 -3
  12. package/dist/agents/templates.js +1 -0
  13. package/dist/background/finish.js +3 -0
  14. package/dist/background/stop.js +2 -0
  15. package/dist/background/store.js +44 -0
  16. package/dist/background/tasks.service.js +3 -2
  17. package/dist/background/wake-rules.js +1 -0
  18. package/dist/catalog/admin-catalog.controller.d.ts +6 -0
  19. package/dist/catalog/admin-catalog.controller.js +13 -0
  20. package/dist/catalog/catalog-content.d.ts +9 -0
  21. package/dist/catalog/catalog-content.js +3 -1
  22. package/dist/catalog/catalog-items.js +4 -0
  23. package/dist/catalog/catalog-scope.service.js +4 -1
  24. package/dist/catalog/component-promotion.js +2 -0
  25. package/dist/catalog/component-scope.controller.d.ts +9 -15
  26. package/dist/catalog/component-scope.controller.js +14 -9
  27. package/dist/catalog/component-scope.service.js +5 -0
  28. package/dist/catalog/component-state.d.ts +4 -1
  29. package/dist/catalog/component-state.js +4 -2
  30. package/dist/catalog/marketplace-fetch.d.ts +1 -1
  31. package/dist/catalog/marketplace-fetch.js +1 -1
  32. package/dist/catalog/marketplaces.service.d.ts +6 -1
  33. package/dist/catalog/marketplaces.service.js +8 -3
  34. package/dist/catalog/org-catalog.controller.d.ts +9 -0
  35. package/dist/catalog/org-catalog.controller.js +18 -0
  36. package/dist/catalog/org-catalog.schemas.d.ts +2 -4
  37. package/dist/catalog/org-catalog.schemas.js +2 -3
  38. package/dist/catalog/org-catalog.service.d.ts +10 -1
  39. package/dist/catalog/org-catalog.service.js +34 -23
  40. package/dist/catalog/org-extension-switch.d.ts +3 -10
  41. package/dist/catalog/org-extension-switch.js +14 -60
  42. package/dist/catalog/org-extension.controller.d.ts +6 -7
  43. package/dist/catalog/org-extension.controller.js +4 -4
  44. package/dist/catalog/org-extension.schemas.d.ts +1 -2
  45. package/dist/catalog/org-extension.schemas.js +1 -3
  46. package/dist/catalog/owned-items.js +10 -1
  47. package/dist/catalog/ownership.js +2 -0
  48. package/dist/catalog/plugin-import.d.ts +3 -0
  49. package/dist/catalog/plugin-import.js +10 -1
  50. package/dist/catalog/plugin-install.d.ts +1 -4
  51. package/dist/catalog/plugin-install.js +11 -12
  52. package/dist/catalog/plugin-upgrade.js +4 -1
  53. package/dist/catalog/request-rules.js +6 -0
  54. package/dist/catalog/requests.service.js +4 -0
  55. package/dist/catalog/scope-orgs.js +1 -0
  56. package/dist/catalog/scope-sync.d.ts +8 -5
  57. package/dist/catalog/scope-sync.js +21 -23
  58. package/dist/catalog/template-description.d.ts +17 -0
  59. package/dist/catalog/template-description.js +18 -0
  60. package/dist/catalog/unshare.js +3 -0
  61. package/dist/channels/connections.service.js +1 -0
  62. package/dist/channels/inbound.js +1 -0
  63. package/dist/channels/jobs.js +1 -0
  64. package/dist/channels/outbound.js +6 -0
  65. package/dist/channels/supervisor.js +1 -0
  66. package/dist/channels/threads.js +1 -0
  67. package/dist/client/client-reports.service.js +1 -0
  68. package/dist/config/fields.js +20 -4
  69. package/dist/config/schema.d.ts +1 -1
  70. package/dist/config/schema.js +13 -13
  71. package/dist/conversations/access.js +1 -0
  72. package/dist/conversations/attachments.service.js +16 -4
  73. package/dist/conversations/conversations.service.js +17 -3
  74. package/dist/conversations/event-log.js +2 -0
  75. package/dist/conversations/events.d.ts +1 -0
  76. package/dist/conversations/events.js +3 -1
  77. package/dist/conversations/files.js +3 -2
  78. package/dist/conversations/permission-profiles.service.js +1 -0
  79. package/dist/conversations/prompt-suggestions.js +2 -0
  80. package/dist/conversations/queue.js +8 -0
  81. package/dist/conversations/queue.service.js +6 -2
  82. package/dist/conversations/source.js +2 -0
  83. package/dist/conversations/titles.js +10 -2
  84. package/dist/conversations/tree.js +6 -0
  85. package/dist/db/kernel-schema.d.ts +5 -1
  86. package/dist/devices/conversation-devices.js +3 -0
  87. package/dist/devices/device-projects.service.js +2 -0
  88. package/dist/devices/devices.service.js +5 -0
  89. package/dist/devices/legacy-cleanup.job.js +5 -2
  90. package/dist/dial-in/handlers.js +2 -0
  91. package/dist/dial-in/machines.js +11 -2
  92. package/dist/dial-in/targets.d.ts +0 -2
  93. package/dist/dial-in/targets.js +0 -10
  94. package/dist/errors.d.ts +0 -1
  95. package/dist/errors.js +0 -1
  96. package/dist/evals/budget.js +14 -1
  97. package/dist/evals/run-replay.js +4 -0
  98. package/dist/evals/runs.service.js +13 -7
  99. package/dist/evals/sets.service.js +23 -8
  100. package/dist/evals/trajectory.service.d.ts +1 -1
  101. package/dist/evals/trajectory.service.js +1 -0
  102. package/dist/evals/worker.js +5 -1
  103. package/dist/extensions/admin-ops.js +1 -0
  104. package/dist/extensions/admin-view.js +3 -1
  105. package/dist/extensions/bootstrap-packages.d.ts +12 -1
  106. package/dist/extensions/bootstrap-packages.js +49 -9
  107. package/dist/extensions/bootstrap.d.ts +17 -2
  108. package/dist/extensions/bootstrap.js +41 -9
  109. package/dist/extensions/config-json-schema.d.ts +2 -2
  110. package/dist/extensions/config-json-schema.js +1 -3
  111. package/dist/extensions/deployment-config.d.ts +5 -3
  112. package/dist/extensions/deployment-config.js +3 -3
  113. package/dist/extensions/effective-config.d.ts +8 -7
  114. package/dist/extensions/effective-config.js +8 -7
  115. package/dist/extensions/enabled.js +1 -0
  116. package/dist/extensions/host.d.ts +4 -3
  117. package/dist/extensions/host.js +11 -12
  118. package/dist/extensions/instance.d.ts +1 -1
  119. package/dist/extensions/instance.js +17 -2
  120. package/dist/extensions/org-config.d.ts +35 -97
  121. package/dist/extensions/org-config.js +48 -315
  122. package/dist/extensions/org-levels.d.ts +22 -9
  123. package/dist/extensions/org-levels.js +100 -20
  124. package/dist/extensions/org-overrides.d.ts +14 -15
  125. package/dist/extensions/org-overrides.js +20 -20
  126. package/dist/extensions/package.js +1 -1
  127. package/dist/extensions/permission-set.d.ts +1 -3
  128. package/dist/extensions/permission-set.js +3 -7
  129. package/dist/extensions/permission-view.d.ts +3 -1
  130. package/dist/extensions/permission-view.js +5 -4
  131. package/dist/extensions/plugin-icons.d.ts +80 -1
  132. package/dist/extensions/plugin-icons.js +211 -2
  133. package/dist/extensions/point-defaults.d.ts +17 -18
  134. package/dist/extensions/point-defaults.js +25 -28
  135. package/dist/git/gateway.js +1 -1
  136. package/dist/git/identity.d.ts +1 -1
  137. package/dist/git/identity.js +2 -2
  138. package/dist/identity/accounts.js +6 -0
  139. package/dist/identity/api-tokens.js +8 -0
  140. package/dist/infra/outbox/outbox.dispatcher.js +4 -1
  141. package/dist/infra/outbox/outbox.service.js +2 -0
  142. package/dist/net/public-address.d.ts +3 -3
  143. package/dist/net/public-address.js +3 -3
  144. package/dist/orgs/directory-sync.d.ts +9 -6
  145. package/dist/orgs/directory-sync.js +15 -12
  146. package/dist/orgs/invitations.service.js +2 -0
  147. package/dist/orgs/members.service.js +2 -0
  148. package/dist/orgs/offboarding.js +2 -0
  149. package/dist/packages/npm.d.ts +10 -2
  150. package/dist/packages/npm.js +38 -6
  151. package/dist/platform/exclusions.js +20 -0
  152. package/dist/platform/ops/admin-items.ops.js +1 -0
  153. package/dist/platform/ops/agents.ops.js +1 -0
  154. package/dist/platform/ops/connectors.ops.js +7 -1
  155. package/dist/platform/ops/extensions.ops.d.ts +6 -8
  156. package/dist/platform/ops/extensions.ops.js +18 -97
  157. package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
  158. package/dist/platform/ops/org-plugins.ops.js +14 -65
  159. package/dist/platform/ops/outbox.ops.js +1 -0
  160. package/dist/platform/ops/person-inputs.d.ts +0 -4
  161. package/dist/platform/ops/person-inputs.js +0 -8
  162. package/dist/platform/ops/plugins.ops.d.ts +4 -1
  163. package/dist/platform/ops/plugins.ops.js +27 -34
  164. package/dist/platform/person-fields.d.ts +1 -1
  165. package/dist/platform/person-fields.js +1 -1
  166. package/dist/platform/sealed-reveals.js +2 -0
  167. package/dist/push/recipients.js +9 -2
  168. package/dist/runtime/permission-context.service.js +1 -0
  169. package/dist/runtime/plugin-context.service.js +1 -0
  170. package/dist/runtime/project/knowledge.service.js +1 -0
  171. package/dist/runtime/run-context.service.js +1 -0
  172. package/dist/runtime/run-deletion.js +4 -0
  173. package/dist/runtime/run-execution.js +2 -0
  174. package/dist/runtime/run-finish.js +3 -0
  175. package/dist/runtime/run-jobs.js +3 -0
  176. package/dist/runtime/run-orphan-check.job.js +7 -0
  177. package/dist/runtime/run-queue.js +21 -2
  178. package/dist/runtime/run-worker.js +5 -0
  179. package/dist/runtime/step-log.js +1 -0
  180. package/dist/runtime/subagents/child.js +2 -0
  181. package/dist/runtime/subagents/deliveries.js +3 -0
  182. package/dist/runtime/subagents/dispatch.js +5 -1
  183. package/dist/runtime/subagents/messages.js +2 -0
  184. package/dist/runtime/subagents/org-agents.d.ts +1 -1
  185. package/dist/runtime/subagents/org-agents.js +2 -1
  186. package/dist/runtime/usage-report-jobs.js +1 -0
  187. package/dist/runtime/usage-report.js +3 -0
  188. package/dist/runtime/waits.js +5 -0
  189. package/dist/sandbox/cloud-permission-snapshot.js +9 -3
  190. package/dist/sandbox/device-reports.js +3 -0
  191. package/dist/sandbox/legacy-retirement.js +5 -1
  192. package/dist/sandbox/managed-device-context.js +1 -0
  193. package/dist/sandbox/modes.d.ts +5 -2
  194. package/dist/sandbox/modes.js +8 -4
  195. package/dist/sandbox/network-grants.js +2 -0
  196. package/dist/sandbox/operation-intents.js +58 -0
  197. package/dist/sandbox/operation-reconcile.job.js +2 -0
  198. package/dist/sandbox/permission-authority-lock.js +12 -6
  199. package/dist/sandbox/permission-call-grants.js +6 -0
  200. package/dist/sandbox/permission-ceiling-writes.js +5 -0
  201. package/dist/sandbox/permission-config-publication.js +5 -0
  202. package/dist/sandbox/permission-instance-writes.js +4 -0
  203. package/dist/sandbox/permission-runtime-reports.js +10 -1
  204. package/dist/sandbox/permission-transitions.js +3 -0
  205. package/dist/sandbox/review/review.service.js +8 -5
  206. package/dist/sandbox/sandbox.service.d.ts +14 -0
  207. package/dist/sandbox/sandbox.service.js +195 -29
  208. package/dist/sandbox/unreachable.js +4 -1
  209. package/dist/schedules/fire.js +9 -3
  210. package/dist/schedules/pause.js +2 -0
  211. package/dist/schedules/run-tracker.js +16 -1
  212. package/dist/schedules/scheduled-tasks.service.js +4 -2
  213. package/dist/schedules/store.js +8 -0
  214. package/dist/schedules/unattended.js +4 -0
  215. package/dist/setup/setup-checks.service.d.ts +1 -10
  216. package/dist/setup/setup-checks.service.js +19 -29
  217. package/dist/shares/share-open.service.js +1 -0
  218. package/dist/shares/shares.service.js +2 -0
  219. package/dist/skills/agent-skills.service.d.ts +1 -1
  220. package/dist/skills/agent-skills.service.js +13 -2
  221. package/dist/skills/catalog.js +3 -0
  222. package/dist/skills/changes.service.js +10 -2
  223. package/dist/skills/conversation-catalog.js +1 -0
  224. package/dist/skills/skills.service.js +4 -0
  225. package/dist/tools/approvals.service.js +40 -0
  226. package/dist/tools/builtins/schedules.js +11 -6
  227. package/dist/tools/builtins/web/fetch.js +1 -1
  228. package/dist/tools/builtins/web/search.js +1 -1
  229. package/dist/tools/connector-account-policies.js +3 -0
  230. package/dist/tools/connectors.controller.d.ts +37 -9
  231. package/dist/tools/connectors.controller.js +47 -12
  232. package/dist/tools/connectors.schemas.d.ts +4 -0
  233. package/dist/tools/connectors.schemas.js +13 -1
  234. package/dist/tools/connectors.service.d.ts +17 -0
  235. package/dist/tools/connectors.service.js +36 -2
  236. package/dist/tools/drift.js +5 -0
  237. package/dist/tools/git-push-policy.js +3 -0
  238. package/dist/tools/oauth/discovery.d.ts +2 -2
  239. package/dist/tools/oauth/discovery.js +2 -2
  240. package/dist/tools/oauth/flow.js +1 -0
  241. package/dist/tools/outputs.js +2 -0
  242. package/dist/tools/permission-approval-jobs.js +3 -0
  243. package/dist/tools/pipeline.js +2 -0
  244. package/dist/tools/policy.js +3 -0
  245. package/dist/tools/questions.service.js +13 -0
  246. package/package.json +3 -3
  247. package/src/migrations/0181_connector_description.sql +3 -0
@@ -223,6 +223,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
223
223
  .innerJoin("agent_versions as v", (j) => j.onRef("v.agent_id", "=", "a.id").onRef("v.version", "=", "a.current_version"))
224
224
  .select("v.definition")
225
225
  .where("a.id", "=", agentId)
226
+ .where("a.org_id", "=", orgId)
226
227
  .executeTakeFirst();
227
228
  model = current?.definition?.model;
228
229
  }
@@ -256,6 +257,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
256
257
  : sql `null`).as("subagent_source"),
257
258
  ])
258
259
  .where("set_id", "=", setId)
260
+ .where("org_id", "=", orgId)
259
261
  .orderBy("created_at")
260
262
  .orderBy("id")
261
263
  .execute();
@@ -381,11 +383,12 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
381
383
  * 集合的 agent 已删除 → `agent.not_found`(删除 agent 会取消它的运行;之后再估算 / 启动只会建出全部跳过的运行)。
382
384
  * 在事务里调用时 FOR SHARE,与删除 agent 互斥。
383
385
  */
384
- async assertAgentLive(agentId, forShare = false) {
386
+ async assertAgentLive(orgId, agentId, forShare = false) {
385
387
  let q = this.d.db
386
388
  .selectFrom("agents")
387
389
  .select("id")
388
390
  .where("id", "=", agentId)
391
+ .where("org_id", "=", orgId)
389
392
  .where("deleted_at", "is", null);
390
393
  if (forShare)
391
394
  q = q.forShare();
@@ -395,7 +398,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
395
398
  }
396
399
  async estimate(orgId, setId, input) {
397
400
  const set = await this.liveSet(orgId, setId);
398
- await this.assertAgentLive(set.agent_id);
401
+ await this.assertAgentLive(orgId, set.agent_id);
399
402
  const caps = this.tokenCaps(input.tokenCap);
400
403
  const versionDef = await this.checkCandidate(orgId, set.agent_id, input.candidate);
401
404
  const plans = await this.plan(orgId, setId, input.mode, input.candidate, versionDef);
@@ -421,7 +424,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
421
424
  */
422
425
  async start(orgId, actor, setId, input, actorTokenId, auditDetail) {
423
426
  const set = await this.liveSet(orgId, setId);
424
- await this.assertAgentLive(set.agent_id);
427
+ await this.assertAgentLive(orgId, set.agent_id);
425
428
  const tokenCap = this.tokenCaps(input.tokenCap).effectiveTokenCap;
426
429
  const versionDef = await this.checkCandidate(orgId, set.agent_id, input.candidate);
427
430
  if (input.judge)
@@ -454,11 +457,12 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
454
457
  .executeTakeFirst();
455
458
  if (!locked)
456
459
  throw setNotFound();
457
- await this.assertAgentLive(agentId, true);
460
+ await this.assertAgentLive(orgId, agentId, true);
458
461
  const alive = new Set((await db
459
462
  .selectFrom("eval_cases")
460
463
  .select("id")
461
464
  .where("set_id", "=", setId)
465
+ .where("org_id", "=", orgId)
462
466
  .where("id", "in", planned.map((p) => p.caseId))
463
467
  .execute()).map((r) => r.id));
464
468
  const plans = planned.filter((p) => alive.has(p.caseId));
@@ -521,7 +525,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
521
525
  return { runId: run.id };
522
526
  }
523
527
  /** 各运行的汇总(只算已结束的)。 */
524
- async summaries(rows) {
528
+ async summaries(orgId, rows) {
525
529
  const finished = rows
526
530
  .filter((r) => !ACTIVE_EVAL_STATUSES.includes(r.status))
527
531
  .map((r) => r.id);
@@ -549,6 +553,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
549
553
  FILTER (WHERE label IS NOT NULL)`.as("human_rate"),
550
554
  ])
551
555
  .where("run_id", "in", finished)
556
+ .where("org_id", "=", orgId)
552
557
  .groupBy("run_id")
553
558
  .execute();
554
559
  for (const id of finished) {
@@ -600,7 +605,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
600
605
  .executeTakeFirst();
601
606
  if (!r)
602
607
  throw runNotFound();
603
- const sums = await this.summaries([r]);
608
+ const sums = await this.summaries(orgId, [r]);
604
609
  return EvalRunsService_1.toView(r, sums.get(r.id) ?? null);
605
610
  }
606
611
  async listForSet(orgId, setId) {
@@ -613,7 +618,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
613
618
  .orderBy("created_at", "desc")
614
619
  .orderBy("id", "desc")
615
620
  .execute();
616
- const sums = await this.summaries(rows);
621
+ const sums = await this.summaries(orgId, rows);
617
622
  return rows.map((r) => EvalRunsService_1.toView(r, sums.get(r.id) ?? null));
618
623
  }
619
624
  /**
@@ -793,6 +798,7 @@ let EvalRunsService = EvalRunsService_1 = class EvalRunsService {
793
798
  .innerJoin("eval_sets as es", "es.id", "er.set_id")
794
799
  .select("er.id")
795
800
  .whereRef("er.id", "=", "eval_results.run_id")
801
+ .where("er.org_id", "=", orgId)
796
802
  .where("es.deleted_at", "is", null)))
797
803
  .returningAll()
798
804
  .executeTakeFirst();
@@ -134,6 +134,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
134
134
  .selectFrom("eval_cases as c")
135
135
  .select(sql `count(*)`.as("n"))
136
136
  .whereRef("c.set_id", "=", "s.id")
137
+ .where("c.org_id", "=", orgId)
137
138
  .as("case_count"),
138
139
  ])
139
140
  .where("s.org_id", "=", orgId)
@@ -269,7 +270,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
269
270
  .executeTakeFirst();
270
271
  if (Number(r.numUpdatedRows) === 0)
271
272
  throw setNotFound();
272
- await stopAndPurgeRuns(this.db, this.budget, setId);
273
+ await stopAndPurgeRuns(this.db, this.budget, orgId, setId);
273
274
  await audit(this.db, {
274
275
  actorAccountId: actor,
275
276
  ...(actorTokenId !== undefined && { actorTokenId }),
@@ -292,7 +293,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
292
293
  .executeTakeFirst();
293
294
  if (!set)
294
295
  throw setNotFound();
295
- if ((await this.caseCount(this.db, setId)) >= max)
296
+ if ((await this.caseCount(this.db, orgId, setId)) >= max)
296
297
  return "full";
297
298
  const row = await this.db
298
299
  .insertInto("eval_cases")
@@ -382,11 +383,12 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
382
383
  throw setNotFound();
383
384
  return set;
384
385
  }
385
- async caseCount(db, setId) {
386
+ async caseCount(db, orgId, setId) {
386
387
  const r = await db
387
388
  .selectFrom("eval_cases")
388
389
  .select(sql `count(*)`.as("n"))
389
390
  .where("set_id", "=", setId)
391
+ .where("org_id", "=", orgId)
390
392
  .executeTakeFirstOrThrow();
391
393
  return Number(r.n);
392
394
  }
@@ -446,6 +448,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
446
448
  .selectFrom("eval_cases")
447
449
  .select("id")
448
450
  .where("set_id", "=", setId)
451
+ .where("org_id", "=", orgId)
449
452
  .where("source_run_id", "=", input.runId)
450
453
  .executeTakeFirst();
451
454
  if (exists)
@@ -454,7 +457,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
454
457
  throw new ApiError("eval.run_not_finished", "The run has not finished yet");
455
458
  }
456
459
  const { maxCasesPerSet } = this.config.get().evals;
457
- if ((await this.caseCount(this.db, setId)) >= maxCasesPerSet)
460
+ if ((await this.caseCount(this.db, orgId, setId)) >= maxCasesPerSet)
458
461
  throw tooMany(maxCasesPerSet);
459
462
  }
460
463
  /**
@@ -487,7 +490,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
487
490
  async sample(orgId, actor, setId, input, actorTokenId, auditDetail) {
488
491
  const set = await this.liveSet(orgId, setId);
489
492
  const { maxCasesPerSet, maxCaseBytes } = this.config.get().evals;
490
- const room = maxCasesPerSet - (await this.caseCount(this.db, setId));
493
+ const room = maxCasesPerSet - (await this.caseCount(this.db, orgId, setId));
491
494
  if (room <= 0)
492
495
  throw tooMany(maxCasesPerSet);
493
496
  let q = this.db
@@ -504,6 +507,7 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
504
507
  .selectFrom("eval_cases as e")
505
508
  .select(sql `1`.as("one"))
506
509
  .where("e.set_id", "=", setId)
510
+ .where("e.org_id", "=", orgId)
507
511
  .whereRef("e.source_run_id", "=", "r.id"))))
508
512
  .orderBy(sql `random()`)
509
513
  .limit(Math.min(input.count, room));
@@ -623,21 +627,27 @@ export { EvalSetsService };
623
627
  * 与回放写种子互斥:种子事务对运行行加共享锁并复核仍在执行(见 `replayRun`),这里的 UPDATE 持行锁,
624
628
  * 先提交的一方胜出,不会在删除之后再长出新的评测对话。
625
629
  */
626
- async function stopAndPurgeRuns(db, budget, setId) {
630
+ async function stopAndPurgeRuns(db, budget, orgId, setId) {
627
631
  const runs = await db
628
632
  .updateTable("eval_runs")
629
633
  .set({ status: "cancelled", finished_at: sql `now()` })
630
634
  .where("set_id", "=", setId)
635
+ .where("org_id", "=", orgId)
631
636
  .where("status", "in", ["queued", "running"])
632
637
  .returning("id")
633
638
  .execute();
634
639
  for (const r of runs) {
635
640
  await budget.skipRun(r.id);
636
641
  }
637
- const all = db.selectFrom("eval_runs").select("id").where("set_id", "=", setId);
642
+ const all = db
643
+ .selectFrom("eval_runs")
644
+ .select("id")
645
+ .where("set_id", "=", setId)
646
+ .where("org_id", "=", orgId);
638
647
  const convs = db
639
648
  .selectFrom("conversations")
640
649
  .select("id")
650
+ .where("org_id", "=", orgId)
641
651
  .where("kind", "=", "eval")
642
652
  .where("eval_run_id", "in", all);
643
653
  const threads = db.selectFrom("runs").select("id").where("conversation_id", "in", convs);
@@ -645,9 +655,14 @@ async function stopAndPurgeRuns(db, budget, setId) {
645
655
  await db.deleteFrom("lg_checkpoints").where("thread_id", "in", threads).execute();
646
656
  await db
647
657
  .deleteFrom("conversations")
658
+ .where("org_id", "=", orgId)
648
659
  .where("kind", "=", "eval")
649
660
  .where("eval_run_id", "in", all)
650
661
  .execute();
651
662
  // 用例快照是复制来的对话内容:硬删(结果随之级联删除),与单个移除用例一致
652
- await db.deleteFrom("eval_cases").where("set_id", "=", setId).execute();
663
+ await db
664
+ .deleteFrom("eval_cases")
665
+ .where("set_id", "=", setId)
666
+ .where("org_id", "=", orgId)
667
+ .execute();
653
668
  }
@@ -15,7 +15,7 @@ export interface TrajectoryListItem {
15
15
  updatedAt: string;
16
16
  lastRun: {
17
17
  runId: string;
18
- status: string;
18
+ status: RunStatus;
19
19
  startedAt: string | null;
20
20
  } | null;
21
21
  }
@@ -162,6 +162,7 @@ let TrajectoryService = TrajectoryService_1 = class TrajectoryService {
162
162
  ? null
163
163
  : {
164
164
  runId: run.id,
165
+ // `runs.status` holds only these (the column's check constraint)
165
166
  status: run.status,
166
167
  startedAt: run.started_at === null ? null : run.started_at.toISOString(),
167
168
  },
@@ -869,7 +869,11 @@ __decorate([
869
869
  Transactional({ propagation: "requires_new" })
870
870
  ], EvalWorker.prototype, "writeRunResultIn", null);
871
871
  EvalWorker = __decorate([
872
- Injectable(),
872
+ Injectable()
873
+ // org-filter: queue worker of cap-kernel-evals: every id it uses is the kernel-written job payload
874
+ // (runId, caseId of one run in one org, enqueued by EvalRunsService.start) or a result row of that
875
+ // run it claimed; no caller input reaches these queries
876
+ ,
873
877
  __param(0, Inject(KernelDb)),
874
878
  __param(1, Inject(EVAL_QUOTA)),
875
879
  __param(2, Inject(KernelConfigService)),
@@ -563,6 +563,7 @@ async function hasRetainedData(db, name) {
563
563
  const schema = await sql `SELECT 1 AS x FROM pg_namespace WHERE nspname = ${pluginSchemaName(name)}`.execute(db);
564
564
  if (schema.rows.length > 0)
565
565
  return true;
566
+ // org-filter: whether any org kept config for the plugin name (a deployment-wide existence check)
566
567
  const hit = await db
567
568
  .selectFrom("extension_permission_snapshots")
568
569
  .select(sql `1`.as("x"))
@@ -44,7 +44,7 @@ const CLIENT_REPORTS_SHOWN = 50;
44
44
  /** 空权限集合(包读不到的降级项)。 */
45
45
  const EMPTY_SET = buildPermissionSet({
46
46
  provides: [],
47
- config: { deployment: [], org: [] },
47
+ config: { deployment: [] },
48
48
  tables: [],
49
49
  });
50
50
  /**
@@ -555,6 +555,7 @@ let ExtensionAdmin = class ExtensionAdmin {
555
555
  const built = [...clients].map(([plugin, c]) => ({ plugin, build: c.build }));
556
556
  if (built.length === 0)
557
557
  return { clients, reports };
558
+ // org-filter: super admin's extension view (ExtensionAdmin): client reports of every org
558
559
  const ranked = this.db
559
560
  .selectFrom("extension_client_reports")
560
561
  .selectAll()
@@ -571,6 +572,7 @@ let ExtensionAdmin = class ExtensionAdmin {
571
572
  list.push({
572
573
  orgId: r.org_id,
573
574
  contribution: r.contribution,
575
+ // written only from a validated report (`ReportBody.kind`)
574
576
  kind: r.kind,
575
577
  count: r.count,
576
578
  firstAt: r.first_at.toISOString(),
@@ -10,6 +10,11 @@ import type { BootstrapGitRunEntry, MergedBootstrapEntry, MergedBootstrapManifes
10
10
  */
11
11
  /** The sha512 integrity (`sha512-<base64>`) of a package's bytes. */
12
12
  export declare const integrityOf: (bytes: Uint8Array) => string;
13
+ /**
14
+ * The waits before the second, third and fourth attempt of an npm download that failed
15
+ * transiently ({@link NpmFetchError.transient}): four attempts in about 8 s per package.
16
+ */
17
+ export declare const BOOTSTRAP_DOWNLOAD_RETRY_DELAYS_MS: readonly number[];
13
18
  /** What {@link resolveBootstrapPackages} needs from the kernel config. */
14
19
  export interface BootstrapResolveOptions {
15
20
  /**
@@ -22,6 +27,11 @@ export interface BootstrapResolveOptions {
22
27
  log?: Pick<Logger, "warn">;
23
28
  /** The npm download (default {@link fetchNpmPackage}; tests replace it). */
24
29
  fetch?: typeof fetchNpmPackage;
30
+ /**
31
+ * The waits between attempts of an npm download that failed transiently (default
32
+ * {@link BOOTSTRAP_DOWNLOAD_RETRY_DELAYS_MS}; one more attempt than entries). Tests shorten them.
33
+ */
34
+ retryDelaysMs?: readonly number[];
25
35
  /**
26
36
  * Entries whose package failing to be obtained is that entry's failure only: the error goes into
27
37
  * `failed` (by entry name) and the other entries are still obtained. Every other entry's failure
@@ -49,7 +59,8 @@ export declare function bootstrapGitMarketplace(manifest: Pick<MergedBootstrapMa
49
59
  /**
50
60
  * Obtains every entry's tgz, checked against its pinned sha512: from the offline directory when a
51
61
  * file there has that sha512, else (a `source: "npm"` entry) downloaded from the npm registry and
52
- * verified against the pin (the packument's `dist.integrity` is not consulted), else (a
62
+ * verified against the pin (the packument's `dist.integrity` is not consulted; a transient failure
63
+ * is retried after each of `retryDelaysMs`; a 404, a refused connection or a mismatch is not), else (a
53
64
  * `source: "git"` entry) its marketplace's tree at the pinned commit, the files under `path`
54
65
  * re-rooted and packed with `packPackageTgz` (the pin is defined on that pack), refused unless the
55
66
  * pack's sha512 is the pin: nothing of an unverified tree is read, translated or imported. The
@@ -1,6 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { readdir, readFile, stat } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
+ import { setTimeout as sleep } from "node:timers/promises";
4
5
  import { PLUGIN_MANIFEST_FILE, parsePluginManifest, } from "@capybara-hq/plugin-sdk";
5
6
  import { isClaudePluginTree, translateClaudePlugin } from "../catalog/claude/translate.js";
6
7
  import { GitSourceError, normalGitPath, readGitTreeAndOids } from "../catalog/git-source.js";
@@ -17,6 +18,11 @@ import { packPackageTgz } from "../packages/tgz.js";
17
18
  */
18
19
  /** The sha512 integrity (`sha512-<base64>`) of a package's bytes. */
19
20
  export const integrityOf = (bytes) => `sha512-${createHash("sha512").update(bytes).digest("base64")}`;
21
+ /**
22
+ * The waits before the second, third and fourth attempt of an npm download that failed
23
+ * transiently ({@link NpmFetchError.transient}): four attempts in about 8 s per package.
24
+ */
25
+ export const BOOTSTRAP_DOWNLOAD_RETRY_DELAYS_MS = [500, 2_000, 5_000];
20
26
  /**
21
27
  * The marketplace a git entry names, its URL expanded as the managed row's (`config:<name>`) is and
22
28
  * checked as an admin-added one is (`bootstrap.extra_invalid` otherwise).
@@ -37,7 +43,8 @@ export function bootstrapGitMarketplace(manifest, e, config) {
37
43
  /**
38
44
  * Obtains every entry's tgz, checked against its pinned sha512: from the offline directory when a
39
45
  * file there has that sha512, else (a `source: "npm"` entry) downloaded from the npm registry and
40
- * verified against the pin (the packument's `dist.integrity` is not consulted), else (a
46
+ * verified against the pin (the packument's `dist.integrity` is not consulted; a transient failure
47
+ * is retried after each of `retryDelaysMs`; a 404, a refused connection or a mismatch is not), else (a
41
48
  * `source: "git"` entry) its marketplace's tree at the pinned commit, the files under `path`
42
49
  * re-rooted and packed with `packPackageTgz` (the pin is defined on that pack), refused unless the
43
50
  * pack's sha512 is the pin: nothing of an unverified tree is read, translated or imported. The
@@ -78,14 +85,37 @@ export async function resolveBootstrapPackages(manifest, o) {
78
85
  }
79
86
  const registry = registryOrigin(npmRegistry);
80
87
  const offlineHint = `to install offline, put the package tgz (npm pack ${e.npm}@${e.version}, any file name) in ${where}`;
88
+ const delays = o.retryDelaysMs ?? BOOTSTRAP_DOWNLOAD_RETRY_DELAYS_MS;
89
+ let attempts = 0;
81
90
  try {
82
- const r = await fetchPackage({
83
- registry: npmRegistry,
84
- ...(npmToken !== undefined && { token: npmToken }),
85
- maxBytes,
86
- net: marketplaceNetPolicy(o.config),
87
- }, e.npm, e.version, signal, { expectedIntegrity: e.integrity });
88
- return r.bytes;
91
+ // The kernel's own download (not an extension's call): one registry hiccup must not fail a
92
+ // whole run of many packages, so a transient failure is retried; a 404, a refusal or a
93
+ // package that differs from its pin is final at once
94
+ for (;;) {
95
+ attempts++;
96
+ try {
97
+ const r = await fetchPackage({
98
+ registry: npmRegistry,
99
+ ...(npmToken !== undefined && { token: npmToken }),
100
+ maxBytes,
101
+ net: marketplaceNetPolicy(o.config),
102
+ }, e.npm, e.version, signal, { expectedIntegrity: e.integrity });
103
+ return r.bytes;
104
+ }
105
+ catch (err) {
106
+ const delay = delays[attempts - 1];
107
+ if (signal.aborted || delay === undefined || !isTransientDownloadError(err))
108
+ throw err;
109
+ o.log?.warn("bootstrap: a package download failed; retrying", {
110
+ plugin: e.name,
111
+ package: `${e.npm}@${e.version}`,
112
+ attempt: attempts,
113
+ retryInMs: delay,
114
+ error: errMsg(err),
115
+ });
116
+ await sleep(delay, undefined, { signal });
117
+ }
118
+ }
89
119
  }
90
120
  catch (err) {
91
121
  if (signal.aborted)
@@ -98,7 +128,7 @@ export async function resolveBootstrapPackages(manifest, o) {
98
128
  : err instanceof Error
99
129
  ? err.message
100
130
  : String(err);
101
- throw new ApiError("bootstrap.download_failed", `Bootstrap plugin ${e.name} ${e.version}: cannot download ${e.npm}@${e.version} from ${registry} (${reason}); ${offlineHint}, or set packages.npmRegistry to a reachable mirror`);
131
+ throw new ApiError("bootstrap.download_failed", `Bootstrap plugin ${e.name} ${e.version}: cannot download ${e.npm}@${e.version} from ${registry} (${reason}${attempts > 1 ? `; ${attempts} attempts` : ""}); ${offlineHint}, or set packages.npmRegistry to a reachable mirror`);
102
132
  }
103
133
  }
104
134
  async function obtainGit(e) {
@@ -154,6 +184,16 @@ export async function resolveBootstrapPackages(manifest, o) {
154
184
  }
155
185
  }
156
186
  const errMsg = (e) => (e instanceof Error ? e.message : String(e));
187
+ /**
188
+ * A download failure worth another attempt: an {@link NpmFetchError} marked transient (network
189
+ * error, timeout, HTTP 408 / 429 / 5xx, a body cut off). Never an integrity mismatch, a package
190
+ * over the size limit, a 404 or a refusal by the network rules.
191
+ */
192
+ function isTransientDownloadError(err) {
193
+ if (err instanceof IntegrityMismatchError || err instanceof PackageTooLargeError)
194
+ return false;
195
+ return err instanceof NpmFetchError && err.transient;
196
+ }
157
197
  /** The registry's origin, for messages (never its credentials or path). */
158
198
  function registryOrigin(registry) {
159
199
  try {
@@ -4,6 +4,7 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
6
  import { LockService } from "../infra/lock/lock.service.js";
7
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
7
8
  import type { KernelLogger } from "../log.js";
8
9
  import { ExtensionAdminOps } from "./admin-ops.js";
9
10
  import { type ExtraManifestTraces, type MergedBootstrapManifest } from "./bootstrap-extra.js";
@@ -161,6 +162,7 @@ export declare class BootstrapService {
161
162
  private readonly approveLock;
162
163
  private readonly installs;
163
164
  private readonly ops;
165
+ private readonly outbox;
164
166
  /**
165
167
  * Config-declared extension names (an entry of the same name is kept, config wins, and no
166
168
  * install record is created): the start sequence records them before the bootstrap step, the
@@ -171,7 +173,7 @@ export declare class BootstrapService {
171
173
  private readonly log;
172
174
  /** The lock's lifetime without renewal. */
173
175
  private readonly lockTtlMs;
174
- constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps,
176
+ constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps, outbox: Pick<OutboxService, "add">,
175
177
  /**
176
178
  * Config-declared extension names (an entry of the same name is kept, config wins, and no
177
179
  * install record is created): the start sequence records them before the bootstrap step, the
@@ -284,8 +286,18 @@ export declare class BootstrapService {
284
286
  * builtin is no longer builtin and keeps scope `all` (the admin may change it from then on).
285
287
  * Only the platform item: an org-owned item of the same name (the entry then fails with
286
288
  * `plugin.name_taken`) is never touched.
289
+ *
290
+ * A demoted item owes its scope sync in the same transaction ({@link demoted}): its extension
291
+ * was on in every org without an org row (always-on), and from now on the sync's org install
292
+ * keeps it on where the scope wants it.
287
293
  */
288
294
  private markBuiltin;
295
+ /**
296
+ * Owes the scope sync of catalog items that just stopped being builtin, in the transaction in
297
+ * context. A builtin item's extension was enabled in every org without an org row and the sync
298
+ * left the item alone; without this sync the orgs its scope (`all`) wants it on in would lose it.
299
+ */
300
+ private demoted;
289
301
  /**
290
302
  * The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
291
303
  * rules refuse is `catalog.invalid_manifest`.
@@ -329,6 +341,9 @@ export declare class BootstrapService {
329
341
  private leftDisabled;
330
342
  /** The permission snapshot of a stored package (source `bootstrap`), under the approve lock. */
331
343
  private approveStored;
332
- /** Install records still `required` whose entry left the manifest lose `required`. */
344
+ /**
345
+ * Install records still `required` whose entry left the manifest lose `required`; the catalog
346
+ * items of entries that left lose `builtin` and owe their scope sync ({@link demoted}).
347
+ */
333
348
  private clearRemoved;
334
349
  }
@@ -17,6 +17,7 @@ import { CONFIG_MARKETPLACE_PREFIX } from "../catalog/marketplaces.service.js";
17
17
  import { otherNameOwner } from "../catalog/ownership.js";
18
18
  import { catalogPackageError, } from "../catalog/plugin-import.js";
19
19
  import { PluginPackageError, readPluginPackage } from "../catalog/plugin-package.js";
20
+ import { oweScopeItem } from "../catalog/scope-jobs.js";
20
21
  import { ApiError } from "../errors.js";
21
22
  import { audit } from "../identity/audit.js";
22
23
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
@@ -24,6 +25,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
24
25
  import { TransactionHost } from "../infra/database/transaction-host.js";
25
26
  import { Transactional } from "../infra/database/transactional.decorator.js";
26
27
  import { LockService } from "../infra/lock/lock.service.js";
28
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
27
29
  import { KERNEL_LOGGER } from "../infra/tokens.js";
28
30
  import { PackageTgzError, unpackPackageTgz } from "../packages/tgz.js";
29
31
  import { ExtensionAdminOps } from "./admin-ops.js";
@@ -84,11 +86,12 @@ let BootstrapService = class BootstrapService {
84
86
  approveLock;
85
87
  installs;
86
88
  ops;
89
+ outbox;
87
90
  registry;
88
91
  configService;
89
92
  log;
90
93
  lockTtlMs;
91
- constructor(kdb, txHost, locks, approveLock, installs, ops,
94
+ constructor(kdb, txHost, locks, approveLock, installs, ops, outbox,
92
95
  /**
93
96
  * Config-declared extension names (an entry of the same name is kept, config wins, and no
94
97
  * install record is created): the start sequence records them before the bootstrap step, the
@@ -103,6 +106,7 @@ let BootstrapService = class BootstrapService {
103
106
  this.approveLock = approveLock;
104
107
  this.installs = installs;
105
108
  this.ops = ops;
109
+ this.outbox = outbox;
106
110
  this.registry = registry;
107
111
  this.configService = configService;
108
112
  this.log = log;
@@ -595,6 +599,10 @@ let BootstrapService = class BootstrapService {
595
599
  * builtin is no longer builtin and keeps scope `all` (the admin may change it from then on).
596
600
  * Only the platform item: an org-owned item of the same name (the entry then fails with
597
601
  * `plugin.name_taken`) is never touched.
602
+ *
603
+ * A demoted item owes its scope sync in the same transaction ({@link demoted}): its extension
604
+ * was on in every org without an org row (always-on), and from now on the sync's org install
605
+ * keeps it on where the scope wants it.
598
606
  */
599
607
  async markBuiltin(name, builtin) {
600
608
  const touch = { updated_at: sql `now()` };
@@ -614,14 +622,25 @@ let BootstrapService = class BootstrapService {
614
622
  .execute();
615
623
  return;
616
624
  }
617
- await this.db
625
+ const rows = await this.db
618
626
  .updateTable("catalog_items")
619
627
  .set({ builtin: false, ...touch })
620
628
  .where("name", "=", name)
621
629
  .where("owner_org_id", "is", null)
622
630
  .where("deleted_at", "is", null)
623
631
  .where("builtin", "=", true)
632
+ .returning("id")
624
633
  .execute();
634
+ await this.demoted(rows.map((r) => r.id));
635
+ }
636
+ /**
637
+ * Owes the scope sync of catalog items that just stopped being builtin, in the transaction in
638
+ * context. A builtin item's extension was enabled in every org without an org row and the sync
639
+ * left the item alone; without this sync the orgs its scope (`all`) wants it on in would lose it.
640
+ */
641
+ async demoted(itemIds) {
642
+ for (const id of itemIds)
643
+ await oweScopeItem(this.outbox, this.db, id);
625
644
  }
626
645
  /**
627
646
  * The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
@@ -802,7 +821,10 @@ let BootstrapService = class BootstrapService {
802
821
  audit: { added, removed, sha256 },
803
822
  });
804
823
  }
805
- /** Install records still `required` whose entry left the manifest lose `required`. */
824
+ /**
825
+ * Install records still `required` whose entry left the manifest lose `required`; the catalog
826
+ * items of entries that left lose `builtin` and owe their scope sync ({@link demoted}).
827
+ */
806
828
  async clearRemoved(manifest) {
807
829
  const names = manifest.plugins.map((p) => p.name);
808
830
  let q = this.db
@@ -823,7 +845,7 @@ let BootstrapService = class BootstrapService {
823
845
  .where("deleted_at", "is", null);
824
846
  if (names.length > 0)
825
847
  items = items.where("name", "not in", names);
826
- await items.execute();
848
+ await this.demoted((await items.returning("id").execute()).map((r) => r.id));
827
849
  return rows.map((r) => ({ name: r.name, action: "required_cleared", version: r.version }));
828
850
  }
829
851
  };
@@ -833,9 +855,18 @@ __decorate([
833
855
  __decorate([
834
856
  Transactional()
835
857
  ], BootstrapService.prototype, "recordDone", null);
858
+ __decorate([
859
+ Transactional()
860
+ ], BootstrapService.prototype, "markBuiltin", null);
861
+ __decorate([
862
+ Transactional({ propagation: "mandatory" })
863
+ ], BootstrapService.prototype, "demoted", null);
836
864
  __decorate([
837
865
  Transactional()
838
866
  ], BootstrapService.prototype, "approveStored", null);
867
+ __decorate([
868
+ Transactional()
869
+ ], BootstrapService.prototype, "clearRemoved", null);
839
870
  BootstrapService = __decorate([
840
871
  Injectable(),
841
872
  __param(0, Inject(KernelDb)),
@@ -844,11 +875,12 @@ BootstrapService = __decorate([
844
875
  __param(3, Inject(PluginApproveLock)),
845
876
  __param(4, Inject(ExtensionInstalls)),
846
877
  __param(5, Inject(ExtensionAdminOps)),
847
- __param(6, Inject(ExtensionRegistry)),
848
- __param(7, Inject(KernelConfigService)),
849
- __param(8, Inject(KERNEL_LOGGER)),
850
- __param(9, Optional()),
851
- __param(9, Inject(BOOTSTRAP_LOCK_TTL))
878
+ __param(6, Inject(OutboxService)),
879
+ __param(7, Inject(ExtensionRegistry)),
880
+ __param(8, Inject(KernelConfigService)),
881
+ __param(9, Inject(KERNEL_LOGGER)),
882
+ __param(10, Optional()),
883
+ __param(10, Inject(BOOTSTRAP_LOCK_TTL))
852
884
  ], BootstrapService);
853
885
  export { BootstrapService };
854
886
  /** A `kept` result whose entry an earlier pass of the same start installed / upgraded / imported. */
@@ -7,7 +7,7 @@ import { type ConfigUiProblem, type JsonSchema } from "@capybara-hq/plugin-sdk";
7
7
  import type { z } from "zod";
8
8
  export { configJsonSchema as configToJsonSchema, type JsonSchema } from "@capybara-hq/plugin-sdk";
9
9
  /** The config level a schema belongs to (which hints `validateConfigUi` allows). */
10
- export type ConfigLevel = "deployment" | "org" | "connection";
10
+ export type ConfigLevel = "deployment" | "connection";
11
11
  /** A config schema as served to forms, with the problems of its hints (empty = kept). */
12
12
  export interface ConfigFormSchema {
13
13
  /** Shared by every caller: clone it before handing it out or changing it. */
@@ -28,7 +28,7 @@ export declare function checkConfigUi(schema: JsonSchema, level: ConfigLevel): C
28
28
  export declare function configFormSchema(schema: z.ZodTypeAny, level: ConfigLevel): ConfigFormSchema;
29
29
  /**
30
30
  * {@link configFormSchema} that never throws, for every caller that serves a form schema or reads
31
- * its messages (deployment, org, connection, issues). A hint conversion that throws (a hand-made
31
+ * its messages (deployment, connection, issues). A hint conversion that throws (a hand-made
32
32
  * package, e.g. hints that won't serialize as JSON) drops the hints: the plain schema with every
33
33
  * `x-ui` stripped, else `null` when even the plain conversion fails. `onFallback` runs once per
34
34
  * schema object and level on this replica (the caller's one warning); later calls reuse the result.
@@ -46,7 +46,6 @@ export function checkConfigUi(schema, level) {
46
46
  /** Manifests are immutable: one conversion per zod schema object and level (read-only, per replica). */
47
47
  const caches = {
48
48
  deployment: new WeakMap(),
49
- org: new WeakMap(),
50
49
  connection: new WeakMap(),
51
50
  };
52
51
  /** A config schema's form JSON Schema ({@link checkConfigUi} applied), cached per schema object. */
@@ -63,12 +62,11 @@ export function configFormSchema(schema, level) {
63
62
  /** The schemas whose hinted conversion threw: their fallback (plain schema, or null). */
64
63
  const fallbacks = {
65
64
  deployment: new WeakMap(),
66
- org: new WeakMap(),
67
65
  connection: new WeakMap(),
68
66
  };
69
67
  /**
70
68
  * {@link configFormSchema} that never throws, for every caller that serves a form schema or reads
71
- * its messages (deployment, org, connection, issues). A hint conversion that throws (a hand-made
69
+ * its messages (deployment, connection, issues). A hint conversion that throws (a hand-made
72
70
  * package, e.g. hints that won't serialize as JSON) drops the hints: the plain schema with every
73
71
  * `x-ui` stripped, else `null` when even the plain conversion fails. `onFallback` runs once per
74
72
  * schema object and level on this replica (the caller's one warning); later calls reuse the result.