@mostra/cli 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 +2 -2
- package/dist/bootstrap-BStzS_41.js +1 -0
- package/dist/{bootstrap-Dc-SQHRF.js → bootstrap-_iCl_HaO.js} +3 -2
- package/dist/bootstrap-_iCl_HaO.js.map +1 -0
- package/dist/{flush-C16w3JL8.js → flush-D648gCYs.js} +12 -3
- package/dist/flush-D648gCYs.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/reference/cli.md +210 -4
- package/dist/reference/diagnostics.json +171 -0
- package/dist/reference/errors/MOSTRA_ACTION_PAUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_BUNDLE_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_NETWORK_FILESYSTEM.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_SUBMIT_PAUSED.md +23 -0
- package/dist/reference/self-hosting.md +130 -0
- package/dist/run-Bpg_ZRY8.js +1 -0
- package/dist/{run-DdYT3iHQ.js → run-BxYL-DaX.js} +333 -225
- package/dist/run-BxYL-DaX.js.map +1 -0
- package/dist/skill/SKILL.md +5 -3
- package/dist/skill/references/answers.md +36 -0
- package/dist/skill/references/mcp.md +9 -4
- package/dist/skill/references/sharing.md +55 -4
- package/dist/telemetry/flush-main.js +1 -1
- package/package.json +5 -5
- package/src/client.ts +1 -1
- package/src/commands/admin.ts +13 -3
- package/src/commands/authoring.ts +85 -3
- package/src/commands/index.ts +18 -3
- package/src/commands/remote.ts +209 -0
- package/src/commands/sharing.ts +33 -6
- package/src/commands/viewing.ts +20 -2
- package/src/detached.ts +3 -0
- package/src/docs.ts +12 -217
- package/src/exit.ts +2 -0
- package/src/mcp.ts +3 -21
- package/src/telemetry/store.ts +15 -4
- package/dist/bootstrap-Dc-SQHRF.js.map +0 -1
- package/dist/bootstrap-aaE5wFo9.js +0 -1
- package/dist/flush-C16w3JL8.js.map +0 -1
- package/dist/run-Bw4_6kcW.js +0 -1
- package/dist/run-DdYT3iHQ.js.map +0 -1
package/dist/skill/SKILL.md
CHANGED
|
@@ -4,7 +4,7 @@ description: Communicate visually with the user through Mostra. Use whenever sho
|
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
compatibility: Needs a shell that runs `mostra` (or `npx` with Node.js 22.19 or later) on macOS, Linux or Windows, x64 or arm64.
|
|
6
6
|
metadata:
|
|
7
|
-
version: "0.
|
|
7
|
+
version: "0.11.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# Mostra
|
|
@@ -13,10 +13,12 @@ Mostra turns a React page you write into an **artifact**: a web page a person op
|
|
|
13
13
|
|
|
14
14
|
## Running Mostra
|
|
15
15
|
|
|
16
|
-
Run `mostra <command>`. When `mostra` isn't on the `PATH`, run `npx -y @mostra/cli@0.
|
|
16
|
+
Run `mostra <command>`. When `mostra` isn't on the `PATH`, run `npx -y @mostra/cli@0.11.0 <command>` everywhere this Skill says `mostra`; the first run downloads Mostra's own runtime (no global Node.js needed beyond `npx`). Every command takes `--json` (one JSON envelope on stdout, logs on stderr) and `--help`. `mostra docs <topic>` prints the reference, including every diagnostic code's page (`mostra docs MOSTRA_FIELD_DUPLICATE_ID`). `mostra list` lists the artifacts you've published, and `mostra status` shows the running instance.
|
|
17
17
|
|
|
18
18
|
When Mostra's tools are in your tool list (`artifact_create`, `artifact_verify` and the rest), use them instead: each step below has its tool, and everything else here holds unchanged. See [references/mcp.md](references/mcp.md).
|
|
19
19
|
|
|
20
|
+
A link that starts with `http://127.0.0.1` opens only on the computer Mostra runs on. When you run in a cloud sandbox (a chat app's code execution, a remote container), the person can't open it: use Mostra's tools from a connector when you have them, and otherwise say so and offer to share the page ([references/sharing.md](references/sharing.md)).
|
|
21
|
+
|
|
20
22
|
## Words
|
|
21
23
|
|
|
22
24
|
| Word | Meaning |
|
|
@@ -57,7 +59,7 @@ Each step ends when its check holds. Don't hand a link out before step 4 passes.
|
|
|
57
59
|
Mostra draws the Submit button in its own frame around your page; `useSubmitControl` names it, and `required` fields block it until they're answered. Make it look considered: [references/design.md](references/design.md) has a baseline stylesheet and the rules for pages people answer. *Done when* every answer you need is a field with a label.
|
|
58
60
|
4. **Verify until it passes.** `mostra verify <dir> --screenshots always`. It type-checks, builds, renders the page headlessly, clicks through it, runs an accessibility check and screenshots it at 1280×800 and 390×844. Fix every error, then **open both screenshots and look at them** (about 1,300 and 450 image tokens). Warnings that start with "Observed only" describe what verify saw; judge them, and leave working code alone. *Done when* the status is `pass` and the screenshots show what you meant at both sizes. More in [references/verify.md](references/verify.md).
|
|
59
61
|
5. **Publish.** `mostra publish <dir>` prints the version and the capability URL. Publishing again after an edit makes a new version; open pages offer the person the new one, and answers carry over by field ID. *Done when* you have the link.
|
|
60
|
-
6. **Hand the link over.** Say who is asking and why, what the page is for, and roughly how long it takes.
|
|
62
|
+
6. **Hand the link over.** Say who is asking and why, what the page is for, and roughly how long it takes. For the person at this machine, `mostra open <dir> --browser` opens it in their browser, and its output says when none could be opened. For a phone or another person, see [references/sharing.md](references/sharing.md): one link is one person's draft, so give each person their own link. *Done when* the person has the link and knows what to do.
|
|
61
63
|
7. **Wait for the answer.** `mostra wait <dir> --until submitted --timeout 10m`. Exit code 0 means submitted; 5 means still waiting, with nothing lost: wait again, or continue other work and check later. *Done when* it exits 0.
|
|
62
64
|
8. **Read the results.** `mostra results <dir>` prints the submission as Markdown (`--format json` for JSON). Act on it. *Done when* you've used every answer.
|
|
63
65
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- Forms with react-hook-form
|
|
7
7
|
- The trusted Submit and `useSubmit`
|
|
8
8
|
- Submission policies
|
|
9
|
+
- Counts by choice
|
|
9
10
|
- Signals
|
|
10
11
|
- Choosing between candidates
|
|
11
12
|
- Waiting
|
|
@@ -111,6 +112,41 @@ Request one in the manifest's `submission`; the host running Mostra decides (`mo
|
|
|
111
112
|
| epochs | `{ policy: "epochs" }` | Rounds: the person submits, you reply with a new version, they submit again. Each round is kept and linked |
|
|
112
113
|
| none | `{ policy: "none" }` | No Submit at all: dashboards, task lists, pages that talk through shared state, actions and signals ([long-lived.md](long-lived.md)) |
|
|
113
114
|
|
|
115
|
+
### Approvals that do something
|
|
116
|
+
|
|
117
|
+
When approving should make something happen (place the order, write the config, send the mail), keep the approval a submission: it is the durable record of who approved what, it arrives in `mostra results`, and the person presses one trusted button.
|
|
118
|
+
|
|
119
|
+
1. Use `once` and name the trusted Submit for the effect: `useSubmitControl({ label: "Approve and place the order", confirm: "Place the order for 3 laptops?" })`.
|
|
120
|
+
2. `mostra wait <dir> --until submitted`, read `mostra results <dir>`, then do the effect yourself.
|
|
121
|
+
3. Publish a new version, or set shared state, that says it's done, so the person sees the outcome.
|
|
122
|
+
|
|
123
|
+
When the effect must happen the moment they press, even while you aren't waiting, run it from the page with `useAction(fn, { key })` (a key makes it happen once, [server.md](server.md)), and still submit with the trusted Submit: `results` lists the run under `actions`. Choosing `none` with a signal instead leaves no submission and no trusted control, so nothing records the approval.
|
|
124
|
+
|
|
125
|
+
## Counts by choice
|
|
126
|
+
|
|
127
|
+
To show everyone how a fixed-choice question is going ("12 for Ship, 4 for Wait"), name the field in the manifest's `tally`. Mostra counts each submission's answer as it is accepted and sends the counts to every open page, with no server code:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { defineArtifact, useField, useLive } from "@mostra/react";
|
|
131
|
+
|
|
132
|
+
export const artifact = defineArtifact({
|
|
133
|
+
title: "Ship the redesign?",
|
|
134
|
+
submission: { policy: "once", scope: "per-viewer" },
|
|
135
|
+
tally: [{ field: "decision", choices: ["ship", "wait", "drop"], minTotal: 5 }],
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
function Decision() {
|
|
139
|
+
const [decision, setDecision] = useField("decision", "");
|
|
140
|
+
const tally = useLive("$tally/decision"); // data: { counts?: { ship, wait, drop }, total }
|
|
141
|
+
// …radio buttons for the three choices…
|
|
142
|
+
return <p>{tally.data?.counts ? `${tally.data.counts.ship} for Ship` : `${tally.data?.total ?? 0} answers so far`}</p>;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- Counts are of answers, never of people, and only of the listed `choices` (2 to 50): any other value counts nothing, so what someone typed never shows. Counts only grow.
|
|
147
|
+
- Below `minTotal` (default 0) a page gets only `total`, so with a handful of answers no one can tell how each person answered.
|
|
148
|
+
- The field is a viewer field (each person's own answer), and the counts come from submissions, so the policy must submit (`once` per viewer or `epochs`).
|
|
149
|
+
|
|
114
150
|
## Signals
|
|
115
151
|
|
|
116
152
|
A signal tells you something happened without submitting: "Ping the agent", "I'm stuck", "Regenerate this section".
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- Files and directories
|
|
8
8
|
- Waiting and results
|
|
9
9
|
- Links for people
|
|
10
|
+
- Through a Mostra server in a chat app
|
|
10
11
|
- Long-lived pages
|
|
11
12
|
- Adding the server to a client
|
|
12
13
|
|
|
@@ -22,7 +23,7 @@ Use Mostra's tools when they're in your tool list (`artifact_create`, `artifact_
|
|
|
22
23
|
| Write | your own file tools | `artifact_write` (whole files), `artifact_patch` (exact replacements or a unified diff) |
|
|
23
24
|
| Verify | `mostra verify <dir>` | `artifact_verify`; `screenshots: "always"` returns both screenshots as images |
|
|
24
25
|
| Publish | `mostra publish <dir>` | `artifact_publish`; its `url` is the default link |
|
|
25
|
-
| Hand out the link | `mostra open <dir
|
|
26
|
+
| Hand out the link | `mostra open <dir> --browser` | `artifact_open` |
|
|
26
27
|
| Wait | `mostra wait <dir> --until submitted` | `artifact_wait` with `until: "submitted"` |
|
|
27
28
|
| Read the answers | `mostra results <dir>` | `artifact_results` (Markdown; `format: "json"` for the full structure) |
|
|
28
29
|
|
|
@@ -46,7 +47,11 @@ When you also have your own file tools on the same computer, use whichever you l
|
|
|
46
47
|
|
|
47
48
|
`artifact_open` returns the artifact's default link. A link made without `viewer` is shared by everyone who holds it: they edit one draft and have one `once` submission between them. For several people, call `artifact_open` once per person with `viewer: { ref, name }` and give each their own link (with `{ policy: "once", scope: "per-viewer" }` each submits once). `ttl`, `scopes` and `version` make a new link that expires, allows less, or opens one version, as in [sharing.md](sharing.md). `open: true` also opens the link in a browser on this computer, for the person sitting at it.
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
A local server's links open on this computer only: to reach someone elsewhere, share the page as [sharing.md](sharing.md) shows. Through a Mostra server (a chat app's connector), links open anywhere: `artifact_publish` and `artifact_open` return the hosted link, `https://` and a server's address ending in `/a/rte_…`.
|
|
51
|
+
|
|
52
|
+
## Through a Mostra server in a chat app
|
|
53
|
+
|
|
54
|
+
A chat app's connector reaches the person's own computer through their Mostra server. Creating, writing, verifying and publishing run there, in its workspace, so that computer must be on with Mostra running; otherwise those tools answer `MOSTRA_REMOTE_NO_INSTANCE`, while listing, waiting and reading results keep working. Answers people send wait on the server while that computer sleeps, and reach it when it's back.
|
|
50
55
|
|
|
51
56
|
## Long-lived pages
|
|
52
57
|
|
|
@@ -54,10 +59,10 @@ Links open on this computer only. To reach someone elsewhere, share it as [shari
|
|
|
54
59
|
|
|
55
60
|
## Adding the server to a client
|
|
56
61
|
|
|
57
|
-
A client starts the server as `mostra mcp` over stdio, or `npx -y @mostra/cli@0.
|
|
62
|
+
A client starts the server as `mostra mcp` over stdio, or `npx -y @mostra/cli@0.11.0 mcp` where `mostra` isn't installed. Its configuration names that command, for example:
|
|
58
63
|
|
|
59
64
|
```json
|
|
60
|
-
{ "mcpServers": { "mostra": { "command": "npx", "args": ["-y", "@mostra/cli@0.
|
|
65
|
+
{ "mcpServers": { "mostra": { "command": "npx", "args": ["-y", "@mostra/cli@0.11.0", "mcp"] } } }
|
|
61
66
|
```
|
|
62
67
|
|
|
63
68
|
For a client that speaks only HTTP, `mostra mcp --http` serves Streamable HTTP on `127.0.0.1` and prints its URL and a token on stderr; every request sends `Authorization: Bearer <token>` (set `MOSTRA_MCP_TOKEN` to choose it). `--workspace <dir>` chooses where new artifacts go.
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
- The link
|
|
6
6
|
- One person, one link
|
|
7
|
-
- The
|
|
7
|
+
- The four setups: local, tailnet share, public share, hosted
|
|
8
|
+
- Hosted on a server
|
|
8
9
|
- Behind a public quick tunnel
|
|
9
10
|
- Managing links and shares
|
|
11
|
+
- Moving a version to another machine
|
|
10
12
|
- Asking people well
|
|
11
13
|
|
|
12
14
|
## The link
|
|
13
15
|
|
|
14
|
-
`mostra publish` prints the artifact's **default link**; `mostra open <dir>` prints it again
|
|
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.
|
|
15
17
|
|
|
16
18
|
The default link doesn't expire and stays the same across versions. It opens on this machine only (`http://127.0.0.1:…`).
|
|
17
19
|
|
|
@@ -28,19 +30,57 @@ mostra open ./retro --new --viewer grace@example.com --viewer-name "Grace Hopper
|
|
|
28
30
|
|
|
29
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).
|
|
30
32
|
|
|
31
|
-
## The
|
|
33
|
+
## The four setups
|
|
32
34
|
|
|
33
35
|
| Setup | Who can open it | Command |
|
|
34
36
|
|---|---|---|
|
|
35
|
-
| **Local** | Only this machine's browser | `mostra open <dir
|
|
37
|
+
| **Local** | Only this machine's browser | `mostra open <dir> --browser` |
|
|
36
38
|
| **Tailnet share** | People and devices in your Tailscale network, such as your phone | `mostra share <dir> --tailnet` |
|
|
37
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` |
|
|
38
41
|
|
|
39
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.
|
|
40
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`.
|
|
41
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`).
|
|
42
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.
|
|
43
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
|
+
|
|
44
84
|
## Behind a public quick tunnel
|
|
45
85
|
|
|
46
86
|
Over a Cloudflare quick tunnel the page runs in a slightly different mode, and nothing in your code needs to change for it:
|
|
@@ -61,6 +101,17 @@ mostra open ./x --revoke <tokenId> # stop a link
|
|
|
61
101
|
|
|
62
102
|
`--json` output carries each link's `tokenId`.
|
|
63
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
|
+
|
|
64
115
|
## Asking people well
|
|
65
116
|
|
|
66
117
|
The link arrives as a message from you, so write it like one:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as TelemetryStore, t as flush } from "../flush-
|
|
1
|
+
import { r as TelemetryStore, t as flush } from "../flush-D648gCYs.js";
|
|
2
2
|
//#region src/telemetry/flush-main.ts
|
|
3
3
|
/**
|
|
4
4
|
* The flusher process (D140 item 6): `node flush-main.js <config dir>`, started detached by the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "The mostra command: author, verify, publish, share and wait on agent artifacts, as a thin client of the Mostra host protocol.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@hono/node-server": "2.1.5",
|
|
38
38
|
"@modelcontextprotocol/server": "2.4.0",
|
|
39
|
-
"@mostra/mcp": "0.
|
|
40
|
-
"@mostra/protocol": "0.
|
|
41
|
-
"@mostra/sdk": "0.
|
|
39
|
+
"@mostra/mcp": "0.11.0",
|
|
40
|
+
"@mostra/protocol": "0.11.0",
|
|
41
|
+
"@mostra/sdk": "0.11.0",
|
|
42
42
|
"zod": "4.6.7"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@modelcontextprotocol/client": "2.4.0",
|
|
46
46
|
"@modelcontextprotocol/conformance": "0.1.16",
|
|
47
47
|
"@modelcontextprotocol/conformance-next": "npm:@modelcontextprotocol/conformance@0.2.0-alpha.12",
|
|
48
|
-
"@mostra/runtime": "0.
|
|
48
|
+
"@mostra/runtime": "0.11.0",
|
|
49
49
|
"@mostra/tools": "0.0.0",
|
|
50
50
|
"@types/node": "24.19.2",
|
|
51
51
|
"tsdown": "0.23.1",
|
package/src/client.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface InstanceSummary {
|
|
|
37
37
|
/** Its process ID. */
|
|
38
38
|
readonly pid: number;
|
|
39
39
|
/** `daemon`, or `host` for an instance a host spawned (telemetry sends nothing then, D140). */
|
|
40
|
-
readonly mode: "host" | "daemon";
|
|
40
|
+
readonly mode: "host" | "daemon" | "hosted";
|
|
41
41
|
/** The runtime's release. */
|
|
42
42
|
readonly version: string;
|
|
43
43
|
/** Whether this command started the daemon. */
|
package/src/commands/admin.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "@mostra/protocol";
|
|
24
24
|
import { checkBrowser, checkFiles, enclosingBundle, readBundle, readSetup } from "@mostra/sdk";
|
|
25
25
|
import { type CommandContext, type CommandDef, defineCommand } from "../command.ts";
|
|
26
|
-
import { docsIndex, indexMarkdown, nearestTopics, topicMarkdown } from "../docs.ts";
|
|
26
|
+
import { docsIndex, indexMarkdown, nearestTopics, skillDir, topicMarkdown } from "../docs.ts";
|
|
27
27
|
import { EXIT, exitCodeFor } from "../exit.ts";
|
|
28
28
|
import { embeddedHome, locateRuntime, readHomeMarks } from "../home.ts";
|
|
29
29
|
import { usage } from "../parse.ts";
|
|
@@ -163,7 +163,17 @@ export const statusCommand: CommandDef = defineCommand({
|
|
|
163
163
|
return { result: detail, human: `${detail.id} ${detail.title}\n${versions}` };
|
|
164
164
|
}
|
|
165
165
|
const status = await context.call(instanceStatusMethod, {});
|
|
166
|
-
|
|
166
|
+
// Each remote server this home is linked to, by its state (INTERFACES §18.7).
|
|
167
|
+
const links = (status.links ?? [])
|
|
168
|
+
.map(
|
|
169
|
+
(link) =>
|
|
170
|
+
`${link.server} ${link.state}${link.default ? " default" : ""}${link.pendingPushes > 0 ? ` ${link.pendingPushes} pushes waiting` : ""}${link.lastError ? ` (${link.lastError})` : ""}\n`,
|
|
171
|
+
)
|
|
172
|
+
.join("");
|
|
173
|
+
return {
|
|
174
|
+
result: status,
|
|
175
|
+
human: `${pretty(status)}${links ? `\nRemote servers:\n${links}` : ""}`,
|
|
176
|
+
};
|
|
167
177
|
},
|
|
168
178
|
});
|
|
169
179
|
|
|
@@ -703,7 +713,7 @@ export const docsCommand: CommandDef = defineCommand({
|
|
|
703
713
|
`No topic "${wanted}". The nearest: ${nearestTopics(wanted, topics).join(", ")}. Run "mostra docs" for the index.`,
|
|
704
714
|
);
|
|
705
715
|
}
|
|
706
|
-
const markdown = topicMarkdown(found);
|
|
716
|
+
const markdown = topicMarkdown(found, skillDir());
|
|
707
717
|
return { result: { topic: found.topic, markdown, url: found.url }, human: markdown };
|
|
708
718
|
},
|
|
709
719
|
});
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Authoring: `new`, `verify`, `publish` and `add`, thin clients of
|
|
3
|
-
* `artifact/verify`, `artifact/publish`
|
|
2
|
+
* Authoring: `new`, `verify`, `publish`, `export`, `run` and `add`, thin clients of
|
|
3
|
+
* `artifact/create`, `artifact/verify`, `artifact/publish`, `artifact/export`, `artifact/import`
|
|
4
|
+
* and `deps/add` (INTERFACES §6, §15).
|
|
4
5
|
*/
|
|
5
6
|
import { randomUUID } from "node:crypto";
|
|
6
7
|
import { resolve } from "node:path";
|
|
7
8
|
import {
|
|
8
9
|
ARTIFACT_PROGRESS,
|
|
9
10
|
artifactCreateMethod,
|
|
11
|
+
artifactExportMethod,
|
|
12
|
+
artifactImportMethod,
|
|
10
13
|
artifactPublishMethod,
|
|
11
14
|
artifactVerifyMethod,
|
|
12
15
|
depsAddMethod,
|
|
@@ -16,7 +19,7 @@ import {
|
|
|
16
19
|
import { type CommandDef, defineCommand } from "../command.ts";
|
|
17
20
|
import { EXIT } from "../exit.ts";
|
|
18
21
|
import { usage } from "../parse.ts";
|
|
19
|
-
import { arg, flag, sourceRef } from "./shared.ts";
|
|
22
|
+
import { arg, artifactRef, flag, sourceRef } from "./shared.ts";
|
|
20
23
|
|
|
21
24
|
/** `mostra new <dir>`. */
|
|
22
25
|
export const newCommand: CommandDef = defineCommand({
|
|
@@ -197,6 +200,85 @@ export const publishCommand: CommandDef = defineCommand({
|
|
|
197
200
|
},
|
|
198
201
|
});
|
|
199
202
|
|
|
203
|
+
/** `mostra export <artifact> --as bundle --out <path>`. */
|
|
204
|
+
export const exportCommand: CommandDef = defineCommand({
|
|
205
|
+
path: ["export"],
|
|
206
|
+
summary: "Write a published version out of the home, as a portable bundle another home can run.",
|
|
207
|
+
args: [{ name: "artifact", summary: "The artifact: its source path or its ID." }],
|
|
208
|
+
flags: [
|
|
209
|
+
{
|
|
210
|
+
name: "as",
|
|
211
|
+
kind: "string",
|
|
212
|
+
value: "<class>",
|
|
213
|
+
choices: ["bundle"],
|
|
214
|
+
default: "bundle",
|
|
215
|
+
summary: "What to write: `bundle`, the version's builds, manifest, lockfile and source.",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "out",
|
|
219
|
+
kind: "string",
|
|
220
|
+
value: "<path>",
|
|
221
|
+
summary: "Where: a new directory, or one archive when it ends in .tar.zst.",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "version",
|
|
225
|
+
kind: "string",
|
|
226
|
+
value: "<number|id>",
|
|
227
|
+
summary: "The version. Default: the latest.",
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
output: { type: "ArtifactExportResult", topic: "cli" },
|
|
231
|
+
exits: [EXIT.failure],
|
|
232
|
+
example: "export ./sidebar-review --out ./sidebar-review.tar.zst",
|
|
233
|
+
async run(context) {
|
|
234
|
+
const out = flag(context, "out");
|
|
235
|
+
if (out === undefined) throw usage('"mostra export" needs --out <path>.');
|
|
236
|
+
const version = flag(context, "version");
|
|
237
|
+
const result = await context.call(artifactExportMethod, {
|
|
238
|
+
artifact: artifactRef(arg(context, "artifact"), context.cwd),
|
|
239
|
+
as: "bundle",
|
|
240
|
+
out: resolve(context.cwd, out),
|
|
241
|
+
...(version !== undefined
|
|
242
|
+
? { version: /^\d+$/.test(version) ? Number(version) : version }
|
|
243
|
+
: {}),
|
|
244
|
+
});
|
|
245
|
+
return {
|
|
246
|
+
result,
|
|
247
|
+
human: `Exported ${result.versionId} to ${result.files.join(", ")}\n`,
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
/** `mostra run <bundle>`. */
|
|
253
|
+
export const runCommand: CommandDef = defineCommand({
|
|
254
|
+
path: ["run"],
|
|
255
|
+
summary:
|
|
256
|
+
"Make a bundle `mostra export` wrote a version of this home, with the same IDs, and print its link.",
|
|
257
|
+
args: [{ name: "bundle", summary: "The bundle: its directory or its .tar.zst archive." }],
|
|
258
|
+
flags: [
|
|
259
|
+
{
|
|
260
|
+
name: "request-id",
|
|
261
|
+
kind: "string",
|
|
262
|
+
value: "<id>",
|
|
263
|
+
summary: "Make a retry return the first attempt's receipt.",
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
output: { type: "PublishReceipt", topic: "cli" },
|
|
267
|
+
exits: [EXIT.failure],
|
|
268
|
+
example: "run ./sidebar-review.tar.zst",
|
|
269
|
+
async run(context) {
|
|
270
|
+
const requestId = flag(context, "request-id");
|
|
271
|
+
const receipt = await context.call(artifactImportMethod, {
|
|
272
|
+
bundle: resolve(context.cwd, arg(context, "bundle")),
|
|
273
|
+
...(requestId !== undefined ? { requestId } : {}),
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
result: receipt,
|
|
277
|
+
human: `${receipt.reused ? "Already here" : "Imported"}: version ${receipt.version} (${receipt.versionId}) of ${receipt.artifactId}\n${receipt.url ?? ""}\n`,
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
|
|
200
282
|
/** `mostra add <package…>`. */
|
|
201
283
|
export const addCommand: CommandDef = defineCommand({
|
|
202
284
|
path: ["add"],
|
package/src/commands/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Every command of `mostra` (D60, D140 item 13), in the order help lists them. Commands later
|
|
3
|
-
* packages own (`review export`, `
|
|
4
|
-
* packages, never as placeholders; `share` joined with WP-13
|
|
3
|
+
* packages own (`review export`, `plugin`, `term`) join this list with their
|
|
4
|
+
* packages, never as placeholders; `share` joined with WP-13, `mcp` with WP-15, and `export` (its `bundle` class) and `run`
|
|
5
|
+
* with WP-29.
|
|
5
6
|
*/
|
|
6
7
|
import type { CommandDef } from "../command.ts";
|
|
7
8
|
import {
|
|
@@ -24,7 +25,14 @@ import {
|
|
|
24
25
|
telemetryOnCommand,
|
|
25
26
|
telemetryStatusCommand,
|
|
26
27
|
} from "./admin.ts";
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
addCommand,
|
|
30
|
+
exportCommand,
|
|
31
|
+
newCommand,
|
|
32
|
+
publishCommand,
|
|
33
|
+
runCommand,
|
|
34
|
+
verifyCommand,
|
|
35
|
+
} from "./authoring.ts";
|
|
28
36
|
import { devCommand } from "./dev.ts";
|
|
29
37
|
import {
|
|
30
38
|
pushCommand,
|
|
@@ -35,6 +43,7 @@ import {
|
|
|
35
43
|
waitCommand,
|
|
36
44
|
} from "./interaction.ts";
|
|
37
45
|
import { mcpCommand } from "./mcp.ts";
|
|
46
|
+
import { loginCommand, logoutCommand, pauseCommand, resumeCommand } from "./remote.ts";
|
|
38
47
|
import { shareCommand, shareListCommand, shareStopCommand } from "./sharing.ts";
|
|
39
48
|
import { openCommand } from "./viewing.ts";
|
|
40
49
|
|
|
@@ -48,6 +57,10 @@ export const COMMANDS: readonly CommandDef[] = [
|
|
|
48
57
|
shareCommand,
|
|
49
58
|
shareStopCommand,
|
|
50
59
|
shareListCommand,
|
|
60
|
+
loginCommand,
|
|
61
|
+
logoutCommand,
|
|
62
|
+
pauseCommand,
|
|
63
|
+
resumeCommand,
|
|
51
64
|
waitCommand,
|
|
52
65
|
resultsCommand,
|
|
53
66
|
stateGetCommand,
|
|
@@ -55,6 +68,8 @@ export const COMMANDS: readonly CommandDef[] = [
|
|
|
55
68
|
statePatchCommand,
|
|
56
69
|
pushCommand,
|
|
57
70
|
addCommand,
|
|
71
|
+
exportCommand,
|
|
72
|
+
runCommand,
|
|
58
73
|
secretSetCommand,
|
|
59
74
|
secretListCommand,
|
|
60
75
|
secretRmCommand,
|