@miadi/tide 0.1.0 → 0.1.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 CHANGED
@@ -28,17 +28,24 @@ is outside the server's `PATH`. The daemon socket is resolved separately via
28
28
  ## Verbs
29
29
 
30
30
  ```ts
31
- import { getContext, peek, steerProposal, send, pingDaemon, describeTransport, TideError } from "@miadi/tide"
31
+ import { getContext, getTerminals, detect, peek, steerProposal, send, pingDaemon, describeTransport, TideError } from "@miadi/tide"
32
32
 
33
- const snapshot = await getContext() // R2 live context (daemon socket → CLI fallback)
34
- const scroll = await peek("56", 80) // operator peek %56 (CLI)
35
- const proposal = await steerProposal("56", "continue from checkpoint") // (CLI)
36
- const sent = await send("56", "continue") // guarded --run, controller mode (CLI)
33
+ const snapshot = await getContext() // R2 live context (daemon socket → CLI fallback)
34
+ const terminals = await getTerminals() // operator terminals inventory (CLI, read-only)
35
+ const match = await detect({ pane: "56" })// R1 domain detection for a pane/cwd → match | null (CLI)
36
+ const scroll = await peek("56", 80) // operator peek %56 (CLI)
37
+ const proposal = await steerProposal("56", "continue from checkpoint") // (CLI)
38
+ const sent = await send("56", "continue") // guarded --run, controller mode (CLI)
37
39
 
38
40
  const up = await pingDaemon() // daemon liveness (ping → pong)
39
41
  const how = describeTransport() // { transport: "socket"|"cli", socketPath, socketAvailable }
40
42
  ```
41
43
 
44
+ `getTerminals` and `detect` are the read-only surface behind `GET /api/tide/terminals`
45
+ and `GET /api/tide/detect` — the typed half of operator-terminal triage and manual
46
+ domain assignment (jgwill/Miadi#382). The write-back half (assign a pane to a domain)
47
+ is deferred to the runtime + a guarded route.
48
+
42
49
  ## Transport status
43
50
 
44
51
  | Layer | Status |
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@miadi/tide",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Typed client boundary for the ironsilk `tide` runtime. Daemon Unix-socket transport with CLI fallback.",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
5
8
  "type": "module",
6
9
  "main": "./src/index.ts",
7
10
  "types": "./src/index.ts",
package/src/client.ts CHANGED
@@ -15,6 +15,8 @@ import { promisify } from "node:util"
15
15
 
16
16
  import type {
17
17
  ContextSnapshot,
18
+ TideTerminalsResult,
19
+ TideDetectResult,
18
20
  TidePeekResult,
19
21
  TideSendResult,
20
22
  TideSteerResult,
@@ -111,6 +113,18 @@ export interface GetContextOptions extends TideRunOptions {
111
113
  transport?: TransportMode
112
114
  }
113
115
 
116
+ export interface GetTerminalsOptions extends TideRunOptions {
117
+ /** Optional domain filter passed through to `tide operator terminals --domain`. */
118
+ domain?: string
119
+ }
120
+
121
+ export interface DetectOptions extends TideRunOptions {
122
+ /** tmux pane id to detect against (with or without the leading `%`). */
123
+ pane?: string
124
+ /** Working directory to detect against (defaults to the runtime's own cwd). */
125
+ detectCwd?: string
126
+ }
127
+
114
128
  /** Which transport `getContext()` would use right now — a diagnostic for the operator cockpit. */
115
129
  export function describeTransport(): {
116
130
  transport: "socket" | "cli"
@@ -156,6 +170,29 @@ export async function getContext(opts: GetContextOptions = {}): Promise<ContextS
156
170
  })
157
171
  }
158
172
 
173
+ /** Operator cockpit — read-only inventory of tmux terminal targets. */
174
+ export function getTerminals(opts: GetTerminalsOptions = {}): Promise<TideTerminalsResult> {
175
+ const args = ["operator", "terminals"]
176
+ const domain = opts.domain?.trim()
177
+ if (domain) args.push("--domain", domain)
178
+ args.push("--format", "json")
179
+ return runTideJson<TideTerminalsResult>(args, { timeoutMs: 8_000, ...opts })
180
+ }
181
+
182
+ /**
183
+ * R1 — domain detection for a pane or cwd without mutating state. Returns the
184
+ * best match (`null` when nothing clears the confidence threshold). The read-only
185
+ * half of manual terminal → domain assignment (F5).
186
+ */
187
+ export function detect(opts: DetectOptions = {}): Promise<TideDetectResult> {
188
+ const args = ["detect", "--format", "json"]
189
+ const pane = opts.pane?.trim()
190
+ if (pane) args.push("--pane", pane.startsWith("%") ? pane : `%${pane}`)
191
+ const cwd = opts.detectCwd?.trim()
192
+ if (cwd) args.push("--cwd", cwd)
193
+ return runTideJson<TideDetectResult>(args, { timeoutMs: 8_000, ...opts })
194
+ }
195
+
159
196
  /** Operator cockpit — read scrollback for a pane without attaching. `pane` is the numeric index (no `%`). */
160
197
  export function peek(pane: string, lines = 30, opts?: TideRunOptions): Promise<TidePeekResult> {
161
198
  return runTideJson<TidePeekResult>(
package/src/types.ts CHANGED
@@ -42,6 +42,38 @@ export interface ContextSnapshot {
42
42
  editor_buffers?: string[]
43
43
  }
44
44
 
45
+ /** `tide operator terminals --format json`. Read-only terminal inventory. */
46
+ export interface TideTerminalTarget {
47
+ terminal_id: string
48
+ session_id: string
49
+ session_name: string
50
+ window_id: string
51
+ window_name: string
52
+ pane_id: string
53
+ cwd: string
54
+ pane_active: boolean
55
+ session_attached: number
56
+ pid: number
57
+ command: string
58
+ domain_id: string | null
59
+ domain_confidence: number
60
+ attach_command: string
61
+ switch_command: string
62
+ select_pane_command: string
63
+ }
64
+
65
+ export type TideTerminalsResult = TideTerminalTarget[]
66
+
67
+ /** `tide detect --format json`. Null means no domain match. */
68
+ export interface TideDetectMatch {
69
+ domain_id: string
70
+ confidence: number
71
+ signal_type: string
72
+ source_detail: string
73
+ }
74
+
75
+ export type TideDetectResult = TideDetectMatch | null
76
+
45
77
  /** `tide operator peek <pane> --format json`. Shape per runtime; loose pending schema. */
46
78
  export interface TidePeekResult {
47
79
  pane?: string