@agent-relay/protocol 0.1.2
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/channels.d.ts +137 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +154 -0
- package/dist/channels.js.map +1 -0
- package/dist/framing.d.ts +80 -0
- package/dist/framing.d.ts.map +1 -0
- package/dist/framing.js +206 -0
- package/dist/framing.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/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/relay-pty-schemas.d.ts +258 -0
- package/dist/relay-pty-schemas.d.ts.map +1 -0
- package/dist/relay-pty-schemas.js +60 -0
- package/dist/relay-pty-schemas.js.map +1 -0
- package/dist/types.d.ts +341 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monotonic ID Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates unique, lexicographically sortable IDs that are faster than UUID v4.
|
|
5
|
+
*
|
|
6
|
+
* Format: <timestamp-base36>-<counter-base36>-<nodeId>
|
|
7
|
+
* Example: "lxyz5g8-0001-7d2a"
|
|
8
|
+
*
|
|
9
|
+
* Properties:
|
|
10
|
+
* - Lexicographically sortable by time
|
|
11
|
+
* - Unique across processes (node prefix)
|
|
12
|
+
* - ~16x faster than UUID v4
|
|
13
|
+
* - Shorter (20-24 chars vs 36 chars)
|
|
14
|
+
*/
|
|
15
|
+
export class IdGenerator {
|
|
16
|
+
counter = 0;
|
|
17
|
+
prefix;
|
|
18
|
+
lastTs = 0;
|
|
19
|
+
constructor(nodeId) {
|
|
20
|
+
// Use process ID + random suffix for uniqueness across processes
|
|
21
|
+
this.prefix = nodeId ?? `${process.pid.toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate a unique, monotonically increasing ID.
|
|
25
|
+
*/
|
|
26
|
+
next() {
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
// Reset counter if timestamp changed
|
|
29
|
+
if (now !== this.lastTs) {
|
|
30
|
+
this.lastTs = now;
|
|
31
|
+
this.counter = 0;
|
|
32
|
+
}
|
|
33
|
+
const ts = now.toString(36);
|
|
34
|
+
const seq = (this.counter++).toString(36).padStart(4, '0');
|
|
35
|
+
return `${ts}-${seq}-${this.prefix}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate a short ID (just timestamp + counter, no node prefix).
|
|
39
|
+
* Use when you don't need cross-process uniqueness.
|
|
40
|
+
*/
|
|
41
|
+
short() {
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
if (now !== this.lastTs) {
|
|
44
|
+
this.lastTs = now;
|
|
45
|
+
this.counter = 0;
|
|
46
|
+
}
|
|
47
|
+
const ts = now.toString(36);
|
|
48
|
+
const seq = (this.counter++).toString(36).padStart(4, '0');
|
|
49
|
+
return `${ts}-${seq}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Singleton instance for the process
|
|
53
|
+
export const idGen = new IdGenerator();
|
|
54
|
+
/**
|
|
55
|
+
* Generate a unique ID (drop-in replacement for uuid()).
|
|
56
|
+
*/
|
|
57
|
+
export function generateId() {
|
|
58
|
+
return idGen.next();
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=id-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../src/id-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,OAAO,WAAW;IACd,OAAO,GAAG,CAAC,CAAC;IACH,MAAM,CAAS;IACxB,MA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E,GAAG,CAAC,CAAC;QAC3D,OAAO,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC;IACxB,CAAC;CACF;AAED,qCAAqC;AACrC,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay PTY Protocol Schemas
|
|
3
|
+
*
|
|
4
|
+
* This file documents the data formats used in the relay-pty message flow:
|
|
5
|
+
*
|
|
6
|
+
* 1. Agent → File (outbox) : RelayFileFormat
|
|
7
|
+
* 2. relay-pty → Orchestrator : ParsedRelayCommand (JSON on stderr)
|
|
8
|
+
* 3. Orchestrator → Socket : InjectRequest (JSON)
|
|
9
|
+
* 4. Socket → Agent PTY : Plain text injection
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* File format that agents write to the relay outbox.
|
|
13
|
+
*
|
|
14
|
+
* Default path: /tmp/relay-outbox/$AGENT_RELAY_NAME/<filename>
|
|
15
|
+
* Workspace path: /tmp/relay/{workspaceId}/outbox/{agentName}/<filename>
|
|
16
|
+
*
|
|
17
|
+
* Note: In workspace deployments, the default path is symlinked to the
|
|
18
|
+
* workspace path, so agents can use the simple path while maintaining
|
|
19
|
+
* workspace isolation.
|
|
20
|
+
*
|
|
21
|
+
* Header-based format (preferred over JSON):
|
|
22
|
+
* - Headers are key: value pairs, one per line
|
|
23
|
+
* - Blank line separates headers from body
|
|
24
|
+
* - Body is free-form text (no escaping needed)
|
|
25
|
+
*
|
|
26
|
+
* @example Message
|
|
27
|
+
* ```
|
|
28
|
+
* TO: Bob
|
|
29
|
+
* THREAD: feature-123
|
|
30
|
+
*
|
|
31
|
+
* Hello Bob, can you review PR #42?
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Blocking Message (sync)
|
|
35
|
+
* ```
|
|
36
|
+
* TO: Bob
|
|
37
|
+
* AWAIT: 30s
|
|
38
|
+
*
|
|
39
|
+
* Your turn. Play a card.
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example Spawn
|
|
43
|
+
* ```
|
|
44
|
+
* KIND: spawn
|
|
45
|
+
* NAME: ReviewerAgent
|
|
46
|
+
* CLI: claude
|
|
47
|
+
*
|
|
48
|
+
* You are a code reviewer.
|
|
49
|
+
* Review the changes in src/auth/*.ts
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Release
|
|
53
|
+
* ```
|
|
54
|
+
* KIND: release
|
|
55
|
+
* NAME: ReviewerAgent
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export interface RelayFileFormat {
|
|
59
|
+
/** Target agent name, "*" for broadcast, or "#channel" */
|
|
60
|
+
TO?: string;
|
|
61
|
+
/** Message type: "message" (default), "spawn", or "release" */
|
|
62
|
+
KIND?: 'message' | 'spawn' | 'release';
|
|
63
|
+
/** Agent name (required for spawn/release) */
|
|
64
|
+
NAME?: string;
|
|
65
|
+
/** CLI to use for spawning (required for spawn) */
|
|
66
|
+
CLI?: string;
|
|
67
|
+
/** Thread identifier for grouping related messages */
|
|
68
|
+
THREAD?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Blocking/await timeout for sync messaging.
|
|
71
|
+
* Formats: "30s" (seconds), "1m" (minutes), "1h" (hours), "30000" (ms), "true" (default timeout)
|
|
72
|
+
* When present, the sender blocks until recipient ACKs or timeout.
|
|
73
|
+
*/
|
|
74
|
+
AWAIT?: string;
|
|
75
|
+
/** Message content or task description (for spawn) */
|
|
76
|
+
body?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* JSON format emitted by relay-pty to stderr when it detects a relay command.
|
|
80
|
+
* The orchestrator parses this to route messages.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```json
|
|
84
|
+
* {
|
|
85
|
+
* "type": "relay_command",
|
|
86
|
+
* "kind": "message",
|
|
87
|
+
* "from": "Alice",
|
|
88
|
+
* "to": "Bob",
|
|
89
|
+
* "body": "Hello!",
|
|
90
|
+
* "raw": "->relay-file:msg-001"
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export interface ParsedRelayCommand {
|
|
95
|
+
/** Always "relay_command" */
|
|
96
|
+
type: 'relay_command';
|
|
97
|
+
/** Command type */
|
|
98
|
+
kind: 'message' | 'spawn' | 'release';
|
|
99
|
+
/** Sender agent name */
|
|
100
|
+
from: string;
|
|
101
|
+
/** Target agent name (or "spawn"/"release" for those commands) */
|
|
102
|
+
to: string;
|
|
103
|
+
/** Message body or task description */
|
|
104
|
+
body: string;
|
|
105
|
+
/** Original raw text that was parsed */
|
|
106
|
+
raw: string;
|
|
107
|
+
/** Thread identifier (optional) */
|
|
108
|
+
thread?: string;
|
|
109
|
+
/** Sync metadata for blocking messages (when AWAIT header present) */
|
|
110
|
+
sync?: {
|
|
111
|
+
/** Whether this is a blocking send */
|
|
112
|
+
blocking: boolean;
|
|
113
|
+
/** Timeout in milliseconds (undefined means use default) */
|
|
114
|
+
timeout_ms?: number;
|
|
115
|
+
};
|
|
116
|
+
/** For spawn: agent name to spawn */
|
|
117
|
+
spawn_name?: string;
|
|
118
|
+
/** For spawn: CLI to use */
|
|
119
|
+
spawn_cli?: string;
|
|
120
|
+
/** For spawn: task description */
|
|
121
|
+
spawn_task?: string;
|
|
122
|
+
/** For release: agent name to release */
|
|
123
|
+
release_name?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* JSON format sent to the relay-pty Unix socket for message injection.
|
|
127
|
+
* Socket path: /tmp/relay-pty-{agentName}.sock
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```json
|
|
131
|
+
* {
|
|
132
|
+
* "type": "inject",
|
|
133
|
+
* "id": "msg-abc123",
|
|
134
|
+
* "from": "Alice",
|
|
135
|
+
* "body": "Hello Bob!",
|
|
136
|
+
* "priority": 0
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export type InjectRequest = {
|
|
141
|
+
type: 'inject';
|
|
142
|
+
/** Unique message ID for tracking */
|
|
143
|
+
id: string;
|
|
144
|
+
/** Sender name (shown as "Relay message from {from}") */
|
|
145
|
+
from: string;
|
|
146
|
+
/** Message body to inject */
|
|
147
|
+
body: string;
|
|
148
|
+
/** Priority (lower = higher priority, default 0) */
|
|
149
|
+
priority?: number;
|
|
150
|
+
} | {
|
|
151
|
+
type: 'status';
|
|
152
|
+
} | {
|
|
153
|
+
type: 'shutdown';
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Response from relay-pty socket
|
|
157
|
+
*/
|
|
158
|
+
export type InjectResponse = {
|
|
159
|
+
type: 'inject_result';
|
|
160
|
+
/** Message ID this response is for */
|
|
161
|
+
id: string;
|
|
162
|
+
/** Status of the injection */
|
|
163
|
+
status: 'queued' | 'injecting' | 'delivered' | 'failed';
|
|
164
|
+
/** Unix timestamp in milliseconds */
|
|
165
|
+
timestamp: number;
|
|
166
|
+
/** Optional error message */
|
|
167
|
+
error?: string;
|
|
168
|
+
} | {
|
|
169
|
+
type: 'status';
|
|
170
|
+
/** Whether agent appears idle (ready for injection) */
|
|
171
|
+
agent_idle: boolean;
|
|
172
|
+
/** Number of messages in queue */
|
|
173
|
+
queue_length: number;
|
|
174
|
+
/** Cursor position [x, y] */
|
|
175
|
+
cursor_position?: [number, number];
|
|
176
|
+
/** Milliseconds since last output */
|
|
177
|
+
last_output_ms: number;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'backpressure';
|
|
180
|
+
/** Current queue length */
|
|
181
|
+
queue_length: number;
|
|
182
|
+
/** Whether new messages are accepted */
|
|
183
|
+
accept: boolean;
|
|
184
|
+
} | {
|
|
185
|
+
type: 'shutdown_ack';
|
|
186
|
+
} | {
|
|
187
|
+
type: 'error';
|
|
188
|
+
/** Error message */
|
|
189
|
+
message: string;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* The final format injected into the recipient agent's PTY as plain text.
|
|
193
|
+
* NOT JSON - this is human-readable text that appears in the agent's terminal.
|
|
194
|
+
*
|
|
195
|
+
* Format: "Relay message from {sender} [{shortId}]: {body}"
|
|
196
|
+
*
|
|
197
|
+
* @example First attempt
|
|
198
|
+
* ```
|
|
199
|
+
* Relay message from Alice [abc1234]: Hello Bob, can you review PR #42?
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @example Retry (1st retry)
|
|
203
|
+
* ```
|
|
204
|
+
* [RETRY] Relay message from Alice [abc1234]: Hello Bob, can you review PR #42?
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @example Urgent (2+ retries)
|
|
208
|
+
* ```
|
|
209
|
+
* [URGENT - PLEASE ACKNOWLEDGE] Relay message from Alice [abc1234]: Hello Bob!
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export type InjectedMessageFormat = string;
|
|
213
|
+
/**
|
|
214
|
+
* ```
|
|
215
|
+
* ┌─────────────────────────────────────────────────────────────────────────────┐
|
|
216
|
+
* │ COMPLETE MESSAGE FLOW │
|
|
217
|
+
* │ │
|
|
218
|
+
* │ STEP 1: Agent writes file │
|
|
219
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
220
|
+
* │ │ cat > /tmp/relay-outbox/$AGENT_RELAY_NAME/msg-001 << 'EOF' │ │
|
|
221
|
+
* │ │ TO: Bob │ │
|
|
222
|
+
* │ │ THREAD: feature-123 │ │
|
|
223
|
+
* │ │ │ │
|
|
224
|
+
* │ │ Hello Bob, can you review PR #42? │ │
|
|
225
|
+
* │ │ EOF │ │
|
|
226
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
227
|
+
* │ │ │
|
|
228
|
+
* │ ▼ │
|
|
229
|
+
* │ STEP 2: Agent outputs trigger │
|
|
230
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
231
|
+
* │ │ ->relay-file:msg-001 │ │
|
|
232
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
233
|
+
* │ │ │
|
|
234
|
+
* │ ▼ │
|
|
235
|
+
* │ STEP 3: relay-pty reads file, emits JSON to stderr │
|
|
236
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
237
|
+
* │ │ {"type":"relay_command","kind":"message","from":"Alice", │ │
|
|
238
|
+
* │ │ "to":"Bob","body":"Hello Bob, can you review PR #42?", │ │
|
|
239
|
+
* │ │ "thread":"feature-123","raw":"->relay-file:msg-001"} │ │
|
|
240
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
241
|
+
* │ │ │
|
|
242
|
+
* │ ▼ │
|
|
243
|
+
* │ STEP 4: Orchestrator routes to Bob's relay-pty socket │
|
|
244
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
245
|
+
* │ │ {"type":"inject","id":"msg-abc123","from":"Alice", │ │
|
|
246
|
+
* │ │ "body":"Hello Bob, can you review PR #42?","priority":0} │ │
|
|
247
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
248
|
+
* │ │ │
|
|
249
|
+
* │ ▼ │
|
|
250
|
+
* │ STEP 5: Bob's relay-pty injects plain text into PTY │
|
|
251
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
252
|
+
* │ │ Relay message from Alice [abc1234]: Hello Bob, can you review PR #42?│ │
|
|
253
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
254
|
+
* │ │
|
|
255
|
+
* └─────────────────────────────────────────────────────────────────────────────┘
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
//# sourceMappingURL=relay-pty-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-pty-schemas.d.ts","sourceRoot":"","sources":["../src/relay-pty-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,WAAW,eAAe;IAG9B,0DAA0D;IAC1D,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,+DAA+D;IAC/D,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAEvC,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAMD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,EAAE,eAAe,CAAC;IAEtB,mBAAmB;IACnB,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAEtC,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IAEb,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IAEX,uCAAuC;IACvC,IAAI,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ClC,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAC;CACxB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;CACjB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;CACtB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAMN;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay PTY Protocol Schemas
|
|
3
|
+
*
|
|
4
|
+
* This file documents the data formats used in the relay-pty message flow:
|
|
5
|
+
*
|
|
6
|
+
* 1. Agent → File (outbox) : RelayFileFormat
|
|
7
|
+
* 2. relay-pty → Orchestrator : ParsedRelayCommand (JSON on stderr)
|
|
8
|
+
* 3. Orchestrator → Socket : InjectRequest (JSON)
|
|
9
|
+
* 4. Socket → Agent PTY : Plain text injection
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Complete Flow Diagram
|
|
14
|
+
// =============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* ```
|
|
17
|
+
* ┌─────────────────────────────────────────────────────────────────────────────┐
|
|
18
|
+
* │ COMPLETE MESSAGE FLOW │
|
|
19
|
+
* │ │
|
|
20
|
+
* │ STEP 1: Agent writes file │
|
|
21
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
22
|
+
* │ │ cat > /tmp/relay-outbox/$AGENT_RELAY_NAME/msg-001 << 'EOF' │ │
|
|
23
|
+
* │ │ TO: Bob │ │
|
|
24
|
+
* │ │ THREAD: feature-123 │ │
|
|
25
|
+
* │ │ │ │
|
|
26
|
+
* │ │ Hello Bob, can you review PR #42? │ │
|
|
27
|
+
* │ │ EOF │ │
|
|
28
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
29
|
+
* │ │ │
|
|
30
|
+
* │ ▼ │
|
|
31
|
+
* │ STEP 2: Agent outputs trigger │
|
|
32
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
33
|
+
* │ │ ->relay-file:msg-001 │ │
|
|
34
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
35
|
+
* │ │ │
|
|
36
|
+
* │ ▼ │
|
|
37
|
+
* │ STEP 3: relay-pty reads file, emits JSON to stderr │
|
|
38
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
39
|
+
* │ │ {"type":"relay_command","kind":"message","from":"Alice", │ │
|
|
40
|
+
* │ │ "to":"Bob","body":"Hello Bob, can you review PR #42?", │ │
|
|
41
|
+
* │ │ "thread":"feature-123","raw":"->relay-file:msg-001"} │ │
|
|
42
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
43
|
+
* │ │ │
|
|
44
|
+
* │ ▼ │
|
|
45
|
+
* │ STEP 4: Orchestrator routes to Bob's relay-pty socket │
|
|
46
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
47
|
+
* │ │ {"type":"inject","id":"msg-abc123","from":"Alice", │ │
|
|
48
|
+
* │ │ "body":"Hello Bob, can you review PR #42?","priority":0} │ │
|
|
49
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
50
|
+
* │ │ │
|
|
51
|
+
* │ ▼ │
|
|
52
|
+
* │ STEP 5: Bob's relay-pty injects plain text into PTY │
|
|
53
|
+
* │ ┌──────────────────────────────────────────────────────────────────────┐ │
|
|
54
|
+
* │ │ Relay message from Alice [abc1234]: Hello Bob, can you review PR #42?│ │
|
|
55
|
+
* │ └──────────────────────────────────────────────────────────────────────┘ │
|
|
56
|
+
* │ │
|
|
57
|
+
* └─────────────────────────────────────────────────────────────────────────────┘
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
//# sourceMappingURL=relay-pty-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-pty-schemas.js","sourceRoot":"","sources":["../src/relay-pty-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;AA8PH,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG"}
|