@mattstack/rt-client 0.15.1 → 0.19.0

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/dist/client.d.ts CHANGED
@@ -195,3 +195,33 @@ export declare function gateClose(a: Commands["gate:close"]["payload"], o?: RtCl
195
195
  export declare function gateSubscribe(a: Commands["gate:subscribe"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["gate:subscribe"]["data"]>>;
196
196
  export declare function gateUnsubscribe(a: Commands["gate:unsubscribe"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["gate:unsubscribe"]["data"]>>;
197
197
  export declare function gateSubscriptions(a: Commands["gate:subscriptions"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["gate:subscriptions"]["data"]>>;
198
+ /** Provisions the room, workspace and subscription before it answers, so it
199
+ gets the same 60s budget as a spawn rather than the 10s default. */
200
+ export declare function herdStart(a: Commands["herd:start"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:start"]["data"]>>;
201
+ /** Worktree provision plus agent launch; the 10s default cannot cover it. */
202
+ export declare function herdSpawn(a: Commands["herd:spawn"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:spawn"]["data"]>>;
203
+ export declare function herdAsk(a: Commands["herd:ask"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:ask"]["data"]>>;
204
+ export declare function herdMilestone(a: Commands["herd:milestone"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:milestone"]["data"]>>;
205
+ export declare function herdAnswer(a: Commands["herd:answer"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:answer"]["data"]>>;
206
+ /** A disposable job's report also closes its pane, one herdr CLI call under the runner's own 15s budget. */
207
+ export declare function herdReport(a: Commands["herd:report"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:report"]["data"]>>;
208
+ export declare function herdGates(a: Commands["herd:gates"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:gates"]["data"]>>;
209
+ export declare function herdStatus(a: Commands["herd:status"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:status"]["data"]>>;
210
+ export declare function herdList(a?: Commands["herd:list"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:list"]["data"]>>;
211
+ export declare function herdResume(a: Commands["herd:resume"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:resume"]["data"]>>;
212
+ /** Closes a herdr pane, one CLI call under the runner's own 15s budget. */
213
+ export declare function herdClose(a: Commands["herd:close"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:close"]["data"]>>;
214
+ /** Three sequential herdr CLI calls (pane get, tab create, pane run), each under the runner's own 15s budget. */
215
+ export declare function herdAttend(a: Commands["herd:attend"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:attend"]["data"]>>;
216
+ /** Closes panes, disposes worktrees and archives the room in one pass; the
217
+ worktree disposals alone can outrun a spawn's budget. */
218
+ export declare function herdWrapUp(a: Commands["herd:wrap-up"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:wrap-up"]["data"]>>;
219
+ /** Runs `herdr session stop`, one CLI call under the runner's own 15s budget. */
220
+ export declare function herdStopHidden(_a: Commands["herd:stop-hidden"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["herd:stop-hidden"]["data"]>>;
221
+ /** May spawn `herdr server` and wait for it to bind; budget matches bg-service's own 10s readyTimeoutMs plus margin. */
222
+ export declare function bgEnsure(a?: Commands["bg:ensure"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["bg:ensure"]["data"]>>;
223
+ /** Never ensures/spawns; a plain read of the current state. */
224
+ export declare function bgStatus(o?: RtClientOptions): Promise<RtResponse<Commands["bg:status"]["data"]>>;
225
+ /** Asks the daemon to stop the background server; refuses (ok:false) while any claim is live, naming the owners. */
226
+ export declare function bgStop(o?: RtClientOptions): Promise<RtResponse<Commands["bg:stop"]["data"]>>;
227
+ export declare function bgRelease(a: Commands["bg:release"]["payload"], o?: RtClientOptions): Promise<RtResponse<Commands["bg:release"]["data"]>>;
@@ -102,12 +102,25 @@ export interface EventsBusEvent {
102
102
  value gates-store.ts's release tracking (CAS winner or loser) reacts to. */
103
103
  export declare const GATE_BY_PANE = "pane";
104
104
  export type GateStatus = "open" | "answered" | "parked" | "closed";
105
+ export type GateOption = string | {
106
+ value: string;
107
+ label: string;
108
+ };
109
+ export interface GateOrigin {
110
+ paneId?: string;
111
+ tabId?: string;
112
+ runId?: string;
113
+ worktree?: string;
114
+ presentation?: "form" | "wait";
115
+ }
105
116
  export interface GateQuestion {
106
117
  id: string;
107
118
  label: string;
108
119
  multi: boolean;
109
- options: string[];
120
+ options: GateOption[];
110
121
  }
122
+ export declare function gateOptionValue(o: GateOption): string;
123
+ export declare function gateOptionLabel(o: GateOption): string;
111
124
  export interface GateAnswer {
112
125
  answers: Record<string, string | string[] | {
113
126
  value: string | string[];
@@ -122,6 +135,8 @@ export interface GateRow {
122
135
  kind: string;
123
136
  questions: GateQuestion[];
124
137
  meta: Record<string, unknown> | null;
138
+ context?: string | null;
139
+ origin?: GateOrigin | null;
125
140
  status: GateStatus;
126
141
  answer: GateAnswer | null;
127
142
  openedAt: number;
@@ -150,6 +165,59 @@ export interface GateSubscription {
150
165
  } | null;
151
166
  dead: boolean;
152
167
  }
168
+ export interface HerdInfo {
169
+ id: string;
170
+ repo: string;
171
+ room: string;
172
+ workspace: string;
173
+ shepherdSession: string;
174
+ shepherdHandle: string;
175
+ herdrSocket: string | null;
176
+ hidden: boolean;
177
+ status: "active" | "wrapped";
178
+ createdAt: number;
179
+ wrappedAt: number | null;
180
+ }
181
+ /** A herd row as `herd:list` reports it: the registry row plus how many jobs hang off it. */
182
+ export interface HerdListRow extends HerdInfo {
183
+ jobs: number;
184
+ }
185
+ export interface HerdJobInfo {
186
+ herd: string;
187
+ name: string;
188
+ worktree: string;
189
+ branch: string | null;
190
+ tree: string | null;
191
+ pane: string | null;
192
+ agentSession: string | null;
193
+ agentId: string | null;
194
+ handle: string;
195
+ status: "spawning" | "active" | "at-gate" | "at-milestone" | "done" | "closed" | "crashed";
196
+ disposable: boolean;
197
+ lastGate: string | null;
198
+ lastReport: number | null;
199
+ createdAt: number;
200
+ updatedAt: number;
201
+ }
202
+ /** `lastGateStatus`/`lastGateDelivery` come from the job's `lastGate` row: an `answered` gate whose delivery is `dead-pane` is the "answered, worker not woken" case the shepherd must act on. */
203
+ export interface HerdStatusData {
204
+ herd: HerdInfo;
205
+ jobs: Array<HerdJobInfo & {
206
+ openGate: string | null;
207
+ paneStatus: string | null;
208
+ lastGateStatus: GateStatus | null;
209
+ lastGateDelivery: "delivered" | "dead-pane" | null;
210
+ }>;
211
+ unread: number;
212
+ lifecycleConnected: boolean;
213
+ hiddenUp: boolean | null;
214
+ /** The shepherd session's own `herd:<id>/` subscription row, or null when none is live. */
215
+ subscription: {
216
+ id: string;
217
+ dead: boolean;
218
+ lastDelivery: GateSubscription["lastDelivery"];
219
+ } | null;
220
+ }
153
221
  /**
154
222
  * Duplicated shape on purpose, same reasoning as EventsBusEvent above:
155
223
  * these mirror lib/state/chat-store.ts's types, which rt-client cannot
@@ -270,9 +338,13 @@ export interface PaneSendResult {
270
338
  delivered: PaneDelivery;
271
339
  reason?: string;
272
340
  }
341
+ /** `attendTab` is set only for a `bg:` ref: focus for a background pane IS
342
+ the attend flow (a visible tab running a terminal attach), and this is
343
+ that tab's id. */
273
344
  export interface PaneFocusResult {
274
345
  paneId: string;
275
346
  focused: boolean;
347
+ attendTab?: string;
276
348
  }
277
349
  export type Attention = {
278
350
  needs: boolean;
@@ -1004,6 +1076,10 @@ export interface Commands {
1004
1076
  workspace?: string;
1005
1077
  tab?: string;
1006
1078
  extraArgs?: string;
1079
+ env?: Record<string, string>;
1080
+ herdrSocket?: string;
1081
+ handle?: string;
1082
+ bg?: boolean;
1007
1083
  };
1008
1084
  data: AgentRecord;
1009
1085
  };
@@ -1093,9 +1169,12 @@ export interface Commands {
1093
1169
  };
1094
1170
  data: PaneSendResult;
1095
1171
  };
1172
+ /** `callerWorkspace` (HERDR_WORKSPACE_ID) is required only for a `bg:`
1173
+ ref, whose focus opens an attend tab in the caller's own workspace. */
1096
1174
  "pane:focus": {
1097
1175
  payload: {
1098
1176
  paneId: string;
1177
+ callerWorkspace?: string;
1099
1178
  };
1100
1179
  data: PaneFocusResult;
1101
1180
  };
@@ -1276,6 +1355,8 @@ export interface Commands {
1276
1355
  nudge?: {
1277
1356
  session: string;
1278
1357
  };
1358
+ context?: string;
1359
+ origin?: GateOrigin;
1279
1360
  };
1280
1361
  data: {
1281
1362
  id: string;
@@ -1373,6 +1454,179 @@ export interface Commands {
1373
1454
  subscriptions: GateSubscription[];
1374
1455
  };
1375
1456
  };
1457
+ "herd:start": {
1458
+ payload: {
1459
+ name: string;
1460
+ repo: string;
1461
+ session: string;
1462
+ hidden?: boolean;
1463
+ };
1464
+ data: {
1465
+ herd: string;
1466
+ room: string;
1467
+ workspace: string;
1468
+ subscription: string;
1469
+ handle: string;
1470
+ hidden: boolean;
1471
+ };
1472
+ };
1473
+ "herd:resume": {
1474
+ payload: {
1475
+ herd: string;
1476
+ session: string;
1477
+ };
1478
+ data: {
1479
+ subscription: string;
1480
+ gates: GateRow[];
1481
+ unread: number;
1482
+ status: HerdStatusData;
1483
+ handle: string;
1484
+ };
1485
+ };
1486
+ "herd:status": {
1487
+ payload: {
1488
+ herd: string;
1489
+ };
1490
+ data: HerdStatusData;
1491
+ };
1492
+ /** Active herds only unless `all`, so a shepherd's "which herd am I on" question has one answer. */
1493
+ "herd:list": {
1494
+ payload: {
1495
+ all?: boolean;
1496
+ };
1497
+ data: {
1498
+ herds: HerdListRow[];
1499
+ };
1500
+ };
1501
+ "herd:close": {
1502
+ payload: {
1503
+ herd: string;
1504
+ job: string;
1505
+ };
1506
+ data: {
1507
+ job: string;
1508
+ status: "closed";
1509
+ };
1510
+ };
1511
+ /** `brief` is the brief TEXT, not a path: the CLI reads the file. It is stored at `<jobsRoot>/<herd>/<job>/job.md`, so a respawn with `dir` and no `brief` reads it back. */
1512
+ "herd:spawn": {
1513
+ payload: {
1514
+ herd: string;
1515
+ job: string;
1516
+ brief?: string;
1517
+ dir?: string;
1518
+ model?: string;
1519
+ effort?: string;
1520
+ account?: string;
1521
+ disposable?: boolean;
1522
+ };
1523
+ data: {
1524
+ herd: string;
1525
+ job: string;
1526
+ pane: string;
1527
+ worktree: string;
1528
+ branch: string | null;
1529
+ tree: string | null; /** null = no provisioning ran (--dir); false = cold create, worth announcing. */
1530
+ wasOnDeck: boolean | null;
1531
+ agentId: string;
1532
+ sessionId: string;
1533
+ handle: string;
1534
+ };
1535
+ };
1536
+ "herd:gates": {
1537
+ payload: {
1538
+ herd: string;
1539
+ };
1540
+ data: {
1541
+ gates: GateRow[];
1542
+ };
1543
+ };
1544
+ "herd:ask": {
1545
+ payload: {
1546
+ herd: string;
1547
+ job: string;
1548
+ session: string;
1549
+ pane?: string;
1550
+ questions: GateQuestion[];
1551
+ context?: string;
1552
+ };
1553
+ data: {
1554
+ gate: string;
1555
+ };
1556
+ };
1557
+ "herd:milestone": {
1558
+ payload: {
1559
+ herd: string;
1560
+ job: string;
1561
+ session: string;
1562
+ pane?: string;
1563
+ artifact: string;
1564
+ summary?: string;
1565
+ };
1566
+ data: {
1567
+ gate: string;
1568
+ message: number;
1569
+ };
1570
+ };
1571
+ "herd:answer": {
1572
+ payload: {
1573
+ gate: string;
1574
+ };
1575
+ data: {
1576
+ gate: string;
1577
+ status: GateStatus;
1578
+ answer: GateAnswer | null;
1579
+ closedReason: GateRow["closedReason"];
1580
+ };
1581
+ };
1582
+ "herd:report": {
1583
+ payload: {
1584
+ herd: string;
1585
+ job: string;
1586
+ body: string;
1587
+ };
1588
+ data: {
1589
+ message: number;
1590
+ };
1591
+ };
1592
+ /** `callerWorkspace` is the attending session's own HERDR_WORKSPACE_ID: the attached tab opens there, not in the herd's workspace. */
1593
+ "herd:attend": {
1594
+ payload: {
1595
+ herd: string;
1596
+ job: string;
1597
+ callerWorkspace: string;
1598
+ };
1599
+ data: {
1600
+ tab: string;
1601
+ pane: string;
1602
+ };
1603
+ };
1604
+ "herd:stop-hidden": {
1605
+ payload: Record<string, never>;
1606
+ data: {
1607
+ stopped: boolean;
1608
+ };
1609
+ };
1610
+ "herd:wrap-up": {
1611
+ payload: {
1612
+ herd: string;
1613
+ closePanes?: boolean;
1614
+ dispose?: string[];
1615
+ deleteJobDirs?: boolean;
1616
+ archiveRoom?: boolean;
1617
+ };
1618
+ data: {
1619
+ closed: string[];
1620
+ workspaceClosed: boolean;
1621
+ disposed: string[];
1622
+ refused: Array<{
1623
+ tree: string;
1624
+ reason: string;
1625
+ }>;
1626
+ deletedJobDirs: boolean;
1627
+ archived: boolean;
1628
+ };
1629
+ };
1376
1630
  /** Wire reply on success is always `{ok:true, repaired}` (no `data`
1377
1631
  * wrapper) — `data` here documents the extra field the same way PingData
1378
1632
  * does for `ping`, not the literal wire nesting (R3). */
@@ -1471,6 +1725,46 @@ export interface Commands {
1471
1725
  };
1472
1726
  data: WorktreeAdoptData;
1473
1727
  };
1728
+ "bg:ensure": {
1729
+ payload: {
1730
+ claim?: string;
1731
+ };
1732
+ data: {
1733
+ socket: string;
1734
+ started: boolean;
1735
+ parity: {
1736
+ ok: boolean;
1737
+ drift: string[];
1738
+ } | null;
1739
+ };
1740
+ };
1741
+ "bg:status": {
1742
+ payload: Record<string, never>;
1743
+ data: {
1744
+ up: boolean;
1745
+ socket: string;
1746
+ claims: Array<{
1747
+ owner: string;
1748
+ pane: string | null;
1749
+ createdAt: number;
1750
+ }>;
1751
+ };
1752
+ };
1753
+ /** Rejects (`ok:false`) naming every live claim owner while any claim is held. */
1754
+ "bg:stop": {
1755
+ payload: Record<string, never>;
1756
+ data: {
1757
+ stopped: boolean;
1758
+ };
1759
+ };
1760
+ "bg:release": {
1761
+ payload: {
1762
+ claim: string;
1763
+ };
1764
+ data: {
1765
+ released: boolean;
1766
+ };
1767
+ };
1474
1768
  }
1475
1769
  export type CommandName = keyof Commands;
1476
1770
  export declare const COMMAND_NAMES: readonly CommandName[];
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  export { rtCommand, DEFAULT_SOCK } from "./transport.ts";
2
2
  export type { RtResponse, RtClientOptions } from "./transport.ts";
3
- export { readProjectMRs, readDiscussions, readMrsByBranch, readBranchCache, resolveForgeToken, listRuns, getRun, abandonRun, chatJoin, chatLeave, chatAck, chatClaim, chatRelease, chatPost, chatRead, chatRooms, chatWho, chatMark, chatMessages, chatSignIn, chatSignOut, chatAway, chatBack, chatBuddies, chatDm, chatArchive, chatDmOpen, eventsHead, eventsEmit, eventsWait, eventsList, agentStart, agentResume, agentGet, agentList, paneList, panePeek, paneSpawn, paneAccounts, paneDirectories, chatInvite, paneSend, paneFocus, gateOpen, gateAnswer, gateWait, gateList, gatePark, gateClose, gateSubscribe, gateUnsubscribe, gateSubscriptions, } from "./client.ts";
4
- export { COMMAND_NAMES, GATE_BY_PANE } from "./commands.ts";
5
- export type { Discussion, DemandDecl, ProjectMRsScope, ProjectMRsData, DiscussionsData, MrByBranchEntry, MrByBranchData, BranchEnrichment, Commands, CommandName, ForgeSlug, ForgeTokenData, Attention, RunSummary, RunStageRow, RunFieldRow, RunDecisionRow, RunDetail, WakeMode, ChatMember, ChatMessage, ChatClaimOutcome, RoomSummary, BuddyStatus, PresenceRow, AgentRecord, AgentSurface, AgentStatus, ChatPane, PaneAccount, PaneDirectory, InviteResult, PaneDelivery, PaneSendResult, PaneFocusResult, GateStatus, GateQuestion, GateAnswer, GateRow, GateSubscription, } from "./commands.ts";
3
+ export { readProjectMRs, readDiscussions, readMrsByBranch, readBranchCache, resolveForgeToken, listRuns, getRun, abandonRun, chatJoin, chatLeave, chatAck, chatClaim, chatRelease, chatPost, chatRead, chatRooms, chatWho, chatMark, chatMessages, chatSignIn, chatSignOut, chatAway, chatBack, chatBuddies, chatDm, chatArchive, chatDmOpen, eventsHead, eventsEmit, eventsWait, eventsList, agentStart, agentResume, agentGet, agentList, paneList, panePeek, paneSpawn, paneAccounts, paneDirectories, chatInvite, paneSend, paneFocus, gateOpen, gateAnswer, gateWait, gateList, gatePark, gateClose, gateSubscribe, gateUnsubscribe, gateSubscriptions, herdStart, herdSpawn, herdAsk, herdMilestone, herdAnswer, herdReport, herdGates, herdStatus, herdList, herdResume, herdClose, herdAttend, herdWrapUp, herdStopHidden, bgEnsure, bgStatus, bgStop, bgRelease, } from "./client.ts";
4
+ export { COMMAND_NAMES, GATE_BY_PANE, gateOptionValue, gateOptionLabel } from "./commands.ts";
5
+ export type { Discussion, DemandDecl, ProjectMRsScope, ProjectMRsData, DiscussionsData, MrByBranchEntry, MrByBranchData, BranchEnrichment, Commands, CommandName, ForgeSlug, ForgeTokenData, Attention, RunSummary, RunStageRow, RunFieldRow, RunDecisionRow, RunDetail, WakeMode, ChatMember, ChatMessage, ChatClaimOutcome, RoomSummary, BuddyStatus, PresenceRow, AgentRecord, AgentSurface, AgentStatus, ChatPane, PaneAccount, PaneDirectory, InviteResult, PaneDelivery, PaneSendResult, PaneFocusResult, GateStatus, GateOption, GateOrigin, GateQuestion, GateAnswer, GateRow, GateSubscription, HerdInfo, HerdListRow, HerdJobInfo, HerdStatusData, } from "./commands.ts";
6
6
  export { subscribe, createRelay, DEFAULT_WS_URL } from "./relay.ts";
7
7
  export type { RelayEventType } from "./relay.ts";
8
8
  export { daemonHealth } from "./health.ts";
9
9
  export { repoNameForPath } from "./repos.ts";
10
10
  export { decidePlacement, openSmartPane } from "./smart-pane.ts";
11
11
  export type { Placement, PlacementOpts, HerdrCall } from "./smart-pane.ts";
12
+ export { BG_PREFIX, parsePaneRef, formatPaneRef } from "./pane-ref.ts";
13
+ export type { PaneServer, PaneRef } from "./pane-ref.ts";
12
14
  export { getSetting, listSettings, explainSetting, expandVariables, SCOPE_ORDER, setSettingsWarnSink } from "./settings/resolve.ts";
13
15
  export type { Scope, Provenance, ResolveOpts, Resolved, InvalidScope, ListedSetting, ExplainRow, ExpandCtx, } from "./settings/resolve.ts";
14
16
  export { setSetting, unsetSetting } from "./settings/write.ts";