@capybara-hq/kernel 0.1.0-rc.2 → 0.1.0-rc.4

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 (312) hide show
  1. package/dist/admin/admin.controller.d.ts +9 -4
  2. package/dist/admin/admin.controller.js +13 -4
  3. package/dist/admin/extensions.controller.d.ts +8 -1
  4. package/dist/admin/extensions.controller.js +22 -2
  5. package/dist/agents/agent-lookup.d.ts +3 -0
  6. package/dist/agents/agent-lookup.js +20 -2
  7. package/dist/agents/agent-profile.service.d.ts +29 -0
  8. package/dist/agents/agent-profile.service.js +117 -0
  9. package/dist/agents/agents.controller.d.ts +93 -3
  10. package/dist/agents/agents.controller.js +114 -4
  11. package/dist/agents/agents.module.js +6 -2
  12. package/dist/agents/agents.service.d.ts +13 -5
  13. package/dist/agents/agents.service.js +49 -13
  14. package/dist/agents/definition.d.ts +35 -8
  15. package/dist/agents/definition.js +203 -17
  16. package/dist/agents/instruction-files.d.ts +60 -0
  17. package/dist/agents/instruction-files.js +111 -0
  18. package/dist/agents/models.controller.d.ts +9 -3
  19. package/dist/agents/models.controller.js +19 -4
  20. package/dist/agents/profile.d.ts +96 -0
  21. package/dist/agents/profile.js +51 -0
  22. package/dist/agents/readiness.controller.d.ts +26 -0
  23. package/dist/agents/readiness.controller.js +56 -0
  24. package/dist/agents/templates.js +20 -5
  25. package/dist/background/background.controller.d.ts +38 -0
  26. package/dist/background/background.controller.js +87 -0
  27. package/dist/background/background.module.d.ts +10 -0
  28. package/dist/background/background.module.js +32 -0
  29. package/dist/background/finish.d.ts +43 -0
  30. package/dist/background/finish.js +94 -0
  31. package/dist/background/launch-lock.d.ts +14 -0
  32. package/dist/background/launch-lock.js +39 -0
  33. package/dist/background/launch.d.ts +36 -0
  34. package/dist/background/launch.js +70 -0
  35. package/dist/background/poll.job.d.ts +53 -0
  36. package/dist/background/poll.job.js +182 -0
  37. package/dist/background/render.d.ts +23 -0
  38. package/dist/background/render.js +48 -0
  39. package/dist/background/session.d.ts +37 -0
  40. package/dist/background/session.js +66 -0
  41. package/dist/background/status.d.ts +35 -0
  42. package/dist/background/status.js +57 -0
  43. package/dist/background/stop.d.ts +62 -0
  44. package/dist/background/stop.js +225 -0
  45. package/dist/background/store.d.ts +150 -0
  46. package/dist/background/store.js +351 -0
  47. package/dist/background/store.module.d.ts +6 -0
  48. package/dist/background/store.module.js +22 -0
  49. package/dist/background/tasks.service.d.ts +67 -0
  50. package/dist/background/tasks.service.js +186 -0
  51. package/dist/background/wake-rules.d.ts +57 -0
  52. package/dist/background/wake-rules.js +83 -0
  53. package/dist/background/wake.d.ts +28 -0
  54. package/dist/background/wake.js +57 -0
  55. package/dist/catalog/catalog-content.js +4 -1
  56. package/dist/catalog/claude/agents.js +15 -10
  57. package/dist/catalog/marketplaces.service.d.ts +1 -1
  58. package/dist/catalog/plugin-import.js +1 -1
  59. package/dist/catalog/plugin-upgrade.js +1 -1
  60. package/dist/channels/cards.d.ts +8 -2
  61. package/dist/channels/cards.js +17 -9
  62. package/dist/channels/connections.service.d.ts +16 -1
  63. package/dist/channels/connections.service.js +38 -4
  64. package/dist/channels/threads.d.ts +5 -0
  65. package/dist/channels/threads.js +8 -0
  66. package/dist/config/schema.d.ts +18 -0
  67. package/dist/config/schema.js +104 -2
  68. package/dist/conversations/access.js +2 -0
  69. package/dist/conversations/artifacts.d.ts +1 -1
  70. package/dist/conversations/artifacts.js +1 -1
  71. package/dist/conversations/attachments.service.d.ts +30 -0
  72. package/dist/conversations/attachments.service.js +130 -5
  73. package/dist/conversations/conversations.controller.d.ts +36 -5
  74. package/dist/conversations/conversations.controller.js +62 -12
  75. package/dist/conversations/conversations.module.js +3 -0
  76. package/dist/conversations/conversations.service.d.ts +44 -2
  77. package/dist/conversations/conversations.service.js +140 -12
  78. package/dist/conversations/event-log.d.ts +12 -1
  79. package/dist/conversations/event-log.js +29 -1
  80. package/dist/conversations/events.d.ts +81 -3
  81. package/dist/conversations/events.js +83 -16
  82. package/dist/conversations/queue.d.ts +3 -1
  83. package/dist/conversations/queue.js +13 -2
  84. package/dist/conversations/queue.service.js +3 -1
  85. package/dist/conversations/titles.d.ts +7 -0
  86. package/dist/conversations/titles.js +15 -0
  87. package/dist/db/kernel-schema.d.ts +60 -4
  88. package/dist/db/pool.d.ts +5 -0
  89. package/dist/db/pool.js +3 -0
  90. package/dist/errors.d.ts +8 -0
  91. package/dist/errors.js +8 -0
  92. package/dist/evals/recorded-tools.d.ts +27 -1
  93. package/dist/evals/recorded-tools.js +85 -10
  94. package/dist/evals/run-replay.d.ts +10 -2
  95. package/dist/evals/run-replay.js +49 -12
  96. package/dist/evals/step-replay.js +12 -6
  97. package/dist/evals/trajectory.d.ts +2 -2
  98. package/dist/evals/trajectory.js +1 -1
  99. package/dist/extensions/admin-ops.js +2 -0
  100. package/dist/extensions/admin-view.d.ts +3 -1
  101. package/dist/extensions/admin-view.js +10 -2
  102. package/dist/extensions/blobs.js +1 -0
  103. package/dist/extensions/config-issues.d.ts +13 -1
  104. package/dist/extensions/config-issues.js +22 -5
  105. package/dist/extensions/config-json-schema.d.ts +43 -7
  106. package/dist/extensions/config-json-schema.js +124 -58
  107. package/dist/extensions/deployment-config-store.d.ts +6 -0
  108. package/dist/extensions/deployment-config.d.ts +50 -3
  109. package/dist/extensions/deployment-config.js +125 -28
  110. package/dist/extensions/display-name.d.ts +22 -0
  111. package/dist/extensions/display-name.js +77 -0
  112. package/dist/extensions/extensions.module.js +6 -0
  113. package/dist/extensions/host.d.ts +26 -1
  114. package/dist/extensions/host.js +82 -9
  115. package/dist/extensions/org-config.controller.d.ts +11 -3
  116. package/dist/extensions/org-config.controller.js +14 -6
  117. package/dist/extensions/org-config.d.ts +6 -0
  118. package/dist/extensions/org-config.js +12 -13
  119. package/dist/extensions/package.d.ts +14 -1
  120. package/dist/extensions/package.js +51 -2
  121. package/dist/extensions/permission-view.d.ts +3 -0
  122. package/dist/extensions/point-defaults.controller.d.ts +34 -0
  123. package/dist/extensions/point-defaults.controller.js +71 -0
  124. package/dist/extensions/point-defaults.d.ts +64 -0
  125. package/dist/extensions/point-defaults.js +206 -0
  126. package/dist/extensions/registry.d.ts +1 -1
  127. package/dist/extensions/registry.js +2 -0
  128. package/dist/http/api.module.js +8 -0
  129. package/dist/http/nest-logger.d.ts +6 -5
  130. package/dist/http/nest-logger.js +24 -10
  131. package/dist/identity/auth.controller.js +9 -5
  132. package/dist/identity/cookies.d.ts +20 -5
  133. package/dist/identity/cookies.js +44 -6
  134. package/dist/identity/me.controller.d.ts +5 -1
  135. package/dist/identity/me.controller.js +12 -3
  136. package/dist/identity/sessions.d.ts +12 -0
  137. package/dist/identity/sessions.js +45 -0
  138. package/dist/identity/settings.js +1 -1
  139. package/dist/index.d.ts +1 -1
  140. package/dist/infra/config/kernel-config.service.js +6 -0
  141. package/dist/infra/database/database.module.js +1 -0
  142. package/dist/infra/events/kernel-events.d.ts +8 -0
  143. package/dist/infra/lifecycle/process-guards.js +4 -0
  144. package/dist/infra/logging/logging.module.d.ts +4 -2
  145. package/dist/infra/logging/logging.module.js +24 -6
  146. package/dist/infra/queue/redis-connection.d.ts +6 -0
  147. package/dist/infra/queue/redis-connection.js +7 -0
  148. package/dist/infra/redis/redis.module.js +6 -2
  149. package/dist/infra/tokens.d.ts +6 -1
  150. package/dist/infra/tokens.js +6 -1
  151. package/dist/lifecycle/kernel-lifecycle.js +5 -0
  152. package/dist/log.d.ts +13 -1
  153. package/dist/log.js +93 -17
  154. package/dist/models/purposes.d.ts +23 -0
  155. package/dist/models/purposes.js +31 -10
  156. package/dist/orgs/offboarding.d.ts +3 -1
  157. package/dist/orgs/offboarding.js +26 -16
  158. package/dist/orgs/settings.service.d.ts +7 -2
  159. package/dist/orgs/settings.service.js +15 -4
  160. package/dist/roles/worker.module.js +6 -0
  161. package/dist/runtime/context/build.d.ts +15 -13
  162. package/dist/runtime/context/build.js +45 -27
  163. package/dist/runtime/context/claude-tools.d.ts +3 -1
  164. package/dist/runtime/context/claude-tools.js +12 -12
  165. package/dist/runtime/context/compaction.js +4 -0
  166. package/dist/runtime/context/legacy-text.d.ts +22 -0
  167. package/dist/runtime/context/legacy-text.js +37 -0
  168. package/dist/runtime/context/skills.d.ts +29 -11
  169. package/dist/runtime/context/skills.js +37 -30
  170. package/dist/runtime/langgraph-loop.js +3 -2
  171. package/dist/runtime/loop.d.ts +5 -4
  172. package/dist/runtime/maintenance.d.ts +4 -2
  173. package/dist/runtime/maintenance.js +17 -5
  174. package/dist/runtime/model-call.d.ts +17 -1
  175. package/dist/runtime/model-call.js +4 -3
  176. package/dist/runtime/providers.d.ts +6 -0
  177. package/dist/runtime/providers.js +8 -0
  178. package/dist/runtime/run-finish.d.ts +1 -1
  179. package/dist/runtime/run-queue.d.ts +28 -5
  180. package/dist/runtime/run-queue.js +131 -35
  181. package/dist/runtime/run-worker.d.ts +2 -2
  182. package/dist/runtime/run-worker.js +20 -7
  183. package/dist/runtime/runtime.module.js +8 -3
  184. package/dist/runtime/step-log.d.ts +6 -0
  185. package/dist/runtime/step-log.js +16 -2
  186. package/dist/runtime/subagents/definition.d.ts +1 -6
  187. package/dist/runtime/subagents/definition.js +14 -13
  188. package/dist/runtime/subagents/dispatch.d.ts +2 -2
  189. package/dist/runtime/subagents/dispatch.js +2 -2
  190. package/dist/runtime/subagents/org-agents.js +2 -1
  191. package/dist/runtime/subagents/roster.d.ts +1 -1
  192. package/dist/runtime/subagents/roster.js +1 -1
  193. package/dist/runtime/subagents/skill-fork.d.ts +2 -2
  194. package/dist/runtime/subagents/skill-fork.js +2 -2
  195. package/dist/runtime/subagents/subagents.service.d.ts +3 -3
  196. package/dist/runtime/subagents/subagents.service.js +3 -3
  197. package/dist/runtime/usage-report.d.ts +2 -1
  198. package/dist/runtime/usage-report.js +2 -1
  199. package/dist/runtime/waits.d.ts +13 -7
  200. package/dist/runtime/waits.js +42 -16
  201. package/dist/sandbox/sandbox.module.js +6 -1
  202. package/dist/sandbox/sandbox.service.d.ts +61 -3
  203. package/dist/sandbox/sandbox.service.js +141 -7
  204. package/dist/skills/catalog.d.ts +4 -4
  205. package/dist/skills/catalog.js +4 -4
  206. package/dist/skills/changes.service.d.ts +2 -2
  207. package/dist/skills/changes.service.js +5 -4
  208. package/dist/skills/invocation-keys.d.ts +1 -1
  209. package/dist/skills/invocation-keys.js +1 -1
  210. package/dist/skills/invoke.d.ts +1 -1
  211. package/dist/skills/invoke.js +5 -4
  212. package/dist/tools/approvals.service.d.ts +6 -0
  213. package/dist/tools/approvals.service.js +21 -1
  214. package/dist/tools/builtin-names.d.ts +91 -0
  215. package/dist/tools/builtin-names.js +143 -0
  216. package/dist/tools/builtins/agent.d.ts +7 -7
  217. package/dist/tools/builtins/agent.js +7 -11
  218. package/dist/tools/builtins/ask-user.d.ts +1 -1
  219. package/dist/tools/builtins/ask-user.js +2 -2
  220. package/dist/tools/builtins/builtin-tools.d.ts +17 -3
  221. package/dist/tools/builtins/builtin-tools.js +36 -4
  222. package/dist/tools/builtins/read-tool-output.d.ts +1 -1
  223. package/dist/tools/builtins/read-tool-output.js +2 -2
  224. package/dist/tools/builtins/sandbox/bash.d.ts +4 -4
  225. package/dist/tools/builtins/sandbox/bash.js +259 -29
  226. package/dist/tools/builtins/sandbox/common.d.ts +30 -7
  227. package/dist/tools/builtins/sandbox/common.js +9 -5
  228. package/dist/tools/builtins/sandbox/deliver.d.ts +1 -1
  229. package/dist/tools/builtins/sandbox/deliver.js +12 -12
  230. package/dist/tools/builtins/sandbox/edit.d.ts +1 -1
  231. package/dist/tools/builtins/sandbox/edit.js +41 -30
  232. package/dist/tools/builtins/sandbox/file-state.d.ts +34 -0
  233. package/dist/tools/builtins/sandbox/file-state.js +34 -0
  234. package/dist/tools/builtins/sandbox/glob-match.d.ts +1 -1
  235. package/dist/tools/builtins/sandbox/glob-match.js +1 -1
  236. package/dist/tools/builtins/sandbox/glob.d.ts +1 -1
  237. package/dist/tools/builtins/sandbox/glob.js +4 -4
  238. package/dist/tools/builtins/sandbox/grep.d.ts +7 -4
  239. package/dist/tools/builtins/sandbox/grep.js +147 -30
  240. package/dist/tools/builtins/sandbox/index.d.ts +3 -1
  241. package/dist/tools/builtins/sandbox/index.js +7 -1
  242. package/dist/tools/builtins/sandbox/read.d.ts +2 -2
  243. package/dist/tools/builtins/sandbox/read.js +21 -14
  244. package/dist/tools/builtins/sandbox/task-output.d.ts +63 -0
  245. package/dist/tools/builtins/sandbox/task-output.js +304 -0
  246. package/dist/tools/builtins/sandbox/task-stop.d.ts +10 -0
  247. package/dist/tools/builtins/sandbox/task-stop.js +112 -0
  248. package/dist/tools/builtins/sandbox/write.d.ts +1 -1
  249. package/dist/tools/builtins/sandbox/write.js +37 -33
  250. package/dist/tools/builtins/skill-load.d.ts +3 -3
  251. package/dist/tools/builtins/skill-load.js +32 -16
  252. package/dist/tools/builtins/skill-write.d.ts +4 -4
  253. package/dist/tools/builtins/skill-write.js +10 -10
  254. package/dist/tools/builtins/tool-search.d.ts +13 -9
  255. package/dist/tools/builtins/tool-search.js +25 -14
  256. package/dist/tools/builtins/web/errors.d.ts +8 -0
  257. package/dist/tools/builtins/web/errors.js +53 -0
  258. package/dist/tools/builtins/web/extract.d.ts +62 -0
  259. package/dist/tools/builtins/web/extract.js +267 -0
  260. package/dist/tools/builtins/web/fetch.d.ts +55 -0
  261. package/dist/tools/builtins/web/fetch.js +174 -0
  262. package/dist/tools/builtins/web/index.d.ts +13 -0
  263. package/dist/tools/builtins/web/index.js +12 -0
  264. package/dist/tools/builtins/web/page-cache.d.ts +25 -0
  265. package/dist/tools/builtins/web/page-cache.js +77 -0
  266. package/dist/tools/builtins/web/search.d.ts +25 -0
  267. package/dist/tools/builtins/web/search.js +209 -0
  268. package/dist/tools/builtins/web/url.d.ts +17 -0
  269. package/dist/tools/builtins/web/url.js +43 -0
  270. package/dist/tools/connectors.service.js +4 -4
  271. package/dist/tools/display-names.d.ts +9 -0
  272. package/dist/tools/display-names.js +24 -0
  273. package/dist/tools/drift.js +5 -5
  274. package/dist/tools/elicitation.js +1 -1
  275. package/dist/tools/info.d.ts +20 -4
  276. package/dist/tools/info.js +55 -32
  277. package/dist/tools/legacy-data.d.ts +34 -0
  278. package/dist/tools/legacy-data.js +76 -0
  279. package/dist/tools/legacy-keys.d.ts +51 -0
  280. package/dist/tools/legacy-keys.js +115 -0
  281. package/dist/tools/naming.d.ts +1 -5
  282. package/dist/tools/naming.js +1 -7
  283. package/dist/tools/oauth/flow-paths.d.ts +1 -1
  284. package/dist/tools/oauth/flow-paths.js +1 -1
  285. package/dist/tools/outputs.js +1 -1
  286. package/dist/tools/pipeline.d.ts +13 -7
  287. package/dist/tools/pipeline.js +112 -39
  288. package/dist/tools/policy.d.ts +1 -14
  289. package/dist/tools/policy.js +13 -19
  290. package/dist/tools/questions.controller.d.ts +1 -1
  291. package/dist/tools/questions.controller.js +1 -1
  292. package/dist/tools/questions.service.d.ts +1 -1
  293. package/dist/tools/registry.d.ts +38 -24
  294. package/dist/tools/registry.js +54 -47
  295. package/dist/tools/resources.d.ts +1 -1
  296. package/dist/tools/resources.js +1 -1
  297. package/dist/tools/tools.module.js +13 -1
  298. package/dist/tools/validate.js +1 -1
  299. package/package.json +3 -3
  300. package/src/migrations/0063_tool_keys_claude_code.sql +220 -0
  301. package/src/migrations/0064_account_last_org.sql +7 -0
  302. package/src/migrations/0065_conversation_archive.sql +8 -0
  303. package/src/migrations/0066_extension_display_name.sql +4 -0
  304. package/src/migrations/0067_agent_profiles.sql +20 -0
  305. package/src/migrations/0068_agent_avatar_uploads.sql +7 -0
  306. package/src/migrations/0069_attachments_agent_idx.sql +3 -0
  307. package/src/migrations/0070_background_tasks.sql +37 -0
  308. package/src/migrations/0071_background_tasks_reserve.sql +6 -0
  309. package/src/migrations/0072_background_tasks_stopping.sql +5 -0
  310. package/src/migrations/0073_org_extension_point_defaults.sql +11 -0
  311. package/dist/tools/builtins/sandbox/names.d.ts +0 -7
  312. package/dist/tools/builtins/sandbox/names.js +0 -20
@@ -7,28 +7,17 @@ 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 { connectorToolKey, extensionToolKey, parseToolKey, } from "@capybara-hq/plugin-sdk";
10
11
  import { Inject, Injectable } from "@nestjs/common";
11
12
  import { ConversationAccess } from "../conversations/access.js";
12
13
  import { ApiError } from "../errors.js";
13
14
  import { KernelDb } from "../infra/database/kernel-db.js";
14
15
  import { UUID_RE } from "../ui/registry.js";
15
- import { KEY_SEPARATOR, toolKey } from "./naming.js";
16
+ import { BUILTIN_TOOL_KINDS, SANDBOX_TOOL_NAMES } from "./builtin-names.js";
17
+ import { pluginDisplayNames } from "./display-names.js";
18
+ import { isLegacyBuiltinKey, LEGACY_BUILTINS } from "./legacy-keys.js";
16
19
  import { ToolRegistry } from "./registry.js";
17
- /** Kinds of the kernel builtin tools; a builtin missing here is a plain `tool`. */
18
- export const BUILTIN_TOOL_KINDS = {
19
- sandbox_bash: "command",
20
- sandbox_read: "read",
21
- sandbox_write: "edit",
22
- sandbox_edit: "edit",
23
- sandbox_glob: "search",
24
- sandbox_grep: "search",
25
- sandbox_deliver: "tool",
26
- tool_search: "meta",
27
- skill_load: "meta",
28
- skill_write: "meta",
29
- read_tool_output: "meta",
30
- ask_user: "meta",
31
- };
20
+ export { BUILTIN_TOOL_KINDS } from "./builtin-names.js";
32
21
  /** At most this many keys per request, each at most {@link TOOL_INFO_KEY_MAX} characters. */
33
22
  export const TOOL_INFO_MAX_KEYS = 100;
34
23
  export const TOOL_INFO_KEY_MAX = 200;
@@ -38,7 +27,7 @@ const display = (spec) => ({
38
27
  });
39
28
  /**
40
29
  * Presentation metadata for `keys` in this org, in request order with repeats dropped. Builtins
41
- * by name; `<prefix>__<tool>` keys first as a loaded extension's registration, then as a live
30
+ * 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
42
31
  * connector's current stored tool (its reviewed definition, never a pending one). Anything else
43
32
  * comes back as an unknown plain tool.
44
33
  *
@@ -55,17 +44,13 @@ const display = (spec) => ({
55
44
  export async function toolInfo(deps, orgId, keys) {
56
45
  const unique = [...new Set(keys)];
57
46
  const builtins = new Map(deps.registry.builtinSpecs().map((s) => [s.name, s]));
58
- const extensions = new Map(deps.registry.extensionToolSpecs().map((t) => [toolKey(t.plugin, t.spec.name), t]));
59
- const split = (key) => {
60
- const i = key.indexOf(KEY_SEPARATOR);
61
- return i > 0 ? [key.slice(0, i), key.slice(i + KEY_SEPARATOR.length)] : null;
62
- };
47
+ const extensions = new Map(deps.registry.extensionToolSpecs().map((t) => [extensionToolKey(t.plugin, t.spec.name), t]));
63
48
  const slugs = [
64
49
  ...new Set(unique.flatMap((k) => {
65
50
  if (builtins.has(k) || extensions.has(k))
66
51
  return [];
67
- const p = split(k);
68
- return p ? [p[0]] : [];
52
+ const p = parseToolKey(k);
53
+ return p?.kind === "connector" ? [p.slug] : [];
69
54
  })),
70
55
  ];
71
56
  const connectorRows = slugs.length === 0
@@ -78,15 +63,37 @@ export async function toolInfo(deps, orgId, keys) {
78
63
  .where("c.deleted_at", "is", null)
79
64
  .where("c.slug", "in", slugs)
80
65
  .execute();
81
- const connectorTools = new Map(connectorRows.map((r) => [toolKey(r.slug, r.tool), r]));
66
+ const connectorTools = new Map(connectorRows.map((r) => [connectorToolKey(r.slug, r.tool), r]));
67
+ const displayNames = await pluginDisplayNames(deps.db, unique.flatMap((k) => {
68
+ const e = extensions.get(k);
69
+ return e ? [e.plugin] : [];
70
+ }));
71
+ const localTool = (key) => {
72
+ const p = parseToolKey(key);
73
+ return p && p.kind !== "builtin" ? p.tool : null;
74
+ };
75
+ const builtinInfo = (key, name, spec) => ({
76
+ key,
77
+ ...display(spec),
78
+ kind: BUILTIN_TOOL_KINDS[name] ?? "tool",
79
+ sandbox: SANDBOX_TOOL_NAMES.includes(name),
80
+ tool: null,
81
+ source: { kind: "builtin" },
82
+ });
82
83
  return unique.map((key) => {
83
84
  const b = builtins.get(key);
84
- if (b) {
85
+ if (b)
86
+ return builtinInfo(key, key, b);
87
+ const legacy = isLegacyBuiltinKey(key) ? LEGACY_BUILTINS[key] : undefined;
88
+ const current = legacy && builtins.get(legacy.name);
89
+ if (legacy && current) {
90
+ // the logged input of an rc call names the old parameters: key arguments in those names
91
+ const oldName = new Map(Object.entries(legacy.params).map(([o, n]) => [n, o]));
92
+ const info = builtinInfo(key, legacy.name, current);
85
93
  return {
86
- key,
87
- ...display(b),
88
- kind: BUILTIN_TOOL_KINDS[key] ?? "tool",
89
- source: { kind: "builtin" },
94
+ ...info,
95
+ aliasOf: legacy.name,
96
+ keyArgs: info.keyArgs.map((a) => oldName.get(a) ?? a),
90
97
  };
91
98
  }
92
99
  const e = extensions.get(key);
@@ -95,7 +102,13 @@ export async function toolInfo(deps, orgId, keys) {
95
102
  key,
96
103
  ...display(e.spec),
97
104
  kind: "tool",
98
- source: { kind: "extension", name: e.plugin },
105
+ sandbox: false,
106
+ tool: e.spec.name,
107
+ source: {
108
+ kind: "extension",
109
+ name: e.plugin,
110
+ displayName: displayNames.get(e.plugin) ?? { zh: e.plugin, en: e.plugin },
111
+ },
99
112
  };
100
113
  const c = connectorTools.get(key);
101
114
  if (c) {
@@ -104,10 +117,20 @@ export async function toolInfo(deps, orgId, keys) {
104
117
  key,
105
118
  ...display(c.spec),
106
119
  kind: "connector",
120
+ sandbox: false,
121
+ tool: c.tool,
107
122
  source: { kind: "connector", id: c.id, name: c.name },
108
123
  };
109
124
  }
110
- return { key, title: null, kind: "tool", keyArgs: [], source: { kind: "unknown" } };
125
+ return {
126
+ key,
127
+ title: null,
128
+ kind: "tool",
129
+ sandbox: false,
130
+ keyArgs: [],
131
+ tool: localTool(key),
132
+ source: { kind: "unknown" },
133
+ };
111
134
  });
112
135
  }
113
136
  /** `GET /conversations/:id/tools`: {@link toolInfo} for a conversation the viewer can read. */
@@ -0,0 +1,34 @@
1
+ import { type AgentDefinition } from "../agents/definition.js";
2
+ import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
+ import type { KernelLogger } from "../log.js";
4
+ import { type LegacyScope } from "./legacy-keys.js";
5
+ /**
6
+ * Stored release-candidate tool keys (tool naming spec §8): the scope that reads an rc
7
+ * `<x>__<tool>` key in an org, the stored-definition readers that use it, and the startup notice
8
+ * for the rows migration 0063 could not map. No in-process state: each call reads PostgreSQL.
9
+ */
10
+ /**
11
+ * What an rc `<x>__<tool>` key can name in `orgId`: the org's live connector slugs and the
12
+ * deployment's extension names (installed ones and config-declared ones, which claim their name
13
+ * in `extension_name_owners`). Migration 0063 reads the same two sources.
14
+ */
15
+ export declare function loadLegacyScope(db: KernelSchemaDb, orgId: string): Promise<LegacyScope>;
16
+ /**
17
+ * A stored agent definition of `orgId` with every rc key it can map read as the current key
18
+ * ({@link normalizeStoredDefinition}); the scope is read only when the definition holds an rc
19
+ * `<x>__<tool>` key.
20
+ */
21
+ export declare function normalizeStoredDefinitionIn(db: KernelSchemaDb, orgId: string, def: unknown): Promise<AgentDefinition>;
22
+ /** A stored agent template (or any template-shaped value) of `orgId` in current keys. */
23
+ export declare function normalizeTemplateIn<T>(db: KernelSchemaDb, orgId: string, t: T): Promise<T>;
24
+ /**
25
+ * Rows still holding an rc tool key after migration 0063: grants and pending approvals and
26
+ * questions it could not map (an ambiguous or unknown `<x>__<tool>`). Read-only.
27
+ */
28
+ export declare function countLegacyToolKeys(db: KernelSchemaDb): Promise<number>;
29
+ /**
30
+ * The startup notice (spec §8.2): one WARN `tools.legacy_key_unmapped` with the count of rows
31
+ * still holding an rc key, only when there are any. A grant that no longer matches stops applying
32
+ * (the person is asked again), so this is a notice, not a failure.
33
+ */
34
+ export declare function warnLegacyToolKeys(db: KernelSchemaDb, log: Pick<KernelLogger, "warn">): Promise<void>;
@@ -0,0 +1,76 @@
1
+ import { sql } from "kysely";
2
+ import { needsLegacyScope, normalizeStoredDefinition, normalizeToolKeys, } from "../agents/definition.js";
3
+ import { LEGACY_BUILTINS } from "./legacy-keys.js";
4
+ /**
5
+ * Stored release-candidate tool keys (tool naming spec §8): the scope that reads an rc
6
+ * `<x>__<tool>` key in an org, the stored-definition readers that use it, and the startup notice
7
+ * for the rows migration 0063 could not map. No in-process state: each call reads PostgreSQL.
8
+ */
9
+ /**
10
+ * What an rc `<x>__<tool>` key can name in `orgId`: the org's live connector slugs and the
11
+ * deployment's extension names (installed ones and config-declared ones, which claim their name
12
+ * in `extension_name_owners`). Migration 0063 reads the same two sources.
13
+ */
14
+ export async function loadLegacyScope(db, orgId) {
15
+ const [connectors, installs, owners] = await Promise.all([
16
+ db
17
+ .selectFrom("connectors")
18
+ .select(["id", "slug"])
19
+ .where("org_id", "=", orgId)
20
+ .where("deleted_at", "is", null)
21
+ .execute(),
22
+ db.selectFrom("extension_installs").select("name").execute(),
23
+ db.selectFrom("extension_name_owners").select("name").execute(),
24
+ ]);
25
+ return {
26
+ connectorSlugs: new Set(connectors.map((r) => r.slug)),
27
+ connectorSlugById: new Map(connectors.map((r) => [r.id, r.slug])),
28
+ extensionNames: new Set([...installs, ...owners].map((r) => r.name)),
29
+ };
30
+ }
31
+ /**
32
+ * A stored agent definition of `orgId` with every rc key it can map read as the current key
33
+ * ({@link normalizeStoredDefinition}); the scope is read only when the definition holds an rc
34
+ * `<x>__<tool>` key.
35
+ */
36
+ export async function normalizeStoredDefinitionIn(db, orgId, def) {
37
+ return normalizeStoredDefinition(def, needsLegacyScope(def) ? await loadLegacyScope(db, orgId) : undefined);
38
+ }
39
+ /** A stored agent template (or any template-shaped value) of `orgId` in current keys. */
40
+ export async function normalizeTemplateIn(db, orgId, t) {
41
+ return normalizeToolKeys(t, needsLegacyScope(t) ? await loadLegacyScope(db, orgId) : undefined);
42
+ }
43
+ /**
44
+ * The SQL test for an rc key, the predicate of migration 0063's partial indexes (so the count
45
+ * below reads only those, nearly empty, indexes): an old builtin name, or `<x>__<tool>` not in the
46
+ * current `mcp__` / `plugin__` format.
47
+ */
48
+ const legacyKeySql = (col) => sql `(${col} = ANY (ARRAY[${sql.join(Object.keys(LEGACY_BUILTINS).map((k) => sql.lit(k)))}]::text[]) OR (${col} ~ '^[a-z0-9][a-z0-9_-]*__.' AND ${col} !~ '^(mcp|plugin)__'))`;
49
+ /**
50
+ * Rows still holding an rc tool key after migration 0063: grants and pending approvals and
51
+ * questions it could not map (an ambiguous or unknown `<x>__<tool>`). Read-only.
52
+ */
53
+ export async function countLegacyToolKeys(db) {
54
+ const r = await sql `
55
+ SELECT
56
+ (SELECT count(*) FROM capybara.tool_grants WHERE ${legacyKeySql(sql.ref("tool_key"))})
57
+ + (SELECT count(*) FROM capybara.conversation_tool_grants
58
+ WHERE ${legacyKeySql(sql.ref("tool_key"))})
59
+ + (SELECT count(*) FROM capybara.approvals
60
+ WHERE status = 'pending' AND ${legacyKeySql(sql.ref("tool_key"))})
61
+ + (SELECT count(*) FROM capybara.questions
62
+ WHERE status = 'pending' AND ${legacyKeySql(sql.raw("(spec->>'toolKey')"))})
63
+ AS n
64
+ `.execute(db);
65
+ return Number(r.rows[0]?.n ?? 0);
66
+ }
67
+ /**
68
+ * The startup notice (spec §8.2): one WARN `tools.legacy_key_unmapped` with the count of rows
69
+ * still holding an rc key, only when there are any. A grant that no longer matches stops applying
70
+ * (the person is asked again), so this is a notice, not a failure.
71
+ */
72
+ export async function warnLegacyToolKeys(db, log) {
73
+ const count = await countLegacyToolKeys(db);
74
+ if (count > 0)
75
+ log.warn("tools.legacy_key_unmapped", { count });
76
+ }
@@ -0,0 +1,51 @@
1
+ import { type BuiltinName } from "./builtin-names.js";
2
+ /**
3
+ * The release-candidate builtin tool names (tool naming spec §8.1). FROZEN: it describes the names
4
+ * of the 0.1.0 release candidates and never grows. Old keys stay in logs, recordings and stored
5
+ * configuration; this map is how the kernel reads them. `check:terms` exempts this file.
6
+ */
7
+ export interface LegacyBuiltin {
8
+ /** The new name. */
9
+ name: BuiltinName;
10
+ /** Old parameter name -> new parameter name (only the renamed ones). */
11
+ params: Readonly<Record<string, string>>;
12
+ /** New parameters whose value is in milliseconds where the old one was in seconds (× 1000). */
13
+ msParams?: readonly string[];
14
+ }
15
+ export declare const LEGACY_BUILTINS: Readonly<Record<string, LegacyBuiltin>>;
16
+ /** Is `key` a release-candidate builtin name? */
17
+ export declare const isLegacyBuiltinKey: (key: string) => boolean;
18
+ /** What a connector slug / extension name can be, to read an old `<x>__<tool>` key. */
19
+ export interface LegacyScope {
20
+ connectorSlugs: ReadonlySet<string>;
21
+ extensionNames: ReadonlySet<string>;
22
+ /**
23
+ * Connector id -> slug, for reading a stored definition's connector refs when a key is
24
+ * ambiguous (a slug that is also an extension name); optional.
25
+ */
26
+ connectorSlugById?: ReadonlyMap<string, string>;
27
+ }
28
+ /**
29
+ * Is `key` an rc `<x>__<tool>` key, which only a {@link LegacyScope} can map? Keys in the current
30
+ * format (`mcp__…`, `plugin__…`) never are.
31
+ */
32
+ export declare const isLegacyPrefixedKey: (key: string) => boolean;
33
+ /**
34
+ * The current key of a release-candidate key: a builtin by the frozen map; `<x>__<tool>` becomes
35
+ * `mcp__x__tool` when `x` is only a connector slug in `scope`, `plugin__x__tool` when only an
36
+ * extension name, else null (ambiguous, unknown, or not an old key; a key in the current format
37
+ * is never mapped again).
38
+ */
39
+ export declare function legacyToolKey(key: string, scope?: LegacyScope): string | null;
40
+ /** The input of an old builtin call in the current parameter names (seconds -> milliseconds). */
41
+ export declare function legacyToolInput(oldKey: string, input: unknown): unknown;
42
+ /** The model-visible hint for a call to an old builtin key; null for any other key. */
43
+ export declare function legacyHint(key: string): string | null;
44
+ /**
45
+ * The current key(s) an rc key stands for, to name in a refusal when a definition is saved with
46
+ * it: a builtin's new name; for `<x>__<tool>`, the candidates among `known` (the agent's tool
47
+ * keys), else both `mcp__<x>__<tool>` and `plugin__<x>__<tool>`. Empty when `key` is no rc key.
48
+ */
49
+ export declare function legacyKeyCandidates(key: string, known?: ReadonlySet<string>): string[];
50
+ /** The refusal text for saving rc key `key` (null when it is none): names the new key(s). */
51
+ export declare function legacyKeySaveText(key: string, known?: ReadonlySet<string>): string | null;
@@ -0,0 +1,115 @@
1
+ import { BUILTIN } from "./builtin-names.js";
2
+ export const LEGACY_BUILTINS = Object.freeze({
3
+ sandbox_bash: {
4
+ name: BUILTIN.Bash,
5
+ params: { timeoutSeconds: "timeout" },
6
+ msParams: ["timeout"],
7
+ },
8
+ sandbox_read: { name: BUILTIN.Read, params: { path: "file_path" } },
9
+ sandbox_write: { name: BUILTIN.Write, params: { path: "file_path" } },
10
+ sandbox_edit: {
11
+ name: BUILTIN.Edit,
12
+ params: {
13
+ path: "file_path",
14
+ oldText: "old_string",
15
+ newText: "new_string",
16
+ replaceAll: "replace_all",
17
+ },
18
+ },
19
+ sandbox_glob: { name: BUILTIN.Glob, params: {} },
20
+ sandbox_grep: { name: BUILTIN.Grep, params: { ignoreCase: "-i" } },
21
+ sandbox_deliver: { name: BUILTIN.Deliver, params: { path: "file_path" } },
22
+ skill_load: { name: BUILTIN.Skill, params: { name: "skill" } },
23
+ skill_write: { name: BUILTIN.SkillWrite, params: {} },
24
+ ask_user: { name: BUILTIN.AskUserQuestion, params: {} },
25
+ read_tool_output: { name: BUILTIN.ReadToolOutput, params: {} },
26
+ tool_search: { name: BUILTIN.ToolSearch, params: { limit: "max_results" } },
27
+ agent: { name: BUILTIN.Agent, params: {} },
28
+ });
29
+ /** Is `key` a release-candidate builtin name? */
30
+ export const isLegacyBuiltinKey = (key) => Object.hasOwn(LEGACY_BUILTINS, key);
31
+ /** A key in the current format for connector and extension tools (`mcp__…`, `plugin__…`). */
32
+ const CURRENT_PREFIXED_RE = /^(mcp|plugin)__/;
33
+ /** An rc connector or extension key `<x>__<tool>` (the SQL of migration 0063 uses the same test). */
34
+ const LEGACY_PREFIXED_RE = /^[a-z0-9][a-z0-9_-]*__./;
35
+ /**
36
+ * Is `key` an rc `<x>__<tool>` key, which only a {@link LegacyScope} can map? Keys in the current
37
+ * format (`mcp__…`, `plugin__…`) never are.
38
+ */
39
+ export const isLegacyPrefixedKey = (key) => LEGACY_PREFIXED_RE.test(key) && !CURRENT_PREFIXED_RE.test(key);
40
+ /**
41
+ * The current key of a release-candidate key: a builtin by the frozen map; `<x>__<tool>` becomes
42
+ * `mcp__x__tool` when `x` is only a connector slug in `scope`, `plugin__x__tool` when only an
43
+ * extension name, else null (ambiguous, unknown, or not an old key; a key in the current format
44
+ * is never mapped again).
45
+ */
46
+ export function legacyToolKey(key, scope) {
47
+ if (isLegacyBuiltinKey(key))
48
+ return LEGACY_BUILTINS[key].name;
49
+ if (scope === undefined || !isLegacyPrefixedKey(key))
50
+ return null;
51
+ const i = key.indexOf("__");
52
+ if (i <= 0 || i + 2 >= key.length)
53
+ return null;
54
+ const head = key.slice(0, i);
55
+ const tool = key.slice(i + 2);
56
+ const connector = scope.connectorSlugs.has(head);
57
+ const extension = scope.extensionNames.has(head);
58
+ if (connector === extension)
59
+ return null;
60
+ return connector ? `mcp__${head}__${tool}` : `plugin__${head}__${tool}`;
61
+ }
62
+ /** The input of an old builtin call in the current parameter names (seconds -> milliseconds). */
63
+ export function legacyToolInput(oldKey, input) {
64
+ if (!isLegacyBuiltinKey(oldKey))
65
+ return input;
66
+ if (typeof input !== "object" || input === null || Array.isArray(input))
67
+ return input;
68
+ const { params, msParams } = LEGACY_BUILTINS[oldKey];
69
+ const out = {};
70
+ for (const [k, v] of Object.entries(input)) {
71
+ const next = Object.hasOwn(params, k) ? params[k] : k;
72
+ out[next] = msParams?.includes(next) === true && typeof v === "number" ? v * 1000 : v;
73
+ }
74
+ return out;
75
+ }
76
+ /** The new parameters of the builtins whose parameters were renamed (model-visible hint text). */
77
+ const HINT_PARAMS = {
78
+ Bash: "command, description, timeout in milliseconds",
79
+ Read: "file_path, offset, limit",
80
+ Write: "file_path, content",
81
+ Edit: "file_path, old_string, new_string, replace_all",
82
+ Grep: "pattern, path, glob, -i, output_mode, -n, -A, -B, -C, head_limit, offset",
83
+ Deliver: "file_path, name",
84
+ Skill: "skill, args",
85
+ ToolSearch: "query, max_results",
86
+ };
87
+ /** The model-visible hint for a call to an old builtin key; null for any other key. */
88
+ export function legacyHint(key) {
89
+ if (!isLegacyBuiltinKey(key))
90
+ return null;
91
+ const { name } = LEGACY_BUILTINS[key];
92
+ const params = HINT_PARAMS[name];
93
+ return `Tool "${key}" no longer exists; it is now "${name}"${params === undefined ? "" : ` (parameters: ${params})`}.`;
94
+ }
95
+ /**
96
+ * The current key(s) an rc key stands for, to name in a refusal when a definition is saved with
97
+ * it: a builtin's new name; for `<x>__<tool>`, the candidates among `known` (the agent's tool
98
+ * keys), else both `mcp__<x>__<tool>` and `plugin__<x>__<tool>`. Empty when `key` is no rc key.
99
+ */
100
+ export function legacyKeyCandidates(key, known) {
101
+ if (isLegacyBuiltinKey(key))
102
+ return [LEGACY_BUILTINS[key].name];
103
+ if (!isLegacyPrefixedKey(key))
104
+ return [];
105
+ const all = [`mcp__${key}`, `plugin__${key}`];
106
+ const hit = all.filter((k) => known?.has(k) === true);
107
+ return hit.length > 0 ? hit : all;
108
+ }
109
+ /** The refusal text for saving rc key `key` (null when it is none): names the new key(s). */
110
+ export function legacyKeySaveText(key, known) {
111
+ const c = legacyKeyCandidates(key, known);
112
+ if (c.length === 0)
113
+ return null;
114
+ return `"${key}" is a release-candidate tool key; use ${c.map((x) => `"${x}"`).join(" or ")}`;
115
+ }
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * 工具命名(Global Constraints):模型可见的工具 key 必须匹配 `^[a-zA-Z0-9_-]{1,64}$`;
3
- * 插件工具为 `<plugin>__<tool>`,连接器工具为 `<connectorSlug>__<tool>`,内置工具就是其名字本身。
3
+ * 插件工具为 `plugin__<plugin>__<tool>`,连接器工具为 `mcp__<connectorSlug>__<tool>`(拼与拆见 SDK 的 tool-key.ts),内置工具就是其名字本身。
4
4
  * 超长或含非法字符的 key 一律报出来,不截断、不猜。
5
5
  */
6
6
  export declare const TOOL_KEY_RE: RegExp;
7
7
  export declare const TOOL_KEY_MAX = 64;
8
8
  /** 连接器 slug:小写字母开头,小写字母 / 数字 / 下划线,最长 24。 */
9
9
  export declare const APP_SLUG_RE: RegExp;
10
- /** 前缀与工具名之间的分隔符。 */
11
- export declare const KEY_SEPARATOR = "__";
12
10
  /**
13
11
  * slug 是否合法:除正则外,不得含连续下划线、不得以下划线结尾——否则 `a__b` + `c` 与 `a` + `b__c`
14
12
  * 会拼出同一个 key。
@@ -21,7 +19,5 @@ export declare const SLUG_RULE = "Slug must start with a lowercase letter, conta
21
19
  * 截到 24 位(再去掉尾部下划线)。推导不出合法 slug(如名称全是中文)时返回 null,由调用方要求显式给出。
22
20
  */
23
21
  export declare function deriveSlug(name: string): string | null;
24
- /** 拼 `<prefix>__<name>`。 */
25
- export declare function toolKey(prefix: string, name: string): string;
26
22
  /** key 不合法时返回英文原因,合法时返回 null。 */
27
23
  export declare function toolKeyIssue(key: string): string | null;
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * 工具命名(Global Constraints):模型可见的工具 key 必须匹配 `^[a-zA-Z0-9_-]{1,64}$`;
3
- * 插件工具为 `<plugin>__<tool>`,连接器工具为 `<connectorSlug>__<tool>`,内置工具就是其名字本身。
3
+ * 插件工具为 `plugin__<plugin>__<tool>`,连接器工具为 `mcp__<connectorSlug>__<tool>`(拼与拆见 SDK 的 tool-key.ts),内置工具就是其名字本身。
4
4
  * 超长或含非法字符的 key 一律报出来,不截断、不猜。
5
5
  */
6
6
  export const TOOL_KEY_RE = /^[a-zA-Z0-9_-]{1,64}$/;
7
7
  export const TOOL_KEY_MAX = 64;
8
8
  /** 连接器 slug:小写字母开头,小写字母 / 数字 / 下划线,最长 24。 */
9
9
  export const APP_SLUG_RE = /^[a-z][a-z0-9_]{0,23}$/;
10
- /** 前缀与工具名之间的分隔符。 */
11
- export const KEY_SEPARATOR = "__";
12
10
  /**
13
11
  * slug 是否合法:除正则外,不得含连续下划线、不得以下划线结尾——否则 `a__b` + `c` 与 `a` + `b__c`
14
12
  * 会拼出同一个 key。
@@ -31,10 +29,6 @@ export function deriveSlug(name) {
31
29
  .replace(/_+$/, "");
32
30
  return isValidSlug(s) ? s : null;
33
31
  }
34
- /** 拼 `<prefix>__<name>`。 */
35
- export function toolKey(prefix, name) {
36
- return `${prefix}${KEY_SEPARATOR}${name}`;
37
- }
38
32
  /** key 不合法时返回英文原因,合法时返回 null。 */
39
33
  export function toolKeyIssue(key) {
40
34
  if (key.length > TOOL_KEY_MAX) {
@@ -6,7 +6,7 @@ export declare const OAUTH_STATE_TTL_SECONDS = 600;
6
6
  /** 浏览器绑定 Cookie:回调必须来自发起连接的同一个浏览器。 */
7
7
  export declare const OAUTH_BINDING_COOKIE = "cap_oauth";
8
8
  /** 回调失败、或连接时没给回跳页面时回到的网页(next-intl 会补语言前缀)。 */
9
- export declare const DEFAULT_RETURN_PATH = "/settings/connections";
9
+ export declare const DEFAULT_RETURN_PATH = "/account/connections";
10
10
  /** OAuth 连接器需要 `http.publicUrl`(回调地址);未配置 → 这条校验错误。 */
11
11
  export declare const publicUrlRequired: () => ApiError;
12
12
  export declare function callbackUrl(publicUrl: string): string;
@@ -8,7 +8,7 @@ export const OAUTH_STATE_TTL_SECONDS = 600;
8
8
  /** 浏览器绑定 Cookie:回调必须来自发起连接的同一个浏览器。 */
9
9
  export const OAUTH_BINDING_COOKIE = "cap_oauth";
10
10
  /** 回调失败、或连接时没给回跳页面时回到的网页(next-intl 会补语言前缀)。 */
11
- export const DEFAULT_RETURN_PATH = "/settings/connections";
11
+ export const DEFAULT_RETURN_PATH = "/account/connections";
12
12
  /** OAuth 连接器需要 `http.publicUrl`(回调地址);未配置 → 这条校验错误。 */
13
13
  export const publicUrlRequired = () => new ApiError("validation_failed", "Request validation failed", [
14
14
  {
@@ -194,7 +194,7 @@ export async function spillIfLarge(text, opts, save) {
194
194
  return {
195
195
  content: `${text.slice(0, opts.previewChars)}\n…\n` +
196
196
  `[Output truncated: ${saved.sizeChars} chars, ${saved.lineCount} lines. Full output id: ${id}. ` +
197
- `Use read_tool_output to page through it, or pass {"$output":"${id}"} as a tool argument.]`,
197
+ `Use ReadToolOutput to page through it, or pass {"$output":"${id}"} as a tool argument.]`,
198
198
  outputId: id,
199
199
  };
200
200
  }
@@ -142,8 +142,8 @@ interface PipelineDeps {
142
142
  */
143
143
  onToolsChanged(orgId: string, connectorId: string): void;
144
144
  /**
145
- * Dispatches the sub-agent of an `agent` call (sub-agents spec §7.1; `dispatchSubagent`). Without
146
- * it, `agent` calls reach the builtin's guard, which refuses them.
145
+ * Dispatches the sub-agent of an `Agent` call (sub-agents spec §7.1; `dispatchSubagent`). Without
146
+ * it, `Agent` calls reach the builtin's guard, which refuses them.
147
147
  */
148
148
  readonly subagents: {
149
149
  dispatch(a: {
@@ -229,7 +229,7 @@ export declare class ToolPipeline {
229
229
  private readonly decide;
230
230
  private readonly deps;
231
231
  constructor(kdb: KernelDb, eventLog: EventLog,
232
- /** The `agent` tool's sub-agent dispatch; absent (tests): `agent` calls are refused. */
232
+ /** The `Agent` tool's sub-agent dispatch; absent (tests): `Agent` calls are refused. */
233
233
  subagents: Pick<SubagentsService, "dispatch"> | 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">, questions: Pick<QuestionsService, "ask" | "forCall">, config: Pick<KernelConfigService, "get">, log: Logger,
234
234
  /** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
235
235
  host: Pick<ExtensionHost, "hooks" | "current"> | undefined, drift: Pick<ToolDrift, "onToolsChanged"> | undefined, txHost: TransactionHost, hooks?: ToolPipelineHooks);
@@ -242,7 +242,7 @@ export declare class ToolPipeline {
242
242
  */
243
243
  runStep(ctx: ToolStepContext): Promise<ToolStepOutcome>;
244
244
  /**
245
- * An `agent` call that was dispatched (spec §7.1 "already dispatched"): when its child run is
245
+ * An `Agent` call that was dispatched (spec §7.1 "already dispatched"): when its child run is
246
246
  * terminal, writes the parent's `subagent_finished` (if the child's finisher did not) and the
247
247
  * call's `tool_result` from the child's log, and returns true; else false (still open).
248
248
  *
@@ -255,14 +255,14 @@ export declare class ToolPipeline {
255
255
  /** {@link stopOpenAgentCalls} in a transaction of its own (a stop seen by the tools node). */
256
256
  private stopOpenAgentCallsNow;
257
257
  /**
258
- * Writes, in the caller's transaction (`mandatory`), the `tool_result` of every open `agent` call
258
+ * Writes, in the caller's transaction (`mandatory`), the `tool_result` of every open `Agent` call
259
259
  * of a run that is being stopped
260
260
  * (sub-agents spec §12: a person stopped it while it waited on sub-agents, or its deadline or a
261
261
  * stop hit its tools node after a dispatch). A call whose child already ended gets the child's
262
262
  * result (and the missing `subagent_finished`); one whose child is still active gets
263
263
  * {@link AGENT_STOPPED_WITH_RUN_TEXT}. The caller stops those children after its commit.
264
264
  *
265
- * Like every `agent` result (see {@link finishAgentCall}), each is audited `tool.called` in it
265
+ * Like every `Agent` result (see {@link finishAgentCall}), each is audited `tool.called` in it
266
266
  * (duration: the child's, or the time since the dispatch) and fires `tool.postExecute`, through
267
267
  * `fire()`, which the caller runs after its commit. Returns the steps and calls written (the
268
268
  * caller must not write a "not executed" result for them) and the highest seq written.
@@ -280,9 +280,15 @@ export declare class ToolPipeline {
280
280
  */
281
281
  private processCall;
282
282
  private runCall;
283
+ /**
284
+ * Every tool key the request that issued this step's calls offered (`request.tools` plus the
285
+ * `catalog` keys), in any mode; null when its model_call is not found. Used to tell a call to an
286
+ * old key that was offered (in flight across the rename) from one that never was.
287
+ */
288
+ private requestToolKeys;
283
289
  /**
284
290
  * 发出本步调用的请求里带了完整定义的工具 key:本步最后一次尝试的 `model_call.request.tools`
285
- * (`assistant_message` 来自最后一次尝试)。该请求不在 tool_search 模式(没有 `catalog`,工具全部发送)
291
+ * (`assistant_message` 来自最后一次尝试)。该请求不在 ToolSearch 模式(没有 `catalog`,工具全部发送)
286
292
  * 或找不到 model_call 时返回 null(不做加载检查)。已加载集合由此从日志得出,不放进程内存。
287
293
  */
288
294
  private sentTools;