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

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 (331) 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 +14 -0
  172. package/dist/identity/me.controller.js +39 -1
  173. package/dist/identity/principal.d.ts +8 -0
  174. package/dist/identity/principal.js +8 -0
  175. package/dist/identity/settings.d.ts +3 -1
  176. package/dist/identity/settings.js +6 -4
  177. package/dist/inbox/inbox.schemas.d.ts +8 -0
  178. package/dist/inbox/inbox.schemas.js +11 -0
  179. package/dist/inbox/platform-inbox.controller.d.ts +1 -1
  180. package/dist/inbox/platform-inbox.controller.js +2 -2
  181. package/dist/index.d.ts +4 -0
  182. package/dist/index.js +6 -0
  183. package/dist/lifecycle/kernel-lifecycle.js +4 -0
  184. package/dist/models/enablement.d.ts +2 -0
  185. package/dist/models/enablement.js +1 -0
  186. package/dist/models/org-models.schemas.d.ts +8 -0
  187. package/dist/models/org-models.schemas.js +22 -0
  188. package/dist/models/prices.d.ts +3 -1
  189. package/dist/models/prices.js +7 -5
  190. package/dist/models/purposes.d.ts +12 -2
  191. package/dist/models/purposes.js +22 -8
  192. package/dist/orgs/orgs.controller.d.ts +2 -5
  193. package/dist/orgs/orgs.controller.js +3 -6
  194. package/dist/orgs/orgs.schemas.d.ts +8 -0
  195. package/dist/orgs/orgs.schemas.js +16 -0
  196. package/dist/orgs/orgs.service.d.ts +3 -1
  197. package/dist/orgs/orgs.service.js +6 -4
  198. package/dist/orgs/settings.service.d.ts +9 -1
  199. package/dist/orgs/settings.service.js +20 -5
  200. package/dist/overrides.d.ts +4 -0
  201. package/dist/overrides.js +2 -0
  202. package/dist/platform/errors.d.ts +21 -4
  203. package/dist/platform/errors.js +45 -6
  204. package/dist/platform/exclusions.d.ts +2 -3
  205. package/dist/platform/exclusions.js +68 -849
  206. package/dist/platform/method.js +1 -1
  207. package/dist/platform/operation.d.ts +82 -5
  208. package/dist/platform/operation.js +62 -7
  209. package/dist/platform/ops/accounts.ops.d.ts +32 -0
  210. package/dist/platform/ops/accounts.ops.js +291 -0
  211. package/dist/platform/ops/admin.ops.d.ts +36 -0
  212. package/dist/platform/ops/admin.ops.js +389 -0
  213. package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
  214. package/dist/platform/ops/agent-skills.ops.js +226 -0
  215. package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
  216. package/dist/platform/ops/agent-templates.ops.js +194 -14
  217. package/dist/platform/ops/agents.ops.d.ts +19 -1
  218. package/dist/platform/ops/agents.ops.js +481 -58
  219. package/dist/platform/ops/approvals.ops.d.ts +30 -0
  220. package/dist/platform/ops/approvals.ops.js +116 -0
  221. package/dist/platform/ops/background.ops.d.ts +14 -0
  222. package/dist/platform/ops/background.ops.js +134 -0
  223. package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
  224. package/dist/platform/ops/catalog-admin.ops.js +587 -0
  225. package/dist/platform/ops/channels.ops.d.ts +16 -0
  226. package/dist/platform/ops/channels.ops.js +195 -0
  227. package/dist/platform/ops/components.ops.d.ts +46 -0
  228. package/dist/platform/ops/components.ops.js +853 -0
  229. package/dist/platform/ops/connectors.ops.d.ts +4 -2
  230. package/dist/platform/ops/connectors.ops.js +68 -6
  231. package/dist/platform/ops/conversations.ops.d.ts +30 -0
  232. package/dist/platform/ops/conversations.ops.js +470 -0
  233. package/dist/platform/ops/environments.ops.d.ts +26 -0
  234. package/dist/platform/ops/environments.ops.js +289 -0
  235. package/dist/platform/ops/errors.d.ts +10 -5
  236. package/dist/platform/ops/errors.js +19 -11
  237. package/dist/platform/ops/evals.ops.d.ts +28 -0
  238. package/dist/platform/ops/evals.ops.js +783 -0
  239. package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
  240. package/dist/platform/ops/extensions-admin.ops.js +344 -0
  241. package/dist/platform/ops/extensions.ops.d.ts +7 -1
  242. package/dist/platform/ops/extensions.ops.js +248 -17
  243. package/dist/platform/ops/inbox.ops.d.ts +25 -0
  244. package/dist/platform/ops/inbox.ops.js +378 -0
  245. package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
  246. package/dist/platform/ops/marketplaces.ops.js +326 -17
  247. package/dist/platform/ops/models.ops.d.ts +25 -0
  248. package/dist/platform/ops/models.ops.js +232 -0
  249. package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
  250. package/dist/platform/ops/org-plugins.ops.js +329 -0
  251. package/dist/platform/ops/org-settings.ops.d.ts +16 -0
  252. package/dist/platform/ops/org-settings.ops.js +102 -0
  253. package/dist/platform/ops/orgs.ops.d.ts +28 -0
  254. package/dist/platform/ops/orgs.ops.js +295 -0
  255. package/dist/platform/ops/other-orgs.d.ts +20 -0
  256. package/dist/platform/ops/other-orgs.js +72 -0
  257. package/dist/platform/ops/platform.ops.d.ts +4 -4
  258. package/dist/platform/ops/platform.ops.js +23 -24
  259. package/dist/platform/ops/plugins.ops.d.ts +10 -8
  260. package/dist/platform/ops/plugins.ops.js +176 -77
  261. package/dist/platform/ops/previewers.ops.d.ts +14 -0
  262. package/dist/platform/ops/previewers.ops.js +109 -0
  263. package/dist/platform/ops/requests.ops.js +57 -19
  264. package/dist/platform/ops/skills.ops.d.ts +5 -1
  265. package/dist/platform/ops/skills.ops.js +129 -11
  266. package/dist/platform/ops/unavailable.d.ts +23 -0
  267. package/dist/platform/ops/unavailable.js +111 -0
  268. package/dist/platform/parity.d.ts +33 -0
  269. package/dist/platform/parity.js +272 -0
  270. package/dist/platform/platform-ops.module.d.ts +32 -0
  271. package/dist/platform/platform-ops.module.js +78 -11
  272. package/dist/platform/route-schemas.d.ts +18 -0
  273. package/dist/platform/route-schemas.js +60 -0
  274. package/dist/roles/worker.module.js +2 -0
  275. package/dist/runtime/context/build.d.ts +2 -0
  276. package/dist/runtime/context/build.js +28 -2
  277. package/dist/runtime/context/compaction.js +10 -1
  278. package/dist/runtime/context/run-context.d.ts +65 -0
  279. package/dist/runtime/context/run-context.js +215 -0
  280. package/dist/runtime/model-call.js +2 -1
  281. package/dist/runtime/providers.js +8 -1
  282. package/dist/runtime/run-context.service.d.ts +65 -0
  283. package/dist/runtime/run-context.service.js +220 -0
  284. package/dist/runtime/run-worker.d.ts +5 -0
  285. package/dist/runtime/run-worker.js +31 -6
  286. package/dist/runtime/runtime.module.js +2 -0
  287. package/dist/runtime/subagents/definition.d.ts +15 -15
  288. package/dist/runtime/subagents/definition.js +46 -115
  289. package/dist/skills/changes.controller.js +2 -1
  290. package/dist/skills/changes.service.d.ts +1 -1
  291. package/dist/skills/changes.service.js +4 -4
  292. package/dist/skills/invocable.controller.d.ts +1 -1
  293. package/dist/skills/invocable.controller.js +2 -2
  294. package/dist/skills/invoke.d.ts +2 -2
  295. package/dist/skills/invoke.js +8 -1
  296. package/dist/skills/skills.controller.d.ts +4 -13
  297. package/dist/skills/skills.controller.js +8 -24
  298. package/dist/skills/skills.schemas.d.ts +48 -0
  299. package/dist/skills/skills.schemas.js +61 -0
  300. package/dist/skills/skills.service.d.ts +11 -1
  301. package/dist/skills/skills.service.js +37 -14
  302. package/dist/time-zone.d.ts +5 -0
  303. package/dist/time-zone.js +19 -0
  304. package/dist/tools/approvals.controller.js +2 -3
  305. package/dist/tools/approvals.schemas.d.ts +21 -0
  306. package/dist/tools/approvals.schemas.js +15 -0
  307. package/dist/tools/builtin-names.d.ts +10 -8
  308. package/dist/tools/builtin-names.js +16 -11
  309. package/dist/tools/builtins/builtin-tools.d.ts +3 -1
  310. package/dist/tools/builtins/builtin-tools.js +15 -3
  311. package/dist/tools/builtins/current-time.d.ts +26 -0
  312. package/dist/tools/builtins/current-time.js +99 -0
  313. package/dist/tools/builtins/platform.d.ts +19 -2
  314. package/dist/tools/builtins/platform.js +105 -16
  315. package/dist/tools/connectors.controller.d.ts +1 -2
  316. package/dist/tools/connectors.controller.js +1 -4
  317. package/dist/tools/connectors.schemas.d.ts +12 -0
  318. package/dist/tools/connectors.schemas.js +19 -0
  319. package/dist/tools/connectors.service.d.ts +5 -2
  320. package/dist/tools/connectors.service.js +7 -5
  321. package/dist/tools/org-tool-switches.d.ts +16 -2
  322. package/dist/tools/org-tool-switches.js +26 -9
  323. package/dist/tools/pipeline.js +3 -1
  324. package/dist/tools/registry.d.ts +48 -51
  325. package/dist/tools/registry.js +222 -233
  326. package/package.json +3 -3
  327. package/src/migrations/0090_initial_passwords.sql +27 -0
  328. package/src/migrations/0091_account_time_zone.sql +4 -0
  329. package/src/migrations/0092_tools_default_on.sql +27 -0
  330. package/dist/platform/redact-orgs.d.ts +0 -7
  331. package/dist/platform/redact-orgs.js +0 -52
@@ -1,6 +1,6 @@
1
1
  import { DOCUMENT_MEDIA_TYPES, hasControlChars, IMAGE_MEDIA_TYPES, isAttachmentId, isSkillName, MEDIA_NAME_MAX_CHARS, } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
- import { AgentDefinitionSchema, AgentToolRef, ModelRef } from "../agents/definition.js";
3
+ import { AgentDefinitionSchema, DisabledToolRef, ModelRef } from "../agents/definition.js";
4
4
  import { ORG_ROLES } from "../orgs/roles.js";
5
5
  import { TOOL_VIEW_DIFF_MAX_LINES, TOOL_VIEW_LINE_MAX_CHARS, TOOL_VIEW_PATH_MAX_CHARS, } from "../tools/view.js";
6
6
  /** 供应商私有数据(`ProviderOpaque`):原样保存、只回放给同一供应商。 */
@@ -176,6 +176,37 @@ const InputFormSchema = z.object({
176
176
  });
177
177
  /** 表单答案(plugin-sdk 的 `FormAnswer`)。 */
178
178
  const FormAnswerSchema = z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]));
179
+ /** The languages a run context names (the org `locale` values). */
180
+ export const RUN_CONTEXT_LOCALES = ["zh", "en"];
181
+ /** `user_message.sender` (run context spec §3.2). */
182
+ export const MessageSenderSchema = z.object({
183
+ name: z.string().min(1).max(80),
184
+ /** Absent = no membership. */
185
+ role: z.enum(ORG_ROLES).optional(),
186
+ /** An IM sender served as the org's anonymous guest; `name` is the IM profile name. */
187
+ anonymous: z.literal(true).optional(),
188
+ });
189
+ /** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
190
+ export const RunContextSchema = z.object({
191
+ /** The agent itself: its name and its versioned description collapsed to one line. */
192
+ agent: z
193
+ .object({ name: z.string().min(1).max(130), description: z.string().max(200).optional() })
194
+ .optional(),
195
+ org: z.object({ name: z.string().min(1).max(200) }).optional(),
196
+ /** Today in `timeZone`, `YYYY-MM-DD`. */
197
+ date: z
198
+ .string()
199
+ .regex(/^\d{4}-\d{2}-\d{2}$/)
200
+ .optional(),
201
+ /** IANA name. */
202
+ timeZone: z.string().min(1).max(64).optional(),
203
+ /** The language of the person whose message started the run. */
204
+ locale: z.enum(RUN_CONTEXT_LOCALES).optional(),
205
+ /** Sub-agents only: who dispatched this conversation. */
206
+ dispatchedBy: z
207
+ .object({ agent: z.string().min(1).max(130), person: z.string().min(1).max(80) })
208
+ .optional(),
209
+ });
179
210
  const ev = (type, payload) => z.object({ type: z.literal(type), payload });
180
211
  /**
181
212
  * 会话事件(`type` + `payload`)的判别联合。事件日志只追加,写入前用它校验 payload;
@@ -193,6 +224,20 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
193
224
  .array(z.object({ appId: z.string(), appName: z.string(), uri: z.string(), name: z.string() }))
194
225
  .optional(),
195
226
  authorAccountId: z.string(),
227
+ /**
228
+ * Who wrote the message, at send time (run context spec §3.2): display name and org role
229
+ * only (never email or ids). Absent in older logs, on a sub-agent's task or `SendMessage`
230
+ * message. Model-visible only through the sender line, written when the sender changes
231
+ * (`senderLines`, runtime/context/run-context.ts).
232
+ */
233
+ sender: MessageSenderSchema.optional(),
234
+ /**
235
+ * The sender's time zone (IANA) and language at send time (run context spec §3.4): the
236
+ * account setting, else the browser's, else the org defaults. Not model-visible: the next
237
+ * run's `run_context` is derived from them.
238
+ */
239
+ timeZone: z.string().min(1).max(64).optional(),
240
+ locale: z.enum(RUN_CONTEXT_LOCALES).optional(),
196
241
  clientMessageId: z.string().optional(),
197
242
  /**
198
243
  * A retry after a failed run (UI refresh B): the seq of the message it repeats. Display only
@@ -232,13 +277,16 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
232
277
  */
233
278
  kind: z.enum(["task", "message"]).optional(),
234
279
  /**
235
- * A follow-up (`resume`, final review I1): the frozen tools and org skills intersected
236
- * with the current version (`narrowFollowUp`); the child's run uses these instead of
237
- * the frozen ones. Absent on a first dispatch and in older logs.
280
+ * A follow-up (`resume`, final review I1): the frozen and the current version's
281
+ * turned-off tools together, and the frozen org skills intersected with the current
282
+ * ones (`narrowFollowUp`); the child's run uses these instead of the frozen ones.
283
+ * Absent on a first dispatch and in older logs; logs from before tools were on by
284
+ * default carry an enabled `tools` list instead of `disabledTools` (read as no tool
285
+ * narrowing).
238
286
  */
239
287
  narrowed: z
240
288
  .object({
241
- tools: z.array(AgentToolRef),
289
+ disabledTools: z.array(DisabledToolRef).optional(),
242
290
  skills: z
243
291
  .object({ orgSkills: z.array(z.string()), pinned: z.array(z.string()).optional() })
244
292
  .optional(),
@@ -380,6 +428,13 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
380
428
  callId: z.string().optional(),
381
429
  })),
382
430
  ev("reminder", z.object({ step: count, text: z.string() })),
431
+ /**
432
+ * Who the agent is and the facts of the day (run context spec §3.1), written at run start
433
+ * (`RunContextService.record`): the conversation's first one holds every field that applies, a
434
+ * later one only the fields that changed. **Model-visible**: rendered at its position as a
435
+ * system message (`runContextText`); a summary covering it restores the current values.
436
+ */
437
+ ev("run_context", RunContextSchema),
383
438
  /**
384
439
  * The step's resolved tool set differs from the one the conversation's previous model request
385
440
  * offered (`toolSetChange`): tool names as the model sees them, sorted. Written before that
@@ -0,0 +1,28 @@
1
+ import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
+ import type { EventPayload } from "./events.js";
3
+ /** The name of an anonymous IM guest whose IM profile gives none. */
4
+ export declare const ANONYMOUS_SENDER_NAME = "Anonymous guest";
5
+ /** What the browser sent with a message (run context spec §3.4); both optional. */
6
+ export interface BrowserContext {
7
+ timeZone?: string | undefined;
8
+ locale?: "zh" | "en" | undefined;
9
+ }
10
+ /** The `user_message` fields {@link readMessageContext} fills. */
11
+ export type MessageContext = Pick<EventPayload<"user_message">, "sender" | "timeZone" | "locale">;
12
+ /**
13
+ * Who wrote a message and in which time zone and language (run context spec §3.2, §3.4), read in
14
+ * the message's transaction (`t`):
15
+ * - `sender`: the account's display name and org role at send time; the org's anonymous guest
16
+ * account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
17
+ * "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
18
+ * - `timeZone`: the account's setting, else the browser's (when valid), else the org default, else
19
+ * UTC. The anonymous guest account has no setting of its own, so it gets the org default.
20
+ * - `locale`: the browser's UI language, else the org's `locale`.
21
+ */
22
+ export declare function readMessageContext(t: KernelSchemaDb, input: {
23
+ orgId: string;
24
+ accountId: string;
25
+ /** An anonymous IM guest's IM profile name. */
26
+ senderName?: string | undefined;
27
+ browser?: BrowserContext | undefined;
28
+ }): Promise<MessageContext>;
@@ -0,0 +1,56 @@
1
+ import { readOrgSettings } from "../orgs/settings.service.js";
2
+ import { sanitizeSenderName } from "../runtime/context/run-context.js";
3
+ import { isTimeZone } from "../time-zone.js";
4
+ /** The name of an anonymous IM guest whose IM profile gives none. */
5
+ export const ANONYMOUS_SENDER_NAME = "Anonymous guest";
6
+ /**
7
+ * Who wrote a message and in which time zone and language (run context spec §3.2, §3.4), read in
8
+ * the message's transaction (`t`):
9
+ * - `sender`: the account's display name and org role at send time; the org's anonymous guest
10
+ * account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
11
+ * "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
12
+ * - `timeZone`: the account's setting, else the browser's (when valid), else the org default, else
13
+ * UTC. The anonymous guest account has no setting of its own, so it gets the org default.
14
+ * - `locale`: the browser's UI language, else the org's `locale`.
15
+ */
16
+ export async function readMessageContext(t, input) {
17
+ const row = await t
18
+ .selectFrom("accounts")
19
+ .leftJoin("memberships", (j) => j
20
+ .onRef("memberships.account_id", "=", "accounts.id")
21
+ .on("memberships.org_id", "=", input.orgId))
22
+ .leftJoin("org_anonymous_accounts as anon", (j) => j.onRef("anon.account_id", "=", "accounts.id").on("anon.org_id", "=", input.orgId))
23
+ .select([
24
+ "accounts.display_name",
25
+ "accounts.time_zone",
26
+ "memberships.role",
27
+ "anon.account_id as anonymous",
28
+ ])
29
+ .where("accounts.id", "=", input.accountId)
30
+ .executeTakeFirst();
31
+ const org = await readOrgSettings(t, input.orgId);
32
+ const anonymous = row?.anonymous !== null && row?.anonymous !== undefined;
33
+ let sender;
34
+ if (row !== undefined) {
35
+ const name = anonymous
36
+ ? sanitizeSenderName(input.senderName ?? "") || ANONYMOUS_SENDER_NAME
37
+ : sanitizeSenderName(row.display_name);
38
+ if (name !== "") {
39
+ sender = anonymous
40
+ ? { name, role: "guest", anonymous: true }
41
+ : { name, ...(row.role !== null && { role: row.role }) };
42
+ }
43
+ }
44
+ const own = row?.time_zone ?? null;
45
+ const browser = input.browser?.timeZone;
46
+ const timeZone = own !== null && isTimeZone(own)
47
+ ? own
48
+ : browser !== undefined && isTimeZone(browser)
49
+ ? browser
50
+ : (org.timeZone ?? "UTC");
51
+ return {
52
+ ...(sender !== undefined && { sender }),
53
+ timeZone,
54
+ locale: input.browser?.locale ?? org.locale,
55
+ };
56
+ }
@@ -5,6 +5,7 @@ import { type InvocationRecord, type RenderedInvocation } from "../skills/invoke
5
5
  import type { AttachmentRef } from "./conversations.service.js";
6
6
  import { type AppendEvent, type EventLog } from "./event-log.js";
7
7
  import type { ConversationEvent, LogContentBlock } from "./events.js";
8
+ import { type MessageContext } from "./message-context.js";
8
9
  /**
9
10
  * Queued messages (UI refresh B, spec §5.7): messages a person queued while a run was going. They
10
11
  * are conversation state in PG, not events: the model has not seen them, so they enter the log only
@@ -113,7 +114,7 @@ export declare function storedSkill(invokedAs: string, invoked: RenderedInvocati
113
114
  first: LogContentBlock;
114
115
  };
115
116
  /** The `user_message` a queued item becomes, as `postUserMessage` would have written it. */
116
- export declare function queuedUserMessage(r: QueueRow): AppendEvent;
117
+ export declare function queuedUserMessage(r: QueueRow, context?: MessageContext): AppendEvent;
117
118
  /**
118
119
  * Appends a queued item inside `t` (the caller holds the conversation row lock): its pick, re-planned
119
120
  * against the selection in effect now, becomes a `model_switched` before the `user_message`, as a
@@ -4,6 +4,7 @@ import { ApiError } from "../errors.js";
4
4
  import { recordedSkillBlocked, } from "../skills/invoke.js";
5
5
  import { payloadJson } from "./event-log.js";
6
6
  import { userMessageIdemKey } from "./idem-keys.js";
7
+ import { readMessageContext } from "./message-context.js";
7
8
  import { planSelection, readSelection } from "./selection.js";
8
9
  /**
9
10
  * Queued messages (UI refresh B, spec §5.7): messages a person queued while a run was going. They
@@ -77,7 +78,7 @@ export function storedSkill(invokedAs, invoked) {
77
78
  return { skill: payloadJson(skill), first: { type: "text", text: invoked.text } };
78
79
  }
79
80
  /** The `user_message` a queued item becomes, as `postUserMessage` would have written it. */
80
- export function queuedUserMessage(r) {
81
+ export function queuedUserMessage(r, context = {}) {
81
82
  const attachments = r.attachments;
82
83
  const skill = r.skill;
83
84
  return {
@@ -91,6 +92,7 @@ export function queuedUserMessage(r) {
91
92
  ],
92
93
  ...(attachments.length > 0 && { attachments }),
93
94
  authorAccountId: r.account_id,
95
+ ...context,
94
96
  clientMessageId: r.client_message_id,
95
97
  ...(skill !== null && { skill: skill.record }),
96
98
  },
@@ -120,7 +122,14 @@ export async function appendQueuedIn(t, eventLog, conversationId, r) {
120
122
  payload: { ...next, byAccountId: r.account_id, reason: "user" },
121
123
  });
122
124
  }
123
- events.push(queuedUserMessage(r));
125
+ // run context spec §3.4: no browser values were stored with a leftover row
126
+ const org = await t
127
+ .selectFrom("conversations")
128
+ .select("org_id")
129
+ .where("id", "=", conversationId)
130
+ .executeTakeFirstOrThrow();
131
+ const context = await readMessageContext(t, { orgId: org.org_id, accountId: r.account_id });
132
+ events.push(queuedUserMessage(r, context));
124
133
  const written = await eventLog.appendIn(conversationId, events);
125
134
  if (next !== null) {
126
135
  await t
@@ -16,6 +16,25 @@ export interface AccountsTable {
16
16
  updated_at: Ts;
17
17
  /** 0064: the org the account last chose as current; a new session starts in it. */
18
18
  last_org_id: ColumnType<string | null, string | null | undefined, string | null>;
19
+ /** 0091: the person's time zone (IANA); null follows the browser (run context spec §3.4). */
20
+ time_zone: ColumnType<string | null, string | null | undefined, string | null>;
21
+ /** 0090: the account must set its own password first (a generated initial password). */
22
+ must_change_password: Generated<boolean>;
23
+ }
24
+ /**
25
+ * 0090: a generated initial password sealed for the person who approved the account's creation,
26
+ * read once on the web (Platform tool spec §14.5 item 2).
27
+ */
28
+ export interface AccountInitialPasswordsTable {
29
+ account_id: string;
30
+ recipient_account_id: string;
31
+ conversation_id: string;
32
+ run_id: string;
33
+ call_id: string;
34
+ master_key_id: string;
35
+ ciphertext: Buffer;
36
+ expires_at: Date | string;
37
+ created_at: Ts;
19
38
  }
20
39
  export interface IdentitiesTable {
21
40
  source: string;
@@ -1036,6 +1055,7 @@ export interface ModelUsageTable {
1036
1055
  }
1037
1056
  export interface KernelDatabase {
1038
1057
  accounts: AccountsTable;
1058
+ account_initial_passwords: AccountInitialPasswordsTable;
1039
1059
  identities: IdentitiesTable;
1040
1060
  local_passwords: LocalPasswordsTable;
1041
1061
  orgs: OrgsTable;
@@ -0,0 +1,3 @@
1
+ import type { RouteSchemas } from "../platform/route-schemas.js";
2
+ /** The environments routes the Platform operations mirror (`check:platform-ops` keys). */
3
+ export declare const ENVIRONMENT_ROUTES: readonly RouteSchemas[];
@@ -0,0 +1,14 @@
1
+ import { EnvironmentNameBody, EnvironmentParams } from "./dto.js";
2
+ /** The environments routes the Platform operations mirror (`check:platform-ops` keys). */
3
+ export const ENVIRONMENT_ROUTES = [
4
+ { route: "GET /api/v1/orgs/:orgId/environments" },
5
+ { route: "POST /api/v1/orgs/:orgId/environments", body: EnvironmentNameBody },
6
+ { route: "GET /api/v1/orgs/:orgId/environments/:id", params: EnvironmentParams },
7
+ {
8
+ route: "PATCH /api/v1/orgs/:orgId/environments/:id",
9
+ params: EnvironmentParams,
10
+ body: EnvironmentNameBody,
11
+ },
12
+ { route: "DELETE /api/v1/orgs/:orgId/environments/:id", params: EnvironmentParams },
13
+ { route: "POST /api/v1/orgs/:orgId/environments/:id/files/reset", params: EnvironmentParams },
14
+ ];
@@ -72,10 +72,22 @@ export declare class EnvironmentsService {
72
72
  */
73
73
  create(orgId: string, accountId: string, input: {
74
74
  name: string;
75
- }, actorTokenId?: string): Promise<EnvironmentView>;
75
+ }, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<EnvironmentView>;
76
76
  private insert;
77
+ /**
78
+ * The refusals {@link create} would raise, read without locks or writes (a precheck before a
79
+ * confirmation card): no sandbox provider, the person's limit, a name already taken. Throws the
80
+ * same {@link ApiError}s; a race still ends in `create`'s own refusal.
81
+ */
82
+ checkCreate(orgId: string, accountId: string, name: string): Promise<void>;
83
+ /** How many of the person's conversations work in the environment (read only). */
84
+ boundConversations(orgId: string, accountId: string, id: string): Promise<number>;
85
+ /** The refusals {@link resetFiles} would raise (not found, its provider not current), read only. */
86
+ checkReset(orgId: string, accountId: string, id: string): Promise<void>;
87
+ /** The refusals {@link rename} would raise, read without locks (see {@link checkCreate}). */
88
+ checkRename(orgId: string, accountId: string, id: string, name: string): Promise<void>;
77
89
  /** Renames one of the person's live environments (the default too); see {@link create}. */
78
- rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string): Promise<EnvironmentView>;
90
+ rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<EnvironmentView>;
79
91
  private renameIn;
80
92
  /**
81
93
  * Deletes one of the person's live environments: soft delete, its IM default row cleared, and
@@ -83,7 +95,7 @@ export declare class EnvironmentsService {
83
95
  * destroys the instance and the files). Conversations bound to it keep pointing at it; their
84
96
  * sandbox tools then fail with `environment.not_found`.
85
97
  */
86
- remove(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
98
+ remove(orgId: string, accountId: string, id: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
87
99
  /**
88
100
  * Starts one of the person's environments over with empty files (after
89
101
  * `environment.files_lost`): records the request (audit), then, after the commit, enqueues the
@@ -92,7 +104,7 @@ export declare class EnvironmentsService {
92
104
  * provider must be the current one (`environment.unavailable`). An enqueue failure is thrown
93
105
  * (the request can be repeated: the reset is idempotent).
94
106
  */
95
- resetFiles(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
107
+ resetFiles(orgId: string, accountId: string, id: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
96
108
  /** The check and audit row of {@link resetFiles}, committed before the job is enqueued. */
97
109
  private recordReset;
98
110
  /**
@@ -94,11 +94,11 @@ let EnvironmentsService = class EnvironmentsService {
94
94
  * (case-insensitive) → `environment.name_taken`; `environments.maxPersonal` live ones (the
95
95
  * default counts) → `environment.limit_reached`. Serialized per person by their membership row.
96
96
  */
97
- async create(orgId, accountId, input, actorTokenId) {
98
- const id = await this.insert(orgId, accountId, input.name, actorTokenId);
97
+ async create(orgId, accountId, input, actorTokenId, auditDetail) {
98
+ const id = await this.insert(orgId, accountId, input.name, actorTokenId, auditDetail);
99
99
  return this.get(orgId, accountId, id);
100
100
  }
101
- async insert(orgId, accountId, name, actorTokenId) {
101
+ async insert(orgId, accountId, name, actorTokenId, auditDetail) {
102
102
  const current = this.providers.current();
103
103
  if (!current)
104
104
  throw environmentUnavailable(null);
@@ -142,16 +142,60 @@ let EnvironmentsService = class EnvironmentsService {
142
142
  orgId,
143
143
  action: "environment.created",
144
144
  target: id,
145
- detail: { name },
145
+ detail: { name, ...auditDetail },
146
146
  });
147
147
  return id;
148
148
  }
149
+ /**
150
+ * The refusals {@link create} would raise, read without locks or writes (a precheck before a
151
+ * confirmation card): no sandbox provider, the person's limit, a name already taken. Throws the
152
+ * same {@link ApiError}s; a race still ends in `create`'s own refusal.
153
+ */
154
+ async checkCreate(orgId, accountId, name) {
155
+ if (!this.providers.current())
156
+ throw environmentUnavailable(null);
157
+ const { n } = await this.db
158
+ .selectFrom("environments")
159
+ .select((eb) => eb.fn.countAll().as("n"))
160
+ .where("org_id", "=", orgId)
161
+ .where("owner_kind", "=", "personal")
162
+ .where("owner_account_id", "=", accountId)
163
+ .where("deleted_at", "is", null)
164
+ .executeTakeFirstOrThrow();
165
+ const max = this.config.get().environments.maxPersonal;
166
+ if (Number(n) >= max) {
167
+ throw new ApiError("environment.limit_reached", `You already have ${max} environments in this organization; delete one to create another`);
168
+ }
169
+ await this.assertNameFree(orgId, accountId, name);
170
+ }
171
+ /** How many of the person's conversations work in the environment (read only). */
172
+ async boundConversations(orgId, accountId, id) {
173
+ const { n } = await this.db
174
+ .selectFrom("conversations")
175
+ .select((eb) => eb.fn.countAll().as("n"))
176
+ .where("org_id", "=", orgId)
177
+ .where("account_id", "=", accountId)
178
+ .where("environment_id", "=", id)
179
+ .executeTakeFirstOrThrow();
180
+ return Number(n);
181
+ }
182
+ /** The refusals {@link resetFiles} would raise (not found, its provider not current), read only. */
183
+ async checkReset(orgId, accountId, id) {
184
+ await this.access.usable(orgId, accountId, id);
185
+ }
186
+ /** The refusals {@link rename} would raise, read without locks (see {@link checkCreate}). */
187
+ async checkRename(orgId, accountId, id, name) {
188
+ const before = await this.get(orgId, accountId, id);
189
+ if (before.name?.toLowerCase() !== name.toLowerCase()) {
190
+ await this.assertNameFree(orgId, accountId, name);
191
+ }
192
+ }
149
193
  /** Renames one of the person's live environments (the default too); see {@link create}. */
150
- async rename(orgId, accountId, id, name, actorTokenId) {
151
- await this.renameIn(orgId, accountId, id, name, actorTokenId);
194
+ async rename(orgId, accountId, id, name, actorTokenId, auditDetail) {
195
+ await this.renameIn(orgId, accountId, id, name, actorTokenId, auditDetail);
152
196
  return this.get(orgId, accountId, id);
153
197
  }
154
- async renameIn(orgId, accountId, id, name, actorTokenId) {
198
+ async renameIn(orgId, accountId, id, name, actorTokenId, auditDetail) {
155
199
  const before = await this.lockOwn(orgId, accountId, id);
156
200
  if (before.name === name)
157
201
  return;
@@ -177,7 +221,7 @@ let EnvironmentsService = class EnvironmentsService {
177
221
  orgId,
178
222
  action: "environment.renamed",
179
223
  target: id,
180
- detail: { from: before.name, to: name },
224
+ detail: { from: before.name, to: name, ...auditDetail },
181
225
  });
182
226
  }
183
227
  /**
@@ -186,7 +230,7 @@ let EnvironmentsService = class EnvironmentsService {
186
230
  * destroys the instance and the files). Conversations bound to it keep pointing at it; their
187
231
  * sandbox tools then fail with `environment.not_found`.
188
232
  */
189
- async remove(orgId, accountId, id, actorTokenId) {
233
+ async remove(orgId, accountId, id, actorTokenId, auditDetail) {
190
234
  const before = await this.lockOwn(orgId, accountId, id);
191
235
  await this.db
192
236
  .updateTable("environments")
@@ -205,7 +249,7 @@ let EnvironmentsService = class EnvironmentsService {
205
249
  orgId,
206
250
  action: "environment.deleted",
207
251
  target: id,
208
- detail: { name: before.name, isDefault: before.is_default },
252
+ detail: { name: before.name, isDefault: before.is_default, ...auditDetail },
209
253
  });
210
254
  afterCommit(async () => {
211
255
  try {
@@ -225,12 +269,12 @@ let EnvironmentsService = class EnvironmentsService {
225
269
  * provider must be the current one (`environment.unavailable`). An enqueue failure is thrown
226
270
  * (the request can be repeated: the reset is idempotent).
227
271
  */
228
- async resetFiles(orgId, accountId, id, actorTokenId) {
229
- await this.recordReset(orgId, accountId, id, actorTokenId);
272
+ async resetFiles(orgId, accountId, id, actorTokenId, auditDetail) {
273
+ await this.recordReset(orgId, accountId, id, actorTokenId, auditDetail);
230
274
  await this.sandboxJobs.resetFiles(id);
231
275
  }
232
276
  /** The check and audit row of {@link resetFiles}, committed before the job is enqueued. */
233
- async recordReset(orgId, accountId, id, actorTokenId) {
277
+ async recordReset(orgId, accountId, id, actorTokenId, auditDetail) {
234
278
  await this.access.usable(orgId, accountId, id);
235
279
  await audit(this.db.db, {
236
280
  actorAccountId: accountId,
@@ -238,6 +282,7 @@ let EnvironmentsService = class EnvironmentsService {
238
282
  orgId,
239
283
  action: "environment.files_reset",
240
284
  target: id,
285
+ ...(auditDetail !== undefined && { detail: auditDetail }),
241
286
  });
242
287
  }
243
288
  /**
package/dist/errors.d.ts CHANGED
@@ -15,6 +15,8 @@ export declare const ERROR_CODES: {
15
15
  readonly "account.login_taken": 409;
16
16
  readonly "account.not_found": 404;
17
17
  readonly "account.last_super_admin": 409;
18
+ readonly "account.initial_password_unavailable": 404;
19
+ readonly "account.create_needs_approval": 409;
18
20
  readonly "auth.account_disabled": 403;
19
21
  readonly "auth.required": 401;
20
22
  readonly "auth.token_expired": 401;
@@ -25,6 +27,7 @@ export declare const ERROR_CODES: {
25
27
  readonly "auth.csrf": 403;
26
28
  readonly "auth.rate_limited": 429;
27
29
  readonly "auth.session_required": 403;
30
+ readonly "auth.password_change_required": 403;
28
31
  readonly "token.not_found": 404;
29
32
  readonly "org.not_found": 404;
30
33
  readonly "org.creation_disabled": 403;
package/dist/errors.js CHANGED
@@ -15,6 +15,8 @@ export const ERROR_CODES = {
15
15
  "account.login_taken": 409,
16
16
  "account.not_found": 404,
17
17
  "account.last_super_admin": 409,
18
+ "account.initial_password_unavailable": 404,
19
+ "account.create_needs_approval": 409,
18
20
  "auth.account_disabled": 403,
19
21
  "auth.required": 401,
20
22
  "auth.token_expired": 401,
@@ -25,6 +27,7 @@ export const ERROR_CODES = {
25
27
  "auth.csrf": 403,
26
28
  "auth.rate_limited": 429,
27
29
  "auth.session_required": 403,
30
+ "auth.password_change_required": 403,
28
31
  "token.not_found": 404,
29
32
  "org.not_found": 404,
30
33
  "org.creation_disabled": 403,
@@ -0,0 +1,110 @@
1
+ import { z } from "zod";
2
+ import type { RouteSchemas } from "../platform/route-schemas.js";
3
+ export declare const EvalSetCreateBody: z.ZodObject<{
4
+ agentId: z.ZodString;
5
+ name: z.ZodString;
6
+ description: z.ZodOptional<z.ZodString>;
7
+ rubric: z.ZodOptional<z.ZodString>;
8
+ }, z.core.$strict>;
9
+ export declare const EvalSetPatchBody: z.ZodObject<{
10
+ name: z.ZodOptional<z.ZodString>;
11
+ description: z.ZodOptional<z.ZodString>;
12
+ rubric: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ }, z.core.$strict>;
14
+ export declare const EvalAddCaseBody: z.ZodObject<{
15
+ conversationId: z.ZodString;
16
+ runId: z.ZodString;
17
+ }, z.core.$strict>;
18
+ export declare const EvalSampleBody: z.ZodObject<{
19
+ from: z.ZodOptional<z.ZodISODateTime>;
20
+ to: z.ZodOptional<z.ZodISODateTime>;
21
+ count: z.ZodNumber;
22
+ status: z.ZodOptional<z.ZodEnum<{
23
+ any: "any";
24
+ completed: "completed";
25
+ failed: "failed";
26
+ }>>;
27
+ minToolCalls: z.ZodOptional<z.ZodNumber>;
28
+ }, z.core.$strict>;
29
+ export declare const EvalCandidateSchema: z.ZodObject<{
30
+ agentVersion: z.ZodOptional<z.ZodNumber>;
31
+ model: z.ZodOptional<z.ZodObject<{
32
+ provider: z.ZodString;
33
+ model: z.ZodString;
34
+ }, z.core.$strict>>;
35
+ modelParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
36
+ instructions: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strict>;
38
+ /** `tokenCap` is only type-checked here; the service judges the range (`eval.token_cap_invalid`). */
39
+ export declare const EvalRunEstimateBody: z.ZodObject<{
40
+ mode: z.ZodEnum<{
41
+ run: "run";
42
+ step: "step";
43
+ }>;
44
+ candidate: z.ZodObject<{
45
+ agentVersion: z.ZodOptional<z.ZodNumber>;
46
+ model: z.ZodOptional<z.ZodObject<{
47
+ provider: z.ZodString;
48
+ model: z.ZodString;
49
+ }, z.core.$strict>>;
50
+ modelParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
51
+ instructions: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>;
53
+ judge: z.ZodDefault<z.ZodBoolean>;
54
+ tokenCap: z.ZodOptional<z.ZodNumber>;
55
+ }, z.core.$strict>;
56
+ export declare const EvalRunStartBody: z.ZodObject<{
57
+ mode: z.ZodEnum<{
58
+ run: "run";
59
+ step: "step";
60
+ }>;
61
+ candidate: z.ZodObject<{
62
+ agentVersion: z.ZodOptional<z.ZodNumber>;
63
+ model: z.ZodOptional<z.ZodObject<{
64
+ provider: z.ZodString;
65
+ model: z.ZodString;
66
+ }, z.core.$strict>>;
67
+ modelParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
68
+ instructions: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strict>;
70
+ judge: z.ZodDefault<z.ZodBoolean>;
71
+ tokenCap: z.ZodOptional<z.ZodNumber>;
72
+ }, z.core.$strict>;
73
+ /**
74
+ * `view=light`: no content blocks (result tables and polling; the response carries `asOf`);
75
+ * default `full`. `updatedSince` (ISO time) takes only what changed after it.
76
+ */
77
+ export declare const EvalRunResultsQuery: z.ZodObject<{
78
+ after: z.ZodOptional<z.ZodString>;
79
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
80
+ view: z.ZodDefault<z.ZodEnum<{
81
+ full: "full";
82
+ light: "light";
83
+ }>>;
84
+ updatedSince: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strict>;
86
+ export declare const EvalLabelBody: z.ZodObject<{
87
+ label: z.ZodNullable<z.ZodEnum<{
88
+ fail: "fail";
89
+ pass: "pass";
90
+ }>>;
91
+ note: z.ZodOptional<z.ZodString>;
92
+ }, z.core.$strict>;
93
+ export declare const EvalSetParams: z.ZodObject<{
94
+ setId: z.ZodString;
95
+ }, z.core.$strip>;
96
+ export declare const EvalCaseParams: z.ZodObject<{
97
+ setId: z.ZodString;
98
+ caseId: z.ZodString;
99
+ }, z.core.$strip>;
100
+ export declare const EvalRunParams: z.ZodObject<{
101
+ runId: z.ZodString;
102
+ }, z.core.$strip>;
103
+ export declare const EvalResultParams: z.ZodObject<{
104
+ runId: z.ZodString;
105
+ resultId: z.ZodString;
106
+ }, z.core.$strip>;
107
+ export declare const EvalLabelParams: z.ZodObject<{
108
+ resultId: z.ZodString;
109
+ }, z.core.$strip>;
110
+ export declare const EVAL_ROUTES: readonly RouteSchemas[];