agent-relay 10.6.6 → 10.6.7
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/lib/project-workspace-key.d.ts +1 -21
- package/dist/cli/lib/project-workspace-key.d.ts.map +1 -1
- package/dist/cli/lib/project-workspace-key.js +3 -83
- package/dist/cli/lib/project-workspace-key.js.map +1 -1
- package/dist/cli/lib/sdk-client.d.ts +2 -1
- package/dist/cli/lib/sdk-client.d.ts.map +1 -1
- package/dist/cli/lib/sdk-client.js +7 -29
- package/dist/cli/lib/sdk-client.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function projectWorkspaceKeyPath(dataDir: string): string;
|
|
3
|
-
/**
|
|
4
|
-
* Read the workspace key recorded for this project's data dir. A missing or
|
|
5
|
-
* malformed file (or a blank key) reads as `undefined` — the caller falls
|
|
6
|
-
* through to the next resolution source rather than failing.
|
|
7
|
-
*/
|
|
8
|
-
export declare function readProjectWorkspaceKey(dataDir: string): string | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Persist the workspace key for this project's data dir with owner-only
|
|
11
|
-
* permissions (matching `connection.json`). A blank key is ignored so a broker
|
|
12
|
-
* that never resolved a key does not clobber a previously recorded one.
|
|
13
|
-
*
|
|
14
|
-
* The write is atomic and symlink-safe: the payload is written to a fresh,
|
|
15
|
-
* exclusively-created temp file (so a pre-planted symlink at the temp path
|
|
16
|
-
* cannot redirect it) and then `rename`d over the destination. `rename` never
|
|
17
|
-
* follows a symlink at the destination and is atomic on POSIX, so a concurrent
|
|
18
|
-
* reader sees either the old or the new complete file — never a truncated one,
|
|
19
|
-
* and never an attacker-chosen target.
|
|
20
|
-
*/
|
|
21
|
-
export declare function writeProjectWorkspaceKey(dataDir: string, workspaceKey: string | undefined): void;
|
|
1
|
+
export { projectWorkspaceKeyPath, readProjectWorkspaceKey, writeProjectWorkspaceKey, } from '@agent-relay/cloud/workspace-key';
|
|
22
2
|
//# sourceMappingURL=project-workspace-key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-workspace-key.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/project-workspace-key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project-workspace-key.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/project-workspace-key.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,84 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Project-local record of the workspace key the broker in this directory was
|
|
5
|
-
* started with. `agent-relay up` writes it into the project data dir
|
|
6
|
-
* (`.agentworkforce/relay/`, the same git-excluded directory that holds
|
|
7
|
-
* `connection.json`) so that later SDK-backed commands run in the same CWD
|
|
8
|
-
* (`fleet nodes`, `node …`, etc.) resolve the workspace the local broker
|
|
9
|
-
* actually joined — rather than falling through to the machine-global active
|
|
10
|
-
* workspace, which may point at a different workspace.
|
|
11
|
-
*/
|
|
12
|
-
const PROJECT_WORKSPACE_KEY_FILENAME = 'workspace-key.json';
|
|
13
|
-
/** Absolute path to the project-local workspace-key file within `dataDir`. */
|
|
14
|
-
export function projectWorkspaceKeyPath(dataDir) {
|
|
15
|
-
return path.join(dataDir, PROJECT_WORKSPACE_KEY_FILENAME);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Read the workspace key recorded for this project's data dir. A missing or
|
|
19
|
-
* malformed file (or a blank key) reads as `undefined` — the caller falls
|
|
20
|
-
* through to the next resolution source rather than failing.
|
|
21
|
-
*/
|
|
22
|
-
export function readProjectWorkspaceKey(dataDir) {
|
|
23
|
-
try {
|
|
24
|
-
const raw = fs.readFileSync(projectWorkspaceKeyPath(dataDir), 'utf-8');
|
|
25
|
-
const parsed = JSON.parse(raw);
|
|
26
|
-
const key = typeof parsed.workspaceKey === 'string' ? parsed.workspaceKey.trim() : '';
|
|
27
|
-
return key || undefined;
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Persist the workspace key for this project's data dir with owner-only
|
|
35
|
-
* permissions (matching `connection.json`). A blank key is ignored so a broker
|
|
36
|
-
* that never resolved a key does not clobber a previously recorded one.
|
|
37
|
-
*
|
|
38
|
-
* The write is atomic and symlink-safe: the payload is written to a fresh,
|
|
39
|
-
* exclusively-created temp file (so a pre-planted symlink at the temp path
|
|
40
|
-
* cannot redirect it) and then `rename`d over the destination. `rename` never
|
|
41
|
-
* follows a symlink at the destination and is atomic on POSIX, so a concurrent
|
|
42
|
-
* reader sees either the old or the new complete file — never a truncated one,
|
|
43
|
-
* and never an attacker-chosen target.
|
|
44
|
-
*/
|
|
45
|
-
export function writeProjectWorkspaceKey(dataDir, workspaceKey) {
|
|
46
|
-
const key = workspaceKey?.trim();
|
|
47
|
-
if (!key)
|
|
48
|
-
return;
|
|
49
|
-
fs.mkdirSync(dataDir, { recursive: true, mode: 0o700 });
|
|
50
|
-
const file = projectWorkspaceKeyPath(dataDir);
|
|
51
|
-
const tmp = `${file}.tmp.${process.pid}`;
|
|
52
|
-
const payload = { workspaceKey: key };
|
|
53
|
-
const data = `${JSON.stringify(payload, null, 2)}\n`;
|
|
54
|
-
// 'wx' == O_CREAT | O_EXCL: create a brand-new regular file, failing (rather
|
|
55
|
-
// than following a symlink or truncating an existing file) if anything is
|
|
56
|
-
// already at the temp path. A stale temp from a crashed run is removed first.
|
|
57
|
-
let fd;
|
|
58
|
-
try {
|
|
59
|
-
fd = fs.openSync(tmp, 'wx', 0o600);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
if (err.code !== 'EEXIST')
|
|
63
|
-
throw err;
|
|
64
|
-
fs.rmSync(tmp, { force: true });
|
|
65
|
-
fd = fs.openSync(tmp, 'wx', 0o600);
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
try {
|
|
69
|
-
fs.writeSync(fd, data);
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
fs.closeSync(fd);
|
|
73
|
-
}
|
|
74
|
-
// openSync's mode is masked by umask; enforce owner-only before publishing.
|
|
75
|
-
fs.chmodSync(tmp, 0o600);
|
|
76
|
-
fs.renameSync(tmp, file);
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
// Never leave a partial temp file behind, whichever step failed.
|
|
80
|
-
fs.rmSync(tmp, { force: true });
|
|
81
|
-
throw err;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
1
|
+
// Compatibility re-export for existing CLI-local imports. The public cloud
|
|
2
|
+
// package owns this contract so SDK consumers and the CLI cannot drift.
|
|
3
|
+
export { projectWorkspaceKeyPath, readProjectWorkspaceKey, writeProjectWorkspaceKey, } from '@agent-relay/cloud/workspace-key';
|
|
84
4
|
//# sourceMappingURL=project-workspace-key.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-workspace-key.js","sourceRoot":"","sources":["../../../src/cli/lib/project-workspace-key.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"project-workspace-key.js","sourceRoot":"","sources":["../../../src/cli/lib/project-workspace-key.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentRelay, type AgentRelayAgent } from '@agent-relay/sdk';
|
|
2
|
+
import { type WorkspaceKeySource } from '@agent-relay/cloud/workspace-key';
|
|
2
3
|
/** Options shared by the SDK-backed (Relaycast) CLI command groups. */
|
|
3
4
|
export interface SdkClientOptions {
|
|
4
5
|
workspaceKey?: string;
|
|
@@ -7,7 +8,7 @@ export interface SdkClientOptions {
|
|
|
7
8
|
env?: NodeJS.ProcessEnv;
|
|
8
9
|
}
|
|
9
10
|
/** Where a resolved workspace key came from, in precedence order. */
|
|
10
|
-
export type WorkspaceKeySource
|
|
11
|
+
export type { WorkspaceKeySource };
|
|
11
12
|
/**
|
|
12
13
|
* Resolve the workspace key and report which source it came from. Precedence:
|
|
13
14
|
* explicit flag → `RELAY_WORKSPACE_KEY`/`RELAY_API_KEY` env → the key the local
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-client.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/sdk-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-client.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/sdk-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAE1C,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAWD,qEAAqE;AACrE,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,GAAE,gBAAqB,GAAG;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB,CAAC;CAC5B,CASA;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAE1E;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,GAAG,SAAS,CAEjF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,GAAG,SAAS,CAEpF;AAED,gDAAgD;AAChD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,gBAAqB,GAAG,UAAU,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,gBAAqB,GAAG,eAAe,CAOhF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AgentRelay } from '@agent-relay/sdk';
|
|
2
|
-
import {
|
|
3
|
-
import { activeWorkspaceKey } from './workspace-store.js';
|
|
4
|
-
import { readProjectWorkspaceKey } from './project-workspace-key.js';
|
|
2
|
+
import { resolveWorkspaceKeyWithSource as resolveCloudWorkspaceKeyWithSource, } from '@agent-relay/cloud/workspace-key';
|
|
5
3
|
function env(options) {
|
|
6
4
|
return options.env ?? process.env;
|
|
7
5
|
}
|
|
@@ -17,37 +15,17 @@ function trimOrUndefined(value) {
|
|
|
17
15
|
* project broker rather than named explicitly.
|
|
18
16
|
*/
|
|
19
17
|
export function resolveWorkspaceKeyWithSource(options = {}) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return { key: envKey, source: 'env' };
|
|
27
|
-
const project = trimOrUndefined(projectWorkspaceKey());
|
|
28
|
-
if (project)
|
|
29
|
-
return { key: project, source: 'project' };
|
|
30
|
-
const store = trimOrUndefined(activeWorkspaceKey(e));
|
|
31
|
-
if (store)
|
|
32
|
-
return { key: store, source: 'store' };
|
|
18
|
+
const resolved = resolveCloudWorkspaceKeyWithSource({
|
|
19
|
+
workspaceKey: options.workspaceKey,
|
|
20
|
+
env: env(options),
|
|
21
|
+
});
|
|
22
|
+
if (resolved)
|
|
23
|
+
return resolved;
|
|
33
24
|
throw new Error('No workspace key found. Pass --workspace-key, set RELAY_WORKSPACE_KEY, or run `relay workspace set_key <name> <key>`.');
|
|
34
25
|
}
|
|
35
26
|
export function resolveWorkspaceKey(options = {}) {
|
|
36
27
|
return resolveWorkspaceKeyWithSource(options).key;
|
|
37
28
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Read the workspace key recorded by `relay up` for the current project
|
|
40
|
-
* directory, or `undefined` when there is none / the project root cannot be
|
|
41
|
-
* resolved. Never throws — a resolution failure just falls through.
|
|
42
|
-
*/
|
|
43
|
-
function projectWorkspaceKey() {
|
|
44
|
-
try {
|
|
45
|
-
return readProjectWorkspaceKey(getProjectPaths().dataDir);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
29
|
export function resolveBaseUrl(options = {}) {
|
|
52
30
|
return trimOrUndefined(options.baseUrl) ?? trimOrUndefined(env(options).RELAY_BASE_URL);
|
|
53
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-client.js","sourceRoot":"","sources":["../../../src/cli/lib/sdk-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk-client.js","sourceRoot":"","sources":["../../../src/cli/lib/sdk-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,6BAA6B,IAAI,kCAAkC,GAEpE,MAAM,kCAAkC,CAAC;AAU1C,SAAS,GAAG,CAAC,OAAyB;IACpC,OAAO,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;AACpC,CAAC;AAED,SAAS,eAAe,CAAC,KAAyB;IAChD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACvC,CAAC;AAKD;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAAC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AAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay",
|
|
3
|
-
"version": "10.6.
|
|
3
|
+
"version": "10.6.7",
|
|
4
4
|
"description": "Real-time agent-to-agent communication system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"pack:validate": "npm pack --dry-run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@agent-relay/cloud": "10.6.
|
|
47
|
-
"@agent-relay/config": "10.6.
|
|
48
|
-
"@agent-relay/fleet": "10.6.
|
|
49
|
-
"@agent-relay/harness-driver": "10.6.
|
|
50
|
-
"@agent-relay/sdk": "10.6.
|
|
51
|
-
"@agent-relay/utils": "10.6.
|
|
46
|
+
"@agent-relay/cloud": "10.6.7",
|
|
47
|
+
"@agent-relay/config": "10.6.7",
|
|
48
|
+
"@agent-relay/fleet": "10.6.7",
|
|
49
|
+
"@agent-relay/harness-driver": "10.6.7",
|
|
50
|
+
"@agent-relay/sdk": "10.6.7",
|
|
51
|
+
"@agent-relay/utils": "10.6.7",
|
|
52
52
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
53
53
|
"@relayfile/client": "^0.10.27",
|
|
54
54
|
"@relayflows/cli": "^1.0.1",
|