@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,11 @@
1
+ // src/session-final-reply.ts
2
+ var EMPTY_FINAL_REPLY_NOTICE = "The model returned no final reply after a reply reminder. Completed work is preserved; the goal and later updates are unaffected.";
3
+ function turnCompletedWithEmptyFinalReply(payload) {
4
+ return payload !== null && typeof payload === "object" && !Array.isArray(payload) && payload.emptyFinalReply === true;
5
+ }
6
+
7
+ export {
8
+ EMPTY_FINAL_REPLY_NOTICE,
9
+ turnCompletedWithEmptyFinalReply
10
+ };
11
+ //# sourceMappingURL=chunk-KHHZTBP7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-final-reply.ts"],"sourcesContent":["/** A response-quality notice, not a failed turn or a completed deliverable. */\nexport const EMPTY_FINAL_REPLY_NOTICE =\n \"The model returned no final reply after a reply reminder. Completed work is preserved; the goal and later updates are unaffected.\";\n\nexport type EmptyFinalReplyCompletion = {\n emptyFinalReply: true;\n};\n\nexport function turnCompletedWithEmptyFinalReply(payload: unknown): boolean {\n return (\n payload !== null &&\n typeof payload === \"object\" &&\n !Array.isArray(payload) &&\n (payload as { emptyFinalReply?: unknown }).emptyFinalReply === true\n );\n}\n"],"mappings":";AACO,IAAM,2BACX;AAMK,SAAS,iCAAiC,SAA2B;AAC1E,SACE,YAAY,QACZ,OAAO,YAAY,YACnB,CAAC,MAAM,QAAQ,OAAO,KACrB,QAA0C,oBAAoB;AAEnE;","names":[]}
@@ -0,0 +1,187 @@
1
+ import {
2
+ Permission
3
+ } from "./chunk-QR5D2IQC.js";
4
+
5
+ // src/external-identities.ts
6
+ import { z } from "zod";
7
+ var encoder = new TextEncoder();
8
+ function opaqueText(maxBytes) {
9
+ return z.string().min(1).max(maxBytes).refine(
10
+ (value) => !value.includes("\0") && !/[\uD800-\uDFFF]/u.test(value) && encoder.encode(value).byteLength <= maxBytes,
11
+ {
12
+ message: `Identifier must be valid PostgreSQL Unicode text of at most ${maxBytes} UTF-8 bytes`
13
+ }
14
+ );
15
+ }
16
+ var externalId = opaqueText(1024);
17
+ var source = opaqueText(200);
18
+ var externalSubject = z.string().regex(/^external_user:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$(?![\s\S])/);
19
+ var nativeSubject = z.string().min(1).max(1024).regex(/^user:[^\r\n]+$(?![\s\S])/);
20
+ var ExternalIdentityReference = z.object({
21
+ externalId,
22
+ source: source.default("default")
23
+ }).strict();
24
+ var AddExternalWorkspaceMemberRequest = z.object({
25
+ identity: ExternalIdentityReference,
26
+ permissions: z.array(Permission).min(1).max(Permission.options.length),
27
+ /** Opt-in durable operation identity; unkeyed legacy requests are not cancellable. */
28
+ operationId: z.string().uuid().optional()
29
+ }).strict();
30
+ var ExternalIdentityLookup = z.discriminatedUnion("found", [
31
+ z.object({ found: z.literal(false) }).strict(),
32
+ z.object({
33
+ found: z.literal(true),
34
+ subjectId: externalSubject,
35
+ organizationMembershipId: z.string().uuid(),
36
+ identityStatus: z.enum(["active", "disabled", "revoked"]),
37
+ identityAuthorizationRevision: z.number().int().positive().safe(),
38
+ membershipStatus: z.enum(["provisioning", "active", "suspended", "revoked"]),
39
+ membershipAuthorizationRevision: z.number().int().positive().safe()
40
+ }).strict()
41
+ ]);
42
+ var CancelExternalWorkspaceMemberGrantRequest = z.object({
43
+ operationId: z.string().uuid(),
44
+ cancelGrantOperationId: z.string().uuid()
45
+ }).strict().refine((value) => value.operationId !== value.cancelGrantOperationId, {
46
+ message: "Revocation and grant must use different operation identities"
47
+ });
48
+ var CancelExternalWorkspaceMemberGrantResponse = z.object({
49
+ removed: z.boolean(),
50
+ replay: z.boolean(),
51
+ fencedGrantOperationId: z.string().uuid()
52
+ }).strict();
53
+ var UpdateExternalWorkspaceMemberRequest = z.object({
54
+ permissions: z.array(Permission).min(1).max(Permission.options.length),
55
+ operationId: z.string().uuid()
56
+ }).strict();
57
+ var UpdateExternalWorkspaceMemberResponse = z.object({
58
+ subjectId: z.string(),
59
+ organizationMembershipId: z.string().uuid(),
60
+ permissions: z.array(Permission),
61
+ /** True when a previously held permission was removed. */
62
+ narrowed: z.boolean(),
63
+ replay: z.boolean()
64
+ }).strict();
65
+ var UpdateExternalIdentityMembershipRequest = z.object({
66
+ kind: z.enum(["suspend", "reactivate", "offboard"]),
67
+ expectedAuthorizationRevision: z.number().int().positive().safe(),
68
+ operationId: z.string().uuid(),
69
+ reason: z.string().max(512).optional()
70
+ }).strict();
71
+ var ExternalActorSelection = z.discriminatedUnion("mode", [
72
+ z.object({ mode: z.literal("external"), identity: ExternalIdentityReference }).strict(),
73
+ z.object({
74
+ mode: z.literal("linked_native"),
75
+ identity: ExternalIdentityReference,
76
+ linkId: z.string().uuid(),
77
+ expectedLinkRevision: z.number().int().positive().safe()
78
+ }).strict()
79
+ ]);
80
+ var ExternalIdentity = z.object({
81
+ id: z.string().uuid(),
82
+ accountId: z.string().uuid(),
83
+ source,
84
+ externalId,
85
+ subjectId: externalSubject,
86
+ organizationMembershipId: z.string().uuid(),
87
+ personalWorkspaceId: z.string().uuid(),
88
+ status: z.enum(["active", "disabled", "revoked"]),
89
+ authorizationRevision: z.number().int().positive().safe()
90
+ }).strict();
91
+ var ExternalActorAttribution = z.object({
92
+ accountId: z.string().uuid(),
93
+ authenticatingApiKeyId: z.string().uuid(),
94
+ externalIdentityId: z.string().uuid(),
95
+ externalSubjectId: externalSubject,
96
+ externalAuthorizationRevision: z.number().int().positive().safe(),
97
+ effectiveSubjectId: z.string().min(1).max(1024),
98
+ actingMode: z.enum(["external", "linked_native"]),
99
+ linkId: z.string().uuid().optional(),
100
+ linkRevision: z.number().int().positive().safe().optional()
101
+ }).strict().superRefine((value, context) => {
102
+ if (value.actingMode === "external") {
103
+ if (value.effectiveSubjectId !== value.externalSubjectId || value.linkId !== void 0 || value.linkRevision !== void 0) {
104
+ context.addIssue({
105
+ code: "custom",
106
+ message: "External mode cannot delegate native identity"
107
+ });
108
+ }
109
+ } else if (!value.linkId || !value.linkRevision || !nativeSubject.safeParse(value.effectiveSubjectId).success) {
110
+ context.addIssue({
111
+ code: "custom",
112
+ message: "Linked mode requires exact native delegation provenance"
113
+ });
114
+ }
115
+ });
116
+ var ExternalActorContinuation = z.object({
117
+ identity: ExternalIdentityReference,
118
+ actor: ExternalActorAttribution
119
+ }).strict();
120
+ var ExternalIdentityLink = z.object({
121
+ id: z.string().uuid(),
122
+ accountId: z.string().uuid(),
123
+ externalIdentityId: z.string().uuid(),
124
+ externalIdentity: ExternalIdentityReference.optional(),
125
+ nativeSubjectId: nativeSubject.nullable(),
126
+ status: z.enum(["pending", "active", "revoked", "expired"]),
127
+ revision: z.number().int().positive().safe(),
128
+ permissions: z.array(Permission).max(Permission.options.length),
129
+ expiresAt: z.string().datetime({ offset: true }).nullable()
130
+ }).strict().refine(
131
+ (value) => value.status !== "active" || value.nativeSubjectId !== null,
132
+ "An active link requires a confirmed native identity"
133
+ );
134
+ var ExternalIdentityLinkPage = z.object({
135
+ links: z.array(ExternalIdentityLink).max(50),
136
+ nextCursor: z.string().uuid().nullable()
137
+ }).strict();
138
+ var BeginExternalIdentityLinkRequest = z.object({
139
+ permissions: z.array(Permission).min(1).max(Permission.options.length),
140
+ expiresAt: z.string().datetime({ offset: true }).nullable().default(null)
141
+ }).strict();
142
+ var ConfirmExternalIdentityLinkRequest = z.object({
143
+ challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
144
+ expectedRevision: z.number().int().positive().safe(),
145
+ permissions: z.array(Permission).min(1).max(Permission.options.length)
146
+ }).strict();
147
+ var BeginExternalIdentityLinkResponse = z.object({
148
+ link: ExternalIdentityLink,
149
+ challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
150
+ confirmBefore: z.string().datetime({ offset: true })
151
+ }).strict();
152
+ var ExternalIdentityLinkPreview = z.object({
153
+ link: ExternalIdentityLink,
154
+ externalIdentity: ExternalIdentityReference,
155
+ nativeSubjectId: nativeSubject,
156
+ organizationId: z.string().uuid()
157
+ }).strict();
158
+ var ExternalLinkWorkSnapshot = z.object({
159
+ identity: ExternalIdentityReference,
160
+ actor: ExternalActorAttribution.refine((value) => value.actingMode === "linked_native"),
161
+ permissions: z.array(Permission).max(Permission.options.length),
162
+ /** Absent on historical snapshots, whose legacy semantics are preserved. */
163
+ permissionMode: z.enum(["legacy", "explicit"]).optional()
164
+ }).strict();
165
+
166
+ export {
167
+ ExternalIdentityReference,
168
+ AddExternalWorkspaceMemberRequest,
169
+ ExternalIdentityLookup,
170
+ CancelExternalWorkspaceMemberGrantRequest,
171
+ CancelExternalWorkspaceMemberGrantResponse,
172
+ UpdateExternalWorkspaceMemberRequest,
173
+ UpdateExternalWorkspaceMemberResponse,
174
+ UpdateExternalIdentityMembershipRequest,
175
+ ExternalActorSelection,
176
+ ExternalIdentity,
177
+ ExternalActorAttribution,
178
+ ExternalActorContinuation,
179
+ ExternalIdentityLink,
180
+ ExternalIdentityLinkPage,
181
+ BeginExternalIdentityLinkRequest,
182
+ ConfirmExternalIdentityLinkRequest,
183
+ BeginExternalIdentityLinkResponse,
184
+ ExternalIdentityLinkPreview,
185
+ ExternalLinkWorkSnapshot
186
+ };
187
+ //# sourceMappingURL=chunk-KR2V42UZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/external-identities.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Permission } from \"./permissions\";\n\n// External identifiers are opaque, case-sensitive strings. In particular a\n// native-looking identifier is still host data, never a native subject claim.\n// Bound bytes, not just JS code units: these values share a PostgreSQL B-tree\n// index entry. Never normalize/truncate an identifier to make it fit, and reject\n// text that the driver would replace or PostgreSQL cannot represent.\nconst encoder = new TextEncoder();\nfunction opaqueText(maxBytes: number) {\n return z\n .string()\n .min(1)\n .max(maxBytes)\n .refine(\n (value) =>\n !value.includes(\"\\0\") &&\n !/[\\uD800-\\uDFFF]/u.test(value) &&\n encoder.encode(value).byteLength <= maxBytes,\n {\n message: `Identifier must be valid PostgreSQL Unicode text of at most ${maxBytes} UTF-8 bytes`,\n },\n );\n}\nconst externalId = opaqueText(1024);\nconst source = opaqueText(200);\nconst externalSubject = z\n .string()\n .regex(/^external_user:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$(?![\\s\\S])/);\nconst nativeSubject = z\n .string()\n .min(1)\n .max(1024)\n .regex(/^user:[^\\r\\n]+$(?![\\s\\S])/);\nexport const ExternalIdentityReference = z\n .object({\n externalId,\n source: source.default(\"default\"),\n })\n .strict();\nexport type ExternalIdentityReference = z.infer<typeof ExternalIdentityReference>;\n\nexport const AddExternalWorkspaceMemberRequest = z\n .object({\n identity: ExternalIdentityReference,\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n /** Opt-in durable operation identity; unkeyed legacy requests are not cancellable. */\n operationId: z.string().uuid().optional(),\n })\n .strict();\nexport type AddExternalWorkspaceMemberRequest = z.infer<typeof AddExternalWorkspaceMemberRequest>;\n\n/** Content-free service lookup, including identities which can no longer act. */\nexport const ExternalIdentityLookup = z.discriminatedUnion(\"found\", [\n z.object({ found: z.literal(false) }).strict(),\n z\n .object({\n found: z.literal(true),\n subjectId: externalSubject,\n organizationMembershipId: z.string().uuid(),\n identityStatus: z.enum([\"active\", \"disabled\", \"revoked\"]),\n identityAuthorizationRevision: z.number().int().positive().safe(),\n membershipStatus: z.enum([\"provisioning\", \"active\", \"suspended\", \"revoked\"]),\n membershipAuthorizationRevision: z.number().int().positive().safe(),\n })\n .strict(),\n]);\nexport type ExternalIdentityLookup = z.infer<typeof ExternalIdentityLookup>;\n\n/** Terminal withdrawal of this external member's workspace access, also fencing\n * an exact earlier onboarding operation whether or not it has reached the API. */\nexport const CancelExternalWorkspaceMemberGrantRequest = z\n .object({\n operationId: z.string().uuid(),\n cancelGrantOperationId: z.string().uuid(),\n })\n .strict()\n .refine((value) => value.operationId !== value.cancelGrantOperationId, {\n message: \"Revocation and grant must use different operation identities\",\n });\nexport type CancelExternalWorkspaceMemberGrantRequest = z.infer<\n typeof CancelExternalWorkspaceMemberGrantRequest\n>;\nexport const CancelExternalWorkspaceMemberGrantResponse = z\n .object({\n removed: z.boolean(),\n replay: z.boolean(),\n fencedGrantOperationId: z.string().uuid(),\n })\n .strict();\nexport type CancelExternalWorkspaceMemberGrantResponse = z.infer<\n typeof CancelExternalWorkspaceMemberGrantResponse\n>;\n\n/** Replace an existing external member's permissions in one shared workspace.\n * Keyed and idempotent like a grant; narrowing forces live authority to\n * re-check but never cancels or tears down work. */\nexport const UpdateExternalWorkspaceMemberRequest = z\n .object({\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n operationId: z.string().uuid(),\n })\n .strict();\nexport type UpdateExternalWorkspaceMemberRequest = z.infer<\n typeof UpdateExternalWorkspaceMemberRequest\n>;\nexport const UpdateExternalWorkspaceMemberResponse = z\n .object({\n subjectId: z.string(),\n organizationMembershipId: z.string().uuid(),\n permissions: z.array(Permission),\n /** True when a previously held permission was removed. */\n narrowed: z.boolean(),\n replay: z.boolean(),\n })\n .strict();\nexport type UpdateExternalWorkspaceMemberResponse = z.infer<\n typeof UpdateExternalWorkspaceMemberResponse\n>;\n\n/** Uses the organization membership ID returned by lazy identity admission.\n * Reactivation restores admission only, not revoked work or workspace grants. */\nexport const UpdateExternalIdentityMembershipRequest = z\n .object({\n kind: z.enum([\"suspend\", \"reactivate\", \"offboard\"]),\n expectedAuthorizationRevision: z.number().int().positive().safe(),\n operationId: z.string().uuid(),\n reason: z.string().max(512).optional(),\n })\n .strict();\nexport type UpdateExternalIdentityMembershipRequest = z.infer<\n typeof UpdateExternalIdentityMembershipRequest\n>;\n\nexport const ExternalActorSelection = z.discriminatedUnion(\"mode\", [\n z.object({ mode: z.literal(\"external\"), identity: ExternalIdentityReference }).strict(),\n z\n .object({\n mode: z.literal(\"linked_native\"),\n identity: ExternalIdentityReference,\n linkId: z.string().uuid(),\n expectedLinkRevision: z.number().int().positive().safe(),\n })\n .strict(),\n]);\nexport type ExternalActorSelection = z.infer<typeof ExternalActorSelection>;\n\nexport const ExternalIdentity = z\n .object({\n id: z.string().uuid(),\n accountId: z.string().uuid(),\n source,\n externalId,\n subjectId: externalSubject,\n organizationMembershipId: z.string().uuid(),\n personalWorkspaceId: z.string().uuid(),\n status: z.enum([\"active\", \"disabled\", \"revoked\"]),\n authorizationRevision: z.number().int().positive().safe(),\n })\n .strict();\nexport type ExternalIdentity = z.infer<typeof ExternalIdentity>;\n\n// Audit attribution, not authentication. Only the canonical access resolver\n// may establish provenance; accepting this JSON from a browser proves nothing.\nexport const ExternalActorAttribution = z\n .object({\n accountId: z.string().uuid(),\n authenticatingApiKeyId: z.string().uuid(),\n externalIdentityId: z.string().uuid(),\n externalSubjectId: externalSubject,\n externalAuthorizationRevision: z.number().int().positive().safe(),\n effectiveSubjectId: z.string().min(1).max(1024),\n actingMode: z.enum([\"external\", \"linked_native\"]),\n linkId: z.string().uuid().optional(),\n linkRevision: z.number().int().positive().safe().optional(),\n })\n .strict()\n .superRefine((value, context) => {\n if (value.actingMode === \"external\") {\n if (\n value.effectiveSubjectId !== value.externalSubjectId ||\n value.linkId !== undefined ||\n value.linkRevision !== undefined\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"External mode cannot delegate native identity\",\n });\n }\n } else if (\n !value.linkId ||\n !value.linkRevision ||\n !nativeSubject.safeParse(value.effectiveSubjectId).success\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"Linked mode requires exact native delegation provenance\",\n });\n }\n });\nexport type ExternalActorAttribution = z.infer<typeof ExternalActorAttribution>;\n\n/** Server-signed/encrypted continuation data, never sufficient live authority. */\nexport const ExternalActorContinuation = z\n .object({\n identity: ExternalIdentityReference,\n actor: ExternalActorAttribution,\n })\n .strict();\nexport type ExternalActorContinuation = z.infer<typeof ExternalActorContinuation>;\n\nexport const ExternalIdentityLink = z\n .object({\n id: z.string().uuid(),\n accountId: z.string().uuid(),\n externalIdentityId: z.string().uuid(),\n externalIdentity: ExternalIdentityReference.optional(),\n nativeSubjectId: nativeSubject.nullable(),\n status: z.enum([\"pending\", \"active\", \"revoked\", \"expired\"]),\n revision: z.number().int().positive().safe(),\n permissions: z.array(Permission).max(Permission.options.length),\n expiresAt: z.string().datetime({ offset: true }).nullable(),\n })\n .strict()\n .refine(\n (value) => value.status !== \"active\" || value.nativeSubjectId !== null,\n \"An active link requires a confirmed native identity\",\n );\nexport type ExternalIdentityLink = z.infer<typeof ExternalIdentityLink>;\n\nexport const ExternalIdentityLinkPage = z\n .object({\n links: z.array(ExternalIdentityLink).max(50),\n nextCursor: z.string().uuid().nullable(),\n })\n .strict();\nexport type ExternalIdentityLinkPage = z.infer<typeof ExternalIdentityLinkPage>;\n\n/** A native confirmation may narrow this request, never broaden it. The\n * challenge is delivered once to the host and is not an authentication token. */\nexport const BeginExternalIdentityLinkRequest = z\n .object({\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n expiresAt: z.string().datetime({ offset: true }).nullable().default(null),\n })\n .strict();\nexport type BeginExternalIdentityLinkRequest = z.input<typeof BeginExternalIdentityLinkRequest>;\nexport const ConfirmExternalIdentityLinkRequest = z\n .object({\n challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),\n expectedRevision: z.number().int().positive().safe(),\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n })\n .strict();\nexport type ConfirmExternalIdentityLinkRequest = z.infer<typeof ConfirmExternalIdentityLinkRequest>;\nexport const BeginExternalIdentityLinkResponse = z\n .object({\n link: ExternalIdentityLink,\n challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),\n confirmBefore: z.string().datetime({ offset: true }),\n })\n .strict();\nexport type BeginExternalIdentityLinkResponse = z.infer<typeof BeginExternalIdentityLinkResponse>;\nexport const ExternalIdentityLinkPreview = z\n .object({\n link: ExternalIdentityLink,\n externalIdentity: ExternalIdentityReference,\n nativeSubjectId: nativeSubject,\n organizationId: z.string().uuid(),\n })\n .strict();\nexport type ExternalIdentityLinkPreview = z.infer<typeof ExternalIdentityLinkPreview>;\n\n/** Immutable accepted-work restriction, not a browser credential. Original key\n * identity remains audit-only; durable use validates the live link and members. */\nexport const ExternalLinkWorkSnapshot = z\n .object({\n identity: ExternalIdentityReference,\n actor: ExternalActorAttribution.refine((value) => value.actingMode === \"linked_native\"),\n permissions: z.array(Permission).max(Permission.options.length),\n /** Absent on historical snapshots, whose legacy semantics are preserved. */\n permissionMode: z.enum([\"legacy\", \"explicit\"]).optional(),\n })\n .strict();\nexport type ExternalLinkWorkSnapshot = z.infer<typeof ExternalLinkWorkSnapshot>;\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAQlB,IAAM,UAAU,IAAI,YAAY;AAChC,SAAS,WAAW,UAAkB;AACpC,SAAO,EACJ,OAAO,EACP,IAAI,CAAC,EACL,IAAI,QAAQ,EACZ;AAAA,IACC,CAAC,UACC,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,mBAAmB,KAAK,KAAK,KAC9B,QAAQ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AE,IAAI,WAAW,QAAQ,MAAM;AAAA,EACrE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,IAAI;AAC1E,CAAC,EACA,OAAO;AAEH,IAAM,qCAAqC,EAC/C,OAAO;AAAA,EACN,WAAW,EAAE,OAAO,EAAE,MAAM,qBAAqB;AAAA,EACjD,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK;AAAA,EACnD,aAAa,EAAE,MAAM,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,WAAW,QAAQ,MAAM;AACvE,CAAC,EACA,OAAO;AAEH,IAAM,oCAAoC,EAC9C,OAAO;AAAA,EACN,MAAM;AAAA,EACN,WAAW,EAAE,OAAO,EAAE,MAAM,qBAAqB;AAAA,EACjD,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,CAAC;AACrD,CAAC,EACA,OAAO;AAEH,IAAM,8BAA8B,EACxC,OAAO;AAAA,EACN,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB,EAAE,OAAO,EAAE,KAAK;AAClC,CAAC,EACA,OAAO;AAKH,IAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,UAAU;AAAA,EACV,OAAO,yBAAyB,OAAO,CAAC,UAAU,MAAM,eAAe,eAAe;AAAA,EACtF,aAAa,EAAE,MAAM,UAAU,EAAE,IAAI,WAAW,QAAQ,MAAM;AAAA;AAAA,EAE9D,gBAAgB,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC,EAAE,SAAS;AAC1D,CAAC,EACA,OAAO;","names":[]}
@@ -0,0 +1,168 @@
1
+ // src/slack-rest-mcp.ts
2
+ var OFFICIAL_SLACK_MCP_URL = "https://mcp.slack.com/mcp";
3
+ var SLACK_REST_API_BASE = "https://slack.com/api/";
4
+ var OPENGENI_SLACK_REST_USER_SCOPES = [
5
+ "channels:read",
6
+ "groups:read",
7
+ "im:read",
8
+ "mpim:read",
9
+ "channels:history",
10
+ "groups:history",
11
+ "im:history",
12
+ "mpim:history",
13
+ "users:read",
14
+ "im:write",
15
+ "chat:write"
16
+ ];
17
+ function normalizeSlackScopes(scopes) {
18
+ return [
19
+ ...new Set(
20
+ (typeof scopes === "string" ? [scopes] : scopes ?? []).flatMap((entry) => entry.split(/[\s,]+/u)).filter(Boolean)
21
+ )
22
+ ].sort();
23
+ }
24
+ var conversationScopes = ["channels:read", "groups:read", "im:read", "mpim:read"];
25
+ var historyScopes = ["channels:history", "groups:history", "im:history", "mpim:history"];
26
+ var channel = { type: "string", description: "Slack conversation ID, such as C123 or D123." };
27
+ var cursor = { type: "string", maxLength: 4096, description: "Cursor from the previous page." };
28
+ var directoryPage = { type: "integer", minimum: 1, maximum: 100, default: 100 };
29
+ var historyPage = { type: "integer", minimum: 1, maximum: 15, default: 15 };
30
+ var timestamp = { type: "string", pattern: "^[0-9]+\\.[0-9]+$" };
31
+ function tool(name, description, properties, required = [], mutation = false) {
32
+ return {
33
+ name,
34
+ description,
35
+ inputSchema: { type: "object", properties, required, additionalProperties: false },
36
+ annotations: {
37
+ readOnlyHint: !mutation,
38
+ destructiveHint: false,
39
+ idempotentHint: !mutation,
40
+ openWorldHint: true
41
+ }
42
+ };
43
+ }
44
+ var SLACK_REST_MCP_TOOLS = [
45
+ tool(
46
+ "slack_list_channels",
47
+ "Lists one page of conversations visible to your connected Slack account. Conversation types without a granted read scope are omitted.",
48
+ {
49
+ types: {
50
+ type: "array",
51
+ items: { type: "string", enum: ["public_channel", "private_channel", "im", "mpim"] },
52
+ minItems: 1,
53
+ maxItems: 4
54
+ },
55
+ cursor,
56
+ limit: directoryPage,
57
+ exclude_archived: { type: "boolean", default: true }
58
+ }
59
+ ),
60
+ tool(
61
+ "slack_get_channel_info",
62
+ "Gets metadata for one conversation visible to your connected Slack account.",
63
+ { channel },
64
+ ["channel"]
65
+ ),
66
+ tool(
67
+ "slack_list_channel_members",
68
+ "Lists one page of members in a visible channel or group conversation.",
69
+ { channel, cursor, limit: directoryPage },
70
+ ["channel"]
71
+ ),
72
+ tool("slack_list_users", "Lists one page of users in the connected Slack workspace.", {
73
+ cursor,
74
+ limit: directoryPage
75
+ }),
76
+ tool(
77
+ "slack_get_user_info",
78
+ "Gets a user's profile by their Slack user ID. Email is included only when Slack has granted that scope.",
79
+ { user: { type: "string" } },
80
+ ["user"]
81
+ ),
82
+ tool(
83
+ "slack_read_channel",
84
+ "Reads one page of at most 15 messages from a selected conversation. Slack history limits are shared across the workspace. No automatic pagination or backfill.",
85
+ {
86
+ channel,
87
+ cursor,
88
+ limit: historyPage,
89
+ oldest: timestamp,
90
+ latest: timestamp,
91
+ inclusive: { type: "boolean", default: false }
92
+ },
93
+ ["channel"]
94
+ ),
95
+ tool(
96
+ "slack_read_thread",
97
+ "Reads one page of at most 15 messages in a selected thread. Slack thread limits are shared across the workspace. No automatic pagination or backfill.",
98
+ {
99
+ channel,
100
+ ts: { ...timestamp, description: "Thread root message timestamp." },
101
+ cursor,
102
+ limit: historyPage
103
+ },
104
+ ["channel", "ts"]
105
+ ),
106
+ tool(
107
+ "slack_open_dm",
108
+ "Opens or resumes a direct message with one Slack user as your connected account.",
109
+ { user: { type: "string" } },
110
+ ["user"],
111
+ true
112
+ ),
113
+ tool(
114
+ "slack_send_message",
115
+ "Sends a message as your connected Slack account. Supply thread_ts to reply in a thread. Review the recipient and text before approving. An uncertain submission is never automatically retried.",
116
+ {
117
+ channel,
118
+ text: { type: "string", minLength: 1, maxLength: 4e4 },
119
+ thread_ts: { ...timestamp, description: "Optional thread root timestamp for a reply." },
120
+ unfurl_links: { type: "boolean", default: false },
121
+ unfurl_media: { type: "boolean", default: false }
122
+ },
123
+ ["channel", "text"],
124
+ true
125
+ )
126
+ ];
127
+ var REQUIRED_ANY_SCOPES = {
128
+ slack_list_channels: conversationScopes,
129
+ slack_get_channel_info: conversationScopes,
130
+ slack_list_channel_members: ["channels:read", "groups:read", "mpim:read"],
131
+ slack_list_users: ["users:read"],
132
+ slack_get_user_info: ["users:read"],
133
+ slack_read_channel: historyScopes,
134
+ slack_read_thread: historyScopes,
135
+ slack_open_dm: ["im:write"],
136
+ slack_send_message: ["chat:write"]
137
+ };
138
+ function slackRestMcpToolsForScopes(scopes) {
139
+ const granted = new Set(normalizeSlackScopes(scopes));
140
+ return SLACK_REST_MCP_TOOLS.filter(
141
+ (entry) => REQUIRED_ANY_SCOPES[entry.name]?.some((scope) => granted.has(scope))
142
+ ).map((entry) => ({
143
+ ...entry,
144
+ inputSchema: {
145
+ ...entry.inputSchema,
146
+ required: [...entry.inputSchema.required],
147
+ properties: { ...entry.inputSchema.properties }
148
+ },
149
+ annotations: { ...entry.annotations }
150
+ }));
151
+ }
152
+ var SLACK_CONVERSATION_READ_SCOPE_BY_TYPE = {
153
+ public_channel: "channels:read",
154
+ private_channel: "groups:read",
155
+ im: "im:read",
156
+ mpim: "mpim:read"
157
+ };
158
+
159
+ export {
160
+ OFFICIAL_SLACK_MCP_URL,
161
+ SLACK_REST_API_BASE,
162
+ OPENGENI_SLACK_REST_USER_SCOPES,
163
+ normalizeSlackScopes,
164
+ SLACK_REST_MCP_TOOLS,
165
+ slackRestMcpToolsForScopes,
166
+ SLACK_CONVERSATION_READ_SCOPE_BY_TYPE
167
+ };
168
+ //# sourceMappingURL=chunk-MZLBPKFE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/slack-rest-mcp.ts"],"sourcesContent":["/** The catalog and OAuth identity stay stable while calls use the ordinary Web API. */\nexport const OFFICIAL_SLACK_MCP_URL = \"https://mcp.slack.com/mcp\";\nexport const SLACK_REST_API_BASE = \"https://slack.com/api/\";\n\nexport const OPENGENI_SLACK_REST_USER_SCOPES = [\n \"channels:read\",\n \"groups:read\",\n \"im:read\",\n \"mpim:read\",\n \"channels:history\",\n \"groups:history\",\n \"im:history\",\n \"mpim:history\",\n \"users:read\",\n \"im:write\",\n \"chat:write\",\n] as const;\n\n/** Slack returns comma-delimited scopes, including in existing saved grants. */\nexport function normalizeSlackScopes(\n scopes: readonly string[] | string | undefined | null,\n): string[] {\n return [\n ...new Set(\n (typeof scopes === \"string\" ? [scopes] : (scopes ?? []))\n .flatMap((entry) => entry.split(/[\\s,]+/u))\n .filter(Boolean),\n ),\n ].sort();\n}\n\nexport type SlackRestMcpTool = {\n name: string;\n description: string;\n inputSchema: {\n type: \"object\";\n properties: Record<string, unknown>;\n required: string[];\n additionalProperties: false;\n };\n annotations: {\n readOnlyHint: boolean;\n destructiveHint: false;\n idempotentHint: boolean;\n openWorldHint: true;\n };\n};\n\nconst conversationScopes = [\"channels:read\", \"groups:read\", \"im:read\", \"mpim:read\"];\nconst historyScopes = [\"channels:history\", \"groups:history\", \"im:history\", \"mpim:history\"];\nconst channel = { type: \"string\", description: \"Slack conversation ID, such as C123 or D123.\" };\nconst cursor = { type: \"string\", maxLength: 4096, description: \"Cursor from the previous page.\" };\nconst directoryPage = { type: \"integer\", minimum: 1, maximum: 100, default: 100 };\nconst historyPage = { type: \"integer\", minimum: 1, maximum: 15, default: 15 };\nconst timestamp = { type: \"string\", pattern: \"^[0-9]+\\\\.[0-9]+$\" };\n\nfunction tool(\n name: string,\n description: string,\n properties: Record<string, unknown>,\n required: string[] = [],\n mutation = false,\n): SlackRestMcpTool {\n return {\n name,\n description,\n inputSchema: { type: \"object\", properties, required, additionalProperties: false },\n annotations: {\n readOnlyHint: !mutation,\n destructiveHint: false,\n idempotentHint: !mutation,\n openWorldHint: true,\n },\n };\n}\n\n/** Static reviewed pilot surface. Each call reads only one explicitly requested page. */\nexport const SLACK_REST_MCP_TOOLS: SlackRestMcpTool[] = [\n tool(\n \"slack_list_channels\",\n \"Lists one page of conversations visible to your connected Slack account. Conversation types without a granted read scope are omitted.\",\n {\n types: {\n type: \"array\",\n items: { type: \"string\", enum: [\"public_channel\", \"private_channel\", \"im\", \"mpim\"] },\n minItems: 1,\n maxItems: 4,\n },\n cursor,\n limit: directoryPage,\n exclude_archived: { type: \"boolean\", default: true },\n },\n ),\n tool(\n \"slack_get_channel_info\",\n \"Gets metadata for one conversation visible to your connected Slack account.\",\n { channel },\n [\"channel\"],\n ),\n tool(\n \"slack_list_channel_members\",\n \"Lists one page of members in a visible channel or group conversation.\",\n { channel, cursor, limit: directoryPage },\n [\"channel\"],\n ),\n tool(\"slack_list_users\", \"Lists one page of users in the connected Slack workspace.\", {\n cursor,\n limit: directoryPage,\n }),\n tool(\n \"slack_get_user_info\",\n \"Gets a user's profile by their Slack user ID. Email is included only when Slack has granted that scope.\",\n { user: { type: \"string\" } },\n [\"user\"],\n ),\n tool(\n \"slack_read_channel\",\n \"Reads one page of at most 15 messages from a selected conversation. Slack history limits are shared across the workspace. No automatic pagination or backfill.\",\n {\n channel,\n cursor,\n limit: historyPage,\n oldest: timestamp,\n latest: timestamp,\n inclusive: { type: \"boolean\", default: false },\n },\n [\"channel\"],\n ),\n tool(\n \"slack_read_thread\",\n \"Reads one page of at most 15 messages in a selected thread. Slack thread limits are shared across the workspace. No automatic pagination or backfill.\",\n {\n channel,\n ts: { ...timestamp, description: \"Thread root message timestamp.\" },\n cursor,\n limit: historyPage,\n },\n [\"channel\", \"ts\"],\n ),\n tool(\n \"slack_open_dm\",\n \"Opens or resumes a direct message with one Slack user as your connected account.\",\n { user: { type: \"string\" } },\n [\"user\"],\n true,\n ),\n tool(\n \"slack_send_message\",\n \"Sends a message as your connected Slack account. Supply thread_ts to reply in a thread. Review the recipient and text before approving. An uncertain submission is never automatically retried.\",\n {\n channel,\n text: { type: \"string\", minLength: 1, maxLength: 40000 },\n thread_ts: { ...timestamp, description: \"Optional thread root timestamp for a reply.\" },\n unfurl_links: { type: \"boolean\", default: false },\n unfurl_media: { type: \"boolean\", default: false },\n },\n [\"channel\", \"text\"],\n true,\n ),\n];\n\nconst REQUIRED_ANY_SCOPES: Readonly<Record<string, readonly string[]>> = {\n slack_list_channels: conversationScopes,\n slack_get_channel_info: conversationScopes,\n slack_list_channel_members: [\"channels:read\", \"groups:read\", \"mpim:read\"],\n slack_list_users: [\"users:read\"],\n slack_get_user_info: [\"users:read\"],\n slack_read_channel: historyScopes,\n slack_read_thread: historyScopes,\n slack_open_dm: [\"im:write\"],\n slack_send_message: [\"chat:write\"],\n};\n\nexport function slackRestMcpToolsForScopes(scopes: readonly string[] | string): SlackRestMcpTool[] {\n const granted = new Set(normalizeSlackScopes(scopes));\n return SLACK_REST_MCP_TOOLS.filter((entry) =>\n REQUIRED_ANY_SCOPES[entry.name]?.some((scope) => granted.has(scope)),\n ).map((entry) => ({\n ...entry,\n inputSchema: {\n ...entry.inputSchema,\n required: [...entry.inputSchema.required],\n properties: { ...entry.inputSchema.properties },\n },\n annotations: { ...entry.annotations },\n }));\n}\n\nexport const SLACK_CONVERSATION_READ_SCOPE_BY_TYPE = {\n public_channel: \"channels:read\",\n private_channel: \"groups:read\",\n im: \"im:read\",\n mpim: \"mpim:read\",\n} as const;\n"],"mappings":";AACO,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB;AAE5B,IAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,qBACd,QACU;AACV,SAAO;AAAA,IACL,GAAG,IAAI;AAAA,OACJ,OAAO,WAAW,WAAW,CAAC,MAAM,IAAK,UAAU,CAAC,GAClD,QAAQ,CAAC,UAAU,MAAM,MAAM,SAAS,CAAC,EACzC,OAAO,OAAO;AAAA,IACnB;AAAA,EACF,EAAE,KAAK;AACT;AAmBA,IAAM,qBAAqB,CAAC,iBAAiB,eAAe,WAAW,WAAW;AAClF,IAAM,gBAAgB,CAAC,oBAAoB,kBAAkB,cAAc,cAAc;AACzF,IAAM,UAAU,EAAE,MAAM,UAAU,aAAa,+CAA+C;AAC9F,IAAM,SAAS,EAAE,MAAM,UAAU,WAAW,MAAM,aAAa,iCAAiC;A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,UAClC,oBAAoB,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,QAAQ,IAAI,KAAK,CAAC;AAAA,EACrE,EAAE,IAAI,CAAC,WAAW;AAAA,IAChB,GAAG;AAAA,IACH,aAAa;AAAA,MACX,GAAG,MAAM;AAAA,MACT,UAAU,CAAC,GAAG,MAAM,YAAY,QAAQ;AAAA,MACxC,YAAY,EAAE,GAAG,MAAM,YAAY,WAAW;AAAA,IAChD;AAAA,IACA,aAAa,EAAE,GAAG,MAAM,YAAY;AAAA,EACtC,EAAE;AACJ;AAEO,IAAM,wCAAwC;AAAA,EACnD,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,IAAI;AAAA,EACJ,MAAM;AACR;","names":[]}
@@ -3,10 +3,10 @@ import {
3
3
  decodeEditableArtifactMutationIntent,
4
4
  encodeEditableArtifactMutationIntent,
5
5
  hashEditableArtifactMutationIntentBytes
6
- } from "./chunk-TZ6YEYN4.js";
6
+ } from "./chunk-NVJMJWLL.js";
7
7
  import {
8
8
  editableArtifactCodecFor
9
- } from "./chunk-FJBG5E4O.js";
9
+ } from "./chunk-SIOU2K4U.js";
10
10
  import {
11
11
  DOCUMENT_ARTIFACT_COMMAND_MAX_COMMANDS,
12
12
  DOCUMENT_ARTIFACT_MAX_STRUCTURAL_COUNTER
@@ -21,10 +21,12 @@ import {
21
21
  fnv1a64,
22
22
  strictUtf8
23
23
  } from "./chunk-MYBZRDTY.js";
24
+ import {
25
+ EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION
26
+ } from "./chunk-PX3VCKAU.js";
24
27
 
25
28
  // src/editable-artifact-serialized-commit.ts
26
29
  import { bytesToHex } from "@noble/hashes/utils";
27
- var EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION = 1;
28
30
  var EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES = 8 * 1024 * 1024;
29
31
  var EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES = 512 * 1024;
30
32
  var MAGIC = strictUtf8("OGAST001", "serialized commit magic");
@@ -372,11 +374,10 @@ function assertUnsharedBytes(value, label) {
372
374
  }
373
375
 
374
376
  export {
375
- EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION,
376
377
  EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES,
377
378
  EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES,
378
379
  encodeEditableArtifactSerializedCommit,
379
380
  decodeEditableArtifactSerializedCommit,
380
381
  assertCanonicalEditableArtifactSerializedCommit
381
382
  };
382
- //# sourceMappingURL=chunk-H5BVCZKF.js.map
383
+ //# sourceMappingURL=chunk-NRMCVHAU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/editable-artifact-serialized-commit.ts"],"sourcesContent":["import { bytesToHex } from \"@noble/hashes/utils\";\n\nimport {\n ArtifactBinaryReader,\n ArtifactBinaryWriter,\n EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES,\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES,\n decodeCountedEnvelope,\n equalBytes,\n fnv1a64,\n strictUtf8,\n} from \"./editable-artifact-binary\";\nimport {\n DOCUMENT_ARTIFACT_COMMAND_MAX_COMMANDS,\n DOCUMENT_ARTIFACT_MAX_STRUCTURAL_COUNTER,\n} from \"./document-artifact-commands\";\nimport {\n EDITABLE_ARTIFACT_INTENT_MAX_BYTES,\n decodeEditableArtifactMutationIntent,\n encodeEditableArtifactMutationIntent,\n hashEditableArtifactMutationIntentBytes,\n type EditableArtifactMutationIntent,\n} from \"./editable-artifacts\";\nimport { editableArtifactCodecFor } from \"./editable-artifact-codec-registry\";\nimport { EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION } from \"./editable-artifact-versions\";\n\nexport { EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION } from \"./editable-artifact-versions\";\nexport const EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES = 8 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES = 512 * 1024;\n\nconst MAGIC = strictUtf8(\"OGAST001\", \"serialized commit magic\");\nconst SHA256_TEXT = /^sha256:[0-9a-f]{64}$/u;\nconst STABLE_ID = /^[0-9a-f]{32}$/u;\nconst DOCUMENT_RECEIPT_MAGIC = \"OGADR001\";\nconst PRESENTATION_RECEIPT_MAGIC = strictUtf8(\"OGAPR001\", \"presentation receipt magic\");\nconst DOCUMENT_RECEIPT_VERSION = 1;\nconst PRESENTATION_RECEIPT_VERSION = 1;\nconst DOCUMENT_CREATED_IDS_PER_COMMAND = 7;\nconst DOCUMENT_ID_BYTES = 17;\nconst PRESENTATION_RECEIPT_BYTES = 32;\nconst MODALITY_TAG = Object.freeze({ document: 1, presentation: 2 } as const);\n\nexport type EditableArtifactSerializedModality = \"document\" | \"presentation\";\n\nexport type EditableArtifactNativeReceiptSummary =\n | Readonly<{\n modality: \"document\";\n revision: number;\n commandCount: number;\n createdIdCount: number;\n }>\n | Readonly<{\n modality: \"presentation\";\n revision: number;\n commandCount: number;\n }>;\n\nexport type EditableArtifactSerializedCommitInput = Readonly<{\n modality: EditableArtifactSerializedModality;\n transactionId: string;\n parentHeadSequence: number;\n resultHeadSequence: number;\n /** Native model revision before applying this non-empty command batch. */\n priorNativeRevision: number;\n priorStateHash: string;\n stateHash: string;\n /** Exact canonical OGATX001 bytes accepted by the server. */\n intentBytes: Uint8Array;\n /** Exact canonical OGADR001 or OGAPR001 bytes returned by the native kernel. */\n nativeReceiptBytes: Uint8Array;\n}>;\n\nexport type EditableArtifactSerializedCommitSummary = Readonly<{\n commitProtocolVersion: typeof EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION;\n modality: EditableArtifactSerializedModality;\n transactionId: string;\n parentHeadSequence: number;\n resultHeadSequence: number;\n priorNativeRevision: number;\n priorStateHash: string;\n stateHash: string;\n requestHash: string;\n /** Canonical client intent nested in this authoritative commit. */\n intent: EditableArtifactMutationIntent;\n intentBytes: Uint8Array;\n nativeReceiptBytes: Uint8Array;\n nativeReceipt: EditableArtifactNativeReceiptSummary;\n}>;\n\n/**\n * Server-only encoder for one authoritative, strictly serialized commit.\n * Client identity remains solely in the exact nested OGATX envelope.\n */\nexport function encodeEditableArtifactSerializedCommit(\n input: EditableArtifactSerializedCommitInput,\n): Uint8Array {\n const normalized = normalizeSerializedCommit(input);\n const payload = new ArtifactBinaryWriter(\n EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES -\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES -\n EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES,\n );\n payload.stableId(normalized.transactionId, \"serialized transaction id\");\n payload.u64(normalized.parentHeadSequence);\n payload.u64(normalized.resultHeadSequence);\n payload.u64(normalized.priorNativeRevision);\n payload.bytes(hashBytes(normalized.priorStateHash));\n payload.bytes(hashBytes(normalized.stateHash));\n payload.u32(normalized.intentBytes.byteLength);\n payload.u32(normalized.nativeReceiptBytes.byteLength);\n payload.bytes(normalized.intentBytes);\n payload.bytes(normalized.nativeReceiptBytes);\n\n const payloadBytes = payload.finish();\n const output = new ArtifactBinaryWriter(EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES);\n output.bytes(MAGIC);\n output.u16(EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION);\n output.u16(0);\n output.u32(MODALITY_TAG[normalized.modality]);\n output.u64(payloadBytes.byteLength);\n output.bytes(payloadBytes);\n output.u64(fnv1a64(output.view()));\n return output.finish();\n}\n\n/** Durable modality must be selected before any nested receipt/command decode. */\nexport function decodeEditableArtifactSerializedCommit(\n bytes: Uint8Array,\n durableModality: EditableArtifactSerializedModality,\n): EditableArtifactSerializedCommitSummary {\n assertUnsharedBytes(bytes, \"serialized commit\");\n const modality = serializedModality(durableModality);\n if (bytes.byteLength > EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES) {\n throw new RangeError(\"serialized commit exceeds its byte limit\");\n }\n if (\n bytes.byteLength <\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES + EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES\n ) {\n throw new TypeError(\"truncated serialized commit envelope\");\n }\n const header = new ArtifactBinaryReader(bytes);\n if (!equalBytes(header.bytes(8), MAGIC)) {\n throw new TypeError(\"invalid serialized commit magic\");\n }\n if (header.u16() !== EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION) {\n throw new TypeError(\"unsupported serialized commit version\");\n }\n if (header.u16() !== 0) {\n throw new TypeError(\"reserved serialized commit flags must be zero\");\n }\n if (header.u32() !== MODALITY_TAG[modality]) {\n throw new TypeError(\"serialized commit modality disagrees with durable artifact\");\n }\n const payloadLength = header.u64Safe(\"serialized commit payload length\");\n const expectedLength =\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES + payloadLength + EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES;\n if (bytes.byteLength < expectedLength) {\n throw new TypeError(\"truncated serialized commit payload\");\n }\n if (bytes.byteLength > expectedLength) {\n throw new TypeError(\"serialized commit contains trailing bytes\");\n }\n const payloadBytes = header.bytes(payloadLength);\n const checksum = header.u64BigInt();\n header.done();\n if (\n checksum !==\n fnv1a64(bytes.subarray(0, bytes.byteLength - EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES))\n ) {\n throw new TypeError(\"serialized commit checksum does not match\");\n }\n\n const payload = new ArtifactBinaryReader(payloadBytes);\n const transactionId = payload.stableId(\"serialized transaction id\");\n const parentHeadSequence = payload.u64Safe(\"serialized parent head sequence\");\n const resultHeadSequence = payload.u64Safe(\"serialized result head sequence\");\n const priorNativeRevision = payload.u64Safe(\"serialized prior native revision\");\n const priorStateHash = stateHashText(payload.bytes(32));\n const stateHash = stateHashText(payload.bytes(32));\n const intentLength = payload.count(\n EDITABLE_ARTIFACT_INTENT_MAX_BYTES,\n \"serialized intent bytes\",\n 1,\n );\n const receiptLength = payload.count(\n EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES,\n \"serialized native receipt bytes\",\n 1,\n );\n if (payload.remaining !== intentLength + receiptLength) {\n throw new TypeError(\"serialized commit nested byte lengths are inconsistent\");\n }\n const intentBytes = payload.bytes(intentLength).slice();\n const nativeReceiptBytes = payload.bytes(receiptLength).slice();\n payload.done();\n\n const normalized = normalizeSerializedCommit({\n modality,\n transactionId,\n parentHeadSequence,\n resultHeadSequence,\n priorNativeRevision,\n priorStateHash,\n stateHash,\n intentBytes,\n nativeReceiptBytes,\n });\n const canonical = encodeEditableArtifactSerializedCommit(normalized);\n if (!equalBytes(bytes, canonical)) {\n throw new TypeError(\"serialized commit is not canonically encoded\");\n }\n return Object.freeze({\n commitProtocolVersion: EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION,\n modality,\n transactionId,\n parentHeadSequence,\n resultHeadSequence,\n priorNativeRevision,\n priorStateHash,\n stateHash,\n requestHash: normalized.requestHash,\n intent: normalized.intent,\n intentBytes,\n nativeReceiptBytes,\n nativeReceipt: normalized.nativeReceipt,\n });\n}\n\nexport function assertCanonicalEditableArtifactSerializedCommit(\n bytes: Uint8Array,\n durableModality: EditableArtifactSerializedModality,\n): void {\n decodeEditableArtifactSerializedCommit(bytes, durableModality);\n}\n\ntype NormalizedSerializedCommit = EditableArtifactSerializedCommitInput &\n Readonly<{\n requestHash: string;\n intent: EditableArtifactMutationIntent;\n nativeReceipt: EditableArtifactNativeReceiptSummary;\n }>;\n\nfunction normalizeSerializedCommit(\n input: EditableArtifactSerializedCommitInput,\n): NormalizedSerializedCommit {\n const modality = serializedModality(input.modality);\n const transactionId = canonicalStableId(input.transactionId, \"serialized transaction id\");\n const parentHeadSequence = safeSequence(\n input.parentHeadSequence,\n \"serialized parent head sequence\",\n );\n const resultHeadSequence = safeSequence(\n input.resultHeadSequence,\n \"serialized result head sequence\",\n );\n if (resultHeadSequence !== parentHeadSequence + 1) {\n throw new TypeError(\"serialized commit must advance the durable head exactly once\");\n }\n const priorNativeRevision = safeSequence(\n input.priorNativeRevision,\n \"serialized prior native revision\",\n );\n const priorStateHash = canonicalSha256(input.priorStateHash, \"serialized prior state hash\");\n const stateHash = canonicalSha256(input.stateHash, \"serialized resulting state hash\");\n assertUnsharedBytes(input.intentBytes, \"serialized intent\");\n assertUnsharedBytes(input.nativeReceiptBytes, \"serialized native receipt\");\n if (\n input.intentBytes.byteLength < 1 ||\n input.intentBytes.byteLength > EDITABLE_ARTIFACT_INTENT_MAX_BYTES\n ) {\n throw new RangeError(\"serialized intent bytes exceed their limit\");\n }\n if (\n input.nativeReceiptBytes.byteLength < 1 ||\n input.nativeReceiptBytes.byteLength > EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES\n ) {\n throw new RangeError(\"serialized native receipt bytes exceed their limit\");\n }\n const intentBytes = input.intentBytes.slice();\n const decodedIntent = decodeEditableArtifactMutationIntent(intentBytes);\n if (!equalBytes(intentBytes, encodeEditableArtifactMutationIntent(decodedIntent))) {\n throw new TypeError(\"nested serialized intent is not canonical OGATX001\");\n }\n if (\n decodedIntent.causalBase.length !== 0 ||\n decodedIntent.selectiveUndoOperationIds.length !== 0\n ) {\n throw new TypeError(\"serialized commits cannot carry CRDT causality or selective undo\");\n }\n if (decodedIntent.observedHeadSequence !== parentHeadSequence) {\n throw new TypeError(\"serialized intent observed head does not match its parent\");\n }\n const descriptor = editableArtifactCodecFor({\n durableModality: modality,\n modelSchemaVersion: decodedIntent.modelSchemaVersion,\n commandProtocolVersion: decodedIntent.commandProtocolVersion,\n });\n descriptor.command.assertCanonical(decodedIntent.commandBytes);\n const commandCount = decodedCommandCount(descriptor.command.decode(decodedIntent.commandBytes));\n if (commandCount < 1) {\n throw new TypeError(\"serialized commits require a non-empty command batch\");\n }\n const nativeReceiptBytes = input.nativeReceiptBytes.slice();\n const nativeReceipt = decodeNativeReceipt(modality, nativeReceiptBytes, commandCount);\n if (modality === \"presentation\") {\n if (nativeReceipt.revision !== priorNativeRevision + 1) {\n throw new TypeError(\n \"presentation receipt must advance its prior native revision exactly once\",\n );\n }\n if (stateHash === priorStateHash) {\n throw new TypeError(\"presentation commit must change its canonical state hash\");\n }\n } else if (nativeReceipt.revision === priorNativeRevision) {\n if (stateHash !== priorStateHash) {\n throw new TypeError(\"document no-op receipt cannot change the canonical state hash\");\n }\n } else {\n if (nativeReceipt.revision !== priorNativeRevision + 1) {\n throw new TypeError(\n \"document receipt must preserve or advance its prior native revision once\",\n );\n }\n if (stateHash === priorStateHash) {\n throw new TypeError(\"document revision advance must change the canonical state hash\");\n }\n }\n const requestHash = hashEditableArtifactMutationIntentBytes(intentBytes);\n return Object.freeze({\n modality,\n transactionId,\n parentHeadSequence,\n resultHeadSequence,\n priorNativeRevision,\n priorStateHash,\n stateHash,\n intentBytes,\n nativeReceiptBytes,\n requestHash,\n intent: decodedIntent,\n nativeReceipt,\n });\n}\n\nfunction decodeNativeReceipt(\n modality: EditableArtifactSerializedModality,\n bytes: Uint8Array,\n expectedCommandCount: number,\n): EditableArtifactNativeReceiptSummary {\n return modality === \"document\"\n ? decodeDocumentReceipt(bytes, expectedCommandCount)\n : decodePresentationReceipt(bytes, expectedCommandCount);\n}\n\nfunction decodeDocumentReceipt(\n bytes: Uint8Array,\n expectedCommandCount: number,\n): Extract<EditableArtifactNativeReceiptSummary, { modality: \"document\" }> {\n const envelope = decodeCountedEnvelope(\n bytes,\n DOCUMENT_RECEIPT_MAGIC,\n DOCUMENT_RECEIPT_VERSION,\n EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES,\n DOCUMENT_ARTIFACT_COMMAND_MAX_COMMANDS,\n );\n const payload = new ArtifactBinaryReader(envelope.payload);\n const revision = payload.u64Safe(\"document receipt revision\");\n const commandCount = payload.u32();\n if (commandCount !== envelope.count || commandCount !== expectedCommandCount) {\n throw new TypeError(\"document receipt command count does not match its intent\");\n }\n const maximumCreatedIds = commandCount * DOCUMENT_CREATED_IDS_PER_COMMAND;\n const createdIdCount = payload.count(\n maximumCreatedIds,\n \"document receipt created ids\",\n DOCUMENT_ID_BYTES,\n );\n for (let index = 0; index < createdIdCount; index += 1) {\n const tag = payload.u8();\n if (tag < 1 || tag > 8) {\n throw new TypeError(\"document receipt contains an invalid id kind\");\n }\n payload.u64BigInt();\n const counter = payload.u64BigInt();\n if (counter === 0n || counter > BigInt(DOCUMENT_ARTIFACT_MAX_STRUCTURAL_COUNTER)) {\n throw new TypeError(\"document receipt contains an invalid id counter\");\n }\n }\n payload.done(\"document receipt contains trailing bytes\");\n return Object.freeze({\n modality: \"document\",\n revision,\n commandCount,\n createdIdCount,\n });\n}\n\nfunction decodePresentationReceipt(\n bytes: Uint8Array,\n expectedCommandCount: number,\n): Extract<EditableArtifactNativeReceiptSummary, { modality: \"presentation\" }> {\n if (bytes.byteLength !== PRESENTATION_RECEIPT_BYTES) {\n throw new TypeError(\n bytes.byteLength < PRESENTATION_RECEIPT_BYTES\n ? \"truncated presentation receipt\"\n : \"presentation receipt contains trailing bytes\",\n );\n }\n const reader = new ArtifactBinaryReader(bytes);\n if (!equalBytes(reader.bytes(8), PRESENTATION_RECEIPT_MAGIC)) {\n throw new TypeError(\"invalid presentation receipt magic\");\n }\n if (reader.u16() !== PRESENTATION_RECEIPT_VERSION) {\n throw new TypeError(\"unsupported presentation receipt version\");\n }\n if (reader.u16() !== 0) {\n throw new TypeError(\"reserved presentation receipt flags must be zero\");\n }\n const revision = reader.u64Safe(\"presentation receipt revision\");\n const commandCount = reader.u32();\n if (commandCount !== expectedCommandCount) {\n throw new TypeError(\"presentation receipt command count does not match its intent\");\n }\n const checksum = reader.u64BigInt();\n reader.done();\n if (\n checksum !==\n fnv1a64(bytes.subarray(0, bytes.byteLength - EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES))\n ) {\n throw new TypeError(\"presentation receipt checksum does not match\");\n }\n return Object.freeze({ modality: \"presentation\", revision, commandCount });\n}\n\nfunction decodedCommandCount(value: unknown): number {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"serialized command decoder returned an invalid batch\");\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, \"commands\");\n if (!descriptor || !(\"value\" in descriptor) || !Array.isArray(descriptor.value)) {\n throw new TypeError(\"serialized command decoder returned an invalid batch\");\n }\n return descriptor.value.length;\n}\n\nfunction serializedModality(value: unknown): EditableArtifactSerializedModality {\n if (value !== \"document\" && value !== \"presentation\") {\n throw new TypeError(\"serialized commit modality is invalid\");\n }\n return value;\n}\n\nfunction canonicalStableId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !STABLE_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be a nonzero lowercase 128-bit hexadecimal id`);\n }\n return value;\n}\n\nfunction canonicalSha256(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !SHA256_TEXT.test(value)) {\n throw new TypeError(`${label} must be canonical sha256 text`);\n }\n return value;\n}\n\nfunction safeSequence(value: unknown, label: string): number {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`${label} must be a nonnegative safe integer`);\n }\n return value;\n}\n\nfunction hashBytes(value: string): Uint8Array {\n const hex = value.slice(\"sha256:\".length);\n const bytes = new Uint8Array(32);\n for (let index = 0; index < bytes.byteLength; index += 1) {\n bytes[index] = Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16);\n }\n return bytes;\n}\n\nfunction stateHashText(value: Uint8Array): string {\n return `sha256:${bytesToHex(value)}`;\n}\n\nfunction assertUnsharedBytes(value: unknown, label: string): asserts value is Uint8Array {\n if (!(value instanceof Uint8Array)) {\n throw new TypeError(`${label} bytes must be a Uint8Array`);\n }\n if (typeof SharedArrayBuffer !== \"undefined\" && value.buffer instanceof SharedArrayBuffer) {\n throw new TypeError(`${label} bytes must not use shared mutable memory`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AA2BpB,IAAM,gDAAgD,IAAI,OAAO;AACjE,IAA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AACxD,UAAM,KAAK,IAAI,OAAO,SAAS,IAAI,MAAM,QAAQ,GAAG,QAAQ,IAAI,CAAC,GAAG,EAAE;AAAA,EACxE;AACA,SAAO;AACT;AAEA,SAAS,cAAc,OAA2B;AAChD,SAAO,UAAU,WAAW,KAAK,CAAC;AACpC;AAEA,SAAS,oBAAoB,OAAgB,OAA4C;AACvF,MAAI,EAAE,iBAAiB,aAAa;AAClC,UAAM,IAAI,UAAU,GAAG,KAAK,6BAA6B;AAAA,EAC3D;AACA,MAAI,OAAO,sBAAsB,eAAe,MAAM,kBAAkB,mBAAmB;AACzF,UAAM,IAAI,UAAU,GAAG,KAAK,2CAA2C;AAAA,EACzE;AACF;","names":[]}
@@ -2,6 +2,7 @@
2
2
  import { sha256 } from "@noble/hashes/sha256";
3
3
  import { bytesToHex } from "@noble/hashes/utils";
4
4
  var EDITABLE_ARTIFACT_INTENT_VERSION = 1;
5
+ var EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION = 1;
5
6
  var EDITABLE_ARTIFACT_INTENT_MAX_BYTES = 5 * 1024 * 1024;
6
7
  var EDITABLE_ARTIFACT_COMMAND_MAX_BYTES = 4 * 1024 * 1024;
7
8
  var EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES = 512;
@@ -371,6 +372,7 @@ var BinaryReader = class {
371
372
 
372
373
  export {
373
374
  EDITABLE_ARTIFACT_INTENT_VERSION,
375
+ EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
374
376
  EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
375
377
  EDITABLE_ARTIFACT_COMMAND_MAX_BYTES,
376
378
  EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES,
@@ -383,4 +385,4 @@ export {
383
385
  hashEditableArtifactMutationIntent,
384
386
  assertEditableArtifactRequestHash
385
387
  };
386
- //# sourceMappingURL=chunk-TZ6YEYN4.js.map
388
+ //# sourceMappingURL=chunk-NVJMJWLL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/editable-artifacts.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\n\nexport * from \"./spreadsheet-artifact-commands\";\nexport * from \"./spreadsheet-artifact-query\";\nexport * from \"./editable-artifact-causal-frontier\";\nexport * from \"./document-artifact-commands\";\nexport * from \"./presentation-artifact-commands\";\nexport * from \"./editable-artifact-codec-registry\";\n\nexport const EDITABLE_ARTIFACT_INTENT_VERSION = 1 as const;\n/** Semantic protocol carried inside the unchanged OGATX001 envelope. */\nexport const EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION = 1 as const;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_BYTES = 5 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_COMMAND_MAX_BYTES = 4 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES = 512;\n/** Largest durable snapshot every supported browser/WASM client can open. */\nexport const EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS = 1_024;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS = 10_000;\n\nconst MAGIC = new TextEncoder().encode(\"OGATX001\");\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: true });\nconst STABLE_ID = /^[0-9a-f]{32}$/u;\nconst REPLICA_ID = /^[0-9a-f]{16}$/u;\nconst CLIENT_TRANSACTION_ID = /^[A-Za-z0-9._:-]{1,200}$/u;\nconst REQUEST_HASH = /^sha256:[0-9a-f]{64}$/u;\n\nexport type EditableArtifactCausalEntry = Readonly<{\n replicaId: string;\n counter: number;\n}>;\n\n/**\n * Exact client-authored mutation identity. Scope and actor authority are\n * deliberately absent: the server derives them and binds them in the\n * idempotency lookup tuple instead of trusting client bytes.\n */\nexport type EditableArtifactMutationIntent = Readonly<{\n envelopeVersion: typeof EDITABLE_ARTIFACT_INTENT_VERSION;\n protocolVersion: number;\n modelSchemaVersion: number;\n commandProtocolVersion: number;\n artifactId: string;\n clientTransactionId: string;\n replicaId: string;\n replicaCounter: number;\n previousLocalTransactionId: string | null;\n observedHeadSequence: number;\n causalBase: readonly EditableArtifactCausalEntry[];\n selectiveUndoOperationIds: readonly string[];\n commandBytes: Uint8Array;\n}>;\n\nexport function encodeEditableArtifactMutationIntent(\n input: EditableArtifactMutationIntent,\n): Uint8Array {\n // The writer owns the emitted bytes, so a second eager copy of a potentially\n // multi-megabyte command block would add no safety.\n const intent = normalizeIntent(input, false);\n const writer = new BinaryWriter(EDITABLE_ARTIFACT_INTENT_MAX_BYTES);\n writer.bytes(MAGIC);\n writer.u16(intent.envelopeVersion);\n writer.u16(intent.protocolVersion);\n writer.u16(intent.modelSchemaVersion);\n writer.u16(intent.commandProtocolVersion);\n writer.string(intent.artifactId);\n writer.string(intent.clientTransactionId);\n writer.string(intent.replicaId);\n writer.u64(intent.replicaCounter);\n writer.u8(intent.previousLocalTransactionId === null ? 0 : 1);\n if (intent.previousLocalTransactionId !== null) {\n writer.string(intent.previousLocalTransactionId);\n }\n writer.u64(intent.observedHeadSequence);\n writer.u16(intent.causalBase.length);\n for (const entry of intent.causalBase) {\n writer.string(entry.replicaId);\n writer.u64(entry.counter);\n }\n writer.u16(intent.selectiveUndoOperationIds.length);\n for (const operationId of intent.selectiveUndoOperationIds) writer.string(operationId);\n writer.byteBlock(intent.commandBytes);\n return writer.finish();\n}\n\nexport function decodeEditableArtifactMutationIntent(\n bytes: Uint8Array,\n): EditableArtifactMutationIntent {\n return parseEditableArtifactMutationIntent(bytes, true);\n}\n\nfunction parseEditableArtifactMutationIntent(\n bytes: Uint8Array,\n copyCommandBytes: boolean,\n): EditableArtifactMutationIntent {\n if (!(bytes instanceof Uint8Array)) throw new TypeError(\"intent bytes must be a Uint8Array\");\n if (bytes.byteLength > EDITABLE_ARTIFACT_INTENT_MAX_BYTES) {\n throw new RangeError(\"editable artifact intent exceeds its byte limit\");\n }\n const reader = new BinaryReader(bytes);\n const magic = reader.bytes(MAGIC.byteLength);\n if (!equalBytes(magic, MAGIC)) throw new TypeError(\"invalid editable artifact intent magic\");\n const envelopeVersion = reader.u16();\n if (envelopeVersion !== EDITABLE_ARTIFACT_INTENT_VERSION) {\n throw new TypeError(`unsupported editable artifact intent version: ${envelopeVersion}`);\n }\n const protocolVersion = reader.u16();\n const modelSchemaVersion = reader.u16();\n const commandProtocolVersion = reader.u16();\n const artifactId = reader.string();\n const clientTransactionId = reader.string();\n const replicaId = reader.string();\n const replicaCounter = reader.u64();\n const predecessorFlag = reader.u8();\n if (predecessorFlag > 1) throw new TypeError(\"invalid predecessor presence flag\");\n const previousLocalTransactionId = predecessorFlag === 1 ? reader.string() : null;\n const observedHeadSequence = reader.u64();\n const causalCount = reader.u16();\n if (causalCount > EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS) {\n throw new RangeError(\"editable artifact causal base exceeds its actor limit\");\n }\n const causalBase: EditableArtifactCausalEntry[] = [];\n let previousReplicaId = \"\";\n for (let index = 0; index < causalCount; index += 1) {\n const causalReplicaId = reader.string();\n if (causalReplicaId <= previousReplicaId) {\n throw new TypeError(\"causal base replica ids must be unique and canonically sorted\");\n }\n previousReplicaId = causalReplicaId;\n causalBase.push(Object.freeze({ replicaId: causalReplicaId, counter: reader.u64() }));\n }\n const undoCount = reader.u16();\n if (undoCount > EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS) {\n throw new RangeError(\"editable artifact undo targets exceed their limit\");\n }\n const selectiveUndoOperationIds: string[] = [];\n let previousOperationId = \"\";\n for (let index = 0; index < undoCount; index += 1) {\n const operationId = reader.string();\n if (operationId <= previousOperationId) {\n throw new TypeError(\"undo operation ids must be unique and canonically sorted\");\n }\n previousOperationId = operationId;\n selectiveUndoOperationIds.push(operationId);\n }\n const commandBytes = reader.byteBlock(EDITABLE_ARTIFACT_COMMAND_MAX_BYTES);\n reader.done();\n return normalizeIntent(\n {\n envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,\n protocolVersion,\n modelSchemaVersion,\n commandProtocolVersion,\n artifactId,\n clientTransactionId,\n replicaId,\n replicaCounter,\n previousLocalTransactionId,\n observedHeadSequence,\n causalBase,\n selectiveUndoOperationIds,\n commandBytes,\n },\n copyCommandBytes,\n );\n}\n\nexport function hashEditableArtifactMutationIntentBytes(bytes: Uint8Array): string {\n // Decode first so noncanonical or malformed bytes can never acquire a valid\n // application-level request hash merely because SHA-256 accepts any bytes.\n parseEditableArtifactMutationIntent(bytes, false);\n return `sha256:${bytesToHex(sha256(bytes))}`;\n}\n\nexport function hashEditableArtifactMutationIntent(intent: EditableArtifactMutationIntent): {\n bytes: Uint8Array;\n requestHash: string;\n} {\n const bytes = encodeEditableArtifactMutationIntent(intent);\n return { bytes, requestHash: `sha256:${bytesToHex(sha256(bytes))}` };\n}\n\nexport function assertEditableArtifactRequestHash(value: string): string {\n if (!REQUEST_HASH.test(value)) {\n throw new TypeError(\"editable artifact request hash must be canonical sha256 text\");\n }\n return value;\n}\n\nfunction normalizeIntent(\n input: EditableArtifactMutationIntent,\n copyCommandBytes = true,\n): EditableArtifactMutationIntent {\n if (!isPlainRecord(input)) throw new TypeError(\"editable artifact intent must be a plain record\");\n if (input.envelopeVersion !== EDITABLE_ARTIFACT_INTENT_VERSION) {\n throw new TypeError(\"editable artifact intent envelope version must be 1\");\n }\n const protocolVersion = positiveU16(input.protocolVersion, \"protocolVersion\");\n const modelSchemaVersion = positiveU16(input.modelSchemaVersion, \"modelSchemaVersion\");\n const commandProtocolVersion = positiveU16(\n input.commandProtocolVersion,\n \"commandProtocolVersion\",\n );\n const artifactId = stableId(input.artifactId, \"artifactId\");\n const clientTransactionId = portableTransactionId(\n input.clientTransactionId,\n \"clientTransactionId\",\n );\n const replicaId = replicaIdentity(input.replicaId, \"replicaId\");\n const replicaCounter = positiveSafeInteger(input.replicaCounter, \"replicaCounter\");\n const previousLocalTransactionId =\n input.previousLocalTransactionId === null\n ? null\n : portableTransactionId(input.previousLocalTransactionId, \"previousLocalTransactionId\");\n const observedHeadSequence = nonnegativeSafeInteger(\n input.observedHeadSequence,\n \"observedHeadSequence\",\n );\n if (!Array.isArray(input.causalBase)) throw new TypeError(\"causalBase must be an array\");\n if (input.causalBase.length > EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS) {\n throw new RangeError(\"editable artifact causal base exceeds its actor limit\");\n }\n const causalByReplica = new Map<string, number>();\n for (const entry of input.causalBase) {\n if (!isPlainRecord(entry)) throw new TypeError(\"causal entries must be plain records\");\n const causalReplicaId = replicaIdentity(entry.replicaId, \"causal replicaId\");\n if (causalByReplica.has(causalReplicaId)) throw new TypeError(\"duplicate causal replicaId\");\n causalByReplica.set(\n causalReplicaId,\n positiveSafeInteger(entry.counter, `causal counter for ${causalReplicaId}`),\n );\n }\n const causalBase = [...causalByReplica]\n .sort(([left], [right]) => compareCodeUnits(left, right))\n .map(([causalReplicaId, counter]) => Object.freeze({ replicaId: causalReplicaId, counter }));\n if (!Array.isArray(input.selectiveUndoOperationIds)) {\n throw new TypeError(\"selectiveUndoOperationIds must be an array\");\n }\n if (input.selectiveUndoOperationIds.length > EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS) {\n throw new RangeError(\"editable artifact undo targets exceed their limit\");\n }\n const undoSet = new Set<string>();\n for (const value of input.selectiveUndoOperationIds) {\n const operationId = stableId(value, \"selective undo operation id\");\n if (undoSet.has(operationId)) throw new TypeError(\"duplicate selective undo operation id\");\n undoSet.add(operationId);\n }\n const selectiveUndoOperationIds = [...undoSet].sort(compareCodeUnits);\n if (!(input.commandBytes instanceof Uint8Array)) {\n throw new TypeError(\"commandBytes must be a Uint8Array\");\n }\n if (input.commandBytes.byteLength < 1) throw new TypeError(\"commandBytes must not be empty\");\n if (input.commandBytes.byteLength > EDITABLE_ARTIFACT_COMMAND_MAX_BYTES) {\n throw new RangeError(\"commandBytes exceeds its byte limit\");\n }\n return Object.freeze({\n envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,\n protocolVersion,\n modelSchemaVersion,\n commandProtocolVersion,\n artifactId,\n clientTransactionId,\n replicaId,\n replicaCounter,\n previousLocalTransactionId,\n observedHeadSequence,\n causalBase: Object.freeze(causalBase),\n selectiveUndoOperationIds: Object.freeze(selectiveUndoOperationIds),\n commandBytes: copyCommandBytes ? input.commandBytes.slice() : input.commandBytes,\n });\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nfunction stableId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !STABLE_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be nonzero fixed-width lowercase hexadecimal text`);\n }\n return value;\n}\n\nfunction replicaIdentity(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !REPLICA_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be nonzero 64-bit lowercase hexadecimal text`);\n }\n return value;\n}\n\nfunction portableTransactionId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !CLIENT_TRANSACTION_ID.test(value)) {\n throw new TypeError(`${label} must contain 1-200 portable identifier characters`);\n }\n return value;\n}\n\nfunction positiveU16(value: unknown, label: string): number {\n if (!Number.isInteger(value) || (value as number) < 1 || (value as number) > 0xffff) {\n throw new TypeError(`${label} must be a positive 16-bit integer`);\n }\n return value as number;\n}\n\nfunction positiveSafeInteger(value: unknown, label: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 1) {\n throw new TypeError(`${label} must be a positive safe integer`);\n }\n return value as number;\n}\n\nfunction nonnegativeSafeInteger(value: unknown, label: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 0) {\n throw new TypeError(`${label} must be a nonnegative safe integer`);\n }\n return value as number;\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction equalBytes(left: Uint8Array, right: Uint8Array): boolean {\n return (\n left.byteLength === right.byteLength && left.every((value, index) => value === right[index])\n );\n}\n\nclass BinaryWriter {\n private buffer = new Uint8Array(1_024);\n private length = 0;\n\n constructor(private readonly maximum: number) {}\n\n u8(value: number): void {\n this.ensure(1);\n this.buffer[this.length++] = value;\n }\n\n u16(value: number): void {\n this.ensure(2);\n this.buffer[this.length++] = value & 0xff;\n this.buffer[this.length++] = (value >>> 8) & 0xff;\n }\n\n u32(value: number): void {\n this.ensure(4);\n for (let offset = 0; offset < 4; offset += 1) {\n this.buffer[this.length++] = Math.floor(value / 2 ** (offset * 8)) & 0xff;\n }\n }\n\n u64(value: number): void {\n if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(\"u64 must be safe\");\n this.ensure(8);\n let remaining = BigInt(value);\n for (let offset = 0; offset < 8; offset += 1) {\n this.buffer[this.length++] = Number(remaining & 0xffn);\n remaining >>= 8n;\n }\n }\n\n string(value: string): void {\n const bytes = textEncoder.encode(value);\n if (bytes.byteLength > 0xffff) throw new RangeError(\"intent string exceeds 65535 bytes\");\n this.u16(bytes.byteLength);\n this.bytes(bytes);\n }\n\n byteBlock(value: Uint8Array): void {\n this.u32(value.byteLength);\n this.bytes(value);\n }\n\n bytes(value: Uint8Array): void {\n this.ensure(value.byteLength);\n this.buffer.set(value, this.length);\n this.length += value.byteLength;\n }\n\n finish(): Uint8Array {\n return this.buffer.slice(0, this.length);\n }\n\n private ensure(additional: number): void {\n const needed = this.length + additional;\n if (!Number.isSafeInteger(needed) || needed > this.maximum) {\n throw new RangeError(\"editable artifact intent exceeds its byte limit\");\n }\n if (needed <= this.buffer.byteLength) return;\n let size = this.buffer.byteLength;\n while (size < needed) size = Math.min(this.maximum, size * 2);\n const next = new Uint8Array(size);\n next.set(this.buffer.subarray(0, this.length));\n this.buffer = next;\n }\n}\n\nclass BinaryReader {\n private offset = 0;\n\n constructor(private readonly input: Uint8Array) {}\n\n u8(): number {\n this.require(1);\n return this.input[this.offset++]!;\n }\n\n u16(): number {\n this.require(2);\n const value = this.input[this.offset]! | (this.input[this.offset + 1]! << 8);\n this.offset += 2;\n return value;\n }\n\n u32(): number {\n this.require(4);\n const value =\n this.input[this.offset]! +\n this.input[this.offset + 1]! * 2 ** 8 +\n this.input[this.offset + 2]! * 2 ** 16 +\n this.input[this.offset + 3]! * 2 ** 24;\n this.offset += 4;\n return value;\n }\n\n u64(): number {\n this.require(8);\n let value = 0n;\n for (let offset = 0; offset < 8; offset += 1) {\n value |= BigInt(this.input[this.offset + offset]!) << BigInt(offset * 8);\n }\n this.offset += 8;\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) throw new RangeError(\"u64 exceeds safe integer\");\n return Number(value);\n }\n\n string(): string {\n return textDecoder.decode(this.bytes(this.u16()));\n }\n\n byteBlock(maximum: number): Uint8Array {\n const length = this.u32();\n if (length < 1) throw new TypeError(\"commandBytes must not be empty\");\n if (length > maximum) throw new RangeError(\"commandBytes exceeds its byte limit\");\n return this.bytes(length);\n }\n\n bytes(length: number): Uint8Array {\n this.require(length);\n const output = this.input.subarray(this.offset, this.offset + length);\n this.offset += length;\n return output;\n }\n\n done(): void {\n if (this.offset !== this.input.byteLength) {\n throw new TypeError(\"editable artifact intent contains trailing bytes\");\n }\n }\n\n private require(length: number): void {\n if (\n !Number.isSafeInteger(length) ||\n length < 0 ||\n this.offset + length > this.input.byteLength\n ) {\n throw new TypeError(\"truncated editable artifact intent\");\n }\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,kBAAkB;AASpB,IAAM,mCAAmC;AAEzC,IAAM,4CAA4C;AAClD,IAAM,qCAAqC,IAAI,OAAO;AACtD,IAAM,sCAAsC,IAAI,OAAO;AACvD,IAAM,6CAA6C;AAEnD,IAAM,+CAA+C,KAAK,OAAO;AACjE,IAAM,6CAA6C;AACnD,IAAM,4CAA4C;AAEzD,IAAM,QAAQ,IAAI,YAAY,EAAE,OA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