Skip to content

Commit 5321d25

Browse files
committed
docs(api+laws): align verbs with OpenAI public API + fix env-layer ordering
INDEX.md sec 2 (API surface): - /v1/mcp Method was 'filesystem' (not an HTTP verb). Corrected to GET and re-marked as a MiOS extension (the public OpenAI surface invokes MCP via POST /v1/responses with tools=[{type:'mcp', server_url:...}]; /v1/mcp is a MiOS-internal manifest endpoint that populates that tools array). - Enumerate the canonical OpenAI endpoints LocalAI serves (chat/completions, responses, embeddings, models, audio/*) with per-row spec links to platform.openai.com/docs/api-reference. The prior table omitted everything except chat/completions + models. - 'x-mios:' prefix marks rows that are MiOS extensions, so strict OpenAI clients can ignore them by name. INDEX.md sec 3 Law 5: - Replace 'MIOS_AI_KEY, MIOS_AI_MODEL, MIOS_AI_ENDPOINT -> URL' (which implied all three vars equal the URL) with role-explicit wording: ENDPOINT is the OpenAI-SDK base_url slot, MODEL is the default model id, KEY is the api_key (empty for the local proxy). - Add /etc/profile.d/mios-env.sh and /usr/bin/mios-env to the enforcement column -- they are the canonical resolver + CLI now. INDEX.md sec 4 + etc/profile.d/mios-env.sh + /usr/bin/mios-env: - Reorder the environment-layer overlay so legacy ~/.env.mios sits between vendor defaults and admin/host layers (was at the bottom in INDEX.md, just-below-current in the resolver -- both wrong). Correct precedence (lowest -> highest): 1. /usr/share/mios/env.defaults 2. ~/.env.mios (legacy) 3. /etc/mios/env.d/*.env 4. /etc/mios/install.env 5. ~/.config/mios/env This guarantees a stale legacy file cannot override a fresher install.env or env.d entry, while still honoring legacy values when no fresher source supplies them. - Reorder the LAYERS array in /usr/bin/mios-env to match. - Fix INDEX.md prose: list now reads lowest -> highest with that direction stated explicitly, since the previous '1 = highest' framing was the source of the inconsistency.
1 parent 7b56947 commit 5321d25

3 files changed

Lines changed: 53 additions & 29 deletions

File tree

INDEX.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,27 @@ OCI image. Source: `README.md`, `Containerfile`. Image:
1313
## 2. API surface (OpenAI-compatible)
1414

1515
All system agents target the local proxy at `http://localhost:8080/v1`,
16-
served by the LocalAI Quadlet at `etc/containers/systemd/mios-ai.container`.
17-
18-
| Path | Method | Manifest |
19-
|---|---|---|
20-
| `/v1/chat/completions` | POST | LocalAI runtime |
21-
| `/v1/models` | GET | `usr/share/mios/ai/v1/models.json` |
22-
| `/v1/mcp` | filesystem | `usr/share/mios/ai/v1/mcp.json` |
23-
24-
Spec: <https://platform.openai.com/docs/api-reference>.
16+
served by the `mios-ai.container` Quadlet (LocalAI runtime). The
17+
endpoints below follow the OpenAI public API spec
18+
(<https://platform.openai.com/docs/api-reference>) verb-for-verb;
19+
`x-mios.*` rows are MiOS extensions, clearly namespaced so strict
20+
OpenAI clients can ignore them.
21+
22+
| Path | Method | Served by | Spec |
23+
|---|---|---|---|
24+
| `/v1/chat/completions` | POST | LocalAI runtime | <https://platform.openai.com/docs/api-reference/chat> |
25+
| `/v1/responses` | POST | LocalAI runtime | <https://platform.openai.com/docs/api-reference/responses> |
26+
| `/v1/embeddings` | POST | LocalAI runtime | <https://platform.openai.com/docs/api-reference/embeddings> |
27+
| `/v1/models` | GET | `usr/share/mios/ai/v1/models.json` | <https://platform.openai.com/docs/api-reference/models/list> |
28+
| `/v1/audio/{transcriptions,speech}` | POST | LocalAI runtime (when configured) | <https://platform.openai.com/docs/api-reference/audio> |
29+
| `x-mios:/v1/mcp` | GET | `usr/share/mios/ai/v1/mcp.json` | <https://modelcontextprotocol.io/specification> |
30+
31+
`/v1/mcp` is a MiOS extension (not part of the OpenAI public API). The
32+
canonical OpenAI route to invoke an MCP server is
33+
`POST /v1/responses` with `tools=[{"type": "mcp", "server_url": ...}]`;
34+
the manifest at `/v1/mcp` is what MiOS agents read to populate that
35+
`tools` array. The `x-mios:` prefix is a documentation marker only --
36+
the served URL is `/v1/mcp`.
2537

2638
## 3. Architectural laws (enforced; non-negotiable)
2739

@@ -31,7 +43,7 @@ Spec: <https://platform.openai.com/docs/api-reference>.
3143
| 2 | **NO-MKDIR-IN-VAR** -- every `/var/` path declared via `usr/lib/tmpfiles.d/*.conf`. | `usr/lib/tmpfiles.d/mios*.conf` |
3244
| 3 | **BOUND-IMAGES** -- every Quadlet image symlinked into `/usr/lib/bootc/bound-images.d/`. Binder loop: `automation/08-system-files-overlay.sh:74-86`. | `usr/lib/bootc/bound-images.d/` |
3345
| 4 | **BOOTC-CONTAINER-LINT** -- final RUN of `Containerfile`. | `Containerfile` (last `RUN`) |
34-
| 5 | **UNIFIED-AI-REDIRECTS** -- `MIOS_AI_KEY`, `MIOS_AI_MODEL`, `MIOS_AI_ENDPOINT` `http://localhost:8080/v1`. No vendor URLs. | `usr/bin/mios`, `etc/mios/ai/` |
46+
| 5 | **UNIFIED-AI-REDIRECTS** -- every OpenAI-API-shaped client resolves through one canonical surface: `MIOS_AI_ENDPOINT` (default `http://localhost:8080/v1`, the OpenAI-SDK `base_url` slot), `MIOS_AI_MODEL` (default model id), `MIOS_AI_KEY` (api key, empty for the local proxy). No vendor-hardcoded URLs. | `/etc/profile.d/mios-env.sh`, `usr/bin/mios`, `usr/bin/mios-env`, `etc/mios/ai/` |
3547
| 6 | **UNPRIVILEGED-QUADLETS** -- every Quadlet declares `User=`, `Group=`, `Delegate=yes`. Documented exceptions: `mios-ceph` and `mios-k3s` declare `User=root`/`Group=root` because Ceph/K3s require uid 0 (see file headers). | `etc/containers/systemd/`, `usr/share/containers/systemd/` |
3648

3749
## 4. Profile + environment resolution
@@ -48,13 +60,19 @@ and at runtime by `mios` CLI clients):
4860
3. `/usr/share/mios/profile.toml` -- vendor defaults (shipped by `mios.git`,
4961
immutable, USR-OVER-ETC)
5062

51-
**Environment layers** (resolved by `/etc/profile.d/mios-env.sh` at login):
63+
**Environment layers** (resolved by `/etc/profile.d/mios-env.sh` at
64+
login; later sources override earlier values, so this list runs from
65+
**lowest** precedence to **highest**):
66+
67+
1. `/usr/share/mios/env.defaults` -- vendor defaults (lowest)
68+
2. `~/.env.mios` -- legacy per-user (deprecated; honored only when no
69+
admin/host/current source supplies the same key)
70+
3. `/etc/mios/env.d/*.env` -- admin/distro drop-ins (alphabetical)
71+
4. `/etc/mios/install.env` -- host identity, written by bootstrap
72+
5. `~/.config/mios/env` -- canonical per-user override (highest)
5273

53-
1. `~/.config/mios/env`
54-
2. `/etc/mios/install.env` (written by bootstrap install.sh)
55-
3. `/etc/mios/env.d/*.env` (admin/distro drop-ins)
56-
4. `/usr/share/mios/env.defaults` (vendor defaults)
57-
5. `~/.env.mios` (legacy, deprecated; kept for backwards compatibility)
74+
The CLI `/usr/bin/mios-env` prints the resolved surface (`--explain`
75+
shows which layer supplied each key).
5876

5977
**Build-time variables** read by `Justfile`:
6078

etc/profile.d/mios-env.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
# MIOS_* variables so every agent and CLI sees the same values regardless
66
# of which shell or terminal launched them.
77
#
8-
# Resolution order (later layers override earlier values):
8+
# Resolution order (later layers override earlier values, so this list
9+
# runs from LOWEST precedence to HIGHEST):
910
# 1. /usr/share/mios/env.defaults vendor defaults (lowest)
10-
# 2. /etc/mios/env.d/*.env admin/distro drop-ins (alphabetical)
11-
# 3. /etc/mios/install.env host bootstrap-written identity
12-
# 4. ~/.env.mios legacy per-user (deprecated)
13-
# 5. ~/.config/mios/env per-user override (highest)
11+
# 2. ~/.env.mios legacy per-user (deprecated;
12+
# sourced before admin/host so a
13+
# stale legacy value cannot
14+
# override a fresher install.env
15+
# or env.d/*.env entry)
16+
# 3. /etc/mios/env.d/*.env admin/distro drop-ins (alphabetical)
17+
# 4. /etc/mios/install.env host bootstrap-written identity
18+
# 5. ~/.config/mios/env canonical per-user override (highest)
1419
#
1520
# Architectural Law 5 (UNIFIED-AI-REDIRECTS): MIOS_AI_ENDPOINT,
1621
# MIOS_AI_MODEL, and MIOS_AI_KEY are exported here so every OpenAI-API
@@ -41,24 +46,25 @@ _mios_source_if_readable() {
4146
. "$1"
4247
}
4348

44-
# Layer 1: vendor defaults (always present on a 'MiOS' system).
49+
# Layer 1 (lowest): vendor defaults (always present on a 'MiOS' system).
4550
_mios_source_if_readable /usr/share/mios/env.defaults
4651

47-
# Layer 2: admin / distro drop-ins (alphabetical, env-style).
52+
# Layer 2: legacy per-user env file (deprecated; sourced before
53+
# admin/host so a stale ~/.env.mios cannot override fresher data).
54+
_mios_source_if_readable "${HOME}/.env.mios"
55+
56+
# Layer 3: admin / distro drop-ins (alphabetical, env-style).
4857
if [ -d /etc/mios/env.d ]; then
4958
for _f in /etc/mios/env.d/*.env; do
5059
_mios_source_if_readable "$_f"
5160
done
5261
unset _f
5362
fi
5463

55-
# Layer 3: host install.env -- bootstrap writes identity here.
64+
# Layer 4: host install.env -- bootstrap writes identity here.
5665
_mios_source_if_readable /etc/mios/install.env
5766

58-
# Layer 4: legacy per-user env file (deprecated; kept for migration).
59-
_mios_source_if_readable "${HOME}/.env.mios"
60-
61-
# Layer 5: canonical per-user env override.
67+
# Layer 5 (highest): canonical per-user env override.
6268
_mios_source_if_readable "${HOME}/.config/mios/env"
6369

6470
# Export the OpenAI-API surface required by every Law-5-compliant agent.

usr/bin/mios-env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set -euo pipefail
2424
# Canonical layer paths (mirrors mios-env.sh).
2525
LAYERS=(
2626
"/usr/share/mios/env.defaults"
27+
"${HOME}/.env.mios"
2728
)
2829
# /etc/mios/env.d/*.env (alphabetical)
2930
if [[ -d /etc/mios/env.d ]]; then
@@ -33,7 +34,6 @@ if [[ -d /etc/mios/env.d ]]; then
3334
fi
3435
LAYERS+=(
3536
"/etc/mios/install.env"
36-
"${HOME}/.env.mios"
3737
"${HOME}/.config/mios/env"
3838
)
3939

0 commit comments

Comments
 (0)