@miadi/tide 0.2.2 → 0.2.3
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 +5 -3
- package/package.json +2 -2
- package/src/client.ts +12 -3
- package/src/herdr.ts +42 -11
package/README.md
CHANGED
|
@@ -68,9 +68,11 @@ they reset on herdr restart, and a stale id fails loudly with `pane_not_found`.
|
|
|
68
68
|
verbs: `runInHerdrPane`, `readHerdrPane` (recent-unwrapped text), `renameHerdrPane` (sets the
|
|
69
69
|
durable label), `waitForHerdrOutput` (typed `TideHerdrWaitOutputResult`),
|
|
70
70
|
`waitForHerdrAgentStatus` (typed `TideHerdrAgentStatusEvent` — live hits print an event
|
|
71
|
-
envelope), `listHerdrPanes/Workspaces/Tabs
|
|
72
|
-
|
|
73
|
-
`
|
|
71
|
+
envelope), `listHerdrPanes/Workspaces/Tabs`, and `getHerdrInventory({ includeTabs? })` — the
|
|
72
|
+
one-call snapshot (`TideHerdrInventory`: workspaces + panes, tabs on request) behind
|
|
73
|
+
`GET /api/tide/herdr`, so cockpit routes stay thin. `peek(pane, lines, { multiplexer: "herdr" })`
|
|
74
|
+
reads herdr scrollback through the stable peek verb. Pane-id segments are alphanumeric
|
|
75
|
+
(`w2:pE` past `p9`). Binary resolution: `TIDE_HERDR_BIN` → `herdr` on `PATH`.
|
|
74
76
|
|
|
75
77
|
> **Readiness: `live-verified`.** Smoked against a real herdr 0.7.4 instance (EP137
|
|
76
78
|
> herdr-smoke lane, 2026-07-16) — inventory parsing, send-text/send-keys, pane run, read,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/tide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Typed client boundary for the ironsilk `tide` runtime. Daemon Unix-socket transport with CLI fallback.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"src"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@miadi/tide-contract": "0.2.
|
|
18
|
+
"@miadi/tide-contract": "0.2.3"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test": "d=$(mktemp -d \"${TMPDIR:-/tmp}/miadi-tide-test.XXXXXX\") && trap 'rm -rf \"$d\"' EXIT && ../../node_modules/.bin/tsc -p tsconfig.test.json --outDir \"$d\" && node --test \"$d\"/packages/tide/test/*.test.js"
|
package/src/client.ts
CHANGED
|
@@ -41,7 +41,13 @@ import {
|
|
|
41
41
|
TideDaemonError,
|
|
42
42
|
} from "./socket"
|
|
43
43
|
import { TideError } from "./errors"
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
HERDR_PANE_ID_PATTERN,
|
|
46
|
+
buildHerdrSendKeysPlan,
|
|
47
|
+
readHerdrPane,
|
|
48
|
+
resolveHerdrPaneId,
|
|
49
|
+
sendKeysViaHerdr,
|
|
50
|
+
} from "./herdr"
|
|
45
51
|
import type { HerdrCommandRunner } from "./herdr"
|
|
46
52
|
|
|
47
53
|
const pExecFile = promisify(execFile)
|
|
@@ -221,8 +227,11 @@ export interface PeekOptions extends TideRunOptions {
|
|
|
221
227
|
*/
|
|
222
228
|
export async function peek(pane: string, lines = 30, opts: PeekOptions = {}): Promise<TidePeekResult> {
|
|
223
229
|
if (opts.multiplexer === "herdr") {
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
// Resolve the label here so the result reports the CURRENT pane id, not
|
|
231
|
+
// the raw (possibly empty) pane argument. Same CLI cost: one list + one read.
|
|
232
|
+
const target = opts.paneLabel ? await resolveHerdrPaneId(opts.paneLabel, opts) : pane
|
|
233
|
+
const text = await readHerdrPane(target, lines, { ...opts, paneLabel: undefined })
|
|
234
|
+
return { multiplexer: "herdr", pane: target, lines: text.split("\n"), text }
|
|
226
235
|
}
|
|
227
236
|
return runTideJson<TidePeekResult>(
|
|
228
237
|
["operator", "peek", `%${pane}`, "--lines", String(lines), "--format", "json"],
|
package/src/herdr.ts
CHANGED
|
@@ -33,9 +33,12 @@ import { promisify } from "node:util"
|
|
|
33
33
|
import type {
|
|
34
34
|
TideAgentStatus,
|
|
35
35
|
TideHerdrAgentStatusEvent,
|
|
36
|
+
TideHerdrInventory,
|
|
36
37
|
TideHerdrPaneInfo,
|
|
37
38
|
TideHerdrSendKeysResult,
|
|
39
|
+
TideHerdrTabInfo,
|
|
38
40
|
TideHerdrWaitOutputResult,
|
|
41
|
+
TideHerdrWorkspaceInfo,
|
|
39
42
|
} from "@miadi/tide-contract"
|
|
40
43
|
import { TideError } from "./errors"
|
|
41
44
|
import type { TideRunOptions } from "./client"
|
|
@@ -123,7 +126,10 @@ function parseHerdrJson<T>(stdout: string, what: string): T {
|
|
|
123
126
|
// ── Pane targets and label→id resolution ────────────────────────────────────
|
|
124
127
|
|
|
125
128
|
// "w1:p2" is the live herdr 0.7 format; the dashed "1-2" form is legacy.
|
|
126
|
-
|
|
129
|
+
// Segments are ALPHANUMERIC, not just digits — live 0.7.4 allocates pane
|
|
130
|
+
// suffixes past p9 as letters (w2:pE, w2:pJ observed in the EP137 follow-up
|
|
131
|
+
// inventory), so a digits-only pattern strands every pane beyond the ninth.
|
|
132
|
+
export const HERDR_PANE_ID_PATTERN = /^(w[0-9A-Za-z]+:p[0-9A-Za-z]+|[0-9]+-[0-9]+)$/
|
|
127
133
|
|
|
128
134
|
/** Validate a herdr pane id (e.g. "w1:p2"). Unlike tmux there is no `%` prefix to add. */
|
|
129
135
|
export function normalizeHerdrPaneTarget(pane: string): string {
|
|
@@ -145,17 +151,11 @@ export interface HerdrPaneInfo extends TideHerdrPaneInfo {
|
|
|
145
151
|
title?: string
|
|
146
152
|
}
|
|
147
153
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
label?: string
|
|
151
|
-
[key: string]: unknown
|
|
152
|
-
}
|
|
154
|
+
/** One row from `herdr workspace list` — the covenant shape (tide-contract 0.2.3). */
|
|
155
|
+
export type HerdrWorkspaceInfo = TideHerdrWorkspaceInfo
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
label?: string
|
|
157
|
-
[key: string]: unknown
|
|
158
|
-
}
|
|
157
|
+
/** One row from `herdr tab list` — the covenant shape (tide-contract 0.2.3). */
|
|
158
|
+
export type HerdrTabInfo = TideHerdrTabInfo
|
|
159
159
|
|
|
160
160
|
// herdr JSON envelopes nest payloads under `result` (the same nesting
|
|
161
161
|
// hermes-conductor parses in src/mux/backends/herdr.ts:
|
|
@@ -191,6 +191,37 @@ export async function listHerdrTabs(workspace: string, opts: HerdrRunOptions = {
|
|
|
191
191
|
return unwrapList<HerdrTabInfo>(parseHerdrJson<unknown>(stdout, "tab list"), "tabs", "tab list")
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
export interface HerdrInventoryOptions extends HerdrRunOptions {
|
|
195
|
+
/** Also list tabs per workspace (extra CLI spawns) and annotate each with its workspace_id. */
|
|
196
|
+
includeTabs?: boolean
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* One-call herdr inventory snapshot for cockpit surfaces: workspaces + panes
|
|
201
|
+
* (and tabs on request) through a single verb, so route handlers stay thin.
|
|
202
|
+
* Pane rows already carry workspace_id/tab_id/label/agent_status/cwd on live
|
|
203
|
+
* 0.7.4 — the UI can group panes by workspace without the tabs leg.
|
|
204
|
+
*/
|
|
205
|
+
export async function getHerdrInventory(opts: HerdrInventoryOptions = {}): Promise<TideHerdrInventory> {
|
|
206
|
+
const [workspaces, panes] = await Promise.all([listHerdrWorkspaces(opts), listHerdrPanes(opts)])
|
|
207
|
+
const inventory: TideHerdrInventory = {
|
|
208
|
+
multiplexer: "herdr",
|
|
209
|
+
captured_at: new Date().toISOString(),
|
|
210
|
+
workspaces,
|
|
211
|
+
panes,
|
|
212
|
+
}
|
|
213
|
+
if (opts.includeTabs) {
|
|
214
|
+
const perWorkspace = await Promise.all(
|
|
215
|
+
workspaces
|
|
216
|
+
.map((ws) => ws.workspace_id)
|
|
217
|
+
.filter((id): id is string => typeof id === "string" && id.length > 0)
|
|
218
|
+
.map(async (id) => (await listHerdrTabs(id, opts)).map((tab) => ({ ...tab, workspace_id: id }))),
|
|
219
|
+
)
|
|
220
|
+
inventory.tabs = perWorkspace.flat()
|
|
221
|
+
}
|
|
222
|
+
return inventory
|
|
223
|
+
}
|
|
224
|
+
|
|
194
225
|
/**
|
|
195
226
|
* Resolve a durable pane label to the CURRENT herdr pane id via `pane list`.
|
|
196
227
|
* Runs before every action when a label is given — herdr ids are
|