@agent-relay/config 0.1.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/agent-config.d.ts +47 -0
- package/dist/agent-config.d.ts.map +1 -0
- package/dist/agent-config.js +119 -0
- package/dist/agent-config.js.map +1 -0
- package/dist/bridge-config.d.ts +52 -0
- package/dist/bridge-config.d.ts.map +1 -0
- package/dist/bridge-config.js +143 -0
- package/dist/bridge-config.js.map +1 -0
- package/dist/bridge-utils.d.ts +30 -0
- package/dist/bridge-utils.d.ts.map +1 -0
- package/dist/bridge-utils.js +54 -0
- package/dist/bridge-utils.js.map +1 -0
- package/dist/cli-auth-config.d.ts +110 -0
- package/dist/cli-auth-config.d.ts.map +1 -0
- package/dist/cli-auth-config.js +391 -0
- package/dist/cli-auth-config.js.map +1 -0
- package/dist/cloud-config.d.ts +75 -0
- package/dist/cloud-config.d.ts.map +1 -0
- package/dist/cloud-config.js +109 -0
- package/dist/cloud-config.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/project-namespace.d.ts +73 -0
- package/dist/project-namespace.d.ts.map +1 -0
- package/dist/project-namespace.js +280 -0
- package/dist/project-namespace.js.map +1 -0
- package/dist/relay-config.d.ts +25 -0
- package/dist/relay-config.d.ts.map +1 -0
- package/dist/relay-config.js +25 -0
- package/dist/relay-config.js.map +1 -0
- package/dist/relay-file-writer.d.ts +200 -0
- package/dist/relay-file-writer.d.ts.map +1 -0
- package/dist/relay-file-writer.js +407 -0
- package/dist/relay-file-writer.js.map +1 -0
- package/dist/schemas.d.ts +672 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +180 -0
- package/dist/schemas.js.map +1 -0
- package/dist/shadow-config.d.ts +87 -0
- package/dist/shadow-config.d.ts.map +1 -0
- package/dist/shadow-config.js +134 -0
- package/dist/shadow-config.js.map +1 -0
- package/dist/teams-config.d.ts +47 -0
- package/dist/teams-config.d.ts.map +1 -0
- package/dist/teams-config.js +100 -0
- package/dist/teams-config.js.map +1 -0
- package/dist/trajectory-config.d.ts +102 -0
- package/dist/trajectory-config.d.ts.map +1 -0
- package/dist/trajectory-config.js +185 -0
- package/dist/trajectory-config.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Namespace Utility
|
|
3
|
+
*
|
|
4
|
+
* Generates project-specific paths for agent-relay data storage.
|
|
5
|
+
* Data is stored in .agent-relay/ within the project root directory.
|
|
6
|
+
* This allows multiple projects to use agent-relay simultaneously
|
|
7
|
+
* without conflicts, and keeps data with the project.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Get the project root by looking for common markers
|
|
11
|
+
*/
|
|
12
|
+
export declare function findProjectRoot(startDir?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get namespaced paths for a project
|
|
15
|
+
*/
|
|
16
|
+
export interface ProjectPaths {
|
|
17
|
+
/** Root directory for all agent-relay data for this project */
|
|
18
|
+
dataDir: string;
|
|
19
|
+
/** Team data directory */
|
|
20
|
+
teamDir: string;
|
|
21
|
+
/** SQLite database path */
|
|
22
|
+
dbPath: string;
|
|
23
|
+
/** Unix socket path */
|
|
24
|
+
socketPath: string;
|
|
25
|
+
/** The project root that was used */
|
|
26
|
+
projectRoot: string;
|
|
27
|
+
/** Short identifier for the project */
|
|
28
|
+
projectId: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function getProjectPaths(projectRoot?: string): ProjectPaths;
|
|
31
|
+
/**
|
|
32
|
+
* Get the default paths (for backwards compatibility or explicit global usage)
|
|
33
|
+
*/
|
|
34
|
+
export declare function getGlobalPaths(): ProjectPaths;
|
|
35
|
+
/**
|
|
36
|
+
* Ensure the project data directory exists
|
|
37
|
+
*/
|
|
38
|
+
export declare function ensureProjectDir(projectRoot?: string): ProjectPaths;
|
|
39
|
+
/**
|
|
40
|
+
* List all known projects (scans global base dir for legacy data)
|
|
41
|
+
* Note: With project-local storage, this only finds projects that
|
|
42
|
+
* used the old global storage location.
|
|
43
|
+
*/
|
|
44
|
+
export declare function listProjects(): Array<{
|
|
45
|
+
projectId: string;
|
|
46
|
+
projectRoot: string;
|
|
47
|
+
dataDir: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Detect the actual workspace directory for cloud deployments.
|
|
51
|
+
*
|
|
52
|
+
* In cloud workspaces, repos are cloned to /workspace/{repo-name}.
|
|
53
|
+
* This function finds the correct working directory:
|
|
54
|
+
*
|
|
55
|
+
* Priority:
|
|
56
|
+
* 1. WORKSPACE_CWD env var (explicit override)
|
|
57
|
+
* 2. If baseDir itself is a git repo, use it
|
|
58
|
+
* 3. Scan baseDir for cloned repos - use the first one found (alphabetically)
|
|
59
|
+
* 4. Fall back to baseDir
|
|
60
|
+
*
|
|
61
|
+
* @param baseDir - The base workspace directory (e.g., /workspace)
|
|
62
|
+
* @returns The actual workspace path to use
|
|
63
|
+
*/
|
|
64
|
+
export declare function detectWorkspacePath(baseDir: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* List all git repos in a workspace directory.
|
|
67
|
+
* Useful for allowing users to select which repo to work in.
|
|
68
|
+
*
|
|
69
|
+
* @param baseDir - The base workspace directory
|
|
70
|
+
* @returns Array of repo paths
|
|
71
|
+
*/
|
|
72
|
+
export declare function listWorkspaceRepos(baseDir: string): string[];
|
|
73
|
+
//# sourceMappingURL=project-namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-namespace.d.ts","sourceRoot":"","sources":["../src/project-namespace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA4CH;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,GAAE,MAAsB,GAAG,MAAM,CAiBxE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAclE;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,YAAY,CAS7C;AA0DD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CA4BnE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BjG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA6C3D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAsB5D"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Namespace Utility
|
|
3
|
+
*
|
|
4
|
+
* Generates project-specific paths for agent-relay data storage.
|
|
5
|
+
* Data is stored in .agent-relay/ within the project root directory.
|
|
6
|
+
* This allows multiple projects to use agent-relay simultaneously
|
|
7
|
+
* without conflicts, and keeps data with the project.
|
|
8
|
+
*/
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
/**
|
|
14
|
+
* Get the global base directory for agent-relay data (used for cross-project data).
|
|
15
|
+
* Priority:
|
|
16
|
+
* 1. AGENT_RELAY_DATA_DIR environment variable
|
|
17
|
+
* 2. XDG_DATA_HOME/agent-relay (Linux/macOS standard)
|
|
18
|
+
* 3. ~/.agent-relay (fallback)
|
|
19
|
+
*/
|
|
20
|
+
function getGlobalBaseDir() {
|
|
21
|
+
// Explicit override
|
|
22
|
+
if (process.env.AGENT_RELAY_DATA_DIR) {
|
|
23
|
+
return process.env.AGENT_RELAY_DATA_DIR;
|
|
24
|
+
}
|
|
25
|
+
// XDG Base Directory Specification
|
|
26
|
+
const xdgDataHome = process.env.XDG_DATA_HOME;
|
|
27
|
+
if (xdgDataHome) {
|
|
28
|
+
return path.join(xdgDataHome, 'agent-relay');
|
|
29
|
+
}
|
|
30
|
+
// Default: ~/.agent-relay
|
|
31
|
+
return path.join(os.homedir(), '.agent-relay');
|
|
32
|
+
}
|
|
33
|
+
const GLOBAL_BASE_DIR = getGlobalBaseDir();
|
|
34
|
+
/** Directory name within project root */
|
|
35
|
+
const PROJECT_DATA_DIR = '.agent-relay';
|
|
36
|
+
/**
|
|
37
|
+
* Generate a short hash of a path for namespacing
|
|
38
|
+
*/
|
|
39
|
+
function hashPath(projectPath) {
|
|
40
|
+
const normalized = path.resolve(projectPath);
|
|
41
|
+
const hash = crypto.createHash('sha256').update(normalized).digest('hex');
|
|
42
|
+
return hash.substring(0, 12); // First 12 chars is enough
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the project root by looking for common markers
|
|
46
|
+
*/
|
|
47
|
+
export function findProjectRoot(startDir = process.cwd()) {
|
|
48
|
+
let current = path.resolve(startDir);
|
|
49
|
+
const root = path.parse(current).root;
|
|
50
|
+
const markers = ['.git', 'package.json', 'Cargo.toml', 'go.mod', 'pyproject.toml', '.agent-relay'];
|
|
51
|
+
while (current !== root) {
|
|
52
|
+
for (const marker of markers) {
|
|
53
|
+
if (fs.existsSync(path.join(current, marker))) {
|
|
54
|
+
return current;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
current = path.dirname(current);
|
|
58
|
+
}
|
|
59
|
+
// Fallback to start directory
|
|
60
|
+
return path.resolve(startDir);
|
|
61
|
+
}
|
|
62
|
+
export function getProjectPaths(projectRoot) {
|
|
63
|
+
const root = projectRoot ?? findProjectRoot();
|
|
64
|
+
const projectId = hashPath(root);
|
|
65
|
+
// Store data in project-local .agent-relay/ directory
|
|
66
|
+
const dataDir = path.join(root, PROJECT_DATA_DIR);
|
|
67
|
+
return {
|
|
68
|
+
dataDir,
|
|
69
|
+
teamDir: path.join(dataDir, 'team'),
|
|
70
|
+
dbPath: path.join(dataDir, 'messages.sqlite'),
|
|
71
|
+
socketPath: path.join(dataDir, 'relay.sock'),
|
|
72
|
+
projectRoot: root,
|
|
73
|
+
projectId,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the default paths (for backwards compatibility or explicit global usage)
|
|
78
|
+
*/
|
|
79
|
+
export function getGlobalPaths() {
|
|
80
|
+
return {
|
|
81
|
+
dataDir: GLOBAL_BASE_DIR,
|
|
82
|
+
teamDir: path.join(GLOBAL_BASE_DIR, 'team'),
|
|
83
|
+
dbPath: path.join(GLOBAL_BASE_DIR, 'messages.sqlite'),
|
|
84
|
+
socketPath: path.join(GLOBAL_BASE_DIR, 'relay.sock'),
|
|
85
|
+
projectRoot: process.cwd(),
|
|
86
|
+
projectId: 'global',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Add .agent-relay/ to .git/info/exclude (local per-repo gitignore).
|
|
91
|
+
*
|
|
92
|
+
* This file is:
|
|
93
|
+
* - Per-repository (not shared across clones)
|
|
94
|
+
* - Not committed (local to each developer)
|
|
95
|
+
* - Standard git feature with no permission issues
|
|
96
|
+
* - No branch/merge complications
|
|
97
|
+
*
|
|
98
|
+
* Returns true if the exclude file was modified
|
|
99
|
+
*/
|
|
100
|
+
function ensureGitExclude(projectRoot) {
|
|
101
|
+
// Find the .git directory (could be in projectRoot or a parent for worktrees)
|
|
102
|
+
const gitDir = path.join(projectRoot, '.git');
|
|
103
|
+
const excludePath = path.join(gitDir, 'info', 'exclude');
|
|
104
|
+
try {
|
|
105
|
+
// Check if this is a git repository
|
|
106
|
+
if (!fs.existsSync(gitDir)) {
|
|
107
|
+
return { modified: false };
|
|
108
|
+
}
|
|
109
|
+
// Ensure .git/info directory exists
|
|
110
|
+
const infoDir = path.join(gitDir, 'info');
|
|
111
|
+
if (!fs.existsSync(infoDir)) {
|
|
112
|
+
fs.mkdirSync(infoDir, { recursive: true });
|
|
113
|
+
}
|
|
114
|
+
let content = '';
|
|
115
|
+
if (fs.existsSync(excludePath)) {
|
|
116
|
+
content = fs.readFileSync(excludePath, 'utf-8');
|
|
117
|
+
// Check if .agent-relay is already in exclude
|
|
118
|
+
const lines = content.split('\n');
|
|
119
|
+
const hasEntry = lines.some(line => {
|
|
120
|
+
const trimmed = line.trim();
|
|
121
|
+
return trimmed === '.agent-relay' || trimmed === '.agent-relay/' || trimmed === '/.agent-relay' || trimmed === '/.agent-relay/';
|
|
122
|
+
});
|
|
123
|
+
if (hasEntry) {
|
|
124
|
+
return { modified: false }; // Already present
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Add .agent-relay/ to exclude
|
|
128
|
+
const newEntry = '.agent-relay/';
|
|
129
|
+
const newContent = content.endsWith('\n') || content === ''
|
|
130
|
+
? `${content}${newEntry}\n`
|
|
131
|
+
: `${content}\n${newEntry}\n`;
|
|
132
|
+
fs.writeFileSync(excludePath, newContent, 'utf-8');
|
|
133
|
+
return { modified: true };
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Silently ignore errors (not a git repo, no write permission, etc.)
|
|
137
|
+
return { modified: false };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Ensure the project data directory exists
|
|
142
|
+
*/
|
|
143
|
+
export function ensureProjectDir(projectRoot) {
|
|
144
|
+
const paths = getProjectPaths(projectRoot);
|
|
145
|
+
// Auto-add to .gitignore on first creation
|
|
146
|
+
const isFirstCreation = !fs.existsSync(paths.dataDir);
|
|
147
|
+
if (isFirstCreation) {
|
|
148
|
+
fs.mkdirSync(paths.dataDir, { recursive: true });
|
|
149
|
+
// Add to .git/info/exclude (local per-repo gitignore, not committed)
|
|
150
|
+
const excludeResult = ensureGitExclude(paths.projectRoot);
|
|
151
|
+
if (excludeResult.modified) {
|
|
152
|
+
console.log('[agent-relay] Added .agent-relay/ to .git/info/exclude');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!fs.existsSync(paths.teamDir)) {
|
|
156
|
+
fs.mkdirSync(paths.teamDir, { recursive: true });
|
|
157
|
+
}
|
|
158
|
+
// Write a marker file with project info
|
|
159
|
+
const markerPath = path.join(paths.dataDir, '.project');
|
|
160
|
+
fs.writeFileSync(markerPath, JSON.stringify({
|
|
161
|
+
projectRoot: paths.projectRoot,
|
|
162
|
+
projectId: paths.projectId,
|
|
163
|
+
createdAt: new Date().toISOString(),
|
|
164
|
+
}, null, 2));
|
|
165
|
+
return paths;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* List all known projects (scans global base dir for legacy data)
|
|
169
|
+
* Note: With project-local storage, this only finds projects that
|
|
170
|
+
* used the old global storage location.
|
|
171
|
+
*/
|
|
172
|
+
export function listProjects() {
|
|
173
|
+
if (!fs.existsSync(GLOBAL_BASE_DIR)) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
const projects = [];
|
|
177
|
+
for (const entry of fs.readdirSync(GLOBAL_BASE_DIR)) {
|
|
178
|
+
const dataDir = path.join(GLOBAL_BASE_DIR, entry);
|
|
179
|
+
const markerPath = path.join(dataDir, '.project');
|
|
180
|
+
if (fs.existsSync(markerPath)) {
|
|
181
|
+
try {
|
|
182
|
+
const info = JSON.parse(fs.readFileSync(markerPath, 'utf-8'));
|
|
183
|
+
projects.push({
|
|
184
|
+
projectId: entry,
|
|
185
|
+
projectRoot: info.projectRoot,
|
|
186
|
+
dataDir,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// Invalid marker, skip
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return projects;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Detect the actual workspace directory for cloud deployments.
|
|
198
|
+
*
|
|
199
|
+
* In cloud workspaces, repos are cloned to /workspace/{repo-name}.
|
|
200
|
+
* This function finds the correct working directory:
|
|
201
|
+
*
|
|
202
|
+
* Priority:
|
|
203
|
+
* 1. WORKSPACE_CWD env var (explicit override)
|
|
204
|
+
* 2. If baseDir itself is a git repo, use it
|
|
205
|
+
* 3. Scan baseDir for cloned repos - use the first one found (alphabetically)
|
|
206
|
+
* 4. Fall back to baseDir
|
|
207
|
+
*
|
|
208
|
+
* @param baseDir - The base workspace directory (e.g., /workspace)
|
|
209
|
+
* @returns The actual workspace path to use
|
|
210
|
+
*/
|
|
211
|
+
export function detectWorkspacePath(baseDir) {
|
|
212
|
+
// 1. Explicit override
|
|
213
|
+
if (process.env.WORKSPACE_CWD) {
|
|
214
|
+
return process.env.WORKSPACE_CWD;
|
|
215
|
+
}
|
|
216
|
+
// 2. Check if baseDir itself is a git repo
|
|
217
|
+
if (fs.existsSync(path.join(baseDir, '.git'))) {
|
|
218
|
+
return baseDir;
|
|
219
|
+
}
|
|
220
|
+
// 3. Scan for cloned repos (directories with .git)
|
|
221
|
+
try {
|
|
222
|
+
const entries = fs.readdirSync(baseDir, { withFileTypes: true });
|
|
223
|
+
const repos = [];
|
|
224
|
+
for (const entry of entries) {
|
|
225
|
+
if (entry.isDirectory()) {
|
|
226
|
+
const repoPath = path.join(baseDir, entry.name);
|
|
227
|
+
const gitPath = path.join(repoPath, '.git');
|
|
228
|
+
if (fs.existsSync(gitPath)) {
|
|
229
|
+
repos.push(repoPath);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Sort alphabetically for consistent behavior
|
|
234
|
+
repos.sort();
|
|
235
|
+
// Use the first repo found
|
|
236
|
+
if (repos.length > 0) {
|
|
237
|
+
if (repos.length > 1) {
|
|
238
|
+
console.log(`[workspace] Multiple repos found, using first: ${repos[0]} (others: ${repos.slice(1).join(', ')})`);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
console.log(`[workspace] Detected repo: ${repos[0]}`);
|
|
242
|
+
}
|
|
243
|
+
return repos[0];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
// Failed to scan, fall back
|
|
248
|
+
console.warn(`[workspace] Failed to scan ${baseDir}:`, err);
|
|
249
|
+
}
|
|
250
|
+
// 4. Fall back to baseDir
|
|
251
|
+
return baseDir;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* List all git repos in a workspace directory.
|
|
255
|
+
* Useful for allowing users to select which repo to work in.
|
|
256
|
+
*
|
|
257
|
+
* @param baseDir - The base workspace directory
|
|
258
|
+
* @returns Array of repo paths
|
|
259
|
+
*/
|
|
260
|
+
export function listWorkspaceRepos(baseDir) {
|
|
261
|
+
const repos = [];
|
|
262
|
+
try {
|
|
263
|
+
const entries = fs.readdirSync(baseDir, { withFileTypes: true });
|
|
264
|
+
for (const entry of entries) {
|
|
265
|
+
if (entry.isDirectory()) {
|
|
266
|
+
const repoPath = path.join(baseDir, entry.name);
|
|
267
|
+
const gitPath = path.join(repoPath, '.git');
|
|
268
|
+
if (fs.existsSync(gitPath)) {
|
|
269
|
+
repos.push(repoPath);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
repos.sort();
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Failed to scan
|
|
277
|
+
}
|
|
278
|
+
return repos;
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=project-namespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-namespace.js","sourceRoot":"","sources":["../src/project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,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK,CAAC,IAAI,EAAE,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const DEFAULT_CONNECTION_CONFIG: {
|
|
2
|
+
readonly maxFrameBytes: number;
|
|
3
|
+
readonly heartbeatMs: 5000;
|
|
4
|
+
readonly heartbeatTimeoutMultiplier: 6;
|
|
5
|
+
readonly maxWriteQueueSize: 2000;
|
|
6
|
+
readonly writeQueueHighWaterMark: 1500;
|
|
7
|
+
readonly writeQueueLowWaterMark: 500;
|
|
8
|
+
};
|
|
9
|
+
export declare const DEFAULT_TMUX_WRAPPER_CONFIG: {
|
|
10
|
+
readonly pollInterval: 200;
|
|
11
|
+
readonly idleBeforeInjectMs: 1500;
|
|
12
|
+
readonly injectRetryMs: 500;
|
|
13
|
+
readonly debug: false;
|
|
14
|
+
readonly debugLogIntervalMs: 0;
|
|
15
|
+
readonly mouseMode: true;
|
|
16
|
+
readonly activityIdleThresholdMs: 30000;
|
|
17
|
+
readonly outputStabilityTimeoutMs: 2000;
|
|
18
|
+
readonly outputStabilityPollMs: 200;
|
|
19
|
+
readonly streamLogs: true;
|
|
20
|
+
};
|
|
21
|
+
export declare const DEFAULT_IDLE_BEFORE_INJECT_MS = 1500;
|
|
22
|
+
export declare const DEFAULT_IDLE_CONFIDENCE_THRESHOLD = 0.7;
|
|
23
|
+
/** Default Unix socket path for daemon communication */
|
|
24
|
+
export declare const DEFAULT_SOCKET_PATH = "/tmp/agent-relay.sock";
|
|
25
|
+
//# sourceMappingURL=relay-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-config.d.ts","sourceRoot":"","sources":["../src/relay-config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB;;;;;;;CAO5B,CAAC;AAEX,eAAO,MAAM,2BAA2B;;;;;;;;;;;CAW9B,CAAC;AAEX,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAClD,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAErD,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
2
|
+
maxFrameBytes: 1024 * 1024,
|
|
3
|
+
heartbeatMs: 5000,
|
|
4
|
+
heartbeatTimeoutMultiplier: 6,
|
|
5
|
+
maxWriteQueueSize: 2000,
|
|
6
|
+
writeQueueHighWaterMark: 1500,
|
|
7
|
+
writeQueueLowWaterMark: 500,
|
|
8
|
+
};
|
|
9
|
+
export const DEFAULT_TMUX_WRAPPER_CONFIG = {
|
|
10
|
+
pollInterval: 200,
|
|
11
|
+
idleBeforeInjectMs: 1500,
|
|
12
|
+
injectRetryMs: 500,
|
|
13
|
+
debug: false,
|
|
14
|
+
debugLogIntervalMs: 0,
|
|
15
|
+
mouseMode: true,
|
|
16
|
+
activityIdleThresholdMs: 30_000,
|
|
17
|
+
outputStabilityTimeoutMs: 2000,
|
|
18
|
+
outputStabilityPollMs: 200,
|
|
19
|
+
streamLogs: true,
|
|
20
|
+
};
|
|
21
|
+
export const DEFAULT_IDLE_BEFORE_INJECT_MS = 1500;
|
|
22
|
+
export const DEFAULT_IDLE_CONFIDENCE_THRESHOLD = 0.7;
|
|
23
|
+
/** Default Unix socket path for daemon communication */
|
|
24
|
+
export const DEFAULT_SOCKET_PATH = '/tmp/agent-relay.sock';
|
|
25
|
+
//# sourceMappingURL=relay-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-config.js","sourceRoot":"","sources":["../src/relay-config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,aAAa,EAAE,IAAI,GAAG,IAAI;IAC1B,WAAW,EAAE,IAAI;IACjB,0BAA0B,EAAE,CAAC;IAC7B,iBAAiB,EAAE,IAAI;IACvB,uBAAuB,EAAE,IAAI;IAC7B,sBAAsB,EAAE,GAAG;CACnB,CAAC;AAEX,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,YAAY,EAAE,GAAG;IACjB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,GAAG;IAClB,KAAK,EAAE,KAAK;IACZ,kBAAkB,EAAE,CAAC;IACrB,SAAS,EAAE,IAAI;IACf,uBAAuB,EAAE,MAAM;IAC/B,wBAAwB,EAAE,IAAI;IAC9B,qBAAqB,EAAE,GAAG;IAC1B,UAAU,EAAE,IAAI;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAClD,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AAErD,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay File Writer
|
|
3
|
+
*
|
|
4
|
+
* Provides a clean abstraction for writing relay messages and attachments
|
|
5
|
+
* to the file system with a structured directory layout.
|
|
6
|
+
*
|
|
7
|
+
* Directory structure (project-local):
|
|
8
|
+
* {projectRoot}/.agent-relay/
|
|
9
|
+
* outbox/{agent-name}/ # Agent outbox messages
|
|
10
|
+
* attachments/{agent-name}/{ts}/ # Attachments organized by timestamp
|
|
11
|
+
* meta/ # Configuration and state files
|
|
12
|
+
*
|
|
13
|
+
* For cloud workspaces with WORKSPACE_ID:
|
|
14
|
+
* /tmp/relay/{workspaceId}/
|
|
15
|
+
* outbox/{agent-name}/
|
|
16
|
+
* attachments/{agent-name}/{ts}/
|
|
17
|
+
*
|
|
18
|
+
* Agents should use $AGENT_RELAY_OUTBOX environment variable which is
|
|
19
|
+
* automatically set by the orchestrator to the correct path.
|
|
20
|
+
*/
|
|
21
|
+
export interface RelayPaths {
|
|
22
|
+
/** Root directory for relay data */
|
|
23
|
+
rootDir: string;
|
|
24
|
+
/** Outbox directory for all agents */
|
|
25
|
+
outboxDir: string;
|
|
26
|
+
/** Attachments directory for all agents */
|
|
27
|
+
attachmentsDir: string;
|
|
28
|
+
/** Meta directory for configuration/state */
|
|
29
|
+
metaDir: string;
|
|
30
|
+
/** Legacy outbox path (for backward compatibility) */
|
|
31
|
+
legacyOutboxDir: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AgentPaths extends RelayPaths {
|
|
34
|
+
/** Agent-specific outbox directory */
|
|
35
|
+
agentOutbox: string;
|
|
36
|
+
/** Agent-specific attachments directory */
|
|
37
|
+
agentAttachments: string;
|
|
38
|
+
/** Whether this is a workspace (cloud) deployment */
|
|
39
|
+
isWorkspace: boolean;
|
|
40
|
+
/** The agent name */
|
|
41
|
+
agentName: string;
|
|
42
|
+
}
|
|
43
|
+
export interface WriteOptions {
|
|
44
|
+
/** Create directories if they don't exist (default: true) */
|
|
45
|
+
mkdir?: boolean;
|
|
46
|
+
/** File mode (default: 0o644) */
|
|
47
|
+
mode?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface AttachmentResult {
|
|
50
|
+
/** Full path to the attachment */
|
|
51
|
+
path: string;
|
|
52
|
+
/** Relative path from attachments root */
|
|
53
|
+
relativePath: string;
|
|
54
|
+
/** Timestamp directory */
|
|
55
|
+
timestamp: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Utility class for writing relay messages and attachments.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const writer = new RelayFileWriter('MyAgent');
|
|
63
|
+
*
|
|
64
|
+
* // Write a message
|
|
65
|
+
* await writer.writeMessage('msg', `TO: Lead\n\nACK: Task received`);
|
|
66
|
+
*
|
|
67
|
+
* // Write an attachment
|
|
68
|
+
* const result = await writer.writeAttachment('screenshot.png', imageBuffer);
|
|
69
|
+
* console.log(`Attachment saved to: ${result.path}`);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class RelayFileWriter {
|
|
73
|
+
private readonly agentName;
|
|
74
|
+
private readonly paths;
|
|
75
|
+
private readonly workspaceId?;
|
|
76
|
+
constructor(agentName: string, workspaceId?: string);
|
|
77
|
+
/**
|
|
78
|
+
* Get the resolved paths for this agent.
|
|
79
|
+
*/
|
|
80
|
+
getPaths(): AgentPaths;
|
|
81
|
+
/**
|
|
82
|
+
* Get the outbox path that agents should write to.
|
|
83
|
+
* Always returns the canonical ~/.agent-relay path.
|
|
84
|
+
* In workspace mode, this path is symlinked to the actual workspace path.
|
|
85
|
+
*/
|
|
86
|
+
getOutboxPath(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Get the legacy outbox path (for backwards compatibility symlinks).
|
|
89
|
+
*/
|
|
90
|
+
getLegacyOutboxPath(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Ensure all necessary directories exist for this agent.
|
|
93
|
+
* In workspace mode, also sets up symlinks from canonical path to workspace path.
|
|
94
|
+
*/
|
|
95
|
+
ensureDirectories(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Set up symlinks for workspace mode.
|
|
98
|
+
* Creates symlink from legacy /tmp/relay-outbox path to workspace path.
|
|
99
|
+
* (The orchestrator creates the canonical→workspace symlink)
|
|
100
|
+
*/
|
|
101
|
+
private setupWorkspaceSymlinks;
|
|
102
|
+
/**
|
|
103
|
+
* Helper to create a symlink, cleaning up existing path first.
|
|
104
|
+
*/
|
|
105
|
+
private createSymlinkSafe;
|
|
106
|
+
/**
|
|
107
|
+
* Write a message to the agent's outbox.
|
|
108
|
+
*
|
|
109
|
+
* @param messageType - Type/name of the message (e.g., 'msg', 'ack', 'done')
|
|
110
|
+
* @param content - Message content (headers + body)
|
|
111
|
+
* @param options - Write options
|
|
112
|
+
* @returns Full path to the written file
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* await writer.writeMessage('ack', `TO: Lead\n\nACK: Task received`);
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
writeMessage(messageType: string, content: string, options?: WriteOptions): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Write an attachment to the agent's attachments directory.
|
|
122
|
+
* Attachments are organized by timestamp to prevent collisions.
|
|
123
|
+
*
|
|
124
|
+
* @param fileName - Name of the attachment file
|
|
125
|
+
* @param data - File content (string or Buffer)
|
|
126
|
+
* @param options - Write options
|
|
127
|
+
* @returns Attachment result with paths
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const result = await writer.writeAttachment('screenshot.png', imageBuffer);
|
|
132
|
+
* console.log(`Saved to: ${result.path}`);
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
writeAttachment(fileName: string, data: string | Buffer, options?: WriteOptions): Promise<AttachmentResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Read a message from the agent's outbox.
|
|
138
|
+
*
|
|
139
|
+
* @param messageType - Type/name of the message
|
|
140
|
+
* @returns Message content or null if not found
|
|
141
|
+
*/
|
|
142
|
+
readMessage(messageType: string): Promise<string | null>;
|
|
143
|
+
/**
|
|
144
|
+
* Delete a message from the agent's outbox.
|
|
145
|
+
*
|
|
146
|
+
* @param messageType - Type/name of the message
|
|
147
|
+
* @returns true if deleted, false if not found
|
|
148
|
+
*/
|
|
149
|
+
deleteMessage(messageType: string): Promise<boolean>;
|
|
150
|
+
/**
|
|
151
|
+
* List all messages in the agent's outbox.
|
|
152
|
+
*
|
|
153
|
+
* @returns Array of message type names
|
|
154
|
+
*/
|
|
155
|
+
listMessages(): Promise<string[]>;
|
|
156
|
+
/**
|
|
157
|
+
* Write metadata to the meta directory.
|
|
158
|
+
*
|
|
159
|
+
* @param key - Metadata key (file name)
|
|
160
|
+
* @param data - Metadata content (will be JSON stringified if object)
|
|
161
|
+
*/
|
|
162
|
+
writeMeta(key: string, data: string | Record<string, unknown>): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Read metadata from the meta directory.
|
|
165
|
+
*
|
|
166
|
+
* @param key - Metadata key (file name)
|
|
167
|
+
* @param parse - If true, parse as JSON (default: false)
|
|
168
|
+
*/
|
|
169
|
+
readMeta<T = string>(key: string, parse?: false): Promise<T | null>;
|
|
170
|
+
readMeta<T>(key: string, parse: true): Promise<T | null>;
|
|
171
|
+
/**
|
|
172
|
+
* Clean up the agent's outbox (remove all messages).
|
|
173
|
+
*/
|
|
174
|
+
cleanOutbox(): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get relay paths for an agent (without creating an instance).
|
|
178
|
+
*/
|
|
179
|
+
export declare function getRelayPaths(agentName: string, workspaceId?: string): AgentPaths;
|
|
180
|
+
/**
|
|
181
|
+
* Get the base relay paths (not agent-specific).
|
|
182
|
+
*/
|
|
183
|
+
export declare function getBaseRelayPaths(workspaceId?: string): RelayPaths;
|
|
184
|
+
/**
|
|
185
|
+
* Get the outbox path that should be used in agent instructions.
|
|
186
|
+
* This is the path agents will write to in their bash commands.
|
|
187
|
+
*
|
|
188
|
+
* Returns the $AGENT_RELAY_OUTBOX environment variable by default.
|
|
189
|
+
* This env var is automatically set by the orchestrator when spawning agents,
|
|
190
|
+
* and contains the correct project-local path.
|
|
191
|
+
*
|
|
192
|
+
* @param _agentNameVar - Deprecated, kept for API compatibility
|
|
193
|
+
* @returns Path template for agent instructions
|
|
194
|
+
*/
|
|
195
|
+
export declare function getAgentOutboxTemplate(_agentNameVar?: string): string;
|
|
196
|
+
/**
|
|
197
|
+
* Ensure the base relay directories exist.
|
|
198
|
+
*/
|
|
199
|
+
export declare function ensureBaseDirectories(workspaceId?: string): Promise<RelayPaths>;
|
|
200
|
+
//# sourceMappingURL=relay-file-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-file-writer.d.ts","sourceRoot":"","sources":["../src/relay-file-writer.ts"],"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