@opengeni/contracts 0.44.1 → 1.0.0

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 (382) hide show
  1. package/dist/agent-authored-durable-text.d.ts +70 -0
  2. package/dist/agent-config.d.ts +869 -0
  3. package/dist/agent-instruction-changes.d.ts +110 -0
  4. package/dist/agent-learning.d.ts +243 -0
  5. package/dist/agent-topology.d.ts +292 -0
  6. package/dist/allowance-refusal.d.ts +9 -0
  7. package/dist/allowance-refusal.js +50 -0
  8. package/dist/allowance-refusal.js.map +1 -0
  9. package/dist/analytics-consent-report.d.ts +19 -0
  10. package/dist/analytics-consent-report.js +10 -0
  11. package/dist/analytics-consent-report.js.map +1 -0
  12. package/dist/api-key-presets.d.ts +19 -0
  13. package/dist/artifact-catalog.d.ts +161 -0
  14. package/dist/artifacts.d.ts +135 -11
  15. package/dist/atlassian-native-retirement.d.ts +16 -0
  16. package/dist/atlassian-native-retirement.js +30 -0
  17. package/dist/atlassian-native-retirement.js.map +1 -0
  18. package/dist/atlassian.d.ts +2 -0
  19. package/dist/atlassian.js +27 -11
  20. package/dist/browser-storage.d.ts +5 -0
  21. package/dist/browser-storage.js +9 -0
  22. package/dist/browser-storage.js.map +1 -0
  23. package/dist/bundled-skills.d.ts +40 -0
  24. package/dist/canonical-human-identities.d.ts +157 -0
  25. package/dist/canonical-human-identities.js +23 -0
  26. package/dist/canonical-human-identities.js.map +1 -0
  27. package/dist/chunk-2ACYHZFB.js +292 -0
  28. package/dist/chunk-2ACYHZFB.js.map +1 -0
  29. package/dist/chunk-2VORLN2R.js +353 -0
  30. package/dist/chunk-2VORLN2R.js.map +1 -0
  31. package/dist/{chunk-Y3MLSLB4.js → chunk-3SIZGL3O.js} +42 -30
  32. package/dist/chunk-3SIZGL3O.js.map +1 -0
  33. package/dist/chunk-46KLD2UH.js +186 -0
  34. package/dist/chunk-46KLD2UH.js.map +1 -0
  35. package/dist/chunk-4JGHSSB7.js +11 -0
  36. package/dist/chunk-4JGHSSB7.js.map +1 -0
  37. package/dist/{chunk-52SGB2QO.js → chunk-5IXYF6XN.js} +50 -10
  38. package/dist/chunk-5IXYF6XN.js.map +1 -0
  39. package/dist/chunk-BCS7WHCK.js +139 -0
  40. package/dist/chunk-BCS7WHCK.js.map +1 -0
  41. package/dist/chunk-EK7NDGFR.js +128 -0
  42. package/dist/chunk-EK7NDGFR.js.map +1 -0
  43. package/dist/{chunk-5UDNP7AO.js → chunk-FZ6BXQHL.js} +78 -38
  44. package/dist/chunk-FZ6BXQHL.js.map +1 -0
  45. package/dist/chunk-GRG7PHWQ.js +25 -0
  46. package/dist/chunk-GRG7PHWQ.js.map +1 -0
  47. package/dist/chunk-JUFK3T4Q.js +80 -0
  48. package/dist/chunk-JUFK3T4Q.js.map +1 -0
  49. package/dist/chunk-KHHZTBP7.js +11 -0
  50. package/dist/chunk-KHHZTBP7.js.map +1 -0
  51. package/dist/chunk-KR2V42UZ.js +187 -0
  52. package/dist/chunk-KR2V42UZ.js.map +1 -0
  53. package/dist/chunk-MZLBPKFE.js +168 -0
  54. package/dist/chunk-MZLBPKFE.js.map +1 -0
  55. package/dist/{chunk-H5BVCZKF.js → chunk-NRMCVHAU.js} +6 -5
  56. package/dist/chunk-NRMCVHAU.js.map +1 -0
  57. package/dist/{chunk-TZ6YEYN4.js → chunk-NVJMJWLL.js} +3 -1
  58. package/dist/chunk-NVJMJWLL.js.map +1 -0
  59. package/dist/chunk-O77VSFYZ.js +70 -0
  60. package/dist/chunk-O77VSFYZ.js.map +1 -0
  61. package/dist/chunk-PX3VCKAU.js +29 -0
  62. package/dist/chunk-PX3VCKAU.js.map +1 -0
  63. package/dist/chunk-QR5D2IQC.js +61 -0
  64. package/dist/chunk-QR5D2IQC.js.map +1 -0
  65. package/dist/chunk-RJ76DRPO.js +117 -0
  66. package/dist/chunk-RJ76DRPO.js.map +1 -0
  67. package/dist/chunk-RKX3NQYS.js +28 -0
  68. package/dist/chunk-RKX3NQYS.js.map +1 -0
  69. package/dist/{chunk-FJBG5E4O.js → chunk-SIOU2K4U.js} +45 -22
  70. package/dist/chunk-SIOU2K4U.js.map +1 -0
  71. package/dist/chunk-TSCDAGET.js +75 -0
  72. package/dist/chunk-TSCDAGET.js.map +1 -0
  73. package/dist/{chunk-LSB7GRLG.js → chunk-TXTQIYCV.js} +15 -11
  74. package/dist/chunk-TXTQIYCV.js.map +1 -0
  75. package/dist/chunk-X7ETVO4P.js +26544 -0
  76. package/dist/chunk-X7ETVO4P.js.map +1 -0
  77. package/dist/{chunk-CADSX6UN.js → chunk-Y3KNXVTD.js} +2 -2
  78. package/dist/chunk-YBW5JSA3.js +251 -0
  79. package/dist/chunk-YBW5JSA3.js.map +1 -0
  80. package/dist/chunk-YRXAWWCU.js +45 -0
  81. package/dist/chunk-YRXAWWCU.js.map +1 -0
  82. package/dist/claude-provider-account-authority.d.ts +18 -0
  83. package/dist/claude-subscription-oauth.d.ts +42 -0
  84. package/dist/claude-subscription-usage.d.ts +159 -0
  85. package/dist/client-error-report.d.ts +109 -0
  86. package/dist/client-error-report.js +87 -0
  87. package/dist/client-error-report.js.map +1 -0
  88. package/dist/code-search.d.ts +52 -0
  89. package/dist/code-search.js +40 -0
  90. package/dist/code-search.js.map +1 -0
  91. package/dist/codex-provider-account-authority.d.ts +23 -0
  92. package/dist/codex-provider-account-authority.js +23 -0
  93. package/dist/codex-provider-account-authority.js.map +1 -0
  94. package/dist/company-brain-governed-writes.d.ts +475 -0
  95. package/dist/company-brain.d.ts +336 -0
  96. package/dist/company-profile.d.ts +566 -0
  97. package/dist/connect.d.ts +325 -0
  98. package/dist/connect.js +191 -0
  99. package/dist/connect.js.map +1 -0
  100. package/dist/connection-account-label.d.ts +2 -0
  101. package/dist/connection-account-label.js +35 -0
  102. package/dist/connection-account-label.js.map +1 -0
  103. package/dist/connection-authority.d.ts +193 -0
  104. package/dist/connection-authority.js +50 -0
  105. package/dist/connection-authority.js.map +1 -0
  106. package/dist/connector-attachments.d.ts +95 -0
  107. package/dist/connector-attachments.js +51 -0
  108. package/dist/connector-attachments.js.map +1 -0
  109. package/dist/connector-tool-permissions.d.ts +73 -0
  110. package/dist/direct-model-provider.d.ts +36 -0
  111. package/dist/editable-artifact-codec-registry.d.ts +16 -7
  112. package/dist/editable-artifact-codec-registry.js +19 -9
  113. package/dist/editable-artifact-committed-transaction.d.ts +2 -2
  114. package/dist/editable-artifact-committed-transaction.js +2 -2
  115. package/dist/editable-artifact-live.d.ts +11 -12
  116. package/dist/editable-artifact-live.js +110 -45
  117. package/dist/editable-artifact-live.js.map +1 -1
  118. package/dist/editable-artifact-serialized-commit.d.ts +2 -1
  119. package/dist/editable-artifact-serialized-commit.js +8 -7
  120. package/dist/editable-artifact-versions.d.ts +20 -5
  121. package/dist/editable-artifact-versions.js +23 -5
  122. package/dist/editable-artifacts.d.ts +2 -0
  123. package/dist/editable-artifacts.js +48 -36
  124. package/dist/external-identities.d.ts +784 -0
  125. package/dist/external-identities.js +44 -0
  126. package/dist/external-identities.js.map +1 -0
  127. package/dist/feedback.d.ts +51 -0
  128. package/dist/github-repository-contracts.d.ts +36 -0
  129. package/dist/github-repository-contracts.js +59 -0
  130. package/dist/github-repository-contracts.js.map +1 -0
  131. package/dist/github-repository.d.ts +14 -0
  132. package/dist/github-repository.js +36 -0
  133. package/dist/github-repository.js.map +1 -0
  134. package/dist/google-drive.d.ts +90 -1
  135. package/dist/google-drive.js +91 -15
  136. package/dist/google-drive.js.map +1 -1
  137. package/dist/governed-learning-activation.d.ts +154 -0
  138. package/dist/governed-learning-evaluator.d.ts +152 -0
  139. package/dist/host-mcp-bindings.d.ts +326 -0
  140. package/dist/host-mcp-bindings.js +252 -0
  141. package/dist/host-mcp-bindings.js.map +1 -0
  142. package/dist/image-generation.d.ts +1 -0
  143. package/dist/index.d.ts +27574 -5374
  144. package/dist/index.js +2531 -177
  145. package/dist/insights-usage.d.ts +877 -0
  146. package/dist/insights-usage.js +509 -0
  147. package/dist/insights-usage.js.map +1 -0
  148. package/dist/interaction.d.ts +1752 -13
  149. package/dist/knowledge-entries.d.ts +982 -0
  150. package/dist/knowledge-preparation.d.ts +237 -0
  151. package/dist/knowledge.d.ts +740 -0
  152. package/dist/managed-auth-session-sets.d.ts +241 -0
  153. package/dist/managed-auth-session-sets.js +191 -0
  154. package/dist/managed-auth-session-sets.js.map +1 -0
  155. package/dist/managed-sign-in-methods.d.ts +56 -0
  156. package/dist/managed-sign-in-methods.js +46 -0
  157. package/dist/managed-sign-in-methods.js.map +1 -0
  158. package/dist/mcp-catalog-limits.d.ts +2 -0
  159. package/dist/mcp-endpoint.d.ts +7 -0
  160. package/dist/mcp-endpoint.js +9 -0
  161. package/dist/mcp-endpoint.js.map +1 -0
  162. package/dist/mcp-oauth.d.ts +71 -0
  163. package/dist/modal-native-proof-v2.d.ts +587 -0
  164. package/dist/modal-native-proof-v2.js +37 -0
  165. package/dist/modal-native-proof-v2.js.map +1 -0
  166. package/dist/model-availability.d.ts +15 -0
  167. package/dist/model-connection-access.d.ts +24 -0
  168. package/dist/model-context-inspector.d.ts +329 -0
  169. package/dist/model-display.d.ts +38 -0
  170. package/dist/model-display.js +134 -0
  171. package/dist/model-display.js.map +1 -0
  172. package/dist/model-picker-order.d.ts +25 -0
  173. package/dist/model-picker-order.js +42 -0
  174. package/dist/model-picker-order.js.map +1 -0
  175. package/dist/organization-access.d.ts +231 -0
  176. package/dist/organization-access.js +34 -0
  177. package/dist/organization-access.js.map +1 -0
  178. package/dist/organization-integration-policy.d.ts +27 -0
  179. package/dist/organization-membership-lifecycle.d.ts +1022 -0
  180. package/dist/organization-model-usage.d.ts +146 -0
  181. package/dist/organization-model-usage.js +67 -0
  182. package/dist/organization-model-usage.js.map +1 -0
  183. package/dist/organization-recovery.d.ts +337 -0
  184. package/dist/organization-recovery.js +37 -0
  185. package/dist/organization-recovery.js.map +1 -0
  186. package/dist/organization-usage.d.ts +138 -0
  187. package/dist/permissions.d.ts +54 -0
  188. package/dist/personal-github.d.ts +320 -0
  189. package/dist/personal-github.js +222 -0
  190. package/dist/personal-github.js.map +1 -0
  191. package/dist/plugin-discovery.d.ts +35 -0
  192. package/dist/plugin-discovery.js +7 -0
  193. package/dist/plugin-discovery.js.map +1 -0
  194. package/dist/preference-registry.d.ts +44 -1
  195. package/dist/product-analytics.d.ts +113 -0
  196. package/dist/product-lifecycle-facts.d.ts +73 -0
  197. package/dist/remember.d.ts +350 -0
  198. package/dist/retained-output.d.ts +8 -0
  199. package/dist/sandbox-file-artifacts.d.ts +57 -0
  200. package/dist/sandbox-provider-command.d.ts +113 -0
  201. package/dist/sandbox-recovery.d.ts +146 -0
  202. package/dist/sandbox-snapshots.d.ts +39 -0
  203. package/dist/session-final-reply.d.ts +6 -0
  204. package/dist/session-final-reply.js +9 -0
  205. package/dist/session-final-reply.js.map +1 -0
  206. package/dist/session-goal-reports.d.ts +21 -0
  207. package/dist/session-history-import.d.ts +947 -0
  208. package/dist/session-list-entries.d.ts +4 -0
  209. package/dist/session-list-entries.js +51 -0
  210. package/dist/session-list-entries.js.map +1 -0
  211. package/dist/session-mcp-projections.d.ts +215 -0
  212. package/dist/session-message-search.d.ts +68 -0
  213. package/dist/session-titles.d.ts +68 -0
  214. package/dist/session-titles.js +25 -0
  215. package/dist/session-titles.js.map +1 -0
  216. package/dist/session-topology-primitives.d.ts +22 -0
  217. package/dist/signup-attribution.d.ts +39 -0
  218. package/dist/site-request-headers.test.d.ts +1 -0
  219. package/dist/site-session-http.d.ts +11 -0
  220. package/dist/site-session-http.js +11 -0
  221. package/dist/site-session-http.js.map +1 -0
  222. package/dist/skill-catalog-context.d.ts +7 -0
  223. package/dist/skill-files.d.ts +12 -0
  224. package/dist/skill-metadata.d.ts +9 -0
  225. package/dist/skill-use.d.ts +61 -0
  226. package/dist/skills.d.ts +185 -0
  227. package/dist/slack-bot-scopes.d.ts +46 -21
  228. package/dist/slack-bot-scopes.js +14 -3
  229. package/dist/slack-rest-mcp.d.ts +31 -0
  230. package/dist/slack-rest-mcp.js +19 -0
  231. package/dist/slack-rest-mcp.js.map +1 -0
  232. package/dist/slack-task-policy.d.ts +294 -0
  233. package/dist/spreadsheet-artifact-commands.d.ts +2 -3
  234. package/dist/spreadsheet-artifact-commands.js +4 -2
  235. package/dist/spreadsheet-artifact-query.js +3 -2
  236. package/dist/subscription-account-pools.d.ts +292 -0
  237. package/dist/task-notes.d.ts +169 -0
  238. package/dist/tool-catalog.d.ts +286 -0
  239. package/dist/tool-result-spill.d.ts +16 -0
  240. package/dist/usage-allowances.d.ts +285 -0
  241. package/dist/usage-allowances.js +49 -0
  242. package/dist/usage-allowances.js.map +1 -0
  243. package/dist/video-generation.d.ts +51 -0
  244. package/dist/video-generation.js +9 -1
  245. package/dist/work-claims.d.ts +411 -0
  246. package/dist/workspace-instruction-policies.d.ts +94 -0
  247. package/dist/workspace-integration-wire.d.ts +36 -0
  248. package/dist/workspace-integration-wire.js +23 -0
  249. package/dist/workspace-integration-wire.js.map +1 -0
  250. package/dist/workspace-integrations.d.ts +948 -0
  251. package/dist/workspace-learning-administration.d.ts +289 -0
  252. package/dist/workspace-learning-policy.d.ts +1 -1
  253. package/dist/workspace-state.d.ts +85 -416
  254. package/dist/xai-provider-account-authority.d.ts +26 -0
  255. package/dist/xai-provider-account-authority.js +9 -0
  256. package/dist/xai-provider-account-authority.js.map +1 -0
  257. package/package.json +146 -1
  258. package/src/agent-authored-durable-text.ts +116 -0
  259. package/src/agent-config.ts +1527 -0
  260. package/src/agent-instruction-changes.ts +98 -0
  261. package/src/agent-learning.ts +161 -0
  262. package/src/agent-topology.ts +69 -0
  263. package/src/allowance-refusal.ts +81 -0
  264. package/src/analytics-consent-report.ts +20 -0
  265. package/src/api-key-presets.ts +25 -0
  266. package/src/artifact-catalog.ts +60 -0
  267. package/src/artifacts.ts +146 -18
  268. package/src/atlassian-native-retirement.ts +33 -0
  269. package/src/browser-storage.ts +10 -0
  270. package/src/bundled-skills.ts +73 -0
  271. package/src/canonical-human-identities.ts +93 -0
  272. package/src/claude-provider-account-authority.ts +12 -0
  273. package/src/claude-subscription-oauth.ts +62 -0
  274. package/src/claude-subscription-usage.ts +59 -0
  275. package/src/client-error-report.ts +184 -0
  276. package/src/code-search.ts +105 -0
  277. package/src/codex-provider-account-authority.ts +37 -0
  278. package/src/company-brain-governed-writes.ts +356 -0
  279. package/src/company-brain.ts +201 -0
  280. package/src/company-profile.ts +167 -1
  281. package/src/connect.ts +202 -0
  282. package/src/connection-account-label.ts +46 -0
  283. package/src/connection-authority.ts +213 -0
  284. package/src/connector-attachments.ts +327 -0
  285. package/src/connector-tool-permissions.ts +60 -0
  286. package/src/direct-model-provider.ts +98 -0
  287. package/src/editable-artifact-codec-registry.ts +55 -17
  288. package/src/editable-artifact-committed-transaction.ts +44 -31
  289. package/src/editable-artifact-live.ts +123 -57
  290. package/src/editable-artifact-serialized-commit.ts +2 -1
  291. package/src/editable-artifact-versions.ts +26 -5
  292. package/src/editable-artifacts.ts +2 -0
  293. package/src/external-identities.ts +285 -0
  294. package/src/feedback.ts +39 -0
  295. package/src/github-repository-contracts.ts +85 -0
  296. package/src/github-repository.ts +59 -0
  297. package/src/google-drive.ts +76 -4
  298. package/src/governed-learning-activation.ts +191 -0
  299. package/src/governed-learning-evaluator.ts +176 -0
  300. package/src/host-mcp-bindings.ts +298 -0
  301. package/src/image-generation.ts +8 -2
  302. package/src/index.ts +8019 -1799
  303. package/src/insights-usage.ts +679 -0
  304. package/src/interaction.ts +1102 -6
  305. package/src/knowledge-entries.ts +375 -0
  306. package/src/knowledge-preparation.ts +50 -0
  307. package/src/knowledge.ts +335 -0
  308. package/src/managed-auth-session-sets.ts +253 -0
  309. package/src/managed-sign-in-methods.ts +37 -0
  310. package/src/mcp-catalog-limits.ts +2 -0
  311. package/src/mcp-endpoint.ts +30 -0
  312. package/src/mcp-oauth.ts +66 -0
  313. package/src/modal-native-proof-v2.ts +398 -0
  314. package/src/model-availability.ts +22 -0
  315. package/src/model-connection-access.ts +17 -0
  316. package/src/model-context-inspector.ts +139 -0
  317. package/src/model-display.ts +195 -0
  318. package/src/model-picker-order.ts +97 -0
  319. package/src/organization-access.ts +176 -0
  320. package/src/organization-integration-policy.ts +54 -0
  321. package/src/organization-membership-lifecycle.ts +559 -0
  322. package/src/organization-model-usage.ts +72 -0
  323. package/src/organization-recovery.ts +186 -0
  324. package/src/organization-usage.ts +79 -0
  325. package/src/permissions.ts +58 -0
  326. package/src/personal-github.ts +267 -0
  327. package/src/plugin-discovery.ts +33 -0
  328. package/src/preference-registry.ts +20 -1
  329. package/src/product-analytics.ts +253 -0
  330. package/src/product-lifecycle-facts.ts +121 -0
  331. package/src/remember.ts +243 -0
  332. package/src/retained-output.ts +20 -3
  333. package/src/sandbox-file-artifacts.ts +73 -0
  334. package/src/sandbox-provider-command.ts +82 -0
  335. package/src/sandbox-recovery.ts +116 -0
  336. package/src/sandbox-snapshots.ts +142 -0
  337. package/src/session-final-reply.ts +16 -0
  338. package/src/session-goal-reports.ts +55 -0
  339. package/src/session-history-import.ts +159 -0
  340. package/src/session-list-entries.ts +91 -0
  341. package/src/session-mcp-projections.ts +273 -0
  342. package/src/session-message-search.ts +54 -0
  343. package/src/session-titles.ts +467 -0
  344. package/src/session-topology-primitives.ts +21 -0
  345. package/src/signup-attribution.ts +81 -0
  346. package/src/site-request-headers.test.ts +28 -0
  347. package/src/site-session-http.ts +63 -0
  348. package/src/skill-catalog-context.ts +50 -0
  349. package/src/skill-files.ts +52 -0
  350. package/src/skill-metadata.ts +40 -0
  351. package/src/skill-use.ts +77 -0
  352. package/src/skills.ts +136 -0
  353. package/src/slack-bot-scopes.ts +106 -42
  354. package/src/slack-rest-mcp.ts +194 -0
  355. package/src/slack-task-policy.ts +215 -0
  356. package/src/spreadsheet-artifact-commands.ts +12 -13
  357. package/src/subscription-account-pools.ts +44 -0
  358. package/src/task-notes.ts +105 -0
  359. package/src/tool-catalog.ts +155 -0
  360. package/src/tool-result-spill.ts +35 -0
  361. package/src/usage-allowances.ts +187 -0
  362. package/src/video-generation.ts +43 -6
  363. package/src/work-claims.ts +266 -0
  364. package/src/workspace-instruction-policies.ts +31 -0
  365. package/src/workspace-integration-wire.ts +99 -0
  366. package/src/workspace-integrations.ts +640 -0
  367. package/src/workspace-learning-administration.ts +88 -0
  368. package/src/workspace-learning-policy.ts +4 -3
  369. package/src/workspace-state.ts +16 -126
  370. package/src/xai-provider-account-authority.ts +38 -0
  371. package/dist/chunk-52SGB2QO.js.map +0 -1
  372. package/dist/chunk-5UDNP7AO.js.map +0 -1
  373. package/dist/chunk-BVGIYW7D.js +0 -11
  374. package/dist/chunk-BVGIYW7D.js.map +0 -1
  375. package/dist/chunk-FJBG5E4O.js.map +0 -1
  376. package/dist/chunk-H5BVCZKF.js.map +0 -1
  377. package/dist/chunk-LSB7GRLG.js.map +0 -1
  378. package/dist/chunk-TZ6YEYN4.js.map +0 -1
  379. package/dist/chunk-VA22KRHS.js +0 -15177
  380. package/dist/chunk-VA22KRHS.js.map +0 -1
  381. package/dist/chunk-Y3MLSLB4.js.map +0 -1
  382. /package/dist/{chunk-CADSX6UN.js.map → chunk-Y3KNXVTD.js.map} +0 -0
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Wire grammar of the content-free web client error beacon
3
+ * (`POST /v1/client-errors`).
4
+ *
5
+ * A report is only a closed error kind, the matched route PATTERN (never a
6
+ * concrete URL), and the bundle revision. The web client that projects a
7
+ * report, the API route that admits it, and the public structured-log
8
+ * projection that prints it all validate against these exact values, so the
9
+ * browser can only send what the API accepts and logs.
10
+ *
11
+ * The same route also admits the closed operational signals below (requests
12
+ * that never reached the server, live-stream health, and web vitals). They
13
+ * follow the same rules: closed values only, a route pattern or page label,
14
+ * never a URL, message, identifier, or user content.
15
+ */
16
+ export const CLIENT_ERRORS_PATH = "/v1/client-errors";
17
+
18
+ export const CLIENT_ERROR_KINDS = [
19
+ "route_error",
20
+ "unhandled_rejection",
21
+ "window_error",
22
+ "chunk_load",
23
+ ] as const;
24
+ export type ClientErrorKind = (typeof CLIENT_ERROR_KINDS)[number];
25
+
26
+ /** Largest accepted report body. A valid report is well under 256 bytes. */
27
+ export const CLIENT_ERROR_REPORT_MAX_BYTES = 512;
28
+
29
+ const ROUTE_SEGMENT = String.raw`(?:[a-z]+(?:-[a-z]+)*|\$[A-Za-z][A-Za-z0-9]{0,31})`;
30
+
31
+ /**
32
+ * A route pattern of at most 160 characters that is `/`, `unknown`, or up to
33
+ * twelve `/`-separated segments that are each either a lowercase literal
34
+ * (`variable-sets`) or a `$param` placeholder. The grammar excludes digits in
35
+ * literals, so a concrete id cannot pass as one.
36
+ */
37
+ export const CLIENT_ERROR_ROUTE_PATTERN = new RegExp(
38
+ String.raw`^(?=.{1,160}$)(?:unknown|/|(?:/${ROUTE_SEGMENT}){1,12})$`,
39
+ );
40
+
41
+ /** The bundle revision token (a commit SHA, `dev`, or `unknown`). */
42
+ export const CLIENT_ERROR_REVISION_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
43
+
44
+ export type ClientErrorReport = { kind: ClientErrorKind; route: string; revision: string };
45
+
46
+ /**
47
+ * Content-free operational signals that share the error beacon route. A
48
+ * signal report carries a `signal` discriminator and only closed values; a
49
+ * report without `signal` is a {@link ClientErrorReport}. Older API servers
50
+ * reject signal reports as invalid, so the extension is backward compatible in
51
+ * both directions.
52
+ */
53
+ export const CLIENT_SIGNALS = ["request_failure", "stream", "web_vital"] as const;
54
+ export type ClientSignal = (typeof CLIENT_SIGNALS)[number];
55
+
56
+ /**
57
+ * Key product mutations whose failure before any HTTP response is counted.
58
+ * `send_message` includes sends the server queues behind an active turn.
59
+ */
60
+ export const CLIENT_REQUEST_ACTIONS = [
61
+ "create_session",
62
+ "send_message",
63
+ "steer_message",
64
+ "composer_submit",
65
+ "retry_turn",
66
+ "connect_integration",
67
+ "connect_model",
68
+ "checkout_start",
69
+ ] as const;
70
+ export type ClientRequestAction = (typeof CLIENT_REQUEST_ACTIONS)[number];
71
+
72
+ /**
73
+ * Why a request never produced an HTTP response: the browser reported no
74
+ * connectivity (`offline`), the client's own deadline expired (`timeout`), or
75
+ * the transport failed (`network`). Cancellations the user or the app
76
+ * initiated are never reported.
77
+ */
78
+ export const CLIENT_REQUEST_FAILURE_REASONS = ["network", "timeout", "offline"] as const;
79
+ export type ClientRequestFailureReason = (typeof CLIENT_REQUEST_FAILURE_REASONS)[number];
80
+
81
+ /** Browser live streams: one session's event stream, or the workspace live stream. */
82
+ export const CLIENT_STREAMS = ["session", "workspace"] as const;
83
+ export type ClientStream = (typeof CLIENT_STREAMS)[number];
84
+
85
+ /**
86
+ * Live stream health: a live stream dropped and started reconnecting
87
+ * (`reconnect`), stopped reconnecting (`reconnect_exhausted`), or stayed
88
+ * disconnected for longer than the long-disconnect threshold while the tab
89
+ * was visible (`long_disconnect`).
90
+ */
91
+ export const CLIENT_STREAM_EVENTS = [
92
+ "reconnect",
93
+ "reconnect_exhausted",
94
+ "long_disconnect",
95
+ ] as const;
96
+ export type ClientStreamEvent = (typeof CLIENT_STREAM_EVENTS)[number];
97
+
98
+ /** Core Web Vitals plus time to first byte, measured once per document. */
99
+ export const CLIENT_WEB_VITAL_METRICS = ["lcp", "inp", "cls", "ttfb"] as const;
100
+ export type ClientWebVitalMetric = (typeof CLIENT_WEB_VITAL_METRICS)[number];
101
+
102
+ /**
103
+ * Largest accepted value: seconds for the timing metrics, the unitless layout
104
+ * shift score for `cls`.
105
+ */
106
+ export const CLIENT_WEB_VITAL_MAX_VALUE: Readonly<Record<ClientWebVitalMetric, number>> = {
107
+ lcp: 600,
108
+ inp: 600,
109
+ cls: 100,
110
+ ttfb: 600,
111
+ };
112
+
113
+ /**
114
+ * The closed page labels of the web console's product-journey projection
115
+ * (`journeyPage` in apps/web/src/lib/analytics-journey.ts; a drift test keeps
116
+ * the two identical). Workspace pages are the first path segment after
117
+ * `/workspaces/<id>/`; the rest are exact top-level routes.
118
+ */
119
+ export const CLIENT_PAGES = [
120
+ "sessions",
121
+ "priority",
122
+ "plugins",
123
+ "capabilities",
124
+ "documents",
125
+ "state",
126
+ "memory",
127
+ "schedules",
128
+ "artifacts",
129
+ "settings",
130
+ "organization",
131
+ "insights",
132
+ "machines",
133
+ "files",
134
+ "agents",
135
+ "variable-sets",
136
+ "environments",
137
+ "rigs",
138
+ "home",
139
+ "session-link",
140
+ "identity-link",
141
+ "checkout-return",
142
+ "integration-return",
143
+ "device",
144
+ "connect-agent",
145
+ "reset-password",
146
+ "setup-account",
147
+ "account-auth",
148
+ "personal-security",
149
+ "other",
150
+ ] as const;
151
+ export type ClientPage = (typeof CLIENT_PAGES)[number];
152
+
153
+ export type ClientRequestFailureReport = {
154
+ signal: "request_failure";
155
+ action: ClientRequestAction;
156
+ reason: ClientRequestFailureReason;
157
+ route: string;
158
+ revision: string;
159
+ };
160
+
161
+ export type ClientStreamReport = {
162
+ signal: "stream";
163
+ stream: ClientStream;
164
+ event: ClientStreamEvent;
165
+ route: string;
166
+ revision: string;
167
+ };
168
+
169
+ export type ClientWebVitalReport = {
170
+ signal: "web_vital";
171
+ metric: ClientWebVitalMetric;
172
+ page: ClientPage;
173
+ /** Seconds for timing metrics, the unitless score for `cls`. */
174
+ value: number;
175
+ revision: string;
176
+ };
177
+
178
+ export type ClientSignalReport =
179
+ | ClientRequestFailureReport
180
+ | ClientStreamReport
181
+ | ClientWebVitalReport;
182
+
183
+ /** Every body the beacon route accepts. */
184
+ export type ClientBeaconReport = ClientErrorReport | ClientSignalReport;
@@ -0,0 +1,105 @@
1
+ // Resolvers for the optional Jev-backed `code_search` agent tool. A separate
2
+ // subpath keeps them out of browser bundles; only server code decides.
3
+
4
+ /**
5
+ * Directories holding platform credential material that `code_search` never
6
+ * searches or reads, as path segments matched at any depth: OpenGeni's
7
+ * sandbox state (`.opengeni/`: Codemode bearer tokens, Git credential files
8
+ * and bindings), the Azure CLI login cache (`.azure/`, from the sandbox's
9
+ * service-principal login with HOME=/workspace) and a Connected Machine
10
+ * agent's enrollment credentials (`.config/opengeni/`). The sandbox channel
11
+ * enforces this list; `@opengeni/jev` keeps the same list for its engine, and
12
+ * a worker test pins that the two agree.
13
+ */
14
+ export const CODE_SEARCH_CREDENTIAL_DIRS: readonly (readonly string[])[] = [
15
+ [".opengeni"],
16
+ [".azure"],
17
+ [".config", "opengeni"],
18
+ ];
19
+
20
+ /**
21
+ * The deployment half of the `code_search` decision. `split` gives the tool to
22
+ * a fixed half of sessions (see `codeSearchSessionInExperiment`) so staging can
23
+ * compare sessions with and without it.
24
+ */
25
+ export type CodeSearchWorkspaceDefault = "off" | "on" | "split";
26
+ export type CodeSearchDeploymentPolicy = {
27
+ available: boolean;
28
+ workspaceDefault: CodeSearchWorkspaceDefault;
29
+ };
30
+
31
+ /**
32
+ * What a workspace gets: the deployment decides first, so nothing enables the
33
+ * tool where the deployment does not offer it. Otherwise an explicit workspace
34
+ * choice wins, and an absent, null or malformed setting follows the deployment
35
+ * default. Only this field is read, so an invalid sibling setting cannot turn
36
+ * an explicit Off back into the deployment default.
37
+ */
38
+ export function resolveWorkspaceCodeSearchMode(
39
+ settings: unknown,
40
+ deployment: CodeSearchDeploymentPolicy,
41
+ ): CodeSearchWorkspaceDefault {
42
+ if (!deployment.available) return "off";
43
+ const explicit = explicitWorkspaceCodeSearchSetting(settings);
44
+ if (explicit === true) return "on";
45
+ if (explicit === false) return "off";
46
+ return deployment.workspaceDefault;
47
+ }
48
+
49
+ function explicitWorkspaceCodeSearchSetting(settings: unknown): boolean | undefined {
50
+ const explicit =
51
+ typeof settings === "object" && settings !== null
52
+ ? (settings as { codeSearchEnabled?: unknown }).codeSearchEnabled
53
+ : undefined;
54
+ return typeof explicit === "boolean" ? explicit : undefined;
55
+ }
56
+
57
+ /**
58
+ * Fixed per-session half for the `split` experiment: 32-bit FNV-1a of the
59
+ * session id, low bit 0 gets the tool. Deterministic and dependency-free, so
60
+ * a root session's arm can be recomputed from its id. Child sessions inherit
61
+ * their parent's decision instead.
62
+ */
63
+ export function codeSearchSessionInExperiment(sessionId: string): boolean {
64
+ let hash = 0x811c9dc5;
65
+ for (let index = 0; index < sessionId.length; index++) {
66
+ hash ^= sessionId.charCodeAt(index);
67
+ hash = Math.imul(hash, 0x01000193) >>> 0;
68
+ }
69
+ return (hash & 1) === 0;
70
+ }
71
+
72
+ /**
73
+ * The decision frozen on a new root session when it is created. Later changes
74
+ * to the workspace setting or the deployment mode never turn the tool on for a
75
+ * session that was created without it.
76
+ */
77
+ export function resolveSessionCodeSearchEnabled(
78
+ settings: unknown,
79
+ deployment: CodeSearchDeploymentPolicy,
80
+ sessionId: string,
81
+ ): boolean {
82
+ const mode = resolveWorkspaceCodeSearchMode(settings, deployment);
83
+ return mode === "on" || (mode === "split" && codeSearchSessionInExperiment(sessionId));
84
+ }
85
+
86
+ /**
87
+ * Whether a turn of this session gets `code_search`. Only a session frozen on
88
+ * at creation can have it. The deployment (mode off or no usable key) and an
89
+ * explicit workspace Off still pause it in running sessions, because they stop
90
+ * repository content going to Jev; undoing that switch-off gives it back to
91
+ * sessions frozen on. Each such change costs every affected session one
92
+ * prompt-cache miss, which is accepted for a deliberate switch. Nothing else
93
+ * changes the tool list of a running session.
94
+ */
95
+ export function codeSearchEnabledForTurn(
96
+ frozen: boolean | null | undefined,
97
+ settings: unknown,
98
+ deployment: CodeSearchDeploymentPolicy,
99
+ ): boolean {
100
+ return (
101
+ frozen === true &&
102
+ deployment.available &&
103
+ explicitWorkspaceCodeSearchSetting(settings) !== false
104
+ );
105
+ }
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+
3
+ const PositiveSafeInteger = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
4
+
5
+ /**
6
+ * Opaque authority frozen at a Codex provider-account acceptance boundary.
7
+ *
8
+ * The snapshot deliberately carries no organization, membership, credential,
9
+ * provider-account, subject, label, quota, token, or plan identity. A later
10
+ * activation slice may use the user generation only together with separately
11
+ * authorized durable state; this value is never sufficient authority alone.
12
+ */
13
+ export const CodexProviderAccountAuthoritySnapshotV1 = z.discriminatedUnion("scope", [
14
+ z
15
+ .object({
16
+ version: z.literal(1),
17
+ scope: z.literal("workspace"),
18
+ })
19
+ .strict(),
20
+ z
21
+ .object({
22
+ version: z.literal(1),
23
+ scope: z.literal("user"),
24
+ authorityGeneration: PositiveSafeInteger,
25
+ })
26
+ .strict(),
27
+ ]);
28
+
29
+ export type CodexProviderAccountAuthoritySnapshotV1 = z.infer<
30
+ typeof CodexProviderAccountAuthoritySnapshotV1
31
+ >;
32
+
33
+ /** Explicit compatibility value for all pre-foundation accepted work. */
34
+ export const LEGACY_WORKSPACE_CODEX_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V1 = {
35
+ version: 1,
36
+ scope: "workspace",
37
+ } as const satisfies CodexProviderAccountAuthoritySnapshotV1;
@@ -0,0 +1,356 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_MAX_CHARS,
4
+ AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_TOO_LONG_MESSAGE,
5
+ AGENT_AUTHORED_PREFERENCE_CONTENT_MAX_CHARS,
6
+ AGENT_AUTHORED_PREFERENCE_CONTENT_TOO_LONG_MESSAGE,
7
+ } from "./agent-authored-durable-text";
8
+ import {
9
+ PREFERENCE_REGISTRY_DESCRIPTOR_DESCRIPTION_MAX_CHARS,
10
+ PREFERENCE_REGISTRY_STABLE_KEY_MAX_CHARS,
11
+ PREFERENCE_REGISTRY_TITLE_MAX_CHARS,
12
+ PreferenceRegistryConflictStrategy,
13
+ PreferenceRegistryStableKey,
14
+ } from "./preference-registry";
15
+ import { GovernedLearningActivationDestination } from "./governed-learning-activation";
16
+ import {
17
+ GovernedLearningDecisionOutcome,
18
+ GovernedLearningDecisionReason,
19
+ } from "./governed-learning-evaluator";
20
+ import { WorkspaceInstructionPolicyTarget } from "./workspace-instruction-policies";
21
+ import { WorkspaceLearningPolicyEffectiveMode } from "./workspace-learning-policy";
22
+
23
+ const boundedReason = z.string().trim().min(1).max(4_096);
24
+ const operationId = z.string().uuid();
25
+ const exactEvidence = {
26
+ claimId: z.string().uuid(),
27
+ evidenceId: z.string().uuid(),
28
+ };
29
+
30
+ /** Exact accepted-attempt authority. It is validated again inside the write transaction. */
31
+ export const CompanyBrainGovernedWriteAttempt = z
32
+ .object({
33
+ accountId: z.string().uuid(),
34
+ workspaceId: z.string().uuid(),
35
+ sessionId: z.string().uuid(),
36
+ turnId: z.string().uuid(),
37
+ attemptId: z.string().uuid(),
38
+ executionGeneration: z.number().int().positive(),
39
+ })
40
+ .strict();
41
+ export type CompanyBrainGovernedWriteAttempt = z.infer<typeof CompanyBrainGovernedWriteAttempt>;
42
+
43
+ export const ProposeWorkspaceKnowledgeClaimRequest = z
44
+ .object({
45
+ kind: z.literal("propose_knowledge"),
46
+ operationId,
47
+ ...exactEvidence,
48
+ reason: boundedReason,
49
+ })
50
+ .strict();
51
+ export type ProposeWorkspaceKnowledgeClaimRequest = z.infer<
52
+ typeof ProposeWorkspaceKnowledgeClaimRequest
53
+ >;
54
+
55
+ export const CorrectWorkspaceKnowledgeClaimRequest = z
56
+ .object({
57
+ kind: z.literal("correct_knowledge"),
58
+ operationId,
59
+ ...exactEvidence,
60
+ replacesClaimId: z.string().uuid(),
61
+ reason: boundedReason,
62
+ })
63
+ .strict();
64
+ export type CorrectWorkspaceKnowledgeClaimRequest = z.infer<
65
+ typeof CorrectWorkspaceKnowledgeClaimRequest
66
+ >;
67
+
68
+ /**
69
+ * Promote one still-active task-tree note into a normalized, workspace-local
70
+ * Knowledge claim proposal. The note text is the exact fact value and source
71
+ * evidence; callers may describe the subject and predicate but cannot widen
72
+ * authority or supply replacement source bytes.
73
+ */
74
+ export const PromoteTaskNoteKnowledgeRequest = z
75
+ .object({
76
+ kind: z.literal("promote_task_note_knowledge"),
77
+ operationId,
78
+ noteId: z.string().uuid(),
79
+ expectedNoteVersion: z.literal(1),
80
+ entityType: z
81
+ .string()
82
+ .trim()
83
+ .min(1)
84
+ .max(96)
85
+ .regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
86
+ normalizedKey: z.string().trim().min(1).max(512),
87
+ displayName: z.string().trim().min(1).max(512),
88
+ predicateKey: z
89
+ .string()
90
+ .trim()
91
+ .min(1)
92
+ .max(128)
93
+ .regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
94
+ confidenceBps: z.number().int().min(0).max(10_000),
95
+ reason: boundedReason,
96
+ })
97
+ .strict();
98
+ export type PromoteTaskNoteKnowledgeRequest = z.infer<typeof PromoteTaskNoteKnowledgeRequest>;
99
+
100
+ /**
101
+ * Promote the exact immutable Task-note bytes into an inactive mandatory-rule
102
+ * draft. The caller selects only the governed target and active-head baseline;
103
+ * it cannot replace the source content or activate the draft.
104
+ */
105
+ export const PromoteTaskNoteInstructionPolicyRequest = z
106
+ .strictObject({
107
+ kind: z.literal("promote_task_note_instruction_policy"),
108
+ operationId,
109
+ noteId: z.string().uuid(),
110
+ expectedNoteVersion: z.literal(1),
111
+ entityType: z
112
+ .string()
113
+ .trim()
114
+ .min(1)
115
+ .max(96)
116
+ .regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
117
+ normalizedKey: z.string().trim().min(1).max(512),
118
+ displayName: z.string().trim().min(1).max(512),
119
+ predicateKey: z
120
+ .string()
121
+ .trim()
122
+ .min(1)
123
+ .max(128)
124
+ .regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
125
+ confidenceBps: z.number().int().min(0).max(10_000),
126
+ target: WorkspaceInstructionPolicyTarget,
127
+ expectedCurrentRevisionId: z.string().uuid().nullable(),
128
+ expectedActivationVersion: z.number().int().nonnegative(),
129
+ reason: boundedReason,
130
+ })
131
+ .superRefine((value, context) => {
132
+ const target = WorkspaceInstructionPolicyTarget.safeParse(value.target);
133
+ if (!target.success) {
134
+ for (const issue of target.error.issues) {
135
+ context.addIssue({ ...issue, path: ["target", ...issue.path] });
136
+ }
137
+ }
138
+ });
139
+ export type PromoteTaskNoteInstructionPolicyRequest = z.infer<
140
+ typeof PromoteTaskNoteInstructionPolicyRequest
141
+ >;
142
+
143
+ /**
144
+ * Promote the exact immutable Task-note bytes into an inactive workspace
145
+ * preference proposal. Descriptor metadata is caller-supplied and bounded,
146
+ * while the full proposal content always comes from the admitted note.
147
+ */
148
+ export const PromoteTaskNotePreferenceRequest = z.strictObject({
149
+ kind: z.literal("promote_task_note_preference"),
150
+ operationId,
151
+ noteId: z.string().uuid(),
152
+ expectedNoteVersion: z.literal(1),
153
+ entityType: z
154
+ .string()
155
+ .trim()
156
+ .min(1)
157
+ .max(96)
158
+ .regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
159
+ normalizedKey: z.string().trim().min(1).max(512),
160
+ displayName: z.string().trim().min(1).max(512),
161
+ predicateKey: z
162
+ .string()
163
+ .trim()
164
+ .min(1)
165
+ .max(128)
166
+ .regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
167
+ confidenceBps: z.number().int().min(0).max(10_000),
168
+ stableKey: PreferenceRegistryStableKey.max(PREFERENCE_REGISTRY_STABLE_KEY_MAX_CHARS),
169
+ title: z.string().trim().min(1).max(PREFERENCE_REGISTRY_TITLE_MAX_CHARS),
170
+ description: z.string().trim().min(1).max(PREFERENCE_REGISTRY_DESCRIPTOR_DESCRIPTION_MAX_CHARS),
171
+ precedenceRank: z.number().int().min(-1_000).max(1_000).default(0),
172
+ conflictStrategy: PreferenceRegistryConflictStrategy.default("override"),
173
+ conflictsWith: z.array(PreferenceRegistryStableKey).max(32).default([]),
174
+ expiresAt: z.string().datetime({ offset: true }).nullable().default(null),
175
+ reason: boundedReason,
176
+ });
177
+ export type PromoteTaskNotePreferenceRequest = z.infer<typeof PromoteTaskNotePreferenceRequest>;
178
+
179
+ export const ProposeWorkspaceInstructionPolicyRequest = z
180
+ .strictObject({
181
+ kind: z.literal("propose_instruction_policy"),
182
+ operationId,
183
+ ...exactEvidence,
184
+ target: WorkspaceInstructionPolicyTarget,
185
+ // Instruction drafts use the same storage bound as the human editor.
186
+ // Prompt composition retains its separate byte limit after activation.
187
+ content: z
188
+ .string()
189
+ .min(1)
190
+ .max(
191
+ AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_MAX_CHARS,
192
+ AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_TOO_LONG_MESSAGE,
193
+ )
194
+ .refine((value) => value.trim().length > 0, "instruction proposal must not be blank"),
195
+ expectedCurrentRevisionId: z.string().uuid().nullable(),
196
+ expectedActivationVersion: z.number().int().nonnegative(),
197
+ reason: boundedReason,
198
+ })
199
+ .superRefine((value, context) => {
200
+ const target = WorkspaceInstructionPolicyTarget.safeParse(value.target);
201
+ if (!target.success) {
202
+ for (const issue of target.error.issues) {
203
+ context.addIssue({ ...issue, path: ["target", ...issue.path] });
204
+ }
205
+ }
206
+ });
207
+ export type ProposeWorkspaceInstructionPolicyRequest = z.infer<
208
+ typeof ProposeWorkspaceInstructionPolicyRequest
209
+ >;
210
+
211
+ export const ProposeWorkspacePreferenceRequest = z.strictObject({
212
+ kind: z.literal("propose_preference"),
213
+ operationId,
214
+ ...exactEvidence,
215
+ stableKey: PreferenceRegistryStableKey.max(PREFERENCE_REGISTRY_STABLE_KEY_MAX_CHARS),
216
+ title: z.string().trim().min(1).max(PREFERENCE_REGISTRY_TITLE_MAX_CHARS),
217
+ description: z.string().trim().min(1).max(PREFERENCE_REGISTRY_DESCRIPTOR_DESCRIPTION_MAX_CHARS),
218
+ // Agent-authored: the descriptor pair is prompt-composed in every session and
219
+ // the content is retrieved on demand, so it stays short.
220
+ content: z
221
+ .string()
222
+ .min(1)
223
+ .max(
224
+ AGENT_AUTHORED_PREFERENCE_CONTENT_MAX_CHARS,
225
+ AGENT_AUTHORED_PREFERENCE_CONTENT_TOO_LONG_MESSAGE,
226
+ )
227
+ .refine((value) => value.trim().length > 0, "preference proposal must not be blank"),
228
+ precedenceRank: z.number().int().min(-1_000).max(1_000).default(0),
229
+ conflictStrategy: PreferenceRegistryConflictStrategy.default("override"),
230
+ conflictsWith: z.array(PreferenceRegistryStableKey).max(32).default([]),
231
+ expiresAt: z.string().datetime({ offset: true }).nullable().default(null),
232
+ reason: boundedReason,
233
+ });
234
+ export type ProposeWorkspacePreferenceRequest = z.infer<typeof ProposeWorkspacePreferenceRequest>;
235
+
236
+ /**
237
+ * Destination selection is explicit and structured. There is deliberately no
238
+ * generic "remember" operation, classifier, personal scope, or active authority.
239
+ */
240
+ export const CompanyBrainGovernedWriteRequest = z.discriminatedUnion("kind", [
241
+ ProposeWorkspaceKnowledgeClaimRequest,
242
+ CorrectWorkspaceKnowledgeClaimRequest,
243
+ PromoteTaskNoteKnowledgeRequest,
244
+ PromoteTaskNoteInstructionPolicyRequest,
245
+ PromoteTaskNotePreferenceRequest,
246
+ ProposeWorkspaceInstructionPolicyRequest,
247
+ ProposeWorkspacePreferenceRequest,
248
+ ]);
249
+ export type CompanyBrainGovernedWriteRequest = z.infer<typeof CompanyBrainGovernedWriteRequest>;
250
+
251
+ export const CompanyBrainGovernedWriteDestination = z.enum([
252
+ "knowledge",
253
+ "instruction_policy",
254
+ "preference",
255
+ ]);
256
+ export type CompanyBrainGovernedWriteDestination = z.infer<
257
+ typeof CompanyBrainGovernedWriteDestination
258
+ >;
259
+
260
+ export const CompanyBrainGovernedWriteReceipt = z.object({
261
+ operationId,
262
+ inputHash: z.string().regex(/^[0-9a-f]{64}$/),
263
+ workspaceId: z.string().uuid(),
264
+ destination: CompanyBrainGovernedWriteDestination,
265
+ outcome: z.literal("proposed"),
266
+ claimId: z.string().uuid(),
267
+ evidenceId: z.string().uuid(),
268
+ relationId: z.string().uuid().nullable(),
269
+ reviewId: z.string().uuid().nullable(),
270
+ knowledgeChangeProposalId: z.string().uuid().nullable(),
271
+ destinationProposalId: z.string().uuid().nullable(),
272
+ destinationRevisionId: z.string().uuid().nullable(),
273
+ taskNoteSource: z
274
+ .object({
275
+ noteId: z.string().uuid(),
276
+ rootSessionId: z.string().uuid(),
277
+ noteVersion: z.literal(1),
278
+ textHash: z.string().regex(/^[0-9a-f]{64}$/),
279
+ })
280
+ .nullable()
281
+ .optional(),
282
+ effectiveBoundary: z.literal("human_review_required"),
283
+ rollback: z.object({
284
+ supported: z.literal(false),
285
+ mechanism: z.literal("not_applicable_proposal_only"),
286
+ }),
287
+ });
288
+ export type CompanyBrainGovernedWriteReceipt = z.infer<typeof CompanyBrainGovernedWriteReceipt>;
289
+
290
+ /**
291
+ * Policy routing is deliberately separate from destination admission. The
292
+ * immutable accepted-attempt snapshot decides whether derived evidence may
293
+ * create a proposal; the destination still owns activation and rollback.
294
+ */
295
+ export const CompanyBrainLearningPolicyDecision = z.enum([
296
+ "blocked",
297
+ "proposal_created",
298
+ "activation_requested",
299
+ "activated",
300
+ ]);
301
+ export type CompanyBrainLearningPolicyDecision = z.infer<typeof CompanyBrainLearningPolicyDecision>;
302
+
303
+ /**
304
+ * Content-free summary of the governed-learning decision receipt recorded for
305
+ * a Ways-of-working proposal (instruction policy or preference). Knowledge
306
+ * destinations create no `knowledge_change_proposals` row and are therefore
307
+ * never evaluated; they report `null`.
308
+ */
309
+ export const CompanyBrainLearningDecisionSummary = z.object({
310
+ receiptId: z.string().uuid(),
311
+ outcome: GovernedLearningDecisionOutcome,
312
+ automaticEligible: z.boolean(),
313
+ reasons: z.array(GovernedLearningDecisionReason).max(16),
314
+ });
315
+ export type CompanyBrainLearningDecisionSummary = z.infer<
316
+ typeof CompanyBrainLearningDecisionSummary
317
+ >;
318
+
319
+ /**
320
+ * Bounded, content-free reason why evaluation or activation did not complete.
321
+ * The proposal write itself remains durable regardless.
322
+ */
323
+ export const CompanyBrainLearningStepFailure = z.object({
324
+ stage: z.enum(["evaluation", "activation"]),
325
+ code: z.enum(["authority", "conflict", "invalid_operation", "unavailable"]),
326
+ });
327
+ export type CompanyBrainLearningStepFailure = z.infer<typeof CompanyBrainLearningStepFailure>;
328
+
329
+ export const CompanyBrainLearningPolicyRouteReceipt = z.object({
330
+ operationId,
331
+ workspaceId: z.string().uuid(),
332
+ effectivePolicy: WorkspaceLearningPolicyEffectiveMode,
333
+ decision: CompanyBrainLearningPolicyDecision,
334
+ write: CompanyBrainGovernedWriteReceipt.nullable(),
335
+ learning: CompanyBrainLearningDecisionSummary.nullable().default(null),
336
+ learningFailure: CompanyBrainLearningStepFailure.nullable().default(null),
337
+ activation: z.object({
338
+ requested: z.boolean(),
339
+ activated: z.boolean(),
340
+ boundary: z.enum([
341
+ "policy_off",
342
+ "human_review",
343
+ "destination_authority",
344
+ "not_eligible",
345
+ "human_activation_required",
346
+ "activated",
347
+ ]),
348
+ receiptId: z.string().uuid().nullable().default(null),
349
+ destination: GovernedLearningActivationDestination.nullable().default(null),
350
+ destinationRevisionId: z.string().uuid().nullable().default(null),
351
+ effectiveAt: z.string().datetime().nullable().default(null),
352
+ }),
353
+ });
354
+ export type CompanyBrainLearningPolicyRouteReceipt = z.infer<
355
+ typeof CompanyBrainLearningPolicyRouteReceipt
356
+ >;