Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ bare clone with no workspace, the full guide is at <https://docs.start9.com/pack
- **The interface port is defined once, in `startos/utils.ts`.** `startos/main.ts`
passes it to `opencode serve` and health-checks it, and `startos/interfaces.ts`
binds it. If the port ever changes, all three must change together.
- **The password is delivered only through the environment.** OpenCode reads
`OPENCODE_PASSWORD`, with the username fixed at `opencode`; it cannot be handed a
password hash in a config file. `startos/fileModels/store.json.ts` holds the value
on the `startos` volume, which no subcontainer mounts. Do not "improve" this by
writing OpenCode's own config file.
- **The login password and provider API keys reach the container only through the
environment.** OpenCode reads the password from `OPENCODE_PASSWORD` (username fixed
at `opencode`) and each provider key from `OPENCODE_KEY_<ID>`; neither can be handed
to it as a hash. `startos/fileModels/store.json.ts` holds both on the `startos`
volume, which no subcontainer mounts, and `opencode.json` refers to a key as
`{env:…}` rather than carrying it.
- **`opencode.json` is written by the Configure Model Providers action, never
generated at startup.** OpenCode reloads that file live, so a provider change needs
no restart — but a new or changed key does, which is why `main.ts` reads
`providerKeys` reactively. Rebuild the `providers` map from the form on every save:
that is what makes leaving an entry out disconnect the provider.
- **`startos/main.ts` mounts the `main` volume over the container's entire home**
(`/root`), which is where OpenCode keeps sessions, provider credentials, cloned
repositories, and projects. Narrowing the mountpoint drops user data from backups.
Expand Down
82 changes: 59 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The package declares two volumes.
| Volume | Mount point | Contents |
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `main` | `/root` (read-write) | The container's entire home: sessions, credentials, repositories, projects, and OpenCode's own config, state, and cache. |
| `startos` | not mounted | StartOS-side state: `store.json`, holding the generated login password. |
| `startos` | not mounted | StartOS-side state: `store.json`, holding the generated login password and the configured providers' API keys. |

`main` is mounted over the image's home directory, so everything OpenCode writes
under `/root` persists across restarts and updates:
Expand All @@ -68,31 +68,38 @@ under `/root` persists across restarts and updates:
lost on restart; treat anything only in there as scratch.

The `startos` volume is deliberately not mounted into `opencode-sub`, so the
running server never sees the password file — it receives the password through
the `OPENCODE_PASSWORD` environment variable instead.
running server never sees the file itself — it receives the login password as
`OPENCODE_PASSWORD` and each configured provider's API key as an
`OPENCODE_KEY_<ID>` variable instead.

## File Models

The package owns exactly one file model: `store.json` on the `startos` volume.
The package owns two file models.

| File | Format | Key | Seeded by | Rewritten by |
| -------------------- | ------ | --------------- | --------------------------------- | ---------------------------- |
| `startos/store.json` | JSON | `adminPassword` | the **Set Admin Password** action | the same action, on each run |
| File | Format | Keys | Seeded by | Rewritten by |
| ------------------------------------- | ------ | ------------------------------- | ---------------------------------------- | ---------------------------- |
| `startos/store.json` | JSON | `adminPassword`, `providerKeys` | the **Set Admin Password** action | the two actions, on each run |
| `main/.config/opencode/opencode.json` | JSON | `$schema`, `providers`, `model` | the **Configure Model Providers** action | the same action, on each run |

`adminPassword` is stored in clear text because the server reads it verbatim
from `OPENCODE_PASSWORD` and cannot be given a hash. There is no default: it is
absent until the user runs the action, which is what the [task](#tasks) waits
for.
for. `providerKeys` maps a configured provider's id to its API key, and has no
default either.

The schema is permissive (`z.looseObject`, every key optional), so the file is
never rewritten by the package on its own — only the action writes it, and it
only ever merges the one key. A hand edit to `adminPassword` therefore survives:
the running server watches the file and restarts with the new value. Nothing
else re-asserts or normalizes the file.
Both schemas are permissive (`z.looseObject`, every key optional), and the
package writes each file only from an action — never at startup, and never to
normalize or repair it. A hand edit therefore survives:

OpenCode's **own** configuration file (`~/.config/opencode/opencode.json`, or
`opencode.jsonc`, on the `main` volume) is not modeled by this package. OpenCode
writes and reads it, and the package neither seeds nor rewrites it.
- In `store.json`, the running server watches the file and restarts with the new
value.
- In `opencode.json`, OpenCode watches the file and reloads it without a restart.
The package leaves every key it does not own — including whatever OpenCode
writes there itself — as it found it.

`opencode.json` is OpenCode's own global configuration, at the path OpenCode
reads it from. The package models it so the Configure Model Providers action can
write provider entries; it is not generated, replaced, or seeded otherwise.

## Dependencies

Expand Down Expand Up @@ -124,14 +131,15 @@ complete and nothing to configure on disk.
3. The user opens the `ui` interface, signs in on the web page with the username
`opencode` and that password.

Model providers are not preconfigured; connecting one is part of using the app,
not part of install. Nothing upstream is disabled or skipped, and the package
adds no files OpenCode did not already expect.
Model providers are not preconfigured; connecting one happens after install,
through the **Configure Model Providers** action rather than during it. Nothing
upstream is disabled or skipped, and the package adds no files OpenCode did not
already expect.

## Actions

One user-facing action. The OS carries its id, name, description, warning, and
status gating; what follows is what the metadata cannot express.
Two user-facing actions. The OS carries each one's id, name, description,
warning, and status gating; what follows is what the metadata cannot express.

### `set-admin-password` — Set Admin Password

Expand All @@ -149,6 +157,27 @@ status gating; what follows is what the metadata cannot express.
- **Outputs.** The username `opencode` (unmasked, copyable) and the new password
(masked, copyable).

### `configure-providers` — Configure Model Providers

- **When to run it.** After install, and whenever the set of models OpenCode can
use changes. It is the only way to connect a model: the packaged OpenCode web
interface has no provider screen of its own.
- **What it changes.** For each provider in the form, an entry in the `providers`
map of `main/.config/opencode/opencode.json`, and its API key under
`providerKeys` in `startos/store.json`. The `model` key is set to the provider
whose **Default** toggle is on, or dropped if that provider is removed. A new
or changed API key restarts the service, because the server receives it as an
`OPENCODE_KEY_<ID>` environment variable; a change that touches no key is
picked up by the running server without a restart.
- **Cost.** Seconds. Nothing outside the two files above is touched, and no
session, repository, or project is affected.
- **Repeat safety.** The form is prefilled from the current configuration and is
the authority for it: what the form lists is what the file holds afterwards, so
saving it unchanged changes nothing and leaving a provider out disconnects it.
An empty form therefore disconnects every provider.
- **Outputs.** Each provider with the model IDs it serves, and the default model
when one is set.

## Tasks

One task, raised by `startos/init/watchCredentials.ts`.
Expand Down Expand Up @@ -207,8 +236,12 @@ required.
2. **The `opencode pair` pairing-link flow is not wired up.** Sign in with the
password from the **Set Admin Password** action instead of a one-time pairing
link or QR code.
3. **Model provider credentials are not preconfigured.** Connect a provider in
the web UI after install; the package ships no provider configuration.
3. **Model providers are configured from StartOS, not from the app.** The
packaged OpenCode web interface has no provider screen, so providers are added
with the **Configure Model Providers** action. It covers OpenAI-compatible
endpoints — your own vLLM, LM Studio, or Ollama server, or a hosted API such
as OpenRouter. Provider families outside that shape are not configured by the
package.
4. **OpenCode's self-updater is disabled** in the container. The server is updated
by updating the StartOS package, not from inside the app.
5. **The container runs as `root`.** The upstream image does, and the package does
Expand All @@ -232,14 +265,17 @@ volumes:
startos: unmounted
file_models:
- startos/store.json
- main/.config/opencode/opencode.json
startos_managed_env_vars:
- OPENCODE_PASSWORD
- OPENCODE_DISABLE_AUTOUPDATE
- OPENCODE_KEY_<PROVIDER_ID>
dependencies: none
interfaces:
ui: { type: ui, port: 4096 }
actions:
- set-admin-password
- configure-providers
tasks:
- { action: set-admin-password, severity: critical }
health_checks:
Expand Down
39 changes: 36 additions & 3 deletions instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ StartOS server. You use it from a browser:
3. On the **Connect to a server** screen, click **Use password**. The server
address is already filled in — leave it as it is — paste the password, and
click **Connect**.
4. In the web app, open **Settings → Providers** and connect a model provider
(an API key, or your OpenCode Console account). OpenCode can't do anything
until it has a model to use.
4. Before OpenCode can answer anything it needs a model to use. From StartOS, run
the **Configure Model Providers** action and add your provider — see
[Connecting a model provider](#connecting-a-model-provider).
5. Back on the home screen, click **Add project** and choose a folder to work in.
Pick a folder inside your home directory (`~/…`, shown as `root` when you
browse from `/`) — that is where your server keeps data across restarts.
Expand All @@ -52,6 +52,35 @@ open past sessions, and change settings from the sidebar. The same address also
serves the HTTP API under `/api/*`, if you want to drive the server from your own
scripts.

### Connecting a model provider

OpenCode talks to any OpenAI-compatible endpoint — a vLLM, LM Studio, or Ollama
server you run yourself, or a hosted API such as OpenRouter. You add one from
StartOS, not from the web app, with the **Configure Model Providers** action.
Each entry asks for:

- **ID** — a short name used to identify the provider (`vllm`). Lowercase
letters, digits, and dashes.
- **Name** — how the provider appears in OpenCode's model list (`Lab vLLM`).
- **Base URL** — the endpoint's API root, including `/v1`, for example
`http://192.168.1.50:8000/v1`.
- **API Key** — only if the endpoint checks one. Leave it blank for a local
server that accepts any request. It is kept on the StartOS side and is never
written into the configuration file.
- **Models** — one entry per model ID the endpoint serves, for example
`glm-5.3`. If you are not sure of the exact IDs, the endpoint lists them under
`/v1/models`.
- **Default** — turn this on to make the first model in the list the one new
sessions start on.

Save, and the models are available in the web app right away — refresh the page
if the picker still looks empty.

Run the action again to change an endpoint or add another provider, and delete a
provider by removing its entry from the list. The API key of a provider you have
already configured is filled in when the form opens, so leave it as it is unless
you are replacing it.

### Changing the password

Run **Set Admin Password** again at any time to generate a new password. The
Expand All @@ -71,6 +100,10 @@ login password back as they were.
password from the **Set Admin Password** action instead.
- **The server does not update itself.** OpenCode's in-app update check is turned
off; update the service by updating this package in StartOS.
- **Providers are configured from StartOS, not from the app.** The web app in this
version has no provider screen — use the **Configure Model Providers** action.
It connects OpenAI-compatible endpoints, such as vLLM, LM Studio, Ollama, and
OpenRouter.

### If you publish the interface through a tunnel

Expand Down
Loading