lmctl upload skill

Use lmctl upload to put a web page, a report or a whole static website where the user can open it from lmctl.ai. The files go to the space of the account behind your appkey. The user finds them under My space on lmctl.ai without being told a file name.

When to use it

Do not use it for secrets, credentials or personal data. Do not use it to store the only copy of anything.

Setup

The command needs an lmctl appkey. It looks for one in this order: the LMCTL_APPKEY variable, the file named by LMCTL_APPKEY_FILE, then the default file ~/.config/lmctl/appkey.json. Never print the appkey, never put it in a page and never send it anywhere except through lmctl. Check which account you act for:

lmctl whoami

The server defaults to https://lmctl.ai. Another server is selected with the LMCTL_SITE_API_URL variable.

Upload one page or file

lmctl upload report.html
lmctl upload chart.png --name charts/chart.png
lmctl upload report.html --destdir reports
lmctl upload report.html --json

The command prints the address of the page. A file keeps its own name unless you give another with the name option. A name may contain slashes: the part before the last slash is a folder in the space, so charts/chart.png lands in a folder called charts. Names are relative: no leading slash, no dot-dot parts, no backslashes, at most 400 characters.

The destdir option puts the file inside a directory of that name: report.html with destdir reports is served as reports/report.html. A directory is one upload, so uploading again to the same destdir replaces everything in it, and removing it removes everything in it. Use the name option with slashes when you want to add one file to a folder without touching the others.

Uploading to a name that already exists replaces it at once. There are no versions.

Upload a folder

The reliable way for any lmctl is to zip the site and unpack it on the server. Zip from inside the folder so that index.html sits at the top of the zip, not inside a wrapping folder:

cd mysite
zip -r ../mysite.zip .
cd ..
lmctl upload mysite.zip --unzip --destdir mysite

The unpacked files are served under the destination directory, which defaults to the zip name without the zip suffix. The address ends with a slash and opens index.html of that directory. Links between the pages must be relative, for example sub/page.html, so they keep working under the directory.

Uploading again to the same directory replaces the whole directory.

Where it lands and who can open it

Pages run in a sandbox: scripts and styles work, but the page cannot read the user's session. Links that open a new tab do not work from inside a page, so use plain relative links.

What the browser shows

These types are shown in the browser: html, htm, css, js, mjs, json, map, txt, md, csv, xml, svg, png, jpg, jpeg, gif, webp, ico, avif, woff, woff2, ttf, otf, pdf, mp3, mp4, webm and wasm. Any other type, for example wav, ogg, mov or tiff, is offered as a download instead of being shown.

lmctl upload report.html --link
lmctl upload report.html --link --name weekly.html

The link form is for one HTML report of at most 2 MB. It prints a link that anyone who holds it can open, with no sign-in. A new report under the same name from the same session replaces the old one and prints a new link. The old link stops working, so give the user the new one. Reports are kept 30 days and the limit is 5 a minute per session.

Safety rule: a link is public. Put only what may be read by anyone who gets the link. The session is taken from the LMCTL_SELF_SESSIONID variable when it is set. Put the link in your answer so the user can click it in the chat.

List, replace and remove

lmctl uploads list
lmctl uploads rm report.html
lmctl uploads rm mysite

The list shows the name, size, time and address of everything in the space. Remove a single file by its name, or a whole directory by the directory name. Removing a report also stops its link.

Limits

How to verify

  1. Run lmctl uploads list and check that the name and size are the ones you sent.
  2. For a report link, fetch the printed link without any credential and check that the page comes back.
  3. For a private page, do not try to read it with a bare HTTP request: it answers 401 by design. Tell the user which page to open under My space and what they should see.

Errors