@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.8

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 (333) hide show
  1. package/bootstrap.json +27 -3
  2. package/dist/admin/admin.controller.d.ts +8 -72
  3. package/dist/admin/admin.controller.js +21 -46
  4. package/dist/admin/admin.schemas.d.ts +57 -0
  5. package/dist/admin/admin.schemas.js +50 -0
  6. package/dist/admin/extensions.controller.d.ts +10 -0
  7. package/dist/admin/extensions.controller.js +18 -0
  8. package/dist/admin/extensions.schemas.d.ts +7 -0
  9. package/dist/admin/extensions.schemas.js +10 -0
  10. package/dist/admin/limit-defaults.d.ts +20 -0
  11. package/dist/admin/limit-defaults.js +10 -0
  12. package/dist/agents/agent-profile.service.d.ts +7 -5
  13. package/dist/agents/agent-profile.service.js +14 -9
  14. package/dist/agents/agents.controller.d.ts +7 -287
  15. package/dist/agents/agents.controller.js +7 -67
  16. package/dist/agents/agents.schemas.d.ts +389 -0
  17. package/dist/agents/agents.schemas.js +126 -0
  18. package/dist/agents/agents.service.d.ts +13 -5
  19. package/dist/agents/agents.service.js +67 -13
  20. package/dist/agents/definition.d.ts +47 -19
  21. package/dist/agents/definition.js +119 -38
  22. package/dist/agents/from-template.d.ts +2 -2
  23. package/dist/agents/from-template.js +76 -45
  24. package/dist/agents/from-template.service.d.ts +12 -0
  25. package/dist/agents/from-template.service.js +20 -3
  26. package/dist/agents/models.controller.d.ts +1 -2
  27. package/dist/agents/models.controller.js +1 -1
  28. package/dist/agents/org-templates.d.ts +13 -3
  29. package/dist/agents/org-templates.js +69 -28
  30. package/dist/agents/pending-connector-requests.d.ts +2 -0
  31. package/dist/agents/pending-connector-requests.js +1 -1
  32. package/dist/agents/pending-connectors.controller.d.ts +1 -1
  33. package/dist/agents/pending-connectors.controller.js +2 -2
  34. package/dist/agents/pending-connectors.service.d.ts +2 -2
  35. package/dist/agents/pending-connectors.service.js +19 -19
  36. package/dist/agents/profile.d.ts +18 -0
  37. package/dist/agents/profile.js +5 -1
  38. package/dist/agents/templates.controller.d.ts +8 -17
  39. package/dist/agents/templates.controller.js +13 -31
  40. package/dist/agents/templates.schemas.d.ts +20 -0
  41. package/dist/agents/templates.schemas.js +45 -0
  42. package/dist/background/background.controller.js +3 -2
  43. package/dist/background/background.schemas.d.ts +10 -0
  44. package/dist/background/background.schemas.js +16 -0
  45. package/dist/background/tasks.service.d.ts +1 -1
  46. package/dist/background/tasks.service.js +7 -2
  47. package/dist/catalog/admin-catalog.controller.d.ts +4 -57
  48. package/dist/catalog/admin-catalog.controller.js +8 -45
  49. package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
  50. package/dist/catalog/admin-catalog.schemas.js +92 -0
  51. package/dist/catalog/catalog-content.d.ts +12 -2
  52. package/dist/catalog/catalog-scope.service.js +8 -2
  53. package/dist/catalog/catalog.service.d.ts +2 -0
  54. package/dist/catalog/catalog.service.js +3 -0
  55. package/dist/catalog/component-scope.controller.d.ts +3 -65
  56. package/dist/catalog/component-scope.controller.js +3 -56
  57. package/dist/catalog/component-scope.schemas.d.ts +114 -0
  58. package/dist/catalog/component-scope.schemas.js +97 -0
  59. package/dist/catalog/component-scope.service.d.ts +28 -4
  60. package/dist/catalog/component-scope.service.js +55 -3
  61. package/dist/catalog/component-state.d.ts +9 -2
  62. package/dist/catalog/component-state.js +22 -13
  63. package/dist/catalog/marketplaces.controller.d.ts +5 -35
  64. package/dist/catalog/marketplaces.controller.js +6 -34
  65. package/dist/catalog/marketplaces.schemas.d.ts +48 -0
  66. package/dist/catalog/marketplaces.schemas.js +53 -0
  67. package/dist/catalog/marketplaces.service.d.ts +15 -1
  68. package/dist/catalog/marketplaces.service.js +22 -1
  69. package/dist/catalog/org-catalog.controller.d.ts +6 -62
  70. package/dist/catalog/org-catalog.controller.js +12 -66
  71. package/dist/catalog/org-catalog.schemas.d.ts +79 -0
  72. package/dist/catalog/org-catalog.schemas.js +82 -0
  73. package/dist/catalog/org-catalog.service.d.ts +9 -2
  74. package/dist/catalog/org-catalog.service.js +38 -5
  75. package/dist/catalog/org-extension.controller.d.ts +1 -12
  76. package/dist/catalog/org-extension.controller.js +1 -10
  77. package/dist/catalog/org-extension.schemas.d.ts +15 -0
  78. package/dist/catalog/org-extension.schemas.js +22 -0
  79. package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
  80. package/dist/catalog/org-plugin-uploads.controller.js +15 -28
  81. package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
  82. package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
  83. package/dist/catalog/owned-items.d.ts +6 -2
  84. package/dist/catalog/owned-items.js +16 -4
  85. package/dist/catalog/platform-components.d.ts +2 -0
  86. package/dist/catalog/platform-components.js +2 -0
  87. package/dist/catalog/plugin-import.js +1 -0
  88. package/dist/catalog/plugin-install.js +1 -1
  89. package/dist/catalog/requests.service.d.ts +2 -1
  90. package/dist/catalog/requests.service.js +6 -2
  91. package/dist/channels/channels.schemas.d.ts +33 -0
  92. package/dist/channels/channels.schemas.js +34 -0
  93. package/dist/channels/connections.controller.d.ts +2 -29
  94. package/dist/channels/connections.controller.js +1 -23
  95. package/dist/channels/connections.service.d.ts +8 -2
  96. package/dist/channels/connections.service.js +23 -5
  97. package/dist/channels/inbound.js +4 -0
  98. package/dist/conversations/conversations.controller.d.ts +16 -37
  99. package/dist/conversations/conversations.controller.js +16 -56
  100. package/dist/conversations/conversations.schemas.d.ts +52 -0
  101. package/dist/conversations/conversations.schemas.js +79 -0
  102. package/dist/conversations/conversations.service.d.ts +9 -1
  103. package/dist/conversations/conversations.service.js +23 -18
  104. package/dist/conversations/events.d.ts +80 -6
  105. package/dist/conversations/events.js +60 -5
  106. package/dist/conversations/message-context.d.ts +28 -0
  107. package/dist/conversations/message-context.js +56 -0
  108. package/dist/conversations/queue.d.ts +2 -1
  109. package/dist/conversations/queue.js +11 -2
  110. package/dist/db/kernel-schema.d.ts +20 -0
  111. package/dist/environments/environments.schemas.d.ts +3 -0
  112. package/dist/environments/environments.schemas.js +14 -0
  113. package/dist/environments/environments.service.d.ts +16 -4
  114. package/dist/environments/environments.service.js +58 -13
  115. package/dist/errors.d.ts +3 -0
  116. package/dist/errors.js +3 -0
  117. package/dist/evals/evals.schemas.d.ts +110 -0
  118. package/dist/evals/evals.schemas.js +107 -0
  119. package/dist/evals/reconstruct.js +18 -11
  120. package/dist/evals/recorded-tools.d.ts +2 -1
  121. package/dist/evals/recorded-tools.js +11 -3
  122. package/dist/evals/run-replay.d.ts +8 -1
  123. package/dist/evals/run-replay.js +13 -0
  124. package/dist/evals/runs.controller.d.ts +2 -57
  125. package/dist/evals/runs.controller.js +1 -42
  126. package/dist/evals/runs.service.d.ts +6 -6
  127. package/dist/evals/runs.service.js +32 -18
  128. package/dist/evals/sets.controller.d.ts +2 -28
  129. package/dist/evals/sets.controller.js +1 -31
  130. package/dist/evals/sets.service.d.ts +7 -7
  131. package/dist/evals/sets.service.js +23 -17
  132. package/dist/evals/snapshot.d.ts +3 -2
  133. package/dist/evals/snapshot.js +17 -4
  134. package/dist/extensions/admin-ops.d.ts +5 -3
  135. package/dist/extensions/admin-ops.js +17 -12
  136. package/dist/extensions/deployment-config.d.ts +16 -1
  137. package/dist/extensions/deployment-config.js +83 -0
  138. package/dist/extensions/extensions.module.js +3 -0
  139. package/dist/extensions/host.d.ts +33 -2
  140. package/dist/extensions/host.js +107 -1
  141. package/dist/extensions/installs.d.ts +5 -0
  142. package/dist/extensions/installs.js +12 -0
  143. package/dist/extensions/org-config.d.ts +17 -2
  144. package/dist/extensions/org-config.js +23 -4
  145. package/dist/extensions/point-defaults.controller.d.ts +2 -8
  146. package/dist/extensions/point-defaults.controller.js +1 -3
  147. package/dist/extensions/point-defaults.d.ts +3 -1
  148. package/dist/extensions/point-defaults.js +4 -2
  149. package/dist/extensions/point-defaults.schemas.d.ts +9 -0
  150. package/dist/extensions/point-defaults.schemas.js +14 -0
  151. package/dist/extensions/unavailable.d.ts +49 -0
  152. package/dist/extensions/unavailable.js +113 -0
  153. package/dist/files/previewers.controller.js +2 -3
  154. package/dist/files/previewers.d.ts +1 -1
  155. package/dist/files/previewers.js +4 -4
  156. package/dist/files/previewers.schemas.d.ts +10 -0
  157. package/dist/files/previewers.schemas.js +9 -0
  158. package/dist/http/api.module.js +2 -0
  159. package/dist/identity/accounts.d.ts +43 -4
  160. package/dist/identity/accounts.js +74 -6
  161. package/dist/identity/auth.guard.js +10 -1
  162. package/dist/identity/cookies.d.ts +6 -0
  163. package/dist/identity/cookies.js +14 -0
  164. package/dist/identity/identity.module.js +3 -0
  165. package/dist/identity/initial-passwords.controller.d.ts +22 -0
  166. package/dist/identity/initial-passwords.controller.js +49 -0
  167. package/dist/identity/initial-passwords.d.ts +61 -0
  168. package/dist/identity/initial-passwords.job.d.ts +16 -0
  169. package/dist/identity/initial-passwords.job.js +46 -0
  170. package/dist/identity/initial-passwords.js +159 -0
  171. package/dist/identity/me.controller.d.ts +12 -0
  172. package/dist/identity/me.controller.js +31 -1
  173. package/dist/identity/me.schemas.d.ts +14 -0
  174. package/dist/identity/me.schemas.js +17 -0
  175. package/dist/identity/principal.d.ts +8 -0
  176. package/dist/identity/principal.js +8 -0
  177. package/dist/identity/settings.d.ts +3 -1
  178. package/dist/identity/settings.js +6 -4
  179. package/dist/inbox/inbox.schemas.d.ts +8 -0
  180. package/dist/inbox/inbox.schemas.js +11 -0
  181. package/dist/inbox/platform-inbox.controller.d.ts +1 -1
  182. package/dist/inbox/platform-inbox.controller.js +2 -2
  183. package/dist/index.d.ts +4 -0
  184. package/dist/index.js +6 -0
  185. package/dist/lifecycle/kernel-lifecycle.js +4 -0
  186. package/dist/models/enablement.d.ts +2 -0
  187. package/dist/models/enablement.js +1 -0
  188. package/dist/models/org-models.schemas.d.ts +8 -0
  189. package/dist/models/org-models.schemas.js +22 -0
  190. package/dist/models/prices.d.ts +3 -1
  191. package/dist/models/prices.js +7 -5
  192. package/dist/models/purposes.d.ts +12 -2
  193. package/dist/models/purposes.js +22 -8
  194. package/dist/orgs/orgs.controller.d.ts +2 -5
  195. package/dist/orgs/orgs.controller.js +3 -6
  196. package/dist/orgs/orgs.schemas.d.ts +8 -0
  197. package/dist/orgs/orgs.schemas.js +16 -0
  198. package/dist/orgs/orgs.service.d.ts +3 -1
  199. package/dist/orgs/orgs.service.js +6 -4
  200. package/dist/orgs/settings.service.d.ts +9 -1
  201. package/dist/orgs/settings.service.js +20 -5
  202. package/dist/overrides.d.ts +4 -0
  203. package/dist/overrides.js +2 -0
  204. package/dist/platform/errors.d.ts +21 -4
  205. package/dist/platform/errors.js +45 -6
  206. package/dist/platform/exclusions.d.ts +2 -3
  207. package/dist/platform/exclusions.js +58 -849
  208. package/dist/platform/method.js +1 -1
  209. package/dist/platform/operation.d.ts +82 -5
  210. package/dist/platform/operation.js +63 -8
  211. package/dist/platform/ops/accounts.ops.d.ts +32 -0
  212. package/dist/platform/ops/accounts.ops.js +291 -0
  213. package/dist/platform/ops/admin.ops.d.ts +36 -0
  214. package/dist/platform/ops/admin.ops.js +389 -0
  215. package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
  216. package/dist/platform/ops/agent-skills.ops.js +226 -0
  217. package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
  218. package/dist/platform/ops/agent-templates.ops.js +194 -14
  219. package/dist/platform/ops/agents.ops.d.ts +19 -1
  220. package/dist/platform/ops/agents.ops.js +481 -58
  221. package/dist/platform/ops/approvals.ops.d.ts +30 -0
  222. package/dist/platform/ops/approvals.ops.js +116 -0
  223. package/dist/platform/ops/background.ops.d.ts +14 -0
  224. package/dist/platform/ops/background.ops.js +134 -0
  225. package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
  226. package/dist/platform/ops/catalog-admin.ops.js +587 -0
  227. package/dist/platform/ops/channels.ops.d.ts +16 -0
  228. package/dist/platform/ops/channels.ops.js +195 -0
  229. package/dist/platform/ops/components.ops.d.ts +46 -0
  230. package/dist/platform/ops/components.ops.js +853 -0
  231. package/dist/platform/ops/connectors.ops.d.ts +4 -2
  232. package/dist/platform/ops/connectors.ops.js +68 -6
  233. package/dist/platform/ops/conversations.ops.d.ts +30 -0
  234. package/dist/platform/ops/conversations.ops.js +470 -0
  235. package/dist/platform/ops/environments.ops.d.ts +26 -0
  236. package/dist/platform/ops/environments.ops.js +289 -0
  237. package/dist/platform/ops/errors.d.ts +10 -5
  238. package/dist/platform/ops/errors.js +19 -11
  239. package/dist/platform/ops/evals.ops.d.ts +28 -0
  240. package/dist/platform/ops/evals.ops.js +783 -0
  241. package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
  242. package/dist/platform/ops/extensions-admin.ops.js +344 -0
  243. package/dist/platform/ops/extensions.ops.d.ts +7 -1
  244. package/dist/platform/ops/extensions.ops.js +248 -17
  245. package/dist/platform/ops/inbox.ops.d.ts +25 -0
  246. package/dist/platform/ops/inbox.ops.js +378 -0
  247. package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
  248. package/dist/platform/ops/marketplaces.ops.js +326 -17
  249. package/dist/platform/ops/models.ops.d.ts +25 -0
  250. package/dist/platform/ops/models.ops.js +232 -0
  251. package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
  252. package/dist/platform/ops/org-plugins.ops.js +329 -0
  253. package/dist/platform/ops/org-settings.ops.d.ts +16 -0
  254. package/dist/platform/ops/org-settings.ops.js +102 -0
  255. package/dist/platform/ops/orgs.ops.d.ts +28 -0
  256. package/dist/platform/ops/orgs.ops.js +295 -0
  257. package/dist/platform/ops/other-orgs.d.ts +20 -0
  258. package/dist/platform/ops/other-orgs.js +72 -0
  259. package/dist/platform/ops/platform.ops.d.ts +11 -6
  260. package/dist/platform/ops/platform.ops.js +73 -27
  261. package/dist/platform/ops/plugins.ops.d.ts +10 -8
  262. package/dist/platform/ops/plugins.ops.js +176 -77
  263. package/dist/platform/ops/previewers.ops.d.ts +14 -0
  264. package/dist/platform/ops/previewers.ops.js +109 -0
  265. package/dist/platform/ops/requests.ops.js +57 -19
  266. package/dist/platform/ops/skills.ops.d.ts +5 -1
  267. package/dist/platform/ops/skills.ops.js +129 -11
  268. package/dist/platform/ops/unavailable.d.ts +23 -0
  269. package/dist/platform/ops/unavailable.js +111 -0
  270. package/dist/platform/parity.d.ts +33 -0
  271. package/dist/platform/parity.js +272 -0
  272. package/dist/platform/platform-ops.module.d.ts +32 -0
  273. package/dist/platform/platform-ops.module.js +78 -11
  274. package/dist/platform/route-schemas.d.ts +18 -0
  275. package/dist/platform/route-schemas.js +63 -0
  276. package/dist/roles/worker.module.js +2 -0
  277. package/dist/runtime/context/build.d.ts +2 -0
  278. package/dist/runtime/context/build.js +28 -2
  279. package/dist/runtime/context/compaction.js +10 -1
  280. package/dist/runtime/context/run-context.d.ts +65 -0
  281. package/dist/runtime/context/run-context.js +215 -0
  282. package/dist/runtime/model-call.js +2 -1
  283. package/dist/runtime/providers.js +8 -1
  284. package/dist/runtime/run-context.service.d.ts +65 -0
  285. package/dist/runtime/run-context.service.js +220 -0
  286. package/dist/runtime/run-worker.d.ts +5 -0
  287. package/dist/runtime/run-worker.js +31 -6
  288. package/dist/runtime/runtime.module.js +2 -0
  289. package/dist/runtime/subagents/definition.d.ts +15 -15
  290. package/dist/runtime/subagents/definition.js +46 -115
  291. package/dist/skills/changes.controller.js +2 -1
  292. package/dist/skills/changes.service.d.ts +1 -1
  293. package/dist/skills/changes.service.js +4 -4
  294. package/dist/skills/invocable.controller.d.ts +1 -1
  295. package/dist/skills/invocable.controller.js +2 -2
  296. package/dist/skills/invoke.d.ts +2 -2
  297. package/dist/skills/invoke.js +8 -1
  298. package/dist/skills/skills.controller.d.ts +4 -13
  299. package/dist/skills/skills.controller.js +8 -24
  300. package/dist/skills/skills.schemas.d.ts +48 -0
  301. package/dist/skills/skills.schemas.js +61 -0
  302. package/dist/skills/skills.service.d.ts +11 -1
  303. package/dist/skills/skills.service.js +37 -14
  304. package/dist/time-zone.d.ts +5 -0
  305. package/dist/time-zone.js +19 -0
  306. package/dist/tools/approvals.controller.js +2 -3
  307. package/dist/tools/approvals.schemas.d.ts +21 -0
  308. package/dist/tools/approvals.schemas.js +15 -0
  309. package/dist/tools/builtin-names.d.ts +10 -8
  310. package/dist/tools/builtin-names.js +16 -11
  311. package/dist/tools/builtins/builtin-tools.d.ts +3 -1
  312. package/dist/tools/builtins/builtin-tools.js +15 -3
  313. package/dist/tools/builtins/current-time.d.ts +26 -0
  314. package/dist/tools/builtins/current-time.js +99 -0
  315. package/dist/tools/builtins/platform.d.ts +19 -2
  316. package/dist/tools/builtins/platform.js +105 -16
  317. package/dist/tools/connectors.controller.d.ts +1 -2
  318. package/dist/tools/connectors.controller.js +1 -4
  319. package/dist/tools/connectors.schemas.d.ts +12 -0
  320. package/dist/tools/connectors.schemas.js +19 -0
  321. package/dist/tools/connectors.service.d.ts +5 -2
  322. package/dist/tools/connectors.service.js +7 -5
  323. package/dist/tools/org-tool-switches.d.ts +16 -2
  324. package/dist/tools/org-tool-switches.js +26 -9
  325. package/dist/tools/pipeline.js +3 -1
  326. package/dist/tools/registry.d.ts +48 -51
  327. package/dist/tools/registry.js +222 -233
  328. package/package.json +3 -3
  329. package/src/migrations/0090_initial_passwords.sql +27 -0
  330. package/src/migrations/0091_account_time_zone.sql +4 -0
  331. package/src/migrations/0092_tools_default_on.sql +27 -0
  332. package/dist/platform/redact-orgs.d.ts +0 -7
  333. package/dist/platform/redact-orgs.js +0 -52
@@ -0,0 +1,272 @@
1
+ import { z } from "zod";
2
+ /** `:orgId` is the conversation's org: never an operation field, so never compared. */
3
+ const IMPLICIT = new Set(["orgId"]);
4
+ /** Bounds an operation may tighten but never loosen: the upper ones, then the lower ones. */
5
+ const UPPER = ["maxLength", "maximum", "exclusiveMaximum", "maxItems", "maxProperties"];
6
+ const LOWER = ["minLength", "minimum", "exclusiveMinimum", "minItems", "minProperties"];
7
+ const toJson = (s) => z.toJSONSchema(s, { io: "input", unrepresentable: "any" });
8
+ /** A schema's alternatives: the branches of `anyOf` / `oneOf` (flattened), else itself. */
9
+ function alternatives(s) {
10
+ const branches = (s.anyOf ?? s.oneOf);
11
+ return branches ? branches.flatMap(alternatives) : [s];
12
+ }
13
+ const propsOf = (s) => s.properties;
14
+ const requiredOf = (s) => new Set((s.required ?? []));
15
+ /**
16
+ * The top-level fields of an object schema; of a union, each branch's fields (a field that
17
+ * differs between branches is the `anyOf` of its branch schemas, required only when every
18
+ * branch requires it).
19
+ */
20
+ function fieldsOf(s) {
21
+ const branches = alternatives(s);
22
+ const out = new Map();
23
+ for (const branch of branches) {
24
+ const req = requiredOf(branch);
25
+ for (const [k, v] of Object.entries(propsOf(branch) ?? {})) {
26
+ const f = out.get(k) ?? { schemas: [], requiredIn: 0 };
27
+ f.schemas.push(v);
28
+ if (req.has(k))
29
+ f.requiredIn += 1;
30
+ out.set(k, f);
31
+ }
32
+ }
33
+ return new Map([...out].map(([k, f]) => {
34
+ const distinct = [...new Map(f.schemas.map((v) => [JSON.stringify(v), v])).values()];
35
+ const schema = distinct.length === 1 ? distinct[0] : { anyOf: distinct };
36
+ return [k, { schema, required: f.requiredIn === branches.length }];
37
+ }));
38
+ }
39
+ /** The route field at a dotted path (`definition.name`): required only when every step is. */
40
+ function fieldAt(fields, path) {
41
+ const [head, ...rest] = path.split(".");
42
+ let f = fields.get(head);
43
+ for (const seg of rest) {
44
+ if (f === undefined)
45
+ return undefined;
46
+ const holder = alternatives(f.schema).find((a) => propsOf(a)?.[seg] !== undefined);
47
+ const next = holder && propsOf(holder)?.[seg];
48
+ if (!holder || !next)
49
+ return undefined;
50
+ f = { schema: next, required: f.required && requiredOf(holder).has(seg) };
51
+ }
52
+ return f;
53
+ }
54
+ const jsonType = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
55
+ /** The JSON types a schema accepts; `undefined` when it accepts anything. */
56
+ function typesOf(s) {
57
+ if (s.type !== undefined)
58
+ return new Set(Array.isArray(s.type) ? s.type : [s.type]);
59
+ if ("const" in s)
60
+ return new Set([jsonType(s.const)]);
61
+ if (Array.isArray(s.enum))
62
+ return new Set(s.enum.map(jsonType));
63
+ return undefined;
64
+ }
65
+ /** `integer` is a `number`; every other type only itself. */
66
+ const typeFits = (t, allowed) => allowed.has(t) || (t === "integer" && allowed.has("number"));
67
+ const describeTypes = (t) => t === undefined ? "any" : [...t].sort().join(" | ");
68
+ const valuesOf = (s) => "const" in s ? [s.const] : Array.isArray(s.enum) ? s.enum : undefined;
69
+ /**
70
+ * Why one operation alternative accepts more than one route alternative, or null when it accepts
71
+ * no more (spec §14.5 item 3). Objects, arrays and records are compared recursively: every
72
+ * operation property is a route property, every property the route requires the operation
73
+ * requires, a closed route object is closed in the operation, items and values fit.
74
+ */
75
+ function misfit(op, route, path, top) {
76
+ /** The reason, prefixed by the path inside the compared field (none at the field itself). */
77
+ const at = (p, why) => (p === top ? why : `${p}: ${why}`);
78
+ const want = typesOf(route);
79
+ const got = typesOf(op);
80
+ if (want !== undefined && (got === undefined || [...got].some((t) => !typeFits(t, want)))) {
81
+ return at(path, `type ${describeTypes(got)} in the operation, ${describeTypes(want)} in the route`);
82
+ }
83
+ const allowed = valuesOf(route);
84
+ if (allowed !== undefined) {
85
+ const vs = valuesOf(op);
86
+ const keys = new Set(allowed.map((v) => JSON.stringify(v)));
87
+ if (vs === undefined || vs.some((v) => !keys.has(JSON.stringify(v)))) {
88
+ return at(path, `values ${vs === undefined ? "any" : JSON.stringify(vs)} are looser than the route's ${JSON.stringify(allowed)}`);
89
+ }
90
+ }
91
+ for (const k of UPPER) {
92
+ const r = route[k];
93
+ const o = op[k];
94
+ if (r !== undefined && (o === undefined || o > r)) {
95
+ return at(path, `${k} ${o ?? "unbounded"} is looser than the route's ${r}`);
96
+ }
97
+ }
98
+ for (const k of LOWER) {
99
+ const r = route[k];
100
+ const o = op[k];
101
+ if (r !== undefined && (o === undefined || o < r)) {
102
+ return at(path, `${k} ${o ?? "unbounded"} is looser than the route's ${r}`);
103
+ }
104
+ }
105
+ for (const k of ["pattern", "format"]) {
106
+ if (route[k] !== undefined && op[k] !== route[k]) {
107
+ return at(path, `${k} ${op[k] === undefined ? "none" : JSON.stringify(op[k])} differs from the route's ${JSON.stringify(route[k])}`);
108
+ }
109
+ }
110
+ const sub = (k) => `${path}.${k}`;
111
+ const rp = propsOf(route);
112
+ if (rp !== undefined) {
113
+ const opProps = propsOf(op) ?? {};
114
+ const opReq = requiredOf(op);
115
+ for (const k of requiredOf(route)) {
116
+ if (!opReq.has(k))
117
+ return at(sub(k), "required by the route, optional or missing here");
118
+ }
119
+ for (const [k, v] of Object.entries(opProps)) {
120
+ const r = rp[k];
121
+ if (r === undefined)
122
+ return at(sub(k), "no field of the route");
123
+ const why = fieldMismatch(v, r, sub(k), top);
124
+ if (why !== null)
125
+ return why;
126
+ }
127
+ }
128
+ if (route.additionalProperties === false && op.additionalProperties !== false) {
129
+ return at(path, "accepts unknown keys, the route does not");
130
+ }
131
+ // a record's values: an operation closed to unknown keys accepts none, else its values must fit
132
+ if (typeof route.additionalProperties === "object" && op.additionalProperties !== false) {
133
+ const why = fieldMismatch((op.additionalProperties ?? {}), route.additionalProperties, sub("*"), top);
134
+ if (why !== null)
135
+ return why;
136
+ }
137
+ if (typeof route.propertyNames === "object") {
138
+ const why = fieldMismatch((op.propertyNames ?? {}), route.propertyNames, sub("<key>"), top);
139
+ if (why !== null)
140
+ return why;
141
+ }
142
+ if (typeof route.items === "object" && route.items !== null) {
143
+ const why = fieldMismatch((op.items ?? {}), route.items, sub("[]"), top);
144
+ if (why !== null)
145
+ return why;
146
+ }
147
+ return null;
148
+ }
149
+ /** Why the operation's schema accepts more than the route's, or null: each op alternative fits one. */
150
+ function fieldMismatch(op, route, path, top) {
151
+ const routeAlts = alternatives(route);
152
+ for (const a of alternatives(op)) {
153
+ const reasons = routeAlts.map((b) => misfit(a, b, path, top));
154
+ if (!reasons.includes(null))
155
+ return reasons[0];
156
+ }
157
+ return null;
158
+ }
159
+ /**
160
+ * Compares an operation's input with one mirrored route's body + query + path params (spec
161
+ * §14.5 item 3), on their input JSON Schemas:
162
+ * - each input field is compared with the route field of the same name, or the route path its
163
+ * `renames` entry names (`skillId` → `id`, `name` → `definition.name`): the same type (an
164
+ * operation `integer` fits a route `number`), enum values a subset, bounds no looser
165
+ * (`maxLength` / `maximum` / `maxItems` at most the route's, the lower bounds at least), the
166
+ * same `pattern` and `format`, and required where the route requires it; nested objects,
167
+ * arrays and records recursively (a nested optional route field the operation leaves out is
168
+ * allowed, a required one is not);
169
+ * - a `loosens` entry names an input field allowed to accept more than the route (with the
170
+ * reason); it is still compared by type, and an entry that loosens nothing is stale;
171
+ * - a top-level route field the input neither has nor renames into is listed in `omits`, an input
172
+ * field with no route counterpart in `extras`; stale entries of either are findings.
173
+ */
174
+ export function inputParity(op, route) {
175
+ const out = [];
176
+ const add = (field, message) => out.push({ op: op.id, route: route.route, field, message: `${op.id}: ${message}` });
177
+ const opFields = fieldsOf(toJson(op.input));
178
+ const routeFields = new Map();
179
+ for (const part of [route.params, route.query, route.body]) {
180
+ if (part === undefined)
181
+ continue;
182
+ for (const [k, v] of fieldsOf(toJson(part)))
183
+ if (!IMPLICIT.has(k))
184
+ routeFields.set(k, v);
185
+ }
186
+ const omits = new Set(op.omits ?? []);
187
+ const extras = new Set(op.extras ?? []);
188
+ const renames = new Map(Object.entries(op.renames ?? {}));
189
+ const loosens = new Map(Object.entries(op.loosens ?? {}));
190
+ const r = `\`${route.route}\``;
191
+ /** Top-level route fields an input field covers (by name or by a rename into it). */
192
+ const covered = new Set();
193
+ for (const [k, opField] of opFields) {
194
+ const target = renames.get(k) ?? k;
195
+ const routeField = fieldAt(routeFields, target);
196
+ if (routeField === undefined) {
197
+ if (renames.has(k))
198
+ add(k, `\`renames\` maps \`${k}\` to \`${target}\`, no field of ${r}`);
199
+ else if (!extras.has(k))
200
+ add(k, `\`${k}\` is no field of ${r} and not in \`extras\``);
201
+ continue;
202
+ }
203
+ covered.add(target.split(".")[0]);
204
+ if (extras.has(k))
205
+ add(k, `\`extras\` names \`${k}\`, which ${r} has as \`${target}\``);
206
+ const reason = loosens.get(k);
207
+ const name = target === k ? `\`${k}\`` : `\`${k}\` (\`${target}\`)`;
208
+ if (reason !== undefined) {
209
+ if (reason.trim() === "")
210
+ add(k, `\`loosens\` names \`${k}\` without a reason`);
211
+ const want = typesOf(routeField.schema);
212
+ const got = typesOf(opField.schema);
213
+ if (want !== undefined && (got === undefined || [...got].some((t) => !typeFits(t, want)))) {
214
+ add(k, `${name}: type ${describeTypes(got)} in the operation, ${describeTypes(want)} in the route (${r}; \`loosens\` excuses bounds, never the type)`);
215
+ }
216
+ const looser = (routeField.required && !opField.required) ||
217
+ fieldMismatch(opField.schema, routeField.schema, target, target) !== null;
218
+ if (!looser)
219
+ add(k, `\`loosens\` names ${name}, which is no looser than ${r}`);
220
+ continue;
221
+ }
222
+ if (routeField.required && !opField.required) {
223
+ add(k, `${name} is required by ${r} but optional here (declare it in \`loosens\` if meant)`);
224
+ }
225
+ const why = fieldMismatch(opField.schema, routeField.schema, target, target);
226
+ if (why !== null)
227
+ add(k, `${name}: ${why} (${r})`);
228
+ }
229
+ for (const k of routeFields.keys()) {
230
+ if (!covered.has(k) && !omits.has(k)) {
231
+ add(k, `\`${k}\` of ${r} is missing from the input and not in \`omits\``);
232
+ }
233
+ }
234
+ for (const k of omits) {
235
+ if (!routeFields.has(k))
236
+ add(k, `\`omits\` names \`${k}\`, no field of ${r}`);
237
+ else if (covered.has(k))
238
+ add(k, `\`omits\` names \`${k}\`, but the input has it`);
239
+ }
240
+ for (const k of extras) {
241
+ if (!opFields.has(k))
242
+ add(k, `\`extras\` names \`${k}\`, which the input lacks`);
243
+ }
244
+ for (const k of renames.keys()) {
245
+ if (!opFields.has(k))
246
+ add(k, `\`renames\` names \`${k}\`, which the input lacks`);
247
+ }
248
+ for (const k of loosens.keys()) {
249
+ if (!opFields.has(k))
250
+ add(k, `\`loosens\` names \`${k}\`, which the input lacks`);
251
+ }
252
+ return out;
253
+ }
254
+ /**
255
+ * {@link inputParity} of every operation against each route it mirrors; a mirrored route whose
256
+ * schemas are not registered is a finding too (a removed route is `check:platform-ops`'s orphan).
257
+ */
258
+ export function checkInputParity(ops, routes) {
259
+ const byRoute = new Map(routes.map((r) => [r.route, r]));
260
+ return ops.flatMap((op) => op.mirrors.flatMap((m) => {
261
+ const r = byRoute.get(m);
262
+ return r !== undefined
263
+ ? inputParity(op, r)
264
+ : [
265
+ {
266
+ op: op.id,
267
+ route: m,
268
+ message: `${op.id} mirrors \`${m}\`, whose schemas are not in ROUTE_SCHEMAS: export them from the controller's <domain>.schemas.ts and list them there`,
269
+ },
270
+ ];
271
+ }));
272
+ }
@@ -1,3 +1,35 @@
1
+ import { AccountsOperations } from "./ops/accounts.ops.js";
2
+ import { AdminOperations } from "./ops/admin.ops.js";
3
+ import { AgentSkillsOperations } from "./ops/agent-skills.ops.js";
4
+ import { AgentTemplatesOperations } from "./ops/agent-templates.ops.js";
5
+ import { AgentsOperations } from "./ops/agents.ops.js";
6
+ import { ApprovalsOperations } from "./ops/approvals.ops.js";
7
+ import { BackgroundOperations } from "./ops/background.ops.js";
8
+ import { CatalogAdminOperations } from "./ops/catalog-admin.ops.js";
9
+ import { ChannelsOperations } from "./ops/channels.ops.js";
10
+ import { ComponentsOperations } from "./ops/components.ops.js";
11
+ import { ConnectorsOperations } from "./ops/connectors.ops.js";
12
+ import { ConversationsOperations } from "./ops/conversations.ops.js";
13
+ import { EnvironmentsOperations } from "./ops/environments.ops.js";
14
+ import { EvalsOperations } from "./ops/evals.ops.js";
15
+ import { ExtensionsOperations } from "./ops/extensions.ops.js";
16
+ import { ExtensionsAdminOperations } from "./ops/extensions-admin.ops.js";
17
+ import { InboxOperations } from "./ops/inbox.ops.js";
18
+ import { MarketplacesOperations } from "./ops/marketplaces.ops.js";
19
+ import { ModelsOperations } from "./ops/models.ops.js";
20
+ import { OrgPluginsOperations } from "./ops/org-plugins.ops.js";
21
+ import { OrgSettingsOperations } from "./ops/org-settings.ops.js";
22
+ import { OrgsOperations } from "./ops/orgs.ops.js";
23
+ import { PlatformOperationsProvider } from "./ops/platform.ops.js";
24
+ import { PluginsOperations } from "./ops/plugins.ops.js";
25
+ import { PreviewersOperations } from "./ops/previewers.ops.js";
26
+ import { RequestsOperations } from "./ops/requests.ops.js";
27
+ import { SkillsOperations } from "./ops/skills.ops.js";
28
+ /**
29
+ * One provider per domain, each taking `PlatformOperations` as its first constructor argument:
30
+ * the parity test in `tools/checks` builds the operations from it without a Nest app.
31
+ */
32
+ export declare const PLATFORM_OPERATION_PROVIDERS: readonly [typeof PlatformOperationsProvider, typeof SkillsOperations, typeof AgentsOperations, typeof AgentTemplatesOperations, typeof PluginsOperations, typeof MarketplacesOperations, typeof RequestsOperations, typeof ConnectorsOperations, typeof ExtensionsOperations, typeof ConversationsOperations, typeof ComponentsOperations, typeof AccountsOperations, typeof OrgsOperations, typeof AdminOperations, typeof CatalogAdminOperations, typeof OrgPluginsOperations, typeof ExtensionsAdminOperations, typeof ModelsOperations, typeof InboxOperations, typeof ApprovalsOperations, typeof ChannelsOperations, typeof OrgSettingsOperations, typeof EvalsOperations, typeof BackgroundOperations, typeof PreviewersOperations, typeof EnvironmentsOperations, typeof AgentSkillsOperations];
1
33
  /**
2
34
  * The `Platform` tool's operations (ruling P2): one provider per domain, each registering its
3
35
  * operations into `PlatformOperations` from `onModuleInit`. It imports the domain modules, which
@@ -6,21 +6,88 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Module } from "@nestjs/common";
8
8
  import { AgentsModule } from "../agents/agents.module.js";
9
+ import { BackgroundModule } from "../background/background.module.js";
9
10
  import { CatalogModule } from "../catalog/catalog.module.js";
11
+ import { ChannelsModule } from "../channels/channels.module.js";
12
+ import { ConversationsModule } from "../conversations/conversations.module.js";
13
+ import { EnvironmentsModule } from "../environments/environments.module.js";
14
+ import { EvalsModule } from "../evals/evals.module.js";
10
15
  import { ExtensionsModule } from "../extensions/extensions.module.js";
16
+ import { FilesModule } from "../files/files.module.js";
17
+ import { IdentityModule } from "../identity/identity.module.js";
18
+ import { InboxModule } from "../inbox/inbox.module.js";
19
+ import { ModelsModule } from "../models/models.module.js";
11
20
  import { OrgsModule } from "../orgs/orgs.module.js";
21
+ import { ProvidersModule } from "../runtime/providers.js";
12
22
  import { SkillsModule } from "../skills/skills.module.js";
13
23
  import { ToolsModule } from "../tools/tools.module.js";
24
+ import { AccountsOperations } from "./ops/accounts.ops.js";
25
+ import { AdminOperations } from "./ops/admin.ops.js";
26
+ import { AgentSkillsOperations } from "./ops/agent-skills.ops.js";
14
27
  import { AgentTemplatesOperations } from "./ops/agent-templates.ops.js";
15
28
  import { AgentsOperations } from "./ops/agents.ops.js";
29
+ import { ApprovalsOperations } from "./ops/approvals.ops.js";
30
+ import { BackgroundOperations } from "./ops/background.ops.js";
31
+ import { CatalogAdminOperations } from "./ops/catalog-admin.ops.js";
32
+ import { ChannelsOperations } from "./ops/channels.ops.js";
33
+ import { ComponentsOperations } from "./ops/components.ops.js";
16
34
  import { ConnectorsOperations } from "./ops/connectors.ops.js";
35
+ import { ConversationsOperations } from "./ops/conversations.ops.js";
36
+ import { EnvironmentsOperations } from "./ops/environments.ops.js";
37
+ import { EvalsOperations } from "./ops/evals.ops.js";
17
38
  import { ExtensionsOperations } from "./ops/extensions.ops.js";
39
+ import { ExtensionsAdminOperations } from "./ops/extensions-admin.ops.js";
40
+ import { InboxOperations } from "./ops/inbox.ops.js";
18
41
  import { MarketplacesOperations } from "./ops/marketplaces.ops.js";
42
+ import { ModelsOperations } from "./ops/models.ops.js";
43
+ import { OrgPluginsOperations } from "./ops/org-plugins.ops.js";
44
+ import { OrgSettingsOperations } from "./ops/org-settings.ops.js";
45
+ import { OrgsOperations } from "./ops/orgs.ops.js";
19
46
  import { PlatformOperationsProvider } from "./ops/platform.ops.js";
20
47
  import { PluginsOperations } from "./ops/plugins.ops.js";
48
+ import { PreviewersOperations } from "./ops/previewers.ops.js";
21
49
  import { RequestsOperations } from "./ops/requests.ops.js";
22
50
  import { SkillsOperations } from "./ops/skills.ops.js";
23
51
  import { PlatformModule } from "./platform.module.js";
52
+ /**
53
+ * One provider per domain, each taking `PlatformOperations` as its first constructor argument:
54
+ * the parity test in `tools/checks` builds the operations from it without a Nest app.
55
+ */
56
+ export const PLATFORM_OPERATION_PROVIDERS = [
57
+ PlatformOperationsProvider,
58
+ SkillsOperations,
59
+ AgentsOperations,
60
+ AgentTemplatesOperations,
61
+ PluginsOperations,
62
+ MarketplacesOperations,
63
+ RequestsOperations,
64
+ ConnectorsOperations,
65
+ ExtensionsOperations,
66
+ ConversationsOperations,
67
+ ComponentsOperations,
68
+ // Task 7: admin accounts and orgs
69
+ AccountsOperations,
70
+ OrgsOperations,
71
+ AdminOperations,
72
+ // Task 8: admin catalog, extensions, marketplaces, models, org uploads
73
+ CatalogAdminOperations,
74
+ OrgPluginsOperations,
75
+ ExtensionsAdminOperations,
76
+ ModelsOperations,
77
+ // Task 9: inbox and pending reads
78
+ InboxOperations,
79
+ ApprovalsOperations,
80
+ // Task 10: channels, org settings
81
+ ChannelsOperations,
82
+ OrgSettingsOperations,
83
+ // Task 11: evals, background tasks, file previewers
84
+ EvalsOperations,
85
+ BackgroundOperations,
86
+ PreviewersOperations,
87
+ // Task 11b: environments, agent skills
88
+ EnvironmentsOperations,
89
+ AgentSkillsOperations,
90
+ ];
24
91
  /**
25
92
  * The `Platform` tool's operations (ruling P2): one provider per domain, each registering its
26
93
  * operations into `PlatformOperations` from `onModuleInit`. It imports the domain modules, which
@@ -38,18 +105,18 @@ PlatformOpsModule = __decorate([
38
105
  CatalogModule,
39
106
  ExtensionsModule,
40
107
  ToolsModule,
108
+ ConversationsModule,
109
+ IdentityModule,
110
+ ModelsModule,
111
+ ProvidersModule,
112
+ InboxModule,
113
+ ChannelsModule,
114
+ EvalsModule,
115
+ EnvironmentsModule,
116
+ BackgroundModule,
117
+ FilesModule,
41
118
  ],
42
- providers: [
43
- PlatformOperationsProvider,
44
- SkillsOperations,
45
- AgentsOperations,
46
- AgentTemplatesOperations,
47
- PluginsOperations,
48
- MarketplacesOperations,
49
- RequestsOperations,
50
- ConnectorsOperations,
51
- ExtensionsOperations,
52
- ],
119
+ providers: [...PLATFORM_OPERATION_PROVIDERS],
53
120
  })
54
121
  ], PlatformOpsModule);
55
122
  export { PlatformOpsModule };
@@ -0,0 +1,18 @@
1
+ import type { z } from "zod";
2
+ /**
3
+ * The zod schemas one HTTP route validates (spec §14.5 item 3), as its controller uses them:
4
+ * `route` is the `check:platform-ops` key (`POST /api/v1/orgs/:orgId/skills`), `params` its path
5
+ * params but `:orgId` (the conversation's org, never an operation field).
6
+ */
7
+ export interface RouteSchemas {
8
+ route: string;
9
+ body?: z.ZodType;
10
+ query?: z.ZodType;
11
+ params?: z.ZodType;
12
+ }
13
+ /**
14
+ * Every route a Platform operation mirrors, from the exported `<domain>.schemas.ts` next to each
15
+ * controller. An operation builds its input from these (`pick` / `omit` / `extend`); the parity
16
+ * test in `tools/checks` compares the two. A route mirrored by a new operation adds its entry here.
17
+ */
18
+ export declare const ROUTE_SCHEMAS: readonly RouteSchemas[];
@@ -0,0 +1,63 @@
1
+ import { ADMIN_ROUTES } from "../admin/admin.schemas.js";
2
+ import { ADMIN_EXTENSION_ROUTES } from "../admin/extensions.schemas.js";
3
+ import { AGENT_ROUTES } from "../agents/agents.schemas.js";
4
+ import { AGENT_TEMPLATE_ROUTES } from "../agents/templates.schemas.js";
5
+ import { BACKGROUND_ROUTES } from "../background/background.schemas.js";
6
+ import { ADMIN_CATALOG_ROUTES } from "../catalog/admin-catalog.schemas.js";
7
+ import { COMPONENT_SCOPE_ROUTES } from "../catalog/component-scope.schemas.js";
8
+ import { MARKETPLACE_ROUTES } from "../catalog/marketplaces.schemas.js";
9
+ import { ORG_CATALOG_ROUTES } from "../catalog/org-catalog.schemas.js";
10
+ import { ORG_EXTENSION_ROUTES } from "../catalog/org-extension.schemas.js";
11
+ import { ORG_PLUGIN_UPLOAD_ROUTES } from "../catalog/org-plugin-uploads.schemas.js";
12
+ import { CHANNEL_ROUTES } from "../channels/channels.schemas.js";
13
+ import { CONVERSATION_ROUTES } from "../conversations/conversations.schemas.js";
14
+ import { ENVIRONMENT_ROUTES } from "../environments/environments.schemas.js";
15
+ import { EVAL_ROUTES } from "../evals/evals.schemas.js";
16
+ import { EXTENSION_POINT_ROUTES } from "../extensions/point-defaults.schemas.js";
17
+ import { FILE_PREVIEWER_ROUTES } from "../files/previewers.schemas.js";
18
+ import { ME_ROUTES } from "../identity/me.schemas.js";
19
+ import { INBOX_ROUTES } from "../inbox/inbox.schemas.js";
20
+ import { ORG_MODEL_ROUTES } from "../models/org-models.schemas.js";
21
+ import { ORG_ROUTES, ORG_SETTINGS_ROUTES } from "../orgs/orgs.schemas.js";
22
+ import { SKILL_ROUTES } from "../skills/skills.schemas.js";
23
+ import { APPROVAL_ROUTES } from "../tools/approvals.schemas.js";
24
+ import { CONNECTOR_ROUTES } from "../tools/connectors.schemas.js";
25
+ /**
26
+ * Every route a Platform operation mirrors, from the exported `<domain>.schemas.ts` next to each
27
+ * controller. An operation builds its input from these (`pick` / `omit` / `extend`); the parity
28
+ * test in `tools/checks` compares the two. A route mirrored by a new operation adds its entry here.
29
+ */
30
+ export const ROUTE_SCHEMAS = [
31
+ ...SKILL_ROUTES,
32
+ ...AGENT_ROUTES,
33
+ ...AGENT_TEMPLATE_ROUTES,
34
+ ...ORG_CATALOG_ROUTES,
35
+ ...ADMIN_CATALOG_ROUTES,
36
+ ...MARKETPLACE_ROUTES,
37
+ ...CONNECTOR_ROUTES,
38
+ ...COMPONENT_SCOPE_ROUTES,
39
+ ...ORG_EXTENSION_ROUTES,
40
+ ...CONVERSATION_ROUTES,
41
+ // Task 7: admin accounts, orgs, deployment settings, platform models
42
+ ...ADMIN_ROUTES,
43
+ ...ORG_ROUTES,
44
+ // Task 8: admin catalog, extensions, marketplaces, models, org uploads
45
+ ...ADMIN_EXTENSION_ROUTES,
46
+ ...ORG_PLUGIN_UPLOAD_ROUTES,
47
+ ...EXTENSION_POINT_ROUTES,
48
+ ...ORG_MODEL_ROUTES,
49
+ // Task 9: inbox and pending reads
50
+ ...INBOX_ROUTES,
51
+ ...APPROVAL_ROUTES,
52
+ // Task 10: channels, org settings
53
+ ...CHANNEL_ROUTES,
54
+ ...ORG_SETTINGS_ROUTES,
55
+ // Task 11: evals, background tasks, file previewers
56
+ ...EVAL_ROUTES,
57
+ ...BACKGROUND_ROUTES,
58
+ ...FILE_PREVIEWER_ROUTES,
59
+ // Task 11b: environments
60
+ ...ENVIRONMENT_ROUTES,
61
+ // personal preferences (run context spec §3.4)
62
+ ...ME_ROUTES,
63
+ ];
@@ -22,6 +22,7 @@ import { LegacySandboxCleanupJob } from "../environments/legacy-cleanup.job.js";
22
22
  import { EvalWorkersModule } from "../evals/evals.module.js";
23
23
  import { ExtensionsModule } from "../extensions/extensions.module.js";
24
24
  import { PluginsReconcileJob } from "../extensions/lifecycle.js";
25
+ import { InitialPasswordCleanupJob } from "../identity/initial-passwords.job.js";
25
26
  import { KernelScheduleModule } from "../infra/schedule/schedule.module.js";
26
27
  import { DirectoryScanJob } from "../orgs/directory-sync.js";
27
28
  import { OffboardSweepJob } from "../orgs/offboarding.js";
@@ -85,6 +86,7 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
85
86
  LegacySandboxCleanupJob,
86
87
  BackgroundTaskPollJob,
87
88
  ToolJobs,
89
+ InitialPasswordCleanupJob,
88
90
  CatalogJobs,
89
91
  PlatformMigration,
90
92
  DirectoryScanJob,
@@ -233,6 +233,8 @@ export declare function summaryText(summary: string): string;
233
233
  * `user_message` / `assistant_message`(content 原样,含 opaque;aborted 的也回放;媒体引用按
234
234
  * {@link resolveMedia} 换成 base64 或文字占位)/ `reminder`
235
235
  * (`role: "system"`,放在它所在的位置)/ `tools_changed` (`role: "system"`, the text of {@link toolsChangedText}, at its position) /
236
+ * `run_context` (`role: "system"` at its position, `runContextText`; covered by the summary: the
237
+ * current context follows the summary whole; a user message's sender line by `senderLines`) /
236
238
  * `background_task_finished`(`role: "system"`, the text of
237
239
  * {@link renderBackgroundFinished}, placed like a user_message)/ `subagent_delivery` (likewise,
238
240
  * the text of {@link renderSubagentDelivery});`tool_result` 事件还原为紧随其 assistant 消息之后的一条 user 消息
@@ -5,6 +5,7 @@ import { isAbsorbable, } from "../../conversations/events.js";
5
5
  import { catalogText, isAlwaysLoaded } from "../../tools/builtins/tool-search.js";
6
6
  import { renderSubagentDelivery } from "../subagents/render.js";
7
7
  import { LEGACY_CATALOG_HEADER, LEGACY_SKILL_TEXTS, usesLegacyToolNames } from "./legacy-text.js";
8
+ import { currentRunContext, runContextEvents, runContextFullText, runContextText, senderLines, } from "./run-context.js";
8
9
  import { invokedSkillNames, invokedSkillsText, SKILL_TEXTS, skillsCatalogEvents, snapshotChangeText, snapshotCurrentText, snapshotSystemText, systemSkillsCatalog, } from "./skills.js";
9
10
  import { toolsChangedText } from "./tool-changes.js";
10
11
  /**
@@ -335,6 +336,8 @@ export function summaryText(summary) {
335
336
  * `user_message` / `assistant_message`(content 原样,含 opaque;aborted 的也回放;媒体引用按
336
337
  * {@link resolveMedia} 换成 base64 或文字占位)/ `reminder`
337
338
  * (`role: "system"`,放在它所在的位置)/ `tools_changed` (`role: "system"`, the text of {@link toolsChangedText}, at its position) /
339
+ * `run_context` (`role: "system"` at its position, `runContextText`; covered by the summary: the
340
+ * current context follows the summary whole; a user message's sender line by `senderLines`) /
338
341
  * `background_task_finished`(`role: "system"`, the text of
339
342
  * {@link renderBackgroundFinished}, placed like a user_message)/ `subagent_delivery` (likewise,
340
343
  * the text of {@link renderSubagentDelivery});`tool_result` 事件还原为紧随其 assistant 消息之后的一条 user 消息
@@ -463,11 +466,21 @@ export function buildModelRequest(input) {
463
466
  }
464
467
  racedPending = racedPending.filter((x) => x.seq > toSeq);
465
468
  };
466
- /** A user message's blocks, with its fork report when it has one. */
469
+ /** Run context spec §4: the sender lines, by the messages after the summary boundary. */
470
+ const senders = senderLines(events, after);
471
+ /**
472
+ * A user message's blocks: its sender line first when the sender changed (a separate block, so
473
+ * `content[0]` stays the typed text), then its own blocks, then its fork report when it has one.
474
+ */
467
475
  const userBlocks = (u) => {
468
476
  const report = forkReports.get(u.seq);
477
+ const line = senders.get(u.seq);
469
478
  const blocks = blocksOf(u.payload.content);
470
- return report === undefined ? blocks : [...blocks, { type: "text", text: report }];
479
+ return [
480
+ ...(line === undefined ? [] : [{ type: "text", text: line }]),
481
+ ...blocks,
482
+ ...(report === undefined ? [] : [{ type: "text", text: report }]),
483
+ ];
471
484
  };
472
485
  /** 被某次模型调用跳过(运行中途到达)、尚未被吸收的可吸收事件,按 seq 升序。 */
473
486
  let deferred = [];
@@ -526,6 +539,14 @@ export function buildModelRequest(input) {
526
539
  role: "user",
527
540
  content: [{ type: "text", text: summaryText(summary.payload.text) }],
528
541
  });
542
+ // run context spec §5: snapshots covered by the summary are not rendered; the context in
543
+ // effect at the summary's boundary follows it whole
544
+ if (runContextEvents(events).some((e) => e.seq <= after)) {
545
+ messages.push({
546
+ role: "system",
547
+ content: runContextFullText(currentRunContext(events, after)),
548
+ });
549
+ }
529
550
  // 被摘要覆盖的变更提醒不再发送:摘要时生效的目录与 system 里的不同 → 紧随摘要补上完整的当前目录
530
551
  const covered = skillSnaps.filter((e) => e.seq <= after).at(-1);
531
552
  // (phase B: plus the current pinned skills and tool-name map when they differ from system's)
@@ -594,6 +615,11 @@ export function buildModelRequest(input) {
594
615
  case "tools_changed":
595
616
  messages.push({ role: "system", content: toolsChangedText(e.payload) });
596
617
  break;
618
+ // who the agent is and the facts of the day (run context spec §4): the first snapshot whole,
619
+ // a later one as the changes against the fold before it
620
+ case "run_context":
621
+ messages.push({ role: "system", content: runContextText(events, e) });
622
+ break;
597
623
  // hook_denied is not model-visible: the model sees only the denied tool call's tool_result
598
624
  // (and nothing for a denied model request), so request building skips it
599
625
  case "hook_denied":
@@ -1,6 +1,7 @@
1
1
  import { renderBackgroundFinished } from "../../background/render.js";
2
2
  import { renderSubagentDelivery } from "../subagents/render.js";
3
3
  import { latestSummary } from "./build.js";
4
+ import { senderTranscriptLabel } from "./run-context.js";
4
5
  import { toolsChangedText } from "./tool-changes.js";
5
6
  /** 压缩请求的标记:放在 system 中,便于识别(model-fake 据此返回摘要)。 */
6
7
  export const COMPACTION_MARKER = "CAPYBARA_COMPACTION";
@@ -106,7 +107,13 @@ function transcriptLine(e) {
106
107
  switch (e.type) {
107
108
  case "user_message": {
108
109
  const text = renderBlocks(e.payload.content);
109
- return text ? `User: ${text}` : null;
110
+ if (!text)
111
+ return null;
112
+ // run context spec §5: the sender as logged (older logs have none: unchanged)
113
+ const sender = e.payload.sender;
114
+ return sender !== undefined
115
+ ? `User (${senderTranscriptLabel(sender)}): ${text}`
116
+ : `User: ${text}`;
110
117
  }
111
118
  case "assistant_message": {
112
119
  const text = renderBlocks(e.payload.content);
@@ -127,6 +134,8 @@ function transcriptLine(e) {
127
134
  // phase D: a forked skill's report is user content of the request (build.ts)
128
135
  case "skill_fork_result":
129
136
  return `User: ${e.payload.text}`;
137
+ // run_context is left out: its current values follow the summary anyway (build.ts), and
138
+ // stale names should not be summarised as current
130
139
  case "tool_result":
131
140
  return `Tool result ${e.payload.toolKey}${e.payload.isError ? " (error)" : ""}: ${e.payload.content}`;
132
141
  default: