@miadi/tide 0.6.4 → 0.6.5
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/package.json +2 -2
- package/src/client.ts +53 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/tide",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
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/annotate-core": "^0.3.
|
|
18
|
+
"@miadi/annotate-core": "^0.3.1",
|
|
19
19
|
"@miadi/tide-contract": "0.3.5"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
package/src/client.ts
CHANGED
|
@@ -616,6 +616,59 @@ export function buildSendKeysPlan(
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
/**
|
|
620
|
+
* The keys a person may press in a pane from the cockpit, one at a time: enough to
|
|
621
|
+
* answer an agent's question (move through its choices, confirm one). Nothing else
|
|
622
|
+
* is reachable this way. Tab and Shift-Tab in particular stay out: in a Claude
|
|
623
|
+
* prompt they change the permission mode (jgwill/Miadi#817).
|
|
624
|
+
*/
|
|
625
|
+
export const PANE_KEYS = ["Up", "Down", "Enter"] as const
|
|
626
|
+
export type PaneKey = (typeof PANE_KEYS)[number]
|
|
627
|
+
|
|
628
|
+
const TMUX_KEY_NAME: Record<PaneKey, string> = { Up: "Up", Down: "Down", Enter: "C-m" }
|
|
629
|
+
|
|
630
|
+
export function isPaneKey(value: unknown): value is PaneKey {
|
|
631
|
+
return typeof value === "string" && (PANE_KEYS as readonly string[]).includes(value)
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** The exact `tmux send-keys` argv for one key, without executing it. */
|
|
635
|
+
export function buildPaneKeyPlan(pane: string, key: PaneKey): { target: string; key: PaneKey; command: string[] } {
|
|
636
|
+
const target = normalizePaneTarget(pane)
|
|
637
|
+
return { target, key, command: ["send-keys", "-t", target, TMUX_KEY_NAME[key]] }
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Press one key in a tmux pane, exactly once: no literal text and no repeated
|
|
642
|
+
* Enter (sendKeys repeats its Enter for a pasted message; for a menu that would
|
|
643
|
+
* answer the next question too). Steer-gated like sendKeys. tmux only.
|
|
644
|
+
*/
|
|
645
|
+
export async function sendPaneKey(
|
|
646
|
+
pane: string,
|
|
647
|
+
key: PaneKey,
|
|
648
|
+
opts: Pick<SendKeysOptions, "timeoutMs" | "cwd" | "gate"> = {},
|
|
649
|
+
): Promise<{ target: string; key: PaneKey; command: string[]; sent_at: string }> {
|
|
650
|
+
if (!isPaneKey(key)) throw new TideError(`key must be one of ${PANE_KEYS.join(", ")}`)
|
|
651
|
+
if (HERDR_PANE_ID_PATTERN.test(pane.trim())) {
|
|
652
|
+
throw new TideError(`"${pane.trim()}" is a herdr pane id: keys are sent to tmux panes only`)
|
|
653
|
+
}
|
|
654
|
+
const plan = buildPaneKeyPlan(pane, key)
|
|
655
|
+
const bin = resolveTmuxBin()
|
|
656
|
+
const runOpts = { timeout: opts.timeoutMs ?? 10_000, cwd: opts.cwd }
|
|
657
|
+
const gate = acceptGateOverrides(opts.gate)
|
|
658
|
+
await requireSteerGate({
|
|
659
|
+
...gate,
|
|
660
|
+
target: plan.target,
|
|
661
|
+
resolveTarget: gate.resolveTarget ?? (() => tmuxTargetResolved(plan.target, bin, runOpts)),
|
|
662
|
+
})
|
|
663
|
+
try {
|
|
664
|
+
await pExecFile(bin, plan.command, runOpts)
|
|
665
|
+
} catch (err) {
|
|
666
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
667
|
+
throw new TideError(`tmux send-keys ${plan.command[3]} to ${plan.target} failed: ${msg}`, err)
|
|
668
|
+
}
|
|
669
|
+
return { ...plan, sent_at: new Date().toISOString() }
|
|
670
|
+
}
|
|
671
|
+
|
|
619
672
|
/**
|
|
620
673
|
* Operator cockpit — steer a pane by typing `message` into it via `tmux send-keys`.
|
|
621
674
|
* Robust and simple: no shell, no Python spawn, no reviewed-proposal artifact.
|