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,647 @@
1
+ import {
2
+ canonicalizeJson,
3
+ sha256Hex
4
+ } from "./design-shared-protocol-contracts-75a938cc.mjs";
5
+
6
+ // packages/artifact/lib/artifact/internal/workspace-address.mjs
7
+ function createWorkspaceAddress({
8
+ label,
9
+ reviewPath,
10
+ defaultBaseUrl = "https://share.openplanr.dev"
11
+ }) {
12
+ function normalizeWorkspaceBase(baseUrl = defaultBaseUrl) {
13
+ const url = new URL(baseUrl);
14
+ if (url.username || url.password || url.search || url.hash || url.pathname !== "/" || url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))
15
+ throw new TypeError(
16
+ `${label} sharing requires an HTTPS origin or a local development server.`
17
+ );
18
+ return url.origin;
19
+ }
20
+ function workspaceReviewUrl(access) {
21
+ if (!/^[A-Za-z0-9_-]{22,64}$/.test(access.id))
22
+ throw new TypeError(`Invalid ${label.toLowerCase()} workspace identity.`);
23
+ return `${normalizeWorkspaceBase(access.baseUrl)}${reviewPath}/${access.id}`;
24
+ }
25
+ return { normalizeWorkspaceBase, workspaceReviewUrl };
26
+ }
27
+
28
+ // packages/artifact/lib/artifact/encrypted-workspace-client.mjs
29
+ function createEncryptedWorkspaceClient({
30
+ domain,
31
+ apiPath,
32
+ reviewPath,
33
+ label,
34
+ compatibilityMessage,
35
+ compatibilityCode = "E_WORKSPACE_UNSUPPORTED",
36
+ defaultBaseUrl = "https://share.openplanr.dev",
37
+ version = "1.0.0",
38
+ maxBytes = 5 * 1024 * 1024,
39
+ maxEventBytes = 256 * 1024,
40
+ schemas,
41
+ assertContract,
42
+ assertBundle,
43
+ assertFeedback,
44
+ bundleDigest,
45
+ digestInput = (bundle) => bundle,
46
+ packBundle = async (bundle) => bundle,
47
+ unpackBundle = async (bundle) => bundle
48
+ }) {
49
+ if (!domain || !apiPath?.startsWith("/") || !reviewPath?.startsWith("/") || !label)
50
+ throw new TypeError("An encrypted workspace requires an explicit domain and routes.");
51
+ const encoder = new TextEncoder();
52
+ const decoder = new TextDecoder("utf-8", { fatal: true });
53
+ const tokenPattern = /^[A-Za-z0-9_-]{43}$/;
54
+ const idPattern = /^[A-Za-z0-9_-]{22,64}$/;
55
+ const ec = { name: "ECDSA", namedCurve: "P-256" };
56
+ const signatureAlgorithm = { name: "ECDSA", hash: "SHA-256" };
57
+ const omitSignature = ({ signature: _signature, ...value }) => value;
58
+ const operationError = (message, code, status) => Object.assign(new Error(message), { code, ...status ? { status } : {} });
59
+ function encodeWorkspaceBytes(bytes) {
60
+ let binary = "";
61
+ for (let offset = 0; offset < bytes.length; offset += 8192)
62
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + 8192));
63
+ return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
64
+ }
65
+ function decodeWorkspaceBytes(value) {
66
+ if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/u.test(value))
67
+ throw new TypeError("Invalid encoded workspace value.");
68
+ const decoded = Uint8Array.from(
69
+ atob(value.replaceAll("-", "+").replaceAll("_", "/")),
70
+ (char) => char.charCodeAt(0)
71
+ );
72
+ if (encodeWorkspaceBytes(decoded) !== value)
73
+ throw new TypeError("Noncanonical encoded workspace value.");
74
+ return decoded;
75
+ }
76
+ function newWorkspaceToken() {
77
+ return encodeWorkspaceBytes(crypto.getRandomValues(new Uint8Array(32)));
78
+ }
79
+ function newWorkspaceId() {
80
+ return encodeWorkspaceBytes(crypto.getRandomValues(new Uint8Array(18)));
81
+ }
82
+ const { normalizeWorkspaceBase, workspaceReviewUrl } = createWorkspaceAddress({
83
+ label,
84
+ reviewPath,
85
+ defaultBaseUrl
86
+ });
87
+ async function tokenMaterial(token, id, purpose) {
88
+ if (!tokenPattern.test(token) || decodeWorkspaceBytes(token).length !== 32 || !idPattern.test(id))
89
+ throw new TypeError("Enter the complete generated access token.");
90
+ const key = await crypto.subtle.importKey("raw", decodeWorkspaceBytes(token), "HKDF", false, [
91
+ "deriveBits"
92
+ ]);
93
+ return new Uint8Array(
94
+ await crypto.subtle.deriveBits(
95
+ {
96
+ name: "HKDF",
97
+ hash: "SHA-256",
98
+ salt: encoder.encode(id),
99
+ info: encoder.encode(`${domain}/${purpose}`)
100
+ },
101
+ key,
102
+ 256
103
+ )
104
+ );
105
+ }
106
+ async function deriveWorkspaceAuthentication(token, id) {
107
+ return encodeWorkspaceBytes(await tokenMaterial(token, id, "reviewer-auth"));
108
+ }
109
+ function canonicalWorkspacePublicKey(value) {
110
+ if (value?.kty !== "EC" || value.crv !== "P-256" || !tokenPattern.test(value.x ?? "") || !tokenPattern.test(value.y ?? "") || "d" in value) {
111
+ throw new TypeError(`Invalid ${label.toLowerCase()} workspace public key.`);
112
+ }
113
+ return { kty: "EC", crv: "P-256", x: value.x, y: value.y };
114
+ }
115
+ async function createWorkspaceSigner() {
116
+ const pair = await crypto.subtle.generateKey(ec, true, ["sign", "verify"]);
117
+ return {
118
+ privateKey: encodeWorkspaceBytes(
119
+ new Uint8Array(await crypto.subtle.exportKey("pkcs8", pair.privateKey))
120
+ ),
121
+ publicKey: canonicalWorkspacePublicKey(await crypto.subtle.exportKey("jwk", pair.publicKey))
122
+ };
123
+ }
124
+ async function signWorkspaceValue(value, privateKey) {
125
+ const key = await crypto.subtle.importKey(
126
+ "pkcs8",
127
+ decodeWorkspaceBytes(privateKey),
128
+ ec,
129
+ false,
130
+ ["sign"]
131
+ );
132
+ const signature = await crypto.subtle.sign(
133
+ signatureAlgorithm,
134
+ key,
135
+ encoder.encode(canonicalizeJson(omitSignature(value)))
136
+ );
137
+ return { ...omitSignature(value), signature: encodeWorkspaceBytes(new Uint8Array(signature)) };
138
+ }
139
+ async function verifyWorkspaceSignature(value, publicKey) {
140
+ try {
141
+ const key = await crypto.subtle.importKey("jwk", publicKey, ec, false, ["verify"]);
142
+ return await crypto.subtle.verify(
143
+ signatureAlgorithm,
144
+ key,
145
+ decodeWorkspaceBytes(value.signature),
146
+ encoder.encode(canonicalizeJson(omitSignature(value)))
147
+ );
148
+ } catch {
149
+ return false;
150
+ }
151
+ }
152
+ async function seal(value, rawKey, context, limit = maxBytes) {
153
+ const bytes = encoder.encode(canonicalizeJson(value));
154
+ if (bytes.length + 16 > limit)
155
+ throw Object.assign(
156
+ new RangeError(
157
+ `Encrypted ${label.toLowerCase()} data exceeds the ${Math.floor(limit / 1024)} KB upload limit.`
158
+ ),
159
+ { code: "E_WORKSPACE_PAYLOAD_TOO_LARGE", status: 413 }
160
+ );
161
+ const key = await crypto.subtle.importKey("raw", rawKey, "AES-GCM", false, ["encrypt"]);
162
+ const iv = crypto.getRandomValues(new Uint8Array(12));
163
+ const ciphertext = await crypto.subtle.encrypt(
164
+ { name: "AES-GCM", iv, additionalData: encoder.encode(canonicalizeJson(context)) },
165
+ key,
166
+ bytes
167
+ );
168
+ return {
169
+ iv: encodeWorkspaceBytes(iv),
170
+ ciphertext: encodeWorkspaceBytes(new Uint8Array(ciphertext))
171
+ };
172
+ }
173
+ async function unseal(value, rawKey, context, limit = maxBytes) {
174
+ const bytes = decodeWorkspaceBytes(value.ciphertext);
175
+ if (bytes.length > limit)
176
+ throw new RangeError(`Shared ${label.toLowerCase()} data exceeds its size limit.`);
177
+ const key = await crypto.subtle.importKey("raw", rawKey, "AES-GCM", false, ["decrypt"]);
178
+ const plaintext = await crypto.subtle.decrypt(
179
+ {
180
+ name: "AES-GCM",
181
+ iv: decodeWorkspaceBytes(value.iv),
182
+ additionalData: encoder.encode(canonicalizeJson(context))
183
+ },
184
+ key,
185
+ bytes
186
+ );
187
+ return JSON.parse(decoder.decode(plaintext));
188
+ }
189
+ const keyringContext = (id, epoch) => ({ type: "keyring", workspaceId: id, epoch });
190
+ const revisionContext = (id, revision) => ({
191
+ type: "revision",
192
+ workspaceId: id,
193
+ id: revision.id,
194
+ epoch: revision.epoch,
195
+ reviewOf: revision.reviewOf
196
+ });
197
+ const eventContext = (id, event) => ({
198
+ type: "event",
199
+ workspaceId: id,
200
+ id: event.id,
201
+ epoch: event.epoch,
202
+ revisionId: event.revisionId,
203
+ reviewOf: event.reviewOf
204
+ });
205
+ function workspaceEnvelopeDigest(value) {
206
+ return bundleDigest(value);
207
+ }
208
+ async function wrapKeyring(custody, token = custody.token, epoch = custody.epoch, keys = custody.keys) {
209
+ return seal(
210
+ { keys, ownerPublicKey: custody.ownerPublicKey },
211
+ await tokenMaterial(token, custody.id, "key-wrap"),
212
+ keyringContext(custody.id, epoch)
213
+ );
214
+ }
215
+ async function prepareRevision(custody, bundle) {
216
+ assertBundle(bundle);
217
+ const header = {
218
+ id: newWorkspaceId(),
219
+ epoch: custody.epoch,
220
+ reviewOf: workspaceEnvelopeDigest(digestInput(bundle)),
221
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
222
+ };
223
+ return signWorkspaceValue(
224
+ {
225
+ ...header,
226
+ ...await seal(
227
+ await packBundle(bundle),
228
+ decodeWorkspaceBytes(custody.keys[custody.epoch]),
229
+ revisionContext(custody.id, header)
230
+ )
231
+ },
232
+ custody.ownerPrivateKey
233
+ );
234
+ }
235
+ async function prepareWorkspace(bundle, { baseUrl = defaultBaseUrl } = {}) {
236
+ const signer = await createWorkspaceSigner();
237
+ const custody = {
238
+ schemaVersion: version,
239
+ id: newWorkspaceId(),
240
+ baseUrl: normalizeWorkspaceBase(baseUrl),
241
+ token: newWorkspaceToken(),
242
+ ownerAuth: newWorkspaceToken(),
243
+ ownerPrivateKey: signer.privateKey,
244
+ ownerPublicKey: signer.publicKey,
245
+ epoch: 1,
246
+ keys: { 1: newWorkspaceToken() },
247
+ version: 0
248
+ };
249
+ custody.keyring = await wrapKeyring(custody);
250
+ custody.pendingCreate = await signWorkspaceValue(
251
+ {
252
+ schemaVersion: version,
253
+ id: custody.id,
254
+ ownerPublicKey: custody.ownerPublicKey,
255
+ ownerAuthHash: sha256Hex(custody.ownerAuth),
256
+ reviewerAuthHash: sha256Hex(await deriveWorkspaceAuthentication(custody.token, custody.id)),
257
+ epoch: 1,
258
+ keyring: custody.keyring,
259
+ revision: await prepareRevision(custody, bundle),
260
+ operationId: newWorkspaceId()
261
+ },
262
+ custody.ownerPrivateKey
263
+ );
264
+ assertContract(custody.pendingCreate, schemas.create);
265
+ return custody;
266
+ }
267
+ async function request(access, suffix = "", {
268
+ method = "GET",
269
+ body,
270
+ fetchImpl = globalThis.fetch,
271
+ owner = Boolean(access.ownerAuth),
272
+ timeoutMs = 2e4
273
+ } = {}) {
274
+ if (!idPattern.test(access.id))
275
+ throw new TypeError(`Invalid ${label.toLowerCase()} workspace identity.`);
276
+ const authorization = owner ? access.ownerAuth : await deriveWorkspaceAuthentication(access.token, access.id);
277
+ const headers = { Authorization: `Bearer ${authorization}`, Accept: "application/json" };
278
+ if (body) headers["Content-Type"] = "application/json";
279
+ let response;
280
+ try {
281
+ response = await fetchImpl(
282
+ `${normalizeWorkspaceBase(access.baseUrl)}${apiPath}/${access.id}${suffix}`,
283
+ {
284
+ method,
285
+ headers,
286
+ body: body ? JSON.stringify(body) : void 0,
287
+ redirect: "error",
288
+ cache: "no-store",
289
+ credentials: "omit",
290
+ signal: AbortSignal.timeout(timeoutMs)
291
+ }
292
+ );
293
+ } catch {
294
+ throw operationError(
295
+ `${label} sharing is unreachable. Check the connection and retry; the previous review is unchanged.`,
296
+ "E_WORKSPACE_NETWORK"
297
+ );
298
+ }
299
+ if (!response.ok) await throwResponseError(response, method);
300
+ return readResponse(response);
301
+ }
302
+ async function throwResponseError(response, method) {
303
+ if (response.status === 404 && method === "PUT" && compatibilityMessage) {
304
+ const error2 = new Error(compatibilityMessage);
305
+ error2.code = compatibilityCode;
306
+ error2.status = 404;
307
+ throw error2;
308
+ }
309
+ const messages = {
310
+ 401: "Access token is incorrect or has been rotated.",
311
+ 403: "This review is unavailable or this action requires its owner.",
312
+ 404: "This shared review could not be found.",
313
+ 409: "The shared review changed. Refresh its status before retrying.",
314
+ 410: "This shared review has been revoked or deleted.",
315
+ 413: `This ${label.toLowerCase()} exceeds the sharing upload limit.`,
316
+ 429: "Too many requests. Wait a moment and retry.",
317
+ 503: `${label} sharing is temporarily unavailable. Retry shortly.`
318
+ };
319
+ const error = new Error(
320
+ messages[response.status] ?? `${label} sharing failed (${response.status}). Retry shortly.`
321
+ );
322
+ error.status = response.status;
323
+ error.code = `E_WORKSPACE_HTTP_${response.status}`;
324
+ try {
325
+ const reader = response.body?.getReader();
326
+ const body = reader && JSON.parse(decoder.decode(await responseBytes(reader, 4096)));
327
+ if (typeof body?.error === "string" && /^[A-Za-z][A-Za-z0-9_-]{0,127}$/u.test(body.error))
328
+ error.code = body.error;
329
+ } catch {
330
+ }
331
+ if (response.status === 429) {
332
+ const header = response.headers.get("retry-after");
333
+ const seconds = header && /^\d+(?:\.\d+)?$/u.test(header.trim()) ? Number(header) : header ? (Date.parse(header) - Date.now()) / 1e3 : NaN;
334
+ if (Number.isFinite(seconds) && seconds >= 0)
335
+ error.retryAfterSeconds = Math.min(3600, Math.max(1, Math.ceil(seconds)));
336
+ }
337
+ throw error;
338
+ }
339
+ async function responseBytes(reader, limit) {
340
+ const chunks = [];
341
+ let length = 0;
342
+ try {
343
+ for (; ; ) {
344
+ const { value, done } = await reader.read();
345
+ if (done) break;
346
+ length += value.length;
347
+ if (length > limit) {
348
+ await reader.cancel();
349
+ throw new RangeError(`${label} service returned an oversized response.`);
350
+ }
351
+ chunks.push(value);
352
+ }
353
+ } catch (error) {
354
+ if (error instanceof RangeError) throw error;
355
+ throw new Error("The sharing response was interrupted. Retry the pending operation.");
356
+ }
357
+ const bytes = new Uint8Array(length);
358
+ let offset = 0;
359
+ for (const chunk of chunks) {
360
+ bytes.set(chunk, offset);
361
+ offset += chunk.length;
362
+ }
363
+ return bytes;
364
+ }
365
+ async function readResponse(response) {
366
+ if (response.status === 204) return {};
367
+ const reader = response.body?.getReader();
368
+ if (!reader) throw new Error(`${label} service returned an empty response.`);
369
+ try {
370
+ return JSON.parse(decoder.decode(await responseBytes(reader, maxBytes * 1.5 + 65536)));
371
+ } catch (cause) {
372
+ throw Object.assign(
373
+ operationError(
374
+ "The sharing response could not be verified. Retry the pending operation.",
375
+ "E_WORKSPACE_RESPONSE_INVALID"
376
+ ),
377
+ { cause }
378
+ );
379
+ }
380
+ }
381
+ async function commitWorkspace(custody, options = {}) {
382
+ if (!custody.pendingCreate) return getWorkspace(custody, options);
383
+ const result = await request(custody, "", {
384
+ ...options,
385
+ method: "PUT",
386
+ body: custody.pendingCreate
387
+ });
388
+ assertContract(result, schemas.workspace);
389
+ if (result.id !== custody.id || result.version !== 1 || result.epoch !== 1 || result.currentRevision !== custody.pendingCreate.revision.id || canonicalizeJson(result.ownerPublicKey) !== canonicalizeJson(custody.ownerPublicKey) || canonicalizeJson(result.keyring) !== canonicalizeJson(custody.keyring))
390
+ throw new Error("The sharing creation receipt is invalid. Retry the saved operation.");
391
+ custody.version = result.version;
392
+ custody.currentRevision = result.currentRevision;
393
+ delete custody.pendingCreate;
394
+ return result;
395
+ }
396
+ async function getWorkspace(access, options = {}) {
397
+ const result = assertContract(await request(access, "", options), schemas.workspace);
398
+ if (result.id !== access.id) throw new Error("Shared review identity mismatch.");
399
+ const ring = await unseal(
400
+ result.keyring,
401
+ await tokenMaterial(access.token, access.id, "key-wrap"),
402
+ keyringContext(access.id, result.epoch)
403
+ );
404
+ if (canonicalizeJson(ring.ownerPublicKey) !== canonicalizeJson(result.ownerPublicKey) || access.ownerPublicKey && canonicalizeJson(access.ownerPublicKey) !== canonicalizeJson(result.ownerPublicKey))
405
+ throw new Error("Shared review owner identity changed.");
406
+ if (!ring.keys?.[result.epoch] || Object.entries(ring.keys).some(
407
+ ([keyEpoch, key]) => !/^[1-9][0-9]*$/u.test(keyEpoch) || !tokenPattern.test(key)
408
+ ))
409
+ throw new Error("Invalid shared review key history.");
410
+ Object.assign(access, {
411
+ keys: ring.keys,
412
+ ownerPublicKey: result.ownerPublicKey,
413
+ epoch: result.epoch,
414
+ keyring: result.keyring,
415
+ version: result.version,
416
+ currentRevision: result.currentRevision,
417
+ commentsPaused: result.commentsPaused
418
+ });
419
+ return result;
420
+ }
421
+ async function listWorkspaceRevisions(access, { after = "", ...options } = {}) {
422
+ if (after && !idPattern.test(after)) throw new TypeError("Invalid revision cursor.");
423
+ return request(
424
+ access,
425
+ `/revisions${after ? `?after=${encodeURIComponent(after)}` : ""}`,
426
+ options
427
+ );
428
+ }
429
+ async function decryptWorkspaceRevision(access, revisionId = access.currentRevision, options = {}) {
430
+ if (!access.keys) await getWorkspace(access, options);
431
+ if (!idPattern.test(revisionId))
432
+ throw new TypeError(`Invalid ${label.toLowerCase()} revision.`);
433
+ const revision = assertContract(
434
+ await request(access, `/revisions/${revisionId}`, options),
435
+ schemas.revision
436
+ );
437
+ if (revision.id !== revisionId || !await verifyWorkspaceSignature(revision, access.ownerPublicKey))
438
+ throw new Error(`The published ${label.toLowerCase()} signature is invalid.`);
439
+ if (!access.keys[revision.epoch])
440
+ throw new Error("The access token cannot open this revision.");
441
+ const bundle = assertBundle(
442
+ await unpackBundle(
443
+ await unseal(
444
+ revision,
445
+ decodeWorkspaceBytes(access.keys[revision.epoch]),
446
+ revisionContext(access.id, revision)
447
+ )
448
+ )
449
+ );
450
+ if (workspaceEnvelopeDigest(digestInput(bundle)) !== revision.reviewOf)
451
+ throw new Error(`Published ${label.toLowerCase()} content does not match its revision.`);
452
+ return { ...bundle, workspaceRevision: revision.id, reviewOf: revision.reviewOf };
453
+ }
454
+ async function prepareWorkspaceMutation(custody, action, payload = void 0) {
455
+ if (custody.pendingCreate)
456
+ throw new Error("Finish creating this shared review before changing it.");
457
+ if (custody.pendingMutation)
458
+ throw new Error("A sharing operation is pending. Retry it before making another change.");
459
+ const body = {
460
+ operationId: newWorkspaceId(),
461
+ expectedVersion: custody.version,
462
+ epoch: custody.epoch
463
+ };
464
+ let next = {};
465
+ if (action === "publish") body.revision = await prepareRevision(custody, payload);
466
+ else if (action === "rotate") {
467
+ const token = newWorkspaceToken();
468
+ const epoch = custody.epoch + 1;
469
+ const keys = { ...custody.keys, [epoch]: newWorkspaceToken() };
470
+ const keyring = await wrapKeyring(custody, token, epoch, keys);
471
+ Object.assign(body, {
472
+ epoch,
473
+ reviewerAuthHash: sha256Hex(await deriveWorkspaceAuthentication(token, custody.id)),
474
+ keyring
475
+ });
476
+ next = { token, epoch, keys, keyring };
477
+ } else if (["pause", "resume", "revoke", "delete"].includes(action)) body.action = action;
478
+ else throw new TypeError(`Unknown ${label.toLowerCase()} sharing operation.`);
479
+ custody.pendingMutation = {
480
+ action,
481
+ body: await signWorkspaceValue(body, custody.ownerPrivateKey),
482
+ next
483
+ };
484
+ return custody.pendingMutation;
485
+ }
486
+ function assertDeletionReceipt(custody, result) {
487
+ if (result.schemaVersion !== version || result.id !== custody.id || result.deleted !== true || Object.keys(result).some((key) => !["schemaVersion", "id", "deleted"].includes(key)))
488
+ throw new Error("The deletion receipt is invalid. Retry the saved operation.");
489
+ }
490
+ function assertMutationReceipt(custody, pending, result) {
491
+ if (pending.action === "delete") return assertDeletionReceipt(custody, result);
492
+ assertContract(result, schemas.workspace);
493
+ const expectedRevision = pending.action === "publish" ? pending.body.revision.id : custody.currentRevision;
494
+ if (result.id !== custody.id || result.version !== pending.body.expectedVersion + 1 || result.epoch !== pending.body.epoch || result.currentRevision !== expectedRevision || canonicalizeJson(result.ownerPublicKey) !== canonicalizeJson(custody.ownerPublicKey) || canonicalizeJson(result.keyring) !== canonicalizeJson(pending.next.keyring ?? custody.keyring) || ["pause", "resume"].includes(pending.action) && result.commentsPaused !== (pending.action === "pause"))
495
+ throw new Error("The sharing operation receipt is invalid. Retry the saved operation.");
496
+ }
497
+ async function commitWorkspaceMutation(custody, options = {}) {
498
+ const pending = custody.pendingMutation;
499
+ if (!pending) throw new Error("No sharing operation is pending.");
500
+ const suffix = ["publish", "rotate"].includes(pending.action) ? pending.action : "manage";
501
+ const result = await request(custody, `/${suffix}`, {
502
+ ...options,
503
+ method: "POST",
504
+ body: pending.body
505
+ });
506
+ assertMutationReceipt(custody, pending, result);
507
+ Object.assign(custody, pending.next, { version: pending.body.expectedVersion + 1 });
508
+ if (pending.action === "publish") custody.currentRevision = pending.body.revision.id;
509
+ if (pending.action === "pause" || pending.action === "resume")
510
+ custody.commentsPaused = pending.action === "pause";
511
+ if (pending.action === "revoke" || pending.action === "delete")
512
+ custody.status = pending.action === "revoke" ? "revoked" : "deleted";
513
+ delete custody.pendingMutation;
514
+ return result;
515
+ }
516
+ async function publishWorkspace(custody, bundle, options = {}) {
517
+ await prepareWorkspaceMutation(custody, "publish", bundle);
518
+ return commitWorkspaceMutation(custody, options);
519
+ }
520
+ async function rotateWorkspace(custody, options = {}) {
521
+ await prepareWorkspaceMutation(custody, "rotate");
522
+ return commitWorkspaceMutation(custody, options);
523
+ }
524
+ async function manageWorkspace(custody, action, options = {}) {
525
+ await prepareWorkspaceMutation(custody, action);
526
+ return commitWorkspaceMutation(custody, options);
527
+ }
528
+ async function prepareWorkspaceEvent(access, payload, { revisionId = access.currentRevision, reviewOf = payload.reviewOf, signer } = {}) {
529
+ if (!access.keys) throw new Error("Unlock the shared review before commenting.");
530
+ assertFeedback(payload);
531
+ const identity = signer ?? await createWorkspaceSigner();
532
+ const publicKey = canonicalWorkspacePublicKey(identity.publicKey);
533
+ const header = { id: newWorkspaceId(), revisionId, reviewOf, epoch: access.epoch };
534
+ const event = await signWorkspaceValue(
535
+ {
536
+ ...header,
537
+ ...await seal(
538
+ payload,
539
+ decodeWorkspaceBytes(access.keys[access.epoch]),
540
+ eventContext(access.id, header),
541
+ maxEventBytes
542
+ ),
543
+ publicKey
544
+ },
545
+ identity.privateKey
546
+ );
547
+ return assertContract(event, schemas.event);
548
+ }
549
+ async function appendWorkspaceEvent(access, payload, { preparedEvent, signer, revisionId, reviewOf, ...options } = {}) {
550
+ const event = preparedEvent ?? await prepareWorkspaceEvent(access, payload, {
551
+ signer,
552
+ revisionId,
553
+ reviewOf: reviewOf ?? payload.reviewOf
554
+ });
555
+ const result = await request(access, "/events", { ...options, method: "POST", body: event });
556
+ if (!result || typeof result !== "object" || Array.isArray(result) || !Number.isSafeInteger(result.sequence) || result.sequence < 1 || !result.event || typeof result.event !== "object" || Array.isArray(result.event))
557
+ throw new Error("The feedback receipt is invalid. Retry the saved operation.");
558
+ const { sequence: eventSequence, ...received } = result.event;
559
+ if (eventSequence !== void 0 && eventSequence !== result.sequence || canonicalizeJson(received) !== canonicalizeJson(event))
560
+ throw new Error(
561
+ "The feedback receipt does not match the saved event. Retry the saved operation."
562
+ );
563
+ return { event: { ...received, sequence: result.sequence }, sequence: result.sequence };
564
+ }
565
+ function assertEventPage(page, after) {
566
+ if (!Array.isArray(page.events) || page.events.length > 100 || !Number.isSafeInteger(page.cursor) || page.cursor < after || typeof page.hasMore !== "boolean")
567
+ throw new Error("Invalid shared feedback page.");
568
+ }
569
+ async function decryptEvent(access, record, sequence) {
570
+ assertContract(record, schemas.event);
571
+ if (!await verifyWorkspaceSignature(record, record.publicKey))
572
+ throw new Error("Signature verification failed.");
573
+ if (!access.keys[record.epoch]) throw new Error("The encryption epoch is unavailable.");
574
+ const payload = await unseal(
575
+ record,
576
+ decodeWorkspaceBytes(access.keys[record.epoch]),
577
+ eventContext(access.id, record),
578
+ maxEventBytes
579
+ );
580
+ assertFeedback(payload);
581
+ if (payload.reviewOf !== record.reviewOf) throw new Error("Feedback revision is invalid.");
582
+ return { ...record, sequence, payload };
583
+ }
584
+ function eventFromPage(item, pageIds, previousSequence, cursor) {
585
+ const { sequence, ...record } = item?.event ? { ...item.event, sequence: item.sequence } : item ?? {};
586
+ if (!Number.isSafeInteger(sequence) || sequence <= previousSequence || sequence > cursor)
587
+ throw new Error("Invalid shared feedback sequence.");
588
+ if (typeof record.id !== "string" || pageIds.has(record.id))
589
+ throw new Error("Invalid shared feedback event identity.");
590
+ pageIds.add(record.id);
591
+ return { sequence, record };
592
+ }
593
+ async function readWorkspaceEvents(access, { after = 0, ...options } = {}) {
594
+ if (!Number.isSafeInteger(after) || after < 0) throw new TypeError("Invalid feedback cursor.");
595
+ if (!access.keys) await getWorkspace(access, options);
596
+ const page = await request(access, `/events?after=${after}`, options);
597
+ assertEventPage(page, after);
598
+ const events = [], issues = [], pageIds = /* @__PURE__ */ new Set();
599
+ let previousSequence = after;
600
+ for (const item of page.events) {
601
+ const { sequence, record } = eventFromPage(item, pageIds, previousSequence, page.cursor);
602
+ previousSequence = sequence;
603
+ try {
604
+ events.push(await decryptEvent(access, record, sequence));
605
+ } catch {
606
+ issues.push({
607
+ sequence,
608
+ id: typeof record.id === "string" && idPattern.test(record.id) ? record.id : null,
609
+ reason: "Invalid encrypted feedback; not imported."
610
+ });
611
+ }
612
+ }
613
+ return { ...page, events, issues };
614
+ }
615
+ return {
616
+ encodeWorkspaceBytes,
617
+ decodeWorkspaceBytes,
618
+ newWorkspaceToken,
619
+ newWorkspaceId,
620
+ normalizeWorkspaceBase,
621
+ workspaceReviewUrl,
622
+ deriveWorkspaceAuthentication,
623
+ canonicalWorkspacePublicKey,
624
+ createWorkspaceSigner,
625
+ signWorkspaceValue,
626
+ verifyWorkspaceSignature,
627
+ workspaceEnvelopeDigest,
628
+ prepareWorkspace,
629
+ commitWorkspace,
630
+ getWorkspace,
631
+ listWorkspaceRevisions,
632
+ decryptWorkspaceRevision,
633
+ prepareWorkspaceMutation,
634
+ commitWorkspaceMutation,
635
+ publishWorkspace,
636
+ rotateWorkspace,
637
+ manageWorkspace,
638
+ prepareWorkspaceEvent,
639
+ appendWorkspaceEvent,
640
+ readWorkspaceEvents
641
+ };
642
+ }
643
+
644
+ export {
645
+ createWorkspaceAddress,
646
+ createEncryptedWorkspaceClient
647
+ };