agent-relay 15.1.1 → 17.0.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/cli/commands/cloud-v1-deprecations.d.ts +1 -1
- package/dist/cli/commands/cloud-v1-deprecations.js +1 -1
- package/dist/cli/commands/cloud-worker.d.ts.map +1 -1
- package/dist/cli/commands/cloud-worker.js +61 -3
- package/dist/cli/commands/cloud-worker.js.map +1 -1
- package/dist/cli/commands/init.d.ts +5 -5
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +41 -66
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/product-surfaces.js +2 -2
- package/dist/cli/commands/product-surfaces.js.map +1 -1
- package/dist/cli/lib/cloud-worker-cli-credentials.d.ts +98 -0
- package/dist/cli/lib/cloud-worker-cli-credentials.d.ts.map +1 -0
- package/dist/cli/lib/cloud-worker-cli-credentials.js +298 -0
- package/dist/cli/lib/cloud-worker-cli-credentials.js.map +1 -0
- package/dist/cli/lib/desktop-presence.d.ts +1 -1
- package/dist/cli/lib/desktop-presence.js +1 -1
- package/dist/cli/lib/{probe-core.d.ts → relay-node.d.ts} +12 -16
- package/dist/cli/lib/relay-node.d.ts.map +1 -0
- package/dist/cli/lib/{probe-core.js → relay-node.js} +22 -26
- package/dist/cli/lib/{probe-core.js.map → relay-node.js.map} +1 -1
- package/package.json +12 -12
- package/dist/cli/lib/probe-core.d.ts.map +0 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// Subscription-login materialisation for `agent-relay cloud worker`.
|
|
2
|
+
//
|
|
3
|
+
// A control plane that holds Codex/Grok subscription logins for the workspace
|
|
4
|
+
// (self-hosted relaycontrol; hosted Cloud mounts the same files in its own
|
|
5
|
+
// sandboxes) puts `cliCredentials` in the assignment payload: a short-lived,
|
|
6
|
+
// run-scoped reference, never the files. Before spawning relayflows, the worker
|
|
7
|
+
// exchanges the reference (with its worker token) for the auth files, writes
|
|
8
|
+
// each one 0600 into a 0700 directory inside the run's private dir, and points
|
|
9
|
+
// the CLI at it (CODEX_HOME / GROK_HOME). After the run it writes back a file
|
|
10
|
+
// the CLI refreshed, so the stored login keeps a live refresh token. The login
|
|
11
|
+
// directory is deleted after the run (even when the run dir is kept).
|
|
12
|
+
//
|
|
13
|
+
// Nothing here logs a file's content or the reference.
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import fsp from 'node:fs/promises';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { execFile } from 'node:child_process';
|
|
18
|
+
import { promisify } from 'node:util';
|
|
19
|
+
const execFileAsync = promisify(execFile);
|
|
20
|
+
/** The only layouts a login may use: each CLI's own home variable, directory and file. */
|
|
21
|
+
const CLI_LAYOUTS = {
|
|
22
|
+
codex: { homeEnv: 'CODEX_HOME', directory: '.codex', file: 'auth.json' },
|
|
23
|
+
grok: { homeEnv: 'GROK_HOME', directory: '.grok', file: 'auth.json' },
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Lists the mounted CLIs. relayflows reads it to give the subscription
|
|
27
|
+
* precedence over API keys (AgentWorkforce/relayflows#65); the precedence
|
|
28
|
+
* applies once the relayflows release containing it is the one this package
|
|
29
|
+
* pins. Codex and Grok themselves read only CODEX_HOME/GROK_HOME.
|
|
30
|
+
*/
|
|
31
|
+
export const SUBSCRIPTION_LOGINS_ENV = 'AGENT_RELAY_SUBSCRIPTION_LOGINS';
|
|
32
|
+
const CREDENTIAL_PATH = /^\/api\/v1\/workers\/\{workerId\}\/assignments\/[A-Za-z0-9_-]{1,128}\/cli-credentials$/;
|
|
33
|
+
const CREDENTIAL_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
34
|
+
const WRITE_BACK_TIMEOUT_MS = 15_000;
|
|
35
|
+
const WRITE_BACK_ATTEMPTS = 3;
|
|
36
|
+
/**
|
|
37
|
+
* Whether an assignment payload's `cliCredentials` has the expected shape.
|
|
38
|
+
*
|
|
39
|
+
* @param value - The raw `payload.cliCredentials` value.
|
|
40
|
+
* @returns True when it carries a reference and a credential path.
|
|
41
|
+
*/
|
|
42
|
+
export function isCliCredentialsPayload(value) {
|
|
43
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
44
|
+
return false;
|
|
45
|
+
const candidate = value;
|
|
46
|
+
return typeof candidate.ref === 'string' && candidate.ref.length > 0 && typeof candidate.path === 'string';
|
|
47
|
+
}
|
|
48
|
+
/** The listed credentials, or an error: a reference without its list cannot be matched safely. */
|
|
49
|
+
function offeredCredentials(credentials) {
|
|
50
|
+
const list = credentials.credentials;
|
|
51
|
+
if (!Array.isArray(list) ||
|
|
52
|
+
!list.every((entry) => entry !== null &&
|
|
53
|
+
typeof entry === 'object' &&
|
|
54
|
+
typeof entry.credentialId === 'string' &&
|
|
55
|
+
typeof entry.cli === 'string')) {
|
|
56
|
+
throw new Error('cliCredentials.credentials must list the CLI logins offered for this run.');
|
|
57
|
+
}
|
|
58
|
+
return new Map(list.map((entry) => [entry.credentialId, entry.cli]));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The run's login directory: `<stateDir>/cli-logins/<runId>`, outside `runs/`,
|
|
62
|
+
* so neither a code-archive entry nor another run's directory can collide
|
|
63
|
+
* with it. Pure path helper.
|
|
64
|
+
*
|
|
65
|
+
* @param runDir - The run's private directory.
|
|
66
|
+
* @returns The login directory path.
|
|
67
|
+
*/
|
|
68
|
+
export function cliLoginHome(runDir) {
|
|
69
|
+
return path.join(path.dirname(path.dirname(runDir)), 'cli-logins', path.basename(runDir));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates the login directory fresh: anything already there (a directory or a
|
|
73
|
+
* symlink) is removed first, so every path below it is created by the worker
|
|
74
|
+
* and no write follows a link.
|
|
75
|
+
*/
|
|
76
|
+
async function freshLoginHome(runDir) {
|
|
77
|
+
const home = cliLoginHome(runDir);
|
|
78
|
+
await fsp.mkdir(path.dirname(home), { recursive: true, mode: 0o700 });
|
|
79
|
+
await fsp.rm(home, { recursive: true, force: true });
|
|
80
|
+
await fsp.mkdir(home, { mode: 0o700 });
|
|
81
|
+
await fsp.chmod(home, 0o700).catch(() => undefined);
|
|
82
|
+
const stat = await fsp.lstat(home);
|
|
83
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
84
|
+
throw new Error('Could not create the CLI login directory');
|
|
85
|
+
return home;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Builds a credential URL under the worker's API base, keeping any base path
|
|
89
|
+
* prefix (e.g. `/cloud`). Only the exact credential route is accepted, so the
|
|
90
|
+
* worker token and reference can never be sent to another origin or route.
|
|
91
|
+
*/
|
|
92
|
+
function credentialUrl(worker, template, credentialId) {
|
|
93
|
+
if (!CREDENTIAL_PATH.test(template)) {
|
|
94
|
+
throw new Error('cliCredentials.path is not the worker credential route');
|
|
95
|
+
}
|
|
96
|
+
if (credentialId !== undefined && !CREDENTIAL_ID.test(credentialId)) {
|
|
97
|
+
throw new Error('Invalid CLI credential id');
|
|
98
|
+
}
|
|
99
|
+
const base = new URL(worker.baseUrl);
|
|
100
|
+
const relative = template.replace('{workerId}', encodeURIComponent(worker.workerId));
|
|
101
|
+
const url = new URL(`${worker.baseUrl.replace(/\/+$/, '')}${relative}${credentialId === undefined ? '' : `/${credentialId}`}`);
|
|
102
|
+
if (url.origin !== base.origin || url.search || url.hash) {
|
|
103
|
+
throw new Error('cliCredentials.path resolves outside the control plane');
|
|
104
|
+
}
|
|
105
|
+
return url.toString();
|
|
106
|
+
}
|
|
107
|
+
function headers(worker, ref, json = false) {
|
|
108
|
+
const result = new Headers({ Authorization: `Bearer ${worker.workerToken}`, 'X-Cli-Credential-Ref': ref });
|
|
109
|
+
if (json)
|
|
110
|
+
result.set('Content-Type', 'application/json');
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Fetches the run's subscription logins and writes each auth file 0600 into a
|
|
115
|
+
* 0700 directory in the run's login dir (a sibling of `runDir`).
|
|
116
|
+
*
|
|
117
|
+
* A file is mounted only when it matches a credential the assignment payload
|
|
118
|
+
* listed, with that credential's CLI and the CLI's own layout; anything else is
|
|
119
|
+
* skipped (and logged by CLI name only).
|
|
120
|
+
*
|
|
121
|
+
* @param input.worker - The authenticated worker (token sent with the request).
|
|
122
|
+
* @param input.credentials - The payload's `cliCredentials`.
|
|
123
|
+
* @param input.runDir - The run's private directory.
|
|
124
|
+
* @returns The env for relayflows, the login directory, and the mounted files.
|
|
125
|
+
* @throws When the control plane refuses the reference or the path is not the credential route.
|
|
126
|
+
*/
|
|
127
|
+
export async function materializeCliCredentials(input) {
|
|
128
|
+
// Validate the payload before any request, so a bad list is reported as such.
|
|
129
|
+
const expected = offeredCredentials(input.credentials);
|
|
130
|
+
const response = await input.fetchImpl(credentialUrl(input.worker, input.credentials.path), {
|
|
131
|
+
method: 'GET',
|
|
132
|
+
headers: headers(input.worker, input.credentials.ref),
|
|
133
|
+
signal: input.signal,
|
|
134
|
+
// A redirect would resend the worker token and reference elsewhere.
|
|
135
|
+
redirect: 'error',
|
|
136
|
+
});
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
throw new Error(`Could not load the run's CLI logins (HTTP ${response.status}).`);
|
|
139
|
+
}
|
|
140
|
+
// An unreadable response fails the run: starting without the offered login
|
|
141
|
+
// could silently fall back to inherited credentials.
|
|
142
|
+
let body;
|
|
143
|
+
try {
|
|
144
|
+
body = (await response.json());
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
throw new Error('The control plane returned an unreadable CLI login response.');
|
|
148
|
+
}
|
|
149
|
+
if (!body || typeof body !== 'object' || !Array.isArray(body.files)) {
|
|
150
|
+
throw new Error('The control plane returned an invalid CLI login response.');
|
|
151
|
+
}
|
|
152
|
+
const home = await freshLoginHome(input.runDir);
|
|
153
|
+
const env = {};
|
|
154
|
+
const files = [];
|
|
155
|
+
const entries = body.files;
|
|
156
|
+
for (const entry of entries) {
|
|
157
|
+
if (!entry || typeof entry !== 'object') {
|
|
158
|
+
input.log?.('[cloud-worker] skipping a malformed CLI login entry');
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const layout = typeof entry.cli === 'string' && Object.hasOwn(CLI_LAYOUTS, entry.cli)
|
|
162
|
+
? CLI_LAYOUTS[entry.cli]
|
|
163
|
+
: undefined;
|
|
164
|
+
const valid = layout !== undefined &&
|
|
165
|
+
typeof entry.credentialId === 'string' &&
|
|
166
|
+
CREDENTIAL_ID.test(entry.credentialId) &&
|
|
167
|
+
expected.get(entry.credentialId) === entry.cli &&
|
|
168
|
+
entry.homeEnv === layout.homeEnv &&
|
|
169
|
+
entry.directory === layout.directory &&
|
|
170
|
+
entry.file === layout.file &&
|
|
171
|
+
typeof entry.content === 'string' &&
|
|
172
|
+
!(layout.homeEnv in env);
|
|
173
|
+
if (!valid || !layout) {
|
|
174
|
+
input.log?.(`[cloud-worker] skipping a CLI login that does not match the assignment (${String(entry.cli)})`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const directory = path.join(home, layout.directory);
|
|
178
|
+
await fsp.mkdir(directory, { mode: 0o700 });
|
|
179
|
+
await fsp.chmod(directory, 0o700).catch(() => undefined);
|
|
180
|
+
const filePath = path.join(directory, layout.file);
|
|
181
|
+
// 'wx' = O_CREAT | O_EXCL: fails on anything already at the path, a symlink included.
|
|
182
|
+
await fsp.writeFile(filePath, entry.content, { encoding: 'utf-8', mode: 0o600, flag: 'wx' });
|
|
183
|
+
await fsp.chmod(filePath, 0o600).catch(() => undefined);
|
|
184
|
+
env[layout.homeEnv] = directory;
|
|
185
|
+
files.push({
|
|
186
|
+
credentialId: entry.credentialId,
|
|
187
|
+
cli: entry.cli,
|
|
188
|
+
filePath,
|
|
189
|
+
original: entry.content,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// Every CLI home points into the run's login dir, empty when nothing mounted,
|
|
193
|
+
// so a CLI never falls back to a login on the worker host (or its ~/.codex).
|
|
194
|
+
for (const layout of Object.values(CLI_LAYOUTS)) {
|
|
195
|
+
if (layout.homeEnv in env)
|
|
196
|
+
continue;
|
|
197
|
+
const directory = path.join(home, layout.directory);
|
|
198
|
+
await fsp.mkdir(directory, { mode: 0o700 });
|
|
199
|
+
env[layout.homeEnv] = directory;
|
|
200
|
+
}
|
|
201
|
+
// Always set, so an inherited value never claims a login this run lacks.
|
|
202
|
+
env[SUBSCRIPTION_LOGINS_ENV] = [...new Set(files.map((file) => file.cli))].sort().join(',');
|
|
203
|
+
if (Array.isArray(body.skipped) && body.skipped.length) {
|
|
204
|
+
input.log?.(`[cloud-worker] ${body.skipped.length} CLI login(s) unavailable for this run`);
|
|
205
|
+
}
|
|
206
|
+
return { env, home, files };
|
|
207
|
+
}
|
|
208
|
+
/** Reads a regular file without following a symlink a workflow may have planted. */
|
|
209
|
+
async function readRegularFile(filePath) {
|
|
210
|
+
const noFollow = fs.constants.O_NOFOLLOW ?? 0;
|
|
211
|
+
if (!noFollow) {
|
|
212
|
+
const stat = await fsp.lstat(filePath).catch(() => null);
|
|
213
|
+
if (!stat?.isFile())
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
let handle;
|
|
217
|
+
try {
|
|
218
|
+
handle = await fsp.open(filePath, fs.constants.O_RDONLY | noFollow);
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const stat = await handle.stat();
|
|
225
|
+
if (!stat.isFile() || stat.size > 256 * 1024)
|
|
226
|
+
return null;
|
|
227
|
+
return await handle.readFile({ encoding: 'utf-8' });
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
await handle.close();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* After the run, sends back each auth file the CLI rewrote (its own token
|
|
235
|
+
* refresh), so the stored login keeps a live refresh token. Each PUT has its
|
|
236
|
+
* own timeout and is retried; it never waits on the run's abort signal, so a
|
|
237
|
+
* cancelled run still stores a rotated (single-use) refresh token.
|
|
238
|
+
*
|
|
239
|
+
* @returns How many files were stored, and which changed files could not be.
|
|
240
|
+
*/
|
|
241
|
+
export async function writeBackCliCredentials(input) {
|
|
242
|
+
const result = { written: 0, failed: [] };
|
|
243
|
+
for (const file of input.materialized.files) {
|
|
244
|
+
const current = await readRegularFile(file.filePath);
|
|
245
|
+
if (current === null || current === file.original)
|
|
246
|
+
continue;
|
|
247
|
+
let stored = false;
|
|
248
|
+
for (let attempt = 1; attempt <= WRITE_BACK_ATTEMPTS && !stored; attempt += 1) {
|
|
249
|
+
try {
|
|
250
|
+
const response = await input.fetchImpl(credentialUrl(input.worker, input.credentials.path, file.credentialId), {
|
|
251
|
+
method: 'PUT',
|
|
252
|
+
headers: headers(input.worker, input.credentials.ref, true),
|
|
253
|
+
body: JSON.stringify({ content: current }),
|
|
254
|
+
signal: AbortSignal.timeout(WRITE_BACK_TIMEOUT_MS),
|
|
255
|
+
redirect: 'error',
|
|
256
|
+
});
|
|
257
|
+
if (response.ok)
|
|
258
|
+
stored = true;
|
|
259
|
+
// A 4xx will not succeed on retry.
|
|
260
|
+
else if (response.status < 500 && response.status !== 429)
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// Network failure or timeout: retry.
|
|
265
|
+
}
|
|
266
|
+
if (!stored && attempt < WRITE_BACK_ATTEMPTS) {
|
|
267
|
+
await new Promise((resolve) => setTimeout(resolve, (input.retryDelayMs ?? 1_000) * attempt));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (stored) {
|
|
271
|
+
result.written += 1;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
result.failed.push({ credentialId: file.credentialId, cli: file.cli });
|
|
275
|
+
input.log?.(`[cloud-worker] the refreshed ${file.cli} login could not be stored; sign in again if the next run fails`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
/** Makes a login tree removable again (a workflow may have chmod-ed it) and removes it. */
|
|
281
|
+
export async function removeLoginHome(home) {
|
|
282
|
+
try {
|
|
283
|
+
await fsp.rm(home, { recursive: true, force: true });
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
// Restore owner permissions and retry once.
|
|
288
|
+
}
|
|
289
|
+
// Restore owner permissions with chmod(1) rather than a check-then-chmod in
|
|
290
|
+
// this process: `chmod -R` (default -P) never follows symlinks, applies the
|
|
291
|
+
// mode to a directory before descending, so a mode-000 directory made by
|
|
292
|
+
// the workflow is repaired too, and leaves no check/use race in this code.
|
|
293
|
+
if (process.platform !== 'win32') {
|
|
294
|
+
await execFileAsync('chmod', ['-R', 'u+rwX', '--', home]).catch(() => undefined);
|
|
295
|
+
}
|
|
296
|
+
await fsp.rm(home, { recursive: true, force: true });
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=cloud-worker-cli-credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-worker-cli-credentials.js","sourceRoot":"","sources":["../../../src/cli/lib/cloud-worker-cli-credentials.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,sEAAsE;AACtE,EAAE;AACF,uDAAuD;AACvD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAsC1C,0FAA0F;AAC1F,MAAM,WAAW,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,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { spawn, spawnSync } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { connectCore, coreSocketPath, readCoreState, } from './
|
|
5
|
+
import { connectCore, coreSocketPath, readCoreState, } from './relay-node.js';
|
|
6
6
|
import { originBindingsPath } from './relaycast-origin-binding.js';
|
|
7
7
|
import { isUsableBinary } from '@agent-relay/harness-driver/install-paths';
|
|
8
8
|
function subdirectories(dir) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Agent Relay core (`agent-relay-
|
|
2
|
+
* The Agent Relay core (`agent-relay-node`): the per-user daemon that finds
|
|
3
3
|
* the coding-agent sessions running on this machine and injects Relay
|
|
4
4
|
* messages into them through each tool's own route (Claude Code's session
|
|
5
5
|
* inbox, Codex hooks and queue, the OpenCode and Pi plugins, Devin and Cursor
|
|
6
|
-
* hooks, Grok's leader socket). `relay init` installs it from a `
|
|
6
|
+
* hooks, Grok's leader socket). `relay init` installs it from a `v<CLI version>`
|
|
7
7
|
* GitHub release of this repository, runs it in the background, and turns on
|
|
8
8
|
* the core's delivery settings for the agent tools the person picked.
|
|
9
9
|
*
|
|
@@ -11,17 +11,13 @@
|
|
|
11
11
|
* `relay init` started. A running core is always attached to, never doubled.
|
|
12
12
|
* Its bridge is JSON-RPC 2.0 over NDJSON on `~/.agentworkforce/desktop/core.sock`
|
|
13
13
|
* (`AGENT_RELAY_CORE_SOCKET` moves it; on Windows a named pipe derived from
|
|
14
|
-
* that path), see crates/
|
|
14
|
+
* that path), see crates/relay-node/docs/relay-core.md.
|
|
15
15
|
*/
|
|
16
16
|
import type { ToolId } from './agent-tools-mcp.js';
|
|
17
17
|
import type { ClaudeFileState, OpenCodeState, PiState } from './init-leftovers.js';
|
|
18
18
|
import type { EnginePlatform } from './relaycast-engine-install.js';
|
|
19
19
|
import { type RelaySkillRecord } from './relay-skill.js';
|
|
20
|
-
/** The
|
|
21
|
-
export declare const PROBE_VERSION = "15.0.9";
|
|
22
|
-
/** Release tags of the core; distinct from the CLI's `v*` tags. */
|
|
23
|
-
export declare const PROBE_TAG_PREFIX = "probe-v";
|
|
24
|
-
/** The bridge version this client speaks (`crates/probe/src/relay/protocol.rs`). */
|
|
20
|
+
/** The bridge version this client speaks (`crates/relay-node/src/relay/protocol.rs`). */
|
|
25
21
|
export declare const BRIDGE_VERSION = 2;
|
|
26
22
|
/** Moves the core's bridge socket, for the core and its clients alike. */
|
|
27
23
|
export declare const CORE_SOCKET_ENV = "AGENT_RELAY_CORE_SOCKET";
|
|
@@ -31,16 +27,16 @@ export declare const CORE_START_TIMEOUT_MS = 30000;
|
|
|
31
27
|
* The release asset of the core for a platform, or undefined when none is published.
|
|
32
28
|
* @param version - Core version, e.g. `15.0.0`
|
|
33
29
|
* @param target - Platform, architecture and libc
|
|
34
|
-
* @returns e.g. `agent-relay-
|
|
30
|
+
* @returns e.g. `agent-relay-node-15.0.0-linux-x64`
|
|
35
31
|
*/
|
|
36
|
-
export declare function
|
|
32
|
+
export declare function relayNodeAssetName(version: string, target: EnginePlatform): string | undefined;
|
|
37
33
|
/**
|
|
38
34
|
* Where a release asset of the core downloads from.
|
|
39
35
|
* @param version - Core version
|
|
40
|
-
* @param asset - Asset name from {@link
|
|
36
|
+
* @param asset - Asset name from {@link relayNodeAssetName}
|
|
41
37
|
* @returns The GitHub release download URL; the checksum is at `<url>.sha256`
|
|
42
38
|
*/
|
|
43
|
-
export declare function
|
|
39
|
+
export declare function relayNodeAssetUrl(version: string, asset: string): string;
|
|
44
40
|
/**
|
|
45
41
|
* The core's bridge socket, resolved as the core resolves it: an absolute
|
|
46
42
|
* `AGENT_RELAY_CORE_SOCKET`, a relative one beside the default, else
|
|
@@ -75,13 +71,13 @@ export interface CoreClient {
|
|
|
75
71
|
*/
|
|
76
72
|
export declare function connectCore(socket: string, timeoutMs?: number): Promise<CoreClient | undefined>;
|
|
77
73
|
/**
|
|
78
|
-
* The version an `agent-relay-
|
|
74
|
+
* The version an `agent-relay-node` binary reports for `--version`. Only
|
|
79
75
|
* the core's own one-line answer counts, so another program that happens to
|
|
80
76
|
* print a version is not taken for the core.
|
|
81
77
|
* @param binary - Path to the binary
|
|
82
78
|
* @returns e.g. `15.0.0`, or undefined when it is not the core or does not run
|
|
83
79
|
*/
|
|
84
|
-
export declare function
|
|
80
|
+
export declare function readRelayNodeVersion(binary: string): string | undefined;
|
|
85
81
|
/** The part of the core's `status.get` that init reads. */
|
|
86
82
|
export interface CoreStatus {
|
|
87
83
|
daemon: {
|
|
@@ -116,7 +112,7 @@ interface CoreSetting {
|
|
|
116
112
|
/** Sessions of every supported tool join Relay on their own. */
|
|
117
113
|
export declare const AUTO_ACTIVATE: CoreSetting;
|
|
118
114
|
/** How the core injects into each tool, and the settings that turn it on. */
|
|
119
|
-
export declare const
|
|
115
|
+
export declare const CORE_DELIVERY: Record<ToolId, {
|
|
120
116
|
settings: CoreSetting[];
|
|
121
117
|
route: string;
|
|
122
118
|
}>;
|
|
@@ -215,4 +211,4 @@ export declare function readDeliveryRecord(file: string): DeliveryRecord;
|
|
|
215
211
|
/** The core settings init turned on, kept for `--uninstall`. */
|
|
216
212
|
export declare function readTurnedOn(file: string): string[];
|
|
217
213
|
export {};
|
|
218
|
-
//# sourceMappingURL=
|
|
214
|
+
//# sourceMappingURL=relay-node.d.ts.map
|
|
@@ -0,0 +1 @@
|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,EAAE,CAAC;IACnB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC9C,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,qEAAqE;IACrE,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,mFAAmF;IACnF,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAmED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAkB/D;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Agent Relay core (`agent-relay-
|
|
2
|
+
* The Agent Relay core (`agent-relay-node`): the per-user daemon that finds
|
|
3
3
|
* the coding-agent sessions running on this machine and injects Relay
|
|
4
4
|
* messages into them through each tool's own route (Claude Code's session
|
|
5
5
|
* inbox, Codex hooks and queue, the OpenCode and Pi plugins, Devin and Cursor
|
|
6
|
-
* hooks, Grok's leader socket). `relay init` installs it from a `
|
|
6
|
+
* hooks, Grok's leader socket). `relay init` installs it from a `v<CLI version>`
|
|
7
7
|
* GitHub release of this repository, runs it in the background, and turns on
|
|
8
8
|
* the core's delivery settings for the agent tools the person picked.
|
|
9
9
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* `relay init` started. A running core is always attached to, never doubled.
|
|
12
12
|
* Its bridge is JSON-RPC 2.0 over NDJSON on `~/.agentworkforce/desktop/core.sock`
|
|
13
13
|
* (`AGENT_RELAY_CORE_SOCKET` moves it; on Windows a named pipe derived from
|
|
14
|
-
* that path), see crates/
|
|
14
|
+
* that path), see crates/relay-node/docs/relay-core.md.
|
|
15
15
|
*/
|
|
16
16
|
import { execFileSync, spawn } from 'node:child_process';
|
|
17
17
|
import { createHash } from 'node:crypto';
|
|
@@ -19,12 +19,8 @@ import fs from 'node:fs';
|
|
|
19
19
|
import net from 'node:net';
|
|
20
20
|
import path from 'node:path';
|
|
21
21
|
import { relaySkillRecordOf } from './relay-skill.js';
|
|
22
|
-
/** The core `relay init` installs. Pinned so every machine runs the same core. */
|
|
23
|
-
export const PROBE_VERSION = '15.0.9';
|
|
24
|
-
/** Release tags of the core; distinct from the CLI's `v*` tags. */
|
|
25
|
-
export const PROBE_TAG_PREFIX = 'probe-v';
|
|
26
22
|
const RELEASE_BASE = 'https://github.com/AgentWorkforce/relay/releases/download';
|
|
27
|
-
/** The bridge version this client speaks (`crates/
|
|
23
|
+
/** The bridge version this client speaks (`crates/relay-node/src/relay/protocol.rs`). */
|
|
28
24
|
export const BRIDGE_VERSION = 2;
|
|
29
25
|
/** Moves the core's bridge socket, for the core and its clients alike. */
|
|
30
26
|
export const CORE_SOCKET_ENV = 'AGENT_RELAY_CORE_SOCKET';
|
|
@@ -35,20 +31,20 @@ const CALL_TIMEOUT_MS = 15_000;
|
|
|
35
31
|
* The release asset of the core for a platform, or undefined when none is published.
|
|
36
32
|
* @param version - Core version, e.g. `15.0.0`
|
|
37
33
|
* @param target - Platform, architecture and libc
|
|
38
|
-
* @returns e.g. `agent-relay-
|
|
34
|
+
* @returns e.g. `agent-relay-node-15.0.0-linux-x64`
|
|
39
35
|
*/
|
|
40
|
-
export function
|
|
36
|
+
export function relayNodeAssetName(version, target) {
|
|
41
37
|
const arch = target.arch === 'x64' || target.arch === 'arm64' ? target.arch : undefined;
|
|
42
38
|
if (!arch)
|
|
43
39
|
return undefined;
|
|
44
40
|
switch (target.platform) {
|
|
45
41
|
case 'darwin':
|
|
46
|
-
return `agent-relay-
|
|
42
|
+
return `agent-relay-node-${version}-darwin-${arch}`;
|
|
47
43
|
case 'linux':
|
|
48
44
|
// Built against glibc; there is no musl build.
|
|
49
|
-
return target.musl ? undefined : `agent-relay-
|
|
45
|
+
return target.musl ? undefined : `agent-relay-node-${version}-linux-${arch}`;
|
|
50
46
|
case 'win32':
|
|
51
|
-
return arch === 'x64' ? `agent-relay-
|
|
47
|
+
return arch === 'x64' ? `agent-relay-node-${version}-windows-x64.exe` : undefined;
|
|
52
48
|
default:
|
|
53
49
|
return undefined;
|
|
54
50
|
}
|
|
@@ -56,11 +52,11 @@ export function probeAssetName(version, target) {
|
|
|
56
52
|
/**
|
|
57
53
|
* Where a release asset of the core downloads from.
|
|
58
54
|
* @param version - Core version
|
|
59
|
-
* @param asset - Asset name from {@link
|
|
55
|
+
* @param asset - Asset name from {@link relayNodeAssetName}
|
|
60
56
|
* @returns The GitHub release download URL; the checksum is at `<url>.sha256`
|
|
61
57
|
*/
|
|
62
|
-
export function
|
|
63
|
-
return `${RELEASE_BASE}
|
|
58
|
+
export function relayNodeAssetUrl(version, asset) {
|
|
59
|
+
return `${RELEASE_BASE}/v${version}/${asset}`;
|
|
64
60
|
}
|
|
65
61
|
/**
|
|
66
62
|
* The core's bridge socket, resolved as the core resolves it: an absolute
|
|
@@ -241,23 +237,23 @@ export async function connectCore(socket, timeoutMs = CALL_TIMEOUT_MS) {
|
|
|
241
237
|
}
|
|
242
238
|
return client;
|
|
243
239
|
}
|
|
244
|
-
/** `agent-relay-
|
|
245
|
-
const
|
|
240
|
+
/** `agent-relay-node --version` prints exactly this: clap's `<name> <version>`. */
|
|
241
|
+
const RELAY_NODE_VERSION_LINE = /^agent-relay-node (\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/;
|
|
246
242
|
/**
|
|
247
|
-
* The version an `agent-relay-
|
|
243
|
+
* The version an `agent-relay-node` binary reports for `--version`. Only
|
|
248
244
|
* the core's own one-line answer counts, so another program that happens to
|
|
249
245
|
* print a version is not taken for the core.
|
|
250
246
|
* @param binary - Path to the binary
|
|
251
247
|
* @returns e.g. `15.0.0`, or undefined when it is not the core or does not run
|
|
252
248
|
*/
|
|
253
|
-
export function
|
|
249
|
+
export function readRelayNodeVersion(binary) {
|
|
254
250
|
try {
|
|
255
251
|
const out = execFileSync(binary, ['--version'], {
|
|
256
252
|
encoding: 'utf8',
|
|
257
253
|
timeout: 10_000,
|
|
258
254
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
259
255
|
});
|
|
260
|
-
return
|
|
256
|
+
return RELAY_NODE_VERSION_LINE.exec(out.trim())?.[1];
|
|
261
257
|
}
|
|
262
258
|
catch {
|
|
263
259
|
return undefined;
|
|
@@ -272,7 +268,7 @@ export function readProbeVersion(binary) {
|
|
|
272
268
|
export function startCoreProcess({ binary, socket, logFile, }) {
|
|
273
269
|
const log = fs.openSync(logFile, 'a', 0o600);
|
|
274
270
|
try {
|
|
275
|
-
const child = spawn(binary, ['
|
|
271
|
+
const child = spawn(binary, ['serve', '--headless', '--cli-managed', '--socket', socket], {
|
|
276
272
|
detached: true,
|
|
277
273
|
stdio: ['ignore', log, log],
|
|
278
274
|
env: process.env,
|
|
@@ -294,7 +290,7 @@ const setting = (key, read = key) => ({ write: key, read });
|
|
|
294
290
|
/** Sessions of every supported tool join Relay on their own. */
|
|
295
291
|
export const AUTO_ACTIVATE = setting('auto_activate');
|
|
296
292
|
/** How the core injects into each tool, and the settings that turn it on. */
|
|
297
|
-
export const
|
|
293
|
+
export const CORE_DELIVERY = {
|
|
298
294
|
claude: {
|
|
299
295
|
// `direct_delivery_default` sets crossSessionInbound to accept only when
|
|
300
296
|
// the person has not chosen a value themselves.
|
|
@@ -337,7 +333,7 @@ export const PROBE_DELIVERY = {
|
|
|
337
333
|
* @returns e.g. `['direct_delivery', 'claude_session_hook']` for Claude Code
|
|
338
334
|
*/
|
|
339
335
|
export function deliveryKeys(id) {
|
|
340
|
-
return
|
|
336
|
+
return CORE_DELIVERY[id].settings.map((s) => s.read);
|
|
341
337
|
}
|
|
342
338
|
/**
|
|
343
339
|
* Turn on the core's delivery for each tool, then automatic activation. A
|
|
@@ -398,7 +394,7 @@ export async function enableDelivery(client, tools, owned = []) {
|
|
|
398
394
|
};
|
|
399
395
|
const results = [];
|
|
400
396
|
for (const id of tools) {
|
|
401
|
-
const { settings, route } =
|
|
397
|
+
const { settings, route } = CORE_DELIVERY[id];
|
|
402
398
|
let failure;
|
|
403
399
|
for (const s of settings) {
|
|
404
400
|
failure = await turnOn(s);
|
|
@@ -581,4 +577,4 @@ export function readDeliveryRecord(file) {
|
|
|
581
577
|
export function readTurnedOn(file) {
|
|
582
578
|
return readDeliveryRecord(file).turnedOn;
|
|
583
579
|
}
|
|
584
|
-
//# sourceMappingURL=
|
|
580
|
+
//# sourceMappingURL=relay-node.js.map
|