@sagmans/dsh-tui 0.2.0 → 0.4.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.
Files changed (174) hide show
  1. package/README.md +282 -25
  2. package/cordis.patch.yml +14 -0
  3. package/lib/agent/model.d.ts +26 -0
  4. package/lib/agent/model.d.ts.map +1 -1
  5. package/lib/agent/model.js +41 -0
  6. package/lib/agent/model.js.map +1 -1
  7. package/lib/agent/projections.d.ts +22 -6
  8. package/lib/agent/projections.d.ts.map +1 -1
  9. package/lib/agent/projections.js +21 -10
  10. package/lib/agent/projections.js.map +1 -1
  11. package/lib/agent/prompt-history.d.ts +89 -0
  12. package/lib/agent/prompt-history.d.ts.map +1 -0
  13. package/lib/agent/prompt-history.js +380 -0
  14. package/lib/agent/prompt-history.js.map +1 -0
  15. package/lib/agent/status.d.ts +16 -0
  16. package/lib/agent/status.d.ts.map +1 -1
  17. package/lib/agent/status.js +3 -0
  18. package/lib/agent/status.js.map +1 -1
  19. package/lib/cards.d.ts +1 -1
  20. package/lib/cards.d.ts.map +1 -1
  21. package/lib/cards.js +4 -3
  22. package/lib/cards.js.map +1 -1
  23. package/lib/gates.d.ts +145 -2
  24. package/lib/gates.d.ts.map +1 -1
  25. package/lib/gates.js +335 -40
  26. package/lib/gates.js.map +1 -1
  27. package/lib/herdr/client.d.ts +57 -0
  28. package/lib/herdr/client.d.ts.map +1 -0
  29. package/lib/herdr/client.js +218 -0
  30. package/lib/herdr/client.js.map +1 -0
  31. package/lib/herdr/constants.d.ts +93 -0
  32. package/lib/herdr/constants.d.ts.map +1 -0
  33. package/lib/herdr/constants.js +79 -0
  34. package/lib/herdr/constants.js.map +1 -0
  35. package/lib/herdr/reporter.d.ts +60 -0
  36. package/lib/herdr/reporter.d.ts.map +1 -0
  37. package/lib/herdr/reporter.js +217 -0
  38. package/lib/herdr/reporter.js.map +1 -0
  39. package/lib/herdr/state.d.ts +57 -0
  40. package/lib/herdr/state.d.ts.map +1 -0
  41. package/lib/herdr/state.js +62 -0
  42. package/lib/herdr/state.js.map +1 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +631 -118
  45. package/lib/index.js.map +1 -1
  46. package/lib/input/actions.d.ts +136 -0
  47. package/lib/input/actions.d.ts.map +1 -0
  48. package/lib/input/actions.js +743 -0
  49. package/lib/input/actions.js.map +1 -0
  50. package/lib/input/ghost.d.ts +46 -0
  51. package/lib/input/ghost.d.ts.map +1 -0
  52. package/lib/input/ghost.js +58 -0
  53. package/lib/input/ghost.js.map +1 -0
  54. package/lib/input/keymap-settings.d.ts +21 -0
  55. package/lib/input/keymap-settings.d.ts.map +1 -0
  56. package/lib/input/keymap-settings.js +28 -0
  57. package/lib/input/keymap-settings.js.map +1 -0
  58. package/lib/input/keymap.d.ts +91 -0
  59. package/lib/input/keymap.d.ts.map +1 -0
  60. package/lib/input/keymap.js +172 -0
  61. package/lib/input/keymap.js.map +1 -0
  62. package/lib/input/match.d.ts +10 -0
  63. package/lib/input/match.d.ts.map +1 -0
  64. package/lib/input/match.js +83 -0
  65. package/lib/input/match.js.map +1 -0
  66. package/lib/input/submission.d.ts +29 -1
  67. package/lib/input/submission.d.ts.map +1 -1
  68. package/lib/input/submission.js +33 -2
  69. package/lib/input/submission.js.map +1 -1
  70. package/lib/input.d.ts +17 -0
  71. package/lib/input.d.ts.map +1 -0
  72. package/lib/input.js +27 -0
  73. package/lib/input.js.map +1 -0
  74. package/lib/keys-command.d.ts +16 -0
  75. package/lib/keys-command.d.ts.map +1 -0
  76. package/lib/keys-command.js +60 -0
  77. package/lib/keys-command.js.map +1 -0
  78. package/lib/queue.d.ts +6 -0
  79. package/lib/queue.d.ts.map +1 -0
  80. package/lib/queue.js +68 -0
  81. package/lib/queue.js.map +1 -0
  82. package/lib/settings-notice.d.ts +19 -0
  83. package/lib/settings-notice.d.ts.map +1 -0
  84. package/lib/settings-notice.js +30 -0
  85. package/lib/settings-notice.js.map +1 -0
  86. package/lib/stash/lock.d.ts +72 -0
  87. package/lib/stash/lock.d.ts.map +1 -0
  88. package/lib/stash/lock.js +374 -0
  89. package/lib/stash/lock.js.map +1 -0
  90. package/lib/stash/paths.d.ts +22 -0
  91. package/lib/stash/paths.d.ts.map +1 -0
  92. package/lib/stash/paths.js +83 -0
  93. package/lib/stash/paths.js.map +1 -0
  94. package/lib/stash/private-fs.d.ts +61 -0
  95. package/lib/stash/private-fs.d.ts.map +1 -0
  96. package/lib/stash/private-fs.js +379 -0
  97. package/lib/stash/private-fs.js.map +1 -0
  98. package/lib/stash/schema.d.ts +57 -0
  99. package/lib/stash/schema.d.ts.map +1 -0
  100. package/lib/stash/schema.js +127 -0
  101. package/lib/stash/schema.js.map +1 -0
  102. package/lib/stash/store.d.ts +92 -0
  103. package/lib/stash/store.d.ts.map +1 -0
  104. package/lib/stash/store.js +262 -0
  105. package/lib/stash/store.js.map +1 -0
  106. package/lib/stash.d.ts +91 -0
  107. package/lib/stash.d.ts.map +1 -0
  108. package/lib/stash.js +296 -0
  109. package/lib/stash.js.map +1 -0
  110. package/lib/theme-settings.d.ts +72 -8
  111. package/lib/theme-settings.d.ts.map +1 -1
  112. package/lib/theme-settings.js +125 -5
  113. package/lib/theme-settings.js.map +1 -1
  114. package/lib/theme-tokens.d.ts +4 -4
  115. package/lib/theme-tokens.d.ts.map +1 -1
  116. package/lib/theme-tokens.js +39 -5
  117. package/lib/theme-tokens.js.map +1 -1
  118. package/lib/todo-guard.d.ts +116 -0
  119. package/lib/todo-guard.d.ts.map +1 -0
  120. package/lib/todo-guard.js +259 -0
  121. package/lib/todo-guard.js.map +1 -0
  122. package/lib/ui/editor.d.ts +58 -1
  123. package/lib/ui/editor.d.ts.map +1 -1
  124. package/lib/ui/editor.js +174 -19
  125. package/lib/ui/editor.js.map +1 -1
  126. package/lib/ui/frame.d.ts +54 -0
  127. package/lib/ui/frame.d.ts.map +1 -0
  128. package/lib/ui/frame.js +79 -0
  129. package/lib/ui/frame.js.map +1 -0
  130. package/lib/ui/gate-input.d.ts +20 -0
  131. package/lib/ui/gate-input.d.ts.map +1 -0
  132. package/lib/ui/gate-input.js +96 -0
  133. package/lib/ui/gate-input.js.map +1 -0
  134. package/lib/ui/history-picker.d.ts +15 -0
  135. package/lib/ui/history-picker.d.ts.map +1 -0
  136. package/lib/ui/history-picker.js +26 -0
  137. package/lib/ui/history-picker.js.map +1 -0
  138. package/lib/ui/markdown.d.ts +11 -2
  139. package/lib/ui/markdown.d.ts.map +1 -1
  140. package/lib/ui/markdown.js +25 -6
  141. package/lib/ui/markdown.js.map +1 -1
  142. package/lib/ui/mermaid.d.ts +44 -0
  143. package/lib/ui/mermaid.d.ts.map +1 -0
  144. package/lib/ui/mermaid.js +178 -0
  145. package/lib/ui/mermaid.js.map +1 -0
  146. package/lib/ui/picker.d.ts +40 -8
  147. package/lib/ui/picker.d.ts.map +1 -1
  148. package/lib/ui/picker.js +79 -24
  149. package/lib/ui/picker.js.map +1 -1
  150. package/lib/ui/prompt.d.ts +32 -0
  151. package/lib/ui/prompt.d.ts.map +1 -0
  152. package/lib/ui/prompt.js +49 -0
  153. package/lib/ui/prompt.js.map +1 -0
  154. package/lib/ui/queue.d.ts +24 -0
  155. package/lib/ui/queue.d.ts.map +1 -0
  156. package/lib/ui/queue.js +57 -0
  157. package/lib/ui/queue.js.map +1 -0
  158. package/lib/ui/stash-picker.d.ts +43 -0
  159. package/lib/ui/stash-picker.d.ts.map +1 -0
  160. package/lib/ui/stash-picker.js +78 -0
  161. package/lib/ui/stash-picker.js.map +1 -0
  162. package/lib/ui/status.d.ts +6 -0
  163. package/lib/ui/status.d.ts.map +1 -1
  164. package/lib/ui/status.js +15 -0
  165. package/lib/ui/status.js.map +1 -1
  166. package/lib/ui/view.d.ts +22 -2
  167. package/lib/ui/view.d.ts.map +1 -1
  168. package/lib/ui/view.js +84 -24
  169. package/lib/ui/view.js.map +1 -1
  170. package/lib/work.d.ts +51 -1
  171. package/lib/work.d.ts.map +1 -1
  172. package/lib/work.js +53 -1
  173. package/lib/work.js.map +1 -1
  174. package/package.json +7 -2
@@ -0,0 +1,218 @@
1
+ /**
2
+ * The Herdr socket.
3
+ *
4
+ * Every method resolves rather than throws: a multiplexer that is absent, busy,
5
+ * or restarting is not a failure this surface may surface to its reader, whose
6
+ * conversation is the thing on screen. The same reasoning keeps the transport
7
+ * off stdout and stderr — the alternate screen owns both.
8
+ */
9
+ import { createConnection } from 'node:net';
10
+ import { DEFAULT_ATTEMPTS, DEFAULT_TIMEOUT_MS, HERDR_AGENT, HERDR_ENV_FLAG, HERDR_ENV_VAR, HERDR_PANE_ID_VAR, HERDR_SOCKET_PATH_VAR, HERDR_SOURCE, MAX_METADATA_VALUE_CHARS, MAX_RESPONSE_BYTES, RESPONSE_DELIMITER, } from "./constants.js";
11
+ /**
12
+ * Create the client for one pane.
13
+ *
14
+ * Requests are serialized instead of racing: state reports are sequenced
15
+ * server-side, and a queue keeps a session's identity arriving before the state
16
+ * that names it. The queue is bounded in practice because states change a
17
+ * handful of times a turn and each attempt is spent against one deadline.
18
+ */
19
+ export function createHerdrClient(env = process.env, options = {}) {
20
+ const paneId = env[HERDR_PANE_ID_VAR];
21
+ const socketPath = env[HERDR_SOCKET_PATH_VAR];
22
+ // Herdr exports all three together; requiring each keeps a half-configured
23
+ // environment from producing reports that name no pane.
24
+ const enabled = env[HERDR_ENV_VAR] === HERDR_ENV_FLAG && paneId !== undefined && socketPath !== undefined;
25
+ const attempts = Math.max(1, options.attempts ?? DEFAULT_ATTEMPTS);
26
+ const timeoutMs = Math.max(1, options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
27
+ let requestNumber = 0;
28
+ let queued = [];
29
+ let pumping = false;
30
+ let closed = false;
31
+ let waiters = [];
32
+ const wake = () => {
33
+ const waiting = waiters;
34
+ waiters = [];
35
+ for (const resolve of waiting)
36
+ resolve();
37
+ };
38
+ const deliver = async (request) => socketPath === undefined
39
+ ? true
40
+ : sendWithRetry(socketPath, request, attempts, timeoutMs, () => closed);
41
+ const pump = async () => {
42
+ if (pumping)
43
+ return;
44
+ pumping = true;
45
+ try {
46
+ while (!closed && queued.length > 0) {
47
+ const next = queued.shift();
48
+ if (next === undefined)
49
+ break;
50
+ next.settle(await deliver(next.request));
51
+ }
52
+ }
53
+ finally {
54
+ pumping = false;
55
+ wake();
56
+ }
57
+ };
58
+ const enqueue = (method, params, coalescing) => new Promise(resolve => {
59
+ if (closed || !enabled || paneId === undefined || socketPath === undefined) {
60
+ resolve(true);
61
+ return;
62
+ }
63
+ const request = {
64
+ id: `${HERDR_SOURCE}:${String(process.pid)}:${String(++requestNumber)}`,
65
+ method,
66
+ params: { pane_id: paneId, source: HERDR_SOURCE, agent: HERDR_AGENT, ...params },
67
+ };
68
+ if (coalescing && queued.some(entry => entry.coalescing)) {
69
+ const superseded = queued.filter(entry => entry.coalescing);
70
+ queued = queued.filter(entry => !entry.coalescing);
71
+ // Superseded, not lost: the report that replaced it says what this one
72
+ // said and more, so nothing is left owed to Herdr.
73
+ for (const entry of superseded)
74
+ entry.settle(true);
75
+ }
76
+ queued.push({ request, coalescing, settle: resolve });
77
+ void pump();
78
+ });
79
+ return {
80
+ enabled,
81
+ reportState(report) {
82
+ return enqueue('pane.report_agent', {
83
+ state: report.state,
84
+ seq: report.seq,
85
+ ...(report.message === undefined ? {} : { message: report.message }),
86
+ ...(report.sessionId === undefined ? {} : { agent_session_id: report.sessionId }),
87
+ }, true);
88
+ },
89
+ reportSession(report) {
90
+ return enqueue('pane.report_agent_session', {
91
+ agent_session_id: report.sessionId,
92
+ seq: report.seq,
93
+ session_start_source: report.reason,
94
+ }, false);
95
+ },
96
+ reportMetadata(tokens) {
97
+ return enqueue('pane.report_metadata', {
98
+ applies_to_source: HERDR_SOURCE,
99
+ tokens: acceptedTokens(tokens),
100
+ }, false);
101
+ },
102
+ stop() {
103
+ // Nothing still waiting is sent once the pane stops being an agent: Herdr
104
+ // ignores the release of a pane nothing has claimed, so a report that
105
+ // landed after the release would claim the row back for a process on its
106
+ // way out. What is already on the wire is left to finish — the waiters
107
+ // hear about it when it does, not before.
108
+ closed = true;
109
+ const discarded = queued;
110
+ queued = [];
111
+ for (const entry of discarded)
112
+ entry.settle(false);
113
+ },
114
+ async settle() {
115
+ // The wait ends when the transport itself is done, not when a timer says
116
+ // so: a report whose first attempt failed still has its retries to spend,
117
+ // and a release that ran between them would be answered as a pane with
118
+ // nothing to clear, leaving the row for that report to claim back. A
119
+ // report's own budget is what bounds this.
120
+ if (!pumping)
121
+ return;
122
+ await new Promise(resolve => {
123
+ waiters.push(resolve);
124
+ });
125
+ },
126
+ };
127
+ }
128
+ /**
129
+ * The tokens Herdr will accept, with the ones it cannot hold cleared.
130
+ *
131
+ * An over-long value is not refused: Herdr cuts it at the limit, so a path that
132
+ * was too long would come back shortened and read as another directory. A null
133
+ * is the one value that tells Herdr to forget the token, which is the honest
134
+ * answer for a fact that cannot be represented.
135
+ */
136
+ export function acceptedTokens(tokens) {
137
+ const accepted = {};
138
+ for (const [key, value] of Object.entries(tokens)) {
139
+ accepted[key] = value === undefined || value.length > MAX_METADATA_VALUE_CHARS ? null : value;
140
+ }
141
+ return accepted;
142
+ }
143
+ /** Herdr's socket is a named pipe on Windows. */
144
+ export function socketEndpoint(path) {
145
+ return process.platform === 'win32' ? `\\\\.\\pipe\\${path}` : path;
146
+ }
147
+ /**
148
+ * Spend one report's budget, not one per attempt.
149
+ *
150
+ * The deadline covers the whole report: a server that accepts a connection and
151
+ * answers slowly, but always within the idle timeout, would otherwise hold the
152
+ * queue open packet by packet for as long as it liked.
153
+ */
154
+ async function sendWithRetry(path, request, attempts, timeoutMs, stopped) {
155
+ const deadline = Date.now() + timeoutMs;
156
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
157
+ // A stopped transport does not try again: the pane is no longer an agent,
158
+ // and an attempt that landed after the release would claim the row back.
159
+ if (stopped())
160
+ return false;
161
+ const remaining = deadline - Date.now();
162
+ if (remaining <= 0)
163
+ return false;
164
+ if (await sendAttempt(path, request, remaining))
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+ function sendAttempt(path, request, timeoutMs) {
170
+ return new Promise(resolve => {
171
+ const socket = createConnection(socketEndpoint(path));
172
+ const chunks = [];
173
+ let received = 0;
174
+ let settled = false;
175
+ const finish = (delivered) => {
176
+ if (settled)
177
+ return;
178
+ settled = true;
179
+ clearTimeout(expiry);
180
+ socket.destroy();
181
+ resolve(delivered);
182
+ };
183
+ // Idle time is the fast signal; the hard deadline is what a peer that keeps
184
+ // the socket busy cannot postpone.
185
+ const expiry = setTimeout(() => finish(false), timeoutMs);
186
+ socket.setTimeout(timeoutMs, () => finish(false));
187
+ socket.once('error', () => finish(false));
188
+ socket.once('end', () => finish(false));
189
+ socket.once('connect', () => socket.write(`${JSON.stringify(request)}${RESPONSE_DELIMITER}`));
190
+ socket.on('data', (chunk) => {
191
+ received += chunk.byteLength;
192
+ if (received > MAX_RESPONSE_BYTES) {
193
+ finish(false);
194
+ return;
195
+ }
196
+ chunks.push(chunk);
197
+ const response = Buffer.concat(chunks, received).toString('utf8');
198
+ const end = response.indexOf(RESPONSE_DELIMITER);
199
+ // A report is only delivered when Herdr says so: a write into a socket
200
+ // that closed on the far side would otherwise look like success.
201
+ if (end >= 0)
202
+ finish(isSuccess(response.slice(0, end), request.id));
203
+ });
204
+ });
205
+ }
206
+ function isSuccess(response, requestId) {
207
+ try {
208
+ const parsed = JSON.parse(response);
209
+ return isRecord(parsed) && parsed.id === requestId && 'result' in parsed && !('error' in parsed);
210
+ }
211
+ catch {
212
+ return false;
213
+ }
214
+ }
215
+ function isRecord(value) {
216
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
217
+ }
218
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/herdr/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EACL,gBAAgB,EA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AAE,SAAiB;IACpD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAY,CAAA;QAC9C,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,SAAS,IAAI,QAAQ,IAAI,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,CAAA;IAClG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The Herdr side of this surface.
3
+ *
4
+ * Herdr is a terminal multiplexer for coding agents: when it starts a pane it
5
+ * exports its own coordinates plus a socket, and anything running in that pane
6
+ * may claim the pane's agent row. These are the names both ends of the claim
7
+ * have to agree on, so they are fixed here rather than at the call sites.
8
+ */
9
+ /** The value `HERDR_ENV` carries inside a pane Herdr itself started. */
10
+ export declare const HERDR_ENV_FLAG = "1";
11
+ export declare const HERDR_ENV_VAR = "HERDR_ENV";
12
+ export declare const HERDR_PANE_ID_VAR = "HERDR_PANE_ID";
13
+ export declare const HERDR_SOCKET_PATH_VAR = "HERDR_SOCKET_PATH";
14
+ export declare const HERDR_BIN_PATH_VAR = "HERDR_BIN_PATH";
15
+ /** The agent label Herdr shows, and the label its pickers and waits match on. */
16
+ export declare const HERDR_AGENT = "dsh";
17
+ /**
18
+ * This reporter's identity.
19
+ *
20
+ * Herdr scopes lifecycle state, report sequencing, and releases by
21
+ * (source, agent), so a second tool reporting the same pane under its own
22
+ * source cannot be mistaken for this one — and clearing this source's
23
+ * authority leaves the other's alone.
24
+ */
25
+ export declare const HERDR_SOURCE = "custom:dsh-tui";
26
+ /** The three states a pane report may carry. */
27
+ export declare const HERDR_STATES: {
28
+ readonly idle: "idle";
29
+ readonly working: "working";
30
+ readonly blocked: "blocked";
31
+ };
32
+ export type HerdrState = (typeof HERDR_STATES)[keyof typeof HERDR_STATES];
33
+ /**
34
+ * Why a session opened, in the words Herdr accepts.
35
+ *
36
+ * A reason outside this set is dropped server-side, so the surface reports the
37
+ * nearest one it recognizes instead of inventing a label.
38
+ */
39
+ export declare const SESSION_START_REASONS: {
40
+ readonly startup: "startup";
41
+ readonly resume: "resume";
42
+ readonly fork: "fork";
43
+ readonly select: "select";
44
+ };
45
+ export type SessionStartReason = (typeof SESSION_START_REASONS)[keyof typeof SESSION_START_REASONS];
46
+ /**
47
+ * Pane metadata keys.
48
+ *
49
+ * Herdr persists a session reference only for its own built-in integrations, so
50
+ * the identity is published as tokens as well: those are readable back off the
51
+ * pane by any script or plugin, which is what makes an exact resume possible
52
+ * from outside this process.
53
+ */
54
+ export declare const METADATA_TOKENS: {
55
+ readonly session: "dsh_session";
56
+ readonly cwd: "dsh_cwd";
57
+ };
58
+ /** A report is best-effort, so its budget is short and it retries once. */
59
+ export declare const DEFAULT_ATTEMPTS = 2;
60
+ export declare const DEFAULT_TIMEOUT_MS = 500;
61
+ /** A release on the way out cannot outlive the process that owes it. */
62
+ export declare const EXIT_RELEASE_TIMEOUT_MS = 250;
63
+ /** The first wait before a report Herdr did not acknowledge is sent again. */
64
+ export declare const RETRY_BASE_MS = 250;
65
+ /** The longest that wait can grow to, so a down socket is still noticed. */
66
+ export declare const RETRY_MAX_MS = 8000;
67
+ /** Beyond this a response is a surprise, not an answer. */
68
+ export declare const MAX_RESPONSE_BYTES: number;
69
+ export declare const RESPONSE_DELIMITER = "\n";
70
+ /**
71
+ * The longest metadata value Herdr can hold whole.
72
+ *
73
+ * A longer value is shortened rather than refused, so a path past the limit
74
+ * would come back reading as a different directory: a value this long is the
75
+ * most the pane can say about itself, and anything longer has to be cleared.
76
+ */
77
+ export declare const MAX_METADATA_VALUE_CHARS = 80;
78
+ /**
79
+ * How much of a wait's title is reported.
80
+ *
81
+ * The text names a tool the model chose, so it crosses a trust boundary into
82
+ * another process's user interface: it is bounded here rather than handed over
83
+ * whole.
84
+ */
85
+ export declare const MAX_BLOCKED_MESSAGE_CHARS = 120;
86
+ /**
87
+ * Reports are sequenced in microseconds.
88
+ *
89
+ * Herdr keeps the newest sequence per source and ignores an older one, so a
90
+ * delivery that arrives late cannot undo a state the surface already left.
91
+ */
92
+ export declare const SEQ_TIME_SCALE = 1000;
93
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/herdr/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wEAAwE;AACxE,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC,eAAO,MAAM,aAAa,cAAc,CAAA;AACxC,eAAO,MAAM,iBAAiB,kBAAkB,CAAA;AAChD,eAAO,MAAM,qBAAqB,sBAAsB,CAAA;AACxD,eAAO,MAAM,kBAAkB,mBAAmB,CAAA;AAElD,iFAAiF;AACjF,eAAO,MAAM,WAAW,QAAQ,CAAA;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,mBAAmB,CAAA;AAE5C,gDAAgD;AAChD,eAAO,MAAM,YAAY;;;;CAAoE,CAAA;AAC7F,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAA;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;CAAoF,CAAA;AACtH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAA;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;CAAsD,CAAA;AAElF,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAE1C,8EAA8E;AAC9E,eAAO,MAAM,aAAa,MAAM,CAAA;AAEhC,4EAA4E;AAC5E,eAAO,MAAM,YAAY,OAAQ,CAAA;AAEjC,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,QAAY,CAAA;AAC3C,eAAO,MAAM,kBAAkB,OAAO,CAAA;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,OAAO,CAAA"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The Herdr side of this surface.
3
+ *
4
+ * Herdr is a terminal multiplexer for coding agents: when it starts a pane it
5
+ * exports its own coordinates plus a socket, and anything running in that pane
6
+ * may claim the pane's agent row. These are the names both ends of the claim
7
+ * have to agree on, so they are fixed here rather than at the call sites.
8
+ */
9
+ /** The value `HERDR_ENV` carries inside a pane Herdr itself started. */
10
+ export const HERDR_ENV_FLAG = '1';
11
+ export const HERDR_ENV_VAR = 'HERDR_ENV';
12
+ export const HERDR_PANE_ID_VAR = 'HERDR_PANE_ID';
13
+ export const HERDR_SOCKET_PATH_VAR = 'HERDR_SOCKET_PATH';
14
+ export const HERDR_BIN_PATH_VAR = 'HERDR_BIN_PATH';
15
+ /** The agent label Herdr shows, and the label its pickers and waits match on. */
16
+ export const HERDR_AGENT = 'dsh';
17
+ /**
18
+ * This reporter's identity.
19
+ *
20
+ * Herdr scopes lifecycle state, report sequencing, and releases by
21
+ * (source, agent), so a second tool reporting the same pane under its own
22
+ * source cannot be mistaken for this one — and clearing this source's
23
+ * authority leaves the other's alone.
24
+ */
25
+ export const HERDR_SOURCE = 'custom:dsh-tui';
26
+ /** The three states a pane report may carry. */
27
+ export const HERDR_STATES = { idle: 'idle', working: 'working', blocked: 'blocked' };
28
+ /**
29
+ * Why a session opened, in the words Herdr accepts.
30
+ *
31
+ * A reason outside this set is dropped server-side, so the surface reports the
32
+ * nearest one it recognizes instead of inventing a label.
33
+ */
34
+ export const SESSION_START_REASONS = { startup: 'startup', resume: 'resume', fork: 'fork', select: 'select' };
35
+ /**
36
+ * Pane metadata keys.
37
+ *
38
+ * Herdr persists a session reference only for its own built-in integrations, so
39
+ * the identity is published as tokens as well: those are readable back off the
40
+ * pane by any script or plugin, which is what makes an exact resume possible
41
+ * from outside this process.
42
+ */
43
+ export const METADATA_TOKENS = { session: 'dsh_session', cwd: 'dsh_cwd' };
44
+ /** A report is best-effort, so its budget is short and it retries once. */
45
+ export const DEFAULT_ATTEMPTS = 2;
46
+ export const DEFAULT_TIMEOUT_MS = 500;
47
+ /** A release on the way out cannot outlive the process that owes it. */
48
+ export const EXIT_RELEASE_TIMEOUT_MS = 250;
49
+ /** The first wait before a report Herdr did not acknowledge is sent again. */
50
+ export const RETRY_BASE_MS = 250;
51
+ /** The longest that wait can grow to, so a down socket is still noticed. */
52
+ export const RETRY_MAX_MS = 8_000;
53
+ /** Beyond this a response is a surprise, not an answer. */
54
+ export const MAX_RESPONSE_BYTES = 64 * 1024;
55
+ export const RESPONSE_DELIMITER = '\n';
56
+ /**
57
+ * The longest metadata value Herdr can hold whole.
58
+ *
59
+ * A longer value is shortened rather than refused, so a path past the limit
60
+ * would come back reading as a different directory: a value this long is the
61
+ * most the pane can say about itself, and anything longer has to be cleared.
62
+ */
63
+ export const MAX_METADATA_VALUE_CHARS = 80;
64
+ /**
65
+ * How much of a wait's title is reported.
66
+ *
67
+ * The text names a tool the model chose, so it crosses a trust boundary into
68
+ * another process's user interface: it is bounded here rather than handed over
69
+ * whole.
70
+ */
71
+ export const MAX_BLOCKED_MESSAGE_CHARS = 120;
72
+ /**
73
+ * Reports are sequenced in microseconds.
74
+ *
75
+ * Herdr keeps the newest sequence per source and ignores an older one, so a
76
+ * delivery that arrives late cannot undo a state the surface already left.
77
+ */
78
+ export const SEQ_TIME_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MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAA;AAEjC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAA;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAA"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Telling a containing Herdr what this pane is doing.
3
+ *
4
+ * The reporter is inert unless Herdr started this process and exported its
5
+ * socket, so the surface behaves identically in a bare terminal and never
6
+ * depends on the multiplexer being there. Nothing here may reach the reader:
7
+ * a report is best-effort, its failures are dropped, and the alternate screen
8
+ * owns stdout.
9
+ */
10
+ import { type HerdrClient, type HerdrEnvironment } from './client.ts';
11
+ import { type SessionStartReason } from './constants.ts';
12
+ export interface HerdrSessionInput {
13
+ readonly id: string;
14
+ readonly cwd: string;
15
+ readonly reason: SessionStartReason;
16
+ }
17
+ export interface HerdrReporterOptions {
18
+ readonly client?: HerdrClient;
19
+ readonly env?: HerdrEnvironment;
20
+ readonly now?: () => number;
21
+ readonly releaseSync?: () => void;
22
+ /** The first retry wait; a test cannot wait a socket out. */
23
+ readonly retryBaseMs?: number | undefined;
24
+ }
25
+ export interface HerdrReporter {
26
+ readonly enabled: boolean;
27
+ /** A turn started. */
28
+ working(): void;
29
+ /** A turn ended. */
30
+ idle(): void;
31
+ /** A decision is waiting on the reader; waits stack, so they are counted. */
32
+ block(message: string): void;
33
+ /** One waiting decision was settled, answered, or abandoned. */
34
+ unblock(): void;
35
+ /** The pane opened, resumed, forked, or switched to a session. */
36
+ session(input: HerdrSessionInput): void;
37
+ /** Send the current facts, or resend them with `force`. */
38
+ publish(force?: boolean): void;
39
+ /** Hand the pane's agent row back before the process leaves. */
40
+ releaseSync(): void;
41
+ /** Hand the row back with the reports already on the wire settled. */
42
+ release(): Promise<void>;
43
+ /** Release on process exit; returns the unregister function. */
44
+ registerExitRelease(): () => void;
45
+ }
46
+ export declare function createHerdrReporter(options?: HerdrReporterOptions): HerdrReporter;
47
+ /**
48
+ * Release the pane's agent row synchronously.
49
+ *
50
+ * The process is leaving, so an awaited report would be dropped with the event
51
+ * loop and Herdr would keep showing a state nothing owns any more — a pane that
52
+ * reads as blocked forever is worse than one that reads as ordinary. The CLI is
53
+ * the only channel that still works at this point.
54
+ *
55
+ * `seq` is what makes the release land, so it is required rather than optional:
56
+ * Herdr sequences reports per source and treats a release that cannot beat them
57
+ * as stale, which would leave the row of a process that is already gone.
58
+ */
59
+ export declare function releaseAgentSync(env: HerdrEnvironment, seq: number): void;
60
+ //# sourceMappingURL=reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/herdr/reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAYL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAA;AAGvB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACjC,6DAA6D;I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