@mostra/protocol 0.0.0-stage → 0.1.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.
- package/LICENSE +202 -0
- package/README.md +38 -2
- package/dist/actions.d.ts +273 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +154 -0
- package/dist/actions.js.map +1 -0
- package/dist/artifact.d.ts +113 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +79 -0
- package/dist/artifact.js.map +1 -0
- package/dist/bridge.d.ts +295 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +343 -0
- package/dist/bridge.js.map +1 -0
- package/dist/browser.d.ts +195 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +156 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundle.d.ts +155 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +130 -0
- package/dist/bundle.js.map +1 -0
- package/dist/canonical.d.ts +23 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +45 -0
- package/dist/canonical.js.map +1 -0
- package/dist/capability.d.ts +38 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +61 -0
- package/dist/capability.js.map +1 -0
- package/dist/diagnostics/codes/a11y.d.ts +8 -0
- package/dist/diagnostics/codes/a11y.d.ts.map +1 -0
- package/dist/diagnostics/codes/a11y.js +30 -0
- package/dist/diagnostics/codes/a11y.js.map +1 -0
- package/dist/diagnostics/codes/action.d.ts +8 -0
- package/dist/diagnostics/codes/action.d.ts.map +1 -0
- package/dist/diagnostics/codes/action.js +110 -0
- package/dist/diagnostics/codes/action.js.map +1 -0
- package/dist/diagnostics/codes/artifact.d.ts +8 -0
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -0
- package/dist/diagnostics/codes/artifact.js +121 -0
- package/dist/diagnostics/codes/artifact.js.map +1 -0
- package/dist/diagnostics/codes/build.d.ts +8 -0
- package/dist/diagnostics/codes/build.d.ts.map +1 -0
- package/dist/diagnostics/codes/build.js +55 -0
- package/dist/diagnostics/codes/build.js.map +1 -0
- package/dist/diagnostics/codes/cli.d.ts +8 -0
- package/dist/diagnostics/codes/cli.d.ts.map +1 -0
- package/dist/diagnostics/codes/cli.js +44 -0
- package/dist/diagnostics/codes/cli.js.map +1 -0
- package/dist/diagnostics/codes/console.d.ts +8 -0
- package/dist/diagnostics/codes/console.d.ts.map +1 -0
- package/dist/diagnostics/codes/console.js +30 -0
- package/dist/diagnostics/codes/console.js.map +1 -0
- package/dist/diagnostics/codes/dep.d.ts +8 -0
- package/dist/diagnostics/codes/dep.d.ts.map +1 -0
- package/dist/diagnostics/codes/dep.js +88 -0
- package/dist/diagnostics/codes/dep.js.map +1 -0
- package/dist/diagnostics/codes/env.d.ts +8 -0
- package/dist/diagnostics/codes/env.d.ts.map +1 -0
- package/dist/diagnostics/codes/env.js +132 -0
- package/dist/diagnostics/codes/env.js.map +1 -0
- package/dist/diagnostics/codes/field.d.ts +8 -0
- package/dist/diagnostics/codes/field.d.ts.map +1 -0
- package/dist/diagnostics/codes/field.js +99 -0
- package/dist/diagnostics/codes/field.js.map +1 -0
- package/dist/diagnostics/codes/home.d.ts +8 -0
- package/dist/diagnostics/codes/home.d.ts.map +1 -0
- package/dist/diagnostics/codes/home.js +132 -0
- package/dist/diagnostics/codes/home.js.map +1 -0
- package/dist/diagnostics/codes/host.d.ts +8 -0
- package/dist/diagnostics/codes/host.d.ts.map +1 -0
- package/dist/diagnostics/codes/host.js +176 -0
- package/dist/diagnostics/codes/host.js.map +1 -0
- package/dist/diagnostics/codes/hygiene.d.ts +8 -0
- package/dist/diagnostics/codes/hygiene.d.ts.map +1 -0
- package/dist/diagnostics/codes/hygiene.js +154 -0
- package/dist/diagnostics/codes/hygiene.js.map +1 -0
- package/dist/diagnostics/codes/index.d.ts +51 -0
- package/dist/diagnostics/codes/index.d.ts.map +1 -0
- package/dist/diagnostics/codes/index.js +72 -0
- package/dist/diagnostics/codes/index.js.map +1 -0
- package/dist/diagnostics/codes/live.d.ts +8 -0
- package/dist/diagnostics/codes/live.d.ts.map +1 -0
- package/dist/diagnostics/codes/live.js +30 -0
- package/dist/diagnostics/codes/live.js.map +1 -0
- package/dist/diagnostics/codes/manifest.d.ts +8 -0
- package/dist/diagnostics/codes/manifest.d.ts.map +1 -0
- package/dist/diagnostics/codes/manifest.js +44 -0
- package/dist/diagnostics/codes/manifest.js.map +1 -0
- package/dist/diagnostics/codes/network.d.ts +8 -0
- package/dist/diagnostics/codes/network.d.ts.map +1 -0
- package/dist/diagnostics/codes/network.js +30 -0
- package/dist/diagnostics/codes/network.js.map +1 -0
- package/dist/diagnostics/codes/platform.d.ts +8 -0
- package/dist/diagnostics/codes/platform.d.ts.map +1 -0
- package/dist/diagnostics/codes/platform.js +18 -0
- package/dist/diagnostics/codes/platform.js.map +1 -0
- package/dist/diagnostics/codes/publish.d.ts +8 -0
- package/dist/diagnostics/codes/publish.d.ts.map +1 -0
- package/dist/diagnostics/codes/publish.js +44 -0
- package/dist/diagnostics/codes/publish.js.map +1 -0
- package/dist/diagnostics/codes/regression.d.ts +8 -0
- package/dist/diagnostics/codes/regression.d.ts.map +1 -0
- package/dist/diagnostics/codes/regression.js +77 -0
- package/dist/diagnostics/codes/regression.js.map +1 -0
- package/dist/diagnostics/codes/runtime.d.ts +8 -0
- package/dist/diagnostics/codes/runtime.d.ts.map +1 -0
- package/dist/diagnostics/codes/runtime.js +66 -0
- package/dist/diagnostics/codes/runtime.js.map +1 -0
- package/dist/diagnostics/codes/secret.d.ts +8 -0
- package/dist/diagnostics/codes/secret.d.ts.map +1 -0
- package/dist/diagnostics/codes/secret.js +18 -0
- package/dist/diagnostics/codes/secret.js.map +1 -0
- package/dist/diagnostics/codes/smoke.d.ts +8 -0
- package/dist/diagnostics/codes/smoke.d.ts.map +1 -0
- package/dist/diagnostics/codes/smoke.js +30 -0
- package/dist/diagnostics/codes/smoke.js.map +1 -0
- package/dist/diagnostics/codes/submit.d.ts +8 -0
- package/dist/diagnostics/codes/submit.d.ts.map +1 -0
- package/dist/diagnostics/codes/submit.js +99 -0
- package/dist/diagnostics/codes/submit.js.map +1 -0
- package/dist/diagnostics/codes/target.d.ts +8 -0
- package/dist/diagnostics/codes/target.d.ts.map +1 -0
- package/dist/diagnostics/codes/target.js +18 -0
- package/dist/diagnostics/codes/target.js.map +1 -0
- package/dist/diagnostics/codes/type.d.ts +8 -0
- package/dist/diagnostics/codes/type.d.ts.map +1 -0
- package/dist/diagnostics/codes/type.js +30 -0
- package/dist/diagnostics/codes/type.js.map +1 -0
- package/dist/diagnostics/codes/verify.d.ts +8 -0
- package/dist/diagnostics/codes/verify.d.ts.map +1 -0
- package/dist/diagnostics/codes/verify.js +99 -0
- package/dist/diagnostics/codes/verify.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +79 -0
- package/dist/diagnostics/diagnostic.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic.js +131 -0
- package/dist/diagnostics/diagnostic.js.map +1 -0
- package/dist/diagnostics/spec.d.ts +49 -0
- package/dist/diagnostics/spec.d.ts.map +1 -0
- package/dist/diagnostics/spec.js +31 -0
- package/dist/diagnostics/spec.js.map +1 -0
- package/dist/hygiene.d.ts +66 -0
- package/dist/hygiene.d.ts.map +1 -0
- package/dist/hygiene.js +134 -0
- package/dist/hygiene.js.map +1 -0
- package/dist/ids.d.ts +119 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +135 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +86 -0
- package/dist/interaction.d.ts +391 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +306 -0
- package/dist/interaction.js.map +1 -0
- package/dist/manifest.d.ts +97 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +101 -0
- package/dist/manifest.js.map +1 -0
- package/dist/method.d.ts +26 -0
- package/dist/method.d.ts.map +1 -0
- package/dist/method.js +10 -0
- package/dist/method.js.map +1 -0
- package/dist/methods/artifact/create.d.ts +29 -0
- package/dist/methods/artifact/create.d.ts.map +1 -0
- package/dist/methods/artifact/create.js +31 -0
- package/dist/methods/artifact/create.js.map +1 -0
- package/dist/methods/artifact/get.d.ts +17 -0
- package/dist/methods/artifact/get.d.ts.map +1 -0
- package/dist/methods/artifact/get.js +21 -0
- package/dist/methods/artifact/get.js.map +1 -0
- package/dist/methods/artifact/list.d.ts +22 -0
- package/dist/methods/artifact/list.d.ts.map +1 -0
- package/dist/methods/artifact/list.js +19 -0
- package/dist/methods/artifact/list.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +28 -0
- package/dist/methods/artifact/publish.d.ts.map +1 -0
- package/dist/methods/artifact/publish.js +28 -0
- package/dist/methods/artifact/publish.js.map +1 -0
- package/dist/methods/artifact/verify.d.ts +29 -0
- package/dist/methods/artifact/verify.d.ts.map +1 -0
- package/dist/methods/artifact/verify.js +27 -0
- package/dist/methods/artifact/verify.js.map +1 -0
- package/dist/methods/deps/add.d.ts +43 -0
- package/dist/methods/deps/add.d.ts.map +1 -0
- package/dist/methods/deps/add.js +40 -0
- package/dist/methods/deps/add.js.map +1 -0
- package/dist/methods/dev/start.d.ts +52 -0
- package/dist/methods/dev/start.d.ts.map +1 -0
- package/dist/methods/dev/start.js +56 -0
- package/dist/methods/dev/start.js.map +1 -0
- package/dist/methods/dev/stop.d.ts +16 -0
- package/dist/methods/dev/stop.d.ts.map +1 -0
- package/dist/methods/dev/stop.js +21 -0
- package/dist/methods/dev/stop.js.map +1 -0
- package/dist/methods/events/ack.d.ts +20 -0
- package/dist/methods/events/ack.d.ts.map +1 -0
- package/dist/methods/events/ack.js +26 -0
- package/dist/methods/events/ack.js.map +1 -0
- package/dist/methods/events/read.d.ts +40 -0
- package/dist/methods/events/read.d.ts.map +1 -0
- package/dist/methods/events/read.js +35 -0
- package/dist/methods/events/read.js.map +1 -0
- package/dist/methods/events/subscribe.d.ts +54 -0
- package/dist/methods/events/subscribe.d.ts.map +1 -0
- package/dist/methods/events/subscribe.js +44 -0
- package/dist/methods/events/subscribe.js.map +1 -0
- package/dist/methods/events/unsubscribe.d.ts +16 -0
- package/dist/methods/events/unsubscribe.d.ts.map +1 -0
- package/dist/methods/events/unsubscribe.js +21 -0
- package/dist/methods/events/unsubscribe.js.map +1 -0
- package/dist/methods/gc/run.d.ts +76 -0
- package/dist/methods/gc/run.d.ts.map +1 -0
- package/dist/methods/gc/run.js +56 -0
- package/dist/methods/gc/run.js.map +1 -0
- package/dist/methods/index.d.ts +6 -0
- package/dist/methods/index.d.ts.map +1 -0
- package/dist/methods/index.js +78 -0
- package/dist/methods/index.js.map +1 -0
- package/dist/methods/instance/check.d.ts +30 -0
- package/dist/methods/instance/check.d.ts.map +1 -0
- package/dist/methods/instance/check.js +34 -0
- package/dist/methods/instance/check.js.map +1 -0
- package/dist/methods/instance/status.d.ts +102 -0
- package/dist/methods/instance/status.d.ts.map +1 -0
- package/dist/methods/instance/status.js +83 -0
- package/dist/methods/instance/status.js.map +1 -0
- package/dist/methods/live/push.d.ts +28 -0
- package/dist/methods/live/push.d.ts.map +1 -0
- package/dist/methods/live/push.js +35 -0
- package/dist/methods/live/push.js.map +1 -0
- package/dist/methods/mostra/initialize.d.ts +143 -0
- package/dist/methods/mostra/initialize.d.ts.map +1 -0
- package/dist/methods/mostra/initialize.js +97 -0
- package/dist/methods/mostra/initialize.js.map +1 -0
- package/dist/methods/mostra/shutdown.d.ts +14 -0
- package/dist/methods/mostra/shutdown.d.ts.map +1 -0
- package/dist/methods/mostra/shutdown.js +22 -0
- package/dist/methods/mostra/shutdown.js.map +1 -0
- package/dist/methods/port/drafts-mirror.d.ts +30 -0
- package/dist/methods/port/drafts-mirror.d.ts.map +1 -0
- package/dist/methods/port/drafts-mirror.js +33 -0
- package/dist/methods/port/drafts-mirror.js.map +1 -0
- package/dist/methods/port/secrets-get.d.ts +19 -0
- package/dist/methods/port/secrets-get.d.ts.map +1 -0
- package/dist/methods/port/secrets-get.js +31 -0
- package/dist/methods/port/secrets-get.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +38 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -0
- package/dist/methods/port/submissions-deliver.js +38 -0
- package/dist/methods/port/submissions-deliver.js.map +1 -0
- package/dist/methods/port/trusted-controls-activated.d.ts +27 -0
- package/dist/methods/port/trusted-controls-activated.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-activated.js +33 -0
- package/dist/methods/port/trusted-controls-activated.js.map +1 -0
- package/dist/methods/port/trusted-controls-policy.d.ts +21 -0
- package/dist/methods/port/trusted-controls-policy.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-policy.js +27 -0
- package/dist/methods/port/trusted-controls-policy.js.map +1 -0
- package/dist/methods/results/get.d.ts +32 -0
- package/dist/methods/results/get.d.ts.map +1 -0
- package/dist/methods/results/get.js +36 -0
- package/dist/methods/results/get.js.map +1 -0
- package/dist/methods/secret/delete.d.ts +22 -0
- package/dist/methods/secret/delete.d.ts.map +1 -0
- package/dist/methods/secret/delete.js +32 -0
- package/dist/methods/secret/delete.js.map +1 -0
- package/dist/methods/secret/list.d.ts +21 -0
- package/dist/methods/secret/list.d.ts.map +1 -0
- package/dist/methods/secret/list.js +29 -0
- package/dist/methods/secret/list.js.map +1 -0
- package/dist/methods/secret/set.d.ts +37 -0
- package/dist/methods/secret/set.d.ts.map +1 -0
- package/dist/methods/secret/set.js +41 -0
- package/dist/methods/secret/set.js.map +1 -0
- package/dist/methods/state/get.d.ts +25 -0
- package/dist/methods/state/get.d.ts.map +1 -0
- package/dist/methods/state/get.js +29 -0
- package/dist/methods/state/get.js.map +1 -0
- package/dist/methods/state/patch.d.ts +32 -0
- package/dist/methods/state/patch.d.ts.map +1 -0
- package/dist/methods/state/patch.js +29 -0
- package/dist/methods/state/patch.js.map +1 -0
- package/dist/methods/view/default.d.ts +19 -0
- package/dist/methods/view/default.d.ts.map +1 -0
- package/dist/methods/view/default.js +23 -0
- package/dist/methods/view/default.js.map +1 -0
- package/dist/methods/view/launch.d.ts +27 -0
- package/dist/methods/view/launch.d.ts.map +1 -0
- package/dist/methods/view/launch.js +30 -0
- package/dist/methods/view/launch.js.map +1 -0
- package/dist/methods/view/revoke.d.ts +19 -0
- package/dist/methods/view/revoke.d.ts.map +1 -0
- package/dist/methods/view/revoke.js +26 -0
- package/dist/methods/view/revoke.js.map +1 -0
- package/dist/methods/view/rotate.d.ts +21 -0
- package/dist/methods/view/rotate.d.ts.map +1 -0
- package/dist/methods/view/rotate.js +27 -0
- package/dist/methods/view/rotate.js.map +1 -0
- package/dist/methods/view/url.d.ts +52 -0
- package/dist/methods/view/url.d.ts.map +1 -0
- package/dist/methods/view/url.js +43 -0
- package/dist/methods/view/url.js.map +1 -0
- package/dist/methods/wait/wait.d.ts +37 -0
- package/dist/methods/wait/wait.d.ts.map +1 -0
- package/dist/methods/wait/wait.js +39 -0
- package/dist/methods/wait/wait.js.map +1 -0
- package/dist/revision.d.ts +43 -0
- package/dist/revision.d.ts.map +1 -0
- package/dist/revision.js +69 -0
- package/dist/revision.js.map +1 -0
- package/dist/rpc/error.d.ts +47 -0
- package/dist/rpc/error.d.ts.map +1 -0
- package/dist/rpc/error.js +77 -0
- package/dist/rpc/error.js.map +1 -0
- package/dist/rpc/lines.d.ts +30 -0
- package/dist/rpc/lines.d.ts.map +1 -0
- package/dist/rpc/lines.js +63 -0
- package/dist/rpc/lines.js.map +1 -0
- package/dist/rpc/messages.d.ts +92 -0
- package/dist/rpc/messages.d.ts.map +1 -0
- package/dist/rpc/messages.js +133 -0
- package/dist/rpc/messages.js.map +1 -0
- package/dist/rpc/peer.d.ts +81 -0
- package/dist/rpc/peer.d.ts.map +1 -0
- package/dist/rpc/peer.js +208 -0
- package/dist/rpc/peer.js.map +1 -0
- package/dist/serializer.d.ts +178 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +929 -0
- package/dist/serializer.js.map +1 -0
- package/dist/verify.d.ts +254 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +243 -0
- package/dist/verify.js.map +1 -0
- package/dist/view.d.ts +103 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +110 -0
- package/dist/view.js.map +1 -0
- package/dist/wire-registry.js +11 -0
- package/dist/wire-registry.js.map +1 -0
- package/dist/worker.d.ts +249 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +158 -0
- package/dist/worker.js.map +1 -0
- package/package.json +114 -3
- package/schemas/protocol.draft-07.json +5120 -0
- package/schemas/protocol.schema.json +4964 -0
- package/src/actions.ts +418 -0
- package/src/artifact.ts +187 -0
- package/src/bridge.ts +618 -0
- package/src/browser.ts +374 -0
- package/src/bundle.ts +264 -0
- package/src/canonical.ts +49 -0
- package/src/capability.ts +92 -0
- package/src/diagnostics/codes/a11y.ts +41 -0
- package/src/diagnostics/codes/action.ts +125 -0
- package/src/diagnostics/codes/artifact.ts +137 -0
- package/src/diagnostics/codes/build.ts +65 -0
- package/src/diagnostics/codes/cli.ts +53 -0
- package/src/diagnostics/codes/console.ts +41 -0
- package/src/diagnostics/codes/dep.ts +101 -0
- package/src/diagnostics/codes/env.ts +149 -0
- package/src/diagnostics/codes/field.ts +113 -0
- package/src/diagnostics/codes/home.ts +150 -0
- package/src/diagnostics/codes/host.ts +197 -0
- package/src/diagnostics/codes/hygiene.ts +175 -0
- package/src/diagnostics/codes/index.ts +142 -0
- package/src/diagnostics/codes/live.ts +41 -0
- package/src/diagnostics/codes/manifest.ts +53 -0
- package/src/diagnostics/codes/network.ts +41 -0
- package/src/diagnostics/codes/platform.ts +30 -0
- package/src/diagnostics/codes/publish.ts +53 -0
- package/src/diagnostics/codes/regression.ts +89 -0
- package/src/diagnostics/codes/runtime.ts +77 -0
- package/src/diagnostics/codes/secret.ts +29 -0
- package/src/diagnostics/codes/smoke.ts +41 -0
- package/src/diagnostics/codes/submit.ts +113 -0
- package/src/diagnostics/codes/target.ts +29 -0
- package/src/diagnostics/codes/type.ts +41 -0
- package/src/diagnostics/codes/verify.ts +113 -0
- package/src/diagnostics/diagnostic.ts +240 -0
- package/src/diagnostics/spec.ts +90 -0
- package/src/hygiene.ts +224 -0
- package/src/ids.ts +279 -0
- package/src/index.ts +576 -0
- package/src/interaction.ts +728 -0
- package/src/manifest.ts +206 -0
- package/src/method.ts +42 -0
- package/src/methods/artifact/create.ts +56 -0
- package/src/methods/artifact/get.ts +30 -0
- package/src/methods/artifact/list.ts +42 -0
- package/src/methods/artifact/publish.ts +46 -0
- package/src/methods/artifact/verify.ts +46 -0
- package/src/methods/deps/add.ts +72 -0
- package/src/methods/dev/start.ts +84 -0
- package/src/methods/dev/stop.ts +32 -0
- package/src/methods/events/ack.ts +41 -0
- package/src/methods/events/read.ts +67 -0
- package/src/methods/events/subscribe.ts +91 -0
- package/src/methods/events/unsubscribe.ts +35 -0
- package/src/methods/gc/run.ts +125 -0
- package/src/methods/index.ts +81 -0
- package/src/methods/instance/check.ts +61 -0
- package/src/methods/instance/status.ts +172 -0
- package/src/methods/live/push.ts +54 -0
- package/src/methods/mostra/initialize.ts +249 -0
- package/src/methods/mostra/shutdown.ts +31 -0
- package/src/methods/port/drafts-mirror.ts +52 -0
- package/src/methods/port/secrets-get.ts +40 -0
- package/src/methods/port/submissions-deliver.ts +70 -0
- package/src/methods/port/trusted-controls-activated.ts +51 -0
- package/src/methods/port/trusted-controls-policy.ts +38 -0
- package/src/methods/results/get.ts +59 -0
- package/src/methods/secret/delete.ts +43 -0
- package/src/methods/secret/list.ts +40 -0
- package/src/methods/secret/set.ts +69 -0
- package/src/methods/state/get.ts +44 -0
- package/src/methods/state/patch.ts +51 -0
- package/src/methods/view/default.ts +32 -0
- package/src/methods/view/launch.ts +47 -0
- package/src/methods/view/revoke.ts +39 -0
- package/src/methods/view/rotate.ts +37 -0
- package/src/methods/view/url.ts +84 -0
- package/src/methods/wait/wait.ts +58 -0
- package/src/revision.ts +101 -0
- package/src/rpc/error.ts +107 -0
- package/src/rpc/lines.ts +70 -0
- package/src/rpc/messages.ts +188 -0
- package/src/rpc/peer.ts +341 -0
- package/src/serializer.ts +1217 -0
- package/src/timers.d.ts +8 -0
- package/src/verify.ts +458 -0
- package/src/view.ts +200 -0
- package/src/web-crypto.d.ts +9 -0
- package/src/web-platform.d.ts +35 -0
- package/src/wire-registry.ts +14 -0
- package/src/worker.ts +374 -0
package/src/rpc/error.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors on a JSON-RPC connection. Every error carries a diagnostic (INTERFACES §1, §6): the
|
|
3
|
+
* JSON-RPC `error.code` says which kind of failure it is, and `error.data` is the diagnostic.
|
|
4
|
+
*/
|
|
5
|
+
import { type HostDiagnosticCode, hostDiagnostics } from "../diagnostics/codes/host.ts";
|
|
6
|
+
import { Diagnostic } from "../diagnostics/diagnostic.ts";
|
|
7
|
+
import { buildDiagnostic, type DiagnosticDetails } from "../diagnostics/spec.ts";
|
|
8
|
+
import type { JsonRpcErrorObject } from "./messages.ts";
|
|
9
|
+
|
|
10
|
+
/** The JSON-RPC 2.0 error codes Mostra uses (INTERFACES §6). */
|
|
11
|
+
export const JSON_RPC_ERROR_CODES: {
|
|
12
|
+
/** The line wasn't valid JSON. */
|
|
13
|
+
readonly parseError: -32700;
|
|
14
|
+
/** The message wasn't a valid request, or was a batch. */
|
|
15
|
+
readonly invalidRequest: -32600;
|
|
16
|
+
/** The method doesn't exist on this side. */
|
|
17
|
+
readonly methodNotFound: -32601;
|
|
18
|
+
/** The params failed the method's schema. */
|
|
19
|
+
readonly invalidParams: -32602;
|
|
20
|
+
/** An unexpected failure. */
|
|
21
|
+
readonly internalError: -32603;
|
|
22
|
+
/** Every other diagnostic. */
|
|
23
|
+
readonly diagnostic: -32000;
|
|
24
|
+
} = {
|
|
25
|
+
parseError: -32700,
|
|
26
|
+
invalidRequest: -32600,
|
|
27
|
+
methodNotFound: -32601,
|
|
28
|
+
invalidParams: -32602,
|
|
29
|
+
internalError: -32603,
|
|
30
|
+
diagnostic: -32000,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function codeFor(diagnostic: Diagnostic): number {
|
|
34
|
+
switch (diagnostic.code) {
|
|
35
|
+
case "MOSTRA_HOST_MALFORMED":
|
|
36
|
+
return JSON_RPC_ERROR_CODES.invalidRequest;
|
|
37
|
+
case "MOSTRA_HOST_METHOD_UNKNOWN":
|
|
38
|
+
return JSON_RPC_ERROR_CODES.methodNotFound;
|
|
39
|
+
case "MOSTRA_HOST_INVALID_PARAMS":
|
|
40
|
+
return JSON_RPC_ERROR_CODES.invalidParams;
|
|
41
|
+
case "MOSTRA_HOST_INTERNAL_ERROR":
|
|
42
|
+
return JSON_RPC_ERROR_CODES.internalError;
|
|
43
|
+
default:
|
|
44
|
+
return JSON_RPC_ERROR_CODES.diagnostic;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* An error that crosses a connection as a JSON-RPC error. Throw it from a request handler to
|
|
50
|
+
* answer with this diagnostic; a request's promise rejects with it when the other side answers
|
|
51
|
+
* with an error, the connection closes or the request times out.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* throw new RpcError(
|
|
55
|
+
* createDiagnostic("MOSTRA_HOME_MISMATCH", { message: "This instance serves /a, not /b." }),
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export class RpcError extends Error {
|
|
60
|
+
/** The JSON-RPC error code. */
|
|
61
|
+
readonly code: number;
|
|
62
|
+
/** The diagnostic: what happened and what to do. */
|
|
63
|
+
readonly diagnostic: Diagnostic;
|
|
64
|
+
|
|
65
|
+
constructor(diagnostic: Diagnostic, code: number = codeFor(diagnostic)) {
|
|
66
|
+
super(diagnostic.message);
|
|
67
|
+
this.name = "RpcError";
|
|
68
|
+
this.code = code;
|
|
69
|
+
this.diagnostic = diagnostic;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The JSON-RPC error object for a response. */
|
|
73
|
+
toErrorObject(): JsonRpcErrorObject {
|
|
74
|
+
return { code: this.code, message: this.diagnostic.message, data: this.diagnostic };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reads a received error object. When its `data` isn't a diagnostic (a peer that isn't Mostra),
|
|
79
|
+
* the result is a `MOSTRA_HOST_MALFORMED` diagnostic that keeps the peer's message.
|
|
80
|
+
*/
|
|
81
|
+
static fromErrorObject(error: JsonRpcErrorObject, docsBase?: string): RpcError {
|
|
82
|
+
const parsed = Diagnostic.safeParse(error.data);
|
|
83
|
+
if (parsed.success) return new RpcError(parsed.data, error.code);
|
|
84
|
+
return new RpcError(
|
|
85
|
+
hostDiagnostic(
|
|
86
|
+
"MOSTRA_HOST_MALFORMED",
|
|
87
|
+
{
|
|
88
|
+
message: `The other side answered with error ${error.code} without a diagnostic: ${error.message.slice(0, 200)}`,
|
|
89
|
+
},
|
|
90
|
+
docsBase,
|
|
91
|
+
),
|
|
92
|
+
error.code,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Builds a HOST-area diagnostic from that area's catalog alone, so the JSON-RPC core doesn't pull
|
|
99
|
+
* every area's text into browser bundles (D83).
|
|
100
|
+
*/
|
|
101
|
+
export function hostDiagnostic(
|
|
102
|
+
code: HostDiagnosticCode,
|
|
103
|
+
details: DiagnosticDetails,
|
|
104
|
+
docsBase?: string,
|
|
105
|
+
): Diagnostic {
|
|
106
|
+
return buildDiagnostic(code, hostDiagnostics[code], details, docsBase);
|
|
107
|
+
}
|
package/src/rpc/lines.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Newline-delimited JSON framing for byte streams (stdio, Unix sockets): one message per line.
|
|
3
|
+
* JSON text never contains a raw newline, so a newline always ends a message.
|
|
4
|
+
*/
|
|
5
|
+
import type { JsonRpcMessage } from "./messages.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The longest line, in UTF-16 code units, either side of a newline-delimited connection accepts:
|
|
9
|
+
* 64 Mi. Writers check it too, so a message that couldn't be read is never sent.
|
|
10
|
+
*/
|
|
11
|
+
export const MAX_LINE_LENGTH: number = 64 * 1024 * 1024;
|
|
12
|
+
|
|
13
|
+
/** Serializes one message as a line, newline included. */
|
|
14
|
+
export function encodeLine(message: JsonRpcMessage): string {
|
|
15
|
+
return `${JSON.stringify(message)}\n`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Splits decoded text into lines. Feed it chunks as they arrive; it returns the complete lines
|
|
20
|
+
* and keeps the unfinished rest. A line longer than `maxLineLength` characters throws a
|
|
21
|
+
* `RangeError`, so a peer can't make the other side buffer without bound: the transport then
|
|
22
|
+
* answers with `MOSTRA_HOST_MALFORMED` and closes the connection.
|
|
23
|
+
*/
|
|
24
|
+
export class LineSplitter {
|
|
25
|
+
readonly #maxLineLength: number;
|
|
26
|
+
/** The unfinished line, in the pieces it arrived in: joined only once its newline comes. */
|
|
27
|
+
#pending: string[] = [];
|
|
28
|
+
#pendingLength = 0;
|
|
29
|
+
|
|
30
|
+
/** @param maxLineLength - The longest line accepted, in UTF-16 code units. Default 64 Mi. */
|
|
31
|
+
constructor(maxLineLength: number = MAX_LINE_LENGTH) {
|
|
32
|
+
this.#maxLineLength = maxLineLength;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the lines completed by `chunk`, without their newlines (and without a trailing `\r`).
|
|
37
|
+
* Only `chunk` is searched for newlines, so a long line costs time in proportion to its length,
|
|
38
|
+
* however many chunks bring it.
|
|
39
|
+
*/
|
|
40
|
+
push(chunk: string): string[] {
|
|
41
|
+
const lines: string[] = [];
|
|
42
|
+
let start = 0;
|
|
43
|
+
for (let index = chunk.indexOf("\n"); index >= 0; index = chunk.indexOf("\n", start)) {
|
|
44
|
+
if (this.#pendingLength + index - start > this.#maxLineLength) this.#overflow();
|
|
45
|
+
this.#pending.push(chunk.slice(start, index));
|
|
46
|
+
const line = this.#pending.join("");
|
|
47
|
+
this.#pending = [];
|
|
48
|
+
this.#pendingLength = 0;
|
|
49
|
+
lines.push(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
50
|
+
start = index + 1;
|
|
51
|
+
}
|
|
52
|
+
if (start < chunk.length) {
|
|
53
|
+
this.#pendingLength += chunk.length - start;
|
|
54
|
+
if (this.#pendingLength > this.#maxLineLength) this.#overflow();
|
|
55
|
+
this.#pending.push(chunk.slice(start));
|
|
56
|
+
}
|
|
57
|
+
return lines;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The unfinished text after the last newline. A stream that ends with it holds a cut-off message. */
|
|
61
|
+
get rest(): string {
|
|
62
|
+
return this.#pending.join("");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#overflow(): never {
|
|
66
|
+
this.#pending = [];
|
|
67
|
+
this.#pendingLength = 0;
|
|
68
|
+
throw new RangeError(`A message is longer than ${this.#maxLineLength} characters.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 message shapes (D59, D83). Every Mostra connection carries these: the host protocol
|
|
3
|
+
* over stdio or the home socket, child-process messaging and the shell bridge. Revision
|
|
4
|
+
* `2026-10-10` has no batches.
|
|
5
|
+
*/
|
|
6
|
+
import * as z from "zod";
|
|
7
|
+
import { wireRegistry } from "../wire-registry.ts";
|
|
8
|
+
|
|
9
|
+
/** A request ID: a string or a number, chosen by the sender and echoed in the response. */
|
|
10
|
+
export type JsonRpcId = string | number;
|
|
11
|
+
|
|
12
|
+
/** Request params: a JSON object (Mostra always uses objects) or an array. */
|
|
13
|
+
export type JsonRpcParams = Readonly<Record<string, unknown>> | readonly unknown[];
|
|
14
|
+
|
|
15
|
+
/** A request: the receiver answers with a response carrying the same `id`. */
|
|
16
|
+
export interface JsonRpcRequest {
|
|
17
|
+
/** Always `"2.0"`. */
|
|
18
|
+
readonly jsonrpc: "2.0";
|
|
19
|
+
/** Chosen by the sender; the response carries the same ID. */
|
|
20
|
+
readonly id: JsonRpcId;
|
|
21
|
+
/** The method name, `group/name` or a bare name. */
|
|
22
|
+
readonly method: string;
|
|
23
|
+
/** The method's params. */
|
|
24
|
+
readonly params?: JsonRpcParams;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A notification: a request without an `id`, which is never answered. */
|
|
28
|
+
export interface JsonRpcNotification {
|
|
29
|
+
/** Always `"2.0"`. */
|
|
30
|
+
readonly jsonrpc: "2.0";
|
|
31
|
+
/** The notification's method name. */
|
|
32
|
+
readonly method: string;
|
|
33
|
+
/** The notification's params. */
|
|
34
|
+
readonly params?: JsonRpcParams;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The error member of a failed response. Mostra puts the diagnostic in `data`. */
|
|
38
|
+
export interface JsonRpcErrorObject {
|
|
39
|
+
/** The JSON-RPC error code (INTERFACES §6). */
|
|
40
|
+
readonly code: number;
|
|
41
|
+
/** A short description; clients switch on `data.code`, never on this text. */
|
|
42
|
+
readonly message: string;
|
|
43
|
+
/** The diagnostic (INTERFACES §13). */
|
|
44
|
+
readonly data?: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A successful response. */
|
|
48
|
+
export interface JsonRpcSuccess {
|
|
49
|
+
/** Always `"2.0"`. */
|
|
50
|
+
readonly jsonrpc: "2.0";
|
|
51
|
+
/** The ID of the request this answers. */
|
|
52
|
+
readonly id: JsonRpcId;
|
|
53
|
+
/** The method's result. */
|
|
54
|
+
readonly result: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A failed response. `id` is `null` when the request's ID couldn't be read. */
|
|
58
|
+
export interface JsonRpcFailure {
|
|
59
|
+
/** Always `"2.0"`. */
|
|
60
|
+
readonly jsonrpc: "2.0";
|
|
61
|
+
/** The ID of the request this answers, or `null` when it couldn't be read. */
|
|
62
|
+
readonly id: JsonRpcId | null;
|
|
63
|
+
/** What went wrong. */
|
|
64
|
+
readonly error: JsonRpcErrorObject;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A response to a request. */
|
|
68
|
+
export type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;
|
|
69
|
+
|
|
70
|
+
/** Any message on a Mostra connection. */
|
|
71
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
72
|
+
|
|
73
|
+
const version = z.literal("2.0");
|
|
74
|
+
const id: z.ZodType<JsonRpcId> = z.union([z.string(), z.number()]);
|
|
75
|
+
const params: z.ZodType<JsonRpcParams> = z.union([
|
|
76
|
+
z.record(z.string(), z.unknown()),
|
|
77
|
+
z.array(z.unknown()).readonly(),
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
/** The Zod schema of the `JsonRpcRequest` type. */
|
|
81
|
+
export const JsonRpcRequest: z.ZodType<JsonRpcRequest> = z
|
|
82
|
+
.object({ jsonrpc: version, id, method: z.string(), params: params.exactOptional() })
|
|
83
|
+
.register(wireRegistry, {
|
|
84
|
+
id: "JsonRpcRequest",
|
|
85
|
+
description: "A JSON-RPC 2.0 request: answered by a response with the same id.",
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/** The Zod schema of the `JsonRpcNotification` type. */
|
|
89
|
+
export const JsonRpcNotification: z.ZodType<JsonRpcNotification> = z
|
|
90
|
+
.object({ jsonrpc: version, method: z.string(), params: params.exactOptional() })
|
|
91
|
+
.register(wireRegistry, {
|
|
92
|
+
id: "JsonRpcNotification",
|
|
93
|
+
description: "A JSON-RPC 2.0 notification: a request without an id, never answered.",
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
/** The Zod schema of the `JsonRpcErrorObject` type. */
|
|
97
|
+
export const JsonRpcErrorObject: z.ZodType<JsonRpcErrorObject> = z
|
|
98
|
+
.object({ code: z.int(), message: z.string(), data: z.unknown().exactOptional() })
|
|
99
|
+
.register(wireRegistry, {
|
|
100
|
+
id: "JsonRpcErrorObject",
|
|
101
|
+
description: "The error of a failed JSON-RPC 2.0 response; Mostra puts the diagnostic in data.",
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/** The Zod schema of the `JsonRpcSuccess` type. */
|
|
105
|
+
export const JsonRpcSuccess: z.ZodType<JsonRpcSuccess> = z
|
|
106
|
+
.object({ jsonrpc: version, id, result: z.unknown() })
|
|
107
|
+
.register(wireRegistry, {
|
|
108
|
+
id: "JsonRpcSuccess",
|
|
109
|
+
description: "A successful JSON-RPC 2.0 response.",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/** The Zod schema of the `JsonRpcFailure` type. */
|
|
113
|
+
export const JsonRpcFailure: z.ZodType<JsonRpcFailure> = z
|
|
114
|
+
.object({ jsonrpc: version, id: id.nullable(), error: JsonRpcErrorObject })
|
|
115
|
+
.register(wireRegistry, {
|
|
116
|
+
id: "JsonRpcFailure",
|
|
117
|
+
description: "A failed JSON-RPC 2.0 response; id is null when the request's id was unreadable.",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/** A message sorted by kind, or the reason it isn't a valid message. */
|
|
121
|
+
export type ClassifiedMessage =
|
|
122
|
+
| { readonly kind: "request"; readonly message: JsonRpcRequest }
|
|
123
|
+
| { readonly kind: "notification"; readonly message: JsonRpcNotification }
|
|
124
|
+
| { readonly kind: "success"; readonly message: JsonRpcSuccess }
|
|
125
|
+
| { readonly kind: "failure"; readonly message: JsonRpcFailure }
|
|
126
|
+
| { readonly kind: "invalid"; readonly reason: string; readonly id: JsonRpcId | null };
|
|
127
|
+
|
|
128
|
+
const isObject = (value: unknown): value is Record<string, unknown> =>
|
|
129
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Sorts a parsed JSON value into a request, notification, success or failure, or explains why it
|
|
133
|
+
* is none of them. A JSON array (a batch) is invalid in revision `2026-10-10` (D83).
|
|
134
|
+
*/
|
|
135
|
+
export function classifyMessage(value: unknown): ClassifiedMessage {
|
|
136
|
+
if (Array.isArray(value)) {
|
|
137
|
+
return {
|
|
138
|
+
kind: "invalid",
|
|
139
|
+
reason: "Batches (JSON arrays) aren't supported in host protocol revision 2026-10-10.",
|
|
140
|
+
id: null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (!isObject(value)) {
|
|
144
|
+
return { kind: "invalid", reason: "A message must be a JSON object.", id: null };
|
|
145
|
+
}
|
|
146
|
+
const rawId = value["id"];
|
|
147
|
+
const readableId = typeof rawId === "string" || typeof rawId === "number" ? rawId : null;
|
|
148
|
+
if (value["jsonrpc"] !== "2.0") {
|
|
149
|
+
return { kind: "invalid", reason: 'A message must have "jsonrpc": "2.0".', id: readableId };
|
|
150
|
+
}
|
|
151
|
+
if ("method" in value) {
|
|
152
|
+
if ("id" in value) {
|
|
153
|
+
const parsed = JsonRpcRequest.safeParse(value);
|
|
154
|
+
return parsed.success
|
|
155
|
+
? { kind: "request", message: parsed.data }
|
|
156
|
+
: { kind: "invalid", reason: describeRequestProblem(value), id: readableId };
|
|
157
|
+
}
|
|
158
|
+
const parsed = JsonRpcNotification.safeParse(value);
|
|
159
|
+
return parsed.success
|
|
160
|
+
? { kind: "notification", message: parsed.data }
|
|
161
|
+
: { kind: "invalid", reason: describeRequestProblem(value), id: null };
|
|
162
|
+
}
|
|
163
|
+
const hasResult = "result" in value;
|
|
164
|
+
const hasError = "error" in value;
|
|
165
|
+
if (hasResult !== hasError && "id" in value) {
|
|
166
|
+
if (hasResult) {
|
|
167
|
+
const parsed = JsonRpcSuccess.safeParse(value);
|
|
168
|
+
if (parsed.success) return { kind: "success", message: parsed.data };
|
|
169
|
+
} else {
|
|
170
|
+
const parsed = JsonRpcFailure.safeParse(value);
|
|
171
|
+
if (parsed.success) return { kind: "failure", message: parsed.data };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
kind: "invalid",
|
|
176
|
+
reason:
|
|
177
|
+
'A message must be a request (with "method") or a response (with "id" and exactly one of "result" and "error").',
|
|
178
|
+
id: readableId,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function describeRequestProblem(value: Record<string, unknown>): string {
|
|
183
|
+
if (typeof value["method"] !== "string") return 'A request\'s "method" must be a string.';
|
|
184
|
+
if ("id" in value && typeof value["id"] !== "string" && typeof value["id"] !== "number") {
|
|
185
|
+
return 'A request\'s "id" must be a string or a number.';
|
|
186
|
+
}
|
|
187
|
+
return 'A request\'s "params" must be an object or an array.';
|
|
188
|
+
}
|