@capybara-hq/kernel 0.1.0-rc.5 → 0.1.0-rc.50

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 (1397) hide show
  1. package/bootstrap.json +61 -19
  2. package/dist/admin/admin-agents.controller.d.ts +28 -0
  3. package/dist/admin/admin-agents.controller.js +79 -0
  4. package/dist/admin/admin-connectors.controller.d.ts +29 -0
  5. package/dist/admin/admin-connectors.controller.js +79 -0
  6. package/dist/admin/admin-items.schemas.d.ts +42 -0
  7. package/dist/admin/admin-items.schemas.js +48 -0
  8. package/dist/admin/admin.controller.d.ts +35 -94
  9. package/dist/admin/admin.controller.js +93 -83
  10. package/dist/admin/admin.module.d.ts +6 -1
  11. package/dist/admin/admin.module.js +62 -4
  12. package/dist/admin/admin.schemas.d.ts +97 -0
  13. package/dist/admin/admin.schemas.js +53 -0
  14. package/dist/admin/audit-log.service.d.ts +51 -0
  15. package/dist/admin/audit-log.service.js +78 -0
  16. package/dist/admin/audit.controller.d.ts +26 -0
  17. package/dist/admin/audit.controller.js +72 -0
  18. package/dist/admin/audit.schemas.d.ts +16 -0
  19. package/dist/admin/audit.schemas.js +37 -0
  20. package/dist/admin/extensions.controller.d.ts +10 -0
  21. package/dist/admin/extensions.controller.js +18 -0
  22. package/dist/admin/extensions.schemas.d.ts +7 -0
  23. package/dist/admin/extensions.schemas.js +10 -0
  24. package/dist/admin/health.service.d.ts +104 -0
  25. package/dist/admin/health.service.js +254 -0
  26. package/dist/admin/limit-defaults.d.ts +20 -0
  27. package/dist/admin/limit-defaults.js +10 -0
  28. package/dist/admin/org-network.controller.d.ts +30 -0
  29. package/dist/admin/org-network.controller.js +77 -0
  30. package/dist/admin/org-network.schemas.d.ts +16 -0
  31. package/dist/admin/org-network.schemas.js +27 -0
  32. package/dist/admin/org-network.service.d.ts +43 -0
  33. package/dist/admin/org-network.service.js +109 -0
  34. package/dist/admin/outbox-dead.controller.d.ts +21 -0
  35. package/dist/admin/outbox-dead.controller.js +65 -0
  36. package/dist/admin/outbox-dead.schemas.d.ts +24 -0
  37. package/dist/admin/outbox-dead.schemas.js +42 -0
  38. package/dist/admin/outbox-dead.service.d.ts +81 -0
  39. package/dist/admin/outbox-dead.service.js +248 -0
  40. package/dist/admin/overview.controller.d.ts +31 -0
  41. package/dist/admin/overview.controller.js +78 -0
  42. package/dist/admin/overview.schemas.d.ts +8 -0
  43. package/dist/admin/overview.schemas.js +13 -0
  44. package/dist/admin/overview.service.d.ts +147 -0
  45. package/dist/admin/overview.service.js +256 -0
  46. package/dist/admin/usage.service.d.ts +149 -0
  47. package/dist/admin/usage.service.js +321 -0
  48. package/dist/agents/admin-agents.d.ts +105 -0
  49. package/dist/agents/admin-agents.js +228 -0
  50. package/dist/agents/agent-lookup.d.ts +10 -2
  51. package/dist/agents/agent-lookup.js +20 -10
  52. package/dist/agents/agent-profile.service.d.ts +7 -5
  53. package/dist/agents/agent-profile.service.js +14 -9
  54. package/dist/agents/agents.controller.d.ts +7 -287
  55. package/dist/agents/agents.controller.js +7 -67
  56. package/dist/agents/agents.module.d.ts +4 -3
  57. package/dist/agents/agents.module.js +13 -3
  58. package/dist/agents/agents.schemas.d.ts +440 -0
  59. package/dist/agents/agents.schemas.js +126 -0
  60. package/dist/agents/agents.service.d.ts +67 -13
  61. package/dist/agents/agents.service.js +243 -80
  62. package/dist/agents/definition.d.ts +94 -49
  63. package/dist/agents/definition.js +183 -233
  64. package/dist/agents/from-template.d.ts +8 -5
  65. package/dist/agents/from-template.js +132 -88
  66. package/dist/agents/from-template.service.d.ts +12 -0
  67. package/dist/agents/from-template.service.js +23 -6
  68. package/dist/agents/instruction-files.js +0 -3
  69. package/dist/agents/models.controller.d.ts +38 -6
  70. package/dist/agents/models.controller.js +70 -9
  71. package/dist/agents/org-templates.d.ts +13 -3
  72. package/dist/agents/org-templates.js +168 -67
  73. package/dist/agents/pending-connector-requests.d.ts +2 -0
  74. package/dist/agents/pending-connector-requests.js +1 -1
  75. package/dist/agents/pending-connectors.controller.d.ts +1 -1
  76. package/dist/agents/pending-connectors.controller.js +2 -2
  77. package/dist/agents/pending-connectors.service.d.ts +2 -2
  78. package/dist/agents/pending-connectors.service.js +20 -20
  79. package/dist/agents/profile.d.ts +18 -0
  80. package/dist/agents/profile.js +5 -1
  81. package/dist/agents/readiness.controller.d.ts +8 -19
  82. package/dist/agents/readiness.controller.js +11 -25
  83. package/dist/agents/readiness.service.d.ts +42 -0
  84. package/dist/agents/readiness.service.js +78 -0
  85. package/dist/agents/templates.controller.d.ts +8 -17
  86. package/dist/agents/templates.controller.js +13 -31
  87. package/dist/agents/templates.js +8 -20
  88. package/dist/agents/templates.schemas.d.ts +20 -0
  89. package/dist/agents/templates.schemas.js +45 -0
  90. package/dist/app.d.ts +4 -0
  91. package/dist/app.js +4 -0
  92. package/dist/attribution/platform-attribution.d.ts +104 -0
  93. package/dist/attribution/platform-attribution.js +149 -0
  94. package/dist/background/background.controller.js +3 -2
  95. package/dist/background/background.module.js +2 -2
  96. package/dist/background/background.schemas.d.ts +10 -0
  97. package/dist/background/background.schemas.js +16 -0
  98. package/dist/background/finish.d.ts +13 -2
  99. package/dist/background/finish.js +71 -6
  100. package/dist/background/launch-lock.d.ts +1 -1
  101. package/dist/background/launch-lock.js +1 -1
  102. package/dist/background/launch.d.ts +37 -19
  103. package/dist/background/launch.js +64 -41
  104. package/dist/background/managed-output.d.ts +110 -0
  105. package/dist/background/managed-output.js +219 -0
  106. package/dist/background/managed.d.ts +52 -0
  107. package/dist/background/managed.js +128 -0
  108. package/dist/background/poll.job.d.ts +41 -11
  109. package/dist/background/poll.job.js +195 -61
  110. package/dist/background/render.d.ts +9 -0
  111. package/dist/background/render.js +20 -0
  112. package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
  113. package/dist/background/retire-legacy-tasks.job.js +149 -0
  114. package/dist/background/session.d.ts +3 -44
  115. package/dist/background/session.js +3 -75
  116. package/dist/background/stop.d.ts +46 -25
  117. package/dist/background/stop.js +126 -90
  118. package/dist/background/store.d.ts +144 -56
  119. package/dist/background/store.js +234 -87
  120. package/dist/background/tasks.service.d.ts +39 -10
  121. package/dist/background/tasks.service.js +128 -75
  122. package/dist/background/wake-rules.d.ts +5 -0
  123. package/dist/background/wake-rules.js +18 -6
  124. package/dist/catalog/admin-catalog.controller.d.ts +70 -69
  125. package/dist/catalog/admin-catalog.controller.js +133 -60
  126. package/dist/catalog/admin-catalog.schemas.d.ts +87 -0
  127. package/dist/catalog/admin-catalog.schemas.js +107 -0
  128. package/dist/catalog/appearance.schemas.d.ts +10 -0
  129. package/dist/catalog/appearance.schemas.js +20 -0
  130. package/dist/catalog/appearance.service.d.ts +105 -0
  131. package/dist/catalog/appearance.service.js +304 -0
  132. package/dist/catalog/catalog-content.d.ts +89 -6
  133. package/dist/catalog/catalog-content.js +89 -9
  134. package/dist/catalog/catalog-files.d.ts +42 -0
  135. package/dist/catalog/catalog-files.js +89 -0
  136. package/dist/catalog/catalog-import.module.js +3 -4
  137. package/dist/catalog/catalog-items.d.ts +11 -0
  138. package/dist/catalog/catalog-items.js +25 -3
  139. package/dist/catalog/catalog-scope.service.d.ts +92 -40
  140. package/dist/catalog/catalog-scope.service.js +278 -133
  141. package/dist/catalog/catalog.module.d.ts +2 -1
  142. package/dist/catalog/catalog.module.js +20 -6
  143. package/dist/catalog/catalog.service.d.ts +32 -6
  144. package/dist/catalog/catalog.service.js +99 -9
  145. package/dist/catalog/claude/report.d.ts +9 -2
  146. package/dist/catalog/claude/report.js +1 -0
  147. package/dist/catalog/claude/translate.js +4 -1
  148. package/dist/catalog/cli.d.ts +0 -10
  149. package/dist/catalog/cli.js +3 -25
  150. package/dist/catalog/component-promotion.js +1 -2
  151. package/dist/catalog/component-scope.controller.d.ts +21 -71
  152. package/dist/catalog/component-scope.controller.js +39 -69
  153. package/dist/catalog/component-scope.schemas.d.ts +118 -0
  154. package/dist/catalog/component-scope.schemas.js +97 -0
  155. package/dist/catalog/component-scope.service.d.ts +105 -14
  156. package/dist/catalog/component-scope.service.js +228 -33
  157. package/dist/catalog/component-state.d.ts +54 -9
  158. package/dist/catalog/component-state.js +93 -37
  159. package/dist/catalog/git-source.d.ts +9 -1
  160. package/dist/catalog/git-source.js +29 -2
  161. package/dist/catalog/install-status.d.ts +6 -0
  162. package/dist/catalog/install-status.js +6 -0
  163. package/dist/catalog/job-ids.d.ts +8 -24
  164. package/dist/catalog/job-ids.js +11 -20
  165. package/dist/catalog/marketplace-fetch.d.ts +5 -2
  166. package/dist/catalog/marketplace-fetch.js +4 -1
  167. package/dist/catalog/marketplace-icons.d.ts +64 -0
  168. package/dist/catalog/marketplace-icons.js +131 -0
  169. package/dist/catalog/marketplaces.controller.d.ts +31 -39
  170. package/dist/catalog/marketplaces.controller.js +85 -50
  171. package/dist/catalog/marketplaces.schemas.d.ts +48 -0
  172. package/dist/catalog/marketplaces.schemas.js +53 -0
  173. package/dist/catalog/marketplaces.service.d.ts +57 -4
  174. package/dist/catalog/marketplaces.service.js +268 -8
  175. package/dist/catalog/org-catalog.controller.d.ts +37 -66
  176. package/dist/catalog/org-catalog.controller.js +71 -72
  177. package/dist/catalog/org-catalog.schemas.d.ts +117 -0
  178. package/dist/catalog/org-catalog.schemas.js +141 -0
  179. package/dist/catalog/org-catalog.service.d.ts +11 -2
  180. package/dist/catalog/org-catalog.service.js +69 -12
  181. package/dist/catalog/org-extension-switch.d.ts +7 -2
  182. package/dist/catalog/org-extension-switch.js +56 -9
  183. package/dist/catalog/org-extension.controller.d.ts +33 -19
  184. package/dist/catalog/org-extension.controller.js +63 -16
  185. package/dist/catalog/org-extension.schemas.d.ts +15 -0
  186. package/dist/catalog/org-extension.schemas.js +22 -0
  187. package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -25
  188. package/dist/catalog/org-plugin-uploads.controller.js +15 -29
  189. package/dist/catalog/org-plugin-uploads.d.ts +18 -13
  190. package/dist/catalog/org-plugin-uploads.js +17 -17
  191. package/dist/catalog/org-plugin-uploads.schemas.d.ts +19 -0
  192. package/dist/catalog/org-plugin-uploads.schemas.js +30 -0
  193. package/dist/catalog/owned-items.d.ts +12 -15
  194. package/dist/catalog/owned-items.js +35 -36
  195. package/dist/catalog/owned-plugin-cleanup.d.ts +8 -17
  196. package/dist/catalog/owned-plugin-cleanup.js +12 -66
  197. package/dist/catalog/platform-components.d.ts +75 -32
  198. package/dist/catalog/platform-components.js +177 -81
  199. package/dist/catalog/platform-import-update.d.ts +50 -0
  200. package/dist/catalog/platform-import-update.js +116 -0
  201. package/dist/catalog/plugin-import.d.ts +146 -51
  202. package/dist/catalog/plugin-import.js +313 -159
  203. package/dist/catalog/plugin-install.d.ts +62 -62
  204. package/dist/catalog/plugin-install.js +185 -183
  205. package/dist/catalog/plugin-package.d.ts +54 -13
  206. package/dist/catalog/plugin-package.js +225 -33
  207. package/dist/catalog/plugin-upgrade.d.ts +81 -16
  208. package/dist/catalog/plugin-upgrade.js +241 -67
  209. package/dist/catalog/requests.service.d.ts +72 -11
  210. package/dist/catalog/requests.service.js +235 -17
  211. package/dist/catalog/scope-jobs.d.ts +59 -0
  212. package/dist/catalog/scope-jobs.js +78 -0
  213. package/dist/catalog/scope-orgs.d.ts +1 -1
  214. package/dist/catalog/scope-orgs.js +1 -2
  215. package/dist/catalog/scope-sync-workers.d.ts +23 -0
  216. package/dist/catalog/scope-sync-workers.js +70 -2
  217. package/dist/catalog/scope-sync.d.ts +68 -95
  218. package/dist/catalog/scope-sync.js +128 -205
  219. package/dist/catalog/unshare.d.ts +3 -4
  220. package/dist/catalog/unshare.js +6 -8
  221. package/dist/channels/actions.d.ts +5 -0
  222. package/dist/channels/actions.js +32 -7
  223. package/dist/channels/cards.d.ts +62 -9
  224. package/dist/channels/cards.js +190 -28
  225. package/dist/channels/channels.module.d.ts +13 -9
  226. package/dist/channels/channels.module.js +36 -13
  227. package/dist/channels/channels.schemas.d.ts +41 -0
  228. package/dist/channels/channels.schemas.js +40 -0
  229. package/dist/channels/connections.controller.d.ts +46 -37
  230. package/dist/channels/connections.controller.js +76 -34
  231. package/dist/channels/connections.service.d.ts +107 -17
  232. package/dist/channels/connections.service.js +260 -31
  233. package/dist/channels/deliver-job.d.ts +32 -0
  234. package/dist/channels/deliver-job.js +29 -0
  235. package/dist/channels/features.d.ts +2 -0
  236. package/dist/channels/features.js +9 -5
  237. package/dist/channels/file-delivery.d.ts +74 -0
  238. package/dist/channels/file-delivery.js +176 -0
  239. package/dist/channels/inbound.d.ts +9 -32
  240. package/dist/channels/inbound.js +84 -52
  241. package/dist/channels/job-ids.d.ts +2 -6
  242. package/dist/channels/job-ids.js +2 -6
  243. package/dist/channels/jobs.d.ts +37 -20
  244. package/dist/channels/jobs.js +79 -27
  245. package/dist/channels/outbound.d.ts +45 -5
  246. package/dist/channels/outbound.js +341 -24
  247. package/dist/channels/phrases.d.ts +176 -34
  248. package/dist/channels/phrases.js +151 -30
  249. package/dist/channels/supervisor.d.ts +4 -3
  250. package/dist/channels/supervisor.js +6 -3
  251. package/dist/channels/threads.d.ts +16 -3
  252. package/dist/channels/threads.js +38 -3
  253. package/dist/channels/webhook.d.ts +21 -1
  254. package/dist/channels/webhook.js +39 -4
  255. package/dist/client/client-access.service.d.ts +102 -0
  256. package/dist/client/client-access.service.js +303 -0
  257. package/dist/client/client-builds.service.d.ts +109 -0
  258. package/dist/client/client-builds.service.js +229 -0
  259. package/dist/client/client-delivery.controller.d.ts +25 -0
  260. package/dist/client/client-delivery.controller.js +66 -0
  261. package/dist/client/client-files.d.ts +48 -0
  262. package/dist/client/client-files.js +136 -0
  263. package/dist/client/client-reports.cron.d.ts +13 -0
  264. package/dist/client/client-reports.cron.js +42 -0
  265. package/dist/client/client-reports.service.d.ts +30 -0
  266. package/dist/client/client-reports.service.js +102 -0
  267. package/dist/client/client-sign-in.service.d.ts +21 -0
  268. package/dist/client/client-sign-in.service.js +49 -0
  269. package/dist/client/client.controller.d.ts +49 -0
  270. package/dist/client/client.controller.js +129 -0
  271. package/dist/client/client.module.d.ts +8 -0
  272. package/dist/client/client.module.js +28 -0
  273. package/dist/client/client.schemas.d.ts +61 -0
  274. package/dist/client/client.schemas.js +27 -0
  275. package/dist/config/docs.js +2 -0
  276. package/dist/config/env.js +19 -1
  277. package/dist/config/load.d.ts +11 -0
  278. package/dist/config/load.js +52 -2
  279. package/dist/config/permission-migration.d.ts +26 -0
  280. package/dist/config/permission-migration.js +64 -0
  281. package/dist/config/schema.d.ts +111 -50
  282. package/dist/config/schema.js +575 -92
  283. package/dist/conversations/access.d.ts +14 -5
  284. package/dist/conversations/access.js +29 -20
  285. package/dist/conversations/agent-tree.d.ts +16 -0
  286. package/dist/conversations/agent-tree.js +36 -0
  287. package/dist/conversations/attachments.service.d.ts +49 -3
  288. package/dist/conversations/attachments.service.js +108 -38
  289. package/dist/conversations/conversations.controller.d.ts +41 -86
  290. package/dist/conversations/conversations.controller.js +75 -114
  291. package/dist/conversations/conversations.module.d.ts +1 -1
  292. package/dist/conversations/conversations.module.js +19 -7
  293. package/dist/conversations/conversations.schemas.d.ts +60 -0
  294. package/dist/conversations/conversations.schemas.js +93 -0
  295. package/dist/conversations/conversations.service.d.ts +268 -41
  296. package/dist/conversations/conversations.service.js +525 -145
  297. package/dist/conversations/delivery-scope.d.ts +34 -0
  298. package/dist/conversations/delivery-scope.js +23 -0
  299. package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
  300. package/dist/conversations/{environment-status.js → device-status.js} +18 -18
  301. package/dist/conversations/event-log.d.ts +58 -12
  302. package/dist/conversations/event-log.js +132 -22
  303. package/dist/conversations/events.d.ts +811 -43
  304. package/dist/conversations/events.js +850 -87
  305. package/dist/conversations/files.d.ts +82 -12
  306. package/dist/conversations/files.js +210 -54
  307. package/dist/conversations/media-types.d.ts +25 -0
  308. package/dist/conversations/media-types.js +38 -0
  309. package/dist/conversations/message-context.d.ts +82 -0
  310. package/dist/conversations/message-context.js +149 -0
  311. package/dist/conversations/permission-profile-store.d.ts +50 -0
  312. package/dist/conversations/permission-profile-store.js +67 -0
  313. package/dist/conversations/permission-profile-store.module.d.ts +2 -0
  314. package/dist/conversations/permission-profile-store.module.js +19 -0
  315. package/dist/conversations/permission-profiles.controller.d.ts +84 -0
  316. package/dist/conversations/permission-profiles.controller.js +105 -0
  317. package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
  318. package/dist/conversations/permission-profiles.schemas.js +23 -0
  319. package/dist/conversations/permission-profiles.service.d.ts +56 -0
  320. package/dist/conversations/permission-profiles.service.js +179 -0
  321. package/dist/conversations/prompt-suggestion-request.d.ts +95 -0
  322. package/dist/conversations/prompt-suggestion-request.js +213 -0
  323. package/dist/conversations/prompt-suggestion-store.d.ts +51 -0
  324. package/dist/conversations/prompt-suggestion-store.js +136 -0
  325. package/dist/conversations/prompt-suggestions.d.ts +153 -0
  326. package/dist/conversations/prompt-suggestions.js +563 -0
  327. package/dist/conversations/queue.d.ts +20 -4
  328. package/dist/conversations/queue.js +31 -3
  329. package/dist/conversations/queue.service.d.ts +20 -9
  330. package/dist/conversations/queue.service.js +92 -27
  331. package/dist/conversations/source.d.ts +10 -0
  332. package/dist/conversations/source.js +17 -0
  333. package/dist/conversations/titles.d.ts +21 -8
  334. package/dist/conversations/titles.js +57 -22
  335. package/dist/conversations/tree.d.ts +10 -0
  336. package/dist/conversations/tree.js +35 -0
  337. package/dist/ctx/create-ctx.d.ts +91 -10
  338. package/dist/ctx/create-ctx.js +231 -48
  339. package/dist/ctx/net.d.ts +50 -0
  340. package/dist/ctx/net.js +67 -0
  341. package/dist/ctx/secrets.d.ts +24 -7
  342. package/dist/ctx/secrets.js +97 -30
  343. package/dist/db/kernel-schema.d.ts +766 -51
  344. package/dist/devices/access.d.ts +66 -0
  345. package/dist/devices/access.js +113 -0
  346. package/dist/devices/access.module.d.ts +2 -0
  347. package/dist/devices/access.module.js +19 -0
  348. package/dist/devices/conversation-devices.d.ts +140 -0
  349. package/dist/devices/conversation-devices.js +331 -0
  350. package/dist/devices/device-projects.service.d.ts +160 -0
  351. package/dist/devices/device-projects.service.js +499 -0
  352. package/dist/devices/devices.controller.d.ts +65 -0
  353. package/dist/devices/devices.controller.js +221 -0
  354. package/dist/devices/devices.module.d.ts +8 -0
  355. package/dist/devices/devices.module.js +49 -0
  356. package/dist/devices/devices.schemas.d.ts +11 -0
  357. package/dist/devices/devices.schemas.js +30 -0
  358. package/dist/devices/devices.service.d.ts +529 -0
  359. package/dist/devices/devices.service.js +1317 -0
  360. package/dist/devices/dto.d.ts +102 -0
  361. package/dist/devices/dto.js +124 -0
  362. package/dist/devices/errors.d.ts +13 -0
  363. package/dist/devices/errors.js +15 -0
  364. package/dist/devices/label.d.ts +11 -0
  365. package/dist/devices/label.js +25 -0
  366. package/dist/{environments → devices}/legacy-cleanup.job.d.ts +4 -4
  367. package/dist/{environments → devices}/legacy-cleanup.job.js +7 -7
  368. package/dist/devices/project-rules.d.ts +44 -0
  369. package/dist/devices/project-rules.js +27 -0
  370. package/dist/devices/public-suffix.d.ts +6 -0
  371. package/dist/devices/public-suffix.js +79 -0
  372. package/dist/devices/working-root.d.ts +47 -0
  373. package/dist/devices/working-root.js +61 -0
  374. package/dist/errors.d.ts +309 -21
  375. package/dist/errors.js +309 -21
  376. package/dist/evals/evals.module.js +16 -3
  377. package/dist/evals/evals.schemas.d.ts +110 -0
  378. package/dist/evals/evals.schemas.js +107 -0
  379. package/dist/evals/jobs.d.ts +14 -6
  380. package/dist/evals/jobs.js +21 -19
  381. package/dist/evals/plan.d.ts +20 -15
  382. package/dist/evals/plan.js +29 -6
  383. package/dist/evals/reconstruct.d.ts +70 -21
  384. package/dist/evals/reconstruct.js +180 -78
  385. package/dist/evals/recorded-permission-context.d.ts +77 -0
  386. package/dist/evals/recorded-permission-context.js +151 -0
  387. package/dist/evals/recorded-tools.d.ts +18 -26
  388. package/dist/evals/recorded-tools.js +54 -84
  389. package/dist/evals/run-replay.d.ts +36 -9
  390. package/dist/evals/run-replay.js +101 -30
  391. package/dist/evals/runs.controller.d.ts +2 -57
  392. package/dist/evals/runs.controller.js +1 -42
  393. package/dist/evals/runs.service.d.ts +13 -13
  394. package/dist/evals/runs.service.js +55 -62
  395. package/dist/evals/sets.controller.d.ts +2 -28
  396. package/dist/evals/sets.controller.js +1 -31
  397. package/dist/evals/sets.service.d.ts +24 -11
  398. package/dist/evals/sets.service.js +64 -23
  399. package/dist/evals/snapshot.d.ts +9 -3
  400. package/dist/evals/snapshot.js +5 -4
  401. package/dist/evals/step-replay.d.ts +8 -1
  402. package/dist/evals/step-replay.js +8 -2
  403. package/dist/evals/trajectory.d.ts +19 -3
  404. package/dist/evals/trajectory.js +14 -1
  405. package/dist/evals/worker.d.ts +10 -1
  406. package/dist/evals/worker.js +24 -14
  407. package/dist/extensions/admin-ops.d.ts +53 -7
  408. package/dist/extensions/admin-ops.js +142 -20
  409. package/dist/extensions/admin-view.d.ts +25 -4
  410. package/dist/extensions/admin-view.js +166 -29
  411. package/dist/extensions/approvals.d.ts +12 -2
  412. package/dist/extensions/blobs.d.ts +14 -1
  413. package/dist/extensions/blobs.js +48 -5
  414. package/dist/extensions/bootstrap.d.ts +73 -11
  415. package/dist/extensions/bootstrap.js +161 -38
  416. package/dist/extensions/cli.js +0 -1
  417. package/dist/extensions/config-hash.d.ts +10 -0
  418. package/dist/extensions/config-hash.js +38 -0
  419. package/dist/extensions/deployment-config.d.ts +16 -1
  420. package/dist/extensions/deployment-config.js +83 -0
  421. package/dist/extensions/effective-config.d.ts +6 -0
  422. package/dist/extensions/effective-config.js +18 -7
  423. package/dist/extensions/enabled.d.ts +24 -4
  424. package/dist/extensions/enabled.js +47 -10
  425. package/dist/extensions/extensions.module.js +29 -13
  426. package/dist/extensions/guide-places.d.ts +68 -0
  427. package/dist/extensions/guide-places.js +152 -0
  428. package/dist/extensions/hooks.d.ts +22 -3
  429. package/dist/extensions/hooks.js +15 -1
  430. package/dist/extensions/host.d.ts +79 -17
  431. package/dist/extensions/host.js +288 -83
  432. package/dist/extensions/installs.d.ts +11 -4
  433. package/dist/extensions/installs.js +24 -2
  434. package/dist/extensions/instance.d.ts +15 -2
  435. package/dist/extensions/instance.js +18 -0
  436. package/dist/extensions/ledger.d.ts +1 -1
  437. package/dist/extensions/lifecycle-hooks.d.ts +99 -0
  438. package/dist/extensions/lifecycle-hooks.js +273 -0
  439. package/dist/extensions/lifecycle.d.ts +6 -1
  440. package/dist/extensions/lifecycle.js +9 -2
  441. package/dist/extensions/locks.d.ts +12 -0
  442. package/dist/extensions/locks.js +26 -0
  443. package/dist/extensions/org-config.d.ts +39 -9
  444. package/dist/extensions/org-config.js +86 -49
  445. package/dist/extensions/package.d.ts +6 -5
  446. package/dist/extensions/package.js +5 -5
  447. package/dist/extensions/permission-set.d.ts +40 -9
  448. package/dist/extensions/permission-set.js +43 -9
  449. package/dist/extensions/permission-view.d.ts +98 -18
  450. package/dist/extensions/permission-view.js +48 -20
  451. package/dist/extensions/plugin-guides.d.ts +282 -0
  452. package/dist/extensions/plugin-guides.js +554 -0
  453. package/dist/extensions/plugin-icons.d.ts +54 -0
  454. package/dist/extensions/plugin-icons.js +125 -0
  455. package/dist/extensions/plugin-items.d.ts +21 -1
  456. package/dist/extensions/plugin-items.js +28 -0
  457. package/dist/extensions/point-defaults.controller.d.ts +2 -8
  458. package/dist/extensions/point-defaults.controller.js +1 -3
  459. package/dist/extensions/point-defaults.d.ts +31 -2
  460. package/dist/extensions/point-defaults.js +48 -15
  461. package/dist/extensions/point-defaults.schemas.d.ts +9 -0
  462. package/dist/extensions/point-defaults.schemas.js +14 -0
  463. package/dist/extensions/resolve.d.ts +46 -0
  464. package/dist/extensions/resolve.js +70 -1
  465. package/dist/extensions/single-provider.d.ts +92 -0
  466. package/dist/extensions/single-provider.js +180 -0
  467. package/dist/extensions/sources.d.ts +13 -2
  468. package/dist/extensions/sources.js +2 -0
  469. package/dist/extensions/state.module.d.ts +9 -0
  470. package/dist/extensions/state.module.js +46 -0
  471. package/dist/extensions/sync.js +5 -10
  472. package/dist/extensions/unavailable.d.ts +50 -0
  473. package/dist/extensions/unavailable.js +114 -0
  474. package/dist/extensions/usage-subscribers.d.ts +43 -0
  475. package/dist/extensions/usage-subscribers.js +108 -0
  476. package/dist/files/previewers.controller.js +2 -3
  477. package/dist/files/previewers.d.ts +46 -2
  478. package/dist/files/previewers.js +90 -30
  479. package/dist/files/previewers.schemas.d.ts +10 -0
  480. package/dist/files/previewers.schemas.js +9 -0
  481. package/dist/git/gateway.d.ts +93 -0
  482. package/dist/git/gateway.js +750 -0
  483. package/dist/git/gateway.route.d.ts +16 -0
  484. package/dist/git/gateway.route.js +41 -0
  485. package/dist/git/git.module.d.ts +10 -0
  486. package/dist/git/git.module.js +31 -0
  487. package/dist/git/identity.d.ts +80 -0
  488. package/dist/git/identity.js +209 -0
  489. package/dist/git/pkt-line.d.ts +53 -0
  490. package/dist/git/pkt-line.js +146 -0
  491. package/dist/git/run-end.d.ts +29 -0
  492. package/dist/git/run-end.js +121 -0
  493. package/dist/git/sources.d.ts +42 -0
  494. package/dist/git/sources.js +134 -0
  495. package/dist/git/tickets.d.ts +69 -0
  496. package/dist/git/tickets.js +194 -0
  497. package/dist/html/csp.d.ts +13 -0
  498. package/dist/html/csp.js +33 -0
  499. package/dist/html/html-document.controller.d.ts +31 -0
  500. package/dist/html/html-document.controller.js +75 -0
  501. package/dist/html/html-document.service.d.ts +49 -0
  502. package/dist/html/html-document.service.js +143 -0
  503. package/dist/html/html-token.d.ts +58 -0
  504. package/dist/html/html-token.js +154 -0
  505. package/dist/html/html-type.d.ts +13 -0
  506. package/dist/html/html-type.js +40 -0
  507. package/dist/html/html.module.d.ts +6 -0
  508. package/dist/html/html.module.js +26 -0
  509. package/dist/http/api.module.js +78 -5
  510. package/dist/http/app.d.ts +14 -2
  511. package/dist/http/app.js +15 -2
  512. package/dist/http/error.filter.d.ts +2 -0
  513. package/dist/http/error.filter.js +9 -2
  514. package/dist/http/gateway-routes.d.ts +7 -3
  515. package/dist/http/gateway-routes.js +6 -3
  516. package/dist/http/plugin-dispatch.d.ts +58 -18
  517. package/dist/http/plugin-dispatch.js +137 -30
  518. package/dist/http/plugin-route-access.d.ts +57 -0
  519. package/dist/http/plugin-route-access.js +207 -0
  520. package/dist/identity/accounts.d.ts +64 -5
  521. package/dist/identity/accounts.js +148 -11
  522. package/dist/identity/audit.d.ts +0 -12
  523. package/dist/identity/audit.js +0 -27
  524. package/dist/identity/auth.controller.js +5 -9
  525. package/dist/identity/auth.guard.d.ts +26 -12
  526. package/dist/identity/auth.guard.js +72 -34
  527. package/dist/identity/cookies.d.ts +8 -7
  528. package/dist/identity/cookies.js +19 -29
  529. package/dist/identity/identity.module.js +5 -0
  530. package/dist/identity/initial-passwords.controller.d.ts +22 -0
  531. package/dist/identity/initial-passwords.controller.js +49 -0
  532. package/dist/identity/initial-passwords.d.ts +61 -0
  533. package/dist/identity/initial-passwords.job.d.ts +16 -0
  534. package/dist/identity/initial-passwords.job.js +46 -0
  535. package/dist/identity/initial-passwords.js +158 -0
  536. package/dist/identity/me.controller.d.ts +12 -0
  537. package/dist/identity/me.controller.js +33 -1
  538. package/dist/identity/me.schemas.d.ts +24 -0
  539. package/dist/identity/me.schemas.js +25 -0
  540. package/dist/identity/principal.d.ts +8 -0
  541. package/dist/identity/principal.js +8 -0
  542. package/dist/identity/sessions.d.ts +0 -6
  543. package/dist/identity/sessions.js +0 -18
  544. package/dist/identity/settings.d.ts +237 -3
  545. package/dist/identity/settings.js +524 -14
  546. package/dist/identity/write-actor.d.ts +11 -0
  547. package/dist/identity/write-actor.js +7 -0
  548. package/dist/inbox/inbox.module.js +2 -1
  549. package/dist/inbox/inbox.schemas.d.ts +8 -0
  550. package/dist/inbox/inbox.schemas.js +11 -0
  551. package/dist/inbox/inbox.service.d.ts +27 -25
  552. package/dist/inbox/inbox.service.js +14 -6
  553. package/dist/inbox/org-notices.d.ts +1 -1
  554. package/dist/inbox/platform-inbox.controller.d.ts +1 -1
  555. package/dist/inbox/platform-inbox.controller.js +2 -2
  556. package/dist/inbox/platform-inbox.service.d.ts +35 -26
  557. package/dist/inbox/platform-inbox.service.js +76 -57
  558. package/dist/index.d.ts +15 -2
  559. package/dist/index.js +16 -2
  560. package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
  561. package/dist/infra/cli/kernel-cli.module.js +10 -2
  562. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  563. package/dist/infra/cli/master-key-rewrap.js +24 -0
  564. package/dist/infra/cli/permission-cutover.d.ts +59 -0
  565. package/dist/infra/cli/permission-cutover.js +107 -0
  566. package/dist/infra/config/kernel-config.service.d.ts +8 -1
  567. package/dist/infra/config/kernel-config.service.js +71 -25
  568. package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
  569. package/dist/infra/database/startup-activation-transaction.js +242 -0
  570. package/dist/infra/database/transaction-host.d.ts +79 -0
  571. package/dist/infra/database/transaction-host.js +159 -3
  572. package/dist/infra/database/xact-lock.d.ts +17 -0
  573. package/dist/infra/database/xact-lock.js +34 -1
  574. package/dist/infra/events/kernel-events.d.ts +14 -28
  575. package/dist/infra/health/health.controller.js +8 -0
  576. package/dist/infra/health/process-fault.d.ts +16 -0
  577. package/dist/infra/health/process-fault.js +49 -0
  578. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  579. package/dist/infra/lifecycle/process-guards.js +12 -3
  580. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  581. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  582. package/dist/infra/lock/lock.service.d.ts +8 -0
  583. package/dist/infra/lock/lock.service.js +27 -0
  584. package/dist/infra/outbox/outbox-relay.module.d.ts +6 -0
  585. package/dist/infra/outbox/outbox-relay.module.js +18 -0
  586. package/dist/infra/outbox/outbox.dispatcher.d.ts +103 -0
  587. package/dist/infra/outbox/outbox.dispatcher.js +310 -0
  588. package/dist/infra/outbox/outbox.module.d.ts +24 -0
  589. package/dist/infra/outbox/outbox.module.js +50 -0
  590. package/dist/infra/outbox/outbox.relay.d.ts +31 -0
  591. package/dist/infra/outbox/outbox.relay.js +76 -0
  592. package/dist/infra/outbox/outbox.service.d.ts +60 -0
  593. package/dist/infra/outbox/outbox.service.js +161 -0
  594. package/dist/infra/outbox/registry.d.ts +386 -0
  595. package/dist/infra/outbox/registry.js +352 -0
  596. package/dist/infra/presence/presence.module.d.ts +6 -0
  597. package/dist/infra/presence/presence.module.js +22 -0
  598. package/dist/infra/presence/replica-presence.d.ts +87 -0
  599. package/dist/infra/presence/replica-presence.js +189 -0
  600. package/dist/infra/queue/queue-names.d.ts +8 -0
  601. package/dist/infra/queue/queue-names.js +18 -0
  602. package/dist/infra/throttler/credential-throttler.d.ts +4 -1
  603. package/dist/infra/throttler/credential-throttler.js +5 -2
  604. package/dist/infra/throttler/named-throttlers.d.ts +16 -0
  605. package/dist/infra/throttler/named-throttlers.js +97 -0
  606. package/dist/infra/throttler/throttler.guard.d.ts +2 -1
  607. package/dist/infra/throttler/throttler.guard.js +3 -2
  608. package/dist/kernel.module.js +21 -1
  609. package/dist/lifecycle/kernel-lifecycle.d.ts +12 -2
  610. package/dist/lifecycle/kernel-lifecycle.js +101 -39
  611. package/dist/local-devices/device-auth.controller.d.ts +42 -0
  612. package/dist/local-devices/device-auth.controller.js +116 -0
  613. package/dist/local-devices/device-auth.d.ts +125 -0
  614. package/dist/local-devices/device-auth.js +410 -0
  615. package/dist/local-devices/device-auth.module.d.ts +7 -0
  616. package/dist/local-devices/device-auth.module.js +25 -0
  617. package/dist/local-devices/device-policy.service.d.ts +204 -0
  618. package/dist/local-devices/device-policy.service.js +645 -0
  619. package/dist/local-devices/device-routes.d.ts +38 -0
  620. package/dist/local-devices/device-routes.js +91 -0
  621. package/dist/local-devices/dto.d.ts +66 -0
  622. package/dist/local-devices/dto.js +44 -0
  623. package/dist/local-devices/instance-bindings.d.ts +82 -0
  624. package/dist/local-devices/instance-bindings.js +304 -0
  625. package/dist/local-devices/keys.d.ts +30 -0
  626. package/dist/local-devices/keys.js +30 -0
  627. package/dist/local-devices/local-device-gateway.d.ts +151 -0
  628. package/dist/local-devices/local-device-gateway.js +703 -0
  629. package/dist/local-devices/local-device-provider.d.ts +119 -0
  630. package/dist/local-devices/local-device-provider.js +298 -0
  631. package/dist/local-devices/local-devices.module.d.ts +31 -0
  632. package/dist/local-devices/local-devices.module.js +98 -0
  633. package/dist/local-devices/machines.d.ts +187 -0
  634. package/dist/local-devices/machines.js +738 -0
  635. package/dist/local-devices/network-grants.d.ts +88 -0
  636. package/dist/local-devices/network-grants.js +267 -0
  637. package/dist/local-devices/network-grants.module.d.ts +2 -0
  638. package/dist/local-devices/network-grants.module.js +14 -0
  639. package/dist/local-devices/owner-report.d.ts +79 -0
  640. package/dist/local-devices/owner-report.js +155 -0
  641. package/dist/local-devices/owner-reports.d.ts +48 -0
  642. package/dist/local-devices/owner-reports.js +190 -0
  643. package/dist/local-devices/policy-op-jobs.d.ts +15 -0
  644. package/dist/local-devices/policy-op-jobs.js +12 -0
  645. package/dist/local-devices/policy-summary.d.ts +121 -0
  646. package/dist/local-devices/policy-summary.js +200 -0
  647. package/dist/local-devices/relay.d.ts +165 -0
  648. package/dist/local-devices/relay.js +532 -0
  649. package/dist/local-devices/targets.d.ts +48 -0
  650. package/dist/local-devices/targets.js +120 -0
  651. package/dist/models/embeddings.d.ts +82 -0
  652. package/dist/models/embeddings.js +319 -0
  653. package/dist/models/enablement.controller.d.ts +40 -0
  654. package/dist/models/enablement.controller.js +74 -0
  655. package/dist/models/enablement.d.ts +100 -0
  656. package/dist/models/enablement.js +257 -0
  657. package/dist/models/image-usable.d.ts +46 -0
  658. package/dist/models/image-usable.js +60 -0
  659. package/dist/models/images.d.ts +125 -0
  660. package/dist/models/images.js +442 -0
  661. package/dist/models/models.module.d.ts +6 -1
  662. package/dist/models/models.module.js +30 -4
  663. package/dist/models/org-models.schemas.d.ts +8 -0
  664. package/dist/models/org-models.schemas.js +23 -0
  665. package/dist/models/prices.d.ts +3 -1
  666. package/dist/models/prices.js +7 -5
  667. package/dist/models/purposes.controller.d.ts +7 -0
  668. package/dist/models/purposes.controller.js +9 -0
  669. package/dist/models/purposes.d.ts +64 -8
  670. package/dist/models/purposes.js +115 -26
  671. package/dist/net/public-address.d.ts +35 -5
  672. package/dist/net/public-address.js +78 -22
  673. package/dist/net/safe-fetch.d.ts +6 -2
  674. package/dist/net/safe-fetch.js +31 -8
  675. package/dist/orgs/cloud-network-setting.d.ts +33 -0
  676. package/dist/orgs/cloud-network-setting.js +47 -0
  677. package/dist/orgs/directory-sync.js +3 -1
  678. package/dist/orgs/members.service.js +6 -1
  679. package/dist/orgs/network-allowances.service.d.ts +79 -0
  680. package/dist/orgs/network-allowances.service.js +371 -0
  681. package/dist/orgs/offboarding.d.ts +59 -58
  682. package/dist/orgs/offboarding.js +146 -168
  683. package/dist/orgs/org-lock.d.ts +34 -2
  684. package/dist/orgs/org-lock.js +65 -4
  685. package/dist/orgs/orgs.controller.d.ts +12 -6
  686. package/dist/orgs/orgs.controller.js +21 -8
  687. package/dist/orgs/orgs.module.d.ts +3 -2
  688. package/dist/orgs/orgs.module.js +13 -12
  689. package/dist/orgs/orgs.schemas.d.ts +20 -0
  690. package/dist/orgs/orgs.schemas.js +21 -0
  691. package/dist/orgs/orgs.service.d.ts +19 -7
  692. package/dist/orgs/orgs.service.js +63 -18
  693. package/dist/orgs/roles.d.ts +1 -1
  694. package/dist/orgs/roles.js +6 -0
  695. package/dist/orgs/settings.controller.d.ts +5 -2
  696. package/dist/orgs/settings.controller.js +9 -4
  697. package/dist/orgs/settings.service.d.ts +381 -48
  698. package/dist/orgs/settings.service.js +615 -81
  699. package/dist/overrides.d.ts +66 -5
  700. package/dist/overrides.js +36 -2
  701. package/dist/packages/npm.d.ts +28 -9
  702. package/dist/packages/npm.js +30 -19
  703. package/dist/packages/provenance.d.ts +3 -1
  704. package/dist/packages/provenance.js +7 -3
  705. package/dist/packages/tgz.d.ts +0 -2
  706. package/dist/packages/tgz.js +0 -2
  707. package/dist/platform/availability.d.ts +5 -0
  708. package/dist/platform/availability.js +7 -3
  709. package/dist/platform/errors.d.ts +21 -4
  710. package/dist/platform/errors.js +45 -6
  711. package/dist/platform/exclusions.d.ts +2 -3
  712. package/dist/platform/exclusions.js +261 -778
  713. package/dist/platform/method.js +1 -1
  714. package/dist/platform/operation.d.ts +82 -5
  715. package/dist/platform/operation.js +79 -8
  716. package/dist/platform/ops/accounts.ops.d.ts +32 -0
  717. package/dist/platform/ops/accounts.ops.js +291 -0
  718. package/dist/platform/ops/admin-items.ops.d.ts +37 -0
  719. package/dist/platform/ops/admin-items.ops.js +278 -0
  720. package/dist/platform/ops/admin.ops.d.ts +38 -0
  721. package/dist/platform/ops/admin.ops.js +566 -0
  722. package/dist/platform/ops/agent-skills.ops.d.ts +50 -0
  723. package/dist/platform/ops/agent-skills.ops.js +512 -0
  724. package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
  725. package/dist/platform/ops/agent-templates.ops.js +196 -16
  726. package/dist/platform/ops/agents.ops.d.ts +19 -1
  727. package/dist/platform/ops/agents.ops.js +497 -68
  728. package/dist/platform/ops/approvals.ops.d.ts +30 -0
  729. package/dist/platform/ops/approvals.ops.js +116 -0
  730. package/dist/platform/ops/background.ops.d.ts +14 -0
  731. package/dist/platform/ops/background.ops.js +134 -0
  732. package/dist/platform/ops/catalog-admin.ops.d.ts +94 -0
  733. package/dist/platform/ops/catalog-admin.ops.js +710 -0
  734. package/dist/platform/ops/channels.ops.d.ts +16 -0
  735. package/dist/platform/ops/channels.ops.js +195 -0
  736. package/dist/platform/ops/components.ops.d.ts +46 -0
  737. package/dist/platform/ops/components.ops.js +854 -0
  738. package/dist/platform/ops/connectors.ops.d.ts +4 -2
  739. package/dist/platform/ops/connectors.ops.js +115 -6
  740. package/dist/platform/ops/conversations.ops.d.ts +30 -0
  741. package/dist/platform/ops/conversations.ops.js +505 -0
  742. package/dist/platform/ops/devices.ops.d.ts +28 -0
  743. package/dist/platform/ops/devices.ops.js +454 -0
  744. package/dist/platform/ops/errors.d.ts +10 -5
  745. package/dist/platform/ops/errors.js +19 -11
  746. package/dist/platform/ops/evals.ops.d.ts +28 -0
  747. package/dist/platform/ops/evals.ops.js +731 -0
  748. package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
  749. package/dist/platform/ops/extensions-admin.ops.js +372 -0
  750. package/dist/platform/ops/extensions.ops.d.ts +7 -1
  751. package/dist/platform/ops/extensions.ops.js +248 -17
  752. package/dist/platform/ops/inbox.ops.d.ts +25 -0
  753. package/dist/platform/ops/inbox.ops.js +397 -0
  754. package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
  755. package/dist/platform/ops/marketplaces.ops.js +326 -17
  756. package/dist/platform/ops/models.ops.d.ts +25 -0
  757. package/dist/platform/ops/models.ops.js +242 -0
  758. package/dist/platform/ops/org-plugins.ops.d.ts +35 -0
  759. package/dist/platform/ops/org-plugins.ops.js +388 -0
  760. package/dist/platform/ops/org-settings.ops.d.ts +18 -0
  761. package/dist/platform/ops/org-settings.ops.js +148 -0
  762. package/dist/platform/ops/orgs.ops.d.ts +36 -0
  763. package/dist/platform/ops/orgs.ops.js +439 -0
  764. package/dist/platform/ops/other-orgs.d.ts +20 -0
  765. package/dist/platform/ops/other-orgs.js +72 -0
  766. package/dist/platform/ops/outbox.ops.d.ts +21 -0
  767. package/dist/platform/ops/outbox.ops.js +125 -0
  768. package/dist/platform/ops/platform.ops.d.ts +24 -6
  769. package/dist/platform/ops/platform.ops.js +141 -38
  770. package/dist/platform/ops/plugins.ops.d.ts +11 -9
  771. package/dist/platform/ops/plugins.ops.js +178 -79
  772. package/dist/platform/ops/previewers.ops.d.ts +14 -0
  773. package/dist/platform/ops/previewers.ops.js +109 -0
  774. package/dist/platform/ops/requests.ops.js +58 -19
  775. package/dist/platform/ops/schedules.ops.d.ts +21 -0
  776. package/dist/platform/ops/schedules.ops.js +509 -0
  777. package/dist/platform/ops/setup.ops.d.ts +24 -0
  778. package/dist/platform/ops/setup.ops.js +212 -0
  779. package/dist/platform/ops/shares.ops.d.ts +16 -0
  780. package/dist/platform/ops/shares.ops.js +107 -0
  781. package/dist/platform/ops/skills.ops.d.ts +5 -1
  782. package/dist/platform/ops/skills.ops.js +99 -37
  783. package/dist/platform/ops/themes.ops.d.ts +14 -0
  784. package/dist/platform/ops/themes.ops.js +47 -0
  785. package/dist/platform/ops/ui.ops.d.ts +8 -0
  786. package/dist/platform/ops/ui.ops.js +41 -0
  787. package/dist/platform/ops/unavailable.d.ts +23 -0
  788. package/dist/platform/ops/unavailable.js +118 -0
  789. package/dist/platform/parity.d.ts +33 -0
  790. package/dist/platform/parity.js +272 -0
  791. package/dist/platform/platform-ops.module.d.ts +39 -0
  792. package/dist/platform/platform-ops.module.js +111 -11
  793. package/dist/platform/route-schemas.d.ts +18 -0
  794. package/dist/platform/route-schemas.js +97 -0
  795. package/dist/roles/gateway-role.d.ts +18 -3
  796. package/dist/roles/gateway-role.js +33 -5
  797. package/dist/roles/gateway.module.d.ts +2 -1
  798. package/dist/roles/gateway.module.js +6 -3
  799. package/dist/roles/worker-role.d.ts +16 -9
  800. package/dist/roles/worker-role.js +39 -31
  801. package/dist/roles/worker.module.js +33 -9
  802. package/dist/runtime/checkpointer.d.ts +3 -0
  803. package/dist/runtime/checkpointer.js +9 -3
  804. package/dist/runtime/compaction-progress.d.ts +62 -0
  805. package/dist/runtime/compaction-progress.js +82 -0
  806. package/dist/runtime/compaction-settings.service.d.ts +24 -0
  807. package/dist/runtime/compaction-settings.service.js +48 -0
  808. package/dist/runtime/compaction.service.d.ts +50 -0
  809. package/dist/runtime/compaction.service.js +75 -0
  810. package/dist/runtime/context/build.d.ts +79 -20
  811. package/dist/runtime/context/build.js +281 -57
  812. package/dist/runtime/context/compaction.d.ts +111 -16
  813. package/dist/runtime/context/compaction.js +419 -55
  814. package/dist/runtime/context/device-paths.d.ts +89 -0
  815. package/dist/runtime/context/device-paths.js +185 -0
  816. package/dist/runtime/context/fit.d.ts +111 -0
  817. package/dist/runtime/context/fit.js +278 -0
  818. package/dist/runtime/context/permission-profile.d.ts +46 -0
  819. package/dist/runtime/context/permission-profile.js +194 -0
  820. package/dist/runtime/context/plugin-context.d.ts +20 -0
  821. package/dist/runtime/context/plugin-context.js +30 -0
  822. package/dist/runtime/context/project-root.d.ts +43 -0
  823. package/dist/runtime/context/project-root.js +85 -0
  824. package/dist/runtime/context/run-context.d.ts +88 -0
  825. package/dist/runtime/context/run-context.js +295 -0
  826. package/dist/runtime/context/skills.d.ts +38 -54
  827. package/dist/runtime/context/skills.js +76 -117
  828. package/dist/runtime/context/tool-changes.d.ts +3 -3
  829. package/dist/runtime/context/tool-changes.js +6 -16
  830. package/dist/runtime/conversation-lock.d.ts +4 -11
  831. package/dist/runtime/conversation-lock.js +14 -18
  832. package/dist/runtime/hook-calls.d.ts +24 -7
  833. package/dist/runtime/hook-calls.js +71 -17
  834. package/dist/runtime/langgraph-loop.js +26 -8
  835. package/dist/runtime/limits.d.ts +15 -0
  836. package/dist/runtime/limits.js +25 -0
  837. package/dist/runtime/loop.d.ts +16 -3
  838. package/dist/runtime/loop.js +2 -1
  839. package/dist/runtime/maintenance.d.ts +25 -14
  840. package/dist/runtime/maintenance.js +134 -33
  841. package/dist/runtime/model-call.d.ts +187 -21
  842. package/dist/runtime/model-call.js +1024 -371
  843. package/dist/runtime/permission-context-errors.d.ts +39 -0
  844. package/dist/runtime/permission-context-errors.js +67 -0
  845. package/dist/runtime/permission-context.service.d.ts +60 -0
  846. package/dist/runtime/permission-context.service.js +286 -0
  847. package/dist/runtime/plugin-context.service.d.ts +75 -0
  848. package/dist/runtime/plugin-context.service.js +220 -0
  849. package/dist/runtime/project/knowledge.d.ts +134 -0
  850. package/dist/runtime/project/knowledge.js +251 -0
  851. package/dist/runtime/project/knowledge.service.d.ts +100 -0
  852. package/dist/runtime/project/knowledge.service.js +352 -0
  853. package/dist/runtime/providers.d.ts +160 -44
  854. package/dist/runtime/providers.js +365 -130
  855. package/dist/runtime/queue-lost-jobs.d.ts +24 -0
  856. package/dist/runtime/queue-lost-jobs.js +51 -0
  857. package/dist/runtime/run-context.service.d.ts +82 -0
  858. package/dist/runtime/run-context.service.js +255 -0
  859. package/dist/runtime/run-control.d.ts +52 -5
  860. package/dist/runtime/run-control.js +86 -12
  861. package/dist/runtime/run-deletion.d.ts +29 -0
  862. package/dist/runtime/run-deletion.js +153 -0
  863. package/dist/runtime/run-execution.d.ts +79 -0
  864. package/dist/runtime/run-execution.js +184 -0
  865. package/dist/runtime/run-finish.d.ts +49 -12
  866. package/dist/runtime/run-finish.js +140 -15
  867. package/dist/runtime/run-jobs.d.ts +112 -13
  868. package/dist/runtime/run-jobs.js +236 -29
  869. package/dist/runtime/run-liveness.d.ts +11 -0
  870. package/dist/runtime/run-liveness.js +19 -0
  871. package/dist/runtime/run-orphan-check.job.d.ts +145 -0
  872. package/dist/runtime/run-orphan-check.job.js +413 -0
  873. package/dist/runtime/run-processors.d.ts +30 -15
  874. package/dist/runtime/run-processors.js +44 -9
  875. package/dist/runtime/run-queue.d.ts +96 -68
  876. package/dist/runtime/run-queue.js +323 -299
  877. package/dist/runtime/run-status.d.ts +12 -0
  878. package/dist/runtime/run-status.js +21 -0
  879. package/dist/runtime/run-steps.d.ts +13 -4
  880. package/dist/runtime/run-steps.js +40 -13
  881. package/dist/runtime/run-worker.d.ts +74 -25
  882. package/dist/runtime/run-worker.js +468 -138
  883. package/dist/runtime/runtime.module.d.ts +3 -4
  884. package/dist/runtime/runtime.module.js +56 -7
  885. package/dist/runtime/step-log.d.ts +23 -5
  886. package/dist/runtime/step-log.js +36 -10
  887. package/dist/runtime/stream.controller.d.ts +2 -4
  888. package/dist/runtime/stream.controller.js +5 -11
  889. package/dist/runtime/stream.d.ts +7 -1
  890. package/dist/runtime/stream.js +77 -5
  891. package/dist/runtime/subagents/child.js +1 -1
  892. package/dist/runtime/subagents/definition.d.ts +41 -25
  893. package/dist/runtime/subagents/definition.js +145 -209
  894. package/dist/runtime/subagents/deliveries.d.ts +6 -3
  895. package/dist/runtime/subagents/deliveries.js +16 -7
  896. package/dist/runtime/subagents/dispatch.d.ts +18 -14
  897. package/dist/runtime/subagents/dispatch.js +32 -41
  898. package/dist/runtime/subagents/messages.d.ts +5 -1
  899. package/dist/runtime/subagents/messages.js +11 -3
  900. package/dist/runtime/subagents/org-agents.js +1 -2
  901. package/dist/runtime/subagents/preamble.d.ts +3 -1
  902. package/dist/runtime/subagents/preamble.js +3 -1
  903. package/dist/runtime/subagents/render.d.ts +1 -2
  904. package/dist/runtime/subagents/render.js +1 -2
  905. package/dist/runtime/subagents/skill-fork.d.ts +5 -7
  906. package/dist/runtime/subagents/skill-fork.js +8 -5
  907. package/dist/runtime/subagents/subagents.service.js +1 -1
  908. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  909. package/dist/runtime/subagents/template-skills.js +76 -0
  910. package/dist/runtime/subagents/tree-jobs.d.ts +62 -0
  911. package/dist/runtime/subagents/tree-jobs.js +86 -0
  912. package/dist/runtime/usage-report-jobs.d.ts +63 -0
  913. package/dist/runtime/usage-report-jobs.js +106 -0
  914. package/dist/runtime/usage-report.d.ts +52 -98
  915. package/dist/runtime/usage-report.js +145 -231
  916. package/dist/runtime/waits.d.ts +64 -204
  917. package/dist/runtime/waits.js +159 -825
  918. package/dist/sandbox/attachments-path.d.ts +15 -0
  919. package/dist/sandbox/attachments-path.js +15 -0
  920. package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
  921. package/dist/sandbox/cloud-permission-snapshot.js +407 -0
  922. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
  923. package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
  924. package/dist/sandbox/held-operations.d.ts +46 -0
  925. package/dist/sandbox/held-operations.js +143 -0
  926. package/dist/sandbox/jobs.d.ts +42 -21
  927. package/dist/sandbox/jobs.js +57 -33
  928. package/dist/sandbox/kernel-read.d.ts +55 -0
  929. package/dist/sandbox/kernel-read.js +57 -0
  930. package/dist/sandbox/leases.d.ts +15 -12
  931. package/dist/sandbox/leases.js +30 -24
  932. package/dist/sandbox/legacy-retirement.d.ts +317 -0
  933. package/dist/sandbox/legacy-retirement.js +1032 -0
  934. package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
  935. package/dist/sandbox/legacy-retirement.module.js +25 -0
  936. package/dist/sandbox/managed-device-context.d.ts +106 -0
  937. package/dist/sandbox/managed-device-context.js +356 -0
  938. package/dist/sandbox/managed-device-context.module.d.ts +6 -0
  939. package/dist/sandbox/managed-device-context.module.js +33 -0
  940. package/dist/sandbox/modes.d.ts +169 -0
  941. package/dist/sandbox/modes.js +218 -0
  942. package/dist/sandbox/operation-authority-types.d.ts +25 -0
  943. package/dist/sandbox/operation-authority-types.js +51 -0
  944. package/dist/sandbox/operation-authority.d.ts +159 -0
  945. package/dist/sandbox/operation-authority.js +885 -0
  946. package/dist/sandbox/operation-authority.module.d.ts +2 -0
  947. package/dist/sandbox/operation-authority.module.js +29 -0
  948. package/dist/sandbox/operation-intents.d.ts +249 -0
  949. package/dist/sandbox/operation-intents.js +1355 -0
  950. package/dist/sandbox/operation-intents.module.d.ts +2 -0
  951. package/dist/sandbox/operation-intents.module.js +21 -0
  952. package/dist/sandbox/operation-payloads.d.ts +33 -0
  953. package/dist/sandbox/operation-payloads.js +332 -0
  954. package/dist/sandbox/operation-reconcile.job.d.ts +60 -0
  955. package/dist/sandbox/operation-reconcile.job.js +294 -0
  956. package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
  957. package/dist/sandbox/permission-authority-epochs.js +83 -0
  958. package/dist/sandbox/permission-authority-lock.d.ts +38 -0
  959. package/dist/sandbox/permission-authority-lock.js +147 -0
  960. package/dist/sandbox/permission-authority.module.d.ts +9 -0
  961. package/dist/sandbox/permission-authority.module.js +55 -0
  962. package/dist/sandbox/permission-availability.d.ts +18 -0
  963. package/dist/sandbox/permission-availability.js +19 -0
  964. package/dist/sandbox/permission-call-grants.d.ts +38 -0
  965. package/dist/sandbox/permission-call-grants.js +378 -0
  966. package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
  967. package/dist/sandbox/permission-call-grants.module.js +21 -0
  968. package/dist/sandbox/permission-call-types.d.ts +107 -0
  969. package/dist/sandbox/permission-call-types.js +1 -0
  970. package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
  971. package/dist/sandbox/permission-ceiling-writes.js +224 -0
  972. package/dist/sandbox/permission-config-publication.d.ts +76 -0
  973. package/dist/sandbox/permission-config-publication.js +339 -0
  974. package/dist/sandbox/permission-context-types.d.ts +64 -0
  975. package/dist/sandbox/permission-context-types.js +24 -0
  976. package/dist/sandbox/permission-facts.d.ts +206 -0
  977. package/dist/sandbox/permission-facts.js +635 -0
  978. package/dist/sandbox/permission-facts.module.d.ts +2 -0
  979. package/dist/sandbox/permission-facts.module.js +20 -0
  980. package/dist/sandbox/permission-instance-writes.d.ts +90 -0
  981. package/dist/sandbox/permission-instance-writes.js +305 -0
  982. package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
  983. package/dist/sandbox/permission-runtime-reports.js +354 -0
  984. package/dist/sandbox/permission-transitions.d.ts +31 -0
  985. package/dist/sandbox/permission-transitions.js +155 -0
  986. package/dist/sandbox/platform-full-access.d.ts +110 -0
  987. package/dist/sandbox/platform-full-access.js +198 -0
  988. package/dist/sandbox/providers.d.ts +56 -7
  989. package/dist/sandbox/providers.js +62 -9
  990. package/dist/sandbox/providers.module.d.ts +2 -0
  991. package/dist/sandbox/providers.module.js +19 -0
  992. package/dist/sandbox/request-not-sent.d.ts +13 -0
  993. package/dist/sandbox/request-not-sent.js +13 -0
  994. package/dist/sandbox/review/classifier.d.ts +137 -0
  995. package/dist/sandbox/review/classifier.js +440 -0
  996. package/dist/sandbox/review/index.d.ts +13 -0
  997. package/dist/sandbox/review/index.js +10 -0
  998. package/dist/sandbox/review/permission-candidate.d.ts +68 -0
  999. package/dist/sandbox/review/permission-candidate.js +312 -0
  1000. package/dist/sandbox/review/review.service.d.ts +166 -0
  1001. package/dist/sandbox/review/review.service.js +563 -0
  1002. package/dist/sandbox/review/rules.d.ts +87 -0
  1003. package/dist/sandbox/review/rules.js +5319 -0
  1004. package/dist/sandbox/review/types.d.ts +116 -0
  1005. package/dist/sandbox/review/types.js +48 -0
  1006. package/dist/sandbox/sandbox-file-reader.d.ts +52 -0
  1007. package/dist/sandbox/sandbox-file-reader.js +142 -0
  1008. package/dist/sandbox/sandbox.module.d.ts +3 -3
  1009. package/dist/sandbox/sandbox.module.js +39 -9
  1010. package/dist/sandbox/sandbox.service.d.ts +550 -134
  1011. package/dist/sandbox/sandbox.service.js +2306 -460
  1012. package/dist/sandbox/unreachable.d.ts +30 -0
  1013. package/dist/sandbox/unreachable.js +122 -0
  1014. package/dist/sandbox/use-context.d.ts +17 -0
  1015. package/dist/sandbox/use-context.js +1 -0
  1016. package/dist/schedules/calendar.d.ts +134 -0
  1017. package/dist/schedules/calendar.js +410 -0
  1018. package/dist/schedules/effective-settings.d.ts +22 -0
  1019. package/dist/schedules/effective-settings.js +18 -0
  1020. package/dist/schedules/errors.d.ts +8 -0
  1021. package/dist/schedules/errors.js +8 -0
  1022. package/dist/schedules/fire.d.ts +137 -0
  1023. package/dist/schedules/fire.js +708 -0
  1024. package/dist/schedules/grant-rules.d.ts +120 -0
  1025. package/dist/schedules/grant-rules.js +186 -0
  1026. package/dist/schedules/job-ids.d.ts +81 -0
  1027. package/dist/schedules/job-ids.js +95 -0
  1028. package/dist/schedules/pause.d.ts +9 -0
  1029. package/dist/schedules/pause.js +33 -0
  1030. package/dist/schedules/run-tracker.d.ts +76 -0
  1031. package/dist/schedules/run-tracker.js +321 -0
  1032. package/dist/schedules/scan.job.d.ts +45 -0
  1033. package/dist/schedules/scan.job.js +189 -0
  1034. package/dist/schedules/schedule-math.d.ts +73 -0
  1035. package/dist/schedules/schedule-math.js +294 -0
  1036. package/dist/schedules/scheduled-tasks.service.d.ts +362 -0
  1037. package/dist/schedules/scheduled-tasks.service.js +1253 -0
  1038. package/dist/schedules/schedules.controller.d.ts +72 -0
  1039. package/dist/schedules/schedules.controller.js +256 -0
  1040. package/dist/schedules/schedules.module.d.ts +16 -0
  1041. package/dist/schedules/schedules.module.js +61 -0
  1042. package/dist/schedules/schedules.schemas.d.ts +351 -0
  1043. package/dist/schedules/schedules.schemas.js +213 -0
  1044. package/dist/schedules/store.d.ts +86 -0
  1045. package/dist/schedules/store.js +410 -0
  1046. package/dist/schedules/store.module.d.ts +6 -0
  1047. package/dist/schedules/store.module.js +21 -0
  1048. package/dist/schedules/types.d.ts +110 -0
  1049. package/dist/schedules/types.js +1 -0
  1050. package/dist/schedules/unattended.d.ts +89 -0
  1051. package/dist/schedules/unattended.js +189 -0
  1052. package/dist/setup/kernel-checks.d.ts +91 -0
  1053. package/dist/setup/kernel-checks.js +296 -0
  1054. package/dist/setup/oauth-token-probe.d.ts +40 -0
  1055. package/dist/setup/oauth-token-probe.js +96 -0
  1056. package/dist/setup/redact-check.d.ts +18 -0
  1057. package/dist/setup/redact-check.js +46 -0
  1058. package/dist/setup/setup-check-registry.d.ts +86 -0
  1059. package/dist/setup/setup-check-registry.js +75 -0
  1060. package/dist/setup/setup-checks.controller.d.ts +28 -0
  1061. package/dist/setup/setup-checks.controller.js +78 -0
  1062. package/dist/setup/setup-checks.schemas.d.ts +38 -0
  1063. package/dist/setup/setup-checks.schemas.js +43 -0
  1064. package/dist/setup/setup-checks.service.d.ts +144 -0
  1065. package/dist/setup/setup-checks.service.js +683 -0
  1066. package/dist/setup/setup-guides.controller.d.ts +18 -0
  1067. package/dist/setup/setup-guides.controller.js +48 -0
  1068. package/dist/setup/setup-guides.schemas.d.ts +10 -0
  1069. package/dist/setup/setup-guides.schemas.js +6 -0
  1070. package/dist/setup/setup-guides.service.d.ts +126 -0
  1071. package/dist/setup/setup-guides.service.js +315 -0
  1072. package/dist/setup/setup.module.d.ts +8 -0
  1073. package/dist/setup/setup.module.js +31 -0
  1074. package/dist/shares/liveness.d.ts +59 -0
  1075. package/dist/shares/liveness.js +163 -0
  1076. package/dist/shares/revoke.d.ts +26 -0
  1077. package/dist/shares/revoke.js +43 -0
  1078. package/dist/shares/settings.d.ts +76 -0
  1079. package/dist/shares/settings.js +117 -0
  1080. package/dist/shares/share-code.d.ts +4 -0
  1081. package/dist/shares/share-code.js +28 -0
  1082. package/dist/shares/share-objects.d.ts +52 -0
  1083. package/dist/shares/share-objects.js +123 -0
  1084. package/dist/shares/share-open.controller.d.ts +35 -0
  1085. package/dist/shares/share-open.controller.js +107 -0
  1086. package/dist/shares/share-open.service.d.ts +107 -0
  1087. package/dist/shares/share-open.service.js +287 -0
  1088. package/dist/shares/share-previews.controller.d.ts +50 -0
  1089. package/dist/shares/share-previews.controller.js +115 -0
  1090. package/dist/shares/shares.controller.d.ts +34 -0
  1091. package/dist/shares/shares.controller.js +114 -0
  1092. package/dist/shares/shares.module.d.ts +8 -0
  1093. package/dist/shares/shares.module.js +41 -0
  1094. package/dist/shares/shares.schemas.d.ts +31 -0
  1095. package/dist/shares/shares.schemas.js +25 -0
  1096. package/dist/shares/shares.service.d.ts +182 -0
  1097. package/dist/shares/shares.service.js +553 -0
  1098. package/dist/shares/sweep.job.d.ts +72 -0
  1099. package/dist/shares/sweep.job.js +330 -0
  1100. package/dist/skills/agent-skills.controller.d.ts +48 -0
  1101. package/dist/skills/agent-skills.controller.js +131 -0
  1102. package/dist/skills/agent-skills.service.d.ts +258 -0
  1103. package/dist/skills/agent-skills.service.js +960 -0
  1104. package/dist/skills/catalog.d.ts +83 -71
  1105. package/dist/skills/catalog.js +144 -215
  1106. package/dist/skills/changes.controller.d.ts +6 -23
  1107. package/dist/skills/changes.controller.js +10 -57
  1108. package/dist/skills/changes.service.d.ts +69 -115
  1109. package/dist/skills/changes.service.js +249 -599
  1110. package/dist/skills/conversation-catalog.d.ts +52 -0
  1111. package/dist/skills/conversation-catalog.js +141 -0
  1112. package/dist/skills/invocable.controller.d.ts +1 -1
  1113. package/dist/skills/invocable.controller.js +2 -2
  1114. package/dist/skills/invocation-keys.d.ts +1 -1
  1115. package/dist/skills/invocation-keys.js +1 -1
  1116. package/dist/skills/invoke.d.ts +91 -6
  1117. package/dist/skills/invoke.js +288 -8
  1118. package/dist/skills/package.d.ts +0 -5
  1119. package/dist/skills/package.js +0 -14
  1120. package/dist/skills/skills.controller.d.ts +7 -14
  1121. package/dist/skills/skills.controller.js +9 -34
  1122. package/dist/skills/skills.module.js +20 -2
  1123. package/dist/skills/skills.schemas.d.ts +44 -0
  1124. package/dist/skills/skills.schemas.js +68 -0
  1125. package/dist/skills/skills.service.d.ts +76 -58
  1126. package/dist/skills/skills.service.js +277 -145
  1127. package/dist/skills/usable.d.ts +57 -7
  1128. package/dist/skills/usable.js +178 -36
  1129. package/dist/storage/storage.service.d.ts +2 -0
  1130. package/dist/storage/storage.service.js +12 -1
  1131. package/dist/themes/render-css.d.ts +13 -0
  1132. package/dist/themes/render-css.js +135 -0
  1133. package/dist/themes/theme-delivery.service.d.ts +36 -0
  1134. package/dist/themes/theme-delivery.service.js +116 -0
  1135. package/dist/themes/theme-state.d.ts +116 -0
  1136. package/dist/themes/theme-state.js +221 -0
  1137. package/dist/themes/theme-usage.d.ts +61 -0
  1138. package/dist/themes/theme-usage.js +98 -0
  1139. package/dist/themes/themes-public.controller.d.ts +33 -0
  1140. package/dist/themes/themes-public.controller.js +98 -0
  1141. package/dist/themes/themes.controller.d.ts +13 -0
  1142. package/dist/themes/themes.controller.js +38 -0
  1143. package/dist/themes/themes.module.d.ts +3 -0
  1144. package/dist/themes/themes.module.js +21 -0
  1145. package/dist/themes/themes.schemas.d.ts +3 -0
  1146. package/dist/themes/themes.schemas.js +2 -0
  1147. package/dist/themes/themes.service.d.ts +50 -0
  1148. package/dist/themes/themes.service.js +99 -0
  1149. package/dist/time-zone.d.ts +5 -0
  1150. package/dist/time-zone.js +19 -0
  1151. package/dist/tools/admin-connectors.d.ts +69 -0
  1152. package/dist/tools/admin-connectors.js +135 -0
  1153. package/dist/tools/approvals.controller.d.ts +5 -2
  1154. package/dist/tools/approvals.controller.js +19 -5
  1155. package/dist/tools/approvals.schemas.d.ts +23 -0
  1156. package/dist/tools/approvals.schemas.js +19 -0
  1157. package/dist/tools/approvals.service.d.ts +483 -17
  1158. package/dist/tools/approvals.service.js +1536 -33
  1159. package/dist/tools/builtin-names.d.ts +40 -23
  1160. package/dist/tools/builtin-names.js +77 -32
  1161. package/dist/tools/builtins/agent.js +5 -5
  1162. package/dist/tools/builtins/artifacts.d.ts +69 -0
  1163. package/dist/tools/builtins/artifacts.js +143 -0
  1164. package/dist/tools/builtins/ask-user.js +3 -2
  1165. package/dist/tools/builtins/builtin-tools.d.ts +29 -6
  1166. package/dist/tools/builtins/builtin-tools.js +111 -31
  1167. package/dist/tools/builtins/current-time.d.ts +26 -0
  1168. package/dist/tools/builtins/current-time.js +99 -0
  1169. package/dist/tools/builtins/image/generate.d.ts +62 -0
  1170. package/dist/tools/builtins/image/generate.js +591 -0
  1171. package/dist/tools/builtins/image/index.d.ts +2 -0
  1172. package/dist/tools/builtins/image/index.js +2 -0
  1173. package/dist/tools/builtins/image/paths.d.ts +12 -0
  1174. package/dist/tools/builtins/image/paths.js +26 -0
  1175. package/dist/tools/builtins/platform.d.ts +19 -4
  1176. package/dist/tools/builtins/platform.js +106 -19
  1177. package/dist/tools/builtins/sandbox/bash.d.ts +40 -3
  1178. package/dist/tools/builtins/sandbox/bash.js +279 -207
  1179. package/dist/tools/builtins/sandbox/common.d.ts +233 -47
  1180. package/dist/tools/builtins/sandbox/common.js +498 -153
  1181. package/dist/tools/builtins/sandbox/deliver.js +27 -58
  1182. package/dist/tools/builtins/sandbox/device-code.d.ts +40 -0
  1183. package/dist/tools/builtins/sandbox/device-code.js +57 -0
  1184. package/dist/tools/builtins/sandbox/device-owner.d.ts +13 -0
  1185. package/dist/tools/builtins/sandbox/device-owner.js +14 -0
  1186. package/dist/tools/builtins/sandbox/edit.js +48 -39
  1187. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  1188. package/dist/tools/builtins/sandbox/fetch-attachment.js +126 -0
  1189. package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
  1190. package/dist/tools/builtins/sandbox/file-state.js +33 -3
  1191. package/dist/tools/builtins/sandbox/glob.js +15 -9
  1192. package/dist/tools/builtins/sandbox/grep.js +13 -9
  1193. package/dist/tools/builtins/sandbox/index.d.ts +11 -5
  1194. package/dist/tools/builtins/sandbox/index.js +15 -5
  1195. package/dist/tools/builtins/sandbox/read.js +15 -9
  1196. package/dist/tools/builtins/sandbox/task-list.d.ts +12 -0
  1197. package/dist/tools/builtins/sandbox/task-list.js +136 -0
  1198. package/dist/tools/builtins/sandbox/task-output.d.ts +33 -40
  1199. package/dist/tools/builtins/sandbox/task-output.js +325 -201
  1200. package/dist/tools/builtins/sandbox/task-stop.d.ts +2 -2
  1201. package/dist/tools/builtins/sandbox/task-stop.js +40 -29
  1202. package/dist/tools/builtins/sandbox/write.js +41 -33
  1203. package/dist/tools/builtins/schedules.d.ts +109 -0
  1204. package/dist/tools/builtins/schedules.js +947 -0
  1205. package/dist/tools/builtins/send-message.d.ts +1 -1
  1206. package/dist/tools/builtins/send-message.js +3 -3
  1207. package/dist/tools/builtins/skill-load.d.ts +56 -8
  1208. package/dist/tools/builtins/skill-load.js +186 -18
  1209. package/dist/tools/builtins/tool-search.d.ts +4 -7
  1210. package/dist/tools/builtins/tool-search.js +10 -13
  1211. package/dist/tools/builtins/web/extract.d.ts +2 -4
  1212. package/dist/tools/builtins/web/extract.js +3 -6
  1213. package/dist/tools/builtins/web/search.js +2 -4
  1214. package/dist/tools/connector-account-policies.d.ts +86 -0
  1215. package/dist/tools/connector-account-policies.js +220 -0
  1216. package/dist/tools/connector-content.js +1 -0
  1217. package/dist/tools/connectors.controller.d.ts +79 -9
  1218. package/dist/tools/connectors.controller.js +155 -17
  1219. package/dist/tools/connectors.schemas.d.ts +40 -0
  1220. package/dist/tools/connectors.schemas.js +46 -0
  1221. package/dist/tools/connectors.service.d.ts +124 -7
  1222. package/dist/tools/connectors.service.js +331 -24
  1223. package/dist/tools/credentials.d.ts +41 -0
  1224. package/dist/tools/credentials.js +150 -1
  1225. package/dist/tools/credentials.module.d.ts +7 -0
  1226. package/dist/tools/credentials.module.js +22 -0
  1227. package/dist/tools/device-op-resolver.d.ts +40 -0
  1228. package/dist/tools/device-op-resolver.js +131 -0
  1229. package/dist/tools/drift.d.ts +6 -2
  1230. package/dist/tools/drift.js +10 -5
  1231. package/dist/tools/elicitation.d.ts +2 -0
  1232. package/dist/tools/elicitation.js +1 -1
  1233. package/dist/tools/fixed-ask.d.ts +7 -0
  1234. package/dist/tools/fixed-ask.js +9 -0
  1235. package/dist/tools/git-asks.d.ts +113 -0
  1236. package/dist/tools/git-asks.js +174 -0
  1237. package/dist/tools/git-push-policy.d.ts +92 -0
  1238. package/dist/tools/git-push-policy.js +177 -0
  1239. package/dist/tools/info.d.ts +7 -11
  1240. package/dist/tools/info.js +8 -21
  1241. package/dist/tools/job-ids.d.ts +0 -4
  1242. package/dist/tools/job-ids.js +1 -6
  1243. package/dist/tools/network-asks.d.ts +122 -0
  1244. package/dist/tools/network-asks.js +233 -0
  1245. package/dist/tools/oauth/discovery.d.ts +38 -16
  1246. package/dist/tools/oauth/discovery.js +59 -33
  1247. package/dist/tools/oauth/flow.js +1 -1
  1248. package/dist/tools/oauth/tokens.d.ts +54 -7
  1249. package/dist/tools/oauth/tokens.js +87 -17
  1250. package/dist/tools/org-tool-switches.d.ts +19 -4
  1251. package/dist/tools/org-tool-switches.js +30 -13
  1252. package/dist/tools/permission-approval-jobs.d.ts +18 -0
  1253. package/dist/tools/permission-approval-jobs.js +92 -0
  1254. package/dist/tools/pipeline.d.ts +176 -22
  1255. package/dist/tools/pipeline.js +1194 -94
  1256. package/dist/tools/policy.d.ts +50 -13
  1257. package/dist/tools/policy.js +178 -58
  1258. package/dist/tools/questions.service.d.ts +50 -9
  1259. package/dist/tools/questions.service.js +128 -12
  1260. package/dist/tools/registry.d.ts +125 -56
  1261. package/dist/tools/registry.js +238 -235
  1262. package/dist/tools/tools.module.js +48 -9
  1263. package/dist/ui/admin-ui.controller.d.ts +56 -0
  1264. package/dist/ui/admin-ui.controller.js +192 -0
  1265. package/dist/ui/arrangement.d.ts +65 -0
  1266. package/dist/ui/arrangement.js +171 -0
  1267. package/dist/ui/embed-token.d.ts +2 -2
  1268. package/dist/ui/embed-token.js +66 -5
  1269. package/dist/ui/registry.d.ts +42 -17
  1270. package/dist/ui/registry.js +46 -14
  1271. package/dist/ui/slots.controller.d.ts +11 -0
  1272. package/dist/ui/slots.controller.js +25 -0
  1273. package/dist/ui/ui-stream.d.ts +20 -3
  1274. package/dist/ui/ui-stream.js +25 -7
  1275. package/dist/ui/ui.schemas.d.ts +70 -0
  1276. package/dist/ui/ui.schemas.js +65 -0
  1277. package/dist/ui/views.controller.d.ts +35 -49
  1278. package/dist/ui/views.controller.js +48 -70
  1279. package/dist/ui/views.d.ts +118 -19
  1280. package/dist/ui/views.js +257 -53
  1281. package/package.json +7 -3
  1282. package/src/migrations/0089_model_kinds_usage.sql +38 -0
  1283. package/src/migrations/0090_initial_passwords.sql +27 -0
  1284. package/src/migrations/0091_account_time_zone.sql +4 -0
  1285. package/src/migrations/0092_tools_default_on.sql +27 -0
  1286. package/src/migrations/0093_connected_environments.sql +37 -0
  1287. package/src/migrations/0094_environment_paths_idx.sql +7 -0
  1288. package/src/migrations/0095_environment_files_resets.sql +5 -0
  1289. package/src/migrations/0096_environment_demoted_default.sql +18 -0
  1290. package/src/migrations/0097_extension_installs_enabled_at.sql +16 -0
  1291. package/src/migrations/0098_single_provider_running_first.sql +41 -0
  1292. package/src/migrations/0099_channel_connection_guide_ack.sql +6 -0
  1293. package/src/migrations/0100_catalog_files.sql +13 -0
  1294. package/src/migrations/0101_marketplace_icons.sql +32 -0
  1295. package/src/migrations/0102_themes.sql +64 -0
  1296. package/src/migrations/0103_ui_theme_setting.sql +7 -0
  1297. package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
  1298. package/src/migrations/0105_devices_rename.sql +136 -0
  1299. package/src/migrations/0106_setup_guides_v2.sql +10 -0
  1300. package/src/migrations/0107_extension_client_builds.sql +50 -0
  1301. package/src/migrations/0108_question_skipped.sql +6 -0
  1302. package/src/migrations/0109_audit_platform_idx.sql +5 -0
  1303. package/src/migrations/0110_usage_time_idx.sql +8 -0
  1304. package/src/migrations/0111_agent_skill_sharing.sql +22 -0
  1305. package/src/migrations/0112_skill_share_requests.sql +4 -0
  1306. package/src/migrations/0113_scheduled_tasks.sql +108 -0
  1307. package/src/migrations/0114_network_asks.sql +23 -0
  1308. package/src/migrations/0115_network_requests.sql +28 -0
  1309. package/src/migrations/0116_skills_default_on.sql +37 -0
  1310. package/src/migrations/0117_sandbox_tiers.sql +11 -0
  1311. package/src/migrations/0118_device_policy_ops.sql +6 -0
  1312. package/src/migrations/0119_outbox.sql +22 -0
  1313. package/src/migrations/0120_drop_usage_report_sweep.sql +7 -0
  1314. package/src/migrations/0121_drop_platform_migration_runs.sql +12 -0
  1315. package/src/migrations/0122_drop_scheduled_task_runs_rechecked_at.sql +5 -0
  1316. package/src/migrations/0123_pgvector.sql +27 -0
  1317. package/src/migrations/0124_conversation_source.sql +36 -0
  1318. package/src/migrations/0125_conversation_tree_stopped_at.sql +5 -0
  1319. package/src/migrations/0126_git_gateway.sql +10 -0
  1320. package/src/migrations/0127_git_push_policy.sql +12 -0
  1321. package/src/migrations/0128_scheduled_task_plugin_disabled.sql +10 -0
  1322. package/src/migrations/0129_connector_plugin_disabled.sql +5 -0
  1323. package/src/migrations/0130_auto_mode.sql +48 -0
  1324. package/src/migrations/0131_device_mode.sql +9 -0
  1325. package/src/migrations/0132_compact_runs.sql +6 -0
  1326. package/src/migrations/0133_project_root.sql +30 -0
  1327. package/src/migrations/0134_org_cloud_network_delta.sql +38 -0
  1328. package/src/migrations/0135_run_execution_claim.sql +2 -0
  1329. package/src/migrations/0136_run_recovery_cursor.sql +6 -0
  1330. package/src/migrations/0137_audit_org_idx.sql +5 -0
  1331. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  1332. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  1333. package/src/migrations/0140_retire_history_forms.sql +148 -0
  1334. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  1335. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  1336. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  1337. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  1338. package/src/migrations/0145_org_network_allowances.sql +12 -0
  1339. package/src/migrations/0146_permission_authority_epochs.sql +6 -0
  1340. package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
  1341. package/src/migrations/0148_first_message_request_hash.sql +2 -0
  1342. package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
  1343. package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
  1344. package/src/migrations/0151_starting_execution_grants.sql +8 -0
  1345. package/src/migrations/0152_background_launch_identity.sql +66 -0
  1346. package/src/migrations/0153_background_cancel_requester.sql +13 -0
  1347. package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
  1348. package/src/migrations/0155_device_instance_generations.sql +30 -0
  1349. package/src/migrations/0156_device_owner_report.sql +7 -0
  1350. package/src/migrations/0157_legacy_retirement.sql +116 -0
  1351. package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
  1352. package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
  1353. package/src/migrations/0160_model_usage_image_kind.sql +10 -0
  1354. package/src/migrations/0161_file_shares.sql +35 -0
  1355. package/src/migrations/0162_permission_call_escalation.sql +9 -0
  1356. package/dist/background/status.d.ts +0 -35
  1357. package/dist/background/status.js +0 -57
  1358. package/dist/catalog/platform-migration.d.ts +0 -115
  1359. package/dist/catalog/platform-migration.js +0 -582
  1360. package/dist/conversations/job-ids.d.ts +0 -6
  1361. package/dist/conversations/job-ids.js +0 -6
  1362. package/dist/environments/access.d.ts +0 -41
  1363. package/dist/environments/access.js +0 -77
  1364. package/dist/environments/conversation-environments.d.ts +0 -61
  1365. package/dist/environments/conversation-environments.js +0 -170
  1366. package/dist/environments/dto.d.ts +0 -25
  1367. package/dist/environments/dto.js +0 -12
  1368. package/dist/environments/environments.controller.d.ts +0 -33
  1369. package/dist/environments/environments.controller.js +0 -110
  1370. package/dist/environments/environments.module.d.ts +0 -8
  1371. package/dist/environments/environments.module.js +0 -27
  1372. package/dist/environments/environments.service.d.ts +0 -153
  1373. package/dist/environments/environments.service.js +0 -541
  1374. package/dist/extensions/job-ids.d.ts +0 -6
  1375. package/dist/extensions/job-ids.js +0 -6
  1376. package/dist/infra/queue/add-job-once.d.ts +0 -14
  1377. package/dist/infra/queue/add-job-once.js +0 -16
  1378. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  1379. package/dist/infra/queue/retired-schedulers.js +0 -9
  1380. package/dist/orgs/job-ids.d.ts +0 -8
  1381. package/dist/orgs/job-ids.js +0 -8
  1382. package/dist/platform/redact-orgs.d.ts +0 -7
  1383. package/dist/platform/redact-orgs.js +0 -52
  1384. package/dist/runtime/context/legacy-text.d.ts +0 -22
  1385. package/dist/runtime/context/legacy-text.js +0 -37
  1386. package/dist/runtime/job-ids.d.ts +0 -10
  1387. package/dist/runtime/job-ids.js +0 -10
  1388. package/dist/runtime/retired-schedulers.d.ts +0 -7
  1389. package/dist/runtime/retired-schedulers.js +0 -31
  1390. package/dist/storage/job-ids.d.ts +0 -6
  1391. package/dist/storage/job-ids.js +0 -6
  1392. package/dist/tools/builtins/skill-write.d.ts +0 -59
  1393. package/dist/tools/builtins/skill-write.js +0 -244
  1394. package/dist/tools/legacy-data.d.ts +0 -34
  1395. package/dist/tools/legacy-data.js +0 -76
  1396. package/dist/tools/legacy-keys.d.ts +0 -51
  1397. package/dist/tools/legacy-keys.js +0 -115
@@ -7,41 +7,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { parseToolKey, ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
10
+ import { ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable, Optional } from "@nestjs/common";
12
+ import { backgroundMaxSeconds } from "../background/launch.js";
12
13
  import { EventLog } from "../conversations/event-log.js";
13
- import { ToolViewSchema } from "../conversations/events.js";
14
+ import { COMMAND_ASK_MAX_CHARS, COMMAND_ASK_TEXT_MAX_CHARS, ToolViewSchema, } from "../conversations/events.js";
15
+ import { ConversationDevices } from "../devices/conversation-devices.js";
16
+ import { pathAgainstWorkingRoot } from "../devices/working-root.js";
17
+ import { ApiError } from "../errors.js";
14
18
  import { EffectiveConfigs, NEEDS_CONFIG_REASON } from "../extensions/effective-config.js";
15
19
  import { clipText } from "../extensions/hooks.js";
16
20
  import { ExtensionHost } from "../extensions/host.js";
17
21
  import { ExtensionUnloadedError, PLUGIN_UNLOADED_TOOL_ERROR } from "../extensions/inflight.js";
18
22
  import { audit } from "../identity/audit.js";
23
+ import { sha256Hex } from "../identity/hash.js";
19
24
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
20
25
  import { KernelDb } from "../infra/database/kernel-db.js";
21
- import { TransactionHost } from "../infra/database/transaction-host.js";
26
+ import { TransactionHost, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
22
27
  import { Transactional } from "../infra/database/transactional.decorator.js";
23
28
  import { KERNEL_LOGGER } from "../infra/tokens.js";
29
+ import { DevicePolicyService } from "../local-devices/device-policy.service.js";
30
+ import { NetworkGrants } from "../local-devices/network-grants.js";
24
31
  import { UNKNOWN_RESULT_TEXT } from "../runtime/context/pairing.js";
25
32
  import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookScope, } from "../runtime/hook-calls.js";
26
33
  import { subagentWaitingIdemKey } from "../runtime/loop.js";
27
- import { assistantIdemKey, MAX_MODEL_ATTEMPTS, modelCallIdemKey } from "../runtime/model-call.js";
34
+ import { assistantIdemKey, MAX_STEP_MODEL_CALLS, modelCallIdemKey } from "../runtime/model-call.js";
35
+ import { currentExecutionClaim } from "../runtime/run-execution.js";
28
36
  import { rootSurfaceOf } from "../runtime/subagents/child.js";
29
37
  import { SubagentMessages } from "../runtime/subagents/messages.js";
30
38
  import { pairStoppedForks } from "../runtime/subagents/skill-fork.js";
31
39
  import { SubagentsService } from "../runtime/subagents/subagents.service.js";
40
+ import { orgHostOutsideCeiling } from "../sandbox/modes.js";
41
+ import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
42
+ import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
43
+ import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
44
+ import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
45
+ import { permissionScopeHash } from "../sandbox/permission-facts.js";
46
+ import { isSessionGrantableRule, } from "../sandbox/review/index.js";
47
+ import { buildPermissionCandidate, ESCALATION_RETRY_HINT, ESCALATION_UNATTENDED_WHY, escalationRefusedText, isEscalatedCall, } from "../sandbox/review/permission-candidate.js";
48
+ import { CommandReviewService } from "../sandbox/review/review.service.js";
49
+ import { SandboxService } from "../sandbox/sandbox.service.js";
50
+ import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRunOf, } from "../schedules/unattended.js";
32
51
  import { skillLoadOfferedIn } from "../skills/catalog.js";
33
- import { ApprovalsService } from "./approvals.service.js";
52
+ import { ApprovalsService, } from "./approvals.service.js";
34
53
  import { Breaker, breakerOpenMessage } from "./breaker.js";
35
- import { SEND_MESSAGE, SUBAGENT_HANDBACK, TOOL_SEARCH } from "./builtin-names.js";
54
+ import { BUILTIN, SEND_MESSAGE, SUBAGENT_HANDBACK, TOOL_SEARCH } from "./builtin-names.js";
36
55
  import { AGENT_TOOL, AgentToolInput } from "./builtins/agent.js";
37
56
  import { HandbackInput } from "./builtins/handback.js";
57
+ import { generateImagePaths } from "./builtins/image/paths.js";
58
+ import { DEVICE_CODE_PATTERN, deviceCodeIdemKey, GITHUB_DEVICE_LOGIN_URL, } from "./builtins/sandbox/device-code.js";
59
+ import { DEVICE_OF_ANOTHER_ACCOUNT_TEXT } from "./builtins/sandbox/device-owner.js";
38
60
  import { SendMessageInput } from "./builtins/send-message.js";
39
61
  import { isAlwaysLoaded, notLoadedText } from "./builtins/tool-search.js";
40
62
  import { canonicalJson } from "./canonical-json.js";
41
63
  import { CredentialMissing, Credentials } from "./credentials.js";
42
64
  import { ToolDrift } from "./drift.js";
43
65
  import { ElicitationSession } from "./elicitation.js";
44
- import { legacyHint, legacyToolInput, legacyToolKey } from "./legacy-keys.js";
66
+ import { blockedEventHosts, clipKept, NETWORK_ASK_KEPT_MAX_BYTES, networkBlockedIdemKey, planNetworkAsk, settledNetworkNotes, withNetworkNotes, } from "./network-asks.js";
45
67
  import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
46
68
  import { renderResult, resolveOutputRefs, spillIfLarge, ToolOutputs } from "./outputs.js";
47
69
  import { createDecidePolicy } from "./policy.js";
@@ -55,40 +77,79 @@ import { validateInput } from "./validate.js";
55
77
  export const APPROVAL_DENIED_TEXT = "The user denied this tool call.";
56
78
  /**
57
79
  * The denied call's result when the approver gave a reason (model-visible, in the log). "An
58
- * approver": under role escalation an admin, not the requester, decides. Older logs keep the text
59
- * they recorded ("The user denied this tool call. Reason: …"); only new denials use this one.
80
+ * approver": under role escalation an admin, not the requester, decides.
60
81
  */
61
82
  export const approvalDeniedText = (reason) => reason === null ? APPROVAL_DENIED_TEXT : `An approver denied this tool call. Reason: ${reason}`;
62
83
  /** 审批超时(按拒绝)。 */
63
84
  export const approvalExpiredText = (hours) => `Approval timed out after ${hours}h; treated as denied.`;
64
85
  /** 等待审批期间 run 被中止。 */
65
86
  export const APPROVAL_CANCELLED_TEXT = "The run was stopped while waiting for approval.";
87
+ /**
88
+ * The command review's deny text (auto mode spec §5.4, P-D12): the model-visible reason and what it
89
+ * can do instead. `kind` says whether a shell command or a file write was held.
90
+ */
91
+ export const commandDeniedText = (reason, kind) => kind === "write"
92
+ ? `This write is blocked by review: ${reason}. Write it another way or ask the user to allow it.`
93
+ : `Command blocked by review: ${reason}. Do the work another way or ask the user to run it.`;
94
+ /**
95
+ * A command (or write) the review held in an unattended run: no one can answer, so it is a deny at
96
+ * once — no approval, no grant (P-D3).
97
+ */
98
+ export const commandUnattendedText = (reason, kind) => kind === "write"
99
+ ? `This write needs approval (${reason}), and no one can approve it now; do it another way or leave it for the person.`
100
+ : `This command needs approval (${reason}), and no one can approve it now; do the work another way or leave it for the person.`;
101
+ /**
102
+ * A command longer than the ask ceiling (`COMMAND_ASK_MAX_CHARS`): it cannot be shown for approval,
103
+ * and an approval must bind the whole text, so the call is refused before any approval exists.
104
+ */
105
+ export const commandTooLongReason = (chars) => `The command is ${chars} characters long; commands over ${COMMAND_ASK_MAX_CHARS} are too long to review and approve.`;
106
+ /** The model-visible result of a command over the ask ceiling (actionable, English). */
107
+ export const commandTooLongText = (chars) => `This command is too long to review (${chars} characters; the limit is ${COMMAND_ASK_MAX_CHARS}). Split it into shorter commands; long inline scripts are reviewed as code the review cannot read.`;
108
+ /** The person declined a held command or write (P-D12); `reason` is what they said, if anything. */
109
+ export const commandDeclinedText = (reason, kind) => {
110
+ const what = kind === "write" ? "this write" : "to run this command";
111
+ return reason === null
112
+ ? `The user declined ${what}. Continue without it or ask the user.`
113
+ : `The user declined ${what}: ${reason}. Continue without it or ask the user.`;
114
+ };
66
115
  /** 等待用户输入期间 run 被中止。 */
67
116
  export const INPUT_CANCELLED_TEXT = "The run was stopped while waiting for user input.";
117
+ /**
118
+ * The result of an `AskUserQuestion` call whose question the user skipped by sending a message
119
+ * (reply-while-question spec §7.1): the message follows in the log as an ordinary user message.
120
+ */
121
+ export const QUESTION_SKIPPED_TEXT = "The user did not answer this question and sent a message instead; read it below and continue.";
122
+ /** The result of any other tool's input request (extension `input_required`, MCP elicitation) skipped by a message. */
123
+ export const INPUT_SKIPPED_TEXT = "The user did not provide the requested input and sent a message instead; read it below and continue. Call the tool again only if it is still needed.";
68
124
  /** 同一调用连续请求输入超过上限。 */
69
125
  export const TOO_MANY_INPUT_REQUESTS_TEXT = "Tool requested user input too many times.";
70
126
  /** run 已被中止 / 到达截止时间,调用尚未开始执行。 */
71
127
  export const RUN_STOPPED_TEXT = "The run was stopped before this tool call was executed.";
72
128
  /** 调用执行中 run 被中止 / 到达截止时间。 */
73
129
  export const RUN_STOPPED_DURING_TEXT = "The run was stopped while this tool call was running; its outcome is unknown. Verify before retrying.";
130
+ /** The fixed result of a call whose input request was skipped by a message (spec §7.1). */
131
+ const skippedResult = (toolKey) => toolKey === "AskUserQuestion"
132
+ ? {
133
+ content: QUESTION_SKIPPED_TEXT,
134
+ isError: false,
135
+ display: {
136
+ summary: {
137
+ zh: "用户没有回答,直接发了消息",
138
+ en: "User sent a message instead of answering",
139
+ },
140
+ },
141
+ }
142
+ : {
143
+ content: INPUT_SKIPPED_TEXT,
144
+ isError: true,
145
+ display: {
146
+ summary: { zh: "用户没有提供输入,直接发了消息", en: "User sent a message instead" },
147
+ },
148
+ };
74
149
  const timeoutText = (key, ms) => `Tool ${key} timed out after ${ms / 1000}s. The operation may or may not have completed; verify before retrying.`;
75
150
  const failedText = (key, errName) => `Tool ${key} failed (${errName}). The operation may not have completed; check before retrying or try another approach.`;
76
- /** The connector slugs and extension names among the run's tools (to read old `<x>__<tool>` keys). */
77
- const legacyScopeOf = (tools) => {
78
- const connectorSlugs = new Set();
79
- const extensionNames = new Set();
80
- for (const t of tools) {
81
- const p = parseToolKey(t.key);
82
- if (p?.kind === "connector")
83
- connectorSlugs.add(p.slug);
84
- else if (p?.kind === "extension")
85
- extensionNames.add(p.plugin);
86
- }
87
- return { connectorSlugs, extensionNames };
88
- };
89
- const unknownToolText = (name, keys, toolSearch, hint = null) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
90
- (toolSearch ? " Use ToolSearch to load other tools." : "") +
91
- (hint === null ? "" : ` ${hint}`);
151
+ const unknownToolText = (name, keys, toolSearch) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
152
+ (toolSearch ? " Use ToolSearch to load other tools." : "");
92
153
  const unavailableText = (name, reason) => `Tool "${name}" is unavailable: ${reason}.`;
93
154
  /** With a per-call policy key (`Platform:<operation>`), the text names it. */
94
155
  const deniedText = (key, policyKey) => policyKey === undefined || policyKey === key
@@ -107,6 +168,105 @@ const personalMissingText = (connectorName) => `The user has not connected ${con
107
168
  const orgMissingText = (connectorName) => `${connectorName} has no organization credential configured; ask an organization admin to set it up.`;
108
169
  /** Optional provider: the pipeline's {@link ToolPipelineHooks} (tests). */
109
170
  export const TOOL_PIPELINE_HOOKS = Symbol("TOOL_PIPELINE_HOOKS");
171
+ /** Review usage and hooks retain the same tree ancestry on both review routes. */
172
+ function reviewParentOf(parent) {
173
+ return parent === undefined
174
+ ? {}
175
+ : {
176
+ parentRunId: parent.runId,
177
+ ...(parent.budgetRunId !== undefined && { budgetRunId: parent.budgetRunId }),
178
+ parent: {
179
+ conversationId: parent.conversationId,
180
+ runId: parent.runId,
181
+ callId: parent.callId,
182
+ },
183
+ };
184
+ }
185
+ /**
186
+ * The tools the command review covers (auto mode spec §5.1): the shell and the file tools whose
187
+ * writes may leave the workspace, and `GenerateImage` when it writes its images into the device
188
+ * (`file_path`; image generation spec §5.3, reviewed as a `Write`). Any other tool call is not
189
+ * reviewed (the review service answers `allow` for it too; the pipeline skips the facts read).
190
+ */
191
+ const REVIEWED_TOOL_KEYS = new Set(["Bash", "Write", "Edit", "GenerateImage"]);
192
+ /** Whether the review covers this call ({@link REVIEWED_TOOL_KEYS}; `GenerateImage` with a path). */
193
+ const isReviewedCall = (toolKey, input) => REVIEWED_TOOL_KEYS.has(toolKey) &&
194
+ (toolKey !== "GenerateImage" || generateImagePaths(input).length > 0);
195
+ /** The paths a reviewed write writes: `file_path`, or every path of a `GenerateImage` call. */
196
+ const writePathsOf = (toolKey, input) => toolKey === "GenerateImage" ? generateImagePaths(input) : [textField(input, "file_path")];
197
+ /**
198
+ * A call that needs reach beyond the working directory on a device whose permission support is
199
+ * not verified: no approval could let admission run it, so nothing is offered.
200
+ */
201
+ export const PERMISSION_SUPPORT_UNVERIFIED_TEXT = "This call needs access outside the working directory, but this device's permission support is not verified yet, so only paths inside the working directory work now. Keep the call inside the working directory, or retry once the device is ready.";
202
+ /**
203
+ * The managed builtins whose review depends on the device's facts (a proposed reach or a
204
+ * sensitive command): their first call starts the device before it is reviewed. The others start
205
+ * it only when they run (a Skill without scripts never does).
206
+ */
207
+ const REVIEWED_ON_FACTS = new Set([
208
+ BUILTIN.Bash,
209
+ BUILTIN.Read,
210
+ BUILTIN.Write,
211
+ BUILTIN.Edit,
212
+ BUILTIN.GenerateImage,
213
+ ]);
214
+ /** The refusals of a permission review that end the call (fail closed), not the run. */
215
+ const FAIL_CLOSED_CODES = new Set([
216
+ "forbidden",
217
+ "conflict",
218
+ "conversation.not_found",
219
+ ]);
220
+ /** What the model gets when the permission check of its call refused (fail closed). */
221
+ export const permissionCheckFailedText = (why) => `The permission check for this call could not be completed (${why.replace(/\.$/, "")}), so it did not run. Retry the call once; if it fails again, ask the user to check the conversation's permission profile or to approve the call again.`;
222
+ /** The builtins whose device entry is the managed operation route once activated. */
223
+ const MANAGED_OPERATION_TOOLS = new Set([
224
+ BUILTIN.Bash,
225
+ BUILTIN.Read,
226
+ BUILTIN.Write,
227
+ BUILTIN.Edit,
228
+ BUILTIN.Glob,
229
+ BUILTIN.Grep,
230
+ BUILTIN.Deliver,
231
+ BUILTIN.FetchAttachment,
232
+ BUILTIN.Skill,
233
+ BUILTIN.GenerateImage,
234
+ ]);
235
+ /**
236
+ * Whether a managed builtin's call enters the device: every call of the device tools, a
237
+ * `GenerateImage` call only with `file_path` (one without writes nothing into the device, so it
238
+ * takes neither the device-owner guard nor the permission review: image generation spec §5.3).
239
+ */
240
+ const entersDevice = (toolKey, input) => toolKey !== BUILTIN.GenerateImage || generateImagePaths(input).length > 0;
241
+ /** Whether the review holds a shell command or a file write, for the texts and the ask's detail. */
242
+ const reviewKindOf = (toolKey) => toolKey === "Bash" ? "command" : "write";
243
+ /**
244
+ * The working root a reviewed call carries to its tool: a project root only. In free mode the
245
+ * reviewed root is the recorded workspace, which may be stale; the tool then maps it to the held
246
+ * instance's own workspace as it always has.
247
+ */
248
+ const carriedRoot = (facts) => facts.workingRoot !== undefined && facts.workingRoot !== facts.workspace
249
+ ? facts.workingRoot
250
+ : undefined;
251
+ /** The review record of an allowed call. */
252
+ const allowRecord = (v) => ({
253
+ decision: "allow",
254
+ by: v.by,
255
+ rule: v.rule,
256
+ reason: v.reason,
257
+ });
258
+ /** The review record of a denied call (the rule table's, the classifier's or a person's). */
259
+ const denyRecord = (by, rule, reason) => ({
260
+ decision: "deny",
261
+ by,
262
+ rule,
263
+ reason,
264
+ });
265
+ /** A string field of a validated tool input, or "" (never another type). */
266
+ const textField = (input, field) => {
267
+ const v = input?.[field];
268
+ return typeof v === "string" ? v : "";
269
+ };
110
270
  const approvalAuthorization = (a) => ({
111
271
  approvalId: a.id,
112
272
  approvedByAccountId: a.decidedBy,
@@ -155,6 +315,59 @@ function withNotes(result, notes) {
155
315
  content: [...content, ...notes.map((text) => ({ type: "text", text }))],
156
316
  };
157
317
  }
318
+ /** A network ask's kept display fields, written with its result when the ask settles. */
319
+ const keptExtras = (kept) => ({
320
+ ...(kept?.outputId !== undefined && { outputId: kept.outputId }),
321
+ ...(kept?.contentTypes !== undefined && { contentTypes: kept.contentTypes }),
322
+ ...(kept?.display !== undefined && { display: kept.display }),
323
+ ...(kept?.view !== undefined && { view: kept.view }),
324
+ });
325
+ /** A builtin result's kernel-internal network report (see `BuiltinResult.networkReport`). */
326
+ function networkReportOf(result) {
327
+ const r = result?.networkReport;
328
+ if (r === undefined || typeof r.deviceId !== "string" || !Array.isArray(r.blocked)) {
329
+ return undefined;
330
+ }
331
+ const blocked = r.blocked.filter((b) => typeof b === "object" &&
332
+ b !== null &&
333
+ typeof b.host === "string" &&
334
+ typeof b.port === "number" &&
335
+ ["device", "org", "address", "unknown"].includes(b.layer));
336
+ return blocked.length === 0 ? undefined : { deviceId: r.deviceId, blocked };
337
+ }
338
+ /**
339
+ * A kernel-internal device code (see `BuiltinResult.loginCode` and `KeptToolResult.loginCode`):
340
+ * the shape is checked again here so a malformed value never reaches the log (the event schema
341
+ * would throw).
342
+ */
343
+ function validLoginCode(v) {
344
+ const r = v;
345
+ if (r == null ||
346
+ typeof r.url !== "string" ||
347
+ typeof r.code !== "string" ||
348
+ r.url !== GITHUB_DEVICE_LOGIN_URL ||
349
+ !DEVICE_CODE_PATTERN.test(r.code)) {
350
+ return undefined;
351
+ }
352
+ return { url: r.url, code: r.code };
353
+ }
354
+ /** A builtin result's kernel-internal device code (`{ loginCode: { url, code } }`). */
355
+ function loginCodeOf(result) {
356
+ return validLoginCode(result?.loginCode);
357
+ }
358
+ /**
359
+ * The display-only `device_code` event of the call whose output carried the code (auto mode spec
360
+ * §6, P-D13). The key is per (run, call), so a retry of that call appends it once; a different
361
+ * call with the same code is deduplicated by value (`EventLog.deviceCodeShown`).
362
+ */
363
+ function deviceCodeEvent(runId, step, callId, code) {
364
+ return {
365
+ type: "device_code",
366
+ runId,
367
+ idemKey: deviceCodeIdemKey(runId, callId),
368
+ payload: { step, callId, ...code },
369
+ };
370
+ }
158
371
  /** 审批的等待时长(小时,四舍五入,至少 1)。 */
159
372
  const approvalHours = (a) => Math.max(1, Math.round((new Date(a.expiresAt).getTime() - new Date(a.createdAt).getTime()) / 3_600_000));
160
373
  const approvalWait = (a) => ({
@@ -177,6 +390,10 @@ const inputWait = (q) => ({
177
390
  let ToolPipeline = class ToolPipeline {
178
391
  config;
179
392
  txHost;
393
+ permissionAuthority;
394
+ permissionGrants;
395
+ permissionLocks;
396
+ sandboxes;
180
397
  decide;
181
398
  deps;
182
399
  constructor(kdb, eventLog,
@@ -185,10 +402,28 @@ let ToolPipeline = class ToolPipeline {
185
402
  /** The message tools between agents; absent (tests): their calls are refused. */
186
403
  messages, registry, credentials, breaker, outputs, approvals, questions, config, log,
187
404
  /** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
188
- host, drift, effective, switches, txHost, hooks) {
405
+ host, drift, effective, switches, txHost, hooks, networkGrants, devicePolicy,
406
+ /** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
407
+ review,
408
+ /** The reviewed call's device facts; absent in hand-built pipelines. */
409
+ devices, permissionAuthority, permissionGrants, permissionLocks,
410
+ /** The paired activation gate: on, the managed builtins take the permission review. */
411
+ activation,
412
+ /** Starts a cloud device before its first managed call is reviewed (absent: never). */
413
+ sandboxes) {
189
414
  this.config = config;
190
415
  this.txHost = txHost;
416
+ this.permissionAuthority = permissionAuthority;
417
+ this.permissionGrants = permissionGrants;
418
+ this.permissionLocks = permissionLocks;
419
+ this.sandboxes = sandboxes;
191
420
  this.deps = {
421
+ // the builtins that enter a device on the managed operation route once activated (common.ts
422
+ // `inToolSandbox`, `inSandboxPreparation`): their review is the permission review, whose
423
+ // approvals issue the exact call grants admission reads; dormant, none (the command review)
424
+ permissionOperations: permissionContextActive(activation)
425
+ ? MANAGED_OPERATION_TOOLS
426
+ : new Set(),
192
427
  get db() {
193
428
  return kdb.db;
194
429
  },
@@ -206,9 +441,9 @@ let ToolPipeline = class ToolPipeline {
206
441
  },
207
442
  effective,
208
443
  switches,
209
- inlineViews: (plugin) => new Set((host?.current(plugin)?.manifest.ui ?? [])
210
- .filter((c) => c.place === "inline" && c.aliasOf === undefined)
211
- .map((c) => c.id)),
444
+ inlineViews: (plugin) => new Set((host?.current(plugin)?.ui ?? [])
445
+ .filter((r) => r.slot.id === "conversation.tool-result.card")
446
+ .map((r) => r.contribution.id)),
212
447
  onToolsChanged: (orgId, connectorId) => {
213
448
  void drift?.onToolsChanged(orgId, connectorId);
214
449
  },
@@ -216,10 +451,17 @@ let ToolPipeline = class ToolPipeline {
216
451
  return subagents ? { dispatch: (a) => subagents.dispatch(a) } : undefined;
217
452
  },
218
453
  messages,
454
+ review,
455
+ devices,
456
+ network: networkGrants && devicePolicy
457
+ ? { grants: networkGrants, devices: devicePolicy }
458
+ : undefined,
219
459
  };
220
460
  const decide = hooks?.decidePolicy;
221
461
  // the default policy reads live, on the context's handle
222
- this.decide = decide ?? ((tool, def, c) => createDecidePolicy(kdb.db)(tool, def, c));
462
+ this.decide =
463
+ decide ??
464
+ ((tool, def, c) => createDecidePolicy(kdb.db, log.debug && { debug: log.debug.bind(log) })(tool, def, c));
223
465
  }
224
466
  /**
225
467
  * tools 节点:按顺序处理本步 assistant 消息里的全部 `tool_call`,每个调用都以一条 `tool_result` 结束
@@ -228,12 +470,21 @@ let ToolPipeline = class ToolPipeline {
228
470
  * 某个调用需要等人处理(审批 / 用户输入)→ 返回 `suspended`,之后的调用留到续跑时处理;
229
471
  * 续跑时重新进入本函数,按 PG 里的审批 / 输入请求结果继续。
230
472
  */
231
- async runStep(ctx) {
473
+ async runStep(given) {
474
+ let ctx = given;
232
475
  const { eventLog } = this.deps;
233
476
  const msg = await eventLog.findByIdem(ctx.conversationId, assistantIdemKey(ctx.runId, ctx.step));
234
477
  if (msg?.type !== "assistant_message")
235
478
  return { kind: "done" };
236
479
  const calls = msg.payload.content.flatMap((b) => b.type === "tool_call" ? [{ id: b.id, name: b.name, input: b.input }] : []);
480
+ // scheduled tasks spec §7: read live for each step (a person's message absorbed since makes the
481
+ // rest of the run attended)
482
+ if (calls.length > 0 && ctx.unattended === undefined) {
483
+ ctx = {
484
+ ...ctx,
485
+ unattended: await unattendedRunOf(this.deps.db, this.config, ctx.orgId, ctx.runId),
486
+ };
487
+ }
237
488
  let resolved;
238
489
  const resolve = async () => {
239
490
  // 每步实时解析(连接器 / 插件状态可能在模型调用之后变化)
@@ -242,11 +493,15 @@ let ToolPipeline = class ToolPipeline {
242
493
  // skill invocation in the log → Skill is offered (see skillLoadOffered)
243
494
  const skillLoad = await skillLoadOfferedIn(this.deps.db, this.deps.eventLog, ctx.conversationId);
244
495
  resolved = await this.deps.registry.forAgent(ctx.orgId, {
245
- tools: ctx.agent.tools ?? [],
496
+ disabledTools: ctx.agent.disabledTools,
497
+ subagentTools: ctx.agent.subagentTools,
246
498
  skillLoad,
247
499
  subagents: ctx.agent.subagents,
248
500
  child: ctx.parent !== undefined,
249
501
  forkChild: ctx.parent?.forSkill === true,
502
+ sandboxConversationId: ctx.parent?.rootConversationId ?? ctx.conversationId,
503
+ replay: ctx.conversationKind === "eval",
504
+ source: ctx.source,
250
505
  });
251
506
  }
252
507
  return resolved;
@@ -264,7 +519,7 @@ let ToolPipeline = class ToolPipeline {
264
519
  }
265
520
  /**
266
521
  * Writes, in the caller's transaction (`mandatory`), what a run that is being stopped (a person,
267
- * its deadline, a failure, the wait sweep) still owes its log: the report of its fork invocation
522
+ * its deadline, a failure, an orphan repair) still owes its log: the report of its fork invocation
268
523
  * (phase D, `pairStoppedForks`; a still active fork child is stopped by the caller after its
269
524
  * commit). An `Agent` call has its result from its dispatch (agent map spec §4.1), so there is
270
525
  * nothing to write for it. Returns the fork's call id (the caller must not write a "not executed"
@@ -284,24 +539,68 @@ let ToolPipeline = class ToolPipeline {
284
539
  const last = rounds.at(-1);
285
540
  if (last?.status === "pending")
286
541
  return inputWait(last);
542
+ // skipped by the starter's message: the kernel writes the result, the tool is not called again
543
+ // (spec D6: an extension would only see `answer: null`, an MCP call would be re-sent)
544
+ if (last?.status === "skipped") {
545
+ await this.writeResult(ctx, call.id, last.toolKey, skippedResult(last.toolKey));
546
+ return undefined;
547
+ }
287
548
  const attempt = rounds.length + 1;
288
549
  const started = await this.deps.eventLog.findByIdem(ctx.conversationId, idem.started(ctx.runId, call.id, attempt));
289
550
  if (started?.type === "tool_call_started") {
551
+ // a command that ran and was refused a network host waits for the device owner (network
552
+ // ask-to-allow spec §6.2, P-D2): pending → wait on; settled → its kept result and the
553
+ // outcome's note (the command is never run again; its tool.called was audited when it ran)
554
+ const ask = await this.deps.approvals.networkForCall(ctx.runId, call.id);
555
+ if (ask !== null) {
556
+ const notes = settledNetworkNotes(ask, approvalHours(ask));
557
+ if (notes === null)
558
+ return approvalWait(ask);
559
+ const kept = ask.detail?.result;
560
+ // the device code the command printed is carried in the kept result: write its
561
+ // display-only event here too (a crash before the ask's first write, or an older kept
562
+ // result; the event's ids and the per-conversation code check keep it to one)
563
+ const keptCode = validLoginCode(kept?.loginCode);
564
+ const pre = keptCode !== undefined &&
565
+ !(await this.deps.eventLog.deviceCodeShown(ctx.conversationId, keptCode.code))
566
+ ? [deviceCodeEvent(ctx.runId, ctx.step, call.id, keptCode)]
567
+ : [];
568
+ await this.writeResult(ctx, call.id, call.name, {
569
+ ...keptExtras(kept),
570
+ content: withNetworkNotes(kept?.content ?? UNKNOWN_RESULT_TEXT, notes),
571
+ isError: kept?.isError ?? true,
572
+ ...(kept?.review !== undefined && { review: kept.review }),
573
+ }, pre);
574
+ return undefined;
575
+ }
290
576
  // 确实开始执行过:照样审计 tool.called(耗时未知);放行依据只认批准了所执行定义的审批记录
291
577
  const key = started.payload.toolKey;
292
578
  const approval = await this.deps.approvals.forCall(ctx.runId, call.id);
293
579
  const approved = approval?.status === "approved" && approval.specHash === started.payload.specHash
294
580
  ? approval
295
581
  : null;
582
+ // a command that ran under the person's `command` approval: its review record and
583
+ // authorization survive the lost result too (the ask is the whole truth on a resume)
584
+ const commandAsk = await this.deps.approvals.commandForCall(ctx.runId, call.id);
585
+ const command = commandAsk?.status === "approved" ? commandAsk : null;
586
+ const authorization = approved !== null
587
+ ? approvalAuthorization(approved)
588
+ : command !== null
589
+ ? approvalAuthorization(command)
590
+ : null;
296
591
  const source = approved ? null : (await resolve()).tools.find((t) => t.key === key)?.source;
297
- await this.writeResult(ctx, call.id, key, { content: UNKNOWN_RESULT_TEXT, isError: true }, [], {
592
+ await this.writeResult(ctx, call.id, key, {
593
+ content: UNKNOWN_RESULT_TEXT,
594
+ isError: true,
595
+ ...(command !== null && { review: this.personAllowRecord(command) }),
596
+ }, [], {
298
597
  durationMs: null,
299
598
  connectorId: approved
300
599
  ? approved.connectorId
301
600
  : source?.kind === "connector"
302
601
  ? source.connectorId
303
602
  : null,
304
- ...(approved && { authorization: approvalAuthorization(approved) }),
603
+ ...(authorization !== null && { authorization }),
305
604
  });
306
605
  return undefined;
307
606
  }
@@ -318,22 +617,18 @@ let ToolPipeline = class ToolPipeline {
318
617
  return this.runCall(ctx, call, await resolve(), attempt, resume);
319
618
  }
320
619
  async runCall(ctx, call, resolved, attempt, resume) {
321
- const fail = async (content, key = call.name) => {
322
- await this.writeResult(ctx, call.id, key, { content, isError: true });
620
+ // the command review's record for this call's result (absent: not reviewed, or no device)
621
+ let review;
622
+ const fail = async (content, key = call.name, view) => {
623
+ await this.writeResult(ctx, call.id, key, {
624
+ content,
625
+ isError: true,
626
+ ...(view !== undefined && { view }),
627
+ ...(review !== undefined && { review }),
628
+ });
323
629
  return undefined;
324
630
  };
325
- let tool = resolved.tools.find((t) => t.key === call.name);
326
- // A call logged before the tool keys were renamed (spec 8.1): the request that issued it offered
327
- // the old key. It runs as the current tool with translated input; the result keeps the logged key.
328
- let legacy = false;
329
- if (!tool) {
330
- const next = legacyToolKey(call.name, legacyScopeOf(resolved.tools));
331
- const current = next === null ? undefined : resolved.tools.find((t) => t.key === next);
332
- if (current && (await this.requestToolKeys(ctx))?.has(call.name) === true) {
333
- tool = current;
334
- legacy = true;
335
- }
336
- }
631
+ const tool = resolved.tools.find((t) => t.key === call.name);
337
632
  if (!tool) {
338
633
  const why = resolved.unavailable.find((u) => u.ref === call.name) ??
339
634
  resolved.hidden?.find((u) => u.ref === call.name);
@@ -347,20 +642,20 @@ let ToolPipeline = class ToolPipeline {
347
642
  keys = keys.filter((k) => isAlwaysLoaded(k) || sent.has(k));
348
643
  }
349
644
  keys.sort();
350
- return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH), legacyHint(call.name)));
645
+ return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH)));
351
646
  }
352
- const outKey = legacy ? call.name : tool.key;
647
+ const outKey = tool.key;
353
648
  // ToolSearch 模式下,模型只能调用请求里带了完整定义的工具:目录里有、但发出本次调用的请求没加载 →
354
649
  // 明确错误,不自动加载(spec 5.5 / 6.3)。同一步里先 ToolSearch 再调用刚加载的工具同样报错。
355
- if (!legacy && resolved.toolSearch === true && !isAlwaysLoaded(tool.key)) {
650
+ // This is the protocol working, not a failure: the `not_loaded` view lets the row read neutral.
651
+ if (resolved.toolSearch === true && !isAlwaysLoaded(tool.key)) {
356
652
  const sent = await this.sentTools(ctx);
357
653
  if (sent !== null && !sent.has(tool.key))
358
- return fail(notLoadedText(tool.key), outKey);
654
+ return fail(notLoadedText(tool.key), outKey, { kind: "not_loaded" });
359
655
  }
360
- const rawInput = legacy ? legacyToolInput(call.name, call.input) : call.input;
361
656
  let input;
362
657
  try {
363
- input = await resolveOutputRefs(rawInput, (id) => this.deps.outputs.load({ orgId: ctx.orgId, conversationId: ctx.conversationId }, id));
658
+ input = await resolveOutputRefs(call.input, (id) => this.deps.outputs.load({ orgId: ctx.orgId, conversationId: ctx.conversationId }, id));
364
659
  }
365
660
  catch (e) {
366
661
  if (e instanceof ToolError)
@@ -382,7 +677,8 @@ let ToolPipeline = class ToolPipeline {
382
677
  agentId: ctx.agentId,
383
678
  conversationId: ctx.conversationId,
384
679
  runId: ctx.runId,
385
- rawInput,
680
+ rawInput: call.input,
681
+ signal: ctx.signal,
386
682
  })) ?? null;
387
683
  // a deny with a reason (e.g. an unavailable operation): the reason is the tool error
388
684
  if (callPolicy?.policy === "deny" && callPolicy.denyReason !== undefined) {
@@ -401,9 +697,16 @@ let ToolPipeline = class ToolPipeline {
401
697
  ...(ctx.parent.otherAgent !== undefined && { parentAgentDiffers: ctx.parent.otherAgent }),
402
698
  }),
403
699
  callPolicy,
700
+ ...(ctx.unattended != null && { unattended: ctx.unattended }),
404
701
  });
405
702
  if (decision === "deny")
406
703
  return fail(deniedText(tool.key, callPolicy?.key), outKey);
704
+ if (typeof decision === "object" && "refused" in decision) {
705
+ if (decision.missingGrant !== undefined && ctx.unattended != null) {
706
+ await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, decision.missingGrant);
707
+ }
708
+ return fail(decision.refused, outKey);
709
+ }
407
710
  if (typeof decision === "object" && "unavailable" in decision) {
408
711
  return fail(unavailableText(tool.key, decision.unavailable), outKey);
409
712
  }
@@ -411,13 +714,10 @@ let ToolPipeline = class ToolPipeline {
411
714
  // (不写 tool_call_started:此时尚未开始执行)。
412
715
  let approval = await this.deps.approvals.forCall(ctx.runId, call.id);
413
716
  // 批准的是旧定义(等待期间工具定义变了):原批准不适用于当前定义,策略仍需审批时按新定义重新审批。
414
- // An in-flight rc call (spec §9) is the exception: its approval was asked under the rc definition
415
- // of the same call, and the rename changed every builtin's definition; the person approved this
416
- // very call, so the approval stands.
417
717
  // An approval binds the exact input it showed (Platform tool spec §6.3): an approved record
418
718
  // whose stored input differs from the call's is not used.
419
719
  const approvedHere = approval?.status === "approved" &&
420
- (legacy || approval.specHash === tool.specHash) &&
720
+ approval.specHash === tool.specHash &&
421
721
  canonicalJson(approval.input) === canonicalJson(call.input ?? {});
422
722
  const stale = approval?.status === "approved" && !approvedHere;
423
723
  if ((!approval || stale) && typeof decision === "object" && "ask" in decision) {
@@ -444,16 +744,35 @@ let ToolPipeline = class ToolPipeline {
444
744
  return refused === null ? approvalWait(approval) : fail(refused, outKey);
445
745
  }
446
746
  // 走到这里即放行:在(与当前定义一致的)审批下执行,否则是授权或策略放行
447
- const authorization = approval?.status === "approved" && approvedHere
747
+ let authorization = approval?.status === "approved" && approvedHere
448
748
  ? approvalAuthorization(approval)
449
749
  : typeof decision === "object" && "grant" in decision
450
750
  ? { grant: decision.grant }
451
751
  : { policy: "allow" };
752
+ // Auto mode spec §5.1: the command review, after argument validation and the tool policy (and
753
+ // its approval), before the plugin hooks and `tool_call_started`. A deny ends the call here; an
754
+ // ask parks the run on the command approval (attended) or is a deny at once (unattended). An
755
+ // already decided command approval resumes the call without re-reviewing.
756
+ const reviewed = await this.reviewCall(ctx, call, tool, input);
757
+ if (reviewed.kind === "wait")
758
+ return reviewed.wait;
759
+ if (reviewed.kind === "result") {
760
+ review = reviewed.review;
761
+ return fail(reviewed.content, outKey);
762
+ }
763
+ review = reviewed.review;
764
+ const reviewedRoots = {
765
+ workingRoot: reviewed.workingRoot,
766
+ against: reviewed.reviewedAgainst,
767
+ ...(reviewed.sandboxEscalation !== undefined && { escalation: reviewed.sandboxEscalation }),
768
+ };
769
+ if (reviewed.commandAsk !== undefined)
770
+ authorization = approvalAuthorization(reviewed.commandAsk);
452
771
  // tool.preExecute after policy and approval, before tool_call_started (F10)
453
772
  const hooks = this.deps.pluginHooks;
454
773
  const scope = hookScope(hooks, ctx);
455
774
  if (scope && hooks?.has("tool.preExecute")) {
456
- // sticky: a denial already logged for this call (e.g. an older log, or a crash right after it)
775
+ // sticky: a denial already logged for this call (e.g. a crash right after it)
457
776
  // is final: fail with the recorded reason, never re-run the hooks or execute the tool. Only
458
777
  // looked up when a tool.preExecute hook could run (M-2: no query without hooks); a denial is
459
778
  // written with the call's tool_result, so a call with a logged denial never runs again anyway.
@@ -499,7 +818,11 @@ let ToolPipeline = class ToolPipeline {
499
818
  step: ctx.step,
500
819
  callId: call.id,
501
820
  });
502
- await this.writeResult(ctx, call.id, outKey, { content: hookDeniedText(verdict.plugin, verdict.reason), isError: true }, [event], undefined, [hookDeniedAudit(site, event.payload, verdict)]);
821
+ await this.writeResult(ctx, call.id, outKey, {
822
+ content: hookDeniedText(verdict.plugin, verdict.reason),
823
+ isError: true,
824
+ ...(review !== undefined && { review }),
825
+ }, [event], undefined, [hookDeniedAudit(site, event.payload, verdict)]);
503
826
  return undefined;
504
827
  }
505
828
  }
@@ -575,13 +898,44 @@ let ToolPipeline = class ToolPipeline {
575
898
  type: "tool_call_started",
576
899
  runId: ctx.runId,
577
900
  idemKey: idem.started(ctx.runId, call.id, attempt),
578
- payload: { step: ctx.step, callId: call.id, toolKey: tool.key, specHash: tool.specHash },
901
+ payload: {
902
+ step: ctx.step,
903
+ callId: call.id,
904
+ toolKey: tool.key,
905
+ specHash: tool.specHash,
906
+ ...(this.operationScoped(tool, input)
907
+ ? {
908
+ permissionInput: {
909
+ callInputHash: permissionScopeHash(call.input),
910
+ resolvedInputHash: permissionScopeHash(input),
911
+ ...(isEscalatedCall(tool.key, input) ? { sandbox: "escalated" } : {}),
912
+ },
913
+ }
914
+ : {}),
915
+ },
579
916
  },
580
917
  ]);
581
918
  const t0 = Date.now();
582
- let outcome = await this.execute(tool, input, ctx, call.id, resume, resolved.tools);
919
+ let outcome = await this.execute(tool, input, ctx, call.id, resume, resolved.tools, reviewedRoots);
583
920
  const durationMs = Date.now() - t0;
584
921
  await this.deps.hooks?.afterExecute?.(ctx.runId, call.id);
922
+ // the record says a call ran outside the sandbox only when admission gave it that scope
923
+ if (review !== undefined && isEscalatedCall(tool.key, input)) {
924
+ const { sandbox: _asked, ...rest } = review;
925
+ review = (await this.admittedOutsideSandbox(ctx.runId, call.id))
926
+ ? { ...rest, sandbox: "escalated" }
927
+ : rest;
928
+ }
929
+ // scheduled tasks spec §7, `fail` mode: no one answers an input request or connects an app
930
+ if (unattendedFails(ctx.unattended) && ctx.unattended != null) {
931
+ if (outcome.kind === "input_required") {
932
+ outcome = { kind: "error", message: UNATTENDED_QUESTION_ERROR };
933
+ }
934
+ else if (outcome.kind === "connection_required") {
935
+ await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, connectionGrantKey(outcome.connectorSlug));
936
+ outcome = { kind: "error", message: UNATTENDED_CONNECTION_ERROR(outcome.connectorName) };
937
+ }
938
+ }
585
939
  if (outcome.kind === "input_required") {
586
940
  const asked = await this.askInput(ctx, call.id, tool.key, attempt, outcome);
587
941
  if (typeof asked !== "string")
@@ -608,6 +962,11 @@ let ToolPipeline = class ToolPipeline {
608
962
  const card = outcome.kind === "result" && tool.source.kind === "plugin"
609
963
  ? this.cardOf(outcome.result, tool.source.plugin, tool.key)
610
964
  : undefined;
965
+ // a `gh auth login --web` device code (`Bash`; auto mode spec §6): display only, written under
966
+ // this call before its result, never part of the result or the request the model sees
967
+ const loginCode = outcome.kind === "result" && tool.source.kind === "builtin"
968
+ ? loginCodeOf(outcome.result)
969
+ : undefined;
611
970
  const cfg = this.config.get().tools;
612
971
  const spilled = await spillIfLarge(rendered.text, {
613
972
  // 内置工具可给更低的转存阈值(沙箱 bash 30000 字符)
@@ -635,8 +994,50 @@ let ToolPipeline = class ToolPipeline {
635
994
  },
636
995
  ]
637
996
  : [];
997
+ if (loginCode !== undefined &&
998
+ !(await this.deps.eventLog.deviceCodeShown(ctx.conversationId, loginCode.code))) {
999
+ // the per-call id makes a retry or a resumed run append it once; a second call (a task read
1000
+ // again, another command printing the same code) does not show the same code twice (P-D13)
1001
+ pre.push(deviceCodeEvent(ctx.runId, ctx.step, call.id, loginCode));
1002
+ }
1003
+ const callAudit = {
1004
+ durationMs,
1005
+ connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
1006
+ authorization,
1007
+ };
1008
+ // a foreground command refused network hosts (network ask-to-allow spec §6.2): display-only
1009
+ // `network_blocked` before the result, then an ask to the device owner (the run waits; the
1010
+ // result is written when the ask settles) or notes after the output
1011
+ const report = outcome.kind === "result" && tool.source.kind === "builtin"
1012
+ ? networkReportOf(outcome.result)
1013
+ : undefined;
1014
+ let content = spilled.content;
1015
+ if (report !== undefined) {
1016
+ const handled = await this.networkBlocked(ctx, call.id, outKey, input, report, pre, callAudit, {
1017
+ text: rendered.text,
1018
+ content: spilled.content,
1019
+ isError: rendered.isError,
1020
+ ...(spilled.outputId !== undefined && { outputId: spilled.outputId }),
1021
+ ...(rendered.contentTypes.length > 0 && { contentTypes: rendered.contentTypes }),
1022
+ ...(display !== undefined && { display }),
1023
+ ...(view !== undefined && { view }),
1024
+ ...(review !== undefined && { review }),
1025
+ // carried into the kept result so a resumed run writes the event too (it was written
1026
+ // with `network_blocked` below when the ask was created)
1027
+ ...(loginCode !== undefined && { loginCode }),
1028
+ });
1029
+ if (handled.kind === "wait") {
1030
+ if (hooks && hookBase) {
1031
+ fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: handled.content, durationMs }, ctx.signal, this.deps.log);
1032
+ }
1033
+ return handled.wait;
1034
+ }
1035
+ if (handled.event !== null)
1036
+ pre.push(handled.event);
1037
+ content = withNetworkNotes(content, handled.notes);
1038
+ }
638
1039
  await this.writeResult(ctx, call.id, outKey, {
639
- content: spilled.content,
1040
+ content,
640
1041
  isError: rendered.isError,
641
1042
  ...(spilled.outputId !== undefined && { outputId: spilled.outputId }),
642
1043
  ...(rendered.contentTypes.length > 0 && { contentTypes: rendered.contentTypes }),
@@ -644,11 +1045,8 @@ let ToolPipeline = class ToolPipeline {
644
1045
  ...(display !== undefined && { display }),
645
1046
  ...(view !== undefined && { view }),
646
1047
  ...(card !== undefined && { card }),
647
- }, pre, {
648
- durationMs,
649
- connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
650
- authorization,
651
- });
1048
+ ...(review !== undefined && { review }),
1049
+ }, pre, callAudit);
652
1050
  // a sub-agent that needs a personal connection: mirrored in the root conversation of its tree
653
1051
  // for display (sub-agents spec §9, agent map spec §7; not a wait, the child got the connect
654
1052
  // text as its result)
@@ -659,10 +1057,668 @@ let ToolPipeline = class ToolPipeline {
659
1057
  }));
660
1058
  }
661
1059
  if (hooks && hookBase) {
662
- fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: spilled.content, durationMs }, ctx.signal, this.deps.log);
1060
+ fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content, durationMs }, ctx.signal, this.deps.log);
663
1061
  }
664
1062
  return undefined;
665
1063
  }
1064
+ /**
1065
+ * The command review of one call (auto mode spec §5.1, §5.4), after argument validation and the
1066
+ * tool policy (and its approval), before the plugin hooks and execution. The device facts come
1067
+ * from the same `ConversationDevices.forTool` the tool enters; with no device (or a deployment
1068
+ * without a review service) the call runs unreviewed and fails on its own if it cannot. A deny is
1069
+ * final whatever the mode and approvals; an `ask` waits for the device owner's `command` approval
1070
+ * when the run is attended, and is a deny at once when it is not. A command approval already
1071
+ * asked is the whole truth on a resume: the call is never reviewed twice.
1072
+ */
1073
+ async reviewCall(ctx, call, tool, input) {
1074
+ // a device tool of a run another account triggered never uses the owner's device: refused
1075
+ // here, with no review and no review model call (the tools refuse it the same way)
1076
+ if (this.operationScoped(tool, input) && ctx.ownerAccountId !== ctx.accountId)
1077
+ return {
1078
+ kind: "result",
1079
+ content: DEVICE_OF_ANOTHER_ACCOUNT_TEXT,
1080
+ review: denyRecord("rule", null, "The run's account is not the conversation's owner"),
1081
+ };
1082
+ if (this.operationScoped(tool, input)) {
1083
+ let scoped;
1084
+ try {
1085
+ scoped = await this.reviewPermissionCall(ctx, call, tool, input);
1086
+ }
1087
+ catch (error) {
1088
+ // fail closed: a permission evidence conflict or an owner check that refuses while the
1089
+ // call is asked about, reviewed or matched to its grant is a refusal of this call, never a
1090
+ // run error and never a run of it
1091
+ if (!(error instanceof ApiError) || !FAIL_CLOSED_CODES.has(error.code))
1092
+ throw error;
1093
+ this.deps.log.warn("permission review refused the call", {
1094
+ conversationId: ctx.conversationId,
1095
+ callId: call.id,
1096
+ err: error,
1097
+ });
1098
+ const content = permissionCheckFailedText(error.message);
1099
+ return { kind: "result", content, review: denyRecord("rule", null, error.message) };
1100
+ }
1101
+ if (scoped)
1102
+ return scoped;
1103
+ }
1104
+ const review = this.deps.review;
1105
+ const devices = this.deps.devices;
1106
+ if (review === undefined || devices === undefined)
1107
+ return { kind: "continue" };
1108
+ if (!isReviewedCall(tool.key, input))
1109
+ return { kind: "continue" };
1110
+ const asked = await this.deps.approvals.commandForCall(ctx.runId, call.id);
1111
+ const rootConversationId = ctx.parent?.rootConversationId ?? ctx.conversationId;
1112
+ if (asked !== null && asked.status !== "superseded") {
1113
+ const settled = this.settledCommandAsk(asked, tool.key);
1114
+ // an approved call runs in the root it was reviewed against only while the device still runs
1115
+ // in the mode recorded with the ask; otherwise the tool decides its working root afresh. A
1116
+ // judged root that is the recorded workspace (free mode) is not carried either
1117
+ // ({@link carriedRoot}): the tool maps it to the held instance's workspace as always
1118
+ if (settled.kind === "continue" && settled.workingRoot !== undefined) {
1119
+ const now = await devices.reviewFacts(ctx.orgId, rootConversationId, ctx.conversationId);
1120
+ if (now === null ||
1121
+ now.mode !== asked.command?.mode ||
1122
+ carriedRoot({ workspace: now.workspace, workingRoot: settled.workingRoot }) === undefined) {
1123
+ // the root the person approved stays the one judged (B-18): only the carried root goes
1124
+ return { ...settled, workingRoot: undefined };
1125
+ }
1126
+ }
1127
+ return settled;
1128
+ }
1129
+ const facts = await devices.reviewFacts(ctx.orgId, rootConversationId, ctx.conversationId);
1130
+ if (facts === null)
1131
+ return { kind: "continue" }; // no device: the tool fails on its own
1132
+ const kind = reviewKindOf(tool.key);
1133
+ const attended = ctx.unattended == null && ctx.accountId === facts.ownerAccountId;
1134
+ // a command over the ceiling is refused before any review: no stage reads it in full, and no
1135
+ // approval could bind a text the person cannot see (hardening spec R8)
1136
+ if (kind === "command") {
1137
+ const text = textField(input, "command");
1138
+ if (text.length > COMMAND_ASK_MAX_CHARS) {
1139
+ return {
1140
+ kind: "result",
1141
+ content: commandTooLongText(text.length),
1142
+ review: denyRecord("rule", null, commandTooLongReason(text.length)),
1143
+ };
1144
+ }
1145
+ }
1146
+ const verdict = await review.review({
1147
+ orgId: ctx.orgId,
1148
+ conversationId: rootConversationId,
1149
+ runId: ctx.runId,
1150
+ accountId: ctx.accountId,
1151
+ toolKey: tool.key,
1152
+ input,
1153
+ mode: facts.mode,
1154
+ // the working root: a bound project's root, where commands start and writes need no ask
1155
+ workspace: facts.workingRoot,
1156
+ // the owner's home, never the project root: the home-level rules stay where they were
1157
+ home: facts.home,
1158
+ // and the device workspace's home, so a project outside every home still protects it
1159
+ deviceHome: facts.deviceHome,
1160
+ attended,
1161
+ step: ctx.step,
1162
+ callId: call.id,
1163
+ signal: ctx.signal,
1164
+ ...reviewParentOf(ctx.parent),
1165
+ agentId: ctx.agentId,
1166
+ agentVersion: ctx.agentVersion,
1167
+ ...(ctx.conversationKind !== undefined && { conversationKind: ctx.conversationKind }),
1168
+ });
1169
+ if (verdict.decision === "allow") {
1170
+ return {
1171
+ kind: "continue",
1172
+ review: allowRecord(verdict),
1173
+ workingRoot: carriedRoot(facts),
1174
+ reviewedAgainst: facts.workingRoot,
1175
+ };
1176
+ }
1177
+ if (verdict.decision === "deny") {
1178
+ return {
1179
+ kind: "result",
1180
+ content: commandDeniedText(verdict.reason, kind),
1181
+ review: denyRecord(verdict.by, verdict.rule, verdict.reason),
1182
+ };
1183
+ }
1184
+ // ask
1185
+ const command = kind === "command" ? textField(input, "command") : tool.key;
1186
+ if (!attended) {
1187
+ const reason = verdict.reason;
1188
+ return {
1189
+ kind: "result",
1190
+ content: commandUnattendedText(reason, kind),
1191
+ review: denyRecord(verdict.by, verdict.rule, reason),
1192
+ };
1193
+ }
1194
+ const detail = {
1195
+ deviceId: facts.deviceId,
1196
+ deviceName: facts.deviceName,
1197
+ mode: facts.mode,
1198
+ kind,
1199
+ // the whole command the approval covers (the event keeps a clamped copy for display)
1200
+ command,
1201
+ // a relative path as it will be written: resolved against the working root
1202
+ // (every path a GenerateImage call writes, comma-separated)
1203
+ ...(kind === "write" && {
1204
+ path: clipText(writePathsOf(tool.key, input)
1205
+ .map((p) => facts.workingRoot === undefined ? p : pathAgainstWorkingRoot(p, facts.workingRoot))
1206
+ .join(", "), 4096),
1207
+ }),
1208
+ rule: verdict.rule,
1209
+ reason: clipText(verdict.reason, COMMAND_ASK_TEXT_MAX_CHARS),
1210
+ // the root the review judged, always (the workspace in free mode): the approved call runs
1211
+ // against what the person approved, not a later snapshot
1212
+ ...(facts.workingRoot !== undefined && { workingRoot: facts.workingRoot }),
1213
+ };
1214
+ let ask;
1215
+ try {
1216
+ ask = await this.deps.approvals.requestCommand({
1217
+ orgId: ctx.orgId,
1218
+ conversationId: ctx.conversationId,
1219
+ runId: ctx.runId,
1220
+ step: ctx.step,
1221
+ callId: call.id,
1222
+ requestedFor: facts.ownerAccountId,
1223
+ detail,
1224
+ // `once` always; `session` only for a concrete rule class, never an `unsure.*` catch-all (P-D2)
1225
+ scopes: isSessionGrantableRule(verdict.rule) ? ["once", "session"] : ["once"],
1226
+ });
1227
+ }
1228
+ catch (err) {
1229
+ // fail closed: an ask that cannot be created is a deny, never a run of the held call
1230
+ this.deps.log.warn("command ask could not be created; denying the call", {
1231
+ conversationId: ctx.conversationId,
1232
+ callId: call.id,
1233
+ err,
1234
+ });
1235
+ const reason = "The approval could not be created";
1236
+ return {
1237
+ kind: "result",
1238
+ content: commandDeniedText(reason, kind),
1239
+ review: denyRecord(verdict.by, verdict.rule, reason),
1240
+ };
1241
+ }
1242
+ return { kind: "wait", wait: approvalWait(ask) };
1243
+ }
1244
+ /**
1245
+ * Whether this call takes the managed route's permission review: a managed builtin once
1246
+ * activated ({@link MANAGED_OPERATION_TOOLS}) whose call enters the device ({@link entersDevice}).
1247
+ */
1248
+ operationScoped(tool, input) {
1249
+ return (tool.source.kind === "builtin" &&
1250
+ this.deps.permissionOperations?.has(tool.key) === true &&
1251
+ entersDevice(tool.key, input));
1252
+ }
1253
+ /**
1254
+ * The permission review of a managed call, with the escalation state a continued restricted
1255
+ * `Bash` call carries to its tool (its sandbox hints: retry with `sandbox: "escalated"` only
1256
+ * where this device and org allow it).
1257
+ */
1258
+ async reviewPermissionCall(ctx, call, tool, input) {
1259
+ const note = {};
1260
+ const outcome = await this.reviewPermissionCallWith(ctx, call, tool, input, note);
1261
+ return outcome?.kind === "continue" && note.escalation !== undefined
1262
+ ? { ...outcome, sandboxEscalation: note.escalation }
1263
+ : outcome;
1264
+ }
1265
+ async reviewPermissionCallWith(ctx, call, tool, input, note) {
1266
+ if (!this.permissionAuthority ||
1267
+ !this.permissionGrants ||
1268
+ !this.permissionLocks ||
1269
+ !this.deps.devices ||
1270
+ !this.deps.review)
1271
+ return null;
1272
+ const permissionLocks = this.permissionLocks;
1273
+ const previous = await this.deps.approvals.commandForCall(ctx.runId, call.id);
1274
+ // A settled refusal belongs to this call, not to a replaceable permission revision.
1275
+ if (previous && !["pending", "approved", "superseded"].includes(previous.status))
1276
+ return this.settledCommandAsk(previous, tool.key);
1277
+ const device = await this.deps.devices.reviewFacts(ctx.orgId, ctx.parent?.rootConversationId ?? ctx.conversationId, ctx.conversationId);
1278
+ if (!device)
1279
+ return null;
1280
+ // a run another account triggered never uses the owner's device (the tool refuses it): there
1281
+ // is no permission authority of that account here to review against
1282
+ if (ctx.accountId !== device.ownerAccountId)
1283
+ return null;
1284
+ const use = {
1285
+ orgId: ctx.orgId,
1286
+ deviceId: device.deviceId,
1287
+ holderConversationId: ctx.conversationId,
1288
+ actor: { accountId: ctx.accountId, conversationId: ctx.conversationId, runId: ctx.runId },
1289
+ };
1290
+ const preview = () => this.permissionAuthority.previewCall(use, { runId: ctx.runId, callId: call.id }, ctx.signal);
1291
+ let facts = await preview();
1292
+ // the facts first: a device not yet started (or not yet probed) whose review depends on them
1293
+ // is started under the normal lifecycle lease, which records a cloud instance's permission
1294
+ // evidence or a local one's installed binding, and read again
1295
+ if (facts.availability.state === "unprobed" &&
1296
+ !facts.unattended &&
1297
+ this.sandboxes &&
1298
+ REVIEWED_ON_FACTS.has(tool.key)) {
1299
+ try {
1300
+ await this.sandboxes.ensureRunning(use, ctx.signal);
1301
+ facts = await preview();
1302
+ }
1303
+ catch (err) {
1304
+ // a start that fails leaves the facts unverified (the conservative branch below); the
1305
+ // tool's own entry reports the device's state
1306
+ ctx.signal.throwIfAborted();
1307
+ this.deps.log.warn("cannot start the device before its review; reviewing unverified", {
1308
+ conversationId: ctx.conversationId,
1309
+ deviceId: device.deviceId,
1310
+ err,
1311
+ });
1312
+ }
1313
+ }
1314
+ if (facts.unattended) {
1315
+ // an unattended run never runs a call outside the sandbox: no one could approve it
1316
+ if (isEscalatedCall(tool.key, input)) {
1317
+ const content = escalationRefusedText(ESCALATION_UNATTENDED_WHY, facts.workingRoot);
1318
+ return { kind: "result", content, review: denyRecord("rule", null, content) };
1319
+ }
1320
+ return null;
1321
+ }
1322
+ if (facts.availability.state !== "supported") {
1323
+ // still unverified: the conservative command review decides (Full access too), but a call
1324
+ // that needs more reach is refused now: admission could never run what an approval allowed
1325
+ if (facts.profile === "full-access")
1326
+ return null;
1327
+ const unverified = buildPermissionCandidate({ toolKey: tool.key, specHash: tool.specHash, rawInput: call.input, validatedInput: input }, facts, [device.home, device.deviceHome], { backgroundMaxSeconds: backgroundMaxSeconds(this.config.get()) });
1328
+ if (unverified.kind === "in-scope")
1329
+ return null;
1330
+ const content = unverified.kind === "proposal" ? PERMISSION_SUPPORT_UNVERIFIED_TEXT : unverified.message;
1331
+ return { kind: "result", content, review: denyRecord("rule", null, content) };
1332
+ }
1333
+ if (tool.key === "Bash" && textField(input, "command").length > COMMAND_ASK_MAX_CHARS)
1334
+ return {
1335
+ kind: "result",
1336
+ content: commandTooLongText(textField(input, "command").length),
1337
+ review: denyRecord("rule", null, "The command exceeds the review limit"),
1338
+ };
1339
+ const escalated = isEscalatedCall(tool.key, input);
1340
+ // the escalation state the tool's hints read: only a restricted Bash call on a device and
1341
+ // org whose ceiling allows running outside the sandbox
1342
+ if (tool.key === "Bash" && facts.profile !== "full-access" && !facts.escalationRefusal)
1343
+ note.escalation = escalated ? "escalated" : "available";
1344
+ const built = facts.profile === "full-access" && !escalated
1345
+ ? { kind: "in-scope" }
1346
+ : buildPermissionCandidate({
1347
+ toolKey: tool.key,
1348
+ specHash: tool.specHash,
1349
+ rawInput: call.input,
1350
+ validatedInput: input,
1351
+ }, facts, [device.home, device.deviceHome], { backgroundMaxSeconds: backgroundMaxSeconds(this.config.get()) });
1352
+ if (built.kind === "unsupported") {
1353
+ // a Bash reach the restricted scope cannot grant: retrying outside the sandbox may
1354
+ const content = note.escalation === "available"
1355
+ ? `${built.message}${ESCALATION_RETRY_HINT}`
1356
+ : built.message;
1357
+ return { kind: "result", content, review: denyRecord("rule", null, content) };
1358
+ }
1359
+ const candidate = built.kind === "proposal" ? built.candidate : undefined;
1360
+ // a sensitive-command consent the person settled (no proposed reach): the call runs under
1361
+ // the base scope it was asked under; the approval adds nothing
1362
+ if (previous &&
1363
+ previous.status !== "superseded" &&
1364
+ !candidate &&
1365
+ !previous.command?.permissionCandidate) {
1366
+ const settled = this.settledCommandAsk(previous, tool.key);
1367
+ // the root the person approved is carried only while the device still runs in the mode
1368
+ // recorded with the ask (B-18: the judged root stays the one recorded)
1369
+ if (settled.kind === "continue" &&
1370
+ settled.workingRoot !== undefined &&
1371
+ (device.mode !== previous.command?.mode ||
1372
+ carriedRoot({ workspace: device.workspace, workingRoot: settled.workingRoot }) ===
1373
+ undefined))
1374
+ return { ...settled, workingRoot: undefined };
1375
+ return settled;
1376
+ }
1377
+ if (previous &&
1378
+ previous.status !== "superseded" &&
1379
+ candidate &&
1380
+ previous.command?.permissionCandidate?.candidateHash === candidate.candidateHash) {
1381
+ if (previous.status !== "approved")
1382
+ return this.settledCommandAsk(previous, tool.key);
1383
+ const grant = await withTransactionFencePrelude(() => permissionLocks.acquire({
1384
+ orgId: facts.orgId,
1385
+ deviceId: facts.deviceId,
1386
+ rootConversationId: facts.rootConversationId,
1387
+ }, { kind: "admit" }), () => this.findPermissionGrant(candidate));
1388
+ if (grant)
1389
+ return this.settledCommandAsk(previous, tool.key);
1390
+ }
1391
+ if (candidate) {
1392
+ const existingGrant = await withTransactionFencePrelude(() => permissionLocks.acquire({
1393
+ orgId: facts.orgId,
1394
+ deviceId: facts.deviceId,
1395
+ rootConversationId: facts.rootConversationId,
1396
+ }, { kind: "admit" }), () => this.findPermissionGrant(candidate));
1397
+ if (existingGrant) {
1398
+ if (existingGrant.scopeKind !== candidate.scopeKind ||
1399
+ permissionScopeHash(existingGrant.expansion) !==
1400
+ permissionScopeHash(candidate.permissionScope))
1401
+ return {
1402
+ kind: "result",
1403
+ content: "This call already has different permission evidence; submit a new call with the intended directory scope.",
1404
+ review: denyRecord("rule", null, "Conflicting permission evidence"),
1405
+ };
1406
+ return {
1407
+ kind: "continue",
1408
+ workingRoot: carriedRoot(device),
1409
+ reviewedAgainst: facts.workingRoot,
1410
+ // the evidence's real source: the person's approval or the review model's allow
1411
+ review: {
1412
+ decision: "allow",
1413
+ by: existingGrant.source === "human" ? "person" : "classifier",
1414
+ rule: null,
1415
+ reason: "The exact current call already has approved permission evidence.",
1416
+ profile: facts.profile,
1417
+ profileRevision: facts.profileRevision,
1418
+ scopeRevision: facts.scopeRevision,
1419
+ decisionSource: existingGrant.source === "human" ? "human" : "review-model",
1420
+ ...(candidate.escalation ? { sandbox: "escalated" } : {}),
1421
+ },
1422
+ };
1423
+ }
1424
+ }
1425
+ const verdict = await this.deps.review.review({
1426
+ orgId: ctx.orgId,
1427
+ conversationId: facts.rootConversationId,
1428
+ runId: ctx.runId,
1429
+ accountId: ctx.accountId,
1430
+ toolKey: tool.key,
1431
+ input,
1432
+ mode: device.mode,
1433
+ workspace: facts.workingRoot,
1434
+ home: device.home,
1435
+ deviceHome: device.deviceHome,
1436
+ attended: true,
1437
+ step: ctx.step,
1438
+ callId: call.id,
1439
+ signal: ctx.signal,
1440
+ ...reviewParentOf(ctx.parent),
1441
+ agentId: ctx.agentId,
1442
+ agentVersion: ctx.agentVersion,
1443
+ ...(ctx.conversationKind ? { conversationKind: ctx.conversationKind } : {}),
1444
+ permissionProfile: facts.profile,
1445
+ ...(candidate ? { permissionCandidate: candidate } : {}),
1446
+ ...(note.escalation === "available" ? { escalationAvailable: true } : {}),
1447
+ });
1448
+ if (candidate && facts.profile === "approve-for-me") {
1449
+ await withTransactionFencePrelude(() => permissionLocks.acquire({
1450
+ orgId: facts.orgId,
1451
+ deviceId: facts.deviceId,
1452
+ rootConversationId: facts.rootConversationId,
1453
+ }, { kind: "admit" }), () => this.recordPermissionReview(candidate, verdict));
1454
+ }
1455
+ const provenance = {
1456
+ profile: facts.profile,
1457
+ profileRevision: facts.profileRevision,
1458
+ scopeRevision: facts.scopeRevision,
1459
+ };
1460
+ if (verdict.decision === "deny")
1461
+ return {
1462
+ kind: "result",
1463
+ content: commandDeniedText(verdict.reason, reviewKindOf(tool.key)),
1464
+ review: { ...denyRecord(verdict.by, verdict.rule, verdict.reason), ...provenance },
1465
+ };
1466
+ if (verdict.decision === "allow")
1467
+ return {
1468
+ kind: "continue",
1469
+ workingRoot: carriedRoot(device),
1470
+ reviewedAgainst: facts.workingRoot,
1471
+ review: {
1472
+ ...allowRecord(verdict),
1473
+ ...provenance,
1474
+ decisionSource: facts.profile === "full-access"
1475
+ ? "full-access"
1476
+ : verdict.by === "classifier"
1477
+ ? "review-model"
1478
+ : "scope",
1479
+ // the review model's allow issued this call's escalation grant: it runs unsandboxed
1480
+ ...(candidate?.escalation && verdict.by === "classifier"
1481
+ ? { sandbox: "escalated" }
1482
+ : {}),
1483
+ },
1484
+ };
1485
+ // an ask: the sensitive-command consent (no proposed reach: approved, the call runs under the
1486
+ // base scope) or the displayed expansion (approved, the call's grant is issued)
1487
+ const kind = reviewKindOf(tool.key);
1488
+ // every path the call writes (a GenerateImage call's suffixed paths, comma-separated)
1489
+ const filePaths = kind === "write" ? writePathsOf(tool.key, input).filter(Boolean) : [];
1490
+ const ask = await this.deps.approvals.requestCommand({
1491
+ orgId: ctx.orgId,
1492
+ conversationId: ctx.conversationId,
1493
+ runId: ctx.runId,
1494
+ step: ctx.step,
1495
+ callId: call.id,
1496
+ requestedFor: ctx.accountId,
1497
+ // `session` only for a consent rule class with no expansion (a grant is per call)
1498
+ scopes: !candidate && isSessionGrantableRule(verdict.rule) ? ["once", "session"] : ["once"],
1499
+ detail: {
1500
+ deviceId: device.deviceId,
1501
+ deviceName: device.deviceName,
1502
+ mode: device.mode,
1503
+ kind,
1504
+ command: tool.key === "Bash" ? textField(input, "command") : tool.key,
1505
+ rule: verdict.rule,
1506
+ reason: clipText(verdict.reason, COMMAND_ASK_TEXT_MAX_CHARS),
1507
+ workingRoot: facts.workingRoot,
1508
+ ...(candidate
1509
+ ? {
1510
+ permissionCandidate: candidate,
1511
+ permissionScope: candidate.permissionScope,
1512
+ candidateHash: candidate.candidateHash,
1513
+ ...(candidate.targetPath
1514
+ ? { targetPath: candidate.targetPath, path: candidate.targetPath }
1515
+ : {}),
1516
+ ...(candidate.escalation ? { escalation: candidate.escalation } : {}),
1517
+ }
1518
+ : filePaths.length > 0
1519
+ ? {
1520
+ path: clipText(filePaths.map((p) => pathAgainstWorkingRoot(p, facts.workingRoot)).join(", "), 4096),
1521
+ }
1522
+ : {}),
1523
+ },
1524
+ });
1525
+ return { kind: "wait", wait: approvalWait(ask) };
1526
+ }
1527
+ /**
1528
+ * Whether an execution of this call was admitted outside the sandbox under a restricted profile
1529
+ * (a per-call escalation's full reach): an intent past admission, or one revoked after dispatch.
1530
+ */
1531
+ async admittedOutsideSandbox(runId, callId) {
1532
+ const rows = await this.deps.db
1533
+ .selectFrom("sandbox_operation_intents")
1534
+ .select(["scope", "state", "outcome_unknown"])
1535
+ .where("run_id", "=", runId)
1536
+ .where("call_id", "=", callId)
1537
+ .where("method", "in", ["exec", "backgroundStart"])
1538
+ .execute();
1539
+ return rows.some((r) => {
1540
+ const scope = r.scope;
1541
+ const admitted = r.state === "revoked" ? r.outcome_unknown : r.state !== "pending";
1542
+ return admitted && scope.profile !== "full-access" && scope.filesystem?.kind === "device";
1543
+ });
1544
+ }
1545
+ findPermissionGrant(candidate) {
1546
+ if (!this.permissionGrants)
1547
+ throw new Error("Permission grants are unavailable");
1548
+ return this.permissionGrants.findForAdmission(candidate.binding);
1549
+ }
1550
+ async recordPermissionReview(candidate, verdict) {
1551
+ if (!this.permissionGrants)
1552
+ throw new Error("Permission grants are unavailable");
1553
+ await this.permissionGrants.assertCurrent(candidate.binding);
1554
+ const events = await this.deps.eventLog.appendIn(candidate.binding.conversationId, [
1555
+ {
1556
+ type: "permission_reviewed",
1557
+ runId: candidate.binding.runId,
1558
+ payload: {
1559
+ ...candidate,
1560
+ outcome: verdict.decision,
1561
+ reason: verdict.reason,
1562
+ // the review model only for its own verdict: a fixed rule's deny, a rule ask (the review
1563
+ // model unmapped or not consulted) and the fail-closed ask are the rules'
1564
+ decisionSource: verdict.by === "classifier" ? "review-model" : "rule",
1565
+ },
1566
+ },
1567
+ ]);
1568
+ const event = events[0];
1569
+ if (!event)
1570
+ throw new Error("The review event was not recorded");
1571
+ if (verdict.decision === "allow" && verdict.by === "classifier")
1572
+ await this.permissionGrants.issueLocked(candidate, {
1573
+ source: "review-model",
1574
+ reviewEventSeq: event.seq,
1575
+ decidedBy: null,
1576
+ });
1577
+ }
1578
+ /** The outcome of a call whose `command` approval was already asked (a resume). */
1579
+ settledCommandAsk(ask, toolKey) {
1580
+ const kind = reviewKindOf(toolKey);
1581
+ const rule = ask.command?.rule ?? null;
1582
+ if (ask.status === "pending")
1583
+ return { kind: "wait", wait: approvalWait(ask) };
1584
+ if (ask.status === "approved") {
1585
+ return {
1586
+ kind: "continue",
1587
+ commandAsk: ask,
1588
+ review: this.personAllowRecord(ask),
1589
+ workingRoot: ask.command?.workingRoot,
1590
+ reviewedAgainst: ask.command?.workingRoot,
1591
+ };
1592
+ }
1593
+ if (ask.status === "denied") {
1594
+ const reason = ask.denyReason;
1595
+ return {
1596
+ kind: "result",
1597
+ content: commandDeclinedText(reason, kind),
1598
+ review: denyRecord("person", rule, reason ?? "The user declined."),
1599
+ };
1600
+ }
1601
+ const text = ask.status === "expired" ? approvalExpiredText(approvalHours(ask)) : APPROVAL_CANCELLED_TEXT;
1602
+ return { kind: "result", content: text, review: denyRecord("person", rule, text) };
1603
+ }
1604
+ /**
1605
+ * The review record of a command (or write) the person allowed: its scope, and for a shell
1606
+ * command the SHA-256 of the text the ask holds in full, so an audit can match record and text.
1607
+ */
1608
+ personAllowRecord(ask) {
1609
+ const binding = ask.command?.permissionCandidate?.binding;
1610
+ const escalated = ask.command?.permissionCandidate?.scopeKind === "sandbox-escalation";
1611
+ return {
1612
+ ...(escalated ? { sandbox: "escalated" } : {}),
1613
+ ...(binding
1614
+ ? {
1615
+ profile: binding.profile,
1616
+ profileRevision: binding.profileRevision,
1617
+ scopeRevision: binding.scopeRevision,
1618
+ decisionSource: "human",
1619
+ }
1620
+ : {}),
1621
+ decision: "allow",
1622
+ by: "person",
1623
+ rule: ask.command?.rule ?? null,
1624
+ reason: ask.command?.reason ?? "The user allowed this call.",
1625
+ ...((ask.scope === "once" || ask.scope === "session") && { scope: ask.scope }),
1626
+ ...(ask.command !== null &&
1627
+ ask.command.kind === "command" && {
1628
+ commandHash: sha256Hex(ask.command.command),
1629
+ }),
1630
+ };
1631
+ }
1632
+ /**
1633
+ * A foreground command's refused network hosts (network ask-to-allow spec §6.2, §6.8, §8.3):
1634
+ * the `network_blocked` event, the missing grants of an unattended run, and either notes for the
1635
+ * result written now, or (device-layer hosts worth asking) `network_blocked` and the call's
1636
+ * `tool.called` audit written now, the result kept in a network ask to the device's owner and
1637
+ * the run's wait. The kept result is the formatted one (≤ 16 KB: larger output is archived)
1638
+ * followed by the notes written now; it is written with the decision's note when the ask
1639
+ * settles (P-D2).
1640
+ */
1641
+ async networkBlocked(ctx, callId, toolKey, input, report, pre, callAudit, result) {
1642
+ const hosts = blockedEventHosts(report.blocked);
1643
+ if (hosts.length === 0)
1644
+ return { kind: "write", event: null, notes: [] };
1645
+ const event = {
1646
+ type: "network_blocked",
1647
+ runId: ctx.runId,
1648
+ idemKey: networkBlockedIdemKey(ctx.runId, callId),
1649
+ payload: { step: ctx.step, callId, hosts },
1650
+ };
1651
+ const network = this.deps.network;
1652
+ if (network === undefined)
1653
+ return { kind: "write", event, notes: [] };
1654
+ const device = await network.devices.summary(report.deviceId);
1655
+ const run = hosts.some((h) => h.layer === "device")
1656
+ ? await network.grants.runState(ctx.runId, report.deviceId)
1657
+ : null;
1658
+ const limits = this.config.get().sandbox.limits;
1659
+ const plan = planNetworkAsk(hosts, run, {
1660
+ device,
1661
+ unattended: ctx.unattended,
1662
+ outsideCeiling: (h) => orgHostOutsideCeiling(limits, h),
1663
+ });
1664
+ if (ctx.unattended != null) {
1665
+ for (const key of plan.missingGrants) {
1666
+ await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, key);
1667
+ }
1668
+ }
1669
+ if (plan.ask.length === 0)
1670
+ return { kind: "write", event, notes: plan.notes };
1671
+ // the device's owner is the only person who may decide (spec §5.2)
1672
+ const owner = await this.deps.db
1673
+ .selectFrom("devices")
1674
+ .select("owner_account_id")
1675
+ .where("id", "=", report.deviceId)
1676
+ .where("org_id", "=", ctx.orgId)
1677
+ .where("deleted_at", "is", null)
1678
+ .executeTakeFirst();
1679
+ if (owner === undefined)
1680
+ return { kind: "write", event, notes: plan.notes };
1681
+ let { content, outputId } = result;
1682
+ if (Buffer.byteLength(content, "utf8") > NETWORK_ASK_KEPT_MAX_BYTES && outputId === undefined) {
1683
+ // output under the spill threshold but over what an ask keeps: archive it after all
1684
+ const spilled = await spillIfLarge(result.text, { spillChars: 0, previewChars: this.config.get().tools.outputPreviewChars }, (c) => this.deps.outputs.save({
1685
+ orgId: ctx.orgId,
1686
+ conversationId: ctx.conversationId,
1687
+ callId,
1688
+ content: c,
1689
+ }));
1690
+ content = spilled.content;
1691
+ outputId = spilled.outputId;
1692
+ }
1693
+ const { text: _text, ...rest } = result;
1694
+ const kept = {
1695
+ ...rest,
1696
+ content: withNetworkNotes(clipKept(content), plan.notes),
1697
+ ...(outputId !== undefined && { outputId }),
1698
+ };
1699
+ // the command ran: the call's display-only events (a `device_code`) and network_blocked with
1700
+ // its tool.called now, the result once the ask settles
1701
+ const written = await this.writeResultIn(ctx, callId, toolKey, { isError: result.isError }, [...pre, event], callAudit, []);
1702
+ await this.deps.eventLog.notify(ctx.conversationId, Math.max(...written.map((e) => e.seq)));
1703
+ const given = (input ?? {});
1704
+ const ask = await this.deps.approvals.requestNetwork({
1705
+ orgId: ctx.orgId,
1706
+ conversationId: ctx.conversationId,
1707
+ runId: ctx.runId,
1708
+ step: ctx.step,
1709
+ callId,
1710
+ requestedFor: owner.owner_account_id,
1711
+ detail: {
1712
+ deviceId: report.deviceId,
1713
+ hosts: plan.ask,
1714
+ command: typeof given.command === "string" ? clipText(given.command, 2000) : "",
1715
+ description: typeof given.description === "string" ? given.description : null,
1716
+ result: kept,
1717
+ },
1718
+ scopes: plan.scopes,
1719
+ });
1720
+ return { kind: "wait", wait: approvalWait(ask), content: kept.content };
1721
+ }
666
1722
  /** Appends a sub-agent's connect card to its root conversation ({@link rootSurfaceOf}). */
667
1723
  async surfaceConnectInRoot(ctx, parent, callId, toolKey) {
668
1724
  const target = await rootSurfaceOf(this.deps.db, ctx.conversationId, ctx.runId, parent);
@@ -683,28 +1739,15 @@ let ToolPipeline = class ToolPipeline {
683
1739
  },
684
1740
  ]);
685
1741
  }
686
- /**
687
- * Every tool key the request that issued this step's calls offered (`request.tools` plus the
688
- * `catalog` keys), in any mode; null when its model_call is not found. Used to tell a call to an
689
- * old key that was offered (in flight across the rename) from one that never was.
690
- */
691
- async requestToolKeys(ctx) {
692
- for (let attempt = MAX_MODEL_ATTEMPTS; attempt >= 1; attempt--) {
693
- const e = await this.deps.eventLog.findByIdem(ctx.conversationId, modelCallIdemKey(ctx.runId, ctx.step, attempt));
694
- if (e?.type !== "model_call")
695
- continue;
696
- const { tools, catalog } = e.payload.request;
697
- return new Set([...(tools ?? []), ...(catalog ?? [])].map((t) => t.key));
698
- }
699
- return null;
700
- }
701
1742
  /**
702
1743
  * 发出本步调用的请求里带了完整定义的工具 key:本步最后一次尝试的 `model_call.request.tools`
703
1744
  * (`assistant_message` 来自最后一次尝试)。该请求不在 ToolSearch 模式(没有 `catalog`,工具全部发送)
704
1745
  * 或找不到 model_call 时返回 null(不做加载检查)。已加载集合由此从日志得出,不放进程内存。
705
1746
  */
706
1747
  async sentTools(ctx) {
707
- for (let attempt = MAX_MODEL_ATTEMPTS; attempt >= 1; attempt--) {
1748
+ // attempts can reach MAX_STEP_MODEL_CALLS after reactive overflow fix-ups; the assistant_message
1749
+ // comes from the last attempt, so scan from the top
1750
+ for (let attempt = MAX_STEP_MODEL_CALLS; attempt >= 1; attempt--) {
708
1751
  const e = await this.deps.eventLog.findByIdem(ctx.conversationId, modelCallIdemKey(ctx.runId, ctx.step, attempt));
709
1752
  if (e?.type !== "model_call")
710
1753
  continue;
@@ -767,7 +1810,9 @@ let ToolPipeline = class ToolPipeline {
767
1810
  * 带 `tools.timeoutMs` 超时与 run 的中止信号(合并后传给处理函数 / 连接器,不响应信号的也按时结束)。
768
1811
  * 熔断只作用于连接器工具(键为组织 × 连接器)。
769
1812
  */
770
- async execute(tool, input, ctx, callId, resume, stepTools) {
1813
+ async execute(tool, input, ctx, callId, resume, stepTools, reviewed) {
1814
+ const reviewedWorkingRoot = reviewed?.workingRoot;
1815
+ const reviewedAgainstRoot = reviewed?.against;
771
1816
  if (tool.source.kind === "connector") {
772
1817
  return this.executeConnector(tool, tool.source, input, ctx, resume);
773
1818
  }
@@ -782,10 +1827,25 @@ let ToolPipeline = class ToolPipeline {
782
1827
  conversationId: ctx.conversationId,
783
1828
  callId,
784
1829
  ...(resume !== undefined && { resume }),
1830
+ // who and where (memory plugin spec §6.2): `accountId` stays the trigger account
1831
+ source: ctx.source,
1832
+ ownerAccountId: ctx.ownerAccountId,
1833
+ role: ctx.role,
785
1834
  ...(tool.source.kind === "builtin" && stepTools !== undefined && { tools: stepTools }),
786
- ...(tool.source.kind === "builtin" && { runId: ctx.runId }),
1835
+ ...(tool.source.kind === "builtin" && {
1836
+ runId: ctx.runId,
1837
+ executionClaim: currentExecutionClaim(),
1838
+ }),
787
1839
  ...(tool.source.kind === "builtin" &&
788
1840
  ctx.deadline !== undefined && { runDeadline: ctx.deadline }),
1841
+ // a reviewed call runs in the working root its review judged (project root spec §4.3)
1842
+ ...(tool.source.kind === "builtin" &&
1843
+ reviewedWorkingRoot !== undefined && { reviewedWorkingRoot }),
1844
+ // and the root it was judged against, workspace included (B-18, the managed route)
1845
+ ...(tool.source.kind === "builtin" &&
1846
+ reviewedAgainstRoot !== undefined && { reviewedAgainstRoot }),
1847
+ ...(tool.source.kind === "builtin" &&
1848
+ reviewed?.escalation !== undefined && { sandboxEscalation: reviewed.escalation }),
789
1849
  // a sub-agent works in its root conversation's sandbox (spec §10.1, at every depth)
790
1850
  ...(tool.source.kind === "builtin" &&
791
1851
  ctx.parent !== undefined && { sandboxConversationId: ctx.parent.rootConversationId }),
@@ -827,7 +1887,11 @@ let ToolPipeline = class ToolPipeline {
827
1887
  }
828
1888
  config = { config: effective.config };
829
1889
  }
830
- const r = await this.bounded(ctx.signal, (signal) => handler(input, { ...base, ...config, signal }), undefined, timeoutMs);
1890
+ const r = await this.bounded(ctx.signal, async (signal) => {
1891
+ await this.txHost.run(async () => { });
1892
+ signal.throwIfAborted();
1893
+ return handler(input, { ...base, ...config, signal });
1894
+ }, undefined, timeoutMs);
831
1895
  if (r === "timeout") {
832
1896
  return { kind: "error", message: timeoutText(tool.key, timeoutMs) };
833
1897
  }
@@ -848,7 +1912,7 @@ let ToolPipeline = class ToolPipeline {
848
1912
  const connectorId = source.connectorId;
849
1913
  const app = await db
850
1914
  .selectFrom("connectors")
851
- .select(["name", "connector", "endpoint", "auth", "status"])
1915
+ .select(["name", "slug", "connector", "endpoint", "auth", "status"])
852
1916
  .where("id", "=", connectorId)
853
1917
  .where("org_id", "=", orgId)
854
1918
  .where("deleted_at", "is", null)
@@ -884,10 +1948,13 @@ let ToolPipeline = class ToolPipeline {
884
1948
  // 远端在调用途中向用户要输入(MCP elicitation,见 elicitation.ts):需要问用户时中止本次调用、按 input_required
885
1949
  // 处理;续跑时用 ctx.resume 的答案答复远端再次发起的同一请求。resources 工具不续跑,一律拒绝。
886
1950
  const suspend = new AbortController();
1951
+ // an unattended run in `fail` mode declines every elicitation: no one is there to answer
1952
+ const unattended = unattendedFails(ctx.unattended);
887
1953
  const elicit = new ElicitationSession({
888
1954
  resume,
889
1955
  onSuspend: () => suspend.abort(),
890
- declineAll: source.resources === true,
1956
+ declineAll: source.resources === true || unattended,
1957
+ ...(unattended && { declineNote: UNATTENDED_ELICITATION_NOTE }),
891
1958
  });
892
1959
  // 远端可能把收到的凭据回显在结果 / 错误 / elicitation 表单里:写入事件之前按本次注入的值打码(见 redact.ts)
893
1960
  const clean = (o) => {
@@ -923,6 +1990,7 @@ let ToolPipeline = class ToolPipeline {
923
1990
  kind: "connection_required",
924
1991
  connectorId,
925
1992
  connectorName: app.name,
1993
+ connectorSlug: app.slug,
926
1994
  message: personalMissingText(app.name),
927
1995
  }
928
1996
  : { kind: "error", message: orgMissingText(app.name) };
@@ -953,6 +2021,7 @@ let ToolPipeline = class ToolPipeline {
953
2021
  await credentials.onUnauthorized(orgId, connectorId, auth, ctx.accountId, stale);
954
2022
  },
955
2023
  signal,
2024
+ orgId,
956
2025
  onElicit: elicit.handle,
957
2026
  onToolsChanged: () => {
958
2027
  try {
@@ -968,6 +2037,8 @@ let ToolPipeline = class ToolPipeline {
968
2037
  },
969
2038
  });
970
2039
  const session = await opened;
2040
+ await this.txHost.run(async () => { });
2041
+ signal.throwIfAborted();
971
2042
  return source.resources
972
2043
  ? runResourceTool(session, source.name, input)
973
2044
  : // 交回已复核的定义(connector_tools.spec,含 connectorData):连接器按它路由,远端变化须先经漂移复核
@@ -1012,6 +2083,11 @@ let ToolPipeline = class ToolPipeline {
1012
2083
  thrown(key, e) {
1013
2084
  if (e instanceof ToolError)
1014
2085
  return { kind: "error", message: e.message };
2086
+ // an extension tool's ctx.models.embed denied by a policy hook (spec B §5.4): the model sees the
2087
+ // deny text (sanitized reason), as for a denied tool call, not a generic failure
2088
+ if (e instanceof ApiError && e.code === "model.hook_denied") {
2089
+ return { kind: "error", message: e.message };
2090
+ }
1015
2091
  // 提供工具的插件实例在调用进行中被撤销(停用 / 升级),排空时限到后中止(C17)
1016
2092
  if (e instanceof ExtensionUnloadedError) {
1017
2093
  this.deps.log.warn("tool call aborted: plugin unloaded", { toolKey: key, plugin: e.plugin });
@@ -1185,6 +2261,12 @@ let ToolPipeline = class ToolPipeline {
1185
2261
  __decorate([
1186
2262
  Transactional({ propagation: "mandatory" })
1187
2263
  ], ToolPipeline.prototype, "stopOpenAgentCalls", null);
2264
+ __decorate([
2265
+ Transactional()
2266
+ ], ToolPipeline.prototype, "findPermissionGrant", null);
2267
+ __decorate([
2268
+ Transactional()
2269
+ ], ToolPipeline.prototype, "recordPermissionReview", null);
1188
2270
  __decorate([
1189
2271
  Transactional()
1190
2272
  ], ToolPipeline.prototype, "writeResultIn", null);
@@ -1208,6 +2290,24 @@ ToolPipeline = __decorate([
1208
2290
  __param(15, Inject(OrgToolSwitches)),
1209
2291
  __param(16, Inject(TransactionHost)),
1210
2292
  __param(17, Optional()),
1211
- __param(17, Inject(TOOL_PIPELINE_HOOKS))
2293
+ __param(17, Inject(TOOL_PIPELINE_HOOKS)),
2294
+ __param(18, Optional()),
2295
+ __param(18, Inject(NetworkGrants)),
2296
+ __param(19, Optional()),
2297
+ __param(19, Inject(DevicePolicyService)),
2298
+ __param(20, Optional()),
2299
+ __param(20, Inject(CommandReviewService)),
2300
+ __param(21, Optional()),
2301
+ __param(21, Inject(ConversationDevices)),
2302
+ __param(22, Optional()),
2303
+ __param(22, Inject(SandboxOperationAuthority)),
2304
+ __param(23, Optional()),
2305
+ __param(23, Inject(PermissionCallGrants)),
2306
+ __param(24, Optional()),
2307
+ __param(24, Inject(PermissionAuthorityLock)),
2308
+ __param(25, Optional()),
2309
+ __param(25, Inject(PERMISSION_CONTEXT_ACTIVATION)),
2310
+ __param(26, Optional()),
2311
+ __param(26, Inject(SandboxService))
1212
2312
  ], ToolPipeline);
1213
2313
  export { ToolPipeline };