agent-relay 2.0.24 → 2.0.26
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/src/cli/index.js +100 -10
- package/package.json +16 -16
- package/packages/api-types/package.json +1 -1
- package/packages/bridge/package.json +8 -8
- package/packages/cli-tester/package.json +1 -1
- package/packages/config/package.json +2 -2
- package/packages/continuity/package.json +1 -1
- package/packages/daemon/dist/consensus-integration.d.ts +2 -1
- package/packages/daemon/dist/consensus.d.ts +1 -3
- package/packages/daemon/dist/enhanced-features.d.ts +2 -1
- package/packages/daemon/dist/orchestrator.js +4 -3
- package/packages/daemon/dist/server.js +48 -0
- package/packages/daemon/package.json +12 -12
- package/packages/hooks/dist/inbox-check/types.d.ts +6 -1
- package/packages/hooks/dist/inbox-check/utils.d.ts +3 -3
- package/packages/hooks/package.json +4 -4
- package/packages/mcp/dist/client.d.ts +57 -46
- package/packages/mcp/dist/client.js +107 -81
- package/packages/mcp/dist/server.js +61 -1
- package/packages/mcp/dist/tools/index.d.ts +5 -0
- package/packages/mcp/dist/tools/index.js +5 -0
- package/packages/mcp/dist/tools/relay-broadcast.d.ts +20 -0
- package/packages/mcp/dist/tools/relay-broadcast.js +25 -0
- package/packages/mcp/dist/tools/relay-channel.d.ts +49 -0
- package/packages/mcp/dist/tools/relay-channel.js +76 -0
- package/packages/mcp/dist/tools/relay-consensus.d.ts +45 -0
- package/packages/mcp/dist/tools/relay-consensus.js +80 -0
- package/packages/mcp/dist/tools/relay-inbox.d.ts +1 -1
- package/packages/mcp/dist/tools/relay-send.d.ts +2 -2
- package/packages/mcp/dist/tools/relay-shadow.d.ts +30 -0
- package/packages/mcp/dist/tools/relay-shadow.js +55 -0
- package/packages/mcp/dist/tools/relay-subscribe.d.ts +27 -0
- package/packages/mcp/dist/tools/relay-subscribe.js +49 -0
- package/packages/mcp/package.json +3 -2
- package/packages/memory/package.json +2 -2
- package/packages/policy/package.json +2 -2
- package/packages/protocol/dist/types.d.ts +130 -2
- package/packages/protocol/package.json +1 -1
- package/packages/resiliency/package.json +1 -1
- package/packages/sdk/dist/client.d.ts +21 -1
- package/packages/sdk/dist/client.js +26 -2
- package/packages/sdk/dist/index.d.ts +1 -1
- package/packages/sdk/dist/protocol/index.d.ts +4 -2
- package/packages/sdk/dist/protocol/index.js +4 -2
- package/packages/sdk/package.json +2 -2
- package/packages/spawner/package.json +1 -1
- package/packages/state/package.json +1 -1
- package/packages/storage/package.json +2 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +1 -1
- package/packages/wrapper/package.json +6 -6
- package/scripts/post-publish-verify/README.md +80 -0
- package/scripts/post-publish-verify/run-verify.sh +127 -0
- package/scripts/post-publish-verify/verify-install.sh +249 -0
- package/packages/sdk/dist/protocol/framing.d.ts +0 -80
- package/packages/sdk/dist/protocol/framing.js +0 -206
- package/packages/sdk/dist/protocol/types.d.ts +0 -560
- package/packages/sdk/dist/protocol/types.js +0 -8
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Frame encoding/decoding for the Agent Relay protocol.
|
|
3
|
-
* @agent-relay/sdk
|
|
4
|
-
*
|
|
5
|
-
* Wire format:
|
|
6
|
-
* - 1 byte: format indicator (0 = JSON, 1 = MessagePack)
|
|
7
|
-
* - 4 bytes: big-endian payload length
|
|
8
|
-
* - N bytes: payload (JSON or MessagePack encoded)
|
|
9
|
-
*
|
|
10
|
-
* Legacy format (for backwards compatibility):
|
|
11
|
-
* - 4 bytes: big-endian payload length
|
|
12
|
-
* - N bytes: JSON payload
|
|
13
|
-
*/
|
|
14
|
-
export const MAX_FRAME_BYTES = 1024 * 1024; // 1 MiB
|
|
15
|
-
export const HEADER_SIZE = 5; // 1 byte format + 4 bytes length
|
|
16
|
-
export const LEGACY_HEADER_SIZE = 4; // For backwards compatibility
|
|
17
|
-
// Format indicator bytes
|
|
18
|
-
const FORMAT_JSON = 0;
|
|
19
|
-
const FORMAT_MSGPACK = 1;
|
|
20
|
-
// Optional MessagePack - loaded dynamically if available
|
|
21
|
-
let msgpack = null;
|
|
22
|
-
/**
|
|
23
|
-
* Initialize MessagePack support.
|
|
24
|
-
* Install @msgpack/msgpack to enable: npm install @msgpack/msgpack
|
|
25
|
-
*/
|
|
26
|
-
export async function initMessagePack() {
|
|
27
|
-
if (msgpack)
|
|
28
|
-
return true;
|
|
29
|
-
try {
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
const mod = await import('@msgpack/msgpack');
|
|
32
|
-
const encode = mod.encode || mod.default?.encode;
|
|
33
|
-
const decode = mod.decode || mod.default?.decode;
|
|
34
|
-
if (encode && decode) {
|
|
35
|
-
msgpack = { encode, decode };
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Check if MessagePack is available.
|
|
46
|
-
*/
|
|
47
|
-
export function hasMessagePack() {
|
|
48
|
-
return msgpack !== null;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Encode a message envelope into a framed buffer.
|
|
52
|
-
*
|
|
53
|
-
* @param envelope - The envelope to encode
|
|
54
|
-
* @param format - Wire format to use (default: 'json')
|
|
55
|
-
* @returns Framed buffer ready for socket write
|
|
56
|
-
*/
|
|
57
|
-
export function encodeFrame(envelope, format = 'json') {
|
|
58
|
-
let data;
|
|
59
|
-
let formatByte;
|
|
60
|
-
if (format === 'msgpack' && msgpack) {
|
|
61
|
-
const encoded = msgpack.encode(envelope);
|
|
62
|
-
data = Buffer.from(encoded.buffer, encoded.byteOffset, encoded.byteLength);
|
|
63
|
-
formatByte = FORMAT_MSGPACK;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
data = Buffer.from(JSON.stringify(envelope), 'utf-8');
|
|
67
|
-
formatByte = FORMAT_JSON;
|
|
68
|
-
}
|
|
69
|
-
if (data.length > MAX_FRAME_BYTES) {
|
|
70
|
-
throw new Error(`Frame too large: ${data.length} > ${MAX_FRAME_BYTES}`);
|
|
71
|
-
}
|
|
72
|
-
const header = Buffer.alloc(HEADER_SIZE);
|
|
73
|
-
header.writeUInt8(formatByte, 0);
|
|
74
|
-
header.writeUInt32BE(data.length, 1);
|
|
75
|
-
return Buffer.concat([header, data]);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Encode a frame in legacy format (no format byte, JSON only).
|
|
79
|
-
* Used for backwards compatibility with older clients.
|
|
80
|
-
*/
|
|
81
|
-
export function encodeFrameLegacy(envelope) {
|
|
82
|
-
const json = JSON.stringify(envelope);
|
|
83
|
-
const data = Buffer.from(json, 'utf-8');
|
|
84
|
-
if (data.length > MAX_FRAME_BYTES) {
|
|
85
|
-
throw new Error(`Frame too large: ${data.length} > ${MAX_FRAME_BYTES}`);
|
|
86
|
-
}
|
|
87
|
-
const header = Buffer.alloc(LEGACY_HEADER_SIZE);
|
|
88
|
-
header.writeUInt32BE(data.length, 0);
|
|
89
|
-
return Buffer.concat([header, data]);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Ring buffer-based frame parser for streaming data.
|
|
93
|
-
*/
|
|
94
|
-
export class FrameParser {
|
|
95
|
-
ring;
|
|
96
|
-
head = 0;
|
|
97
|
-
tail = 0;
|
|
98
|
-
capacity;
|
|
99
|
-
maxFrameBytes;
|
|
100
|
-
format = 'json';
|
|
101
|
-
legacyMode = false;
|
|
102
|
-
constructor(maxFrameBytes = MAX_FRAME_BYTES) {
|
|
103
|
-
this.maxFrameBytes = maxFrameBytes;
|
|
104
|
-
this.capacity = maxFrameBytes * 2 + HEADER_SIZE;
|
|
105
|
-
this.ring = Buffer.allocUnsafe(this.capacity);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Set the expected wire format for parsing.
|
|
109
|
-
*/
|
|
110
|
-
setFormat(format) {
|
|
111
|
-
this.format = format;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Enable legacy mode (4-byte header, JSON only).
|
|
115
|
-
*/
|
|
116
|
-
setLegacyMode(legacy) {
|
|
117
|
-
this.legacyMode = legacy;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get current unread bytes in buffer.
|
|
121
|
-
*/
|
|
122
|
-
get pendingBytes() {
|
|
123
|
-
return this.tail - this.head;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Push data into the parser and extract complete frames.
|
|
127
|
-
*
|
|
128
|
-
* @param data - Incoming data buffer
|
|
129
|
-
* @returns Array of parsed envelope frames
|
|
130
|
-
*/
|
|
131
|
-
push(data) {
|
|
132
|
-
const spaceAtEnd = this.capacity - this.tail;
|
|
133
|
-
if (data.length > spaceAtEnd) {
|
|
134
|
-
this.compact();
|
|
135
|
-
if (data.length > this.capacity - this.tail) {
|
|
136
|
-
throw new Error(`Buffer overflow: data ${data.length} exceeds capacity`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
data.copy(this.ring, this.tail);
|
|
140
|
-
this.tail += data.length;
|
|
141
|
-
return this.extractFrames();
|
|
142
|
-
}
|
|
143
|
-
extractFrames() {
|
|
144
|
-
const frames = [];
|
|
145
|
-
const headerSize = this.legacyMode ? LEGACY_HEADER_SIZE : HEADER_SIZE;
|
|
146
|
-
while (this.pendingBytes >= headerSize) {
|
|
147
|
-
let formatByte = FORMAT_JSON;
|
|
148
|
-
let frameLength;
|
|
149
|
-
if (this.legacyMode) {
|
|
150
|
-
frameLength = this.ring.readUInt32BE(this.head);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
formatByte = this.ring.readUInt8(this.head);
|
|
154
|
-
frameLength = this.ring.readUInt32BE(this.head + 1);
|
|
155
|
-
}
|
|
156
|
-
if (frameLength > this.maxFrameBytes) {
|
|
157
|
-
throw new Error(`Frame too large: ${frameLength} > ${this.maxFrameBytes}`);
|
|
158
|
-
}
|
|
159
|
-
const totalLength = headerSize + frameLength;
|
|
160
|
-
if (this.pendingBytes < totalLength) {
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
const payloadStart = this.head + headerSize;
|
|
164
|
-
const payloadEnd = this.head + totalLength;
|
|
165
|
-
let envelope;
|
|
166
|
-
try {
|
|
167
|
-
envelope = this.decodePayload(formatByte, payloadStart, payloadEnd);
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
throw new Error(`Invalid frame payload: ${err}`);
|
|
171
|
-
}
|
|
172
|
-
this.head += totalLength;
|
|
173
|
-
frames.push(envelope);
|
|
174
|
-
}
|
|
175
|
-
if (this.head > this.capacity / 2 && this.pendingBytes < this.capacity / 4) {
|
|
176
|
-
this.compact();
|
|
177
|
-
}
|
|
178
|
-
return frames;
|
|
179
|
-
}
|
|
180
|
-
decodePayload(formatByte, start, end) {
|
|
181
|
-
if (formatByte === FORMAT_MSGPACK && msgpack) {
|
|
182
|
-
return msgpack.decode(this.ring.subarray(start, end));
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
return JSON.parse(this.ring.toString('utf-8', start, end));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
compact() {
|
|
189
|
-
if (this.head === 0)
|
|
190
|
-
return;
|
|
191
|
-
const unread = this.pendingBytes;
|
|
192
|
-
if (unread > 0) {
|
|
193
|
-
this.ring.copy(this.ring, 0, this.head, this.tail);
|
|
194
|
-
}
|
|
195
|
-
this.head = 0;
|
|
196
|
-
this.tail = unread;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Reset parser state.
|
|
200
|
-
*/
|
|
201
|
-
reset() {
|
|
202
|
-
this.head = 0;
|
|
203
|
-
this.tail = 0;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
//# sourceMappingURL=framing.js.map
|