openplanr 2.2640.8 → 2.2641.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 (192) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/dashboard/.vite/manifest.json +1 -1
  3. package/dist/dashboard/assets/{index-COZ36pFn.js → index-D7R6tnlX.js} +2 -2
  4. package/dist/dashboard/assets/{index-COZ36pFn.js.map → index-D7R6tnlX.js.map} +1 -1
  5. package/dist/dashboard/dashboard-manifest.json +8 -8
  6. package/dist/dashboard/index.html +1 -1
  7. package/lib/host-packages/adapter-registry.json +5 -5
  8. package/lib/host-packages/capability-map.json +1 -1
  9. package/lib/host-packages/claude/.claude-plugin/marketplace.json +2 -2
  10. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +1 -1
  11. package/lib/host-packages/claude/openplanr/.openplanr-content.json +167 -35
  12. package/lib/host-packages/claude/openplanr/README.md +22 -1
  13. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +3 -11
  14. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +555 -0
  15. package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-pako-esm.mjs → design-compression.mjs} +2 -1521
  16. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +133 -12
  17. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +647 -0
  18. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-entities.mjs +17 -67
  19. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +14 -16
  20. package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-planr-home.mjs → design-loopback-server.mjs} +15 -36
  21. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-owner-custody.mjs +121 -0
  22. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-resource-pack.mjs +698 -0
  23. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +798 -796
  24. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +39 -0
  25. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-support-5cb7531bede8.mjs +24 -0
  26. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share.mjs +138 -765
  27. package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-escape.mjs → design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs} +158 -156
  28. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-artifact-sources.mjs → claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs} +1 -1
  29. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-bounded-json-data.mjs → claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs} +241 -454
  30. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +222 -0
  31. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-upload-spool.mjs +198 -0
  32. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +12 -5
  33. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
  34. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +18 -0
  35. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +809 -0
  36. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +5193 -0
  37. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +4175 -0
  38. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +65 -0
  39. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +1755 -0
  40. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +62 -0
  41. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +2600 -0
  42. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +123 -0
  43. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  44. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +3 -3
  45. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +34 -0
  46. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +992 -0
  47. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +2513 -0
  48. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +1919 -0
  49. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +1759 -0
  50. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +1551 -0
  51. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +1121 -0
  52. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +2183 -0
  53. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +705 -0
  54. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +27 -0
  55. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +13 -0
  56. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-design-review-experience.js +3561 -0
  57. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-studio-shell.js +184 -0
  58. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +5045 -0
  59. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +1698 -0
  60. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +455 -0
  61. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-design-studio.js +1844 -0
  62. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +257 -0
  63. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +1 -1
  64. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +4966 -0
  65. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +240 -5192
  66. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +1 -1
  67. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/backend-diagnostics.mjs +6 -2
  68. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +166 -34
  69. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  70. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/backend-diagnostics.mjs +6 -2
  71. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +3 -11
  72. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +555 -0
  73. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-pako-esm.mjs → cursor/openplanr/runtime/design/scripts/design-compression.mjs} +2 -1521
  74. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +133 -12
  75. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +647 -0
  76. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-entities.mjs +17 -67
  77. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +14 -16
  78. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-planr-home.mjs → cursor/openplanr/runtime/design/scripts/design-loopback-server.mjs} +15 -36
  79. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-owner-custody.mjs +121 -0
  80. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-resource-pack.mjs +698 -0
  81. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +798 -796
  82. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +39 -0
  83. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-support-5cb7531bede8.mjs +24 -0
  84. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share.mjs +138 -765
  85. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-escape.mjs → cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs} +158 -156
  86. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-artifact-sources.mjs → cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs} +1 -1
  87. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/{design-bounded-json-data.mjs → design-shared-protocol-contracts-31a760fc.mjs} +241 -454
  88. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +222 -0
  89. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-upload-spool.mjs +198 -0
  90. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +12 -5
  91. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
  92. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +18 -0
  93. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +809 -0
  94. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +5193 -0
  95. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +4175 -0
  96. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +65 -0
  97. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +1755 -0
  98. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +62 -0
  99. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +2600 -0
  100. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +123 -0
  101. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  102. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +3 -3
  103. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +34 -0
  104. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +992 -0
  105. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +2513 -0
  106. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +1919 -0
  107. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +1759 -0
  108. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +1551 -0
  109. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +1121 -0
  110. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +2183 -0
  111. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +705 -0
  112. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +27 -0
  113. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +13 -0
  114. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-design-review-experience.js +3561 -0
  115. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-studio-shell.js +184 -0
  116. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +5045 -0
  117. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +1698 -0
  118. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +455 -0
  119. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-design-studio.js +1844 -0
  120. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +257 -0
  121. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +1 -1
  122. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +4966 -0
  123. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +240 -5192
  124. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +1 -1
  125. package/lib/host-packages/openai/.claude-plugin/marketplace.json +2 -2
  126. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +1 -1
  127. package/lib/host-packages/openai/openplanr/.openplanr-content.json +166 -34
  128. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +3 -11
  129. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +555 -0
  130. package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-pako-esm.mjs → openai/openplanr/runtime/design/scripts/design-compression.mjs} +2 -1521
  131. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +133 -12
  132. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +647 -0
  133. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-entities.mjs +17 -67
  134. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +14 -16
  135. package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-planr-home.mjs → openai/openplanr/runtime/design/scripts/design-loopback-server.mjs} +15 -36
  136. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-owner-custody.mjs +121 -0
  137. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-resource-pack.mjs +698 -0
  138. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +798 -796
  139. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +39 -0
  140. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-support-5cb7531bede8.mjs +24 -0
  141. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share.mjs +138 -765
  142. package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-escape.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs} +158 -156
  143. package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-artifact-sources.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs} +1 -1
  144. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-bounded-json-data.mjs → openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs} +241 -454
  145. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +222 -0
  146. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-upload-spool.mjs +198 -0
  147. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +12 -5
  148. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
  149. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +18 -0
  150. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +809 -0
  151. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +5193 -0
  152. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +4175 -0
  153. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +65 -0
  154. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +1755 -0
  155. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +62 -0
  156. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +2600 -0
  157. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +123 -0
  158. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  159. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +3 -3
  160. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +34 -0
  161. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +992 -0
  162. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +2513 -0
  163. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +1919 -0
  164. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +1759 -0
  165. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +1551 -0
  166. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +1121 -0
  167. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +2183 -0
  168. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +705 -0
  169. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +27 -0
  170. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +13 -0
  171. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-design-review-experience.js +3561 -0
  172. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-studio-shell.js +184 -0
  173. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +5045 -0
  174. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +1698 -0
  175. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +455 -0
  176. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-design-studio.js +1844 -0
  177. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +257 -0
  178. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +1 -1
  179. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +4966 -0
  180. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +240 -5192
  181. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +1 -1
  182. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/backend-diagnostics.mjs +6 -2
  183. package/package.json +2 -2
  184. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-generated-b0798298053515fd.mjs +0 -18
  185. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js +0 -5
  186. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js +0 -25597
  187. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-generated-b0798298053515fd.mjs +0 -18
  188. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js +0 -5
  189. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js +0 -25597
  190. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-generated-b0798298053515fd.mjs +0 -18
  191. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js +0 -5
  192. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js +0 -25597
@@ -0,0 +1,555 @@
1
+ import {
2
+ decodeResourceBytes,
3
+ encodeResourceBytes,
4
+ encryptResourcePack,
5
+ openResourcePack,
6
+ packResourceBundle,
7
+ resourceSha256
8
+ } from "./design-resource-pack.mjs";
9
+ import {
10
+ LARGE_OBJECT_LIMITS,
11
+ assertLargeObjectContract
12
+ } from "./design-shared-protocol-contracts-31a760fc.mjs";
13
+ import {
14
+ canonicalizeJson,
15
+ sha256Hex
16
+ } from "./design-shared-protocol-contracts-75a938cc.mjs";
17
+
18
+ // packages/artifact/lib/artifact/chunked-workspace-client.mjs
19
+ var encoder = new TextEncoder();
20
+ var decoder = new TextDecoder("utf-8", { fatal: true });
21
+ var preparedChunks = /* @__PURE__ */ new WeakMap();
22
+ async function boundedResponseBytes(response, limit) {
23
+ const declared = response.headers?.get("content-length");
24
+ if (declared !== void 0 && declared !== null && (!/^[0-9]+$/.test(declared) || BigInt(declared) > BigInt(limit))) {
25
+ await response.body?.cancel();
26
+ throw new RangeError("The sharing response declared size exceeds its byte limit.");
27
+ }
28
+ const reader = response.body?.getReader();
29
+ if (!reader) throw new TypeError("The sharing service returned an empty response.");
30
+ const chunks = [];
31
+ let size = 0;
32
+ try {
33
+ for (; ; ) {
34
+ const { done, value } = await reader.read();
35
+ if (done) break;
36
+ size += value.byteLength;
37
+ if (size > limit) {
38
+ await reader.cancel();
39
+ throw new RangeError("The sharing response exceeds its byte limit.");
40
+ }
41
+ chunks.push(value);
42
+ }
43
+ } finally {
44
+ reader.releaseLock();
45
+ }
46
+ const bytes = new Uint8Array(size);
47
+ let offset = 0;
48
+ for (const chunk of chunks) {
49
+ bytes.set(chunk, offset);
50
+ offset += chunk.byteLength;
51
+ }
52
+ return bytes;
53
+ }
54
+ function unsupported() {
55
+ return Object.assign(
56
+ new Error(
57
+ "This sharing service does not support bounded resource uploads. Upgrade the hosted service before sharing this design; your local work is saved."
58
+ ),
59
+ { code: "E_WORKSPACE_TRANSPORT_UNSUPPORTED", status: 426 }
60
+ );
61
+ }
62
+ function uploadChunksFor(custody) {
63
+ const body = custody.pendingCreate ?? (custody.pendingMutation?.action === "publish" ? custody.pendingMutation.body : null);
64
+ return body && preparedChunks.get(body);
65
+ }
66
+ function createChunkedWorkspaceClient({
67
+ legacy,
68
+ domain,
69
+ apiPath,
70
+ assertBundle,
71
+ assertFeedback,
72
+ digestInput = (value) => value,
73
+ digestBundle
74
+ }) {
75
+ const api = apiPath.replace("/api/v1/", "/api/v2/");
76
+ const idPattern = /^[A-Za-z0-9_-]{22,64}$/u;
77
+ const tokenPattern = /^[A-Za-z0-9_-]{43}$/u;
78
+ function validateAccess(access) {
79
+ legacy.normalizeWorkspaceBase(access.baseUrl);
80
+ if (!idPattern.test(access.id)) throw new TypeError("Workspace identity is invalid.");
81
+ }
82
+ async function keyMaterial(token, id, purpose) {
83
+ if (!tokenPattern.test(token) || !idPattern.test(id))
84
+ throw new TypeError("Workspace token is invalid.");
85
+ const imported = await crypto.subtle.importKey(
86
+ "raw",
87
+ decodeResourceBytes(token, 32),
88
+ "HKDF",
89
+ false,
90
+ ["deriveBits"]
91
+ );
92
+ return new Uint8Array(
93
+ await crypto.subtle.deriveBits(
94
+ {
95
+ name: "HKDF",
96
+ hash: "SHA-256",
97
+ salt: encoder.encode(id),
98
+ info: encoder.encode(`${domain}/${purpose}`)
99
+ },
100
+ imported,
101
+ 256
102
+ )
103
+ );
104
+ }
105
+ async function seal(value, rawKey, context, limit = 65536) {
106
+ const bytes = encoder.encode(canonicalizeJson(value));
107
+ if (bytes.byteLength + 16 > limit)
108
+ throw new RangeError("Encrypted metadata exceeds its byte limit.");
109
+ const key = await crypto.subtle.importKey("raw", rawKey, "AES-GCM", false, ["encrypt"]);
110
+ const iv = crypto.getRandomValues(new Uint8Array(12));
111
+ const cipher = await crypto.subtle.encrypt(
112
+ {
113
+ name: "AES-GCM",
114
+ iv,
115
+ additionalData: encoder.encode(canonicalizeJson(context)),
116
+ tagLength: 128
117
+ },
118
+ key,
119
+ bytes
120
+ );
121
+ return { iv: encodeResourceBytes(iv), ciphertext: encodeResourceBytes(new Uint8Array(cipher)) };
122
+ }
123
+ async function unseal(value, rawKey, context, limit = 65536) {
124
+ const key = await crypto.subtle.importKey("raw", rawKey, "AES-GCM", false, ["decrypt"]);
125
+ const bytes = await crypto.subtle.decrypt(
126
+ {
127
+ name: "AES-GCM",
128
+ iv: decodeResourceBytes(value.iv, 12),
129
+ additionalData: encoder.encode(canonicalizeJson(context)),
130
+ tagLength: 128
131
+ },
132
+ key,
133
+ decodeResourceBytes(value.ciphertext, limit)
134
+ );
135
+ return JSON.parse(decoder.decode(bytes));
136
+ }
137
+ async function wrap(custody, token = custody.token, epoch = custody.epoch, keys = custody.keys) {
138
+ return seal(
139
+ { keys, ownerPublicKey: custody.ownerPublicKey },
140
+ await keyMaterial(token, custody.id, "key-wrap"),
141
+ { type: "keyring", workspaceId: custody.id, epoch }
142
+ );
143
+ }
144
+ async function network(url, init, fetchImpl = globalThis.fetch) {
145
+ let response;
146
+ try {
147
+ response = await fetchImpl(url, {
148
+ redirect: "error",
149
+ credentials: "omit",
150
+ cache: "no-store",
151
+ signal: AbortSignal.timeout(2e4),
152
+ ...init
153
+ });
154
+ } catch (cause) {
155
+ throw Object.assign(
156
+ new Error(
157
+ "Sharing was interrupted. Retry the saved operation; its identity and bytes are retained."
158
+ ),
159
+ { code: "E_WORKSPACE_NETWORK", cause }
160
+ );
161
+ }
162
+ if (!response.ok) {
163
+ const error = Object.assign(
164
+ new Error(`Sharing failed (${response.status}). Retry the saved operation.`),
165
+ { status: response.status, code: `E_WORKSPACE_HTTP_${response.status}` }
166
+ );
167
+ try {
168
+ const value = JSON.parse(decoder.decode(await boundedResponseBytes(response, 4096)));
169
+ if (/^[A-Za-z][A-Za-z0-9_-]{0,127}$/u.test(value.error ?? "")) error.code = value.error;
170
+ } catch {
171
+ }
172
+ const seconds = Number(response.headers.get("retry-after"));
173
+ if (response.status === 429 && Number.isFinite(seconds) && seconds > 0)
174
+ error.retryAfterSeconds = Math.min(3600, Math.ceil(seconds));
175
+ throw error;
176
+ }
177
+ return response;
178
+ }
179
+ async function capabilities({ baseUrl, fetchImpl } = {}) {
180
+ const response = await network(
181
+ `${legacy.normalizeWorkspaceBase(baseUrl)}/.well-known/openplanr-sharing`,
182
+ { method: "GET", headers: { Accept: "application/json" } },
183
+ fetchImpl
184
+ );
185
+ const value = JSON.parse(decoder.decode(await boundedResponseBytes(response, 65536)));
186
+ if (!Array.isArray(value.workspaceTransports) || !value.workspaceTransports.includes("2"))
187
+ throw unsupported();
188
+ return value;
189
+ }
190
+ async function request(access, suffix = "", { method = "GET", body, binary, limit = 128 * 1024, fetchImpl, signal } = {}) {
191
+ validateAccess(access);
192
+ const auth = access.ownerAuth ?? await legacy.deriveWorkspaceAuthentication(access.token, access.id);
193
+ const headers = {
194
+ Authorization: `Bearer ${auth}`,
195
+ Accept: binary ? "application/octet-stream" : "application/json"
196
+ };
197
+ if (body !== void 0)
198
+ headers["Content-Type"] = binary ? "application/octet-stream" : "application/json";
199
+ const response = await network(
200
+ `${legacy.normalizeWorkspaceBase(access.baseUrl)}${api}/${access.id}${suffix}`,
201
+ {
202
+ method,
203
+ headers,
204
+ body: body === void 0 ? void 0 : binary ? body : canonicalizeJson(body),
205
+ ...signal ? { signal } : {}
206
+ },
207
+ fetchImpl
208
+ );
209
+ if (response.status === 204) return {};
210
+ const bytes = await boundedResponseBytes(response, limit);
211
+ return binary ? bytes : JSON.parse(decoder.decode(bytes));
212
+ }
213
+ async function prepareUpload(custody, bundle) {
214
+ assertBundle(bundle);
215
+ const reviewOf = digestBundle ? digestBundle(bundle) : legacy.workspaceEnvelopeDigest(digestInput(bundle));
216
+ const encrypted = await encryptResourcePack(await packResourceBundle(bundle, { reviewOf }), {
217
+ workspaceId: custody.id,
218
+ revisionId: legacy.newWorkspaceId(),
219
+ epoch: custody.epoch,
220
+ rawKey: decodeResourceBytes(custody.keys[custody.epoch], 32),
221
+ sign: (value) => legacy.signWorkspaceValue(value, custody.ownerPrivateKey)
222
+ });
223
+ const body = await legacy.signWorkspaceValue(
224
+ {
225
+ schemaVersion: "2.0.0",
226
+ workspaceId: custody.id,
227
+ operationId: legacy.newWorkspaceId(),
228
+ expectedVersion: custody.version,
229
+ epoch: custody.epoch,
230
+ ownerPublicKey: custody.ownerPublicKey,
231
+ ownerAuthHash: sha256Hex(custody.ownerAuth),
232
+ reviewerAuthHash: sha256Hex(
233
+ await legacy.deriveWorkspaceAuthentication(custody.token, custody.id)
234
+ ),
235
+ keyring: custody.keyring,
236
+ manifest: encrypted.manifest
237
+ },
238
+ custody.ownerPrivateKey
239
+ );
240
+ assertLargeObjectContract(body, "encrypted-upload-prepare");
241
+ preparedChunks.set(body, encrypted.chunks);
242
+ return body;
243
+ }
244
+ async function prepareWorkspace(bundle, { baseUrl } = {}) {
245
+ const signer = await legacy.createWorkspaceSigner();
246
+ const custody = {
247
+ schemaVersion: "2.0.0",
248
+ id: legacy.newWorkspaceId(),
249
+ baseUrl: legacy.normalizeWorkspaceBase(baseUrl),
250
+ token: legacy.newWorkspaceToken(),
251
+ ownerAuth: legacy.newWorkspaceToken(),
252
+ ownerPrivateKey: signer.privateKey,
253
+ ownerPublicKey: signer.publicKey,
254
+ epoch: 1,
255
+ keys: { 1: legacy.newWorkspaceToken() },
256
+ version: 0
257
+ };
258
+ custody.keyring = await wrap(custody);
259
+ custody.pendingCreate = await prepareUpload(custody, bundle);
260
+ return custody;
261
+ }
262
+ function verifyReceipt(custody, body, receipt) {
263
+ assertLargeObjectContract(receipt, "encrypted-upload-receipt");
264
+ if (receipt.workspaceId !== custody.id || receipt.operationId !== body.operationId || receipt.revisionId !== body.manifest.revisionId || receipt.manifestSha256 !== sha256Hex(canonicalizeJson(body.manifest)) || receipt.version !== body.expectedVersion + 1)
265
+ throw new TypeError("Publication receipt differs from the saved operation.");
266
+ return receipt;
267
+ }
268
+ async function commitUpload(custody, body, options = {}) {
269
+ if (!options.readChunk)
270
+ throw new Error("Persist the exact upload spool before contacting the sharing service.");
271
+ const readChunk = options.readChunk;
272
+ const status = assertLargeObjectContract(
273
+ await request(custody, `/uploads/${body.operationId}`, { ...options, method: "PUT", body }),
274
+ "encrypted-upload-status"
275
+ );
276
+ const manifestSha256 = sha256Hex(canonicalizeJson(body.manifest));
277
+ if (status.workspaceId !== custody.id || status.operationId !== body.operationId || status.revisionId !== body.manifest.revisionId || status.manifestSha256 !== manifestSha256)
278
+ throw new TypeError("Upload status differs from the saved operation.");
279
+ if (status.status === "committed") return verifyReceipt(custody, body, status.receipt);
280
+ const received = /* @__PURE__ */ new Set();
281
+ for (const part of status.receivedChunks) {
282
+ const expected = body.manifest.chunks[part.index];
283
+ if (!expected || expected.byteLength !== part.byteLength || expected.sha256 !== part.sha256)
284
+ throw new TypeError("Uploaded chunk identity differs.");
285
+ received.add(part.index);
286
+ }
287
+ for (const part of body.manifest.chunks) {
288
+ if (received.has(part.index)) continue;
289
+ const bytes = await readChunk(part.index);
290
+ if (bytes.byteLength !== part.byteLength || await resourceSha256(bytes) !== part.sha256)
291
+ throw new TypeError("Saved upload chunk is corrupt.");
292
+ await request(custody, `/uploads/${body.operationId}/chunks/${part.index}`, {
293
+ ...options,
294
+ method: "PUT",
295
+ body: bytes,
296
+ binary: true,
297
+ limit: 65536
298
+ });
299
+ }
300
+ const commit = await legacy.signWorkspaceValue(
301
+ {
302
+ schemaVersion: "2.0.0",
303
+ workspaceId: custody.id,
304
+ operationId: body.operationId,
305
+ manifestSha256
306
+ },
307
+ custody.ownerPrivateKey
308
+ );
309
+ return verifyReceipt(
310
+ custody,
311
+ body,
312
+ await request(custody, `/uploads/${body.operationId}/commit`, {
313
+ ...options,
314
+ method: "POST",
315
+ body: commit
316
+ })
317
+ );
318
+ }
319
+ async function commitWorkspace(custody, options) {
320
+ if (!custody.pendingCreate) return getWorkspace(custody, options);
321
+ const receipt = await commitUpload(custody, custody.pendingCreate, options);
322
+ custody.version = receipt.version;
323
+ custody.currentRevision = receipt.revisionId;
324
+ delete custody.pendingCreate;
325
+ delete custody.spoolDirectory;
326
+ return receipt;
327
+ }
328
+ async function getWorkspace(access, options) {
329
+ const result = assertLargeObjectContract(
330
+ await request(access, "", options),
331
+ "encrypted-workspace-v2"
332
+ );
333
+ if (result.id !== access.id) throw new TypeError("Workspace identity differs.");
334
+ const ring = await unseal(
335
+ result.keyring,
336
+ await keyMaterial(access.token, access.id, "key-wrap"),
337
+ { type: "keyring", workspaceId: access.id, epoch: result.epoch }
338
+ );
339
+ if (canonicalizeJson(ring.ownerPublicKey) !== canonicalizeJson(result.ownerPublicKey) || access.ownerPublicKey && canonicalizeJson(access.ownerPublicKey) !== canonicalizeJson(result.ownerPublicKey) || !ring.keys?.[result.epoch] || Object.entries(ring.keys).some(
340
+ ([epoch, key]) => !/^[1-9][0-9]*$/u.test(epoch) || !tokenPattern.test(key)
341
+ ))
342
+ throw new TypeError("Workspace key history or owner identity differs.");
343
+ Object.assign(access, result, { keys: ring.keys });
344
+ return result;
345
+ }
346
+ async function openRevision(access, revisionId = access.currentRevision, options = {}) {
347
+ if (!access.keys) await getWorkspace(access, options);
348
+ if (!idPattern.test(revisionId)) throw new TypeError("Revision identity is invalid.");
349
+ const manifest = assertLargeObjectContract(
350
+ await request(access, `/revisions/${revisionId}/manifest`, {
351
+ ...options,
352
+ limit: LARGE_OBJECT_LIMITS.manifestBytes
353
+ }),
354
+ "encrypted-resource-manifest"
355
+ );
356
+ if (manifest.workspaceId !== access.id || manifest.revisionId !== revisionId || !access.keys[manifest.epoch])
357
+ throw new TypeError("Revision identity or key epoch differs.");
358
+ return openResourcePack(manifest, {
359
+ rawKey: decodeResourceBytes(access.keys[manifest.epoch], 32),
360
+ verify: (value) => legacy.verifyWorkspaceSignature(value, access.ownerPublicKey),
361
+ fetchChunk: (index) => request(access, `/revisions/${revisionId}/chunks/${index}`, {
362
+ ...options,
363
+ binary: true,
364
+ limit: LARGE_OBJECT_LIMITS.chunkBytes
365
+ })
366
+ });
367
+ }
368
+ async function decryptWorkspaceRevision(access, revisionId, options) {
369
+ const pack = await openRevision(access, revisionId, options);
370
+ try {
371
+ const bundle = assertBundle(await pack.loadBundle());
372
+ const reviewOf = digestBundle ? digestBundle(bundle) : legacy.workspaceEnvelopeDigest(digestInput(bundle));
373
+ if (pack.reviewOf !== void 0 && pack.reviewOf !== reviewOf)
374
+ throw new TypeError("Full review basis differs from authenticated catalog.");
375
+ return { ...bundle, workspaceRevision: revisionId ?? access.currentRevision, reviewOf };
376
+ } finally {
377
+ pack.dispose();
378
+ }
379
+ }
380
+ async function prepareWorkspaceMutation(custody, action, payload) {
381
+ if (custody.pendingCreate || custody.pendingMutation)
382
+ throw new Error("Retry the pending sharing operation before preparing another.");
383
+ if (action === "publish")
384
+ custody.pendingMutation = { action, body: await prepareUpload(custody, payload), next: {} };
385
+ else {
386
+ let body = {
387
+ operationId: legacy.newWorkspaceId(),
388
+ expectedVersion: custody.version,
389
+ epoch: custody.epoch
390
+ }, next = {};
391
+ if (action === "rotate") {
392
+ const token = legacy.newWorkspaceToken(), epoch = custody.epoch + 1, keys = { ...custody.keys, [epoch]: legacy.newWorkspaceToken() };
393
+ const keyring = await wrap(custody, token, epoch, keys);
394
+ body = {
395
+ ...body,
396
+ epoch,
397
+ reviewerAuthHash: sha256Hex(
398
+ await legacy.deriveWorkspaceAuthentication(token, custody.id)
399
+ ),
400
+ keyring
401
+ };
402
+ next = { token, epoch, keys, keyring };
403
+ } else if (["pause", "resume", "revoke", "delete"].includes(action)) body.action = action;
404
+ else throw new TypeError("Unknown sharing action.");
405
+ custody.pendingMutation = {
406
+ action,
407
+ body: await legacy.signWorkspaceValue(body, custody.ownerPrivateKey),
408
+ next
409
+ };
410
+ }
411
+ return custody.pendingMutation;
412
+ }
413
+ async function commitWorkspaceMutation(custody, options) {
414
+ const pending = custody.pendingMutation;
415
+ if (!pending) throw new Error("No sharing operation is pending.");
416
+ let result;
417
+ if (pending.action === "publish") result = await commitUpload(custody, pending.body, options);
418
+ else {
419
+ result = await request(custody, pending.action === "rotate" ? "/rotate" : "/manage", {
420
+ ...options,
421
+ method: "POST",
422
+ body: pending.body
423
+ });
424
+ if (pending.action === "delete") {
425
+ if (result.id !== custody.id || result.deleted !== true || result.schemaVersion !== "2.0.0" || Object.keys(result).some((key) => !["id", "deleted", "schemaVersion"].includes(key)))
426
+ throw new TypeError("Deletion receipt is invalid.");
427
+ } else {
428
+ assertLargeObjectContract(result, "encrypted-workspace-v2");
429
+ if (["pause", "resume"].includes(pending.action) && result.commentsPaused !== (pending.action === "pause"))
430
+ throw new TypeError("Management state differs.");
431
+ if (result.id !== custody.id || result.version !== pending.body.expectedVersion + 1 || result.epoch !== pending.body.epoch || result.currentRevision !== custody.currentRevision || canonicalizeJson(result.ownerPublicKey) !== canonicalizeJson(custody.ownerPublicKey) || canonicalizeJson(result.keyring) !== canonicalizeJson(pending.next.keyring ?? custody.keyring))
432
+ throw new TypeError("Management receipt is invalid.");
433
+ }
434
+ }
435
+ Object.assign(custody, pending.next, { version: pending.body.expectedVersion + 1 });
436
+ if (pending.action === "publish") {
437
+ custody.currentRevision = result.revisionId;
438
+ delete custody.spoolDirectory;
439
+ }
440
+ if (["pause", "resume"].includes(pending.action))
441
+ custody.commentsPaused = pending.action === "pause";
442
+ if (["revoke", "delete"].includes(pending.action))
443
+ custody.status = pending.action === "revoke" ? "revoked" : "deleted";
444
+ delete custody.pendingMutation;
445
+ return result;
446
+ }
447
+ async function prepareWorkspaceEvent(access, payload, { revisionId = access.currentRevision, reviewOf, signer } = {}) {
448
+ assertFeedback(payload);
449
+ if (!access.keys) throw new Error("Load the workspace before preparing feedback.");
450
+ signer ??= await legacy.createWorkspaceSigner();
451
+ const header = {
452
+ id: legacy.newWorkspaceId(),
453
+ epoch: access.epoch,
454
+ revisionId,
455
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
456
+ authorPublicKey: signer.publicKey
457
+ };
458
+ const context = {
459
+ context: "openplanr.workspace-event.v2",
460
+ workspaceId: access.id,
461
+ id: header.id,
462
+ epoch: header.epoch,
463
+ revisionId
464
+ };
465
+ const event = await legacy.signWorkspaceValue(
466
+ {
467
+ ...header,
468
+ ...await seal(
469
+ { payload, reviewOf: reviewOf ?? payload.reviewOf },
470
+ decodeResourceBytes(access.keys[header.epoch], 32),
471
+ context,
472
+ LARGE_OBJECT_LIMITS.eventBytes
473
+ )
474
+ },
475
+ signer.privateKey
476
+ );
477
+ return assertLargeObjectContract(event, "encrypted-workspace-event-v2");
478
+ }
479
+ async function appendWorkspaceEvent(access, event, options) {
480
+ assertLargeObjectContract(event, "encrypted-workspace-event-v2");
481
+ const result = await request(access, "/events", { ...options, method: "POST", body: event });
482
+ if (result.id !== event.id || !Number.isSafeInteger(result.sequence) || result.sequence < 1)
483
+ throw new TypeError("Feedback receipt differs.");
484
+ return result;
485
+ }
486
+ async function readWorkspaceEvents(access, { after = 0, ...options } = {}) {
487
+ if (!Number.isSafeInteger(after) || after < 0) throw new TypeError("Invalid feedback cursor.");
488
+ if (!access.keys) await getWorkspace(access, options);
489
+ const page = await request(access, `/events?after=${after}`, {
490
+ ...options,
491
+ limit: LARGE_OBJECT_LIMITS.eventPageBytes
492
+ });
493
+ if (!Array.isArray(page.events) || page.events.length > LARGE_OBJECT_LIMITS.eventPageCount || !Number.isSafeInteger(page.cursor) || page.cursor < after || page.hasMore && page.cursor === after || typeof page.hasMore !== "boolean")
494
+ throw new TypeError("Feedback page is invalid.");
495
+ const events = [], issues = [];
496
+ let previous = after;
497
+ for (const entry of page.events) {
498
+ try {
499
+ const { sequence, ...event } = entry;
500
+ if (!Number.isSafeInteger(sequence) || sequence <= previous || sequence > page.cursor)
501
+ throw new TypeError("Feedback sequence is invalid.");
502
+ previous = sequence;
503
+ assertLargeObjectContract(event, "encrypted-workspace-event-v2");
504
+ if (!await legacy.verifyWorkspaceSignature(event, event.authorPublicKey) || !access.keys[event.epoch])
505
+ throw new TypeError("Feedback signature or key epoch is invalid.");
506
+ const value = await unseal(
507
+ event,
508
+ decodeResourceBytes(access.keys[event.epoch], 32),
509
+ {
510
+ context: "openplanr.workspace-event.v2",
511
+ workspaceId: access.id,
512
+ id: event.id,
513
+ epoch: event.epoch,
514
+ revisionId: event.revisionId
515
+ },
516
+ LARGE_OBJECT_LIMITS.eventBytes
517
+ );
518
+ assertFeedback(value.payload);
519
+ if (value.payload.reviewOf !== void 0 && value.payload.reviewOf !== value.reviewOf)
520
+ throw new TypeError("Feedback payload identity differs.");
521
+ if (!/^[a-f0-9]{64}$/u.test(value.reviewOf ?? ""))
522
+ throw new TypeError("Feedback review identity is invalid.");
523
+ events.push({
524
+ ...event,
525
+ publicKey: event.authorPublicKey,
526
+ sequence,
527
+ reviewOf: value.reviewOf,
528
+ payload: value.payload
529
+ });
530
+ } catch (error) {
531
+ issues.push({ id: entry.id, sequence: entry.sequence, reason: error.message });
532
+ }
533
+ }
534
+ return { ...page, events, issues };
535
+ }
536
+ return {
537
+ capabilities,
538
+ prepareWorkspace,
539
+ commitWorkspace,
540
+ getWorkspace,
541
+ openRevision,
542
+ decryptWorkspaceRevision,
543
+ listWorkspaceRevisions: (access, options) => request(access, "/revisions", options),
544
+ prepareWorkspaceMutation,
545
+ commitWorkspaceMutation,
546
+ prepareWorkspaceEvent,
547
+ appendWorkspaceEvent,
548
+ readWorkspaceEvents
549
+ };
550
+ }
551
+
552
+ export {
553
+ uploadChunksFor,
554
+ createChunkedWorkspaceClient
555
+ };