@miadi/tide 0.6.8 → 0.6.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miadi/tide",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
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"
@@ -17,7 +17,7 @@
17
17
  "scripts/*.py"
18
18
  ],
19
19
  "dependencies": {
20
- "@miadi/annotate-core": "^0.3.1",
20
+ "@miadi/annotate-core": "^0.5.0",
21
21
  "@miadi/tide-contract": "0.3.5"
22
22
  },
23
23
  "keywords": [
package/src/annotate.ts CHANGED
@@ -626,22 +626,12 @@ function assertTarget(target: string): void {
626
626
 
627
627
  // -------------------------------------------------------------------- verbs --
628
628
 
629
- /**
630
- * The newest earlier vessel that holds this very reply from this very pane and
631
- * has marks on it. Fetching reopens it instead of keeping a fresh copy, so
632
- * marks another person made on the reply are there when it is fetched again
633
- * (Episode 339: William opens an agent in the cockpit and finds Mia's marks).
634
- * Two layouts are searched: web runs at `<root>/web/<run>/<vessel>/` and
635
- * terminal `tan` runs at `<root>/<stamp>-<target>/`, which the review script
636
- * gives a `source.json` since jgwill/gaia#87. Their stamps are not comparable
637
- * (UTC vs local time), so matches are ordered by `fetched_at`.
638
- * Null when the reply changed since, or nobody marked it.
639
- */
640
- export async function findMarkedVessel(
629
+ /** Earlier vessels of a pane holding exactly this reply, newest fetch first (the search findMarkedVessel describes). */
630
+ async function sameReplyVessels(
641
631
  paneId: string,
642
632
  text: string,
643
- opts: { root?: string; storeRoot?: string; exclude?: string } = {},
644
- ): Promise<{ vessel: string; doc: string; source: SourceIdentity } | null> {
633
+ opts: { root?: string; exclude?: string } = {},
634
+ ): Promise<{ vessel: string; doc: string; source: SourceIdentity }[]> {
645
635
  const root = opts.root ?? resolveVesselRoot()
646
636
  const webDir = join(root, WEB_VESSEL_SUBDIR)
647
637
  const dirs = async (dir: string) =>
@@ -669,10 +659,46 @@ export async function findMarkedVessel(
669
659
  }
670
660
  // Stable: vessels without fetched_at keep their name order.
671
661
  matches.sort((a, b) => String(b.source.fetched_at ?? "").localeCompare(String(a.source.fetched_at ?? "")))
672
- for (const m of matches) if ((await listMarks(m.doc, opts.storeRoot)).length > 0) return m
662
+ return matches
663
+ }
664
+
665
+ /**
666
+ * The newest earlier vessel that holds this very reply from this very pane and
667
+ * has marks on it. Fetching reopens it instead of keeping a fresh copy, so
668
+ * marks another person made on the reply are there when it is fetched again
669
+ * (Episode 339: William opens an agent in the cockpit and finds Mia's marks).
670
+ * Two layouts are searched: web runs at `<root>/web/<run>/<vessel>/` and
671
+ * terminal `tan` runs at `<root>/<stamp>-<target>/`, which the review script
672
+ * gives a `source.json` since jgwill/gaia#87. Their stamps are not comparable
673
+ * (UTC vs local time), so matches are ordered by `fetched_at`.
674
+ * Null when the reply changed since, or nobody marked it.
675
+ */
676
+ export async function findMarkedVessel(
677
+ paneId: string,
678
+ text: string,
679
+ opts: { root?: string; storeRoot?: string; exclude?: string } = {},
680
+ ): Promise<{ vessel: string; doc: string; source: SourceIdentity } | null> {
681
+ for (const m of await sameReplyVessels(paneId, text, opts)) if ((await listMarks(m.doc, opts.storeRoot)).length > 0) return m
673
682
  return null
674
683
  }
675
684
 
685
+ /**
686
+ * The vessel a fetch of this reply reopens: the newest one already marked,
687
+ * else the newest one holding the same reply. So the cockpit and every
688
+ * terminal that fetch the same reply share one document from the first fetch:
689
+ * their marks meet on it, and so does who is writing there (jgwill/Miadi#643).
690
+ * Null when nobody fetched this reply from this pane before.
691
+ */
692
+ export async function findReplyVessel(
693
+ paneId: string,
694
+ text: string,
695
+ opts: { root?: string; storeRoot?: string; exclude?: string } = {},
696
+ ): Promise<{ vessel: string; doc: string; source: SourceIdentity; marked: boolean } | null> {
697
+ const matches = await sameReplyVessels(paneId, text, opts)
698
+ for (const m of matches) if ((await listMarks(m.doc, opts.storeRoot)).length > 0) return { ...m, marked: true }
699
+ return matches[0] ? { ...matches[0], marked: false } : null
700
+ }
701
+
676
702
  /**
677
703
  * Resolve the agent under `target`, read its last reply, and keep it in a fresh
678
704
  * vessel together with the pane's identity. When an earlier vessel already holds
@@ -700,11 +726,12 @@ export async function fetchReply(target: string, opts: { pick?: number; host?: A
700
726
  const source: SourceIdentity = { target, ...here, ...parseAgentFromLog(log), fetched_at: new Date().toISOString() }
701
727
  await writeFile(join(vessel, SOURCE_FILE), JSON.stringify(source, null, 2) + "\n", "utf8")
702
728
  const text = await readFile(doc, "utf8")
703
- const earlier = await findMarkedVessel(here.pane_id, text, { exclude: webRoot })
729
+ // The same reply fetched before keeps its document: everyone's marks and presence meet on one copy.
730
+ const earlier = await findReplyVessel(here.pane_id, text, { exclude: webRoot })
704
731
  if (earlier) {
705
732
  await rm(webRoot, { recursive: true, force: true })
706
733
  const blocks = await listBlocks(earlier.doc, text)
707
- return { id: earlier.doc, target, vessel: earlier.vessel, doc: earlier.doc, text, blocks, source: earlier.source, log, reopened: true }
734
+ return { id: earlier.doc, target, vessel: earlier.vessel, doc: earlier.doc, text, blocks, source: earlier.source, log, ...(earlier.marked ? { reopened: true } : {}) }
708
735
  }
709
736
  const blocks = await listBlocks(doc, text)
710
737
  return { id: doc, target, vessel, doc, text, blocks, source, log }
package/src/client.ts CHANGED
@@ -523,6 +523,88 @@ export async function openCompanion(opts: CompanionOpenOptions): Promise<TideCom
523
523
  }
524
524
  }
525
525
 
526
+ // ── Open one agent session by its id (jgwill/Miadi#868) ─────────────────────
527
+
528
+ export interface AgentOpenOptions {
529
+ /** A Claude session id, or its first 8 characters or more. */
530
+ session: string
531
+ /** Resume it when it does not run, instead of returning the plan. */
532
+ run?: boolean
533
+ timeoutMs?: number
534
+ }
535
+
536
+ /** `tide agents open --format json`: where the session runs, or how it is resumed. */
537
+ export interface TideAgentOpenPlan {
538
+ session_id: string
539
+ /** `running`: `pane_id` is its pane and nothing starts. `resume`: the plan. `refused`: `reason` says why. */
540
+ state: "running" | "resume" | "refused"
541
+ reason: string
542
+ kind: string
543
+ name: string
544
+ cwd: string
545
+ launch_alias: string
546
+ /** The tmux session it runs in, or the one it is resumed in. */
547
+ tmux_session: string
548
+ /** The pane it runs in; after a run, the pane it was resumed in. */
549
+ pane_id: string
550
+ command: string[]
551
+ how: string
552
+ /** `new-session`, or `new-window` in a session of its name that exists. */
553
+ target: "" | "new-session" | "new-window"
554
+ tmux_commands: string[]
555
+ last_seen: string
556
+ executed: boolean
557
+ }
558
+
559
+ export interface TideAgentOpenResult {
560
+ /** 0 an answer (running, a plan, or resumed), 4 refused, 2 the controller gate or an unknown session, 1 tmux failed. */
561
+ exitCode: number
562
+ plan: TideAgentOpenPlan | null
563
+ /** The runtime's own words when it printed no JSON. */
564
+ message?: string
565
+ }
566
+
567
+ export const AGENT_SESSION_KEY = /^[0-9a-f]{8}[0-9a-f-]{0,28}$/
568
+
569
+ /**
570
+ * Open one agent session by its id: the pane it runs in, or resumed in a tmux session of the
571
+ * name it last ran under (ironsilk ≥ 0.9.70, `tide agents open`). Dry run unless `run`.
572
+ * Exit 4 (refused) still prints the plan and comes back as an answer.
573
+ */
574
+ export async function openAgentSession(opts: AgentOpenOptions): Promise<TideAgentOpenResult> {
575
+ const session = opts.session.trim().toLowerCase()
576
+ if (!AGENT_SESSION_KEY.test(session)) {
577
+ throw new TideError(`session must be a session id or its first 8 characters or more: ${JSON.stringify(opts.session)}`)
578
+ }
579
+ const args = ["agents", "open", session, "--format", "json"]
580
+ if (opts.run) args.push("--run")
581
+ const bin = await resolveTideBin()
582
+ const timeoutMs = opts.timeoutMs ?? 60_000
583
+ const env = opts.run ? { ...process.env, TIDE_ALLOW_NON_INTERACTIVE_RUN: "1" } : process.env
584
+ const startedAt = Date.now()
585
+ const parse = (stdout: string): TideAgentOpenPlan | null => {
586
+ try {
587
+ const plan = JSON.parse(stdout) as TideAgentOpenPlan
588
+ return plan && typeof plan === "object" && typeof plan.state === "string" ? plan : null
589
+ } catch {
590
+ return null
591
+ }
592
+ }
593
+ try {
594
+ const res = await pExecFile(bin, args, { timeout: timeoutMs, env, maxBuffer: 1024 * 1024 })
595
+ return { exitCode: 0, plan: parse(res.stdout) }
596
+ } catch (err) {
597
+ const e = err as { code?: unknown; killed?: boolean; stdout?: string; stderr?: string }
598
+ if (typeof e.code === "number" && !e.killed) {
599
+ const plan = parse(e.stdout ?? "")
600
+ return plan
601
+ ? { exitCode: e.code, plan }
602
+ : { exitCode: e.code, plan: null, message: `${e.stdout ?? ""}${e.stderr ?? ""}`.trim() }
603
+ }
604
+ throw classifyExecFailure(bin, args, err, Date.now() - startedAt, timeoutMs)
605
+ }
606
+ }
607
+
526
608
  // ── Direct send-keys (simple, robust steer transport) ───────────────────────
527
609
  //
528
610
  // The operator cockpit's primary steer path. Instead of the heavier reviewed
@@ -544,7 +626,7 @@ export function normalizePaneTarget(pane: string): string {
544
626
 
545
627
  export interface SendKeysOptions extends TideRunOptions {
546
628
  /**
547
- * Append a trailing Enter (`C-m`) after typing the literal text. Default true.
629
+ * Append a trailing Enter after typing the literal text. Default true.
548
630
  * When false the text is left on the pane's prompt unsubmitted, so a human can
549
631
  * review and press Enter — the "send Enter after content" cockpit toggle.
550
632
  */
@@ -612,7 +694,9 @@ export function buildSendKeysPlan(
612
694
  submitted: submit,
613
695
  // `-l` types the bytes literally (no tmux key-name interpretation).
614
696
  literal_command: ["send-keys", "-l", "-t", target, message],
615
- submit_command: submit ? ["send-keys", "-t", target, "C-m"] : null,
697
+ // Enter and Ctrl-M diverge under tmux extended keys (Pi enables this).
698
+ // Send the semantic key, not its legacy control-character alias.
699
+ submit_command: submit ? ["send-keys", "-t", target, "Enter"] : null,
616
700
  }
617
701
  }
618
702
 
@@ -625,8 +709,6 @@ export function buildSendKeysPlan(
625
709
  export const PANE_KEYS = ["Up", "Down", "Enter"] as const
626
710
  export type PaneKey = (typeof PANE_KEYS)[number]
627
711
 
628
- const TMUX_KEY_NAME: Record<PaneKey, string> = { Up: "Up", Down: "Down", Enter: "C-m" }
629
-
630
712
  export function isPaneKey(value: unknown): value is PaneKey {
631
713
  return typeof value === "string" && (PANE_KEYS as readonly string[]).includes(value)
632
714
  }
@@ -634,7 +716,7 @@ export function isPaneKey(value: unknown): value is PaneKey {
634
716
  /** The exact `tmux send-keys` argv for one key, without executing it. */
635
717
  export function buildPaneKeyPlan(pane: string, key: PaneKey): { target: string; key: PaneKey; command: string[] } {
636
718
  const target = normalizePaneTarget(pane)
637
- return { target, key, command: ["send-keys", "-t", target, TMUX_KEY_NAME[key]] }
719
+ return { target, key, command: ["send-keys", "-t", target, key] }
638
720
  }
639
721
 
640
722
  /**
@@ -674,8 +756,7 @@ export async function sendPaneKey(
674
756
  * Robust and simple: no shell, no Python spawn, no reviewed-proposal artifact.
675
757
  * Set `submit: false` to type the content without pressing Enter.
676
758
  *
677
- * Two tmux invocations when submitting: the literal text is typed first, then a
678
- * separate `C-m` submits it. If the literal step succeeds but the submit step
759
+ * The literal text is typed first, then a separate `Enter` submits it. If the literal step succeeds but the submit step
679
760
  * fails, the text is already on the pane's prompt (unsubmitted) — the thrown
680
761
  * `TideError` names which step failed so the caller can surface that partial state.
681
762
  *
@@ -977,3 +1058,206 @@ export async function setSessionTeam(session: string, team: string | null, opts:
977
1058
  throw new TideError(`tmux set-option @miadi-team on session ${name} failed: ${msg}`, err)
978
1059
  }
979
1060
  }
1061
+
1062
+ // ── Drafts being prepared (jgwill/Miadi#691, Episode 548 S2 and H3) ─────────
1063
+ //
1064
+ // `tide drafts list --json` prints one object per open draft, without its words.
1065
+ // These verbs never pass `--text`, and `listDrafts` drops a `text` key if a runtime
1066
+ // ever printed one anyway: the words of a draft stay with its author's pane.
1067
+
1068
+ /** Where the labels of a mctgo draft point, by kind. A shell draft has none. */
1069
+ export interface TideDraftLabels {
1070
+ paths?: string[]
1071
+ packages?: string[]
1072
+ repositories?: string[]
1073
+ addresses?: string[]
1074
+ issues?: string[]
1075
+ team?: string
1076
+ }
1077
+
1078
+ /** One draft as `tide drafts list --json` gives it (ironsilk ≥ 0.9.60), never its words. */
1079
+ export interface TideDraft {
1080
+ id: string
1081
+ subject: string
1082
+ state: string
1083
+ /** `mctgo` (a session being prepared on a team) or `shell` (an unsent line at a shell prompt). */
1084
+ kind: string
1085
+ pane: string
1086
+ team: string | null
1087
+ target_session: string | null
1088
+ session_id: string | null
1089
+ labels: TideDraftLabels
1090
+ version: number
1091
+ chars: number
1092
+ in_view: boolean
1093
+ reason: string | null
1094
+ /** A ready draft's moment, ISO UTC (ironsilk ≥ 0.9.61). Null when judged or not ready. */
1095
+ send_at?: string | null
1096
+ /** `judged` when a scheduler seat chooses the moment. */
1097
+ scheduler?: string | null
1098
+ /** How late after its moment a ready draft may still go. Null unless ready. */
1099
+ window_seconds?: number | null
1100
+ opened_at: string | null
1101
+ changed_at: string | null
1102
+ closed_at: string | null
1103
+ }
1104
+
1105
+ /** What `withdrawDraft` names: a full id, `draft:<id>`, or a prefix of 4 or more. */
1106
+ export const DRAFT_REF_PATTERN = /^(?:draft:)?[0-9a-f]{4,64}$/
1107
+
1108
+ /** The longest reason passed to the runtime; it is written in the event as given. */
1109
+ export const DRAFT_REASON_MAX = 500
1110
+
1111
+ /**
1112
+ * The drafts tide holds: open ones, and with `all` the closed ones of the last 7 days.
1113
+ * One `tide drafts list --json` call. Lines that are not JSON objects are skipped.
1114
+ */
1115
+ export async function listDrafts(opts: TideRunOptions & { all?: boolean } = {}): Promise<TideDraft[]> {
1116
+ const bin = await resolveTideBin()
1117
+ const args = ["drafts", "list", "--json", ...(opts.all ? ["--all"] : [])]
1118
+ const timeoutMs = opts.timeoutMs ?? 15_000
1119
+ const startedAt = Date.now()
1120
+ let stdout: string
1121
+ try {
1122
+ ;({ stdout } = await pExecFile(bin, args, { timeout: timeoutMs, cwd: opts.cwd, maxBuffer: 8 * 1024 * 1024 }))
1123
+ } catch (err) {
1124
+ throw classifyExecFailure(bin, args, err, Date.now() - startedAt, timeoutMs)
1125
+ }
1126
+ const drafts: TideDraft[] = []
1127
+ for (const line of stdout.split("\n")) {
1128
+ if (!line.trim()) continue
1129
+ let row: unknown
1130
+ try {
1131
+ row = JSON.parse(line)
1132
+ } catch {
1133
+ continue
1134
+ }
1135
+ if (!row || typeof row !== "object" || Array.isArray(row)) continue
1136
+ const { text: _words, ...draft } = row as Record<string, unknown>
1137
+ if (typeof draft.id !== "string") continue
1138
+ drafts.push(draft as unknown as TideDraft)
1139
+ }
1140
+ return drafts
1141
+ }
1142
+
1143
+ export interface TideDraftWithdrawal {
1144
+ /** The id the runtime closed, from its answer line. */
1145
+ id: string
1146
+ /** The runtime's one line: `tide.draft.withdrawn <id> <pane> <reason>`. */
1147
+ line: string
1148
+ }
1149
+
1150
+ /**
1151
+ * Close a draft as withdrawn (`tide.draft.withdrawn`). A restore never types it back.
1152
+ * A refusal (no such draft, a prefix naming several, a closed draft, one being typed
1153
+ * back) is a `TideError` of kind `exit` whose `detail.stderr` carries the runtime's reason.
1154
+ */
1155
+ /** `--by`: the person whose decision this is, named as the event's actor (ironsilk 0.9.62). */
1156
+ const byArgs = (by: string | undefined): string[] => {
1157
+ if (by === undefined) return []
1158
+ if (!DRAFT_BY_PATTERN.test(by)) throw new TideError(`"${by}" is not a person id`)
1159
+ return ["--by", by]
1160
+ }
1161
+
1162
+ /** What tide accepts as `--by`. */
1163
+ export const DRAFT_BY_PATTERN = /^[\w.:@+-]{1,200}$/
1164
+
1165
+ export async function withdrawDraft(ref: string, opts: TideRunOptions & { reason?: string; by?: string } = {}): Promise<TideDraftWithdrawal> {
1166
+ const id = draftRef(ref)
1167
+ const reason = (opts.reason ?? "").replace(/[\s\u0000-\u001f\u007f]+/g, " ").trim()
1168
+ if (reason.length > DRAFT_REASON_MAX) throw new TideError(`a reason is at most ${DRAFT_REASON_MAX} characters`)
1169
+ const line = await runDraftVerb(["drafts", "withdraw", id, ...(reason ? ["--reason", reason] : []), ...byArgs(opts.by)], opts)
1170
+ const closed = /^tide\.draft\.withdrawn\s+([0-9a-f]+)/.exec(line)?.[1]
1171
+ return { id: closed ?? id.replace(/^draft:/, ""), line }
1172
+ }
1173
+
1174
+ /** What `readyDraft` asks for: one of a time, a delay, or a scheduler's judgment. */
1175
+ export type DraftReadyWhen =
1176
+ | { at: string }
1177
+ | { in: string }
1178
+ | { judged: true }
1179
+
1180
+ /** `14:30`, or an ISO time (`2026-10-31T14:30`, with or without an offset): what `--at` reads. */
1181
+ export const DRAFT_AT_PATTERN = /^(?:\d{1,2}:\d{2}|\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,6})?)?(?:Z|[+-]\d{2}:\d{2})?)$/
1182
+ /** `90s`, `45m`, `1h`, `4h30m`, `2d`: what `--in` and `--window` read. */
1183
+ export const DRAFT_DURATION_PATTERN = /^(?:\d{1,4}(?:\.\d{1,3})?[smhd]){1,4}$/
1184
+
1185
+ export interface TideDraftReadied {
1186
+ id: string
1187
+ /** The moment tide will send at, ISO UTC; null when a scheduler judges it. */
1188
+ send_at: string | null
1189
+ judged: boolean
1190
+ window_seconds: number | null
1191
+ line: string
1192
+ }
1193
+
1194
+ /** Run one `tide drafts <verb>` that answers a single line, or throw the classified failure. */
1195
+ async function runDraftVerb(args: string[], opts: TideRunOptions): Promise<string> {
1196
+ const bin = await resolveTideBin()
1197
+ const timeoutMs = opts.timeoutMs ?? 15_000
1198
+ const startedAt = Date.now()
1199
+ try {
1200
+ const { stdout } = await pExecFile(bin, args, { timeout: timeoutMs, cwd: opts.cwd })
1201
+ return stdout.trim().split("\n").pop() ?? ""
1202
+ } catch (err) {
1203
+ throw classifyExecFailure(bin, args, err, Date.now() - startedAt, timeoutMs)
1204
+ }
1205
+ }
1206
+
1207
+ function draftRef(ref: string): string {
1208
+ const id = ref.trim()
1209
+ if (!DRAFT_REF_PATTERN.test(id)) {
1210
+ throw new TideError(`"${ref}" is not a draft id: hex, 4 to 64 characters, optionally after "draft:"`)
1211
+ }
1212
+ return id
1213
+ }
1214
+
1215
+ /**
1216
+ * Flag a mctgo draft's present text ready to be sent at a moment (`tide.draft.readied`,
1217
+ * Episode 548 R1). The flag is the person's consent for that one text; tide presses Enter
1218
+ * at the moment only when nobody has the pane in front of them (R2). Changing the text,
1219
+ * `unreadyDraft`, or a missed window ends it. Refusals are `TideError`s of kind `exit`.
1220
+ */
1221
+ export async function readyDraft(
1222
+ ref: string,
1223
+ when: DraftReadyWhen,
1224
+ opts: TideRunOptions & { window?: string; by?: string } = {},
1225
+ ): Promise<TideDraftReadied> {
1226
+ const id = draftRef(ref)
1227
+ const args = ["drafts", "ready", id]
1228
+ if ("at" in when) {
1229
+ if (!DRAFT_AT_PATTERN.test(when.at)) throw new TideError(`"${when.at}" is not a time: 14:30, or an ISO time`)
1230
+ args.push("--at", when.at)
1231
+ } else if ("in" in when) {
1232
+ if (!DRAFT_DURATION_PATTERN.test(when.in)) throw new TideError(`"${when.in}" is not a duration: 90m, 1h, 4h30m, 2d`)
1233
+ args.push("--in", when.in)
1234
+ } else if (when.judged === true) {
1235
+ args.push("--judged")
1236
+ } else {
1237
+ throw new TideError("say when: at a time, in a delay, or judged")
1238
+ }
1239
+ if (opts.window !== undefined) {
1240
+ if (!DRAFT_DURATION_PATTERN.test(opts.window)) throw new TideError(`"${opts.window}" is not a window: 30m, 1h, 2h`)
1241
+ args.push("--window", opts.window)
1242
+ }
1243
+ args.push(...byArgs(opts.by))
1244
+ const line = await runDraftVerb(args, opts)
1245
+ // tide.draft.readied <id> <pane> <send_at | judged> window <n> s
1246
+ const m = /^tide\.draft\.readied\s+([0-9a-f]+)\s+\S+\s+(\S+)\s+window\s+(\d+)\s*s/.exec(line)
1247
+ const moment = m?.[2] ?? null
1248
+ return {
1249
+ id: m?.[1] ?? id.replace(/^draft:/, ""),
1250
+ send_at: moment && moment !== "judged" ? moment : null,
1251
+ judged: moment === "judged" || "judged" in when,
1252
+ window_seconds: m ? Number(m[3]) : null,
1253
+ line,
1254
+ }
1255
+ }
1256
+
1257
+ /** End a draft's ready flag (`tide.draft.unreadied`). It stays at its prompt, unsent. */
1258
+ export async function unreadyDraft(ref: string, opts: TideRunOptions & { by?: string } = {}): Promise<{ id: string; line: string }> {
1259
+ const id = draftRef(ref)
1260
+ const line = await runDraftVerb(["drafts", "unready", id, ...byArgs(opts.by)], opts)
1261
+ const closed = /^tide\.draft\.unreadied\s+([0-9a-f]+)/.exec(line)?.[1]
1262
+ return { id: closed ?? id.replace(/^draft:/, ""), line }
1263
+ }