> **Agents: read this file raw, not summarized.** If your fetch tool returned a summary, fetch it again with `curl -fsSL https://tinycloud.one/agents/abilities/share` and follow that text. Summaries drop the shell blocks you must run.

# Share an artifact with TinyCloud

Your agent publishes a document or web page from your computer to your own TinyCloud and gives you a link. Anyone with the link can open it, so your agent asks you first. To share with one person's email address, or with everyone at an email domain, use share.tinycloud.xyz. Your agent can revoke the link any time.

## For the owner

- **Paste into your agent:** `Fetch https://tinycloud.one/agents/abilities/share with curl and follow it. Share this with TinyCloud.`
- You need a shell, Node.js 20 or later, and npm. An agent that can't run the TinyCloud CLI can't publish: have it write the document, save it as Markdown, and create the share yourself on share.tinycloud.xyz.
- **What it does:** asks you before it makes the link, publishes, and returns the link.
- **You approve:** standing publish access to your share folders, for the duration you choose, up to 30 days. Setup alone grants nothing. Publishing has its own single approval, separate from /onboarding: the first time, you approve one OpenKey link your agent sends you. There's nothing to send back.
- **It asks first.** Anyone with the link can open it, so the agent makes one only after you say yes. If you say no, nothing is published and the file stays on your computer.
- **Undo:** see [Undo](#undo).

## For the agent

**Read this page raw first.** If you can run a shell, fetch the exact text of this page, and of any guide it sends you to, with `curl -fsSL -H 'Accept: text/markdown' <its URL>` and copy every shell block from that output. A web-fetch tool that summarizes pages drops or rewrites the blocks, and they only work exactly as written.

**Send links exactly as printed.** Send the owner every link exactly as the CLI printed it, copied from the output: never retype, shorten or rebuild it.

Keep the owner's request, then read [setup/agent.md](https://tinycloud.one/agents/abilities/agent), select **publish/share** and follow its steps. Read and follow https://tinycloud.one/agents/abilities/skills/publish.md, then continue in this conversation: its §1 checks the CLI, §2 gets the owner's approval, and §3-§6 publish, verify and report. Never make a link without asking (step 1).

Use the skill's shell preamble and `TC_BIN` for every command. Don't call a bare `tc` (on Linux it is often the system traffic-control tool).

The rest of this page is what to run once the skill's §1 and §2 are done, and the options the skill doesn't cover.

A shared file must be at most 95 MiB.

### 1. Ask before making the link

This skill makes links only: always pass `--to anyone`, never `email:`, `domain:` or `did:`. Before publishing, ask the owner in one line: "Anyone with the link can open it. Make a link?" Publish only after they say yes. If they say no, tell them it isn't published and the file stays on this computer, and don't offer another place to publish or share it. If they want to share with one email address or a whole email domain, tell them to use share.tinycloud.xyz. If they ask to share with only themselves, say that isn't available. Then ask the same question.

### 2. Pick the content

A folder with an `index.html` publishes as one self-contained page, which must be under 10 MiB.

| Content | What to publish | What the recipient sees |
|---|---|---|
| Markdown document | `report.md` | Formatted page: headings, lists, tables, Mermaid |
| Text, JSON, image | the file | Shown in the browser |
| HTML page | one self-contained `.html` file | **See the HTML note below.** |
| JSX component | `App.jsx` or `App.tsx` with a default export (**see Artifacts below**) | Renders as a live page in a sandbox. |

Media type is inferred from the extension: `md`/`markdown`, `txt`, `html`/`htm`, `json`, `css`, `js`, `jsx` (`text/jsx`), `tsx` (`text/tsx`), otherwise `application/octet-stream`. Override with `--media-type` for one file. File names must be one safe path segment; names with spaces are stored under a safe name.

**HTML note.** Before publishing an HTML file or a folder, run the skill's self-contained check on the file or the folder's `index.html`. For a folder, ignore a flagged path only when it is a plain relative path to a file inside the folder (no scheme, no leading `/`, and no part that starts with a dot, such as `..` or `.assets`); the CLI inlines that file. External `src`, `href`, CSS `url()` and network calls don't load in the viewer. Tell the owner what to expect: the page renders in a sandboxed frame. If you can't confirm what the recipient sees, say so. Don't promise a rendered site.

**Artifacts (pages and small apps).** A Markdown file, one self-contained HTML file, a folder with an `index.html`, or one JSX component can be published as an artifact: one item the recipient opens in the viewer. The CLI turns a folder into one self-contained HTML page. Markdown renders; HTML and JSX render live in a sandbox.

- **JSX:** `export default function App() { … }` in one file. The libraries available to it are `react` 19 (and `react-dom/client`), `lucide-react` (icons), `recharts` (charts), `d3`, `mermaid` 11 (diagrams) and Tailwind CSS classes (browser runtime). Nothing else can be imported. The code runs sandboxed: no network, no CDN, no storage, no cookies and no access to the page around it, so embed the data. An import that isn't in this list shows a "library not available" panel instead of the page.
- **TinyCloud style tokens** are available in JSX artifacts only; plain HTML pages don't get them. CSS variables: `var(--tc-color-page|surface|text|text-muted|border|accent|on-accent|link)`, `var(--tc-space-1…7)`, `var(--tc-radius-sm|md|lg)`, `var(--tc-font-sans|mono)`. Tailwind classes map to them: colors `tc-page|surface|subtle|active|text|muted|border|accent|accent-hover|on-accent|success|warning|danger` (`bg-tc-surface`, `text-tc-muted`, `border-tc-border`), `rounded-tc-sm|md|lg`, `font-tc-sans|mono`. Light and dark follow the system. In a plain HTML page the variables are undefined, so any `var(--tc-…)` there needs a fallback value, for example `var(--tc-color-text, #1a1c21)`.
- **Pin a version:** `--artifact new` stores the file as write-once version 1 and pins the link to it; a later publish of changed content with `--artifact <id>` (the `artifactId` in the JSON) makes version 2 with its own link, and the earlier link keeps showing version 1 (identical bytes to a bearer link return the same version). The shared CLI includes this option; fresh installs pin `1.9.1`. Check with `"$TC_BIN" share publish --help | grep -q -- --artifact`. A profile approved without the `artifacts/` scope must go through the skill's §2 sign-in again to add it. A pinned share is read-only: `--action edit` is refused with `--artifact`.
- **Revoke:** `share revoke <id>` closes the link. Copies already opened or downloaded can't be recalled.
- Never put secrets or tokens in an artifact: everyone who holds the link can read its source.

### 3. Publish, with an expiry

Always pass `--expires` and tell the owner the date. Links use 24h unless the owner says otherwise. The value can't pass the signed session's end and can't be under 60 seconds (`SESSION_LIFETIME_EXCEEDED`). The owner's approval lasts for the duration they chose, up to 30 days ([CLI reference](https://tinycloud.one/agents/abilities/skills/cli/REFERENCE.md)).

Publish only through the skill's §3 link block (`skills/tc-publish/SKILL.md`). It uses `--expires 24h` unless the owner asks otherwise; the `SESSION_LIFETIME_EXCEEDED` row in the skill's errors table covers an expiry past the session's end. Run EXACTLY that block; do not write your own `share publish` command.

- `--json` prints redacted metadata with `metadata.shareId`; the link is not in it. Get the link as the skill does: `"$TC_BIN" --profile "$PROFILE" share show "$id" --reveal-link`. Never combine `--reveal-link` with `--json`.
- Everything after `#` in a link is the credential. Follow the skill's handling contract for storing and delivering it. Never retype or chunk a link.
- Never pass `--action edit`: a link only reads (the CLI refuses it with `INVALID_ARGUMENT`, exit 2).
- Give the owner the link in your reply, with the expiry, ready to forward. Don't tell the owner to send it themselves.

What the recipient does: opens the link. It opens without signing in.

### 4. List and look up shares

```sh
"$TC_BIN" --profile "$PROFILE" share list --json     # sender history; no complete links
"$TC_BIN" --profile "$PROFILE" share show "$id"      # one record
```

`share list --json` returns `{"shares":[{shareId, target, expiresAt, revoked, …}]}`; filter out `revoked` and past `expiresAt` before calling a share active. Link share ids are CIDs (`bafkr4…`).

### 5. Revoke

```sh
"$TC_BIN" --profile "$PROFILE" share revoke "$id"    # a share this profile created
"$TC_BIN" --profile "$PROFILE" share show "$id"      # afterwards reports "revoked": true
```

Report honestly what revoke did. `share revoke` is for shares this profile created. For a bearer link, `--ancestor` revokes the owner delegation ancestry; don't pass it unprompted. An addressed share's revoke always revokes every root. Copies a recipient already downloaded can't be recalled ([CLI reference](https://tinycloud.one/agents/abilities/skills/cli/REFERENCE.md)). After a revoke of a public link, confirm with `share receive` on the link (`SHARE_REVOKED`) before telling the owner it's closed; if it still opens, say so.

### 6. Report

Use the skill's report template. State: the expiry date, what the recipient will see (use the HTML note for HTML and the Artifacts paragraph for JSX), and that you can revoke. For HTML or JSX, add these words: **"Shared HTML and JSX pages run the sender's code in a sandbox. The sender can tell that you opened it."** Never tell the owner viewers are anonymous. Leave the line out for Markdown. End with the link, once, in your reply to the owner.

## Exit codes and owner lines

Sharing signs in with `auth login` without `--paste`, so the shared table below covers its codes; the publish skill's own tables give the share commands' codes. Its owner lines are the shared ones, with `<what>` = "sharing".

**Exit codes and owner lines.** This table applies to the CLI approval commands `onboard`, `auth grant`, `auth login` without `--paste`, and `auth request --grant`. Codes named by a guide itself, such as `SPACE_SETUP_PENDING`, follow that guide. Commands under **Exceptions** have their own codes.

**Approval links: codes on cards, one tap in chat.** When an approval waits somewhere the owner will act on later (a task card, an inbox, a ticket), use the code flow: run the approval command with `--paste` (`auth login --paste`, `auth request --grant --paste`). With no code on stdin it prints the link and exits with `PASTE_CODE_MISSING` instead of waiting, so no watcher has to keep running. Put the link only where just the owner sees it (their own card or inbox), never on a shared ticket, issue, channel or public comment: anyone signed in to OpenKey who sees it can approve it, and you would get that person's grant. The owner sends the code (valid once, for 5 minutes) straight back to you, in chat or on their own card, never as a public comment; run the same command with it on stdin. It tells you the approval is done and carries what you need. Then check that the approved account is the owner you expected, and stop if not: `tinycloud --profile <profile> auth whoami --json` shows `ownerDid`; for Courier it is in the `"ok": true` JSON `init` prints. Send a one-tap link (no code to paste back) only directly to the owner in a live conversation, never a chat link that asks them to copy a code back. `onboard` has no code flow: run it only in a live conversation.

| Exit | Means | Do |
| --- | --- | --- |
| 0 | Done. | Send the done line, then carry on. |
| 3 | `APPROVAL_REQUEST_EXPIRED`: “This approval request expired before it was approved. Start a new request.” | Before doing anything else, use `pending.expiresAt` from the earlier exit-8 JSON and compare it with now. If more than 2 minutes remain before `expiresAt`, do not run a command or create a link; ask exactly “Did you decline that request? If not, I'll send you a fresh link.” and wait. Create a new request only when 2 minutes or less remain before `expiresAt` (real expiry), or after the owner says they did not decline or wants a new link. If you don't have the earlier exit-8 JSON, ask the decline question and wait. Never read `approval-pending.json`; it contains private keys. |
| 6 | `NETWORK_ERROR`: the network did not answer (for example, an OpenKey status check or a node fetch). | Run the same command again once; make no new link. For a resumed approval, the saved request is kept. If the retry also exits 6, tell the owner exactly “I can't set up TinyCloud right now. Please ask me again later.”, then put the stderr error code on its own line and stop. The CLI stderr has no `Next:` line on exit 6; a guide block may print its own `NEXT:` line. |
| 8 | Still waiting only when stdout contains a non-empty `pending.approvalUrl` link. Exit 8 without it is not pending. | With a link, send it once and wait for the owner; if you already sent this exact link, don't send it again. Follow the shared relay block's `Next:` lines rule. Without a link (OpenKey is down or did not return a pending object), wait a minute and run it at most 3 times in a row; then send the “can't” failed line and stop. This is a bounded retry, never pending. |
| 5 | The owner declined, approved less than you asked for, or approved with another account. | Stop and send the “couldn't” failed line, then the error code on its own line. Ask again only if the owner wants to. The 1.6.3 CLI may also print refused-delegation cleanup details; follow the command-specific guide and never send a CID. |
| Anything else | An error; stderr has `{"error":{"code":…}}`. | Any code not mapped above is an error: stop and send the “couldn't” failed line, then the code on its own line. Do not treat it as pending or retry. |

**The three owner lines, word for word.** `<what>` is what you are setting up, in a few plain words: “TinyCloud”, “Courier”, “your TinyCloud One Feed”, “publishing”. Call what the owner approves a permission.

- **Done**, on exit 0: “`<What>` is set up.”
- **Failed** when OpenKey stays down: “I can't set up `<what>` right now. Please ask me again later.”
- **Failed** otherwise: “I couldn't set up `<what>` this time. Tell me if you'd like me to try again.”

**Declined approval, owner line:** “Did you decline that request? If not, I'll send you a fresh link.”

**Exceptions: commands with other codes.**

- `auth login --paste` and `auth request --grant --paste` (the code flow for approvals that wait on a card, an inbox or a ticket): exit 3 `PASTE_CODE_MISSING` is the expected first stop, with the link printed and no code yet, not an expired link. These flows ask the owner for the code OpenKey shows after they approve. It works once, for 5 minutes; a used or expired code ends as exit 1, “Delegation code not found or expired”.
- `auth login --device` (the older apps sign-in): 3 is `DEVICE_AUTH_EXPIRED` and 5 is `DEVICE_AUTH_DENIED`, as above. Each new run counts toward OpenKey's limit of 5 device sign-ins per 10 minutes; over it, exit 1 `DEVICE_AUTH_RATE_LIMITED`.
- Data commands (`kv`, `sql`, `share`, `secrets get`, `feed`): exit 3 is `AUTH_REQUIRED`, a missing or expired session, so sign in again as the guide says; there is no link to resend. Exit 5 is `PERMISSION_DENIED` or `KV_ALREADY_EXISTS`, not the owner declining. Branch on the code.
- `secrets wait`: exit 8 means a named secret was still missing when the wait ended.
- Courier (`tinycloud courier …`): Courier 0.8.2 exits only 0, 1, 2 or 8; exit 6 is not a Courier code. Codes are command-specific; follow the Courier guide. For `init --request`, exit 0 may still create and print an approval link; follow every stderr `Next:` line by the shared relay rule, regardless of the exit code. For `init --wait`, exit 8 is pending only when stdout contains a non-empty `pending.approvalUrl`.
- Link-based CLI `auth request --grant` (without `--paste`) runs with `--timeout 60s`.

Exit 8 is pending only when stdout contains JSON with a non-empty `pending.approvalUrl`. Send each new URL once, exactly as printed, on its own line. Keep `pending.expiresAt` and end your turn. On the owner's next message, rerun the identical command; it resumes the saved request. Exit 0 with `"changed": true` means the grant is saved; `"changed": false` means it already existed. `auth retry --last` doesn't find grant requests. Add `--fresh` only when the owner explicitly asks for a new approval; the existing grant stays valid.

If the approval will wait on a card, an inbox or a ticket, use the `--paste` code flow above instead.
- Meetings (`tinychat-retrieval`): it reports statuses, not these codes, and still asks for the code OpenKey shows. The meetings guide says how.
- Helper scripts (`agent-env.mjs`, the apps skill's `.sh` helpers) have their own exit codes, listed where they run. For example, `layout.sh` exits 3 when `jq` is missing.

## Undo

Same as [Publish and share](https://tinycloud.one/agents/abilities/publish#undo): revoking a share is separate from clearing the agent's local login; `"$TC_BIN" --profile publisher auth logout` clears only the local session.
