openplanr 3.2.0 → 3.4.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 (411) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/cli/commands/artifact-design-share.d.ts +9 -0
  3. package/dist/cli/commands/artifact-design-share.d.ts.map +1 -0
  4. package/dist/cli/commands/artifact-design-share.js +200 -0
  5. package/dist/cli/commands/artifact-design-share.js.map +1 -0
  6. package/dist/cli/commands/artifact.d.ts.map +1 -1
  7. package/dist/cli/commands/artifact.js +5 -18
  8. package/dist/cli/commands/artifact.js.map +1 -1
  9. package/dist/cli/commands/ship.d.ts.map +1 -1
  10. package/dist/cli/commands/ship.js +2 -0
  11. package/dist/cli/commands/ship.js.map +1 -1
  12. package/dist/cli/commands/spec.d.ts +2 -1
  13. package/dist/cli/commands/spec.d.ts.map +1 -1
  14. package/dist/cli/commands/spec.js +45 -5
  15. package/dist/cli/commands/spec.js.map +1 -1
  16. package/dist/dashboard/.vite/manifest.json +2 -2
  17. package/dist/dashboard/assets/index-Cv4Vwhuw.css +2 -0
  18. package/dist/dashboard/assets/index-CvQAlBy3.js +75 -0
  19. package/dist/dashboard/assets/index-CvQAlBy3.js.map +1 -0
  20. package/dist/dashboard/dashboard-manifest.json +14 -14
  21. package/dist/dashboard/index.html +2 -2
  22. package/dist/services/claude-plugin-service.d.ts +5 -0
  23. package/dist/services/claude-plugin-service.d.ts.map +1 -1
  24. package/dist/services/claude-plugin-service.js +18 -2
  25. package/dist/services/claude-plugin-service.js.map +1 -1
  26. package/dist/services/codex-plugin-service.d.ts.map +1 -1
  27. package/dist/services/codex-plugin-service.js +11 -3
  28. package/dist/services/codex-plugin-service.js.map +1 -1
  29. package/dist/services/design-artifact-service.d.ts +20 -1
  30. package/dist/services/design-artifact-service.d.ts.map +1 -1
  31. package/dist/services/design-artifact-service.js +137 -18
  32. package/dist/services/design-artifact-service.js.map +1 -1
  33. package/dist/services/runtime-manager/codex-discovery.d.ts +1 -3
  34. package/dist/services/runtime-manager/codex-discovery.d.ts.map +1 -1
  35. package/dist/services/runtime-manager/codex-discovery.js +3 -16
  36. package/dist/services/runtime-manager/codex-discovery.js.map +1 -1
  37. package/dist/services/runtime-manager/doctor.d.ts +25 -0
  38. package/dist/services/runtime-manager/doctor.d.ts.map +1 -1
  39. package/dist/services/runtime-manager/doctor.js +480 -0
  40. package/dist/services/runtime-manager/doctor.js.map +1 -1
  41. package/dist/services/runtime-manager/errors.d.ts +12 -0
  42. package/dist/services/runtime-manager/errors.d.ts.map +1 -0
  43. package/dist/services/runtime-manager/errors.js +14 -0
  44. package/dist/services/runtime-manager/errors.js.map +1 -0
  45. package/dist/services/runtime-manager/global-state.d.ts +7 -0
  46. package/dist/services/runtime-manager/global-state.d.ts.map +1 -1
  47. package/dist/services/runtime-manager/global-state.js +116 -0
  48. package/dist/services/runtime-manager/global-state.js.map +1 -1
  49. package/dist/services/runtime-manager/host-version-probe.d.ts +8 -0
  50. package/dist/services/runtime-manager/host-version-probe.d.ts.map +1 -0
  51. package/dist/services/runtime-manager/host-version-probe.js +14 -0
  52. package/dist/services/runtime-manager/host-version-probe.js.map +1 -0
  53. package/dist/services/runtime-manager/install-plan.d.ts +25 -0
  54. package/dist/services/runtime-manager/install-plan.d.ts.map +1 -1
  55. package/dist/services/runtime-manager/install-plan.js +305 -0
  56. package/dist/services/runtime-manager/install-plan.js.map +1 -1
  57. package/dist/services/runtime-manager/inventory.d.ts +6 -0
  58. package/dist/services/runtime-manager/inventory.d.ts.map +1 -1
  59. package/dist/services/runtime-manager/inventory.js +16 -1
  60. package/dist/services/runtime-manager/inventory.js.map +1 -1
  61. package/dist/services/runtime-manager/legacy-adapters.d.ts +9 -0
  62. package/dist/services/runtime-manager/legacy-adapters.d.ts.map +1 -0
  63. package/dist/services/runtime-manager/legacy-adapters.js +187 -0
  64. package/dist/services/runtime-manager/legacy-adapters.js.map +1 -0
  65. package/dist/services/runtime-manager/paths.d.ts +18 -0
  66. package/dist/services/runtime-manager/paths.d.ts.map +1 -0
  67. package/dist/services/runtime-manager/paths.js +83 -0
  68. package/dist/services/runtime-manager/paths.js.map +1 -0
  69. package/dist/services/runtime-manager/runtime-package.d.ts +21 -0
  70. package/dist/services/runtime-manager/runtime-package.d.ts.map +1 -1
  71. package/dist/services/runtime-manager/runtime-package.js +77 -0
  72. package/dist/services/runtime-manager/runtime-package.js.map +1 -1
  73. package/dist/services/runtime-manager/storage.d.ts +47 -0
  74. package/dist/services/runtime-manager/storage.d.ts.map +1 -0
  75. package/dist/services/runtime-manager/storage.js +604 -0
  76. package/dist/services/runtime-manager/storage.js.map +1 -0
  77. package/dist/services/runtime-manager-service.d.ts +7 -17
  78. package/dist/services/runtime-manager-service.d.ts.map +1 -1
  79. package/dist/services/runtime-manager-service.js +32 -1695
  80. package/dist/services/runtime-manager-service.js.map +1 -1
  81. package/dist/services/ship-checks/contract.d.ts +15 -1
  82. package/dist/services/ship-checks/contract.d.ts.map +1 -1
  83. package/dist/services/ship-checks/contract.js +1 -1
  84. package/dist/services/ship-checks/contract.js.map +1 -1
  85. package/dist/services/ship-checks/coverage.d.ts +4 -0
  86. package/dist/services/ship-checks/coverage.d.ts.map +1 -0
  87. package/dist/services/ship-checks/coverage.js +113 -0
  88. package/dist/services/ship-checks/coverage.js.map +1 -0
  89. package/dist/services/ship-checks/discover.d.ts.map +1 -1
  90. package/dist/services/ship-checks/discover.js +5 -1
  91. package/dist/services/ship-checks/discover.js.map +1 -1
  92. package/dist/services/ship-checks/package-contents.d.ts +4 -0
  93. package/dist/services/ship-checks/package-contents.d.ts.map +1 -0
  94. package/dist/services/ship-checks/package-contents.js +91 -0
  95. package/dist/services/ship-checks/package-contents.js.map +1 -0
  96. package/dist/services/ship-checks/packages.d.ts +2 -0
  97. package/dist/services/ship-checks/packages.d.ts.map +1 -1
  98. package/dist/services/ship-checks/packages.js +4 -0
  99. package/dist/services/ship-checks/packages.js.map +1 -1
  100. package/dist/services/ship-checks/scope.js +2 -1
  101. package/dist/services/ship-checks/scope.js.map +1 -1
  102. package/dist/services/spec-service.d.ts +18 -0
  103. package/dist/services/spec-service.d.ts.map +1 -1
  104. package/dist/services/spec-service.js +174 -9
  105. package/dist/services/spec-service.js.map +1 -1
  106. package/dist/templates/spec/spec-shaped.md.hbs +1 -1
  107. package/dist/templates/spec/spec.md.hbs +2 -2
  108. package/dist/utils/splice-managed-block.js +1 -1
  109. package/dist/utils/splice-managed-block.js.map +1 -1
  110. package/docs/CLI.md +86 -2
  111. package/lib/host-packages/adapter-registry.json +5 -5
  112. package/lib/host-packages/capability-map.json +3 -3
  113. package/lib/host-packages/claude/.claude-plugin/marketplace.json +3 -3
  114. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +6 -6
  115. package/lib/host-packages/claude/openplanr/.openplanr-content.json +94 -146
  116. package/lib/host-packages/claude/openplanr/README.md +12 -12
  117. package/lib/host-packages/claude/openplanr/agents/planr-qa.md +5 -3
  118. package/lib/host-packages/claude/openplanr/references/agents/shared/modes/shared/task-context-resolution.md +4 -4
  119. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  120. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +110 -25
  121. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +851 -57
  122. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  123. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  124. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  125. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  126. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +1652 -0
  127. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs → claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs} +537 -5
  128. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  129. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +374 -61
  130. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +32 -59
  131. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +138 -133
  132. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5608
  133. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +2568 -0
  134. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  135. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +4 -4
  136. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  137. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +2 -2
  138. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +5 -5
  139. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +72 -2
  140. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +14 -7
  141. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +71 -34
  142. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +28 -14
  143. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +12 -12
  144. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +6 -2
  145. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.20.0 → claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0}/design-document.schema.json +131 -4
  146. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  147. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +616 -4775
  148. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +219 -424
  149. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +6 -2
  150. package/lib/host-packages/claude/openplanr/skills/delegate/SKILL.md +2 -1
  151. package/lib/host-packages/claude/openplanr/skills/delegate/references/integration-review.md +26 -20
  152. package/lib/host-packages/claude/openplanr/skills/delegate/references/operator-guide.md +25 -1
  153. package/lib/host-packages/claude/openplanr/skills/delegate/references/run-handoff.md +2 -2
  154. package/lib/host-packages/claude/openplanr/skills/delegate/references/worktree-custody.md +17 -9
  155. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/claude.mjs +15 -3
  156. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/codex.mjs +38 -2
  157. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/native.mjs +5 -0
  158. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/custody.mjs +217 -10
  159. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/handoff.mjs +1080 -0
  160. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integrate.mjs +96 -201
  161. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integration-files.mjs +3 -382
  162. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/presentation.mjs +29 -12
  163. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-contract.mjs +11 -0
  164. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-execution.mjs +1 -1
  165. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-lifecycle.mjs +14 -10
  166. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-preparation.mjs +4 -0
  167. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-record.mjs +2 -2
  168. package/lib/host-packages/claude/openplanr/skills/design/references/design-system.md +17 -2
  169. package/lib/host-packages/claude/openplanr/skills/design/references/generation.md +60 -2
  170. package/lib/host-packages/claude/openplanr/skills/design/references/utilities.md +23 -7
  171. package/lib/host-packages/claude/openplanr/skills/design/schemas/design-document.schema.json +131 -4
  172. package/lib/host-packages/claude/openplanr/skills/design-loop/references/design-system.md +17 -2
  173. package/lib/host-packages/claude/openplanr/skills/design-loop/references/generation.md +60 -2
  174. package/lib/host-packages/claude/openplanr/skills/design-loop/references/utilities.md +23 -7
  175. package/lib/host-packages/claude/openplanr/skills/design-loop/schemas/design-document.schema.json +131 -4
  176. package/lib/host-packages/claude/openplanr/skills/design-review/references/design-system.md +17 -2
  177. package/lib/host-packages/claude/openplanr/skills/design-review/references/generation.md +60 -2
  178. package/lib/host-packages/claude/openplanr/skills/design-review/references/utilities.md +23 -7
  179. package/lib/host-packages/claude/openplanr/skills/design-review/schemas/design-document.schema.json +131 -4
  180. package/lib/host-packages/claude/openplanr/skills/investigate/SKILL.md +2 -1
  181. package/lib/host-packages/claude/openplanr/skills/investigate/references/fail-first.md +40 -0
  182. package/lib/host-packages/claude/openplanr/skills/plan/SKILL.md +21 -11
  183. package/lib/host-packages/claude/openplanr/skills/plan/schemas/design-document.schema.json +131 -4
  184. package/lib/host-packages/claude/openplanr/skills/ship/SKILL.md +51 -18
  185. package/lib/host-packages/claude/openplanr/skills/ship/references/fail-first.md +40 -0
  186. package/lib/host-packages/claude/openplanr/skills/ship/references/result-contract.md +7 -3
  187. package/lib/host-packages/claude/openplanr/skills/spec/SKILL.md +6 -0
  188. package/lib/host-packages/claude/openplanr/skills/spec/references/specification-contract.md +3 -1
  189. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +91 -143
  190. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  191. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/integration-review.md +26 -20
  192. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/operator-guide.md +25 -1
  193. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/run-handoff.md +2 -2
  194. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/worktree-custody.md +17 -9
  195. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/claude.mjs +15 -3
  196. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/codex.mjs +38 -2
  197. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/native.mjs +5 -0
  198. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/custody.mjs +217 -10
  199. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/handoff.mjs +1080 -0
  200. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integrate.mjs +96 -201
  201. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integration-files.mjs +3 -382
  202. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/presentation.mjs +29 -12
  203. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-contract.mjs +11 -0
  204. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-execution.mjs +1 -1
  205. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-lifecycle.mjs +14 -10
  206. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-preparation.mjs +4 -0
  207. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-record.mjs +2 -2
  208. package/lib/host-packages/cursor/openplanr/rules/planr-delegate.mdc +2 -1
  209. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/design-system.md +17 -2
  210. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/generation.md +60 -2
  211. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/utilities.md +23 -7
  212. package/lib/host-packages/cursor/openplanr/rules/planr-design/schemas/design-document.schema.json +131 -4
  213. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/design-system.md +17 -2
  214. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/generation.md +60 -2
  215. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/utilities.md +23 -7
  216. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/schemas/design-document.schema.json +131 -4
  217. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/design-system.md +17 -2
  218. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/generation.md +60 -2
  219. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/utilities.md +23 -7
  220. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/schemas/design-document.schema.json +131 -4
  221. package/lib/host-packages/cursor/openplanr/rules/planr-investigate/references/fail-first.md +40 -0
  222. package/lib/host-packages/cursor/openplanr/rules/planr-investigate.mdc +2 -1
  223. package/lib/host-packages/cursor/openplanr/rules/planr-plan/schemas/design-document.schema.json +131 -4
  224. package/lib/host-packages/cursor/openplanr/rules/planr-plan.mdc +21 -11
  225. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/fail-first.md +40 -0
  226. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/result-contract.md +7 -3
  227. package/lib/host-packages/cursor/openplanr/rules/planr-ship.mdc +51 -18
  228. package/lib/host-packages/cursor/openplanr/rules/planr-spec/references/specification-contract.md +3 -1
  229. package/lib/host-packages/cursor/openplanr/rules/planr-spec.mdc +6 -0
  230. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  231. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +110 -25
  232. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +851 -57
  233. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  234. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  235. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  236. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  237. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +1652 -0
  238. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/{design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs → design-shared-artifact-support-protocol-contracts-9f6918b0.mjs} +537 -5
  239. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  240. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +374 -61
  241. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +32 -59
  242. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +138 -133
  243. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5608
  244. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +2568 -0
  245. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  246. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +4 -4
  247. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  248. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +2 -2
  249. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +5 -5
  250. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +72 -2
  251. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +14 -7
  252. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +71 -34
  253. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +28 -14
  254. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +12 -12
  255. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +6 -2
  256. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/{v1.20.0 → v1.22.0}/design-document.schema.json +131 -4
  257. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  258. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +616 -4775
  259. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +219 -424
  260. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +6 -2
  261. package/lib/host-packages/openai/.claude-plugin/marketplace.json +3 -3
  262. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +2 -2
  263. package/lib/host-packages/openai/openplanr/.openplanr-content.json +98 -150
  264. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  265. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +110 -25
  266. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +851 -57
  267. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  268. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  269. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  270. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  271. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +1652 -0
  272. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs} +537 -5
  273. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  274. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +374 -61
  275. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +32 -59
  276. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +138 -133
  277. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5608
  278. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +2568 -0
  279. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  280. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +4 -4
  281. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  282. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +2 -2
  283. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +5 -5
  284. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +72 -2
  285. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +14 -7
  286. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +71 -34
  287. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +28 -14
  288. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +12 -12
  289. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +6 -2
  290. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.20.0 → openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0}/design-document.schema.json +131 -4
  291. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  292. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +616 -4775
  293. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +219 -424
  294. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +6 -2
  295. package/lib/host-packages/openai/openplanr/skills/delegate/SKILL.md +2 -1
  296. package/lib/host-packages/openai/openplanr/skills/delegate/openplanr.skill.json +1 -1
  297. package/lib/host-packages/openai/openplanr/skills/delegate/references/integration-review.md +26 -20
  298. package/lib/host-packages/openai/openplanr/skills/delegate/references/operator-guide.md +25 -1
  299. package/lib/host-packages/openai/openplanr/skills/delegate/references/run-handoff.md +2 -2
  300. package/lib/host-packages/openai/openplanr/skills/delegate/references/worktree-custody.md +17 -9
  301. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/claude.mjs +15 -3
  302. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/codex.mjs +38 -2
  303. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/native.mjs +5 -0
  304. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/custody.mjs +217 -10
  305. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/handoff.mjs +1080 -0
  306. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integrate.mjs +96 -201
  307. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integration-files.mjs +3 -382
  308. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/presentation.mjs +29 -12
  309. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-contract.mjs +11 -0
  310. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-execution.mjs +1 -1
  311. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-lifecycle.mjs +14 -10
  312. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-preparation.mjs +4 -0
  313. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-record.mjs +2 -2
  314. package/lib/host-packages/openai/openplanr/skills/design/references/design-system.md +17 -2
  315. package/lib/host-packages/openai/openplanr/skills/design/references/generation.md +60 -2
  316. package/lib/host-packages/openai/openplanr/skills/design/references/utilities.md +23 -7
  317. package/lib/host-packages/openai/openplanr/skills/design/schemas/design-document.schema.json +131 -4
  318. package/lib/host-packages/openai/openplanr/skills/design-loop/references/design-system.md +17 -2
  319. package/lib/host-packages/openai/openplanr/skills/design-loop/references/generation.md +60 -2
  320. package/lib/host-packages/openai/openplanr/skills/design-loop/references/utilities.md +23 -7
  321. package/lib/host-packages/openai/openplanr/skills/design-loop/schemas/design-document.schema.json +131 -4
  322. package/lib/host-packages/openai/openplanr/skills/design-review/references/design-system.md +17 -2
  323. package/lib/host-packages/openai/openplanr/skills/design-review/references/generation.md +60 -2
  324. package/lib/host-packages/openai/openplanr/skills/design-review/references/utilities.md +23 -7
  325. package/lib/host-packages/openai/openplanr/skills/design-review/schemas/design-document.schema.json +131 -4
  326. package/lib/host-packages/openai/openplanr/skills/investigate/SKILL.md +2 -1
  327. package/lib/host-packages/openai/openplanr/skills/investigate/agents/openai.yaml +1 -1
  328. package/lib/host-packages/openai/openplanr/skills/investigate/openplanr.skill.json +12 -1
  329. package/lib/host-packages/openai/openplanr/skills/investigate/references/fail-first.md +40 -0
  330. package/lib/host-packages/openai/openplanr/skills/plan/SKILL.md +21 -11
  331. package/lib/host-packages/openai/openplanr/skills/plan/openplanr.skill.json +1 -1
  332. package/lib/host-packages/openai/openplanr/skills/plan/schemas/design-document.schema.json +131 -4
  333. package/lib/host-packages/openai/openplanr/skills/ship/SKILL.md +51 -18
  334. package/lib/host-packages/openai/openplanr/skills/ship/agents/openai.yaml +1 -1
  335. package/lib/host-packages/openai/openplanr/skills/ship/openplanr.skill.json +12 -1
  336. package/lib/host-packages/openai/openplanr/skills/ship/references/fail-first.md +40 -0
  337. package/lib/host-packages/openai/openplanr/skills/ship/references/result-contract.md +7 -3
  338. package/lib/host-packages/openai/openplanr/skills/spec/SKILL.md +6 -0
  339. package/lib/host-packages/openai/openplanr/skills/spec/openplanr.skill.json +1 -1
  340. package/lib/host-packages/openai/openplanr/skills/spec/references/specification-contract.md +3 -1
  341. package/lib/json-schema.mjs +4 -0
  342. package/package.json +16 -16
  343. package/dist/dashboard/assets/index-BU5fzjyz.css +0 -1
  344. package/dist/dashboard/assets/index-L8qtwqv6.js +0 -572
  345. package/dist/dashboard/assets/index-L8qtwqv6.js.map +0 -1
  346. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  347. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  348. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  349. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  350. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  351. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-support-6774fd3d5d02.mjs +0 -24
  352. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  353. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs +0 -1020
  354. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  355. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5778
  356. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  357. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  358. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  359. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +0 -1755
  360. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  361. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +0 -2633
  362. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  363. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  364. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  365. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  366. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  367. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integration-transaction.mjs +0 -958
  368. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integration-transaction.mjs +0 -958
  369. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  370. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  371. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  372. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  373. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  374. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-support-6774fd3d5d02.mjs +0 -24
  375. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  376. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs +0 -1020
  377. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  378. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5778
  379. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  380. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  381. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  382. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +0 -1755
  383. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  384. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +0 -2633
  385. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  386. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  387. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  388. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  389. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  390. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  391. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  392. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  393. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  394. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  395. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-support-6774fd3d5d02.mjs +0 -24
  396. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  397. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs +0 -1020
  398. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  399. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5778
  400. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  401. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  402. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  403. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +0 -1755
  404. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  405. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +0 -2633
  406. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  407. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  408. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  409. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  410. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  411. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integration-transaction.mjs +0 -958
@@ -1,555 +0,0 @@
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-b5f28f94.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
- };