@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.38

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 (351) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.d.ts +3 -2
  3. package/dist/admin/admin.module.js +9 -5
  4. package/dist/admin/audit-log.service.d.ts +51 -0
  5. package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
  6. package/dist/admin/audit.controller.d.ts +18 -6
  7. package/dist/admin/audit.controller.js +36 -6
  8. package/dist/admin/audit.schemas.d.ts +9 -1
  9. package/dist/admin/audit.schemas.js +22 -2
  10. package/dist/admin/org-network.controller.d.ts +30 -0
  11. package/dist/admin/org-network.controller.js +77 -0
  12. package/dist/admin/org-network.schemas.d.ts +16 -0
  13. package/dist/admin/org-network.schemas.js +27 -0
  14. package/dist/admin/org-network.service.d.ts +41 -0
  15. package/dist/admin/org-network.service.js +101 -0
  16. package/dist/admin/outbox-dead.controller.d.ts +4 -6
  17. package/dist/admin/outbox-dead.controller.js +9 -6
  18. package/dist/admin/outbox-dead.schemas.d.ts +16 -0
  19. package/dist/admin/outbox-dead.schemas.js +25 -1
  20. package/dist/admin/outbox-dead.service.d.ts +16 -7
  21. package/dist/admin/outbox-dead.service.js +34 -10
  22. package/dist/admin/overview.service.d.ts +3 -3
  23. package/dist/admin/overview.service.js +0 -1
  24. package/dist/agents/agent-lookup.js +2 -10
  25. package/dist/agents/agents.service.js +9 -20
  26. package/dist/agents/definition.d.ts +3 -51
  27. package/dist/agents/definition.js +4 -254
  28. package/dist/agents/org-templates.js +2 -6
  29. package/dist/agents/readiness.controller.d.ts +4 -12
  30. package/dist/agents/readiness.controller.js +4 -12
  31. package/dist/agents/readiness.service.d.ts +23 -11
  32. package/dist/agents/readiness.service.js +31 -14
  33. package/dist/agents/templates.d.ts +0 -6
  34. package/dist/agents/templates.js +8 -34
  35. package/dist/background/store.d.ts +2 -0
  36. package/dist/background/store.js +3 -1
  37. package/dist/background/wake-rules.js +2 -1
  38. package/dist/catalog/admin-catalog.controller.d.ts +1 -2
  39. package/dist/catalog/admin-catalog.controller.js +1 -2
  40. package/dist/catalog/appearance.service.js +1 -3
  41. package/dist/catalog/catalog-content.d.ts +1 -1
  42. package/dist/catalog/catalog-content.js +1 -4
  43. package/dist/catalog/catalog-items.js +3 -3
  44. package/dist/catalog/catalog-scope.service.d.ts +10 -28
  45. package/dist/catalog/catalog-scope.service.js +22 -73
  46. package/dist/catalog/cli.d.ts +0 -11
  47. package/dist/catalog/cli.js +0 -20
  48. package/dist/catalog/component-scope.service.js +0 -2
  49. package/dist/catalog/component-state.js +2 -2
  50. package/dist/catalog/install-status.d.ts +6 -0
  51. package/dist/catalog/install-status.js +6 -0
  52. package/dist/catalog/job-ids.d.ts +0 -4
  53. package/dist/catalog/job-ids.js +0 -4
  54. package/dist/catalog/marketplaces.service.d.ts +1 -1
  55. package/dist/catalog/org-catalog.service.d.ts +2 -0
  56. package/dist/catalog/org-catalog.service.js +8 -3
  57. package/dist/catalog/org-extension-switch.d.ts +7 -2
  58. package/dist/catalog/org-extension-switch.js +56 -9
  59. package/dist/catalog/org-plugin-uploads.d.ts +6 -15
  60. package/dist/catalog/org-plugin-uploads.js +9 -27
  61. package/dist/catalog/owned-items.js +1 -3
  62. package/dist/catalog/platform-import-update.js +1 -1
  63. package/dist/catalog/plugin-import.d.ts +15 -13
  64. package/dist/catalog/plugin-import.js +21 -30
  65. package/dist/catalog/plugin-install.d.ts +3 -43
  66. package/dist/catalog/plugin-install.js +8 -150
  67. package/dist/catalog/plugin-package.d.ts +5 -10
  68. package/dist/catalog/plugin-package.js +12 -33
  69. package/dist/catalog/plugin-upgrade.js +5 -4
  70. package/dist/catalog/scope-jobs.d.ts +34 -34
  71. package/dist/catalog/scope-jobs.js +50 -37
  72. package/dist/catalog/scope-orgs.d.ts +1 -1
  73. package/dist/catalog/scope-orgs.js +1 -2
  74. package/dist/catalog/scope-sync-workers.d.ts +4 -3
  75. package/dist/catalog/scope-sync-workers.js +18 -6
  76. package/dist/catalog/scope-sync.d.ts +56 -59
  77. package/dist/catalog/scope-sync.js +96 -166
  78. package/dist/catalog/unshare.d.ts +3 -4
  79. package/dist/catalog/unshare.js +5 -8
  80. package/dist/channels/job-ids.d.ts +2 -6
  81. package/dist/channels/job-ids.js +2 -6
  82. package/dist/channels/outbound.d.ts +1 -1
  83. package/dist/channels/outbound.js +1 -1
  84. package/dist/channels/supervisor.d.ts +2 -3
  85. package/dist/channels/supervisor.js +2 -3
  86. package/dist/client/client-access.service.js +1 -1
  87. package/dist/config/env.js +19 -1
  88. package/dist/config/load.d.ts +0 -6
  89. package/dist/config/load.js +8 -27
  90. package/dist/config/schema.d.ts +54 -47
  91. package/dist/config/schema.js +198 -42
  92. package/dist/conversations/attachments.service.d.ts +10 -3
  93. package/dist/conversations/attachments.service.js +49 -16
  94. package/dist/conversations/conversations.controller.d.ts +0 -39
  95. package/dist/conversations/conversations.controller.js +0 -39
  96. package/dist/conversations/event-log.js +4 -1
  97. package/dist/conversations/events.d.ts +71 -46
  98. package/dist/conversations/events.js +124 -112
  99. package/dist/conversations/media-types.d.ts +25 -0
  100. package/dist/conversations/media-types.js +38 -0
  101. package/dist/conversations/queue.d.ts +3 -1
  102. package/dist/conversations/queue.service.js +9 -2
  103. package/dist/conversations/titles.js +6 -0
  104. package/dist/ctx/create-ctx.d.ts +8 -1
  105. package/dist/ctx/create-ctx.js +13 -3
  106. package/dist/ctx/net.d.ts +50 -0
  107. package/dist/ctx/net.js +67 -0
  108. package/dist/ctx/secrets.d.ts +24 -7
  109. package/dist/ctx/secrets.js +97 -30
  110. package/dist/db/kernel-schema.d.ts +27 -6
  111. package/dist/devices/devices.service.js +2 -1
  112. package/dist/errors.d.ts +10 -2
  113. package/dist/errors.js +10 -2
  114. package/dist/evals/reconstruct.d.ts +4 -17
  115. package/dist/evals/reconstruct.js +13 -53
  116. package/dist/evals/recorded-tools.d.ts +0 -27
  117. package/dist/evals/recorded-tools.js +2 -92
  118. package/dist/evals/run-replay.d.ts +1 -6
  119. package/dist/evals/run-replay.js +10 -17
  120. package/dist/evals/sets.service.d.ts +17 -5
  121. package/dist/evals/sets.service.js +33 -12
  122. package/dist/evals/snapshot.d.ts +1 -2
  123. package/dist/evals/snapshot.js +4 -17
  124. package/dist/extensions/admin-ops.d.ts +6 -1
  125. package/dist/extensions/admin-ops.js +17 -4
  126. package/dist/extensions/admin-view.d.ts +7 -4
  127. package/dist/extensions/admin-view.js +27 -21
  128. package/dist/extensions/bootstrap.js +0 -1
  129. package/dist/extensions/cli.js +0 -1
  130. package/dist/extensions/extensions.module.js +3 -0
  131. package/dist/extensions/host.d.ts +9 -4
  132. package/dist/extensions/host.js +14 -8
  133. package/dist/extensions/installs.d.ts +1 -3
  134. package/dist/extensions/instance.d.ts +0 -2
  135. package/dist/extensions/instance.js +0 -3
  136. package/dist/extensions/org-config.d.ts +4 -4
  137. package/dist/extensions/org-config.js +13 -22
  138. package/dist/extensions/package.d.ts +6 -6
  139. package/dist/extensions/package.js +3 -7
  140. package/dist/extensions/permission-view.d.ts +2 -4
  141. package/dist/extensions/plugin-items.d.ts +21 -1
  142. package/dist/extensions/plugin-items.js +28 -0
  143. package/dist/extensions/sync.js +5 -10
  144. package/dist/extensions/unavailable.js +0 -1
  145. package/dist/http/api.module.js +4 -1
  146. package/dist/identity/audit.d.ts +0 -12
  147. package/dist/identity/audit.js +0 -27
  148. package/dist/identity/auth.controller.js +5 -9
  149. package/dist/identity/cookies.d.ts +4 -9
  150. package/dist/identity/cookies.js +8 -32
  151. package/dist/identity/initial-passwords.d.ts +1 -1
  152. package/dist/identity/initial-passwords.js +1 -2
  153. package/dist/identity/sessions.d.ts +0 -6
  154. package/dist/identity/sessions.js +0 -18
  155. package/dist/inbox/platform-inbox.service.d.ts +33 -1
  156. package/dist/inbox/platform-inbox.service.js +56 -6
  157. package/dist/index.d.ts +4 -2
  158. package/dist/index.js +4 -2
  159. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  160. package/dist/infra/cli/master-key-rewrap.js +24 -0
  161. package/dist/infra/config/kernel-config.service.js +0 -17
  162. package/dist/infra/database/transaction-host.d.ts +32 -1
  163. package/dist/infra/database/transaction-host.js +30 -4
  164. package/dist/infra/database/xact-lock.d.ts +16 -0
  165. package/dist/infra/database/xact-lock.js +28 -1
  166. package/dist/infra/health/health.controller.js +8 -0
  167. package/dist/infra/health/process-fault.d.ts +16 -0
  168. package/dist/infra/health/process-fault.js +49 -0
  169. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  170. package/dist/infra/lifecycle/process-guards.js +12 -3
  171. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  172. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  173. package/dist/infra/outbox/outbox.service.d.ts +12 -9
  174. package/dist/infra/outbox/outbox.service.js +22 -26
  175. package/dist/infra/outbox/registry.d.ts +15 -7
  176. package/dist/infra/outbox/registry.js +39 -23
  177. package/dist/lifecycle/kernel-lifecycle.js +1 -7
  178. package/dist/models/enablement.d.ts +5 -6
  179. package/dist/models/enablement.js +7 -14
  180. package/dist/net/public-address.d.ts +21 -1
  181. package/dist/net/public-address.js +56 -10
  182. package/dist/net/safe-fetch.d.ts +4 -1
  183. package/dist/net/safe-fetch.js +15 -4
  184. package/dist/orgs/directory-sync.js +2 -0
  185. package/dist/orgs/members.service.js +5 -0
  186. package/dist/orgs/network-allowances.service.d.ts +79 -0
  187. package/dist/orgs/network-allowances.service.js +371 -0
  188. package/dist/orgs/offboarding.d.ts +3 -1
  189. package/dist/orgs/offboarding.js +9 -2
  190. package/dist/orgs/org-lock.d.ts +28 -2
  191. package/dist/orgs/org-lock.js +59 -4
  192. package/dist/orgs/orgs.controller.d.ts +11 -2
  193. package/dist/orgs/orgs.controller.js +19 -3
  194. package/dist/orgs/orgs.module.d.ts +3 -2
  195. package/dist/orgs/orgs.module.js +6 -2
  196. package/dist/orgs/orgs.schemas.d.ts +12 -0
  197. package/dist/orgs/orgs.schemas.js +5 -0
  198. package/dist/orgs/orgs.service.js +6 -1
  199. package/dist/orgs/settings.controller.d.ts +3 -2
  200. package/dist/orgs/settings.service.d.ts +59 -14
  201. package/dist/orgs/settings.service.js +102 -20
  202. package/dist/overrides.d.ts +7 -7
  203. package/dist/overrides.js +4 -4
  204. package/dist/packages/tgz.d.ts +0 -2
  205. package/dist/packages/tgz.js +0 -2
  206. package/dist/platform/exclusions.js +0 -5
  207. package/dist/platform/operation.js +1 -1
  208. package/dist/platform/ops/admin.ops.d.ts +2 -2
  209. package/dist/platform/ops/admin.ops.js +9 -6
  210. package/dist/platform/ops/agents.ops.js +1 -1
  211. package/dist/platform/ops/connectors.ops.js +46 -1
  212. package/dist/platform/ops/evals.ops.js +1 -64
  213. package/dist/platform/ops/extensions-admin.ops.js +1 -1
  214. package/dist/platform/ops/inbox.ops.js +16 -3
  215. package/dist/platform/ops/org-plugins.ops.js +1 -1
  216. package/dist/platform/ops/orgs.ops.d.ts +11 -3
  217. package/dist/platform/ops/orgs.ops.js +139 -5
  218. package/dist/platform/ops/outbox.ops.js +5 -5
  219. package/dist/platform/route-schemas.js +3 -0
  220. package/dist/roles/worker-role.d.ts +2 -3
  221. package/dist/roles/worker-role.js +3 -13
  222. package/dist/runtime/checkpointer.d.ts +3 -0
  223. package/dist/runtime/checkpointer.js +7 -4
  224. package/dist/runtime/context/build.d.ts +56 -18
  225. package/dist/runtime/context/build.js +143 -50
  226. package/dist/runtime/context/compaction.d.ts +1 -3
  227. package/dist/runtime/context/compaction.js +42 -8
  228. package/dist/runtime/context/run-context.js +1 -2
  229. package/dist/runtime/context/skills.d.ts +27 -56
  230. package/dist/runtime/context/skills.js +42 -114
  231. package/dist/runtime/context/tool-changes.d.ts +3 -3
  232. package/dist/runtime/context/tool-changes.js +6 -16
  233. package/dist/runtime/hook-calls.d.ts +6 -6
  234. package/dist/runtime/hook-calls.js +7 -7
  235. package/dist/runtime/langgraph-loop.js +9 -3
  236. package/dist/runtime/maintenance.d.ts +3 -11
  237. package/dist/runtime/maintenance.js +5 -20
  238. package/dist/runtime/model-call.d.ts +5 -0
  239. package/dist/runtime/model-call.js +48 -36
  240. package/dist/runtime/providers.d.ts +33 -35
  241. package/dist/runtime/providers.js +64 -109
  242. package/dist/runtime/run-context.service.js +7 -22
  243. package/dist/runtime/run-deletion.d.ts +6 -0
  244. package/dist/runtime/run-deletion.js +39 -16
  245. package/dist/runtime/run-execution.d.ts +56 -3
  246. package/dist/runtime/run-execution.js +81 -11
  247. package/dist/runtime/run-finish.js +2 -1
  248. package/dist/runtime/run-liveness.d.ts +11 -0
  249. package/dist/runtime/run-liveness.js +19 -0
  250. package/dist/runtime/run-orphan-check.job.js +2 -1
  251. package/dist/runtime/run-queue.js +8 -16
  252. package/dist/runtime/run-worker.d.ts +2 -2
  253. package/dist/runtime/run-worker.js +8 -6
  254. package/dist/runtime/step-log.d.ts +5 -0
  255. package/dist/runtime/step-log.js +9 -4
  256. package/dist/runtime/subagents/definition.d.ts +16 -20
  257. package/dist/runtime/subagents/definition.js +27 -27
  258. package/dist/runtime/subagents/dispatch.d.ts +6 -2
  259. package/dist/runtime/subagents/dispatch.js +17 -3
  260. package/dist/runtime/subagents/org-agents.js +1 -2
  261. package/dist/runtime/subagents/preamble.d.ts +3 -2
  262. package/dist/runtime/subagents/preamble.js +3 -2
  263. package/dist/runtime/subagents/render.d.ts +1 -2
  264. package/dist/runtime/subagents/render.js +1 -2
  265. package/dist/runtime/subagents/skill-fork.d.ts +2 -4
  266. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  267. package/dist/runtime/subagents/template-skills.js +76 -0
  268. package/dist/runtime/waits.js +3 -1
  269. package/dist/schedules/effective-settings.d.ts +9 -3
  270. package/dist/schedules/effective-settings.js +5 -4
  271. package/dist/schedules/fire.js +11 -0
  272. package/dist/schedules/scheduled-tasks.service.js +5 -0
  273. package/dist/schedules/unattended.d.ts +2 -0
  274. package/dist/schedules/unattended.js +6 -1
  275. package/dist/skills/agent-skills.service.js +1 -2
  276. package/dist/skills/catalog.d.ts +1 -3
  277. package/dist/skills/catalog.js +1 -3
  278. package/dist/skills/conversation-catalog.d.ts +1 -2
  279. package/dist/skills/conversation-catalog.js +1 -2
  280. package/dist/skills/usable.js +2 -3
  281. package/dist/storage/storage.service.js +9 -1
  282. package/dist/tools/approvals.service.js +2 -4
  283. package/dist/tools/builtin-names.d.ts +2 -9
  284. package/dist/tools/builtin-names.js +4 -13
  285. package/dist/tools/builtins/sandbox/bash.js +3 -3
  286. package/dist/tools/builtins/sandbox/common.d.ts +7 -13
  287. package/dist/tools/builtins/sandbox/common.js +8 -115
  288. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  289. package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
  290. package/dist/tools/builtins/sandbox/glob.js +1 -3
  291. package/dist/tools/builtins/sandbox/grep.js +3 -5
  292. package/dist/tools/builtins/sandbox/index.d.ts +8 -5
  293. package/dist/tools/builtins/sandbox/index.js +10 -5
  294. package/dist/tools/builtins/sandbox/read.js +3 -2
  295. package/dist/tools/builtins/tool-search.d.ts +4 -7
  296. package/dist/tools/builtins/tool-search.js +6 -10
  297. package/dist/tools/connector-account-policies.d.ts +30 -3
  298. package/dist/tools/connector-account-policies.js +54 -7
  299. package/dist/tools/connector-content.js +1 -0
  300. package/dist/tools/connectors.controller.d.ts +24 -11
  301. package/dist/tools/connectors.controller.js +35 -6
  302. package/dist/tools/connectors.schemas.d.ts +14 -1
  303. package/dist/tools/connectors.schemas.js +14 -2
  304. package/dist/tools/connectors.service.d.ts +22 -0
  305. package/dist/tools/connectors.service.js +65 -6
  306. package/dist/tools/drift.d.ts +6 -2
  307. package/dist/tools/drift.js +10 -5
  308. package/dist/tools/git-push-policy.d.ts +4 -1
  309. package/dist/tools/git-push-policy.js +3 -1
  310. package/dist/tools/info.d.ts +1 -7
  311. package/dist/tools/info.js +5 -18
  312. package/dist/tools/job-ids.d.ts +0 -4
  313. package/dist/tools/job-ids.js +1 -6
  314. package/dist/tools/pipeline.d.ts +4 -10
  315. package/dist/tools/pipeline.js +17 -62
  316. package/dist/tools/policy.d.ts +6 -2
  317. package/dist/tools/policy.js +14 -12
  318. package/dist/tools/registry.js +1 -5
  319. package/dist/ui/views.d.ts +5 -5
  320. package/dist/ui/views.js +10 -16
  321. package/package.json +3 -3
  322. package/src/migrations/0137_audit_org_idx.sql +5 -0
  323. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  324. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  325. package/src/migrations/0140_retire_history_forms.sql +148 -0
  326. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  327. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  328. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  329. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  330. package/src/migrations/0145_org_network_allowances.sql +12 -0
  331. package/dist/admin/platform-audit.service.d.ts +0 -41
  332. package/dist/conversations/job-ids.d.ts +0 -6
  333. package/dist/conversations/job-ids.js +0 -6
  334. package/dist/extensions/job-ids.d.ts +0 -6
  335. package/dist/extensions/job-ids.js +0 -6
  336. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  337. package/dist/infra/queue/retired-schedulers.js +0 -9
  338. package/dist/orgs/job-ids.d.ts +0 -8
  339. package/dist/orgs/job-ids.js +0 -8
  340. package/dist/runtime/context/legacy-text.d.ts +0 -22
  341. package/dist/runtime/context/legacy-text.js +0 -37
  342. package/dist/runtime/job-ids.d.ts +0 -10
  343. package/dist/runtime/job-ids.js +0 -10
  344. package/dist/runtime/retired-schedulers.d.ts +0 -7
  345. package/dist/runtime/retired-schedulers.js +0 -31
  346. package/dist/storage/job-ids.d.ts +0 -6
  347. package/dist/storage/job-ids.js +0 -6
  348. package/dist/tools/legacy-data.d.ts +0 -34
  349. package/dist/tools/legacy-data.js +0 -76
  350. package/dist/tools/legacy-keys.d.ts +0 -51
  351. package/dist/tools/legacy-keys.js +0 -114
@@ -19,7 +19,10 @@ export type GitPushReason =
19
19
  | "org_deny"
20
20
  /** The member denied pushes to the repository for themselves. */
21
21
  | "member_deny"
22
- /** The org forbids `git:push` (or the repository's key) in scheduled runs. */
22
+ /**
23
+ * The org forbids `git:push` (or the repository's key) in scheduled runs, or its forbidden list
24
+ * cannot be read (fails closed).
25
+ */
23
26
  | "forbidden"
24
27
  /** An unattended run in `fail` mode without a task grant: no one can be asked. */
25
28
  | "unattended"
@@ -79,7 +79,9 @@ export async function decideGitPush(db, config, input) {
79
79
  ? input.unattended
80
80
  : await unattendedRunOf(db, config, input.orgId, input.runId);
81
81
  const rules = unattendedRules(unattended) ? unattended : null;
82
- if (rules !== null && gitPushForbidden(rules.forbiddenTools, key)) {
82
+ // fail closed: an unreadable list forbids every push of an unattended run
83
+ if (rules !== null &&
84
+ (rules.forbiddenToolsUnreadable === true || gitPushForbidden(rules.forbiddenTools, key))) {
83
85
  return { decision: "deny", reason: "forbidden", repo };
84
86
  }
85
87
  if (base.policy === "allow")
@@ -13,12 +13,6 @@ export type ToolKind = "command" | "read" | "edit" | "search" | "connector" | "m
13
13
  export interface ToolInfo {
14
14
  /** The model-visible tool key, as asked for. */
15
15
  key: string;
16
- /**
17
- * Set only for a release-candidate builtin key (old history, tool naming spec §9): the current
18
- * tool it stands for. Everything else describes that tool, with `keyArgs` in the old parameter
19
- * names the logged input carries. Pages map a call's name through it (the `Agent` row, labels).
20
- */
21
- aliasOf?: string;
22
16
  /** The declared display title (`ToolSpec.title`), or null. */
23
17
  title: string | null;
24
18
  kind: ToolKind;
@@ -59,7 +53,7 @@ export interface ToolInfoDeps {
59
53
  }
60
54
  /**
61
55
  * Presentation metadata for `keys` in this org, in request order with repeats dropped. Builtins
62
- * by name (a release-candidate builtin key as its current tool, with `aliasOf`); `plugin__<plugin>__<tool>` keys as a loaded extension's registration, and `mcp__<slug>__<tool>` keys as a live
56
+ * by name; `plugin__<plugin>__<tool>` keys as a loaded extension's registration, and `mcp__<slug>__<tool>` keys as a live
63
57
  * connector's current stored tool (its reviewed definition, never a pending one). Anything else
64
58
  * comes back as an unknown plain tool.
65
59
  *
@@ -15,7 +15,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
15
15
  import { UUID_RE } from "../ui/registry.js";
16
16
  import { BUILTIN_TOOL_KINDS, SANDBOX_TOOL_NAMES } from "./builtin-names.js";
17
17
  import { pluginDisplayNames } from "./display-names.js";
18
- import { isLegacyBuiltinKey, LEGACY_BUILTINS } from "./legacy-keys.js";
19
18
  import { toolKeyIssue } from "./naming.js";
20
19
  import { OrgToolSwitches } from "./org-tool-switches.js";
21
20
  import { policyFromAnnotations, ToolRegistry } from "./registry.js";
@@ -29,7 +28,7 @@ const display = (spec) => ({
29
28
  });
30
29
  /**
31
30
  * Presentation metadata for `keys` in this org, in request order with repeats dropped. Builtins
32
- * by name (a release-candidate builtin key as its current tool, with `aliasOf`); `plugin__<plugin>__<tool>` keys as a loaded extension's registration, and `mcp__<slug>__<tool>` keys as a live
31
+ * by name; `plugin__<plugin>__<tool>` keys as a loaded extension's registration, and `mcp__<slug>__<tool>` keys as a live
33
32
  * connector's current stored tool (its reviewed definition, never a pending one). Anything else
34
33
  * comes back as an unknown plain tool.
35
34
  *
@@ -74,30 +73,18 @@ export async function toolInfo(deps, orgId, keys) {
74
73
  const p = parseToolKey(key);
75
74
  return p && p.kind !== "builtin" ? p.tool : null;
76
75
  };
77
- const builtinInfo = (key, name, spec) => ({
76
+ const builtinInfo = (key, spec) => ({
78
77
  key,
79
78
  ...display(spec),
80
- kind: BUILTIN_TOOL_KINDS[name] ?? "tool",
81
- sandbox: SANDBOX_TOOL_NAMES.includes(name),
79
+ kind: BUILTIN_TOOL_KINDS[key] ?? "tool",
80
+ sandbox: SANDBOX_TOOL_NAMES.includes(key),
82
81
  tool: null,
83
82
  source: { kind: "builtin" },
84
83
  });
85
84
  return unique.map((key) => {
86
85
  const b = builtins.get(key);
87
86
  if (b)
88
- return builtinInfo(key, key, b);
89
- const legacy = isLegacyBuiltinKey(key) ? LEGACY_BUILTINS[key] : undefined;
90
- const current = legacy && builtins.get(legacy.name);
91
- if (legacy && current) {
92
- // the logged input of an rc call names the old parameters: key arguments in those names
93
- const oldName = new Map(Object.entries(legacy.params).map(([o, n]) => [n, o]));
94
- const info = builtinInfo(key, legacy.name, current);
95
- return {
96
- ...info,
97
- aliasOf: legacy.name,
98
- keyArgs: info.keyArgs.map((a) => oldName.get(a) ?? a),
99
- };
100
- }
87
+ return builtinInfo(key, b);
101
88
  const e = extensions.get(key);
102
89
  if (e)
103
90
  return {
@@ -1,7 +1,5 @@
1
1
  /** The periodic drift scan (`@LockedInterval`, tools/jobs.ts). */
2
2
  export declare const DRIFT_SCAN_JOB = "drift-scan";
3
- /** The BullMQ repeatable scheduler the scan had before it became `@LockedInterval` (retired). */
4
- export declare const DRIFT_SCHEDULER_ID = "drift-scan-interval";
5
3
  /**
6
4
  * 单个连接器的漂移检查任务名(维护队列上的一次性任务:生产方是 `ToolDrift`,消费方是
7
5
  * `MaintenanceProcessor`)。
@@ -9,5 +7,3 @@ export declare const DRIFT_SCHEDULER_ID = "drift-scan-interval";
9
7
  export declare const DRIFT_CONNECTOR_JOB = "drift-connector";
10
8
  /** The hourly cleanup of expired tool output archives (`@LockedCron`, tools/jobs.ts). */
11
9
  export declare const OUTPUT_CLEANUP_JOB = "output-cleanup";
12
- /** The BullMQ repeatable scheduler the cleanup had before it became `@LockedCron` (retired). */
13
- export declare const OUTPUT_CLEANUP_SCHEDULER_ID = "output-cleanup-hourly";
@@ -1,9 +1,6 @@
1
- // The tools' job names and the retired scheduler ids: a leaf module (no service imports), read by
2
- // the maintenance queue's retirement list.
1
+ // The tools' job names: a leaf module (no service imports), read by the maintenance queue.
3
2
  /** The periodic drift scan (`@LockedInterval`, tools/jobs.ts). */
4
3
  export const DRIFT_SCAN_JOB = "drift-scan";
5
- /** The BullMQ repeatable scheduler the scan had before it became `@LockedInterval` (retired). */
6
- export const DRIFT_SCHEDULER_ID = "drift-scan-interval";
7
4
  /**
8
5
  * 单个连接器的漂移检查任务名(维护队列上的一次性任务:生产方是 `ToolDrift`,消费方是
9
6
  * `MaintenanceProcessor`)。
@@ -11,5 +8,3 @@ export const DRIFT_SCHEDULER_ID = "drift-scan-interval";
11
8
  export const DRIFT_CONNECTOR_JOB = "drift-connector";
12
9
  /** The hourly cleanup of expired tool output archives (`@LockedCron`, tools/jobs.ts). */
13
10
  export const OUTPUT_CLEANUP_JOB = "output-cleanup";
14
- /** The BullMQ repeatable scheduler the cleanup had before it became `@LockedCron` (retired). */
15
- export const OUTPUT_CLEANUP_SCHEDULER_ID = "output-cleanup-hourly";
@@ -10,6 +10,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
10
10
  import { TransactionHost } from "../infra/database/transaction-host.js";
11
11
  import { DevicePolicyService } from "../local-devices/device-policy.service.js";
12
12
  import { type NetworkRunState } from "../local-devices/network-grants.js";
13
+ import type { KernelLogger } from "../log.js";
13
14
  import type { OrgRole } from "../orgs/roles.js";
14
15
  import { type ConversationKindForHooks, type HookRunner } from "../runtime/hook-calls.js";
15
16
  import { type SubagentParent, type WaitingFor } from "../runtime/loop.js";
@@ -31,8 +32,7 @@ import { type CallPolicy, type ResolvedTool, ToolRegistry } from "./registry.js"
31
32
  export declare const APPROVAL_DENIED_TEXT = "The user denied this tool call.";
32
33
  /**
33
34
  * The denied call's result when the approver gave a reason (model-visible, in the log). "An
34
- * approver": under role escalation an admin, not the requester, decides. Older logs keep the text
35
- * they recorded ("The user denied this tool call. Reason: …"); only new denials use this one.
35
+ * approver": under role escalation an admin, not the requester, decides.
36
36
  */
37
37
  export declare const approvalDeniedText: (reason: string | null) => string;
38
38
  /** 审批超时(按拒绝)。 */
@@ -95,7 +95,7 @@ export interface AskRequest {
95
95
  /**
96
96
  * Which rule made a call need approval: role escalation, the agent's tool policy, the connector's
97
97
  * policy, a fixed ask (R3, `requiresUserInteraction`), the org's `sandboxToolPolicy`, or the tool's
98
- * own default. `org` and `fixed` were added after the first B events (older logs say `default`).
98
+ * own default.
99
99
  */
100
100
  export type ApprovalPolicySource = "agent" | "connector" | "member" | "default" | "role" | "org" | "fixed";
101
101
  /**
@@ -335,7 +335,7 @@ export declare class ToolPipeline {
335
335
  /** The `Agent` tool's sub-agent dispatch; absent (tests): `Agent` calls are refused. */
336
336
  subagents: Pick<SubagentsService, "dispatch"> | undefined,
337
337
  /** The message tools between agents; absent (tests): their calls are refused. */
338
- messages: Pick<SubagentMessages, "toChild" | "toParent"> | undefined, registry: Pick<ToolRegistry, "forAgent" | "findConnector" | "handler">, credentials: Pick<Credentials, "injection" | "onUnauthorized">, breaker: Pick<Breaker, "check" | "failure" | "success">, outputs: Pick<ToolOutputs, "save" | "load">, approvals: Pick<ApprovalsService, "request" | "forCall" | "networkForCall" | "requestNetwork" | "commandForCall" | "requestCommand">, questions: Pick<QuestionsService, "ask" | "forCall">, config: Pick<KernelConfigService, "get">, log: Logger,
338
+ messages: Pick<SubagentMessages, "toChild" | "toParent"> | undefined, registry: Pick<ToolRegistry, "forAgent" | "findConnector" | "handler">, credentials: Pick<Credentials, "injection" | "onUnauthorized">, breaker: Pick<Breaker, "check" | "failure" | "success">, outputs: Pick<ToolOutputs, "save" | "load">, approvals: Pick<ApprovalsService, "request" | "forCall" | "networkForCall" | "requestNetwork" | "commandForCall" | "requestCommand">, questions: Pick<QuestionsService, "ask" | "forCall">, config: Pick<KernelConfigService, "get">, log: Logger & Partial<Pick<KernelLogger, "debug">>,
339
339
  /** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
340
340
  host: Pick<ExtensionHost, "hooks" | "current"> | undefined, drift: Pick<ToolDrift, "onToolsChanged"> | undefined, effective: Pick<EffectiveConfigs, "get">, switches: Pick<OrgToolSwitches, "isToolOff">, txHost: TransactionHost, hooks?: ToolPipelineHooks, networkGrants?: {
341
341
  runState(runId: string, deviceId?: string): Promise<NetworkRunState>;
@@ -402,12 +402,6 @@ export declare class ToolPipeline {
402
402
  private networkBlocked;
403
403
  /** Appends a sub-agent's connect card to its root conversation ({@link rootSurfaceOf}). */
404
404
  private surfaceConnectInRoot;
405
- /**
406
- * Every tool key the request that issued this step's calls offered (`request.tools` plus the
407
- * `catalog` keys), in any mode; null when its model_call is not found. Used to tell a call to an
408
- * old key that was offered (in flight across the rename) from one that never was.
409
- */
410
- private requestToolKeys;
411
405
  /**
412
406
  * 发出本步调用的请求里带了完整定义的工具 key:本步最后一次尝试的 `model_call.request.tools`
413
407
  * (`assistant_message` 来自最后一次尝试)。该请求不在 ToolSearch 模式(没有 `catalog`,工具全部发送)
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { parseToolKey, ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
10
+ import { ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable, Optional } from "@nestjs/common";
12
12
  import { EventLog } from "../conversations/event-log.js";
13
13
  import { COMMAND_ASK_MAX_CHARS, COMMAND_ASK_TEXT_MAX_CHARS, ToolViewSchema, } from "../conversations/events.js";
@@ -52,7 +52,6 @@ import { canonicalJson } from "./canonical-json.js";
52
52
  import { CredentialMissing, Credentials } from "./credentials.js";
53
53
  import { ToolDrift } from "./drift.js";
54
54
  import { ElicitationSession } from "./elicitation.js";
55
- import { legacyHint, legacyToolInput, legacyToolKey } from "./legacy-keys.js";
56
55
  import { blockedEventHosts, clipKept, NETWORK_ASK_KEPT_MAX_BYTES, networkBlockedIdemKey, planNetworkAsk, settledNetworkNotes, withNetworkNotes, } from "./network-asks.js";
57
56
  import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
58
57
  import { renderResult, resolveOutputRefs, spillIfLarge, ToolOutputs } from "./outputs.js";
@@ -67,8 +66,7 @@ import { validateInput } from "./validate.js";
67
66
  export const APPROVAL_DENIED_TEXT = "The user denied this tool call.";
68
67
  /**
69
68
  * The denied call's result when the approver gave a reason (model-visible, in the log). "An
70
- * approver": under role escalation an admin, not the requester, decides. Older logs keep the text
71
- * they recorded ("The user denied this tool call. Reason: …"); only new denials use this one.
69
+ * approver": under role escalation an admin, not the requester, decides.
72
70
  */
73
71
  export const approvalDeniedText = (reason) => reason === null ? APPROVAL_DENIED_TEXT : `An approver denied this tool call. Reason: ${reason}`;
74
72
  /** 审批超时(按拒绝)。 */
@@ -139,22 +137,8 @@ const skippedResult = (toolKey) => toolKey === "AskUserQuestion"
139
137
  };
140
138
  const timeoutText = (key, ms) => `Tool ${key} timed out after ${ms / 1000}s. The operation may or may not have completed; verify before retrying.`;
141
139
  const failedText = (key, errName) => `Tool ${key} failed (${errName}). The operation may not have completed; check before retrying or try another approach.`;
142
- /** The connector slugs and extension names among the run's tools (to read old `<x>__<tool>` keys). */
143
- const legacyScopeOf = (tools) => {
144
- const connectorSlugs = new Set();
145
- const extensionNames = new Set();
146
- for (const t of tools) {
147
- const p = parseToolKey(t.key);
148
- if (p?.kind === "connector")
149
- connectorSlugs.add(p.slug);
150
- else if (p?.kind === "extension")
151
- extensionNames.add(p.plugin);
152
- }
153
- return { connectorSlugs, extensionNames };
154
- };
155
- const unknownToolText = (name, keys, toolSearch, hint = null) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
156
- (toolSearch ? " Use ToolSearch to load other tools." : "") +
157
- (hint === null ? "" : ` ${hint}`);
140
+ const unknownToolText = (name, keys, toolSearch) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
141
+ (toolSearch ? " Use ToolSearch to load other tools." : "");
158
142
  const unavailableText = (name, reason) => `Tool "${name}" is unavailable: ${reason}.`;
159
143
  /** With a per-call policy key (`Platform:<operation>`), the text names it. */
160
144
  const deniedText = (key, policyKey) => policyKey === undefined || policyKey === key
@@ -365,8 +349,7 @@ let ToolPipeline = class ToolPipeline {
365
349
  effective,
366
350
  switches,
367
351
  inlineViews: (plugin) => new Set((host?.current(plugin)?.ui ?? [])
368
- .filter((r) => r.slot.id === "conversation.tool-result.card" &&
369
- r.contribution.aliasOf === undefined)
352
+ .filter((r) => r.slot.id === "conversation.tool-result.card")
370
353
  .map((r) => r.contribution.id)),
371
354
  onToolsChanged: (orgId, connectorId) => {
372
355
  void drift?.onToolsChanged(orgId, connectorId);
@@ -383,7 +366,9 @@ let ToolPipeline = class ToolPipeline {
383
366
  };
384
367
  const decide = hooks?.decidePolicy;
385
368
  // the default policy reads live, on the context's handle
386
- this.decide = decide ?? ((tool, def, c) => createDecidePolicy(kdb.db)(tool, def, c));
369
+ this.decide =
370
+ decide ??
371
+ ((tool, def, c) => createDecidePolicy(kdb.db, log.debug && { debug: log.debug.bind(log) })(tool, def, c));
387
372
  }
388
373
  /**
389
374
  * tools 节点:按顺序处理本步 assistant 消息里的全部 `tool_call`,每个调用都以一条 `tool_result` 结束
@@ -550,18 +535,7 @@ let ToolPipeline = class ToolPipeline {
550
535
  });
551
536
  return undefined;
552
537
  };
553
- let tool = resolved.tools.find((t) => t.key === call.name);
554
- // A call logged before the tool keys were renamed (spec 8.1): the request that issued it offered
555
- // the old key. It runs as the current tool with translated input; the result keeps the logged key.
556
- let legacy = false;
557
- if (!tool) {
558
- const next = legacyToolKey(call.name, legacyScopeOf(resolved.tools));
559
- const current = next === null ? undefined : resolved.tools.find((t) => t.key === next);
560
- if (current && (await this.requestToolKeys(ctx))?.has(call.name) === true) {
561
- tool = current;
562
- legacy = true;
563
- }
564
- }
538
+ const tool = resolved.tools.find((t) => t.key === call.name);
565
539
  if (!tool) {
566
540
  const why = resolved.unavailable.find((u) => u.ref === call.name) ??
567
541
  resolved.hidden?.find((u) => u.ref === call.name);
@@ -575,21 +549,20 @@ let ToolPipeline = class ToolPipeline {
575
549
  keys = keys.filter((k) => isAlwaysLoaded(k) || sent.has(k));
576
550
  }
577
551
  keys.sort();
578
- return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH), legacyHint(call.name)));
552
+ return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH)));
579
553
  }
580
- const outKey = legacy ? call.name : tool.key;
554
+ const outKey = tool.key;
581
555
  // ToolSearch 模式下,模型只能调用请求里带了完整定义的工具:目录里有、但发出本次调用的请求没加载 →
582
556
  // 明确错误,不自动加载(spec 5.5 / 6.3)。同一步里先 ToolSearch 再调用刚加载的工具同样报错。
583
557
  // This is the protocol working, not a failure: the `not_loaded` view lets the row read neutral.
584
- if (!legacy && resolved.toolSearch === true && !isAlwaysLoaded(tool.key)) {
558
+ if (resolved.toolSearch === true && !isAlwaysLoaded(tool.key)) {
585
559
  const sent = await this.sentTools(ctx);
586
560
  if (sent !== null && !sent.has(tool.key))
587
561
  return fail(notLoadedText(tool.key), outKey, { kind: "not_loaded" });
588
562
  }
589
- const rawInput = legacy ? legacyToolInput(call.name, call.input) : call.input;
590
563
  let input;
591
564
  try {
592
- input = await resolveOutputRefs(rawInput, (id) => this.deps.outputs.load({ orgId: ctx.orgId, conversationId: ctx.conversationId }, id));
565
+ input = await resolveOutputRefs(call.input, (id) => this.deps.outputs.load({ orgId: ctx.orgId, conversationId: ctx.conversationId }, id));
593
566
  }
594
567
  catch (e) {
595
568
  if (e instanceof ToolError)
@@ -611,7 +584,7 @@ let ToolPipeline = class ToolPipeline {
611
584
  agentId: ctx.agentId,
612
585
  conversationId: ctx.conversationId,
613
586
  runId: ctx.runId,
614
- rawInput,
587
+ rawInput: call.input,
615
588
  signal: ctx.signal,
616
589
  })) ?? null;
617
590
  // a deny with a reason (e.g. an unavailable operation): the reason is the tool error
@@ -648,13 +621,10 @@ let ToolPipeline = class ToolPipeline {
648
621
  // (不写 tool_call_started:此时尚未开始执行)。
649
622
  let approval = await this.deps.approvals.forCall(ctx.runId, call.id);
650
623
  // 批准的是旧定义(等待期间工具定义变了):原批准不适用于当前定义,策略仍需审批时按新定义重新审批。
651
- // An in-flight rc call (spec §9) is the exception: its approval was asked under the rc definition
652
- // of the same call, and the rename changed every builtin's definition; the person approved this
653
- // very call, so the approval stands.
654
624
  // An approval binds the exact input it showed (Platform tool spec §6.3): an approved record
655
625
  // whose stored input differs from the call's is not used.
656
626
  const approvedHere = approval?.status === "approved" &&
657
- (legacy || approval.specHash === tool.specHash) &&
627
+ approval.specHash === tool.specHash &&
658
628
  canonicalJson(approval.input) === canonicalJson(call.input ?? {});
659
629
  const stale = approval?.status === "approved" && !approvedHere;
660
630
  if ((!approval || stale) && typeof decision === "object" && "ask" in decision) {
@@ -705,7 +675,7 @@ let ToolPipeline = class ToolPipeline {
705
675
  const hooks = this.deps.pluginHooks;
706
676
  const scope = hookScope(hooks, ctx);
707
677
  if (scope && hooks?.has("tool.preExecute")) {
708
- // sticky: a denial already logged for this call (e.g. an older log, or a crash right after it)
678
+ // sticky: a denial already logged for this call (e.g. a crash right after it)
709
679
  // is final: fail with the recorded reason, never re-run the hooks or execute the tool. Only
710
680
  // looked up when a tool.preExecute hook could run (M-2: no query without hooks); a denial is
711
681
  // written with the call's tool_result, so a call with a logged denial never runs again anyway.
@@ -1276,22 +1246,6 @@ let ToolPipeline = class ToolPipeline {
1276
1246
  },
1277
1247
  ]);
1278
1248
  }
1279
- /**
1280
- * Every tool key the request that issued this step's calls offered (`request.tools` plus the
1281
- * `catalog` keys), in any mode; null when its model_call is not found. Used to tell a call to an
1282
- * old key that was offered (in flight across the rename) from one that never was.
1283
- */
1284
- async requestToolKeys(ctx) {
1285
- // attempts can reach MAX_STEP_MODEL_CALLS after reactive overflow fix-ups; scan from the top
1286
- for (let attempt = MAX_STEP_MODEL_CALLS; attempt >= 1; attempt--) {
1287
- const e = await this.deps.eventLog.findByIdem(ctx.conversationId, modelCallIdemKey(ctx.runId, ctx.step, attempt));
1288
- if (e?.type !== "model_call")
1289
- continue;
1290
- const { tools, catalog } = e.payload.request;
1291
- return new Set([...(tools ?? []), ...(catalog ?? [])].map((t) => t.key));
1292
- }
1293
- return null;
1294
- }
1295
1249
  /**
1296
1250
  * 发出本步调用的请求里带了完整定义的工具 key:本步最后一次尝试的 `model_call.request.tools`
1297
1251
  * (`assistant_message` 来自最后一次尝试)。该请求不在 ToolSearch 模式(没有 `catalog`,工具全部发送)
@@ -1564,6 +1518,7 @@ let ToolPipeline = class ToolPipeline {
1564
1518
  await credentials.onUnauthorized(orgId, connectorId, auth, ctx.accountId, stale);
1565
1519
  },
1566
1520
  signal,
1521
+ orgId,
1567
1522
  onElicit: elicit.handle,
1568
1523
  onToolsChanged: () => {
1569
1524
  try {
@@ -1,4 +1,5 @@
1
1
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
+ import type { KernelLogger } from "../log.js";
2
3
  import type { DecidePolicy } from "./pipeline.js";
3
4
  import type { ToolPolicy } from "./registry.js";
4
5
  export { R3_FIXED_ASK_TOOL_KEYS } from "./builtin-names.js";
@@ -69,7 +70,8 @@ export declare function connectorPolicy(input: {
69
70
  * 结果为 `ask` 时返回审批请求,默认指向发起人本人;记住的授权把 `ask` 放行时返回 `{ grant }`(按 allow 执行)。
70
71
  *
71
72
  * An unattended run (`ctx.unattended`, not a trial run; scheduled tasks spec §7):
72
- * - a tool in the org's `forbiddenTools` (by tool key or per-call key) is denied;
73
+ * - a tool in the org's `forbiddenTools` (by tool key or per-call key) is denied; when the stored
74
+ * list cannot be read every call is refused (`FORBIDDEN_TOOLS_UNREADABLE_ERROR`);
73
75
  * - a Platform call that changes the agent's skills (`agents.register-skill`, ...) is an ask no
74
76
  * grant covers, even on a private agent where it would run without asking;
75
77
  * - an ask is also allowed by a task grant of the current definition (`{ grant: "task" }`), never
@@ -77,4 +79,6 @@ export declare function connectorPolicy(input: {
77
79
  * - in `fail` mode an ask still left is refused (`{ refused, missingGrant }`, no approval), and
78
80
  * `AskUserQuestion` is refused; in `wait` mode both ask the creator as in an attended run.
79
81
  */
80
- export declare function createDecidePolicy(db: KernelSchemaDb): DecidePolicy;
82
+ export declare function createDecidePolicy(db: KernelSchemaDb,
83
+ /** Logs (debug: once per call) when an org's stored security setting is unreadable. */
84
+ log?: Pick<KernelLogger, "debug">): DecidePolicy;
@@ -1,13 +1,13 @@
1
1
  import { sql } from "kysely";
2
+ import { normalizeStoredDefinition } from "../agents/definition.js";
2
3
  import { roleAtLeast } from "../orgs/roles.js";
3
- import { readOrgSettings } from "../orgs/settings.service.js";
4
+ import { FORBIDDEN_TOOLS_UNREADABLE_ERROR, readOrgSettings } from "../orgs/settings.service.js";
4
5
  import { grantRefusalOf } from "../schedules/grant-rules.js";
5
6
  import { findTaskGrant } from "../schedules/store.js";
6
7
  import { changesAgentSkills, UNATTENDED_ASK_ERROR, UNATTENDED_FIXED_ASK_ERROR, UNATTENDED_QUESTION_ERROR, unattendedRules, } from "../schedules/unattended.js";
7
8
  import { BUILTIN, SANDBOX_ASK_TOOL_NAMES } from "./builtin-names.js";
8
9
  import { personalAuth } from "./connector-account-policies.js";
9
10
  import { isFixedAsk } from "./fixed-ask.js";
10
- import { normalizeStoredDefinitionIn } from "./legacy-data.js";
11
11
  export { R3_FIXED_ASK_TOOL_KEYS } from "./builtin-names.js";
12
12
  export { isFixedAsk } from "./fixed-ask.js";
13
13
  const RANK = { allow: 0, ask: 1, deny: 2 };
@@ -93,7 +93,8 @@ export function connectorPolicy(input) {
93
93
  * 结果为 `ask` 时返回审批请求,默认指向发起人本人;记住的授权把 `ask` 放行时返回 `{ grant }`(按 allow 执行)。
94
94
  *
95
95
  * An unattended run (`ctx.unattended`, not a trial run; scheduled tasks spec §7):
96
- * - a tool in the org's `forbiddenTools` (by tool key or per-call key) is denied;
96
+ * - a tool in the org's `forbiddenTools` (by tool key or per-call key) is denied; when the stored
97
+ * list cannot be read every call is refused (`FORBIDDEN_TOOLS_UNREADABLE_ERROR`);
97
98
  * - a Platform call that changes the agent's skills (`agents.register-skill`, ...) is an ask no
98
99
  * grant covers, even on a private agent where it would run without asking;
99
100
  * - an ask is also allowed by a task grant of the current definition (`{ grant: "task" }`), never
@@ -101,7 +102,9 @@ export function connectorPolicy(input) {
101
102
  * - in `fail` mode an ask still left is refused (`{ refused, missingGrant }`, no approval), and
102
103
  * `AskUserQuestion` is refused; in `wait` mode both ask the creator as in an attended run.
103
104
  */
104
- export function createDecidePolicy(db) {
105
+ export function createDecidePolicy(db,
106
+ /** Logs (debug: once per call) when an org's stored security setting is unreadable. */
107
+ log) {
105
108
  return async (tool, agentDef, ctx) => {
106
109
  // a per-call policy (Platform tool spec §6.2): its key replaces the tool key for policies,
107
110
  // grants and approvals, and its policy replaces the tool's default
@@ -161,6 +164,10 @@ export function createDecidePolicy(db) {
161
164
  // scheduled tasks spec §7: what an unattended run may not do at all
162
165
  const unattended = unattendedRules(ctx.unattended) ? ctx.unattended : undefined;
163
166
  if (unattended !== undefined) {
167
+ // fail closed: an unreadable list never runs as "nothing forbidden"
168
+ if (unattended.forbiddenToolsUnreadable === true) {
169
+ return { refused: FORBIDDEN_TOOLS_UNREADABLE_ERROR };
170
+ }
164
171
  const forbidden = unattended.forbiddenTools;
165
172
  if (forbidden.includes(tool.key) || forbidden.includes(policyKey))
166
173
  return "deny";
@@ -174,7 +181,7 @@ export function createDecidePolicy(db) {
174
181
  // `orgAsk`: the org setting, not the tool's own default, is what makes it ask
175
182
  let orgAsk = false;
176
183
  if (tool.source.kind === "builtin" && SANDBOX_ASK_TOOL_NAMES.has(tool.source.name)) {
177
- if ((await readOrgSettings(db, ctx.orgId)).sandboxToolPolicy === "ask") {
184
+ if ((await readOrgSettings(db, ctx.orgId, log)).sandboxToolPolicy === "ask") {
178
185
  orgAsk = connectorDefault === "allow";
179
186
  connectorDefault = stricter(connectorDefault, "ask");
180
187
  }
@@ -189,10 +196,7 @@ export function createDecidePolicy(db) {
189
196
  .select(["agent_versions.definition"])
190
197
  .where("agents.id", "=", ctx.agentId)
191
198
  .executeTakeFirst();
192
- // stored raw: an rc version's keys read as current keys, so its deny keeps applying (§8.3)
193
- const currentDef = current === undefined
194
- ? undefined
195
- : await normalizeStoredDefinitionIn(db, ctx.orgId, current.definition);
199
+ const currentDef = current === undefined ? undefined : normalizeStoredDefinition(current.definition);
196
200
  const currentPolicies = currentDef?.toolPolicies;
197
201
  const currentSetting = settingOf(currentPolicies, tool.key, policyKey);
198
202
  // the run's version, the agent's current version and (a sub-agent) its parent agent's
@@ -331,9 +335,7 @@ async function parentAgentSetting(db, toolKey, policyKey, ctx) {
331
335
  .executeTakeFirst();
332
336
  if (!row || row.id === ctx.agentId)
333
337
  return undefined;
334
- // stored raw: an rc version's keys read as current keys, so its deny keeps applying (§8.3)
335
- const policies = (await normalizeStoredDefinitionIn(db, ctx.orgId, row.definition))
336
- .toolPolicies;
338
+ const policies = normalizeStoredDefinition(row.definition).toolPolicies;
337
339
  return settingOf(policies, toolKey, policyKey);
338
340
  }
339
341
  /**
@@ -24,7 +24,6 @@ import { AGENT_BUILTIN_NAMES, AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN, SEND_ME
24
24
  import { agentToolSpec } from "./builtins/agent.js";
25
25
  import { BuiltinTools } from "./builtins/builtin-tools.js";
26
26
  import { canonicalJson } from "./canonical-json.js";
27
- import { legacyKeySaveText } from "./legacy-keys.js";
28
27
  import { toolKeyIssue } from "./naming.js";
29
28
  import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
30
29
  export { BUILTIN_TOOL_NAMES } from "./builtin-names.js";
@@ -244,12 +243,9 @@ let ToolRegistry = class ToolRegistry {
244
243
  return;
245
244
  if (ref.kind === "builtin") {
246
245
  if (!builtins.has(ref.name)) {
247
- const renamed = legacyKeySaveText(ref.name);
248
246
  issues.push({
249
247
  path,
250
- message: renamed !== null
251
- ? `Built-in tool ${renamed}`
252
- : `"${ref.name}" is not a built-in tool an agent can turn off`,
248
+ message: `"${ref.name}" is not a built-in tool an agent can turn off`,
253
249
  });
254
250
  }
255
251
  }
@@ -132,7 +132,7 @@ export declare class UiViews {
132
132
  * The contributions the role may use in the org, of one slot or of every org-reachable slot:
133
133
  * the extension enabled and loaded, a view's render registered (a component is listed with or
134
134
  * without a server view), the slot's `minRole` ({@link canUseSlot}, so never `platform.page`);
135
- * no alias, no `file.preview` contribution (the file previewers list those). Base order (spec
135
+ * no `file.preview` contribution (the file previewers list those). Base order (spec
136
136
  * §5): extension name, then manifest order. A single slot lists at most its winner
137
137
  * ({@link resolveSingleSlot} over what this role may use: none until one is chosen, and the web
138
138
  * renders the built-in); display only, the routes that serve a contribution never read it. The
@@ -157,7 +157,7 @@ export declare class UiViews {
157
157
  platformArrangementView(): Promise<UiArrangementSlot[]>;
158
158
  /**
159
159
  * The `platform.page` contributions of the running extensions, for the admin console (super
160
- * admins; no org enablement applies): no alias, a view's render registered (a component is
160
+ * admins; no org enablement applies): a view's render registered (a component is
161
161
  * listed with or without a server view). Base order like {@link contributions}.
162
162
  */
163
163
  platformContributions(): Promise<UiContributionItem[]>;
@@ -174,11 +174,11 @@ export declare class UiViews {
174
174
  payload?: unknown;
175
175
  answer?: FormAnswer;
176
176
  }): Promise<UiActionResult>;
177
- /** Ids of the extension's live `panel` contributions (aliases of panels included). */
177
+ /** Ids of the extension's live `panel` contributions. */
178
178
  private panels;
179
179
  /**
180
- * The single access gate of the org UI routes (UI slots spec §7): finds the contribution (a
181
- * retired alias answers with the one it names), then checks, in order, that its slot is reachable
180
+ * The single access gate of the org UI routes (UI slots spec §7): finds the contribution, then
181
+ * checks, in order, that its slot is reachable
182
182
  * from an org (not `platform`), the role meets the slot's `minRole`, the extension is enabled in
183
183
  * the org, its effective config is valid, and the slot's scope rule (conversation: readable;
184
184
  * agent: readable and in this org; org: the role alone; file: a conversation the caller reads,
package/dist/ui/views.js CHANGED
@@ -73,14 +73,13 @@ export function dropForeignOpens(view, panels) {
73
73
  return { ...rest, ...(open !== undefined && ok(open) && { open }), blocks };
74
74
  }
75
75
  /**
76
- * Lists contributions for a listing route: no alias, a view's render registered (an embed or a
76
+ * Lists contributions for a listing route: a view's render registered (an embed or a
77
77
  * component is listed without one: a component's server view is optional); base order (spec §5):
78
78
  * extension name, then manifest order (stable).
79
79
  */
80
80
  function listed(entries) {
81
81
  return entries
82
- .filter((c) => c.contribution.aliasOf === undefined &&
83
- (c.contribution.kind === "embed" || c.contribution.kind === "component" || c.render))
82
+ .filter((c) => c.contribution.kind === "embed" || c.contribution.kind === "component" || c.render)
84
83
  .map((c, i) => ({ c, i }))
85
84
  .sort((x, y) => (x.c.plugin === y.c.plugin ? x.i - y.i : x.c.plugin < y.c.plugin ? -1 : 1))
86
85
  .map(({ c: { plugin, contribution: c, slot: s, after } }) => ({
@@ -171,7 +170,7 @@ let UiViews = class UiViews {
171
170
  * The contributions the role may use in the org, of one slot or of every org-reachable slot:
172
171
  * the extension enabled and loaded, a view's render registered (a component is listed with or
173
172
  * without a server view), the slot's `minRole` ({@link canUseSlot}, so never `platform.page`);
174
- * no alias, no `file.preview` contribution (the file previewers list those). Base order (spec
173
+ * no `file.preview` contribution (the file previewers list those). Base order (spec
175
174
  * §5): extension name, then manifest order. A single slot lists at most its winner
176
175
  * ({@link resolveSingleSlot} over what this role may use: none until one is chosen, and the web
177
176
  * renders the built-in); display only, the routes that serve a contribution never read it. The
@@ -254,7 +253,7 @@ let UiViews = class UiViews {
254
253
  }
255
254
  /**
256
255
  * The `platform.page` contributions of the running extensions, for the admin console (super
257
- * admins; no org enablement applies): no alias, a view's render registered (a component is
256
+ * admins; no org enablement applies): a view's render registered (a component is
258
257
  * listed with or without a server view). Base order like {@link contributions}.
259
258
  */
260
259
  async platformContributions() {
@@ -337,7 +336,7 @@ let UiViews = class UiViews {
337
336
  return { view: dropForeignOpens(res.view, this.panels(t.plugin)) };
338
337
  return res.toast !== undefined ? { toast: { zh: res.toast.zh, en: res.toast.en } } : {};
339
338
  }
340
- /** Ids of the extension's live `panel` contributions (aliases of panels included). */
339
+ /** Ids of the extension's live `panel` contributions. */
341
340
  panels(plugin) {
342
341
  return new Set(this.d.host
343
342
  .uiContributions()
@@ -345,8 +344,8 @@ let UiViews = class UiViews {
345
344
  .map((c) => c.contribution.id));
346
345
  }
347
346
  /**
348
- * The single access gate of the org UI routes (UI slots spec §7): finds the contribution (a
349
- * retired alias answers with the one it names), then checks, in order, that its slot is reachable
347
+ * The single access gate of the org UI routes (UI slots spec §7): finds the contribution, then
348
+ * checks, in order, that its slot is reachable
350
349
  * from an org (not `platform`), the role meets the slot's `minRole`, the extension is enabled in
351
350
  * the org, its effective config is valid, and the slot's scope rule (conversation: readable;
352
351
  * agent: readable and in this org; org: the role alone; file: a conversation the caller reads,
@@ -357,13 +356,8 @@ let UiViews = class UiViews {
357
356
  */
358
357
  async resolve(t, need) {
359
358
  const loaded = this.d.host.uiContributions();
360
- const named = loaded.find((c) => c.plugin === t.plugin && c.contribution.id === t.id);
361
- // a retired alias answers with the contribution it names (same extension and kind)
362
- const aliasOf = named?.contribution.aliasOf;
363
- const id = aliasOf ?? t.id;
364
359
  const entry = loaded.find((c) => c.plugin === t.plugin &&
365
- c.contribution.id === id &&
366
- c.contribution.aliasOf === undefined &&
360
+ c.contribution.id === t.id &&
367
361
  (need === "embed"
368
362
  ? c.contribution.kind === "embed"
369
363
  : // a view, or a component's server view (served like a view of its slot)
@@ -433,13 +427,13 @@ let UiViews = class UiViews {
433
427
  await this.d.checkWritable?.(t.orgId, conversationId, t.accountId);
434
428
  if (t.card !== undefined) {
435
429
  // args.card is attested: an inline view, and a tool_result of this conversation recorded this
436
- // very card (plugin, the requested id or its alias target, key); else it is not found
430
+ // very card (plugin, the requested id, key); else it is not found
437
431
  const recorded = entry.slot.id === "conversation.tool-result.card" && this.d.recordedCard !== undefined
438
432
  ? await this.d.recordedCard(conversationId, t.card.callId)
439
433
  : null;
440
434
  if (recorded === null ||
441
435
  recorded.plugin !== t.plugin ||
442
- (recorded.view !== t.id && recorded.view !== id) ||
436
+ recorded.view !== t.id ||
443
437
  recorded.key !== t.card.key) {
444
438
  throw notFound();
445
439
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.36",
3
+ "version": "0.1.0-rc.38",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -65,7 +65,7 @@
65
65
  "yaml": "^2.9.1",
66
66
  "yauzl": "3.4.0",
67
67
  "zod": "^4.6.7",
68
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.25"
68
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.29"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -74,7 +74,7 @@
74
74
  "@types/ws": "^8.18.2",
75
75
  "@types/yauzl": "3.4.0",
76
76
  "ws": "^8.22.0",
77
- "@capybara-hq/testing": "0.1.0-rc.20"
77
+ "@capybara-hq/testing": "0.1.0-rc.23"
78
78
  },
79
79
  "scripts": {
80
80
  "build": "tsc -b"