borgmcp 5.4.1 → 5.6.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/README.md +15 -0
- package/dist/assimilate-cmd.d.ts +8 -1
- package/dist/assimilate-cmd.d.ts.map +1 -1
- package/dist/assimilate-cmd.js +54 -21
- package/dist/assimilate-cmd.js.map +1 -1
- package/dist/claude.d.ts.map +1 -1
- package/dist/claude.js +30 -0
- package/dist/claude.js.map +1 -1
- package/dist/cli-help.d.ts +1 -0
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +45 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/docs-sections.d.ts.map +1 -1
- package/dist/docs-sections.js +8 -0
- package/dist/docs-sections.js.map +1 -1
- package/dist/local-server-cursor.d.ts +10 -1
- package/dist/local-server-cursor.d.ts.map +1 -1
- package/dist/local-server-cursor.js +64 -5
- package/dist/local-server-cursor.js.map +1 -1
- package/dist/log-stream.d.ts +13 -0
- package/dist/log-stream.d.ts.map +1 -1
- package/dist/log-stream.js +45 -13
- package/dist/log-stream.js.map +1 -1
- package/dist/remote-client.d.ts +17 -0
- package/dist/remote-client.d.ts.map +1 -1
- package/dist/remote-client.js +37 -15
- package/dist/remote-client.js.map +1 -1
- package/dist/representative-cmd.d.ts +94 -0
- package/dist/representative-cmd.d.ts.map +1 -0
- package/dist/representative-cmd.js +290 -0
- package/dist/representative-cmd.js.map +1 -0
- package/dist/representative-core.d.ts +243 -0
- package/dist/representative-core.d.ts.map +1 -0
- package/dist/representative-core.js +679 -0
- package/dist/representative-core.js.map +1 -0
- package/dist/representative-delivery-store.d.ts +79 -0
- package/dist/representative-delivery-store.d.ts.map +1 -0
- package/dist/representative-delivery-store.js +233 -0
- package/dist/representative-delivery-store.js.map +1 -0
- package/dist/representative-listener-store.d.ts +46 -0
- package/dist/representative-listener-store.d.ts.map +1 -0
- package/dist/representative-listener-store.js +119 -0
- package/dist/representative-listener-store.js.map +1 -0
- package/dist/representative-listener.d.ts +32 -0
- package/dist/representative-listener.d.ts.map +1 -0
- package/dist/representative-listener.js +293 -0
- package/dist/representative-listener.js.map +1 -0
- package/dist/representative-mcp.d.ts +37 -0
- package/dist/representative-mcp.d.ts.map +1 -0
- package/dist/representative-mcp.js +211 -0
- package/dist/representative-mcp.js.map +1 -0
- package/dist/representative-owner.d.ts +10 -0
- package/dist/representative-owner.d.ts.map +1 -0
- package/dist/representative-owner.js +107 -0
- package/dist/representative-owner.js.map +1 -0
- package/dist/representative-store.d.ts +68 -0
- package/dist/representative-store.d.ts.map +1 -0
- package/dist/representative-store.js +173 -0
- package/dist/representative-store.js.map +1 -0
- package/dist/seat-probe.d.ts +1 -0
- package/dist/seat-probe.d.ts.map +1 -1
- package/dist/seat-probe.js +1 -1
- package/dist/seat-probe.js.map +1 -1
- package/dist/seat-store.d.ts +13 -0
- package/dist/seat-store.d.ts.map +1 -1
- package/dist/seat-store.js +55 -10
- package/dist/seat-store.js.map +1 -1
- package/dist/server-trust.d.ts +10 -0
- package/dist/server-trust.d.ts.map +1 -1
- package/dist/server-trust.js +23 -6
- package/dist/server-trust.js.map +1 -1
- package/dist/stream-owner.d.ts +10 -0
- package/dist/stream-owner.d.ts.map +1 -1
- package/dist/stream-owner.js +129 -21
- package/dist/stream-owner.js.map +1 -1
- package/dist/unknown-subcommand.d.ts +1 -1
- package/dist/unknown-subcommand.d.ts.map +1 -1
- package/dist/unknown-subcommand.js +1 -0
- package/dist/unknown-subcommand.js.map +1 -1
- package/docs/HUMAN_REPRESENTATIVE.md +434 -0
- package/package.json +1 -1
- package/src/assimilate-cmd.ts +73 -22
- package/src/claude.ts +30 -0
- package/src/cli-help.ts +48 -0
- package/src/docs-sections.ts +8 -0
- package/src/local-server-cursor.ts +56 -4
- package/src/log-stream.ts +47 -14
- package/src/remote-client.ts +54 -13
- package/src/representative-cmd.ts +369 -0
- package/src/representative-core.ts +908 -0
- package/src/representative-delivery-store.ts +235 -0
- package/src/representative-listener-store.ts +115 -0
- package/src/representative-listener.ts +215 -0
- package/src/representative-mcp.ts +250 -0
- package/src/representative-owner.ts +105 -0
- package/src/representative-store.ts +224 -0
- package/src/seat-probe.ts +1 -1
- package/src/seat-store.ts +61 -10
- package/src/server-trust.ts +25 -6
- package/src/stream-owner.ts +129 -20
- package/src/unknown-subcommand.ts +1 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/** Supervised body-free wake channel; independent of the lazy MCP tools lease. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { realpathSync } from 'node:fs';
|
|
5
|
+
import { borgConfigRoot } from './private-root.js';
|
|
6
|
+
import { acquireStreamLease, readOwnershipSnapshot, STREAM_OWNER_STALE_MS } from './stream-owner.js';
|
|
7
|
+
import { representativeOwnerDeps } from './representative-owner.js';
|
|
8
|
+
import { createListenerInbox } from './representative-listener-store.js';
|
|
9
|
+
import { streamOnce, streamReconnectDelay } from './log-stream.js';
|
|
10
|
+
import { resolveRepresentativeContext } from './representative-cmd.js';
|
|
11
|
+
import { DroneEvictedError, CubeDeletedError } from './drone-lifecycle.js';
|
|
12
|
+
import { BorgServerTrustError, BorgServerUnreachableError } from './server-errors.js';
|
|
13
|
+
import { isTransportFailure } from './seat-probe.js';
|
|
14
|
+
import { readBorgServerTrustIdentity } from './server-trust.js';
|
|
15
|
+
import { RepresentativeError, verifyLiveBinding } from './representative-core.js';
|
|
16
|
+
import { bindingFingerprint } from './representative-store.js';
|
|
17
|
+
function listenerOwnerDeps(binding) {
|
|
18
|
+
const authority = createHash('sha256').update(JSON.stringify([binding.origin, binding.trustIdentity])).digest('hex');
|
|
19
|
+
return { ...representativeOwnerDeps(binding), locksDir: join(borgConfigRoot(), 'representative-listener-locks', authority) };
|
|
20
|
+
}
|
|
21
|
+
export async function representativeListenerStatus(binding) {
|
|
22
|
+
const ownership = await readOwnershipSnapshot(binding.cubeId, binding.representativeDroneId, listenerOwnerDeps(binding));
|
|
23
|
+
let alive = false;
|
|
24
|
+
if (ownership.pid) {
|
|
25
|
+
try {
|
|
26
|
+
process.kill(ownership.pid, 0);
|
|
27
|
+
alive = true;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
alive = error.code === 'EPERM';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { ...ownership, running: alive && (ownership.ageMs ?? Infinity) <= STREAM_OWNER_STALE_MS,
|
|
34
|
+
...await createListenerInbox(binding).snapshot() };
|
|
35
|
+
}
|
|
36
|
+
function codeOf(error) {
|
|
37
|
+
if (error instanceof DroneEvictedError)
|
|
38
|
+
return 'DRONE_EVICTED';
|
|
39
|
+
if (error instanceof CubeDeletedError)
|
|
40
|
+
return 'CUBE_DELETED';
|
|
41
|
+
if (error instanceof BorgServerTrustError)
|
|
42
|
+
return 'TRUST_CHANGED';
|
|
43
|
+
return typeof error?.code === 'string' ? error.code : 'LISTENER_ERROR';
|
|
44
|
+
}
|
|
45
|
+
function terminalReason(error) {
|
|
46
|
+
const code = codeOf(error);
|
|
47
|
+
if (code === 'DRONE_EVICTED' || code === 'CUBE_DELETED' || code === 'SEAT_UNAVAILABLE')
|
|
48
|
+
return 'evicted';
|
|
49
|
+
if (code === 'BINDING_MISMATCH' || code === 'COORDINATOR_UNAVAILABLE')
|
|
50
|
+
return 'rebound';
|
|
51
|
+
if (code.includes('TRUST'))
|
|
52
|
+
return 'trust-changed';
|
|
53
|
+
if (['SESSION_REVOKED', 'SESSION_REJECTED', 'CREDENTIAL_REJECTED'].includes(code))
|
|
54
|
+
return 'revoked';
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
export async function runListener(command, deps, options = {}) {
|
|
58
|
+
const emit = async (event) => {
|
|
59
|
+
deps.stdout(JSON.stringify(event) + '\n');
|
|
60
|
+
// The command exits after its final event; wait for the pipe to flush.
|
|
61
|
+
await new Promise((resolve, reject) => process.stdout.write('', error => error ? reject(error) : resolve()));
|
|
62
|
+
};
|
|
63
|
+
let lease = null;
|
|
64
|
+
let timer;
|
|
65
|
+
let started = false, reason, active;
|
|
66
|
+
const abort = new AbortController();
|
|
67
|
+
let pending = Promise.resolve();
|
|
68
|
+
const serial = (fn) => {
|
|
69
|
+
const result = pending.then(fn);
|
|
70
|
+
pending = result.catch(() => { });
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
73
|
+
const stop = (why) => { reason ??= why; abort.abort(); };
|
|
74
|
+
const signal = () => stop('signal');
|
|
75
|
+
let outputBroken = false;
|
|
76
|
+
const outputError = () => { outputBroken = true; reason = 'fatal'; abort.abort(); };
|
|
77
|
+
process.stdout.on('error', outputError);
|
|
78
|
+
const exitCode = () => reason === 'signal' ? 0 : reason === 'fatal' ? 1 : 4;
|
|
79
|
+
try {
|
|
80
|
+
let worktree = command.worktree ?? deps.cwd();
|
|
81
|
+
try {
|
|
82
|
+
worktree = realpathSync(worktree);
|
|
83
|
+
}
|
|
84
|
+
catch { /* resolve refuses missing bindings */ }
|
|
85
|
+
worktree = deps.findProjectRoot(worktree);
|
|
86
|
+
const ctx = await resolveRepresentativeContext(worktree, deps);
|
|
87
|
+
// Only this server step maps transport failures to SERVER_UNREACHABLE; typed
|
|
88
|
+
// rejections keep their binding codes and storage keeps STORAGE_REFUSED.
|
|
89
|
+
await verifyLiveBinding(ctx).catch((error) => {
|
|
90
|
+
throw isTransportFailure(error) && !(error instanceof BorgServerUnreachableError)
|
|
91
|
+
? new BorgServerUnreachableError('Borg server unreachable during startup verification', { cause: error }) : error;
|
|
92
|
+
});
|
|
93
|
+
const binding = ctx.binding;
|
|
94
|
+
active = (await deps.hydrateSeat(worktree));
|
|
95
|
+
const ownerDeps = listenerOwnerDeps(binding);
|
|
96
|
+
lease = await acquireStreamLease(binding.cubeId, binding.representativeDroneId, STREAM_OWNER_STALE_MS, ownerDeps);
|
|
97
|
+
if (!lease) {
|
|
98
|
+
const owner = await readOwnershipSnapshot(binding.cubeId, binding.representativeDroneId, ownerDeps);
|
|
99
|
+
await emit({ event: 'refused', code: 'REPRESENTATIVE_LISTENER_OWNED', exit_code: 3,
|
|
100
|
+
owner_pid: owner.pid ?? null, owner_started_at: owner.startedAt ?? null });
|
|
101
|
+
return 3;
|
|
102
|
+
}
|
|
103
|
+
const guard = async () => {
|
|
104
|
+
if (abort.signal.aborted)
|
|
105
|
+
throw new Error('listener stopped');
|
|
106
|
+
const current = await deps.store.getBinding(worktree);
|
|
107
|
+
if (!current || JSON.stringify([current.origin, current.trustIdentity, current.cubeId, current.representativeDroneId, current.coordinatorDroneId, current.boundAt]) !==
|
|
108
|
+
JSON.stringify([binding.origin, binding.trustIdentity, binding.cubeId, binding.representativeDroneId, binding.coordinatorDroneId, binding.boundAt])) {
|
|
109
|
+
stop('rebound');
|
|
110
|
+
throw new RepresentativeError('BINDING_MISMATCH', 'Representative binding changed');
|
|
111
|
+
}
|
|
112
|
+
const saved = await deps.hydrateSeat(worktree);
|
|
113
|
+
if (!saved) {
|
|
114
|
+
stop('revoked');
|
|
115
|
+
throw new RepresentativeError('SEAT_UNAVAILABLE', 'Representative seat unavailable');
|
|
116
|
+
}
|
|
117
|
+
if (saved.serverTrustIdentity !== binding.trustIdentity) {
|
|
118
|
+
stop('trust-changed');
|
|
119
|
+
throw new BorgServerTrustError('Representative trust changed');
|
|
120
|
+
}
|
|
121
|
+
if (saved.cubeId !== binding.cubeId || saved.droneId !== binding.representativeDroneId || saved.apiUrl !== binding.origin) {
|
|
122
|
+
stop('rebound');
|
|
123
|
+
throw new RepresentativeError('BINDING_MISMATCH', 'Representative seat changed');
|
|
124
|
+
}
|
|
125
|
+
// Recheck authority trust while the stream stays open, not only on reconnect.
|
|
126
|
+
// Controlled transports may omit trust loading; production never does.
|
|
127
|
+
if (!options.streamDeps?.fetchImpl || options.streamDeps.loadTrust) {
|
|
128
|
+
try {
|
|
129
|
+
// Read fresh: the loader's local-authority cache never observes a change.
|
|
130
|
+
const identity = options.streamDeps?.loadTrust
|
|
131
|
+
? (await options.streamDeps.loadTrust(binding.origin)).identity
|
|
132
|
+
: await readBorgServerTrustIdentity(binding.origin);
|
|
133
|
+
if (identity !== binding.trustIdentity)
|
|
134
|
+
throw new BorgServerTrustError('Representative authority trust changed');
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
stop('trust-changed');
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const observed = await readOwnershipSnapshot(binding.cubeId, binding.representativeDroneId, ownerDeps);
|
|
142
|
+
if (observed.processNonce !== lease.record.processNonce) {
|
|
143
|
+
stop('lease-lost');
|
|
144
|
+
throw new Error('Listener ownership lost');
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const inbox = createListenerInbox(binding, guard);
|
|
148
|
+
await inbox.snapshot(); // refuse unsafe persisted paths before emitting listening
|
|
149
|
+
process.once('SIGTERM', signal);
|
|
150
|
+
process.once('SIGINT', signal);
|
|
151
|
+
timer = setInterval(() => {
|
|
152
|
+
void serial(async () => { await guard(); if (!await lease.refresh())
|
|
153
|
+
stop('lease-lost'); }).catch(error => { if (!reason)
|
|
154
|
+
stop(terminalReason(error) ?? 'lease-lost'); });
|
|
155
|
+
}, options.heartbeatIntervalMs ?? 20_000);
|
|
156
|
+
let attempt = 0;
|
|
157
|
+
let consumerFailure;
|
|
158
|
+
let pendingGap;
|
|
159
|
+
// Failures of the listener's own guard, storage and output are fatal; every
|
|
160
|
+
// other non-terminal stream failure is transport and reconnects, as in the
|
|
161
|
+
// ordinary stream loop (pinned HTTPS surfaces raw errno/string codes).
|
|
162
|
+
const local = (fn) => async (...args) => {
|
|
163
|
+
try {
|
|
164
|
+
return await fn(...args);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
consumerFailure ??= error;
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
while (!reason) {
|
|
172
|
+
const resumed = await inbox.cursor();
|
|
173
|
+
try {
|
|
174
|
+
consumerFailure = undefined;
|
|
175
|
+
await local(() => serial(guard))();
|
|
176
|
+
await streamOnce(active, resumed?.id ?? null, () => { }, {
|
|
177
|
+
...options.streamDeps, getCursor: local(async () => inbox.cursor()), abortSignal: abort.signal,
|
|
178
|
+
consumer: {
|
|
179
|
+
catchupCursor: await local(() => inbox.dedupeCursor())(),
|
|
180
|
+
beforeEvent: local(() => serial(guard)),
|
|
181
|
+
clearCursor: local(() => serial(async () => {
|
|
182
|
+
const previous = await inbox.snapshot();
|
|
183
|
+
await inbox.clearCursor();
|
|
184
|
+
if (started)
|
|
185
|
+
await emit({ event: 'gap', after: previous.watermark, reason: 'cursor-expired' });
|
|
186
|
+
else
|
|
187
|
+
pendingGap = previous.watermark;
|
|
188
|
+
})),
|
|
189
|
+
connected: local(() => serial(async () => {
|
|
190
|
+
await guard();
|
|
191
|
+
if (!started) {
|
|
192
|
+
await emit({ event: 'listening', cube_id: binding.cubeId, drone_id: binding.representativeDroneId,
|
|
193
|
+
binding_fingerprint: bindingFingerprint(binding), ...await inbox.snapshot() });
|
|
194
|
+
started = true;
|
|
195
|
+
if (pendingGap !== undefined)
|
|
196
|
+
await emit({ event: 'gap', after: pendingGap, reason: 'cursor-expired' });
|
|
197
|
+
if (command.replayAfter) {
|
|
198
|
+
const replay = await inbox.replay(command.replayAfter);
|
|
199
|
+
if (replay.missing)
|
|
200
|
+
await emit({ event: 'gap', after: command.replayAfter, reason: 'replay-checkpoint-missing' });
|
|
201
|
+
for (const hint of replay.hints) {
|
|
202
|
+
await guard();
|
|
203
|
+
await emit(hint);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else
|
|
208
|
+
await emit({ event: 'connected', resumed_from: resumed?.id ?? null });
|
|
209
|
+
})),
|
|
210
|
+
log: local((event, catchupCursor) => serial(async () => {
|
|
211
|
+
await guard();
|
|
212
|
+
const hint = await inbox.append({ ...event.data, id: event.id }, catchupCursor);
|
|
213
|
+
if (hint) {
|
|
214
|
+
await guard();
|
|
215
|
+
await emit(hint);
|
|
216
|
+
}
|
|
217
|
+
})),
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
attempt = 0;
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (reason) {
|
|
224
|
+
if (!started)
|
|
225
|
+
throw error;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
if (consumerFailure)
|
|
229
|
+
throw consumerFailure;
|
|
230
|
+
const terminal = terminalReason(error);
|
|
231
|
+
if (terminal) {
|
|
232
|
+
if (!started)
|
|
233
|
+
throw error;
|
|
234
|
+
stop(terminal);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
deps.stderr(`Representative listener: ${error instanceof Error ? error.message : 'stream disconnected'}\n`);
|
|
238
|
+
}
|
|
239
|
+
if (reason)
|
|
240
|
+
break;
|
|
241
|
+
const delay = Math.round((options.reconnectDelay ?? streamReconnectDelay)(attempt++));
|
|
242
|
+
if (started)
|
|
243
|
+
await emit({ event: 'reconnecting', attempt, delay_ms: delay });
|
|
244
|
+
await new Promise(resolve => {
|
|
245
|
+
const done = () => { clearTimeout(timeout); abort.signal.removeEventListener('abort', done); resolve(); };
|
|
246
|
+
const timeout = setTimeout(done, delay);
|
|
247
|
+
abort.signal.addEventListener('abort', done, { once: true });
|
|
248
|
+
if (abort.signal.aborted)
|
|
249
|
+
done();
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return exitCode();
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
deps.stderr(`Representative listener refused: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
256
|
+
if (!started && (error instanceof RepresentativeError || terminalReason(error))) {
|
|
257
|
+
await emit({ event: 'refused', code: typeof error?.code === 'string' ? error.code : 'BACKEND_ERROR', exit_code: 2 });
|
|
258
|
+
return 2;
|
|
259
|
+
}
|
|
260
|
+
if (started)
|
|
261
|
+
reason = 'fatal';
|
|
262
|
+
else if (!outputBroken)
|
|
263
|
+
await emit({ event: 'refused', code: error instanceof BorgServerUnreachableError
|
|
264
|
+
? 'REPRESENTATIVE_LISTENER_SERVER_UNREACHABLE' : 'REPRESENTATIVE_LISTENER_STORAGE_REFUSED', exit_code: 1 });
|
|
265
|
+
return 1;
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
if (timer)
|
|
269
|
+
clearInterval(timer);
|
|
270
|
+
process.removeListener('SIGTERM', signal);
|
|
271
|
+
process.removeListener('SIGINT', signal);
|
|
272
|
+
await pending;
|
|
273
|
+
let releaseFailed = false;
|
|
274
|
+
try {
|
|
275
|
+
await lease?.release();
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
releaseFailed = true;
|
|
279
|
+
reason = 'fatal';
|
|
280
|
+
deps.stderr(`Listener lease release failed: ${String(error)}\n`);
|
|
281
|
+
}
|
|
282
|
+
if (started && reason && !outputBroken) {
|
|
283
|
+
try {
|
|
284
|
+
await emit({ event: 'stopped', reason, exit_code: exitCode() });
|
|
285
|
+
}
|
|
286
|
+
catch { /* stdout failure is fatal to the host */ }
|
|
287
|
+
}
|
|
288
|
+
process.stdout.removeListener('error', outputError);
|
|
289
|
+
if (releaseFailed || outputBroken)
|
|
290
|
+
return 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=representative-listener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"representative-listener.js","sourceRoot":"","sources":["../src/representative-listener.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAoB,MAAM,mBAAmB,CAAC;AACvH,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,OAAO,EAAE,WAAW,CAAC,CAAC;QACpD,IAAI,aAAa,IAAI,YAAY;YAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restricted stdio MCP facade for the human representative.
|
|
3
|
+
*
|
|
4
|
+
* A Borg server speaks pinned-TLS HTTPS, not MCP, so a generic MCP host reaches
|
|
5
|
+
* it through this local stdio process. The surface is five tools: status, send
|
|
6
|
+
* (to the ONE bound Coordinator), read (that Coordinator's replies), deliver
|
|
7
|
+
* (the host's durable delivery checkpoint) and ack.
|
|
8
|
+
* There is deliberately no log/broadcast/dispatch, roster-management, grant,
|
|
9
|
+
* evict, release, regen or server-lifecycle tool, and no dispatcher escape hatch.
|
|
10
|
+
*
|
|
11
|
+
* The connection context is resolved per call and injected, so the same facade
|
|
12
|
+
* runs over the real seat-scoped backend or a controlled test backend.
|
|
13
|
+
*/
|
|
14
|
+
import type { Readable, Writable } from 'node:stream';
|
|
15
|
+
import { type RepresentativeContext } from './representative-core.js';
|
|
16
|
+
export declare const REPRESENTATIVE_TOOL_NAMES: readonly ["borg_representative-status", "borg_representative-send", "borg_representative-read", "borg_representative-deliver", "borg_representative-ack"];
|
|
17
|
+
export declare const REPRESENTATIVE_INSTRUCTIONS: string;
|
|
18
|
+
export interface ServeRepresentativeOptions {
|
|
19
|
+
/** Resolved on every call; a throw fails that call closed. */
|
|
20
|
+
context: () => Promise<RepresentativeContext>;
|
|
21
|
+
/**
|
|
22
|
+
* The binding generation this process started with. Every call except status
|
|
23
|
+
* refuses with BINDING_MISMATCH, before any lease, ledger, checkpoint, cursor
|
|
24
|
+
* or network activity, once the saved binding's fingerprint differs.
|
|
25
|
+
*/
|
|
26
|
+
pinnedFingerprint?: string;
|
|
27
|
+
version: string;
|
|
28
|
+
stdin?: Readable;
|
|
29
|
+
stdout?: Writable;
|
|
30
|
+
/** Internal timing seam for heartbeat controls; production uses 20 seconds. */
|
|
31
|
+
heartbeatIntervalMs?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function serveRepresentativeMcp(options: ServeRepresentativeOptions): Promise<{
|
|
34
|
+
close: () => Promise<void>;
|
|
35
|
+
closed: Promise<void>;
|
|
36
|
+
}>;
|
|
37
|
+
//# sourceMappingURL=representative-mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"representative-mcp.d.ts","sourceRoot":"","sources":["../src/representative-mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAItD,OAAO,EAUL,KAAK,qBAAqB,EAC3B,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,yBAAyB,2JAM5B,CAAC;AAEX,eAAO,MAAM,2BAA2B,QAMV,CAAC;AA8G/B,MAAM,WAAW,0BAA0B;IACzC,8DAA8D;IAC9D,OAAO,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC9C;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAwEhE"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restricted stdio MCP facade for the human representative.
|
|
3
|
+
*
|
|
4
|
+
* A Borg server speaks pinned-TLS HTTPS, not MCP, so a generic MCP host reaches
|
|
5
|
+
* it through this local stdio process. The surface is five tools: status, send
|
|
6
|
+
* (to the ONE bound Coordinator), read (that Coordinator's replies), deliver
|
|
7
|
+
* (the host's durable delivery checkpoint) and ack.
|
|
8
|
+
* There is deliberately no log/broadcast/dispatch, roster-management, grant,
|
|
9
|
+
* evict, release, regen or server-lifecycle tool, and no dispatcher escape hatch.
|
|
10
|
+
*
|
|
11
|
+
* The connection context is resolved per call and injected, so the same facade
|
|
12
|
+
* runs over the real seat-scoped backend or a controlled test backend.
|
|
13
|
+
*/
|
|
14
|
+
import { ErrorCode } from 'borgmcp-shared/protocol';
|
|
15
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
16
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
17
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
18
|
+
import { REPRESENTATIVE_DELIVERY_NOTE, REPRESENTATIVE_MESSAGE_LIMIT_BYTES, RepresentativeError, ackRepresentativeReply, deliverRepresentativeReplies, readRepresentativeReplies, serializeRepresentativeResult, representativeStatus, sendRepresentativeMessage, } from './representative-core.js';
|
|
19
|
+
import { RepresentativeStoreError, bindingFingerprint } from './representative-store.js';
|
|
20
|
+
import { createDeliveryStore } from './representative-delivery-store.js';
|
|
21
|
+
import { createRepresentativeOwner } from './representative-owner.js';
|
|
22
|
+
export const REPRESENTATIVE_TOOL_NAMES = [
|
|
23
|
+
'borg_representative-status',
|
|
24
|
+
'borg_representative-send',
|
|
25
|
+
'borg_representative-read',
|
|
26
|
+
'borg_representative-deliver',
|
|
27
|
+
'borg_representative-ack',
|
|
28
|
+
];
|
|
29
|
+
export const REPRESENTATIVE_INSTRUCTIONS = 'You are connected as the human representative of one Borg cube: an automated delegate that relays the ' +
|
|
30
|
+
'human\'s requests, questions and decisions to ONE bound Coordinator drone and reads its replies. You are not the ' +
|
|
31
|
+
'Coordinator and not the human: never plan or dispatch work for other drones — the Coordinator does that. ' +
|
|
32
|
+
'Mark content user_authorized ONLY when the human explicitly said it; everything you originate is model_advice. ' +
|
|
33
|
+
'A relayed decision authorizes only its own text, never broader approval. ' +
|
|
34
|
+
REPRESENTATIVE_DELIVERY_NOTE;
|
|
35
|
+
const TOOLS = [
|
|
36
|
+
{
|
|
37
|
+
name: 'borg_representative-status',
|
|
38
|
+
description: 'Show which cube, representative drone and Coordinator this connection is bound to, whether the live cube still matches, ' +
|
|
39
|
+
'any unresolved (ambiguous) sends, process ownership and the delivery limits. Read-only; never takes ownership.',
|
|
40
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'borg_representative-send',
|
|
44
|
+
description: 'Relay ONE human request, question or decision to the bound Coordinator. The recipient is fixed; workers and broadcast ' +
|
|
45
|
+
'are not addressable. Returns a request_id. If the outcome is "ambiguous" (the result names the cause), retry only ' +
|
|
46
|
+
'with the SAME request_id and identical content (server-deduplicated); never re-send under a new id. A ' +
|
|
47
|
+
'SEND_REJECTED error names the refusal and its recovery. Do not issue overlapping sends of the same content.',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
kind: { type: 'string', enum: ['request', 'question', 'decision'] },
|
|
52
|
+
authorization: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
enum: ['user_authorized', 'model_advice'],
|
|
55
|
+
description: 'user_authorized: the human explicitly said/approved this exact content. model_advice: your own suggestion. ' +
|
|
56
|
+
'A decision must be user_authorized.',
|
|
57
|
+
},
|
|
58
|
+
message: { type: 'string', description: `Plain text, at most ${REPRESENTATIVE_MESSAGE_LIMIT_BYTES} bytes.` },
|
|
59
|
+
request_id: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Omit for a new request. To retry, pass the request_id returned earlier with identical content.',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ['kind', 'authorization', 'message'],
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'borg_representative-read',
|
|
70
|
+
description: 'Read the bound Coordinator\'s replies addressed to this representative that come after your delivered checkpoint, ' +
|
|
71
|
+
'oldest first. Reading changes nothing: the same replies return on every call until you call ' +
|
|
72
|
+
'borg_representative-deliver. Persist each reply durably, route it by in_reply_to or hold it for the human, then ' +
|
|
73
|
+
'deliver through the last one you persisted. At most `limit` replies and `max_bytes` of serialized result; a reply ' +
|
|
74
|
+
'larger than max_bytes is returned whole and alone with oversize:true, and the result never exceeds ' +
|
|
75
|
+
'max(max_bytes, 16384) bytes (oversize citations reduced to ids, documents_reduced:true). has_more means more ' +
|
|
76
|
+
'replies follow the window; an empty page never has has_more. ' +
|
|
77
|
+
'Stop routing if binding_fingerprint differs from the value you persisted at binding time.',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
include_broadcast: { type: 'boolean', description: 'Also return the Coordinator\'s cube-wide broadcasts (marked as such).' },
|
|
82
|
+
limit: { type: 'integer', minimum: 1, maximum: 50, description: 'Hard cap on returned replies. Default 10.' },
|
|
83
|
+
max_bytes: {
|
|
84
|
+
type: 'integer', minimum: 4096, maximum: 60000,
|
|
85
|
+
description: 'Hard cap on the serialized result size in bytes. Default 32768.',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'borg_representative-deliver',
|
|
93
|
+
description: 'Record that every reply up to and including `through` is durably persisted by the host. Only this call moves the ' +
|
|
94
|
+
'read window. `through` must be a reply borg_representative-read returned; the same or an older id is a no-op ' +
|
|
95
|
+
'(advanced:false). Call it only after durable persistence: a delivered reply is not returned again. It does not ' +
|
|
96
|
+
'notify the Coordinator; that is borg_representative-ack.',
|
|
97
|
+
inputSchema: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: { through: { type: 'string', description: 'entry_id of the last reply you persisted.' } },
|
|
100
|
+
required: ['through'],
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'borg_representative-ack',
|
|
106
|
+
description: 'Signal to the Coordinator that one of its direct replies (entry_id from borg_representative-read) was received. ' +
|
|
107
|
+
'It is only that signal: it is not delivery, does not move the read window (that is borg_representative-deliver), ' +
|
|
108
|
+
'and is not needed for reading.',
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: { entry_id: { type: 'string' } },
|
|
112
|
+
required: ['entry_id'],
|
|
113
|
+
additionalProperties: false,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
function errorBody(error) {
|
|
118
|
+
if (error instanceof RepresentativeError || error instanceof RepresentativeStoreError) {
|
|
119
|
+
const details = error instanceof RepresentativeError ? error.details : undefined;
|
|
120
|
+
return { error: { code: error.code, message: error.message, ...(details ? { details } : {}) } };
|
|
121
|
+
}
|
|
122
|
+
const code = error?.code;
|
|
123
|
+
return {
|
|
124
|
+
error: {
|
|
125
|
+
code: typeof code === 'string' ? code : 'BACKEND_ERROR',
|
|
126
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const toolResult = (body, isError = false) => ({
|
|
131
|
+
content: [{ type: 'text', text: serializeRepresentativeResult(body) }],
|
|
132
|
+
...(isError ? { isError: true } : {}),
|
|
133
|
+
});
|
|
134
|
+
export async function serveRepresentativeMcp(options) {
|
|
135
|
+
const owner = createRepresentativeOwner(options.heartbeatIntervalMs);
|
|
136
|
+
const server = new Server({ name: 'borg-human-representative', version: options.version }, { capabilities: { tools: {} }, instructions: REPRESENTATIVE_INSTRUCTIONS });
|
|
137
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS.map((tool) => ({ ...tool })) }));
|
|
138
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
139
|
+
const name = request.params.name;
|
|
140
|
+
const args = request.params.arguments ?? {};
|
|
141
|
+
try {
|
|
142
|
+
if (!REPRESENTATIVE_TOOL_NAMES.includes(name)) {
|
|
143
|
+
throw new RepresentativeError(ErrorCode.INVALID_INPUT, `Unknown tool ${JSON.stringify(name)}; this connection exposes only the representative tools.`);
|
|
144
|
+
}
|
|
145
|
+
const ctx = await options.context();
|
|
146
|
+
const pinned = options.pinnedFingerprint ? { pinned_binding_fingerprint: options.pinnedFingerprint } : {};
|
|
147
|
+
if (name === 'borg_representative-status') {
|
|
148
|
+
return toolResult({ ...await representativeStatus(ctx), ...pinned, ownership: await owner.snapshot(ctx.binding) });
|
|
149
|
+
}
|
|
150
|
+
if (options.pinnedFingerprint && bindingFingerprint(ctx.binding) !== options.pinnedFingerprint) {
|
|
151
|
+
throw new RepresentativeError('BINDING_MISMATCH', 'The operator rebound this connection (a new binding generation) while it was running. Restart the MCP server to use the new binding.');
|
|
152
|
+
}
|
|
153
|
+
// An untrustworthy delivery checkpoint stops every effect, not only read
|
|
154
|
+
// and deliver, so the refusal reaches the human. Read-only; status stays.
|
|
155
|
+
await createDeliveryStore(ctx.binding).load();
|
|
156
|
+
await owner.ensure(ctx.binding);
|
|
157
|
+
// Recheck at each network boundary, not just at tool dispatch: a process
|
|
158
|
+
// may have paused or lost its lease while awaiting live verification.
|
|
159
|
+
const backend = ctx.backend;
|
|
160
|
+
const guarded = { ...ctx, guard: () => owner.ensure(ctx.binding), backend: Object.fromEntries(['whoami', 'roster', 'append', 'readAfter', 'unreadCursor', 'readEntry', 'ack'].map((key) => [key, async (...args) => {
|
|
161
|
+
await owner.ensure(ctx.binding);
|
|
162
|
+
if (key === 'readAfter')
|
|
163
|
+
args[2] = () => owner.ensure(ctx.binding);
|
|
164
|
+
const result = await backend[key].apply(backend, args);
|
|
165
|
+
await owner.ensure(ctx.binding);
|
|
166
|
+
return result;
|
|
167
|
+
}])) };
|
|
168
|
+
switch (name) {
|
|
169
|
+
case 'borg_representative-send': {
|
|
170
|
+
const sent = await sendRepresentativeMessage(guarded, args);
|
|
171
|
+
return toolResult(sent, sent.outcome === 'ambiguous');
|
|
172
|
+
}
|
|
173
|
+
case 'borg_representative-read':
|
|
174
|
+
return toolResult(await readRepresentativeReplies(guarded, args));
|
|
175
|
+
case 'borg_representative-deliver':
|
|
176
|
+
return toolResult(await deliverRepresentativeReplies(guarded, args));
|
|
177
|
+
default:
|
|
178
|
+
return toolResult(await ackRepresentativeReply(guarded, args));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return toolResult(errorBody(error), true);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const transport = new StdioServerTransport(options.stdin, options.stdout);
|
|
186
|
+
let finish;
|
|
187
|
+
const closed = new Promise((resolve) => { finish = resolve; });
|
|
188
|
+
const shutdown = async () => {
|
|
189
|
+
process.removeListener('SIGTERM', signalClose);
|
|
190
|
+
process.removeListener('SIGINT', signalClose);
|
|
191
|
+
try {
|
|
192
|
+
await owner.close();
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
finish();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const signalClose = () => { void server.close(); };
|
|
199
|
+
server.onclose = () => { void shutdown().catch(() => { }); };
|
|
200
|
+
process.once('SIGTERM', signalClose);
|
|
201
|
+
process.once('SIGINT', signalClose);
|
|
202
|
+
try {
|
|
203
|
+
await server.connect(transport);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
await shutdown();
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
return { close: async () => { await server.close(); await closed; }, closed };
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=representative-mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"representative-mcp.js","sourceRoot":"","sources":["../src/representative-mcp.ts"],"names":[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AC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type StreamOwnerDeps, type StreamOwnershipSnapshot } from './stream-owner.js';
|
|
2
|
+
import type { RepresentativeBinding } from './representative-store.js';
|
|
3
|
+
export declare function representativeOwnerDeps(binding: RepresentativeBinding): StreamOwnerDeps;
|
|
4
|
+
export declare function representativeOwnership(binding: RepresentativeBinding): Promise<StreamOwnershipSnapshot>;
|
|
5
|
+
export declare function createRepresentativeOwner(heartbeatIntervalMs?: number): {
|
|
6
|
+
snapshot: (binding: RepresentativeBinding) => Promise<StreamOwnershipSnapshot>;
|
|
7
|
+
ensure: (binding: RepresentativeBinding) => Promise<undefined>;
|
|
8
|
+
close: () => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=representative-owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"representative-owner.d.ts","sourceRoot":"","sources":["../src/representative-owner.ts"],"names":[],"mappings":"AAIA,OAAO,EAEa,KAAK,eAAe,EAAE,KAAK,uBAAuB,EACrE,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CASvF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAExG;AAoBD,wBAAgB,yBAAyB,CAAC,mBAAmB,SAAS;wBAezC,qBAAqB;sBAsB5B,qBAAqB;;EAuB1C"}
|