@miadi/tide-contract 0.3.0 → 0.3.1
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 +51 -23
- package/package.json +1 -1
- package/schema/tide-api.schema.json +2 -0
package/README.md
CHANGED
|
@@ -1,33 +1,61 @@
|
|
|
1
1
|
# @miadi/tide-contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The shared schema for steering agents in terminals: what the `tide` runtime answers and what a
|
|
4
|
+
client can expect back.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
In the Miadi stack, `@miadi/tide` reads and steers the agents working in tmux or herdr panes,
|
|
7
|
+
and the `tide` runtime (the `ironsilk` Python package) does the work on the machine. This
|
|
8
|
+
package is the agreement between the two: one JSON Schema, and TypeScript types that follow
|
|
9
|
+
it. A Python runtime validates against the schema, a TypeScript client compiles against the
|
|
10
|
+
types, and a change to either shows up as a difference here first.
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
- the `@miadi/tide` TypeScript client,
|
|
9
|
-
- the `/api/tide/*` Next.js routes,
|
|
10
|
-
- and the cockpit UI at `/tide`.
|
|
12
|
+
Works with:
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
- `@miadi/tide`: the TypeScript client, whose verbs return these types.
|
|
15
|
+
- the `tide` CLI and daemon from `ironsilk`: the runtime these shapes describe.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
- `src/index.ts` carries hand-written TypeScript types for this scaffold, edited in lockstep with the schema (guarded by `npm test`, `test/schema-patterns.test.ts`).
|
|
16
|
-
- 0.2.0 adds the `multiplexer` discriminator (`"tmux" | "herdr"`, absent ⇒ `"tmux"`), pane targets in both formats, optional `pane_label`, the `TideSendKeysResult` discriminated union, and optional `agent_status` on `EpisodeLane` / `TidePendingApproval`.
|
|
17
|
-
- 0.2.1 corrects the herdr pane-id story from the EP137 live smoke (herdr 0.7.4): real ids are `w1:p2` (legacy `1-2` still accepted), **session-scoped and monotonic** — they do not compact or get reused when panes close, a stale id fails loudly with `pane_not_found`, and `pane rename` sets the `label` field that label→id resolution matches at action time.
|
|
18
|
-
- 0.2.2 types the remaining live-verified herdr envelopes: `TideHerdrPaneInfo` (`pane list` rows), `TideHerdrWaitOutputResult` (`wait output` hit), and `TideHerdrAgentStatusEvent` (`wait agent-status` hits print an EVENT envelope, not a result envelope).
|
|
19
|
-
- 0.2.3 adds the one-call inventory snapshot `TideHerdrInventory` (+ `TideHerdrWorkspaceInfo`/`TideHerdrTabInfo`) behind `getHerdrInventory()`, and widens every pane-id pattern to ALPHANUMERIC segments — live herdr allocates pane suffixes past `p9` as letters (`w2:pE` observed 2026-07-18), which the digits-only patterns rejected.
|
|
20
|
-
- 0.2.4 (unpublished) covenants the peek response from live EP152 cockpit receipts — the previously documented `pane?`/`lines?` fields were fiction; `TidePeekResult` is now the `TideTmuxPeekResult` (`{target, resolved, content}`) / `TideHerdrPeekResult` (`{multiplexer, pane, lines, text}`) union — and lands the deterministic schema→TS drift gate (see Drift posture).
|
|
21
|
-
- Runtime identity constants are exported from `src/index.ts` and mirrored in the schema `x-tide` metadata: `tide`, `MIADI_HOME`, `~/.miadi/navigator`, and `miadi.tide.daemon.v2`.
|
|
22
|
-
- Future work should generate the TypeScript types from the schema and validate IronSilk runtime payloads with Python `jsonschema`.
|
|
17
|
+
## Install
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npm i @miadi/tide-contract
|
|
21
|
+
```
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import type { ContextSnapshot, TidePeekResult, TideSendKeysResult } from "@miadi/tide-contract"
|
|
25
|
+
import { TIDE_DAEMON_CONTRACT_VERSION } from "@miadi/tide-contract"
|
|
26
|
+
import schema from "@miadi/tide-contract/schema/tide-api.schema.json" with { type: "json" }
|
|
27
|
+
```
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
2. **Done** — `test/drift-gate.test.ts` byte-checks the committed reference (`npm run drift:check`) and compile-asserts exact assignability between every public export and its reference type. Pre-existing divergences sit in explicit waiver sections whose pins fail the build once reconciled. **Layered claims (post-W11):** the byte-check is the schema-movement tripwire — constraint-only edits (pattern/bounds) reach it via the emitted `SCHEMA_CONSTRAINTS` manifest, and unknown or co-occurring schema constructs make generation throw; the type layer proves hand-written parity at assignability granularity only (an optional field added over a loose shape's index signature is byte-layer-visible, not type-layer-visible). Review discipline: a `.generated.ts` diff *is* the schema change — read it.
|
|
30
|
-
3. Validate runtime fixture JSON from IronSilk.
|
|
31
|
-
4. Fail when the contract, client, routes, and runtime drift.
|
|
29
|
+
## What it describes
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
| area | types |
|
|
32
|
+
|---|---|
|
|
33
|
+
| live context | `ContextSnapshot`, `TerminalContext`, `WindowEvent`, `TideHealthResult` |
|
|
34
|
+
| terminals and detection | `TideTerminalsResult`, `TideTerminalTarget`, `TideDetectResult`, `TideDetectMatch` |
|
|
35
|
+
| reading and steering a pane | `TidePeekResult`, `TideSteerResult`, `TideSendResult`, `TideSendKeysResult` |
|
|
36
|
+
| herdr | `TideHerdrPaneInfo`, `TideHerdrInventory`, `TideHerdrWorkspaceInfo`, `TideHerdrTabInfo`, `TideHerdrWaitOutputResult`, `TideHerdrAgentStatusEvent` |
|
|
37
|
+
| agent lanes in an episode | `EpisodeLane`, `EpisodeLaneTopology`, `TideLaneCheckpoint`, `TideResumeLink`, `TideAudioManifestLink`, `TidePendingApproval`, `ObserverControllerPosture` |
|
|
38
|
+
|
|
39
|
+
Results that differ by multiplexer are unions discriminated by `multiplexer` (`"tmux"` or
|
|
40
|
+
`"herdr"`; absent means `"tmux"`). A peek is `{ target, resolved, content }` on tmux and
|
|
41
|
+
`{ multiplexer, pane, lines, text }` on herdr.
|
|
42
|
+
|
|
43
|
+
herdr pane ids look like `w1:p2`. Both segments are alphanumeric, because herdr allocates
|
|
44
|
+
letters past `p9` (`w2:pE`). The legacy form `1-2` is still accepted. Ids are scoped to a herdr
|
|
45
|
+
session: they are never reused while it runs and do not survive a restart. A stale id fails
|
|
46
|
+
with `pane_not_found`, and a pane `label` set with `herdr pane rename` is what a client matches
|
|
47
|
+
to find the current id.
|
|
48
|
+
|
|
49
|
+
## Runtime constants
|
|
50
|
+
|
|
51
|
+
Exported from the package and mirrored in the schema's `x-tide` metadata:
|
|
52
|
+
|
|
53
|
+
| constant | value |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `TIDE_CLI_COMMAND` | `tide` |
|
|
56
|
+
| `TIDE_STATE_ROOT_ENV` | `MIADI_HOME` |
|
|
57
|
+
| `TIDE_DEFAULT_STATE_ROOT` | `~/.miadi/navigator` |
|
|
58
|
+
| `TIDE_DAEMON_CONTRACT_VERSION` | `miadi.tide.daemon.v2` |
|
|
59
|
+
|
|
60
|
+
The TypeScript types are written by hand and checked against the schema by a test that fails
|
|
61
|
+
when the two drift apart. Generating them from the schema is planned.
|
package/package.json
CHANGED
|
@@ -148,6 +148,8 @@
|
|
|
148
148
|
"properties": {
|
|
149
149
|
"multiplexer": { "$ref": "#/$defs/multiplexer" },
|
|
150
150
|
"tmux_pane": { "type": "string", "pattern": "^(%?[0-9]+|[0-9]+-[0-9]+|w[0-9A-Za-z]+:p[0-9A-Za-z]+)$", "description": "Pane id in the owning multiplexer: tmux (e.g., '%56') or herdr (e.g., 'w1:p2' as of herdr 0.7; legacy '1-2' accepted). Field name is historical." },
|
|
151
|
+
"session_name": { "type": "string", "description": "Name of the owning tmux session (#{session_name}) — the human-readable half of a pane's identity, which the pane id alone does not carry. OPTIONAL: a producer older than this field omits it, and a consumer must fall back to the pane id rather than render an empty title." },
|
|
152
|
+
"window_name": { "type": "string", "description": "Name of the owning tmux window (#{window_name}). Optional for the same reason as session_name." },
|
|
151
153
|
"pid": { "type": "integer" },
|
|
152
154
|
"cwd": { "type": "string" },
|
|
153
155
|
"domain_id": { "type": ["string", "null"] },
|