@capybara-hq/kernel 0.1.0-rc.35 → 0.1.0-rc.37

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 (311) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.d.ts +3 -3
  3. package/dist/admin/admin.module.js +6 -6
  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/outbox-dead.controller.d.ts +4 -6
  11. package/dist/admin/outbox-dead.controller.js +9 -6
  12. package/dist/admin/outbox-dead.schemas.d.ts +16 -0
  13. package/dist/admin/outbox-dead.schemas.js +25 -1
  14. package/dist/admin/outbox-dead.service.d.ts +16 -7
  15. package/dist/admin/outbox-dead.service.js +34 -10
  16. package/dist/admin/overview.service.d.ts +3 -3
  17. package/dist/admin/overview.service.js +0 -1
  18. package/dist/agents/agent-lookup.js +2 -10
  19. package/dist/agents/agents.module.js +3 -0
  20. package/dist/agents/agents.service.js +9 -20
  21. package/dist/agents/definition.d.ts +3 -51
  22. package/dist/agents/definition.js +4 -254
  23. package/dist/agents/org-templates.js +2 -6
  24. package/dist/agents/readiness.controller.d.ts +8 -19
  25. package/dist/agents/readiness.controller.js +11 -25
  26. package/dist/agents/readiness.service.d.ts +42 -0
  27. package/dist/agents/readiness.service.js +78 -0
  28. package/dist/agents/templates.d.ts +0 -6
  29. package/dist/agents/templates.js +8 -34
  30. package/dist/background/store.d.ts +2 -0
  31. package/dist/background/store.js +3 -1
  32. package/dist/background/wake-rules.js +2 -1
  33. package/dist/catalog/admin-catalog.controller.d.ts +1 -2
  34. package/dist/catalog/admin-catalog.controller.js +1 -2
  35. package/dist/catalog/appearance.service.js +1 -3
  36. package/dist/catalog/catalog-content.d.ts +1 -1
  37. package/dist/catalog/catalog-content.js +1 -4
  38. package/dist/catalog/catalog-items.js +3 -3
  39. package/dist/catalog/catalog-scope.service.d.ts +10 -28
  40. package/dist/catalog/catalog-scope.service.js +22 -73
  41. package/dist/catalog/cli.d.ts +0 -11
  42. package/dist/catalog/cli.js +0 -20
  43. package/dist/catalog/component-scope.service.js +0 -2
  44. package/dist/catalog/component-state.js +2 -2
  45. package/dist/catalog/install-status.d.ts +6 -0
  46. package/dist/catalog/install-status.js +6 -0
  47. package/dist/catalog/job-ids.d.ts +0 -4
  48. package/dist/catalog/job-ids.js +0 -4
  49. package/dist/catalog/marketplaces.service.d.ts +1 -1
  50. package/dist/catalog/org-catalog.service.d.ts +2 -0
  51. package/dist/catalog/org-catalog.service.js +8 -3
  52. package/dist/catalog/org-extension-switch.d.ts +7 -2
  53. package/dist/catalog/org-extension-switch.js +56 -9
  54. package/dist/catalog/org-plugin-uploads.d.ts +6 -15
  55. package/dist/catalog/org-plugin-uploads.js +9 -27
  56. package/dist/catalog/owned-items.js +1 -3
  57. package/dist/catalog/platform-import-update.js +1 -1
  58. package/dist/catalog/plugin-import.d.ts +15 -13
  59. package/dist/catalog/plugin-import.js +21 -30
  60. package/dist/catalog/plugin-install.d.ts +3 -43
  61. package/dist/catalog/plugin-install.js +8 -150
  62. package/dist/catalog/plugin-package.d.ts +5 -10
  63. package/dist/catalog/plugin-package.js +12 -33
  64. package/dist/catalog/plugin-upgrade.js +5 -4
  65. package/dist/catalog/scope-jobs.d.ts +34 -34
  66. package/dist/catalog/scope-jobs.js +50 -37
  67. package/dist/catalog/scope-orgs.d.ts +1 -1
  68. package/dist/catalog/scope-orgs.js +1 -2
  69. package/dist/catalog/scope-sync-workers.d.ts +4 -3
  70. package/dist/catalog/scope-sync-workers.js +18 -6
  71. package/dist/catalog/scope-sync.d.ts +56 -59
  72. package/dist/catalog/scope-sync.js +96 -166
  73. package/dist/catalog/unshare.d.ts +3 -4
  74. package/dist/catalog/unshare.js +5 -8
  75. package/dist/channels/job-ids.d.ts +2 -6
  76. package/dist/channels/job-ids.js +2 -6
  77. package/dist/channels/outbound.d.ts +1 -1
  78. package/dist/channels/outbound.js +1 -1
  79. package/dist/channels/supervisor.d.ts +2 -3
  80. package/dist/channels/supervisor.js +2 -3
  81. package/dist/client/client-access.service.js +1 -1
  82. package/dist/config/env.js +19 -1
  83. package/dist/config/load.d.ts +0 -6
  84. package/dist/config/load.js +8 -27
  85. package/dist/config/schema.d.ts +53 -47
  86. package/dist/config/schema.js +190 -40
  87. package/dist/conversations/attachments.service.d.ts +10 -3
  88. package/dist/conversations/attachments.service.js +49 -16
  89. package/dist/conversations/conversations.controller.d.ts +0 -39
  90. package/dist/conversations/conversations.controller.js +0 -39
  91. package/dist/conversations/events.d.ts +71 -46
  92. package/dist/conversations/events.js +124 -112
  93. package/dist/conversations/media-types.d.ts +25 -0
  94. package/dist/conversations/media-types.js +38 -0
  95. package/dist/conversations/queue.d.ts +3 -1
  96. package/dist/conversations/queue.service.js +9 -2
  97. package/dist/conversations/titles.js +6 -0
  98. package/dist/ctx/create-ctx.js +1 -2
  99. package/dist/ctx/secrets.d.ts +24 -7
  100. package/dist/ctx/secrets.js +97 -30
  101. package/dist/db/kernel-schema.d.ts +17 -6
  102. package/dist/errors.d.ts +5 -2
  103. package/dist/errors.js +5 -2
  104. package/dist/evals/reconstruct.d.ts +4 -17
  105. package/dist/evals/reconstruct.js +13 -53
  106. package/dist/evals/recorded-tools.d.ts +0 -27
  107. package/dist/evals/recorded-tools.js +2 -92
  108. package/dist/evals/run-replay.d.ts +1 -6
  109. package/dist/evals/run-replay.js +10 -17
  110. package/dist/evals/sets.service.d.ts +17 -5
  111. package/dist/evals/sets.service.js +33 -12
  112. package/dist/evals/snapshot.d.ts +1 -2
  113. package/dist/evals/snapshot.js +4 -17
  114. package/dist/extensions/admin-ops.d.ts +6 -1
  115. package/dist/extensions/admin-ops.js +17 -4
  116. package/dist/extensions/admin-view.d.ts +7 -4
  117. package/dist/extensions/admin-view.js +27 -21
  118. package/dist/extensions/bootstrap.js +0 -1
  119. package/dist/extensions/cli.js +0 -1
  120. package/dist/extensions/host.d.ts +2 -3
  121. package/dist/extensions/host.js +1 -5
  122. package/dist/extensions/installs.d.ts +1 -3
  123. package/dist/extensions/instance.d.ts +0 -2
  124. package/dist/extensions/instance.js +0 -3
  125. package/dist/extensions/org-config.d.ts +4 -4
  126. package/dist/extensions/org-config.js +13 -22
  127. package/dist/extensions/package.d.ts +6 -6
  128. package/dist/extensions/package.js +3 -7
  129. package/dist/extensions/permission-view.d.ts +2 -4
  130. package/dist/extensions/plugin-items.d.ts +21 -1
  131. package/dist/extensions/plugin-items.js +28 -0
  132. package/dist/extensions/sync.js +5 -10
  133. package/dist/extensions/unavailable.js +0 -1
  134. package/dist/http/api.module.js +2 -1
  135. package/dist/identity/audit.d.ts +0 -12
  136. package/dist/identity/audit.js +0 -27
  137. package/dist/identity/auth.controller.js +5 -9
  138. package/dist/identity/cookies.d.ts +4 -9
  139. package/dist/identity/cookies.js +8 -32
  140. package/dist/identity/initial-passwords.d.ts +1 -1
  141. package/dist/identity/initial-passwords.js +1 -2
  142. package/dist/identity/sessions.d.ts +0 -6
  143. package/dist/identity/sessions.js +0 -18
  144. package/dist/inbox/platform-inbox.service.d.ts +33 -1
  145. package/dist/inbox/platform-inbox.service.js +56 -6
  146. package/dist/index.d.ts +4 -2
  147. package/dist/index.js +4 -2
  148. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  149. package/dist/infra/cli/master-key-rewrap.js +24 -0
  150. package/dist/infra/config/kernel-config.service.js +0 -17
  151. package/dist/infra/health/health.controller.js +8 -0
  152. package/dist/infra/health/process-fault.d.ts +16 -0
  153. package/dist/infra/health/process-fault.js +49 -0
  154. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  155. package/dist/infra/lifecycle/process-guards.js +12 -3
  156. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  157. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  158. package/dist/infra/outbox/outbox.service.d.ts +12 -9
  159. package/dist/infra/outbox/outbox.service.js +22 -26
  160. package/dist/infra/outbox/registry.d.ts +15 -7
  161. package/dist/infra/outbox/registry.js +39 -23
  162. package/dist/lifecycle/kernel-lifecycle.js +1 -7
  163. package/dist/models/enablement.d.ts +5 -6
  164. package/dist/models/enablement.js +7 -14
  165. package/dist/orgs/orgs.module.d.ts +2 -2
  166. package/dist/orgs/orgs.module.js +2 -2
  167. package/dist/orgs/settings.controller.d.ts +3 -2
  168. package/dist/orgs/settings.service.d.ts +59 -14
  169. package/dist/orgs/settings.service.js +102 -20
  170. package/dist/overrides.d.ts +3 -7
  171. package/dist/overrides.js +2 -4
  172. package/dist/packages/tgz.d.ts +0 -2
  173. package/dist/packages/tgz.js +0 -2
  174. package/dist/platform/exclusions.js +0 -5
  175. package/dist/platform/operation.js +1 -1
  176. package/dist/platform/ops/admin.ops.d.ts +2 -2
  177. package/dist/platform/ops/admin.ops.js +9 -6
  178. package/dist/platform/ops/agents.ops.d.ts +3 -3
  179. package/dist/platform/ops/agents.ops.js +7 -10
  180. package/dist/platform/ops/connectors.ops.js +46 -1
  181. package/dist/platform/ops/evals.ops.js +1 -64
  182. package/dist/platform/ops/extensions-admin.ops.js +1 -1
  183. package/dist/platform/ops/inbox.ops.js +16 -3
  184. package/dist/platform/ops/org-plugins.ops.js +1 -1
  185. package/dist/platform/ops/orgs.ops.d.ts +5 -3
  186. package/dist/platform/ops/orgs.ops.js +19 -4
  187. package/dist/platform/ops/outbox.ops.js +5 -5
  188. package/dist/roles/worker-role.d.ts +2 -3
  189. package/dist/roles/worker-role.js +3 -13
  190. package/dist/runtime/context/build.d.ts +56 -18
  191. package/dist/runtime/context/build.js +143 -50
  192. package/dist/runtime/context/compaction.d.ts +1 -3
  193. package/dist/runtime/context/compaction.js +42 -8
  194. package/dist/runtime/context/run-context.js +1 -2
  195. package/dist/runtime/context/skills.d.ts +27 -56
  196. package/dist/runtime/context/skills.js +42 -114
  197. package/dist/runtime/context/tool-changes.d.ts +3 -3
  198. package/dist/runtime/context/tool-changes.js +6 -16
  199. package/dist/runtime/hook-calls.d.ts +6 -6
  200. package/dist/runtime/hook-calls.js +7 -7
  201. package/dist/runtime/langgraph-loop.js +1 -0
  202. package/dist/runtime/maintenance.d.ts +3 -11
  203. package/dist/runtime/maintenance.js +5 -20
  204. package/dist/runtime/model-call.d.ts +5 -0
  205. package/dist/runtime/model-call.js +48 -36
  206. package/dist/runtime/providers.d.ts +33 -35
  207. package/dist/runtime/providers.js +64 -109
  208. package/dist/runtime/run-context.service.js +7 -22
  209. package/dist/runtime/run-deletion.d.ts +6 -0
  210. package/dist/runtime/run-deletion.js +39 -16
  211. package/dist/runtime/run-execution.js +4 -3
  212. package/dist/runtime/run-finish.js +2 -1
  213. package/dist/runtime/run-liveness.d.ts +11 -0
  214. package/dist/runtime/run-liveness.js +19 -0
  215. package/dist/runtime/run-orphan-check.job.js +2 -1
  216. package/dist/runtime/run-queue.js +8 -16
  217. package/dist/runtime/run-worker.d.ts +2 -2
  218. package/dist/runtime/run-worker.js +8 -6
  219. package/dist/runtime/subagents/definition.d.ts +16 -20
  220. package/dist/runtime/subagents/definition.js +27 -27
  221. package/dist/runtime/subagents/dispatch.d.ts +6 -2
  222. package/dist/runtime/subagents/dispatch.js +17 -3
  223. package/dist/runtime/subagents/org-agents.js +1 -2
  224. package/dist/runtime/subagents/preamble.d.ts +3 -2
  225. package/dist/runtime/subagents/preamble.js +3 -2
  226. package/dist/runtime/subagents/render.d.ts +1 -2
  227. package/dist/runtime/subagents/render.js +1 -2
  228. package/dist/runtime/subagents/skill-fork.d.ts +2 -4
  229. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  230. package/dist/runtime/subagents/template-skills.js +76 -0
  231. package/dist/schedules/effective-settings.d.ts +9 -3
  232. package/dist/schedules/effective-settings.js +5 -4
  233. package/dist/schedules/fire.js +11 -0
  234. package/dist/schedules/scheduled-tasks.service.js +5 -0
  235. package/dist/schedules/unattended.d.ts +2 -0
  236. package/dist/schedules/unattended.js +6 -1
  237. package/dist/skills/agent-skills.service.js +1 -2
  238. package/dist/skills/catalog.d.ts +1 -3
  239. package/dist/skills/catalog.js +1 -3
  240. package/dist/skills/conversation-catalog.d.ts +1 -2
  241. package/dist/skills/conversation-catalog.js +1 -2
  242. package/dist/skills/usable.js +2 -3
  243. package/dist/storage/storage.service.js +9 -1
  244. package/dist/tools/approvals.service.js +2 -4
  245. package/dist/tools/builtin-names.d.ts +2 -9
  246. package/dist/tools/builtin-names.js +4 -13
  247. package/dist/tools/builtins/sandbox/bash.js +3 -3
  248. package/dist/tools/builtins/sandbox/common.d.ts +7 -13
  249. package/dist/tools/builtins/sandbox/common.js +8 -115
  250. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  251. package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
  252. package/dist/tools/builtins/sandbox/glob.js +1 -3
  253. package/dist/tools/builtins/sandbox/grep.js +3 -5
  254. package/dist/tools/builtins/sandbox/index.d.ts +8 -5
  255. package/dist/tools/builtins/sandbox/index.js +10 -5
  256. package/dist/tools/builtins/sandbox/read.js +3 -2
  257. package/dist/tools/builtins/tool-search.d.ts +4 -7
  258. package/dist/tools/builtins/tool-search.js +6 -10
  259. package/dist/tools/connector-account-policies.d.ts +30 -3
  260. package/dist/tools/connector-account-policies.js +54 -7
  261. package/dist/tools/connectors.controller.d.ts +24 -11
  262. package/dist/tools/connectors.controller.js +35 -6
  263. package/dist/tools/connectors.schemas.d.ts +14 -1
  264. package/dist/tools/connectors.schemas.js +14 -2
  265. package/dist/tools/connectors.service.d.ts +22 -0
  266. package/dist/tools/connectors.service.js +56 -0
  267. package/dist/tools/drift.d.ts +1 -1
  268. package/dist/tools/drift.js +1 -1
  269. package/dist/tools/git-push-policy.d.ts +4 -1
  270. package/dist/tools/git-push-policy.js +3 -1
  271. package/dist/tools/info.d.ts +1 -7
  272. package/dist/tools/info.js +5 -18
  273. package/dist/tools/job-ids.d.ts +0 -4
  274. package/dist/tools/job-ids.js +1 -6
  275. package/dist/tools/pipeline.d.ts +4 -10
  276. package/dist/tools/pipeline.js +16 -62
  277. package/dist/tools/policy.d.ts +6 -2
  278. package/dist/tools/policy.js +14 -12
  279. package/dist/tools/registry.js +1 -5
  280. package/dist/ui/views.d.ts +5 -5
  281. package/dist/ui/views.js +10 -16
  282. package/package.json +3 -3
  283. package/src/migrations/0137_audit_org_idx.sql +5 -0
  284. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  285. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  286. package/src/migrations/0140_retire_history_forms.sql +148 -0
  287. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  288. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  289. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  290. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  291. package/dist/admin/platform-audit.service.d.ts +0 -41
  292. package/dist/conversations/job-ids.d.ts +0 -6
  293. package/dist/conversations/job-ids.js +0 -6
  294. package/dist/extensions/job-ids.d.ts +0 -6
  295. package/dist/extensions/job-ids.js +0 -6
  296. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  297. package/dist/infra/queue/retired-schedulers.js +0 -9
  298. package/dist/orgs/job-ids.d.ts +0 -8
  299. package/dist/orgs/job-ids.js +0 -8
  300. package/dist/runtime/context/legacy-text.d.ts +0 -22
  301. package/dist/runtime/context/legacy-text.js +0 -37
  302. package/dist/runtime/job-ids.d.ts +0 -10
  303. package/dist/runtime/job-ids.js +0 -10
  304. package/dist/runtime/retired-schedulers.d.ts +0 -7
  305. package/dist/runtime/retired-schedulers.js +0 -31
  306. package/dist/storage/job-ids.d.ts +0 -6
  307. package/dist/storage/job-ids.js +0 -6
  308. package/dist/tools/legacy-data.d.ts +0 -34
  309. package/dist/tools/legacy-data.js +0 -76
  310. package/dist/tools/legacy-keys.d.ts +0 -51
  311. package/dist/tools/legacy-keys.js +0 -114
@@ -0,0 +1,47 @@
1
+ import type { Logger } from "@capybara-hq/plugin-sdk";
2
+ import type { AgentDefinition } from "../../agents/definition.js";
3
+ import type { EventPayload } from "../../conversations/events.js";
4
+ import type { SkillInvoker } from "../../skills/invoke.js";
5
+ import type { ToolStepContext } from "../../tools/pipeline.js";
6
+ import type { TemplateSkill } from "./definition.js";
7
+ /**
8
+ * A template's skills at child start (Claude Code's sub-agent `skills`, skills default-on spec
9
+ * §6.1): the dispatch writes one skill invocation message per skill the child has, after its task
10
+ * message and in the same transaction, so the child starts with the instructions instead of
11
+ * spending model steps on `Skill` calls. Each message is a `user_message` with the `skill` record
12
+ * (`mode: "inline"`, no arguments, `template: true`: nobody typed it) and the version's rendered
13
+ * `<skill_invocation>` text, as an inline invocation is logged: the text is fixed in the log
14
+ * (replay never renders it again), and the record lets the child's `Skill` copy the files of that
15
+ * version.
16
+ */
17
+ /** The lead of a template skill's invocation message (model-visible, English). */
18
+ export declare const templateSkillLeadText: (name: string) => string;
19
+ /** The message of a template skill whose SKILL.md could not be read at dispatch. */
20
+ export declare const templateSkillUnreadableText: (name: string) => string;
21
+ /** The dispatch warning of a template skill that could not be read or rendered (not model-visible). */
22
+ export declare const templateSkillUnreadableWarning: (name: string) => string;
23
+ type UserMessage = {
24
+ type: "user_message";
25
+ payload: EventPayload<"user_message">;
26
+ };
27
+ /**
28
+ * The invocation messages of `skills` for the child's effective definition `child` (its tools
29
+ * decide the shell line), read from the versions its catalog lists. A version that cannot be read
30
+ * or rendered (storage down, integrity, over the size limit) gets {@link
31
+ * templateSkillUnreadableText} instead (marked `templateSkillNotice`, display only) and a dispatch
32
+ * warning ({@link templateSkillUnreadableWarning}, for `subagent_started.warnings`), and the
33
+ * dispatch goes on.
34
+ * Null when the run's signal aborted before a read: the dispatch writes nothing.
35
+ */
36
+ export declare function templateSkillMessages(d: {
37
+ invoker: Pick<SkillInvoker, "renderTask">;
38
+ log: Pick<Logger, "warn">;
39
+ }, a: {
40
+ ctx: ToolStepContext;
41
+ child: AgentDefinition;
42
+ skills: readonly TemplateSkill[];
43
+ }): Promise<{
44
+ messages: UserMessage[];
45
+ warnings: string[];
46
+ } | null>;
47
+ export {};
@@ -0,0 +1,76 @@
1
+ import { ApiError } from "../../errors.js";
2
+ /**
3
+ * A template's skills at child start (Claude Code's sub-agent `skills`, skills default-on spec
4
+ * §6.1): the dispatch writes one skill invocation message per skill the child has, after its task
5
+ * message and in the same transaction, so the child starts with the instructions instead of
6
+ * spending model steps on `Skill` calls. Each message is a `user_message` with the `skill` record
7
+ * (`mode: "inline"`, no arguments, `template: true`: nobody typed it) and the version's rendered
8
+ * `<skill_invocation>` text, as an inline invocation is logged: the text is fixed in the log
9
+ * (replay never renders it again), and the record lets the child's `Skill` copy the files of that
10
+ * version.
11
+ */
12
+ /** The lead of a template skill's invocation message (model-visible, English). */
13
+ export const templateSkillLeadText = (name) => `Your sub-agent type comes with the skill "${name}"; its instructions follow. Use them for this task.`;
14
+ /** The message of a template skill whose SKILL.md could not be read at dispatch. */
15
+ export const templateSkillUnreadableText = (name) => `Your sub-agent type comes with the skill "${name}", but it could not be read when you started; load it with Skill before you use it.`;
16
+ /** The dispatch warning of a template skill that could not be read or rendered (not model-visible). */
17
+ export const templateSkillUnreadableWarning = (name) => `The skill "${name}" could not be read at dispatch; the sub-agent was told to load it with Skill.`;
18
+ /**
19
+ * The invocation messages of `skills` for the child's effective definition `child` (its tools
20
+ * decide the shell line), read from the versions its catalog lists. A version that cannot be read
21
+ * or rendered (storage down, integrity, over the size limit) gets {@link
22
+ * templateSkillUnreadableText} instead (marked `templateSkillNotice`, display only) and a dispatch
23
+ * warning ({@link templateSkillUnreadableWarning}, for `subagent_started.warnings`), and the
24
+ * dispatch goes on.
25
+ * Null when the run's signal aborted before a read: the dispatch writes nothing.
26
+ */
27
+ export async function templateSkillMessages(d, a) {
28
+ const messages = [];
29
+ const warnings = [];
30
+ for (const s of a.skills) {
31
+ // a stopped run reads no more skill files (as the fork path checks before its read)
32
+ if (a.ctx.signal.aborted)
33
+ return null;
34
+ const record = {
35
+ id: s.id,
36
+ version: s.version,
37
+ source: s.source,
38
+ name: s.name,
39
+ ...(s.plugin !== undefined && { plugin: s.plugin }),
40
+ arguments: "",
41
+ mode: "inline",
42
+ template: true,
43
+ };
44
+ let text;
45
+ try {
46
+ const { task } = await d.invoker.renderTask({
47
+ orgId: a.ctx.orgId,
48
+ conversationId: a.ctx.conversationId,
49
+ skill: record,
50
+ });
51
+ text = `${templateSkillLeadText(s.name)}\n\n${task(a.child)}`;
52
+ }
53
+ catch (e) {
54
+ if (!(e instanceof ApiError) && !(e instanceof RangeError))
55
+ throw e;
56
+ d.log.warn("template skill not loaded at dispatch", {
57
+ orgId: a.ctx.orgId,
58
+ conversationId: a.ctx.conversationId,
59
+ skillId: s.id,
60
+ version: s.version,
61
+ err: e,
62
+ });
63
+ messages.push(message(a.ctx, templateSkillUnreadableText(s.name), {
64
+ templateSkillNotice: { name: s.name },
65
+ }));
66
+ warnings.push(templateSkillUnreadableWarning(s.name));
67
+ continue;
68
+ }
69
+ messages.push(message(a.ctx, text, { skill: record }));
70
+ }
71
+ return { messages, warnings };
72
+ }
73
+ const message = (ctx, text, marker) => ({
74
+ type: "user_message",
75
+ payload: { content: [{ type: "text", text }], ...marker, authorAccountId: ctx.accountId },
76
+ });
@@ -8,9 +8,15 @@ export interface ScheduleBounds {
8
8
  maxTasksPerOrgCap: number;
9
9
  maxRunsPerHourCap: number;
10
10
  }
11
- /** The org's scheduled-task settings after clamping to the platform bounds. */
12
- export type EffectiveScheduleSettings = ScheduledTasksSettings;
11
+ /**
12
+ * The org's scheduled-task settings after clamping to the platform bounds. `forbiddenToolsUnreadable`:
13
+ * the stored list cannot be read (`invalidStoredForbiddenTools`); `forbiddenTools` is then `[]`
14
+ * and unattended runs of the org must fail instead of running with nothing forbidden.
15
+ */
16
+ export type EffectiveScheduleSettings = ScheduledTasksSettings & {
17
+ forbiddenToolsUnreadable: boolean;
18
+ };
13
19
  /** An org value outside the platform bounds is clamped: the interval up, the counts down. */
14
- export declare function effectiveScheduleSettings(org: ScheduledTasksSettings, bounds: ScheduleBounds): EffectiveScheduleSettings;
20
+ export declare function effectiveScheduleSettings(org: ScheduledTasksSettings, bounds: ScheduleBounds, forbiddenToolsUnreadable?: boolean): EffectiveScheduleSettings;
15
21
  /** Read the org's effective settings live (PG and the current kernel config). */
16
22
  export declare function readScheduleSettings(db: KernelSchemaDb, config: Pick<KernelConfigService, "get">, orgId: string): Promise<EffectiveScheduleSettings>;
@@ -1,9 +1,10 @@
1
- import { readOrgSettings } from "../orgs/settings.service.js";
1
+ import { invalidStoredForbiddenTools, parseOrgSettings, readStoredOrgSettings, } from "../orgs/settings.service.js";
2
2
  /** An org value outside the platform bounds is clamped: the interval up, the counts down. */
3
- export function effectiveScheduleSettings(org, bounds) {
3
+ export function effectiveScheduleSettings(org, bounds, forbiddenToolsUnreadable = false) {
4
4
  return {
5
5
  ...org,
6
6
  forbiddenTools: [...org.forbiddenTools],
7
+ forbiddenToolsUnreadable,
7
8
  minIntervalMinutes: Math.max(org.minIntervalMinutes, bounds.minIntervalFloorMinutes),
8
9
  maxTasksPerMember: Math.min(org.maxTasksPerMember, bounds.maxTasksPerMemberCap),
9
10
  maxTasksPerOrg: Math.min(org.maxTasksPerOrg, bounds.maxTasksPerOrgCap),
@@ -12,6 +13,6 @@ export function effectiveScheduleSettings(org, bounds) {
12
13
  }
13
14
  /** Read the org's effective settings live (PG and the current kernel config). */
14
15
  export async function readScheduleSettings(db, config, orgId) {
15
- const org = await readOrgSettings(db, orgId);
16
- return effectiveScheduleSettings(org.scheduledTasks, config.get().schedules);
16
+ const raw = await readStoredOrgSettings(db, orgId);
17
+ return effectiveScheduleSettings(parseOrgSettings(raw).scheduledTasks, config.get().schedules, invalidStoredForbiddenTools(raw));
17
18
  }
@@ -27,6 +27,7 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
27
27
  import { KERNEL_LOGGER } from "../infra/tokens.js";
28
28
  import { deviceLeaseKey } from "../local-devices/keys.js";
29
29
  import { OrgLock, OrgLockModule } from "../orgs/org-lock.js";
30
+ import { FORBIDDEN_TOOLS_UNREADABLE_ERROR } from "../orgs/settings.service.js";
30
31
  import { RuntimeModule } from "../runtime/runtime.module.js";
31
32
  import { readScheduleSettings } from "./effective-settings.js";
32
33
  import { oweSchedSettle, SCHED_LATE_FIRE_SLACK_MS, SCHED_SETTLE_AFTER_MS, SCHED_SETTLE_LONG_CHECKS, SCHED_SETTLE_RECHECK_MS, } from "./job-ids.js";
@@ -249,6 +250,16 @@ let ScheduledTaskFirer = class ScheduledTaskFirer {
249
250
  }
250
251
  if (!resumed && !settings.enabled)
251
252
  return skip("org_disabled");
253
+ // an unattended run must not run with nothing forbidden (a trial run is attended)
254
+ if (!resumed && !run.trial && settings.forbiddenToolsUnreadable) {
255
+ this.log.warn("scheduled task run failed: the org's forbidden tool list is unreadable", {
256
+ orgId,
257
+ taskId: task.id,
258
+ taskRunId: run.id,
259
+ });
260
+ await this.tracker.failStartIn(run.id, FORBIDDEN_TOOLS_UNREADABLE_ERROR);
261
+ return null;
262
+ }
252
263
  if (!resumed && !(await this.creatorActive(orgId, task.accountId))) {
253
264
  return skip("creator_inactive");
254
265
  }
@@ -26,6 +26,7 @@ import { KERNEL_LOGGER } from "../infra/tokens.js";
26
26
  import { orgAllows } from "../local-devices/network-grants.js";
27
27
  import { OrgLock } from "../orgs/org-lock.js";
28
28
  import { can, roleAtLeast } from "../orgs/roles.js";
29
+ import { FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR } from "../orgs/settings.service.js";
29
30
  import { ProviderRegistry } from "../runtime/providers.js";
30
31
  import { orgHostOutsideCeiling } from "../sandbox/modes.js";
31
32
  import { SandboxService } from "../sandbox/sandbox.service.js";
@@ -1035,6 +1036,10 @@ let ScheduledTasksService = class ScheduledTasksService {
1035
1036
  async resolveGrants(orgId, role, agent, settings, grants, _deviceId, source = {}) {
1036
1037
  if (grants.length === 0)
1037
1038
  return [];
1039
+ // fail closed: no grant can be checked against a list that cannot be read
1040
+ if (settings.forbiddenToolsUnreadable) {
1041
+ throw grantNotAllowed(FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR);
1042
+ }
1038
1043
  const out = new Map();
1039
1044
  const network = grants.filter((g) => isNetworkGrantKey(g.toolKey));
1040
1045
  if (network.length > 0) {
@@ -58,6 +58,8 @@ export interface UnattendedRun {
58
58
  trial: boolean;
59
59
  unattendedAsk: "fail" | "wait";
60
60
  forbiddenTools: string[];
61
+ /** The org's stored `forbiddenTools` cannot be read: every tool call of the run is refused. */
62
+ forbiddenToolsUnreadable?: boolean;
61
63
  }
62
64
  /** An unattended run that is not a trial run: the §7 rules apply. */
63
65
  export declare const unattendedRules: (u: UnattendedRun | null | undefined) => u is UnattendedRun;
@@ -146,7 +146,12 @@ export async function unattendedRunOf(db, config, orgId, runId) {
146
146
  if (!run.trial && (await personJoined(db, runId)))
147
147
  return null;
148
148
  const s = await readScheduleSettings(db, config, orgId);
149
- return { ...run, unattendedAsk: s.unattendedAsk, forbiddenTools: s.forbiddenTools };
149
+ return {
150
+ ...run,
151
+ unattendedAsk: s.unattendedAsk,
152
+ forbiddenTools: s.forbiddenTools,
153
+ forbiddenToolsUnreadable: s.forbiddenToolsUnreadable,
154
+ };
150
155
  }
151
156
  /**
152
157
  * The scheduled task whose grants a run's actions use (spec §7; network ask-to-allow spec §8.1),
@@ -91,8 +91,7 @@ export async function shareSkillIn(db, v) {
91
91
  }
92
92
  /**
93
93
  * The catalog snapshot `base` with skill `name` replaced by the version just written or proposed
94
- * (`source` = its prefix), or removed when that version is manual-only. Pinned skills of an old
95
- * snapshot are not carried (skills default-on spec §8).
94
+ * (`source` = its prefix), or removed when that version is manual-only.
96
95
  */
97
96
  function withVersion(base, v) {
98
97
  return {
@@ -142,9 +142,7 @@ export declare function lockLatestCatalog(db: KernelSchemaDb, conversationId: st
142
142
  * 解析只读 skills / agents / 申请(不加锁),不会与别的路径形成死锁。
143
143
  *
144
144
  * The snapshot also carries each skill's `plugin` and the Claude Code tool-name map (`toolMap`,
145
- * iff an effective skill has source format `claude-code`). It never carries `pinned` any more
146
- * (skills default-on spec §8): a conversation whose latest snapshot has pins gets one without them,
147
- * and the request tells the model they were removed. Run start reads no object storage.
145
+ * iff an effective skill has source format `claude-code`). Run start reads no object storage.
148
146
  *
149
147
  * The catalog budget (`skills.catalogBudgetChars`, spec §7) is applied here and recorded in the
150
148
  * snapshot: entries past it carry `nameOnly: true` ({@link applyCatalogBudget}); the cut is logged
@@ -254,9 +254,7 @@ export async function lockLatestCatalog(db, conversationId) {
254
254
  * 解析只读 skills / agents / 申请(不加锁),不会与别的路径形成死锁。
255
255
  *
256
256
  * The snapshot also carries each skill's `plugin` and the Claude Code tool-name map (`toolMap`,
257
- * iff an effective skill has source format `claude-code`). It never carries `pinned` any more
258
- * (skills default-on spec §8): a conversation whose latest snapshot has pins gets one without them,
259
- * and the request tells the model they were removed. Run start reads no object storage.
257
+ * iff an effective skill has source format `claude-code`). Run start reads no object storage.
260
258
  *
261
259
  * The catalog budget (`skills.catalogBudgetChars`, spec §7) is applied here and recorded in the
262
260
  * snapshot: entries past it carry `nameOnly: true` ({@link applyCatalogBudget}); the cut is logged
@@ -22,8 +22,7 @@ export interface CancelledDrafts {
22
22
  * between "read latest" and "append". Returns the seq written, or null when nothing was written;
23
23
  * the caller calls `eventLog.notify` after the commit.
24
24
  * `derive` gets the whole latest payload, so `toolMap` is carried forward (it is only recomputed at
25
- * run start). `pinned` of an old snapshot never is: new snapshots carry no pinned skills (skills
26
- * default-on spec §8).
25
+ * run start).
27
26
  */
28
27
  export declare function appendConversationCatalog(deps: ConversationCatalogDeps, conversationId: string, derive: (base: SkillsSnapshot) => SkillsSnapshot | null, idemKey: string, runId?: string | null): Promise<number | null>;
29
28
  /**
@@ -10,8 +10,7 @@ const byName = (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
10
10
  * between "read latest" and "append". Returns the seq written, or null when nothing was written;
11
11
  * the caller calls `eventLog.notify` after the commit.
12
12
  * `derive` gets the whole latest payload, so `toolMap` is carried forward (it is only recomputed at
13
- * run start). `pinned` of an old snapshot never is: new snapshots carry no pinned skills (skills
14
- * default-on spec §8).
13
+ * run start).
15
14
  */
16
15
  export async function appendConversationCatalog(deps, conversationId, derive, idemKey, runId) {
17
16
  const base = (await lockLatestCatalog(deps.db.db, conversationId)) ?? { skills: [] };
@@ -1,5 +1,6 @@
1
1
  import { skillDisabled } from "../agents/definition.js";
2
2
  import { componentOn, platformBuiltin } from "../catalog/component-state.js";
3
+ import { LIVE_INSTALL_STATUSES } from "../catalog/install-status.js";
3
4
  /** The `source` prefix of a platform skill version in a snapshot or an invocation record. */
4
5
  export const PLATFORM_SOURCE = "platform:";
5
6
  /** The snapshot `source` of a platform skill version stored at `prefix` (in `deployment/`). */
@@ -14,8 +15,6 @@ export function skillFileStore(storage, orgId, source) {
14
15
  ? { store: storage.deployment(), prefix: source.slice(PLATFORM_SOURCE.length) }
15
16
  : { store: storage.kernel(orgId), prefix: source };
16
17
  }
17
- /** Plugin install statuses that make a plugin on in the org (phase 1, org catalog state). */
18
- const LIVE_INSTALL = ["installing", "installed", "upgrading"];
19
18
  const byNameThenId = (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
20
19
  /** The live platform skill rows on in the org (`ids`: only those), before any name clash. */
21
20
  async function platformRowsOn(db, orgId, ids) {
@@ -48,7 +47,7 @@ async function platformRowsOn(db, orgId, ids) {
48
47
  .select("a.id")
49
48
  .whereRef("a.item_id", "=", "p.catalog_item_id")
50
49
  .where("a.org_id", "=", orgId)
51
- .where("a.status", "in", [...LIVE_INSTALL]))
50
+ .where("a.status", "in", [...LIVE_INSTALL_STATUSES]))
52
51
  .as("installed"),
53
52
  eb
54
53
  .exists(eb
@@ -84,7 +84,7 @@ export class PrefixedStorage {
84
84
  }
85
85
  scopedStore(ks) {
86
86
  const scoped = () => new ScopedStore(this.require(), ks);
87
- return {
87
+ const store = {
88
88
  put: async (key, body, opts) => scoped().put(key, body, opts),
89
89
  get: async (key, opts) => scoped().get(key, opts),
90
90
  head: async (key) => scoped().head(key),
@@ -94,6 +94,14 @@ export class PrefixedStorage {
94
94
  presignGet: async (key, opts) => scoped().presignGet(key, opts),
95
95
  presignPut: async (key, opts) => scoped().presignPut(key, opts),
96
96
  };
97
+ // the unsigned URI of a key (`s3://bucket/key`, no credentials) comes from the provider when it
98
+ // has one and carries the prefix; without it `uri` stays absent (the caller falls back)
99
+ const provider = this.d.provider();
100
+ const uri = provider?.uri;
101
+ if (provider !== undefined && uri !== undefined) {
102
+ store.uri = (key) => uri.call(provider, ks.key(key));
103
+ }
104
+ return store;
97
105
  }
98
106
  /** 删除该组织的全部对象:`kernel/<orgId>/` 与每个插件的 `plugins/<插件>/<orgId>/`。返回删除数。 */
99
107
  async deleteOrg(orgId) {
@@ -12,6 +12,7 @@ import { isDeepStrictEqual } from "node:util";
12
12
  import { connectorToolKey, parseToolKey, validateAllowHost, } from "@capybara-hq/plugin-sdk";
13
13
  import { Inject, Injectable } from "@nestjs/common";
14
14
  import { sql } from "kysely";
15
+ import { normalizeStoredDefinition } from "../agents/definition.js";
15
16
  import { EventLog } from "../conversations/event-log.js";
16
17
  import { COMMAND_ASK_TEXT_MAX_CHARS, GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS, NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS, } from "../conversations/events.js";
17
18
  import { conversationSourceOf } from "../conversations/source.js";
@@ -40,7 +41,6 @@ import { ScheduledTaskStore } from "../schedules/store.js";
40
41
  import { unattendedTaskRunOf } from "../schedules/unattended.js";
41
42
  import { gitPushPolicyName, personalAuth } from "./connector-account-policies.js";
42
43
  import { pluginDisplayNames } from "./display-names.js";
43
- import { normalizeStoredDefinitionIn } from "./legacy-data.js";
44
44
  import { ToolRegistry } from "./registry.js";
45
45
  export { APPROVAL_DENY_REASON_MAX_CHARS } from "../conversations/events.js";
46
46
  /** `list` 一次最多返回的审批数(收件箱据此判断这个来源是否取满)。 */
@@ -1437,9 +1437,7 @@ let ApprovalsService = class ApprovalsService {
1437
1437
  .executeTakeFirst();
1438
1438
  if (!member)
1439
1439
  return;
1440
- const def = task.definition === null
1441
- ? undefined
1442
- : await normalizeStoredDefinitionIn(t, a.orgId, task.definition);
1440
+ const def = task.definition === null ? undefined : normalizeStoredDefinition(task.definition);
1443
1441
  const { tools } = await this.registry.forAgent(a.orgId, {
1444
1442
  disabledTools: def?.disabledTools ?? [],
1445
1443
  subagentTools: def?.subagentTools,
@@ -3,8 +3,7 @@ import type { ToolKind } from "./info.js";
3
3
  * The names (model-visible keys) of the kernel's builtin tools, following Claude Code (tool naming
4
4
  * spec §4.1). Plain constants: `BuiltinTools`, the tool factories, the registry, policy and the
5
5
  * runtime import them from here. The web keeps its own copy (`apps/web/src/lib/agents.ts`,
6
- * `lib/timeline.ts`), checked equal by `test/tools/builtin-names.test.ts`. The release-candidate
7
- * names are in `legacy-keys.ts`, never here.
6
+ * `lib/timeline.ts`), checked equal by `test/tools/builtin-names.test.ts`.
8
7
  */
9
8
  export declare const BUILTIN: {
10
9
  readonly Bash: "Bash";
@@ -14,6 +13,7 @@ export declare const BUILTIN: {
14
13
  readonly Glob: "Glob";
15
14
  readonly Grep: "Grep";
16
15
  readonly Deliver: "Deliver";
16
+ readonly FetchAttachment: "FetchAttachment";
17
17
  readonly Skill: "Skill";
18
18
  readonly AskUserQuestion: "AskUserQuestion";
19
19
  readonly ReadToolOutput: "ReadToolOutput";
@@ -71,13 +71,6 @@ export declare const SCHEDULE_TOOL_NAMES: readonly BuiltinName[];
71
71
  * manage the person's scheduled tasks ({@link SCHEDULE_TOOL_NAMES}).
72
72
  */
73
73
  export declare const BUILTIN_TOOL_NAMES: readonly BuiltinName[];
74
- /**
75
- * Is `key` a builtin-shaped key (a bare name, no `mcp__` / `plugin__` prefix) that names no
76
- * builtin the kernel has now, e.g. the removed `SkillWrite`? Saving an agent or an org template
77
- * drops such a `toolPolicies` key instead of refusing the save: a stored definition may still
78
- * carry it, and the web sends the whole definition back.
79
- */
80
- export declare function isRemovedBuiltinKey(key: string): boolean;
81
74
  /** The builtin that loads a skill (added by the registry when the log has a skills catalog). */
82
75
  export declare const SKILL_LOAD: "Skill";
83
76
  /** The builtin that searches the tool catalog (added by the registry by org setting and threshold). */
@@ -1,10 +1,8 @@
1
- import { parseToolKey } from "@capybara-hq/plugin-sdk";
2
1
  /**
3
2
  * The names (model-visible keys) of the kernel's builtin tools, following Claude Code (tool naming
4
3
  * spec §4.1). Plain constants: `BuiltinTools`, the tool factories, the registry, policy and the
5
4
  * runtime import them from here. The web keeps its own copy (`apps/web/src/lib/agents.ts`,
6
- * `lib/timeline.ts`), checked equal by `test/tools/builtin-names.test.ts`. The release-candidate
7
- * names are in `legacy-keys.ts`, never here.
5
+ * `lib/timeline.ts`), checked equal by `test/tools/builtin-names.test.ts`.
8
6
  */
9
7
  export const BUILTIN = {
10
8
  Bash: "Bash",
@@ -14,6 +12,7 @@ export const BUILTIN = {
14
12
  Glob: "Glob",
15
13
  Grep: "Grep",
16
14
  Deliver: "Deliver",
15
+ FetchAttachment: "FetchAttachment",
17
16
  Skill: "Skill",
18
17
  AskUserQuestion: "AskUserQuestion",
19
18
  ReadToolOutput: "ReadToolOutput",
@@ -47,6 +46,7 @@ export const SANDBOX_TOOL_NAMES = [
47
46
  BUILTIN.Glob,
48
47
  BUILTIN.Grep,
49
48
  BUILTIN.Deliver,
49
+ BUILTIN.FetchAttachment,
50
50
  BUILTIN.TaskOutput,
51
51
  BUILTIN.TaskStop,
52
52
  BUILTIN.TaskList,
@@ -109,16 +109,6 @@ export const BUILTIN_TOOL_NAMES = [
109
109
  BUILTIN.CurrentTime,
110
110
  ...SCHEDULE_TOOL_NAMES,
111
111
  ];
112
- const BUILTIN_NAME_SET = new Set(Object.values(BUILTIN));
113
- /**
114
- * Is `key` a builtin-shaped key (a bare name, no `mcp__` / `plugin__` prefix) that names no
115
- * builtin the kernel has now, e.g. the removed `SkillWrite`? Saving an agent or an org template
116
- * drops such a `toolPolicies` key instead of refusing the save: a stored definition may still
117
- * carry it, and the web sends the whole definition back.
118
- */
119
- export function isRemovedBuiltinKey(key) {
120
- return parseToolKey(key)?.kind === "builtin" && !BUILTIN_NAME_SET.has(key);
121
- }
122
112
  /** The builtin that loads a skill (added by the registry when the log has a skills catalog). */
123
113
  export const SKILL_LOAD = BUILTIN.Skill;
124
114
  /** The builtin that searches the tool catalog (added by the registry by org setting and threshold). */
@@ -186,6 +176,7 @@ export const BUILTIN_TOOL_KINDS = {
186
176
  [BUILTIN.Glob]: "search",
187
177
  [BUILTIN.Grep]: "search",
188
178
  [BUILTIN.Deliver]: "tool",
179
+ [BUILTIN.FetchAttachment]: "tool",
189
180
  [BUILTIN.TaskOutput]: "read",
190
181
  [BUILTIN.TaskStop]: "command",
191
182
  [BUILTIN.TaskList]: "read",
@@ -20,9 +20,9 @@ const SPEC = {
20
20
  "filesystem. The working directory is the workspace directory; files persist between calls in the same " +
21
21
  "conversation, but background processes may not: when the sandbox is suspended after a period " +
22
22
  "without use they can be stopped and the temporary files directory cleared, so keep results in " +
23
- "files under the workspace directory. Files the user attached to the conversation are copied to " +
24
- "attachments/<conversation>/ in the workspace directory (the result names the paths), " +
25
- "and skill files to the skills directory (read-only). Each call runs in a fresh shell (no state such as " +
23
+ "files under the workspace directory. Files the user attached to the conversation are not in " +
24
+ "the device until FetchAttachment copies one into the workspace's attachments directory; " +
25
+ "skill files are in the skills directory (read-only). Each call runs in a fresh shell (no state such as " +
26
26
  "cd or environment variables carries over). The result has stdout, stderr and the exit code; " +
27
27
  "long output is saved and can be paged with ReadToolOutput. A command that runs longer than " +
28
28
  "timeout milliseconds is stopped. Prefer Read, Write, Edit, Glob and " +
@@ -122,13 +122,6 @@ export declare const ATTACHMENTS_ROOT: string;
122
122
  * UUID, so conversations sharing a device do not overwrite each other's files.
123
123
  */
124
124
  export declare const attachmentsDir: (roots: SandboxRoots, rootConversationId: string) => string;
125
- /** The conversation's marker of synced attachments: `{ <attachment id>: <file name> }`. */
126
- export declare const syncMarkerPath: (roots: SandboxRoots, rootConversationId: string) => string;
127
- /**
128
- * Whether a path, or a Grep output line starting with one, belongs to a sync marker of the
129
- * instance with `roots` (hidden from Glob / Grep). Build it once per call and test every entry.
130
- */
131
- export declare function syncMarkerMatcher(roots?: SandboxRoots): (pathOrLine: string) => boolean;
132
125
  /** 附件文件名的上限(UTF-8 字节,常见文件系统单个文件名上限 255 字节,留出 `-N` 后缀的余量)。 */
133
126
  export declare const ATTACHMENT_NAME_MAX_BYTES = 200;
134
127
  /**
@@ -209,7 +202,7 @@ export declare function checkToolWritable(path: string, s: Pick<SandboxSession,
209
202
  export declare function shellQuote(s: string): string;
210
203
  /**
211
204
  * 给附件分配沙箱里的文件名(按给定顺序,确定性):清理成安全的路径段(≤ {@link ATTACHMENT_NAME_MAX_BYTES}
212
- * 字节),与 `used`(已同步的)及彼此不重名,重名时加 `-2`、`-3`……(加在扩展名之前)。
205
+ * 字节),与 `used`(已占用的)及彼此不重名,重名时加 `-2`、`-3`……(加在扩展名之前)。
213
206
  * 清理后仍不是合法沙箱路径的用 `attachment-<id 前 8 位>`。
214
207
  */
215
208
  export declare function assignAttachmentNames(items: readonly {
@@ -228,11 +221,12 @@ export declare function mapSandboxError(e: unknown, log: Pick<Logger, "warn"> |
228
221
  * Runs `fn` in the device of the call's conversation (a sub-agent: its root's): resolves and
229
222
  * checks the device for the conversation's owner (binding an unbound conversation to the
230
223
  * owner's default first), then `SandboxService.withSandbox` (the instance created, resumed or
231
- * rebuilt on the kept files as needed, every `exec` carrying the call's actor). Attachments are
232
- * synced first. Returns the value and the notices to put before the result (first use, a new
233
- * instance, newly copied attachments). When `withSandbox` rebuilds a gone instance and calls
234
- * `fn` again, the notices are the last call's. The instance's roots are recorded for the model
235
- * on the conversation's first call and whenever they change ({@link recordDevicePaths}).
224
+ * rebuilt on the kept files as needed, every `exec` carrying the call's actor). It never touches
225
+ * attachments: `FetchAttachment` is the only way one enters the device. Returns the value and the
226
+ * notices to put before the result (first use, a new instance). When `withSandbox` rebuilds a gone
227
+ * instance and calls `fn` again, the notices are the last call's. The instance's roots are recorded
228
+ * for the model on the conversation's first call and whenever they change
229
+ * ({@link recordDevicePaths}).
236
230
  */
237
231
  export declare function inSandbox<T>(deps: SandboxToolDeps, ctx: BuiltinCallContext, fn: (s: SandboxSession) => Promise<T>): Promise<{
238
232
  value: T;