@miadi/connector 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -23
- package/STEERING.md +7 -3
- package/dist/approve.d.ts +28 -3
- package/dist/approve.js +179 -25
- package/dist/claude-models.d.ts +69 -4
- package/dist/claude-models.js +111 -22
- package/dist/config.d.ts +2 -2
- package/dist/config.js +4 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +68 -7
- package/dist/draft-review.d.ts +3 -1
- package/dist/draft-review.js +34 -6
- package/dist/mission-standard.d.ts +5 -0
- package/dist/mission-standard.js +14 -0
- package/dist/tools.js +72 -20
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
One remote MCP service through which a person reaches Miadi from ChatGPT, Claude or any MCP client. Each person signs in with their own Miadi person token. They read agent sessions, Miadi reviews, Chronicle episodes and circles, and record observations, inquiries, handoffs and proposals. Every record carries the person's name.
|
|
4
4
|
|
|
5
|
-
The
|
|
5
|
+
The session reads use Miadi's `GET /api/session` and `GET /api/session/{id}`.
|
|
6
6
|
|
|
7
7
|
## Connect
|
|
8
8
|
|
|
9
|
+
A connector answers at `$MIADI_CONNECTOR_PUBLIC_URL/mcp`, the public address the host that runs it sets ([Run it](#run-it)). Ask that host's operator for the address. On a machine set up with the `miadi-config` apt package, `miadi-config get MIADI_CONNECTOR_PUBLIC_URL` prints it.
|
|
10
|
+
|
|
9
11
|
| client | how |
|
|
10
12
|
|---|---|
|
|
11
|
-
| ChatGPT | Add a custom connector (an app with an MCP server) with the URL
|
|
12
|
-
| Claude Code | `claude mcp add --transport http miadi
|
|
13
|
+
| ChatGPT | Add a custom connector (an app with an MCP server) with the URL `$MIADI_CONNECTOR_PUBLIC_URL/mcp`, written out, and OAuth authentication. ChatGPT registers itself; the sign-in page then asks for your Miadi person token once. |
|
|
14
|
+
| Claude Code | `claude mcp add --transport http miadi "$MIADI_CONNECTOR_PUBLIC_URL/mcp" --header "Authorization: Bearer <your Miadi person token>"` |
|
|
13
15
|
| any MCP client | Streamable HTTP at `/mcp`, OAuth 2.1 with dynamic client registration and PKCE, or a Miadi person token as Bearer. |
|
|
14
16
|
|
|
15
17
|
A person token comes from `/me` on Miadi (or an admin, under /admin → People).
|
|
@@ -43,7 +45,7 @@ The model that asked cannot approve its own request.
|
|
|
43
45
|
|
|
44
46
|
`get_run_result` returns one `projection` of the decision, dispatch/completion state, receipt link and outstanding instructions. The in-chat card, approval page and Miadi's research page use that same read model. Asking `show_decisions` for an already-decided `record_id` shows its receipt without issuing another decision token. An in-flight card can refresh status without repeating the operation. A completed basic review with unapplied approval instructions remains open as **changes outstanding**, not falsely finished.
|
|
45
47
|
|
|
46
|
-
### A review's transcript
|
|
48
|
+
### A review's transcript
|
|
47
49
|
|
|
48
50
|
A review is processed from the words of its video, so the connector acquires them itself, for a review made anywhere: the review service's own page, a manual edit, another client, or this connector's `create`.
|
|
49
51
|
|
|
@@ -54,11 +56,11 @@ A review is processed from the words of its video, so the connector acquires the
|
|
|
54
56
|
- **Every review, however it was made.** The review service announces `review.created` for each review it creates (its site, its API, a Shortcut, this connector), built with `@miadi/hooks-core`'s `buildReviewCreatedEvent` and signed like its other factory webhooks. Miadi's `/api/factory/review-events` normalizes it, records it in the event ledger (`@miadi/hooks-gateway`, `MIADI_EVENTS_DIR`, default `/srv/miadi/events`) and hands it to this connector's inbox, `inbox/connector-transcripts/`. Every 15 seconds the connector takes up to three: it asks the review service for the review again, starts the review's transcript job (a review that already holds one stores nothing, a withheld source is held), records the fact as the job's authority, and moves the file to `done/` or, with the reason, to `rejected/`. A fact waits in the inbox while the connector is down or the review service cannot be asked.
|
|
55
57
|
- **Endings are facts too.** When a job reaches `stored`, `held` or `failed`, the connector records `review.transcript.stored`, `review.transcript.held` or `review.transcript.failed` in the same ledger, on the review's trace (`miadi-review:<id>`) and naming the fact that caused it. The same ending recorded twice is one fact.
|
|
56
58
|
- **A worker's door.** A factory worker's account holds no Miadi API tier, so it cannot call the tools. `node packages/connector/scripts/ensure-transcript.mjs <review id> --mission run_request:<id> [--verify]` runs the same job under an approved run or work proposal that names the review (a person with the write tier approved it, and the job records the mission and who approved it). `--status` reads the state without a mission. A second process's attempt is left alone until it has written no stage for five minutes.
|
|
57
|
-
- **The host's reading runtime.** `get_capabilities` loads the module `MIADI_READING_ADAPTER` names (`scripts/host-reading-runtime.mjs`
|
|
59
|
+
- **The host's reading runtime.** `get_capabilities` loads the module `MIADI_READING_ADAPTER` names (`scripts/host-reading-runtime.mjs` in the source tree) and reports `reading_workflow.provider_runtime` from what it finds: `verified_transcript_only` while only caption acquisition has a provider. A reading acquires its transcript with the same reader and the same language rule, keeps durable stage receipts, and stops at the generation stages with a named blocker. Acquiring a transcript does not depend on the review service's import handshake.
|
|
58
60
|
|
|
59
61
|
### Revising a mission before it is decided
|
|
60
62
|
|
|
61
|
-
A mission is revised, never re-requested
|
|
63
|
+
A mission is revised, never re-requested. `revise_pending_request` changes an agent run or work proposal that still awaits a decision, or that its approver sent back, and gives it its next version. Pass the version you read as `expected_version` and only the fields that change. The request keeps its id, its approval page and its one card. A change of `provider` is verified on the host again. Each revision is a record in the ledger carrying the whole new content, its reason, author, changed fields and `sha256` content hash, so every earlier version stays readable verbatim with `get_request_history`. A request already approved, queued or declined is refused: a change after a decision is a new request or a steer.
|
|
62
64
|
|
|
63
65
|
A decision names the version it decides. The approval page carries the version it shows, and each card's decision token is bound to its version. A page or card that showed an earlier version is refused as `stale_version`, so no brief is queued for a version the person did not read. The receipt and the brief (`version="N"`, and the hash) name the version approved.
|
|
64
66
|
|
|
@@ -68,13 +70,13 @@ Requests made before this, one new request per revision, are joined with `supers
|
|
|
68
70
|
|
|
69
71
|
`mission_status` joins one mission read-only: its source request and decision, the sessions bound to it (each with how it is bound — a signed `session:` ref, the delivered brief's target, or the requested name), its issues and PRs, its steering grant, and where it stands stage by stage — approved, queued, delivered, running, merged, released, closed — each by its evidence, so an idle pane or a merge is never read as completion. Live panes and Miadi's session view are joined only for the write tier.
|
|
70
72
|
|
|
71
|
-
A mission is found by the issue it implements
|
|
73
|
+
A mission is found by the issue it implements. `request_authorized_run` and `propose_work` take `primary_issue`; older requests are read by their first issue ref, as an inference. An issue held as primary by several requests answers `ambiguous_mission` with the candidates, an issue only cited answers `related_only`, and only a record id or a declared primary that no older request holds by inference (`contested`) authorizes a steer, release or closure (`identity.authorizes_actions`). A release receipt names artifact, target, production check and check time; record it as `completion_receipt.release` on a handoff that cites the mission. `released` is `verified` only when the connector confirms it itself (the target is `miadi-connector` and the running version is the one released); any other complete receipt within seven days is `receipt_recorded`, with who recorded it and whether that was the approver. Old checks are `stale`; a version string, a future date or an incomplete receipt is `claimed_unverified`. `closed` needs an approved `propose_session_completion` ending (`exit` or `complete_then_exit`) that names the mission in its `mission` field and ends one of the mission's sessions; a completed request is `request_completed`. A GitHub reference the connector cannot read is `unverified`, with the reason (`no_github_token`, `not_visible_to_token`…), never `not_found`.
|
|
72
74
|
|
|
73
|
-
**The factory binding
|
|
75
|
+
**The factory binding.** The factory runner records every brief it hands to a seat in `delivered.jsonl`: the record, the tmux session, the pane id and the Claude Code session id that took the line. `mission_status` reads that receipt (write tier) and checks it against Miadi's session registry: `binding` is `verified` when both agree on session, tmux session and pane, `receipt_only` when the registry cannot confirm it, `unverified_association` when the registry places the session elsewhere or the pane is gone. Busy or idle comes from the registry when the binding is verified, else from a read-only peek of the bound pane, and is never read as completion. `mission_status` with `session:<uuid>` finds the one mission the factory delivered to that session (`factory_bound`); two are `ambiguous_mission`. `provider` names the provider requested, resolved and actually run, and `match: false` when they differ; nothing is re-run because of it. `get_session` lists the missions the factory delivered to the session (`binding: "factory_receipt"`), then the miadi-run missions Miadi links to it from their records and its inventory record (`binding: "miadi_run"`).
|
|
74
76
|
|
|
75
|
-
**The agent's result
|
|
77
|
+
**The agent's result.** An agent returns its work with `propose_session_completion` naming the mission in `mission`, from its bound session, with its evidence refs and, optionally, a structured `result`: `summary`, `outputs` (`ref`, `label`, `git_sha`), `tests` (`command`, `passed`, `failed`, `skipped`) and `blockers`. `mission_status` and `get_run_result` read it back by the mission id as `result`: the standing submission (the newest `verified` one: it names the mission, ends a bound session and was submitted with Miadi's write tier or the factory's writer token, which the connector records on the ending as `submitted_with_tier`; anything else naming the mission is `unverified_association` with an `association_code`, a mere citation `cited_only` and never a result), its summary, tests and blockers as the agent's claim, and each output typed and checked when read. A commit or file on GitHub is read through GitHub (`GITHUB_TOKEN` when the host has one): `verified` with its sha, `changed_since_submission` when its declared `git_sha` no longer matches or the file changed on its branch after the submission, `unverified` with the reason when GitHub cannot be read, never `not_found`. A connector record id the ledger does not hold is `not_found`. Bound sessions are taken from the factory's receipts for every reader, so the verdict is the same at every tier; below the write tier the session ids are left out. The completion decision stays the person's, and only a verified submission sets it: `stage_truth.completion` is `pending_approval`, `accepted`, `declined` or `revision_requested` (`none` for an unverified one, whose stage is `result_submitted_unverified`; an approved exit submitted below the write tier closes nothing), `pending_human_gates` lists what waits on a person with its approval page, and `mission_stage` names the furthest stage with evidence (`result_submitted_awaiting_completion_approval`, `completion_accepted`, `merged`, `released`, `closed`…). A duplicate submission (same session, ending and mission, still pending) is handed back with `replayed: true`, and `not_recorded` names what the second call carried that was not kept.
|
|
76
78
|
|
|
77
|
-
`request_session_steer` sends one person's correction to a running agent, within the steering grant an approved run carries (`steering: { max_attempts, expires_at, pane }` on `request_authorized_run`). Busy is the normal case
|
|
79
|
+
`request_session_steer` sends one person's correction to a running agent, within the steering grant an approved run carries (`steering: { max_attempts, expires_at, pane }` on `request_authorized_run`). Busy is the normal case. [`STEERING.md`](STEERING.md) is the contract every provider's adapter keeps (`miadi.steering/1`), with what was shown on real sessions of Claude Code, Pi, Copilot and Codex and each one's limits. `get_capabilities.steering` and `provider_capabilities` serve the same matrix, with what this host would load into a new session.
|
|
78
80
|
|
|
79
81
|
| who | owns | never does |
|
|
80
82
|
|---|---|---|
|
|
@@ -105,30 +107,32 @@ The record itself moves with its evidence: `completed` once the model has it, `b
|
|
|
105
107
|
|
|
106
108
|
`revoke_session_steering` stops a run's steering or one steer. What is still pending moves out at once, a marker stops anything later, and the answer says exactly what was revoked and what the agent had already consumed. The same idempotency key gets the first answer back, and the same words under a new key answer `duplicate`. Only a typed or forwarded steer uses one of the grant's attempts.
|
|
107
109
|
|
|
108
|
-
An idle seat takes the same inbox, and the connector types into no session that has an adapter
|
|
110
|
+
An idle seat takes the same inbox, and the connector types into no session that has an adapter. Pi's and Copilot's adapters start a turn themselves. A Codex seat gets `codex queue` from the factory runner. A Claude Code seat gets one line from the factory runner, which holds none of the correction's words and waits for anyone's words at the prompt; the connector asks for that at once with `miadi-factory-runner wake` (`MIADI_FACTORY_RUNNER_BIN`), and the runner's timer is the net. The one case still typed by the connector is a Claude Code session from before its adapter, idle with an empty prompt: into the mission's bound pane, never whichever pane is active, with an exact tmux address (`=name:w.p`). It peeks first, presses Enter again while the words still sit at the prompt, and re-peeks after. Text already at the prompt, or a prompt box it cannot read, stops it. Any other provider without an adapter answers `unsupported`, and nothing is typed.
|
|
109
111
|
|
|
110
112
|
Rollback: run the connector version before this one (`git checkout` of its `dist`, then `systemctl --user restart miadi-connector`). A steer to a Pi, Copilot or Codex session then answers `unsupported` again and nothing else changes. To stop an adapter, follow [`STEERING.md`](STEERING.md#rollback); a new session then has no `adapter.json` and answers `unsupported`. Envelopes already queued stay on disk, unread.
|
|
111
113
|
|
|
112
114
|
`request_authorized_run` may name a `provider` (`codex`, `pi`, `copilot`, `claude`). The connector verifies it is installed on the host before recording anything; an unknown or unavailable provider answers `provider_unavailable` and the mission stays unstarted. With no provider named, a person's own default applies, then one the operator set for them, then Claude Code, and the result is named in the brief. A default that is missing or shows no sign-in leaves the mission unstarted, and no other provider stands in for it. Pi, Copilot and Codex otherwise run only when named. `provider_capabilities` (write tier) reports what the host has installed, the sign-in evidence, the preference order, and the read-only Jev check: `unconfigured` without `JEV_AI_API_KEY` or `TYPESAFE_API_KEY` in the connector's environment, else the models Jev lists for the key (no charge). A provider name inside a task's text selects nothing.
|
|
113
115
|
|
|
114
|
-
**Codex runs only on its requester's own choice
|
|
116
|
+
**Codex runs only on its requester's own choice.** The provider field is the caller's: the connector cannot read the chat, so `provider: "codex"` chooses nothing for the person. A run that names Codex is recorded, and its answer says it `needs_person_choice`. The approval page then shows no Approve button. Only the requester, signed in there with their own Miadi person token, can tick and send "Choose codex for this mission". That `provider_choice` record is bound to the request id, its version and its content hash, must be under 24 hours old when the request is approved, and covers that one mission. A revision makes it stale. A generic Approve, on the page or on a card, is refused as `provider_choice_required`, and so is a choice by any other person or by a service token. The requester can instead set their own policy at `/providers` so their requests may name Codex without a per-mission choice; that policy is theirs only and revisable. The check runs at request, revision, approval, and where the brief is written (approval and every rerun). The brief carries `provider_authorization` and `provider_choice` (or `provider_policy`), and the factory runner refuses to launch Codex for a connector brief without them. `request_authorized_run`, `revise_pending_request`, `mission_status`, `show_decisions` and `mission_model_preflight` show `provider_authorization`; after approval it is also in the request's `completion_receipt`, which `get_run_result` returns. A Codex launch without it is named on the mission and fails the preflight closed as `provider_not_authorized`. A brief the runner refuses goes to `queue/refused/` with its reason, and the request shows it. Other providers keep their regular policy, and nothing falls back to Codex. What this does not cover: anyone who can write `/srv/miadi/factory/queue` or the connector's state directory can forge a brief or a record (the folder's permissions are the boundary); a configured launcher that runs Codex behind a wrapper whose name does not say codex is trusted as configured; a brief to an existing session reaches only an idle Claude Code agent today, so it is not checked; and an agent that starts `codex` itself from inside its session is outside the connector's reach.
|
|
117
|
+
|
|
118
|
+
**Which Claude Code model a run launches on.** `request_authorized_run` and `propose_work` may name a `model`, and that model is used. It must be on the host's permitted list, and a model named with any other provider is refused, so a model never moves a mission to a provider nobody chose. With none named, Jev chooses among the permitted models once, when the run is approved. It is sent the task type and criticality (`task_type`, `criticality`; default `implementation`, `normal`) and the candidates, never task text, a mission id or a repository name, and its choice authorizes nothing. If Jev has no key, is down, abstains, answers below the 0.8 floor or breaks the answer contract, the launch uses the configured Claude Code model, and the receipt's `fallback_reasons` says why. Jev knows these models only through the fit notes in `claude-models.ts`, which are the Factory's reading of Anthropic's descriptions and not a measurement: `implementation` fits Sonnet, `file_relevance` and normal `review` fit Opus, `architecture_refactor` and anything `security_critical` fit Fable. Its confidence is uncalibrated. A request that fills no `task_type` counts as `implementation`, so it goes to Sonnet even where Claude Code's own setting says Opus; the draft review flags that absence (aspect S7), and the approval page and the receipt (`model_routing.labels`) say which label was a default and which the requester or the approver set.
|
|
115
119
|
|
|
116
|
-
**
|
|
120
|
+
**A floor, and the approver's fields.** A request may set `model_floor` (`opus`, `sonnet`, `haiku` or `fable`): the weakest model it may run on, for a floor its words set ("a high-reasoning review"). Models below it are offered to Jev as ineligible, so it chooses at or above the floor and reads no words; without Jev's choice the configured model launches, or the first permitted model at or above the floor when the configured one is below it. When no permitted model meets the floor, the approval page says so, offers only Approve with my changes, and a plain approve is refused as `model_floor_unmet`. A model named below the request's own floor is refused as `model_below_floor`. The draft review's S7 also flags words that set a model or a floor with no `model_floor` to carry them. A person approving with changes may set the model, the task type and the criticality in fields, on the approval page, on the card and in `decide_request`: a model they set launches with `model_source` `approver` and Jev is not asked, labels they set replace the request's in what Jev is sent, and the receipt keeps them as `routing_changes` and the replaced values as `model_routing.replaced`. Their instructions go to the agent and are not read for the model; the page says so before the click and the receipt says so after (`model_routing.instructions`). No reasoning effort is chosen: the seat starts at the `effortLevel` of Claude Code's settings on the host that opens it, and the receipt says so (`model_routing.effort`).
|
|
117
121
|
|
|
118
122
|
A session already running keeps its model: Jev is not asked, and a named model fails the run rather than being ignored. A request recorded before this behaviour launches as it was approved. If Claude Code is missing or shows no sign-in when a run is approved, the run fails with no brief and can be run again. The brief carries `model` and `model_source`, and the factory runner passes `--model`; publish the runner first, because a runner older than 0.1.5 ignores it. `mission_status` shows the choice, its source, the flag, the model the session's own transcript says answered, read when asked, and whether they match. A mismatch or an old runner is a note, and nothing is re-run. A config directory is sign-in evidence only: only the transcript shows a launch worked.
|
|
119
123
|
|
|
120
124
|
`factory.json` narrows the list and sets the fallback: `"claudeModels": ["opus", "sonnet"]`, `"claudeDefaultModel": "opus"`. Without them every model in `claude-models.ts` is permitted, and the fallback is the `model` in Claude Code's own settings. A list that leaves that setting out wins over it, and the fallback is then the first listed. A name goes on that list after a real answer shows it: `claude -p "Reply with OK." --model <name> --output-format json` names the model that answered under `modelUsage`, and an unknown name exits 1.
|
|
121
125
|
|
|
122
|
-
`mission_model_preflight` (write tier) answers, for one mission, which provider and model fit its task type and criticality, and how that is known: contract `miadi.mission_model_preflight` v1, candidates with their configured default model, sign-in evidence (config directory only), quota `unknown`, policy eligibility, a review floor, and a recommendation or an abstention with reasons. Its `decider.source` is `static_fallback`, `jev` or `synthetic_fixture`. Jev is asked only with `consult_jev: true` and a key on the host; it is sent task type, criticality and candidates, never task text, mission id or repository, and its answer is advisory: uncalibrated, below 0.8 or outside the contract, the preflight abstains. A reported `launch` on another provider than the approved one answers `provider_mismatch` before anything is asked. It authorizes nothing. `bench/model-preflight-bench.mjs` compares the 0.1.12 baseline, the static preflight and Jev on synthetic scenarios; `bench/results/` keeps the runs.
|
|
126
|
+
`mission_model_preflight` (write tier) answers, for one mission, which provider and model fit its task type and criticality, and how that is known. Left out, the task type and criticality are the mission's own, as a launch reads them (the approver's fields, else the requester's, else the default), its floor applies, and `labels` says where each came from: contract `miadi.mission_model_preflight` v1, candidates with their configured default model, sign-in evidence (config directory only), quota `unknown`, policy eligibility, a review floor, and a recommendation or an abstention with reasons. Its `decider.source` is `static_fallback`, `jev` or `synthetic_fixture`. Jev is asked only with `consult_jev: true` and a key on the host; it is sent task type, criticality and candidates, never task text, mission id or repository, and its answer is advisory: uncalibrated, below 0.8 or outside the contract, the preflight abstains. A reported `launch` on another provider than the approved one answers `provider_mismatch` before anything is asked. It authorizes nothing. `bench/model-preflight-bench.mjs` compares the 0.1.12 baseline, the static preflight and Jev on synthetic scenarios; `bench/results/` keeps the runs.
|
|
123
127
|
|
|
124
128
|
### The mission standard
|
|
125
129
|
|
|
126
|
-
A new or revised run or work proposal answers with `draft_review`, the report on that version against the mission standard
|
|
130
|
+
A new or revised run or work proposal answers with `draft_review`, the report on that version against the mission standard. It lists aspects to revise, each with `aspect`, `name`, `checked_by`, `why`, `ask`, `settled_by` and sometimes `span`, in `needs_revision`, and what it did not judge in `not_checked`. `running_missions` lists what a person approved in the last 48 hours that has not finished, `preferences` holds the requester's standing preferences, and `next_action` says what to do. It carries no overall verdict, it advises and blocks nothing, and a failure in it never refuses a request. The report is also in `get_run_result`, and the open aspects are on the decision card and the approval page. The worker reads `delivery`, `person_words` and any aspect still open at approval in its brief.
|
|
127
131
|
|
|
128
132
|
| aspect | requires | checked by | settled by |
|
|
129
133
|
|---|---|---|---|
|
|
130
134
|
| S1 | one exact place the result lands, in `delivery` | code for an address, an issue, a uuid or a path; Jev below 0.3 otherwise | drafter |
|
|
131
|
-
| S2 | who may release, deploy or start a session | not checked yet:
|
|
135
|
+
| S2 | who may release, deploy or start a session | not checked yet: a local reviewer is planned | person |
|
|
132
136
|
| S3 | running work on the same ground | code, on a shared issue only; the local reviewer judges the rest | drafter |
|
|
133
137
|
| S4 | a mechanism the mission dictates | Jev at 0.8 or above | drafter |
|
|
134
138
|
| S5 | the person's words for what is credited to them, in `person_words` | Jev at 0.8 or above notices the credit; only the drafter can answer | drafter |
|
|
@@ -140,7 +144,7 @@ The drafter gets two rounds: a report and a revision, twice. The third report's
|
|
|
140
144
|
|
|
141
145
|
**The standard is a document.** A text prompt named `mission-standard`, label `production`, in the prompt store's Engineering domain, read at most once per ten minutes, holding `{ jev_model, aspects, preferences }`. Revising it needs no release, and a report names the version that judged it. An aspect with a Jev check and a new code runs as written, so an aspect can be added there. `S1`, `S3` and `S6` have code behind them. A failed read keeps the last good version and says so, and with none the built-in copy answers and says why. A person's preferences live only in the store, because this package is published.
|
|
142
146
|
|
|
143
|
-
**What leaves the host.** The mission's text and its `delivery`, with ids, paths, hashes, URLs and repository names removed, to Jev, when the connector's environment holds a key. `mission_model_preflight` still sends no task text. Keys go in an environment file only the connector's user can read (`EnvironmentFile=-%h/.config/miadi/connector.env`): `JEV_AI_API_KEY` or `TYPESAFE_API_KEY`, and `ENG_LANGFUSE_PUBLIC_KEY`, `ENG_LANGFUSE_SECRET_KEY`, `ENG_LANGFUSE_BASE_URL`. Without them the report says what went unchecked, and code's findings stand. The bars are uncalibrated.
|
|
147
|
+
**What leaves the host.** The mission's text and its `delivery`, with ids, paths, hashes, URLs and repository names removed, to Jev, when the connector's environment holds a key. `mission_model_preflight` still sends no task text. Keys go in an environment file only the connector's user can read (`EnvironmentFile=-%h/.config/miadi/connector.env`): `JEV_AI_API_KEY` or `TYPESAFE_API_KEY`, and `ENG_LANGFUSE_PUBLIC_KEY`, `ENG_LANGFUSE_SECRET_KEY`, `ENG_LANGFUSE_BASE_URL`. Without them the report says what went unchecked, and code's findings stand. The bars are uncalibrated.
|
|
144
148
|
|
|
145
149
|
### Deciding inside the conversation
|
|
146
150
|
|
|
@@ -159,11 +163,11 @@ Earned 2026-11-06: 0.1.22 moved the card to `decisions-v2.html` and stopped serv
|
|
|
159
163
|
|
|
160
164
|
A decision is recorded once. An approved run that calls another service (a review operation, Deep Diver, an episode door, a steer) is written to the ledger as approved and running before the call, so a restart can never offer the request for a second approval; a run the connector was recording when it stopped reads as failed and may be run again. A decision whose run takes longer than `MIADI_CONNECTOR_DECISION_WAIT_MS` is answered as recorded and running, and the card reads `get_run_result` every 3 seconds until the outcome is in. The same decision sent again (a host retrying a call, a second click, the page form sent twice) answers with the first one's receipt, marked `replayed`, and runs nothing. A different decision is refused as `decision_conflict`, with where the request stands. When the host gives up on a call, the card reads where the request stands before it offers the buttons again.
|
|
161
165
|
|
|
162
|
-
**A person mentioned and a person on the record
|
|
166
|
+
**A person mentioned and a person on the record.** A person mentioned, by name or as a kind of user, holds nothing back: a spoken name is never a reason to withhold a source or to ask anyone. A person on the record, meaning filmed or with their own voice, words or screens shown, has a release agreed at the start of the production. Nothing but the owner's `withheld` registration holds a source back, and no code counts names. `request_participant_consent` is the door for a person on the record who has no release yet.
|
|
163
167
|
|
|
164
|
-
**An approved create or new version sends the person's words
|
|
168
|
+
**An approved create or new version sends the person's words.** `POST /api/reviews` and `POST /api/reviews/:id/versions` carry `source: { title, description, boundaries }` from the `source_intent`: its own fields, or the `TITLE:`, `DESCRIPTION` and `Review boundaries:` lines of its intention. The service keeps none of it, so each generation sends it again, and a new version finds its source through the review's video. The receipt's `source_words.title_taken` reads from the answer whether the service used them. A video already reviewed answers with the existing review, so a `create` on it uses nothing.
|
|
165
169
|
|
|
166
|
-
**A created review gets its transcript
|
|
170
|
+
**A created review gets its transcript.** An approved `create` calls the review service, then reads the video's original-language YouTube captions with a local `uvx yt-dlp` and stores them on the review as `[mm:ss] text`, so an agent reads them through `fetch` and the factory's kind briefs find them with `miadi_review.py transcript`. No model is called for the transcript. The service answers an empty `POST /api/reviews/:id/transcript` by asking Gemini, so an empty one is never sent. `completion_receipt.transcript` says where it stands, and the card and the approval page say the same:
|
|
167
171
|
|
|
168
172
|
| outcome | meaning |
|
|
169
173
|
|---|---|
|
|
@@ -191,14 +195,23 @@ Every record has a claim category: `observed`, `hypothesis`, `desired_future`, `
|
|
|
191
195
|
|
|
192
196
|
```bash
|
|
193
197
|
pnpm --filter @miadi/connector build
|
|
194
|
-
MIADI_CONNECTOR_PUBLIC_URL=https://
|
|
198
|
+
MIADI_CONNECTOR_PUBLIC_URL=https://connector.example.org node packages/connector/dist/bin.js
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`MIADI_CONNECTOR_PUBLIC_URL` is the connector's one address: the OAuth issuer, the base of the links in its answers, and what people add to their client as `$MIADI_CONNECTOR_PUBLIC_URL/mcp`. Unset, the connector is reachable only from its own host, at `http://127.0.0.1:<port>`. On a host set up with the `miadi-config` apt package, set it once in `/etc/miadi/miadi.env`:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
sudo miadi-config set MIADI_CONNECTOR_PUBLIC_URL https://connector.example.org
|
|
195
205
|
```
|
|
196
206
|
|
|
207
|
+
A service reads the same file with `EnvironmentFile=-/etc/miadi/miadi.env`, and login shells get it, so the `claude mcp add` line under [Connect](#connect) works as written. A person's own machine with `miadi-config` takes the same setting, with the address of the connector they use.
|
|
208
|
+
|
|
197
209
|
| variable | default | meaning |
|
|
198
210
|
|---|---|---|
|
|
199
|
-
| `MIADI_CONNECTOR_PUBLIC_URL` | `http://127.0.0.1:<port>` | the address clients use
|
|
211
|
+
| `MIADI_CONNECTOR_PUBLIC_URL` | `http://127.0.0.1:<port>` | the address clients use, without `/mcp`; the OAuth issuer |
|
|
200
212
|
| `MIADI_CONNECTOR_PORT` / `MIADI_CONNECTOR_HOST` | `3337` / `127.0.0.1` | where it listens |
|
|
201
213
|
| `MIADI_CONNECTOR_MIADI_URL` | `http://127.0.0.1:3335` | the Miadi app it calls, as the person |
|
|
214
|
+
| `MIADI_PUBLIC_URL` | `MIADI_URL_BASE`, else `MIADI_CONNECTOR_MIADI_URL` | the Miadi app's address in the links people open from an answer (`/chronicle/…`, `/research`) |
|
|
202
215
|
| `MIADI_CONNECTOR_STATE_DIR` | `/srv/miadi/connector` | `oauth.json` (token digests, clients) and `ledger.jsonl` (records), mode 0700 |
|
|
203
216
|
| `MIADI_REVIEW_BASE_URL` | `https://miadi-review-service.vercel.app` | the review service |
|
|
204
217
|
| `MIADI_REVIEW_TOKEN` | read from `~/.env` | review search and approved review operations |
|
|
@@ -208,7 +221,7 @@ MIADI_CONNECTOR_PUBLIC_URL=https://mcp.sanctuaireagentique.com node packages/con
|
|
|
208
221
|
| `MIADI_CONNECTOR_DECISION_TOKEN_TTL` | `604800` (7 days) | seconds a card's decision token stays usable, held between 300 and 2592000 |
|
|
209
222
|
| `MIADI_CONNECTOR_DECISION_WAIT_MS` | `20000` | how long a decision answer waits for its run before answering it as recorded and running, at most 50000 |
|
|
210
223
|
|
|
211
|
-
|
|
224
|
+
It listens on loopback by default, and a tunnel or reverse proxy on the same host serves `MIADI_CONNECTOR_PUBLIC_URL` from it.
|
|
212
225
|
|
|
213
226
|
## Security
|
|
214
227
|
|
|
@@ -226,3 +239,30 @@ On gaia it runs as the user service `miadi-connector.service`, and the Cloudflar
|
|
|
226
239
|
```bash
|
|
227
240
|
pnpm --filter @miadi/connector test
|
|
228
241
|
```
|
|
242
|
+
|
|
243
|
+
## Related
|
|
244
|
+
|
|
245
|
+
The issues and the episode behind each part. `jgwill/Miadi` is a private repository.
|
|
246
|
+
|
|
247
|
+
| part | where it was decided |
|
|
248
|
+
|---|---|
|
|
249
|
+
| the contract: three domains, five accountable circles | jgwill/Miadi#815 |
|
|
250
|
+
| the review bridge | jgwill/Miadi#816 |
|
|
251
|
+
| the session reads | jgwill/Miadi#746 |
|
|
252
|
+
| a review's transcript, its jobs and its facts | jgwill/Miadi#995 |
|
|
253
|
+
| a created review's transcript from its captions | jgwill/Miadi#925 |
|
|
254
|
+
| the person's words on an approved create or version | jgwill/Miadi#963 |
|
|
255
|
+
| a person mentioned and a person on the record | jgwill/Miadi#962 |
|
|
256
|
+
| revising a mission before it is decided | jgwill/Miadi#919 |
|
|
257
|
+
| a mission found by its issue | jgwill/Miadi#913 |
|
|
258
|
+
| the factory binding | jgwill/Miadi#909 |
|
|
259
|
+
| the agent's result | jgwill/Miadi#921 |
|
|
260
|
+
| miadi-run missions on a session | jgwill/Miadi#993 |
|
|
261
|
+
| steering a busy agent | jgwill/Miadi#930 |
|
|
262
|
+
| `miadi.steering/1` and the adapters | jgwill/Miadi#942 |
|
|
263
|
+
| Codex on its requester's own choice | jgwill/Miadi#926 |
|
|
264
|
+
| the mission standard, and the local reviewer that will check S2 (A3) | jgwill/Miadi#939 |
|
|
265
|
+
| the tests the standard's bars were read from | Episode 564 (miadi-chronicle://564), `mission-draft-review-261105/` |
|
|
266
|
+
| what a published README holds | jgwill/Miadi#685 |
|
|
267
|
+
|
|
268
|
+
On the factory host (gaia) the connector runs as the user service `miadi-connector.service`, installed from the Miadi repository's `scripts/ops/etc/miadi-connector.user.service`. That host's `/etc/miadi/miadi.env` sets `MIADI_CONNECTOR_PUBLIC_URL`, and the Cloudflare tunnel `gaia` serves that address from the loopback port. Its reading runtime is `packages/connector/scripts/host-reading-runtime.mjs`.
|
package/STEERING.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The steering contract: `miadi.steering/1`
|
|
2
2
|
|
|
3
|
-
A person controlling a mission sends one correction. It reaches that mission's running agent at the earliest continuation that agent supports, and what the model received and did is read from the agent's own record.
|
|
3
|
+
A person controlling a mission sends one correction. It reaches that mission's running agent at the earliest continuation that agent supports, and what the model received and did is read from the agent's own record. The runtime owns delivery to the model.
|
|
4
4
|
|
|
5
5
|
## Who owns what
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ A person controlling a mission sends one correction. It reaches that mission's r
|
|
|
26
26
|
|
|
27
27
|
A pane echo, a spinner, an inbox file and a hook's stdout prove none of the middle three. Without `expect_next_action`, whether the next actions follow the correction is a person's judgment, and the state stays at `acknowledged` with `behavior: not_judged`.
|
|
28
28
|
|
|
29
|
-
`acknowledged` can be skipped. A Claude Code transcript does not always hold text written just before a tool call, as on the production baseline
|
|
29
|
+
`acknowledged` can be skipped. A Claude Code transcript does not always hold text written just before a tool call, as on the production baseline (see Related), where the model's "received" never reached the file and `behavior_adjusted` still did. Its absence shows nothing either way.
|
|
30
30
|
|
|
31
31
|
## The inbox
|
|
32
32
|
|
|
@@ -80,8 +80,12 @@ What this keeps:
|
|
|
80
80
|
|
|
81
81
|
## Which provider a request runs on
|
|
82
82
|
|
|
83
|
-
A named provider is used, or the request is left unstarted. With none named, a person's own default from `/providers` applies, then one the operator set for them in `factory.json` (`person_default_provider`), then Claude Code. A default that is not installed or shows no sign-in leaves the mission unstarted and is never replaced. Codex is never a default
|
|
83
|
+
A named provider is used, or the request is left unstarted. With none named, a person's own default from `/providers` applies, then one the operator set for them in `factory.json` (`person_default_provider`), then Claude Code. A default that is not installed or shows no sign-in leaves the mission unstarted and is never replaced. Codex is never a default. The answer to `request_authorized_run`, the decision card and `mission_status` say whether a session of that provider could be corrected before anyone depends on it.
|
|
84
84
|
|
|
85
85
|
## Rollback
|
|
86
86
|
|
|
87
87
|
Run the connector version before this one, and restart `miadi-connector`. A steer to a non-Claude session then answers `unsupported` again and nothing else changes. To stop an adapter: `pi/miadi-session-observability/package.json` without `steering-inbox.ts`, `copilot/miadi-steering/install.sh --remove`, `node codex/miadi-steering/install.mjs --remove`. A new session then answers `unsupported`. Envelopes already queued stay on disk, unread.
|
|
88
|
+
|
|
89
|
+
## Related
|
|
90
|
+
|
|
91
|
+
`jgwill/Miadi` is a private repository. jgwill/Miadi#942 holds the evidence for this contract, its production baseline included. jgwill/Miadi#930 holds the correction it was built from: the runtime owns delivery to the model. jgwill/Miadi#926 is why Codex is never a default.
|
package/dist/approve.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { type RequestProjection } from "./request-state.js";
|
|
|
19
19
|
import type { DraftReviewService } from "./draft-review.js";
|
|
20
20
|
import { type RuntimeDeps } from "./runtime-steer.js";
|
|
21
21
|
import { type TmuxLike } from "./steer.js";
|
|
22
|
-
import { type ModelRoutingDeps } from "./claude-models.js";
|
|
22
|
+
import { type ApproverRouting, type ModelRoutingDeps } from "./claude-models.js";
|
|
23
23
|
import { type FetchCaptions } from "./captions.js";
|
|
24
24
|
import { type TranscriptJobIo } from "./transcript-job.js";
|
|
25
25
|
import { type ProviderAuthorization } from "./provider-policy.js";
|
|
@@ -98,7 +98,28 @@ export declare function episodeReferences(record: ConnectorRecord): string[];
|
|
|
98
98
|
export declare function sourceWithheld(records: ConnectorRecord[], videoId: unknown): boolean;
|
|
99
99
|
/** What a transcript job needs from this connector: its ledger, the review service's transcript door and the readers. */
|
|
100
100
|
export declare function transcriptJobIo(deps: Pick<ApprovalDeps, "config" | "ledger" | "fetchImpl" | "captions" | "localTranscription" | "log" | "eventsDir">): TranscriptJobIo;
|
|
101
|
-
|
|
101
|
+
/** Whether a mission's model is chosen by routing (a model named, or Jev's choice): only then do the approver's model fields apply. */
|
|
102
|
+
export declare function isClaudeRouted(r: ConnectorRecord): boolean;
|
|
103
|
+
export type ApproverRoutingCheck = {
|
|
104
|
+
routing?: ApproverRouting;
|
|
105
|
+
} | {
|
|
106
|
+
refusal: {
|
|
107
|
+
code: string;
|
|
108
|
+
message: string;
|
|
109
|
+
permitted?: string[];
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* The model fields a person sets when approving with changes, checked as a request's are: a model on the permitted
|
|
114
|
+
* list, a task type and criticality from their lists, and only on a mission whose model is routed on Claude Code
|
|
115
|
+
* (jgwill/Miadi#1029). Empty fields are no change.
|
|
116
|
+
*/
|
|
117
|
+
export declare function approverRoutingOf(r: ConnectorRecord, fields: {
|
|
118
|
+
model?: unknown;
|
|
119
|
+
task_type?: unknown;
|
|
120
|
+
criticality?: unknown;
|
|
121
|
+
}, permitted: string[]): ApproverRoutingCheck;
|
|
122
|
+
export declare function executeApproved(record: ConnectorRecord, approver: MiadiPerson, deps: ApprovalDeps, instructions?: string, approverRouting?: ApproverRouting): Promise<Record<string, unknown>>;
|
|
102
123
|
export declare function page(title: string, body: string): string;
|
|
103
124
|
/**
|
|
104
125
|
* Record a person's decision on a request and, when approved, run it once as
|
|
@@ -129,6 +150,9 @@ export declare class ProviderChoiceRequired extends Error {
|
|
|
129
150
|
readonly authorization: ProviderAuthorization;
|
|
130
151
|
constructor(authorization: ProviderAuthorization);
|
|
131
152
|
}
|
|
153
|
+
/** An approval no permitted model can run: the request sets a floor none meets, and the approver named no model (jgwill/Miadi#1028). */
|
|
154
|
+
export declare class ModelFloorUnmet extends Error {
|
|
155
|
+
}
|
|
132
156
|
/** What a decision answers: the state it left, its receipt, and `replayed` when it repeats a decision already taken. */
|
|
133
157
|
export interface Decided {
|
|
134
158
|
decision: NonNullable<ConnectorRecord["approval_state"]>;
|
|
@@ -151,6 +175,7 @@ export declare function approvalStateOf(choice: Decision): NonNullable<Connector
|
|
|
151
175
|
*/
|
|
152
176
|
export declare function decide(r: ConnectorRecord, person: MiadiPerson, choice: Decision, deps: ApprovalDeps, opts: {
|
|
153
177
|
instructions?: string;
|
|
178
|
+
routing?: ApproverRouting;
|
|
154
179
|
note?: string;
|
|
155
180
|
via: string;
|
|
156
181
|
expectedVersion?: number;
|
|
@@ -193,7 +218,7 @@ export declare function consequenceOf(r: ConnectorRecord, authorization?: Provid
|
|
|
193
218
|
steerable: boolean;
|
|
194
219
|
basis: string;
|
|
195
220
|
reason?: string;
|
|
196
|
-
}): string;
|
|
221
|
+
}, floorUnmet?: boolean): string;
|
|
197
222
|
export declare function registerApprovalRoutes(app: Express, deps: ApprovalDeps): void;
|
|
198
223
|
/**
|
|
199
224
|
* The page a person named in a consent request decides on. Their link is the door: a person who never
|