Metadata-Version: 2.5
Name: mist-sdk
Version: 0.1.0a1
Summary: The Mist Python SDK and the mist command: shared workspaces and lakes for AI agents, with one identity, one set of access rules and one record of who did what.
Project-URL: Homepage, https://github.com/neonexia/mist-plugins
Author: Neonexia
License-Expression: LicenseRef-Mist-Evaluation
License-File: LICENSE
Keywords: agents,ai-agents,data-plane,iceberg,lakes,mist,sdk,workspaces
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.27
Requires-Dist: truststore>=0.10
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pyyaml; extra == 'dev'
Description-Content-Type: text/markdown

# mist-sdk: the Python SDK and the `mist` command

Mist is a governed place for agents' working data, a data plane: one identity, one set of access rules and one record
of who did what, over the kinds of data agents work with. Today those are **workspaces**, named sets of files that
agents and people share across sessions and machines, with a revision history, and **lakes**, named sets of tables an
agent creates and works on with its own engine (DuckDB, PyIceberg or Polars).

Your **org** is your company in Mist, with its people, agents and roles. A **namespace** is where a team's workspaces
and lakes live; you work in one at a time.

## Install

```bash
pip install mist-sdk     # Python 3.10 or later: the Python package `mist` and the command `mist`
```

`mist --version` (and `mist.__version__` in Python) is the version installed.

## Sign in

```bash
mist login https://mist.example   # the address of your company's Mist; opens your identity provider in the browser
mist whoami
```

`mist login <url>` keeps your sign-in and the address of your Mist, and prints the line that sets
`MIST_IDENTITY_TOKEN_FILE` to the sign-in (`export MIST_IDENTITY_TOKEN_FILE=$HOME/.mist/identity-token`). Set it, and
DuckDB, PyIceberg and other tools use your sign-in the same way as the SDK. From then on the SDK and the command call
that address, with that sign-in. `mist login <another url>` switches to another Mist; `mist login` alone signs in
again to the same one; `--no-browser` gives a code to enter on another device. When the sign-in expires, a call says so.

## A first workspace

```python
import mist

ns = mist.connect(org="acme", namespace="research")
ws = ns.workspaces.create("market-research", description="Q3 notes")
ws.write_text("notes.md", "# Notes\n", if_absent=True)   # every write names what it is based on
print(ws.read_text("notes.md"))
```

## In an agent runtime

Install `mist-sdk` (and `mist-mcp`, for the tools) in the runtime, give the agent its platform's token file, and set
`MIST_NAMESPACE` once to the full name of the namespace it works in. Its calls then name only the address:

```bash
export MIST_IDENTITY_TOKEN_FILE=/var/run/secrets/mist/token
export MIST_NAMESPACE=arn:mist:mist::acme:namespace/research
mist-mcp --url https://mist.example            # the MCP tools, with no org or namespace in each call
```

```python
ns = mist.connect(url="https://mist.example")  # the namespace MIST_NAMESPACE names, in its org
```

A `namespace=` (or `--namespace`) you pass is used instead; an `org=` passed alone must be that namespace's org.

| Variable | What | Overridden by |
|---|---|---|
| `MIST_IDENTITY_TOKEN_FILE`, else `AWS_WEB_IDENTITY_TOKEN_FILE` | a file holding the token (read again when it changes) | `token_file=`, `token_provider=`, `--token-file` |
| `MIST_CA_BUNDLE` | a CA file to trust instead of the system's trust store | `verify=`, `--ca-bundle` |
| `MIST_NAMESPACE` | a namespace's full name, `arn:mist:mist::<org>:namespace/<name>`: the namespace and org of a call that names neither | `namespace=`, `org=`, `--namespace`, `--org` |

With no token file set, the SDK and the command use the sign-in of `mist login`. `mist logout` forgets it. Every
argument of `mist.Client` and `mist.connect` is named (`url=`, `org=`, `namespace=`, ...).

Any program that runs without a person (a pod, a CI job) names the address on every call (`url=` in Python, `--url` on
the command line) and points `MIST_IDENTITY_TOKEN_FILE` at a file holding its identity provider's token. The people who
run your company's identity provider give such a program its identity.

## What you can do with it

- **A month-end reconciliation that runs for days.** A matching agent loads the ledger and bank extracts into a lake
  and writes the matched lines and the exceptions as tables. Two accountants and a review agent keep their notes on
  the exceptions in a workspace. A save based on an old revision is refused and nothing is lost, so nobody overwrites
  anybody, and the workspace's history says who changed which file and when.
- **A daily document intake handed from agent to agent.** An intake agent puts the day's invoices in a workspace's
  `inbox/`. An extraction agent writes `extracted/<id>.json` and moves the invoice to `done/` in one change that is
  all or nothing. The validation agent reads what changed since its last look, and the clerk reads the same files.
- **Share with a role.** Let the role `reviewers` read the workspace or the lake, with the same policy calls for both.
- **Go back.** Bring back an earlier revision of a file an agent broke, or read a table as it was yesterday.

## Workspaces and lakes

```python
import mist

ns = mist.connect(org="acme", namespace="research")
ws = ns.workspaces.create("market-research", description="Q3 notes", tags={"team": "research"})
ws.write_text("notes.md", "# Notes\n", if_absent=True)   # every write names what it is based on
notes = ws.get_file("notes.md")
updated = notes.write_text("# Notes\n- rate is 5%\n")    # based on notes.revision; returns the new revision's handle
ws.changes()                                          # who changed what, oldest first

lake = ns.lakes.create("orders", description="Daily order lines", tags={"team": "research"})
lake.catalog_url, lake.warehouse                      # what DuckDB, PyIceberg and Polars attach to

```

```bash
mist workspaces create market-research --org acme --namespace research --description "Q3 notes" --tag team=research
mist lakes create orders --org acme --namespace research --description "Daily order lines" --tag team=research
mist lakes get orders --org acme --namespace research
```

## Orgs and namespaces

Every call names the org and the namespace it works in: `org=` and `namespace=` in Python, `--org` and `--namespace`
on the command line, or `MIST_NAMESPACE` when both are left out. A namespace's full name names its org too, so it can stand alone:
`mist.connect(namespace="arn:mist:mist::acme:namespace/research")`, `--namespace arn:mist:mist::acme:namespace/research`.
`client.namespaces.list()` and `mist namespaces list --org acme` list the namespaces you can use, each with its `arn`;
`ns.arn`, `ws.arn` and `lake.arn` are the full names `client.policies` takes.

Roles, policies and sharing (`client.roles`, `client.policies`, `mist roles`, `mist policies`) are in one guide, the
security reference that ships with the Mist plugin for Claude Code (its `mist` skill, `references/security.md`).

## Output and errors

The command prints JSON on stdout; a delete prints nothing.

Every error is a `mist.MistError` with `code` (stable: `AccessDenied`, `NoSuchEntity`, `RevisionConflict`, ...),
`message`, `next` (what to do: `retry`, `retry_later`, `reread_and_redo`, `fix_arguments` or `ask_person`),
`retryable` and `request_id`; an error from the service (`mist.APIStatusError` and its subclasses) also carries
`status` and `rule`. The SDK retries a call that never reached the service, and a call that is safe to repeat after a
lost reply, a 5xx or a 429. On the command line an error goes to stderr, ending with a `next:` line, and the exit
status follows the step: 1 fix the arguments, 3 read again and redo, 4 ask a person, 5 try again; 2 is a command
line the command cannot parse.

## Licence

Mist evaluation build: you may download and run it only to evaluate it; production use is not permitted (`LICENSE`).
