@mostra/runtime 0.9.0 → 0.11.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/dist/bin.js +6628 -9
- package/dist/bin.js.map +1 -1
- package/dist/builder/child/main.js +2 -2
- package/dist/{child-Chiavhdx.js → child-BmNZ4a70.js} +2 -2
- package/dist/{child-Chiavhdx.js.map → child-BmNZ4a70.js.map} +1 -1
- package/dist/deps/child/install.js +1 -1
- package/dist/{directories-mJ1qlVht.js → directories-BLJjeSPD.js} +5 -5
- package/dist/directories-BLJjeSPD.js.map +1 -0
- package/dist/{files-FygSJIzK.js → files-DGeWuE4I.js} +2 -2
- package/dist/{files-FygSJIzK.js.map → files-DGeWuE4I.js.map} +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{instance-EnaZPs14.js → instance-DCiUHvgZ.js} +3835 -255
- package/dist/instance-DCiUHvgZ.js.map +1 -0
- package/dist/reference/cli.md +1322 -0
- package/dist/reference/diagnostics.json +1552 -0
- package/dist/reference/errors/MOSTRA_A11Y_MINOR.md +23 -0
- package/dist/reference/errors/MOSTRA_A11Y_SERIOUS.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_CANCELLED.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_EVENT_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_EXPORT_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_INTERRUPTED.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_PAUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_RUN_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_THREW.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_TOO_LARGE.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_UNKNOWN_FUNCTION.md +23 -0
- package/dist/reference/errors/MOSTRA_ACTION_UNSERIALIZABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_BUNDLE_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_DIR_NOT_EMPTY.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_ENTRY_AMBIGUOUS.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_ID_DROPPED.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_NO_ENTRY.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_NO_PAGE.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_PATCH_REJECTED.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_PATH_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_SOURCE_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_SOURCE_UNREADABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_TEMPLATE_UNKNOWN.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_VERSION_COLLECTED.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_VERSION_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_BUILD_CRASHED.md +23 -0
- package/dist/reference/errors/MOSTRA_BUILD_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_BUILD_TIMEOUT.md +23 -0
- package/dist/reference/errors/MOSTRA_BUILD_UNRESOLVED.md +23 -0
- package/dist/reference/errors/MOSTRA_CLI_CONFIG_UNWRITABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_CLI_UNKNOWN_COMMAND.md +23 -0
- package/dist/reference/errors/MOSTRA_CLI_USAGE.md +23 -0
- package/dist/reference/errors/MOSTRA_CONSOLE_ERROR.md +23 -0
- package/dist/reference/errors/MOSTRA_CONSOLE_WARNING.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_INSTALL_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_OFFLINE.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_SPEC_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_TIMEOUT.md +23 -0
- package/dist/reference/errors/MOSTRA_DEP_WARM_CONFLICT.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_BIND_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_BROWSER_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_BUNDLE_DOWNLOAD_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_BUNDLE_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_BUNDLE_UNAVAILABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_HELPER_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_NODE_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_PORT_TAKEN.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_RUNTIME_INSTALLING.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_RUNTIME_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_SERVICE_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_SHELL_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_ENV_WARM_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_CONFLICT.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_DUPLICATE_ID.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_ID_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_ID_UNSTABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_MUTATION_ID_REUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_SHARED.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_TOO_LARGE.md +23 -0
- package/dist/reference/errors/MOSTRA_FIELD_UNBOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_DISK_FULL.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_GC_INCOMPLETE.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_GONE.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_INTEGRITY.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_LEDGER_UNREADABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_LOCKED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_MISMATCH.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_NETWORK_FILESYSTEM.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_NOT_ALWAYS_ON.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_NOT_OWNED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_SOCKET_TOO_LONG.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_TOO_NEW.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_CONNECTION_CLOSED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_CURSOR_COMPACTED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_IDENTITY_UNAVAILABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_INITIALIZE_ORDER.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_INTERNAL_ERROR.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_INVALID_PARAMS.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_MALFORMED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_MESSAGE_TOO_LARGE.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_METHOD_UNKNOWN.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_NOTIFICATION_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_PORT_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_REQUEST_ID_REUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_REVISION_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_SHUTDOWN_REFUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_SUBSCRIPTION_UNKNOWN.md +23 -0
- package/dist/reference/errors/MOSTRA_HOST_TIMEOUT.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_CONTENT_TYPE.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_CSRF_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_FRAME_SESSION.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_HEADERS_TOO_LARGE.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_HOST_REFUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_NOT_SERVED.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_ORIGIN_REFUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_RATE_LIMITED.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_REQUEST_MALFORMED.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_SCOPE_DENIED.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_SESSION_CONFLICT.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_SESSION_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_TOKEN_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_HYGIENE_TOKEN_REVOKED.md +23 -0
- package/dist/reference/errors/MOSTRA_LIVE_SOURCE_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_LIVE_TOO_LARGE.md +23 -0
- package/dist/reference/errors/MOSTRA_MANIFEST_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_MANIFEST_NOT_LITERAL.md +23 -0
- package/dist/reference/errors/MOSTRA_MANIFEST_UNKNOWN_KEY.md +23 -0
- package/dist/reference/errors/MOSTRA_NETWORK_EXTERNAL_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_NETWORK_REQUEST_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLATFORM_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PUBLISH_ID_CONFLICT.md +23 -0
- package/dist/reference/errors/MOSTRA_PUBLISH_SOURCE_CHANGED.md +23 -0
- package/dist/reference/errors/MOSTRA_PUBLISH_VERIFY_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_REGRESSION_ACTION_REMOVED.md +23 -0
- package/dist/reference/errors/MOSTRA_REGRESSION_ARIA.md +23 -0
- package/dist/reference/errors/MOSTRA_REGRESSION_FIELD_REMOVED.md +23 -0
- package/dist/reference/errors/MOSTRA_REGRESSION_LIVE_REMOVED.md +23 -0
- package/dist/reference/errors/MOSTRA_REGRESSION_PAGE_REMOVED.md +23 -0
- package/dist/reference/errors/MOSTRA_REGRESSION_PIXELS.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_CONFIG_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_HOME_MOVING.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_HOME_SUSPENDED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_LIMIT_REACHED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_LOGIN_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_NOT_OWNER_INSTANCE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_NO_INSTANCE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_OPERATOR_UNAVAILABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_OWNER_OFFLINE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_PAUSED_BY_OPERATOR.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_QUEUE_FULL.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_RATE_LIMITED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_SIGN_IN_REQUIRED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_UNDER_REVIEW.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_UNREACHABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_RUNTIME_BLANK.md +23 -0
- package/dist/reference/errors/MOSTRA_RUNTIME_NOT_READY.md +23 -0
- package/dist/reference/errors/MOSTRA_RUNTIME_PAGE_ERROR.md +23 -0
- package/dist/reference/errors/MOSTRA_RUNTIME_WORKER_CRASHED.md +23 -0
- package/dist/reference/errors/MOSTRA_RUNTIME_WORKER_PARKED.md +23 -0
- package/dist/reference/errors/MOSTRA_SECRET_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_NOT_ENABLED.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_PORTS_EXHAUSTED.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_TOOL_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_TOOL_NOT_READY.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_TTL_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_SHARE_TUNNEL_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_SMOKE_BUDGET.md +23 -0
- package/dist/reference/errors/MOSTRA_SMOKE_NO_EFFECT.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_ALREADY.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_BLOCKED.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_CHANNEL_DENIED.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_PAUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_POLICY_NONE.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_REVISION_MOVED.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_SIGNAL_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_VIEW_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_TARGET_UNAVAILABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_TYPE_ERROR.md +23 -0
- package/dist/reference/errors/MOSTRA_TYPE_UNTYPED_PACKAGE.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_ACTION_SKIPPED.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_BASELINE_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_CRASHED.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_LIVE_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_NO_BASELINE.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_SECRET_MISSING.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_SKIP_CONSEQUENCE.md +23 -0
- package/dist/reference/errors/MOSTRA_VERIFY_TIMEOUT.md +23 -0
- package/dist/reference/self-hosting.md +130 -0
- package/dist/reference/telemetry.md +84 -0
- package/dist/skill/SKILL.md +122 -0
- package/dist/skill/assets/examples/dashboard/index.tsx +161 -0
- package/dist/skill/assets/examples/dashboard/live.ts +25 -0
- package/dist/skill/assets/examples/dashboard/styles.css +125 -0
- package/dist/skill/assets/examples/decision/index.tsx +95 -0
- package/dist/skill/assets/examples/decision/styles.css +125 -0
- package/dist/skill/assets/examples/inbox/actions.ts +23 -0
- package/dist/skill/assets/examples/inbox/index.tsx +109 -0
- package/dist/skill/assets/examples/inbox/styles.css +125 -0
- package/dist/skill/assets/studio.css +125 -0
- package/dist/skill/references/answers.md +217 -0
- package/dist/skill/references/design.md +154 -0
- package/dist/skill/references/libraries.md +167 -0
- package/dist/skill/references/long-lived.md +148 -0
- package/dist/skill/references/mcp.md +68 -0
- package/dist/skill/references/page.md +131 -0
- package/dist/skill/references/server.md +146 -0
- package/dist/skill/references/sharing.md +123 -0
- package/dist/skill/references/verify.md +71 -0
- package/package.json +12 -5
- package/src/actions/index.ts +163 -10
- package/src/bin.ts +78 -1
- package/src/gateway/actions.ts +40 -4
- package/src/gateway/browser.ts +162 -95
- package/src/gateway/capabilities.ts +23 -6
- package/src/gateway/http.ts +12 -1
- package/src/gateway/index.ts +282 -20
- package/src/gateway/listener.ts +31 -6
- package/src/gateway/routes.ts +23 -7
- package/src/gc/index.ts +19 -0
- package/src/instance/index.ts +60 -2
- package/src/interaction/ephemeral.ts +32 -23
- package/src/interaction/events.ts +21 -1
- package/src/interaction/imports.ts +317 -0
- package/src/interaction/index.ts +228 -15
- package/src/interaction/outbox.ts +9 -0
- package/src/interaction/pause.ts +106 -0
- package/src/interaction/results.ts +8 -1
- package/src/interaction/runs.ts +52 -2
- package/src/interaction/submissions.ts +59 -2
- package/src/interaction/tally.ts +129 -0
- package/src/interaction/viewers.ts +34 -1
- package/src/ledger/index.ts +124 -10
- package/src/ledger/migrations.ts +234 -0
- package/src/ledger/types.ts +8 -0
- package/src/link/author.ts +215 -0
- package/src/link/binding.ts +289 -0
- package/src/link/hosted.ts +101 -0
- package/src/link/http.ts +141 -0
- package/src/link/index.ts +10 -0
- package/src/link/manager.ts +1489 -0
- package/src/link/relay.ts +512 -0
- package/src/live/index.ts +112 -2
- package/src/platform/filesystems.ts +78 -0
- package/src/platform/index.ts +1 -0
- package/src/protocol-server/client.ts +53 -0
- package/src/protocol-server/index.ts +19 -2
- package/src/protocol-server/server.ts +38 -7
- package/src/protocol-server/websocket.ts +161 -0
- package/src/publish/bundle.ts +398 -0
- package/src/publish/manifest.ts +9 -0
- package/src/publish/methods.ts +12 -1
- package/src/publish/publisher.ts +127 -0
- package/src/registry/index.ts +35 -14
- package/src/server/api.ts +881 -0
- package/src/server/auth.ts +1139 -0
- package/src/server/authorize.ts +816 -0
- package/src/server/clients.ts +235 -0
- package/src/server/config.ts +228 -0
- package/src/server/data.ts +427 -0
- package/src/server/directory.ts +210 -0
- package/src/server/feed.ts +191 -0
- package/src/server/handle.ts +172 -0
- package/src/server/hosted-pages.ts +532 -0
- package/src/server/hosted.ts +1323 -0
- package/src/server/index.ts +650 -0
- package/src/server/mcp.ts +330 -0
- package/src/server/metering.ts +156 -0
- package/src/server/oauth-clients.ts +510 -0
- package/src/server/operator.ts +498 -0
- package/src/server/providers.ts +284 -0
- package/src/server/relay.ts +1163 -0
- package/src/server/remove.ts +148 -0
- package/src/server/routing.ts +275 -0
- package/src/share/index.ts +110 -6
- package/src/verify/runner.ts +23 -2
- package/dist/directories-mJ1qlVht.js.map +0 -1
- package/dist/instance-EnaZPs14.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Sharing: links, people and devices
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- The link
|
|
6
|
+
- One person, one link
|
|
7
|
+
- The four setups: local, tailnet share, public share, hosted
|
|
8
|
+
- Hosted on a server
|
|
9
|
+
- Behind a public quick tunnel
|
|
10
|
+
- Managing links and shares
|
|
11
|
+
- Moving a version to another machine
|
|
12
|
+
- Asking people well
|
|
13
|
+
|
|
14
|
+
## The link
|
|
15
|
+
|
|
16
|
+
`mostra publish` prints the artifact's **default link**; `mostra open <dir>` prints it again; `--browser` also opens it in this machine's browser (without it, only a terminal opens one), and stderr says when no browser opened. The link is a capability URL: whoever holds it can view, answer, submit and run the page's actions. The secret is after the `#`, so it never reaches a server log, but treat the whole link like a password.
|
|
17
|
+
|
|
18
|
+
The default link doesn't expire and stays the same across versions. It opens on this machine only (`http://127.0.0.1:…`).
|
|
19
|
+
|
|
20
|
+
## One person, one link
|
|
21
|
+
|
|
22
|
+
A link without a named person acts as one person: everyone who holds the default link shares one draft and one `once` submission. When several people should answer, mint one link per person:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
mostra open ./retro --new --viewer ada@example.com --viewer-name "Ada Lovelace" --no-browser
|
|
26
|
+
mostra open ./retro --new --viewer grace@example.com --viewer-name "Grace Hopper" --no-browser
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`--viewer` is your own stable key for the person (an email, a user ID); the same key always means the same person, and results name them. Use `{ policy: "once", scope: "per-viewer" }` so each of them submits once.
|
|
30
|
+
|
|
31
|
+
Other options of `mostra open <dir> --new`: `--ttl 24h` (the link expires), `--scope view` (look but not answer; also `draft`, `submit`, `review`, `signal`, `action:*`), `--version 3` (only that version).
|
|
32
|
+
|
|
33
|
+
## The four setups
|
|
34
|
+
|
|
35
|
+
| Setup | Who can open it | Command |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| **Local** | Only this machine's browser | `mostra open <dir> --browser` |
|
|
38
|
+
| **Tailnet share** | People and devices in your Tailscale network, such as your phone | `mostra share <dir> --tailnet` |
|
|
39
|
+
| **Public share** | Anyone with the link, on any device | `mostra share <dir> --public` |
|
|
40
|
+
| **Hosted** | Anyone with the link, even while this machine sleeps | `mostra share <dir> --cloud` |
|
|
41
|
+
|
|
42
|
+
- **Tailnet share** uses Tailscale Serve. Each person is their tailnet identity, so results name them without `--viewer`. The link doesn't expire unless you give `--ttl`. The output names the two ports the tailnet's access policy must allow, and the viewer's device must run Tailscale.
|
|
43
|
+
- **Public share** uses a Cloudflare quick tunnel by default (no account needed), or Tailscale Funnel with `--via funnel` (the URL shows your device's tailnet name). The link lasts 1 hour unless `--ttl` says otherwise, 7 days at most. Each public link is a visitor of its own: their answers never mix with yours or anyone else's, and results show them as "Shared link" unless you pass `--viewer`.
|
|
44
|
+
- Both drive tools installed on this machine (`tailscale`, `cloudflared`); when one is missing or signed out, the command says how to install or enable it (`MOSTRA_SHARE_TOOL_MISSING`, `MOSTRA_SHARE_TOOL_NOT_READY`, `MOSTRA_SHARE_NOT_ENABLED`).
|
|
45
|
+
- A share keeps Mostra running while it lasts. A quick tunnel can't keep its address across a restart, so a public Cloudflare share ends when Mostra restarts; tailnet and Funnel shares come back.
|
|
46
|
+
|
|
47
|
+
## Hosted on a server
|
|
48
|
+
|
|
49
|
+
`mostra share <dir> --cloud` puts the latest version on a remote server this machine signed in to, and prints a link there. The page keeps taking answers while this machine is off: they wait on the server and reach `mostra wait` and `mostra results` here when Mostra runs again, the same as local answers. Every later `mostra publish` of the artifact goes to the server too.
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
mostra login https://api.example.com # once per machine: open the address it prints and approve the code
|
|
53
|
+
mostra share ./x --cloud # host it there; prints the hosted link
|
|
54
|
+
mostra status # the servers this machine is linked to, and whether they're connected
|
|
55
|
+
mostra logout # sign out; hosted pages keep working, answers wait for the next login
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- The person answering sees "Your answer was sent." once the server has it, and nothing about this machine. You see the delivery states.
|
|
59
|
+
- Only the source, its versions and its secrets stay on this machine; the server holds the built page and what people enter.
|
|
60
|
+
- Several machines can sign in to one account. The one that shared a page receives its answers. `mostra login <server> --default` makes this machine the one pages created from a chat app go to.
|
|
61
|
+
- `mostra share stop` and `mostra share list` include hosted shares.
|
|
62
|
+
- `mostra pause ./x --reason "Closed until Monday"` stops a page taking answers and running actions, here and on every server it's hosted on; it stays viewable, its links keep working, and the draft people typed is kept. `mostra resume ./x` opens it again. A pause the server's operator made can only be lifted by the operator.
|
|
63
|
+
|
|
64
|
+
### Actions on a hosted page
|
|
65
|
+
|
|
66
|
+
A hosted page's actions run on this machine, with its secrets, while it is connected. The manifest's `hosted` key says how they behave on the server:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
export const artifact = defineArtifact({
|
|
70
|
+
title: "Proposal",
|
|
71
|
+
hosted: {
|
|
72
|
+
actions: "link", // who may press them: "signed-in" (default) or anyone with the link
|
|
73
|
+
offline: { actions: "queue", limit: "24h" }, // while this machine is off: wait ("queue", default) or fail at once ("fail")
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- By default only people the link names (`--viewer`) or who signed in may run actions; `actions: "link"` lets anyone with the link run them.
|
|
79
|
+
- While this machine is off, a pressed action waits: `useAction`'s `status` is `"waiting"`, and it runs once, in order, when Mostra runs here again. Past `limit` (at most `7d`) a run that never started fails. Under `"fail"` it fails at once.
|
|
80
|
+
- If the connection drops while an action runs and this machine never reports how it ended within the limit, its `status` becomes `"unknown"`: it may have happened, so show that rather than "failed". `run()` rejects with `MOSTRA_REMOTE_OWNER_OFFLINE`; the real end replaces `unknown` if it arrives later.
|
|
81
|
+
- A plain server function (called directly, not through `useAction`) answers `MOSTRA_REMOTE_OWNER_OFFLINE` while this machine is off.
|
|
82
|
+
- Live values show the last value, with `ownerOffline` set, while this machine is off.
|
|
83
|
+
|
|
84
|
+
## Behind a public quick tunnel
|
|
85
|
+
|
|
86
|
+
Over a Cloudflare quick tunnel the page runs in a slightly different mode, and nothing in your code needs to change for it:
|
|
87
|
+
|
|
88
|
+
- updates arrive by polling rather than streaming, so other people's edits and live values show up a second or two later;
|
|
89
|
+
- a streamed result (an async iterable) arrives in one piece at the end;
|
|
90
|
+
- the page can't register a service worker of its own (`MOSTRA_HYGIENE_FRAME_SESSION`).
|
|
91
|
+
|
|
92
|
+
## Managing links and shares
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
mostra share list # active shares, with their links
|
|
96
|
+
mostra share list --all # ended ones too, and why
|
|
97
|
+
mostra share stop <shareId> # or the artifact, for all of its shares; the link stops working
|
|
98
|
+
mostra open ./x --rotate <tokenId> # replace a link that leaked; the old one stops working
|
|
99
|
+
mostra open ./x --revoke <tokenId> # stop a link
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`--json` output carries each link's `tokenId`.
|
|
103
|
+
|
|
104
|
+
## Moving a version to another machine
|
|
105
|
+
|
|
106
|
+
A published version can move whole to another Mostra home, where it is the same version with the same IDs, and its actions run there:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
mostra export ./x --out ./x.tar.zst # the latest version; --version 2 for another
|
|
110
|
+
mostra run ./x.tar.zst # on the other machine: imports it and prints its link
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The bundle holds the version's builds, manifest, lockfile and source, never secrets: set the secrets its actions read on the other machine with `mostra secret set`. Answers stay in the home where people gave them.
|
|
114
|
+
|
|
115
|
+
## Asking people well
|
|
116
|
+
|
|
117
|
+
The link arrives as a message from you, so write it like one:
|
|
118
|
+
|
|
119
|
+
- Say who is asking and why ("I'm the coding agent working on the checkout redesign; I need your call between two layouts").
|
|
120
|
+
- Say what the page asks of them and how long it takes.
|
|
121
|
+
- Give a real deadline only if there is one.
|
|
122
|
+
- Ask for no passwords, keys or codes on a page; collect secrets through `mostra secret set` instead.
|
|
123
|
+
- Post a link somewhere public only if the page is meant for anyone.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Verify: the verdict, screenshots and the dev preview
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- What verify does
|
|
6
|
+
- Reading the verdict
|
|
7
|
+
- Errors, warnings and hints
|
|
8
|
+
- Screenshots and the ARIA snapshot
|
|
9
|
+
- Regressions between versions
|
|
10
|
+
- Publish and verify
|
|
11
|
+
- The dev preview: `mostra dev`
|
|
12
|
+
|
|
13
|
+
## What verify does
|
|
14
|
+
|
|
15
|
+
`mostra verify <dir>` checks the artifact's current source without publishing it, in a sandbox that touches no one's answers and calls no host:
|
|
16
|
+
|
|
17
|
+
1. **prepare** and **compile**: reads the manifest, resolves and installs packages, type-checks (TypeScript in strict mode, or with the artifact's own `tsconfig.json` settings), builds.
|
|
18
|
+
2. **boot** and **render**: opens the page in a headless Chromium at 1280 × 800 and 390 × 844, with a fixed clock and reduced motion, waits until it's still (and until the calls, runs and live values it loads at mount have arrived), records page errors, console errors and failed requests, runs axe, takes an ARIA snapshot and a screenshot per size.
|
|
19
|
+
3. **smoke**: clicks and types through the page's controls (up to 200 interactions or 60 s), checking that each does something and that nothing breaks. Server functions run only when they opt in through `dryRun()` ([server.md](server.md)); live sources run for real, and secrets resolve as they would.
|
|
20
|
+
4. **regression**: compares with the last published version that passed ([below](#regressions-between-versions)).
|
|
21
|
+
|
|
22
|
+
It takes 10 to 30 s.
|
|
23
|
+
|
|
24
|
+
## Reading the verdict
|
|
25
|
+
|
|
26
|
+
The human output prints `verify: pass` or `verify: fail`, each diagnostic with its hint, and the screenshots worth looking at. Exit code 0 is pass, 1 is fail. With `--json`, the result is:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"status": "pass",
|
|
31
|
+
"artifact": { "id": "art_…", "path": "…", "sourceDigest": "…", "envDigest": "…", "versionId": "ver_…" },
|
|
32
|
+
"diagnostics": [{ "code": "MOSTRA_…", "severity": "error", "message": "…", "hint": "…", "location": { "file": "index.tsx", "line": 12, "column": 7 }, "docs": "…" }],
|
|
33
|
+
"screenshots": [{ "viewport": "desktop", "path": "…/desktop.png", "width": 1280, "height": 800, "tokensEstimate": { "claude": 1334, "gpt": 1200, "gemini": 1120 }, "returned": false }],
|
|
34
|
+
"aria": [{ "viewport": "desktop", "path": "…/desktop.aria.yml", "summary": "3 headings, 1 button, 1 textbox, landmarks: main" }],
|
|
35
|
+
"smoke": { "interactions": 3, "skippedActions": [], "stateChanges": 3 },
|
|
36
|
+
"regressions": {},
|
|
37
|
+
"timingsMs": { "build": 36, "typecheck": 538, "render": 9548, "smoke": 2492, "total": 13898 }
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`status` is `fail` exactly when there is an error. Diagnostics come errors first; identical ones fold into one with a `count`. `mostra docs <CODE>` prints any code's page with an example fix.
|
|
42
|
+
|
|
43
|
+
## Errors, warnings and hints
|
|
44
|
+
|
|
45
|
+
| Severity | Means | Examples |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| error | Something is definitely broken; publish refuses it | type and build errors, uncaught page errors, console errors, failed requests to the page's own origin, a blank page, a page that never gets ready, duplicate or unstable field IDs, a manifest that can't be read |
|
|
48
|
+
| warning | Worth checking; publish allows it | axe's serious findings, failed requests to other sites, a failing live source, a package without types, a secret the page needed that isn't set, every regression, a control with no visible effect |
|
|
49
|
+
| hint | Information | an input not bound to a field (`MOSTRA_FIELD_UNBOUND`, fine for a search box or a draft you don't want saved), an action skipped in verify, axe's minor findings, the smoke test's budget, no baseline yet |
|
|
50
|
+
|
|
51
|
+
Warnings that begin with **"Observed only"** (`MOSTRA_SMOKE_NO_EFFECT`, `MOSTRA_REGRESSION_*`) report what verify saw, such as a button whose click changed nothing visible or a page that changed since the last version. Look at the screenshot and decide; when the behavior is what you intended, change nothing.
|
|
52
|
+
|
|
53
|
+
Fix errors at their location, run verify again, and repeat until it passes. Fix the first error first: later ones are often its consequences.
|
|
54
|
+
|
|
55
|
+
## Screenshots and the ARIA snapshot
|
|
56
|
+
|
|
57
|
+
Screenshots are always taken. `--screenshots on-failure` (the default) marks them `returned` only when verify fails; `always` marks them every time; `never` never does. The human output lists the returned ones. **Look at them before you publish**, on every round: verify can't tell you that the page looks wrong, only that it works. The design checks in [design.md](design.md#reading-your-screenshots) say what to look for.
|
|
58
|
+
|
|
59
|
+
The ARIA snapshot (`.aria.yml`) is the page as a screen reader sees it: headings, buttons, inputs and their names. Read it when you can't look at images: it shows what text and controls the page actually rendered.
|
|
60
|
+
|
|
61
|
+
## Regressions between versions
|
|
62
|
+
|
|
63
|
+
From the second version on, verify renders the last published version that passed, in the same run, and compares: the ARIA snapshot, the pixels at each size, and the contract (fields, actions, live sources and pages that disappeared). A field you removed leaves people's answers behind, so `MOSTRA_REGRESSION_FIELD_REMOVED` is worth a second look; a layout change you made on purpose is expected.
|
|
64
|
+
|
|
65
|
+
## Publish and verify
|
|
66
|
+
|
|
67
|
+
`mostra publish` reuses the verdict of the same source, or runs verify itself. It refuses a source whose verdict has errors (`MOSTRA_PUBLISH_VERIFY_FAILED`). `--force` publishes anyway and records the failing codes on the version; it never publishes a source that didn't build. Use it only when you know why the error doesn't matter. When the headless browser isn't available (`MOSTRA_ENV_BROWSER_MISSING`), verify still type-checks and builds, and the code's page says how to install the browser.
|
|
68
|
+
|
|
69
|
+
## The dev preview: `mostra dev`
|
|
70
|
+
|
|
71
|
+
`mostra dev <dir>` serves the unpublished source with hot reload on this machine until Ctrl-C, and prints a link. Edits appear in the browser as you save; changed server code restarts its worker. Answers and submissions there go to a scratch store that's thrown away, and actions run for real with the real secrets. Nobody but you sees it: use it while building, then verify and publish.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "The Mostra runtime: the supervisor that owns a home, its ledger, its child processes and the host protocol server (mostra-runtime host|daemon).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -36,12 +36,14 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@hono/node-server": "2.1.5",
|
|
38
38
|
"@mdx-js/mdx": "3.1.1",
|
|
39
|
-
"@mostra/
|
|
39
|
+
"@mostra/mcp": "0.11.0",
|
|
40
|
+
"@mostra/protocol": "0.11.0",
|
|
40
41
|
"@tailwindcss/vite": "4.3.3",
|
|
41
42
|
"@vitejs/plugin-react": "6.1.2",
|
|
42
43
|
"better-sqlite3": "13.0.3",
|
|
43
44
|
"hono": "4.13.13",
|
|
44
45
|
"ignore": "7.0.13",
|
|
46
|
+
"openid-client": "6.8.8",
|
|
45
47
|
"oxc-parser": "0.155.0",
|
|
46
48
|
"pnpm": "10.34.7",
|
|
47
49
|
"remark-frontmatter": "5.0.0",
|
|
@@ -50,18 +52,23 @@
|
|
|
50
52
|
"tailwindcss": "4.3.3",
|
|
51
53
|
"typescript": "7.0.2",
|
|
52
54
|
"vite": "8.3.4",
|
|
55
|
+
"ws": "8.22.0",
|
|
53
56
|
"yaml": "2.9.1",
|
|
54
57
|
"zod": "4.6.7"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
57
|
-
"@
|
|
60
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
61
|
+
"@modelcontextprotocol/conformance": "0.1.16",
|
|
62
|
+
"@modelcontextprotocol/conformance-next": "npm:@modelcontextprotocol/conformance@0.2.0-alpha.12",
|
|
63
|
+
"@mostra/shell": "0.11.0",
|
|
58
64
|
"@mostra/tools": "0.0.0",
|
|
59
|
-
"@mostra/verify": "0.
|
|
65
|
+
"@mostra/verify": "0.11.0",
|
|
60
66
|
"@mostra/warm": "0.0.0",
|
|
61
|
-
"@mostra/worker": "0.
|
|
67
|
+
"@mostra/worker": "0.11.0",
|
|
62
68
|
"@types/better-sqlite3": "9.6.0",
|
|
63
69
|
"@types/node": "24.19.2",
|
|
64
70
|
"@types/semver": "7.8.0",
|
|
71
|
+
"@types/ws": "8.18.2",
|
|
65
72
|
"fast-check": "4.10.2",
|
|
66
73
|
"playwright": "1.64.1",
|
|
67
74
|
"tsdown": "0.23.1",
|
package/src/actions/index.ts
CHANGED
|
@@ -62,8 +62,32 @@ export interface ActionsOptions {
|
|
|
62
62
|
/** Told about each refused function, for the verdict's `skippedActions`. */
|
|
63
63
|
readonly skipped: (fnId: string) => void;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* A hosted artifact's shared state, which lives on its hosted home (D165 item 1): server code's
|
|
67
|
+
* `state` reads and writes it there, refused with `MOSTRA_REMOTE_UNREACHABLE` when it can't be
|
|
68
|
+
* reached, never applied here alone. `undefined` for an artifact that isn't hosted.
|
|
69
|
+
*/
|
|
70
|
+
readonly hostedState?: (artifactId: string) => HostedState | undefined;
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
/** A hosted artifact's shared state on its hosted home. */
|
|
74
|
+
export interface HostedState {
|
|
75
|
+
get(ids: readonly string[] | undefined): Promise<unknown>;
|
|
76
|
+
patch(input: {
|
|
77
|
+
readonly ops: unknown;
|
|
78
|
+
readonly mutationId?: string | undefined;
|
|
79
|
+
readonly baseRevision?: string | undefined;
|
|
80
|
+
readonly runId?: string | undefined;
|
|
81
|
+
}): Promise<unknown>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Where a relayed run's or call's signals and host events go: its hosted home (D165 item 4). */
|
|
85
|
+
export type RelayedEffect = (
|
|
86
|
+
kind: "signal" | "emit",
|
|
87
|
+
name: string,
|
|
88
|
+
payload: unknown,
|
|
89
|
+
) => Promise<string>;
|
|
90
|
+
|
|
67
91
|
/** Plain calls and action runs, and the bridge workers ask through. */
|
|
68
92
|
export interface Actions {
|
|
69
93
|
/**
|
|
@@ -105,6 +129,51 @@ export interface Actions {
|
|
|
105
129
|
recover(): void;
|
|
106
130
|
/** How many runs and calls are in flight: the daemon stays while any are (D62). */
|
|
107
131
|
activity(): number;
|
|
132
|
+
/**
|
|
133
|
+
* Runs a relayed run a hosted home recorded and this instance recorded under the same ID
|
|
134
|
+
* (D165 item 4), in this instance's pool with its secrets, telling `observer` what it does so
|
|
135
|
+
* the owner's link reports it back. Starts nothing for a run that is running or has ended.
|
|
136
|
+
*/
|
|
137
|
+
runRelayed(runId: string, extra: RelayedRun): void;
|
|
138
|
+
/** Cancels a relayed run: its `abortSignal` fires if it runs (AC-04). */
|
|
139
|
+
cancelRelayed(runId: string): void;
|
|
140
|
+
/** A relayed plain call (D165 item 4): no record, its lines as they come. */
|
|
141
|
+
callRelayed(
|
|
142
|
+
input: {
|
|
143
|
+
readonly versionId: string;
|
|
144
|
+
readonly fnId: string;
|
|
145
|
+
readonly args: Batches;
|
|
146
|
+
readonly viewer?: { readonly id: string; readonly name?: string } | undefined;
|
|
147
|
+
readonly viewId?: string | undefined;
|
|
148
|
+
readonly effect?: RelayedEffect | undefined;
|
|
149
|
+
},
|
|
150
|
+
signal: AbortSignal,
|
|
151
|
+
): Promise<AsyncIterable<CallLine>>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** What a relayed run's execution tells the owner's link (D165 item 4). */
|
|
155
|
+
export interface RunObserver {
|
|
156
|
+
/** Its worker has it. */
|
|
157
|
+
running(): void;
|
|
158
|
+
/** What it produced since the last flush, as kept. */
|
|
159
|
+
output(flush: {
|
|
160
|
+
readonly logFrom: number;
|
|
161
|
+
readonly log: readonly string[];
|
|
162
|
+
readonly batchFrom: number;
|
|
163
|
+
readonly batches: Batches;
|
|
164
|
+
readonly progress?: RunProgress;
|
|
165
|
+
}): void;
|
|
166
|
+
/** How it ended. */
|
|
167
|
+
ended(state: RunState): void;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** A relayed run's context: the hosted viewer server code sees, and who hears of its output. */
|
|
171
|
+
export interface RelayedRun {
|
|
172
|
+
readonly viewer?: { readonly id: string; readonly name?: string } | undefined;
|
|
173
|
+
readonly viewId?: string | undefined;
|
|
174
|
+
readonly observer: RunObserver;
|
|
175
|
+
/** Where its signals and host events go. */
|
|
176
|
+
readonly effect?: RelayedEffect;
|
|
108
177
|
}
|
|
109
178
|
|
|
110
179
|
/** A run this instance is executing. */
|
|
@@ -129,6 +198,9 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
129
198
|
const callRuns = new Map<string, string>();
|
|
130
199
|
/** Why a run's worker stopped under it, until its `execute` ends it. */
|
|
131
200
|
const crashCauses = new Map<string, string>();
|
|
201
|
+
/** Where relayed runs' and calls' effects go: by run ID, and by worker call ID. */
|
|
202
|
+
const runEffects = new Map<string, RelayedEffect>();
|
|
203
|
+
const callEffects = new Map<string, RelayedEffect>();
|
|
132
204
|
let calls = 0;
|
|
133
205
|
|
|
134
206
|
const redact = (text: string): string => options.redactor.redact(text);
|
|
@@ -191,7 +263,9 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
191
263
|
bus.publishRun(artifactId, { kind: "run", run });
|
|
192
264
|
|
|
193
265
|
/** Runs a recorded run in its version's worker, writing its output as it comes. */
|
|
194
|
-
const execute = async (row: RunRow): Promise<void> => {
|
|
266
|
+
const execute = async (row: RunRow, relayed?: RelayedRun): Promise<void> => {
|
|
267
|
+
const observer = relayed?.observer;
|
|
268
|
+
if (relayed?.effect) runEffects.set(row.id, relayed.effect);
|
|
195
269
|
const entry: Executing = { cancelled: false };
|
|
196
270
|
executing.set(row.id, entry);
|
|
197
271
|
let pendingLines: string[] = [];
|
|
@@ -217,6 +291,13 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
217
291
|
pendingProgress = undefined;
|
|
218
292
|
const written = interaction.runOutput(row.id, output);
|
|
219
293
|
if (!written) return;
|
|
294
|
+
observer?.output({
|
|
295
|
+
logFrom: written.logFrom,
|
|
296
|
+
log: written.log,
|
|
297
|
+
batchFrom: written.batchFrom,
|
|
298
|
+
batches: written.batches,
|
|
299
|
+
...(progress ? { progress } : {}),
|
|
300
|
+
});
|
|
220
301
|
publish(row.artifact_id, {
|
|
221
302
|
runId: row.id,
|
|
222
303
|
status: "running",
|
|
@@ -242,6 +323,7 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
242
323
|
...(error ? { error: redactError(error) } : {}),
|
|
243
324
|
});
|
|
244
325
|
if (state) {
|
|
326
|
+
observer?.ended(state);
|
|
245
327
|
publish(row.artifact_id, {
|
|
246
328
|
runId: row.id,
|
|
247
329
|
status: state.status,
|
|
@@ -283,6 +365,7 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
283
365
|
return;
|
|
284
366
|
}
|
|
285
367
|
interaction.runRunning(row.id);
|
|
368
|
+
observer?.running();
|
|
286
369
|
publish(row.artifact_id, {
|
|
287
370
|
runId: row.id,
|
|
288
371
|
status: "running",
|
|
@@ -291,7 +374,10 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
291
374
|
batchFrom: 0,
|
|
292
375
|
batches: [],
|
|
293
376
|
});
|
|
294
|
-
|
|
377
|
+
// A relayed run acts for the hosted home's viewer, who has no row here (D165 item 4).
|
|
378
|
+
const viewer =
|
|
379
|
+
relayed?.viewer ?? (row.viewer_id ? interaction.viewer(row.viewer_id) : undefined);
|
|
380
|
+
const viewId = relayed?.viewId ?? row.view_id ?? undefined;
|
|
295
381
|
const { callId, outcome } = handle.call(
|
|
296
382
|
{
|
|
297
383
|
fnId: row.action,
|
|
@@ -299,7 +385,7 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
299
385
|
context: {
|
|
300
386
|
kind: "run",
|
|
301
387
|
runId: row.id,
|
|
302
|
-
...(
|
|
388
|
+
...(viewId ? { viewId } : {}),
|
|
303
389
|
...(viewer
|
|
304
390
|
? { viewer: { id: viewer.id, ...(viewer.name ? { name: viewer.name } : {}) } }
|
|
305
391
|
: {}),
|
|
@@ -376,17 +462,24 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
376
462
|
});
|
|
377
463
|
} finally {
|
|
378
464
|
executing.delete(row.id);
|
|
465
|
+
runEffects.delete(row.id);
|
|
379
466
|
}
|
|
380
467
|
};
|
|
381
468
|
|
|
382
469
|
/** A plain call's lines, from a worker that has it. */
|
|
383
470
|
async function* stream(
|
|
384
|
-
|
|
385
|
-
|
|
471
|
+
caller: {
|
|
472
|
+
readonly viewer?: { readonly id: string; readonly name?: string } | undefined;
|
|
473
|
+
/** The local viewer whose call raises its signals, if it is one of this home's. */
|
|
474
|
+
readonly viewerId?: string | undefined;
|
|
475
|
+
/** A relayed call's effects go to its hosted home. */
|
|
476
|
+
readonly effect?: RelayedEffect | undefined;
|
|
477
|
+
},
|
|
478
|
+
input: { readonly viewId?: string | undefined; readonly fnId: string; readonly args: Batches },
|
|
386
479
|
signal: AbortSignal,
|
|
387
480
|
handle: WorkerHandle,
|
|
388
481
|
): AsyncGenerator<CallLine> {
|
|
389
|
-
const viewer =
|
|
482
|
+
const viewer = caller.viewer;
|
|
390
483
|
const queue: CallLine[] = [];
|
|
391
484
|
let wake: (() => void) | undefined;
|
|
392
485
|
let size = 0;
|
|
@@ -397,11 +490,13 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
397
490
|
args: input.args,
|
|
398
491
|
context: {
|
|
399
492
|
kind: "call",
|
|
400
|
-
viewId: input.viewId,
|
|
401
|
-
|
|
493
|
+
...(input.viewId !== undefined ? { viewId: input.viewId } : {}),
|
|
494
|
+
...(viewer
|
|
495
|
+
? { viewer: { id: viewer.id, ...(viewer.name ? { name: viewer.name } : {}) } }
|
|
496
|
+
: {}),
|
|
402
497
|
dryRun: options.dryRun !== undefined,
|
|
403
498
|
},
|
|
404
|
-
viewerId:
|
|
499
|
+
...(caller.viewerId !== undefined ? { viewerId: caller.viewerId } : {}),
|
|
405
500
|
},
|
|
406
501
|
{
|
|
407
502
|
onBatch(batch) {
|
|
@@ -419,6 +514,7 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
419
514
|
},
|
|
420
515
|
);
|
|
421
516
|
calls += 1;
|
|
517
|
+
if (caller.effect) callEffects.set(callId, caller.effect);
|
|
422
518
|
const abort = (): void => handle.cancel(callId, "The page went away.");
|
|
423
519
|
signal.addEventListener("abort", abort, { once: true });
|
|
424
520
|
let ended: CallLine | undefined;
|
|
@@ -485,6 +581,7 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
485
581
|
}
|
|
486
582
|
} finally {
|
|
487
583
|
calls -= 1;
|
|
584
|
+
callEffects.delete(callId);
|
|
488
585
|
signal.removeEventListener("abort", abort);
|
|
489
586
|
// A reader that stopped early (the response failed) leaves nothing running.
|
|
490
587
|
if (!ended) handle.cancel(callId, "The page went away.");
|
|
@@ -494,6 +591,10 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
494
591
|
const bridge: Actions["bridge"] = {
|
|
495
592
|
async request(worker, method, params, call) {
|
|
496
593
|
const runId = call?.context.runId;
|
|
594
|
+
const relayedEffect =
|
|
595
|
+
(runId !== undefined ? runEffects.get(runId) : undefined) ??
|
|
596
|
+
(call ? callEffects.get(call.callId) : undefined);
|
|
597
|
+
const hosted = options.hostedState?.(worker.artifactId);
|
|
497
598
|
switch (method) {
|
|
498
599
|
case WORKER_METHODS.secret: {
|
|
499
600
|
const { name } = ServerSecretParams.parse(params);
|
|
@@ -501,6 +602,16 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
501
602
|
}
|
|
502
603
|
case WORKER_METHODS.signal: {
|
|
503
604
|
const parsed = ServerSignalParams.parse(params);
|
|
605
|
+
// A relayed run's signal goes to its hosted home, without a secret (AC-06).
|
|
606
|
+
if (relayedEffect) {
|
|
607
|
+
return {
|
|
608
|
+
cursor: await relayedEffect(
|
|
609
|
+
"signal",
|
|
610
|
+
parsed.name,
|
|
611
|
+
redactValue(parsed.payload, options.redactor),
|
|
612
|
+
),
|
|
613
|
+
};
|
|
614
|
+
}
|
|
504
615
|
return {
|
|
505
616
|
cursor: interaction.serverSignal(worker.artifactId, {
|
|
506
617
|
name: parsed.name,
|
|
@@ -518,6 +629,15 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
518
629
|
`${parsed.type.slice(0, 80)} isn't a host event type.`,
|
|
519
630
|
);
|
|
520
631
|
}
|
|
632
|
+
if (relayedEffect) {
|
|
633
|
+
return {
|
|
634
|
+
cursor: await relayedEffect(
|
|
635
|
+
"emit",
|
|
636
|
+
parsed.type,
|
|
637
|
+
redactValue(parsed.payload, options.redactor),
|
|
638
|
+
),
|
|
639
|
+
};
|
|
640
|
+
}
|
|
521
641
|
return {
|
|
522
642
|
cursor: interaction.serverEmit(worker.artifactId, {
|
|
523
643
|
type: parsed.type,
|
|
@@ -529,10 +649,19 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
529
649
|
}
|
|
530
650
|
case WORKER_METHODS.stateGet: {
|
|
531
651
|
const parsed = ServerStateGetParams.parse(params);
|
|
652
|
+
if (hosted) return hosted.get(parsed.ids);
|
|
532
653
|
return interaction.serverState(worker.artifactId, parsed.ids);
|
|
533
654
|
}
|
|
534
655
|
case WORKER_METHODS.statePatch: {
|
|
535
656
|
const parsed = ServerStatePatchParams.parse(params);
|
|
657
|
+
if (hosted) {
|
|
658
|
+
return hosted.patch({
|
|
659
|
+
ops: redactValue(parsed.ops, options.redactor),
|
|
660
|
+
mutationId: parsed.mutationId,
|
|
661
|
+
baseRevision: parsed.baseRevision,
|
|
662
|
+
runId,
|
|
663
|
+
});
|
|
664
|
+
}
|
|
536
665
|
return interaction.serverPatch(worker.artifactId, {
|
|
537
666
|
ops: redactValue(parsed.ops, options.redactor),
|
|
538
667
|
...(parsed.mutationId !== undefined ? { mutationId: parsed.mutationId } : {}),
|
|
@@ -554,7 +683,8 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
554
683
|
checkArgs(input.args);
|
|
555
684
|
const versionId = interaction.viewVersion(page, input.viewId);
|
|
556
685
|
const handle = await pool.acquire(functionOf(versionId, input.fnId));
|
|
557
|
-
|
|
686
|
+
const viewer = interaction.viewer(page.viewerId);
|
|
687
|
+
return stream({ viewer, viewerId: page.viewerId }, input, signal, handle);
|
|
558
688
|
},
|
|
559
689
|
|
|
560
690
|
startRun(page, input) {
|
|
@@ -618,5 +748,28 @@ export function createActions(options: ActionsOptions): Actions {
|
|
|
618
748
|
activity() {
|
|
619
749
|
return executing.size + calls;
|
|
620
750
|
},
|
|
751
|
+
|
|
752
|
+
runRelayed(runId, relayed) {
|
|
753
|
+
if (executing.has(runId)) return;
|
|
754
|
+
const state = interaction.runState(runId);
|
|
755
|
+
if (!state || (state.status !== "queued" && state.status !== "waiting")) return;
|
|
756
|
+
const row = interaction.runRow(runId);
|
|
757
|
+
if (row) void execute(row, relayed);
|
|
758
|
+
},
|
|
759
|
+
|
|
760
|
+
cancelRelayed(runId) {
|
|
761
|
+
const running = executing.get(runId);
|
|
762
|
+
if (!running) return;
|
|
763
|
+
running.cancelled = true;
|
|
764
|
+
if (running.handle && running.callId) {
|
|
765
|
+
running.handle.cancel(running.callId, "Cancelled from a hosted page.");
|
|
766
|
+
} else running.endNow?.();
|
|
767
|
+
},
|
|
768
|
+
|
|
769
|
+
async callRelayed(input, signal) {
|
|
770
|
+
checkArgs(input.args);
|
|
771
|
+
const handle = await pool.acquire(functionOf(input.versionId, input.fnId));
|
|
772
|
+
return stream({ viewer: input.viewer, effect: input.effect }, input, signal, handle);
|
|
773
|
+
},
|
|
621
774
|
};
|
|
622
775
|
}
|