@agent-relay/wrapper 0.1.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/__fixtures__/claude-outputs.d.ts +49 -0
- package/dist/__fixtures__/claude-outputs.d.ts.map +1 -0
- package/dist/__fixtures__/claude-outputs.js +443 -0
- package/dist/__fixtures__/claude-outputs.js.map +1 -0
- package/dist/__fixtures__/codex-outputs.d.ts +9 -0
- package/dist/__fixtures__/codex-outputs.d.ts.map +1 -0
- package/dist/__fixtures__/codex-outputs.js +94 -0
- package/dist/__fixtures__/codex-outputs.js.map +1 -0
- package/dist/__fixtures__/gemini-outputs.d.ts +19 -0
- package/dist/__fixtures__/gemini-outputs.d.ts.map +1 -0
- package/dist/__fixtures__/gemini-outputs.js +144 -0
- package/dist/__fixtures__/gemini-outputs.js.map +1 -0
- package/dist/__fixtures__/index.d.ts +68 -0
- package/dist/__fixtures__/index.d.ts.map +1 -0
- package/dist/__fixtures__/index.js +44 -0
- package/dist/__fixtures__/index.js.map +1 -0
- package/dist/auth-detection.d.ts +49 -0
- package/dist/auth-detection.d.ts.map +1 -0
- package/dist/auth-detection.js +199 -0
- package/dist/auth-detection.js.map +1 -0
- package/dist/base-wrapper.d.ts +225 -0
- package/dist/base-wrapper.d.ts.map +1 -0
- package/dist/base-wrapper.js +572 -0
- package/dist/base-wrapper.js.map +1 -0
- package/dist/client.d.ts +254 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +801 -0
- package/dist/client.js.map +1 -0
- package/dist/id-generator.d.ts +35 -0
- package/dist/id-generator.d.ts.map +1 -0
- package/dist/id-generator.js +60 -0
- package/dist/id-generator.js.map +1 -0
- package/dist/idle-detector.d.ts +110 -0
- package/dist/idle-detector.d.ts.map +1 -0
- package/dist/idle-detector.js +304 -0
- package/dist/idle-detector.js.map +1 -0
- package/dist/inbox.d.ts +37 -0
- package/dist/inbox.d.ts.map +1 -0
- package/dist/inbox.js +73 -0
- package/dist/inbox.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.d.ts +236 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +1238 -0
- package/dist/parser.js.map +1 -0
- package/dist/prompt-composer.d.ts +67 -0
- package/dist/prompt-composer.d.ts.map +1 -0
- package/dist/prompt-composer.js +168 -0
- package/dist/prompt-composer.js.map +1 -0
- package/dist/relay-pty-orchestrator.d.ts +407 -0
- package/dist/relay-pty-orchestrator.d.ts.map +1 -0
- package/dist/relay-pty-orchestrator.js +1885 -0
- package/dist/relay-pty-orchestrator.js.map +1 -0
- package/dist/shared.d.ts +201 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +341 -0
- package/dist/shared.js.map +1 -0
- package/dist/stuck-detector.d.ts +161 -0
- package/dist/stuck-detector.d.ts.map +1 -0
- package/dist/stuck-detector.js +402 -0
- package/dist/stuck-detector.js.map +1 -0
- package/dist/tmux-resolver.d.ts +55 -0
- package/dist/tmux-resolver.d.ts.map +1 -0
- package/dist/tmux-resolver.js +175 -0
- package/dist/tmux-resolver.js.map +1 -0
- package/dist/tmux-wrapper.d.ts +345 -0
- package/dist/tmux-wrapper.d.ts.map +1 -0
- package/dist/tmux-wrapper.js +1747 -0
- package/dist/tmux-wrapper.js.map +1 -0
- package/dist/trajectory-integration.d.ts +292 -0
- package/dist/trajectory-integration.d.ts.map +1 -0
- package/dist/trajectory-integration.js +979 -0
- package/dist/trajectory-integration.js.map +1 -0
- package/dist/wrapper-types.d.ts +41 -0
- package/dist/wrapper-types.d.ts.map +1 -0
- package/dist/wrapper-types.js +7 -0
- package/dist/wrapper-types.js.map +1 -0
- package/package.json +63 -0
- package/src/__fixtures__/claude-outputs.ts +471 -0
- package/src/__fixtures__/codex-outputs.ts +99 -0
- package/src/__fixtures__/gemini-outputs.ts +151 -0
- package/src/__fixtures__/index.ts +47 -0
- package/src/auth-detection.ts +244 -0
- package/src/base-wrapper.test.ts +540 -0
- package/src/base-wrapper.ts +741 -0
- package/src/client.test.ts +262 -0
- package/src/client.ts +984 -0
- package/src/id-generator.test.ts +71 -0
- package/src/id-generator.ts +69 -0
- package/src/idle-detector.test.ts +390 -0
- package/src/idle-detector.ts +370 -0
- package/src/inbox.test.ts +233 -0
- package/src/inbox.ts +89 -0
- package/src/index.ts +170 -0
- package/src/parser.regression.test.ts +251 -0
- package/src/parser.test.ts +1359 -0
- package/src/parser.ts +1477 -0
- package/src/prompt-composer.test.ts +219 -0
- package/src/prompt-composer.ts +231 -0
- package/src/relay-pty-orchestrator.test.ts +1027 -0
- package/src/relay-pty-orchestrator.ts +2270 -0
- package/src/shared.test.ts +221 -0
- package/src/shared.ts +454 -0
- package/src/stuck-detector.test.ts +303 -0
- package/src/stuck-detector.ts +511 -0
- package/src/tmux-resolver.test.ts +104 -0
- package/src/tmux-resolver.ts +207 -0
- package/src/tmux-wrapper.test.ts +316 -0
- package/src/tmux-wrapper.ts +2010 -0
- package/src/trajectory-detection.test.ts +151 -0
- package/src/trajectory-integration.ts +1261 -0
- package/src/wrapper-types.ts +45 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RelayPtyOrchestrator - Orchestrates the relay-pty Rust binary
|
|
3
|
+
*
|
|
4
|
+
* This wrapper spawns the relay-pty binary and communicates via Unix socket.
|
|
5
|
+
* It provides the same interface as PtyWrapper but with improved latency
|
|
6
|
+
* (~550ms vs ~1700ms) by using direct PTY writes instead of tmux send-keys.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* 1. Spawn relay-pty --name {agentName} -- {command} as child process
|
|
10
|
+
* 2. Connect to socket for injection:
|
|
11
|
+
* - With WORKSPACE_ID: /tmp/relay/{workspaceId}/sockets/{agentName}.sock
|
|
12
|
+
* - Without: /tmp/relay-pty-{agentName}.sock (legacy)
|
|
13
|
+
* 3. Parse stdout for relay commands (relay-pty echoes all output)
|
|
14
|
+
* 4. Translate SEND envelopes → inject messages via socket
|
|
15
|
+
*
|
|
16
|
+
* @see docs/RUST_WRAPPER_DESIGN.md for protocol details
|
|
17
|
+
*/
|
|
18
|
+
import { BaseWrapper, type BaseWrapperConfig } from './base-wrapper.js';
|
|
19
|
+
import type { SendPayload, SendMeta } from '@agent-relay/protocol/types';
|
|
20
|
+
interface StatusResponse {
|
|
21
|
+
type: 'status';
|
|
22
|
+
agent_idle: boolean;
|
|
23
|
+
queue_length: number;
|
|
24
|
+
cursor_position?: [number, number];
|
|
25
|
+
last_output_ms: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for RelayPtyOrchestrator
|
|
29
|
+
*/
|
|
30
|
+
export interface RelayPtyOrchestratorConfig extends BaseWrapperConfig {
|
|
31
|
+
/** Path to relay-pty binary (default: searches PATH and ./relay-pty/target/release) */
|
|
32
|
+
relayPtyPath?: string;
|
|
33
|
+
/** Socket connect timeout in ms (default: 5000) */
|
|
34
|
+
socketConnectTimeoutMs?: number;
|
|
35
|
+
/** Socket reconnect attempts (default: 3) */
|
|
36
|
+
socketReconnectAttempts?: number;
|
|
37
|
+
/** Callback when agent exits */
|
|
38
|
+
onExit?: (code: number) => void;
|
|
39
|
+
/** Callback when injection fails after retries */
|
|
40
|
+
onInjectionFailed?: (messageId: string, error: string) => void;
|
|
41
|
+
/** Enable debug logging (default: false) */
|
|
42
|
+
debug?: boolean;
|
|
43
|
+
/** Force headless mode (use pipes instead of inheriting TTY) */
|
|
44
|
+
headless?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Events emitted by RelayPtyOrchestrator
|
|
48
|
+
*/
|
|
49
|
+
export interface RelayPtyOrchestratorEvents {
|
|
50
|
+
output: (data: string) => void;
|
|
51
|
+
exit: (code: number) => void;
|
|
52
|
+
error: (error: Error) => void;
|
|
53
|
+
'injection-failed': (event: {
|
|
54
|
+
messageId: string;
|
|
55
|
+
from: string;
|
|
56
|
+
error: string;
|
|
57
|
+
}) => void;
|
|
58
|
+
'backpressure': (event: {
|
|
59
|
+
queueLength: number;
|
|
60
|
+
accept: boolean;
|
|
61
|
+
}) => void;
|
|
62
|
+
'summary': (event: {
|
|
63
|
+
agentName: string;
|
|
64
|
+
summary: unknown;
|
|
65
|
+
}) => void;
|
|
66
|
+
'session-end': (event: {
|
|
67
|
+
agentName: string;
|
|
68
|
+
marker: unknown;
|
|
69
|
+
}) => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Orchestrator for relay-pty Rust binary
|
|
73
|
+
*
|
|
74
|
+
* Extends BaseWrapper to provide the same interface as PtyWrapper
|
|
75
|
+
* but uses the relay-pty binary for improved injection reliability.
|
|
76
|
+
*/
|
|
77
|
+
export declare class RelayPtyOrchestrator extends BaseWrapper {
|
|
78
|
+
protected config: RelayPtyOrchestratorConfig;
|
|
79
|
+
private relayPtyProcess?;
|
|
80
|
+
private socketPath;
|
|
81
|
+
private _logPath;
|
|
82
|
+
private _outboxPath;
|
|
83
|
+
private _legacyOutboxPath;
|
|
84
|
+
private _canonicalOutboxPath;
|
|
85
|
+
private _workspaceId?;
|
|
86
|
+
private socket?;
|
|
87
|
+
private socketConnected;
|
|
88
|
+
private outputBuffer;
|
|
89
|
+
private rawBuffer;
|
|
90
|
+
private lastParsedLength;
|
|
91
|
+
private isInteractive;
|
|
92
|
+
private pendingInjections;
|
|
93
|
+
private backpressureActive;
|
|
94
|
+
private readyForMessages;
|
|
95
|
+
private throttle;
|
|
96
|
+
private lastUnreadIndicatorTime;
|
|
97
|
+
private readonly UNREAD_INDICATOR_COOLDOWN_MS;
|
|
98
|
+
private hasReceivedOutput;
|
|
99
|
+
private queueMonitorTimer?;
|
|
100
|
+
private readonly QUEUE_MONITOR_INTERVAL_MS;
|
|
101
|
+
private protocolWatcher?;
|
|
102
|
+
private protocolReminderCooldown;
|
|
103
|
+
private readonly PROTOCOL_REMINDER_COOLDOWN_MS;
|
|
104
|
+
private periodicReminderTimer?;
|
|
105
|
+
private readonly PERIODIC_REMINDER_INTERVAL_MS;
|
|
106
|
+
private sessionStartTime;
|
|
107
|
+
private isGracefulStop;
|
|
108
|
+
private memoryMonitor;
|
|
109
|
+
private memoryAlertHandler;
|
|
110
|
+
constructor(config: RelayPtyOrchestratorConfig);
|
|
111
|
+
/**
|
|
112
|
+
* Debug log - only outputs when debug is enabled
|
|
113
|
+
*/
|
|
114
|
+
private log;
|
|
115
|
+
/**
|
|
116
|
+
* Error log - always outputs (errors are important)
|
|
117
|
+
*/
|
|
118
|
+
private logError;
|
|
119
|
+
/**
|
|
120
|
+
* Get the outbox path for this agent (for documentation purposes)
|
|
121
|
+
*/
|
|
122
|
+
get outboxPath(): string;
|
|
123
|
+
/**
|
|
124
|
+
* Start the relay-pty process and connect to socket
|
|
125
|
+
*/
|
|
126
|
+
start(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Stop the relay-pty process gracefully
|
|
129
|
+
*/
|
|
130
|
+
stop(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Inject content into the agent via socket
|
|
133
|
+
*/
|
|
134
|
+
protected performInjection(_content: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Get cleaned output for parsing
|
|
137
|
+
*/
|
|
138
|
+
protected getCleanOutput(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Find the relay-pty binary
|
|
141
|
+
*/
|
|
142
|
+
private findRelayPtyBinary;
|
|
143
|
+
/**
|
|
144
|
+
* Spawn the relay-pty process
|
|
145
|
+
*/
|
|
146
|
+
private spawnRelayPty;
|
|
147
|
+
/**
|
|
148
|
+
* Handle output from relay-pty stdout (headless mode only)
|
|
149
|
+
* In interactive mode, stdout goes directly to terminal via inherited stdio
|
|
150
|
+
*/
|
|
151
|
+
private handleOutput;
|
|
152
|
+
/**
|
|
153
|
+
* Format an unread message indicator if there are pending messages.
|
|
154
|
+
* Returns empty string if no pending messages or within cooldown period.
|
|
155
|
+
*
|
|
156
|
+
* Example output:
|
|
157
|
+
* ───────────────────────────
|
|
158
|
+
* 📬 2 unread messages (from: Alice, Bob)
|
|
159
|
+
*/
|
|
160
|
+
private formatUnreadIndicator;
|
|
161
|
+
/**
|
|
162
|
+
* Handle stderr from relay-pty (logs and JSON parsed commands)
|
|
163
|
+
*/
|
|
164
|
+
private handleStderr;
|
|
165
|
+
/**
|
|
166
|
+
* Handle a parsed command from Rust relay-pty
|
|
167
|
+
* Rust outputs structured JSON with 'kind' field: "message", "spawn", "release"
|
|
168
|
+
*/
|
|
169
|
+
private handleRustParsedCommand;
|
|
170
|
+
/**
|
|
171
|
+
* Handle spawn command (from Rust stderr JSON parsing)
|
|
172
|
+
*
|
|
173
|
+
* Note: We do NOT send the initial task message here because the spawner
|
|
174
|
+
* now handles it after waitUntilCliReady(). Sending it here would cause
|
|
175
|
+
* duplicate task delivery.
|
|
176
|
+
*/
|
|
177
|
+
private handleSpawnCommand;
|
|
178
|
+
/**
|
|
179
|
+
* Handle release command
|
|
180
|
+
*/
|
|
181
|
+
private handleReleaseCommand;
|
|
182
|
+
/**
|
|
183
|
+
* Spawn agent via dashboard API
|
|
184
|
+
*/
|
|
185
|
+
private spawnViaDashboardApi;
|
|
186
|
+
/**
|
|
187
|
+
* Release agent via dashboard API
|
|
188
|
+
*/
|
|
189
|
+
private releaseViaDashboardApi;
|
|
190
|
+
/**
|
|
191
|
+
* Connect to the relay-pty socket
|
|
192
|
+
*/
|
|
193
|
+
private connectToSocket;
|
|
194
|
+
/**
|
|
195
|
+
* Attempt a single socket connection
|
|
196
|
+
*/
|
|
197
|
+
private attemptSocketConnection;
|
|
198
|
+
/**
|
|
199
|
+
* Disconnect from socket
|
|
200
|
+
*/
|
|
201
|
+
private disconnectSocket;
|
|
202
|
+
/**
|
|
203
|
+
* Send a request to the socket and optionally wait for response
|
|
204
|
+
*/
|
|
205
|
+
private sendSocketRequest;
|
|
206
|
+
/**
|
|
207
|
+
* Handle a response from the socket
|
|
208
|
+
*/
|
|
209
|
+
private handleSocketResponse;
|
|
210
|
+
/**
|
|
211
|
+
* Handle injection result response
|
|
212
|
+
* After Rust reports 'delivered', verifies the message appeared in output.
|
|
213
|
+
* If verification fails, retries up to MAX_RETRIES times.
|
|
214
|
+
*/
|
|
215
|
+
private handleInjectResult;
|
|
216
|
+
/**
|
|
217
|
+
* Handle backpressure notification
|
|
218
|
+
*/
|
|
219
|
+
private handleBackpressure;
|
|
220
|
+
/**
|
|
221
|
+
* Inject a message into the agent via socket
|
|
222
|
+
*/
|
|
223
|
+
private injectMessage;
|
|
224
|
+
/** Maximum retries for failed injections before giving up */
|
|
225
|
+
private static readonly MAX_INJECTION_RETRIES;
|
|
226
|
+
/** Backoff delay multiplier (ms) for retries: delay = BASE * 2^retryCount */
|
|
227
|
+
private static readonly INJECTION_RETRY_BASE_MS;
|
|
228
|
+
/**
|
|
229
|
+
* Process queued messages
|
|
230
|
+
*/
|
|
231
|
+
private processMessageQueue;
|
|
232
|
+
/**
|
|
233
|
+
* Override handleIncomingMessage to trigger queue processing
|
|
234
|
+
*/
|
|
235
|
+
protected handleIncomingMessage(from: string, payload: SendPayload, messageId: string, meta?: SendMeta, originalTo?: string): void;
|
|
236
|
+
/**
|
|
237
|
+
* Start the queue monitor to periodically check for stuck messages.
|
|
238
|
+
* This ensures messages don't get orphaned in the queue when the agent is idle.
|
|
239
|
+
*/
|
|
240
|
+
private startQueueMonitor;
|
|
241
|
+
/**
|
|
242
|
+
* Stop the queue monitor.
|
|
243
|
+
*/
|
|
244
|
+
private stopQueueMonitor;
|
|
245
|
+
/**
|
|
246
|
+
* Start watching for protocol issues in the outbox directory.
|
|
247
|
+
* Detects common mistakes like:
|
|
248
|
+
* - Empty AGENT_RELAY_NAME causing files at outbox//
|
|
249
|
+
* - Files created directly in outbox/ instead of agent subdirectory
|
|
250
|
+
*/
|
|
251
|
+
private startProtocolMonitor;
|
|
252
|
+
/**
|
|
253
|
+
* Stop the protocol monitor.
|
|
254
|
+
*/
|
|
255
|
+
private stopProtocolMonitor;
|
|
256
|
+
/**
|
|
257
|
+
* Scan for existing protocol issues (called once at startup).
|
|
258
|
+
*/
|
|
259
|
+
private scanForProtocolIssues;
|
|
260
|
+
/**
|
|
261
|
+
* Handle a detected protocol issue by injecting a helpful reminder.
|
|
262
|
+
*/
|
|
263
|
+
private handleProtocolIssue;
|
|
264
|
+
/**
|
|
265
|
+
* Inject a protocol reminder message to the agent.
|
|
266
|
+
*/
|
|
267
|
+
private injectProtocolReminder;
|
|
268
|
+
/**
|
|
269
|
+
* Start sending periodic protocol reminders.
|
|
270
|
+
* Agents in long sessions sometimes forget the relay protocol - these
|
|
271
|
+
* reminders help them stay on track without user intervention.
|
|
272
|
+
*/
|
|
273
|
+
private startPeriodicReminder;
|
|
274
|
+
/**
|
|
275
|
+
* Stop periodic protocol reminders.
|
|
276
|
+
*/
|
|
277
|
+
private stopPeriodicReminder;
|
|
278
|
+
/**
|
|
279
|
+
* Send a periodic protocol reminder to the agent.
|
|
280
|
+
* This reminds agents about proper relay communication format after long sessions.
|
|
281
|
+
*/
|
|
282
|
+
private sendPeriodicProtocolReminder;
|
|
283
|
+
/**
|
|
284
|
+
* Check for messages stuck in the queue and process them if the agent is idle.
|
|
285
|
+
*
|
|
286
|
+
* This handles cases where:
|
|
287
|
+
* 1. Messages arrived while the agent was busy and the retry mechanism failed
|
|
288
|
+
* 2. Socket disconnection/reconnection left messages orphaned
|
|
289
|
+
* 3. Injection timeouts occurred without proper queue resumption
|
|
290
|
+
*/
|
|
291
|
+
private checkForStuckQueue;
|
|
292
|
+
/**
|
|
293
|
+
* Parse relay commands from output
|
|
294
|
+
*/
|
|
295
|
+
private parseRelayCommands;
|
|
296
|
+
/**
|
|
297
|
+
* Parse fenced multi-line messages
|
|
298
|
+
*/
|
|
299
|
+
private parseFencedMessages;
|
|
300
|
+
/**
|
|
301
|
+
* Parse single-line messages
|
|
302
|
+
*/
|
|
303
|
+
private parseSingleLineMessages;
|
|
304
|
+
/**
|
|
305
|
+
* Check for [[SUMMARY]] blocks
|
|
306
|
+
*/
|
|
307
|
+
private checkForSummary;
|
|
308
|
+
/**
|
|
309
|
+
* Check for [[SESSION_END]] blocks
|
|
310
|
+
*/
|
|
311
|
+
private checkForSessionEnd;
|
|
312
|
+
/**
|
|
313
|
+
* Query status from relay-pty
|
|
314
|
+
*/
|
|
315
|
+
queryStatus(): Promise<StatusResponse | null>;
|
|
316
|
+
/**
|
|
317
|
+
* Wait for the CLI to be ready to receive messages.
|
|
318
|
+
* This waits for:
|
|
319
|
+
* 1. The CLI to produce at least one output (it has started)
|
|
320
|
+
* 2. The CLI to become idle (it's ready for input)
|
|
321
|
+
*
|
|
322
|
+
* This is more reliable than a random sleep because it waits for
|
|
323
|
+
* actual signals from the CLI rather than guessing how long it takes to start.
|
|
324
|
+
*
|
|
325
|
+
* @param timeoutMs Maximum time to wait (default: 30s)
|
|
326
|
+
* @param pollMs Polling interval (default: 100ms)
|
|
327
|
+
* @returns true if CLI is ready, false if timeout
|
|
328
|
+
*/
|
|
329
|
+
waitUntilCliReady(timeoutMs?: number, pollMs?: number): Promise<boolean>;
|
|
330
|
+
/**
|
|
331
|
+
* Check if the CLI has produced any output yet.
|
|
332
|
+
* Useful for checking if the CLI has started without blocking.
|
|
333
|
+
* In interactive mode, returns true if process is running (output isn't captured).
|
|
334
|
+
*/
|
|
335
|
+
hasCliStarted(): boolean;
|
|
336
|
+
/**
|
|
337
|
+
* Check if the orchestrator is ready to receive and inject messages.
|
|
338
|
+
* This requires:
|
|
339
|
+
* 1. relay-pty process spawned
|
|
340
|
+
* 2. Socket connected to relay-pty
|
|
341
|
+
* 3. running flag set
|
|
342
|
+
*
|
|
343
|
+
* Use this to verify the agent can actually receive injected messages,
|
|
344
|
+
* not just that the CLI is running.
|
|
345
|
+
*/
|
|
346
|
+
isReadyForMessages(): boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Wait until the orchestrator is ready to receive and inject messages.
|
|
349
|
+
* This is more comprehensive than waitUntilCliReady because it ensures:
|
|
350
|
+
* 1. CLI is ready (has output and is idle)
|
|
351
|
+
* 2. Orchestrator is ready (socket connected, can inject)
|
|
352
|
+
*
|
|
353
|
+
* @param timeoutMs Maximum time to wait (default: 30s)
|
|
354
|
+
* @param pollMs Polling interval (default: 100ms)
|
|
355
|
+
* @returns true if ready, false if timeout
|
|
356
|
+
*/
|
|
357
|
+
waitUntilReadyForMessages(timeoutMs?: number, pollMs?: number): Promise<boolean>;
|
|
358
|
+
/**
|
|
359
|
+
* Get raw output buffer
|
|
360
|
+
*/
|
|
361
|
+
getRawOutput(): string;
|
|
362
|
+
/**
|
|
363
|
+
* Check if backpressure is active
|
|
364
|
+
*/
|
|
365
|
+
isBackpressureActive(): boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Get the socket path
|
|
368
|
+
*/
|
|
369
|
+
getSocketPath(): string;
|
|
370
|
+
/**
|
|
371
|
+
* Get the relay-pty process PID
|
|
372
|
+
*/
|
|
373
|
+
get pid(): number | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* Get the log file path (not used by relay-pty, returns undefined)
|
|
376
|
+
*/
|
|
377
|
+
get logPath(): string | undefined;
|
|
378
|
+
/**
|
|
379
|
+
* Kill the process forcefully
|
|
380
|
+
*/
|
|
381
|
+
kill(): Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Get output lines (for compatibility with PtyWrapper)
|
|
384
|
+
* @param limit Maximum number of lines to return
|
|
385
|
+
*/
|
|
386
|
+
getOutput(limit?: number): string[];
|
|
387
|
+
/**
|
|
388
|
+
* Write data directly to the process stdin
|
|
389
|
+
* @param data Data to write
|
|
390
|
+
*/
|
|
391
|
+
write(data: string | Buffer): Promise<void>;
|
|
392
|
+
/**
|
|
393
|
+
* Inject a task using the socket-based injection system with verification.
|
|
394
|
+
* This is the preferred method for spawned agent task delivery.
|
|
395
|
+
*
|
|
396
|
+
* @param task The task text to inject
|
|
397
|
+
* @param from The sender name (default: "spawner")
|
|
398
|
+
* @returns Promise resolving to true if injection succeeded, false otherwise
|
|
399
|
+
*/
|
|
400
|
+
injectTask(task: string, from?: string): Promise<boolean>;
|
|
401
|
+
/**
|
|
402
|
+
* Get the agent ID (from continuity if available)
|
|
403
|
+
*/
|
|
404
|
+
getAgentId(): string | undefined;
|
|
405
|
+
}
|
|
406
|
+
export {};
|
|
407
|
+
//# sourceMappingURL=relay-pty-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-pty-orchestrator.d.ts","sourceRoot":"","sources":["../src/relay-pty-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAeH,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA2DzE,UAAU,cAAc;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;CACxB;AAwBD;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,6CAA6C;IAC7C,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,gCAAgC;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/D,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC,E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