@dipoleml/dcode-cli 1.1.0 → 1.2.1

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 (447) hide show
  1. package/dist/THIRD-PARTY-NOTICES.md +1081 -12
  2. package/dist/dcode.cjs +59368 -45608
  3. package/dist/packages/browser-use-plugin/README.md +12 -12
  4. package/dist/packages/browser-use-plugin/docs/api.json +1 -1
  5. package/dist/packages/browser-use-plugin/docs/overview.md +5 -4
  6. package/dist/packages/browser-use-plugin/docs/workflow.md +1 -1
  7. package/dist/packages/browser-use-plugin/scripts/build.mjs +1 -0
  8. package/dist/packages/browser-use-plugin/skills/control-browser/SKILL.md +10 -7
  9. package/dist/packages/bundled-skills/skills/dynamic-workflows/SKILL.md +760 -687
  10. package/dist/packages/bundled-skills/skills/dynamic-workflows/examples.md +310 -1
  11. package/dist/packages/bundled-skills/skills/dynamic-workflows/patterns.md +336 -4
  12. package/dist/packages/node-repl-host/.dcode-plugin/plugin.json +1 -1
  13. package/dist/packages/node-repl-host/dist/mcp/server.js +9 -14
  14. package/dist/packages/node-repl-host/scripts/build.mjs +1 -0
  15. package/dist/provider/dcode-builtin.json +6612 -202
  16. package/node_modules/@dcode/contracts/dist/compact/index.d.ts +7 -7
  17. package/node_modules/@dcode/contracts/dist/config/index.d.ts +1 -1
  18. package/node_modules/@dcode/contracts/dist/events/event-reducer.js +1 -0
  19. package/node_modules/@dcode/contracts/dist/events/in-memory-session-event-store.js +3 -2
  20. package/node_modules/@dcode/contracts/dist/events/session-event-retention.d.ts +8 -0
  21. package/node_modules/@dcode/contracts/dist/events/session-event-retention.js +18 -0
  22. package/node_modules/@dcode/contracts/dist/events/session.events.d.ts +94 -16
  23. package/node_modules/@dcode/contracts/dist/events/session.events.js +10 -0
  24. package/node_modules/@dcode/contracts/dist/hooks/index.d.ts +134 -134
  25. package/node_modules/@dcode/contracts/dist/hooks/workspace-hook-trust.d.ts +14 -14
  26. package/node_modules/@dcode/contracts/dist/index.d.ts +2 -0
  27. package/node_modules/@dcode/contracts/dist/index.js +2 -0
  28. package/node_modules/@dcode/contracts/dist/interfaces/browser-control.port.d.ts +22 -0
  29. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-hole.port.d.ts +92 -0
  30. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-hole.port.js +9 -0
  31. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-retune.port.d.ts +4 -4
  32. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-retune.port.js +7 -3
  33. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-workspace.port.js +8 -3
  34. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run.port.d.ts +119 -18
  35. package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run.port.js +13 -0
  36. package/node_modules/@dcode/contracts/dist/interfaces/index.d.ts +1 -0
  37. package/node_modules/@dcode/contracts/dist/interfaces/index.js +1 -0
  38. package/node_modules/@dcode/contracts/dist/interfaces/mcp.port.d.ts +161 -1
  39. package/node_modules/@dcode/contracts/dist/interfaces/mcp.port.js +17 -0
  40. package/node_modules/@dcode/contracts/dist/interfaces/permission-full-access.d.ts +15 -15
  41. package/node_modules/@dcode/contracts/dist/interfaces/permission-full-access.js +1 -1
  42. package/node_modules/@dcode/contracts/dist/interfaces/permission.port.d.ts +15 -1
  43. package/node_modules/@dcode/contracts/dist/interfaces/provider-endpoint-routing.port.d.ts +19 -0
  44. package/node_modules/@dcode/contracts/dist/interfaces/provider-endpoint-routing.port.js +1 -0
  45. package/node_modules/@dcode/contracts/dist/interfaces/session-store.port.d.ts +4 -2
  46. package/node_modules/@dcode/contracts/dist/interfaces/session-store.port.js +5 -0
  47. package/node_modules/@dcode/contracts/dist/interfaces/session.port.d.ts +92 -3
  48. package/node_modules/@dcode/contracts/dist/interfaces/session.port.js +4 -1
  49. package/node_modules/@dcode/contracts/dist/interfaces/topic-resource.port.d.ts +25 -0
  50. package/node_modules/@dcode/contracts/dist/interfaces/topic-resource.port.js +1 -0
  51. package/node_modules/@dcode/contracts/dist/model/index.d.ts +15 -1
  52. package/node_modules/@dcode/contracts/dist/model/index.js +5 -0
  53. package/node_modules/@dcode/contracts/dist/model/invocation-context.d.ts +6 -1
  54. package/node_modules/@dcode/contracts/dist/plugins/index.d.ts +23 -0
  55. package/node_modules/@dcode/contracts/dist/plugins/index.js +2 -1
  56. package/node_modules/@dcode/contracts/dist/telemetry/agent-execution.d.ts +2 -0
  57. package/node_modules/@dcode/contracts/dist/telemetry/agent-execution.js +2 -0
  58. package/node_modules/@dcode/contracts/dist/telemetry/index.d.ts +5 -1
  59. package/node_modules/@dcode/contracts/dist/telemetry/index.js +12 -0
  60. package/node_modules/@dcode/contracts/dist/tools/agent.d.ts +12 -12
  61. package/node_modules/@dcode/contracts/dist/tools/amend-workflow.d.ts +39 -15
  62. package/node_modules/@dcode/contracts/dist/tools/amend-workflow.js +12 -6
  63. package/node_modules/@dcode/contracts/dist/tools/automation.d.ts +32 -32
  64. package/node_modules/@dcode/contracts/dist/tools/automation.js +1 -1
  65. package/node_modules/@dcode/contracts/dist/tools/bash.d.ts +16 -16
  66. package/node_modules/@dcode/contracts/dist/tools/bash.js +1 -1
  67. package/node_modules/@dcode/contracts/dist/tools/create-workflow.d.ts +365 -66
  68. package/node_modules/@dcode/contracts/dist/tools/create-workflow.js +92 -11
  69. package/node_modules/@dcode/contracts/dist/tools/edit.d.ts +16 -16
  70. package/node_modules/@dcode/contracts/dist/tools/eval-workflow-snippet.d.ts +6 -6
  71. package/node_modules/@dcode/contracts/dist/tools/eval-workflow-snippet.js +5 -1
  72. package/node_modules/@dcode/contracts/dist/tools/fill-workflow-hole.d.ts +729 -0
  73. package/node_modules/@dcode/contracts/dist/tools/fill-workflow-hole.js +102 -0
  74. package/node_modules/@dcode/contracts/dist/tools/get-workflow-run.d.ts +136 -28
  75. package/node_modules/@dcode/contracts/dist/tools/get-workflow-run.js +36 -0
  76. package/node_modules/@dcode/contracts/dist/tools/grep.d.ts +4 -4
  77. package/node_modules/@dcode/contracts/dist/tools/grep.js +4 -0
  78. package/node_modules/@dcode/contracts/dist/tools/index.d.ts +2 -0
  79. package/node_modules/@dcode/contracts/dist/tools/index.js +4 -0
  80. package/node_modules/@dcode/contracts/dist/tools/list-saved-workflows.d.ts +8 -8
  81. package/node_modules/@dcode/contracts/dist/tools/list-workflow-runs.d.ts +8 -8
  82. package/node_modules/@dcode/contracts/dist/tools/node-repl.d.ts +2 -2
  83. package/node_modules/@dcode/contracts/dist/tools/off-peak.d.ts +3 -3
  84. package/node_modules/@dcode/contracts/dist/tools/off-peak.js +2 -2
  85. package/node_modules/@dcode/contracts/dist/tools/performance.d.ts +22 -22
  86. package/node_modules/@dcode/contracts/dist/tools/plan-mode.d.ts +12 -12
  87. package/node_modules/@dcode/contracts/dist/tools/plan-mode.js +6 -4
  88. package/node_modules/@dcode/contracts/dist/tools/read-session-context.d.ts +86 -13
  89. package/node_modules/@dcode/contracts/dist/tools/read-session-context.js +37 -6
  90. package/node_modules/@dcode/contracts/dist/tools/read.d.ts +38 -38
  91. package/node_modules/@dcode/contracts/dist/tools/save-workflow.d.ts +21 -10
  92. package/node_modules/@dcode/contracts/dist/tools/save-workflow.js +22 -2
  93. package/node_modules/@dcode/contracts/dist/tools/saved-workflow.d.ts +4 -4
  94. package/node_modules/@dcode/contracts/dist/tools/send-message.d.ts +2 -2
  95. package/node_modules/@dcode/contracts/dist/tools/skill.js +1 -0
  96. package/node_modules/@dcode/contracts/dist/tools/task-output.d.ts +6 -6
  97. package/node_modules/@dcode/contracts/dist/tools/tool-result-metadata.d.ts +1228 -259
  98. package/node_modules/@dcode/contracts/dist/tools/tool-result-metadata.js +41 -0
  99. package/node_modules/@dcode/contracts/dist/tools/webfetch.d.ts +2 -2
  100. package/node_modules/@dcode/contracts/dist/tools/workflow-observation-display.d.ts +20 -20
  101. package/node_modules/@dcode/contracts/dist/tools/workflow-settings.d.ts +55 -0
  102. package/node_modules/@dcode/contracts/dist/tools/workflow-settings.js +86 -0
  103. package/node_modules/@dcode/contracts/dist/tools/workflow.d.ts +8 -8
  104. package/node_modules/@dcode/contracts/dist/tools/write.d.ts +18 -18
  105. package/node_modules/@dcode/contracts/dist/workflow/index.d.ts +98 -98
  106. package/node_modules/@dcode/contracts/dist/workflow/script.d.ts +12 -12
  107. package/node_modules/@dcode/i18n/dist/index.js +2 -2
  108. package/node_modules/@dcode/i18n/dist/locale.d.ts +1 -1
  109. package/node_modules/@dcode/i18n/dist/locale.js +4 -4
  110. package/node_modules/@dcode/i18n/dist/locales/en-US.js +5 -5
  111. package/node_modules/@dcode/i18n/dist/locales/fr-CA.d.ts +3 -0
  112. package/node_modules/@dcode/i18n/dist/locales/fr-CA.js +354 -0
  113. package/node_modules/@dcode/model-option-map/package.json +1 -1
  114. package/node_modules/@dcode/shared/dist/api-key-usage-scene.d.ts +7 -0
  115. package/node_modules/@dcode/shared/dist/api-key-usage-scene.js +6 -0
  116. package/node_modules/@dcode/shared/dist/attachment-source.d.ts +8 -0
  117. package/node_modules/@dcode/shared/dist/attachment-source.js +4 -0
  118. package/node_modules/@dcode/shared/dist/background-bash-output.d.ts +4 -4
  119. package/node_modules/@dcode/shared/dist/bots.d.ts +763 -15
  120. package/node_modules/@dcode/shared/dist/bots.js +236 -2
  121. package/node_modules/@dcode/shared/dist/browser-use/command-metadata.d.ts +2 -2
  122. package/node_modules/@dcode/shared/dist/browser-use/commands.d.ts +4 -3
  123. package/node_modules/@dcode/shared/dist/browser-use/commands.js +3 -1
  124. package/node_modules/@dcode/shared/dist/browser-use/nodeReplBroker.d.ts +5 -4
  125. package/node_modules/@dcode/shared/dist/browser-use/result.d.ts +6 -6
  126. package/node_modules/@dcode/shared/dist/channel-mention.d.ts +173 -0
  127. package/node_modules/@dcode/shared/dist/channel-mention.js +120 -0
  128. package/node_modules/@dcode/shared/dist/channels.d.ts +128 -1
  129. package/node_modules/@dcode/shared/dist/channels.js +66 -0
  130. package/node_modules/@dcode/shared/dist/clientConfig.d.ts +1 -0
  131. package/node_modules/@dcode/shared/dist/clientConfig.js +18 -2
  132. package/node_modules/@dcode/shared/dist/cloudContent.d.ts +160 -0
  133. package/node_modules/@dcode/shared/dist/cloudContent.js +116 -0
  134. package/node_modules/@dcode/shared/dist/coding-plan-subscription.d.ts +59 -0
  135. package/node_modules/@dcode/shared/dist/conversation-message-projection-policy.js +2 -0
  136. package/node_modules/@dcode/shared/dist/conversation-share.d.ts +351 -47
  137. package/node_modules/@dcode/shared/dist/conversation-share.js +8 -6
  138. package/node_modules/@dcode/shared/dist/conversationSelection.d.ts +23 -0
  139. package/node_modules/@dcode/shared/dist/conversationSelection.js +30 -0
  140. package/node_modules/@dcode/shared/dist/database-startup.d.ts +5 -5
  141. package/node_modules/@dcode/shared/dist/dcode-agent-model-state.js +14 -6
  142. package/node_modules/@dcode/shared/dist/dcode-agent-policy.d.ts +16 -1
  143. package/node_modules/@dcode/shared/dist/dcode-agent-policy.js +17 -1
  144. package/node_modules/@dcode/shared/dist/dcode-agent-runtime.js +1 -1
  145. package/node_modules/@dcode/shared/dist/dcode-protocol/index.d.ts +1733 -318
  146. package/node_modules/@dcode/shared/dist/dcode-protocol/index.js +555 -24
  147. package/node_modules/@dcode/shared/dist/dcode-protocol/trace.d.ts +9 -0
  148. package/node_modules/@dcode/shared/dist/dcode-protocol/trace.js +10 -0
  149. package/node_modules/@dcode/shared/dist/dcode-protocol-legacy-types.d.ts +30 -20
  150. package/node_modules/@dcode/shared/dist/dcode-protocol-legacy-types.js +3 -1
  151. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/apply.js +12 -3
  152. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/attachment-ref.d.ts +5 -0
  153. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/attachment-ref.js +3 -0
  154. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/coalesce.d.ts +3 -1
  155. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/coalesce.js +3 -1
  156. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/command.d.ts +359 -28
  157. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/command.js +67 -45
  158. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/controller.d.ts +170 -65
  159. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-session-config.d.ts +20 -0
  160. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-session-config.js +15 -0
  161. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-workflow-display.d.ts +34 -0
  162. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-workflow-display.js +45 -1
  163. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/delta.d.ts +1453 -278
  164. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/delta.js +45 -2
  165. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/index.d.ts +1 -0
  166. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/index.js +1 -0
  167. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/input-intent.d.ts +173 -6
  168. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/input-intent.js +29 -0
  169. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/rows.d.ts +731 -125
  170. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/rows.js +23 -11
  171. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index-workflow-activity.d.ts +30 -11
  172. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index-workflow-activity.js +35 -3
  173. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index.d.ts +40 -25
  174. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/snapshot.d.ts +1444 -216
  175. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/snapshot.js +3 -0
  176. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/submission.d.ts +1 -0
  177. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/submission.js +1 -1
  178. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/telemetry.d.ts +62 -58
  179. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/toolDisplay.d.ts +185 -50
  180. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/toolDisplay.js +31 -3
  181. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/transport.d.ts +7145 -1002
  182. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/transport.js +18 -5
  183. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-assembler.js +2 -1
  184. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-fault.js +4 -1
  185. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-reassembly.js +5 -3
  186. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-artifacts.d.ts +29 -1
  187. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-artifacts.js +64 -4
  188. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-command-rejections.d.ts +13 -0
  189. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-command-rejections.js +23 -0
  190. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-observation-display.d.ts +14 -14
  191. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-row-meta.d.ts +52 -8
  192. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-row-meta.js +22 -3
  193. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-run-settings-command.d.ts +4 -4
  194. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-run-settings-command.js +2 -2
  195. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-session.d.ts +21 -0
  196. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-session.js +44 -0
  197. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-status.d.ts +1 -1
  198. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-status.js +3 -2
  199. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-caps.js +5 -4
  200. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-concurrency.d.ts +26 -19
  201. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-concurrency.js +40 -32
  202. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-delta.d.ts +4 -3
  203. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-delta.js +4 -3
  204. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-entries.d.ts +12 -2
  205. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-entries.js +44 -6
  206. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-eviction.d.ts +2 -2
  207. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-eviction.js +17 -10
  208. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-holes.d.ts +33 -0
  209. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-holes.js +202 -0
  210. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-legacy.d.ts +1 -1
  211. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-legacy.js +1 -1
  212. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-phases.js +10 -1
  213. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-reducer.d.ts +1 -1
  214. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-reducer.js +29 -22
  215. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-started.js +5 -2
  216. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-tables.js +2 -1
  217. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-unlisted.js +6 -3
  218. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs.d.ts +125 -40
  219. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs.js +101 -26
  220. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-workspace.d.ts +4 -4
  221. package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workspace-hook-review.d.ts +1 -1
  222. package/node_modules/@dcode/shared/dist/dcode-session-content-profile.d.ts +5 -0
  223. package/node_modules/@dcode/shared/dist/dcode-session-content-profile.js +49 -0
  224. package/node_modules/@dcode/shared/dist/dcode-slash-command-help.js +4 -4
  225. package/node_modules/@dcode/shared/dist/dcode-task-mode-schema.d.ts +6 -1
  226. package/node_modules/@dcode/shared/dist/dcode-task-mode-schema.js +13 -1
  227. package/node_modules/@dcode/shared/dist/dcode-task-types-core.d.ts +12 -2
  228. package/node_modules/@dcode/shared/dist/dcode-task-types.d.ts +23 -0
  229. package/node_modules/@dcode/shared/dist/dcodeEndpoint.d.ts +20 -1
  230. package/node_modules/@dcode/shared/dist/dcodeEndpoint.js +98 -17
  231. package/node_modules/@dcode/shared/dist/desktopMenu.js +48 -48
  232. package/node_modules/@dcode/shared/dist/dynamic-workflow-feature.d.ts +35 -6
  233. package/node_modules/@dcode/shared/dist/dynamic-workflow-feature.js +45 -6
  234. package/node_modules/@dcode/shared/dist/env.d.ts +5 -4
  235. package/node_modules/@dcode/shared/dist/env.js +9 -9
  236. package/node_modules/@dcode/shared/dist/errors.d.ts +24 -0
  237. package/node_modules/@dcode/shared/dist/errors.js +54 -0
  238. package/node_modules/@dcode/shared/dist/execution-state.d.ts +4 -2
  239. package/node_modules/@dcode/shared/dist/execution-state.js +1 -1
  240. package/node_modules/@dcode/shared/dist/feedback.d.ts +1 -1
  241. package/node_modules/@dcode/shared/dist/gen-ui/contract.d.ts +140 -0
  242. package/node_modules/@dcode/shared/dist/gen-ui/contract.example.d.ts +5 -0
  243. package/node_modules/@dcode/shared/dist/gen-ui/contract.example.js +36 -0
  244. package/node_modules/@dcode/shared/dist/gen-ui/contract.js +196 -0
  245. package/node_modules/@dcode/shared/dist/gen-ui/contract.test.d.ts +2 -0
  246. package/node_modules/@dcode/shared/dist/gen-ui/contract.test.js +75 -0
  247. package/node_modules/@dcode/shared/dist/gen-ui/index.d.ts +2 -0
  248. package/node_modules/@dcode/shared/dist/gen-ui/index.js +2 -0
  249. package/node_modules/@dcode/shared/dist/gen-ui/module.d.ts +7 -0
  250. package/node_modules/@dcode/shared/dist/gen-ui/module.js +7 -0
  251. package/node_modules/@dcode/shared/dist/gen-ui/tweakProtocol.d.ts +202 -0
  252. package/node_modules/@dcode/shared/dist/gen-ui/tweakProtocol.js +126 -0
  253. package/node_modules/@dcode/shared/dist/helpAppConfig.d.ts +1 -1
  254. package/node_modules/@dcode/shared/dist/helpAppConfig.js +2 -2
  255. package/node_modules/@dcode/shared/dist/highspeed.d.ts +181 -0
  256. package/node_modules/@dcode/shared/dist/highspeed.js +112 -0
  257. package/node_modules/@dcode/shared/dist/index.d.ts +27 -5
  258. package/node_modules/@dcode/shared/dist/index.js +24 -2
  259. package/node_modules/@dcode/shared/dist/localTtft.d.ts +27 -27
  260. package/node_modules/@dcode/shared/dist/marketingTouch.d.ts +930 -0
  261. package/node_modules/@dcode/shared/dist/marketingTouch.js +170 -0
  262. package/node_modules/@dcode/shared/dist/mcp-apps/appTools.d.ts +83 -0
  263. package/node_modules/@dcode/shared/dist/mcp-apps/appTools.js +124 -0
  264. package/node_modules/@dcode/shared/dist/mcp-apps/content.d.ts +4 -0
  265. package/node_modules/@dcode/shared/dist/mcp-apps/content.js +8 -0
  266. package/node_modules/@dcode/shared/dist/mcp-apps/contract.d.ts +241 -0
  267. package/node_modules/@dcode/shared/dist/mcp-apps/contract.example.d.ts +31 -0
  268. package/node_modules/@dcode/shared/dist/mcp-apps/contract.example.js +42 -0
  269. package/node_modules/@dcode/shared/dist/mcp-apps/contract.js +101 -0
  270. package/node_modules/@dcode/shared/dist/mcp-apps/contract.test.d.ts +2 -0
  271. package/node_modules/@dcode/shared/dist/mcp-apps/contract.test.js +64 -0
  272. package/node_modules/@dcode/shared/dist/mcp-apps/hostContract.d.ts +47 -0
  273. package/node_modules/@dcode/shared/dist/mcp-apps/hostContract.js +8 -0
  274. package/node_modules/@dcode/shared/dist/mcp-apps/index.d.ts +9 -0
  275. package/node_modules/@dcode/shared/dist/mcp-apps/index.js +9 -0
  276. package/node_modules/@dcode/shared/dist/mcp-apps/instance.d.ts +10 -0
  277. package/node_modules/@dcode/shared/dist/mcp-apps/instance.js +11 -0
  278. package/node_modules/@dcode/shared/dist/mcp-apps/module.d.ts +12 -0
  279. package/node_modules/@dcode/shared/dist/mcp-apps/module.js +12 -0
  280. package/node_modules/@dcode/shared/dist/mcp-apps/resourceMime.d.ts +8 -0
  281. package/node_modules/@dcode/shared/dist/mcp-apps/resourceMime.js +73 -0
  282. package/node_modules/@dcode/shared/dist/mcp-apps/sampling.d.ts +101 -0
  283. package/node_modules/@dcode/shared/dist/mcp-apps/sampling.js +107 -0
  284. package/node_modules/@dcode/shared/dist/mcp-apps/sampling.test.d.ts +2 -0
  285. package/node_modules/@dcode/shared/dist/mcp-apps/sampling.test.js +55 -0
  286. package/node_modules/@dcode/shared/dist/mcp-apps/schemas.d.ts +78 -0
  287. package/node_modules/@dcode/shared/dist/mcp-apps/schemas.js +65 -0
  288. package/node_modules/@dcode/shared/dist/mcp-apps/toolMeta.d.ts +39 -0
  289. package/node_modules/@dcode/shared/dist/mcp-apps/toolMeta.js +199 -0
  290. package/node_modules/@dcode/shared/dist/mcp.d.ts +6 -2
  291. package/node_modules/@dcode/shared/dist/memory.d.ts +9 -0
  292. package/node_modules/@dcode/shared/dist/memory.js +2 -0
  293. package/node_modules/@dcode/shared/dist/model-execution.d.ts +31 -0
  294. package/node_modules/@dcode/shared/dist/model-execution.js +38 -0
  295. package/node_modules/@dcode/shared/dist/networkCapture.d.ts +49 -0
  296. package/node_modules/@dcode/shared/dist/networkCapture.js +41 -0
  297. package/node_modules/@dcode/shared/dist/node/genUiPaths.d.ts +6 -0
  298. package/node_modules/@dcode/shared/dist/node/genUiPaths.js +16 -0
  299. package/node_modules/@dcode/shared/dist/node/genUiPaths.test.d.ts +2 -0
  300. package/node_modules/@dcode/shared/dist/node/genUiPaths.test.js +30 -0
  301. package/node_modules/@dcode/shared/dist/node/networkCapture.d.ts +8 -0
  302. package/node_modules/@dcode/shared/dist/node/networkCapture.js +96 -0
  303. package/node_modules/@dcode/shared/dist/node/officialPluginCache.d.ts +1 -2
  304. package/node_modules/@dcode/shared/dist/node/subagentMarkdownMigration.d.ts +1 -2
  305. package/node_modules/@dcode/shared/dist/node.d.ts +2 -0
  306. package/node_modules/@dcode/shared/dist/node.js +2 -0
  307. package/node_modules/@dcode/shared/dist/output-style.d.ts +17 -0
  308. package/node_modules/@dcode/shared/dist/output-style.js +2 -0
  309. package/node_modules/@dcode/shared/dist/platform.d.ts +149 -1
  310. package/node_modules/@dcode/shared/dist/platform.js +2 -0
  311. package/node_modules/@dcode/shared/dist/platformUpdate.d.ts +61 -0
  312. package/node_modules/@dcode/shared/dist/platformUpdate.js +2 -0
  313. package/node_modules/@dcode/shared/dist/plugin-marketplaces.d.ts +5 -0
  314. package/node_modules/@dcode/shared/dist/plugin-marketplaces.js +20 -14
  315. package/node_modules/@dcode/shared/dist/project-access-token-client.d.ts +42 -0
  316. package/node_modules/@dcode/shared/dist/project-access-token-client.js +260 -0
  317. package/node_modules/@dcode/shared/dist/project-access-token-response.d.ts +4 -0
  318. package/node_modules/@dcode/shared/dist/project-access-token-response.js +9 -0
  319. package/node_modules/@dcode/shared/dist/project-access-token.d.ts +45 -0
  320. package/node_modules/@dcode/shared/dist/project-access-token.js +164 -0
  321. package/node_modules/@dcode/shared/dist/protocol.d.ts +41 -4
  322. package/node_modules/@dcode/shared/dist/protocol.js +1 -1
  323. package/node_modules/@dcode/shared/dist/provider-provisioning.d.ts +26 -2
  324. package/node_modules/@dcode/shared/dist/provider-provisioning.js +19 -3
  325. package/node_modules/@dcode/shared/dist/providers.d.ts +1 -2
  326. package/node_modules/@dcode/shared/dist/providers.js +1 -1
  327. package/node_modules/@dcode/shared/dist/remote-workspace-identity.d.ts +6 -1
  328. package/node_modules/@dcode/shared/dist/remote-workspace-identity.js +35 -1
  329. package/node_modules/@dcode/shared/dist/remoteAppConfig.js +1 -1
  330. package/node_modules/@dcode/shared/dist/remoteEnvironmentKey.js +19 -0
  331. package/node_modules/@dcode/shared/dist/remoteTarget.d.ts +14 -1
  332. package/node_modules/@dcode/shared/dist/remoteTarget.js +4 -0
  333. package/node_modules/@dcode/shared/dist/remoteUsageTelemetry.d.ts +27 -0
  334. package/node_modules/@dcode/shared/dist/remoteUsageTelemetry.js +43 -0
  335. package/node_modules/@dcode/shared/dist/rendererActionTrace.d.ts +35 -35
  336. package/node_modules/@dcode/shared/dist/request-security-edition/index.d.ts +3 -0
  337. package/node_modules/@dcode/shared/dist/request-security-edition/index.js +3 -0
  338. package/node_modules/@dcode/shared/dist/request-security-edition/policy.d.ts +3 -0
  339. package/node_modules/@dcode/shared/dist/request-security-edition/policy.js +5 -0
  340. package/node_modules/@dcode/shared/dist/request-security-edition/verification-policy.d.ts +19 -0
  341. package/node_modules/@dcode/shared/dist/request-security-edition/verification-policy.js +29 -0
  342. package/node_modules/@dcode/shared/dist/rewardsBridge.d.ts +8 -0
  343. package/node_modules/@dcode/shared/dist/rewardsBridge.js +80 -0
  344. package/node_modules/@dcode/shared/dist/rewardsEmbedded.d.ts +37 -0
  345. package/node_modules/@dcode/shared/dist/rewardsEmbedded.js +50 -0
  346. package/node_modules/@dcode/shared/dist/sessionCreateTelemetry.d.ts +3 -3
  347. package/node_modules/@dcode/shared/dist/subagent-profile-frontmatter.d.ts +10 -0
  348. package/node_modules/@dcode/shared/dist/subagent-profile-frontmatter.js +212 -0
  349. package/node_modules/@dcode/shared/dist/subagent-profile-parser.d.ts +10 -0
  350. package/node_modules/@dcode/shared/dist/subagent-profile-parser.js +200 -0
  351. package/node_modules/@dcode/shared/dist/subagent-profile.d.ts +82 -0
  352. package/node_modules/@dcode/shared/dist/subagent-profile.js +28 -0
  353. package/node_modules/@dcode/shared/dist/subagent-runtime-config.d.ts +135 -0
  354. package/node_modules/@dcode/shared/dist/subagent-runtime-config.js +39 -0
  355. package/node_modules/@dcode/shared/dist/subagents-types.d.ts +1 -1
  356. package/node_modules/@dcode/shared/dist/task-realtime-core.d.ts +57 -24
  357. package/node_modules/@dcode/shared/dist/task-realtime-core.js +8 -2
  358. package/node_modules/@dcode/shared/dist/test-ids-workflow.d.ts +4 -0
  359. package/node_modules/@dcode/shared/dist/test-ids-workflow.js +5 -0
  360. package/node_modules/@dcode/shared/dist/test-ids.d.ts +25 -0
  361. package/node_modules/@dcode/shared/dist/test-ids.js +25 -0
  362. package/node_modules/@dcode/shared/dist/tool-identity.d.ts +1 -1
  363. package/node_modules/@dcode/shared/dist/tool-identity.js +4 -0
  364. package/node_modules/@dcode/shared/dist/tool-plan-adapter.js +14 -1
  365. package/node_modules/@dcode/shared/dist/usage-stats.d.ts +13 -0
  366. package/node_modules/@dcode/shared/dist/validation.d.ts +1461 -85
  367. package/node_modules/@dcode/shared/dist/validation.js +423 -14
  368. package/node_modules/@dcode/shared/dist/validationAppSettings.d.ts +71 -15
  369. package/node_modules/@dcode/shared/dist/validationAppSettings.js +74 -12
  370. package/node_modules/@dcode/shared/dist/web-remote-control-heartbeat.d.ts +8 -0
  371. package/node_modules/@dcode/shared/dist/web-remote-control-heartbeat.js +40 -0
  372. package/node_modules/@dcode/shared/dist/web-remote-control-rpc-transport.d.ts +183 -0
  373. package/node_modules/@dcode/shared/dist/web-remote-control-rpc-transport.js +562 -0
  374. package/node_modules/@dcode/shared/dist/web-remote-control.d.ts +645 -0
  375. package/node_modules/@dcode/shared/dist/web-remote-control.js +174 -0
  376. package/node_modules/@dcode/shared/package.json +5 -2
  377. package/node_modules/@dcode/tui/dist/app-approval-panel.js +3 -2
  378. package/node_modules/@dcode/tui/dist/app-approval.d.ts +3 -1
  379. package/node_modules/@dcode/tui/dist/app-approval.js +9 -5
  380. package/node_modules/@dcode/tui/dist/app-compact-timeline.d.ts +3 -0
  381. package/node_modules/@dcode/tui/dist/app-compact-timeline.js +5 -2
  382. package/node_modules/@dcode/tui/dist/app-empty-transcript.d.ts +1 -0
  383. package/node_modules/@dcode/tui/dist/app-empty-transcript.js +1 -1
  384. package/node_modules/@dcode/tui/dist/app-file-mentions.d.ts +2 -0
  385. package/node_modules/@dcode/tui/dist/app-file-mentions.js +2 -2
  386. package/node_modules/@dcode/tui/dist/app-input-pane.d.ts +38 -0
  387. package/node_modules/@dcode/tui/dist/app-input-pane.js +19 -19
  388. package/node_modules/@dcode/tui/dist/app-input-status.d.ts +17 -0
  389. package/node_modules/@dcode/tui/dist/app-input-status.js +4 -4
  390. package/node_modules/@dcode/tui/dist/app-input.d.ts +1 -0
  391. package/node_modules/@dcode/tui/dist/app-input.js +1 -1
  392. package/node_modules/@dcode/tui/dist/app-markdown-theme.d.ts +2 -1
  393. package/node_modules/@dcode/tui/dist/app-markdown-theme.js +1 -1
  394. package/node_modules/@dcode/tui/dist/app-markdown.d.ts +1 -0
  395. package/node_modules/@dcode/tui/dist/app-markdown.js +1 -1
  396. package/node_modules/@dcode/tui/dist/app-mode-command.d.ts +3 -0
  397. package/node_modules/@dcode/tui/dist/app-mode-command.js +4 -4
  398. package/node_modules/@dcode/tui/dist/app-mode-suggestion-panel.d.ts +5 -0
  399. package/node_modules/@dcode/tui/dist/app-mode-suggestion-panel.js +1 -1
  400. package/node_modules/@dcode/tui/dist/app-mode.d.ts +1 -1
  401. package/node_modules/@dcode/tui/dist/app-mode.js +1 -1
  402. package/node_modules/@dcode/tui/dist/app-model-ref.d.ts +1 -0
  403. package/node_modules/@dcode/tui/dist/app-model-ref.js +1 -1
  404. package/node_modules/@dcode/tui/dist/app-motion.d.ts +13 -0
  405. package/node_modules/@dcode/tui/dist/app-motion.js +17 -7
  406. package/node_modules/@dcode/tui/dist/app-session-event-handler.d.ts +33 -0
  407. package/node_modules/@dcode/tui/dist/app-session-event-handler.js +4 -4
  408. package/node_modules/@dcode/tui/dist/app-shiki-diff-view.d.ts +18 -1
  409. package/node_modules/@dcode/tui/dist/app-shiki-diff-view.js +3 -3
  410. package/node_modules/@dcode/tui/dist/app-shiki-highlighter.d.ts +3 -0
  411. package/node_modules/@dcode/tui/dist/app-shiki-highlighter.js +7 -2
  412. package/node_modules/@dcode/tui/dist/app-sidebar-layout.d.ts +10 -0
  413. package/node_modules/@dcode/tui/dist/app-sidebar-layout.js +4 -4
  414. package/node_modules/@dcode/tui/dist/app-submit.d.ts +1 -0
  415. package/node_modules/@dcode/tui/dist/app-submit.js +1 -1
  416. package/node_modules/@dcode/tui/dist/app-thought-components.d.ts +7 -0
  417. package/node_modules/@dcode/tui/dist/app-thought-components.js +2 -2
  418. package/node_modules/@dcode/tui/dist/app-tool-transcript.d.ts +1 -0
  419. package/node_modules/@dcode/tui/dist/app-tool-transcript.js +3 -0
  420. package/node_modules/@dcode/tui/dist/app-view.d.ts +27 -0
  421. package/node_modules/@dcode/tui/dist/app-view.js +1 -1
  422. package/node_modules/@dcode/tui/dist/app-workflow-card.js +1 -1
  423. package/node_modules/@dcode/tui/dist/app-workflow-seed.d.ts +18 -1
  424. package/node_modules/@dcode/tui/dist/app-workflow-seed.js +4 -4
  425. package/node_modules/@dcode/tui/dist/index.js +5118 -2579
  426. package/node_modules/@dcode/tui/dist/tui.d.ts +3 -0
  427. package/node_modules/@dcode/tui/dist/tui.js +1 -1
  428. package/node_modules/@dcode/tui/dist/types.d.ts +1 -1
  429. package/node_modules/oniguruma-parser/LICENSE +1 -1
  430. package/node_modules/oniguruma-parser/README.md +15 -61
  431. package/node_modules/oniguruma-parser/dist/oniguruma-parser.min.js +4 -4
  432. package/node_modules/oniguruma-parser/dist/parser/parse.js +1 -1
  433. package/node_modules/oniguruma-parser/dist/traverser/traverse.js +1 -1
  434. package/node_modules/oniguruma-parser/package.json +5 -5
  435. package/node_modules/oniguruma-to-es/dist/cjs/generate.d.ts +1 -1
  436. package/node_modules/oniguruma-to-es/dist/cjs/index.js +121 -120
  437. package/node_modules/oniguruma-to-es/dist/cjs/subclass.d.ts +2 -2
  438. package/node_modules/oniguruma-to-es/dist/cjs/transform.d.ts +3 -5
  439. package/node_modules/oniguruma-to-es/dist/cjs/unicode.d.ts +1 -1
  440. package/node_modules/oniguruma-to-es/dist/esm/generate.d.ts +1 -1
  441. package/node_modules/oniguruma-to-es/dist/esm/index.js +1 -3
  442. package/node_modules/oniguruma-to-es/dist/esm/subclass.d.ts +2 -2
  443. package/node_modules/oniguruma-to-es/dist/esm/transform.d.ts +3 -5
  444. package/node_modules/oniguruma-to-es/dist/esm/unicode.d.ts +1 -1
  445. package/node_modules/oniguruma-to-es/dist/index.min.js +6 -6
  446. package/node_modules/oniguruma-to-es/package.json +5 -5
  447. package/package.json +5 -5
@@ -0,0 +1,562 @@
1
+ /* eslint-disable max-lines -- raw RPC 的 schema、精确计量、编码与单 assembly 状态机共享同一组物理不变量。 */
2
+ import { z } from "zod";
3
+ import { PROTOCOL_V4_LIMITS } from "./dcode-protocol-v4/core.js";
4
+ import { crc32WireBytes, decodeWireBase64, encodeWireBytesBase64, } from "./dcode-protocol-v4/wire-binary.js";
5
+ export const WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS = {
6
+ maxPhysicalFrameBytes: PROTOCOL_V4_LIMITS.maxFrameBytes,
7
+ maxMessageBytes: 16 * 1024 * 1024,
8
+ maxFragments: 64,
9
+ assemblyTimeoutMs: 30_000,
10
+ transportIdMaxChars: PROTOCOL_V4_LIMITS.transportEnvelopeIdMaxChars,
11
+ };
12
+ const positiveSafeIntegerSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
13
+ const nonnegativeSafeIntegerSchema = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
14
+ export const webRemoteControlRpcTransportIdSchema = z
15
+ .string()
16
+ .min(1)
17
+ .max(WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.transportIdMaxChars)
18
+ .regex(/^[A-Za-z0-9._~-]+$/u);
19
+ export const webRemoteControlRpcTransportIdentitySchema = z
20
+ .object({
21
+ bridgeSessionId: webRemoteControlRpcTransportIdSchema,
22
+ bridgeGeneration: nonnegativeSafeIntegerSchema.optional(),
23
+ recoveryId: webRemoteControlRpcTransportIdSchema.optional(),
24
+ })
25
+ .strict();
26
+ export const webRemoteControlRpcTransportChecksumSchema = z
27
+ .object({
28
+ algorithm: z.literal("crc32"),
29
+ value: z.string().regex(/^[0-9a-f]{8}$/u),
30
+ })
31
+ .strict();
32
+ function isCanonicalBase64(value) {
33
+ // Zod 的后续 refine 不保证在 max issue 后短路;先按 raw string 做硬闸,避免先分配 decoded buffer。
34
+ if (value.length < 4 ||
35
+ value.length > WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxPhysicalFrameBytes) {
36
+ return false;
37
+ }
38
+ const decoded = decodeWireBase64(value);
39
+ return decoded !== null && decoded.byteLength > 0 && encodeWireBytesBase64(decoded) === value;
40
+ }
41
+ export const webRemoteControlRpcTransportFrameSchema = z
42
+ .object({
43
+ dcode_type: z.literal("rpc-frame"),
44
+ bridgeSessionId: webRemoteControlRpcTransportIdSchema,
45
+ bridgeGeneration: nonnegativeSafeIntegerSchema.optional(),
46
+ recoveryId: webRemoteControlRpcTransportIdSchema.optional(),
47
+ seq: positiveSafeIntegerSchema,
48
+ messageSeq: positiveSafeIntegerSchema,
49
+ fragmentIndex: z
50
+ .number()
51
+ .int()
52
+ .nonnegative()
53
+ .max(WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxFragments - 1),
54
+ fragmentCount: z
55
+ .number()
56
+ .int()
57
+ .positive()
58
+ .max(WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxFragments),
59
+ messageBytes: z
60
+ .number()
61
+ .int()
62
+ .positive()
63
+ .max(WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxMessageBytes),
64
+ checksum: webRemoteControlRpcTransportChecksumSchema,
65
+ // 先做字符串长度硬闸,再进入 decode/refine,避免恶意超长 base64 先分配 decoded buffer。
66
+ dataBase64: z
67
+ .string()
68
+ .min(4)
69
+ .max(WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxPhysicalFrameBytes)
70
+ .refine(isCanonicalBase64),
71
+ })
72
+ .strict()
73
+ .superRefine((value, context) => {
74
+ if (value.fragmentIndex >= value.fragmentCount) {
75
+ context.addIssue({
76
+ code: "custom",
77
+ path: ["fragmentIndex"],
78
+ message: "fragmentIndex must be smaller than fragmentCount",
79
+ });
80
+ }
81
+ if (value.fragmentCount > value.messageBytes) {
82
+ context.addIssue({
83
+ code: "custom",
84
+ path: ["fragmentCount"],
85
+ message: "non-empty fragments cannot exceed message bytes",
86
+ });
87
+ }
88
+ });
89
+ export const webRemoteControlRpcTransportAckSchema = z
90
+ .object({
91
+ dcode_type: z.literal("rpc-frame-ack"),
92
+ bridgeSessionId: webRemoteControlRpcTransportIdSchema,
93
+ bridgeGeneration: nonnegativeSafeIntegerSchema.optional(),
94
+ recoveryId: webRemoteControlRpcTransportIdSchema.optional(),
95
+ ackMessageSeq: positiveSafeIntegerSchema,
96
+ })
97
+ .strict();
98
+ export const webRemoteControlRpcTransportPayloadSchema = z.union([
99
+ webRemoteControlRpcTransportFrameSchema,
100
+ webRemoteControlRpcTransportAckSchema,
101
+ ]);
102
+ export const webRemoteControlRpcRelayEnvelopeSchema = z
103
+ .object({
104
+ type: z.literal("data"),
105
+ payload: webRemoteControlRpcTransportPayloadSchema,
106
+ client_ts: nonnegativeSafeIntegerSchema.optional(),
107
+ server_ts: nonnegativeSafeIntegerSchema.optional(),
108
+ })
109
+ .strict();
110
+ function utf8Bytes(value) {
111
+ return new TextEncoder().encode(value).byteLength;
112
+ }
113
+ function relayEnvelopeFor(payload, timestamps = {}) {
114
+ const clientTimestamp = timestamps.clientTimestamp === undefined ? Number.MAX_SAFE_INTEGER : timestamps.clientTimestamp;
115
+ const serverTimestamp = timestamps.serverTimestamp === undefined ? Number.MAX_SAFE_INTEGER : timestamps.serverTimestamp;
116
+ return {
117
+ type: "data",
118
+ payload,
119
+ ...(clientTimestamp === null ? {} : { client_ts: clientTimestamp }),
120
+ ...(serverTimestamp === null ? {} : { server_ts: serverTimestamp }),
121
+ };
122
+ }
123
+ /** 最终 relay JSON(默认同时含最坏 client/server timestamp)的精确 UTF-8 byte 数。 */
124
+ export function measureWebRemoteControlRpcRelayEnvelopeBytes(payload, timestamps) {
125
+ return utf8Bytes(JSON.stringify(relayEnvelopeFor(payload, timestamps)));
126
+ }
127
+ function boundedPositive(value, maximum, reasonCode) {
128
+ const resolved = value ?? maximum;
129
+ if (!Number.isSafeInteger(resolved) || resolved <= 0) {
130
+ throw new WebRemoteControlRpcTransportEncodingError(reasonCode);
131
+ }
132
+ return Math.min(resolved, maximum);
133
+ }
134
+ export function parseWebRemoteControlRpcTransportPayload(value) {
135
+ const result = webRemoteControlRpcTransportPayloadSchema.safeParse(value);
136
+ return result.success ? result.data : null;
137
+ }
138
+ /** D3 接线时在 JSON.parse 前调用;本切片只提供 standalone primitive。 */
139
+ export function parseWebRemoteControlRpcRelayEnvelopeJson(rawJson, options = {}) {
140
+ let maxPhysicalFrameBytes;
141
+ try {
142
+ maxPhysicalFrameBytes = boundedPositive(options.maxPhysicalFrameBytes, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxPhysicalFrameBytes, "remote.rpcFrame.invalidPhysicalLimit");
143
+ }
144
+ catch (error) {
145
+ return {
146
+ kind: "fault",
147
+ fault: {
148
+ reasonCode: error instanceof WebRemoteControlRpcTransportEncodingError
149
+ ? error.reasonCode
150
+ : "remote.rpcFrame.invalidPhysicalLimit",
151
+ terminal: true,
152
+ },
153
+ };
154
+ }
155
+ const bytes = utf8Bytes(rawJson);
156
+ if (bytes > maxPhysicalFrameBytes) {
157
+ return {
158
+ kind: "fault",
159
+ fault: { reasonCode: "remote.rpcFrame.envelopeTooLarge", terminal: true },
160
+ };
161
+ }
162
+ let parsed;
163
+ try {
164
+ parsed = JSON.parse(rawJson);
165
+ }
166
+ catch {
167
+ return {
168
+ kind: "fault",
169
+ fault: { reasonCode: "remote.rpcFrame.invalidJson", terminal: true },
170
+ };
171
+ }
172
+ const envelope = webRemoteControlRpcRelayEnvelopeSchema.safeParse(parsed);
173
+ return envelope.success
174
+ ? { kind: "accepted", bytes, envelope: envelope.data }
175
+ : {
176
+ kind: "fault",
177
+ fault: { reasonCode: "remote.rpcFrame.invalidEnvelope", terminal: true },
178
+ };
179
+ }
180
+ export class WebRemoteControlRpcTransportEncodingError extends Error {
181
+ reasonCode;
182
+ constructor(reasonCode) {
183
+ super(reasonCode);
184
+ this.reasonCode = reasonCode;
185
+ this.name = "WebRemoteControlRpcTransportEncodingError";
186
+ }
187
+ }
188
+ function identityFrom(value) {
189
+ const parsed = webRemoteControlRpcTransportIdentitySchema.safeParse({
190
+ bridgeSessionId: value.bridgeSessionId,
191
+ ...(value.bridgeGeneration === undefined ? {} : { bridgeGeneration: value.bridgeGeneration }),
192
+ ...(value.recoveryId === undefined ? {} : { recoveryId: value.recoveryId }),
193
+ });
194
+ if (!parsed.success) {
195
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.invalidIdentity");
196
+ }
197
+ return parsed.data;
198
+ }
199
+ function assertPositiveSafe(value, reasonCode) {
200
+ if (!Number.isSafeInteger(value) || value <= 0) {
201
+ throw new WebRemoteControlRpcTransportEncodingError(reasonCode);
202
+ }
203
+ }
204
+ function base64Length(decodedBytes) {
205
+ return 4 * Math.ceil(decodedBytes / 3);
206
+ }
207
+ function frameShell(params) {
208
+ return {
209
+ dcode_type: "rpc-frame",
210
+ ...params.identity,
211
+ seq: params.seq,
212
+ messageSeq: params.messageSeq,
213
+ fragmentIndex: params.fragmentIndex,
214
+ fragmentCount: params.fragmentCount,
215
+ messageBytes: params.messageBytes,
216
+ checksum: params.checksum,
217
+ dataBase64: params.dataBase64,
218
+ };
219
+ }
220
+ function findDecodedBudget(params) {
221
+ const empty = frameShell({
222
+ identity: params.identity,
223
+ seq: params.endSeq,
224
+ messageSeq: params.messageSeq,
225
+ fragmentIndex: params.fragmentCount - 1,
226
+ fragmentCount: params.fragmentCount,
227
+ messageBytes: params.messageBytes,
228
+ checksum: params.checksum,
229
+ // 这里只用于精确固定 envelope 计量;真正 payload 仍须非空 canonical base64。
230
+ dataBase64: "",
231
+ });
232
+ const fixedBytes = measureWebRemoteControlRpcRelayEnvelopeBytes(empty);
233
+ let low = 0;
234
+ let high = params.messageBytes;
235
+ while (low < high) {
236
+ const middle = Math.ceil((low + high) / 2);
237
+ if (fixedBytes + base64Length(middle) <= params.maxPhysicalFrameBytes)
238
+ low = middle;
239
+ else
240
+ high = middle - 1;
241
+ }
242
+ return low;
243
+ }
244
+ /** raw Channel bytes -> immutable bounded physical payload batch。 */
245
+ export function encodeWebRemoteControlRpcTransportMessage(bytes, options) {
246
+ const identity = identityFrom(options);
247
+ assertPositiveSafe(options.firstPhysicalSeq, "remote.rpcFrame.invalidPhysicalSeq");
248
+ assertPositiveSafe(options.messageSeq, "remote.rpcFrame.invalidMessageSeq");
249
+ const maxPhysicalFrameBytes = boundedPositive(options.maxPhysicalFrameBytes, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxPhysicalFrameBytes, "remote.rpcFrame.invalidPhysicalLimit");
250
+ const maxMessageBytes = boundedPositive(options.maxMessageBytes, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxMessageBytes, "remote.rpcFrame.invalidMessageLimit");
251
+ const maxFragments = boundedPositive(options.maxFragments, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxFragments, "remote.rpcFrame.invalidFragmentLimit");
252
+ if (bytes.byteLength === 0) {
253
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.emptyMessage");
254
+ }
255
+ if (bytes.byteLength > maxMessageBytes) {
256
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.messageTooLarge");
257
+ }
258
+ const checksum = Object.freeze({
259
+ algorithm: "crc32",
260
+ value: crc32WireBytes(bytes),
261
+ });
262
+ let fragmentCount = 1;
263
+ let decodedBudget = 0;
264
+ for (;;) {
265
+ const endSeq = options.firstPhysicalSeq + fragmentCount - 1;
266
+ if (!Number.isSafeInteger(endSeq) || endSeq > Number.MAX_SAFE_INTEGER) {
267
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.sequenceOverflow");
268
+ }
269
+ decodedBudget = findDecodedBudget({
270
+ identity,
271
+ endSeq,
272
+ messageSeq: options.messageSeq,
273
+ fragmentCount,
274
+ messageBytes: bytes.byteLength,
275
+ checksum,
276
+ maxPhysicalFrameBytes,
277
+ });
278
+ if (decodedBudget < 1) {
279
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.envelopeTooLarge");
280
+ }
281
+ const required = Math.ceil(bytes.byteLength / decodedBudget);
282
+ if (required > maxFragments) {
283
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.fragmentLimitExceeded");
284
+ }
285
+ if (required <= fragmentCount)
286
+ break;
287
+ fragmentCount = required;
288
+ }
289
+ const frames = [];
290
+ for (let fragmentIndex = 0; fragmentIndex < fragmentCount; fragmentIndex += 1) {
291
+ const start = fragmentIndex * decodedBudget;
292
+ const end = Math.min(bytes.byteLength, start + decodedBudget);
293
+ const payload = frameShell({
294
+ identity,
295
+ seq: options.firstPhysicalSeq + fragmentIndex,
296
+ messageSeq: options.messageSeq,
297
+ fragmentIndex,
298
+ fragmentCount,
299
+ messageBytes: bytes.byteLength,
300
+ checksum,
301
+ dataBase64: encodeWireBytesBase64(bytes.subarray(start, end)),
302
+ });
303
+ if (measureWebRemoteControlRpcRelayEnvelopeBytes(payload) > maxPhysicalFrameBytes ||
304
+ !webRemoteControlRpcTransportFrameSchema.safeParse(payload).success) {
305
+ throw new WebRemoteControlRpcTransportEncodingError("remote.rpcFrame.internalEnvelopeError");
306
+ }
307
+ frames.push(Object.freeze(payload));
308
+ }
309
+ return Object.freeze(frames);
310
+ }
311
+ function sameIdentity(expected, frameValue) {
312
+ return (frameValue.bridgeSessionId === expected.bridgeSessionId &&
313
+ frameValue.bridgeGeneration === expected.bridgeGeneration &&
314
+ frameValue.recoveryId === expected.recoveryId);
315
+ }
316
+ function hasRawIdentityMismatch(expected, candidate) {
317
+ if (typeof candidate !== "object" || candidate === null)
318
+ return false;
319
+ const value = candidate;
320
+ const identityKeys = ["bridgeSessionId", "bridgeGeneration", "recoveryId"];
321
+ if (!identityKeys.some((key) => key in value))
322
+ return false;
323
+ return (value.bridgeSessionId !== expected.bridgeSessionId ||
324
+ value.bridgeGeneration !== expected.bridgeGeneration ||
325
+ value.recoveryId !== expected.recoveryId);
326
+ }
327
+ function frameFingerprint(frameValue, decoded) {
328
+ return {
329
+ messageSeq: frameValue.messageSeq,
330
+ // 完成后的 tombstone 只保留有界 metadata + fragment digest,不保留整段 base64。
331
+ value: JSON.stringify([
332
+ frameValue.bridgeSessionId,
333
+ frameValue.bridgeGeneration ?? null,
334
+ frameValue.recoveryId ?? null,
335
+ frameValue.seq,
336
+ frameValue.messageSeq,
337
+ frameValue.fragmentIndex,
338
+ frameValue.fragmentCount,
339
+ frameValue.messageBytes,
340
+ frameValue.checksum.algorithm,
341
+ frameValue.checksum.value,
342
+ decoded.byteLength,
343
+ crc32WireBytes(decoded),
344
+ ]),
345
+ };
346
+ }
347
+ function sameFingerprint(left, right) {
348
+ return left.value === right.value;
349
+ }
350
+ /** 每方向一个实例;任何 terminal fault 后由 04D-2 映射为 bridge degraded。 */
351
+ export class WebRemoteControlRpcTransportAssembler {
352
+ identity;
353
+ maxPhysicalFrameBytes;
354
+ maxMessageBytes;
355
+ maxFragments;
356
+ timeoutMs;
357
+ now;
358
+ expectedPhysicalSeq;
359
+ expectedMessageSeq;
360
+ lastCompletedMessageSeq;
361
+ physicalSequenceExhausted = false;
362
+ messageSequenceExhausted = false;
363
+ settledFrameFingerprintsBySeq = new Map();
364
+ active = null;
365
+ terminalReason = null;
366
+ constructor(options) {
367
+ this.identity = identityFrom(options.identity);
368
+ this.expectedPhysicalSeq = options.initialPhysicalSeq ?? 1;
369
+ this.expectedMessageSeq = options.initialMessageSeq ?? 1;
370
+ assertPositiveSafe(this.expectedPhysicalSeq, "remote.rpcFrame.invalidPhysicalSeq");
371
+ assertPositiveSafe(this.expectedMessageSeq, "remote.rpcFrame.invalidMessageSeq");
372
+ this.lastCompletedMessageSeq = this.expectedMessageSeq - 1;
373
+ this.maxPhysicalFrameBytes = boundedPositive(options.maxPhysicalFrameBytes, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxPhysicalFrameBytes, "remote.rpcFrame.invalidPhysicalLimit");
374
+ this.maxMessageBytes = boundedPositive(options.maxMessageBytes, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxMessageBytes, "remote.rpcFrame.invalidMessageLimit");
375
+ this.maxFragments = boundedPositive(options.maxFragments, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.maxFragments, "remote.rpcFrame.invalidFragmentLimit");
376
+ this.timeoutMs = boundedPositive(options.timeoutMs, WEB_REMOTE_CONTROL_RPC_TRANSPORT_LIMITS.assemblyTimeoutMs, "remote.rpcFrame.invalidTimeout");
377
+ this.now = options.now ?? Date.now;
378
+ }
379
+ get nextExpiryAt() {
380
+ return this.active ? this.active.firstSeenAt + this.timeoutMs : null;
381
+ }
382
+ fault(reasonCode, terminal, frameValue) {
383
+ if (terminal) {
384
+ this.terminalReason = reasonCode;
385
+ this.active = null;
386
+ }
387
+ return {
388
+ kind: "fault",
389
+ fault: {
390
+ reasonCode,
391
+ terminal,
392
+ ...(typeof frameValue?.seq === "number" ? { seq: frameValue.seq } : {}),
393
+ ...(typeof frameValue?.messageSeq === "number"
394
+ ? { messageSeq: frameValue.messageSeq }
395
+ : {}),
396
+ expectedSeq: this.expectedPhysicalSeq,
397
+ expectedMessageSeq: this.expectedMessageSeq,
398
+ },
399
+ };
400
+ }
401
+ expire(now = this.now()) {
402
+ if (!this.active || now - this.active.firstSeenAt < this.timeoutMs)
403
+ return null;
404
+ return this.fault("remote.rpcFrame.assemblyTimeout", true, {
405
+ messageSeq: this.active.messageSeq,
406
+ });
407
+ }
408
+ accept(candidate, now = this.now()) {
409
+ // foreign identity 必须先于本连接的 timeout、schema 与 base64 工作拒绝,否则坏外片会清空 owning assembly。
410
+ if (hasRawIdentityMismatch(this.identity, candidate)) {
411
+ return this.fault("remote.rpcFrame.identityMismatch", false);
412
+ }
413
+ if (this.terminalReason)
414
+ return this.fault(this.terminalReason, true);
415
+ const expired = this.expire(now);
416
+ if (expired)
417
+ return expired;
418
+ const rawBase64 = typeof candidate === "object" && candidate !== null && "dataBase64" in candidate
419
+ ? candidate.dataBase64
420
+ : undefined;
421
+ if (typeof rawBase64 === "string" &&
422
+ (rawBase64.length > this.maxPhysicalFrameBytes || !isCanonicalBase64(rawBase64))) {
423
+ return this.fault("remote.rpcFrame.invalidBase64", true);
424
+ }
425
+ const parsed = webRemoteControlRpcTransportFrameSchema.safeParse(candidate);
426
+ if (!parsed.success)
427
+ return this.fault("remote.rpcFrame.invalidMetadata", true);
428
+ const frameValue = parsed.data;
429
+ if (!sameIdentity(this.identity, frameValue)) {
430
+ return this.fault("remote.rpcFrame.identityMismatch", false, frameValue);
431
+ }
432
+ if (frameValue.messageBytes > this.maxMessageBytes) {
433
+ return this.fault("remote.rpcFrame.messageTooLarge", true, frameValue);
434
+ }
435
+ if (frameValue.fragmentCount > this.maxFragments) {
436
+ return this.fault("remote.rpcFrame.fragmentLimitExceeded", true, frameValue);
437
+ }
438
+ if (measureWebRemoteControlRpcRelayEnvelopeBytes(frameValue) > this.maxPhysicalFrameBytes) {
439
+ return this.fault("remote.rpcFrame.envelopeTooLarge", true, frameValue);
440
+ }
441
+ const decoded = decodeWireBase64(frameValue.dataBase64);
442
+ if (!decoded || decoded.byteLength === 0) {
443
+ return this.fault("remote.rpcFrame.invalidBase64", true, frameValue);
444
+ }
445
+ const fingerprint = frameFingerprint(frameValue, decoded);
446
+ const activeFingerprint = this.active?.frameFingerprintsBySeq.get(frameValue.seq);
447
+ if (activeFingerprint) {
448
+ if (!sameFingerprint(activeFingerprint, fingerprint)) {
449
+ return this.fault("remote.rpcFrame.conflictingDuplicate", true, frameValue);
450
+ }
451
+ return {
452
+ kind: "duplicate",
453
+ ackMessageSeq: this.lastCompletedMessageSeq > 0 ? this.lastCompletedMessageSeq : null,
454
+ };
455
+ }
456
+ const settledFingerprint = this.settledFrameFingerprintsBySeq.get(frameValue.seq);
457
+ if (settledFingerprint) {
458
+ if (sameFingerprint(settledFingerprint, fingerprint)) {
459
+ return {
460
+ kind: "duplicate",
461
+ ackMessageSeq: this.lastCompletedMessageSeq > 0 ? this.lastCompletedMessageSeq : null,
462
+ };
463
+ }
464
+ if (this.physicalSequenceExhausted &&
465
+ frameValue.messageSeq !== settledFingerprint.messageSeq) {
466
+ return this.fault("remote.rpcFrame.physicalSequenceExhausted", true, frameValue);
467
+ }
468
+ return this.fault("remote.rpcFrame.conflictingDuplicate", true, frameValue);
469
+ }
470
+ if (frameValue.seq < this.expectedPhysicalSeq) {
471
+ return {
472
+ kind: "duplicate",
473
+ ackMessageSeq: this.lastCompletedMessageSeq > 0 ? this.lastCompletedMessageSeq : null,
474
+ };
475
+ }
476
+ if (this.physicalSequenceExhausted) {
477
+ return this.fault("remote.rpcFrame.physicalSequenceExhausted", true, frameValue);
478
+ }
479
+ if (this.messageSequenceExhausted && !this.active) {
480
+ return this.fault("remote.rpcFrame.messageSequenceExhausted", true, frameValue);
481
+ }
482
+ if (frameValue.seq > this.expectedPhysicalSeq) {
483
+ return this.fault("remote.rpcFrame.physicalGap", true, frameValue);
484
+ }
485
+ if (frameValue.messageSeq !== this.expectedMessageSeq) {
486
+ return this.fault("remote.rpcFrame.messageGap", true, frameValue);
487
+ }
488
+ if (frameValue.seq === Number.MAX_SAFE_INTEGER &&
489
+ frameValue.fragmentIndex + 1 < frameValue.fragmentCount) {
490
+ return this.fault("remote.rpcFrame.physicalSequenceExhausted", true, frameValue);
491
+ }
492
+ const expectedFragmentIndex = this.active?.fragments.length ?? 0;
493
+ if (frameValue.fragmentIndex !== expectedFragmentIndex) {
494
+ return this.fault("remote.rpcFrame.fragmentGap", true, frameValue);
495
+ }
496
+ if (this.active &&
497
+ (frameValue.fragmentCount !== this.active.fragmentCount ||
498
+ frameValue.messageBytes !== this.active.messageBytes)) {
499
+ return this.fault("remote.rpcFrame.metadataMismatch", true, frameValue);
500
+ }
501
+ if (this.active && frameValue.checksum.value !== this.active.checksum.value) {
502
+ return this.fault("remote.rpcFrame.checksumMismatch", true, frameValue);
503
+ }
504
+ if (!this.active) {
505
+ this.active = {
506
+ messageSeq: frameValue.messageSeq,
507
+ fragmentCount: frameValue.fragmentCount,
508
+ messageBytes: frameValue.messageBytes,
509
+ checksum: frameValue.checksum,
510
+ firstSeenAt: now,
511
+ stagedBytes: 0,
512
+ fragments: [],
513
+ frameFingerprintsBySeq: new Map(),
514
+ };
515
+ }
516
+ if (this.active.stagedBytes + decoded.byteLength > this.active.messageBytes) {
517
+ return this.fault("remote.rpcFrame.lengthMismatch", true, frameValue);
518
+ }
519
+ this.active.fragments.push(decoded);
520
+ this.active.frameFingerprintsBySeq.set(frameValue.seq, fingerprint);
521
+ this.active.stagedBytes += decoded.byteLength;
522
+ if (frameValue.seq === Number.MAX_SAFE_INTEGER) {
523
+ // 本消息可在最大 seq 收口,但任何后继消息都必须新 bridge generation。
524
+ this.physicalSequenceExhausted = true;
525
+ }
526
+ else {
527
+ this.expectedPhysicalSeq += 1;
528
+ }
529
+ if (this.active.fragments.length < this.active.fragmentCount) {
530
+ return {
531
+ kind: "incomplete",
532
+ messageSeq: frameValue.messageSeq,
533
+ receivedFragments: this.active.fragments.length,
534
+ };
535
+ }
536
+ if (this.active.stagedBytes !== this.active.messageBytes) {
537
+ return this.fault("remote.rpcFrame.lengthMismatch", true, frameValue);
538
+ }
539
+ const completedBytes = new Uint8Array(this.active.messageBytes);
540
+ let offset = 0;
541
+ for (const fragment of this.active.fragments) {
542
+ completedBytes.set(fragment, offset);
543
+ offset += fragment.byteLength;
544
+ }
545
+ if (crc32WireBytes(completedBytes) !== this.active.checksum.value) {
546
+ return this.fault("remote.rpcFrame.checksumMismatch", true, frameValue);
547
+ }
548
+ const completedAssembly = this.active;
549
+ const messageSeq = completedAssembly.messageSeq;
550
+ this.settledFrameFingerprintsBySeq = new Map(completedAssembly.frameFingerprintsBySeq);
551
+ this.active = null;
552
+ this.lastCompletedMessageSeq = messageSeq;
553
+ if (messageSeq === Number.MAX_SAFE_INTEGER) {
554
+ this.messageSequenceExhausted = true;
555
+ }
556
+ else {
557
+ this.expectedMessageSeq += 1;
558
+ }
559
+ return { kind: "complete", messageSeq, bytes: completedBytes };
560
+ }
561
+ }
562
+ //# sourceMappingURL=web-remote-control-rpc-transport.js.map